V4L/DVB (4958): Fix namespace conflict between w9968cf.c on MIPS
[safe/jmp/linux-2.6] / drivers / media / video / saa7115.c
index 61642f8..c2374ed 100644 (file)
@@ -48,7 +48,7 @@
 #include <media/saa7115.h>
 #include <asm/div64.h>
 
-#define HRES_60HZ      (480+16)
+#define VRES_60HZ      (480+16)
 
 MODULE_DESCRIPTION("Philips SAA7111/SAA7113/SAA7114/SAA7115/SAA7118 video decoder driver");
 MODULE_AUTHOR(  "Maxim Yevtyushkin, Kevin Thayer, Chris Kennedy, "
@@ -155,7 +155,7 @@ static inline int saa711x_read(struct i2c_client *client, u8 reg)
 /* ----------------------------------------------------------------------- */
 
 /* SAA7111 initialization table */
-static const unsigned char saa7111_init_auto_input[] = {
+static const unsigned char saa7111_init[] = {
        R_01_INC_DELAY, 0x00,           /* reserved */
 
        /*front end */
@@ -195,7 +195,7 @@ static const unsigned char saa7111_init_auto_input[] = {
 };
 
 /* SAA7113 init codes */
-static const unsigned char saa7113_init_auto_input[] = {
+static const unsigned char saa7113_init[] = {
        R_01_INC_DELAY, 0x08,
        R_02_INPUT_CNTL_1, 0xc2,
        R_03_INPUT_CNTL_2, 0x30,
@@ -237,6 +237,7 @@ static const unsigned char saa7115_init_auto_input[] = {
                /* Decoder Part */
        R_06_H_SYNC_START, 0xeb,                /* horiz sync begin = -21 */
        R_07_H_SYNC_STOP, 0xe0,                 /* horiz sync stop = -17 */
+       R_09_LUMA_CNTL, 0x53,                   /* 0x53, was 0x56 for 60hz. luminance control */
        R_0A_LUMA_BRIGHT_CNTL, 0x80,            /* was 0x88. decoder brightness, 0x80 is itu standard */
        R_0B_LUMA_CONTRAST_CNTL, 0x44,          /* was 0x48. decoder contrast, 0x44 is itu standard */
        R_0C_CHROMA_SAT_CNTL, 0x40,             /* was 0x47. decoder saturation, 0x40 is itu standard */
@@ -332,8 +333,8 @@ static const unsigned char saa7115_cfg_60hz_video[] = {
        R_C9_B_VERT_INPUT_WINDOW_START_MSB, 0x00,
 
        /* vwindow length 0xf8 = 248 */
-       R_CA_B_VERT_INPUT_WINDOW_LENGTH, HRES_60HZ>>1,
-       R_CB_B_VERT_INPUT_WINDOW_LENGTH_MSB, HRES_60HZ>>9,
+       R_CA_B_VERT_INPUT_WINDOW_LENGTH, VRES_60HZ>>1,
+       R_CB_B_VERT_INPUT_WINDOW_LENGTH_MSB, VRES_60HZ>>9,
 
        /* hwindow 0x02d0 = 720 */
        R_CC_B_HORIZ_OUTPUT_WINDOW_LENGTH, 0xd0,
@@ -582,7 +583,6 @@ static const unsigned char saa7115_init_misc[] = {
        R_5E_SDID, 0x35,
 
        R_02_INPUT_CNTL_1, 0x84,                /* input tuner -> input 4, amplifier active */
-       R_09_LUMA_CNTL, 0x53,                   /* 0x53, was 0x56 for 60hz. luminance control */
 
        R_80_GLOBAL_CNTL_1, 0x20,               /* enable task B */
        R_88_POWER_SAVE_ADC_PORT_CNTL, 0xd0,
@@ -851,7 +851,7 @@ static int saa711x_set_size(struct i2c_client *client, int width, int height)
 
        /* On 60Hz, it is using a higher Vertical Output Size */
        if (!is_50hz)
-               res+=(480-HRES_60HZ)>>1;
+               res += (VRES_60HZ - 480) >> 1;
 
                /* height */
        saa711x_write(client, R_CE_B_VERT_OUTPUT_WINDOW_LENGTH,
@@ -907,7 +907,7 @@ static int saa711x_set_size(struct i2c_client *client, int width, int height)
 
        /* Activates task "B" */
        saa711x_write(client, R_80_GLOBAL_CNTL_1,
-                               saa711x_read(client,R_80_GLOBAL_CNTL_1)|0x20);
+                               saa711x_read(client,R_80_GLOBAL_CNTL_1) | 0x20);
 
        return 0;
 }
@@ -932,11 +932,11 @@ static void saa711x_set_v4lstd(struct i2c_client *client, v4l2_std_id std)
        if (std & V4L2_STD_525_60) {
                v4l_dbg(1, debug, client, "decoder set standard 60 Hz\n");
                saa711x_writeregs(client, saa7115_cfg_60hz_video);
-               saa711x_set_size(client,720,480);
+               saa711x_set_size(client, 720, 480);
        } else {
                v4l_dbg(1, debug, client, "decoder set standard 50 Hz\n");
                saa711x_writeregs(client, saa7115_cfg_50hz_video);
-               saa711x_set_size(client,720,576);
+               saa711x_set_size(client, 720, 576);
        }
 
        /* Register 0E - Bits D6-D4 on NO-AUTO mode
@@ -960,6 +960,8 @@ static void saa711x_set_v4lstd(struct i2c_client *client, v4l2_std_id std)
                        reg |= 0x10;
                } else if (std == V4L2_STD_NTSC_M_JP) {
                        reg |= 0x40;
+               } else if (std == V4L2_STD_SECAM) {
+                       reg |= 0x50;
                }
                saa711x_write(client, R_0E_CHROMA_CNTL_1, reg);
        } else {
@@ -1462,19 +1464,24 @@ static int saa711x_attach(struct i2c_adapter *adapter, int address, int kind)
        client->driver = &i2c_driver_saa711x;
        snprintf(client->name, sizeof(client->name) - 1, "saa7115");
 
-       v4l_dbg(1, debug, client, "detecting saa7115 client on address 0x%x\n", address << 1);
-
-       for (i=0;i<0x0f;i++) {
+       for (i = 0; i < 0x0f; i++) {
                saa711x_write(client, 0, i);
-               name[i] = (saa711x_read(client, 0) &0x0f) +'0';
-               if (name[i]>'9')
-                       name[i]+='a'-'9'-1;
+               name[i] = (saa711x_read(client, 0) & 0x0f) + '0';
+               if (name[i] > '9')
+                       name[i] += 'a' - '9' - 1;
        }
-       name[i]='\0';
+       name[i] = '\0';
 
        saa711x_write(client, 0, 5);
        chip_id = saa711x_read(client, 0) & 0x0f;
 
+       /* Check whether this chip is part of the saa711x series */
+       if (memcmp(name, "1f711", 5)) {
+               v4l_dbg(1, debug, client, "chip found @ 0x%x (ID %s) does not match a known saa711x chip.\n",
+                       address << 1, name);
+               return 0;
+       }
+
        snprintf(client->name, sizeof(client->name) - 1, "saa711%d",chip_id);
        v4l_info(client, "saa711%d found (%s) @ 0x%x (%s)\n", chip_id, name, address << 1, adapter->name);
 
@@ -1518,11 +1525,15 @@ static int saa711x_attach(struct i2c_adapter *adapter, int address, int kind)
        v4l_dbg(1, debug, client, "writing init values\n");
 
        /* init to 60hz/48khz */
-       if (state->ident == V4L2_IDENT_SAA7111 ||
-                       state->ident == V4L2_IDENT_SAA7113) {
-               state->crystal_freq = SAA7115_FREQ_24_576_MHZ;
-               saa711x_writeregs(client, saa7113_init_auto_input);
-       } else {
+       state->crystal_freq = SAA7115_FREQ_24_576_MHZ;
+       switch (state->ident) {
+       case V4L2_IDENT_SAA7111:
+               saa711x_writeregs(client, saa7111_init);
+               break;
+       case V4L2_IDENT_SAA7113:
+               saa711x_writeregs(client, saa7113_init);
+               break;
+       default:
                state->crystal_freq = SAA7115_FREQ_32_11_MHZ;
                saa711x_writeregs(client, saa7115_init_auto_input);
        }