1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Imagination E5010 JPEG Encoder driver.
5 * Copyright (C) 2023 Texas Instruments Incorporated - https://www.ti.com/
7 * Author: David Huang <d-huang@ti.com>
8 * Author: Devarsh Thakkar <devarsht@ti.com>
11 #include <media/v4l2-ctrls.h>
12 #include <media/v4l2-device.h>
13 #include <media/v4l2-fh.h>
15 #ifndef _E5010_JPEG_ENC_H
16 #define _E5010_JPEG_ENC_H
19 #define HEADER_SIZE 0x025D
20 #define MIN_DIMENSION 64
21 #define MAX_DIMENSION 8192
22 #define DEFAULT_WIDTH 640
23 #define DEFAULT_HEIGHT 480
24 #define E5010_MODULE_NAME "e5010"
25 #define JPEG_MAX_BYTES_PER_PIXEL 2
27 /* JPEG marker definitions */
28 #define START_OF_IMAGE 0xFFD8
29 #define SOF_BASELINE_DCT 0xFFC0
30 #define END_OF_IMAGE 0xFFD9
31 #define START_OF_SCAN 0xFFDA
33 /* Definitions for the huffman table specification in the Marker segment */
34 #define DHT_MARKER 0xFFC4
38 /* Definitions for the quantization table specification in the Marker segment */
39 #define DQT_MARKER 0xFFDB
43 /* Length and precision of the quantization table parameters */
47 /* Misc JPEG header definitions */
50 #define HORZ_SAMPLING_FACTOR (2 << 4)
51 #define VERT_SAMPLING_FACTOR_422 1
52 #define VERT_SAMPLING_FACTOR_420 2
53 #define COMPONENTS_IN_SCAN 3
54 #define PELS_IN_BLOCK 64
56 /* Used for Qp table generation */
60 #define QP_TABLE_SIZE (8 * 8)
61 #define QP_TABLE_FIELD_OFFSET 0x04
65 * contains queue data information
69 * @height: frame height
70 * @bytesperline: bytes per line in memory
71 * @size_image: image size in memory
74 struct e5010_fmt
*fmt
;
79 u32 sizeimage
[MAX_PLANES
];
80 u32 bytesperline
[MAX_PLANES
];
82 struct v4l2_rect crop
;
87 * Driver device structure
88 * Holds all memory handles and global parameters
89 * Shared by all instances
93 struct v4l2_device v4l2_dev
;
94 struct v4l2_m2m_dev
*m2m_dev
;
95 struct video_device
*vdev
;
96 void __iomem
*core_base
;
97 void __iomem
*mmu_base
;
99 struct e5010_context
*last_context_run
;
100 /* Protect access to device data */
102 /* Protect access to hardware*/
107 * Driver context structure
108 * One of these exists for every m2m context
109 * Holds context specific data
111 struct e5010_context
{
113 struct e5010_dev
*e5010
;
114 struct e5010_q_data out_queue
;
115 struct e5010_q_data cap_queue
;
118 struct v4l2_ctrl_handler ctrl_handler
;
119 u8 luma_qp
[QP_TABLE_SIZE
];
120 u8 chroma_qp
[QP_TABLE_SIZE
];
125 * Contains info for all buffers
127 struct e5010_buffer
{
128 struct v4l2_m2m_buffer buffer
;
132 CHROMA_ORDER_CB_CR
= 0, //UV ordering
133 CHROMA_ORDER_CR_CB
= 1, //VU ordering
142 * e5010 format structure
143 * contains format information
147 unsigned int num_planes
;
151 const struct v4l2_frmsize_stepwise frmsize
;
155 * struct e5010_ctrl - contains info for each supported v4l2 control
159 enum v4l2_ctrl_type type
;
160 unsigned char name
[32];
165 unsigned char compound
;