]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - drivers/media/video/msp3400.c
Merge master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
[karo-tx-linux.git] / drivers / media / video / msp3400.c
index d996ec99caff9e57aae945af220d222a3d5f1cac..f0d43fc2632f35db99f404d04cc42ef50a4f2818 100644 (file)
@@ -124,10 +124,14 @@ module_param(standard,         int, 0644);
 module_param(amsound,          int, 0644);
 module_param(dolby,            int, 0644);
 
+MODULE_PARM_DESC(opmode, "Forces a MSP3400 opmode. 0=Manual, 1=Simple, 2=Simpler");
 MODULE_PARM_DESC(once, "No continuous stereo monitoring");
 MODULE_PARM_DESC(debug, "Enable debug messages");
+MODULE_PARM_DESC(stereo_threshold, "Sets signal threshold to activate stereo");
 MODULE_PARM_DESC(standard, "Specify audio standard: 32 = NTSC, 64 = radio, Default: Autodetect");
 MODULE_PARM_DESC(amsound, "Hardwire AM sound at 6.5Hz (France), FM can autoscan");
+MODULE_PARM_DESC(dolby, "Activates Dolby processsing");
+
 
 MODULE_DESCRIPTION("device driver for msp34xx TV sound processor");
 MODULE_AUTHOR("Gerd Knorr");
@@ -147,7 +151,6 @@ static unsigned short normal_i2c[] = {
        I2C_MSP3400C_ALT  >> 1,
        I2C_CLIENT_END
 };
-static unsigned short normal_i2c_range[] = {I2C_CLIENT_END,I2C_CLIENT_END};
 I2C_CLIENT_INSMOD;
 
 /* ----------------------------------------------------------------------- */
@@ -380,7 +383,9 @@ static void msp3400c_setvolume(struct i2c_client *client,
        int val = 0, bal = 0;
 
        if (!muted) {
-               val = (volume * 0x7F / 65535) << 8;
+               /* 0x7f instead if 0x73 here has sound quality issues,
+                * probably due to overmodulation + clipping ... */
+               val = (volume * 0x73 / 65535) << 8;
        }
        if (val) {
                bal = (balance / 256) - 128;
@@ -566,10 +571,6 @@ static void msp3400c_set_audmode(struct i2c_client *client, int audmode)
        switch (audmode) {
        case V4L2_TUNER_MODE_STEREO:
                src = 0x0020 | nicam;
-#if 0
-               /* spatial effect */
-               msp3400c_write(client,I2C_MSP3400C_DFP, 0x0005,0x4000);
-#endif
                break;
        case V4L2_TUNER_MODE_MONO:
                if (msp->mode == MSP_MODE_AM_NICAM) {
@@ -734,28 +735,19 @@ static int msp34xx_sleep(struct msp3400c *msp, int timeout)
 {
        DECLARE_WAITQUEUE(wait, current);
 
-again:
        add_wait_queue(&msp->wq, &wait);
        if (!kthread_should_stop()) {
                if (timeout < 0) {
                        set_current_state(TASK_INTERRUPTIBLE);
                        schedule();
                } else {
-#if 0
-                       /* hmm, that one doesn't return on wakeup ... */
-                       msleep_interruptible(timeout);
-#else
                        set_current_state(TASK_INTERRUPTIBLE);
                        schedule_timeout(msecs_to_jiffies(timeout));
-#endif
                }
        }
 
        remove_wait_queue(&msp->wq, &wait);
-
-       if (try_to_freeze(PF_FREEZE))
-               goto again;
-
+       try_to_freeze();
        return msp->restart;
 }
 
@@ -997,7 +989,13 @@ static int msp34xx_modus(int norm)
 {
        switch (norm) {
        case VIDEO_MODE_PAL:
+#if 1
+               /* experimental: not sure this works with all chip versions */
+               return 0x7003;
+#else
+               /* previous value, try this if it breaks ... */
                return 0x1003;
+#endif
        case VIDEO_MODE_NTSC:  /* BTSC */
                return 0x2003;
        case VIDEO_MODE_SECAM:
@@ -1152,17 +1150,10 @@ static int msp3410d_thread(void *data)
                                            MSP_CARRIER(10.7));
                        /* scart routing */
                        msp3400c_set_scart(client,SCART_IN2,0);
-#if 0
-                       /* radio from SCART_IN2 */
-                       msp3400c_write(client,I2C_MSP3400C_DFP, 0x08, 0x0220);
-                       msp3400c_write(client,I2C_MSP3400C_DFP, 0x09, 0x0220);
-                       msp3400c_write(client,I2C_MSP3400C_DFP, 0x0b, 0x0220);
-#else
                        /* msp34xx does radio decoding */
                        msp3400c_write(client,I2C_MSP3400C_DFP, 0x08, 0x0020);
                        msp3400c_write(client,I2C_MSP3400C_DFP, 0x09, 0x0020);
                        msp3400c_write(client,I2C_MSP3400C_DFP, 0x0b, 0x0020);
-#endif
                        break;
                case 0x0003:
                case 0x0004:
@@ -1264,6 +1255,7 @@ static int msp34xxg_thread(void *data)
        int val, std, i;
 
        printk("msp34xxg: daemon started\n");
+       msp->source = 1; /* default */
        for (;;) {
                d2printk(KERN_DEBUG "msp34xxg: thread: sleep\n");
                msp34xx_sleep(msp,-1);
@@ -1334,8 +1326,9 @@ static void msp34xxg_set_source(struct i2c_client *client, int source)
 
        /* fix matrix mode to stereo and let the msp choose what
         * to output according to 'source', as recommended
+        * for MONO (source==0) downmixing set bit[7:0] to 0x30
         */
-       int value = (source&0x07)<<8|(source==0 ? 0x00:0x20);
+       int value = (source&0x07)<<8|(source==0 ? 0x30:0x20);
        dprintk("msp34xxg: set source to %d (0x%x)\n", source, value);
        msp3400c_write(client,
                       I2C_MSP3400C_DFP,
@@ -1359,7 +1352,7 @@ static void msp34xxg_set_source(struct i2c_client *client, int source)
        msp3400c_write(client,
                       I2C_MSP3400C_DEM,
                       0x22, /* a2 threshold for stereo/bilingual */
-                      source==0 ? 0x7f0:stereo_threshold);
+                      stereo_threshold);
        msp->source=source;
 }
 
@@ -1394,7 +1387,7 @@ static void msp34xxg_detect_stereo(struct i2c_client *client)
 static void msp34xxg_set_audmode(struct i2c_client *client, int audmode)
 {
        struct msp3400c *msp = i2c_get_clientdata(client);
-       int source = 0;
+       int source;
 
        switch (audmode) {
        case V4L2_TUNER_MODE_MONO:
@@ -1410,9 +1403,10 @@ static void msp34xxg_set_audmode(struct i2c_client *client, int audmode)
        case V4L2_TUNER_MODE_LANG2:
                source=4; /* stereo or B */
                break;
-       default: /* doing nothing: a safe, sane default */
+       default:
                audmode = 0;
-               return;
+               source  = 1;
+               break;
        }
        msp->audmode = audmode;
        msp34xxg_set_source(client, source);
@@ -1426,7 +1420,7 @@ static int msp_detach(struct i2c_client *client);
 static int msp_probe(struct i2c_adapter *adap);
 static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg);
 
-static int msp_suspend(struct device * dev, u32 state, u32 level);
+static int msp_suspend(struct device * dev, pm_message_t state, u32 level);
 static int msp_resume(struct device * dev, u32 level);
 
 static void msp_wake_thread(struct i2c_client *client);
@@ -1447,7 +1441,7 @@ static struct i2c_driver driver = {
 
 static struct i2c_client client_template =
 {
-       I2C_DEVNAME("(unset)"),
+       .name      = "(unset)",
        .flags     = I2C_CLIENT_ALLOW_USE,
         .driver    = &driver,
 };
@@ -1462,7 +1456,7 @@ static int msp_attach(struct i2c_adapter *adap, int addr, int kind)
         client_template.addr = addr;
 
         if (-1 == msp3400c_reset(&client_template)) {
-                dprintk("msp3400: no chip found\n");
+                dprintk("msp34xx: no chip found\n");
                 return -1;
         }
 
@@ -1488,7 +1482,7 @@ static int msp_attach(struct i2c_adapter *adap, int addr, int kind)
        if (-1 == msp3400c_reset(c)) {
                kfree(msp);
                kfree(c);
-               dprintk("msp3400: no chip found\n");
+               dprintk("msp34xx: no chip found\n");
                return -1;
        }
 
@@ -1498,14 +1492,10 @@ static int msp_attach(struct i2c_adapter *adap, int addr, int kind)
        if ((-1 == msp->rev1) || (0 == msp->rev1 && 0 == msp->rev2)) {
                kfree(msp);
                kfree(c);
-               printk("msp3400: error while reading chip version\n");
+               dprintk("msp34xx: error while reading chip version\n");
                return -1;
        }
 
-#if 0
-       /* this will turn on a 1kHz beep - might be useful for debugging... */
-       msp3400c_write(c,I2C_MSP3400C_DFP, 0x0014, 0x1040);
-#endif
        msp3400c_setvolume(c, msp->muted, msp->volume, msp->balance);
 
        snprintf(c->name, sizeof(c->name), "MSP34%02d%c-%c%d",
@@ -1514,19 +1504,16 @@ static int msp_attach(struct i2c_adapter *adap, int addr, int kind)
 
        msp->opmode = opmode;
        if (OPMODE_AUTO == msp->opmode) {
-#if 0 /* seems to work for ivtv only, disable by default for now ... */
                if (HAVE_SIMPLER(msp))
                        msp->opmode = OPMODE_SIMPLER;
-               else
-#endif
-               if (HAVE_SIMPLE(msp))
+               else if (HAVE_SIMPLE(msp))
                        msp->opmode = OPMODE_SIMPLE;
                else
                        msp->opmode = OPMODE_MANUAL;
        }
 
        /* hello world :-) */
-       printk(KERN_INFO "msp34xx: init: chip=%s",i2c_clientname(c));
+       printk(KERN_INFO "msp34xx: init: chip=%s", c->name);
        if (HAVE_NICAM(msp))
                printk(" +nicam");
        if (HAVE_SIMPLE(msp))
@@ -1834,7 +1821,7 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
        return 0;
 }
 
-static int msp_suspend(struct device * dev, u32 state, u32 level)
+static int msp_suspend(struct device * dev, pm_message_t state, u32 level)
 {
        struct i2c_client *c = container_of(dev, struct i2c_client, dev);