* Re: [RFC PATCH 4/4] ivtv: implement new decoder command ioctls.
@ 2011-11-23 11:54 Martin Dauskardt
2011-11-23 12:14 ` Hans Verkuil
0 siblings, 1 reply; 5+ messages in thread
From: Martin Dauskardt @ 2011-11-23 11:54 UTC (permalink / raw)
To: linux-media, Hans Verkuil
Hi Hans,
I am not sure if I understand this right. You wrote:
"Comments are added on how to convert the legacy ioctls to standard V4L2 API
in applications. Perhaps these legacy ioctls in ivtv can even be removed in a
few years time."
But the patch looks for me as if the currently used ioctls shall be removed
now, which would immidiately break existing applications.
This is an example of the currently used code:
void cPvr350Device::DecoderStop(int blank)
{
struct video_command cmd;
memset(&cmd, 0, sizeof(cmd));
cmd.cmd = VIDEO_CMD_STOP;
if (blank) {
cmd.flags = VIDEO_CMD_STOP_TO_BLACK | VIDEO_CMD_STOP_IMMEDIATELY;
} else { //show last frame instead of a black screen
cmd.flags = VIDEO_CMD_STOP_IMMEDIATELY;
}
if (IOCTL(fd_out, VIDEO_COMMAND, &cmd) < 0) {
log(pvrERROR, "pvr350: VIDEO_CMD_STOP %s error=%d:%s",
blank ? "(blank)" : "", errno, strerror(errno));
}
}
As far as I know my pvr350-Plugin for vdr is the only application which uses
the hardware decoder of the PVR350 (mythtv has dropped support some years
ago). There are only a few users left in time of HDTV.
I don't really understand why it is necessary to do this changes.
I suggest to increase the ivtv driver version number when implementing the
changes. The application (which must be backward compatible) should be able to
determine which ioctl it has to use.
It would be much better if the ivtv driver would continue to support the old
ioctl for the few years we still have any PVR350 user.
Greets,
Martin
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [RFC PATCH 4/4] ivtv: implement new decoder command ioctls. 2011-11-23 11:54 [RFC PATCH 4/4] ivtv: implement new decoder command ioctls Martin Dauskardt @ 2011-11-23 12:14 ` Hans Verkuil 2011-11-23 12:51 ` Mauro Carvalho Chehab 2011-11-23 19:44 ` Martin Dauskardt 0 siblings, 2 replies; 5+ messages in thread From: Hans Verkuil @ 2011-11-23 12:14 UTC (permalink / raw) To: Martin Dauskardt; +Cc: linux-media On Wednesday, November 23, 2011 12:54:18 Martin Dauskardt wrote: > Hi Hans, > > I am not sure if I understand this right. You wrote: > > "Comments are added on how to convert the legacy ioctls to standard V4L2 API > in applications. Perhaps these legacy ioctls in ivtv can even be removed in a > few years time." > > But the patch looks for me as if the currently used ioctls shall be removed > now, which would immidiately break existing applications. ??? I'm not removing anything. All current ioctls remain present. > This is an example of the currently used code: > > void cPvr350Device::DecoderStop(int blank) > { > struct video_command cmd; > memset(&cmd, 0, sizeof(cmd)); > cmd.cmd = VIDEO_CMD_STOP; > if (blank) { > cmd.flags = VIDEO_CMD_STOP_TO_BLACK | VIDEO_CMD_STOP_IMMEDIATELY; > } else { //show last frame instead of a black screen > cmd.flags = VIDEO_CMD_STOP_IMMEDIATELY; > } > if (IOCTL(fd_out, VIDEO_COMMAND, &cmd) < 0) { > log(pvrERROR, "pvr350: VIDEO_CMD_STOP %s error=%d:%s", > blank ? "(blank)" : "", errno, strerror(errno)); > } > } > > As far as I know my pvr350-Plugin for vdr is the only application which uses > the hardware decoder of the PVR350 (mythtv has dropped support some years > ago). There are only a few users left in time of HDTV. > I don't really understand why it is necessary to do this changes. It's an DVB/V4L API cleanup: these ioctls ended up in the DVB API when they should have been part of the V4L API. We're cleaning this up, especially since the decoder API might become relevant for embedded systems where decoder support is much more common. > I suggest to increase the ivtv driver version number when implementing the > changes. The application (which must be backward compatible) should be able to > determine which ioctl it has to use. These days the version number of all drivers is the same as the kernel version number, so it is easy to check when new ioctls became available. > It would be much better if the ivtv driver would continue to support the old > ioctl for the few years we still have any PVR350 user. Don't worry, I won't be removing anything. I checked the plugin code and you aren't using VIDEO_GET_EVENT. The VIDEO_GET_EVENT ioctl is the only one I'd really like to get rid of in ivtv in favor of the V4L2 event API. It's only used as far as I can tell in ivtv-ctl and ivtvplay, both ivtv utilities that can easily be changed. Are you perhaps aware of any other userspace applications that use that ioctl? Regards, Hans ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC PATCH 4/4] ivtv: implement new decoder command ioctls. 2011-11-23 12:14 ` Hans Verkuil @ 2011-11-23 12:51 ` Mauro Carvalho Chehab 2011-11-23 19:44 ` Martin Dauskardt 1 sibling, 0 replies; 5+ messages in thread From: Mauro Carvalho Chehab @ 2011-11-23 12:51 UTC (permalink / raw) To: Hans Verkuil; +Cc: Martin Dauskardt, linux-media Em 23-11-2011 10:14, Hans Verkuil escreveu: > On Wednesday, November 23, 2011 12:54:18 Martin Dauskardt wrote: >> Hi Hans, >> >> I am not sure if I understand this right. You wrote: >> >> "Comments are added on how to convert the legacy ioctls to standard V4L2 API >> in applications. Perhaps these legacy ioctls in ivtv can even be removed in a >> few years time." >> >> But the patch looks for me as if the currently used ioctls shall be removed >> now, which would immidiately break existing applications. > > ??? I'm not removing anything. All current ioctls remain present. I'd prefer to deprecate its usage on ivtv and remove it after a few kernel versions, but there's no rush. So, it would be better if the existing application(s) could detect if the new ioctl is present or not, and use it instead of the legacy one. Assuming that this patch enters into kernel 3.3, the ioctl's will be there at least up to 3.5. So, we have some time to make sure that userspace will be ready for it, when the old ioctl's got deprecated. In other words, the better strategy seems to apply those patches for 3.3, change the existing applications to work with either way, and then schedule when the existing behavior will no longer be supported inside kernel (3.5? 3.6? 3.8?). A compat code might be added at libv4l, but IMO, it seems an overkill, as there are very few applications using this feature for ivtv. >> This is an example of the currently used code: >> >> void cPvr350Device::DecoderStop(int blank) >> { >> struct video_command cmd; >> memset(&cmd, 0, sizeof(cmd)); >> cmd.cmd = VIDEO_CMD_STOP; >> if (blank) { >> cmd.flags = VIDEO_CMD_STOP_TO_BLACK | VIDEO_CMD_STOP_IMMEDIATELY; >> } else { //show last frame instead of a black screen >> cmd.flags = VIDEO_CMD_STOP_IMMEDIATELY; >> } >> if (IOCTL(fd_out, VIDEO_COMMAND, &cmd) < 0) { >> log(pvrERROR, "pvr350: VIDEO_CMD_STOP %s error=%d:%s", >> blank ? "(blank)" : "", errno, strerror(errno)); >> } >> } >> >> As far as I know my pvr350-Plugin for vdr is the only application which uses >> the hardware decoder of the PVR350 (mythtv has dropped support some years >> ago). There are only a few users left in time of HDTV. >> I don't really understand why it is necessary to do this changes. > > It's an DVB/V4L API cleanup: these ioctls ended up in the DVB API when they > should have been part of the V4L API. We're cleaning this up, especially > since the decoder API might become relevant for embedded systems where decoder > support is much more common. > >> I suggest to increase the ivtv driver version number when implementing the >> changes. The application (which must be backward compatible) should be able to >> determine which ioctl it has to use. > > These days the version number of all drivers is the same as the kernel version > number, so it is easy to check when new ioctls became available. Yes. This applies for kernel >= 3.1. Also, on those Kernels, if an ioctl is not available, the return code is different (ENOTTY). >> It would be much better if the ivtv driver would continue to support the old >> ioctl for the few years we still have any PVR350 user. > > Don't worry, I won't be removing anything. > > I checked the plugin code and you aren't using VIDEO_GET_EVENT. The VIDEO_GET_EVENT > ioctl is the only one I'd really like to get rid of in ivtv in favor of the > V4L2 event API. It's only used as far as I can tell in ivtv-ctl and ivtvplay, > both ivtv utilities that can easily be changed. > > Are you perhaps aware of any other userspace applications that use that > ioctl? > > Regards, > > Hans > -- > To unsubscribe from this list: send the line "unsubscribe linux-media" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC PATCH 4/4] ivtv: implement new decoder command ioctls. 2011-11-23 12:14 ` Hans Verkuil 2011-11-23 12:51 ` Mauro Carvalho Chehab @ 2011-11-23 19:44 ` Martin Dauskardt 1 sibling, 0 replies; 5+ messages in thread From: Martin Dauskardt @ 2011-11-23 19:44 UTC (permalink / raw) To: Hans Verkuil; +Cc: linux-media > > I suggest to increase the ivtv driver version number when implementing > > the changes. The application (which must be backward compatible) should > > be able to determine which ioctl it has to use. > > These days the version number of all drivers is the same as the kernel > version number, so it is easy to check when new ioctls became available. Does this mean that the ivtv driver version is also 3.3 when somebody uses an older kernel with updated drivers from media_build? I am worried that this might be the case if somebody checks out from the staging/for_v3.3 Branch **before** the patch is merged. > > > > It would be much better if the ivtv driver would continue to support the > > old ioctl for the few years we still have any PVR350 user. > > Don't worry, I won't be removing anything. good :-) > > I checked the plugin code and you aren't using VIDEO_GET_EVENT. The > VIDEO_GET_EVENT ioctl is the only one I'd really like to get rid of in > ivtv in favor of the V4L2 event API. It's only used as far as I can tell > in ivtv-ctl and ivtvplay, both ivtv utilities that can easily be changed. > > Are you perhaps aware of any other userspace applications that use that > ioctl? no. I think mythtv used it, but I doubt that the dropped support for the decoder will come back anytime. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [RFC PATCH 0/4] Replace VIDEO_COMMAND with VIDIOC_DECODER_CMD @ 2011-11-23 11:12 Hans Verkuil 2011-11-23 11:12 ` [RFC PATCH 1/4] v4l2: add VIDIOC_(TRY_)DECODER_CMD Hans Verkuil 0 siblings, 1 reply; 5+ messages in thread From: Hans Verkuil @ 2011-11-23 11:12 UTC (permalink / raw) To: linux-media; +Cc: Mauro Carvalho Chehab During the 2011 workshop we discussed replacing the decoder commands in include/linux/dvb/video.h and audio.h by a proper V4L2 API. This patch series is the first phase of that. It adds new VIDIOC_(TRY_)DECODER_CMD ioctls to the V4L2 API. These are identical to the VIDEO_(TRY_)COMMAND from dvb/video.h, but the names of the fields and defines now conform to the V4L2 API conventions. Documentation has been added and ivtv (the only V4L2 driver that used VIDEO_COMMAND) has been adapted to support the new V4L2 API. I do have one question for Mauro: what do you want to do with video.h? Should it be removed altogether eventually? Some of the commands defined there aren't used by any driver (e.g. VIDEO_GET_NAVI), some are specific to the av7110 driver (e.g. VIDEO_STILLPICTURE), some are specific to ivtv (VIDEO_COMMAND) and some are used by both ivtv and av7110 (e.g. VIDEO_PLAY). My proposal would be to: 1) remove anything that is not used by any driver from audio.h and video.h 2) move av7110 specific stuff to a new linux/av7110.h header 3) move ivtv specific stuff to the linux/ivtv.h header 4) shared code should be moved to the new linux/av7110.h header and also copied to linux/ivtv.h. The ivtv version will rename the names (e.g. VIDEO_ becomes IVTV_) but is otherwise unchanged to preserve the ABI. Comments are added on how to convert the legacy ioctls to standard V4L2 API in applications. Perhaps these legacy ioctls in ivtv can even be removed in a few years time. 5) remove linux/dvb/audio.h and video.h. What do you think, Mauro? Regards, Hans ^ permalink raw reply [flat|nested] 5+ messages in thread
* [RFC PATCH 1/4] v4l2: add VIDIOC_(TRY_)DECODER_CMD. 2011-11-23 11:12 [RFC PATCH 0/4] Replace VIDEO_COMMAND with VIDIOC_DECODER_CMD Hans Verkuil @ 2011-11-23 11:12 ` Hans Verkuil 2011-11-23 11:12 ` [RFC PATCH 4/4] ivtv: implement new decoder command ioctls Hans Verkuil 0 siblings, 1 reply; 5+ messages in thread From: Hans Verkuil @ 2011-11-23 11:12 UTC (permalink / raw) To: linux-media; +Cc: Mauro Carvalho Chehab, Hans Verkuil From: Hans Verkuil <hans.verkuil@cisco.com> 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> --- drivers/media/video/v4l2-compat-ioctl32.c | 2 + drivers/media/video/v4l2-ioctl.c | 30 +++++++++++++++++ include/linux/videodev2.h | 50 +++++++++++++++++++++++++++++ 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 c68531b..ffd9b1e 100644 --- a/drivers/media/video/v4l2-compat-ioctl32.c +++ b/drivers/media/video/v4l2-compat-ioctl32.c @@ -1003,6 +1003,8 @@ long v4l2_compat_ioctl32(struct file *file, unsigned int cmd, unsigned long arg) case VIDIOC_G_ENC_INDEX: case VIDIOC_ENCODER_CMD: case VIDIOC_TRY_ENCODER_CMD: + case VIDIOC_DECODER_CMD: + case VIDIOC_TRY_DECODER_CMD: case VIDIOC_DBG_S_REGISTER: case VIDIOC_DBG_G_REGISTER: case VIDIOC_DBG_G_CHIP_IDENT: diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c index e1da8fc..e3bda4e 100644 --- a/drivers/media/video/v4l2-ioctl.c +++ b/drivers/media/video/v4l2-ioctl.c @@ -258,6 +258,8 @@ static const char *v4l2_ioctls[] = { [_IOC_NR(VIDIOC_ENCODER_CMD)] = "VIDIOC_ENCODER_CMD", [_IOC_NR(VIDIOC_TRY_ENCODER_CMD)] = "VIDIOC_TRY_ENCODER_CMD", + [_IOC_NR(VIDIOC_DECODER_CMD)] = "VIDIOC_DECODER_CMD", + [_IOC_NR(VIDIOC_TRY_DECODER_CMD)] = "VIDIOC_TRY_DECODER_CMD", [_IOC_NR(VIDIOC_DBG_S_REGISTER)] = "VIDIOC_DBG_S_REGISTER", [_IOC_NR(VIDIOC_DBG_G_REGISTER)] = "VIDIOC_DBG_G_REGISTER", @@ -1658,6 +1660,32 @@ static long __video_do_ioctl(struct file *file, dbgarg(cmd, "cmd=%d, flags=%x\n", p->cmd, p->flags); break; } + case VIDIOC_DECODER_CMD: + { + struct v4l2_decoder_cmd *p = arg; + + if (!ops->vidioc_decoder_cmd) + break; + if (ret_prio) { + ret = ret_prio; + break; + } + ret = ops->vidioc_decoder_cmd(file, fh, p); + if (!ret) + dbgarg(cmd, "cmd=%d, flags=%x\n", p->cmd, p->flags); + break; + } + case VIDIOC_TRY_DECODER_CMD: + { + struct v4l2_decoder_cmd *p = arg; + + if (!ops->vidioc_try_decoder_cmd) + break; + ret = ops->vidioc_try_decoder_cmd(file, fh, p); + if (!ret) + dbgarg(cmd, "cmd=%d, flags=%x\n", p->cmd, p->flags); + break; + } case VIDIOC_G_PARM: { struct v4l2_streamparm *p = arg; @@ -2188,6 +2216,8 @@ static unsigned long cmd_input_size(unsigned int cmd) CMDINSIZE(ENUMAUDOUT, audioout, index); CMDINSIZE(ENCODER_CMD, encoder_cmd, flags); CMDINSIZE(TRY_ENCODER_CMD, encoder_cmd, flags); + CMDINSIZE(DECODER_CMD, decoder_cmd, flags); + CMDINSIZE(TRY_DECODER_CMD, decoder_cmd, flags); CMDINSIZE(G_SLICED_VBI_CAP, sliced_vbi_cap, type); CMDINSIZE(ENUM_FRAMESIZES, frmsizeenum, pixel_format); CMDINSIZE(ENUM_FRAMEINTERVALS, frmivalenum, height); diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h index 4b752d5..de3737a 100644 --- a/include/linux/videodev2.h +++ b/include/linux/videodev2.h @@ -1849,6 +1849,51 @@ struct v4l2_encoder_cmd { }; }; +/* Decoder commands */ +#define V4L2_DEC_CMD_START (0) +#define V4L2_DEC_CMD_STOP (1) +#define V4L2_DEC_CMD_PAUSE (2) +#define V4L2_DEC_CMD_RESUME (3) + +/* Flags for V4L2_DEC_CMD_PAUSE */ +#define V4L2_DEC_CMD_PAUSE_TO_BLACK (1 << 0) + +/* Flags for V4L2_DEC_CMD_STOP */ +#define V4L2_DEC_CMD_STOP_TO_BLACK (1 << 0) +#define V4L2_DEC_CMD_STOP_IMMEDIATELY (1 << 1) + +/* Play format requirements (returned by the driver): */ + +/* The decoder has no special format requirements */ +#define V4L2_DEC_START_FMT_NONE (0) +/* The decoder requires full GOPs */ +#define V4L2_DEC_START_FMT_GOP (1) + +/* The structure must be zeroed before use by the application + This ensures it can be extended safely in the future. */ +struct v4l2_decoder_cmd { + __u32 cmd; + __u32 flags; + union { + struct { + __u64 pts; + } stop; + + struct { + /* 0 or 1000 specifies normal speed, + 1 specifies forward single stepping, + -1 specifies backward single stepping, + >1: playback at speed/1000 of the normal speed, + <-1: reverse playback at (-speed/1000) of the normal speed. */ + __s32 speed; + __u32 format; + } start; + + struct { + __u32 data[16]; + } raw; + }; +}; #endif @@ -2255,6 +2300,11 @@ struct v4l2_create_buffers { #define VIDIOC_CREATE_BUFS _IOWR('V', 92, struct v4l2_create_buffers) #define VIDIOC_PREPARE_BUF _IOWR('V', 93, struct v4l2_buffer) +/* Experimental, these two ioctls may change over the next couple of kernel + versions. */ +#define VIDIOC_DECODER_CMD _IOWR('V', 94, struct v4l2_decoder_cmd) +#define VIDIOC_TRY_DECODER_CMD _IOWR('V', 95, struct v4l2_decoder_cmd) + /* Reminder: when adding new ioctls please add support for them to drivers/media/video/v4l2-compat-ioctl32.c as well! */ diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h index 4d1c74a..46c13ba 100644 --- a/include/media/v4l2-ioctl.h +++ b/include/media/v4l2-ioctl.h @@ -207,6 +207,10 @@ struct v4l2_ioctl_ops { struct v4l2_encoder_cmd *a); int (*vidioc_try_encoder_cmd) (struct file *file, void *fh, struct v4l2_encoder_cmd *a); + int (*vidioc_decoder_cmd) (struct file *file, void *fh, + struct v4l2_decoder_cmd *a); + int (*vidioc_try_decoder_cmd) (struct file *file, void *fh, + struct v4l2_decoder_cmd *a); /* Stream type-dependent parameter ioctls */ int (*vidioc_g_parm) (struct file *file, void *fh, -- 1.7.7.3 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [RFC PATCH 4/4] ivtv: implement new decoder command ioctls. 2011-11-23 11:12 ` [RFC PATCH 1/4] v4l2: add VIDIOC_(TRY_)DECODER_CMD Hans Verkuil @ 2011-11-23 11:12 ` Hans Verkuil 0 siblings, 0 replies; 5+ messages in thread From: Hans Verkuil @ 2011-11-23 11:12 UTC (permalink / raw) To: linux-media; +Cc: Mauro Carvalho Chehab, Hans Verkuil From: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> --- drivers/media/video/ivtv/ivtv-driver.c | 2 +- drivers/media/video/ivtv/ivtv-fileops.c | 2 +- drivers/media/video/ivtv/ivtv-ioctl.c | 102 +++++++++++++++++++------------ drivers/media/video/ivtv/ivtv-streams.c | 4 +- 4 files changed, 67 insertions(+), 43 deletions(-) diff --git a/drivers/media/video/ivtv/ivtv-driver.c b/drivers/media/video/ivtv/ivtv-driver.c index 41108a9..7ee7594 100644 --- a/drivers/media/video/ivtv/ivtv-driver.c +++ b/drivers/media/video/ivtv/ivtv-driver.c @@ -1378,7 +1378,7 @@ static void ivtv_remove(struct pci_dev *pdev) else type = IVTV_DEC_STREAM_TYPE_MPG; ivtv_stop_v4l2_decode_stream(&itv->streams[type], - VIDEO_CMD_STOP_TO_BLACK | VIDEO_CMD_STOP_IMMEDIATELY, 0); + V4L2_DEC_CMD_STOP_TO_BLACK | V4L2_DEC_CMD_STOP_IMMEDIATELY, 0); } ivtv_halt_firmware(itv); } diff --git a/drivers/media/video/ivtv/ivtv-fileops.c b/drivers/media/video/ivtv/ivtv-fileops.c index 38f0522..66228ee 100644 --- a/drivers/media/video/ivtv/ivtv-fileops.c +++ b/drivers/media/video/ivtv/ivtv-fileops.c @@ -899,7 +899,7 @@ int ivtv_v4l2_close(struct file *filp) } else if (s->type >= IVTV_DEC_STREAM_TYPE_MPG) { struct ivtv_stream *s_vout = &itv->streams[IVTV_DEC_STREAM_TYPE_VOUT]; - ivtv_stop_decoding(id, VIDEO_CMD_STOP_TO_BLACK | VIDEO_CMD_STOP_IMMEDIATELY, 0); + ivtv_stop_decoding(id, V4L2_DEC_CMD_STOP_TO_BLACK | V4L2_DEC_CMD_STOP_IMMEDIATELY, 0); /* If all output streams are closed, and if the user doesn't have IVTV_DEC_STREAM_TYPE_VOUT open, then disable CC on TV-out. */ diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c b/drivers/media/video/ivtv/ivtv-ioctl.c index ecafa69..b3a554f 100644 --- a/drivers/media/video/ivtv/ivtv-ioctl.c +++ b/drivers/media/video/ivtv/ivtv-ioctl.c @@ -244,19 +244,21 @@ static int ivtv_validate_speed(int cur_speed, int new_speed) } static int ivtv_video_command(struct ivtv *itv, struct ivtv_open_id *id, - struct video_command *vc, int try) + struct v4l2_decoder_cmd *dc, int try) { struct ivtv_stream *s = &itv->streams[IVTV_DEC_STREAM_TYPE_MPG]; if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) return -EINVAL; - switch (vc->cmd) { - case VIDEO_CMD_PLAY: { - vc->flags = 0; - vc->play.speed = ivtv_validate_speed(itv->speed, vc->play.speed); - if (vc->play.speed < 0) - vc->play.format = VIDEO_PLAY_FMT_GOP; + switch (dc->cmd) { + case V4L2_DEC_CMD_START: { + dc->flags = 0; + dc->start.speed = ivtv_validate_speed(itv->speed, dc->start.speed); + if (dc->start.speed < 0) + dc->start.format = V4L2_DEC_START_FMT_GOP; + else + dc->start.format = V4L2_DEC_START_FMT_NONE; if (try) break; if (ivtv_set_output_mode(itv, OUT_MPG) != OUT_MPG) @@ -265,13 +267,13 @@ static int ivtv_video_command(struct ivtv *itv, struct ivtv_open_id *id, /* forces ivtv_set_speed to be called */ itv->speed = 0; } - return ivtv_start_decoding(id, vc->play.speed); + return ivtv_start_decoding(id, dc->start.speed); } - case VIDEO_CMD_STOP: - vc->flags &= VIDEO_CMD_STOP_IMMEDIATELY|VIDEO_CMD_STOP_TO_BLACK; - if (vc->flags & VIDEO_CMD_STOP_IMMEDIATELY) - vc->stop.pts = 0; + case V4L2_DEC_CMD_STOP: + dc->flags &= V4L2_DEC_CMD_STOP_IMMEDIATELY | V4L2_DEC_CMD_STOP_TO_BLACK; + if (dc->flags & V4L2_DEC_CMD_STOP_IMMEDIATELY) + dc->stop.pts = 0; if (try) break; if (atomic_read(&itv->decoding) == 0) return 0; @@ -279,22 +281,22 @@ static int ivtv_video_command(struct ivtv *itv, struct ivtv_open_id *id, return -EBUSY; itv->output_mode = OUT_NONE; - return ivtv_stop_v4l2_decode_stream(s, vc->flags, vc->stop.pts); + return ivtv_stop_v4l2_decode_stream(s, dc->flags, dc->stop.pts); - case VIDEO_CMD_FREEZE: - vc->flags &= VIDEO_CMD_FREEZE_TO_BLACK; + case V4L2_DEC_CMD_PAUSE: + dc->flags &= V4L2_DEC_CMD_PAUSE_TO_BLACK; if (try) break; if (itv->output_mode != OUT_MPG) return -EBUSY; if (atomic_read(&itv->decoding) > 0) { ivtv_vapi(itv, CX2341X_DEC_PAUSE_PLAYBACK, 1, - (vc->flags & VIDEO_CMD_FREEZE_TO_BLACK) ? 1 : 0); + (dc->flags & V4L2_DEC_CMD_PAUSE_TO_BLACK) ? 1 : 0); set_bit(IVTV_F_I_DEC_PAUSED, &itv->i_flags); } break; - case VIDEO_CMD_CONTINUE: - vc->flags = 0; + case V4L2_DEC_CMD_RESUME: + dc->flags = 0; if (try) break; if (itv->output_mode != OUT_MPG) return -EBUSY; @@ -1568,6 +1570,24 @@ static int ivtv_log_status(struct file *file, void *fh) return 0; } +static int ivtv_decoder_cmd(struct file *file, void *fh, struct v4l2_decoder_cmd *dec) +{ + struct ivtv_open_id *id = fh2id(file->private_data); + struct ivtv *itv = id->itv; + + IVTV_DEBUG_IOCTL("VIDIOC_DECODER_CMD %d\n", dec->cmd); + return ivtv_video_command(itv, id, dec, false); +} + +static int ivtv_try_decoder_cmd(struct file *file, void *fh, struct v4l2_decoder_cmd *dec) +{ + struct ivtv_open_id *id = fh2id(file->private_data); + struct ivtv *itv = id->itv; + + IVTV_DEBUG_IOCTL("VIDIOC_TRY_DECODER_CMD %d\n", dec->cmd); + return ivtv_video_command(itv, id, dec, true); +} + static int ivtv_decoder_ioctls(struct file *filp, unsigned int cmd, void *arg) { struct ivtv_open_id *id = fh2id(filp->private_data); @@ -1662,52 +1682,54 @@ static int ivtv_decoder_ioctls(struct file *filp, unsigned int cmd, void *arg) } case VIDEO_PLAY: { - struct video_command vc; + struct v4l2_decoder_cmd dc; IVTV_DEBUG_IOCTL("VIDEO_PLAY\n"); - memset(&vc, 0, sizeof(vc)); - vc.cmd = VIDEO_CMD_PLAY; - return ivtv_video_command(itv, id, &vc, 0); + memset(&dc, 0, sizeof(dc)); + dc.cmd = V4L2_DEC_CMD_START; + return ivtv_video_command(itv, id, &dc, 0); } case VIDEO_STOP: { - struct video_command vc; + struct v4l2_decoder_cmd dc; IVTV_DEBUG_IOCTL("VIDEO_STOP\n"); - memset(&vc, 0, sizeof(vc)); - vc.cmd = VIDEO_CMD_STOP; - vc.flags = VIDEO_CMD_STOP_TO_BLACK | VIDEO_CMD_STOP_IMMEDIATELY; - return ivtv_video_command(itv, id, &vc, 0); + memset(&dc, 0, sizeof(dc)); + dc.cmd = V4L2_DEC_CMD_STOP; + dc.flags = V4L2_DEC_CMD_STOP_TO_BLACK | V4L2_DEC_CMD_STOP_IMMEDIATELY; + return ivtv_video_command(itv, id, &dc, 0); } case VIDEO_FREEZE: { - struct video_command vc; + struct v4l2_decoder_cmd dc; IVTV_DEBUG_IOCTL("VIDEO_FREEZE\n"); - memset(&vc, 0, sizeof(vc)); - vc.cmd = VIDEO_CMD_FREEZE; - return ivtv_video_command(itv, id, &vc, 0); + memset(&dc, 0, sizeof(dc)); + dc.cmd = V4L2_DEC_CMD_PAUSE; + return ivtv_video_command(itv, id, &dc, 0); } case VIDEO_CONTINUE: { - struct video_command vc; + struct v4l2_decoder_cmd dc; IVTV_DEBUG_IOCTL("VIDEO_CONTINUE\n"); - memset(&vc, 0, sizeof(vc)); - vc.cmd = VIDEO_CMD_CONTINUE; - return ivtv_video_command(itv, id, &vc, 0); + memset(&dc, 0, sizeof(dc)); + dc.cmd = V4L2_DEC_CMD_RESUME; + return ivtv_video_command(itv, id, &dc, 0); } case VIDEO_COMMAND: case VIDEO_TRY_COMMAND: { - struct video_command *vc = arg; + /* Note: struct v4l2_decoder_cmd has the same layout as + struct video_command */ + struct v4l2_decoder_cmd *dc = arg; int try = (cmd == VIDEO_TRY_COMMAND); if (try) - IVTV_DEBUG_IOCTL("VIDEO_TRY_COMMAND %d\n", vc->cmd); + IVTV_DEBUG_IOCTL("VIDEO_TRY_COMMAND %d\n", dc->cmd); else - IVTV_DEBUG_IOCTL("VIDEO_COMMAND %d\n", vc->cmd); - return ivtv_video_command(itv, id, vc, try); + IVTV_DEBUG_IOCTL("VIDEO_COMMAND %d\n", dc->cmd); + return ivtv_video_command(itv, id, dc, try); } case VIDEO_GET_EVENT: { @@ -1901,6 +1923,8 @@ static const struct v4l2_ioctl_ops ivtv_ioctl_ops = { .vidioc_enum_fmt_vid_cap = ivtv_enum_fmt_vid_cap, .vidioc_encoder_cmd = ivtv_encoder_cmd, .vidioc_try_encoder_cmd = ivtv_try_encoder_cmd, + .vidioc_decoder_cmd = ivtv_decoder_cmd, + .vidioc_try_decoder_cmd = ivtv_try_decoder_cmd, .vidioc_enum_fmt_vid_out = ivtv_enum_fmt_vid_out, .vidioc_g_fmt_vid_cap = ivtv_g_fmt_vid_cap, .vidioc_g_fmt_vbi_cap = ivtv_g_fmt_vbi_cap, diff --git a/drivers/media/video/ivtv/ivtv-streams.c b/drivers/media/video/ivtv/ivtv-streams.c index e7794dc..75226b7 100644 --- a/drivers/media/video/ivtv/ivtv-streams.c +++ b/drivers/media/video/ivtv/ivtv-streams.c @@ -891,7 +891,7 @@ int ivtv_stop_v4l2_decode_stream(struct ivtv_stream *s, int flags, u64 pts) IVTV_DEBUG_INFO("Stop Decode at %llu, flags: %x\n", (unsigned long long)pts, flags); /* Stop Decoder */ - if (!(flags & VIDEO_CMD_STOP_IMMEDIATELY) || pts) { + if (!(flags & V4L2_DEC_CMD_STOP_IMMEDIATELY) || pts) { u32 tmp = 0; /* Wait until the decoder is no longer running */ @@ -911,7 +911,7 @@ int ivtv_stop_v4l2_decode_stream(struct ivtv_stream *s, int flags, u64 pts) break; } } - ivtv_vapi(itv, CX2341X_DEC_STOP_PLAYBACK, 3, flags & VIDEO_CMD_STOP_TO_BLACK, 0, 0); + ivtv_vapi(itv, CX2341X_DEC_STOP_PLAYBACK, 3, flags & V4L2_DEC_CMD_STOP_TO_BLACK, 0, 0); /* turn off notification of dual/stereo mode change */ ivtv_vapi(itv, CX2341X_DEC_SET_EVENT_NOTIFICATION, 4, 0, 0, IVTV_IRQ_DEC_AUD_MODE_CHG, -1); -- 1.7.7.3 ^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-11-23 19:44 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-11-23 11:54 [RFC PATCH 4/4] ivtv: implement new decoder command ioctls Martin Dauskardt 2011-11-23 12:14 ` Hans Verkuil 2011-11-23 12:51 ` Mauro Carvalho Chehab 2011-11-23 19:44 ` Martin Dauskardt -- strict thread matches above, loose matches on Subject: below -- 2011-11-23 11:12 [RFC PATCH 0/4] Replace VIDEO_COMMAND with VIDIOC_DECODER_CMD Hans Verkuil 2011-11-23 11:12 ` [RFC PATCH 1/4] v4l2: add VIDIOC_(TRY_)DECODER_CMD Hans Verkuil 2011-11-23 11:12 ` [RFC PATCH 4/4] ivtv: implement new decoder command ioctls Hans Verkuil
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox