From 24c19a217e543b6b4a7715229f0e1fcf4bbd2659 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Thu, 15 Dec 2011 10:46:16 -0300 Subject: [media] v4l2-ctrls: add new controls for MPEG decoder devices As discussed during the 2011 V4L-DVB workshop we want to create a proper V4L2 decoder API that replaces the DVBv5 API that has been used until now. This adds the four controls necessary to be able to switch ivtv over to this new API. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/v4l2-ctrls.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'drivers/media/video/v4l2-ctrls.c') diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c index cccd42be718a..94fbb5b50c74 100644 --- a/drivers/media/video/v4l2-ctrls.c +++ b/drivers/media/video/v4l2-ctrls.c @@ -175,6 +175,15 @@ const char * const *v4l2_ctrl_get_menu(u32 id) "16-bit CRC", NULL }; + static const char * const mpeg_audio_dec_playback[] = { + "Auto", + "Stereo", + "Left", + "Right", + "Mono", + "Swapped Stereo", + NULL + }; static const char * const mpeg_video_encoding[] = { "MPEG-1", "MPEG-2", @@ -374,6 +383,9 @@ const char * const *v4l2_ctrl_get_menu(u32 id) return mpeg_audio_emphasis; case V4L2_CID_MPEG_AUDIO_CRC: return mpeg_audio_crc; + case V4L2_CID_MPEG_AUDIO_DEC_PLAYBACK: + case V4L2_CID_MPEG_AUDIO_DEC_MULTILINGUAL_PLAYBACK: + return mpeg_audio_dec_playback; case V4L2_CID_MPEG_VIDEO_ENCODING: return mpeg_video_encoding; case V4L2_CID_MPEG_VIDEO_ASPECT: @@ -492,6 +504,8 @@ const char *v4l2_ctrl_get_name(u32 id) case V4L2_CID_MPEG_AUDIO_MUTE: return "Audio Mute"; case V4L2_CID_MPEG_AUDIO_AAC_BITRATE: return "Audio AAC Bitrate"; case V4L2_CID_MPEG_AUDIO_AC3_BITRATE: return "Audio AC-3 Bitrate"; + case V4L2_CID_MPEG_AUDIO_DEC_PLAYBACK: return "Audio Playback"; + case V4L2_CID_MPEG_AUDIO_DEC_MULTILINGUAL_PLAYBACK: return "Audio Multilingual Playback"; case V4L2_CID_MPEG_VIDEO_ENCODING: return "Video Encoding"; case V4L2_CID_MPEG_VIDEO_ASPECT: return "Video Aspect"; case V4L2_CID_MPEG_VIDEO_B_FRAMES: return "Video B Frames"; @@ -546,6 +560,8 @@ const char *v4l2_ctrl_get_name(u32 id) case V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_MB: return "Number of MBs in a Slice"; case V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MODE: return "Slice Partitioning Method"; case V4L2_CID_MPEG_VIDEO_VBV_SIZE: return "VBV Buffer Size"; + case V4L2_CID_MPEG_VIDEO_DEC_PTS: return "Video Decoder PTS"; + case V4L2_CID_MPEG_VIDEO_DEC_FRAME: return "Video Decoder Frame Count"; /* CAMERA controls */ /* Keep the order of the 'case's the same as in videodev2.h! */ @@ -674,6 +690,8 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, case V4L2_CID_MPEG_AUDIO_MODE_EXTENSION: case V4L2_CID_MPEG_AUDIO_EMPHASIS: case V4L2_CID_MPEG_AUDIO_CRC: + case V4L2_CID_MPEG_AUDIO_DEC_PLAYBACK: + case V4L2_CID_MPEG_AUDIO_DEC_MULTILINGUAL_PLAYBACK: case V4L2_CID_MPEG_VIDEO_ENCODING: case V4L2_CID_MPEG_VIDEO_ASPECT: case V4L2_CID_MPEG_VIDEO_BITRATE_MODE: @@ -724,6 +742,11 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, *type = V4L2_CTRL_TYPE_INTEGER; *flags |= V4L2_CTRL_FLAG_READ_ONLY; break; + case V4L2_CID_MPEG_VIDEO_DEC_FRAME: + case V4L2_CID_MPEG_VIDEO_DEC_PTS: + *type = V4L2_CTRL_TYPE_INTEGER64; + *flags |= V4L2_CTRL_FLAG_READ_ONLY | V4L2_CTRL_FLAG_VOLATILE; + break; default: *type = V4L2_CTRL_TYPE_INTEGER; break; -- cgit v1.2.3 From e2ecb257eebd8525029f43fcb4f922c4976dba53 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Thu, 2 Feb 2012 08:20:53 -0300 Subject: [media] v4l2: standardize log start/end message For drivers that properly use the v4l2 framework (i.e. set v4l2_dev in the video_device struct), the start and end messages of VIDIOC_LOG_STATUS are now generated automatically. People tended to forget these, but the v4l2-ctl tool scans for these messages, and it also makes it easier to read the status output in the kernel log. The cx18, ivtv and bttv drivers were changed since they no longer need to log these start/end messages. In saa7164 two empty log_status functions were removed. Also added a helper function to v4l2-ctrl.c that can be used as the vidioc_log_status callback if all you need to do is to log the current control values. This is now used by pwc and vivi. Signed-off-by: Hans Verkuil Cc: Steven Toth Cc: Andy Walls Cc: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/bt8xx/bttv-driver.c | 4 ---- drivers/media/video/cx18/cx18-ioctl.c | 4 ---- drivers/media/video/ivtv/ivtv-ioctl.c | 5 ----- drivers/media/video/pwc/pwc-v4l.c | 10 +--------- drivers/media/video/saa7164/saa7164-encoder.c | 6 ------ drivers/media/video/saa7164/saa7164-vbi.c | 6 ------ drivers/media/video/v4l2-ctrls.c | 12 ++++++++++++ drivers/media/video/v4l2-ioctl.c | 6 ++++++ drivers/media/video/vivi.c | 10 +--------- include/media/v4l2-ctrls.h | 4 ++++ 10 files changed, 24 insertions(+), 43 deletions(-) (limited to 'drivers/media/video/v4l2-ctrls.c') diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c index 76c301f05095..e581b37be789 100644 --- a/drivers/media/video/bt8xx/bttv-driver.c +++ b/drivers/media/video/bt8xx/bttv-driver.c @@ -2035,11 +2035,7 @@ static int bttv_log_status(struct file *file, void *f) struct bttv_fh *fh = f; struct bttv *btv = fh->btv; - pr_info("%d: ======== START STATUS CARD #%d ========\n", - btv->c.nr, btv->c.nr); bttv_call_all(btv, core, log_status); - pr_info("%d: ======== END STATUS CARD #%d ========\n", - btv->c.nr, btv->c.nr); return 0; } diff --git a/drivers/media/video/cx18/cx18-ioctl.c b/drivers/media/video/cx18/cx18-ioctl.c index 66b1c15c3541..be49f68ddf37 100644 --- a/drivers/media/video/cx18/cx18-ioctl.c +++ b/drivers/media/video/cx18/cx18-ioctl.c @@ -1085,8 +1085,6 @@ static int cx18_log_status(struct file *file, void *fh) struct v4l2_audio audin; int i; - CX18_INFO("================= START STATUS CARD #%d " - "=================\n", cx->instance); CX18_INFO("Version: %s Card: %s\n", CX18_VERSION, cx->card_name); if (cx->hw_flags & CX18_HW_TVEEPROM) { struct tveeprom tv; @@ -1120,8 +1118,6 @@ static int cx18_log_status(struct file *file, void *fh) CX18_INFO("Read MPEG/VBI: %lld/%lld bytes\n", (long long)cx->mpg_data_received, (long long)cx->vbi_data_inserted); - CX18_INFO("================== END STATUS CARD #%d " - "==================\n", cx->instance); return 0; } diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c b/drivers/media/video/ivtv/ivtv-ioctl.c index 37ac32b53baf..385e003fcfbb 100644 --- a/drivers/media/video/ivtv/ivtv-ioctl.c +++ b/drivers/media/video/ivtv/ivtv-ioctl.c @@ -1485,8 +1485,6 @@ static int ivtv_log_status(struct file *file, void *fh) struct v4l2_audio audin; int i; - IVTV_INFO("================= START STATUS CARD #%d =================\n", - itv->instance); IVTV_INFO("Version: %s Card: %s\n", IVTV_VERSION, itv->card_name); if (itv->hw_flags & IVTV_HW_TVEEPROM) { struct tveeprom tv; @@ -1568,9 +1566,6 @@ static int ivtv_log_status(struct file *file, void *fh) IVTV_INFO("Read MPG/VBI: %lld/%lld bytes\n", (long long)itv->mpg_data_received, (long long)itv->vbi_data_inserted); - IVTV_INFO("================== END STATUS CARD #%d ==================\n", - itv->instance); - return 0; } diff --git a/drivers/media/video/pwc/pwc-v4l.c b/drivers/media/video/pwc/pwc-v4l.c index f495eeb5403a..2834e3e65b39 100644 --- a/drivers/media/video/pwc/pwc-v4l.c +++ b/drivers/media/video/pwc/pwc-v4l.c @@ -1146,14 +1146,6 @@ leave: return ret; } -static int pwc_log_status(struct file *file, void *priv) -{ - struct pwc_device *pdev = video_drvdata(file); - - v4l2_ctrl_handler_log_status(&pdev->ctrl_handler, PWC_NAME); - return 0; -} - const struct v4l2_ioctl_ops pwc_ioctl_ops = { .vidioc_querycap = pwc_querycap, .vidioc_enum_input = pwc_enum_input, @@ -1169,7 +1161,7 @@ const struct v4l2_ioctl_ops pwc_ioctl_ops = { .vidioc_dqbuf = pwc_dqbuf, .vidioc_streamon = pwc_streamon, .vidioc_streamoff = pwc_streamoff, - .vidioc_log_status = pwc_log_status, + .vidioc_log_status = v4l2_ctrl_log_status, .vidioc_enum_framesizes = pwc_enum_framesizes, .vidioc_enum_frameintervals = pwc_enum_frameintervals, .vidioc_g_parm = pwc_g_parm, diff --git a/drivers/media/video/saa7164/saa7164-encoder.c b/drivers/media/video/saa7164/saa7164-encoder.c index 2fd38a01887f..a9ed686ad08a 100644 --- a/drivers/media/video/saa7164/saa7164-encoder.c +++ b/drivers/media/video/saa7164/saa7164-encoder.c @@ -791,11 +791,6 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, return 0; } -static int vidioc_log_status(struct file *file, void *priv) -{ - return 0; -} - static int fill_queryctrl(struct saa7164_encoder_params *params, struct v4l2_queryctrl *c) { @@ -1347,7 +1342,6 @@ static const struct v4l2_ioctl_ops mpeg_ioctl_ops = { .vidioc_g_ext_ctrls = vidioc_g_ext_ctrls, .vidioc_s_ext_ctrls = vidioc_s_ext_ctrls, .vidioc_try_ext_ctrls = vidioc_try_ext_ctrls, - .vidioc_log_status = vidioc_log_status, .vidioc_queryctrl = vidioc_queryctrl, .vidioc_g_chip_ident = saa7164_g_chip_ident, #ifdef CONFIG_VIDEO_ADV_DEBUG diff --git a/drivers/media/video/saa7164/saa7164-vbi.c b/drivers/media/video/saa7164/saa7164-vbi.c index e2e034158718..273cf807401c 100644 --- a/drivers/media/video/saa7164/saa7164-vbi.c +++ b/drivers/media/video/saa7164/saa7164-vbi.c @@ -730,11 +730,6 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, return 0; } -static int vidioc_log_status(struct file *file, void *priv) -{ - return 0; -} - static int fill_queryctrl(struct saa7164_vbi_params *params, struct v4l2_queryctrl *c) { @@ -1256,7 +1251,6 @@ static const struct v4l2_ioctl_ops vbi_ioctl_ops = { .vidioc_g_ext_ctrls = vidioc_g_ext_ctrls, .vidioc_s_ext_ctrls = vidioc_s_ext_ctrls, .vidioc_try_ext_ctrls = vidioc_try_ext_ctrls, - .vidioc_log_status = vidioc_log_status, .vidioc_queryctrl = vidioc_queryctrl, #if 0 .vidioc_g_chip_ident = saa7164_g_chip_ident, diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c index 94fbb5b50c74..7d58e4d420cd 100644 --- a/drivers/media/video/v4l2-ctrls.c +++ b/drivers/media/video/v4l2-ctrls.c @@ -2382,3 +2382,15 @@ void v4l2_ctrl_del_event(struct v4l2_ctrl *ctrl, v4l2_ctrl_unlock(ctrl); } EXPORT_SYMBOL(v4l2_ctrl_del_event); + +int v4l2_ctrl_log_status(struct file *file, void *fh) +{ + struct video_device *vfd = video_devdata(file); + struct v4l2_fh *vfh = file->private_data; + + if (test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags) && vfd->v4l2_dev) + v4l2_ctrl_handler_log_status(vfh->ctrl_handler, + vfd->v4l2_dev->name); + return 0; +} +EXPORT_SYMBOL(v4l2_ctrl_log_status); diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c index a288ee6fd456..74cab51a66e0 100644 --- a/drivers/media/video/v4l2-ioctl.c +++ b/drivers/media/video/v4l2-ioctl.c @@ -1939,7 +1939,13 @@ static long __video_do_ioctl(struct file *file, { if (!ops->vidioc_log_status) break; + if (vfd->v4l2_dev) + pr_info("%s: ================= START STATUS =================\n", + vfd->v4l2_dev->name); ret = ops->vidioc_log_status(file, fh); + if (vfd->v4l2_dev) + pr_info("%s: ================== END STATUS ==================\n", + vfd->v4l2_dev->name); break; } #ifdef CONFIG_VIDEO_ADV_DEBUG diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c index 5578c1953585..64a3b5276ccf 100644 --- a/drivers/media/video/vivi.c +++ b/drivers/media/video/vivi.c @@ -959,14 +959,6 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) return vb2_streamoff(&dev->vb_vidq, i); } -static int vidioc_log_status(struct file *file, void *priv) -{ - struct vivi_dev *dev = video_drvdata(file); - - v4l2_ctrl_handler_log_status(&dev->ctrl_handler, dev->v4l2_dev.name); - return 0; -} - static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *i) { return 0; @@ -1210,7 +1202,7 @@ static const struct v4l2_ioctl_ops vivi_ioctl_ops = { .vidioc_s_input = vidioc_s_input, .vidioc_streamon = vidioc_streamon, .vidioc_streamoff = vidioc_streamoff, - .vidioc_log_status = vidioc_log_status, + .vidioc_log_status = v4l2_ctrl_log_status, .vidioc_subscribe_event = vidioc_subscribe_event, .vidioc_unsubscribe_event = v4l2_event_unsubscribe, }; diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h index eeb3df637144..5f246c277ff8 100644 --- a/include/media/v4l2-ctrls.h +++ b/include/media/v4l2-ctrls.h @@ -492,6 +492,10 @@ void v4l2_ctrl_add_event(struct v4l2_ctrl *ctrl, void v4l2_ctrl_del_event(struct v4l2_ctrl *ctrl, struct v4l2_subscribed_event *sev); +/* Can be used as a vidioc_log_status function that just dumps all controls + associated with the filehandle. */ +int v4l2_ctrl_log_status(struct file *file, void *fh); + /* Helpers for ioctl_ops. If hdl == NULL then they will all return -EINVAL. */ int v4l2_queryctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_queryctrl *qc); int v4l2_querymenu(struct v4l2_ctrl_handler *hdl, struct v4l2_querymenu *qm); -- cgit v1.2.3 From a26243b0e3726d2b39dc23dd2c8717c52a286af4 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Fri, 27 Jan 2012 16:18:42 -0300 Subject: [media] v4l2-ctrls: add helper functions for control events Many drivers just support control events, and most radio drivers just need to poll for control events. Add some functions to simplify those jobs. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/v4l2-ctrls.c | 20 ++++++++++++++++++++ include/media/v4l2-ctrls.h | 9 +++++++++ 2 files changed, 29 insertions(+) (limited to 'drivers/media/video/v4l2-ctrls.c') diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c index 7d58e4d420cd..909117203610 100644 --- a/drivers/media/video/v4l2-ctrls.c +++ b/drivers/media/video/v4l2-ctrls.c @@ -2394,3 +2394,23 @@ int v4l2_ctrl_log_status(struct file *file, void *fh) return 0; } EXPORT_SYMBOL(v4l2_ctrl_log_status); + +int v4l2_ctrl_subscribe_event(struct v4l2_fh *fh, + struct v4l2_event_subscription *sub) +{ + if (sub->type == V4L2_EVENT_CTRL) + return v4l2_event_subscribe(fh, sub, 0); + return -EINVAL; +} +EXPORT_SYMBOL(v4l2_ctrl_subscribe_event); + +unsigned int v4l2_ctrl_poll(struct file *file, struct poll_table_struct *wait) +{ + struct v4l2_fh *fh = file->private_data; + + if (v4l2_event_pending(fh)) + return POLLPRI; + poll_wait(file, &fh->wait, wait); + return 0; +} +EXPORT_SYMBOL(v4l2_ctrl_poll); diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h index 5f246c277ff8..3dbd06638506 100644 --- a/include/media/v4l2-ctrls.h +++ b/include/media/v4l2-ctrls.h @@ -33,6 +33,7 @@ struct video_device; struct v4l2_subdev; struct v4l2_subscribed_event; struct v4l2_fh; +struct poll_table_struct; /** struct v4l2_ctrl_ops - The control operations that the driver has to provide. * @g_volatile_ctrl: Get a new value for this control. Generally only relevant @@ -496,6 +497,14 @@ void v4l2_ctrl_del_event(struct v4l2_ctrl *ctrl, associated with the filehandle. */ int v4l2_ctrl_log_status(struct file *file, void *fh); +/* Can be used as a vidioc_subscribe_event function that just subscribes + control events. */ +int v4l2_ctrl_subscribe_event(struct v4l2_fh *fh, + struct v4l2_event_subscription *sub); + +/* Can be used as a poll function that just polls for control events. */ +unsigned int v4l2_ctrl_poll(struct file *file, struct poll_table_struct *wait); + /* Helpers for ioctl_ops. If hdl == NULL then they will all return -EINVAL. */ int v4l2_queryctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_queryctrl *qc); int v4l2_querymenu(struct v4l2_ctrl_handler *hdl, struct v4l2_querymenu *qm); -- cgit v1.2.3 From c7361ae1e7a5a5395693f1f978af032c41cdb10d Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Fri, 20 Jan 2012 15:37:44 -0300 Subject: [media] V4L: Add JPEG compression control class The V4L2_CID_JPEG_CLASS control class is intended to expose various adjustable parameters of JPEG encoders and decoders. Following controls are defined: - V4L2_CID_JPEG_CHROMA_SUBSAMPLING, - V4L2_CID_JPEG_RESTART_INTERVAL, - V4L2_CID_JPEG_COMPRESSION_QUALITY, - V4L2_CID_JPEG_ACTIVE_MARKER. This covers only a part of relevant standard specifications. More controls should be added in future if required. The purpose of V4L2_CID_JPEG_CLASS class is also to replace some functionality covered by VIDIOC_S/G_JPEGCOMP ioctls, i.e. the JPEG markers presence and compression quality control. The applications and drivers should switch from the ioctl to control based API, as described in the subsequent patches for the Media API DocBook. Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/v4l2-ctrls.c | 24 ++++++++++++++++++++++++ include/linux/videodev2.h | 24 ++++++++++++++++++++++++ 2 files changed, 48 insertions(+) (limited to 'drivers/media/video/v4l2-ctrls.c') diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c index 909117203610..e6c7c8e8cc4e 100644 --- a/drivers/media/video/v4l2-ctrls.c +++ b/drivers/media/video/v4l2-ctrls.c @@ -362,6 +362,16 @@ const char * const *v4l2_ctrl_get_menu(u32 id) NULL, }; + static const char * const jpeg_chroma_subsampling[] = { + "4:4:4", + "4:2:2", + "4:2:0", + "4:1:1", + "4:1:0", + "Gray", + NULL, + }; + switch (id) { case V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ: return mpeg_audio_sampling_freq; @@ -426,6 +436,9 @@ const char * const *v4l2_ctrl_get_menu(u32 id) return mpeg_mpeg4_level; case V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE: return mpeg4_profile; + case V4L2_CID_JPEG_CHROMA_SUBSAMPLING: + return jpeg_chroma_subsampling; + default: return NULL; } @@ -623,6 +636,14 @@ const char *v4l2_ctrl_get_name(u32 id) case V4L2_CID_FLASH_CHARGE: return "Charge"; case V4L2_CID_FLASH_READY: return "Ready to Strobe"; + /* JPEG encoder controls */ + /* Keep the order of the 'case's the same as in videodev2.h! */ + case V4L2_CID_JPEG_CLASS: return "JPEG Compression Controls"; + case V4L2_CID_JPEG_CHROMA_SUBSAMPLING: return "Chroma Subsampling"; + case V4L2_CID_JPEG_RESTART_INTERVAL: return "Restart Interval"; + case V4L2_CID_JPEG_COMPRESSION_QUALITY: return "Compression Quality"; + case V4L2_CID_JPEG_ACTIVE_MARKER: return "Active Markers"; + default: return NULL; } @@ -711,6 +732,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, case V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_IDC: case V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL: case V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE: + case V4L2_CID_JPEG_CHROMA_SUBSAMPLING: *type = V4L2_CTRL_TYPE_MENU; break; case V4L2_CID_RDS_TX_PS_NAME: @@ -722,6 +744,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, case V4L2_CID_MPEG_CLASS: case V4L2_CID_FM_TX_CLASS: case V4L2_CID_FLASH_CLASS: + case V4L2_CID_JPEG_CLASS: *type = V4L2_CTRL_TYPE_CTRL_CLASS; /* You can neither read not write these */ *flags |= V4L2_CTRL_FLAG_READ_ONLY | V4L2_CTRL_FLAG_WRITE_ONLY; @@ -735,6 +758,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, *max = 0xFFFFFF; break; case V4L2_CID_FLASH_FAULT: + case V4L2_CID_JPEG_ACTIVE_MARKER: *type = V4L2_CTRL_TYPE_BITMASK; break; case V4L2_CID_MIN_BUFFERS_FOR_CAPTURE: diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h index b739d7d6f7e7..3fab6cacccbe 100644 --- a/include/linux/videodev2.h +++ b/include/linux/videodev2.h @@ -1136,6 +1136,7 @@ struct v4l2_ext_controls { #define V4L2_CTRL_CLASS_CAMERA 0x009a0000 /* Camera class controls */ #define V4L2_CTRL_CLASS_FM_TX 0x009b0000 /* FM Modulator control class */ #define V4L2_CTRL_CLASS_FLASH 0x009c0000 /* Camera flash controls */ +#define V4L2_CTRL_CLASS_JPEG 0x009d0000 /* JPEG-compression controls */ #define V4L2_CTRL_ID_MASK (0x0fffffff) #define V4L2_CTRL_ID2CLASS(id) ((id) & 0x0fff0000UL) @@ -1758,6 +1759,29 @@ enum v4l2_flash_strobe_source { #define V4L2_CID_FLASH_CHARGE (V4L2_CID_FLASH_CLASS_BASE + 11) #define V4L2_CID_FLASH_READY (V4L2_CID_FLASH_CLASS_BASE + 12) +/* JPEG-class control IDs defined by V4L2 */ +#define V4L2_CID_JPEG_CLASS_BASE (V4L2_CTRL_CLASS_JPEG | 0x900) +#define V4L2_CID_JPEG_CLASS (V4L2_CTRL_CLASS_JPEG | 1) + +#define V4L2_CID_JPEG_CHROMA_SUBSAMPLING (V4L2_CID_JPEG_CLASS_BASE + 1) +enum v4l2_jpeg_chroma_subsampling { + V4L2_JPEG_CHROMA_SUBSAMPLING_444 = 0, + V4L2_JPEG_CHROMA_SUBSAMPLING_422 = 1, + V4L2_JPEG_CHROMA_SUBSAMPLING_420 = 2, + V4L2_JPEG_CHROMA_SUBSAMPLING_411 = 3, + V4L2_JPEG_CHROMA_SUBSAMPLING_410 = 4, + V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY = 5, +}; +#define V4L2_CID_JPEG_RESTART_INTERVAL (V4L2_CID_JPEG_CLASS_BASE + 2) +#define V4L2_CID_JPEG_COMPRESSION_QUALITY (V4L2_CID_JPEG_CLASS_BASE + 3) + +#define V4L2_CID_JPEG_ACTIVE_MARKER (V4L2_CID_JPEG_CLASS_BASE + 4) +#define V4L2_JPEG_ACTIVE_MARKER_APP0 (1 << 0) +#define V4L2_JPEG_ACTIVE_MARKER_APP1 (1 << 1) +#define V4L2_JPEG_ACTIVE_MARKER_COM (1 << 16) +#define V4L2_JPEG_ACTIVE_MARKER_DQT (1 << 17) +#define V4L2_JPEG_ACTIVE_MARKER_DHT (1 << 18) + /* * T U N I N G */ -- cgit v1.2.3 From 072e660257ee26e4f4defd836b1e1fa23d68de32 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Fri, 2 Mar 2012 12:41:25 -0300 Subject: [media] v4l2-ctrls: v4l2_ctrl_add_handler should add all refs Currently v4l2_ctrl_add_handler adds only the controls that are owned by the handler. This is wrong. Instead all controls, whether owned or not, should be added. This is also implied by the v4l2-controls.txt documentation and it is clearly the right thing to do. The only reason this was never noticed before is because we never did this. Only recent changes in ivtv made this error visible because there a third handler layer was added (handler A inherits from handler B which inherits from C, D and E). Without this change handler A only sees the controls owned by handler B and the controls from C, D and E are missing. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/v4l2-ctrls.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'drivers/media/video/v4l2-ctrls.c') diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c index e6c7c8e8cc4e..88cb2c6e5d23 100644 --- a/drivers/media/video/v4l2-ctrls.c +++ b/drivers/media/video/v4l2-ctrls.c @@ -1517,7 +1517,7 @@ EXPORT_SYMBOL(v4l2_ctrl_add_ctrl); int v4l2_ctrl_add_handler(struct v4l2_ctrl_handler *hdl, struct v4l2_ctrl_handler *add) { - struct v4l2_ctrl *ctrl; + struct v4l2_ctrl_ref *ref; int ret = 0; /* Do nothing if either handler is NULL or if they are the same */ @@ -1526,7 +1526,9 @@ int v4l2_ctrl_add_handler(struct v4l2_ctrl_handler *hdl, if (hdl->error) return hdl->error; mutex_lock(&add->lock); - list_for_each_entry(ctrl, &add->ctrls, node) { + list_for_each_entry(ref, &add->ctrl_refs, node) { + struct v4l2_ctrl *ctrl = ref->ctrl; + /* Skip handler-private controls. */ if (ctrl->is_private) continue; -- cgit v1.2.3 From f769c26085ee0945fba3ba0ea48781770a8c81e2 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Fri, 2 Mar 2012 04:20:19 -0300 Subject: [media] Two small string fixes in v4l2-ctrls.c Fix one typo and use 'Microseconds' instead of 'useconds' in the pre-emphasis descriptions. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/v4l2-ctrls.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/media/video/v4l2-ctrls.c') diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c index 88cb2c6e5d23..18015c0a8d31 100644 --- a/drivers/media/video/v4l2-ctrls.c +++ b/drivers/media/video/v4l2-ctrls.c @@ -245,8 +245,8 @@ const char * const *v4l2_ctrl_get_menu(u32 id) }; static const char * const tune_preemphasis[] = { "No Preemphasis", - "50 useconds", - "75 useconds", + "50 Microseconds", + "75 Microseconds", NULL, }; static const char * const header_mode[] = { @@ -343,7 +343,7 @@ const char * const *v4l2_ctrl_get_menu(u32 id) }; static const char * const mpeg4_profile[] = { "Simple", - "Adcanved Simple", + "Advanced Simple", "Core", "Simple Scalable", "Advanced Coding Efficency", -- cgit v1.2.3