V4L/DVB (3313): FIX: Check if FW was downloaded or not + new firmware file
[pandora-kernel.git] / drivers / media / dvb / dvb-usb / digitv.c
index f70e0be..caa1346 100644 (file)
@@ -32,7 +32,7 @@ static int digitv_ctrl_msg(struct dvb_usb_device *d,
        sndbuf[1] = vv;
        sndbuf[2] = wo ? wlen : rlen;
 
-       if (!wo) {
+       if (wo) {
                memcpy(&sndbuf[3],wbuf,wlen);
                dvb_usb_generic_write(d,sndbuf,7);
        } else {
@@ -111,31 +111,28 @@ static int digitv_mt352_demod_init(struct dvb_frontend *fe)
 }
 
 static struct mt352_config digitv_mt352_config = {
-       .demod_address = 0x0, /* ignored by the digitv anyway */
        .demod_init = digitv_mt352_demod_init,
        .pll_set = dvb_usb_pll_set,
 };
 
-static struct nxt6000_config digitv_nxt6000_config = {
-       .demod_address = 0x0, /* ignored by the digitv anyway */
-       .clock_inversion = 0x0,
+static int digitv_nxt6000_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep)
+{
+       struct dvb_usb_device *d = fe->dvb->priv;
+       u8 b[5];
+       dvb_usb_pll_set(fe,fep,b);
+       return digitv_ctrl_msg(d,USB_WRITE_TUNER,0,&b[1],4,NULL,0);
+}
 
-       .pll_init = NULL,
-       .pll_set = NULL,
+static struct nxt6000_config digitv_nxt6000_config = {
+       .clock_inversion = 1,
+       .pll_set = digitv_nxt6000_pll_set,
 };
 
 static int digitv_frontend_attach(struct dvb_usb_device *d)
 {
-       if ((d->fe = mt352_attach(&digitv_mt352_config, &d->i2c_adap)) != NULL)
-               return 0;
-       if ((d->fe = nxt6000_attach(&digitv_nxt6000_config, &d->i2c_adap)) != NULL) {
-
-               warn("nxt6000 support is not done yet, in fact you are one of the first "
-                               "person who wants to use this device in Linux. Please report to "
-                               "linux-dvb@linuxtv.org");
-
+       if ((d->fe = mt352_attach(&digitv_mt352_config, &d->i2c_adap)) != NULL ||
+               (d->fe = nxt6000_attach(&digitv_nxt6000_config, &d->i2c_adap)) != NULL)
                return 0;
-       }
        return -EIO;
 }
 
@@ -151,7 +148,7 @@ static struct dvb_usb_rc_key digitv_rc_keys[] = {
 };
 
 /* TODO is it really the NEC protocol ? */
-int digitv_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
+static int digitv_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
 {
        u8 key[5];
 
@@ -173,7 +170,20 @@ static struct dvb_usb_properties digitv_properties;
 static int digitv_probe(struct usb_interface *intf,
                const struct usb_device_id *id)
 {
-       return dvb_usb_device_init(intf,&digitv_properties,THIS_MODULE);
+       struct dvb_usb_device *d;
+       int ret;
+       if ((ret = dvb_usb_device_init(intf,&digitv_properties,THIS_MODULE,&d)) == 0) {
+               u8 b[4] = { 0 };
+
+               if (d != NULL) { /* do that only when the firmware is loaded */
+                       b[0] = 1;
+                       digitv_ctrl_msg(d,USB_WRITE_REMOTE_TYPE,0,b,4,NULL,0);
+
+                       b[0] = 0;
+                       digitv_ctrl_msg(d,USB_WRITE_REMOTE,0,b,4,NULL,0);
+               }
+       }
+       return ret;
 }
 
 static struct usb_device_id digitv_table [] = {
@@ -186,7 +196,7 @@ static struct dvb_usb_properties digitv_properties = {
        .caps = DVB_USB_IS_AN_I2C_ADAPTER,
 
        .usb_ctrl = CYPRESS_FX2,
-       .firmware = "dvb-usb-digitv-01.fw",
+       .firmware = "dvb-usb-digitv-02.fw",
 
        .size_of_priv     = 0,
 
@@ -221,11 +231,11 @@ static struct dvb_usb_properties digitv_properties = {
                        { &digitv_table[0], NULL },
                        { NULL },
                },
+               { NULL },
        }
 };
 
 static struct usb_driver digitv_driver = {
-       .owner          = THIS_MODULE,
        .name           = "dvb_usb_digitv",
        .probe          = digitv_probe,
        .disconnect = dvb_usb_device_exit,