gpu: ipu-v3: Add chroma plane offset overrides to ipu_cpmem_set_image()
authorSteve Longerbeam <slongerbeam@gmail.com>
Sat, 6 Oct 2018 21:45:48 +0000 (14:45 -0700)
committerPhilipp Zabel <p.zabel@pengutronix.de>
Mon, 5 Nov 2018 13:40:06 +0000 (14:40 +0100)
Allow the caller of ipu_cpmem_set_image() to override the latters
calculation of the chroma plane offsets, by adding override U/V
plane offsets to 'struct ipu_image'.

Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>
Tested-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
drivers/gpu/ipu-v3/ipu-cpmem.c
drivers/gpu/ipu-v3/ipu-image-convert.c
include/video/imx-ipu-v3.h

index 7e65954..163fadb 100644 (file)
@@ -745,48 +745,56 @@ int ipu_cpmem_set_image(struct ipuv3_channel *ch, struct ipu_image *image)
        switch (pix->pixelformat) {
        case V4L2_PIX_FMT_YUV420:
                offset = Y_OFFSET(pix, image->rect.left, image->rect.top);
-               u_offset = U_OFFSET(pix, image->rect.left,
-                                   image->rect.top) - offset;
-               v_offset = V_OFFSET(pix, image->rect.left,
-                                   image->rect.top) - offset;
+               u_offset = image->u_offset ?
+                       image->u_offset : U_OFFSET(pix, image->rect.left,
+                                                  image->rect.top) - offset;
+               v_offset = image->v_offset ?
+                       image->v_offset : V_OFFSET(pix, image->rect.left,
+                                                  image->rect.top) - offset;
 
                ipu_cpmem_set_yuv_planar_full(ch, pix->bytesperline / 2,
                                              u_offset, v_offset);
                break;
        case V4L2_PIX_FMT_YVU420:
                offset = Y_OFFSET(pix, image->rect.left, image->rect.top);
-               u_offset = U_OFFSET(pix, image->rect.left,
-                                   image->rect.top) - offset;
-               v_offset = V_OFFSET(pix, image->rect.left,
-                                   image->rect.top) - offset;
+               u_offset = image->u_offset ?
+                       image->u_offset : V_OFFSET(pix, image->rect.left,
+                                                  image->rect.top) - offset;
+               v_offset = image->v_offset ?
+                       image->v_offset : U_OFFSET(pix, image->rect.left,
+                                                  image->rect.top) - offset;
 
                ipu_cpmem_set_yuv_planar_full(ch, pix->bytesperline / 2,
-                                             v_offset, u_offset);
+                                             u_offset, v_offset);
                break;
        case V4L2_PIX_FMT_YUV422P:
                offset = Y_OFFSET(pix, image->rect.left, image->rect.top);
-               u_offset = U2_OFFSET(pix, image->rect.left,
-                                    image->rect.top) - offset;
-               v_offset = V2_OFFSET(pix, image->rect.left,
-                                    image->rect.top) - offset;
+               u_offset = image->u_offset ?
+                       image->u_offset : U2_OFFSET(pix, image->rect.left,
+                                                   image->rect.top) - offset;
+               v_offset = image->v_offset ?
+                       image->v_offset : V2_OFFSET(pix, image->rect.left,
+                                                   image->rect.top) - offset;
 
                ipu_cpmem_set_yuv_planar_full(ch, pix->bytesperline / 2,
                                              u_offset, v_offset);
                break;
        case V4L2_PIX_FMT_NV12:
                offset = Y_OFFSET(pix, image->rect.left, image->rect.top);
-               u_offset = UV_OFFSET(pix, image->rect.left,
-                                    image->rect.top) - offset;
-               v_offset = 0;
+               u_offset = image->u_offset ?
+                       image->u_offset : UV_OFFSET(pix, image->rect.left,
+                                                   image->rect.top) - offset;
+               v_offset = image->v_offset ? image->v_offset : 0;
 
                ipu_cpmem_set_yuv_planar_full(ch, pix->bytesperline,
                                              u_offset, v_offset);
                break;
        case V4L2_PIX_FMT_NV16:
                offset = Y_OFFSET(pix, image->rect.left, image->rect.top);
-               u_offset = UV2_OFFSET(pix, image->rect.left,
-                                     image->rect.top) - offset;
-               v_offset = 0;
+               u_offset = image->u_offset ?
+                       image->u_offset : UV2_OFFSET(pix, image->rect.left,
+                                                    image->rect.top) - offset;
+               v_offset = image->v_offset ? image->v_offset : 0;
 
                ipu_cpmem_set_yuv_planar_full(ch, pix->bytesperline,
                                              u_offset, v_offset);
index f408196..41fb62b 100644 (file)
@@ -655,12 +655,12 @@ static void init_idmac_channel(struct ipu_image_convert_ctx *ctx,
        tile_image.pix.pixelformat =  image->fmt->fourcc;
        tile_image.phys0 = addr0;
        tile_image.phys1 = addr1;
-       ipu_cpmem_set_image(channel, &tile_image);
+       if (image->fmt->planar && !rot_swap_width_height) {
+               tile_image.u_offset = image->tile[tile_idx[0]].u_off;
+               tile_image.v_offset = image->tile[tile_idx[0]].v_off;
+       }
 
-       if (image->fmt->planar && !rot_swap_width_height)
-               ipu_cpmem_set_uv_offset(channel,
-                                       image->tile[tile_idx[0]].u_off,
-                                       image->tile[tile_idx[0]].v_off);
+       ipu_cpmem_set_image(channel, &tile_image);
 
        if (rot_mode)
                ipu_cpmem_set_rotation(channel, rot_mode);
index abbad94..8bb163c 100644 (file)
@@ -246,6 +246,9 @@ struct ipu_image {
        struct v4l2_rect rect;
        dma_addr_t phys0;
        dma_addr_t phys1;
+       /* chroma plane offset overrides */
+       u32 u_offset;
+       u32 v_offset;
 };
 
 void ipu_cpmem_zero(struct ipuv3_channel *ch);