[PATCH] i2c: Drop i2c_driver.{owner,name}, 5 of 11
[deliverable/linux.git] / drivers / media / video / cx25840 / cx25840-core.c
index f6afeec499c509b1a692df5cf3d7353215945bb2..830d5195d1c0b30826e0d3479e5e0606e021fbea 100644 (file)
@@ -208,8 +208,11 @@ static void cx25840_initialize(struct i2c_client *client, int loadfw)
 
 static void input_change(struct i2c_client *client)
 {
+       struct cx25840_state *state = i2c_get_clientdata(client);
        v4l2_std_id std = cx25840_get_v4lstd(client);
 
+       /* Note: perhaps V4L2_STD_PAL_M should be handled as V4L2_STD_NTSC
+          instead of V4L2_STD_PAL. Someone needs to test this. */
        if (std & V4L2_STD_PAL) {
                /* Follow tuner change procedure for PAL */
                cx25840_write(client, 0x808, 0xff);
@@ -220,7 +223,32 @@ static void input_change(struct i2c_client *client)
                cx25840_write(client, 0x80b, 0x10);
        } else if (std & V4L2_STD_NTSC) {
                /* NTSC */
-               cx25840_write(client, 0x808, 0xf6);
+               if (state->cardtype == CARDTYPE_PVR150_WORKAROUND) {
+                       /* Certain Hauppauge PVR150 models have a hardware bug
+                          that causes audio to drop out. For these models the
+                          audio standard must be set explicitly.
+                          To be precise: it affects cards with tuner models
+                          85, 99 and 112 (model numbers from tveeprom). */
+                       if (std == V4L2_STD_NTSC_M_JP) {
+                               /* Japan uses EIAJ audio standard */
+                               cx25840_write(client, 0x808, 0x2f);
+                       } else {
+                               /* Others use the BTSC audio standard */
+                               cx25840_write(client, 0x808, 0x1f);
+                       }
+                       /* South Korea uses the A2-M (aka Zweiton M) audio
+                          standard, and should set 0x808 to 0x3f, but I don't
+                          know how to detect this. */
+               } else if (std == V4L2_STD_NTSC_M_JP) {
+                       /* Japan uses EIAJ audio standard */
+                       cx25840_write(client, 0x808, 0xf7);
+               } else {
+                       /* Others use the BTSC audio standard */
+                       cx25840_write(client, 0x808, 0xf6);
+               }
+               /* South Korea uses the A2-M (aka Zweiton M) audio standard,
+                  and should set 0x808 to 0xf8, but I don't know how to
+                  detect this. */
                cx25840_write(client, 0x80b, 0x00);
        }
 
@@ -241,7 +269,8 @@ static int set_input(struct i2c_client *client, enum cx25840_input input)
        case CX25840_TUNER:
                cx25840_dbg("now setting Tuner input\n");
 
-               if (state->cardtype == CARDTYPE_PVR150) {
+               if (state->cardtype == CARDTYPE_PVR150 ||
+                   state->cardtype == CARDTYPE_PVR150_WORKAROUND) {
                        /* CH_SEL_ADC2=1 */
                        cx25840_and_or(client, 0x102, ~0x2, 0x02);
                }
@@ -304,24 +333,30 @@ static int set_input(struct i2c_client *client, enum cx25840_input input)
 
 static int set_v4lstd(struct i2c_client *client, v4l2_std_id std)
 {
-       u8 fmt;
-
-       switch (std) {
-       /* zero is autodetect */
-       case 0: fmt = 0x0; break;
-       /* default ntsc to ntsc-m */
-       case V4L2_STD_NTSC:
-       case V4L2_STD_NTSC_M: fmt = 0x1; break;
-       case V4L2_STD_NTSC_M_JP: fmt = 0x2; break;
-       case V4L2_STD_NTSC_443: fmt = 0x3; break;
-       case V4L2_STD_PAL: fmt = 0x4; break;
-       case V4L2_STD_PAL_M: fmt = 0x5; break;
-       case V4L2_STD_PAL_N: fmt = 0x6; break;
-       case V4L2_STD_PAL_Nc: fmt = 0x7; break;
-       case V4L2_STD_PAL_60: fmt = 0x8; break;
-       case V4L2_STD_SECAM: fmt = 0xc; break;
-       default:
-               return -ERANGE;
+       u8 fmt=0;       /* zero is autodetect */
+
+       /* First tests should be against specific std */
+       if (std & V4L2_STD_NTSC_M_JP) {
+               fmt=0x2;
+       } else if (std & V4L2_STD_NTSC_443) {
+               fmt=0x3;
+       } else if (std & V4L2_STD_PAL_M) {
+               fmt=0x5;
+       } else if (std & V4L2_STD_PAL_N) {
+               fmt=0x6;
+       } else if (std & V4L2_STD_PAL_Nc) {
+               fmt=0x7;
+       } else if (std & V4L2_STD_PAL_60) {
+               fmt=0x8;
+       } else {
+               /* Then, test against generic ones */
+               if (std & V4L2_STD_NTSC) {
+                       fmt=0x1;
+               } else if (std & V4L2_STD_PAL) {
+                       fmt=0x4;
+               } else if (std & V4L2_STD_SECAM) {
+                       fmt=0xc;
+               }
        }
 
        cx25840_and_or(client, 0x400, ~0xf, fmt);
@@ -363,6 +398,7 @@ static int set_v4lctrl(struct i2c_client *client, struct v4l2_control *ctrl)
        case CX25840_CID_CARDTYPE:
                switch (ctrl->value) {
                case CARDTYPE_PVR150:
+               case CARDTYPE_PVR150_WORKAROUND:
                case CARDTYPE_PG600:
                        state->cardtype = ctrl->value;
                        break;
@@ -714,7 +750,7 @@ static int cx25840_command(struct i2c_client *client, unsigned int cmd,
 
 /* ----------------------------------------------------------------------- */
 
-struct i2c_driver i2c_driver_cx25840;
+static struct i2c_driver i2c_driver_cx25840;
 
 static int cx25840_detect_client(struct i2c_adapter *adapter, int address,
                                 int kind)
@@ -737,7 +773,6 @@ static int cx25840_detect_client(struct i2c_adapter *adapter, int address,
        client->addr = address;
        client->adapter = adapter;
        client->driver = &i2c_driver_cx25840;
-       client->flags = I2C_CLIENT_ALLOW_USE;
        snprintf(client->name, sizeof(client->name) - 1, "cx25840");
 
        cx25840_dbg("detecting cx25840 client on address 0x%x\n", address << 1);
@@ -807,16 +842,17 @@ static int cx25840_detach_client(struct i2c_client *client)
 
 /* ----------------------------------------------------------------------- */
 
-struct i2c_driver i2c_driver_cx25840 = {
-       .name = "cx25840",
+static struct i2c_driver i2c_driver_cx25840 = {
+       .driver = {
+               .owner = THIS_MODULE,
+               .name = "cx25840",
+       },
 
        .id = I2C_DRIVERID_CX25840,
-       .flags = I2C_DF_NOTIFY,
 
        .attach_adapter = cx25840_attach_adapter,
        .detach_client = cx25840_detach_client,
        .command = cx25840_command,
-       .owner = THIS_MODULE,
 };
 
 
This page took 0.026353 seconds and 5 git commands to generate.