Commit 355cf16f authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] v4l: misc i2c fixes

From: Gerd Knorr <kraxel@bytesex.org>

This is a collection of misc i2c tv helper module fixes.
parent e6cc7a13
......@@ -50,10 +50,6 @@
#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;
}
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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)
......
......@@ -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;
}
......
......@@ -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++) {
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment