#include <asm/unaligned.h>
#include <linux/irqreturn.h>
#include <linux/kernel.h>
#include <linux/ktime.h>
#include <linux/slab.h>
#include <linux/swab.h>
#include <linux/videodev2.h>
#include <media/v4l2-common.h>
#include <media/v4l2-fh.h>
#include <media/v4l2-jpeg.h>
#include <media/v4l2-mem2mem.h>
#include <media/videobuf2-core.h>
#include <media/videobuf2-dma-contig.h>
#include "coda.h"
#include "trace.h"
#define SOI_MARKER …
#define APP9_MARKER …
#define DRI_MARKER …
#define DQT_MARKER …
#define DHT_MARKER …
#define SOF_MARKER …
#define SOS_MARKER …
#define EOI_MARKER …
enum { … };
struct coda_huff_tab { … };
#define CODA9_JPEG_ENC_HUFF_DATA_SIZE …
static const unsigned char luma_dc[16 + 12] = …;
static const unsigned char chroma_dc[16 + 12] = …;
static const unsigned char luma_ac[16 + 162 + 2] = …;
static const unsigned char chroma_ac[16 + 162 + 2] = …;
static unsigned char luma_q[64] = …;
static unsigned char chroma_q[64] = …;
static const unsigned char width_align[] = …;
static const unsigned char height_align[] = …;
static int coda9_jpeg_chroma_format(u32 pixfmt)
{ … }
struct coda_memcpy_desc { … };
static void coda_memcpy_parabuf(void *parabuf,
const struct coda_memcpy_desc *desc)
{ … }
int coda_jpeg_write_tables(struct coda_ctx *ctx)
{ … }
bool coda_jpeg_check_buffer(struct coda_ctx *ctx, struct vb2_buffer *vb)
{ … }
static int coda9_jpeg_gen_dec_huff_tab(struct coda_ctx *ctx, int tab_num);
int coda_jpeg_decode_header(struct coda_ctx *ctx, struct vb2_buffer *vb)
{ … }
static inline void coda9_jpeg_write_huff_values(struct coda_dev *dev, u8 *bits,
int num_values)
{ … }
static void coda9_jpeg_dec_huff_setup(struct coda_ctx *ctx)
{ … }
static inline void coda9_jpeg_write_qmat_tab(struct coda_dev *dev,
u8 *qmat, int index)
{ … }
static void coda9_jpeg_qmat_setup(struct coda_ctx *ctx)
{ … }
static void coda9_jpeg_dec_bbc_gbu_setup(struct coda_ctx *ctx,
struct vb2_buffer *buf, u32 ecs_offset)
{ … }
static const int bus_req_num[] = …;
#define MCU_INFO(mcu_block_num, comp_num, comp0_info, comp1_info, comp2_info) …
static const u32 mcu_info[] = …;
static int coda9_jpeg_gen_enc_huff_tab(struct coda_ctx *ctx, int tab_num,
int *ehufsi, int *ehufco)
{ … }
#define DC_TABLE_INDEX0 …
#define AC_TABLE_INDEX0 …
#define DC_TABLE_INDEX1 …
#define AC_TABLE_INDEX1 …
static u8 *coda9_jpeg_get_huff_bits(struct coda_ctx *ctx, int tab_num)
{ … }
static int coda9_jpeg_gen_dec_huff_tab(struct coda_ctx *ctx, int tab_num)
{ … }
static int coda9_jpeg_load_huff_tab(struct coda_ctx *ctx)
{ … }
static void coda9_jpeg_write_huff_tab(struct coda_ctx *ctx)
{ … }
static inline void coda9_jpeg_write_qmat_quotients(struct coda_dev *dev,
u8 *qmat, int index)
{ … }
static void coda9_jpeg_load_qmat_tab(struct coda_ctx *ctx)
{ … }
struct coda_jpeg_stream { … };
static inline int coda_jpeg_put_byte(u8 byte, struct coda_jpeg_stream *stream)
{ … }
static inline int coda_jpeg_put_word(u16 word, struct coda_jpeg_stream *stream)
{ … }
static int coda_jpeg_put_table(u16 marker, u8 index, const u8 *table,
size_t len, struct coda_jpeg_stream *stream)
{ … }
static int coda_jpeg_define_quantization_table(struct coda_ctx *ctx, u8 index,
struct coda_jpeg_stream *stream)
{ … }
static int coda_jpeg_define_huffman_table(u8 index, const u8 *table, size_t len,
struct coda_jpeg_stream *stream)
{ … }
static int coda9_jpeg_encode_header(struct coda_ctx *ctx, int len, u8 *buf)
{ … }
static void coda_scale_quant_table(u8 *q_tab, int scale)
{ … }
void coda_set_jpeg_compression_quality(struct coda_ctx *ctx, int quality)
{ … }
static int coda9_jpeg_start_encoding(struct coda_ctx *ctx)
{ … }
static int coda9_jpeg_prepare_encode(struct coda_ctx *ctx)
{ … }
static void coda9_jpeg_finish_encode(struct coda_ctx *ctx)
{ … }
static void coda9_jpeg_encode_timeout(struct coda_ctx *ctx)
{ … }
static void coda9_jpeg_release(struct coda_ctx *ctx)
{ … }
const struct coda_context_ops coda9_jpeg_encode_ops = …;
static int coda9_jpeg_start_decoding(struct coda_ctx *ctx)
{ … }
static int coda9_jpeg_prepare_decode(struct coda_ctx *ctx)
{ … }
static void coda9_jpeg_finish_decode(struct coda_ctx *ctx)
{ … }
const struct coda_context_ops coda9_jpeg_decode_ops = …;
irqreturn_t coda9_jpeg_irq_handler(int irq, void *data)
{ … }