V4L/DVB (4650): Misc fixes for dib0700 download
[pandora-kernel.git] / drivers / media / dvb / dvb-usb / dib0700_core.c
index 1f444a4..a1a8165 100644 (file)
@@ -26,7 +26,7 @@ static int dib0700_ctrl_wr(struct dvb_usb_device *d, u8 *tx, u8 txlen)
                USB_CTRL_GET_TIMEOUT);
 
        if (status != txlen)
-               err("ep 0 write error (status = %d, len: %d)",status,txlen);
+               deb_data("ep 0 write error (status = %d, len: %d)\n",status,txlen);
 
        return status < 0 ? status : 0;
 }
@@ -65,7 +65,7 @@ static int dib0700_ctrl_rd(struct dvb_usb_device *d, u8 *tx, u8 txlen, u8 *rx, u
                        USB_CTRL_GET_TIMEOUT);
 
        if (status < 0)
-               err("ep 0 read error (status = %d)",status);
+               deb_info("ep 0 read error (status = %d)\n",status);
 
        deb_data("<<< ");
        debug_dump(rx,rxlen,deb_data);
@@ -130,6 +130,17 @@ struct i2c_algorithm dib0700_i2c_algo = {
        .functionality = dib0700_i2c_func,
 };
 
+int dib0700_identify_state(struct usb_device *udev, struct dvb_usb_device_properties *props,
+                       struct dvb_usb_device_description **desc, int *cold)
+{
+       u8 buf[3] = { REQUEST_SET_GPIO, 4, (GPIO_IN << 7) | (0 << 6) }; // GPIO4 is save - used for I2C
+       *cold = usb_control_msg(udev, usb_sndctrlpipe(udev,0),
+               buf[0], USB_TYPE_VENDOR | USB_DIR_OUT, 0, 0, buf, 3, USB_CTRL_GET_TIMEOUT) != 3;
+
+       deb_info("cold: %d\n", *cold);
+       return 0;
+}
+
 static int dib0700_jumpram(struct usb_device *udev, u32 address)
 {
        int ret, actlen;
@@ -158,11 +169,11 @@ int dib0700_download_firmware(struct usb_device *udev, const struct firmware *fw
        u8 buf[260];
 
        while ((ret = dvb_usb_get_hexline(fw, &hx, &pos)) > 0) {
-               deb_fwdata("writing to address 0x%04x (buffer: 0x%02x %02x)\n",hx.addr, hx.len, hx.chk);
+               deb_fwdata("writing to address 0x%08x (buffer: 0x%02x %02x)\n",hx.addr, hx.len, hx.chk);
 
                buf[0] = hx.len;
-               buf[1] = hx.addr >> 8;
-               buf[2] = hx.addr & 0xff;
+               buf[1] = (hx.addr >> 8) & 0xff;
+               buf[2] =  hx.addr       & 0xff;
                buf[3] = hx.type;
                memcpy(&buf[4],hx.data,hx.len);
                buf[4+hx.len] = hx.chk;
@@ -182,8 +193,10 @@ int dib0700_download_firmware(struct usb_device *udev, const struct firmware *fw
 
        if (ret == 0) {
                /* start the firmware */
-               if ((ret = dib0700_jumpram(udev,0x70000000)) == 0)
+               if ((ret = dib0700_jumpram(udev, 0x70000000)) == 0) {
                        info("firmware started successfully.");
+                       msleep(100);
+               }
        } else
                ret = -EIO;