fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / media / video / bt819.c
index 16be0ef..e7b38fd 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
  *  bt819 - BT819A VideoStream Decoder (Rockwell Part)
  *
  * Copyright (C) 1999 Mike Bernson <mike@mlb.org>
@@ -6,7 +6,7 @@
  *
  * Modifications for LML33/DC10plus unified driver
  * Copyright (C) 2000 Serguei Miridonov <mirsev@cicese.mx>
- *  
+ *
  * Changes by Ronald Bultje <rbultje@ronald.bitfreak.net>
  *    - moved over to linux>=2.4.x i2c protocol (9/9/2002)
  *
@@ -43,7 +43,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>
@@ -54,14 +53,13 @@ MODULE_AUTHOR("Mike Bernson & Dave Perks");
 MODULE_LICENSE("GPL");
 
 #include <linux/i2c.h>
-#include <linux/i2c-dev.h>
 
 #define I2C_NAME(s) (s)->name
 
 #include <linux/video_decoder.h>
 
 static int debug = 0;
-MODULE_PARM(debug, "i");
+module_param(debug, int, 0);
 MODULE_PARM_DESC(debug, "Debug level (0-1)");
 
 #define dprintk(num, format, args...) \
@@ -95,7 +93,7 @@ struct timing {
 };
 
 /* for values, see the bt819 datasheet */
-struct timing timing_data[] = {
+static struct timing timing_data[] = {
        {864 - 24, 20, 625 - 2, 1, 0x0504, 0x0000},
        {858 - 24, 20, 525 - 2, 1, 0x00f8, 0x0000},
 };
@@ -142,24 +140,21 @@ bt819_write_block (struct i2c_client *client,
        if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
                /* do raw I2C, not smbus compatible */
                struct bt819 *decoder = i2c_get_clientdata(client);
-               struct i2c_msg msg;
                u8 block_data[32];
+               int block_len;
 
-               msg.addr = client->addr;
-               msg.flags = client->flags;
                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++] =
+                               block_data[block_len++] =
                                    decoder->reg[reg++] = data[1];
                                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 {
@@ -211,9 +206,9 @@ bt819_init (struct i2c_client *client)
                                           Bug in the bt819 stepping on my board?
                                        */
                0x14, 0x00,     /* 0x14 Vertial Scaling lsb */
-               0x16, 0x07,     /* 0x16 Video Timing Polarity 
+               0x16, 0x07,     /* 0x16 Video Timing Polarity
                                           ACTIVE=active low
-                                          FIELD: high=odd, 
+                                          FIELD: high=odd,
                                           vreset=active high,
                                           hreset=active high */
                0x18, 0x68,     /* 0x18 AGC Delay */
@@ -236,7 +231,8 @@ bt819_init (struct i2c_client *client)
        init[0x07 * 2 - 1] = timing->hactive & 0xff;
        init[0x08 * 2 - 1] = timing->hscale >> 8;
        init[0x09 * 2 - 1] = timing->hscale & 0xff;
-       init[0x19*2-1] = decoder->norm == 0 ? 115 : 93; /* Chroma burst delay */
+       /* 0x15 in array is address 0x19 */
+       init[0x15 * 2 - 1] = (decoder->norm == 0) ? 115 : 93;   /* Chroma burst delay */
        /* reset */
        bt819_write(client, 0x1f, 0x00);
        mdelay(1);
@@ -499,25 +495,15 @@ static unsigned short normal_i2c[] = {
        I2C_BT819 >> 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 int bt819_i2c_id = 0;
 static struct i2c_driver i2c_driver_bt819;
 
 static int
@@ -538,23 +524,18 @@ bt819_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_bt819;
-       client->flags = I2C_CLIENT_ALLOW_USE;
-       client->id = bt819_i2c_id++;
 
-       decoder = kmalloc(sizeof(struct bt819), GFP_KERNEL);
+       decoder = kzalloc(sizeof(struct bt819), GFP_KERNEL);
        if (decoder == NULL) {
                kfree(client);
                return -ENOMEM;
        }
-
-       memset(decoder, 0, sizeof(struct bt819));
        decoder->norm = VIDEO_MODE_NTSC;
        decoder->input = 0;
        decoder->enable = 1;
@@ -568,16 +549,13 @@ bt819_detect_client (struct i2c_adapter *adapter,
        id = bt819_read(client, 0x17);
        switch (id & 0xf0) {
        case 0x70:
-               snprintf(I2C_NAME(client), sizeof(I2C_NAME(client)) - 1,
-                        "bt819a[%d]", client->id);
+               strlcpy(I2C_NAME(client), "bt819a", sizeof(I2C_NAME(client)));
                break;
        case 0x60:
-               snprintf(I2C_NAME(client), sizeof(I2C_NAME(client)) - 1,
-                        "bt817a[%d]", client->id);
+               strlcpy(I2C_NAME(client), "bt817a", sizeof(I2C_NAME(client)));
                break;
        case 0x20:
-               snprintf(I2C_NAME(client), sizeof(I2C_NAME(client)) - 1,
-                        "bt815a[%d]", client->id);
+               strlcpy(I2C_NAME(client), "bt815a", sizeof(I2C_NAME(client)));
                break;
        default:
                dprintk(1,
@@ -637,11 +615,11 @@ bt819_detach_client (struct i2c_client *client)
 /* ----------------------------------------------------------------------- */
 
 static struct i2c_driver i2c_driver_bt819 = {
-       .owner = THIS_MODULE,
-       .name = "bt819",
+       .driver = {
+               .name = "bt819",
+       },
 
        .id = I2C_DRIVERID_BT819,
-       .flags = I2C_DF_NOTIFY,
 
        .attach_adapter = bt819_attach_adapter,
        .detach_client = bt819_detach_client,