diff options
author | Andy Walls <awalls@radix.net> | 2009-01-01 17:02:31 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-03-30 11:42:24 -0400 |
commit | 0d82fe801d7c6d8cb8987e66b570f6decde9e235 (patch) | |
tree | c161730acec942f8474516d5aa7587d6d64e2fd9 /drivers/media/video/cx2341x.c | |
parent | 50299994181b835e5a6ee2882df2ee07e7fb4491 (diff) |
V4L/DVB (10276): cx18, cx2341x, ivtv: Add AC-3 audio encoding control to cx18
Initial addition of controls to set AC-3 audio encoding for the CX23418 - it
does not work yet due to firmware or cx18 driver issues. This change affects
the common cx2341x and ivtv modules due to shared structures and
common functions.
Signed-off-by: Andy Walls <awalls@radix.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/cx2341x.c')
-rw-r--r-- | drivers/media/video/cx2341x.c | 73 |
1 files changed, 67 insertions, 6 deletions
diff --git a/drivers/media/video/cx2341x.c b/drivers/media/video/cx2341x.c index cbbe47fb87b7..0acfacfa9436 100644 --- a/drivers/media/video/cx2341x.c +++ b/drivers/media/video/cx2341x.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * cx2341x - generic code for cx23415/6 based devices | 2 | * cx2341x - generic code for cx23415/6/8 based devices |
3 | * | 3 | * |
4 | * Copyright (C) 2006 Hans Verkuil <hverkuil@xs4all.nl> | 4 | * Copyright (C) 2006 Hans Verkuil <hverkuil@xs4all.nl> |
5 | * | 5 | * |
@@ -30,7 +30,7 @@ | |||
30 | #include <media/cx2341x.h> | 30 | #include <media/cx2341x.h> |
31 | #include <media/v4l2-common.h> | 31 | #include <media/v4l2-common.h> |
32 | 32 | ||
33 | MODULE_DESCRIPTION("cx23415/6 driver"); | 33 | MODULE_DESCRIPTION("cx23415/6/8 driver"); |
34 | MODULE_AUTHOR("Hans Verkuil"); | 34 | MODULE_AUTHOR("Hans Verkuil"); |
35 | MODULE_LICENSE("GPL"); | 35 | MODULE_LICENSE("GPL"); |
36 | 36 | ||
@@ -45,6 +45,7 @@ const u32 cx2341x_mpeg_ctrls[] = { | |||
45 | V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ, | 45 | V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ, |
46 | V4L2_CID_MPEG_AUDIO_ENCODING, | 46 | V4L2_CID_MPEG_AUDIO_ENCODING, |
47 | V4L2_CID_MPEG_AUDIO_L2_BITRATE, | 47 | V4L2_CID_MPEG_AUDIO_L2_BITRATE, |
48 | V4L2_CID_MPEG_AUDIO_AC3_BITRATE, | ||
48 | V4L2_CID_MPEG_AUDIO_MODE, | 49 | V4L2_CID_MPEG_AUDIO_MODE, |
49 | V4L2_CID_MPEG_AUDIO_MODE_EXTENSION, | 50 | V4L2_CID_MPEG_AUDIO_MODE_EXTENSION, |
50 | V4L2_CID_MPEG_AUDIO_EMPHASIS, | 51 | V4L2_CID_MPEG_AUDIO_EMPHASIS, |
@@ -94,6 +95,7 @@ static const struct cx2341x_mpeg_params default_params = { | |||
94 | .audio_sampling_freq = V4L2_MPEG_AUDIO_SAMPLING_FREQ_48000, | 95 | .audio_sampling_freq = V4L2_MPEG_AUDIO_SAMPLING_FREQ_48000, |
95 | .audio_encoding = V4L2_MPEG_AUDIO_ENCODING_LAYER_2, | 96 | .audio_encoding = V4L2_MPEG_AUDIO_ENCODING_LAYER_2, |
96 | .audio_l2_bitrate = V4L2_MPEG_AUDIO_L2_BITRATE_224K, | 97 | .audio_l2_bitrate = V4L2_MPEG_AUDIO_L2_BITRATE_224K, |
98 | .audio_ac3_bitrate = V4L2_MPEG_AUDIO_AC3_BITRATE_224K, | ||
97 | .audio_mode = V4L2_MPEG_AUDIO_MODE_STEREO, | 99 | .audio_mode = V4L2_MPEG_AUDIO_MODE_STEREO, |
98 | .audio_mode_extension = V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_4, | 100 | .audio_mode_extension = V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_4, |
99 | .audio_emphasis = V4L2_MPEG_AUDIO_EMPHASIS_NONE, | 101 | .audio_emphasis = V4L2_MPEG_AUDIO_EMPHASIS_NONE, |
@@ -148,6 +150,9 @@ static int cx2341x_get_ctrl(const struct cx2341x_mpeg_params *params, | |||
148 | case V4L2_CID_MPEG_AUDIO_L2_BITRATE: | 150 | case V4L2_CID_MPEG_AUDIO_L2_BITRATE: |
149 | ctrl->value = params->audio_l2_bitrate; | 151 | ctrl->value = params->audio_l2_bitrate; |
150 | break; | 152 | break; |
153 | case V4L2_CID_MPEG_AUDIO_AC3_BITRATE: | ||
154 | ctrl->value = params->audio_ac3_bitrate; | ||
155 | break; | ||
151 | case V4L2_CID_MPEG_AUDIO_MODE: | 156 | case V4L2_CID_MPEG_AUDIO_MODE: |
152 | ctrl->value = params->audio_mode; | 157 | ctrl->value = params->audio_mode; |
153 | break; | 158 | break; |
@@ -256,6 +261,12 @@ static int cx2341x_set_ctrl(struct cx2341x_mpeg_params *params, int busy, | |||
256 | params->audio_sampling_freq = ctrl->value; | 261 | params->audio_sampling_freq = ctrl->value; |
257 | break; | 262 | break; |
258 | case V4L2_CID_MPEG_AUDIO_ENCODING: | 263 | case V4L2_CID_MPEG_AUDIO_ENCODING: |
264 | if (busy) | ||
265 | return -EBUSY; | ||
266 | if (params->capabilities & CX2341X_CAP_HAS_AC3 && | ||
267 | ctrl->value != V4L2_MPEG_AUDIO_ENCODING_LAYER_2 && | ||
268 | ctrl->value != V4L2_MPEG_AUDIO_ENCODING_AC3) | ||
269 | return -EINVAL; | ||
259 | params->audio_encoding = ctrl->value; | 270 | params->audio_encoding = ctrl->value; |
260 | break; | 271 | break; |
261 | case V4L2_CID_MPEG_AUDIO_L2_BITRATE: | 272 | case V4L2_CID_MPEG_AUDIO_L2_BITRATE: |
@@ -263,6 +274,11 @@ static int cx2341x_set_ctrl(struct cx2341x_mpeg_params *params, int busy, | |||
263 | return -EBUSY; | 274 | return -EBUSY; |
264 | params->audio_l2_bitrate = ctrl->value; | 275 | params->audio_l2_bitrate = ctrl->value; |
265 | break; | 276 | break; |
277 | case V4L2_CID_MPEG_AUDIO_AC3_BITRATE: | ||
278 | if (busy) | ||
279 | return -EBUSY; | ||
280 | params->audio_ac3_bitrate = ctrl->value; | ||
281 | break; | ||
266 | case V4L2_CID_MPEG_AUDIO_MODE: | 282 | case V4L2_CID_MPEG_AUDIO_MODE: |
267 | params->audio_mode = ctrl->value; | 283 | params->audio_mode = ctrl->value; |
268 | break; | 284 | break; |
@@ -482,6 +498,12 @@ int cx2341x_ctrl_query(const struct cx2341x_mpeg_params *params, | |||
482 | 498 | ||
483 | switch (qctrl->id) { | 499 | switch (qctrl->id) { |
484 | case V4L2_CID_MPEG_AUDIO_ENCODING: | 500 | case V4L2_CID_MPEG_AUDIO_ENCODING: |
501 | if (params->capabilities & CX2341X_CAP_HAS_AC3) | ||
502 | return v4l2_ctrl_query_fill(qctrl, | ||
503 | V4L2_MPEG_AUDIO_ENCODING_LAYER_2, | ||
504 | V4L2_MPEG_AUDIO_ENCODING_AC3, 1, | ||
505 | default_params.audio_encoding); | ||
506 | |||
485 | return v4l2_ctrl_query_fill(qctrl, | 507 | return v4l2_ctrl_query_fill(qctrl, |
486 | V4L2_MPEG_AUDIO_ENCODING_LAYER_2, | 508 | V4L2_MPEG_AUDIO_ENCODING_LAYER_2, |
487 | V4L2_MPEG_AUDIO_ENCODING_LAYER_2, 1, | 509 | V4L2_MPEG_AUDIO_ENCODING_LAYER_2, 1, |
@@ -497,6 +519,12 @@ int cx2341x_ctrl_query(const struct cx2341x_mpeg_params *params, | |||
497 | case V4L2_CID_MPEG_AUDIO_L3_BITRATE: | 519 | case V4L2_CID_MPEG_AUDIO_L3_BITRATE: |
498 | return -EINVAL; | 520 | return -EINVAL; |
499 | 521 | ||
522 | case V4L2_CID_MPEG_AUDIO_AC3_BITRATE: | ||
523 | return v4l2_ctrl_query_fill(qctrl, | ||
524 | V4L2_MPEG_AUDIO_AC3_BITRATE_48K, | ||
525 | V4L2_MPEG_AUDIO_AC3_BITRATE_448K, 1, | ||
526 | default_params.audio_ac3_bitrate); | ||
527 | |||
500 | case V4L2_CID_MPEG_AUDIO_MODE_EXTENSION: | 528 | case V4L2_CID_MPEG_AUDIO_MODE_EXTENSION: |
501 | err = v4l2_ctrl_query_fill_std(qctrl); | 529 | err = v4l2_ctrl_query_fill_std(qctrl); |
502 | if (err == 0 && | 530 | if (err == 0 && |
@@ -671,6 +699,15 @@ const char **cx2341x_ctrl_get_menu(const struct cx2341x_mpeg_params *p, u32 id) | |||
671 | NULL | 699 | NULL |
672 | }; | 700 | }; |
673 | 701 | ||
702 | static const char *mpeg_audio_encoding_l2_ac3[] = { | ||
703 | "", | ||
704 | "MPEG-1/2 Layer II", | ||
705 | "", | ||
706 | "", | ||
707 | "AC-3", | ||
708 | NULL | ||
709 | }; | ||
710 | |||
674 | static const char *cx2341x_video_spatial_filter_mode_menu[] = { | 711 | static const char *cx2341x_video_spatial_filter_mode_menu[] = { |
675 | "Manual", | 712 | "Manual", |
676 | "Auto", | 713 | "Auto", |
@@ -711,6 +748,9 @@ const char **cx2341x_ctrl_get_menu(const struct cx2341x_mpeg_params *p, u32 id) | |||
711 | case V4L2_CID_MPEG_STREAM_TYPE: | 748 | case V4L2_CID_MPEG_STREAM_TYPE: |
712 | return (p->capabilities & CX2341X_CAP_HAS_TS) ? | 749 | return (p->capabilities & CX2341X_CAP_HAS_TS) ? |
713 | mpeg_stream_type_with_ts : mpeg_stream_type_without_ts; | 750 | mpeg_stream_type_with_ts : mpeg_stream_type_without_ts; |
751 | case V4L2_CID_MPEG_AUDIO_ENCODING: | ||
752 | return (p->capabilities & CX2341X_CAP_HAS_AC3) ? | ||
753 | mpeg_audio_encoding_l2_ac3 : v4l2_ctrl_get_menu(id); | ||
714 | case V4L2_CID_MPEG_AUDIO_L1_BITRATE: | 754 | case V4L2_CID_MPEG_AUDIO_L1_BITRATE: |
715 | case V4L2_CID_MPEG_AUDIO_L3_BITRATE: | 755 | case V4L2_CID_MPEG_AUDIO_L3_BITRATE: |
716 | return NULL; | 756 | return NULL; |
@@ -730,16 +770,34 @@ const char **cx2341x_ctrl_get_menu(const struct cx2341x_mpeg_params *p, u32 id) | |||
730 | } | 770 | } |
731 | EXPORT_SYMBOL(cx2341x_ctrl_get_menu); | 771 | EXPORT_SYMBOL(cx2341x_ctrl_get_menu); |
732 | 772 | ||
773 | /* definitions for audio properties bits 29-28 */ | ||
774 | #define CX2341X_AUDIO_ENCDING_METHOD_MPEG 0 | ||
775 | #define CX2341X_AUDIO_ENCDING_METHOD_AC3 1 | ||
776 | #define CX2341X_AUDIO_ENCDING_METHOD_LPCM 2 | ||
777 | |||
733 | static void cx2341x_calc_audio_properties(struct cx2341x_mpeg_params *params) | 778 | static void cx2341x_calc_audio_properties(struct cx2341x_mpeg_params *params) |
734 | { | 779 | { |
735 | params->audio_properties = (params->audio_sampling_freq << 0) | | 780 | params->audio_properties = |
736 | ((3 - params->audio_encoding) << 2) | | 781 | (params->audio_sampling_freq << 0) | |
737 | ((1 + params->audio_l2_bitrate) << 4) | | ||
738 | (params->audio_mode << 8) | | 782 | (params->audio_mode << 8) | |
739 | (params->audio_mode_extension << 10) | | 783 | (params->audio_mode_extension << 10) | |
740 | (((params->audio_emphasis == V4L2_MPEG_AUDIO_EMPHASIS_CCITT_J17) | 784 | (((params->audio_emphasis == V4L2_MPEG_AUDIO_EMPHASIS_CCITT_J17) |
741 | ? 3 : params->audio_emphasis) << 12) | | 785 | ? 3 : params->audio_emphasis) << 12) | |
742 | (params->audio_crc << 14); | 786 | (params->audio_crc << 14); |
787 | |||
788 | if ((params->capabilities & CX2341X_CAP_HAS_AC3) && | ||
789 | params->audio_encoding == V4L2_MPEG_AUDIO_ENCODING_AC3) { | ||
790 | params->audio_properties |= | ||
791 | /* Not sure if this MPEG Layer II setting is required */ | ||
792 | ((3 - V4L2_MPEG_AUDIO_ENCODING_LAYER_2) << 2) | | ||
793 | (params->audio_ac3_bitrate << 4) | | ||
794 | (CX2341X_AUDIO_ENCDING_METHOD_AC3 << 28); | ||
795 | } else { | ||
796 | /* Assuming MPEG Layer II */ | ||
797 | params->audio_properties |= | ||
798 | ((3 - params->audio_encoding) << 2) | | ||
799 | ((1 + params->audio_l2_bitrate) << 4); | ||
800 | } | ||
743 | } | 801 | } |
744 | 802 | ||
745 | int cx2341x_ext_ctrls(struct cx2341x_mpeg_params *params, int busy, | 803 | int cx2341x_ext_ctrls(struct cx2341x_mpeg_params *params, int busy, |
@@ -1022,7 +1080,10 @@ void cx2341x_log_status(const struct cx2341x_mpeg_params *p, const char *prefix) | |||
1022 | prefix, | 1080 | prefix, |
1023 | cx2341x_menu_item(p, V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ), | 1081 | cx2341x_menu_item(p, V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ), |
1024 | cx2341x_menu_item(p, V4L2_CID_MPEG_AUDIO_ENCODING), | 1082 | cx2341x_menu_item(p, V4L2_CID_MPEG_AUDIO_ENCODING), |
1025 | cx2341x_menu_item(p, V4L2_CID_MPEG_AUDIO_L2_BITRATE), | 1083 | cx2341x_menu_item(p, |
1084 | p->audio_encoding == V4L2_MPEG_AUDIO_ENCODING_AC3 | ||
1085 | ? V4L2_CID_MPEG_AUDIO_AC3_BITRATE | ||
1086 | : V4L2_CID_MPEG_AUDIO_L2_BITRATE), | ||
1026 | cx2341x_menu_item(p, V4L2_CID_MPEG_AUDIO_MODE), | 1087 | cx2341x_menu_item(p, V4L2_CID_MPEG_AUDIO_MODE), |
1027 | p->audio_mute ? " (muted)" : ""); | 1088 | p->audio_mute ? " (muted)" : ""); |
1028 | if (p->audio_mode == V4L2_MPEG_AUDIO_MODE_JOINT_STEREO) | 1089 | if (p->audio_mode == V4L2_MPEG_AUDIO_MODE_JOINT_STEREO) |