[PATCH] v4l: BTTV updates and card additions
[powerpc.git] / drivers / media / video / tda9887.c
index 108c3ad..79e0bd1 100644 (file)
@@ -49,7 +49,7 @@ MODULE_LICENSE("GPL");
 struct tda9887 {
        struct i2c_client  client;
        v4l2_std_id        std;
-       unsigned int       radio;
+       enum tuner_mode    mode;
        unsigned int       config;
        unsigned int       pinnacle_id;
        unsigned int       using_v4l2;
@@ -196,7 +196,7 @@ static struct tvnorm tvnorms[] = {
                .b     = ( cNegativeFmTV  |
                           cQSS           ),
                .c     = ( cDeemphasisON  |
-                          cDeemphasis50  ),
+                          cDeemphasis75  ),
                .e     = ( cGating_36     |
                           cAudioIF_4_5   |
                           cVideoIF_45_75 ),
@@ -364,7 +364,7 @@ static int tda9887_set_tvnorm(struct tda9887 *t, char *buf)
        struct tvnorm *norm = NULL;
        int i;
 
-       if (t->radio) {
+       if (t->mode == T_RADIO) {
                if (t->radio_mode == V4L2_TUNER_MODE_MONO)
                        norm = &radio_mono;
                else
@@ -378,7 +378,7 @@ static int tda9887_set_tvnorm(struct tda9887 *t, char *buf)
                }
        }
        if (NULL == norm) {
-               dprintk(PREFIX "Oops: no tvnorm entry found\n");
+               dprintk(PREFIX "Unsupported tvnorm entry - audio muted\n");
                return -1;
        }
 
@@ -569,6 +569,10 @@ static int tda9887_configure(struct tda9887 *t)
        tda9887_set_config(t,buf);
        tda9887_set_insmod(t,buf);
 
+       if (t->mode == T_STANDBY) {
+               buf[1] |= cForcedMuteAudioON;
+       }
+
 
        dprintk(PREFIX "writing: b=0x%02x c=0x%02x e=0x%02x\n",
                buf[1],buf[2],buf[3]);
@@ -618,9 +622,9 @@ static int tda9887_probe(struct i2c_adapter *adap)
                return i2c_probe(adap, &addr_data, tda9887_attach);
 #else
        switch (adap->id) {
-       case I2C_ALGO_BIT | I2C_HW_B_BT848:
-       case I2C_ALGO_BIT | I2C_HW_B_RIVA:
-       case I2C_ALGO_SAA7134:
+       case I2C_HW_B_BT848:
+       case I2C_HW_B_RIVA:
+       case I2C_HW_SAA7134:
                return i2c_probe(adap, &addr_data, tda9887_attach);
                break;
        }
@@ -653,10 +657,17 @@ tda9887_command(struct i2c_client *client, unsigned int cmd, void *arg)
 
        /* --- configuration --- */
        case AUDC_SET_RADIO:
-               t->radio = 1;
+       {
+               t->mode = T_RADIO;
                tda9887_configure(t);
                break;
-
+       }
+       case TUNER_SET_STANDBY:
+       {
+               t->mode = T_STANDBY;
+               tda9887_configure(t);
+               break;
+       }
        case AUDC_CONFIG_PINNACLE:
        {
                int *i = arg;
@@ -689,7 +700,7 @@ tda9887_command(struct i2c_client *client, unsigned int cmd, void *arg)
                struct video_channel *vc = arg;
 
                CHECK_V4L2;
-               t->radio = 0;
+               t->mode = T_ANALOG_TV;
                if (vc->norm < ARRAY_SIZE(map))
                        t->std = map[vc->norm];
                tda9887_fixup_std(t);
@@ -701,7 +712,7 @@ tda9887_command(struct i2c_client *client, unsigned int cmd, void *arg)
                v4l2_std_id *id = arg;
 
                SWITCH_V4L2;
-               t->radio = 0;
+               t->mode = T_ANALOG_TV;
                t->std   = *id;
                tda9887_fixup_std(t);
                tda9887_configure(t);
@@ -713,14 +724,14 @@ tda9887_command(struct i2c_client *client, unsigned int cmd, void *arg)
 
                SWITCH_V4L2;
                if (V4L2_TUNER_ANALOG_TV == f->type) {
-                       if (t->radio == 0)
+                       if (t->mode == T_ANALOG_TV)
                                return 0;
-                       t->radio = 0;
+                       t->mode = T_ANALOG_TV;
                }
                if (V4L2_TUNER_RADIO == f->type) {
-                       if (t->radio == 1)
+                       if (t->mode == T_RADIO)
                                return 0;
-                       t->radio = 1;
+                       t->mode = T_RADIO;
                }
                tda9887_configure(t);
                break;
@@ -735,7 +746,7 @@ tda9887_command(struct i2c_client *client, unsigned int cmd, void *arg)
                };
                struct v4l2_tuner* tuner = arg;
 
-               if (t->radio) {
+               if (t->mode == T_RADIO) {
                        __u8 reg = 0;
                        tuner->afc=0;
                        if (1 == i2c_master_recv(&t->client,&reg,1))
@@ -747,7 +758,7 @@ tda9887_command(struct i2c_client *client, unsigned int cmd, void *arg)
        {
                struct v4l2_tuner* tuner = arg;
 
-               if (t->radio) {
+               if (t->mode == T_RADIO) {
                        t->radio_mode = tuner->audmode;
                        tda9887_configure (t);
                }
@@ -760,7 +771,7 @@ tda9887_command(struct i2c_client *client, unsigned int cmd, void *arg)
        return 0;
 }
 
-static int tda9887_suspend(struct device * dev, u32 state, u32 level)
+static int tda9887_suspend(struct device * dev, pm_message_t state, u32 level)
 {
        dprintk("tda9887: suspend\n");
        return 0;
@@ -793,7 +804,7 @@ static struct i2c_driver driver = {
 };
 static struct i2c_client client_template =
 {
-       I2C_DEVNAME("tda9887"),
+       .name      = "tda9887",
        .flags     = I2C_CLIENT_ALLOW_USE,
         .driver    = &driver,
 };