media: bttv: copy vbi_fmt from bttv_fh
authorDeborah Brouwer <deborah.brouwer@collabora.com>
Sat, 15 Jul 2023 02:16:01 +0000 (19:16 -0700)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Mon, 14 Aug 2023 18:27:59 +0000 (20:27 +0200)
In preparation for the vb2 conversion, copy the vbi format from struct
bttv_fh and add it to the main struct bttv. Use vbi format from struct
bttv wherever it will be needed after the vb2 conversion which stops using
separate bttv file handles altogether. To avoid changing more code than
necessary, just leave the vbi format in separate file handles wherever it
will be subsequently removed by vb2.

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-vbi.c
drivers/media/pci/bt8xx/bttvp.h

index 7e7658a7ed40cb98c486b230e8558cd17c6d3593..f9a6f671277fc8bf3bd030a84838fc7e7501e3d9 100644 (file)
@@ -672,12 +672,12 @@ int check_alloc_btres_lock(struct bttv *btv, struct bttv_fh *fh, int bit)
                   Claim scan lines crop[].rect.top to bottom. */
                btv->crop_start = top;
        } else if (bit & VBI_RESOURCES) {
-               __s32 end = fh->vbi_fmt.end;
+               __s32 end = btv->vbi_fmt.end;
 
                if (end > btv->crop_start)
                        goto fail;
 
-               /* Claim scan lines above fh->vbi_fmt.end. */
+               /* Claim scan lines above btv->vbi_fmt.end. */
                btv->vbi_end = end;
        }
 
@@ -3637,6 +3637,8 @@ static int bttv_probe(struct pci_dev *dev, const struct pci_device_id *pci_id)
        btv->width = 320;
        btv->height = 240;
        btv->input = 0;
+       btv->tvnorm = 0; /* Index into bttv_tvnorms[] i.e. PAL. */
+       bttv_vbi_fmt_reset(&btv->vbi_fmt, btv->tvnorm);
 
        v4l2_ctrl_new_std(hdl, &bttv_ctrl_ops,
                        V4L2_CID_BRIGHTNESS, 0, 0xff00, 0x100, 32768);
index 0b05309d1fb71133341d72f3c04390504288959b..4e7fd9a78ace3ce2871168c02bf6930c78a6f478 100644 (file)
@@ -350,6 +350,9 @@ int bttv_s_fmt_vbi_cap(struct file *file, void *f, struct v4l2_format *frt)
        fh->vbi_fmt.fmt    = frt->fmt.vbi;
        fh->vbi_fmt.tvnorm = tvnorm;
        fh->vbi_fmt.end    = end;
+       btv->vbi_fmt.fmt = frt->fmt.vbi;
+       btv->vbi_fmt.tvnorm = tvnorm;
+       btv->vbi_fmt.end = end;
 
        mutex_unlock(&fh->vbi.vb_lock);
 
@@ -364,15 +367,14 @@ int bttv_s_fmt_vbi_cap(struct file *file, void *f, struct v4l2_format *frt)
 
 int bttv_g_fmt_vbi_cap(struct file *file, void *f, struct v4l2_format *frt)
 {
-       struct bttv_fh *fh = f;
        const struct bttv_tvnorm *tvnorm;
        struct bttv *btv = video_drvdata(file);
 
-       frt->fmt.vbi = fh->vbi_fmt.fmt;
+       frt->fmt.vbi = btv->vbi_fmt.fmt;
 
        tvnorm = &bttv_tvnorms[btv->tvnorm];
 
-       if (tvnorm != fh->vbi_fmt.tvnorm) {
+       if (tvnorm != btv->vbi_fmt.tvnorm) {
                __s32 max_end;
                unsigned int i;
 
@@ -388,9 +390,8 @@ int bttv_g_fmt_vbi_cap(struct file *file, void *f, struct v4l2_format *frt)
                for (i = 0; i < 2; ++i) {
                        __s32 new_start;
 
-                       new_start = frt->fmt.vbi.start[i]
-                               + tvnorm->vbistart[i]
-                               - fh->vbi_fmt.tvnorm->vbistart[i];
+                       new_start = frt->fmt.vbi.start[i] + tvnorm->vbistart[i]
+                               - btv->vbi_fmt.tvnorm->vbistart[i];
 
                        frt->fmt.vbi.start[i] = min(new_start, max_end - 1);
                        frt->fmt.vbi.count[i] =
index 7f02dd5866d78c97820a03dd5fda998a1a5ebf45..a36817dfaaec354c647cc952a722075ea82eee7f 100644 (file)
@@ -452,6 +452,7 @@ struct bttv {
        const struct bttv_format *fmt;
        int width;
        int height;
+       struct bttv_vbi_fmt vbi_fmt;
 
        /* used to make dvb-bt8xx autoloadable */
        struct work_struct request_module_wk;