Commit 7c39c153 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] v4l: #5 - i2c module updates.

From: Gerd Knorr <kraxel@bytesex.org>

This patch updates a number of video4linux-related i2c modules.  There are a
number of bugfixes which accumulated over time, also some no-op i2c changes
due to merging the i2c cleanups back into my tree and tweak them to make the
modules compile on both 2.5.x and 2.4.x.
parent e508ffb3
This diff is collapsed.
......@@ -330,8 +330,6 @@ static int tda7432_attach(struct i2c_adapter *adap, int addr, int kind)
i2c_set_clientdata(client, t);
do_tda7432_init(client);
MOD_INC_USE_COUNT;
strncpy(client->dev.name, "TDA7432", DEVICE_NAME_SIZE);
printk(KERN_INFO "tda7432: init\n");
i2c_attach_client(client);
......@@ -347,13 +345,12 @@ static int tda7432_probe(struct i2c_adapter *adap)
static int tda7432_detach(struct i2c_client *client)
{
struct tda7432 *t = i2c_get_clientdata(client);
struct tda7432 *t = i2c_get_clientdata(client);
do_tda7432_init(client);
i2c_detach_client(client);
kfree(t);
MOD_DEC_USE_COUNT;
return 0;
}
......@@ -525,11 +522,9 @@ static struct i2c_driver driver = {
static struct i2c_client client_template =
{
.id = -1,
.driver = &driver,
.dev = {
.name = "tda7432",
},
I2C_DEVNAME("tda7432"),
.id = -1,
.driver = &driver,
};
static int tda7432_init(void)
......
......@@ -161,7 +161,8 @@ static void tda9875_set(struct i2c_client *client)
struct tda9875 *tda = i2c_get_clientdata(client);
unsigned char a;
dprintk(KERN_DEBUG "tda9875_set(%04x,%04x,%04x,%04x)\n",tda->lvol,tda->rvol,tda->bass,tda->treble);
dprintk(KERN_DEBUG "tda9875_set(%04x,%04x,%04x,%04x)\n",
tda->lvol,tda->rvol,tda->bass,tda->treble);
a = tda->lvol & 0xff;
......@@ -263,8 +264,6 @@ static int tda9875_attach(struct i2c_adapter *adap, int addr, int kind)
}
do_tda9875_init(client);
MOD_INC_USE_COUNT;
strncpy(client->dev.name, "TDA9875", DEVICE_NAME_SIZE);
printk(KERN_INFO "tda9875: init\n");
i2c_attach_client(client);
......@@ -280,13 +279,12 @@ static int tda9875_probe(struct i2c_adapter *adap)
static int tda9875_detach(struct i2c_client *client)
{
struct tda9875 *t = i2c_get_clientdata(client);
struct tda9875 *t = i2c_get_clientdata(client);
do_tda9875_init(client);
i2c_detach_client(client);
kfree(t);
MOD_DEC_USE_COUNT;
return 0;
}
......@@ -395,11 +393,9 @@ static struct i2c_driver driver = {
static struct i2c_client client_template =
{
.id = -1,
.driver = &driver,
.dev = {
.name = "tda9875",
},
I2C_DEVNAME("tda9875"),
.id = -1,
.driver = &driver,
};
static int tda9875_init(void)
......
......@@ -293,8 +293,6 @@ static int tda9887_configure(struct tda9887 *t)
unsigned char *buf = NULL;
int rc;
printk("tda9887_configure\n");
if (t->radio) {
dprintk("tda9885/6/7: FM Radio mode\n");
buf = buf_fm_stereo;
......@@ -358,11 +356,11 @@ static int tda9887_attach(struct i2c_adapter *adap, int addr, int kind)
return -ENOMEM;
memset(t,0,sizeof(*t));
t->client = client_template;
i2c_set_clientdata(&t->client, t);
t->pinnacle_id = -1;
t->tvnorm=VIDEO_MODE_PAL;
i2c_set_clientdata(&t->client, t);
i2c_attach_client(&t->client);
MOD_INC_USE_COUNT;
return 0;
}
......@@ -379,7 +377,6 @@ static int tda9887_detach(struct i2c_client *client)
i2c_detach_client(client);
kfree(t);
MOD_DEC_USE_COUNT;
return 0;
}
......@@ -404,6 +401,7 @@ tda9887_command(struct i2c_client *client, unsigned int cmd, void *arg)
int *i = arg;
t->pinnacle_id = *i;
tda9887_miro(t);
break;
}
/* --- v4l ioctls --- */
......@@ -441,11 +439,9 @@ static struct i2c_driver driver = {
};
static struct i2c_client client_template =
{
.flags = I2C_CLIENT_ALLOW_USE,
.driver = &driver,
.dev = {
.name = "tda9887",
},
.dev.name = "tda9887",
.flags = I2C_CLIENT_ALLOW_USE,
.driver = &driver,
};
static int tda9887_init_module(void)
......
This diff is collapsed.
......@@ -3,7 +3,7 @@
*/
#define I2C_TDA8425 0x82
#define I2C_TDA9840 0x84
#define I2C_TDA9840 0x84 /* also used by TA8874Z */
#define I2C_TDA985x_L 0xb4 /* also used by 9873 */
#define I2C_TDA985x_H 0xb6
#define I2C_TDA9874 0xb0 /* also used by 9875 */
......
......@@ -10,19 +10,16 @@
#include <linux/videodev.h>
#include <linux/init.h>
#include <linux/kdev_t.h>
#include <asm/semaphore.h>
#include <linux/sound.h>
#include <linux/soundcard.h>
#include <asm/semaphore.h>
#include <asm/uaccess.h>
#define DEV_MAX 4
static int debug = 0;
static int devnr = -1;
MODULE_PARM(debug,"i");
MODULE_PARM(devnr,"i");
MODULE_AUTHOR("Gerd Knorr");
......@@ -87,7 +84,7 @@ static int tvmixer_ioctl(struct inode *inode, struct file *file, unsigned int cm
if (cmd == SOUND_MIXER_INFO) {
mixer_info info;
strncpy(info.id, "tv card", sizeof(info.id));
strncpy(info.name, client->dev.name, sizeof(info.name));
strncpy(info.name, i2c_clientname(client), sizeof(info.name));
info.modify_counter = 42 /* FIXME */;
if (copy_to_user((void *)arg, &info, sizeof(info)))
return -EFAULT;
......@@ -96,7 +93,7 @@ static int tvmixer_ioctl(struct inode *inode, struct file *file, unsigned int cm
if (cmd == SOUND_OLD_MIXER_INFO) {
_old_mixer_info info;
strncpy(info.id, "tv card", sizeof(info.id));
strncpy(info.name, client->dev.name, sizeof(info.name));
strncpy(info.name, i2c_clientname(client), sizeof(info.name));
if (copy_to_user((void *)arg, &info, sizeof(info)))
return -EFAULT;
return 0;
......@@ -143,7 +140,7 @@ static int tvmixer_ioctl(struct inode *inode, struct file *file, unsigned int cm
case MIXER_READ(SOUND_MIXER_VOLUME):
left = (min(65536 - va.balance,32768) *
va.volume) / 32768;
right = (min(va.balance,32768) *
right = (min(va.balance,(u16)32768) *
va.volume) / 32768;
ret = v4l_to_mix2(left,right);
break;
......@@ -218,8 +215,8 @@ static struct i2c_driver driver = {
.name = "tv card mixer driver",
.id = I2C_DRIVERID_TVMIXER,
.flags = I2C_DF_NOTIFY,
.attach_adapter = tvmixer_adapters,
.detach_adapter = tvmixer_adapters,
.attach_adapter = tvmixer_adapters,
.detach_client = tvmixer_clients,
};
......@@ -238,9 +235,6 @@ static int tvmixer_adapters(struct i2c_adapter *adap)
struct list_head *item;
struct i2c_client *client;
if (debug)
printk("tvmixer: adapter %s\n",adap->dev.name);
list_for_each(item,&adap->clients) {
client = list_entry(item, struct i2c_client, list);
tvmixer_clients(client);
......@@ -253,16 +247,8 @@ static int tvmixer_clients(struct i2c_client *client)
struct video_audio va;
int i,minor;
/* TV card ??? */
if (!(client->adapter->class & I2C_ADAP_CLASS_TV_ANALOG)) {
/* ignore that one */
if (debug)
printk("tvmixer: %s is not a tv card\n",
client->adapter->dev.name);
if (!(client->adapter->class & I2C_ADAP_CLASS_TV_ANALOG))
return -1;
}
if (debug)
printk("tvmixer: debug: %s\n",client->dev.name);
/* unregister ?? */
for (i = 0; i < DEV_MAX; i++) {
......@@ -271,7 +257,8 @@ static int tvmixer_clients(struct i2c_client *client)
unregister_sound_mixer(devices[i].minor);
devices[i].dev = NULL;
devices[i].minor = -1;
printk("tvmixer: %s unregistered (#1)\n",client->dev.name);
printk("tvmixer: %s unregistered (#1)\n",
i2c_clientname(client));
return 0;
}
}
......@@ -286,25 +273,13 @@ static int tvmixer_clients(struct i2c_client *client)
}
/* audio chip with mixer ??? */
if (NULL == client->driver->command) {
if (debug)
printk("tvmixer: %s: driver->command is NULL\n",
client->driver->name);
if (NULL == client->driver->command)
return -1;
}
memset(&va,0,sizeof(va));
if (0 != client->driver->command(client,VIDIOCGAUDIO,&va)) {
if (debug)
printk("tvmixer: %s: VIDIOCGAUDIO failed\n",
client->dev.name);
if (0 != client->driver->command(client,VIDIOCGAUDIO,&va))
return -1;
}
if (0 == (va.flags & VIDEO_AUDIO_VOLUME)) {
if (debug)
printk("tvmixer: %s: has no volume control\n",
client->dev.name);
if (0 == (va.flags & VIDEO_AUDIO_VOLUME))
return -1;
}
/* everything is fine, register */
if ((minor = register_sound_mixer(&tvmixer_fops,devnr)) < 0) {
......@@ -342,7 +317,7 @@ static void tvmixer_cleanup_module(void)
if (devices[i].minor != -1) {
unregister_sound_mixer(devices[i].minor);
printk("tvmixer: %s unregistered (#2)\n",
devices[i].dev->dev.name);
i2c_clientname(devices[i].dev));
}
}
}
......
......@@ -18,6 +18,15 @@
#define AUDIO_MUTE 0x80
#define AUDIO_UNMUTE 0x81
/* all the stuff below is obsolete and just here for reference. I'll
* remove it once the driver is tested and works fine.
*
* Instead creating alot of tiny API's for all kinds of different
* chips, we'll just pass throuth the v4l ioctl structs (v4l2 not
* yet...). It is a bit less flexible, but most/all used i2c chips
* make sense in v4l context only. So I think that's acceptable...
*/
/* misc stuff to pass around config info to i2c chips */
#define AUDC_CONFIG_PINNACLE _IOW('m',32,int)
......
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