media: bttv: remove format field from bttv_buffer
authorDeborah Brouwer <deborah.brouwer@collabora.com>
Sat, 15 Jul 2023 02:16:03 +0000 (19:16 -0700)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Mon, 14 Aug 2023 18:27:59 +0000 (20:27 +0200)
Instead of storing the format (video or vbi) in each bttv buffer
separately, just use the global bttv format because the format does not
change per buffer.

Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
drivers/media/pci/bt8xx/bttv-driver.c
drivers/media/pci/bt8xx/bttv-risc.c
drivers/media/pci/bt8xx/bttvp.h

index af295ce3e9f0a401e618601bb7fcd37eafd8b49f..0032e143611195006fadbedda16b81485456267d 100644 (file)
@@ -1553,7 +1553,7 @@ static int bttv_prepare_buffer(struct videobuf_queue *q,struct bttv *btv,
        /* alloc + fill struct bttv_buffer (if changed) */
        if (buf->vb.width != width || buf->vb.height != height ||
            buf->vb.field != field ||
-           buf->tvnorm != norm || buf->fmt != fmt ||
+           buf->tvnorm != norm || btv->fmt != fmt ||
            buf->crop.top != c.rect.top ||
            buf->crop.left != c.rect.left ||
            buf->crop.width != c.rect.width ||
@@ -1562,7 +1562,6 @@ static int bttv_prepare_buffer(struct videobuf_queue *q,struct bttv *btv,
                buf->vb.height = height;
                buf->vb.field  = field;
                buf->tvnorm    = norm;
-               buf->fmt       = fmt;
                buf->crop      = c.rect;
                redo_dma_risc = 1;
        }
index fae8b10de7a992644882264b22d232c9654c6f13..67ea7ed42623922ea74c5c474a67c13030b8de57 100644 (file)
@@ -611,11 +611,11 @@ bttv_buffer_risc(struct bttv *btv, struct bttv_buffer *buf)
 
        dprintk("%d: buffer field: %s  format: 0x%08x  size: %dx%d\n",
                btv->c.nr, v4l2_field_names[buf->vb.field],
-               buf->fmt->fourcc, buf->vb.width, buf->vb.height);
+               btv->fmt->fourcc, buf->vb.width, buf->vb.height);
 
        /* packed pixel modes */
-       if (buf->fmt->flags & FORMAT_FLAGS_PACKED) {
-               int bpl = (buf->fmt->depth >> 3) * buf->vb.width;
+       if (btv->fmt->flags & FORMAT_FLAGS_PACKED) {
+               int bpl = (btv->fmt->depth >> 3) * buf->vb.width;
                int bpf = bpl * (buf->vb.height >> 1);
 
                bttv_calc_geo(btv,&buf->geo,buf->vb.width,buf->vb.height,
@@ -651,22 +651,22 @@ bttv_buffer_risc(struct bttv *btv, struct bttv_buffer *buf)
        }
 
        /* planar modes */
-       if (buf->fmt->flags & FORMAT_FLAGS_PLANAR) {
+       if (btv->fmt->flags & FORMAT_FLAGS_PLANAR) {
                int uoffset, voffset;
                int ypadding, cpadding, lines;
 
                /* calculate chroma offsets */
                uoffset = buf->vb.width * buf->vb.height;
                voffset = buf->vb.width * buf->vb.height;
-               if (buf->fmt->flags & FORMAT_FLAGS_CrCb) {
+               if (btv->fmt->flags & FORMAT_FLAGS_CrCb) {
                        /* Y-Cr-Cb plane order */
-                       uoffset >>= buf->fmt->hshift;
-                       uoffset >>= buf->fmt->vshift;
+                       uoffset >>= btv->fmt->hshift;
+                       uoffset >>= btv->fmt->vshift;
                        uoffset  += voffset;
                } else {
                        /* Y-Cb-Cr plane order */
-                       voffset >>= buf->fmt->hshift;
-                       voffset >>= buf->fmt->vshift;
+                       voffset >>= btv->fmt->hshift;
+                       voffset >>= btv->fmt->vshift;
                        voffset  += uoffset;
                }
 
@@ -677,8 +677,8 @@ bttv_buffer_risc(struct bttv *btv, struct bttv_buffer *buf)
                                      tvnorm,&buf->crop);
                        bttv_risc_planar(btv, &buf->top, dma->sglist,
                                         0,buf->vb.width,0,buf->vb.height,
-                                        uoffset,voffset,buf->fmt->hshift,
-                                        buf->fmt->vshift,0);
+                                        uoffset, voffset, btv->fmt->hshift,
+                                        btv->fmt->vshift, 0);
                        break;
                case V4L2_FIELD_BOTTOM:
                        bttv_calc_geo(btv,&buf->geo,buf->vb.width,
@@ -686,8 +686,8 @@ bttv_buffer_risc(struct bttv *btv, struct bttv_buffer *buf)
                                      tvnorm,&buf->crop);
                        bttv_risc_planar(btv, &buf->bottom, dma->sglist,
                                         0,buf->vb.width,0,buf->vb.height,
-                                        uoffset,voffset,buf->fmt->hshift,
-                                        buf->fmt->vshift,0);
+                                        uoffset, voffset, btv->fmt->hshift,
+                                        btv->fmt->vshift, 0);
                        break;
                case V4L2_FIELD_INTERLACED:
                        bttv_calc_geo(btv,&buf->geo,buf->vb.width,
@@ -695,21 +695,21 @@ bttv_buffer_risc(struct bttv *btv, struct bttv_buffer *buf)
                                      tvnorm,&buf->crop);
                        lines    = buf->vb.height >> 1;
                        ypadding = buf->vb.width;
-                       cpadding = buf->vb.width >> buf->fmt->hshift;
+                       cpadding = buf->vb.width >> btv->fmt->hshift;
                        bttv_risc_planar(btv,&buf->top,
                                         dma->sglist,
                                         0,buf->vb.width,ypadding,lines,
                                         uoffset,voffset,
-                                        buf->fmt->hshift,
-                                        buf->fmt->vshift,
+                                        btv->fmt->hshift,
+                                        btv->fmt->vshift,
                                         cpadding);
                        bttv_risc_planar(btv,&buf->bottom,
                                         dma->sglist,
                                         ypadding,buf->vb.width,ypadding,lines,
                                         uoffset+cpadding,
                                         voffset+cpadding,
-                                        buf->fmt->hshift,
-                                        buf->fmt->vshift,
+                                        btv->fmt->hshift,
+                                        btv->fmt->vshift,
                                         cpadding);
                        break;
                case V4L2_FIELD_SEQ_TB:
@@ -718,22 +718,22 @@ bttv_buffer_risc(struct bttv *btv, struct bttv_buffer *buf)
                                      tvnorm,&buf->crop);
                        lines    = buf->vb.height >> 1;
                        ypadding = buf->vb.width;
-                       cpadding = buf->vb.width >> buf->fmt->hshift;
+                       cpadding = buf->vb.width >> btv->fmt->hshift;
                        bttv_risc_planar(btv,&buf->top,
                                         dma->sglist,
                                         0,buf->vb.width,0,lines,
                                         uoffset >> 1,
                                         voffset >> 1,
-                                        buf->fmt->hshift,
-                                        buf->fmt->vshift,
+                                        btv->fmt->hshift,
+                                        btv->fmt->vshift,
                                         0);
                        bttv_risc_planar(btv,&buf->bottom,
                                         dma->sglist,
                                         lines * ypadding,buf->vb.width,0,lines,
                                         lines * ypadding + (uoffset >> 1),
                                         lines * ypadding + (voffset >> 1),
-                                        buf->fmt->hshift,
-                                        buf->fmt->vshift,
+                                        btv->fmt->hshift,
+                                        btv->fmt->vshift,
                                         0);
                        break;
                default:
@@ -742,7 +742,7 @@ bttv_buffer_risc(struct bttv *btv, struct bttv_buffer *buf)
        }
 
        /* raw data */
-       if (buf->fmt->flags & FORMAT_FLAGS_RAW) {
+       if (btv->fmt->flags & FORMAT_FLAGS_RAW) {
                /* build risc code */
                buf->vb.field = V4L2_FIELD_SEQ_TB;
                bttv_calc_geo(btv,&buf->geo,tvnorm->swidth,tvnorm->sheight,
@@ -755,7 +755,7 @@ bttv_buffer_risc(struct bttv *btv, struct bttv_buffer *buf)
        }
 
        /* copy format info */
-       buf->btformat = buf->fmt->btformat;
-       buf->btswap   = buf->fmt->btswap;
+       buf->btformat = btv->fmt->btformat;
+       buf->btswap   = btv->fmt->btswap;
        return 0;
 }
index 48317c5935d19cb50aeadc2b1b4520092f5c99c1..402fe1f1846ef60272fe7a1aadbb246bb14b0389 100644 (file)
@@ -145,7 +145,6 @@ struct bttv_buffer {
        struct videobuf_buffer     vb;
 
        /* bttv specific */
-       const struct bttv_format   *fmt;
        unsigned int               tvnorm;
        int                        btformat;
        int                        btswap;