aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2011-11-24 07:53:43 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-02-14 10:41:42 -0500
commita45c0ad51d344dad18c6fb67304b4f87cf0ffd59 (patch)
treeacdd8cac43a26db7f5d993adffb5e7e6a2634498
parent32d7e63c1f4f86ad18404e3f36be99c9910fae9b (diff)
[media] v4l2: add VIDIOC_(TRY_)DECODER_CMD
As discussed during the 2011 V4L-DVB workshop, the API in dvb/video.h should be replaced by a proper V4L2 API. This patch turns the VIDEO_(TRY_)DECODER_CMD ioctls into proper V4L2 ioctls. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/video/v4l2-compat-ioctl32.c2
-rw-r--r--drivers/media/video/v4l2-ioctl.c28
-rw-r--r--include/linux/videodev2.h53
-rw-r--r--include/media/v4l2-ioctl.h4
4 files changed, 87 insertions, 0 deletions
diff --git a/drivers/media/video/v4l2-compat-ioctl32.c b/drivers/media/video/v4l2-compat-ioctl32.c
index af4419e6c658..e6f67aa5b4c0 100644
--- a/drivers/media/video/v4l2-compat-ioctl32.c
+++ b/drivers/media/video/v4l2-compat-ioctl32.c
@@ -1005,6 +1005,8 @@ long v4l2_compat_ioctl32(struct file *file, unsigned int cmd, unsigned long arg)
1005 case VIDIOC_G_ENC_INDEX: 1005 case VIDIOC_G_ENC_INDEX:
1006 case VIDIOC_ENCODER_CMD: 1006 case VIDIOC_ENCODER_CMD:
1007 case VIDIOC_TRY_ENCODER_CMD: 1007 case VIDIOC_TRY_ENCODER_CMD:
1008 case VIDIOC_DECODER_CMD:
1009 case VIDIOC_TRY_DECODER_CMD:
1008 case VIDIOC_DBG_S_REGISTER: 1010 case VIDIOC_DBG_S_REGISTER:
1009 case VIDIOC_DBG_G_REGISTER: 1011 case VIDIOC_DBG_G_REGISTER:
1010 case VIDIOC_DBG_G_CHIP_IDENT: 1012 case VIDIOC_DBG_G_CHIP_IDENT:
diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c
index d0d7281e01e0..a288ee6fd456 100644
--- a/drivers/media/video/v4l2-ioctl.c
+++ b/drivers/media/video/v4l2-ioctl.c
@@ -260,6 +260,8 @@ static const char *v4l2_ioctls[] = {
260 [_IOC_NR(VIDIOC_ENCODER_CMD)] = "VIDIOC_ENCODER_CMD", 260 [_IOC_NR(VIDIOC_ENCODER_CMD)] = "VIDIOC_ENCODER_CMD",
261 [_IOC_NR(VIDIOC_TRY_ENCODER_CMD)] = "VIDIOC_TRY_ENCODER_CMD", 261 [_IOC_NR(VIDIOC_TRY_ENCODER_CMD)] = "VIDIOC_TRY_ENCODER_CMD",
262 262
263 [_IOC_NR(VIDIOC_DECODER_CMD)] = "VIDIOC_DECODER_CMD",
264 [_IOC_NR(VIDIOC_TRY_DECODER_CMD)] = "VIDIOC_TRY_DECODER_CMD",
263 [_IOC_NR(VIDIOC_DBG_S_REGISTER)] = "VIDIOC_DBG_S_REGISTER", 265 [_IOC_NR(VIDIOC_DBG_S_REGISTER)] = "VIDIOC_DBG_S_REGISTER",
264 [_IOC_NR(VIDIOC_DBG_G_REGISTER)] = "VIDIOC_DBG_G_REGISTER", 266 [_IOC_NR(VIDIOC_DBG_G_REGISTER)] = "VIDIOC_DBG_G_REGISTER",
265 267
@@ -1764,6 +1766,32 @@ static long __video_do_ioctl(struct file *file,
1764 dbgarg(cmd, "cmd=%d, flags=%x\n", p->cmd, p->flags); 1766 dbgarg(cmd, "cmd=%d, flags=%x\n", p->cmd, p->flags);
1765 break; 1767 break;
1766 } 1768 }
1769 case VIDIOC_DECODER_CMD:
1770 {
1771 struct v4l2_decoder_cmd *p = arg;
1772
1773 if (!ops->vidioc_decoder_cmd)
1774 break;
1775 if (ret_prio) {
1776 ret = ret_prio;
1777 break;
1778 }
1779 ret = ops->vidioc_decoder_cmd(file, fh, p);
1780 if (!ret)
1781 dbgarg(cmd, "cmd=%d, flags=%x\n", p->cmd, p->flags);
1782 break;
1783 }
1784 case VIDIOC_TRY_DECODER_CMD:
1785 {
1786 struct v4l2_decoder_cmd *p = arg;
1787
1788 if (!ops->vidioc_try_decoder_cmd)
1789 break;
1790 ret = ops->vidioc_try_decoder_cmd(file, fh, p);
1791 if (!ret)
1792 dbgarg(cmd, "cmd=%d, flags=%x\n", p->cmd, p->flags);
1793 break;
1794 }
1767 case VIDIOC_G_PARM: 1795 case VIDIOC_G_PARM:
1768 { 1796 {
1769 struct v4l2_streamparm *p = arg; 1797 struct v4l2_streamparm *p = arg;
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index 0db05033c2ec..e4ba8d77196d 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -1908,6 +1908,54 @@ struct v4l2_encoder_cmd {
1908 }; 1908 };
1909}; 1909};
1910 1910
1911/* Decoder commands */
1912#define V4L2_DEC_CMD_START (0)
1913#define V4L2_DEC_CMD_STOP (1)
1914#define V4L2_DEC_CMD_PAUSE (2)
1915#define V4L2_DEC_CMD_RESUME (3)
1916
1917/* Flags for V4L2_DEC_CMD_START */
1918#define V4L2_DEC_CMD_START_MUTE_AUDIO (1 << 0)
1919
1920/* Flags for V4L2_DEC_CMD_PAUSE */
1921#define V4L2_DEC_CMD_PAUSE_TO_BLACK (1 << 0)
1922
1923/* Flags for V4L2_DEC_CMD_STOP */
1924#define V4L2_DEC_CMD_STOP_TO_BLACK (1 << 0)
1925#define V4L2_DEC_CMD_STOP_IMMEDIATELY (1 << 1)
1926
1927/* Play format requirements (returned by the driver): */
1928
1929/* The decoder has no special format requirements */
1930#define V4L2_DEC_START_FMT_NONE (0)
1931/* The decoder requires full GOPs */
1932#define V4L2_DEC_START_FMT_GOP (1)
1933
1934/* The structure must be zeroed before use by the application
1935 This ensures it can be extended safely in the future. */
1936struct v4l2_decoder_cmd {
1937 __u32 cmd;
1938 __u32 flags;
1939 union {
1940 struct {
1941 __u64 pts;
1942 } stop;
1943
1944 struct {
1945 /* 0 or 1000 specifies normal speed,
1946 1 specifies forward single stepping,
1947 -1 specifies backward single stepping,
1948 >1: playback at speed/1000 of the normal speed,
1949 <-1: reverse playback at (-speed/1000) of the normal speed. */
1950 __s32 speed;
1951 __u32 format;
1952 } start;
1953
1954 struct {
1955 __u32 data[16];
1956 } raw;
1957 };
1958};
1911#endif 1959#endif
1912 1960
1913 1961
@@ -2318,6 +2366,11 @@ struct v4l2_create_buffers {
2318#define VIDIOC_G_SELECTION _IOWR('V', 94, struct v4l2_selection) 2366#define VIDIOC_G_SELECTION _IOWR('V', 94, struct v4l2_selection)
2319#define VIDIOC_S_SELECTION _IOWR('V', 95, struct v4l2_selection) 2367#define VIDIOC_S_SELECTION _IOWR('V', 95, struct v4l2_selection)
2320 2368
2369/* Experimental, these two ioctls may change over the next couple of kernel
2370 versions. */
2371#define VIDIOC_DECODER_CMD _IOWR('V', 96, struct v4l2_decoder_cmd)
2372#define VIDIOC_TRY_DECODER_CMD _IOWR('V', 97, struct v4l2_decoder_cmd)
2373
2321/* Reminder: when adding new ioctls please add support for them to 2374/* Reminder: when adding new ioctls please add support for them to
2322 drivers/media/video/v4l2-compat-ioctl32.c as well! */ 2375 drivers/media/video/v4l2-compat-ioctl32.c as well! */
2323 2376
diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
index 3f5d60fc5df6..4df031af9949 100644
--- a/include/media/v4l2-ioctl.h
+++ b/include/media/v4l2-ioctl.h
@@ -211,6 +211,10 @@ struct v4l2_ioctl_ops {
211 struct v4l2_encoder_cmd *a); 211 struct v4l2_encoder_cmd *a);
212 int (*vidioc_try_encoder_cmd) (struct file *file, void *fh, 212 int (*vidioc_try_encoder_cmd) (struct file *file, void *fh,
213 struct v4l2_encoder_cmd *a); 213 struct v4l2_encoder_cmd *a);
214 int (*vidioc_decoder_cmd) (struct file *file, void *fh,
215 struct v4l2_decoder_cmd *a);
216 int (*vidioc_try_decoder_cmd) (struct file *file, void *fh,
217 struct v4l2_decoder_cmd *a);
214 218
215 /* Stream type-dependent parameter ioctls */ 219 /* Stream type-dependent parameter ioctls */
216 int (*vidioc_g_parm) (struct file *file, void *fh, 220 int (*vidioc_g_parm) (struct file *file, void *fh,