V4L/DVB (6079): Cleanup: remove linux/moduleparam.h from drivers/media files
[linux-2.6.git] / drivers / media / video / cx88 / cx88-tvaudio.c
index 1e4278b..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/config.h>
 #include <linux/kthread.h>
 
 #include "cx88.h"
@@ -65,6 +61,10 @@ 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)
@@ -138,29 +138,12 @@ static void set_audio_finish(struct cx88_core *core, u32 ctl)
 {
        u32 volume;
 
-#ifndef CONFIG_VIDEO_CX88_ALSA
        /* restart dma; This avoids buzz in NICAM and is good in others  */
        cx88_stop_audio_dma(core);
-#endif
        cx_write(AUD_RATE_THRES_DMD, 0x000000C0);
-#ifndef CONFIG_VIDEO_CX88_ALSA
        cx88_start_audio_dma(core);
-#endif
-
-       if (cx88_boards[core->board].blackbird) {
-               /* sets sound input from external adc */
-               switch (core->board) {
-               case CX88_BOARD_HAUPPAUGE_ROSLYN:
-               case CX88_BOARD_KWORLD_MCE200_DELUXE:
-               case CX88_BOARD_KWORLD_HARDWARE_MPEG_TV_XPERT:
-               case CX88_BOARD_PIXELVIEW_PLAYTV_P7000:
-               case CX88_BOARD_ASUS_PVR_416:
-                       cx_clear(AUD_CTL, EN_I2SIN_ENABLE);
-                       break;
-               default:
-                       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 */
@@ -169,7 +152,7 @@ static void set_audio_finish(struct cx88_core *core, u32 ctl)
                cx_write(AUD_I2SCNTL, 0);
                /* cx_write(AUD_APB_IN_RATE_ADJ, 0); */
        }
-       if ((always_analog) || (!cx88_boards[core->board].blackbird)) {
+       if ((always_analog) || (!(core->board.mpeg & CX88_MPEG_BLACKBIRD))) {
                ctl |= EN_DAC_ENABLE;
                cx_write(AUD_CTL, ctl);
        }
@@ -698,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},
@@ -708,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;
@@ -726,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;
 
@@ -777,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:
@@ -815,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;
 }
 
@@ -975,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));