38 #include <linux/module.h>
39 #include <linux/errno.h>
41 #include <linux/kernel.h>
43 #include <linux/poll.h>
44 #include <linux/signal.h>
46 #include <linux/types.h>
55 static unsigned int audio_debug;
59 static unsigned int always_analog;
63 static unsigned int radio_deemphasis;
66 "0=None, 1=50us (elsewhere), 2=75us (USA)");
68 #define dprintk(fmt, arg...) if (audio_debug) \
69 printk(KERN_DEBUG "%s/0: " fmt, core->name , ## arg)
73 static const char *
const aud_ctl_names[64] = {
108 for (i = 0; l[
i].
reg; i++) {
171 static void set_audio_standard_BTSC(
struct cx88_core *core,
unsigned int sap,
174 static const struct rlist btsc[] = {
211 static const struct rlist btsc_sap[] = {
269 dprintk(
"%s SAP (status: unknown)\n", __func__);
270 set_audio_start(core,
SEL_SAP);
271 set_audio_registers(core, btsc_sap);
272 set_audio_finish(core, mode);
274 dprintk(
"%s (status: known-good)\n", __func__);
276 set_audio_registers(core, btsc);
277 set_audio_finish(core, mode);
281 static void set_audio_standard_NICAM(
struct cx88_core *core,
u32 mode)
283 static const struct rlist nicam_l[] = {
315 static const struct rlist nicam_bgdki_common[] = {
338 static const struct rlist nicam_i[] = {
345 static const struct rlist nicam_default[] = {
355 dprintk(
"%s SECAM-L NICAM (status: devel)\n", __func__);
356 set_audio_registers(core, nicam_l);
359 dprintk(
"%s PAL-I NICAM (status: known-good)\n", __func__);
360 set_audio_registers(core, nicam_bgdki_common);
361 set_audio_registers(core, nicam_i);
372 dprintk(
"%s PAL-BGDK NICAM (status: known-good)\n", __func__);
373 set_audio_registers(core, nicam_bgdki_common);
374 set_audio_registers(core, nicam_default);
379 set_audio_finish(core, mode);
382 static void set_audio_standard_A2(
struct cx88_core *core,
u32 mode)
384 static const struct rlist a2_bgdk_common[] = {
442 static const struct rlist a2_bg[] = {
451 static const struct rlist a2_dk[] = {
462 static const struct rlist a1_i[] = {
531 static const struct rlist am_l[] = {
600 static const struct rlist a2_deemph50[] = {
609 set_audio_start(core,
SEL_A2);
612 dprintk(
"%s PAL-BG A1/2 (status: known-good)\n", __func__);
613 set_audio_registers(core, a2_bgdk_common);
614 set_audio_registers(core, a2_bg);
615 set_audio_registers(core, a2_deemph50);
618 dprintk(
"%s PAL-DK A1/2 (status: known-good)\n", __func__);
619 set_audio_registers(core, a2_bgdk_common);
620 set_audio_registers(core, a2_dk);
621 set_audio_registers(core, a2_deemph50);
624 dprintk(
"%s PAL-I A1 (status: known-good)\n", __func__);
625 set_audio_registers(core, a1_i);
626 set_audio_registers(core, a2_deemph50);
629 dprintk(
"%s AM-L (status: devel)\n", __func__);
630 set_audio_registers(core, am_l);
639 dprintk(
"%s Warning: wrong value\n", __func__);
645 set_audio_finish(core, mode);
648 static void set_audio_standard_EIAJ(
struct cx88_core *core)
650 static const struct rlist eiaj[] = {
655 dprintk(
"%s (status: unknown)\n", __func__);
658 set_audio_registers(core, eiaj);
662 static void set_audio_standard_FM(
struct cx88_core *core,
665 static const struct rlist fm_deemph_50[] = {
681 static const struct rlist fm_deemph_75[] = {
703 static const struct rlist fm_no_deemph[] = {
709 dprintk(
"%s (status: unknown)\n", __func__);
715 set_audio_registers(core, fm_no_deemph);
719 set_audio_registers(core, fm_deemph_50);
723 set_audio_registers(core, fm_deemph_75);
732 static int cx88_detect_nicam(
struct cx88_core *core)
736 dprintk(
"start nicam autodetect.\n");
738 for (i = 0; i < 6; i++) {
743 dprintk(
"nicam is detected.\n");
751 dprintk(
"nicam is not detected.\n");
772 if (0 == cx88_detect_nicam(core)) {
782 set_audio_standard_EIAJ(core);
785 set_audio_standard_FM(core, radio_deemphasis);
788 set_audio_start(core, 0x01);
801 printk(
"%s/0: unknown tv audio mode [%d]\n",
816 static const char *
const m[] = {
"stereo",
"dual mono",
"mono",
"sap" };
817 static const char *
const p[] = {
"no pilot",
"pilot c1",
"pilot c2",
"?" };
822 pilot = (reg >> 2) & 0x03;
824 if (core->
astat != reg)
825 dprintk(
"AUD_STATUS: 0x%x [%s/%s] ctl=%s\n",
826 reg, m[mode], p[pilot],
922 set_audio_standard_NICAM(core,
926 set_audio_standard_NICAM(core,
931 set_audio_standard_NICAM(core,
979 dprintk(
"cx88_set_stereo: mask 0x%x, ctl 0x%x "
980 "[status=0x%x,ctl=0x%x,vol=0x%x]\n",
994 dprintk(
"cx88: tvaudio thread started\n");
1012 memset(&t, 0,
sizeof(t));
1042 dprintk(
"cx88: tvaudio thread exiting\n");