diff options
-rw-r--r-- | drivers/media/video/v4l2-compat-ioctl32.c | 2 | ||||
-rw-r--r-- | drivers/media/video/v4l2-ioctl.c | 34 | ||||
-rw-r--r-- | include/linux/videodev2.h | 46 | ||||
-rw-r--r-- | include/media/v4l2-ioctl.h | 4 |
4 files changed, 86 insertions, 0 deletions
diff --git a/drivers/media/video/v4l2-compat-ioctl32.c b/drivers/media/video/v4l2-compat-ioctl32.c index c68531b88279..af4419e6c658 100644 --- a/drivers/media/video/v4l2-compat-ioctl32.c +++ b/drivers/media/video/v4l2-compat-ioctl32.c | |||
@@ -985,6 +985,8 @@ long v4l2_compat_ioctl32(struct file *file, unsigned int cmd, unsigned long arg) | |||
985 | case VIDIOC_CROPCAP: | 985 | case VIDIOC_CROPCAP: |
986 | case VIDIOC_G_CROP: | 986 | case VIDIOC_G_CROP: |
987 | case VIDIOC_S_CROP: | 987 | case VIDIOC_S_CROP: |
988 | case VIDIOC_G_SELECTION: | ||
989 | case VIDIOC_S_SELECTION: | ||
988 | case VIDIOC_G_JPEGCOMP: | 990 | case VIDIOC_G_JPEGCOMP: |
989 | case VIDIOC_S_JPEGCOMP: | 991 | case VIDIOC_S_JPEGCOMP: |
990 | case VIDIOC_QUERYSTD: | 992 | case VIDIOC_QUERYSTD: |
diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c index 639abeee3392..072cfc1a166f 100644 --- a/drivers/media/video/v4l2-ioctl.c +++ b/drivers/media/video/v4l2-ioctl.c | |||
@@ -238,6 +238,8 @@ static const char *v4l2_ioctls[] = { | |||
238 | [_IOC_NR(VIDIOC_CROPCAP)] = "VIDIOC_CROPCAP", | 238 | [_IOC_NR(VIDIOC_CROPCAP)] = "VIDIOC_CROPCAP", |
239 | [_IOC_NR(VIDIOC_G_CROP)] = "VIDIOC_G_CROP", | 239 | [_IOC_NR(VIDIOC_G_CROP)] = "VIDIOC_G_CROP", |
240 | [_IOC_NR(VIDIOC_S_CROP)] = "VIDIOC_S_CROP", | 240 | [_IOC_NR(VIDIOC_S_CROP)] = "VIDIOC_S_CROP", |
241 | [_IOC_NR(VIDIOC_G_SELECTION)] = "VIDIOC_G_SELECTION", | ||
242 | [_IOC_NR(VIDIOC_S_SELECTION)] = "VIDIOC_S_SELECTION", | ||
241 | [_IOC_NR(VIDIOC_G_JPEGCOMP)] = "VIDIOC_G_JPEGCOMP", | 243 | [_IOC_NR(VIDIOC_G_JPEGCOMP)] = "VIDIOC_G_JPEGCOMP", |
242 | [_IOC_NR(VIDIOC_S_JPEGCOMP)] = "VIDIOC_S_JPEGCOMP", | 244 | [_IOC_NR(VIDIOC_S_JPEGCOMP)] = "VIDIOC_S_JPEGCOMP", |
243 | [_IOC_NR(VIDIOC_QUERYSTD)] = "VIDIOC_QUERYSTD", | 245 | [_IOC_NR(VIDIOC_QUERYSTD)] = "VIDIOC_QUERYSTD", |
@@ -1571,6 +1573,38 @@ static long __video_do_ioctl(struct file *file, | |||
1571 | ret = ops->vidioc_s_crop(file, fh, p); | 1573 | ret = ops->vidioc_s_crop(file, fh, p); |
1572 | break; | 1574 | break; |
1573 | } | 1575 | } |
1576 | case VIDIOC_G_SELECTION: | ||
1577 | { | ||
1578 | struct v4l2_selection *p = arg; | ||
1579 | |||
1580 | if (!ops->vidioc_g_selection) | ||
1581 | break; | ||
1582 | |||
1583 | dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names)); | ||
1584 | |||
1585 | ret = ops->vidioc_g_selection(file, fh, p); | ||
1586 | if (!ret) | ||
1587 | dbgrect(vfd, "", &p->r); | ||
1588 | break; | ||
1589 | } | ||
1590 | case VIDIOC_S_SELECTION: | ||
1591 | { | ||
1592 | struct v4l2_selection *p = arg; | ||
1593 | |||
1594 | if (!ops->vidioc_s_selection) | ||
1595 | break; | ||
1596 | |||
1597 | if (ret_prio) { | ||
1598 | ret = ret_prio; | ||
1599 | break; | ||
1600 | } | ||
1601 | |||
1602 | dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names)); | ||
1603 | dbgrect(vfd, "", &p->r); | ||
1604 | |||
1605 | ret = ops->vidioc_s_selection(file, fh, p); | ||
1606 | break; | ||
1607 | } | ||
1574 | case VIDIOC_CROPCAP: | 1608 | case VIDIOC_CROPCAP: |
1575 | { | 1609 | { |
1576 | struct v4l2_cropcap *p = arg; | 1610 | struct v4l2_cropcap *p = arg; |
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h index b2e1331ca76b..012a29604522 100644 --- a/include/linux/videodev2.h +++ b/include/linux/videodev2.h | |||
@@ -743,6 +743,48 @@ struct v4l2_crop { | |||
743 | struct v4l2_rect c; | 743 | struct v4l2_rect c; |
744 | }; | 744 | }; |
745 | 745 | ||
746 | /* Hints for adjustments of selection rectangle */ | ||
747 | #define V4L2_SEL_FLAG_GE 0x00000001 | ||
748 | #define V4L2_SEL_FLAG_LE 0x00000002 | ||
749 | |||
750 | /* Selection targets */ | ||
751 | |||
752 | /* current cropping area */ | ||
753 | #define V4L2_SEL_TGT_CROP_ACTIVE 0 | ||
754 | /* default cropping area */ | ||
755 | #define V4L2_SEL_TGT_CROP_DEFAULT 1 | ||
756 | /* cropping bounds */ | ||
757 | #define V4L2_SEL_TGT_CROP_BOUNDS 2 | ||
758 | /* current composing area */ | ||
759 | #define V4L2_SEL_TGT_COMPOSE_ACTIVE 256 | ||
760 | /* default composing area */ | ||
761 | #define V4L2_SEL_TGT_COMPOSE_DEFAULT 257 | ||
762 | /* composing bounds */ | ||
763 | #define V4L2_SEL_TGT_COMPOSE_BOUNDS 258 | ||
764 | /* current composing area plus all padding pixels */ | ||
765 | #define V4L2_SEL_TGT_COMPOSE_PADDED 259 | ||
766 | |||
767 | /** | ||
768 | * struct v4l2_selection - selection info | ||
769 | * @type: buffer type (do not use *_MPLANE types) | ||
770 | * @target: selection target, used to choose one of possible rectangles | ||
771 | * @flags: constraints flags | ||
772 | * @r: coordinates of selection window | ||
773 | * @reserved: for future use, rounds structure size to 64 bytes, set to zero | ||
774 | * | ||
775 | * Hardware may use multiple helper window to process a video stream. | ||
776 | * The structure is used to exchange this selection areas between | ||
777 | * an application and a driver. | ||
778 | */ | ||
779 | struct v4l2_selection { | ||
780 | __u32 type; | ||
781 | __u32 target; | ||
782 | __u32 flags; | ||
783 | struct v4l2_rect r; | ||
784 | __u32 reserved[9]; | ||
785 | }; | ||
786 | |||
787 | |||
746 | /* | 788 | /* |
747 | * A N A L O G V I D E O S T A N D A R D | 789 | * A N A L O G V I D E O S T A N D A R D |
748 | */ | 790 | */ |
@@ -2259,6 +2301,10 @@ struct v4l2_create_buffers { | |||
2259 | #define VIDIOC_CREATE_BUFS _IOWR('V', 92, struct v4l2_create_buffers) | 2301 | #define VIDIOC_CREATE_BUFS _IOWR('V', 92, struct v4l2_create_buffers) |
2260 | #define VIDIOC_PREPARE_BUF _IOWR('V', 93, struct v4l2_buffer) | 2302 | #define VIDIOC_PREPARE_BUF _IOWR('V', 93, struct v4l2_buffer) |
2261 | 2303 | ||
2304 | /* Experimental selection API */ | ||
2305 | #define VIDIOC_G_SELECTION _IOWR('V', 94, struct v4l2_selection) | ||
2306 | #define VIDIOC_S_SELECTION _IOWR('V', 95, struct v4l2_selection) | ||
2307 | |||
2262 | /* Reminder: when adding new ioctls please add support for them to | 2308 | /* Reminder: when adding new ioctls please add support for them to |
2263 | drivers/media/video/v4l2-compat-ioctl32.c as well! */ | 2309 | drivers/media/video/v4l2-compat-ioctl32.c as well! */ |
2264 | 2310 | ||
diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h index 4d1c74ad4c84..3f5d60fc5df6 100644 --- a/include/media/v4l2-ioctl.h +++ b/include/media/v4l2-ioctl.h | |||
@@ -196,6 +196,10 @@ struct v4l2_ioctl_ops { | |||
196 | struct v4l2_crop *a); | 196 | struct v4l2_crop *a); |
197 | int (*vidioc_s_crop) (struct file *file, void *fh, | 197 | int (*vidioc_s_crop) (struct file *file, void *fh, |
198 | struct v4l2_crop *a); | 198 | struct v4l2_crop *a); |
199 | int (*vidioc_g_selection) (struct file *file, void *fh, | ||
200 | struct v4l2_selection *s); | ||
201 | int (*vidioc_s_selection) (struct file *file, void *fh, | ||
202 | struct v4l2_selection *s); | ||
199 | /* Compression ioctls */ | 203 | /* Compression ioctls */ |
200 | int (*vidioc_g_jpegcomp) (struct file *file, void *fh, | 204 | int (*vidioc_g_jpegcomp) (struct file *file, void *fh, |
201 | struct v4l2_jpegcompression *a); | 205 | struct v4l2_jpegcompression *a); |