]> git.hungrycats.org Git - linux/commitdiff
[PATCH] v4l: misc i2c fixes
authorAndrew Morton <akpm@osdl.org>
Mon, 19 Jan 2004 02:55:21 +0000 (18:55 -0800)
committerLinus Torvalds <torvalds@home.osdl.org>
Mon, 19 Jan 2004 02:55:21 +0000 (18:55 -0800)
From: Gerd Knorr <kraxel@bytesex.org>

This is a collection of misc i2c tv helper module fixes.

drivers/media/video/msp3400.c
drivers/media/video/tda7432.c
drivers/media/video/tda9875.c
drivers/media/video/tda9887.c
drivers/media/video/tvaudio.c
drivers/media/video/tvmixer.c
include/media/id.h

index b0fbe97230c3b0bb3ceed89720d6032b2de6ac60..bbb97e3186ca52ea3dc664d6ff6418b49f0ea0bb 100644 (file)
 #include <asm/semaphore.h>
 #include <asm/pgtable.h>
 
-/* kernel_thread */
-#define __KERNEL_SYSCALLS__
-#include <linux/unistd.h>
-
 #include <media/audiochip.h>
 #include "msp3400.h"
 
@@ -194,7 +190,7 @@ msp3400c_read(struct i2c_client *client, int dev, int addr)
                err++;
                printk(KERN_WARNING "msp34xx: I/O error #%d (read 0x%02x/0x%02x)\n",
                       err, dev, addr);
-               current->state = TASK_INTERRUPTIBLE;
+               set_current_state(TASK_INTERRUPTIBLE);
                schedule_timeout(HZ/10);
        }
        if (3 == err) {
@@ -223,7 +219,7 @@ msp3400c_write(struct i2c_client *client, int dev, int addr, int val)
                err++;
                printk(KERN_WARNING "msp34xx: I/O error #%d (write 0x%02x/0x%02x)\n",
                       err, dev, addr);
-               current->state = TASK_INTERRUPTIBLE;
+               set_current_state(TASK_INTERRUPTIBLE);
                schedule_timeout(HZ/10);
        }
        if (3 == err) {
@@ -804,7 +800,7 @@ static int msp3400c_thread(void *data)
                }
 
                /* some time for the tuner to sync */
-               current->state   = TASK_INTERRUPTIBLE;
+               set_current_state(TASK_INTERRUPTIBLE);
                schedule_timeout(HZ/5);
                if (signal_pending(current))
                        goto done;
@@ -839,7 +835,7 @@ static int msp3400c_thread(void *data)
                for (this = 0; this < count; this++) {
                        msp3400c_setcarrier(client, cd[this].cdo,cd[this].cdo);
 
-                       current->state   = TASK_INTERRUPTIBLE;
+                       set_current_state(TASK_INTERRUPTIBLE);
                        schedule_timeout(HZ/10);
                        if (signal_pending(current))
                                goto done;
@@ -876,7 +872,7 @@ static int msp3400c_thread(void *data)
                for (this = 0; this < count; this++) {
                        msp3400c_setcarrier(client, cd[this].cdo,cd[this].cdo);
 
-                       current->state   = TASK_INTERRUPTIBLE;
+                       set_current_state(TASK_INTERRUPTIBLE);
                        schedule_timeout(HZ/10);
                        if (signal_pending(current))
                                goto done;
@@ -1052,7 +1048,7 @@ static int msp3410d_thread(void *data)
                }
        
                /* some time for the tuner to sync */
-               current->state   = TASK_INTERRUPTIBLE;
+               set_current_state(TASK_INTERRUPTIBLE);
                schedule_timeout(HZ/5);
                if (signal_pending(current))
                        goto done;
@@ -1113,7 +1109,7 @@ static int msp3410d_thread(void *data)
                } else {
                        /* triggered autodetect */
                        for (;;) {
-                               current->state   = TASK_INTERRUPTIBLE;
+                               set_current_state(TASK_INTERRUPTIBLE);
                                schedule_timeout(HZ/10);
                                if (signal_pending(current))
                                        goto done;
@@ -1204,6 +1200,8 @@ static int msp3410d_thread(void *data)
 #endif
                        break;
                case 0x0003:
+               case 0x0004:
+               case 0x0005:
                        msp->mode   = MSP_MODE_FM_TERRA;
                        msp->stereo = VIDEO_SOUND_MONO;
                        msp->nicam_on = 0;
@@ -1262,7 +1260,7 @@ static int msp_attach(struct i2c_adapter *adap, int addr, int kind)
        DECLARE_MUTEX_LOCKED(sem);
        struct msp3400c *msp;
         struct i2c_client *c;
-       int i;
+       int i, rc;
 
         client_template.adapter = adap;
         client_template.addr = addr;
@@ -1316,7 +1314,7 @@ static int msp_attach(struct i2c_adapter *adap, int addr, int kind)
 #endif
        msp3400c_setvolume(c,msp->muted,msp->left,msp->right);
 
-       snprintf(c->name, I2C_NAME_SIZE, "MSP34%02d%c-%c%d",
+       snprintf(c->name, sizeof(c->name), "MSP34%02d%c-%c%d",
                 (msp->rev2>>8)&0xff, (msp->rev1&0xff)+'@',
                 ((msp->rev1>>8)&0xff)+'@', msp->rev2&0x1f);
 
@@ -1345,9 +1343,12 @@ static int msp_attach(struct i2c_adapter *adap, int addr, int kind)
 
        /* startup control thread */
        msp->notify = &sem;
-       kernel_thread(msp->simple ? msp3410d_thread : msp3400c_thread,
-                     (void *)c, 0);
-       down(&sem);
+       rc = kernel_thread(msp->simple ? msp3410d_thread : msp3400c_thread,
+                          (void *)c, 0);
+       if (rc < 0)
+               printk(KERN_WARNING "msp34xx: kernel_thread() failed\n");
+       else
+               down(&sem);
        msp->notify = NULL;
        wake_up_interruptible(&msp->wq);
 
@@ -1398,8 +1399,13 @@ static int msp_detach(struct i2c_client *client)
 
 static int msp_probe(struct i2c_adapter *adap)
 {
+#ifdef I2C_ADAP_CLASS_TV_ANALOG
        if (adap->class & I2C_ADAP_CLASS_TV_ANALOG)
                return i2c_probe(adap, &addr_data, msp_attach);
+#else
+       if (adap->id == (I2C_ALGO_BIT | I2C_HW_B_BT848))
+               return i2c_probe(adap, &addr_data, msp_attach);
+#endif
        return 0;
 }
 
index c74fbcc8fb8c2c0a30dc85f079e720560051a8ea..015f2f5fe49d1cd62b6403ad4650557f436e7618 100644 (file)
@@ -338,8 +338,13 @@ static int tda7432_attach(struct i2c_adapter *adap, int addr, int kind)
 
 static int tda7432_probe(struct i2c_adapter *adap)
 {
+#ifdef I2C_ADAP_CLASS_TV_ANALOG
        if (adap->class & I2C_ADAP_CLASS_TV_ANALOG)
                return i2c_probe(adap, &addr_data, tda7432_attach);
+#else
+       if (adap->id == (I2C_ALGO_BIT | I2C_HW_B_BT848))
+               return i2c_probe(adap, &addr_data, tda7432_attach);
+#endif
        return 0;
 }
 
index ef9dd4854ed0b1a140f6d02985a072db2e177648..8c7a57944a68a27052c5aa5e8465142ab915b74e 100644 (file)
@@ -272,8 +272,13 @@ static int tda9875_attach(struct i2c_adapter *adap, int addr, int kind)
 
 static int tda9875_probe(struct i2c_adapter *adap)
 {
+#ifdef I2C_ADAP_CLASS_TV_ANALOG
        if (adap->class & I2C_ADAP_CLASS_TV_ANALOG)
                return i2c_probe(adap, &addr_data, tda9875_attach);
+#else
+       if (adap->id == (I2C_ALGO_BIT | I2C_HW_B_BT848))
+               return i2c_probe(adap, &addr_data, tda9875_attach);
+#endif
        return 0;
 }
 
index 2fcf6c685bbaebd0c792dc4406862190ceec4df3..5b1ceb97765915f23befe7bc993de05d3bc84a69 100644 (file)
@@ -169,7 +169,7 @@ static int tda9887_miro(struct tda9887 *t)
                bDeEmphVal   = cDeemphasis50;
                bModulation  = cNegativeFmTV;
                bOutPort1    = cOutputPort1Inactive;
-               if (1 == t->pinnacle_id) {
+               if ((1 == t->pinnacle_id) || (7 == t->pinnacle_id)) {
                        bCarrierMode = cIntercarrier;
                } else {
                        // stereo boards
@@ -366,8 +366,18 @@ static int tda9887_attach(struct i2c_adapter *adap, int addr, int kind)
 
 static int tda9887_probe(struct i2c_adapter *adap)
 {
+#ifdef I2C_ADAP_CLASS_TV_ANALOG
        if (adap->class & I2C_ADAP_CLASS_TV_ANALOG)
                return i2c_probe(adap, &addr_data, tda9887_attach);
+#else
+       switch (adap->id) {
+       case I2C_ALGO_BIT | I2C_HW_B_BT848:
+       case I2C_ALGO_BIT | I2C_HW_B_RIVA:
+       case I2C_ALGO_SAA7134:
+               return i2c_probe(adap, &addr_data, tda9887_attach);
+               break;
+       }
+#endif
        return 0;
 }
 
@@ -439,9 +449,9 @@ static struct i2c_driver driver = {
 };
 static struct i2c_client client_template =
 {
-       .flags  = I2C_CLIENT_ALLOW_USE,
-        .driver = &driver,
-       .name   = "tda9887",
+       I2C_DEVNAME("tda9887"),
+       .flags     = I2C_CLIENT_ALLOW_USE,
+        .driver    = &driver,
 };
 
 static int tda9887_init_module(void)
index d755120966e223f27b88b4a97855db567d76af0e..81f0244af173875e0730460f95b1d4b60ae20aff 100644 (file)
@@ -1420,6 +1420,7 @@ static int chip_attach(struct i2c_adapter *adap, int addr, int kind)
 {
        struct CHIPSTATE *chip;
        struct CHIPDESC  *desc;
+       int rc;
 
        chip = kmalloc(sizeof(*chip),GFP_KERNEL);
        if (!chip)
@@ -1487,8 +1488,12 @@ static int chip_attach(struct i2c_adapter *adap, int addr, int kind)
                chip->wt.function = chip_thread_wake;
                chip->wt.data     = (unsigned long)chip;
                init_waitqueue_head(&chip->wq);
-               kernel_thread(chip_thread,(void *)chip,0);
-               down(&sem);
+               rc = kernel_thread(chip_thread,(void *)chip,0);
+               if (rc < 0)
+                       printk(KERN_WARNING "%s: kernel_thread() failed\n",
+                              i2c_clientname(&chip->c));
+               else
+                       down(&sem);
                chip->notify = NULL;
                wake_up_interruptible(&chip->wq);
        }
@@ -1497,8 +1502,17 @@ static int chip_attach(struct i2c_adapter *adap, int addr, int kind)
 
 static int chip_probe(struct i2c_adapter *adap)
 {
+#ifdef I2C_ADAP_CLASS_TV_ANALOG
        if (adap->class & I2C_ADAP_CLASS_TV_ANALOG)
                return i2c_probe(adap, &addr_data, chip_attach);
+#else
+       switch (adap->id) {
+       case I2C_ALGO_BIT | I2C_HW_B_BT848:
+       case I2C_ALGO_BIT | I2C_HW_B_RIVA:
+       case I2C_ALGO_SAA7134:
+               return i2c_probe(adap, &addr_data, chip_attach);
+       }
+#endif
        return 0;
 }
 
index cffcdfae3470030cf7cb5fc04578510b22863ac2..9547482f89f1a2d1dc8981f0592b56a76a4c7839 100644 (file)
@@ -190,6 +190,10 @@ static int tvmixer_open(struct inode *inode, struct file *file)
 
        /* lock bttv in memory while the mixer is in use  */
        file->private_data = mix;
+#ifndef I2C_PEC
+       if (client->adapter->inc_use)
+               client->adapter->inc_use(client->adapter);
+#endif
        if (client->adapter->owner)
                try_module_get(client->adapter->owner);
         return 0;
@@ -205,17 +209,27 @@ static int tvmixer_release(struct inode *inode, struct file *file)
                return -ENODEV;
        }
 
+#ifndef I2C_PEC
+       if (client->adapter->dec_use)
+               client->adapter->dec_use(client->adapter);
+#endif
        if (client->adapter->owner)
                module_put(client->adapter->owner);
        return 0;
 }
 
 static struct i2c_driver driver = {
+#ifdef I2C_PEC
        .owner           = THIS_MODULE,
+#endif
        .name            = "tv card mixer driver",
         .id              = I2C_DRIVERID_TVMIXER,
+#ifdef I2C_DF_DUMMY
+       .flags           = I2C_DF_DUMMY,
+#else
        .flags           = I2C_DF_NOTIFY,
         .detach_adapter  = tvmixer_adapters,
+#endif
         .attach_adapter  = tvmixer_adapters,
         .detach_client   = tvmixer_clients,
 };
@@ -247,8 +261,21 @@ static int tvmixer_clients(struct i2c_client *client)
        struct video_audio va;
        int i,minor;
 
+#ifdef I2C_ADAP_CLASS_TV_ANALOG
        if (!(client->adapter->class & I2C_ADAP_CLASS_TV_ANALOG))
                return -1;
+#else
+       /* TV card ??? */
+       switch (client->adapter->id) {
+       case I2C_ALGO_BIT | I2C_HW_B_BT848:
+       case I2C_ALGO_BIT | I2C_HW_B_RIVA:
+               /* ok, have a look ... */
+               break;
+       default:
+               /* ignore that one */
+               return -1;
+       }
+#endif
 
        /* unregister ?? */
        for (i = 0; i < DEV_MAX; i++) {
index f9360b0665bb782d90a22f084b7c7f0df72aa1c7..dca5dcfc054b6dc4abaabe070ed062b79adf3bc0 100644 (file)
@@ -27,6 +27,9 @@
 #ifndef  I2C_DRIVERID_TDA9874
 # define I2C_DRIVERID_TDA9874 I2C_DRIVERID_EXP0+7
 #endif
+#ifndef  I2C_DRIVERID_SAA6752HS
+# define I2C_DRIVERID_SAA6752HS I2C_DRIVERID_EXP0+8
+#endif
 
 /* algorithms */
 #ifndef I2C_ALGO_SAA7134