tree-wide: fix assorted typos all over the place
[safe/jmp/linux-2.6] / drivers / media / dvb / dvb-usb / anysee.c
index a3f9bbc..bb69f37 100644 (file)
@@ -23,8 +23,8 @@
  * Card reader in Anysee is nothing more than ISO 7816 card reader.
  * There is no hardware CAM in any Anysee device sold.
  * In my understanding it should be implemented by making own module
- * for ISO 7816 card reader, like dvb_ca_en50221 is implented. This
- * module registers serial interface that can be used to comminicate
+ * for ISO 7816 card reader, like dvb_ca_en50221 is implemented. This
+ * module registers serial interface that can be used to communicate
  * with any ISO 7816 smart card.
  *
  * Any help according to implement serial smart card reader support
 static int dvb_usb_anysee_debug;
 module_param_named(debug, dvb_usb_anysee_debug, int, 0644);
 MODULE_PARM_DESC(debug, "set debugging level" DVB_USB_DEBUG_STATUS);
+static int dvb_usb_anysee_delsys;
+module_param_named(delsys, dvb_usb_anysee_delsys, int, 0644);
+MODULE_PARM_DESC(delsys, "select delivery mode (0=DVB-C, 1=DVB-T)");
 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
 
-struct mutex anysee_usb_mutex;
+static DEFINE_MUTEX(anysee_usb_mutex);
 
 static int anysee_ctrl_msg(struct dvb_usb_device *d, u8 *sbuf, u8 slen,
        u8 *rbuf, u8 rlen)
@@ -150,7 +153,7 @@ static int anysee_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msg,
        int num)
 {
        struct dvb_usb_device *d = i2c_get_adapdata(adap);
-       int ret, inc, i = 0;
+       int ret = 0, inc, i = 0;
 
        if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
                return -EAGAIN;
@@ -178,14 +181,14 @@ static int anysee_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msg,
                        inc = 1;
                }
                if (ret)
-                       return ret;
+                       break;
 
                i += inc;
        }
 
        mutex_unlock(&d->i2c_mutex);
 
-       return i;
+       return ret ? ret : i;
 }
 
 static u32 anysee_i2c_func(struct i2c_adapter *adapter)
@@ -200,11 +203,11 @@ static struct i2c_algorithm anysee_i2c_algo = {
 
 static int anysee_mt352_demod_init(struct dvb_frontend *fe)
 {
-       static u8 clock_config []  = { CLOCK_CTL,  0x38, 0x28 };
-       static u8 reset []         = { RESET,      0x80 };
-       static u8 adc_ctl_1_cfg [] = { ADC_CTL_1,  0x40 };
-       static u8 agc_cfg []       = { AGC_TARGET, 0x28, 0x20 };
-       static u8 gpp_ctl_cfg []   = { GPP_CTL,    0x33 };
+       static u8 clock_config[]   = { CLOCK_CTL,  0x38, 0x28 };
+       static u8 reset[]          = { RESET,      0x80 };
+       static u8 adc_ctl_1_cfg[]  = { ADC_CTL_1,  0x40 };
+       static u8 agc_cfg[]        = { AGC_TARGET, 0x28, 0x20 };
+       static u8 gpp_ctl_cfg[]    = { GPP_CTL,    0x33 };
        static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
 
        mt352_write(fe, clock_config,   sizeof(clock_config));
@@ -272,9 +275,11 @@ static int anysee_frontend_attach(struct dvb_usb_adapter *adap)
              model      demod     hw  firmware
           1. E30        MT352     02  0.2.1
           2. E30        ZL10353   02  0.2.1
-          3. E30 Plus   ZL10353   06  0.1.0
-          4. E30C Plus  TDA10023  0a  0.1.0    rev 0.2
-          4. E30C Plus  TDA10023  0f  0.1.2    rev 0.4
+          3. E30 Combo  ZL10353   0f  0.1.2    DVB-T/C combo
+          4. E30 Plus   ZL10353   06  0.1.0
+          5. E30C Plus  TDA10023  0a  0.1.0    rev 0.2
+             E30C Plus  TDA10023  0f  0.1.2    rev 0.4
+             E30 Combo  TDA10023  0f  0.1.2    DVB-T/C combo
        */
 
        /* Zarlink MT352 DVB-T demod inside of Samsung DNOS404ZH102A NIM */
@@ -293,6 +298,21 @@ static int anysee_frontend_attach(struct dvb_usb_adapter *adap)
                return 0;
        }
 
+       /* for E30 Combo Plus DVB-T demodulator */
+       if (dvb_usb_anysee_delsys) {
+               ret = anysee_write_reg(adap->dev, 0xb0, 0x01);
+               if (ret)
+                       return ret;
+
+               /* Zarlink ZL10353 DVB-T demod */
+               adap->fe = dvb_attach(zl10353_attach, &anysee_zl10353_config,
+                                     &adap->dev->i2c_adap);
+               if (adap->fe != NULL) {
+                       state->tuner = DVB_PLL_SAMSUNG_DTOS403IH102A;
+                       return 0;
+               }
+       }
+
        /* connect demod on IO port D for TDA10023 & ZL10353 */
        ret = anysee_write_reg(adap->dev, 0xb0, 0x25);
        if (ret)
@@ -324,7 +344,7 @@ static int anysee_frontend_attach(struct dvb_usb_adapter *adap)
        if (ret)
                return ret;
 
-       err("Unkown Anysee version: %02x %02x %02x. "\
+       err("Unknown Anysee version: %02x %02x %02x. "\
            "Please report the <linux-dvb@linuxtv.org>.",
            hw_info[0], hw_info[1], hw_info[2]);
 
@@ -369,8 +389,8 @@ static int anysee_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
        *state = REMOTE_NO_KEY_PRESSED;
 
        for (i = 0; i < d->props.rc_key_map_size; i++) {
-               if (keymap[i].custom == ircode[0] &&
-                   keymap[i].data == ircode[1]) {
+               if (rc5_custom(&keymap[i]) == ircode[0] &&
+                   rc5_data(&keymap[i]) == ircode[1]) {
                        *event = keymap[i].event;
                        *state = REMOTE_KEY_PRESSED;
                        return 0;
@@ -380,50 +400,50 @@ static int anysee_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
 }
 
 static struct dvb_usb_rc_key anysee_rc_keys[] = {
-       { 0x01, 0x00, KEY_0 },
-       { 0x01, 0x01, KEY_1 },
-       { 0x01, 0x02, KEY_2 },
-       { 0x01, 0x03, KEY_3 },
-       { 0x01, 0x04, KEY_4 },
-       { 0x01, 0x05, KEY_5 },
-       { 0x01, 0x06, KEY_6 },
-       { 0x01, 0x07, KEY_7 },
-       { 0x01, 0x08, KEY_8 },
-       { 0x01, 0x09, KEY_9 },
-       { 0x01, 0x0a, KEY_POWER },
-       { 0x01, 0x0b, KEY_DOCUMENTS },    /* * */
-       { 0x01, 0x19, KEY_FAVORITES },
-       { 0x01, 0x20, KEY_SLEEP },
-       { 0x01, 0x21, KEY_MODE },         /* 4:3 / 16:9 select */
-       { 0x01, 0x22, KEY_ZOOM },
-       { 0x01, 0x47, KEY_TEXT },
-       { 0x01, 0x16, KEY_TV },           /* TV / radio select */
-       { 0x01, 0x1e, KEY_LANGUAGE },     /* Second Audio Program */
-       { 0x01, 0x1a, KEY_SUBTITLE },
-       { 0x01, 0x1b, KEY_CAMERA },       /* screenshot */
-       { 0x01, 0x42, KEY_MUTE },
-       { 0x01, 0x0e, KEY_MENU },
-       { 0x01, 0x0f, KEY_EPG },
-       { 0x01, 0x17, KEY_INFO },
-       { 0x01, 0x10, KEY_EXIT },
-       { 0x01, 0x13, KEY_VOLUMEUP },
-       { 0x01, 0x12, KEY_VOLUMEDOWN },
-       { 0x01, 0x11, KEY_CHANNELUP },
-       { 0x01, 0x14, KEY_CHANNELDOWN },
-       { 0x01, 0x15, KEY_OK },
-       { 0x01, 0x1d, KEY_RED },
-       { 0x01, 0x1f, KEY_GREEN },
-       { 0x01, 0x1c, KEY_YELLOW },
-       { 0x01, 0x44, KEY_BLUE },
-       { 0x01, 0x0c, KEY_SHUFFLE },      /* snapshot */
-       { 0x01, 0x48, KEY_STOP },
-       { 0x01, 0x50, KEY_PLAY },
-       { 0x01, 0x51, KEY_PAUSE },
-       { 0x01, 0x49, KEY_RECORD },
-       { 0x01, 0x18, KEY_PREVIOUS },     /* |<< */
-       { 0x01, 0x0d, KEY_NEXT },         /* >>| */
-       { 0x01, 0x24, KEY_PROG1 },        /* F1 */
-       { 0x01, 0x25, KEY_PROG2 },        /* F2 */
+       { 0x0100, KEY_0 },
+       { 0x0101, KEY_1 },
+       { 0x0102, KEY_2 },
+       { 0x0103, KEY_3 },
+       { 0x0104, KEY_4 },
+       { 0x0105, KEY_5 },
+       { 0x0106, KEY_6 },
+       { 0x0107, KEY_7 },
+       { 0x0108, KEY_8 },
+       { 0x0109, KEY_9 },
+       { 0x010a, KEY_POWER },
+       { 0x010b, KEY_DOCUMENTS },    /* * */
+       { 0x0119, KEY_FAVORITES },
+       { 0x0120, KEY_SLEEP },
+       { 0x0121, KEY_MODE },         /* 4:3 / 16:9 select */
+       { 0x0122, KEY_ZOOM },
+       { 0x0147, KEY_TEXT },
+       { 0x0116, KEY_TV },           /* TV / radio select */
+       { 0x011e, KEY_LANGUAGE },     /* Second Audio Program */
+       { 0x011a, KEY_SUBTITLE },
+       { 0x011b, KEY_CAMERA },       /* screenshot */
+       { 0x0142, KEY_MUTE },
+       { 0x010e, KEY_MENU },
+       { 0x010f, KEY_EPG },
+       { 0x0117, KEY_INFO },
+       { 0x0110, KEY_EXIT },
+       { 0x0113, KEY_VOLUMEUP },
+       { 0x0112, KEY_VOLUMEDOWN },
+       { 0x0111, KEY_CHANNELUP },
+       { 0x0114, KEY_CHANNELDOWN },
+       { 0x0115, KEY_OK },
+       { 0x011d, KEY_RED },
+       { 0x011f, KEY_GREEN },
+       { 0x011c, KEY_YELLOW },
+       { 0x0144, KEY_BLUE },
+       { 0x010c, KEY_SHUFFLE },      /* snapshot */
+       { 0x0148, KEY_STOP },
+       { 0x0150, KEY_PLAY },
+       { 0x0151, KEY_PAUSE },
+       { 0x0149, KEY_RECORD },
+       { 0x0118, KEY_PREVIOUS },     /* |<< */
+       { 0x010d, KEY_NEXT },         /* >>| */
+       { 0x0124, KEY_PROG1 },        /* F1 */
+       { 0x0125, KEY_PROG2 },        /* F2 */
 };
 
 /* DVB USB Driver stuff */
@@ -436,8 +456,6 @@ static int anysee_probe(struct usb_interface *intf,
        struct usb_host_interface *alt;
        int ret;
 
-       mutex_init(&anysee_usb_mutex);
-
        /* There is one interface with two alternate settings.
           Alternate setting 0 is for bulk transfer.
           Alternate setting 1 is for isochronous transfer.
@@ -467,7 +485,7 @@ static int anysee_probe(struct usb_interface *intf,
        return ret;
 }
 
-static struct usb_device_id anysee_table [] = {
+static struct usb_device_id anysee_table[] = {
        { USB_DEVICE(USB_VID_CYPRESS, USB_PID_ANYSEE) },
        { USB_DEVICE(USB_VID_AMT,     USB_PID_ANYSEE) },
        { }             /* Terminating entry */
@@ -493,7 +511,7 @@ static struct dvb_usb_device_properties anysee_properties = {
                                .endpoint = 0x82,
                                .u = {
                                        .bulk = {
-                                               .buffersize = 512,
+                                               .buffersize = (16*512),
                                        }
                                }
                        },