Add support for Exynox4x12 to the s5p-jpeg driver
Subsystems (2)
v2 cover Add support for Exynox4x12 to the s5p-jpeg driver
This is the second version of the series that adds support for the Exynos4x12 device to the s5p_jpeg driver along with accompanying fixes. It contains following improvements
(Hans, Sylwester thanks for the review):
- moved adjusting chroma subsampling control value from s_ctrl to try_ctrl callback and switched from using v4l2_s_ctrl to v4l2_ctrl_s_ctrl
- avoided big switch statement in favour of lookup tables for adjusting capture queue fourcc during decoding phase
- avoided unnecessary displacement of clk_get call in the probe function
- renamed decoded_subsampling_to_v4l2 to s5p_jpeg_to_user_subsampling
- added freeing ctrl_handler when v4l2_ctrl_handler_setup fails
- calling s5p_jpeg_runtime_suspend and s5p_jpeg_runtime_resume only when pm_runtime_suspended returns false
Thanks,
Jacek Anaszewski
Jacek Anaszewski (16):
s5p-jpeg: Reorder quantization tables
s5p-jpeg: Fix output YUV 4:2:0 fourcc for decoder
s5p-jpeg: Fix erroneous condition while validating bytesperline value
s5p-jpeg: Remove superfluous call to the jpeg_bound_align_image
function
s5p-jpeg: Rename functions specific to the S5PC210 SoC accordingly
s5p-jpeg: Fix clock resource management
s5p-jpeg: Fix lack of spin_lock protection
s5p-jpeg: Synchronize cached controls with V4L2 core
s5p-jpeg: Split jpeg-hw.h to jpeg-hw-s5p.c and jpeg-hw-s5p.c
s5p-jpeg: Add hardware API for the exynos4x12 JPEG codec.
s5p-jpeg: Retrieve "YCbCr subsampling" field from the jpeg header
s5p-jpeg: Ensure correct capture format for Exynos4x12
s5p-jpeg: Allow for wider JPEG subsampling scope for Exynos4x12
encoder
s5p-jpeg: Synchronize V4L2_CID_JPEG_CHROMA_SUBSAMPLING control value
s5p-jpeg: Ensure setting correct value of the chroma subsampling
control
s5p-jpeg: Adjust g_volatile_ctrl callback to Exynos4x12 needs
drivers/media/platform/s5p-jpeg/Makefile | 2 +-
drivers/media/platform/s5p-jpeg/jpeg-core.c | 1089 ++++++++++++++++----
drivers/media/platform/s5p-jpeg/jpeg-core.h | 75 +-
drivers/media/platform/s5p-jpeg/jpeg-hw-exynos.c | 293 ++++++
drivers/media/platform/s5p-jpeg/jpeg-hw-exynos.h | 44 +
.../platform/s5p-jpeg/{jpeg-hw.h => jpeg-hw-s5p.c} | 82 +-
drivers/media/platform/s5p-jpeg/jpeg-hw-s5p.h | 63 ++
drivers/media/platform/s5p-jpeg/jpeg-regs.h | 215 +++-
8 files changed, 1614 insertions(+), 249 deletions(-)
create mode 100644 drivers/media/platform/s5p-jpeg/jpeg-hw-exynos.c
create mode 100644 drivers/media/platform/s5p-jpeg/jpeg-hw-exynos.h
rename drivers/media/platform/s5p-jpeg/{jpeg-hw.h => jpeg-hw-s5p.c} (71%)
create mode 100644 drivers/media/platform/s5p-jpeg/jpeg-hw-s5p.hSignature · 1 line
1.7.9.5
PATCH v2 1/16 s5p-jpeg: Reorder quantization tables
Reorder quantization tables so that their elements are arranged in the manner reflecting compression quality level that is in accordance with V4L2 documentation, i.e. the larger value of the V4L2_CID_JPEG_COMPRESSION_QUALITY control the better image quality, and thus lower compression quality. The modification allows also to get rid of reverse logic in the s_ctrl callback while assigning user space value to the ctx->compr_quality variable.
--- drivers/media/platform/s5p-jpeg/jpeg-core.c | 116 +++++++++++++-------------- 1 file changed, 58 insertions(+), 58 deletions(-)
drivers/media/platform/s5p-jpeg/jpeg-core.c +58 -58
@@ -84,15 +84,25 @@ static struct s5p_jpeg_fmt formats_dec[] = {#define NUM_FORMATS_DEC ARRAY_SIZE(formats_dec)static const unsigned char qtbl_luminance[4 ][64 ] = { - {/* level 1 - high quality */ -8 ,6 ,6 ,8 ,12 ,14 ,16 ,17 , -6 ,6 ,6 ,8 ,10 ,13 ,12 ,15 , -6 ,6 ,7 ,8 ,13 ,14 ,18 ,24 , -8 ,8 ,8 ,14 ,13 ,19 ,24 ,35 , -12 ,10 ,13 ,13 ,20 ,26 ,34 ,39 , -14 ,13 ,14 ,19 ,26 ,34 ,39 ,39 , -16 ,12 ,18 ,24 ,34 ,39 ,39 ,39 , -17 ,15 ,24 ,35 ,39 ,39 ,39 ,39 + {/*level 0 - high compression quality */ +20 ,16 ,25 ,39 ,50 ,46 ,62 ,68 , +16 ,18 ,23 ,38 ,38 ,53 ,65 ,68 , +25 ,23 ,31 ,38 ,53 ,65 ,68 ,68 , +39 ,38 ,38 ,53 ,65 ,68 ,68 ,68 , +50 ,38 ,53 ,65 ,68 ,68 ,68 ,68 , +46 ,53 ,65 ,68 ,68 ,68 ,68 ,68 , +62 ,65 ,68 ,68 ,68 ,68 ,68 ,68 , +68 ,68 ,68 ,68 ,68 ,68 ,68 ,68 + }, + {/* level 1 */ +16 ,11 ,11 ,16 ,23 ,27 ,31 ,30 , +11 ,12 ,12 ,15 ,20 ,23 ,23 ,30 , +11 ,12 ,13 ,16 ,23 ,26 ,35 ,47 , +16 ,15 ,16 ,23 ,26 ,37 ,47 ,64 , +23 ,20 ,23 ,26 ,39 ,51 ,64 ,64 , +27 ,23 ,26 ,37 ,51 ,64 ,64 ,64 , +31 ,23 ,35 ,47 ,64 ,64 ,64 ,64 , +30 ,30 ,47 ,64 ,64 ,64 ,64 ,64 }, {/* level 2 */ 12 ,8 ,8 ,12 ,17 ,21 ,24 ,23 ,
@@ -104,38 +114,38 @@ static const unsigned char qtbl_luminance[4][64] = { 24, 18, 27, 36, 51, 59, 59, 59, 23, 23, 36, 53, 59, 59, 59, 59 }, - {/* level 3 */ - 16, 11, 11, 16, 23, 27, 31, 30, - 11, 12, 12, 15, 20, 23, 23, 30, - 11, 12, 13, 16, 23, 26, 35, 47, - 16, 15, 16, 23, 26, 37, 47, 64, - 23, 20, 23, 26, 39, 51, 64, 64, - 27, 23, 26, 37, 51, 64, 64, 64, - 31, 23, 35, 47, 64, 64, 64, 64, - 30, 30, 47, 64, 64, 64, 64, 64 - }, - {/*level 4 - low quality */ - 20, 16, 25, 39, 50, 46, 62, 68, - 16, 18, 23, 38, 38, 53, 65, 68, - 25, 23, 31, 38, 53, 65, 68, 68, - 39, 38, 38, 53, 65, 68, 68, 68, - 50, 38, 53, 65, 68, 68, 68, 68, - 46, 53, 65, 68, 68, 68, 68, 68, - 62, 65, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68 + {/* level 3 - low compression quality */ + 8, 6, 6, 8, 12, 14, 16, 17, + 6, 6, 6, 8, 10, 13, 12, 15, + 6, 6, 7, 8, 13, 14, 18, 24, + 8, 8, 8, 14, 13, 19, 24, 35, + 12, 10, 13, 13, 20, 26, 34, 39, + 14, 13, 14, 19, 26, 34, 39, 39, + 16, 12, 18, 24, 34, 39, 39, 39, + 17, 15, 24, 35, 39, 39, 39, 39 } }; static const unsigned char qtbl_chrominance[4][64] = { - {/* level 1 - high quality */ - 9, 8, 9, 11, 14, 17, 19, 24, - 8, 10, 9, 11, 14, 13, 17, 22, - 9, 9, 13, 14, 13, 15, 23, 26, - 11, 11, 14, 14, 15, 20, 26, 33, - 14, 14, 13, 15, 20, 24, 33, 39, - 17, 13, 15, 20, 24, 32, 39, 39, - 19, 17, 23, 26, 33, 39, 39, 39, - 24, 22, 26, 33, 39, 39, 39, 39 + {/*level 0 - high compression quality */ + 21, 25, 32, 38, 54, 68, 68, 68, + 25, 28, 24, 38, 54, 68, 68, 68, + 32, 24, 32, 43, 66, 68, 68, 68, + 38, 38, 43, 53, 68, 68, 68, 68, + 54, 54, 66, 68, 68, 68, 68, 68, + 68, 68, 68, 68, 68, 68, 68, 68, + 68, 68, 68, 68, 68, 68, 68, 68, + 68, 68, 68, 68, 68, 68, 68, 68 + }, + {/* level 1 */ + 17, 15, 17, 21, 20, 26, 38, 48, + 15, 19, 18, 17, 20, 26, 35, 43, + 17, 18, 20, 22, 26, 30, 46, 53, + 21, 17, 22, 28, 30, 39, 53, 64, + 20, 20, 26, 30, 39, 48, 64, 64, + 26, 26, 30, 39, 48, 63, 64, 64, + 38, 35, 46, 53, 64, 64, 64, 64, + 48, 43, 53, 64, 64, 64, 64, 64 }, {/* level 2 */ 13, 11, 13, 16, 20, 20, 29, 37,
@@ -147,25 +157,15 @@ static const unsigned char qtbl_chrominance[4][64] = { 29, 26, 35, 40, 50, 59, 59, 59, 37, 32, 40, 50, 59, 59, 59, 59 }, - {/* level 3 */ -17 ,15 ,17 ,21 ,20 ,26 ,38 ,48 , -15 ,19 ,18 ,17 ,20 ,26 ,35 ,43 , -17 ,18 ,20 ,22 ,26 ,30 ,46 ,53 , -21 ,17 ,22 ,28 ,30 ,39 ,53 ,64 , -20 ,20 ,26 ,30 ,39 ,48 ,64 ,64 , -26 ,26 ,30 ,39 ,48 ,63 ,64 ,64 , -38 ,35 ,46 ,53 ,64 ,64 ,64 ,64 , -48 ,43 ,53 ,64 ,64 ,64 ,64 ,64 - }, - {/*level 4 - low quality */ -21 ,25 ,32 ,38 ,54 ,68 ,68 ,68 , -25 ,28 ,24 ,38 ,54 ,68 ,68 ,68 , -32 ,24 ,32 ,43 ,66 ,68 ,68 ,68 , -38 ,38 ,43 ,53 ,68 ,68 ,68 ,68 , -54 ,54 ,66 ,68 ,68 ,68 ,68 ,68 , -68 ,68 ,68 ,68 ,68 ,68 ,68 ,68 , -68 ,68 ,68 ,68 ,68 ,68 ,68 ,68 , -68 ,68 ,68 ,68 ,68 ,68 ,68 ,68 + {/* level 3 - low compression quality */ +9 ,8 ,9 ,11 ,14 ,17 ,19 ,24 , +8 ,10 ,9 ,11 ,14 ,13 ,17 ,22 , +9 ,9 ,13 ,14 ,13 ,15 ,23 ,26 , +11 ,11 ,14 ,14 ,15 ,20 ,26 ,33 , +14 ,14 ,13 ,15 ,20 ,24 ,33 ,39 , +17 ,13 ,15 ,20 ,24 ,32 ,39 ,39 , +19 ,17 ,23 ,26 ,33 ,39 ,39 ,39 , +24 ,22 ,26 ,33 ,39 ,39 ,39 ,39 } };
@@ -834,7 +834,7 @@ static int s5p_jpeg_s_ctrl(struct v4l2_ctrl *ctrl)switch (ctrl->id) {case V4L2_CID_JPEG_COMPRESSION_QUALITY : - ctx->compr_quality =S5P_JPEG_COMPR_QUAL_WORST - ctrl->val; + ctx->compr_quality = ctrl->val;break ;case V4L2_CID_JPEG_RESTART_INTERVAL : ctx->restart_interval = ctrl->val;
@@ -863,7 +863,7 @@ static int s5p_jpeg_controls_create(struct s5p_jpeg_ctx *ctx)if (ctx->mode ==S5P_JPEG_ENCODE ) {v4l2_ctrl_new_std (&ctx->ctrl_handler, &s5p_jpeg_ctrl_ops,V4L2_CID_JPEG_COMPRESSION_QUALITY , -0 ,3 ,1 ,3 ); +0 ,3 ,1 ,S5P_JPEG_COMPR_QUAL_WORST ); v4l2_ctrl_new_std(&ctx->ctrl_handler, &s5p_jpeg_ctrl_ops, V4L2_CID_JPEG_RESTART_INTERVAL,
Signature · 1 line
1.7.9.5
PATCH v2 2/16 s5p-jpeg: Fix output YUV 4:2:0 fourcc for decoder
In reply to Jacek AnaszewskiOutput samples during decoding phase for the YUV 4:2:0 format are arranged in the manner compatible with 2-planar NV12, not 3-planar YUV420 fourcc.
--- drivers/media/platform/s5p-jpeg/jpeg-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/s5p-jpeg/jpeg-core.c +1 -1
@@ -58,7 +58,7 @@ static struct s5p_jpeg_fmt formats_enc[] = {static struct s5p_jpeg_fmt formats_dec[] = { { .name ="YUV 4:2:0 planar, YCbCr" , - .fourcc =V4L2_PIX_FMT_YUV420 , + .fourcc =V4L2_PIX_FMT_NV12 , .depth =12 , .colplanes =3 , .h_align =4 ,
Signature · 1 line
1.7.9.5
PATCH v2 3/16 s5p-jpeg: Fix erroneous condition while validating bytesperline value
In reply to Jacek AnaszewskiThe aim of the condition is ensuring that the bytesperline value set by the user space application is proper for the given format and adjusting it if isn't. As the depth value of the format description entry is expressed in bits then the bytesperline value needs to be divided, not multiplied, by that value to get the number of bytes required to store single line of image samples.
--- drivers/media/platform/s5p-jpeg/jpeg-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/s5p-jpeg/jpeg-core.c +1 -1
@@ -670,7 +670,7 @@ static int vidioc_try_fmt(struct v4l2_format *f, struct s5p_jpeg_fmt *fmt, bpl = pix->width;/* planar */ if (fmt->colplanes ==1 &&/* packed */ - (bpl <<3 ) * fmt->depth < pix->width) + (bpl <<3 ) / fmt->depth < pix->width) bpl = (pix->width * fmt->depth) >>3 ; pix->bytesperline = bpl;
Signature · 1 line
1.7.9.5
PATCH v2 4/16 s5p-jpeg: Remove superfluous call to the jpeg_bound_align_image function
In reply to Jacek AnaszewskiAligning capture queue image dimensions while enqueuing output queue doesn't make a sense as the S_FMT ioctl might have not been called for the capture queue until that moment, whereas it is required to know capture format as the type of alignment heavily depends on it.
--- drivers/media/platform/s5p-jpeg/jpeg-core.c | 7 ------- 1 file changed, 7 deletions(-)
drivers/media/platform/s5p-jpeg/jpeg-core.c +0 -7
@@ -1089,13 +1089,6 @@ static void s5p_jpeg_buf_queue(struct vb2_buffer *vb) q_data = &ctx->cap_q; q_data->w = tmp.w; q_data->h = tmp.h; - -jpeg_bound_align_image (&q_data->w,S5P_JPEG_MIN_WIDTH , -S5P_JPEG_MAX_WIDTH , q_data->fmt->h_align, - &q_data->h,S5P_JPEG_MIN_HEIGHT , -S5P_JPEG_MAX_HEIGHT , q_data->fmt->v_align - ); - q_data->size = q_data->w * q_data->h * q_data->fmt->depth >>3 ; }v4l2_m2m_buf_queue (ctx->fh.m2m_ctx, vb);
Signature · 1 line
1.7.9.5
PATCH v2 5/16 s5p-jpeg: Rename functions specific to the S5PC210 SoC accordingly
In reply to Jacek Anaszewski--- drivers/media/platform/s5p-jpeg/jpeg-core.c | 58 ++++++++++++++++----------- 1 file changed, 34 insertions(+), 24 deletions(-)
drivers/media/platform/s5p-jpeg/jpeg-core.c +34 -24
@@ -213,8 +213,9 @@ static inline struct s5p_jpeg_ctx *fh_to_ctx(struct v4l2_fh *fh) return container_of(fh, struct s5p_jpeg_ctx, fh); } -static inline void jpeg_set_qtbl (void __iomem *regs,const unsigned char *qtbl, -unsigned long tab,int len) +static inline void s5p_jpeg_set_qtbl (void __iomem *regs, +const unsigned char *qtbl, +unsigned long tab,int len) {int i;
@@ -222,22 +223,25 @@ static inline void jpeg_set_qtbl(void __iomem *regs, const unsigned char *qtbl,writel ((unsigned int )qtbl[i], regs + tab + (i *0x04 )); } -static inline void jpeg_set_qtbl_lum (void __iomem *regs,int quality) +static inline void s5p_jpeg_set_qtbl_lum (void __iomem *regs,int quality) {/* this driver fills quantisation table 0 with data for luma */ -jpeg_set_qtbl (regs, qtbl_luminance[quality],S5P_JPG_QTBL_CONTENT (0 ), -ARRAY_SIZE (qtbl_luminance[quality])); +s5p_jpeg_set_qtbl (regs, qtbl_luminance[quality], +S5P_JPG_QTBL_CONTENT (0 ), +ARRAY_SIZE (qtbl_luminance[quality])); } -static inline void jpeg_set_qtbl_chr (void __iomem *regs,int quality) +static inline void s5p_jpeg_set_qtbl_chr (void __iomem *regs,int quality) {/* this driver fills quantisation table 1 with data for chroma */ -jpeg_set_qtbl (regs, qtbl_chrominance[quality],S5P_JPG_QTBL_CONTENT (1 ), -ARRAY_SIZE (qtbl_chrominance[quality])); +s5p_jpeg_set_qtbl (regs, qtbl_chrominance[quality], +S5P_JPG_QTBL_CONTENT (1 ), +ARRAY_SIZE (qtbl_chrominance[quality])); } -static inline void jpeg_set_htbl (void __iomem *regs,const unsigned char *htbl, -unsigned long tab,int len) +static inline void s5p_jpeg_set_htbl (void __iomem *regs, +const unsigned char *htbl, +unsigned long tab,int len) {int i;
@@ -245,28 +249,32 @@ static inline void jpeg_set_htbl(void __iomem *regs, const unsigned char *htbl,writel ((unsigned int )htbl[i], regs + tab + (i *0x04 )); } -static inline void jpeg_set_hdctbl (void __iomem *regs) +static inline void s5p_jpeg_set_hdctbl (void __iomem *regs) {/* this driver fills table 0 for this component */ -jpeg_set_htbl (regs, hdctbl0,S5P_JPG_HDCTBL (0 ),ARRAY_SIZE (hdctbl0)); +s5p_jpeg_set_htbl (regs, hdctbl0,S5P_JPG_HDCTBL (0 ), +ARRAY_SIZE (hdctbl0)); } -static inline void jpeg_set_hdctblg (void __iomem *regs) +static inline void s5p_jpeg_set_hdctblg (void __iomem *regs) {/* this driver fills table 0 for this component */ -jpeg_set_htbl (regs, hdctblg0,S5P_JPG_HDCTBLG (0 ),ARRAY_SIZE (hdctblg0)); +s5p_jpeg_set_htbl (regs, hdctblg0,S5P_JPG_HDCTBLG (0 ), +ARRAY_SIZE (hdctblg0)); } -static inline void jpeg_set_hactbl (void __iomem *regs) +static inline void s5p_jpeg_set_hactbl (void __iomem *regs) {/* this driver fills table 0 for this component */ -jpeg_set_htbl (regs, hactbl0,S5P_JPG_HACTBL (0 ),ARRAY_SIZE (hactbl0)); +s5p_jpeg_set_htbl (regs, hactbl0,S5P_JPG_HACTBL (0 ), +ARRAY_SIZE (hactbl0)); } -static inline void jpeg_set_hactblg (void __iomem *regs) +static inline void s5p_jpeg_set_hactblg (void __iomem *regs) {/* this driver fills table 0 for this component */ -jpeg_set_htbl (regs, hactblg0,S5P_JPG_HACTBLG (0 ),ARRAY_SIZE (hactblg0)); +s5p_jpeg_set_htbl (regs, hactblg0,S5P_JPG_HACTBLG (0 ), +ARRAY_SIZE (hactblg0)); }/*
@@ -962,8 +970,8 @@ static void s5p_jpeg_device_run(void *priv)* JPEG IP allows storing 4 quantization tables * We fill table 0 for luma and table 1 for chroma */ -jpeg_set_qtbl_lum (jpeg->regs, ctx->compr_quality); -jpeg_set_qtbl_chr (jpeg->regs, ctx->compr_quality); +s5p_jpeg_set_qtbl_lum (jpeg->regs, ctx->compr_quality); +s5p_jpeg_set_qtbl_chr (jpeg->regs, ctx->compr_quality);/* use table 0 for Y */ jpeg_qtbl (jpeg->regs,1 ,0 );/* use table 1 for Cb and Cr*/
@@ -1406,14 +1414,16 @@ static int s5p_jpeg_runtime_suspend(struct device *dev)static int s5p_jpeg_runtime_resume (struct device *dev) {struct s5p_jpeg *jpeg =dev_get_drvdata (dev); +/* * JPEG IP allows storing two Huffman tables for each component * We fill table 0 for each component */ -jpeg_set_hdctbl (jpeg->regs); -jpeg_set_hdctblg (jpeg->regs); -jpeg_set_hactbl (jpeg->regs); -jpeg_set_hactblg (jpeg->regs); +s5p_jpeg_set_hdctbl (jpeg->regs); +s5p_jpeg_set_hdctblg (jpeg->regs); +s5p_jpeg_set_hactbl (jpeg->regs); +s5p_jpeg_set_hactblg (jpeg->regs); +return 0 ; }
Signature · 1 line
1.7.9.5
PATCH v2 6/16 s5p-jpeg: Fix clock resource management
In reply to Jacek AnaszewskiStandard suspend/resume path is called after runtime resume of the given device, so suspend/resume callbacks must do all clock management done also by runtime pm to allow for proper power domain shutdown. Moreover, JPEG clock is enabled from probe function but is is not necessary. This patch also moves control of jpeg clock to runtime_pm callbacks.
--- drivers/media/platform/s5p-jpeg/jpeg-core.c | 35 +++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 5 deletions(-)
drivers/media/platform/s5p-jpeg/jpeg-core.c +30 -5
@@ -1272,7 +1272,6 @@ static int s5p_jpeg_probe(struct platform_device *pdev)return ret; }dev_dbg (&pdev->dev,"clock source %p\n" , jpeg->clk); -clk_prepare_enable (jpeg->clk);/* v4l2 device */ ret =v4l2_device_register (&pdev->dev, &jpeg->v4l2_dev);
@@ -1380,7 +1379,6 @@ device_register_rollback:v4l2_device_unregister (&jpeg->v4l2_dev); clk_get_rollback: -clk_disable_unprepare (jpeg->clk);clk_put (jpeg->clk);return ret;
@@ -1400,7 +1398,9 @@ static int s5p_jpeg_remove(struct platform_device *pdev)v4l2_m2m_release (jpeg->m2m_dev);v4l2_device_unregister (&jpeg->v4l2_dev); -clk_disable_unprepare (jpeg->clk); +if (!pm_runtime_status_suspended (&pdev->dev)) +clk_disable_unprepare (jpeg->clk); +clk_put (jpeg->clk);return 0 ;
@@ -1408,12 +1408,21 @@ static int s5p_jpeg_remove(struct platform_device *pdev)static int s5p_jpeg_runtime_suspend (struct device *dev) { +struct s5p_jpeg *jpeg =dev_get_drvdata (dev); + +clk_disable_unprepare (jpeg->clk); +return 0 ; }static int s5p_jpeg_runtime_resume (struct device *dev) {struct s5p_jpeg *jpeg =dev_get_drvdata (dev); +int ret; + + ret =clk_prepare_enable (jpeg->clk); +if (ret <0 ) +return ret;/* * JPEG IP allows storing two Huffman tables for each component
@@ -1427,9 +1436,25 @@ static int s5p_jpeg_runtime_resume(struct device *dev)return 0 ; } +static int s5p_jpeg_suspend (struct device *dev) +{ +if (pm_runtime_suspended (dev)) +return 0 ; + +return s5p_jpeg_runtime_suspend (dev); +} + +static int s5p_jpeg_resume (struct device *dev) +{ +if (pm_runtime_suspended (dev)) +return 0 ; + +return s5p_jpeg_runtime_resume (dev); +} +static const struct dev_pm_ops s5p_jpeg_pm_ops = { - .runtime_suspend = s5p_jpeg_runtime_suspend, - .runtime_resume = s5p_jpeg_runtime_resume, + SET_SYSTEM_SLEEP_PM_OPS(s5p_jpeg_suspend, s5p_jpeg_resume) +SET_RUNTIME_PM_OPS (s5p_jpeg_runtime_suspend, s5p_jpeg_runtime_resume,NULL ) };#ifdef CONFIG_OF
Signature · 1 line
1.7.9.5
PATCH v2 7/16 s5p-jpeg: Fix lack of spin_lock protection
In reply to Jacek Anaszewskis5p_jpeg_device_run and s5p_jpeg_runtime_resume callbacks should have spin_lock protection as they alter device registers.
--- drivers/media/platform/s5p-jpeg/jpeg-core.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/media/platform/s5p-jpeg/jpeg-core.c +10 -1
@@ -930,7 +930,9 @@ static void s5p_jpeg_device_run(void *priv)struct s5p_jpeg_ctx *ctx = priv;struct s5p_jpeg *jpeg = ctx->jpeg;struct vb2_buffer *src_buf, *dst_buf; -unsigned long src_addr, dst_addr; +unsigned long src_addr, dst_addr, flags; + +spin_lock_irqsave (&ctx->jpeg->slock, flags); src_buf =v4l2_m2m_next_src_buf (ctx->fh.m2m_ctx); dst_buf =v4l2_m2m_next_dst_buf (ctx->fh.m2m_ctx);
@@ -998,6 +1000,8 @@ static void s5p_jpeg_device_run(void *priv) }jpeg_start (jpeg->regs); + +spin_unlock_irqrestore (&ctx->jpeg->slock, flags); }static int s5p_jpeg_job_ready (void *priv)
@@ -1418,12 +1422,15 @@ static int s5p_jpeg_runtime_suspend(struct device *dev)static int s5p_jpeg_runtime_resume (struct device *dev) {struct s5p_jpeg *jpeg =dev_get_drvdata (dev); +unsigned long flags;int ret; ret =clk_prepare_enable (jpeg->clk);if (ret <0 )return ret; +spin_lock_irqsave (&jpeg->slock, flags); +/* * JPEG IP allows storing two Huffman tables for each component * We fill table 0 for each component
@@ -1433,6 +1440,8 @@ static int s5p_jpeg_runtime_resume(struct device *dev)s5p_jpeg_set_hactbl (jpeg->regs);s5p_jpeg_set_hactblg (jpeg->regs); +spin_unlock_irqrestore (&jpeg->slock, flags); +return 0 ; }
Signature · 1 line
1.7.9.5
PATCH v2 8/16 s5p-jpeg: Synchronize cached controls with V4L2 core
In reply to Jacek AnaszewskiThis patch adds proper initialization of the in-driver cached state of JPEG controls with V4L2 core.
--- drivers/media/platform/s5p-jpeg/jpeg-core.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
drivers/media/platform/s5p-jpeg/jpeg-core.c +15 -3
@@ -865,6 +865,7 @@ static int s5p_jpeg_controls_create(struct s5p_jpeg_ctx *ctx) {unsigned int mask = ~0x27 ;/* 444, 422, 420, GRAY */ struct v4l2_ctrl *ctrl; +int ret;v4l2_ctrl_handler_init (&ctx->ctrl_handler,3 );
@@ -884,13 +885,24 @@ static int s5p_jpeg_controls_create(struct s5p_jpeg_ctx *ctx)V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY , mask, V4L2_JPEG_CHROMA_SUBSAMPLING_422); -if (ctx->ctrl_handler.error) -return ctx->ctrl_handler.error; +if (ctx->ctrl_handler.error) { + ret = ctx->ctrl_handler.error; + goto error_free; + }if (ctx->mode ==S5P_JPEG_DECODE ) ctrl->flags |=V4L2_CTRL_FLAG_VOLATILE |V4L2_CTRL_FLAG_READ_ONLY ; -return 0 ; + + ret =v4l2_ctrl_handler_setup (&ctx->ctrl_handler); +if (ret <0 ) + goto error_free; + +return ret; + +error_free: +v4l2_ctrl_handler_free (&ctx->ctrl_handler); +return ret; }static const struct v4l2_ioctl_ops s5p_jpeg_ioctl_ops = {
Signature · 1 line
1.7.9.5
PATCH v2 9/16 s5p-jpeg: Split jpeg-hw.h to jpeg-hw-s5p.c and jpeg-hw-s5p.c
In reply to Jacek AnaszewskiMove function definitions from jpeg-hw.h to jpeg-hw-s5p.c and put function declarations in the jpeg-hw-s5p.h.
---
drivers/media/platform/s5p-jpeg/Makefile | 2 +-
drivers/media/platform/s5p-jpeg/jpeg-core.c | 2 +-
drivers/media/platform/s5p-jpeg/jpeg-core.h | 5 ++
.../platform/s5p-jpeg/{jpeg-hw.h => jpeg-hw-s5p.c} | 82 ++++++++------------
drivers/media/platform/s5p-jpeg/jpeg-hw-s5p.h | 63 +++++++++++++++
5 files changed, 104 insertions(+), 50 deletions(-)
rename drivers/media/platform/s5p-jpeg/{jpeg-hw.h => jpeg-hw-s5p.c} (71%)
create mode 100644 drivers/media/platform/s5p-jpeg/jpeg-hw-s5p.hdrivers/media/platform/s5p-jpeg/Makefile +1 -1
@@ -1,2 +1,2 @@ -s5p-jpeg-objs := jpeg-core.o +s5p-jpeg-objs := jpeg-core.o jpeg-hw-s5p.o obj-$(CONFIG_VIDEO_SAMSUNG_S5P_JPEG) += s5p-jpeg.o
drivers/media/platform/s5p-jpeg/jpeg-core.c +1 -1
@@ -29,7 +29,7 @@#include <media/videobuf2-dma-contig.h> #include "jpeg-core.h" -#include "jpeg-hw.h" +#include "jpeg-hw-s5p.h" static struct s5p_jpeg_fmt formats_enc[] = { {
drivers/media/platform/s5p-jpeg/jpeg-core.h +5 -0
@@ -42,10 +42,15 @@#define EOI 0xd9#define DHP 0xde +#define S5P_JPEG_ENCODE 0 +#define S5P_JPEG_DECODE 1 +/* Flags that indicate a format can be used for capture/output */ #define MEM2MEM_CAPTURE (1 << 0)#define MEM2MEM_OUTPUT (1 << 1) + +/** * struct s5p_jpeg - JPEG IP abstraction * @lock: the mutex protecting this structure
drivers/media/platform/s5p-jpeg/jpeg-hw-s5p.c renamed from drivers/media/platform/s5p-jpeg/jpeg-hw.h +34 -48
269 lines not on this page · raw message
drivers/media/platform/s5p-jpeg/jpeg-hw-s5p.h new file +63 -0
63 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Re: [PATCH v2 09/16] s5p-jpeg: Split jpeg-hw.h to jpeg-hw-s5p.c and jpeg-hw-s5p.c
Em Mon, 25 Nov 2013 10:58:16 +0100
Jacek Anaszewski <[email protected]> escreveu:
Quoted 5 lines
Move function definitions from
jpeg-hw.htojpeg-hw-s5p.cand put function declarations in thejpeg-hw-s5p.h.Signed-off-by Jacek Anaszewski <[email protected]>Signed-off-by Kyungmin Park <[email protected]>
...
Quoted 23 lines
drivers/media/platform/s5p-jpeg/jpeg-hw-s5p.h new file +23
-0+void jpeg_reset (void __iomem *regs); +void jpeg_poweron (void __iomem *regs); +void jpeg_input_raw_mode (void __iomem *regs,unsigned long mode); +void jpeg_input_raw_y16 (void __iomem *regs,bool y16); +void jpeg_proc_mode (void __iomem *regs,unsigned long mode); +void jpeg_subsampling_mode (void __iomem *regs,unsigned int mode); +unsigned int jpeg_get_subsampling_mode (void __iomem *regs); +void jpeg_dri (void __iomem *regs,unsigned int dri); +void jpeg_qtbl (void __iomem *regs,unsigned int t,unsigned int n); +void jpeg_htbl_ac (void __iomem *regs,unsigned int t); +void jpeg_htbl_dc (void __iomem *regs,unsigned int t); +void jpeg_y (void __iomem *regs,unsigned int y); +void jpeg_x (void __iomem *regs,unsigned int x); +void jpeg_rst_int_enable (void __iomem *regs,bool enable); +void jpeg_data_num_int_enable (void __iomem *regs,bool enable); +void jpeg_final_mcu_num_int_enable (void __iomem *regs,bool enbl); +void jpeg_timer_enable (void __iomem *regs,unsigned long val); +void jpeg_timer_disable (void __iomem *regs); +int jpeg_timer_stat (void __iomem *regs); +void jpeg_clear_timer_stat (void __iomem *regs); +void jpeg_enc_stream_int (void __iomem *regs,unsigned long size); +int jpeg_enc_stream_stat (void __iomem *regs); +void jpeg_clear_enc_stream_stat (void __iomem *regs);
drivers/media/platform/s5p-jpeg/jpeg-hw-s5p.h line 61
Quoted 10 lines
drivers/media/platform/s5p-jpeg/jpeg-hw-s5p.h new file +10
-0+void jpeg_outform_raw (void __iomem *regs,unsigned long format); +void jpeg_jpgadr (void __iomem *regs,unsigned long addr); +void jpeg_imgadr (void __iomem *regs,unsigned long addr); +void jpeg_coef (void __iomem *regs,unsigned int i, +unsigned int j,unsigned int coef); +void jpeg_start (void __iomem *regs); +int jpeg_result_stat_ok (void __iomem *regs); +int jpeg_stream_stat_ok (void __iomem *regs); +void jpeg_clear_int (void __iomem *regs); +unsigned int jpeg_compressed_size (void __iomem *regs);
NACK. Please don't pollute Kernel name space.
Those functions are specific to s5p. They should all be prepended by s5p_, or otherwise it will risk to cause conflicts with other global symbols that could have the same name, for kernels compiled will allyesconfig.
Regards,
Signature · 2 lines
Cheers, Mauro
PATCH v2 10/16 s5p-jpeg: Add hardware API for the exynos4x12 JPEG codec.
In reply to Jacek Anaszewski--- drivers/media/platform/s5p-jpeg/Makefile | 2 +- drivers/media/platform/s5p-jpeg/jpeg-core.c | 620 +++++++++++++++++++--- drivers/media/platform/s5p-jpeg/jpeg-core.h | 72 ++- drivers/media/platform/s5p-jpeg/jpeg-hw-exynos.c | 293 ++++++++++ drivers/media/platform/s5p-jpeg/jpeg-hw-exynos.h | 44 ++ drivers/media/platform/s5p-jpeg/jpeg-regs.h | 215 +++++++- 6 files changed, 1152 insertions(+), 94 deletions(-) create mode 100644 drivers/media/platform/s5p-jpeg/jpeg-hw-exynos.c create mode 100644 drivers/media/platform/s5p-jpeg/jpeg-hw-exynos.h
drivers/media/platform/s5p-jpeg/Makefile +1 -1
@@ -1,2 +1,2 @@ -s5p-jpeg-objs := jpeg-core.o jpeg-hw-s5p.o +s5p-jpeg-objs := jpeg-core.o jpeg-hw-exynos.o jpeg-hw-s5p.o obj-$(CONFIG_VIDEO_SAMSUNG_S5P_JPEG) += s5p-jpeg.o
drivers/media/platform/s5p-jpeg/jpeg-core.c +533 -87
868 lines not on this page · raw message
drivers/media/platform/s5p-jpeg/jpeg-core.h +67 -5
114 lines not on this page · raw message
drivers/media/platform/s5p-jpeg/jpeg-hw-exynos.c new file +293 -0
293 lines not on this page · raw message
drivers/media/platform/s5p-jpeg/jpeg-hw-exynos.h new file +44 -0
44 lines not on this page · raw message
drivers/media/platform/s5p-jpeg/jpeg-regs.h +214 -1
235 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH v2 11/16 s5p-jpeg: Retrieve "YCbCr subsampling" field from the jpeg header
In reply to Jacek AnaszewskiMake s5p_jpeg_parse_hdr function capable of parsing "YCbCr subsampling" field of a jpeg file header. Store the parsed value in the context. The information about source JPEG subsampling is required to make validation of destination format possible, which must be conducted for exynos4x12 device as the decoding process will not succeed if the destination format is set to YUV with subsampling lower than the one of the source JPEG image. With this knowledge the driver can adjust the destination format appropriately.
--- drivers/media/platform/s5p-jpeg/jpeg-core.c | 35 ++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-)
drivers/media/platform/s5p-jpeg/jpeg-core.c +31 -4
@@ -624,10 +624,11 @@ static void skip(struct s5p_jpeg_buffer *buf, long len) }static bool s5p_jpeg_parse_hdr (struct s5p_jpeg_q_data *result, -unsigned long buffer,unsigned long size) +unsigned long buffer,unsigned long size, +struct s5p_jpeg_ctx *ctx) {int c, components, notfound; -unsigned int height, width, word; +unsigned int height, width, word, subsampling =0 ;long length;struct s5p_jpeg_buffer jpeg_buffer;
@@ -666,7 +667,15 @@ static bool s5p_jpeg_parse_hdr(struct s5p_jpeg_q_data *result,break ; notfound =0 ; -skip (&jpeg_buffer, components *3 ); +if (components ==1 ) { + subsampling =0x33 ; + }else { +skip (&jpeg_buffer,1 ); + subsampling =get_byte (&jpeg_buffer); +skip (&jpeg_buffer,1 ); + } + +skip (&jpeg_buffer, components *2 );break ;/* skip payload-less markers */
@@ -688,6 +697,24 @@ static bool s5p_jpeg_parse_hdr(struct s5p_jpeg_q_data *result, result->w = width; result->h = height; result->size = components; + +switch (subsampling) { +case 0x11 : + ctx->subsampling =V4L2_JPEG_CHROMA_SUBSAMPLING_444 ; +break ; +case 0x21 : + ctx->subsampling =V4L2_JPEG_CHROMA_SUBSAMPLING_422 ; +break ; +case 0x22 : + ctx->subsampling =V4L2_JPEG_CHROMA_SUBSAMPLING_420 ; +break ; +case 0x33 : + ctx->subsampling =V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY ; +break ; +default : +return false; + } +return !notfound; }
@@ -1435,7 +1462,7 @@ static void s5p_jpeg_buf_queue(struct vb2_buffer *vb) ctx->hdr_parsed =s5p_jpeg_parse_hdr (&tmp, (unsigned long )vb2_plane_vaddr (vb,0 ),min ((unsigned long )ctx->out_q.size, -vb2_get_plane_payload (vb,0 ))); +vb2_get_plane_payload (vb,0 )), ctx);if (!ctx->hdr_parsed) {vb2_buffer_done (vb,VB2_BUF_STATE_ERROR );return ;
Signature · 1 line
1.7.9.5
PATCH v2 12/16 s5p-jpeg: Ensure correct capture format for Exynos4x12
In reply to Jacek AnaszewskiAdjust capture format to the Exynos4x12 device limitations, according to the subsampling value parsed from the source JPEG image header. If the capture format was set to YUV with subsampling lower than the one of the source JPEG image the decoding process would not succeed.
--- drivers/media/platform/s5p-jpeg/jpeg-core.c | 113 +++++++++++++++++++++++++++ 1 file changed, 113 insertions(+)
drivers/media/platform/s5p-jpeg/jpeg-core.c +113 -0
@@ -358,6 +358,99 @@ static const unsigned char hactblg0[162] = {0xf9 ,0xfa }; +/* +* Fourcc downgrade schema lookup tables for 422 and 420 +* chroma subsampling - fourcc on each position maps on the +* fourcc from the table fourcc_to_dwngrd_schema_id which allows +* to get the most suitable fourcc counterpart for the given +* downgraded subsampling property. +*/ +static const u32 subs422_fourcc_dwngrd_schema[] = { +V4L2_PIX_FMT_NV16 , +V4L2_PIX_FMT_NV61 , +}; + +static const u32 subs420_fourcc_dwngrd_schema[] = { +V4L2_PIX_FMT_NV12 , +V4L2_PIX_FMT_NV21 , +V4L2_PIX_FMT_NV12 , +V4L2_PIX_FMT_NV21 , +V4L2_PIX_FMT_NV12 , +V4L2_PIX_FMT_NV21 , +V4L2_PIX_FMT_GREY , +V4L2_PIX_FMT_GREY , +V4L2_PIX_FMT_GREY , +V4L2_PIX_FMT_GREY , +}; + +/* +* Lookup table for translation of a fourcc to the position +* of its downgraded counterpart in the *fourcc_dwngrd_schema +* tables. +*/ +static const u32 fourcc_to_dwngrd_schema_id[] = { +V4L2_PIX_FMT_NV24 , +V4L2_PIX_FMT_NV42 , +V4L2_PIX_FMT_NV16 , +V4L2_PIX_FMT_NV61 , +V4L2_PIX_FMT_YUYV , +V4L2_PIX_FMT_YVYU , +V4L2_PIX_FMT_NV12 , +V4L2_PIX_FMT_NV21 , +V4L2_PIX_FMT_YUV420 , +V4L2_PIX_FMT_GREY , +}; + +static int s5p_jpeg_get_dwngrd_sch_id_by_fourcc (u32 fourcc) +{ +int i; +for (i =0 ; i <ARRAY_SIZE (fourcc_to_dwngrd_schema_id); ++i) { +if (fourcc_to_dwngrd_schema_id[i] == fourcc) +return i; + } + +return -EINVAL ; +} + +static int s5p_jpeg_adjust_fourcc_to_subsampling ( +enum v4l2_jpeg_chroma_subsampling subs, +u32 in_fourcc, +u32 *out_fourcc, +struct s5p_jpeg_ctx *ctx) +{ +int dwngrd_sch_id; + +if (ctx->subsampling !=V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY ) { + dwngrd_sch_id = +s5p_jpeg_get_dwngrd_sch_id_by_fourcc (in_fourcc); +if (dwngrd_sch_id <0 ) +return -EINVAL ; + } + +switch (ctx->subsampling) { +case V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY : + *out_fourcc =V4L2_PIX_FMT_GREY ; +break ; +case V4L2_JPEG_CHROMA_SUBSAMPLING_420 : +if (dwngrd_sch_id > +ARRAY_SIZE (subs420_fourcc_dwngrd_schema) -1 ) +return -EINVAL ; + *out_fourcc = subs420_fourcc_dwngrd_schema[dwngrd_sch_id]; +break ; +case V4L2_JPEG_CHROMA_SUBSAMPLING_422 : +if (dwngrd_sch_id > +ARRAY_SIZE (subs422_fourcc_dwngrd_schema) -1 ) +return -EINVAL ; + *out_fourcc = subs422_fourcc_dwngrd_schema[dwngrd_sch_id]; +break ; +default : + *out_fourcc =V4L2_PIX_FMT_GREY ; +break ; + } + +return 0 ; +} +static inline struct s5p_jpeg_ctx *ctrl_to_ctx (struct v4l2_ctrl *c) { return container_of(c->handler, struct s5p_jpeg_ctx, ctrl_handler);
@@ -941,7 +1034,9 @@ static int s5p_jpeg_try_fmt_vid_cap(struct file *file, void *priv, struct v4l2_format *f) {struct s5p_jpeg_ctx *ctx =fh_to_ctx (priv); +struct v4l2_pix_format *pix = &f->fmt.pix;struct s5p_jpeg_fmt *fmt; +int ret; fmt =s5p_jpeg_find_format (ctx, f->fmt.pix.pixelformat,FMT_TYPE_CAPTURE );
@@ -952,6 +1047,24 @@ static int s5p_jpeg_try_fmt_vid_cap(struct file *file, void *priv,return -EINVAL ; } +/* +* The exynos4x12 device requires resulting YUV image +* subsampling not to be lower than the input jpeg subsampling. +* If this requirement is not met then downgrade the requested +* capture format to the one with subsampling equal to the input jpeg. +*/ +if ((ctx->jpeg->variant->version !=SJPEG_S5P ) && + (ctx->mode ==S5P_JPEG_DECODE ) && + (fmt->flags &SJPEG_FMT_NON_RGB ) && + (fmt->subsampling < ctx->subsampling)) { + ret =s5p_jpeg_adjust_fourcc_to_subsampling (ctx->subsampling, + fmt->fourcc, + &pix->pixelformat, + ctx); +if (ret <0 ) + pix->pixelformat =V4L2_PIX_FMT_GREY ; + } +return vidioc_try_fmt (f, fmt, ctx,FMT_TYPE_CAPTURE ); }
Signature · 1 line
1.7.9.5
PATCH v2 13/16 s5p-jpeg: Allow for wider JPEG subsampling scope for Exynos4x12 encoder
In reply to Jacek AnaszewskiExynos4x12 supports wider scope of subsampling modes than S5PC210. Adjust corresponding mask accordingly.
--- drivers/media/platform/s5p-jpeg/jpeg-core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/platform/s5p-jpeg/jpeg-core.c +2 -1
@@ -1246,7 +1246,8 @@ static int s5p_jpeg_controls_create(struct s5p_jpeg_ctx *ctx)v4l2_ctrl_new_std (&ctx->ctrl_handler, &s5p_jpeg_ctrl_ops,V4L2_CID_JPEG_RESTART_INTERVAL ,0 ,3 ,0xffff ,0 ); - mask = ~0x06 ;/* 422, 420 */ +if (ctx->jpeg->variant->version ==SJPEG_S5P ) + mask = ~0x06 ;/* 422, 420 */ } ctrl = v4l2_ctrl_new_std_menu(&ctx->ctrl_handler, &s5p_jpeg_ctrl_ops,
Signature · 1 line
1.7.9.5
PATCH v2 14/16 s5p-jpeg: Synchronize V4L2_CID_JPEG_CHROMA_SUBSAMPLING control value
In reply to Jacek AnaszewskiWhen output queue fourcc is set to any flavour of YUV, the V4L2_CID_JPEG_CHROMA_SUBSAMPLING control value as well as its in-driver cached counterpart have to be updated with the subsampling property of the format so as to be able to provide correct information to the user space and preclude setting an illegal subsampling mode for Exynos4x12 encoder.
--- drivers/media/platform/s5p-jpeg/jpeg-core.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/media/platform/s5p-jpeg/jpeg-core.c +8 -0
@@ -1091,6 +1091,7 @@ static int s5p_jpeg_s_fmt(struct s5p_jpeg_ctx *ct, struct v4l2_format *f)struct vb2_queue *vq;struct s5p_jpeg_q_data *q_data =NULL ;struct v4l2_pix_format *pix = &f->fmt.pix; +struct v4l2_ctrl *ctrl_subs;unsigned int f_type; vq =v4l2_m2m_get_vq (ct->fh.m2m_ctx, f->type);
@@ -1116,6 +1117,13 @@ static int s5p_jpeg_s_fmt(struct s5p_jpeg_ctx *ct, struct v4l2_format *f)else q_data->size = pix->sizeimage; +if (f_type ==FMT_TYPE_OUTPUT ) { + ctrl_subs =v4l2_ctrl_find (&ct->ctrl_handler, +V4L2_CID_JPEG_CHROMA_SUBSAMPLING ); +if (ctrl_subs) +v4l2_ctrl_s_ctrl (ctrl_subs, q_data->fmt->subsampling); + } +return 0 ; }
Signature · 1 line
1.7.9.5
PATCH v2 15/16 s5p-jpeg: Ensure setting correct value of the chroma subsampling control
In reply to Jacek AnaszewskiExynos4x12 has limitations regarding setting chroma subsampling of an output JPEG image. It cannot be lower than the subsampling of the raw source image. Also in case of V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY option the source image fourcc has to be V4L2_PIX_FMT_GREY. This patch implements try_ctrl callback containing mechanism that prevents setting invalid value of the V4L2_CID_JPEG_CHROMA_SUBSAMPLING control.
--- drivers/media/platform/s5p-jpeg/jpeg-core.c | 35 +++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
drivers/media/platform/s5p-jpeg/jpeg-core.c +35 -0
@@ -1210,6 +1210,40 @@ static int s5p_jpeg_g_volatile_ctrl(struct v4l2_ctrl *ctrl)return 0 ; } +static int s5p_jpeg_try_ctrl (struct v4l2_ctrl *ctrl) +{ +struct s5p_jpeg_ctx *ctx =ctrl_to_ctx (ctrl); +unsigned long flags; +int ret =0 ; + +spin_lock_irqsave (&ctx->jpeg->slock, flags); + +if (ctrl->id ==V4L2_CID_JPEG_CHROMA_SUBSAMPLING ) { +if (ctx->jpeg->variant->version ==SJPEG_S5P ) + goto error_free; +/* +* The exynos4x12 device requires input raw image fourcc +* to be V4L2_PIX_FMT_GREY if gray jpeg format +* is to be set. +*/ +if (ctx->out_q.fmt->fourcc !=V4L2_PIX_FMT_GREY && + ctrl->val ==V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY ) { + ret = -EINVAL ; + goto error_free; + } +/* +* The exynos4x12 device requires resulting jpeg subsampling +* not to be lower than the input raw image subsampling. +*/ +if (ctx->out_q.fmt->subsampling > ctrl->val) + ctrl->val = ctx->out_q.fmt->subsampling; + } + +error_free: +spin_unlock_irqrestore (&ctx->jpeg->slock, flags); +return ret; +} +static int s5p_jpeg_s_ctrl (struct v4l2_ctrl *ctrl) {struct s5p_jpeg_ctx *ctx =ctrl_to_ctx (ctrl);
@@ -1235,6 +1269,7 @@ static int s5p_jpeg_s_ctrl(struct v4l2_ctrl *ctrl)static const struct v4l2_ctrl_ops s5p_jpeg_ctrl_ops = { .g_volatile_ctrl = s5p_jpeg_g_volatile_ctrl, + .try_ctrl = s5p_jpeg_try_ctrl, .s_ctrl = s5p_jpeg_s_ctrl, };
Signature · 1 line
1.7.9.5
PATCH v2 16/16 s5p-jpeg: Adjust g_volatile_ctrl callback to Exynos4x12 needs
In reply to Jacek AnaszewskiWhereas S5PC210 device produces decoded JPEG subsampling values that map on V4L2_JPEG_CHROMA_SUBSAMPLNG values, the Exynos4x12 device doesn't. This patch adds helper function s5p_jpeg_to_user_subsampling, which performs suitable translation.
--- drivers/media/platform/s5p-jpeg/jpeg-core.c | 32 ++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 6 deletions(-)
drivers/media/platform/s5p-jpeg/jpeg-core.c +26 -6
@@ -451,6 +451,13 @@ static int s5p_jpeg_adjust_fourcc_to_subsampling(return 0 ; } +static int exynos4x12_decoded_subsampling[] = { +V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY , +V4L2_JPEG_CHROMA_SUBSAMPLING_444 , +V4L2_JPEG_CHROMA_SUBSAMPLING_422 , +V4L2_JPEG_CHROMA_SUBSAMPLING_420 , +}; +static inline struct s5p_jpeg_ctx *ctrl_to_ctx (struct v4l2_ctrl *c) { return container_of(c->handler, struct s5p_jpeg_ctx, ctrl_handler);
@@ -461,6 +468,24 @@ static inline struct s5p_jpeg_ctx *fh_to_ctx(struct v4l2_fh *fh) return container_of(fh, struct s5p_jpeg_ctx, fh); } +static int s5p_jpeg_to_user_subsampling (struct s5p_jpeg_ctx *ctx) +{ +WARN_ON (ctx->subsampling >3 ); + +if (ctx->jpeg->variant->version ==SJPEG_S5P ) { +if (ctx->subsampling >2 ) +return V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY ; +else +return ctx->subsampling; + }else { +if (ctx->subsampling >2 ) +return V4L2_JPEG_CHROMA_SUBSAMPLING_420 ; +else +return + exynos4x12_decoded_subsampling[ctx->subsampling]; + } +} +static inline void s5p_jpeg_set_qtbl (void __iomem *regs,const unsigned char *qtbl,unsigned long tab,int len)
@@ -1197,12 +1222,7 @@ static int s5p_jpeg_g_volatile_ctrl(struct v4l2_ctrl *ctrl)switch (ctrl->id) {case V4L2_CID_JPEG_CHROMA_SUBSAMPLING :spin_lock_irqsave (&jpeg->slock, flags); - -WARN_ON (ctx->subsampling >S5P_SUBSAMPLING_MODE_GRAY ); -if (ctx->subsampling >2 ) - ctrl->val =V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY ; -else - ctrl->val = ctx->subsampling; + ctrl->val =s5p_jpeg_to_user_subsampling (ctx);spin_unlock_irqrestore (&jpeg->slock, flags);break ; }
Signature · 1 line
1.7.9.5
Hi Jacek,
For this patch series:
Regards,
Hans
Quoted 54 lines · Jacek Anaszewski
This is the second version of the series that adds support for the Exynos4x12 device to the
s5p_jpegdriver along with accompanying fixes. It contains following improvements
(Hans, Sylwester thanks for the review):- moved adjusting chroma subsampling control value from
s_ctrltotry_ctrlcallback and switched from usingv4l2_s_ctrltov4l2_ctrl_s_ctrl
- avoided big switch statement in favour of lookup tables for adjusting capture queue fourcc during decoding phase
- avoided unnecessary displacement ofclk_getcall in the probe function
- renameddecoded_subsampling_to_v4l2tos5p_jpeg_to_user_subsampling
- added freeingctrl_handlerwhenv4l2_ctrl_handler_setupfails
- callings5p_jpeg_runtime_suspendands5p_jpeg_runtime_resumeonly whenpm_runtime_suspendedreturns falseThanks,
Jacek AnaszewskiJacek Anaszewski (16):
s5p-jpeg: Reorder quantization tables
s5p-jpeg: Fix output YUV 4:2:0 fourcc for decoder
s5p-jpeg: Fix erroneous condition while validating bytesperline value
s5p-jpeg: Remove superfluous call to thejpeg_bound_align_image
function
s5p-jpeg: Rename functions specific to the S5PC210 SoC accordingly
s5p-jpeg: Fix clock resource management
s5p-jpeg: Fix lack ofspin_lockprotection
s5p-jpeg: Synchronize cached controls with V4L2 core
s5p-jpeg: Splitjpeg-hw.htojpeg-hw-s5p.candjpeg-hw-s5p.c
s5p-jpeg: Add hardware API for the exynos4x12 JPEG codec.
s5p-jpeg: Retrieve "YCbCr subsampling" field from the jpeg header
s5p-jpeg: Ensure correct capture format for Exynos4x12
s5p-jpeg: Allow for wider JPEG subsampling scope for Exynos4x12
encoder
s5p-jpeg: SynchronizeV4L2_CID_JPEG_CHROMA_SUBSAMPLINGcontrol value
s5p-jpeg: Ensure setting correct value of the chroma subsampling
control
s5p-jpeg: Adjustg_volatile_ctrlcallback to Exynos4x12 needsdrivers/media/platform/s5p-jpeg/Makefile | 2 +- drivers/media/platform/s5p-jpeg/jpeg-core.c | 1089 ++++++++++++++++---- drivers/media/platform/s5p-jpeg/jpeg-core.h | 75 +- drivers/media/platform/s5p-jpeg/jpeg-hw-exynos.c | 293 ++++++ drivers/media/platform/s5p-jpeg/jpeg-hw-exynos.h | 44 + .../platform/s5p-jpeg/{jpeg-hw.h => jpeg-hw-s5p.c} | 82 +- drivers/media/platform/s5p-jpeg/jpeg-hw-s5p.h | 63 ++ drivers/media/platform/s5p-jpeg/jpeg-regs.h | 215 +++- 8 files changed, 1614 insertions(+), 249 deletions(-) create mode 100644 drivers/media/platform/s5p-jpeg/jpeg-hw-exynos.c create mode 100644 drivers/media/platform/s5p-jpeg/jpeg-hw-exynos.h rename drivers/media/platform/s5p-jpeg/{jpeg-hw.h => jpeg-hw-s5p.c} (71%) create mode 100644 drivers/media/platform/s5p-jpeg/jpeg-hw-s5p.h