Skip to content

Commit 79bbd35

Browse files
deborahbrouwermchehab
authored andcommitted
media: bttv: copy vid fmt/width/height from fh
In preparation for the vb2 conversion, copy the video format, width and height fields from struct bttv_fh and add them to the main struct bttv. Use these fields from struct bttv wherever they 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 video format, width and height fields in separate file handles wherever the code will be subsequently removed by vb2. Signed-off-by: Deborah Brouwer <[email protected]> Signed-off-by: Hans Verkuil <[email protected]>
1 parent 45b6f5b commit 79bbd35

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

drivers/media/pci/bt8xx/bttv-driver.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2066,11 +2066,11 @@ static int bttv_g_fmt_vid_cap(struct file *file, void *priv,
20662066
struct v4l2_format *f)
20672067
{
20682068
struct bttv_fh *fh = priv;
2069+
struct bttv *btv = video_drvdata(file);
20692070

2070-
pix_format_set_size(&f->fmt.pix, fh->fmt,
2071-
fh->width, fh->height);
2071+
pix_format_set_size(&f->fmt.pix, btv->fmt, btv->width, btv->height);
20722072
f->fmt.pix.field = fh->cap.field;
2073-
f->fmt.pix.pixelformat = fh->fmt->fourcc;
2073+
f->fmt.pix.pixelformat = btv->fmt->fourcc;
20742074
f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
20752075

20762076
return 0;
@@ -2190,6 +2190,9 @@ static int bttv_s_fmt_vid_cap(struct file *file, void *priv,
21902190
btv->init.fmt = fmt;
21912191
btv->init.width = f->fmt.pix.width;
21922192
btv->init.height = f->fmt.pix.height;
2193+
btv->fmt = fmt;
2194+
btv->width = f->fmt.pix.width;
2195+
btv->height = f->fmt.pix.height;
21932196

21942197
return 0;
21952198
}
@@ -2446,21 +2449,15 @@ static int bttv_s_selection(struct file *file, void *f, struct v4l2_selection *s
24462449

24472450
fh->do_crop = 1;
24482451

2449-
if (fh->width < c.min_scaled_width) {
2450-
fh->width = c.min_scaled_width;
2451-
btv->init.width = c.min_scaled_width;
2452-
} else if (fh->width > c.max_scaled_width) {
2453-
fh->width = c.max_scaled_width;
2454-
btv->init.width = c.max_scaled_width;
2455-
}
2452+
if (btv->width < c.min_scaled_width)
2453+
btv->width = c.min_scaled_width;
2454+
else if (btv->width > c.max_scaled_width)
2455+
btv->width = c.max_scaled_width;
24562456

2457-
if (fh->height < c.min_scaled_height) {
2458-
fh->height = c.min_scaled_height;
2459-
btv->init.height = c.min_scaled_height;
2460-
} else if (fh->height > c.max_scaled_height) {
2461-
fh->height = c.max_scaled_height;
2462-
btv->init.height = c.max_scaled_height;
2463-
}
2457+
if (btv->height < c.min_scaled_height)
2458+
btv->height = c.min_scaled_height;
2459+
else if (btv->height > c.max_scaled_height)
2460+
btv->height = c.max_scaled_height;
24642461

24652462
return 0;
24662463
}
@@ -3636,6 +3633,9 @@ static int bttv_probe(struct pci_dev *dev, const struct pci_device_id *pci_id)
36363633
btv->init.fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24);
36373634
btv->init.width = 320;
36383635
btv->init.height = 240;
3636+
btv->fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24);
3637+
btv->width = 320;
3638+
btv->height = 240;
36393639
btv->input = 0;
36403640

36413641
v4l2_ctrl_new_std(hdl, &bttv_ctrl_ops,

drivers/media/pci/bt8xx/bttvp.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,9 @@ struct bttv {
449449

450450
unsigned int users;
451451
struct bttv_fh init;
452+
const struct bttv_format *fmt;
453+
int width;
454+
int height;
452455

453456
/* used to make dvb-bt8xx autoloadable */
454457
struct work_struct request_module_wk;

0 commit comments

Comments
 (0)