media: zoran: move overlay_settings out of zoran_fh
authorCorentin Labbe <clabbe@baylibre.com>
Fri, 25 Sep 2020 18:30:29 +0000 (20:30 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Thu, 1 Oct 2020 07:39:22 +0000 (09:39 +0200)
We need to get rid of zoran_fh, so move the overlay_settings directly in the
zoran structure.

Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/staging/media/zoran/zoran.h
drivers/staging/media/zoran/zoran_device.c
drivers/staging/media/zoran/zoran_driver.c

index 7e6e035..e9fef23 100644 (file)
@@ -211,7 +211,6 @@ struct zoran_fh {
 
        enum zoran_map_mode map_mode;           /* Flag which bufferset will map by next mmap() */
 
-       struct zoran_overlay_settings overlay_settings;
        u32 *overlay_mask;                      /* overlay mask */
        enum zoran_lock_activity overlay_active;/* feature currently in use? */
 
index 672b8d9..139cfc6 100644 (file)
@@ -508,10 +508,10 @@ void write_overlay_mask(struct zoran_fh *fh, struct v4l2_clip *vp, int count)
                        height += y;
                        y = 0;
                }
-               if (x + width > fh->overlay_settings.width)
-                       width = fh->overlay_settings.width - x;
-               if (y + height > fh->overlay_settings.height)
-                       height = fh->overlay_settings.height - y;
+               if (x + width > zr->overlay_settings.width)
+                       width = zr->overlay_settings.width - x;
+               if (y + height > zr->overlay_settings.height)
+                       height = zr->overlay_settings.height - y;
 
                /* ignore degenerate clips */
                if (height <= 0)
index 27dcf89..3a59aa6 100644 (file)
@@ -744,9 +744,7 @@ static void zoran_open_init_session(struct zoran_fh *fh)
        map_mode_raw(fh);
 
        /* take over the card's current settings */
-       fh->overlay_settings = zr->overlay_settings;
-       fh->overlay_settings.is_set = 0;
-       fh->overlay_settings.format = zr->overlay_settings.format;
+       zr->overlay_settings.is_set = 0;
        fh->overlay_active = ZORAN_FREE;
 
        /* buffers */
@@ -1005,7 +1003,7 @@ static int setup_window(struct zoran_fh *fh, int x, int y, int width, int height
                return -EINVAL;
        }
 
-       if (!fh->overlay_settings.format) {
+       if (!zr->overlay_settings.format) {
                pci_err(zr->pci_dev, "%s - no overlay format set\n", __func__);
                return -EINVAL;
        }
@@ -1043,11 +1041,11 @@ static int setup_window(struct zoran_fh *fh, int x, int y, int width, int height
                return -EINVAL;
        }
 
-       fh->overlay_settings.x = x;
-       fh->overlay_settings.y = y;
-       fh->overlay_settings.width = width;
-       fh->overlay_settings.height = height;
-       fh->overlay_settings.clipcount = clipcount;
+       zr->overlay_settings.x = x;
+       zr->overlay_settings.y = y;
+       zr->overlay_settings.width = width;
+       zr->overlay_settings.height = height;
+       zr->overlay_settings.clipcount = clipcount;
 
        /*
         * If an overlay is running, we have to switch it off
@@ -1069,7 +1067,7 @@ static int setup_window(struct zoran_fh *fh, int x, int y, int width, int height
         */
        if (bitmap) {
                /* fake value - it just means we want clips */
-               fh->overlay_settings.clipcount = 1;
+               zr->overlay_settings.clipcount = 1;
 
                if (copy_from_user(fh->overlay_mask, bitmap,
                                   (width * height + 7) / 8)) {
@@ -1091,10 +1089,7 @@ static int setup_window(struct zoran_fh *fh, int x, int y, int width, int height
                vfree(vcp);
        }
 
-       fh->overlay_settings.is_set = 1;
-       if (fh->overlay_active != ZORAN_FREE &&
-           zr->overlay_active != ZORAN_FREE)
-               zr->overlay_settings = fh->overlay_settings;
+       zr->overlay_settings.is_set = 1;
 
        if (on)
                zr36057_overlay(zr, 1);
@@ -1135,18 +1130,17 @@ static int setup_overlay(struct zoran_fh *fh, int on)
                        zr36057_overlay(zr, 0);
                zr->overlay_mask = NULL;
        } else {
-               if (!zr->vbuf_base || !fh->overlay_settings.is_set) {
+               if (!zr->vbuf_base || !zr->overlay_settings.is_set) {
                        pci_err(zr->pci_dev, "%s - buffer or window not set\n", __func__);
                        return -EINVAL;
                }
-               if (!fh->overlay_settings.format) {
+               if (!zr->overlay_settings.format) {
                        pci_err(zr->pci_dev, "%s - no overlay format set\n", __func__);
                        return -EINVAL;
                }
                zr->overlay_active = fh->overlay_active = ZORAN_LOCKED;
                zr->v4l_overlay_active = 1;
                zr->overlay_mask = fh->overlay_mask;
-               zr->overlay_settings = fh->overlay_settings;
                if (!zr->v4l_memgrab_active)
                        zr36057_overlay(zr, 1);
                /*
@@ -1433,11 +1427,11 @@ static int zoran_g_fmt_vid_overlay(struct file *file, void *__fh,
        struct zoran_fh *fh = __fh;
        struct zoran *zr = fh->zr;
 
-       fmt->fmt.win.w.left = fh->overlay_settings.x;
-       fmt->fmt.win.w.top = fh->overlay_settings.y;
-       fmt->fmt.win.w.width = fh->overlay_settings.width;
-       fmt->fmt.win.w.height = fh->overlay_settings.height;
-       if (fh->overlay_settings.width * 2 > BUZ_MAX_HEIGHT)
+       fmt->fmt.win.w.left = zr->overlay_settings.x;
+       fmt->fmt.win.w.top = zr->overlay_settings.y;
+       fmt->fmt.win.w.width = zr->overlay_settings.width;
+       fmt->fmt.win.w.height = zr->overlay_settings.height;
+       if (zr->overlay_settings.width * 2 > BUZ_MAX_HEIGHT)
                fmt->fmt.win.field = V4L2_FIELD_INTERLACED;
        else
                fmt->fmt.win.field = V4L2_FIELD_TOP;
@@ -1710,7 +1704,7 @@ static int zoran_g_fbuf(struct file *file, void *__fh,
        fb->fmt.width = zr->vbuf_width;
        fb->fmt.height = zr->vbuf_height;
        if (zr->overlay_settings.format)
-               fb->fmt.pixelformat = fh->overlay_settings.format->fourcc;
+               fb->fmt.pixelformat = zr->overlay_settings.format->fourcc;
        fb->fmt.bytesperline = zr->vbuf_bytesperline;
        fb->fmt.colorspace = V4L2_COLORSPACE_SRGB;
        fb->fmt.field = V4L2_FIELD_INTERLACED;