V4L/DVB (6079): Cleanup: remove linux/moduleparam.h from drivers/media files
[linux-2.6.git] / drivers / media / video / cx88 / cx88-tvaudio.c
index 00051a4..82364fb 100644 (file)
 */
 
 #include <linux/module.h>
-#include <linux/moduleparam.h>
 #include <linux/errno.h>
+#include <linux/freezer.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/mm.h>
 #include <linux/poll.h>
-#include <linux/pci.h>
 #include <linux/signal.h>
 #include <linux/ioport.h>
-#include <linux/sched.h>
 #include <linux/types.h>
 #include <linux/interrupt.h>
 #include <linux/vmalloc.h>
 #include <linux/init.h>
-#include <linux/smp_lock.h>
 #include <linux/delay.h>
 #include <linux/kthread.h>
 
@@ -60,6 +57,15 @@ static unsigned int audio_debug = 0;
 module_param(audio_debug, int, 0644);
 MODULE_PARM_DESC(audio_debug, "enable debug messages [audio]");
 
+static unsigned int always_analog = 0;
+module_param(always_analog,int,0644);
+MODULE_PARM_DESC(always_analog,"force analog audio out");
+
+static unsigned int radio_deemphasis = 0;
+module_param(radio_deemphasis,int,0644);
+MODULE_PARM_DESC(radio_deemphasis, "Radio deemphasis time constant, "
+                "0=None, 1=50us (elsewhere), 2=75us (USA)");
+
 #define dprintk(fmt, arg...)   if (audio_debug) \
        printk(KERN_DEBUG "%s/0: " fmt, core->name , ## arg)
 
@@ -137,13 +143,7 @@ static void set_audio_finish(struct cx88_core *core, u32 ctl)
        cx_write(AUD_RATE_THRES_DMD, 0x000000C0);
        cx88_start_audio_dma(core);
 
-       if (cx88_boards[core->board].blackbird) {
-               /* sets sound input from external adc */
-               if (core->board == CX88_BOARD_HAUPPAUGE_ROSLYN)
-                       cx_clear(AUD_CTL, EN_I2SIN_ENABLE);
-               else
-                       cx_set(AUD_CTL, EN_I2SIN_ENABLE);
-
+       if (core->board.mpeg & CX88_MPEG_BLACKBIRD) {
                cx_write(AUD_I2SINPUTCNTL, 4);
                cx_write(AUD_BAUDRATE, 1);
                /* 'pass-thru mode': this enables the i2s output to the mpeg encoder */
@@ -151,7 +151,8 @@ static void set_audio_finish(struct cx88_core *core, u32 ctl)
                cx_write(AUD_I2SOUTPUTCNTL, 1);
                cx_write(AUD_I2SCNTL, 0);
                /* cx_write(AUD_APB_IN_RATE_ADJ, 0); */
-       } else {
+       }
+       if ((always_analog) || (!(core->board.mpeg & CX88_MPEG_BLACKBIRD))) {
                ctl |= EN_DAC_ENABLE;
                cx_write(AUD_CTL, ctl);
        }
@@ -680,6 +681,10 @@ static void set_audio_standard_FM(struct cx88_core *core,
        };
 
        /* It is enough to leave default values? */
+       /* No, it's not!  The deemphasis registers are reset to the 75us
+        * values by default.  Analyzing the spectrum of the decoded audio
+        * reveals that "no deemphasis" is the same as 75 us, while the 50 us
+        * setting results in less deemphasis.  */
        static const struct rlist fm_no_deemph[] = {
 
                {AUD_POLYPH80SCALEFAC, 0x0003},
@@ -690,6 +695,7 @@ static void set_audio_standard_FM(struct cx88_core *core,
        set_audio_start(core, SEL_FMRADIO);
 
        switch (deemph) {
+       default:
        case FM_NO_DEEMPH:
                set_audio_registers(core, fm_no_deemph);
                break;
@@ -708,7 +714,7 @@ static void set_audio_standard_FM(struct cx88_core *core,
 
 /* ----------------------------------------------------------- */
 
-int cx88_detect_nicam(struct cx88_core *core)
+static int cx88_detect_nicam(struct cx88_core *core)
 {
        int i, j = 0;
 
@@ -759,7 +765,7 @@ void cx88_set_tvaudio(struct cx88_core *core)
                set_audio_standard_EIAJ(core);
                break;
        case WW_FM:
-               set_audio_standard_FM(core, FM_NO_DEEMPH);
+               set_audio_standard_FM(core, radio_deemphasis);
                break;
        case WW_NONE:
        default:
@@ -797,55 +803,6 @@ void cx88_get_stereo(struct cx88_core *core, struct v4l2_tuner *t)
        Add some code here later.
 */
 
-# if 0
-       t->capability = V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_SAP |
-           V4L2_TUNER_CAP_LANG1 | V4L2_TUNER_CAP_LANG2;
-       t->rxsubchans = V4L2_TUNER_SUB_MONO;
-       t->audmode = V4L2_TUNER_MODE_MONO;
-
-       switch (core->tvaudio) {
-       case WW_BTSC:
-               t->capability = V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_SAP;
-               t->rxsubchans = V4L2_TUNER_SUB_STEREO;
-               if (1 == pilot) {
-                       /* SAP */
-                       t->rxsubchans |= V4L2_TUNER_SUB_SAP;
-               }
-               break;
-       case WW_A2_BG:
-       case WW_A2_DK:
-       case WW_A2_M:
-               if (1 == pilot) {
-                       /* stereo */
-                       t->rxsubchans =
-                           V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO;
-                       if (0 == mode)
-                               t->audmode = V4L2_TUNER_MODE_STEREO;
-               }
-               if (2 == pilot) {
-                       /* dual language -- FIXME */
-                       t->rxsubchans =
-                           V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2;
-                       t->audmode = V4L2_TUNER_MODE_LANG1;
-               }
-               break;
-       case WW_NICAM_BGDKL:
-               if (0 == mode) {
-                       t->audmode = V4L2_TUNER_MODE_STEREO;
-                       t->rxsubchans |= V4L2_TUNER_SUB_STEREO;
-               }
-               break;
-       case WW_SYSTEM_L_AM:
-               if (0x0 == mode && !(cx_read(AUD_INIT) & 0x04)) {
-                       t->audmode = V4L2_TUNER_MODE_STEREO;
-                       t->rxsubchans |= V4L2_TUNER_SUB_STEREO;
-               }
-               break;
-       default:
-               /* nothing */
-               break;
-       }
-# endif
        return;
 }
 
@@ -875,6 +832,7 @@ void cx88_set_stereo(struct cx88_core *core, u32 mode, int manual)
                        set_audio_standard_BTSC(core, 1, EN_BTSC_FORCE_SAP);
                        break;
                case V4L2_TUNER_MODE_STEREO:
+               case V4L2_TUNER_MODE_LANG1_LANG2:
                        set_audio_standard_BTSC(core, 0, EN_BTSC_FORCE_STEREO);
                        break;
                }
@@ -895,6 +853,7 @@ void cx88_set_stereo(struct cx88_core *core, u32 mode, int manual)
                                                         EN_NICAM_FORCE_MONO2);
                                break;
                        case V4L2_TUNER_MODE_STEREO:
+                       case V4L2_TUNER_MODE_LANG1_LANG2:
                                set_audio_standard_NICAM(core,
                                                         EN_NICAM_FORCE_STEREO);
                                break;
@@ -916,6 +875,7 @@ void cx88_set_stereo(struct cx88_core *core, u32 mode, int manual)
                                                              EN_A2_FORCE_MONO2);
                                        break;
                                case V4L2_TUNER_MODE_STEREO:
+                               case V4L2_TUNER_MODE_LANG1_LANG2:
                                        set_audio_standard_A2(core,
                                                              EN_A2_FORCE_STEREO);
                                        break;
@@ -954,10 +914,12 @@ int cx88_audio_thread(void *data)
        u32 mode = 0;
 
        dprintk("cx88: tvaudio thread started\n");
+       set_freezable();
        for (;;) {
                msleep_interruptible(1000);
                if (kthread_should_stop())
                        break;
+               try_to_freeze();
 
                /* just monitor the audio status for now ... */
                memset(&t, 0, sizeof(t));