Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] s5p-jpeg: Adapt to new controls

Adapt to new controls (subsampling).

For encoding, the destination format now needs to be set to V4L2_PIX_FMT_JPEG
and the subsampling (4:2:2 or 4:2:0) needs to be set using the respective
control (V4L2_CID_JPEG_CHROMA_SUBSAMPLING). Required buffer size for
destination image during encoding is no longer deduced from the format (which
generally implied overestimation), but needs to be given from userspace in
sizeimage.

Not strictly related to the added controls, this patch also fixes setting the
subsampling of the destination image for decoding, depending on the destination
format.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by

Andrzej Pietrasiewicz and committed by
Mauro Carvalho Chehab
fb6f8c02 27dda973

+10 -7
+10 -7
drivers/media/video/s5p-jpeg/jpeg-core.c
··· 32 32 33 33 static struct s5p_jpeg_fmt formats_enc[] = { 34 34 { 35 - .name = "YUV 4:2:0 planar, YCbCr", 36 - .fourcc = V4L2_PIX_FMT_YUV420, 37 - .depth = 12, 38 - .colplanes = 3, 35 + .name = "JPEG JFIF", 36 + .fourcc = V4L2_PIX_FMT_JPEG, 37 + .colplanes = 1, 39 38 .types = MEM2MEM_CAPTURE, 40 39 }, 41 40 { ··· 42 43 .fourcc = V4L2_PIX_FMT_YUYV, 43 44 .depth = 16, 44 45 .colplanes = 1, 45 - .types = MEM2MEM_CAPTURE | MEM2MEM_OUTPUT, 46 + .types = MEM2MEM_OUTPUT, 46 47 }, 47 48 { 48 49 .name = "RGB565", ··· 1024 1025 jpeg_htbl_dc(jpeg->regs, 2); 1025 1026 jpeg_htbl_ac(jpeg->regs, 3); 1026 1027 jpeg_htbl_dc(jpeg->regs, 3); 1027 - } else { 1028 + } else { /* S5P_JPEG_DECODE */ 1028 1029 jpeg_rst_int_enable(jpeg->regs, true); 1029 1030 jpeg_data_num_int_enable(jpeg->regs, true); 1030 1031 jpeg_final_mcu_num_int_enable(jpeg->regs, true); 1031 - jpeg_outform_raw(jpeg->regs, S5P_JPEG_RAW_OUT_422); 1032 + if (ctx->cap_q.fmt->fourcc == V4L2_PIX_FMT_YUYV) 1033 + jpeg_outform_raw(jpeg->regs, S5P_JPEG_RAW_OUT_422); 1034 + else 1035 + jpeg_outform_raw(jpeg->regs, S5P_JPEG_RAW_OUT_420); 1032 1036 jpeg_jpgadr(jpeg->regs, src_addr); 1033 1037 jpeg_imgadr(jpeg->regs, dst_addr); 1034 1038 } ··· 1271 1269 1272 1270 curr_ctx->subsampling = jpeg_get_subsampling_mode(jpeg->regs); 1273 1271 spin_unlock(&jpeg->slock); 1272 + 1274 1273 jpeg_clear_int(jpeg->regs); 1275 1274 1276 1275 return IRQ_HANDLED;