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) ...@@ -330,8 +330,6 @@ static int tda7432_attach(struct i2c_adapter *adap, int addr, int kind)
i2c_set_clientdata(client, t); i2c_set_clientdata(client, t);
do_tda7432_init(client); do_tda7432_init(client);
MOD_INC_USE_COUNT;
strncpy(client->dev.name, "TDA7432", DEVICE_NAME_SIZE);
printk(KERN_INFO "tda7432: init\n"); printk(KERN_INFO "tda7432: init\n");
i2c_attach_client(client); i2c_attach_client(client);
...@@ -347,13 +345,12 @@ static int tda7432_probe(struct i2c_adapter *adap) ...@@ -347,13 +345,12 @@ static int tda7432_probe(struct i2c_adapter *adap)
static int tda7432_detach(struct i2c_client *client) 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); do_tda7432_init(client);
i2c_detach_client(client); i2c_detach_client(client);
kfree(t); kfree(t);
MOD_DEC_USE_COUNT;
return 0; return 0;
} }
...@@ -525,11 +522,9 @@ static struct i2c_driver driver = { ...@@ -525,11 +522,9 @@ static struct i2c_driver driver = {
static struct i2c_client client_template = static struct i2c_client client_template =
{ {
.id = -1, I2C_DEVNAME("tda7432"),
.driver = &driver, .id = -1,
.dev = { .driver = &driver,
.name = "tda7432",
},
}; };
static int tda7432_init(void) static int tda7432_init(void)
......
...@@ -161,7 +161,8 @@ static void tda9875_set(struct i2c_client *client) ...@@ -161,7 +161,8 @@ static void tda9875_set(struct i2c_client *client)
struct tda9875 *tda = i2c_get_clientdata(client); struct tda9875 *tda = i2c_get_clientdata(client);
unsigned char a; 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; a = tda->lvol & 0xff;
...@@ -263,8 +264,6 @@ static int tda9875_attach(struct i2c_adapter *adap, int addr, int kind) ...@@ -263,8 +264,6 @@ static int tda9875_attach(struct i2c_adapter *adap, int addr, int kind)
} }
do_tda9875_init(client); do_tda9875_init(client);
MOD_INC_USE_COUNT;
strncpy(client->dev.name, "TDA9875", DEVICE_NAME_SIZE);
printk(KERN_INFO "tda9875: init\n"); printk(KERN_INFO "tda9875: init\n");
i2c_attach_client(client); i2c_attach_client(client);
...@@ -280,13 +279,12 @@ static int tda9875_probe(struct i2c_adapter *adap) ...@@ -280,13 +279,12 @@ static int tda9875_probe(struct i2c_adapter *adap)
static int tda9875_detach(struct i2c_client *client) 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); do_tda9875_init(client);
i2c_detach_client(client); i2c_detach_client(client);
kfree(t); kfree(t);
MOD_DEC_USE_COUNT;
return 0; return 0;
} }
...@@ -395,11 +393,9 @@ static struct i2c_driver driver = { ...@@ -395,11 +393,9 @@ static struct i2c_driver driver = {
static struct i2c_client client_template = static struct i2c_client client_template =
{ {
.id = -1, I2C_DEVNAME("tda9875"),
.driver = &driver, .id = -1,
.dev = { .driver = &driver,
.name = "tda9875",
},
}; };
static int tda9875_init(void) static int tda9875_init(void)
......
...@@ -293,8 +293,6 @@ static int tda9887_configure(struct tda9887 *t) ...@@ -293,8 +293,6 @@ static int tda9887_configure(struct tda9887 *t)
unsigned char *buf = NULL; unsigned char *buf = NULL;
int rc; int rc;
printk("tda9887_configure\n");
if (t->radio) { if (t->radio) {
dprintk("tda9885/6/7: FM Radio mode\n"); dprintk("tda9885/6/7: FM Radio mode\n");
buf = buf_fm_stereo; buf = buf_fm_stereo;
...@@ -358,11 +356,11 @@ static int tda9887_attach(struct i2c_adapter *adap, int addr, int kind) ...@@ -358,11 +356,11 @@ static int tda9887_attach(struct i2c_adapter *adap, int addr, int kind)
return -ENOMEM; return -ENOMEM;
memset(t,0,sizeof(*t)); memset(t,0,sizeof(*t));
t->client = client_template; t->client = client_template;
i2c_set_clientdata(&t->client, t);
t->pinnacle_id = -1; t->pinnacle_id = -1;
t->tvnorm=VIDEO_MODE_PAL;
i2c_set_clientdata(&t->client, t);
i2c_attach_client(&t->client); i2c_attach_client(&t->client);
MOD_INC_USE_COUNT;
return 0; return 0;
} }
...@@ -379,7 +377,6 @@ static int tda9887_detach(struct i2c_client *client) ...@@ -379,7 +377,6 @@ static int tda9887_detach(struct i2c_client *client)
i2c_detach_client(client); i2c_detach_client(client);
kfree(t); kfree(t);
MOD_DEC_USE_COUNT;
return 0; return 0;
} }
...@@ -404,6 +401,7 @@ tda9887_command(struct i2c_client *client, unsigned int cmd, void *arg) ...@@ -404,6 +401,7 @@ tda9887_command(struct i2c_client *client, unsigned int cmd, void *arg)
int *i = arg; int *i = arg;
t->pinnacle_id = *i; t->pinnacle_id = *i;
tda9887_miro(t);
break; break;
} }
/* --- v4l ioctls --- */ /* --- v4l ioctls --- */
...@@ -441,11 +439,9 @@ static struct i2c_driver driver = { ...@@ -441,11 +439,9 @@ static struct i2c_driver driver = {
}; };
static struct i2c_client client_template = static struct i2c_client client_template =
{ {
.flags = I2C_CLIENT_ALLOW_USE, .dev.name = "tda9887",
.driver = &driver, .flags = I2C_CLIENT_ALLOW_USE,
.dev = { .driver = &driver,
.name = "tda9887",
},
}; };
static int tda9887_init_module(void) static int tda9887_init_module(void)
......
This diff is collapsed.
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
*/ */
#define I2C_TDA8425 0x82 #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_L 0xb4 /* also used by 9873 */
#define I2C_TDA985x_H 0xb6 #define I2C_TDA985x_H 0xb6
#define I2C_TDA9874 0xb0 /* also used by 9875 */ #define I2C_TDA9874 0xb0 /* also used by 9875 */
......
...@@ -10,19 +10,16 @@ ...@@ -10,19 +10,16 @@
#include <linux/videodev.h> #include <linux/videodev.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/kdev_t.h> #include <linux/kdev_t.h>
#include <asm/semaphore.h>
#include <linux/sound.h> #include <linux/sound.h>
#include <linux/soundcard.h> #include <linux/soundcard.h>
#include <asm/semaphore.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#define DEV_MAX 4 #define DEV_MAX 4
static int debug = 0;
static int devnr = -1; static int devnr = -1;
MODULE_PARM(debug,"i");
MODULE_PARM(devnr,"i"); MODULE_PARM(devnr,"i");
MODULE_AUTHOR("Gerd Knorr"); MODULE_AUTHOR("Gerd Knorr");
...@@ -87,7 +84,7 @@ static int tvmixer_ioctl(struct inode *inode, struct file *file, unsigned int cm ...@@ -87,7 +84,7 @@ static int tvmixer_ioctl(struct inode *inode, struct file *file, unsigned int cm
if (cmd == SOUND_MIXER_INFO) { if (cmd == SOUND_MIXER_INFO) {
mixer_info info; mixer_info info;
strncpy(info.id, "tv card", sizeof(info.id)); 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 */; info.modify_counter = 42 /* FIXME */;
if (copy_to_user((void *)arg, &info, sizeof(info))) if (copy_to_user((void *)arg, &info, sizeof(info)))
return -EFAULT; return -EFAULT;
...@@ -96,7 +93,7 @@ static int tvmixer_ioctl(struct inode *inode, struct file *file, unsigned int cm ...@@ -96,7 +93,7 @@ static int tvmixer_ioctl(struct inode *inode, struct file *file, unsigned int cm
if (cmd == SOUND_OLD_MIXER_INFO) { if (cmd == SOUND_OLD_MIXER_INFO) {
_old_mixer_info info; _old_mixer_info info;
strncpy(info.id, "tv card", sizeof(info.id)); 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))) if (copy_to_user((void *)arg, &info, sizeof(info)))
return -EFAULT; return -EFAULT;
return 0; return 0;
...@@ -143,7 +140,7 @@ static int tvmixer_ioctl(struct inode *inode, struct file *file, unsigned int cm ...@@ -143,7 +140,7 @@ static int tvmixer_ioctl(struct inode *inode, struct file *file, unsigned int cm
case MIXER_READ(SOUND_MIXER_VOLUME): case MIXER_READ(SOUND_MIXER_VOLUME):
left = (min(65536 - va.balance,32768) * left = (min(65536 - va.balance,32768) *
va.volume) / 32768; va.volume) / 32768;
right = (min(va.balance,32768) * right = (min(va.balance,(u16)32768) *
va.volume) / 32768; va.volume) / 32768;
ret = v4l_to_mix2(left,right); ret = v4l_to_mix2(left,right);
break; break;
...@@ -218,8 +215,8 @@ static struct i2c_driver driver = { ...@@ -218,8 +215,8 @@ static struct i2c_driver driver = {
.name = "tv card mixer driver", .name = "tv card mixer driver",
.id = I2C_DRIVERID_TVMIXER, .id = I2C_DRIVERID_TVMIXER,
.flags = I2C_DF_NOTIFY, .flags = I2C_DF_NOTIFY,
.attach_adapter = tvmixer_adapters,
.detach_adapter = tvmixer_adapters, .detach_adapter = tvmixer_adapters,
.attach_adapter = tvmixer_adapters,
.detach_client = tvmixer_clients, .detach_client = tvmixer_clients,
}; };
...@@ -238,9 +235,6 @@ static int tvmixer_adapters(struct i2c_adapter *adap) ...@@ -238,9 +235,6 @@ static int tvmixer_adapters(struct i2c_adapter *adap)
struct list_head *item; struct list_head *item;
struct i2c_client *client; struct i2c_client *client;
if (debug)
printk("tvmixer: adapter %s\n",adap->dev.name);
list_for_each(item,&adap->clients) { list_for_each(item,&adap->clients) {
client = list_entry(item, struct i2c_client, list); client = list_entry(item, struct i2c_client, list);
tvmixer_clients(client); tvmixer_clients(client);
...@@ -253,16 +247,8 @@ static int tvmixer_clients(struct i2c_client *client) ...@@ -253,16 +247,8 @@ static int tvmixer_clients(struct i2c_client *client)
struct video_audio va; struct video_audio va;
int i,minor; int i,minor;
/* TV card ??? */ if (!(client->adapter->class & I2C_ADAP_CLASS_TV_ANALOG))
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);
return -1; return -1;
}
if (debug)
printk("tvmixer: debug: %s\n",client->dev.name);
/* unregister ?? */ /* unregister ?? */
for (i = 0; i < DEV_MAX; i++) { for (i = 0; i < DEV_MAX; i++) {
...@@ -271,7 +257,8 @@ static int tvmixer_clients(struct i2c_client *client) ...@@ -271,7 +257,8 @@ static int tvmixer_clients(struct i2c_client *client)
unregister_sound_mixer(devices[i].minor); unregister_sound_mixer(devices[i].minor);
devices[i].dev = NULL; devices[i].dev = NULL;
devices[i].minor = -1; devices[i].minor = -1;
printk("tvmixer: %s unregistered (#1)\n",client->dev.name); printk("tvmixer: %s unregistered (#1)\n",
i2c_clientname(client));
return 0; return 0;
} }
} }
...@@ -286,25 +273,13 @@ static int tvmixer_clients(struct i2c_client *client) ...@@ -286,25 +273,13 @@ static int tvmixer_clients(struct i2c_client *client)
} }
/* audio chip with mixer ??? */ /* audio chip with mixer ??? */
if (NULL == client->driver->command) { if (NULL == client->driver->command)
if (debug)
printk("tvmixer: %s: driver->command is NULL\n",
client->driver->name);
return -1; return -1;
}
memset(&va,0,sizeof(va)); memset(&va,0,sizeof(va));
if (0 != client->driver->command(client,VIDIOCGAUDIO,&va)) { if (0 != client->driver->command(client,VIDIOCGAUDIO,&va))
if (debug)
printk("tvmixer: %s: VIDIOCGAUDIO failed\n",
client->dev.name);
return -1; return -1;
} if (0 == (va.flags & VIDEO_AUDIO_VOLUME))
if (0 == (va.flags & VIDEO_AUDIO_VOLUME)) {
if (debug)
printk("tvmixer: %s: has no volume control\n",
client->dev.name);
return -1; return -1;
}
/* everything is fine, register */ /* everything is fine, register */
if ((minor = register_sound_mixer(&tvmixer_fops,devnr)) < 0) { if ((minor = register_sound_mixer(&tvmixer_fops,devnr)) < 0) {
...@@ -342,7 +317,7 @@ static void tvmixer_cleanup_module(void) ...@@ -342,7 +317,7 @@ static void tvmixer_cleanup_module(void)
if (devices[i].minor != -1) { if (devices[i].minor != -1) {
unregister_sound_mixer(devices[i].minor); unregister_sound_mixer(devices[i].minor);
printk("tvmixer: %s unregistered (#2)\n", printk("tvmixer: %s unregistered (#2)\n",
devices[i].dev->dev.name); i2c_clientname(devices[i].dev));
} }
} }
} }
......
...@@ -18,6 +18,15 @@ ...@@ -18,6 +18,15 @@
#define AUDIO_MUTE 0x80 #define AUDIO_MUTE 0x80
#define AUDIO_UNMUTE 0x81 #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 */ /* misc stuff to pass around config info to i2c chips */
#define AUDC_CONFIG_PINNACLE _IOW('m',32,int) #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