Commit a913beae authored by Alan Cox's avatar Alan Cox Committed by Linus Torvalds

[PATCH] update sa7111/7185 to new i2c

parent 72ad73df
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include <linux/videodev.h> #include <linux/videodev.h>
#include <linux/version.h> #include <linux/version.h>
#include <linux/i2c-old.h> #include <linux/i2c.h>
#include <linux/video_decoder.h> #include <linux/video_decoder.h>
...@@ -43,8 +43,9 @@ ...@@ -43,8 +43,9 @@
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
struct saa7111 { struct saa7111 {
struct i2c_bus *bus; struct i2c_client *client;
int addr; int addr;
struct semaphore lock;
unsigned char reg[32]; unsigned char reg[32];
int norm; int norm;
...@@ -60,74 +61,32 @@ struct saa7111 { ...@@ -60,74 +61,32 @@ struct saa7111 {
#define I2C_DELAY 10 #define I2C_DELAY 10
/* ----------------------------------------------------------------------- */ static unsigned short normal_i2c[] = { 34>>1, I2C_CLIENT_END };
static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
static int saa7111_write(struct saa7111 *dev, unsigned char subaddr, static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
unsigned char data) static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
{ static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
int ack; static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END };
LOCK_I2C_BUS(dev->bus);
i2c_start(dev->bus); static struct i2c_client_address_data addr_data = {
i2c_sendbyte(dev->bus, dev->addr, I2C_DELAY); .normal_i2c = normal_i2c,
i2c_sendbyte(dev->bus, subaddr, I2C_DELAY); .normal_i2c_range = normal_i2c_range,
ack = i2c_sendbyte(dev->bus, data, I2C_DELAY); .probe = probe,
dev->reg[subaddr] = data; .probe_range = probe_range,
i2c_stop(dev->bus); .ignore = ignore,
UNLOCK_I2C_BUS(dev->bus); .ignore_range = ignore_range,
return ack; .force = force
} };
static int saa7111_write_block(struct saa7111 *dev,
unsigned const char *data, unsigned int len)
{
int ack = -1;
unsigned subaddr;
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 saa7111_read(struct saa7111 *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 struct i2c_client client_template;
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
static int saa7111_attach(struct i2c_device *device) static int saa7111_attach(struct i2c_adapter *adap, int addr, unsigned short flags, int kind)
{ {
int i; int i;
struct saa7111 *decoder; struct saa7111 *decoder;
struct i2c_client *client;
static const unsigned char init[] = { static const unsigned char init[] = {
0x00, 0x00, /* 00 - ID byte */ 0x00, 0x00, /* 00 - ID byte */
0x01, 0x00, /* 01 - reserved */ 0x01, 0x00, /* 01 - reserved */
...@@ -158,20 +117,25 @@ static int saa7111_attach(struct i2c_device *device) ...@@ -158,20 +117,25 @@ static int saa7111_attach(struct i2c_device *device)
0x16, 0x00, /* 16 - VBI */ 0x16, 0x00, /* 16 - VBI */
0x17, 0x00, /* 17 - VBI */ 0x17, 0x00, /* 17 - VBI */
}; };
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));
MOD_INC_USE_COUNT; decoder = kmalloc(sizeof(*decoder), GFP_KERNEL);
device->data = decoder = kmalloc(sizeof(struct saa7111), GFP_KERNEL);
if (decoder == NULL) if (decoder == NULL)
{ {
MOD_DEC_USE_COUNT; kfree(client);
return -ENOMEM; return -ENOMEM;
} }
memset(decoder, 0, sizeof(struct saa7111)); memset(decoder, 0, sizeof(*decoder));
strcpy(device->name, "saa7111"); strcpy(client->name, "saa7111");
decoder->bus = device->bus; decoder->client = client;
decoder->addr = device->addr; client->data = decoder;
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;
...@@ -180,29 +144,38 @@ static int saa7111_attach(struct i2c_device *device) ...@@ -180,29 +144,38 @@ static int saa7111_attach(struct i2c_device *device)
decoder->hue = 32768; decoder->hue = 32768;
decoder->sat = 32768; decoder->sat = 32768;
i = saa7111_write_block(decoder, init, sizeof(init)); i = i2c_master_send(client, init, sizeof(init));
if (i < 0) { if (i < 0) {
printk(KERN_ERR "%s_attach: init status %d\n", printk(KERN_ERR "%s_attach: init status %d\n",
device->name, i); client->name, i);
} else { } else {
printk(KERN_INFO "%s_attach: chip version %x\n", printk(KERN_INFO "%s_attach: chip version %x\n",
device->name, saa7111_read(decoder, 0x00) >> 4); client->name, i2c_smbus_read_byte_data(client, 0x00) >> 4);
} }
init_MUTEX(&decoder->lock);
i2c_attach_client(client);
MOD_INC_USE_COUNT;
return 0; return 0;
} }
static int saa7111_probe(struct i2c_adapter *adap)
{
return i2c_probe(adap, &addr_data, saa7111_attach);
}
static int saa7111_detach(struct i2c_client *client)
static int saa7111_detach(struct i2c_device *device)
{ {
kfree(device->data); struct saa7111 *decoder = client->data;
i2c_detach_client(client);
kfree(decoder);
kfree(client);
MOD_DEC_USE_COUNT; MOD_DEC_USE_COUNT;
return 0; return 0;
} }
static int saa7111_command(struct i2c_device *device, unsigned int cmd, static int saa7111_command(struct i2c_client *client, unsigned int cmd,
void *arg) void *arg)
{ {
struct saa7111 *decoder = device->data; struct saa7111 *decoder = client->data;
switch (cmd) { switch (cmd) {
...@@ -214,11 +187,11 @@ static int saa7111_command(struct i2c_device *device, unsigned int cmd, ...@@ -214,11 +187,11 @@ static int saa7111_command(struct i2c_device *device, unsigned int cmd,
for (i = 0; i < 32; i += 16) { for (i = 0; i < 32; i += 16) {
int j; int j;
printk("KERN_DEBUG %s: %03x", device->name, printk("KERN_DEBUG %s: %03x", client->name,
i); i);
for (j = 0; j < 16; ++j) { for (j = 0; j < 16; ++j) {
printk(" %02x", printk(" %02x",
saa7111_read(decoder, i2c_smbus_read_byte_data(client,
i + j)); i + j));
} }
printk("\n"); printk("\n");
...@@ -246,7 +219,7 @@ static int saa7111_command(struct i2c_device *device, unsigned int cmd, ...@@ -246,7 +219,7 @@ static int saa7111_command(struct i2c_device *device, unsigned int cmd,
int status; int status;
int res; int res;
status = saa7111_read(decoder, 0x1f); status = i2c_smbus_read_byte_data(client, 0x1f);
res = 0; res = 0;
if ((status & (1 << 6)) == 0) { if ((status & (1 << 6)) == 0) {
res |= DECODER_STATUS_GOOD; res |= DECODER_STATUS_GOOD;
...@@ -281,19 +254,19 @@ static int saa7111_command(struct i2c_device *device, unsigned int cmd, ...@@ -281,19 +254,19 @@ static int saa7111_command(struct i2c_device *device, unsigned int cmd,
switch (*iarg) { switch (*iarg) {
case VIDEO_MODE_NTSC: case VIDEO_MODE_NTSC:
saa7111_write(decoder, 0x08, i2c_smbus_write_byte_data(client, 0x08,
(decoder-> (decoder->
reg[0x08] & 0x3f) | 0x40); reg[0x08] & 0x3f) | 0x40);
break; break;
case VIDEO_MODE_PAL: case VIDEO_MODE_PAL:
saa7111_write(decoder, 0x08, i2c_smbus_write_byte_data(client, 0x08,
(decoder-> (decoder->
reg[0x08] & 0x3f) | 0x00); reg[0x08] & 0x3f) | 0x00);
break; break;
case VIDEO_MODE_AUTO: case VIDEO_MODE_AUTO:
saa7111_write(decoder, 0x08, i2c_smbus_write_byte_data(client, 0x08,
(decoder-> (decoder->
reg[0x08] & 0x3f) | 0x80); reg[0x08] & 0x3f) | 0x80);
break; break;
...@@ -317,12 +290,12 @@ static int saa7111_command(struct i2c_device *device, unsigned int cmd, ...@@ -317,12 +290,12 @@ static int saa7111_command(struct i2c_device *device, unsigned int cmd,
if (decoder->input != *iarg) { if (decoder->input != *iarg) {
decoder->input = *iarg; decoder->input = *iarg;
/* select mode */ /* select mode */
saa7111_write(decoder, 0x02, i2c_smbus_write_byte_data(client, 0x02,
(decoder-> (decoder->
reg[0x02] & 0xf8) | reg[0x02] & 0xf8) |
decoder->input); decoder->input);
/* bypass chrominance trap for modes 4..7 */ /* bypass chrominance trap for modes 4..7 */
saa7111_write(decoder, 0x09, i2c_smbus_write_byte_data(client, 0x09,
(decoder-> (decoder->
reg[0x09] & 0x7f) | reg[0x09] & 0x7f) |
((decoder->input > ((decoder->input >
...@@ -357,26 +330,26 @@ static int saa7111_command(struct i2c_device *device, unsigned int cmd, ...@@ -357,26 +330,26 @@ static int saa7111_command(struct i2c_device *device, unsigned int cmd,
// If output should be enabled, we have to reverse the above. // If output should be enabled, we have to reverse the above.
if (decoder->enable) { if (decoder->enable) {
saa7111_write(decoder, 0x02, i2c_smbus_write_byte_data(client, 0x02,
(decoder-> (decoder->
reg[0x02] & 0xf8) | reg[0x02] & 0xf8) |
decoder->input); decoder->input);
saa7111_write(decoder, 0x08, i2c_smbus_write_byte_data(client, 0x08,
(decoder-> (decoder->
reg[0x08] & 0xfb)); reg[0x08] & 0xfb));
saa7111_write(decoder, 0x11, i2c_smbus_write_byte_data(client, 0x11,
(decoder-> (decoder->
reg[0x11] & 0xf3) | reg[0x11] & 0xf3) |
0x0c); 0x0c);
} else { } else {
saa7111_write(decoder, 0x02, i2c_smbus_write_byte_data(client, 0x02,
(decoder-> (decoder->
reg[0x02] & 0xf8)); reg[0x02] & 0xf8));
saa7111_write(decoder, 0x08, i2c_smbus_write_byte_data(client, 0x08,
(decoder-> (decoder->
reg[0x08] & 0xfb) | reg[0x08] & 0xfb) |
0x04); 0x04);
saa7111_write(decoder, 0x11, i2c_smbus_write_byte_data(client, 0x11,
(decoder-> (decoder->
reg[0x11] & 0xf3)); reg[0x11] & 0xf3));
} }
...@@ -391,25 +364,25 @@ static int saa7111_command(struct i2c_device *device, unsigned int cmd, ...@@ -391,25 +364,25 @@ static int saa7111_command(struct i2c_device *device, unsigned int cmd,
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;
saa7111_write(decoder, 0x0a, i2c_smbus_write_byte_data(client, 0x0a,
decoder->bright >> 8); 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;
saa7111_write(decoder, 0x0b, i2c_smbus_write_byte_data(client, 0x0b,
decoder->contrast >> 9); 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;
saa7111_write(decoder, 0x0c, i2c_smbus_write_byte_data(client, 0x0c,
decoder->sat >> 9); 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;
saa7111_write(decoder, 0x0d, i2c_smbus_write_byte_data(client, 0x0d,
(decoder->hue - 32768) >> 8); (decoder->hue - 32768) >> 8);
} }
} }
...@@ -425,23 +398,28 @@ static int saa7111_command(struct i2c_device *device, unsigned int cmd, ...@@ -425,23 +398,28 @@ static int saa7111_command(struct i2c_device *device, unsigned int cmd,
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
static struct i2c_driver i2c_driver_saa7111 = { static struct i2c_driver i2c_driver_saa7111 = {
"saa7111", /* name */ .name = "saa7111", /* name */
I2C_DRIVERID_VIDEODECODER, /* ID */ .id = I2C_DRIVERID_SAA7111A, /* ID */
I2C_SAA7111, I2C_SAA7111 + 1, .flags = I2C_DF_NOTIFY,
.attach_adapter = saa7111_probe,
.detach_client = saa7111_detach,
.command = saa7111_command
};
saa7111_attach, static struct i2c_client client_template = {
saa7111_detach, .name = "saa7111_client",
saa7111_command .id = -1,
.driver = &i2c_driver_saa7111
}; };
static int saa7111_init(void) static int saa7111_init(void)
{ {
return i2c_register_driver(&i2c_driver_saa7111); return i2c_add_driver(&i2c_driver_saa7111);
} }
static void saa7111_exit(void) static void saa7111_exit(void)
{ {
i2c_unregister_driver(&i2c_driver_saa7111); i2c_del_driver(&i2c_driver_saa7111);
} }
module_init(saa7111_init); module_init(saa7111_init);
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
#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>
...@@ -52,9 +52,10 @@ ...@@ -52,9 +52,10 @@
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
struct saa7185 { struct saa7185 {
struct i2c_bus *bus; struct i2c_client *client;
int addr; int addr;
unsigned char reg[128]; unsigned char reg[128];
struct semaphore lock;
int norm; int norm;
int enable; int enable;
...@@ -69,66 +70,25 @@ struct saa7185 { ...@@ -69,66 +70,25 @@ struct saa7185 {
#define I2C_DELAY 10 #define I2C_DELAY 10
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
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,
.normal_i2c_range = normal_i2c_range,
.probe = probe,
.probe_range = probe_range,
.ignore = ignore,
.ignore_range = ignore_range,
.force = force
};
static int saa7185_read(struct saa7185 *dev) static struct i2c_client client_template;
{
int ack;
LOCK_I2C_BUS(dev->bus);
i2c_start(dev->bus);
i2c_sendbyte(dev->bus, dev->addr | 1, I2C_DELAY);
ack = i2c_readbyte(dev->bus, 1);
i2c_stop(dev->bus);
UNLOCK_I2C_BUS(dev->bus);
return ack;
}
static int saa7185_write(struct saa7185 *dev, unsigned char subaddr,
unsigned char data)
{
int ack;
DEBUG(printk
(KERN_DEBUG "SAA7185: %02x set to %02x\n", subaddr, 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);
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 saa7185_write_block(struct saa7185 *dev,
unsigned const char *data, unsigned int len)
{
int ack = -1;
unsigned subaddr;
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 const unsigned char init_common[] = { static const unsigned char init_common[] = {
0x3a, 0x0f, /* CBENB=0, V656=0, VY2C=1, YUV2C=1, MY2C=1, MUV2C=1 */ 0x3a, 0x0f, /* CBENB=0, V656=0, VY2C=1, YUV2C=1, MY2C=1, MUV2C=1 */
...@@ -222,58 +182,71 @@ static const unsigned char init_ntsc[] = { ...@@ -222,58 +182,71 @@ static const unsigned char init_ntsc[] = {
0x66, 0x21, /* FSC3 */ 0x66, 0x21, /* FSC3 */
}; };
static int saa7185_attach(struct i2c_device *device) static int saa7185_attach(struct i2c_adapter *adap, int addr, unsigned short flags, int kind)
{ {
int i; int i;
struct saa7185 *encoder; struct saa7185 *encoder;
struct i2c_client client;
MOD_INC_USE_COUNT; client = kmalloc(sizeof(*client), GFP_KERNEL);
if (client == NULL)
device->data = encoder = kmalloc(sizeof(struct saa7185), GFP_KERNEL); return -ENOMEM;
client_template.adapter = adap;
client_template.addr = addr;
memcpy(client, &client_template, sizeof(*client));
encoder = kmalloc(sizeof(*decoder), GFP_KERNEL);
if (encoder == NULL) { if (encoder == NULL) {
MOD_DEC_USE_COUNT; kfree(client);
return -ENOMEM; return -ENOMEM;
} }
memset(encoder, 0, sizeof(struct saa7185)); memset(encoder, 0, sizeof(*decoder));
strcpy(device->name, "saa7185"); strcpy(client->name, "saa7185");
encoder->bus = device->bus; encoder->client = client;
encoder->addr = device->addr; client->data = encoder;
encoder->addr = addr;
encoder->norm = VIDEO_MODE_NTSC; encoder->norm = VIDEO_MODE_NTSC;
encoder->enable = 1; encoder->enable = 1;
i = saa7185_write_block(encoder, init_common, sizeof(init_common)); i = i2c_master_send(client, init_common, sizeof(init_common));
if (i >= 0) { if (i >= 0) {
i = saa7185_write_block(encoder, init_ntsc, i = i2c_master_send(client, init_ntsc,
sizeof(init_ntsc)); sizeof(init_ntsc));
} }
if (i < 0) { if (i < 0) {
printk(KERN_ERR "%s_attach: init error %d\n", device->name, printk(KERN_ERR "%s_attach: init error %d\n", client->name,
i); i);
} else { } else {
printk(KERN_INFO "%s_attach: chip version %d\n", printk(KERN_INFO "%s_attach: chip version %d\n",
device->name, saa7185_read(encoder) >> 5); client->name, i2c_smbus_read_byte(client) >> 5);
} }
init_MUTEX(&decoder->lock);
i2c_attach_client(client);
MOD_INC_USE_COUNT;
return 0; return 0;
} }
static int saa7185_probe(struct i2c_adapter *adap)
{
return i2c_probe(adap, &addr_data, saa7185_attach);
}
static int saa7185_detach(struct i2c_client *client)
static int saa7185_detach(struct i2c_device *device)
{ {
struct saa7185 *encoder = device->data; struct saa7185 *encoder = client->data;
saa7185_write(encoder, 0x61, (encoder->reg[0x61]) | 0x40); /* SW: output off is active */ i2c_detach_client(client);
//saa7185_write(encoder, 0x3a, (encoder->reg[0x3a]) | 0x80); /* SW: color bar */ i2c_smbus_write_byte_data(client, 0x61, (encoder->reg[0x61]) | 0x40); /* SW: output off is active */
//i2c_smbus_write_byte_data(client, 0x3a, (encoder->reg[0x3a]) | 0x80); /* SW: color bar */
kfree(encoder); kfree(encoder);
kfree(client);
MOD_DEC_USE_COUNT; MOD_DEC_USE_COUNT;
return 0; return 0;
} }
static int saa7185_command(struct i2c_device *device, unsigned int cmd, static int saa7185_command(struct i2c_client *client, unsigned int cmd,
void *arg) void *arg)
{ {
struct saa7185 *encoder = device->data; struct saa7185 *encoder = client->data;
switch (cmd) { switch (cmd) {
...@@ -297,12 +270,12 @@ static int saa7185_command(struct i2c_device *device, unsigned int cmd, ...@@ -297,12 +270,12 @@ static int saa7185_command(struct i2c_device *device, unsigned int cmd,
switch (*iarg) { switch (*iarg) {
case VIDEO_MODE_NTSC: case VIDEO_MODE_NTSC:
saa7185_write_block(encoder, init_ntsc, i2c_master_send(client, init_ntsc,
sizeof(init_ntsc)); sizeof(init_ntsc));
break; break;
case VIDEO_MODE_PAL: case VIDEO_MODE_PAL:
saa7185_write_block(encoder, init_pal, i2c_master_send(client, init_pal,
sizeof(init_pal)); sizeof(init_pal));
break; break;
...@@ -326,19 +299,19 @@ static int saa7185_command(struct i2c_device *device, unsigned int cmd, ...@@ -326,19 +299,19 @@ static int saa7185_command(struct i2c_device *device, unsigned int cmd,
case 0: case 0:
/* Switch RTCE to 1 */ /* Switch RTCE to 1 */
saa7185_write(encoder, 0x61, i2c_smbus_write_byte_data(client, 0x61,
(encoder-> (encoder->
reg[0x61] & 0xf7) | 0x08); reg[0x61] & 0xf7) | 0x08);
saa7185_write(encoder, 0x6e, 0x01); i2c_smbus_write_byte_data(client, 0x6e, 0x01);
break; break;
case 1: case 1:
/* Switch RTCE to 0 */ /* Switch RTCE to 0 */
saa7185_write(encoder, 0x61, i2c_smbus_write_byte_data(client, 0x61,
(encoder-> (encoder->
reg[0x61] & 0xf7) | 0x00); reg[0x61] & 0xf7) | 0x00);
/* SW: a slight sync problem... */ /* SW: a slight sync problem... */
saa7185_write(encoder, 0x6e, 0x00); i2c_smbus_write_byte_data(client, 0x6e, 0x00);
break; break;
default: default:
...@@ -364,7 +337,7 @@ static int saa7185_command(struct i2c_device *device, unsigned int cmd, ...@@ -364,7 +337,7 @@ static int saa7185_command(struct i2c_device *device, unsigned int cmd,
int *iarg = arg; int *iarg = arg;
encoder->enable = !!*iarg; encoder->enable = !!*iarg;
saa7185_write(encoder, 0x61, i2c_smbus_write_byte_data(client, 0x61,
(encoder-> (encoder->
reg[0x61] & 0xbf) | (encoder-> reg[0x61] & 0xbf) | (encoder->
enable ? 0x00 : enable ? 0x00 :
...@@ -382,23 +355,28 @@ static int saa7185_command(struct i2c_device *device, unsigned int cmd, ...@@ -382,23 +355,28 @@ static int saa7185_command(struct i2c_device *device, unsigned int cmd,
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
static struct i2c_driver i2c_driver_saa7185 = { static struct i2c_driver i2c_driver_saa7185 = {
"saa7185", /* name */ .name = "saa7185", /* name */
I2C_DRIVERID_VIDEOENCODER, /* ID */ .id = I2C_DRIVERID_SAA7185B, /* ID */
I2C_SAA7185, I2C_SAA7185 + 1, .flags = I2C_DF_NOTIFY,
.attach_adapter = saa7185_probe,
.detach_client = saa7185_detach,
.command = saa7185_command
};
saa7185_attach, static struct i2c_client client_template = {
saa7185_detach, .name = "saa7185_client",
saa7185_command .id = -1,
.driver = &i2c_driver_saa7185
}; };
static int saa7185_init(void) static int saa7185_init(void)
{ {
return i2c_register_driver(&i2c_driver_saa7185); return i2c_add_driver(&i2c_driver_saa7185);
} }
static void saa7185_exit(void) static void saa7185_exit(void)
{ {
i2c_unregister_driver(&i2c_driver_saa7185); i2c_del_driver(&i2c_driver_saa7185);
} }
module_init(saa7185_init); module_init(saa7185_init);
......
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