Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / drivers / media / video / saa7114.c
index e730236..90398ab 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
  * saa7114 - Philips SAA7114H video decoder driver version 0.0.1
  *
  * Copyright (C) 2002 Maxim Yevtyushkin <max@linuxmedialabs.com>
@@ -45,7 +45,6 @@
 #include <asm/pgtable.h>
 #include <asm/page.h>
 #include <linux/sched.h>
-#include <asm/segment.h>
 #include <linux/types.h>
 
 #include <linux/videodev.h>
@@ -56,7 +55,6 @@ MODULE_AUTHOR("Maxim Yevtyushkin");
 MODULE_LICENSE("GPL");
 
 #include <linux/i2c.h>
-#include <linux/i2c-dev.h>
 
 #define I2C_NAME(x) (x)->name
 
@@ -140,9 +138,6 @@ saa7114_write (struct i2c_client *client,
               u8                 reg,
               u8                 value)
 {
-       /*struct saa7114 *decoder = i2c_get_clientdata(client);*/
-
-       /*decoder->reg[reg] = value;*/
        return i2c_smbus_write_byte_data(client, reg, value);
 }
 
@@ -158,25 +153,21 @@ saa7114_write_block (struct i2c_client *client,
         * the adapter understands raw I2C */
        if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
                /* do raw I2C, not smbus compatible */
-               /*struct saa7114 *decoder = i2c_get_clientdata(client);*/
-               struct i2c_msg msg;
                u8 block_data[32];
+               int block_len;
 
-               msg.addr = client->addr;
-               msg.flags = 0;
                while (len >= 2) {
-                       msg.buf = (char *) block_data;
-                       msg.len = 0;
-                       block_data[msg.len++] = reg = data[0];
+                       block_len = 0;
+                       block_data[block_len++] = reg = data[0];
                        do {
-                               block_data[msg.len++] =
-                                   /*decoder->reg[reg++] =*/ data[1];
+                               block_data[block_len++] = data[1];
+                               reg++;
                                len -= 2;
                                data += 2;
                        } while (len >= 2 && data[0] == reg &&
-                                msg.len < 32);
-                       if ((ret = i2c_transfer(client->adapter,
-                                               &msg, 1)) < 0)
+                                block_len < 32);
+                       if ((ret = i2c_master_send(client, block_data,
+                                                  block_len)) < 0)
                                break;
                }
        } else {
@@ -309,7 +300,7 @@ static const unsigned char init[] = {
        0x55, 0xff,
        0x56, 0xff,
        0x57, 0xff,
-       0x58, 0x40,             // framing code 
+       0x58, 0x40,             // framing code
        0x59, 0x47,             // horizontal offset
        0x5a, 0x06,             // vertical offset
        0x5b, 0x83,             // field offset
@@ -354,7 +345,7 @@ static const unsigned char init[] = {
        0x82, 0x00,
        0x83, 0x00,
        0x84, 0xc5,
-       0x85, 0x0d,             // hsync and vsync ? 
+       0x85, 0x0d,             // hsync and vsync ?
        0x86, 0x40,
        0x87, 0x01,
        0x88, 0x00,
@@ -443,7 +434,7 @@ static const unsigned char init[] = {
        0xd9, 0x04,
        0xda, 0x00,             // horizontal luminance phase offset
        0xdb, 0x00,
-       0xdc, 0x00,             // horizontal chrominance scaling increment 
+       0xdc, 0x00,             // horizontal chrominance scaling increment
        0xdd, 0x02,
        0xde, 0x00,             // horizontal chrominance phase offset
        0xdf, 0x00,
@@ -763,7 +754,7 @@ saa7114_command (struct i2c_client *client,
                        saa7114_write(client, 0x87,
                                      decoder->reg[REG_ADDR(0x87)]);
                        saa7114_write(client, 0x88, 0xd8);      // sw reset scaler
-                       saa7114_write(client, 0x88, 0xf8);      // sw reset scaler release            
+                       saa7114_write(client, 0x88, 0xf8);      // sw reset scaler release
                        saa7114_write(client, 0x80, 0x36);
 
                }
@@ -820,22 +811,13 @@ saa7114_command (struct i2c_client *client,
  */
 static unsigned short normal_i2c[] =
     { I2C_SAA7114 >> 1, I2C_SAA7114A >> 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 unsigned short ignore = 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
+       .probe                  = &ignore,
+       .ignore                 = &ignore,
 };
 
 static struct i2c_driver i2c_driver_saa7114;
@@ -862,22 +844,19 @@ saa7114_detect_client (struct i2c_adapter *adapter,
        if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
                return 0;
 
-       client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
+       client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
        if (client == 0)
                return -ENOMEM;
-       memset(client, 0, sizeof(struct i2c_client));
        client->addr = address;
        client->adapter = adapter;
        client->driver = &i2c_driver_saa7114;
-       client->flags = I2C_CLIENT_ALLOW_USE;
        strlcpy(I2C_NAME(client), "saa7114", sizeof(I2C_NAME(client)));
 
-       decoder = kmalloc(sizeof(struct saa7114), GFP_KERNEL);
+       decoder = kzalloc(sizeof(struct saa7114), GFP_KERNEL);
        if (decoder == NULL) {
                kfree(client);
                return -ENOMEM;
        }
-       memset(decoder, 0, sizeof(struct saa7114));
        decoder->norm = VIDEO_MODE_NTSC;
        decoder->input = -1;
        decoder->enable = 1;
@@ -1214,11 +1193,11 @@ saa7114_detach_client (struct i2c_client *client)
 /* ----------------------------------------------------------------------- */
 
 static struct i2c_driver i2c_driver_saa7114 = {
-       .owner = THIS_MODULE,
-       .name = "saa7114",
+       .driver = {
+               .name = "saa7114",
+       },
 
        .id = I2C_DRIVERID_SAA7114,
-       .flags = I2C_DF_NOTIFY,
 
        .attach_adapter = saa7114_attach_adapter,
        .detach_client = saa7114_detach_client,