aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/cx2341x.c
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2007-04-27 11:31:00 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-04-27 14:43:18 -0400
commit5eee72e88416ef11f55791626440ac3c9018c4c0 (patch)
tree0d4f7a69f2ec75c95a459d5ef6ab461e6750910a /drivers/media/video/cx2341x.c
parentb7eee616ad8db5db5441a7d82083003df3ab6d3b (diff)
V4L/DVB (5268): Add support for three new MPEG controls.
Added V4L2_CID_MPEG_AUDIO_MUTE, V4L2_CID_MPEG_VIDEO_MUTE and V4L2_CID_MPEG_CX2341X_STREAM_INSERT_NAV_PACKETS controls together with their implementation in the cx2341x module. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/cx2341x.c')
-rw-r--r--drivers/media/video/cx2341x.c72
1 files changed, 67 insertions, 5 deletions
diff --git a/drivers/media/video/cx2341x.c b/drivers/media/video/cx2341x.c
index d60cd5ecf821..88dbdddeec42 100644
--- a/drivers/media/video/cx2341x.c
+++ b/drivers/media/video/cx2341x.c
@@ -51,6 +51,7 @@ const u32 cx2341x_mpeg_ctrls[] = {
51 V4L2_CID_MPEG_AUDIO_MODE_EXTENSION, 51 V4L2_CID_MPEG_AUDIO_MODE_EXTENSION,
52 V4L2_CID_MPEG_AUDIO_EMPHASIS, 52 V4L2_CID_MPEG_AUDIO_EMPHASIS,
53 V4L2_CID_MPEG_AUDIO_CRC, 53 V4L2_CID_MPEG_AUDIO_CRC,
54 V4L2_CID_MPEG_AUDIO_MUTE,
54 V4L2_CID_MPEG_VIDEO_ENCODING, 55 V4L2_CID_MPEG_VIDEO_ENCODING,
55 V4L2_CID_MPEG_VIDEO_ASPECT, 56 V4L2_CID_MPEG_VIDEO_ASPECT,
56 V4L2_CID_MPEG_VIDEO_B_FRAMES, 57 V4L2_CID_MPEG_VIDEO_B_FRAMES,
@@ -60,6 +61,8 @@ const u32 cx2341x_mpeg_ctrls[] = {
60 V4L2_CID_MPEG_VIDEO_BITRATE, 61 V4L2_CID_MPEG_VIDEO_BITRATE,
61 V4L2_CID_MPEG_VIDEO_BITRATE_PEAK, 62 V4L2_CID_MPEG_VIDEO_BITRATE_PEAK,
62 V4L2_CID_MPEG_VIDEO_TEMPORAL_DECIMATION, 63 V4L2_CID_MPEG_VIDEO_TEMPORAL_DECIMATION,
64 V4L2_CID_MPEG_VIDEO_MUTE,
65 V4L2_CID_MPEG_VIDEO_MUTE_YUV,
63 V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE, 66 V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE,
64 V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER, 67 V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER,
65 V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE, 68 V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE,
@@ -71,6 +74,7 @@ const u32 cx2341x_mpeg_ctrls[] = {
71 V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_TOP, 74 V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_TOP,
72 V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_BOTTOM, 75 V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_BOTTOM,
73 V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_TOP, 76 V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_TOP,
77 V4L2_CID_MPEG_CX2341X_STREAM_INSERT_NAV_PACKETS,
74 0 78 0
75}; 79};
76 80
@@ -102,6 +106,9 @@ static int cx2341x_get_ctrl(struct cx2341x_mpeg_params *params,
102 case V4L2_CID_MPEG_AUDIO_CRC: 106 case V4L2_CID_MPEG_AUDIO_CRC:
103 ctrl->value = params->audio_crc; 107 ctrl->value = params->audio_crc;
104 break; 108 break;
109 case V4L2_CID_MPEG_AUDIO_MUTE:
110 ctrl->value = params->audio_mute;
111 break;
105 case V4L2_CID_MPEG_VIDEO_ENCODING: 112 case V4L2_CID_MPEG_VIDEO_ENCODING:
106 ctrl->value = params->video_encoding; 113 ctrl->value = params->video_encoding;
107 break; 114 break;
@@ -129,6 +136,12 @@ static int cx2341x_get_ctrl(struct cx2341x_mpeg_params *params,
129 case V4L2_CID_MPEG_VIDEO_TEMPORAL_DECIMATION: 136 case V4L2_CID_MPEG_VIDEO_TEMPORAL_DECIMATION:
130 ctrl->value = params->video_temporal_decimation; 137 ctrl->value = params->video_temporal_decimation;
131 break; 138 break;
139 case V4L2_CID_MPEG_VIDEO_MUTE:
140 ctrl->value = params->video_mute;
141 break;
142 case V4L2_CID_MPEG_VIDEO_MUTE_YUV:
143 ctrl->value = params->video_mute_yuv;
144 break;
132 case V4L2_CID_MPEG_STREAM_TYPE: 145 case V4L2_CID_MPEG_STREAM_TYPE:
133 ctrl->value = params->stream_type; 146 ctrl->value = params->stream_type;
134 break; 147 break;
@@ -168,6 +181,9 @@ static int cx2341x_get_ctrl(struct cx2341x_mpeg_params *params,
168 case V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_BOTTOM: 181 case V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_BOTTOM:
169 ctrl->value = params->video_chroma_median_filter_bottom; 182 ctrl->value = params->video_chroma_median_filter_bottom;
170 break; 183 break;
184 case V4L2_CID_MPEG_CX2341X_STREAM_INSERT_NAV_PACKETS:
185 ctrl->value = params->stream_insert_nav_packets;
186 break;
171 default: 187 default:
172 return -EINVAL; 188 return -EINVAL;
173 } 189 }
@@ -201,6 +217,9 @@ static int cx2341x_set_ctrl(struct cx2341x_mpeg_params *params,
201 case V4L2_CID_MPEG_AUDIO_CRC: 217 case V4L2_CID_MPEG_AUDIO_CRC:
202 params->audio_crc = ctrl->value; 218 params->audio_crc = ctrl->value;
203 break; 219 break;
220 case V4L2_CID_MPEG_AUDIO_MUTE:
221 params->audio_mute = ctrl->value;
222 break;
204 case V4L2_CID_MPEG_VIDEO_ASPECT: 223 case V4L2_CID_MPEG_VIDEO_ASPECT:
205 params->video_aspect = ctrl->value; 224 params->video_aspect = ctrl->value;
206 break; 225 break;
@@ -243,6 +262,12 @@ static int cx2341x_set_ctrl(struct cx2341x_mpeg_params *params,
243 case V4L2_CID_MPEG_VIDEO_TEMPORAL_DECIMATION: 262 case V4L2_CID_MPEG_VIDEO_TEMPORAL_DECIMATION:
244 params->video_temporal_decimation = ctrl->value; 263 params->video_temporal_decimation = ctrl->value;
245 break; 264 break;
265 case V4L2_CID_MPEG_VIDEO_MUTE:
266 params->video_mute = (ctrl->value != 0);
267 break;
268 case V4L2_CID_MPEG_VIDEO_MUTE_YUV:
269 params->video_mute_yuv = ctrl->value;
270 break;
246 case V4L2_CID_MPEG_STREAM_TYPE: 271 case V4L2_CID_MPEG_STREAM_TYPE:
247 params->stream_type = ctrl->value; 272 params->stream_type = ctrl->value;
248 params->video_encoding = 273 params->video_encoding =
@@ -290,6 +315,9 @@ static int cx2341x_set_ctrl(struct cx2341x_mpeg_params *params,
290 case V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_BOTTOM: 315 case V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_BOTTOM:
291 params->video_chroma_median_filter_bottom = ctrl->value; 316 params->video_chroma_median_filter_bottom = ctrl->value;
292 break; 317 break;
318 case V4L2_CID_MPEG_CX2341X_STREAM_INSERT_NAV_PACKETS:
319 params->stream_insert_nav_packets = ctrl->value;
320 break;
293 default: 321 default:
294 return -EINVAL; 322 return -EINVAL;
295 } 323 }
@@ -336,6 +364,9 @@ static int cx2341x_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 min, s32 ma
336 case V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_BOTTOM: 364 case V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_BOTTOM:
337 name = "Median Chroma Filter Minimum"; 365 name = "Median Chroma Filter Minimum";
338 break; 366 break;
367 case V4L2_CID_MPEG_CX2341X_STREAM_INSERT_NAV_PACKETS:
368 name = "Insert Navigation Packets";
369 break;
339 370
340 default: 371 default:
341 return v4l2_ctrl_query_fill(qctrl, min, max, step, def); 372 return v4l2_ctrl_query_fill(qctrl, min, max, step, def);
@@ -350,6 +381,12 @@ static int cx2341x_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 min, s32 ma
350 min = 0; 381 min = 0;
351 step = 1; 382 step = 1;
352 break; 383 break;
384 case V4L2_CID_MPEG_CX2341X_STREAM_INSERT_NAV_PACKETS:
385 qctrl->type = V4L2_CTRL_TYPE_BOOLEAN;
386 min = 0;
387 max = 1;
388 step = 1;
389 break;
353 default: 390 default:
354 qctrl->type = V4L2_CTRL_TYPE_INTEGER; 391 qctrl->type = V4L2_CTRL_TYPE_INTEGER;
355 break; 392 break;
@@ -505,6 +542,9 @@ int cx2341x_ctrl_query(struct cx2341x_mpeg_params *params, struct v4l2_queryctrl
505 qctrl->flags |= V4L2_CTRL_FLAG_INACTIVE; 542 qctrl->flags |= V4L2_CTRL_FLAG_INACTIVE;
506 return 0; 543 return 0;
507 544
545 case V4L2_CID_MPEG_CX2341X_STREAM_INSERT_NAV_PACKETS:
546 return cx2341x_ctrl_query_fill(qctrl, 0, 1, 1, 0);
547
508 default: 548 default:
509 return v4l2_ctrl_query_fill_std(qctrl); 549 return v4l2_ctrl_query_fill_std(qctrl);
510 550
@@ -656,6 +696,7 @@ void cx2341x_fill_defaults(struct cx2341x_mpeg_params *p)
656 /* stream */ 696 /* stream */
657 .stream_type = V4L2_MPEG_STREAM_TYPE_MPEG2_PS, 697 .stream_type = V4L2_MPEG_STREAM_TYPE_MPEG2_PS,
658 .stream_vbi_fmt = V4L2_MPEG_STREAM_VBI_FMT_NONE, 698 .stream_vbi_fmt = V4L2_MPEG_STREAM_VBI_FMT_NONE,
699 .stream_insert_nav_packets = 0,
659 700
660 /* audio */ 701 /* audio */
661 .audio_sampling_freq = V4L2_MPEG_AUDIO_SAMPLING_FREQ_48000, 702 .audio_sampling_freq = V4L2_MPEG_AUDIO_SAMPLING_FREQ_48000,
@@ -665,6 +706,7 @@ void cx2341x_fill_defaults(struct cx2341x_mpeg_params *p)
665 .audio_mode_extension = V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_4, 706 .audio_mode_extension = V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_4,
666 .audio_emphasis = V4L2_MPEG_AUDIO_EMPHASIS_NONE, 707 .audio_emphasis = V4L2_MPEG_AUDIO_EMPHASIS_NONE,
667 .audio_crc = V4L2_MPEG_AUDIO_CRC_NONE, 708 .audio_crc = V4L2_MPEG_AUDIO_CRC_NONE,
709 .audio_mute = 0,
668 710
669 /* video */ 711 /* video */
670 .video_encoding = V4L2_MPEG_VIDEO_ENCODING_MPEG_2, 712 .video_encoding = V4L2_MPEG_VIDEO_ENCODING_MPEG_2,
@@ -676,6 +718,8 @@ void cx2341x_fill_defaults(struct cx2341x_mpeg_params *p)
676 .video_bitrate = 6000000, 718 .video_bitrate = 6000000,
677 .video_bitrate_peak = 8000000, 719 .video_bitrate_peak = 8000000,
678 .video_temporal_decimation = 0, 720 .video_temporal_decimation = 0,
721 .video_mute = 0,
722 .video_mute_yuv = 0x008080, /* YCbCr value for black */
679 723
680 /* encoding filters */ 724 /* encoding filters */
681 .video_spatial_filter_mode = V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_MANUAL, 725 .video_spatial_filter_mode = V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_MANUAL,
@@ -779,6 +823,10 @@ int cx2341x_update(void *priv, cx2341x_mbox_func func,
779 err = cx2341x_api(priv, func, CX2341X_ENC_SET_AUDIO_PROPERTIES, 1, new->audio_properties); 823 err = cx2341x_api(priv, func, CX2341X_ENC_SET_AUDIO_PROPERTIES, 1, new->audio_properties);
780 if (err) return err; 824 if (err) return err;
781 } 825 }
826 if (old == NULL || old->audio_mute != new->audio_mute) {
827 err = cx2341x_api(priv, func, CX2341X_ENC_MUTE_AUDIO, 1, new->audio_mute);
828 if (err) return err;
829 }
782 if (old == NULL || old->video_bitrate_mode != new->video_bitrate_mode || 830 if (old == NULL || old->video_bitrate_mode != new->video_bitrate_mode ||
783 old->video_bitrate != new->video_bitrate || 831 old->video_bitrate != new->video_bitrate ||
784 old->video_bitrate_peak != new->video_bitrate_peak) { 832 old->video_bitrate_peak != new->video_bitrate_peak) {
@@ -826,6 +874,15 @@ int cx2341x_update(void *priv, cx2341x_mbox_func func,
826 new->video_temporal_decimation); 874 new->video_temporal_decimation);
827 if (err) return err; 875 if (err) return err;
828 } 876 }
877 if (old == NULL || old->video_mute != new->video_mute ||
878 (new->video_mute && old->video_mute_yuv != new->video_mute_yuv)) {
879 err = cx2341x_api(priv, func, CX2341X_ENC_MUTE_VIDEO, 1, new->video_mute | (new->video_mute_yuv << 8));
880 if (err) return err;
881 }
882 if (old == NULL || old->stream_insert_nav_packets != new->stream_insert_nav_packets) {
883 err = cx2341x_api(priv, func, CX2341X_ENC_MISC, 2, 7, new->stream_insert_nav_packets);
884 if (err) return err;
885 }
829 return 0; 886 return 0;
830} 887}
831 888
@@ -854,18 +911,22 @@ void cx2341x_log_status(struct cx2341x_mpeg_params *p, const char *prefix)
854 int temporal = p->video_temporal_filter; 911 int temporal = p->video_temporal_filter;
855 912
856 /* Stream */ 913 /* Stream */
857 printk(KERN_INFO "%s: Stream: %s\n", 914 printk(KERN_INFO "%s: Stream: %s",
858 prefix, 915 prefix,
859 cx2341x_menu_item(p, V4L2_CID_MPEG_STREAM_TYPE)); 916 cx2341x_menu_item(p, V4L2_CID_MPEG_STREAM_TYPE));
917 if (p->stream_insert_nav_packets)
918 printk(" (with navigation packets)");
919 printk("\n");
860 printk(KERN_INFO "%s: VBI Format: %s\n", 920 printk(KERN_INFO "%s: VBI Format: %s\n",
861 prefix, 921 prefix,
862 cx2341x_menu_item(p, V4L2_CID_MPEG_STREAM_VBI_FMT)); 922 cx2341x_menu_item(p, V4L2_CID_MPEG_STREAM_VBI_FMT));
863 923
864 /* Video */ 924 /* Video */
865 printk(KERN_INFO "%s: Video: %dx%d, %d fps\n", 925 printk(KERN_INFO "%s: Video: %dx%d, %d fps%s\n",
866 prefix, 926 prefix,
867 p->width / (is_mpeg1 ? 2 : 1), p->height / (is_mpeg1 ? 2 : 1), 927 p->width / (is_mpeg1 ? 2 : 1), p->height / (is_mpeg1 ? 2 : 1),
868 p->is_50hz ? 25 : 30); 928 p->is_50hz ? 25 : 30,
929 (p->video_mute) ? " (muted)" : "");
869 printk(KERN_INFO "%s: Video: %s, %s, %s, %d", 930 printk(KERN_INFO "%s: Video: %s, %s, %s, %d",
870 prefix, 931 prefix,
871 cx2341x_menu_item(p, V4L2_CID_MPEG_VIDEO_ENCODING), 932 cx2341x_menu_item(p, V4L2_CID_MPEG_VIDEO_ENCODING),
@@ -886,12 +947,13 @@ void cx2341x_log_status(struct cx2341x_mpeg_params *p, const char *prefix)
886 } 947 }
887 948
888 /* Audio */ 949 /* Audio */
889 printk(KERN_INFO "%s: Audio: %s, %s, %s, %s", 950 printk(KERN_INFO "%s: Audio: %s, %s, %s, %s%s",
890 prefix, 951 prefix,
891 cx2341x_menu_item(p, V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ), 952 cx2341x_menu_item(p, V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ),
892 cx2341x_menu_item(p, V4L2_CID_MPEG_AUDIO_ENCODING), 953 cx2341x_menu_item(p, V4L2_CID_MPEG_AUDIO_ENCODING),
893 cx2341x_menu_item(p, V4L2_CID_MPEG_AUDIO_L2_BITRATE), 954 cx2341x_menu_item(p, V4L2_CID_MPEG_AUDIO_L2_BITRATE),
894 cx2341x_menu_item(p, V4L2_CID_MPEG_AUDIO_MODE)); 955 cx2341x_menu_item(p, V4L2_CID_MPEG_AUDIO_MODE),
956 p->audio_mute ? " (muted)" : "");
895 if (p->audio_mode == V4L2_MPEG_AUDIO_MODE_JOINT_STEREO) { 957 if (p->audio_mode == V4L2_MPEG_AUDIO_MODE_JOINT_STEREO) {
896 printk(", %s", 958 printk(", %s",
897 cx2341x_menu_item(p, V4L2_CID_MPEG_AUDIO_MODE_EXTENSION)); 959 cx2341x_menu_item(p, V4L2_CID_MPEG_AUDIO_MODE_EXTENSION));