1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef JPEG_CORE_H_
14#define JPEG_CORE_H_
15
16#include <linux/interrupt.h>
17#include <media/v4l2-device.h>
18#include <media/v4l2-fh.h>
19#include <media/v4l2-ctrls.h>
20
21#define S5P_JPEG_M2M_NAME "s5p-jpeg"
22
23
24#define S5P_JPEG_COMPR_QUAL_BEST 0
25#define S5P_JPEG_COMPR_QUAL_WORST 3
26
27
28#define S5P_JPEG_COEF11 0x4d
29#define S5P_JPEG_COEF12 0x97
30#define S5P_JPEG_COEF13 0x1e
31#define S5P_JPEG_COEF21 0x2c
32#define S5P_JPEG_COEF22 0x57
33#define S5P_JPEG_COEF23 0x83
34#define S5P_JPEG_COEF31 0x83
35#define S5P_JPEG_COEF32 0x6e
36#define S5P_JPEG_COEF33 0x13
37
38#define EXYNOS3250_IRQ_TIMEOUT 0x10000000
39
40
41#define TEM 0x01
42#define SOF0 0xc0
43#define RST 0xd0
44#define SOI 0xd8
45#define EOI 0xd9
46#define DHP 0xde
47
48
49#define SJPEG_FMT_FLAG_ENC_CAPTURE (1 << 0)
50#define SJPEG_FMT_FLAG_ENC_OUTPUT (1 << 1)
51#define SJPEG_FMT_FLAG_DEC_CAPTURE (1 << 2)
52#define SJPEG_FMT_FLAG_DEC_OUTPUT (1 << 3)
53#define SJPEG_FMT_FLAG_S5P (1 << 4)
54#define SJPEG_FMT_FLAG_EXYNOS3250 (1 << 5)
55#define SJPEG_FMT_FLAG_EXYNOS4 (1 << 6)
56#define SJPEG_FMT_RGB (1 << 7)
57#define SJPEG_FMT_NON_RGB (1 << 8)
58
59#define S5P_JPEG_ENCODE 0
60#define S5P_JPEG_DECODE 1
61
62#define FMT_TYPE_OUTPUT 0
63#define FMT_TYPE_CAPTURE 1
64
65#define SJPEG_SUBSAMPLING_444 0x11
66#define SJPEG_SUBSAMPLING_422 0x21
67#define SJPEG_SUBSAMPLING_420 0x22
68
69
70
71#define SJPEG_S5P 1
72#define SJPEG_EXYNOS3250 2
73#define SJPEG_EXYNOS4 3
74
75enum exynos4_jpeg_result {
76 OK_ENC_OR_DEC,
77 ERR_PROT,
78 ERR_DEC_INVALID_FORMAT,
79 ERR_MULTI_SCAN,
80 ERR_FRAME,
81 ERR_UNKNOWN,
82};
83
84enum exynos4_jpeg_img_quality_level {
85 QUALITY_LEVEL_1 = 0,
86 QUALITY_LEVEL_2,
87 QUALITY_LEVEL_3,
88 QUALITY_LEVEL_4,
89};
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110struct s5p_jpeg {
111 struct mutex lock;
112 spinlock_t slock;
113
114 struct v4l2_device v4l2_dev;
115 struct video_device *vfd_encoder;
116 struct video_device *vfd_decoder;
117 struct v4l2_m2m_dev *m2m_dev;
118
119 void __iomem *regs;
120 unsigned int irq;
121 enum exynos4_jpeg_result irq_ret;
122 struct clk *clk;
123 struct clk *sclk;
124 struct device *dev;
125 void *alloc_ctx;
126 struct s5p_jpeg_variant *variant;
127 u32 irq_status;
128};
129
130struct s5p_jpeg_variant {
131 unsigned int version;
132 unsigned int fmt_ver_flag;
133 struct v4l2_m2m_ops *m2m_ops;
134 irqreturn_t (*jpeg_irq)(int irq, void *priv);
135};
136
137
138
139
140
141
142
143
144
145
146
147struct s5p_jpeg_fmt {
148 char *name;
149 u32 fourcc;
150 int depth;
151 int colplanes;
152 int memplanes;
153 int h_align;
154 int v_align;
155 int subsampling;
156 u32 flags;
157};
158
159
160
161
162
163
164
165
166struct s5p_jpeg_q_data {
167 struct s5p_jpeg_fmt *fmt;
168 u32 w;
169 u32 h;
170 u32 size;
171};
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189struct s5p_jpeg_ctx {
190 struct s5p_jpeg *jpeg;
191 unsigned int mode;
192 unsigned short compr_quality;
193 unsigned short restart_interval;
194 unsigned short subsampling;
195 struct s5p_jpeg_q_data out_q;
196 struct s5p_jpeg_q_data cap_q;
197 unsigned int scale_factor;
198 struct v4l2_rect crop_rect;
199 struct v4l2_fh fh;
200 bool hdr_parsed;
201 bool crop_altered;
202 struct v4l2_ctrl_handler ctrl_handler;
203};
204
205
206
207
208
209
210
211struct s5p_jpeg_buffer {
212 unsigned long size;
213 unsigned long curr;
214 unsigned long data;
215};
216
217
218
219
220
221
222
223struct s5p_jpeg_addr {
224 u32 y;
225 u32 cb;
226 u32 cr;
227};
228
229#endif
230