V4L/DVB (3198): make cx25840 recover from some firmware load failures
authorTyler Trafford <tatrafford@comcast.net>
Mon, 9 Jan 2006 17:25:29 +0000 (15:25 -0200)
committerMauro Carvalho Chehab <mchehab@brturbo.com.br>
Mon, 9 Jan 2006 17:25:29 +0000 (15:25 -0200)
- In the rare event that a 333MHz i2c firmware load fails after
writing some data, this fix makes the driver reset the DL_ADDR
registers to the proper values before continuing on with 100MHz
transfers.

Signed-off-by: Tyler Trafford <tatrafford@comcast.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@brturbo.com.br>
drivers/media/video/cx25840/cx25840-firmware.c

index df9d50a75542461c22ee79535ed84d63196bc95a..f43024f2aaef0b085a6661fdf3d097a43d7befd6 100644 (file)
@@ -15,7 +15,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 
-
 #include <linux/module.h>
 #include <linux/i2c.h>
 #include <linux/i2c-algo-bit.h>
@@ -94,13 +93,23 @@ static inline int check_fw_load(struct i2c_client *client, int size)
 
 static inline int fw_write(struct i2c_client *client, u8 * data, int size)
 {
-       if (i2c_master_send(client, data, size) < size) {
+       int sent;
+
+       if ((sent = i2c_master_send(client, data, size)) < size) {
 
                if (fastfw) {
                        cx25840_err("333MHz i2c firmware load failed\n");
                        fastfw = 0;
                        set_i2c_delay(client, 10);
 
+                       if (sent > 2) {
+                               u16 dl_addr = cx25840_read(client, 0x801) << 8;
+                               dl_addr |= cx25840_read(client, 0x800);
+                               dl_addr -= sent - 2;
+                               cx25840_write(client, 0x801, dl_addr >> 8);
+                               cx25840_write(client, 0x800, dl_addr & 0xff);
+                       }
+
                        if (i2c_master_send(client, data, size) < size) {
                                cx25840_err
                                    ("100MHz i2c firmware load failed\n");