Commit 58c2e6e8 authored by Linus Torvalds's avatar Linus Torvalds

Merge http://gkernel.bkbits.net/net-drivers-2.5

into home.transmeta.com:/home/torvalds/v2.5/linux
parents ceaade5e b893e082
...@@ -39,15 +39,32 @@ ...@@ -39,15 +39,32 @@
#include <linux/videodev.h> #include <linux/videodev.h>
#include <linux/i2c-old.h> #include <linux/i2c.h>
#include <linux/video_decoder.h> #include <linux/video_decoder.h>
#define DEBUG(x) x /* Debug driver */ #define DEBUG(x) x /* Debug driver */
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
static unsigned short normal_i2c[] = {34>>1, I2C_CLIENT_END };
static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
static unsigned short probe[2] = { I2C_CLIENT_END , I2C_CLIENT_END };
static unsigned short probe_range[2] = { I2C_CLIENT_END , I2C_CLIENT_END };
static unsigned short ignore[2] = { I2C_CLIENT_END , I2C_CLIENT_END };
static unsigned short ignore_range[2] = { I2C_CLIENT_END , I2C_CLIENT_END };
static unsigned force[2] = { I2C_CLIENT_END , I2C_CLIENT_END };
static struct i2c_client_address_data addr_data = {
normal_i2c , normal_i2c_range,
probe , probe_range,
ignore , ignore_range,
force
};
static struct i2c_client client_template;
struct bt819 { struct bt819 {
struct i2c_bus *bus; struct i2c_client *client;
int addr; int addr;
unsigned char reg[32]; unsigned char reg[32];
...@@ -59,6 +76,7 @@ struct bt819 { ...@@ -59,6 +76,7 @@ struct bt819 {
int contrast; int contrast;
int hue; int hue;
int sat; int sat;
struct semaphore lock;
}; };
struct timing { struct timing {
...@@ -82,71 +100,17 @@ struct timing timing_data[] = { ...@@ -82,71 +100,17 @@ struct timing timing_data[] = {
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
static int bt819_write(struct bt819 *dev, unsigned char subaddr, static int bt819_probe(struct i2c_adapter *adap)
unsigned char data)
{ {
int ack; return i2c_probe(adap, &addr_data, bt819_attach);
LOCK_I2C_BUS(dev->bus);
i2c_start(dev->bus);
i2c_sendbyte(dev->bus, dev->addr, I2C_DELAY);
i2c_sendbyte(dev->bus, subaddr, I2C_DELAY);
ack = i2c_sendbyte(dev->bus, data, I2C_DELAY);
dev->reg[subaddr] = data;
i2c_stop(dev->bus);
UNLOCK_I2C_BUS(dev->bus);
return ack;
} }
static int bt819_setbit(struct bt819 *dev, int subaddr, int bit, int data) static int bt819_setbit(struct bt819 *dev, int subaddr, int bit, int data)
{ {
return bt819_write(dev, subaddr, (dev->reg[subaddr] & ~(1 << bit)) | (data ? (1 << bit) : 0)); return i2c_smbus_write_byte_data(dev->client, subaddr, (dev->reg[subaddr] & ~(1 << bit)) | (data ? (1 << bit) : 0));
}
static int bt819_write_block(struct bt819 *dev, unsigned const char *data,
unsigned int len)
{
int ack;
unsigned subaddr;
ack = 0;
while (len > 1) {
LOCK_I2C_BUS(dev->bus);
i2c_start(dev->bus);
i2c_sendbyte(dev->bus, dev->addr, I2C_DELAY);
ack = i2c_sendbyte(dev->bus, (subaddr = *data++), I2C_DELAY);
ack = i2c_sendbyte(dev->bus, (dev->reg[subaddr] = *data++),
I2C_DELAY);
len -= 2;
while (len > 1 && *data == ++subaddr) {
data++;
ack =
i2c_sendbyte(dev->bus, (dev->reg[subaddr] = *data++), I2C_DELAY);
len -= 2;
}
i2c_stop(dev->bus);
UNLOCK_I2C_BUS(dev->bus);
}
return ack;
}
static int bt819_read(struct bt819 *dev, unsigned char subaddr)
{
int data;
LOCK_I2C_BUS(dev->bus);
i2c_start(dev->bus);
i2c_sendbyte(dev->bus, dev->addr, I2C_DELAY);
i2c_sendbyte(dev->bus, subaddr, I2C_DELAY);
i2c_start(dev->bus);
i2c_sendbyte(dev->bus, dev->addr | 1, I2C_DELAY);
data = i2c_readbyte(dev->bus, 1);
i2c_stop(dev->bus);
UNLOCK_I2C_BUS(dev->bus);
return data;
} }
static int bt819_init(struct i2c_device *device) static int bt819_init(struct i2c_client *client)
{ {
struct bt819 *decoder; struct bt819 *decoder;
...@@ -178,7 +142,7 @@ static int bt819_init(struct i2c_device *device) ...@@ -178,7 +142,7 @@ static int bt819_init(struct i2c_device *device)
struct timing *timing; struct timing *timing;
decoder = device->data; decoder = client->data;
timing = &timing_data[decoder->norm]; timing = &timing_data[decoder->norm];
init[3 * 2 - 1] = (((timing->vdelay >> 8) & 0x03) << 6) | init[3 * 2 - 1] = (((timing->vdelay >> 8) & 0x03) << 6) |
...@@ -192,31 +156,38 @@ static int bt819_init(struct i2c_device *device) ...@@ -192,31 +156,38 @@ static int bt819_init(struct i2c_device *device)
init[8 * 2 - 1] = timing->hscale >> 8; init[8 * 2 - 1] = timing->hscale >> 8;
init[9 * 2 - 1] = timing->hscale & 0xff; init[9 * 2 - 1] = timing->hscale & 0xff;
bt819_write(decoder, 0x1f, 0x00); i2c_smbus_write_byte_data(client, 0x1f, 0x00);
mdelay(1); mdelay(1);
return bt819_write_block(decoder, init, sizeof(init)); return i2c_master_send(client, init, sizeof(init));
} }
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
static int bt819_attach(struct i2c_device *device) static int bt819_attach(struct i2c_adapter *adap, int addr , unsigned long flags, int kind)
{ {
int i; int i;
struct bt819 *decoder; struct bt819 *decoder;
struct i2c_client *client;
MOD_INC_USE_COUNT; client = kmalloc(sizeof(*client), GFP_KERNEL);
if(client == NULL)
return -ENOMEM;
client_template.adapter = adap;
client_template.addr = addr;
memcpy(client, &client_template, sizeof(*client));
device->data = decoder = kmalloc(sizeof(struct bt819), GFP_KERNEL); decoder = kmalloc(sizeof(struct bt819), GFP_KERNEL);
if (decoder == NULL) { if (decoder == NULL) {
MOD_DEC_USE_COUNT; MOD_DEC_USE_COUNT;
return -ENOMEM; return -ENOMEM;
} }
memset(decoder, 0, sizeof(struct bt819)); memset(decoder, 0, sizeof(struct bt819));
strcpy(device->name, "bt819"); strcpy(client->name, "bt819");
decoder->bus = device->bus; client->data = decoder;
decoder->addr = device->addr; decoder->client = client;
decoder->addr = addr;
decoder->norm = VIDEO_MODE_NTSC; decoder->norm = VIDEO_MODE_NTSC;
decoder->input = 0; decoder->input = 0;
decoder->enable = 1; decoder->enable = 1;
...@@ -226,34 +197,39 @@ static int bt819_attach(struct i2c_device *device) ...@@ -226,34 +197,39 @@ static int bt819_attach(struct i2c_device *device)
decoder->sat = 32768; decoder->sat = 32768;
decoder->initialized = 0; decoder->initialized = 0;
i = bt819_init(device); i = bt819_init(client);
if (i < 0) { if (i < 0) {
printk(KERN_ERR "%s: bt819_attach: init status %d\n", printk(KERN_ERR "%s: bt819_attach: init status %d\n",
decoder->bus->name, i); decoder->client->name, i);
} else { } else {
printk(KERN_INFO "%s: bt819_attach: chip version %x\n", printk(KERN_INFO "%s: bt819_attach: chip version %x\n",
decoder->bus->name, bt819_read(decoder, decoder->client->name, i2c_smbus_read_byte_data(client,
0x17) & 0x0f); 0x17) & 0x0f);
} }
init_MUTEX(&decoder->lock);
i2c_attach_client(client);
MOD_INC_USE_COUNT;
return 0; return 0;
} }
static int bt819_detach(struct i2c_device *device) static int bt819_detach(struct i2c_client *client)
{ {
kfree(device->data); i2c_detach_client(client);
kfree(client->data);
kfree(client);
MOD_DEC_USE_COUNT; MOD_DEC_USE_COUNT;
return 0; return 0;
} }
static int bt819_command(struct i2c_device *device, unsigned int cmd, void *arg) static int bt819_command(struct i2c_client *client, unsigned int cmd, void *arg)
{ {
int temp; int temp;
struct bt819 *decoder = device->data; struct bt819 *decoder = client->data;
//return 0; //return 0;
if (!decoder->initialized) { // First call to bt819_init could be if (!decoder->initialized) { // First call to bt819_init could be
bt819_init(device); // without #FRST = 0 bt819_init(client); // without #FRST = 0
decoder->initialized = 1; decoder->initialized = 1;
} }
...@@ -277,7 +253,7 @@ static int bt819_command(struct i2c_device *device, unsigned int cmd, void *arg) ...@@ -277,7 +253,7 @@ static int bt819_command(struct i2c_device *device, unsigned int cmd, void *arg)
int status; int status;
int res; int res;
status = bt819_read(decoder, 0x00); status = i2c_smbus_read_byte_data(client, 0x00);
res = 0; res = 0;
if ((status & 0x80)) { if ((status & 0x80)) {
res |= DECODER_STATUS_GOOD; res |= DECODER_STATUS_GOOD;
...@@ -302,7 +278,7 @@ static int bt819_command(struct i2c_device *device, unsigned int cmd, void *arg) ...@@ -302,7 +278,7 @@ static int bt819_command(struct i2c_device *device, unsigned int cmd, void *arg)
*iarg = res; *iarg = res;
DEBUG(printk(KERN_INFO "%s-bt819: get status %x\n", DEBUG(printk(KERN_INFO "%s-bt819: get status %x\n",
decoder->bus->name, *iarg)); decoder->client->name, *iarg));
} }
break; break;
...@@ -312,37 +288,38 @@ static int bt819_command(struct i2c_device *device, unsigned int cmd, void *arg) ...@@ -312,37 +288,38 @@ static int bt819_command(struct i2c_device *device, unsigned int cmd, void *arg)
struct timing *timing; struct timing *timing;
DEBUG(printk(KERN_INFO "%s-bt819: set norm %x\n", DEBUG(printk(KERN_INFO "%s-bt819: set norm %x\n",
decoder->bus->name, *iarg)); decoder->client->name, *iarg));
if (*iarg == VIDEO_MODE_NTSC) { if (*iarg == VIDEO_MODE_NTSC) {
bt819_setbit(decoder, 0x01, 0, 1); bt819_setbit(decoder, 0x01, 0, 1);
bt819_setbit(decoder, 0x01, 1, 0); bt819_setbit(decoder, 0x01, 1, 0);
bt819_write(decoder, 0x18, 0x68); i2c_smbus_write_byte_data(client, 0x18, 0x68);
bt819_write(decoder, 0x19, 0x5d); i2c_smbus_write_byte_data(client, 0x19, 0x5d);
//bt819_setbit(decoder, 0x1a, 5, 1); //bt819_setbit(decoder, 0x1a, 5, 1);
timing = &timing_data[VIDEO_MODE_NTSC]; timing = &timing_data[VIDEO_MODE_NTSC];
} else { } else {
bt819_setbit(decoder, 0x01, 0, 1); bt819_setbit(decoder, 0x01, 0, 1);
bt819_setbit(decoder, 0x01, 1, 1); bt819_setbit(decoder, 0x01, 1, 1);
bt819_write(decoder, 0x18, 0x7f); i2c_smbus_write_byte_data(client, 0x18, 0x7f);
bt819_write(decoder, 0x19, 0x72); i2c_smbus_write_byte_data(client, 0x19, 0x72);
//bt819_setbit(decoder, 0x1a, 5, 0); //bt819_setbit(decoder, 0x1a, 5, 0);
timing = &timing_data[VIDEO_MODE_PAL]; timing = &timing_data[VIDEO_MODE_PAL];
} }
bt819_write(decoder, 0x03, i2c_smbus_write_byte_data(client, 0x03,
(((timing->vdelay >> 8) & 0x03) << 6) | (((timing->vdelay >> 8) & 0x03) << 6) |
(((timing-> (((timing->
vactive >> 8) & 0x03) << 4) | vactive >> 8) & 0x03) << 4) |
(((timing-> (((timing->
hdelay >> 8) & 0x03) << 2) | hdelay >> 8) & 0x03) << 2) |
((timing->hactive >> 8) & 0x03)); ((timing->hactive >> 8) & 0x03));
bt819_write(decoder, 0x04, timing->vdelay & 0xff);
bt819_write(decoder, 0x05, timing->vactive & 0xff); i2c_smbus_write_byte_data(client, 0x04, timing->vdelay & 0xff);
bt819_write(decoder, 0x06, timing->hdelay & 0xff); i2c_smbus_write_byte_data(client, 0x05, timing->vactive & 0xff);
bt819_write(decoder, 0x07, timing->hactive & 0xff); i2c_smbus_write_byte_data(client, 0x06, timing->hdelay & 0xff);
bt819_write(decoder, 0x08, timing->hscale >> 8); i2c_smbus_write_byte_data(client, 0x07, timing->hactive & 0xff);
bt819_write(decoder, 0x09, timing->hscale & 0xff); i2c_smbus_write_byte_data(client, 0x08, timing->hscale >> 8);
i2c_smbus_write_byte_data(client, 0x09, timing->hscale & 0xff);
decoder->norm = *iarg; decoder->norm = *iarg;
} }
break; break;
...@@ -352,7 +329,7 @@ static int bt819_command(struct i2c_device *device, unsigned int cmd, void *arg) ...@@ -352,7 +329,7 @@ static int bt819_command(struct i2c_device *device, unsigned int cmd, void *arg)
int *iarg = arg; int *iarg = arg;
DEBUG(printk(KERN_INFO "%s-bt819: set input %x\n", DEBUG(printk(KERN_INFO "%s-bt819: set input %x\n",
decoder->bus->name, *iarg)); decoder->client->name, *iarg));
if (*iarg < 0 || *iarg > 7) { if (*iarg < 0 || *iarg > 7) {
return -EINVAL; return -EINVAL;
...@@ -377,7 +354,7 @@ static int bt819_command(struct i2c_device *device, unsigned int cmd, void *arg) ...@@ -377,7 +354,7 @@ static int bt819_command(struct i2c_device *device, unsigned int cmd, void *arg)
int *iarg = arg; int *iarg = arg;
DEBUG(printk(KERN_INFO "%s-bt819: set output %x\n", DEBUG(printk(KERN_INFO "%s-bt819: set output %x\n",
decoder->bus->name, *iarg)); decoder->client->name, *iarg));
/* not much choice of outputs */ /* not much choice of outputs */
if (*iarg != 0) { if (*iarg != 0) {
...@@ -393,7 +370,7 @@ static int bt819_command(struct i2c_device *device, unsigned int cmd, void *arg) ...@@ -393,7 +370,7 @@ static int bt819_command(struct i2c_device *device, unsigned int cmd, void *arg)
DEBUG(printk DEBUG(printk
(KERN_INFO "%s-bt819: enable output %x\n", (KERN_INFO "%s-bt819: enable output %x\n",
decoder->bus->name, *iarg)); decoder->client->name, *iarg));
if (decoder->enable != enable) { if (decoder->enable != enable) {
decoder->enable = enable; decoder->enable = enable;
...@@ -414,21 +391,21 @@ static int bt819_command(struct i2c_device *device, unsigned int cmd, void *arg) ...@@ -414,21 +391,21 @@ static int bt819_command(struct i2c_device *device, unsigned int cmd, void *arg)
DEBUG(printk DEBUG(printk
(KERN_INFO (KERN_INFO
"%s-bt819: set picture brightness %d contrast %d colour %d\n", "%s-bt819: set picture brightness %d contrast %d colour %d\n",
decoder->bus->name, pic->brightness, decoder->client->name, pic->brightness,
pic->contrast, pic->colour)); pic->contrast, pic->colour));
if (decoder->bright != pic->brightness) { if (decoder->bright != pic->brightness) {
/* We want -128 to 127 we get 0-65535 */ /* We want -128 to 127 we get 0-65535 */
decoder->bright = pic->brightness; decoder->bright = pic->brightness;
bt819_write(decoder, 0x0a, i2c_smbus_write_byte_data(client, 0x0a,
(decoder->bright >> 8) - 128); (decoder->bright >> 8) - 128);
} }
if (decoder->contrast != pic->contrast) { if (decoder->contrast != pic->contrast) {
/* We want 0 to 511 we get 0-65535 */ /* We want 0 to 511 we get 0-65535 */
decoder->contrast = pic->contrast; decoder->contrast = pic->contrast;
bt819_write(decoder, 0x0c, i2c_smbus_write_byte_data(client, 0x0c,
(decoder-> (decoder->
contrast >> 7) & 0xff); contrast >> 7) & 0xff);
bt819_setbit(decoder, 0x0b, 2, bt819_setbit(decoder, 0x0b, 2,
...@@ -439,14 +416,14 @@ static int bt819_command(struct i2c_device *device, unsigned int cmd, void *arg) ...@@ -439,14 +416,14 @@ static int bt819_command(struct i2c_device *device, unsigned int cmd, void *arg)
if (decoder->sat != pic->colour) { if (decoder->sat != pic->colour) {
/* We want 0 to 511 we get 0-65535 */ /* We want 0 to 511 we get 0-65535 */
decoder->sat = pic->colour; decoder->sat = pic->colour;
bt819_write(decoder, 0x0d, i2c_smbus_write_byte_data(client, 0x0d,
(decoder->sat >> 7) & 0xff); (decoder->sat >> 7) & 0xff);
bt819_setbit(decoder, 0x0b, 1, bt819_setbit(decoder, 0x0b, 1,
((decoder-> ((decoder->
sat >> 15) & 0x01)); sat >> 15) & 0x01));
temp = (decoder->sat * 201) / 237; temp = (decoder->sat * 201) / 237;
bt819_write(decoder, 0x0e, i2c_smbus_write_byte_data(client, 0x0e,
(temp >> 7) & 0xff); (temp >> 7) & 0xff);
bt819_setbit(decoder, 0x0b, 0, bt819_setbit(decoder, 0x0b, 0,
(temp >> 15) & 0x01); (temp >> 15) & 0x01);
...@@ -455,7 +432,7 @@ static int bt819_command(struct i2c_device *device, unsigned int cmd, void *arg) ...@@ -455,7 +432,7 @@ static int bt819_command(struct i2c_device *device, unsigned int cmd, void *arg)
if (decoder->hue != pic->hue) { if (decoder->hue != pic->hue) {
/* We want -128 to 127 we get 0-65535 */ /* We want -128 to 127 we get 0-65535 */
decoder->hue = pic->hue; decoder->hue = pic->hue;
bt819_write(decoder, 0x0f, i2c_smbus_write_byte_data(client, 0x0f,
128 - (decoder->hue >> 8)); 128 - (decoder->hue >> 8));
} }
} }
...@@ -472,22 +449,30 @@ static int bt819_command(struct i2c_device *device, unsigned int cmd, void *arg) ...@@ -472,22 +449,30 @@ static int bt819_command(struct i2c_device *device, unsigned int cmd, void *arg)
static struct i2c_driver i2c_driver_bt819 = { static struct i2c_driver i2c_driver_bt819 = {
"bt819", /* name */ "bt819", /* name */
I2C_DRIVERID_VIDEODECODER, /* ID */ I2C_DRIVERID_BT819, /* ID */
I2C_BT819, I2C_BT819 + 1, I2C_DF_NOTIFY,
bt819_probe,
bt819_attach,
bt819_detach, bt819_detach,
bt819_command bt819_command
}; };
static struct i2c_client client_template = {
"bt819_client",
-1,
0,
0,
NULL,
&i2c_driver_bt819
};
static int bt819_setup(void) static int bt819_setup(void)
{ {
return i2c_register_driver(&i2c_driver_bt819); return i2c_add_driver(&i2c_driver_bt819);
} }
static void bt819_exit(void) static void bt819_exit(void)
{ {
i2c_unregister_driver(&i2c_driver_bt819); i2c_del_driver(&i2c_driver_bt819);
} }
module_init(bt819_setup); module_init(bt819_setup);
......
...@@ -47,15 +47,32 @@ ...@@ -47,15 +47,32 @@
#include <linux/version.h> #include <linux/version.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <linux/i2c-old.h> #include <linux/i2c.h>
#include <linux/video_encoder.h> #include <linux/video_encoder.h>
#define DEBUG(x) x /* Debug driver */ #define DEBUG(x) x /* Debug driver */
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
static unsigned short normal_i2c[] = {34>>1, I2C_CLIENT_END };
static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
static unsigned short probe_range[2] = { I2C_CLIENT_END , I2C_CLIENT_END };
static unsigned short ignore[2] = { I2C_CLIENT_END , I2C_CLIENT_END };
static unsigned short ignore_range[2] = { I2C_CLIENT_END , I2C_CLIENT_END };
static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END };
static struct i2c_client_address_data addr_data = {
normal_i2c , normal_i2c_range,
probe , probe_range,
ignore , ignore_range,
force
};
static struct i2c_client client_template;
struct bt856 { struct bt856 {
struct i2c_bus *bus; struct i2c_client *client;
int addr; int addr;
unsigned char reg[128]; unsigned char reg[128];
...@@ -73,40 +90,35 @@ struct bt856 { ...@@ -73,40 +90,35 @@ struct bt856 {
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
static int bt856_write(struct bt856 *dev, unsigned char subaddr, static int bt856_probe(struct i2c_adapter *adap)
unsigned char data)
{ {
int ack; return i2c_probe(adap, &addr_data , bt856_attach);
LOCK_I2C_BUS(dev->bus);
i2c_start(dev->bus);
i2c_sendbyte(dev->bus, dev->addr, I2C_DELAY);
i2c_sendbyte(dev->bus, subaddr, I2C_DELAY);
ack = i2c_sendbyte(dev->bus, data, I2C_DELAY);
dev->reg[subaddr] = data;
i2c_stop(dev->bus);
UNLOCK_I2C_BUS(dev->bus);
return ack;
} }
static int bt856_setbit(struct bt856 *dev, int subaddr, int bit, int data) static int bt856_setbit(struct bt856 *dev, int subaddr, int bit, int data)
{ {
return bt856_write(dev, subaddr,(dev->reg[subaddr] & ~(1 << bit)) | (data ? (1 << bit) : 0)); return i2c_smbus_write_byte_data(dev->client, subaddr,(dev->reg[subaddr] & ~(1 << bit)) | (data ? (1 << bit) : 0));
} }
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
static int bt856_attach(struct i2c_device *device) static int bt856_attach(struct i2c_adapter *adap, int addr , unsigned long flags, int kind)
{ {
struct bt856 *encoder; struct bt856 *encoder;
struct i2c_client *client;
client = kmalloc(sizeof(*client), GFP_KERNEL);
if(client == NULL)
return -ENOMEM;
client_template.adapter = adap;
client_template.addr = addr;
memcpy(client, &client_template, sizeof(*client));
/* This chip is not on the buz card but at the same address saa7185 */ /* This chip is not on the buz card but at the same address saa7185 */
//if (memcmp(device->bus->name, "buz", 3) == 0 || memcmp(device->bus->name, "zr36057", 6) == 0) //if (memcmp(device->bus->name, "buz", 3) == 0 || memcmp(device->bus->name, "zr36057", 6) == 0)
// return 1; // return 1;
MOD_INC_USE_COUNT; encoder = kmalloc(sizeof(struct bt856), GFP_KERNEL);
device->data = encoder = kmalloc(sizeof(struct bt856), GFP_KERNEL);
if (encoder == NULL) { if (encoder == NULL) {
MOD_DEC_USE_COUNT; MOD_DEC_USE_COUNT;
...@@ -115,17 +127,21 @@ static int bt856_attach(struct i2c_device *device) ...@@ -115,17 +127,21 @@ static int bt856_attach(struct i2c_device *device)
memset(encoder, 0, sizeof(struct bt856)); memset(encoder, 0, sizeof(struct bt856));
strcpy(device->name, "bt856"); strcpy(client->name, "bt856");
encoder->bus = device->bus; encoder->client = client;
encoder->addr = device->addr; client->data = encoder;
encoder->addr = client->addr;
encoder->norm = VIDEO_MODE_NTSC; encoder->norm = VIDEO_MODE_NTSC;
encoder->enable = 1; encoder->enable = 1;
DEBUG(printk(KERN_INFO "%s-bt856: attach\n", encoder->bus->name)); DEBUG(printk(KERN_INFO "%s-bt856: attach\n", encoder->bus->name));
bt856_write(encoder, 0xdc, 0x18); i2c_smbus_write_byte_data(client, 0xdc, 0x18);
bt856_write(encoder, 0xda, 0); encoder->reg[0xdc] = 0x18;
bt856_write(encoder, 0xde, 0); i2c_smbus_write_byte_data(client, 0xda, 0);
encoder->reg[0xda] = 0;
i2c_smbus_write_byte_data(client, 0xde, 0);
encoder->reg[0xde] = 0;
bt856_setbit(encoder, 0xdc, 3, 1); bt856_setbit(encoder, 0xdc, 3, 1);
//bt856_setbit(encoder, 0xdc, 6, 0); //bt856_setbit(encoder, 0xdc, 6, 0);
...@@ -145,21 +161,26 @@ static int bt856_attach(struct i2c_device *device) ...@@ -145,21 +161,26 @@ static int bt856_attach(struct i2c_device *device)
bt856_setbit(encoder, 0xdc, 1, 1); bt856_setbit(encoder, 0xdc, 1, 1);
bt856_setbit(encoder, 0xde, 4, 0); bt856_setbit(encoder, 0xde, 4, 0);
bt856_setbit(encoder, 0xde, 3, 1); bt856_setbit(encoder, 0xde, 3, 1);
init_MUTEX(&encoder->lock);
i2c_attach_client(client);
MOD_INC_USE_COUNT;
return 0; return 0;
} }
static int bt856_detach(struct i2c_device *device) static int bt856_detach(struct i2c_client *client)
{ {
kfree(device->data); i2c_detach_client(client);
kfree(client->data);
kfree(client);
MOD_DEC_USE_COUNT; MOD_DEC_USE_COUNT;
return 0; return 0;
} }
static int bt856_command(struct i2c_device *device, unsigned int cmd, static int bt856_command(struct i2c_client *client, unsigned int cmd,
void *arg) void *arg)
{ {
struct bt856 *encoder = device->data; struct bt856 *encoder = client->data;
switch (cmd) { switch (cmd) {
...@@ -169,7 +190,7 @@ static int bt856_command(struct i2c_device *device, unsigned int cmd, ...@@ -169,7 +190,7 @@ static int bt856_command(struct i2c_device *device, unsigned int cmd,
DEBUG(printk DEBUG(printk
(KERN_INFO "%s-bt856: get capabilities\n", (KERN_INFO "%s-bt856: get capabilities\n",
encoder->bus->name)); encoder->client->name));
cap->flags cap->flags
= VIDEO_ENCODER_PAL = VIDEO_ENCODER_PAL
...@@ -184,7 +205,7 @@ static int bt856_command(struct i2c_device *device, unsigned int cmd, ...@@ -184,7 +205,7 @@ static int bt856_command(struct i2c_device *device, unsigned int cmd,
int *iarg = arg; int *iarg = arg;
DEBUG(printk(KERN_INFO "%s-bt856: set norm %d\n", DEBUG(printk(KERN_INFO "%s-bt856: set norm %d\n",
encoder->bus->name, *iarg)); encoder->client->name, *iarg));
switch (*iarg) { switch (*iarg) {
...@@ -211,7 +232,7 @@ static int bt856_command(struct i2c_device *device, unsigned int cmd, ...@@ -211,7 +232,7 @@ static int bt856_command(struct i2c_device *device, unsigned int cmd,
int *iarg = arg; int *iarg = arg;
DEBUG(printk(KERN_INFO "%s-bt856: set input %d\n", DEBUG(printk(KERN_INFO "%s-bt856: set input %d\n",
encoder->bus->name, *iarg)); encoder->client->name, *iarg));
/* We only have video bus. /* We only have video bus.
*iarg = 0: input is from bt819 *iarg = 0: input is from bt819
...@@ -247,7 +268,7 @@ static int bt856_command(struct i2c_device *device, unsigned int cmd, ...@@ -247,7 +268,7 @@ static int bt856_command(struct i2c_device *device, unsigned int cmd,
int *iarg = arg; int *iarg = arg;
DEBUG(printk(KERN_INFO "%s-bt856: set output %d\n", DEBUG(printk(KERN_INFO "%s-bt856: set output %d\n",
encoder->bus->name, *iarg)); encoder->client->name, *iarg));
/* not much choice of outputs */ /* not much choice of outputs */
if (*iarg != 0) { if (*iarg != 0) {
...@@ -264,7 +285,7 @@ static int bt856_command(struct i2c_device *device, unsigned int cmd, ...@@ -264,7 +285,7 @@ static int bt856_command(struct i2c_device *device, unsigned int cmd,
DEBUG(printk DEBUG(printk
(KERN_INFO "%s-bt856: enable output %d\n", (KERN_INFO "%s-bt856: enable output %d\n",
encoder->bus->name, encoder->enable)); encoder->client->name, encoder->enable));
} }
break; break;
...@@ -279,21 +300,30 @@ static int bt856_command(struct i2c_device *device, unsigned int cmd, ...@@ -279,21 +300,30 @@ static int bt856_command(struct i2c_device *device, unsigned int cmd,
static struct i2c_driver i2c_driver_bt856 = { static struct i2c_driver i2c_driver_bt856 = {
"bt856", /* name */ "bt856", /* name */
I2C_DRIVERID_VIDEOENCODER, /* ID */ I2C_DRIVERID_BT856, /* ID */
I2C_BT856, I2C_BT856 + 1, I2C_DF_NOTIFY,
bt856_attach, bt856_probe,
bt856_detach, bt856_detach,
bt856_command bt856_command
}; };
static struct i2c_client client_template = {
"bt856_client",
-1,
0,
0,
NULL,
&i2c_driver_bt856
};
static int bt856_init(void) static int bt856_init(void)
{ {
return i2c_register_driver(&i2c_driver_bt856); return i2c_add_driver(&i2c_driver_bt856);
} }
static void bt856_exit(void) static void bt856_exit(void)
{ {
i2c_unregister_driver(&i2c_driver_bt856); i2c_del_driver(&i2c_driver_bt856);
} }
module_init(bt856_init); module_init(bt856_init);
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include <asm/io.h> #include <asm/io.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <linux/i2c-old.h> #include <linux/i2c.h>
#include <linux/videodev.h> #include <linux/videodev.h>
#include "linux/video_decoder.h" #include "linux/video_decoder.h"
...@@ -37,13 +37,31 @@ ...@@ -37,13 +37,31 @@
#define I2C_SAA7110 0x9C /* or 0x9E */ #define I2C_SAA7110 0x9C /* or 0x9E */
#define IF_NAME "saa7110"
#define I2C_DELAY 10 /* 10 us or 100khz */ #define I2C_DELAY 10 /* 10 us or 100khz */
static unsigned short normal_i2c[] = {34>>1, I2C_CLIENT_END };
static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
static unsigned short force[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
static struct i2c_client_address_data addr_data = {
normal_i2c, normal_i2c_range,
probe, probe_range,
ignore, ignore_range,
force
};
static struct i2c_client client_template;
struct saa7110 { struct saa7110 {
struct i2c_bus *bus; struct i2c_client *client;
int addr; int addr;
unsigned char reg[36]; unsigned char reg[36];
struct semaphore lock;
int norm; int norm;
int input; int input;
int enable; int enable;
...@@ -53,68 +71,11 @@ struct saa7110 { ...@@ -53,68 +71,11 @@ struct saa7110 {
int sat; int sat;
}; };
/* ----------------------------------------------------------------------- */
/* I2C support functions */
/* ----------------------------------------------------------------------- */
static
int saa7110_write(struct saa7110 *decoder, unsigned char subaddr, unsigned char data)
{
int ack;
LOCK_I2C_BUS(decoder->bus);
i2c_start(decoder->bus);
i2c_sendbyte(decoder->bus, decoder->addr, I2C_DELAY);
i2c_sendbyte(decoder->bus, subaddr, I2C_DELAY);
ack = i2c_sendbyte(decoder->bus, data, I2C_DELAY);
i2c_stop(decoder->bus);
decoder->reg[subaddr] = data;
UNLOCK_I2C_BUS(decoder->bus);
return ack;
}
static
int saa7110_write_block(struct saa7110* decoder, unsigned const char *data, unsigned int len)
{
unsigned subaddr = *data;
LOCK_I2C_BUS(decoder->bus);
i2c_start(decoder->bus);
i2c_sendbyte(decoder->bus,decoder->addr,I2C_DELAY);
while (len-- > 0) {
if (i2c_sendbyte(decoder->bus,*data,0)) {
i2c_stop(decoder->bus);
UNLOCK_I2C_BUS(decoder->bus);
return -EAGAIN;
}
decoder->reg[subaddr++] = *data++;
}
i2c_stop(decoder->bus);
UNLOCK_I2C_BUS(decoder->bus);
return 0;
}
static
int saa7110_read(struct saa7110* decoder)
{
int data;
LOCK_I2C_BUS(decoder->bus);
i2c_start(decoder->bus);
i2c_sendbyte(decoder->bus, decoder->addr, I2C_DELAY);
i2c_start(decoder->bus);
i2c_sendbyte(decoder->bus, decoder->addr | 1, I2C_DELAY);
data = i2c_readbyte(decoder->bus, 1);
i2c_stop(decoder->bus);
UNLOCK_I2C_BUS(decoder->bus);
return data;
}
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
/* SAA7110 functions */ /* SAA7110 functions */
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
static static
int saa7110_selmux(struct i2c_device *device, int chan) int saa7110_selmux(struct i2c_client *client, int chan)
{ {
static const unsigned char modes[9][8] = { static const unsigned char modes[9][8] = {
/* mode 0 */ { 0x00, 0xD9, 0x17, 0x40, 0x03, 0x44, 0x75, 0x16 }, /* mode 0 */ { 0x00, 0xD9, 0x17, 0x40, 0x03, 0x44, 0x75, 0x16 },
...@@ -126,61 +87,59 @@ static const unsigned char modes[9][8] = { ...@@ -126,61 +87,59 @@ static const unsigned char modes[9][8] = {
/* mode 6 */ { 0x80, 0x59, 0x17, 0x42, 0xA3, 0x44, 0x75, 0x12 }, /* mode 6 */ { 0x80, 0x59, 0x17, 0x42, 0xA3, 0x44, 0x75, 0x12 },
/* mode 7 */ { 0x80, 0x9A, 0x17, 0xB1, 0x13, 0x60, 0xB5, 0x14 }, /* mode 7 */ { 0x80, 0x9A, 0x17, 0xB1, 0x13, 0x60, 0xB5, 0x14 },
/* mode 8 */ { 0x80, 0x3C, 0x27, 0xC1, 0x23, 0x44, 0x75, 0x21 } }; /* mode 8 */ { 0x80, 0x3C, 0x27, 0xC1, 0x23, 0x44, 0x75, 0x21 } };
struct saa7110* decoder = device->data;
const unsigned char* ptr = modes[chan]; const unsigned char* ptr = modes[chan];
saa7110_write(decoder,0x06,ptr[0]); /* Luminance control */ i2c_smbus_write_byte_data(client,0x06,ptr[0]); /* Luminance control */
saa7110_write(decoder,0x20,ptr[1]); /* Analog Control #1 */ i2c_smbus_write_byte_data(client,0x20,ptr[1]); /* Analog Control #1 */
saa7110_write(decoder,0x21,ptr[2]); /* Analog Control #2 */ i2c_smbus_write_byte_data(client,0x21,ptr[2]); /* Analog Control #2 */
saa7110_write(decoder,0x22,ptr[3]); /* Mixer Control #1 */ i2c_smbus_write_byte_data(client,0x22,ptr[3]); /* Mixer Control #1 */
saa7110_write(decoder,0x2C,ptr[4]); /* Mixer Control #2 */ i2c_smbus_write_byte_data(client,0x2C,ptr[4]); /* Mixer Control #2 */
saa7110_write(decoder,0x30,ptr[5]); /* ADCs gain control */ i2c_smbus_write_byte_data(client,0x30,ptr[5]); /* ADCs gain control */
saa7110_write(decoder,0x31,ptr[6]); /* Mixer Control #3 */ i2c_smbus_write_byte_data(client,0x31,ptr[6]); /* Mixer Control #3 */
saa7110_write(decoder,0x21,ptr[7]); /* Analog Control #2 */ i2c_smbus_write_byte_data(client,0x21,ptr[7]); /* Analog Control #2 */
return 0; return 0;
} }
static static
int determine_norm(struct i2c_device* dev) int determine_norm(struct i2c_client* client)
{ {
struct saa7110* decoder = dev->data;
int status; int status;
/* mode changed, start automatic detection */ /* mode changed, start automatic detection */
status = saa7110_read(decoder); status = i2c_smbus_read_byte(client);
if ((status & 3) == 0) { if ((status & 3) == 0) {
saa7110_write(decoder,0x06,0x80); i2c_smbus_write_byte_data(client,0x06,0x80);
if (status & 0x20) { if (status & 0x20) {
DEBUG(printk(KERN_INFO "%s: norm=bw60\n",dev->name)); DEBUG(printk(KERN_INFO "%s: norm=bw60\n",adp->name));
saa7110_write(decoder,0x2E,0x81); i2c_smbus_write_byte_data(client,0x2E,0x81);
return VIDEO_MODE_NTSC; return VIDEO_MODE_NTSC;
} }
DEBUG(printk(KERN_INFO "%s: norm=bw50\n",dev->name)); DEBUG(printk(KERN_INFO "%s: norm=bw50\n",adp->name));
saa7110_write(decoder,0x2E,0x9A); i2c_smbus_write_byte_data(client,0x2E,0x9A);
return VIDEO_MODE_PAL; return VIDEO_MODE_PAL;
} }
saa7110_write(decoder,0x06,0x00); i2c_smbus_write_byte_data(client,0x06,0x00);
if (status & 0x20) { /* 60Hz */ if (status & 0x20) { /* 60Hz */
DEBUG(printk(KERN_INFO "%s: norm=ntsc\n",dev->name)); DEBUG(printk(KERN_INFO "%s: norm=ntsc\n",adp->name));
saa7110_write(decoder,0x0D,0x06); i2c_smbus_write_byte_data(client,0x0D,0x06);
saa7110_write(decoder,0x11,0x2C); i2c_smbus_write_byte_data(client,0x11,0x2C);
saa7110_write(decoder,0x2E,0x81); i2c_smbus_write_byte_data(client,0x2E,0x81);
return VIDEO_MODE_NTSC; return VIDEO_MODE_NTSC;
} }
/* 50Hz -> PAL/SECAM */ /* 50Hz -> PAL/SECAM */
saa7110_write(decoder,0x0D,0x06); i2c_smbus_write_byte_data(client,0x0D,0x06);
saa7110_write(decoder,0x11,0x59); i2c_smbus_write_byte_data(client,0x11,0x59);
saa7110_write(decoder,0x2E,0x9A); i2c_smbus_write_byte_data(client,0x2E,0x9A);
mdelay(150); /* pause 150 ms */ mdelay(150); /* pause 150 ms */
status = saa7110_read(decoder); status = i2c_smbus_read_byte(client);
if ((status & 0x03) == 0x01) { if ((status & 0x03) == 0x01) {
DEBUG(printk(KERN_INFO "%s: norm=secam\n",dev->name)); DEBUG(printk(KERN_INFO "%s: norm=secam\n",dev->name));
saa7110_write(decoder,0x0D,0x07); i2c_smbus_write_byte_data(client,0x0D,0x07);
return VIDEO_MODE_SECAM; return VIDEO_MODE_SECAM;
} }
DEBUG(printk(KERN_INFO "%s: norm=pal\n",dev->name)); DEBUG(printk(KERN_INFO "%s: norm=pal\n",dev->name));
...@@ -188,7 +147,7 @@ int determine_norm(struct i2c_device* dev) ...@@ -188,7 +147,7 @@ int determine_norm(struct i2c_device* dev)
} }
static static
int saa7110_attach(struct i2c_device *device) int saa7110_attach(struct i2c_adapter *adap, int addr, unsigned short flags, int kind)
{ {
static const unsigned char initseq[] = { static const unsigned char initseq[] = {
0, 0x4C, 0x3C, 0x0D, 0xEF, 0xBD, 0xF0, 0x00, 0x00, 0, 0x4C, 0x3C, 0x0D, 0xEF, 0xBD, 0xF0, 0x00, 0x00,
...@@ -198,20 +157,28 @@ static const unsigned char initseq[] = { ...@@ -198,20 +157,28 @@ static const unsigned char initseq[] = {
0xD9, 0x17, 0x40, 0x41, 0x80, 0x41, 0x80, 0x4F, 0xD9, 0x17, 0x40, 0x41, 0x80, 0x41, 0x80, 0x4F,
0xFE, 0x01, 0xCF, 0x0F, 0x03, 0x01, 0x81, 0x03, 0xFE, 0x01, 0xCF, 0x0F, 0x03, 0x01, 0x81, 0x03,
0x40, 0x75, 0x01, 0x8C, 0x03}; 0x40, 0x75, 0x01, 0x8C, 0x03};
struct saa7110* decoder; struct saa7110 *decoder;
struct i2c_client *client;
int rv; int rv;
client=kmalloc(sizeof(*client), GFP_KERNEL);
device->data = decoder = kmalloc(sizeof(struct saa7110), GFP_KERNEL); if(client == NULL)
if (device->data == 0)
return -ENOMEM; return -ENOMEM;
client_template.adapter = adap;
client_template.addr = addr;
memcpy(client, &client_template, sizeof(*client));
MOD_INC_USE_COUNT; decoder = kmalloc(sizeof(*decoder), GFP_KERNEL);
if (decoder == NULL) {
kfree(client);
return -ENOMEM;
}
/* clear our private data */ /* clear our private data */
memset(decoder, 0, sizeof(struct saa7110)); memset(decoder, 0, sizeof(*decoder));
strcpy(device->name, "saa7110"); strcpy(client->name, IF_NAME);
decoder->bus = device->bus; decoder->client = client;
decoder->addr = device->addr; client->data = decoder;
decoder->addr = addr;
decoder->norm = VIDEO_MODE_PAL; decoder->norm = VIDEO_MODE_PAL;
decoder->input = 0; decoder->input = 0;
decoder->enable = 1; decoder->enable = 1;
...@@ -220,40 +187,52 @@ static const unsigned char initseq[] = { ...@@ -220,40 +187,52 @@ static const unsigned char initseq[] = {
decoder->hue = 32768; decoder->hue = 32768;
decoder->sat = 32768; decoder->sat = 32768;
rv = saa7110_write_block(decoder, initseq, sizeof(initseq)); rv = i2c_master_send(client, initseq, sizeof(initseq));
if (rv < 0) if (rv < 0)
printk(KERN_ERR "%s_attach: init status %d\n", device->name, rv); printk(KERN_ERR "%s_attach: init status %d\n", client->name, rv);
else { else {
saa7110_write(decoder,0x21,0x16); i2c_smbus_write_byte_data(client,0x21,0x16);
saa7110_write(decoder,0x0D,0x04); i2c_smbus_write_byte_data(client,0x0D,0x04);
DEBUG(printk(KERN_INFO "%s_attach: chip version %x\n", device->name, saa7110_read(decoder))); DEBUG(printk(KERN_INFO "%s_attach: chip version %x\n", client->name, i2c_smbus_read_byte(client)));
saa7110_write(decoder,0x0D,0x06); i2c_smbus_write_byte_data(client,0x0D,0x06);
} }
init_MUTEX(&decoder->lock);
i2c_attach_client(client);
MOD_INC_USE_COUNT;
/* setup and implicit mode 0 select has been performed */ /* setup and implicit mode 0 select has been performed */
return 0; return 0;
} }
static static
int saa7110_detach(struct i2c_device *device) int saa7110_probe(struct i2c_adapter *adap)
{ {
struct saa7110* decoder = device->data; return i2c_probe(adap, &addr_data, saa7110_attach);
}
static
int saa7110_detach(struct i2c_client *client)
{
struct saa7110* decoder = client->data;
DEBUG(printk(KERN_INFO "%s_detach\n",device->name)); i2c_detach_client(client);
DEBUG(printk(KERN_INFO "%s_detach\n",client->name));
/* stop further output */ /* stop further output */
saa7110_write(decoder,0x0E,0x00); i2c_smbus_write_byte_data(client,0x0E,0x00);
kfree(device->data); kfree(decoder);
kfree(client);
MOD_DEC_USE_COUNT; MOD_DEC_USE_COUNT;
return 0; return 0;
} }
static static
int saa7110_command(struct i2c_device *device, unsigned int cmd, void *arg) int saa7110_command(struct i2c_client *client, unsigned int cmd, void *arg)
{ {
struct saa7110* decoder = device->data; struct saa7110* decoder = client->data;
int v; int v;
switch (cmd) { switch (cmd) {
...@@ -272,11 +251,11 @@ int saa7110_command(struct i2c_device *device, unsigned int cmd, void *arg) ...@@ -272,11 +251,11 @@ int saa7110_command(struct i2c_device *device, unsigned int cmd, void *arg)
case DECODER_GET_STATUS: case DECODER_GET_STATUS:
{ {
struct saa7110* decoder = device->data; struct saa7110* decoder = client->data;
int status; int status;
int res = 0; int res = 0;
status = i2c_read(device->bus,device->addr|1); status = i2c_smbus_read_byte(client);
if (status & 0x40) if (status & 0x40)
res |= DECODER_STATUS_GOOD; res |= DECODER_STATUS_GOOD;
if (status & 0x03) if (status & 0x03)
...@@ -301,26 +280,26 @@ int saa7110_command(struct i2c_device *device, unsigned int cmd, void *arg) ...@@ -301,26 +280,26 @@ int saa7110_command(struct i2c_device *device, unsigned int cmd, void *arg)
v = *(int*)arg; v = *(int*)arg;
if (decoder->norm != v) { if (decoder->norm != v) {
decoder->norm = v; decoder->norm = v;
saa7110_write(decoder, 0x06, 0x00); i2c_smbus_write_byte_data(client, 0x06, 0x00);
switch (v) { switch (v) {
case VIDEO_MODE_NTSC: case VIDEO_MODE_NTSC:
saa7110_write(decoder, 0x0D, 0x06); i2c_smbus_write_byte_data(client, 0x0D, 0x06);
saa7110_write(decoder, 0x11, 0x2C); i2c_smbus_write_byte_data(client, 0x11, 0x2C);
saa7110_write(decoder, 0x30, 0x81); i2c_smbus_write_byte_data(client, 0x30, 0x81);
saa7110_write(decoder, 0x2A, 0xDF); i2c_smbus_write_byte_data(client, 0x2A, 0xDF);
break; break;
case VIDEO_MODE_PAL: case VIDEO_MODE_PAL:
saa7110_write(decoder, 0x0D, 0x06); i2c_smbus_write_byte_data(client, 0x0D, 0x06);
saa7110_write(decoder, 0x11, 0x59); i2c_smbus_write_byte_data(client, 0x11, 0x59);
saa7110_write(decoder, 0x2E, 0x9A); i2c_smbus_write_byte_data(client, 0x2E, 0x9A);
break; break;
case VIDEO_MODE_SECAM: case VIDEO_MODE_SECAM:
saa7110_write(decoder, 0x0D, 0x07); i2c_smbus_write_byte_data(client, 0x0D, 0x07);
saa7110_write(decoder, 0x11, 0x59); i2c_smbus_write_byte_data(client, 0x11, 0x59);
saa7110_write(decoder, 0x2E, 0x9A); i2c_smbus_write_byte_data(client, 0x2E, 0x9A);
break; break;
case VIDEO_MODE_AUTO: case VIDEO_MODE_AUTO:
*(int*)arg = determine_norm(device); *(int*)arg = determine_norm(client);
break; break;
default: default:
return -EPERM; return -EPERM;
...@@ -334,7 +313,7 @@ int saa7110_command(struct i2c_device *device, unsigned int cmd, void *arg) ...@@ -334,7 +313,7 @@ int saa7110_command(struct i2c_device *device, unsigned int cmd, void *arg)
return -EINVAL; return -EINVAL;
if (decoder->input != v) { if (decoder->input != v) {
decoder->input = v; decoder->input = v;
saa7110_selmux(device, v); saa7110_selmux(client, v);
} }
break; break;
...@@ -349,7 +328,7 @@ int saa7110_command(struct i2c_device *device, unsigned int cmd, void *arg) ...@@ -349,7 +328,7 @@ int saa7110_command(struct i2c_device *device, unsigned int cmd, void *arg)
v = *(int*)arg; v = *(int*)arg;
if (decoder->enable != v) { if (decoder->enable != v) {
decoder->enable = v; decoder->enable = v;
saa7110_write(decoder,0x0E, v ? 0x18 : 0x00); i2c_smbus_write_byte_data(client,0x0E, v ? 0x18 : 0x00);
} }
break; break;
...@@ -360,22 +339,22 @@ int saa7110_command(struct i2c_device *device, unsigned int cmd, void *arg) ...@@ -360,22 +339,22 @@ int saa7110_command(struct i2c_device *device, unsigned int cmd, void *arg)
if (decoder->bright != pic->brightness) { if (decoder->bright != pic->brightness) {
/* We want 0 to 255 we get 0-65535 */ /* We want 0 to 255 we get 0-65535 */
decoder->bright = pic->brightness; decoder->bright = pic->brightness;
saa7110_write(decoder, 0x19, decoder->bright >> 8); i2c_smbus_write_byte_data(client, 0x19, decoder->bright >> 8);
} }
if (decoder->contrast != pic->contrast) { if (decoder->contrast != pic->contrast) {
/* We want 0 to 127 we get 0-65535 */ /* We want 0 to 127 we get 0-65535 */
decoder->contrast = pic->contrast; decoder->contrast = pic->contrast;
saa7110_write(decoder, 0x13, decoder->contrast >> 9); i2c_smbus_write_byte_data(client, 0x13, decoder->contrast >> 9);
} }
if (decoder->sat != pic->colour) { if (decoder->sat != pic->colour) {
/* We want 0 to 127 we get 0-65535 */ /* We want 0 to 127 we get 0-65535 */
decoder->sat = pic->colour; decoder->sat = pic->colour;
saa7110_write(decoder, 0x12, decoder->sat >> 9); i2c_smbus_write_byte_data(client, 0x12, decoder->sat >> 9);
} }
if (decoder->hue != pic->hue) { if (decoder->hue != pic->hue) {
/* We want -128 to 127 we get 0-65535 */ /* We want -128 to 127 we get 0-65535 */
decoder->hue = pic->hue; decoder->hue = pic->hue;
saa7110_write(decoder, 0x07, (decoder->hue>>8)-128); i2c_smbus_write_byte_data(client, 0x07, (decoder->hue>>8)-128);
} }
} }
break; break;
...@@ -383,7 +362,7 @@ int saa7110_command(struct i2c_device *device, unsigned int cmd, void *arg) ...@@ -383,7 +362,7 @@ int saa7110_command(struct i2c_device *device, unsigned int cmd, void *arg)
case DECODER_DUMP: case DECODER_DUMP:
for (v=0; v<34; v+=16) { for (v=0; v<34; v+=16) {
int j; int j;
DEBUG(printk(KERN_INFO "%s: %03x\n",device->name,v)); DEBUG(printk(KERN_INFO "%s: %03x\n",client->name,v));
for (j=0; j<16; j++) { for (j=0; j<16; j++) {
DEBUG(printk(KERN_INFO " %02x",decoder->reg[v+j])); DEBUG(printk(KERN_INFO " %02x",decoder->reg[v+j]));
} }
...@@ -402,24 +381,30 @@ int saa7110_command(struct i2c_device *device, unsigned int cmd, void *arg) ...@@ -402,24 +381,30 @@ int saa7110_command(struct i2c_device *device, unsigned int cmd, void *arg)
static struct i2c_driver i2c_driver_saa7110 = static struct i2c_driver i2c_driver_saa7110 =
{ {
"saa7110", /* name */ IF_NAME, /* name */
I2C_DRIVERID_SAA7110, /* in i2c.h */
I2C_DRIVERID_VIDEODECODER, /* in i2c.h */ I2C_DF_NOTIFY, /* Addr range */
I2C_SAA7110, I2C_SAA7110+1, /* Addr range */ saa7110_probe,
saa7110_attach,
saa7110_detach, saa7110_detach,
saa7110_command saa7110_command
}; };
static struct i2c_client client_template = {
"saa7110_client",
-1,
0,
0,
NULL,
&i2c_driver_saa7110
};
static int saa7110_init(void) static int saa7110_init(void)
{ {
return i2c_register_driver(&i2c_driver_saa7110); return i2c_add_driver(&i2c_driver_saa7110);
} }
static void saa7110_exit(void) static void saa7110_exit(void)
{ {
i2c_unregister_driver(&i2c_driver_saa7110); i2c_del_driver(&i2c_driver_saa7110);
} }
......
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