X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fmedia%2Fvideo%2Ftda9875.c;h=103ccb91929260353df41e36a2e0be86ae882dc2;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=8c7a57944a68a27052c5aa5e8465142ab915b74e;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/drivers/media/video/tda9875.c b/drivers/media/video/tda9875.c index 8c7a57944..103ccb919 100644 --- a/drivers/media/video/tda9875.c +++ b/drivers/media/video/tda9875.c @@ -1,19 +1,19 @@ /* * For the TDA9875 chip - * (The TDA9875 is used on the Diamond DTV2000 french version + * (The TDA9875 is used on the Diamond DTV2000 french version * Other cards probably use these chips as well.) - * This driver will not complain if used with any + * This driver will not complain if used with any * other i2c device with the same address. * * Copyright (c) 2000 Guillaume Delvit based on Gerd Knorr source and - * Eric Sandeen + * Eric Sandeen * This code is placed under the terms of the GNU General Public License * Based on tda9855.c by Steve VanDeBogart (vandebo@uclink.berkeley.edu) * Which was based on tda8425.c by Greg Alexander (c) 1998 * * OPTIONS: * debug - set to 1 if you'd like to see debug messages - * + * * Revision: 0.1 - original version */ @@ -30,26 +30,22 @@ #include #include -#include "bttv.h" -#include -#include -MODULE_PARM(debug,"i"); -MODULE_LICENSE("GPL"); +#include -static int debug = 0; /* insmod parameter */ +static int debug; /* insmod parameter */ +module_param(debug, int, S_IRUGO | S_IWUSR); +MODULE_LICENSE("GPL"); /* Addresses to scan */ static unsigned short normal_i2c[] = { - I2C_TDA9875 >> 1, + I2C_ADDR_TDA9875 >> 1, I2C_CLIENT_END }; -static unsigned short normal_i2c_range[] = {I2C_CLIENT_END}; I2C_CLIENT_INSMOD; /* This is a superset of the TDA9875 */ struct tda9875 { - int mode; int rvol, lvol; int bass, treble; struct i2c_client c; @@ -64,7 +60,7 @@ static struct i2c_client client_template; * http://www.semiconductors.philips.com * TDA9875: I2C-bus controlled DSP audio processor, FM demodulator * - */ + */ /* subaddresses for TDA9875 */ #define TDA9875_MUT 0x12 /*General mute (value --> 0b11001100*/ @@ -124,36 +120,23 @@ static int tda9875_write(struct i2c_client *client, int subaddr, unsigned char v return 0; } -#if 0 -static int tda9875_read(struct i2c_client *client) -{ - unsigned char buffer; - dprintk("In tda9875_read\n"); - if (1 != i2c_master_recv(client,&buffer,1)) { - printk(KERN_WARNING "tda9875: I/O error, trying (read)\n"); - return -1; - } - dprintk("Read 0x%02x\n", buffer); - return buffer; -} -#endif static int i2c_read_register(struct i2c_adapter *adap, int addr, int reg) { - unsigned char write[1]; - unsigned char read[1]; - struct i2c_msg msgs[2] = { - { addr, 0, 1, write }, - { addr, I2C_M_RD, 1, read } - }; - write[0] = reg; - - if (2 != i2c_transfer(adap,msgs,2)) { - printk(KERN_WARNING "tda9875: I/O error (read2)\n"); - return -1; - } - dprintk("tda9875: chip_read2: reg%d=0x%x\n",reg,read[0]); - return read[0]; + unsigned char write[1]; + unsigned char read[1]; + struct i2c_msg msgs[2] = { + { addr, 0, 1, write }, + { addr, I2C_M_RD, 1, read } + }; + write[0] = reg; + + if (2 != i2c_transfer(adap,msgs,2)) { + printk(KERN_WARNING "tda9875: I/O error (read2)\n"); + return -1; + } + dprintk("tda9875: chip_read2: reg%d=0x%x\n",reg,read[0]); + return read[0]; } static void tda9875_set(struct i2c_client *client) @@ -178,7 +161,7 @@ static void tda9875_set(struct i2c_client *client) static void do_tda9875_init(struct i2c_client *client) { struct tda9875 *t = i2c_get_clientdata(client); - dprintk("In tda9875_init\n"); + dprintk("In tda9875_init\n"); tda9875_write(client, TDA9875_CFG, 0xd0 ); /*reg de config 0 (reset)*/ tda9875_write(client, TDA9875_MSR, 0x03 ); /* Monitor 0b00000XXX*/ tda9875_write(client, TDA9875_C1MSB, 0x00 ); /*Car1(FM) MSB XMHz*/ @@ -192,29 +175,28 @@ static void do_tda9875_init(struct i2c_client *client) tda9875_write(client, TDA9875_FMAT, 0x00 ); /*FM Matrix reg 0x00*/ tda9875_write(client, TDA9875_SC1, 0x00 ); /* SCART 1 (SC1)*/ tda9875_write(client, TDA9875_SC2, 0x01 ); /* SCART 2 (sc2)*/ - + tda9875_write(client, TDA9875_CH1V, 0x10 ); /* Channel volume 1 mute*/ tda9875_write(client, TDA9875_CH2V, 0x10 ); /* Channel volume 2 mute */ tda9875_write(client, TDA9875_DACOS, 0x02 ); /* sig DAC i/o(in:nicam)*/ tda9875_write(client, TDA9875_ADCIS, 0x6f ); /* sig ADC input(in:mono)*/ tda9875_write(client, TDA9875_LOSR, 0x00 ); /* line out (in:mono)*/ - tda9875_write(client, TDA9875_AER, 0x00 ); /*06 Effect (AVL+PSEUDO) */ + tda9875_write(client, TDA9875_AER, 0x00 ); /*06 Effect (AVL+PSEUDO) */ tda9875_write(client, TDA9875_MCS, 0x44 ); /* Main ch select (DAC) */ tda9875_write(client, TDA9875_MVL, 0x03 ); /* Vol Main left 10dB */ tda9875_write(client, TDA9875_MVR, 0x03 ); /* Vol Main right 10dB*/ tda9875_write(client, TDA9875_MBA, 0x00 ); /* Main Bass Main 0dB*/ tda9875_write(client, TDA9875_MTR, 0x00 ); /* Main Treble Main 0dB*/ - tda9875_write(client, TDA9875_ACS, 0x44 ); /* Aux chan select (dac)*/ + tda9875_write(client, TDA9875_ACS, 0x44 ); /* Aux chan select (dac)*/ tda9875_write(client, TDA9875_AVL, 0x00 ); /* Vol Aux left 0dB*/ tda9875_write(client, TDA9875_AVR, 0x00 ); /* Vol Aux right 0dB*/ tda9875_write(client, TDA9875_ABA, 0x00 ); /* Aux Bass Main 0dB*/ tda9875_write(client, TDA9875_ATR, 0x00 ); /* Aux Aigus Main 0dB*/ - + tda9875_write(client, TDA9875_MUT, 0xcc ); /* General mute */ - - t->mode=AUDIO_UNMUTE; + t->lvol=t->rvol =0; /* 0dB */ - t->bass=0; /* 0dB */ + t->bass=0; /* 0dB */ t->treble=0; /* 0dB */ tda9875_set(client); @@ -247,22 +229,21 @@ static int tda9875_attach(struct i2c_adapter *adap, int addr, int kind) struct i2c_client *client; dprintk("In tda9875_attach\n"); - t = kmalloc(sizeof *t,GFP_KERNEL); + t = kzalloc(sizeof *t,GFP_KERNEL); if (!t) return -ENOMEM; - memset(t,0,sizeof *t); client = &t->c; - memcpy(client,&client_template,sizeof(struct i2c_client)); - client->adapter = adap; - client->addr = addr; + memcpy(client,&client_template,sizeof(struct i2c_client)); + client->adapter = adap; + client->addr = addr; i2c_set_clientdata(client, t); if(!tda9875_checkit(adap,addr)) { kfree(t); return 1; } - + do_tda9875_init(client); printk(KERN_INFO "tda9875: init\n"); @@ -272,13 +253,8 @@ 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)) + if (adap->class & I2C_CLASS_TV_ANALOG) return i2c_probe(adap, &addr_data, tda9875_attach); -#endif return 0; } @@ -288,7 +264,7 @@ static int tda9875_detach(struct i2c_client *client) do_tda9875_init(client); i2c_detach_client(client); - + kfree(t); return 0; } @@ -298,10 +274,10 @@ static int tda9875_command(struct i2c_client *client, { struct tda9875 *t = i2c_get_clientdata(client); - dprintk("In tda9875_command...\n"); + dprintk("In tda9875_command...\n"); - switch (cmd) { - /* --- v4l ioctls --- */ + switch (cmd) { + /* --- v4l ioctls --- */ /* take care: bttv does userspace copying, we'll get a kernel pointer here... */ case VIDIOCGAUDIO: @@ -335,7 +311,7 @@ static int tda9875_command(struct i2c_client *client, struct video_audio *va = arg; int left,right; - dprintk("VIDEOCSAUDIO...\n"); + dprintk("VIDEOCSAUDIO...\n"); left = (min(65536 - va->balance,32768) * va->volume) / 32768; right = (min(va->balance,(__u16)32768) * @@ -357,7 +333,7 @@ static int tda9875_command(struct i2c_client *client, t->bass = 15; if (t->bass < -12) t->bass = -12 & 0xff; - + t->treble = ((va->treble/2700)-12) & 0xff; if (t->treble > 12) t->treble = 12; @@ -367,9 +343,9 @@ static int tda9875_command(struct i2c_client *client, //printk("tda9875 bal:%04x vol:%04x bass:%04x treble:%04x\n",va->balance,va->volume,va->bass,va->treble); - - tda9875_set(client); + + tda9875_set(client); break; @@ -387,29 +363,27 @@ static int tda9875_command(struct i2c_client *client, static struct i2c_driver driver = { - .owner = THIS_MODULE, - .name = "i2c tda9875 driver", - .id = I2C_DRIVERID_TDA9875, - .flags = I2C_DF_NOTIFY, + .driver = { + .name = "tda9875", + }, + .id = I2C_DRIVERID_TDA9875, .attach_adapter = tda9875_probe, - .detach_client = tda9875_detach, - .command = tda9875_command, + .detach_client = tda9875_detach, + .command = tda9875_command, }; static struct i2c_client client_template = { - I2C_DEVNAME("tda9875"), - .id = -1, - .driver = &driver, + .name = "tda9875", + .driver = &driver, }; -static int tda9875_init(void) +static int __init tda9875_init(void) { - i2c_add_driver(&driver); - return 0; + return i2c_add_driver(&driver); } -static void tda9875_fini(void) +static void __exit tda9875_fini(void) { i2c_del_driver(&driver); }