If IDMAC interweaving is enabled in a write channel, the channel must
write the odd chroma rows for 4:2:0 formats. Skipping writing the odd
chroma rows produces corrupted captured 4:2:0 images when interweave
is enabled.

Reported-by: Krzysztof Hałasa <khal...@piap.pl>
Signed-off-by: Steve Longerbeam <steve_longerb...@mentor.com>
---
 drivers/staging/media/imx/imx-ic-prpencvf.c | 9 +++++++--
 drivers/staging/media/imx/imx-media-csi.c   | 8 ++++++--
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c 
b/drivers/staging/media/imx/imx-ic-prpencvf.c
index 894db21..7e1e0c3 100644
--- a/drivers/staging/media/imx/imx-ic-prpencvf.c
+++ b/drivers/staging/media/imx/imx-ic-prpencvf.c
@@ -393,12 +393,17 @@ static int prp_setup_channel(struct prp_priv *priv,
        image.phys0 = addr0;
        image.phys1 = addr1;
 
-       if (channel == priv->out_ch || channel == priv->rot_out_ch) {
+       /*
+        * Skip writing U and V components to odd rows in the output
+        * channels for planar 4:2:0 (but not when enabling IDMAC
+        * interweaving, they are incompatible).
+        */
+       if (!interweave && (channel == priv->out_ch ||
+                           channel == priv->rot_out_ch)) {
                switch (image.pix.pixelformat) {
                case V4L2_PIX_FMT_YUV420:
                case V4L2_PIX_FMT_YVU420:
                case V4L2_PIX_FMT_NV12:
-                       /* Skip writing U and V components to odd rows */
                        ipu_cpmem_skip_odd_chroma_rows(channel);
                        break;
                }
diff --git a/drivers/staging/media/imx/imx-media-csi.c 
b/drivers/staging/media/imx/imx-media-csi.c
index 2c77ef9..6a2a47c 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -436,8 +436,12 @@ static int csi_idmac_setup_channel(struct csi_priv *priv)
                              ((image.pix.width & 0xf) ? 8 : 16) : 32) : 64;
                passthrough = is_parallel_16bit_bus(&priv->upstream_ep);
                passthrough_bits = 16;
-               /* Skip writing U and V components to odd rows */
-               ipu_cpmem_skip_odd_chroma_rows(priv->idmac_ch);
+               /*
+                * Skip writing U and V components to odd rows (but not
+                * when enabling IDMAC interweaving, they are incompatible).
+                */
+               if (!interweave)
+                       ipu_cpmem_skip_odd_chroma_rows(priv->idmac_ch);
                break;
        case V4L2_PIX_FMT_YUYV:
        case V4L2_PIX_FMT_UYVY:
-- 
2.7.4

Reply via email to