Skip to content

Commit 04d5356

Browse files
deborahbrouwermchehab
authored andcommitted
media: bttv: move do_crop flag out of bttv_fh
The do_crop flag indicates whether a cropping rectangle has been set. Instead of storing this flag separately in each file handle, move do_crop to struct bttv in preparation for vb2 conversion which stops using separate bttv file handles. Signed-off-by: Deborah Brouwer <[email protected]> Signed-off-by: Hans Verkuil <[email protected]>
1 parent faebe84 commit 04d5356

File tree

2 files changed

+11
-18
lines changed

2 files changed

+11
-18
lines changed

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

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ int check_alloc_btres_lock(struct bttv *btv, struct bttv_fh *fh, int bit)
663663
if ((bit & VIDEO_RESOURCES)
664664
&& 0 == (btv->resources & VIDEO_RESOURCES)) {
665665
/* Do crop - use current, don't - use default parameters. */
666-
__s32 top = btv->crop[!!fh->do_crop].rect.top;
666+
__s32 top = btv->crop[!!btv->do_crop].rect.top;
667667

668668
if (btv->vbi_end > top)
669669
goto fail;
@@ -1493,7 +1493,6 @@ static int bttv_prepare_buffer(struct videobuf_queue *q,struct bttv *btv,
14931493
unsigned int width, unsigned int height,
14941494
enum v4l2_field field)
14951495
{
1496-
struct bttv_fh *fh = q->priv_data;
14971496
int redo_dma_risc = 0;
14981497
struct bttv_crop c;
14991498
int norm;
@@ -1523,7 +1522,7 @@ static int bttv_prepare_buffer(struct videobuf_queue *q,struct bttv *btv,
15231522
c.rect = bttv_tvnorms[norm].cropcap.defrect;
15241523
} else {
15251524
norm = btv->tvnorm;
1526-
c = btv->crop[!!fh->do_crop];
1525+
c = btv->crop[!!btv->do_crop];
15271526

15281527
if (width < c.min_scaled_width ||
15291528
width > c.max_scaled_width ||
@@ -1919,9 +1918,9 @@ limit_scaled_size_lock (struct bttv_fh * fh,
19191918
b = &bttv_tvnorms[btv->tvnorm].cropcap.bounds;
19201919

19211920
/* Do crop - use current, don't - use default parameters. */
1922-
c = &btv->crop[!!fh->do_crop];
1921+
c = &btv->crop[!!btv->do_crop];
19231922

1924-
if (fh->do_crop
1923+
if (btv->do_crop
19251924
&& adjust_size
19261925
&& adjust_crop
19271926
&& !locked_btres(btv, VIDEO_RESOURCES)) {
@@ -2121,7 +2120,7 @@ static int bttv_try_fmt_vid_cap(struct file *file, void *priv,
21212120
}
21222121
fallthrough;
21232122
default: /* FIELD_ANY case */
2124-
height2 = btv->crop[!!fh->do_crop].rect.height >> 1;
2123+
height2 = btv->crop[!!btv->do_crop].rect.height >> 1;
21252124
field = (f->fmt.pix.height > height2)
21262125
? V4L2_FIELD_INTERLACED
21272126
: V4L2_FIELD_BOTTOM;
@@ -2360,20 +2359,14 @@ static int bttv_g_pixelaspect(struct file *file, void *priv,
23602359

23612360
static int bttv_g_selection(struct file *file, void *f, struct v4l2_selection *sel)
23622361
{
2363-
struct bttv_fh *fh = f;
23642362
struct bttv *btv = video_drvdata(file);
23652363

23662364
if (sel->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
23672365
return -EINVAL;
23682366

23692367
switch (sel->target) {
23702368
case V4L2_SEL_TGT_CROP:
2371-
/*
2372-
* No fh->do_crop = 1; because btv->crop[1] may be
2373-
* inconsistent with fh->width or fh->height and apps
2374-
* do not expect a change here.
2375-
*/
2376-
sel->r = btv->crop[!!fh->do_crop].rect;
2369+
sel->r = btv->crop[!!btv->do_crop].rect;
23772370
break;
23782371
case V4L2_SEL_TGT_CROP_DEFAULT:
23792372
sel->r = bttv_tvnorms[btv->tvnorm].cropcap.defrect;
@@ -2447,7 +2440,7 @@ static int bttv_s_selection(struct file *file, void *f, struct v4l2_selection *s
24472440

24482441
btv->crop[1] = c;
24492442

2450-
fh->do_crop = 1;
2443+
btv->do_crop = 1;
24512444

24522445
if (btv->width < c.min_scaled_width)
24532446
btv->width = c.min_scaled_width;
@@ -2610,7 +2603,7 @@ static int bttv_open(struct file *file)
26102603
current video standard, and VIDIOC_S_FMT will not implicitly
26112604
change the cropping parameters until VIDIOC_S_SELECTION has been
26122605
called. */
2613-
fh->do_crop = !reset_crop; /* module parameter */
2606+
btv->do_crop = !reset_crop; /* module parameter */
26142607

26152608
/* Likewise there should be one global set of VBI capture
26162609
parameters, but for compatibility with V4L apps and earlier
@@ -3639,6 +3632,7 @@ static int bttv_probe(struct pci_dev *dev, const struct pci_device_id *pci_id)
36393632
btv->input = 0;
36403633
btv->tvnorm = 0; /* Index into bttv_tvnorms[] i.e. PAL. */
36413634
bttv_vbi_fmt_reset(&btv->vbi_fmt, btv->tvnorm);
3635+
btv->do_crop = 0;
36423636

36433637
v4l2_ctrl_new_std(hdl, &bttv_ctrl_ops,
36443638
V4L2_CID_BRIGHTNESS, 0, 0xff00, 0x100, 32768);

drivers/media/pci/bt8xx/bttvp.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,6 @@ struct bttv_fh {
206206
int width;
207207
int height;
208208

209-
/* Application called VIDIOC_S_SELECTION. */
210-
int do_crop;
211-
212209
/* vbi capture */
213210
struct videobuf_queue vbi;
214211
/* Current VBI capture window as seen through this fh (cannot
@@ -453,6 +450,8 @@ struct bttv {
453450
int width;
454451
int height;
455452
struct bttv_vbi_fmt vbi_fmt;
453+
/* Application called VIDIOC_S_SELECTION. */
454+
int do_crop;
456455

457456
/* used to make dvb-bt8xx autoloadable */
458457
struct work_struct request_module_wk;

0 commit comments

Comments
 (0)