Lines Matching +full:gop +full:- +full:port +full:- +full:id

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * cx2341x - generic code for cx23415/6/8 based devices
17 #include <media/drv-intf/cx2341x.h>
18 #include <media/v4l2-common.h>
26 MODULE_PARM_DESC(debug, "Debug level (0-1)");
30 /* definitions for audio properties bits 29-28 */
35 static const char *cx2341x_get_name(u32 id) in cx2341x_get_name() argument
37 switch (id) { in cx2341x_get_name()
66 static const char **cx2341x_get_menu(u32 id) in cx2341x_get_menu() argument
79 "2D Symmetric non-separable", in cx2341x_get_menu()
104 switch (id) { in cx2341x_get_menu()
119 static void cx2341x_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, in cx2341x_ctrl_fill() argument
122 *name = cx2341x_get_name(id); in cx2341x_ctrl_fill()
125 switch (id) { in cx2341x_ctrl_fill()
144 switch (id) { in cx2341x_ctrl_fill()
167 /* Must be sorted from low to high control ID! */
211 .port = CX2341X_PORT_MEMORY,
263 /* Map the control ID to the correct field in the cx2341x_mpeg_params
264 struct. Return -EINVAL if the ID is unknown, else return 0. */
268 switch (ctrl->id) { in cx2341x_get_ctrl()
270 ctrl->value = params->audio_sampling_freq; in cx2341x_get_ctrl()
273 ctrl->value = params->audio_encoding; in cx2341x_get_ctrl()
276 ctrl->value = params->audio_l2_bitrate; in cx2341x_get_ctrl()
279 ctrl->value = params->audio_ac3_bitrate; in cx2341x_get_ctrl()
282 ctrl->value = params->audio_mode; in cx2341x_get_ctrl()
285 ctrl->value = params->audio_mode_extension; in cx2341x_get_ctrl()
288 ctrl->value = params->audio_emphasis; in cx2341x_get_ctrl()
291 ctrl->value = params->audio_crc; in cx2341x_get_ctrl()
294 ctrl->value = params->audio_mute; in cx2341x_get_ctrl()
297 ctrl->value = params->video_encoding; in cx2341x_get_ctrl()
300 ctrl->value = params->video_aspect; in cx2341x_get_ctrl()
303 ctrl->value = params->video_b_frames; in cx2341x_get_ctrl()
306 ctrl->value = params->video_gop_size; in cx2341x_get_ctrl()
309 ctrl->value = params->video_gop_closure; in cx2341x_get_ctrl()
312 ctrl->value = params->video_bitrate_mode; in cx2341x_get_ctrl()
315 ctrl->value = params->video_bitrate; in cx2341x_get_ctrl()
318 ctrl->value = params->video_bitrate_peak; in cx2341x_get_ctrl()
321 ctrl->value = params->video_temporal_decimation; in cx2341x_get_ctrl()
324 ctrl->value = params->video_mute; in cx2341x_get_ctrl()
327 ctrl->value = params->video_mute_yuv; in cx2341x_get_ctrl()
330 ctrl->value = params->stream_type; in cx2341x_get_ctrl()
333 ctrl->value = params->stream_vbi_fmt; in cx2341x_get_ctrl()
336 ctrl->value = params->video_spatial_filter_mode; in cx2341x_get_ctrl()
339 ctrl->value = params->video_spatial_filter; in cx2341x_get_ctrl()
342 ctrl->value = params->video_luma_spatial_filter_type; in cx2341x_get_ctrl()
345 ctrl->value = params->video_chroma_spatial_filter_type; in cx2341x_get_ctrl()
348 ctrl->value = params->video_temporal_filter_mode; in cx2341x_get_ctrl()
351 ctrl->value = params->video_temporal_filter; in cx2341x_get_ctrl()
354 ctrl->value = params->video_median_filter_type; in cx2341x_get_ctrl()
357 ctrl->value = params->video_luma_median_filter_top; in cx2341x_get_ctrl()
360 ctrl->value = params->video_luma_median_filter_bottom; in cx2341x_get_ctrl()
363 ctrl->value = params->video_chroma_median_filter_top; in cx2341x_get_ctrl()
366 ctrl->value = params->video_chroma_median_filter_bottom; in cx2341x_get_ctrl()
369 ctrl->value = params->stream_insert_nav_packets; in cx2341x_get_ctrl()
372 return -EINVAL; in cx2341x_get_ctrl()
377 /* Map the control ID to the correct field in the cx2341x_mpeg_params
378 struct. Return -EINVAL if the ID is unknown, else return 0. */
382 switch (ctrl->id) { in cx2341x_set_ctrl()
385 return -EBUSY; in cx2341x_set_ctrl()
386 params->audio_sampling_freq = ctrl->value; in cx2341x_set_ctrl()
390 return -EBUSY; in cx2341x_set_ctrl()
391 if (params->capabilities & CX2341X_CAP_HAS_AC3) in cx2341x_set_ctrl()
392 if (ctrl->value != V4L2_MPEG_AUDIO_ENCODING_LAYER_2 && in cx2341x_set_ctrl()
393 ctrl->value != V4L2_MPEG_AUDIO_ENCODING_AC3) in cx2341x_set_ctrl()
394 return -ERANGE; in cx2341x_set_ctrl()
395 params->audio_encoding = ctrl->value; in cx2341x_set_ctrl()
399 return -EBUSY; in cx2341x_set_ctrl()
400 params->audio_l2_bitrate = ctrl->value; in cx2341x_set_ctrl()
404 return -EBUSY; in cx2341x_set_ctrl()
405 if (!(params->capabilities & CX2341X_CAP_HAS_AC3)) in cx2341x_set_ctrl()
406 return -EINVAL; in cx2341x_set_ctrl()
407 params->audio_ac3_bitrate = ctrl->value; in cx2341x_set_ctrl()
410 params->audio_mode = ctrl->value; in cx2341x_set_ctrl()
413 params->audio_mode_extension = ctrl->value; in cx2341x_set_ctrl()
416 params->audio_emphasis = ctrl->value; in cx2341x_set_ctrl()
419 params->audio_crc = ctrl->value; in cx2341x_set_ctrl()
422 params->audio_mute = ctrl->value; in cx2341x_set_ctrl()
425 params->video_aspect = ctrl->value; in cx2341x_set_ctrl()
428 int b = ctrl->value + 1; in cx2341x_set_ctrl()
429 int gop = params->video_gop_size; in cx2341x_set_ctrl() local
430 params->video_b_frames = ctrl->value; in cx2341x_set_ctrl()
431 params->video_gop_size = b * ((gop + b - 1) / b); in cx2341x_set_ctrl()
432 /* Max GOP size = 34 */ in cx2341x_set_ctrl()
433 while (params->video_gop_size > 34) in cx2341x_set_ctrl()
434 params->video_gop_size -= b; in cx2341x_set_ctrl()
438 int b = params->video_b_frames + 1; in cx2341x_set_ctrl()
439 int gop = ctrl->value; in cx2341x_set_ctrl() local
440 params->video_gop_size = b * ((gop + b - 1) / b); in cx2341x_set_ctrl()
441 /* Max GOP size = 34 */ in cx2341x_set_ctrl()
442 while (params->video_gop_size > 34) in cx2341x_set_ctrl()
443 params->video_gop_size -= b; in cx2341x_set_ctrl()
444 ctrl->value = params->video_gop_size; in cx2341x_set_ctrl()
448 params->video_gop_closure = ctrl->value; in cx2341x_set_ctrl()
452 return -EBUSY; in cx2341x_set_ctrl()
453 /* MPEG-1 only allows CBR */ in cx2341x_set_ctrl()
454 if (params->video_encoding == V4L2_MPEG_VIDEO_ENCODING_MPEG_1 && in cx2341x_set_ctrl()
455 ctrl->value != V4L2_MPEG_VIDEO_BITRATE_MODE_CBR) in cx2341x_set_ctrl()
456 return -EINVAL; in cx2341x_set_ctrl()
457 params->video_bitrate_mode = ctrl->value; in cx2341x_set_ctrl()
461 return -EBUSY; in cx2341x_set_ctrl()
462 params->video_bitrate = ctrl->value; in cx2341x_set_ctrl()
466 return -EBUSY; in cx2341x_set_ctrl()
467 params->video_bitrate_peak = ctrl->value; in cx2341x_set_ctrl()
470 params->video_temporal_decimation = ctrl->value; in cx2341x_set_ctrl()
473 params->video_mute = (ctrl->value != 0); in cx2341x_set_ctrl()
476 params->video_mute_yuv = ctrl->value; in cx2341x_set_ctrl()
480 return -EBUSY; in cx2341x_set_ctrl()
481 params->stream_type = ctrl->value; in cx2341x_set_ctrl()
482 params->video_encoding = in cx2341x_set_ctrl()
483 (params->stream_type == V4L2_MPEG_STREAM_TYPE_MPEG1_SS || in cx2341x_set_ctrl()
484 params->stream_type == V4L2_MPEG_STREAM_TYPE_MPEG1_VCD) ? in cx2341x_set_ctrl()
487 if (params->video_encoding == V4L2_MPEG_VIDEO_ENCODING_MPEG_1) in cx2341x_set_ctrl()
488 /* MPEG-1 implies CBR */ in cx2341x_set_ctrl()
489 params->video_bitrate_mode = in cx2341x_set_ctrl()
493 params->stream_vbi_fmt = ctrl->value; in cx2341x_set_ctrl()
496 params->video_spatial_filter_mode = ctrl->value; in cx2341x_set_ctrl()
499 params->video_spatial_filter = ctrl->value; in cx2341x_set_ctrl()
502 params->video_luma_spatial_filter_type = ctrl->value; in cx2341x_set_ctrl()
505 params->video_chroma_spatial_filter_type = ctrl->value; in cx2341x_set_ctrl()
508 params->video_temporal_filter_mode = ctrl->value; in cx2341x_set_ctrl()
511 params->video_temporal_filter = ctrl->value; in cx2341x_set_ctrl()
514 params->video_median_filter_type = ctrl->value; in cx2341x_set_ctrl()
517 params->video_luma_median_filter_top = ctrl->value; in cx2341x_set_ctrl()
520 params->video_luma_median_filter_bottom = ctrl->value; in cx2341x_set_ctrl()
523 params->video_chroma_median_filter_top = ctrl->value; in cx2341x_set_ctrl()
526 params->video_chroma_median_filter_bottom = ctrl->value; in cx2341x_set_ctrl()
529 params->stream_insert_nav_packets = ctrl->value; in cx2341x_set_ctrl()
532 return -EINVAL; in cx2341x_set_ctrl()
542 switch (qctrl->id) { in cx2341x_ctrl_query_fill()
556 cx2341x_ctrl_fill(qctrl->id, &name, &qctrl->type, in cx2341x_ctrl_query_fill()
557 &min, &max, &step, &def, &qctrl->flags); in cx2341x_ctrl_query_fill()
558 qctrl->minimum = min; in cx2341x_ctrl_query_fill()
559 qctrl->maximum = max; in cx2341x_ctrl_query_fill()
560 qctrl->step = step; in cx2341x_ctrl_query_fill()
561 qctrl->default_value = def; in cx2341x_ctrl_query_fill()
562 qctrl->reserved[0] = qctrl->reserved[1] = 0; in cx2341x_ctrl_query_fill()
563 strscpy(qctrl->name, name, sizeof(qctrl->name)); in cx2341x_ctrl_query_fill()
576 switch (qctrl->id) { in cx2341x_ctrl_query()
586 if (params->capabilities & CX2341X_CAP_HAS_SLICED_VBI) in cx2341x_ctrl_query()
603 if (params->capabilities & CX2341X_CAP_HAS_AC3) { in cx2341x_ctrl_query()
628 if (params->capabilities & CX2341X_CAP_HAS_AC3 && in cx2341x_ctrl_query()
629 params->audio_encoding != V4L2_MPEG_AUDIO_ENCODING_LAYER_2) in cx2341x_ctrl_query()
630 qctrl->flags |= V4L2_CTRL_FLAG_INACTIVE; in cx2341x_ctrl_query()
645 params->audio_mode != V4L2_MPEG_AUDIO_MODE_JOINT_STEREO) in cx2341x_ctrl_query()
646 qctrl->flags |= V4L2_CTRL_FLAG_INACTIVE; in cx2341x_ctrl_query()
671 if (params->capabilities & CX2341X_CAP_HAS_AC3) { in cx2341x_ctrl_query()
672 if (params->audio_encoding != in cx2341x_ctrl_query()
674 qctrl->flags |= V4L2_CTRL_FLAG_INACTIVE; in cx2341x_ctrl_query()
676 qctrl->flags |= V4L2_CTRL_FLAG_DISABLED; in cx2341x_ctrl_query()
680 /* this setting is read-only for the cx2341x since the in cx2341x_ctrl_query()
682 MPEG-1/2 setting */ in cx2341x_ctrl_query()
688 qctrl->flags |= V4L2_CTRL_FLAG_READ_ONLY; in cx2341x_ctrl_query()
702 params->is_50hz ? 12 : 15); in cx2341x_ctrl_query()
713 params->video_encoding == V4L2_MPEG_VIDEO_ENCODING_MPEG_1) in cx2341x_ctrl_query()
714 qctrl->flags |= V4L2_CTRL_FLAG_INACTIVE; in cx2341x_ctrl_query()
723 params->video_bitrate_mode == in cx2341x_ctrl_query()
725 qctrl->flags |= V4L2_CTRL_FLAG_INACTIVE; in cx2341x_ctrl_query()
747 qctrl->flags |= V4L2_CTRL_FLAG_SLIDER; in cx2341x_ctrl_query()
748 if (params->video_spatial_filter_mode == in cx2341x_ctrl_query()
750 qctrl->flags |= V4L2_CTRL_FLAG_INACTIVE; in cx2341x_ctrl_query()
759 if (params->video_spatial_filter_mode == in cx2341x_ctrl_query()
761 qctrl->flags |= V4L2_CTRL_FLAG_INACTIVE; in cx2341x_ctrl_query()
770 if (params->video_spatial_filter_mode == in cx2341x_ctrl_query()
772 qctrl->flags |= V4L2_CTRL_FLAG_INACTIVE; in cx2341x_ctrl_query()
784 qctrl->flags |= V4L2_CTRL_FLAG_SLIDER; in cx2341x_ctrl_query()
785 if (params->video_temporal_filter_mode == in cx2341x_ctrl_query()
787 qctrl->flags |= V4L2_CTRL_FLAG_INACTIVE; in cx2341x_ctrl_query()
799 qctrl->flags |= V4L2_CTRL_FLAG_SLIDER; in cx2341x_ctrl_query()
800 if (params->video_median_filter_type == in cx2341x_ctrl_query()
802 qctrl->flags |= V4L2_CTRL_FLAG_INACTIVE; in cx2341x_ctrl_query()
808 qctrl->flags |= V4L2_CTRL_FLAG_SLIDER; in cx2341x_ctrl_query()
809 if (params->video_median_filter_type == in cx2341x_ctrl_query()
811 qctrl->flags |= V4L2_CTRL_FLAG_INACTIVE; in cx2341x_ctrl_query()
817 qctrl->flags |= V4L2_CTRL_FLAG_SLIDER; in cx2341x_ctrl_query()
818 if (params->video_median_filter_type == in cx2341x_ctrl_query()
820 qctrl->flags |= V4L2_CTRL_FLAG_INACTIVE; in cx2341x_ctrl_query()
826 qctrl->flags |= V4L2_CTRL_FLAG_SLIDER; in cx2341x_ctrl_query()
827 if (params->video_median_filter_type == in cx2341x_ctrl_query()
829 qctrl->flags |= V4L2_CTRL_FLAG_INACTIVE; in cx2341x_ctrl_query()
837 return -EINVAL; in cx2341x_ctrl_query()
843 const char * const *cx2341x_ctrl_get_menu(const struct cx2341x_mpeg_params *p, u32 id) in cx2341x_ctrl_get_menu() argument
846 "MPEG-2 Program Stream", in cx2341x_ctrl_get_menu()
848 "MPEG-1 System Stream", in cx2341x_ctrl_get_menu()
849 "MPEG-2 DVD-compatible Stream", in cx2341x_ctrl_get_menu()
850 "MPEG-1 VCD-compatible Stream", in cx2341x_ctrl_get_menu()
851 "MPEG-2 SVCD-compatible Stream", in cx2341x_ctrl_get_menu()
856 "MPEG-2 Program Stream", in cx2341x_ctrl_get_menu()
857 "MPEG-2 Transport Stream", in cx2341x_ctrl_get_menu()
858 "MPEG-1 System Stream", in cx2341x_ctrl_get_menu()
859 "MPEG-2 DVD-compatible Stream", in cx2341x_ctrl_get_menu()
860 "MPEG-1 VCD-compatible Stream", in cx2341x_ctrl_get_menu()
861 "MPEG-2 SVCD-compatible Stream", in cx2341x_ctrl_get_menu()
867 "MPEG-1/2 Layer II", in cx2341x_ctrl_get_menu()
870 "AC-3", in cx2341x_ctrl_get_menu()
874 switch (id) { in cx2341x_ctrl_get_menu()
876 return (p->capabilities & CX2341X_CAP_HAS_TS) ? in cx2341x_ctrl_get_menu()
879 return (p->capabilities & CX2341X_CAP_HAS_AC3) ? in cx2341x_ctrl_get_menu()
880 mpeg_audio_encoding_l2_ac3 : v4l2_ctrl_get_menu(id); in cx2341x_ctrl_get_menu()
889 return cx2341x_get_menu(id); in cx2341x_ctrl_get_menu()
891 return v4l2_ctrl_get_menu(id); in cx2341x_ctrl_get_menu()
898 params->audio_properties = in cx2341x_calc_audio_properties()
899 (params->audio_sampling_freq << 0) | in cx2341x_calc_audio_properties()
900 (params->audio_mode << 8) | in cx2341x_calc_audio_properties()
901 (params->audio_mode_extension << 10) | in cx2341x_calc_audio_properties()
902 (((params->audio_emphasis == V4L2_MPEG_AUDIO_EMPHASIS_CCITT_J17) in cx2341x_calc_audio_properties()
903 ? 3 : params->audio_emphasis) << 12) | in cx2341x_calc_audio_properties()
904 (params->audio_crc << 14); in cx2341x_calc_audio_properties()
906 if ((params->capabilities & CX2341X_CAP_HAS_AC3) && in cx2341x_calc_audio_properties()
907 params->audio_encoding == V4L2_MPEG_AUDIO_ENCODING_AC3) { in cx2341x_calc_audio_properties()
908 params->audio_properties |= in cx2341x_calc_audio_properties()
910 ((3 - V4L2_MPEG_AUDIO_ENCODING_LAYER_2) << 2) | in cx2341x_calc_audio_properties()
911 (params->audio_ac3_bitrate << 4) | in cx2341x_calc_audio_properties()
915 params->audio_properties |= in cx2341x_calc_audio_properties()
916 ((3 - params->audio_encoding) << 2) | in cx2341x_calc_audio_properties()
917 ((1 + params->audio_l2_bitrate) << 4); in cx2341x_calc_audio_properties()
927 if (qctrl->flags & V4L2_CTRL_FLAG_DISABLED) in v4l2_ctrl_check()
928 return -EINVAL; in v4l2_ctrl_check()
929 if (qctrl->flags & V4L2_CTRL_FLAG_GRABBED) in v4l2_ctrl_check()
930 return -EBUSY; in v4l2_ctrl_check()
931 if (qctrl->type == V4L2_CTRL_TYPE_STRING) in v4l2_ctrl_check()
933 if (qctrl->type == V4L2_CTRL_TYPE_BUTTON || in v4l2_ctrl_check()
934 qctrl->type == V4L2_CTRL_TYPE_INTEGER64 || in v4l2_ctrl_check()
935 qctrl->type == V4L2_CTRL_TYPE_CTRL_CLASS) in v4l2_ctrl_check()
937 if (ctrl->value < qctrl->minimum || ctrl->value > qctrl->maximum) in v4l2_ctrl_check()
938 return -ERANGE; in v4l2_ctrl_check()
939 if (qctrl->type == V4L2_CTRL_TYPE_MENU && menu_items != NULL) { in v4l2_ctrl_check()
940 if (menu_items[ctrl->value] == NULL || in v4l2_ctrl_check()
941 menu_items[ctrl->value][0] == '\0') in v4l2_ctrl_check()
942 return -EINVAL; in v4l2_ctrl_check()
944 if (qctrl->type == V4L2_CTRL_TYPE_BITMASK && in v4l2_ctrl_check()
945 (ctrl->value & ~qctrl->maximum)) in v4l2_ctrl_check()
946 return -ERANGE; in v4l2_ctrl_check()
957 for (i = 0; i < ctrls->count; i++) { in cx2341x_ext_ctrls()
958 struct v4l2_ext_control *ctrl = ctrls->controls + i; in cx2341x_ext_ctrls()
962 ctrls->error_idx = i; in cx2341x_ext_ctrls()
968 for (i = 0; i < ctrls->count; i++) { in cx2341x_ext_ctrls()
969 struct v4l2_ext_control *ctrl = ctrls->controls + i; in cx2341x_ext_ctrls()
973 qctrl.id = ctrl->id; in cx2341x_ext_ctrls()
978 menu_items = cx2341x_ctrl_get_menu(params, qctrl.id); in cx2341x_ext_ctrls()
987 params->video_bitrate_mode == V4L2_MPEG_VIDEO_BITRATE_MODE_VBR && in cx2341x_ext_ctrls()
988 params->video_bitrate_peak < params->video_bitrate) { in cx2341x_ext_ctrls()
989 err = -ERANGE; in cx2341x_ext_ctrls()
990 ctrls->error_idx = ctrls->count; in cx2341x_ext_ctrls()
993 ctrls->error_idx = i; in cx2341x_ext_ctrls()
1022 #define CMP_FIELD(__old, __new, __field) (__old->__field != __new->__field)
1029 0, /* MPEG-2 PS */ in cx2341x_update()
1030 1, /* MPEG-2 TS */ in cx2341x_update()
1031 2, /* MPEG-1 SS */ in cx2341x_update()
1038 cx2341x_api(priv, func, CX2341X_ENC_SET_OUTPUT_PORT, 2, new->port, 0); in cx2341x_update()
1043 new->is_50hz); in cx2341x_update()
1052 u16 w = new->width; in cx2341x_update()
1053 u16 h = new->height; in cx2341x_update()
1055 if (new->video_encoding == V4L2_MPEG_VIDEO_ENCODING_MPEG_1) { in cx2341x_update()
1067 mpeg_stream_type[new->stream_type]); in cx2341x_update()
1074 1 + new->video_aspect); in cx2341x_update()
1082 new->video_gop_size, new->video_b_frames + 1); in cx2341x_update()
1089 new->video_gop_closure); in cx2341x_update()
1096 1, new->audio_properties); in cx2341x_update()
1103 new->audio_mute); in cx2341x_update()
1112 new->video_bitrate_mode, new->video_bitrate, in cx2341x_update()
1113 new->video_bitrate_peak / 400, 0, 0); in cx2341x_update()
1123 new->video_spatial_filter_mode | in cx2341x_update()
1124 (new->video_temporal_filter_mode << 1), in cx2341x_update()
1125 new->video_median_filter_type); in cx2341x_update()
1135 new->video_luma_median_filter_bottom, in cx2341x_update()
1136 new->video_luma_median_filter_top, in cx2341x_update()
1137 new->video_chroma_median_filter_bottom, in cx2341x_update()
1138 new->video_chroma_median_filter_top); in cx2341x_update()
1147 2, new->video_luma_spatial_filter_type, in cx2341x_update()
1148 new->video_chroma_spatial_filter_type); in cx2341x_update()
1156 2, new->video_spatial_filter, in cx2341x_update()
1157 new->video_temporal_filter); in cx2341x_update()
1164 1, new->video_temporal_decimation); in cx2341x_update()
1170 (new->video_mute && CMP_FIELD(old, new, video_mute_yuv))) { in cx2341x_update()
1172 new->video_mute | (new->video_mute_yuv << 8)); in cx2341x_update()
1179 7, new->stream_insert_nav_packets); in cx2341x_update()
1187 static const char *cx2341x_menu_item(const struct cx2341x_mpeg_params *p, u32 id) in cx2341x_menu_item() argument
1189 const char * const *menu = cx2341x_ctrl_get_menu(p, id); in cx2341x_menu_item()
1194 ctrl.id = id; in cx2341x_menu_item()
1197 while (ctrl.value-- && *menu) menu++; in cx2341x_menu_item()
1208 int is_mpeg1 = p->video_encoding == V4L2_MPEG_VIDEO_ENCODING_MPEG_1; in cx2341x_log_status()
1214 if (p->stream_insert_nav_packets) in cx2341x_log_status()
1224 p->width / (is_mpeg1 ? 2 : 1), p->height / (is_mpeg1 ? 2 : 1), in cx2341x_log_status()
1225 p->is_50hz ? 25 : 30, in cx2341x_log_status()
1226 (p->video_mute) ? " (muted)" : ""); in cx2341x_log_status()
1232 p->video_bitrate); in cx2341x_log_status()
1233 if (p->video_bitrate_mode == V4L2_MPEG_VIDEO_BITRATE_MODE_VBR) in cx2341x_log_status()
1234 printk(KERN_CONT ", Peak %d", p->video_bitrate_peak); in cx2341x_log_status()
1237 "%s: Video: GOP Size %d, %d B-Frames, %sGOP Closure\n", in cx2341x_log_status()
1239 p->video_gop_size, p->video_b_frames, in cx2341x_log_status()
1240 p->video_gop_closure ? "" : "No "); in cx2341x_log_status()
1241 if (p->video_temporal_decimation) in cx2341x_log_status()
1243 prefix, p->video_temporal_decimation); in cx2341x_log_status()
1251 p->audio_encoding == V4L2_MPEG_AUDIO_ENCODING_AC3 in cx2341x_log_status()
1255 p->audio_mute ? " (muted)" : ""); in cx2341x_log_status()
1256 if (p->audio_mode == V4L2_MPEG_AUDIO_MODE_JOINT_STEREO) in cx2341x_log_status()
1272 p->video_spatial_filter); in cx2341x_log_status()
1278 p->video_temporal_filter); in cx2341x_log_status()
1284 p->video_luma_median_filter_bottom, in cx2341x_log_status()
1285 p->video_luma_median_filter_top, in cx2341x_log_status()
1286 p->video_chroma_median_filter_bottom, in cx2341x_log_status()
1287 p->video_chroma_median_filter_top); in cx2341x_log_status()
1297 return container_of(ctrl->handler, struct cx2341x_handler, hdl); in to_cxhdl()
1312 return hdl->func(hdl->priv, cmd, args, 0, data); in cx2341x_hdl_api()
1315 /* ctrl->handler->lock is held, so it is safe to access cur.val */
1318 return ctrl && ctrl->val != ctrl->cur.val; in cx2341x_neq()
1324 s32 val = ctrl->val; in cx2341x_try_ctrl()
1326 switch (ctrl->id) { in cx2341x_try_ctrl()
1328 /* video gop cluster */ in cx2341x_try_ctrl()
1330 int gop = hdl->video_gop_size->val; in cx2341x_try_ctrl() local
1332 gop = b * ((gop + b - 1) / b); in cx2341x_try_ctrl()
1334 /* Max GOP size = 34 */ in cx2341x_try_ctrl()
1335 while (gop > 34) in cx2341x_try_ctrl()
1336 gop -= b; in cx2341x_try_ctrl()
1337 hdl->video_gop_size->val = gop; in cx2341x_try_ctrl()
1343 hdl->video_encoding->val = in cx2341x_try_ctrl()
1344 (hdl->stream_type->val == V4L2_MPEG_STREAM_TYPE_MPEG1_SS || in cx2341x_try_ctrl()
1345 hdl->stream_type->val == V4L2_MPEG_STREAM_TYPE_MPEG1_VCD) ? in cx2341x_try_ctrl()
1348 if (hdl->video_encoding->val == V4L2_MPEG_VIDEO_ENCODING_MPEG_1) in cx2341x_try_ctrl()
1349 /* MPEG-1 implies CBR */ in cx2341x_try_ctrl()
1350 hdl->video_bitrate_mode->val = in cx2341x_try_ctrl()
1353 if (hdl->video_bitrate_mode->val == V4L2_MPEG_VIDEO_BITRATE_MODE_VBR && in cx2341x_try_ctrl()
1354 hdl->video_bitrate_peak->val < hdl->video_bitrate->val) in cx2341x_try_ctrl()
1355 hdl->video_bitrate_peak->val = hdl->video_bitrate->val; in cx2341x_try_ctrl()
1364 0, /* MPEG-2 PS */ in cx2341x_s_ctrl()
1365 1, /* MPEG-2 TS */ in cx2341x_s_ctrl()
1366 2, /* MPEG-1 SS */ in cx2341x_s_ctrl()
1372 s32 val = ctrl->val; in cx2341x_s_ctrl()
1376 switch (ctrl->id) { in cx2341x_s_ctrl()
1378 if (hdl->ops && hdl->ops->s_stream_vbi_fmt) in cx2341x_s_ctrl()
1379 return hdl->ops->s_stream_vbi_fmt(hdl, val); in cx2341x_s_ctrl()
1401 props = (hdl->audio_sampling_freq->val << 0) | in cx2341x_s_ctrl()
1402 (hdl->audio_mode->val << 8) | in cx2341x_s_ctrl()
1403 (hdl->audio_mode_extension->val << 10) | in cx2341x_s_ctrl()
1404 (hdl->audio_crc->val << 14); in cx2341x_s_ctrl()
1405 if (hdl->audio_emphasis->val == V4L2_MPEG_AUDIO_EMPHASIS_CCITT_J17) in cx2341x_s_ctrl()
1408 props |= hdl->audio_emphasis->val << 12; in cx2341x_s_ctrl()
1410 if (hdl->audio_encoding->val == V4L2_MPEG_AUDIO_ENCODING_AC3) { in cx2341x_s_ctrl()
1414 ((3 - V4L2_MPEG_AUDIO_ENCODING_LAYER_2) << 2) | in cx2341x_s_ctrl()
1416 (hdl->audio_ac3_bitrate->val << 4) | in cx2341x_s_ctrl()
1421 ((3 - hdl->audio_encoding->val) << 2) | in cx2341x_s_ctrl()
1422 ((1 + hdl->audio_l2_bitrate->val) << 4); in cx2341x_s_ctrl()
1429 hdl->audio_properties = props; in cx2341x_s_ctrl()
1430 if (hdl->audio_ac3_bitrate) { in cx2341x_s_ctrl()
1431 int is_ac3 = hdl->audio_encoding->val == in cx2341x_s_ctrl()
1434 v4l2_ctrl_activate(hdl->audio_ac3_bitrate, is_ac3); in cx2341x_s_ctrl()
1435 v4l2_ctrl_activate(hdl->audio_l2_bitrate, !is_ac3); in cx2341x_s_ctrl()
1437 v4l2_ctrl_activate(hdl->audio_mode_extension, in cx2341x_s_ctrl()
1438 hdl->audio_mode->val == V4L2_MPEG_AUDIO_MODE_JOINT_STEREO); in cx2341x_s_ctrl()
1439 if (cx2341x_neq(hdl->audio_sampling_freq) && in cx2341x_s_ctrl()
1440 hdl->ops && hdl->ops->s_audio_sampling_freq) in cx2341x_s_ctrl()
1441 return hdl->ops->s_audio_sampling_freq(hdl, hdl->audio_sampling_freq->val); in cx2341x_s_ctrl()
1442 if (cx2341x_neq(hdl->audio_mode) && in cx2341x_s_ctrl()
1443 hdl->ops && hdl->ops->s_audio_mode) in cx2341x_s_ctrl()
1444 return hdl->ops->s_audio_mode(hdl, hdl->audio_mode->val); in cx2341x_s_ctrl()
1448 /* video gop cluster */ in cx2341x_s_ctrl()
1450 hdl->video_gop_size->val, in cx2341x_s_ctrl()
1451 hdl->video_b_frames->val + 1); in cx2341x_s_ctrl()
1461 hdl->video_bitrate_mode->val, in cx2341x_s_ctrl()
1462 hdl->video_bitrate->val, in cx2341x_s_ctrl()
1463 hdl->video_bitrate_peak->val / 400, 0, 0); in cx2341x_s_ctrl()
1467 v4l2_ctrl_activate(hdl->video_bitrate_mode, in cx2341x_s_ctrl()
1468 hdl->video_encoding->val != V4L2_MPEG_VIDEO_ENCODING_MPEG_1); in cx2341x_s_ctrl()
1469 v4l2_ctrl_activate(hdl->video_bitrate_peak, in cx2341x_s_ctrl()
1470 hdl->video_bitrate_mode->val != V4L2_MPEG_VIDEO_BITRATE_MODE_CBR); in cx2341x_s_ctrl()
1471 if (cx2341x_neq(hdl->video_encoding) && in cx2341x_s_ctrl()
1472 hdl->ops && hdl->ops->s_video_encoding) in cx2341x_s_ctrl()
1473 return hdl->ops->s_video_encoding(hdl, hdl->video_encoding->val); in cx2341x_s_ctrl()
1479 hdl->video_mute->val | in cx2341x_s_ctrl()
1480 (hdl->video_mute_yuv->val << 8)); in cx2341x_s_ctrl()
1487 hdl->video_spatial_filter_mode->val | in cx2341x_s_ctrl()
1488 (hdl->video_temporal_filter_mode->val << 1), in cx2341x_s_ctrl()
1489 hdl->video_median_filter_type->val); in cx2341x_s_ctrl()
1493 active_filter = hdl->video_spatial_filter_mode->val != in cx2341x_s_ctrl()
1495 v4l2_ctrl_activate(hdl->video_spatial_filter, active_filter); in cx2341x_s_ctrl()
1496 v4l2_ctrl_activate(hdl->video_luma_spatial_filter_type, active_filter); in cx2341x_s_ctrl()
1497 v4l2_ctrl_activate(hdl->video_chroma_spatial_filter_type, active_filter); in cx2341x_s_ctrl()
1498 active_filter = hdl->video_temporal_filter_mode->val != in cx2341x_s_ctrl()
1500 v4l2_ctrl_activate(hdl->video_temporal_filter, active_filter); in cx2341x_s_ctrl()
1501 active_filter = hdl->video_median_filter_type->val != in cx2341x_s_ctrl()
1503 v4l2_ctrl_activate(hdl->video_luma_median_filter_bottom, active_filter); in cx2341x_s_ctrl()
1504 v4l2_ctrl_activate(hdl->video_luma_median_filter_top, active_filter); in cx2341x_s_ctrl()
1505 v4l2_ctrl_activate(hdl->video_chroma_median_filter_bottom, active_filter); in cx2341x_s_ctrl()
1506 v4l2_ctrl_activate(hdl->video_chroma_median_filter_top, active_filter); in cx2341x_s_ctrl()
1514 hdl->video_luma_spatial_filter_type->val, in cx2341x_s_ctrl()
1515 hdl->video_chroma_spatial_filter_type->val); in cx2341x_s_ctrl()
1520 hdl->video_spatial_filter->val, in cx2341x_s_ctrl()
1521 hdl->video_temporal_filter->val); in cx2341x_s_ctrl()
1526 hdl->video_luma_median_filter_bottom->val, in cx2341x_s_ctrl()
1527 hdl->video_luma_median_filter_top->val, in cx2341x_s_ctrl()
1528 hdl->video_chroma_median_filter_bottom->val, in cx2341x_s_ctrl()
1529 hdl->video_chroma_median_filter_top->val); in cx2341x_s_ctrl()
1531 return -EINVAL; in cx2341x_s_ctrl()
1540 u32 id, s32 min, s32 max, s32 step, s32 def) in cx2341x_ctrl_new_custom() argument
1545 cx2341x_ctrl_fill(id, &cfg.name, &cfg.type, &min, &max, &step, &def, &cfg.flags); in cx2341x_ctrl_new_custom()
1547 cfg.id = id; in cx2341x_ctrl_new_custom()
1554 cfg.qmenu = cx2341x_get_menu(id); in cx2341x_ctrl_new_custom()
1563 u32 id, s32 min, s32 max, s32 step, s32 def) in cx2341x_ctrl_new_std() argument
1565 return v4l2_ctrl_new_std(hdl, &cx2341x_ops, id, min, max, step, def); in cx2341x_ctrl_new_std()
1569 u32 id, s32 max, s32 mask, s32 def) in cx2341x_ctrl_new_menu() argument
1571 return v4l2_ctrl_new_std_menu(hdl, &cx2341x_ops, id, max, mask, def); in cx2341x_ctrl_new_menu()
1577 struct v4l2_ctrl_handler *hdl = &cxhdl->hdl; in cx2341x_handler_init()
1578 u32 caps = cxhdl->capabilities; in cx2341x_handler_init()
1583 cxhdl->width = 720; in cx2341x_handler_init()
1584 cxhdl->height = 480; in cx2341x_handler_init()
1588 /* Add controls in ascending control ID order for fastest in cx2341x_handler_init()
1590 cxhdl->stream_type = cx2341x_ctrl_new_menu(hdl, in cx2341x_handler_init()
1594 cxhdl->stream_vbi_fmt = cx2341x_ctrl_new_menu(hdl, in cx2341x_handler_init()
1598 cxhdl->audio_sampling_freq = cx2341x_ctrl_new_menu(hdl, in cx2341x_handler_init()
1602 cxhdl->audio_encoding = cx2341x_ctrl_new_menu(hdl, in cx2341x_handler_init()
1606 cxhdl->audio_l2_bitrate = cx2341x_ctrl_new_menu(hdl, in cx2341x_handler_init()
1610 cxhdl->audio_mode = cx2341x_ctrl_new_menu(hdl, in cx2341x_handler_init()
1614 cxhdl->audio_mode_extension = cx2341x_ctrl_new_menu(hdl, in cx2341x_handler_init()
1618 cxhdl->audio_emphasis = cx2341x_ctrl_new_menu(hdl, in cx2341x_handler_init()
1622 cxhdl->audio_crc = cx2341x_ctrl_new_menu(hdl, in cx2341x_handler_init()
1629 cxhdl->audio_ac3_bitrate = cx2341x_ctrl_new_menu(hdl, in cx2341x_handler_init()
1633 cxhdl->video_encoding = cx2341x_ctrl_new_menu(hdl, in cx2341x_handler_init()
1641 cxhdl->video_b_frames = cx2341x_ctrl_new_std(hdl, in cx2341x_handler_init()
1643 cxhdl->video_gop_size = cx2341x_ctrl_new_std(hdl, in cx2341x_handler_init()
1645 1, 34, 1, cxhdl->is_50hz ? 12 : 15); in cx2341x_handler_init()
1647 cxhdl->video_bitrate_mode = cx2341x_ctrl_new_menu(hdl, in cx2341x_handler_init()
1651 cxhdl->video_bitrate = cx2341x_ctrl_new_std(hdl, in cx2341x_handler_init()
1654 cxhdl->video_bitrate_peak = cx2341x_ctrl_new_std(hdl, in cx2341x_handler_init()
1659 cxhdl->video_mute = cx2341x_ctrl_new_std(hdl, in cx2341x_handler_init()
1661 cxhdl->video_mute_yuv = cx2341x_ctrl_new_std(hdl, in cx2341x_handler_init()
1665 cxhdl->video_spatial_filter_mode = cx2341x_ctrl_new_custom(hdl, in cx2341x_handler_init()
1670 cxhdl->video_spatial_filter = cx2341x_ctrl_new_custom(hdl, in cx2341x_handler_init()
1673 cxhdl->video_luma_spatial_filter_type = cx2341x_ctrl_new_custom(hdl, in cx2341x_handler_init()
1679 cxhdl->video_chroma_spatial_filter_type = cx2341x_ctrl_new_custom(hdl, in cx2341x_handler_init()
1685 cxhdl->video_temporal_filter_mode = cx2341x_ctrl_new_custom(hdl, in cx2341x_handler_init()
1691 cxhdl->video_temporal_filter = cx2341x_ctrl_new_custom(hdl, in cx2341x_handler_init()
1694 cxhdl->video_median_filter_type = cx2341x_ctrl_new_custom(hdl, in cx2341x_handler_init()
1700 cxhdl->video_luma_median_filter_bottom = cx2341x_ctrl_new_custom(hdl, in cx2341x_handler_init()
1703 cxhdl->video_luma_median_filter_top = cx2341x_ctrl_new_custom(hdl, in cx2341x_handler_init()
1706 cxhdl->video_chroma_median_filter_bottom = cx2341x_ctrl_new_custom(hdl, in cx2341x_handler_init()
1709 cxhdl->video_chroma_median_filter_top = cx2341x_ctrl_new_custom(hdl, in cx2341x_handler_init()
1715 if (hdl->error) { in cx2341x_handler_init()
1716 int err = hdl->error; in cx2341x_handler_init()
1722 v4l2_ctrl_cluster(8, &cxhdl->audio_sampling_freq); in cx2341x_handler_init()
1723 v4l2_ctrl_cluster(2, &cxhdl->video_b_frames); in cx2341x_handler_init()
1724 v4l2_ctrl_cluster(5, &cxhdl->stream_type); in cx2341x_handler_init()
1725 v4l2_ctrl_cluster(2, &cxhdl->video_mute); in cx2341x_handler_init()
1726 v4l2_ctrl_cluster(3, &cxhdl->video_spatial_filter_mode); in cx2341x_handler_init()
1727 v4l2_ctrl_cluster(2, &cxhdl->video_luma_spatial_filter_type); in cx2341x_handler_init()
1728 v4l2_ctrl_cluster(2, &cxhdl->video_spatial_filter); in cx2341x_handler_init()
1729 v4l2_ctrl_cluster(4, &cxhdl->video_luma_median_filter_top); in cx2341x_handler_init()
1737 cxhdl->is_50hz = is_50hz; in cx2341x_handler_set_50hz()
1738 cxhdl->video_gop_size->default_value = cxhdl->is_50hz ? 12 : 15; in cx2341x_handler_set_50hz()
1744 int h = cxhdl->height; in cx2341x_handler_setup()
1745 int w = cxhdl->width; in cx2341x_handler_setup()
1748 err = cx2341x_hdl_api(cxhdl, CX2341X_ENC_SET_OUTPUT_PORT, 2, cxhdl->port, 0); in cx2341x_handler_setup()
1751 err = cx2341x_hdl_api(cxhdl, CX2341X_ENC_SET_FRAME_RATE, 1, cxhdl->is_50hz); in cx2341x_handler_setup()
1755 if (v4l2_ctrl_g_ctrl(cxhdl->video_encoding) == V4L2_MPEG_VIDEO_ENCODING_MPEG_1) { in cx2341x_handler_setup()
1762 return v4l2_ctrl_handler_setup(&cxhdl->hdl); in cx2341x_handler_setup()
1768 v4l2_ctrl_grab(cxhdl->audio_sampling_freq, busy); in cx2341x_handler_set_busy()
1769 v4l2_ctrl_grab(cxhdl->audio_encoding, busy); in cx2341x_handler_set_busy()
1770 v4l2_ctrl_grab(cxhdl->audio_l2_bitrate, busy); in cx2341x_handler_set_busy()
1771 v4l2_ctrl_grab(cxhdl->audio_ac3_bitrate, busy); in cx2341x_handler_set_busy()
1772 v4l2_ctrl_grab(cxhdl->stream_vbi_fmt, busy); in cx2341x_handler_set_busy()
1773 v4l2_ctrl_grab(cxhdl->stream_type, busy); in cx2341x_handler_set_busy()
1774 v4l2_ctrl_grab(cxhdl->video_bitrate_mode, busy); in cx2341x_handler_set_busy()
1775 v4l2_ctrl_grab(cxhdl->video_bitrate, busy); in cx2341x_handler_set_busy()
1776 v4l2_ctrl_grab(cxhdl->video_bitrate_peak, busy); in cx2341x_handler_set_busy()