media: imx: Miscellaneous fixes for i.MX7
cover media: imx: Miscellaneous fixes for i.MX7
Hello,
This patch series contains miscellaneous fixes I developed while trying to capture from a CSI-2 sensor on the i.MX7.
Patches 1/7, 2/7 and 6/7 are small fixes or enhancements, please see individual commit messages. Patches 3/7, 4/7 and 5/7 add support for 10- and 12-bit greyscale formats (both on the i.MX7 CSI-2 receiver side and the CSI side). Patch 7/7 finally fixes a recent issue with video field handling.
Laurent Pinchart (7):
media: imx: imx7_mipi_csis: Power off the source when stopping
streaming
media: imx: imx7_mipi_csis: Print the RESOL_CH0 register
media: imx: imx7_mipi_csis: Add greyscale formats support
media: imx: imx6-media-csi: Replace Y16 with Y10 and Y12
media: imx: imx7-media-csi: Add Y10 and Y12 formats support
media: imx: imx7-media-csi: Remove unneeded register read
media: imx: imx7-media-csi: Fix video field handling
drivers/staging/media/imx/imx-media-csi.c | 3 ++- drivers/staging/media/imx/imx-media-utils.c | 13 ++++++++----- drivers/staging/media/imx/imx7-media-csi.c | 14 +++++++++++++- drivers/staging/media/imx/imx7-mipi-csis.c | 15 ++++++++++++++- 4 files changed, 37 insertions(+), 8 deletions(-)
Signature · 3 lines
Regards, Laurent Pinchart
PATCH 1/7 media: imx: imx7_mipi_csis: Power off the source when stopping streaming
The .s_stream() implementation incorrectly powers on the source when stopping the stream. Power it off instead.
--- drivers/staging/media/imx/imx7-mipi-csis.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/imx/imx7-mipi-csis.c +1 -1
@@ -577,7 +577,7 @@ static int mipi_csis_s_stream(struct v4l2_subdev *mipi_sd, int enable) state->flags |=ST_STREAMING ; }else {v4l2_subdev_call (state->src_sd, video, s_stream,0 ); - ret =v4l2_subdev_call (state->src_sd, core, s_power,1 ); + ret =v4l2_subdev_call (state->src_sd, core, s_power,0 );mipi_csis_stop_stream (state); state->flags &= ~ST_STREAMING ;if (state->debug)
Signature · 3 lines
Regards, Laurent Pinchart
Fabio Estevam
reviewerRe: [PATCH 1/7] media: imx: imx7_mipi_csis: Power off the source when stopping streaming
Hi Laurent,
Quoted 5 lines · Laurent Pinchart
The .s_stream() implementation incorrectly powers on the source when stopping the stream. Power it off instead.
Signed-off-by Laurent Pinchart <[email protected]>
Should this one have a Fixes tag?
Thanks
Re: [PATCH 1/7] media: imx: imx7_mipi_csis: Power off the source when stopping streaming
Hi Laurent,
Quoted 11 lines · Fabio Estevam
Hi Laurent,
Quoted 5 lines · Laurent Pinchart
The .s_stream() implementation incorrectly powers on the source when stopping the stream. Power it off instead.
Signed-off-by Laurent Pinchart <[email protected]>Should this one have a Fixes tag?
let me help you on this one:
---
Cheers,
Rui
Quoted 2 lines
Thanks
PATCH 2/7 media: imx: imx7_mipi_csis: Print the RESOL_CH0 register
In reply to Laurent PinchartAdd the RESOL_CH0 register to the list of registers printed through the debugfs debug infrastructure for the driver, as it can be useful to verify proper configuration of the CSI-2 receiver.
--- drivers/staging/media/imx/imx7-mipi-csis.c | 1 + 1 file changed, 1 insertion(+)
drivers/staging/media/imx/imx7-mipi-csis.c +1 -0
@@ -303,6 +303,7 @@ static int mipi_csis_dump_regs(struct csi_state *state) { 0x20, "DPHYSTS" }, { 0x10, "INTMSK" }, { 0x40, "CONFIG_CH0" }, + { 0x44, "RESOL_CH0" }, { 0xC0, "DBG_CONFIG" }, { 0x38, "DPHYSLAVE_L" }, { 0x3C, "DPHYSLAVE_H" },
Signature · 3 lines
Regards, Laurent Pinchart
PATCH 3/7 media: imx: imx7_mipi_csis: Add greyscale formats support
In reply to Laurent PinchartAdd support for the 8-, 10- and 12-bit greyscale media bus formats, and map them to the CSI-2 RAW8, RAW10 and RAW12 formats respectively.
--- drivers/staging/media/imx/imx7-mipi-csis.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/staging/media/imx/imx7-mipi-csis.c +12 -0
@@ -282,6 +282,18 @@ static const struct csis_pix_format mipi_csis_formats[] = { .code = MEDIA_BUS_FMT_YUYV8_2X8, .fmt_reg = MIPI_CSIS_ISPCFG_FMT_YCBCR422_8BIT, .data_alignment = 16, + }, { + .code = MEDIA_BUS_FMT_Y8_1X8, + .fmt_reg = MIPI_CSIS_ISPCFG_FMT_RAW8, + .data_alignment = 8, + }, { + .code = MEDIA_BUS_FMT_Y10_1X10, + .fmt_reg = MIPI_CSIS_ISPCFG_FMT_RAW10, + .data_alignment = 16, + }, { + .code = MEDIA_BUS_FMT_Y12_1X12, + .fmt_reg = MIPI_CSIS_ISPCFG_FMT_RAW12, + .data_alignment = 16, } };
Signature · 3 lines
Regards, Laurent Pinchart
PATCH 4/7 media: imx: imx6-media-csi: Replace Y16 with Y10 and Y12
In reply to Laurent PinchartThe driver doesn't really support V4L2_PIX_FMT_Y16, as there's no 16-bit greyscale media bus code defined by the kernel. It (ab)uses the format to capture 10-bit and 12-bit greyscale formats. Fix it to properly support MEDIA_BUS_FMT_Y10_1X10 and MEDIA_BUS_FMT_Y12_1X12 instead.
--- drivers/staging/media/imx/imx-media-csi.c | 3 ++- drivers/staging/media/imx/imx-media-utils.c | 13 ++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-)
drivers/staging/media/imx/imx-media-csi.c +2 -1
@@ -457,7 +457,8 @@ static int csi_idmac_setup_channel(struct csi_priv *priv)case V4L2_PIX_FMT_SGBRG16 :case V4L2_PIX_FMT_SGRBG16 :case V4L2_PIX_FMT_SRGGB16 : -case V4L2_PIX_FMT_Y16 : +case V4L2_PIX_FMT_Y10 : +case V4L2_PIX_FMT_Y12 : burst_size =8 ; passthrough_bits =16 ;break ;
drivers/staging/media/imx/imx-media-utils.c +8 -5
@@ -166,11 +166,14 @@ static const struct imx_media_pixfmt rgb_formats[] = { .bpp = 8, .bayer = true, }, { - .fourcc = V4L2_PIX_FMT_Y16, - .codes = { -MEDIA_BUS_FMT_Y10_1X10 , - MEDIA_BUS_FMT_Y12_1X12, - }, + .fourcc = V4L2_PIX_FMT_Y10, + .codes = {MEDIA_BUS_FMT_Y10_1X10}, + .cs = IPUV3_COLORSPACE_RGB, + .bpp = 16, + .bayer = true, + }, { + .fourcc = V4L2_PIX_FMT_Y12, + .codes = {MEDIA_BUS_FMT_Y12_1X12}, .cs = IPUV3_COLORSPACE_RGB, .bpp = 16, .bayer = true,
Signature · 3 lines
Regards, Laurent Pinchart
PATCH 5/7 media: imx: imx7-media-csi: Add Y10 and Y12 formats support
In reply to Laurent PinchartSupport capturing the 10- and 12-bit greyscale formats.
--- drivers/staging/media/imx/imx7-media-csi.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/staging/media/imx/imx7-media-csi.c +8 -0
@@ -804,6 +804,14 @@ static int imx7_csi_configure(struct imx7_csi *csi)case V4L2_PIX_FMT_YUYV : cr18 |=BIT_MIPI_DATA_FORMAT_YUV422_8B ;break ; +case V4L2_PIX_FMT_Y10 : + cr18 |=BIT_MIPI_DATA_FORMAT_RAW10 ; + cr1 |=BIT_PIXEL_BIT ; +break ; +case V4L2_PIX_FMT_Y12 : + cr18 |=BIT_MIPI_DATA_FORMAT_RAW12 ; + cr1 |=BIT_PIXEL_BIT ; +break ;case V4L2_PIX_FMT_SBGGR8 : cr18 |=BIT_MIPI_DATA_FORMAT_RAW8 ;break ;
Signature · 3 lines
Regards, Laurent Pinchart
PATCH 6/7 media: imx: imx7-media-csi: Remove unneeded register read
In reply to Laurent PinchartThe imx7_csi_dma_reflash() function starts by reading the unrelated register CSI_CSICR18 to then overwrite the read value with a read from register CSI_CSICR3. This is likely due to a bad copy&paste, and is not needed. Remove the extraneous read from register CSI_CSICR18.
--- drivers/staging/media/imx/imx7-media-csi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/imx/imx7-media-csi.c +1 -1
@@ -292,7 +292,7 @@ static void imx7_csi_hw_disable(struct imx7_csi *csi)static void imx7_csi_dma_reflash (struct imx7_csi *csi) { -u32 cr3 =imx7_csi_reg_read (csi,CSI_CSICR18 ); +u32 cr3; cr3 =imx7_csi_reg_read (csi,CSI_CSICR3 ); cr3 |=BIT_DMA_REFLASH_RFF ;
Signature · 3 lines
Regards, Laurent Pinchart
Steve Longerbeam
maintainerRe: [PATCH 6/7] media: imx: imx7-media-csi: Remove unneeded register read
Hi Laurent,
This patch also looks like it needs a Fixes tag.
Steve
Quoted 23 lines · Laurent Pinchart
The
imx7_csi_dma_reflash()function starts by reading the unrelated registerCSI_CSICR18to then overwrite the read value with a read from registerCSI_CSICR3. This is likely due to a bad copy&paste, and is not needed. Remove the extraneous read from registerCSI_CSICR18.Signed-off-by Laurent Pinchart <[email protected]>--- drivers/staging/media/imx/imx7-media-csi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/media/imx/imx7-media-csi.c +1
-1@@ -292,7 +292,7 @@ static void imx7_csi_hw_disable(struct imx7_csi *csi)static void imx7_csi_dma_reflash (struct imx7_csi *csi) { -u32 cr3 =imx7_csi_reg_read (csi,CSI_CSICR18 ); +u32 cr3; cr3 =imx7_csi_reg_read (csi,CSI_CSICR3 ); cr3 |=BIT_DMA_REFLASH_RFF ;
Steve Longerbeam
maintainerRe: [PATCH 6/7] media: imx: imx7-media-csi: Remove unneeded register read
Quoted 3 lines · Steve Longerbeam
Hi Laurent,
This patch also looks like it needs a Fixes tag.
Quoted 27 lines · Laurent Pinchart
Quoted 22 lines
The
imx7_csi_dma_reflash()function starts by reading the unrelated registerCSI_CSICR18to then overwrite the read value with a read from registerCSI_CSICR3. This is likely due to a bad copy&paste, and is not needed. Remove the extraneous read from registerCSI_CSICR18.Signed-off-by Laurent Pinchart <[email protected]>---
drivers/staging/media/imx/imx7-media-csi.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/media/imx/imx7-media-csi.c +1
-1@@ -292,7 +292,7 @@ static void imx7_csi_hw_disable(struct imx7_csi *csi) static void imx7_csi_dma_reflash(struct imx7_csi *csi) { - u32 cr3 = imx7_csi_reg_read(csi, CSI_CSICR18); + u32 cr3; cr3 = imx7_csi_reg_read(csi, CSI_CSICR3); cr3 |= BIT_DMA_REFLASH_RFF;
PATCH 7/7 media: imx: imx7-media-csi: Fix video field handling
In reply to Laurent PinchartCommit 4791bd7d6adc ("media: imx: Try colorimetry at both sink and source pads") reworked the way that formats are set on the sink pad of the CSI subdevice, and accidentally removed video field handling. Restore it by defaulting to V4L2_FIELD_NONE if the field value isn't supported, with the only two supported value being V4L2_FIELD_NONE and V4L2_FIELD_ALTERNATE.
--- drivers/staging/media/imx/imx7-media-csi.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/staging/media/imx/imx7-media-csi.c +4 -0
@@ -1017,6 +1017,7 @@ static int imx7_csi_try_fmt(struct imx7_csi *csi, sdformat->format.width = in_fmt->width; sdformat->format.height = in_fmt->height; sdformat->format.code = in_fmt->code; + sdformat->format.field = in_fmt->field; *cc = in_cc; sdformat->format.colorspace = in_fmt->colorspace;
@@ -1031,6 +1032,9 @@ static int imx7_csi_try_fmt(struct imx7_csi *csi, false); sdformat->format.code = (*cc)->codes[0 ]; } + +if (sdformat->format.field !=V4L2_FIELD_INTERLACED ) + sdformat->format.field =V4L2_FIELD_NONE ;break ;default :return -EINVAL ;
Signature · 3 lines
Regards, Laurent Pinchart
Steve Longerbeam
maintainerRe: [PATCH 7/7] media: imx: imx7-media-csi: Fix video field handling
Hi Laurent,
Quoted 6 lines · Laurent Pinchart
Commit
4791bd7d6adc("media: imx: Try colorimetry at both sink and source pads") reworked the way that formats are set on the sink pad of the CSI subdevice, and accidentally removed video field handling. Restore it by defaulting toV4L2_FIELD_NONEif the field value isn't supported, with the only two supported value beingV4L2_FIELD_NONEandV4L2_FIELD_ALTERNATE.
I think you mean the only two supported field values being V4L2_FIELD_NONE and V4L2_FIELD_INTERLACED.
For this driver to support ALTERNATE, it would have to detect the captured field type and place that type in the returned vb2 buf->field, which it is not doing.
Steve
Quoted 29 lines
Fixes 4791bd7d6adc ("media: imx: Try colorimetry at both sink and source pads")Signed-off-by Laurent Pinchart <[email protected]>--- drivers/staging/media/imx/imx7-media-csi.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/staging/media/imx/imx7-media-csi.c +4
-0@@ -1017,6 +1017,7 @@ static int imx7_csi_try_fmt(struct imx7_csi *csi, sdformat->format.width = in_fmt->width; sdformat->format.height = in_fmt->height; sdformat->format.code = in_fmt->code; + sdformat->format.field = in_fmt->field; *cc = in_cc; sdformat->format.colorspace = in_fmt->colorspace;@@ -1031,6 +1032,9 @@ static int imx7_csi_try_fmt(struct imx7_csi *csi, false); sdformat->format.code = (*cc)->codes[0 ]; } + +if (sdformat->format.field !=V4L2_FIELD_INTERLACED ) + sdformat->format.field =V4L2_FIELD_NONE ;break ;default :return -EINVAL ;
Steve Longerbeam
maintainerRe: [PATCH 7/7] media: imx: imx7-media-csi: Fix video field handling
Quoted 10 lines · Steve Longerbeam
Hi Laurent,
Quoted 6 lines · Laurent Pinchart
Commit
4791bd7d6adc("media: imx: Try colorimetry at both sink and source pads") reworked the way that formats are set on the sink pad of the CSI subdevice, and accidentally removed video field handling. Restore it by defaulting toV4L2_FIELD_NONEif the field value isn't supported, with the only two supported value beingV4L2_FIELD_NONEandV4L2_FIELD_ALTERNATE.
Quoted 3 lines
I think you mean the only two supported field values being
V4L2_FIELD_NONEandV4L2_FIELD_INTERLACED.For this driver to support ALTERNATE, it would have to detect the captured field type and place that type in the returned vb2
buf->field, which it is not doing.
So the code change is correct, only the commit description is wrong.
Steve
Quoted 32 lines
Quoted 31 lines
Fixes 4791bd7d6adc ("media: imx: Try colorimetry at both sink and source pads")Signed-off-by Laurent Pinchart <[email protected]>---
drivers/staging/media/imx/imx7-media-csi.c| 4 ++++1 file changed, 4 insertions(+)drivers/staging/media/imx/imx7-media-csi.c +4
-0@@ -1017,6 +1017,7 @@ static int imx7_csi_try_fmt(struct imx7_csi *csi, sdformat->format.width = in_fmt->width; sdformat->format.height = in_fmt->height; sdformat->format.code = in_fmt->code; + sdformat->format.field = in_fmt->field; *cc = in_cc; sdformat->format.colorspace = in_fmt->colorspace;@@ -1031,6 +1032,9 @@ static int imx7_csi_try_fmt(struct imx7_csi *csi, false); sdformat->format.code = (*cc)->codes[0]; } + + if (sdformat->format.field != V4L2_FIELD_INTERLACED) + sdformat->format.field = V4L2_FIELD_NONE; break;default:
return-EINVAL;
Re: [PATCH 7/7] media: imx: imx7-media-csi: Fix video field handling
In reply to Steve LongerbeamHi Steve,
Quoted 8 lines · Steve Longerbeam
Quoted 6 lines · Laurent Pinchart
Commit
4791bd7d6adc("media: imx: Try colorimetry at both sink and source pads") reworked the way that formats are set on the sink pad of the CSI subdevice, and accidentally removed video field handling. Restore it by defaulting toV4L2_FIELD_NONEif the field value isn't supported, with the only two supported value beingV4L2_FIELD_NONEandV4L2_FIELD_ALTERNATE.
Quoted 6 lines
I think you mean the only two supported field values being
V4L2_FIELD_NONEandV4L2_FIELD_INTERLACED.For this driver to support ALTERNATE, it would have to detect the captured field type and place that type in the returned vb2
buf->field, which it is not doing.
Yes, that's what I meant, sorry. I'll fix the commit message.
Quoted 29 lines
Quoted 28 lines
Fixes 4791bd7d6adc ("media: imx: Try colorimetry at both sink and source pads")Signed-off-by Laurent Pinchart <[email protected]>--- drivers/staging/media/imx/imx7-media-csi.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/staging/media/imx/imx7-media-csi.c +4
-0@@ -1017,6 +1017,7 @@ static int imx7_csi_try_fmt(struct imx7_csi *csi, sdformat->format.width = in_fmt->width; sdformat->format.height = in_fmt->height; sdformat->format.code = in_fmt->code; + sdformat->format.field = in_fmt->field; *cc = in_cc; sdformat->format.colorspace = in_fmt->colorspace;@@ -1031,6 +1032,9 @@ static int imx7_csi_try_fmt(struct imx7_csi *csi, false); sdformat->format.code = (*cc)->codes[0 ]; } + +if (sdformat->format.field !=V4L2_FIELD_INTERLACED ) + sdformat->format.field =V4L2_FIELD_NONE ;break ;default :return -EINVAL ;
Signature · 3 lines
Regards, Laurent Pinchart
Steve Longerbeam
maintainerRe: [PATCH 7/7] media: imx: imx7-media-csi: Fix video field handling
In reply to Laurent PinchartHi Laurent,
Quoted 3 lines · Laurent Pinchart
Commit
4791bd7d6adc("media: imx: Try colorimetry at both sink and source pads") reworked the way that formats are set on the sink pad of the CSI subdevice, and accidentally removed video field handling.
Well, let me restate the problem. This driver never did have correct field handling (as you demonstrate in this patch, the driver never set/propagated the field type to its source pad). So it's not accurate to say the patch is a fix. A better description is that it adds rudimentary field handling.
Steve
Quoted 32 lines
Restore it by defaulting to
V4L2_FIELD_NONEif the field value isn't supported, with the only two supported value beingV4L2_FIELD_NONEandV4L2_FIELD_ALTERNATE.Fixes 4791bd7d6adc ("media: imx: Try colorimetry at both sink and source pads")Signed-off-by Laurent Pinchart <[email protected]>--- drivers/staging/media/imx/imx7-media-csi.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/staging/media/imx/imx7-media-csi.c +4
-0@@ -1017,6 +1017,7 @@ static int imx7_csi_try_fmt(struct imx7_csi *csi, sdformat->format.width = in_fmt->width; sdformat->format.height = in_fmt->height; sdformat->format.code = in_fmt->code; + sdformat->format.field = in_fmt->field; *cc = in_cc; sdformat->format.colorspace = in_fmt->colorspace;@@ -1031,6 +1032,9 @@ static int imx7_csi_try_fmt(struct imx7_csi *csi, false); sdformat->format.code = (*cc)->codes[0 ]; } + +if (sdformat->format.field !=V4L2_FIELD_INTERLACED ) + sdformat->format.field =V4L2_FIELD_NONE ;break ;default :return -EINVAL ;
Re: [PATCH 7/7] media: imx: imx7-media-csi: Fix video field handling
Hi Steve,
Quoted 10 lines · Steve Longerbeam
Quoted 3 lines · Laurent Pinchart
Commit
4791bd7d6adc("media: imx: Try colorimetry at both sink and source pads") reworked the way that formats are set on the sink pad of the CSI subdevice, and accidentally removed video field handling.Well, let me restate the problem. This driver never did have correct field handling (as you demonstrate in this patch, the driver never set/propagated the field type to its source pad). So it's not accurate to say the patch is a fix. A better description is that it adds rudimentary field handling.
Didn't it ? The above commit removed a call to imx_media_fill_default_mbus_fields() from imx7_csi_try_fmt(), and that function had rudimentary field handling. The Fixes: tag isn't there to blame you :-)
Quoted 32 lines
Quoted 32 lines
Restore it by defaulting to
V4L2_FIELD_NONEif the field value isn't supported, with the only two supported value beingV4L2_FIELD_NONEandV4L2_FIELD_ALTERNATE.Fixes 4791bd7d6adc ("media: imx: Try colorimetry at both sink and source pads")Signed-off-by Laurent Pinchart <[email protected]>--- drivers/staging/media/imx/imx7-media-csi.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/staging/media/imx/imx7-media-csi.c +4
-0@@ -1017,6 +1017,7 @@ static int imx7_csi_try_fmt(struct imx7_csi *csi, sdformat->format.width = in_fmt->width; sdformat->format.height = in_fmt->height; sdformat->format.code = in_fmt->code; + sdformat->format.field = in_fmt->field; *cc = in_cc; sdformat->format.colorspace = in_fmt->colorspace;@@ -1031,6 +1032,9 @@ static int imx7_csi_try_fmt(struct imx7_csi *csi, false); sdformat->format.code = (*cc)->codes[0 ]; } + +if (sdformat->format.field !=V4L2_FIELD_INTERLACED ) + sdformat->format.field =V4L2_FIELD_NONE ;break ;default :return -EINVAL ;
Signature · 3 lines
Regards, Laurent Pinchart
Steve Longerbeam
maintainerRe: [PATCH 7/7] media: imx: imx7-media-csi: Fix video field handling
Hi Laurent,
Quoted 12 lines · Laurent Pinchart
Hi Steve,
Quoted 9 lines · Steve Longerbeam
Quoted 3 lines · Laurent Pinchart
Commit
4791bd7d6adc("media: imx: Try colorimetry at both sink and source pads") reworked the way that formats are set on the sink pad of the CSI subdevice, and accidentally removed video field handling.Well, let me restate the problem. This driver never did have correct field handling (as you demonstrate in this patch, the driver never set/propagated the field type to its source pad). So it's not accurate to say the patch is a fix. A better description is that it adds rudimentary field handling.
Quoted 4 lines
Didn't it ? The above commit removed a call to
imx_media_fill_default_mbus_fields()fromimx7_csi_try_fmt(), and that function had rudimentary field handling. The Fixes: tag isn't there to blame you :-)
Sorry, you're right, 4791bd7d6adc should have placed some sane field value back at sink pad in imx7_csi_try_fmt(). But the problem is that at the time, I didn't know what a sane field value for imx7 would be (your patch resolved that question, by stating only NONE and INTERLACED are supported). But I must stand by my statement that field was never propagated to source. I guess I was waiting for someone to implement basic field handling, instead of possibly doing the wrong thing myself. I should have clarified at the time that there needed to be basic field handling added.
Steve
Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
Restore it by defaulting to
V4L2_FIELD_NONEif the field value isn't supported, with the only two supported value beingV4L2_FIELD_NONEandV4L2_FIELD_ALTERNATE.Fixes 4791bd7d6adc ("media: imx: Try colorimetry at both sink and source pads")Signed-off-by Laurent Pinchart <[email protected]>--- drivers/staging/media/imx/imx7-media-csi.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/staging/media/imx/imx7-media-csi.c +4
-0@@ -1017,6 +1017,7 @@ static int imx7_csi_try_fmt(struct imx7_csi *csi, sdformat->format.width = in_fmt->width; sdformat->format.height = in_fmt->height; sdformat->format.code = in_fmt->code; + sdformat->format.field = in_fmt->field; *cc = in_cc; sdformat->format.colorspace = in_fmt->colorspace;@@ -1031,6 +1032,9 @@ static int imx7_csi_try_fmt(struct imx7_csi *csi, false); sdformat->format.code = (*cc)->codes[0 ]; } + +if (sdformat->format.field !=V4L2_FIELD_INTERLACED ) + sdformat->format.field =V4L2_FIELD_NONE ;break ;default :return -EINVAL ;
Re: [PATCH 7/7] media: imx: imx7-media-csi: Fix video field handling
Hi Steve,
Quoted 18 lines · Steve Longerbeam
Quoted 12 lines · Laurent Pinchart
Quoted 10 lines · Steve Longerbeam
Quoted 3 lines · Laurent Pinchart
Commit
4791bd7d6adc("media: imx: Try colorimetry at both sink and source pads") reworked the way that formats are set on the sink pad of the CSI subdevice, and accidentally removed video field handling.Well, let me restate the problem. This driver never did have correct field handling (as you demonstrate in this patch, the driver never set/propagated the field type to its source pad). So it's not accurate to say the patch is a fix. A better description is that it adds rudimentary field handling.
Quoted 4 lines
Didn't it ? The above commit removed a call to
imx_media_fill_default_mbus_fields()fromimx7_csi_try_fmt(), and that function had rudimentary field handling. The Fixes: tag isn't there to blame you :-)
Quoted 9 lines
Sorry, you're right,
4791bd7d6adcshould have placed some sane field value back at sink pad inimx7_csi_try_fmt(). But the problem is that at the time, I didn't know what a sane field value for imx7 would be (your patch resolved that question, by stating only NONE and INTERLACED are supported). But I must stand by my statement that field was never propagated to source. I guess I was waiting for someone to implement basic field handling, instead of possibly doing the wrong thing myself. I should have clarified at the time that there needed to be basic field handling added.
We all know there's a bit of work needed on this driver :-) Hence the staging status. I'll post a v2 of this series, and additional patches will follow. I will likely not address interlaced support though, as I have no system to test that on, but you can expect improvements for the rest of the code, especially the parts used with CSI-2 sensors.
Quoted 32 lines
Quoted 32 lines
Quoted 32 lines
Quoted 32 lines
Restore it by defaulting to
V4L2_FIELD_NONEif the field value isn't supported, with the only two supported value beingV4L2_FIELD_NONEandV4L2_FIELD_ALTERNATE.Fixes 4791bd7d6adc ("media: imx: Try colorimetry at both sink and source pads")Signed-off-by Laurent Pinchart <[email protected]>--- drivers/staging/media/imx/imx7-media-csi.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/staging/media/imx/imx7-media-csi.c +4
-0@@ -1017,6 +1017,7 @@ static int imx7_csi_try_fmt(struct imx7_csi *csi, sdformat->format.width = in_fmt->width; sdformat->format.height = in_fmt->height; sdformat->format.code = in_fmt->code; + sdformat->format.field = in_fmt->field; *cc = in_cc; sdformat->format.colorspace = in_fmt->colorspace;@@ -1031,6 +1032,9 @@ static int imx7_csi_try_fmt(struct imx7_csi *csi, false); sdformat->format.code = (*cc)->codes[0 ]; } + +if (sdformat->format.field !=V4L2_FIELD_INTERLACED ) + sdformat->format.field =V4L2_FIELD_NONE ;break ;default :return -EINVAL ;
Signature · 3 lines
Regards, Laurent Pinchart
Re: [PATCH 7/7] media: imx: imx7-media-csi: Fix video field handling
In reply to Steve LongerbeamHi Steve and Rui,
I've spent more time on the i.MX7 support in the i.MX media staging driver today, and I've reached a point where I'm not comfortable moving forward without your ack.
I found format handling to be very broken, the driver enumerates formats that are not supported by the device, and doesn't properly handle the supported formats. While trying to fix that, I found out that the common i.MX6 and i.MX7 helpers (imx-media-capture.c and imx-media-utils.c) get in the way, as i.MX6 and i.MX7 format support are very entangled. I would like to split the two in order to clean up the i.MX7 code, which would also give an opportunity to later clean the i.MX6 code if desired.
Before moving in that time-consuming direction, I want to make sure this will be accepted, as I don't want to spend days of work for nothing. If you want to discuss this in real time, I'm available in the #v4l channel on Freenode (nickname pinchartl).
Signature · 3 lines
Regards, Laurent Pinchart
Steve Longerbeam
maintainerRe: [PATCH 7/7] media: imx: imx7-media-csi: Fix video field handling
Hi Laurent,
Quoted 14 lines · Laurent Pinchart
Hi Steve and Rui,
I've spent more time on the i.MX7 support in the i.MX media staging driver today, and I've reached a point where I'm not comfortable moving forward without your ack.
I found format handling to be very broken, the driver enumerates formats that are not supported by the device, and doesn't properly handle the supported formats. While trying to fix that, I found out that the common i.MX6 and i.MX7 helpers (
imx-media-capture.candimx-media-utils.c) get in the way, as i.MX6 and i.MX7 format support are very entangled. I would like to split the two in order to clean up the i.MX7 code, which would also give an opportunity to later clean the i.MX6 code if desired.
Quoted 4 lines
Before moving in that time-consuming direction, I want to make sure this will be accepted, as I don't want to spend days of work for nothing. If you want to discuss this in real time, I'm available in the #v4l channel on Freenode (nickname pinchartl).
I'm on vacation returning March 16, maybe we can chat on irc when I return. I'm in California (PDT).
Steve
Re: [PATCH 7/7] media: imx: imx7-media-csi: Fix video field handling
Hi Steve,
Quoted 15 lines · Steve Longerbeam
Quoted 14 lines · Laurent Pinchart
Hi Steve and Rui,
I've spent more time on the i.MX7 support in the i.MX media staging driver today, and I've reached a point where I'm not comfortable moving forward without your ack.
I found format handling to be very broken, the driver enumerates formats that are not supported by the device, and doesn't properly handle the supported formats. While trying to fix that, I found out that the common i.MX6 and i.MX7 helpers (
imx-media-capture.candimx-media-utils.c) get in the way, as i.MX6 and i.MX7 format support are very entangled. I would like to split the two in order to clean up the i.MX7 code, which would also give an opportunity to later clean the i.MX6 code if desired.
Quoted 7 lines
Quoted 4 lines
Before moving in that time-consuming direction, I want to make sure this will be accepted, as I don't want to spend days of work for nothing. If you want to discuss this in real time, I'm available in the #v4l channel on Freenode (nickname pinchartl).
I'm on vacation returning March 16, maybe we can chat on irc when I return. I'm in California (PDT).
Sure. Enjoy your vacation :-)
In the meantime, I've moved forward with development without duplicating the whole imx-media-capture.c file, and I believe I'm close to reaching a working result. Some parts were not pretty (it's a staging driver after all), and if you agree with my approach, I think the end result will be much cleaner. Let's talk about it when you come back.
Signature · 3 lines
Regards, Laurent Pinchart
Hi Laurent,
Many thanks for this patches.
Quoted 11 lines · Laurent Pinchart
Hello,
This patch series contains miscellaneous fixes I developed while trying to capture from a CSI-2 sensor on the i.MX7.
Patches 1/7, 2/7 and 6/7 are small fixes or enhancements, please see individual commit messages. Patches 3/7, 4/7 and 5/7 add support for 10- and 12-bit greyscale formats (both on the i.MX7 CSI-2 receiver side and the CSI side). Patch 7/7 finally fixes a recent issue with video field handling.
Quoted 10 lines
Laurent Pinchart (7):
media: imx:imx7_mipi_csis: Power off the source when stopping
streaming
media: imx:imx7_mipi_csis: Print theRESOL_CH0register
media: imx:imx7_mipi_csis: Add greyscale formats support
media: imx: imx6-media-csi: Replace Y16 with Y10 and Y12
media: imx: imx7-media-csi: Add Y10 and Y12 formats support
media: imx: imx7-media-csi: Remove unneeded register read
media: imx: imx7-media-csi: Fix video field handling
For the all series, if the remarks from Steve and Fabio regarding the fixes tags and changelog in 7/7 get fixed:
---
Cheers,
Rui
Quoted 6 lines
drivers/staging/media/imx/imx-media-csi.c | 3 ++- drivers/staging/media/imx/imx-media-utils.c | 13 ++++++++----- drivers/staging/media/imx/imx7-media-csi.c | 14 +++++++++++++- drivers/staging/media/imx/imx7-mipi-csis.c | 15 ++++++++++++++- 4 files changed, 37 insertions(+), 8 deletions(-)