media: staging: rkisp1: cap: various fixes for capture formats
Subsystems (3)
cover media: staging: rkisp1: cap: various fixes for capture formats
This patchset fixes various issues related to
the supported formats in the rkisp1 capture.
Patches summary:
patch 1 - fixes a wrong assignments to the register that swaps the 'u', 'v' planes in YUV semiplanar formats.
patch 2 - sets the register from patch 1 only if the format is semiplanar.
patch 3 - adds support to planar YUV formats with swapped u,v planes by swapping the addresses of the planes
patch 4 - removes some packed YUV formats that are not supported by the driver.
Dafna Hirschfeld (4):
media: staging: rkisp1: cap: fix issues when writing to uv swap
register
media: staging: rkisp1: cap: support uv swap only for semiplanar
formats
media: staging: rkisp1: cap: support uv swapped plane formats
media: staging: rkisp1: cap: remove unsupported formats
drivers/staging/media/rkisp1/rkisp1-capture.c | 55 ++++++++++--------- 1 file changed, 28 insertions(+), 27 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/4 media: staging: rkisp1: cap: fix issues when writing to uv swap register
When writing to the RKISP1_CIF_MI_XTD_FORMAT_CTRL register in mainpath, a redundant mask that clears the related swap flag is applied and then the flag is set again.
In the selfpath, a mask that clears the swap setting is applied instead of adding the setting.
This patch fixes those issues by just adding the swap setting.
--- drivers/staging/media/rkisp1/rkisp1-capture.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/staging/media/rkisp1/rkisp1-capture.c +3 -4
@@ -432,8 +432,7 @@ static void rkisp1_mp_config(struct rkisp1_capture *cap)if (cap->pix.cfg->uv_swap) { reg =rkisp1_read (rkisp1,RKISP1_CIF_MI_XTD_FORMAT_CTRL ); - reg = (reg & ~BIT (0 )) | -RKISP1_CIF_MI_XTD_FMT_CTRL_MP_CB_CR_SWAP ; + reg = reg |RKISP1_CIF_MI_XTD_FMT_CTRL_MP_CB_CR_SWAP ;rkisp1_write (rkisp1, reg,RKISP1_CIF_MI_XTD_FORMAT_CTRL ); }
@@ -470,8 +469,8 @@ static void rkisp1_sp_config(struct rkisp1_capture *cap)if (cap->pix.cfg->uv_swap) {u32 reg =rkisp1_read (rkisp1,RKISP1_CIF_MI_XTD_FORMAT_CTRL ); -rkisp1_write (rkisp1, reg & ~BIT (1 ), -RKISP1_CIF_MI_XTD_FORMAT_CTRL ); + reg = reg |RKISP1_CIF_MI_XTD_FMT_CTRL_SP_CB_CR_SWAP ; +rkisp1_write (rkisp1, reg,RKISP1_CIF_MI_XTD_FORMAT_CTRL ); }rkisp1_mi_config_ctrl (cap);
Signature · 1 line
2.17.1
Re: [PATCH 1/4] media: staging: rkisp1: cap: fix issues when writing to uv swap register
Hi Dafna,
Thanks for your patch.
Quoted 7 lines · Dafna Hirschfeld
When writing to the
RKISP1_CIF_MI_XTD_FORMAT_CTRLregister in mainpath, a redundant mask that clears the related swap flag is applied and then the flag is set again.In the selfpath, a mask that clears the swap setting is applied instead of adding the setting.
This patch fixes those issues by just adding the swap setting.
One is a clean-up, and the other one is a bug fix. Could you please split those in two separated patches?
It is better for tracking bugs and bisectability to not mix cleanups with fixes.
Thanks
Helen
Quoted 32 lines
Signed-off-by Dafna Hirschfeld <[email protected]>--- drivers/staging/media/rkisp1/rkisp1-capture.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)drivers/staging/media/rkisp1/rkisp1-capture.c +3
-4@@ -432,8 +432,7 @@ static void rkisp1_mp_config(struct rkisp1_capture *cap)if (cap->pix.cfg->uv_swap) { reg =rkisp1_read (rkisp1,RKISP1_CIF_MI_XTD_FORMAT_CTRL ); - reg = (reg & ~BIT (0 )) | -RKISP1_CIF_MI_XTD_FMT_CTRL_MP_CB_CR_SWAP ; + reg = reg |RKISP1_CIF_MI_XTD_FMT_CTRL_MP_CB_CR_SWAP ;rkisp1_write (rkisp1, reg,RKISP1_CIF_MI_XTD_FORMAT_CTRL ); }@@ -470,8 +469,8 @@ static void rkisp1_sp_config(struct rkisp1_capture *cap)if (cap->pix.cfg->uv_swap) {u32 reg =rkisp1_read (rkisp1,RKISP1_CIF_MI_XTD_FORMAT_CTRL ); -rkisp1_write (rkisp1, reg & ~BIT (1 ), -RKISP1_CIF_MI_XTD_FORMAT_CTRL ); + reg = reg |RKISP1_CIF_MI_XTD_FMT_CTRL_SP_CB_CR_SWAP ; +rkisp1_write (rkisp1, reg,RKISP1_CIF_MI_XTD_FORMAT_CTRL ); }rkisp1_mi_config_ctrl (cap);
PATCH 2/4 media: staging: rkisp1: cap: support uv swap only for semiplanar formats
In reply to Dafna HirschfeldThe register RKISP1_CIF_MI_XTD_FORMAT_CTRL is relevant only for semiplanar formats, therefore the uv swap can be supported through this register only for semiplanar formats.
--- drivers/staging/media/rkisp1/rkisp1-capture.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/staging/media/rkisp1/rkisp1-capture.c +8 -2
@@ -37,6 +37,10 @@#define RKISP1_MIN_BUFFERS_NEEDED 3 +#define RKISP1_IS_SEMI_PLANAR (write_format) \ + (((write_format) == RKISP1_MI_CTRL_MP_WRITE_YUV_SPLA) || \ + ((write_format) == RKISP1_MI_CTRL_SP_WRITE_SPLA)) +enum rkisp1_plane {RKISP1_PLANE_Y =0 ,RKISP1_PLANE_CB =1 ,
@@ -429,7 +433,8 @@ static void rkisp1_mp_config(struct rkisp1_capture *cap) cap->config->mi.cr_size_init);rkisp1_irq_frame_end_enable (cap); -if (cap->pix.cfg->uv_swap) { +if (RKISP1_IS_SEMI_PLANAR (cap->pix.cfg->write_format) && + cap->pix.cfg->uv_swap) { reg =rkisp1_read (rkisp1,RKISP1_CIF_MI_XTD_FORMAT_CTRL ); reg = reg |RKISP1_CIF_MI_XTD_FMT_CTRL_MP_CB_CR_SWAP ;
@@ -466,7 +471,8 @@ static void rkisp1_sp_config(struct rkisp1_capture *cap)rkisp1_write (rkisp1, cap->sp_y_stride,RKISP1_CIF_MI_SP_Y_LLENGTH );rkisp1_irq_frame_end_enable (cap); -if (cap->pix.cfg->uv_swap) { +if (RKISP1_IS_SEMI_PLANAR (cap->pix.cfg->write_format) && + cap->pix.cfg->uv_swap) {u32 reg =rkisp1_read (rkisp1,RKISP1_CIF_MI_XTD_FORMAT_CTRL ); reg = reg |RKISP1_CIF_MI_XTD_FMT_CTRL_SP_CB_CR_SWAP ;
Signature · 1 line
2.17.1
Re: [PATCH 2/4] media: staging: rkisp1: cap: support uv swap only for semiplanar formats
Quoted 5 lines · Dafna Hirschfeld
The register
RKISP1_CIF_MI_XTD_FORMAT_CTRLis relevant only for semiplanar formats, therefore the uv swap can be supported through this register only for semiplanar formats.Signed-off-by Dafna Hirschfeld <[email protected]>
Quoted 40 lines
--- drivers/staging/media/rkisp1/rkisp1-capture.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)drivers/staging/media/rkisp1/rkisp1-capture.c +8
-2@@ -37,6 +37,10 @@#define RKISP1_MIN_BUFFERS_NEEDED 3 +#define RKISP1_IS_SEMI_PLANAR (write_format) \ + (((write_format) == RKISP1_MI_CTRL_MP_WRITE_YUV_SPLA) || \ + ((write_format) == RKISP1_MI_CTRL_SP_WRITE_SPLA)) +enum rkisp1_plane {RKISP1_PLANE_Y =0 ,RKISP1_PLANE_CB =1 ,@@ -429,7 +433,8 @@ static void rkisp1_mp_config(struct rkisp1_capture *cap) cap->config->mi.cr_size_init);rkisp1_irq_frame_end_enable (cap); -if (cap->pix.cfg->uv_swap) { +if (RKISP1_IS_SEMI_PLANAR (cap->pix.cfg->write_format) && + cap->pix.cfg->uv_swap) { reg =rkisp1_read (rkisp1,RKISP1_CIF_MI_XTD_FORMAT_CTRL ); reg = reg |RKISP1_CIF_MI_XTD_FMT_CTRL_MP_CB_CR_SWAP ;@@ -466,7 +471,8 @@ static void rkisp1_sp_config(struct rkisp1_capture *cap)rkisp1_write (rkisp1, cap->sp_y_stride,RKISP1_CIF_MI_SP_Y_LLENGTH );rkisp1_irq_frame_end_enable (cap); -if (cap->pix.cfg->uv_swap) { +if (RKISP1_IS_SEMI_PLANAR (cap->pix.cfg->write_format) && + cap->pix.cfg->uv_swap) {u32 reg =rkisp1_read (rkisp1,RKISP1_CIF_MI_XTD_FORMAT_CTRL ); reg = reg |RKISP1_CIF_MI_XTD_FMT_CTRL_SP_CB_CR_SWAP ;
PATCH 3/4 media: staging: rkisp1: cap: support uv swapped plane formats
In reply to Dafna HirschfeldPlane formats with the u and v planes swapped can be supported by changing the address of the cb and cr in the buffer.
--- drivers/staging/media/rkisp1/rkisp1-capture.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/staging/media/rkisp1/rkisp1-capture.c +17 -0
@@ -41,6 +41,10 @@ (((write_format) ==RKISP1_MI_CTRL_MP_WRITE_YUV_SPLA ) || \ ((write_format) == RKISP1_MI_CTRL_SP_WRITE_SPLA)) +#define RKISP1_IS_PLANAR (write_format) \ + (((write_format) == RKISP1_MI_CTRL_SP_WRITE_PLA) || \ + ((write_format) == RKISP1_MI_CTRL_MP_WRITE_YUV_PLA_OR_RAW8)) +enum rkisp1_plane {RKISP1_PLANE_Y =0 ,RKISP1_PLANE_CB =1 ,
@@ -788,6 +792,19 @@ static void rkisp1_vb2_buf_queue(struct vb2_buffer *vb)rkisp1_pixfmt_comp_size (pixm,RKISP1_PLANE_CB ); } +/* +* uv swap can be supported for plane formats by switching +* the address of cb and cr +*/ +if (RKISP1_IS_PLANAR (cap->pix.cfg->write_format) && + cap->pix.cfg->uv_swap) { + ispbuf->buff_addr[RKISP1_PLANE_CR ] = + ispbuf->buff_addr[RKISP1_PLANE_CB ]; + ispbuf->buff_addr[RKISP1_PLANE_CB ] = + ispbuf->buff_addr[RKISP1_PLANE_CR ] + +rkisp1_pixfmt_comp_size (pixm,RKISP1_PLANE_CR ); + } +spin_lock_irqsave (&cap->buf.lock, flags);/*
Signature · 1 line
2.17.1
Re: [PATCH 3/4] media: staging: rkisp1: cap: support uv swapped plane formats
Quoted 5 lines · Dafna Hirschfeld
Plane formats with the u and v planes swapped can be supported by changing the address of the cb and cr in the buffer.
Signed-off-by Dafna Hirschfeld <[email protected]>
Quoted 40 lines
--- drivers/staging/media/rkisp1/rkisp1-capture.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)drivers/staging/media/rkisp1/rkisp1-capture.c +17
-0@@ -41,6 +41,10 @@ (((write_format) ==RKISP1_MI_CTRL_MP_WRITE_YUV_SPLA ) || \ ((write_format) == RKISP1_MI_CTRL_SP_WRITE_SPLA)) +#define RKISP1_IS_PLANAR (write_format) \ + (((write_format) == RKISP1_MI_CTRL_SP_WRITE_PLA) || \ + ((write_format) == RKISP1_MI_CTRL_MP_WRITE_YUV_PLA_OR_RAW8)) +enum rkisp1_plane {RKISP1_PLANE_Y =0 ,RKISP1_PLANE_CB =1 ,@@ -788,6 +792,19 @@ static void rkisp1_vb2_buf_queue(struct vb2_buffer *vb)rkisp1_pixfmt_comp_size (pixm,RKISP1_PLANE_CB ); } +/* +* uv swap can be supported for plane formats by switching +* the address of cb and cr +*/ +if (RKISP1_IS_PLANAR (cap->pix.cfg->write_format) && + cap->pix.cfg->uv_swap) { + ispbuf->buff_addr[RKISP1_PLANE_CR ] = + ispbuf->buff_addr[RKISP1_PLANE_CB ]; + ispbuf->buff_addr[RKISP1_PLANE_CB ] = + ispbuf->buff_addr[RKISP1_PLANE_CR ] + +rkisp1_pixfmt_comp_size (pixm,RKISP1_PLANE_CR ); + } +spin_lock_irqsave (&cap->buf.lock, flags);/*
PATCH 4/4 media: staging: rkisp1: cap: remove unsupported formats
In reply to Dafna HirschfeldFor Ycbcr packed formats only YUYV can be supported by the driver. This patch removes the other formats.
--- drivers/staging/media/rkisp1/rkisp1-capture.c | 21 ------------------- 1 file changed, 21 deletions(-)
drivers/staging/media/rkisp1/rkisp1-capture.c +0 -21
@@ -98,15 +98,6 @@ static const struct rkisp1_capture_fmt_cfg rkisp1_mp_fmts[] = { .fmt_type = RKISP1_FMT_YUV, .uv_swap = 0, .write_format = RKISP1_MI_CTRL_MP_WRITE_YUVINT, - }, { - .fourcc = V4L2_PIX_FMT_YVYU, - .fmt_type = RKISP1_FMT_YUV, - .uv_swap = 1, - .write_format = RKISP1_MI_CTRL_MP_WRITE_YUVINT, - }, { - .fourcc = V4L2_PIX_FMT_VYUY, - .fmt_type = RKISP1_FMT_YUV, - .write_format = RKISP1_MI_CTRL_MP_WRITE_YUVINT, }, { .fourcc = V4L2_PIX_FMT_YUV422P, .fmt_type = RKISP1_FMT_YUV,
@@ -234,18 +225,6 @@ static const struct rkisp1_capture_fmt_cfg rkisp1_sp_fmts[] = { .uv_swap = 0, .write_format = RKISP1_MI_CTRL_SP_WRITE_INT, .output_format = RKISP1_MI_CTRL_SP_OUTPUT_YUV422, - }, { - .fourcc = V4L2_PIX_FMT_YVYU, - .fmt_type = RKISP1_FMT_YUV, - .uv_swap = 1, - .write_format = RKISP1_MI_CTRL_SP_WRITE_INT, - .output_format = RKISP1_MI_CTRL_SP_OUTPUT_YUV422, - }, { - .fourcc = V4L2_PIX_FMT_VYUY, - .fmt_type = RKISP1_FMT_YUV, - .uv_swap = 1, - .write_format = RKISP1_MI_CTRL_SP_WRITE_INT, - .output_format = RKISP1_MI_CTRL_SP_OUTPUT_YUV422, }, { .fourcc = V4L2_PIX_FMT_YUV422P, .fmt_type = RKISP1_FMT_YUV,
Signature · 1 line
2.17.1
Re: [PATCH 4/4] media: staging: rkisp1: cap: remove unsupported formats
Quoted 4 lines · Dafna Hirschfeld
For Ycbcr packed formats only YUYV can be supported by the driver. This patch removes the other formats.
Signed-off-by Dafna Hirschfeld <[email protected]>
Quoted 44 lines
--- drivers/staging/media/rkisp1/rkisp1-capture.c | 21 ------------------- 1 file changed, 21 deletions(-)drivers/staging/media/rkisp1/rkisp1-capture.c +0
-21@@ -98,15 +98,6 @@ static const struct rkisp1_capture_fmt_cfg rkisp1_mp_fmts[] = { .fmt_type = RKISP1_FMT_YUV, .uv_swap = 0, .write_format = RKISP1_MI_CTRL_MP_WRITE_YUVINT, - }, { - .fourcc = V4L2_PIX_FMT_YVYU, - .fmt_type = RKISP1_FMT_YUV, - .uv_swap = 1, - .write_format = RKISP1_MI_CTRL_MP_WRITE_YUVINT, - }, { - .fourcc = V4L2_PIX_FMT_VYUY, - .fmt_type = RKISP1_FMT_YUV, - .write_format = RKISP1_MI_CTRL_MP_WRITE_YUVINT, }, { .fourcc = V4L2_PIX_FMT_YUV422P, .fmt_type = RKISP1_FMT_YUV,@@ -234,18 +225,6 @@ static const struct rkisp1_capture_fmt_cfg rkisp1_sp_fmts[] = { .uv_swap = 0, .write_format = RKISP1_MI_CTRL_SP_WRITE_INT, .output_format = RKISP1_MI_CTRL_SP_OUTPUT_YUV422, - }, { - .fourcc = V4L2_PIX_FMT_YVYU, - .fmt_type = RKISP1_FMT_YUV, - .uv_swap = 1, - .write_format = RKISP1_MI_CTRL_SP_WRITE_INT, - .output_format = RKISP1_MI_CTRL_SP_OUTPUT_YUV422, - }, { - .fourcc = V4L2_PIX_FMT_VYUY, - .fmt_type = RKISP1_FMT_YUV, - .uv_swap = 1, - .write_format = RKISP1_MI_CTRL_SP_WRITE_INT, - .output_format = RKISP1_MI_CTRL_SP_OUTPUT_YUV422, }, { .fourcc = V4L2_PIX_FMT_YUV422P, .fmt_type = RKISP1_FMT_YUV,