Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 285791
b: refs/heads/master
c: 992efef
h: refs/heads/master
i:
  285789: 8a7d2cc
  285787: b6f84ba
  285783: 81c38ef
  285775: 3050877
  285759: 74cfa91
v: v3
  • Loading branch information
Tomasz Stanislawski authored and Mauro Carvalho Chehab committed Jan 11, 2012
1 parent 582f0a8 commit 86f5b9a
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8af4922fe5d1574acfdedf8a9eaafccf1b955c1d
refs/heads/master: 992efeff79fe8de44d4e8b7636bb2e5d9dcf698d
82 changes: 76 additions & 6 deletions trunk/drivers/media/video/v4l2-ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1549,11 +1549,32 @@ static long __video_do_ioctl(struct file *file,
{
struct v4l2_crop *p = arg;

if (!ops->vidioc_g_crop)
if (!ops->vidioc_g_crop && !ops->vidioc_g_selection)
break;

dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names));
ret = ops->vidioc_g_crop(file, fh, p);

if (ops->vidioc_g_crop) {
ret = ops->vidioc_g_crop(file, fh, p);
} else {
/* simulate capture crop using selection api */
struct v4l2_selection s = {
.type = p->type,
};

/* crop means compose for output devices */
if (V4L2_TYPE_IS_OUTPUT(p->type))
s.target = V4L2_SEL_TGT_COMPOSE_ACTIVE;
else
s.target = V4L2_SEL_TGT_CROP_ACTIVE;

ret = ops->vidioc_g_selection(file, fh, &s);

/* copying results to old structure on success */
if (!ret)
p->c = s.r;
}

if (!ret)
dbgrect(vfd, "", &p->c);
break;
Expand All @@ -1562,15 +1583,33 @@ static long __video_do_ioctl(struct file *file,
{
struct v4l2_crop *p = arg;

if (!ops->vidioc_s_crop)
if (!ops->vidioc_s_crop && !ops->vidioc_s_selection)
break;

if (ret_prio) {
ret = ret_prio;
break;
}
dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names));
dbgrect(vfd, "", &p->c);
ret = ops->vidioc_s_crop(file, fh, p);

if (ops->vidioc_s_crop) {
ret = ops->vidioc_s_crop(file, fh, p);
} else {
/* simulate capture crop using selection api */
struct v4l2_selection s = {
.type = p->type,
.r = p->c,
};

/* crop means compose for output devices */
if (V4L2_TYPE_IS_OUTPUT(p->type))
s.target = V4L2_SEL_TGT_COMPOSE_ACTIVE;
else
s.target = V4L2_SEL_TGT_CROP_ACTIVE;

ret = ops->vidioc_s_selection(file, fh, &s);
}
break;
}
case VIDIOC_G_SELECTION:
Expand Down Expand Up @@ -1610,11 +1649,42 @@ static long __video_do_ioctl(struct file *file,
struct v4l2_cropcap *p = arg;

/*FIXME: Should also show v4l2_fract pixelaspect */
if (!ops->vidioc_cropcap)
if (!ops->vidioc_cropcap && !ops->vidioc_g_selection)
break;

dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names));
ret = ops->vidioc_cropcap(file, fh, p);
if (ops->vidioc_cropcap) {
ret = ops->vidioc_cropcap(file, fh, p);
} else {
struct v4l2_selection s = { .type = p->type };

/* obtaining bounds */
if (V4L2_TYPE_IS_OUTPUT(p->type))
s.target = V4L2_SEL_TGT_COMPOSE_BOUNDS;
else
s.target = V4L2_SEL_TGT_CROP_BOUNDS;

ret = ops->vidioc_g_selection(file, fh, &s);
if (ret)
break;
p->bounds = s.r;

/* obtaining defrect */
if (V4L2_TYPE_IS_OUTPUT(p->type))
s.target = V4L2_SEL_TGT_COMPOSE_DEFAULT;
else
s.target = V4L2_SEL_TGT_CROP_DEFAULT;

ret = ops->vidioc_g_selection(file, fh, &s);
if (ret)
break;
p->defrect = s.r;

/* setting trivial pixelaspect */
p->pixelaspect.numerator = 1;
p->pixelaspect.denominator = 1;
}

if (!ret) {
dbgrect(vfd, "bounds ", &p->bounds);
dbgrect(vfd, "defrect ", &p->defrect);
Expand Down

0 comments on commit 86f5b9a

Please sign in to comment.