From: Laurent Pinchart Date: Wed, 3 Feb 2021 03:08:19 +0000 (+0100) Subject: media: imx: imx7-media-csi: Set TWO_8BIT_SENSOR for >= 10-bit formats X-Git-Tag: v5.15-rc1~149^2~19 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a581c87c681c6202403d74e8e816968841afe2f7;p=thirdparty%2Fkernel%2Flinux.git media: imx: imx7-media-csi: Set TWO_8BIT_SENSOR for >= 10-bit formats Sample code from NXP, as well as experiments on i.MX8MM with RAW10 capture with an OV5640 sensor connected over CSI-2, showed that the TWO_8BIT_SENSOR field of the CSICR3 register needs to be set for formats larger than 8 bits. Do so, even if the reference manual doesn't clearly describe the effect of the field. Signed-off-by: Laurent Pinchart Tested-by: Martin Kepplinger Reviewed-by: Rui Miguel Silva Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index 894c4de31790e..8aefcf0e219f3 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -421,6 +421,7 @@ static void imx7_csi_configure(struct imx7_csi *csi) struct v4l2_pix_format *out_pix = &vdev->fmt; int width = out_pix->width; u32 stride = 0; + u32 cr3 = BIT_FRMCNT_RST; u32 cr1, cr18; cr18 = imx7_csi_reg_read(csi, CSI_CSICR18); @@ -464,6 +465,7 @@ static void imx7_csi_configure(struct imx7_csi *csi) case MEDIA_BUS_FMT_SGBRG10_1X10: case MEDIA_BUS_FMT_SGRBG10_1X10: case MEDIA_BUS_FMT_SRGGB10_1X10: + cr3 |= BIT_TWO_8BIT_SENSOR; cr18 |= BIT_MIPI_DATA_FORMAT_RAW10; break; case MEDIA_BUS_FMT_Y12_1X12: @@ -471,6 +473,7 @@ static void imx7_csi_configure(struct imx7_csi *csi) case MEDIA_BUS_FMT_SGBRG12_1X12: case MEDIA_BUS_FMT_SGRBG12_1X12: case MEDIA_BUS_FMT_SRGGB12_1X12: + cr3 |= BIT_TWO_8BIT_SENSOR; cr18 |= BIT_MIPI_DATA_FORMAT_RAW12; break; case MEDIA_BUS_FMT_Y14_1X14: @@ -478,6 +481,7 @@ static void imx7_csi_configure(struct imx7_csi *csi) case MEDIA_BUS_FMT_SGBRG14_1X14: case MEDIA_BUS_FMT_SGRBG14_1X14: case MEDIA_BUS_FMT_SRGGB14_1X14: + cr3 |= BIT_TWO_8BIT_SENSOR; cr18 |= BIT_MIPI_DATA_FORMAT_RAW14; break; /* @@ -510,7 +514,7 @@ static void imx7_csi_configure(struct imx7_csi *csi) imx7_csi_reg_write(csi, cr1, CSI_CSICR1); imx7_csi_reg_write(csi, BIT_DMA_BURST_TYPE_RFF_INCR16, CSI_CSICR2); - imx7_csi_reg_write(csi, BIT_FRMCNT_RST, CSI_CSICR3); + imx7_csi_reg_write(csi, cr3, CSI_CSICR3); imx7_csi_reg_write(csi, cr18, CSI_CSICR18); imx7_csi_reg_write(csi, (width * out_pix->height) >> 2, CSI_CSIRXCNT);