diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-07-23 08:51:12 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-01-21 10:44:44 -0500 |
commit | d20a7f7277785e6f7fbe02eb469f7a99a9f058a4 (patch) | |
tree | 4d7b76b706b61f0efb28429d9348a57b268bfd29 /drivers/media/dvb/dvb-usb/az6007.c | |
parent | caa1a700ed2a06a831e6a7db5d9f213fc63caee3 (diff) |
[media] az6007: Fix the I2C code in order to handle mt2063
mt2063 uses a one-byte transfer. This requires a special handling
inside the i2c code. Fix it to properly accept i2c reads. This
is needed to make the mt2063 to be detected.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb/dvb-usb/az6007.c')
-rw-r--r-- | drivers/media/dvb/dvb-usb/az6007.c | 47 |
1 files changed, 30 insertions, 17 deletions
diff --git a/drivers/media/dvb/dvb-usb/az6007.c b/drivers/media/dvb/dvb-usb/az6007.c index 6a21f928550a..56126d41a604 100644 --- a/drivers/media/dvb/dvb-usb/az6007.c +++ b/drivers/media/dvb/dvb-usb/az6007.c | |||
@@ -42,7 +42,7 @@ struct az6007_device_state { | |||
42 | struct drxk_config terratec_h7_drxk = { | 42 | struct drxk_config terratec_h7_drxk = { |
43 | .adr = 0x29, | 43 | .adr = 0x29, |
44 | .single_master = 1, | 44 | .single_master = 1, |
45 | .no_i2c_bridge = 1, | 45 | .no_i2c_bridge = 0, |
46 | .microcode_name = "dvb-usb-terratec-h5-drxk.fw", | 46 | .microcode_name = "dvb-usb-terratec-h5-drxk.fw", |
47 | }; | 47 | }; |
48 | 48 | ||
@@ -451,7 +451,6 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msgs[],int nu | |||
451 | 451 | ||
452 | for (i = 0; i < num; i++) { | 452 | for (i = 0; i < num; i++) { |
453 | addr = msgs[i].addr << 1; | 453 | addr = msgs[i].addr << 1; |
454 | |||
455 | if (((i + 1) < num) | 454 | if (((i + 1) < num) |
456 | && (msgs[i].len == 1) | 455 | && (msgs[i].len == 1) |
457 | && (!msgs[i].flags & I2C_M_RD) | 456 | && (!msgs[i].flags & I2C_M_RD) |
@@ -462,44 +461,55 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msgs[],int nu | |||
462 | * the first xfer has just 1 byte length. | 461 | * the first xfer has just 1 byte length. |
463 | * Need to join both into one operation | 462 | * Need to join both into one operation |
464 | */ | 463 | */ |
465 | printk("az6007 I2C xfer write+read addr=0x%x len=%d/%d: ", | 464 | if (dvb_usb_az6007_debug & 2) |
466 | addr, msgs[i].len, msgs[i + 1].len); | 465 | printk(KERN_DEBUG |
466 | "az6007 I2C xfer write+read addr=0x%x len=%d/%d: ", | ||
467 | addr, msgs[i].len, msgs[i + 1].len); | ||
467 | req = 0xb9; | 468 | req = 0xb9; |
468 | index = 0; | 469 | index = msgs[i].buf[0]; |
469 | value = addr; | 470 | value = addr | (1 << 8); |
470 | for (j = 0; j < msgs[i].len; j++) | ||
471 | data[j] = msgs[i].buf[j]; | ||
472 | length = 6 + msgs[i + 1].len; | 471 | length = 6 + msgs[i + 1].len; |
473 | len = msgs[i + 1].len; | 472 | len = msgs[i + 1].len; |
474 | ret = az6007_usb_in_op(d,req,value,index,data,length); | 473 | ret = az6007_usb_in_op(d,req,value,index,data,length); |
475 | if (ret >= len) { | 474 | if (ret >= len) { |
476 | for (j = 0; j < len; j++) { | 475 | for (j = 0; j < len; j++) { |
477 | msgs[i + 1].buf[j] = data[j + 5]; | 476 | msgs[i + 1].buf[j] = data[j + 5]; |
478 | printk("0x%02x ", msgs[i + 1].buf[j]); | 477 | if (dvb_usb_az6007_debug & 2) |
478 | printk(KERN_CONT | ||
479 | "0x%02x ", | ||
480 | msgs[i + 1].buf[j]); | ||
479 | } | 481 | } |
480 | } else | 482 | } else |
481 | ret = -EIO; | 483 | ret = -EIO; |
482 | i++; | 484 | i++; |
483 | } else if (!(msgs[i].flags & I2C_M_RD)) { | 485 | } else if (!(msgs[i].flags & I2C_M_RD)) { |
484 | /* write bytes */ | 486 | /* write bytes */ |
485 | // printk("az6007 I2C xfer write addr=0x%x len=%d: ", | 487 | if (dvb_usb_az6007_debug & 2) |
486 | // addr, msgs[i].len); | 488 | printk(KERN_DEBUG |
489 | "az6007 I2C xfer write addr=0x%x len=%d: ", | ||
490 | addr, msgs[i].len); | ||
487 | req = 0xbd; | 491 | req = 0xbd; |
488 | index = msgs[i].buf[0]; | 492 | index = msgs[i].buf[0]; |
489 | value = addr | (1 << 8); | 493 | value = addr | (1 << 8); |
490 | length = msgs[i].len - 1; | 494 | length = msgs[i].len - 1; |
491 | len = msgs[i].len - 1; | 495 | len = msgs[i].len - 1; |
492 | // printk("(0x%02x) ", msgs[i].buf[0]); | 496 | if (dvb_usb_az6007_debug & 2) |
497 | printk(KERN_CONT | ||
498 | "(0x%02x) ", msgs[i].buf[0]); | ||
493 | for (j = 0; j < len; j++) | 499 | for (j = 0; j < len; j++) |
494 | { | 500 | { |
495 | data[j] = msgs[i].buf[j + 1]; | 501 | data[j] = msgs[i].buf[j + 1]; |
496 | // printk("0x%02x ", data[j]); | 502 | if (dvb_usb_az6007_debug & 2) |
503 | printk(KERN_CONT | ||
504 | "0x%02x ", data[j]); | ||
497 | } | 505 | } |
498 | ret = az6007_usb_out_op(d,req,value,index,data,length); | 506 | ret = az6007_usb_out_op(d,req,value,index,data,length); |
499 | } else { | 507 | } else { |
500 | /* read bytes */ | 508 | /* read bytes */ |
501 | // printk("az6007 I2C xfer read addr=0x%x len=%d: ", | 509 | if (dvb_usb_az6007_debug & 2) |
502 | // addr, msgs[i].len); | 510 | printk(KERN_DEBUG |
511 | "az6007 I2C xfer read addr=0x%x len=%d: ", | ||
512 | addr, msgs[i].len); | ||
503 | req = 0xb9; | 513 | req = 0xb9; |
504 | index = msgs[i].buf[0]; | 514 | index = msgs[i].buf[0]; |
505 | value = addr; | 515 | value = addr; |
@@ -509,10 +519,13 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msgs[],int nu | |||
509 | for (j = 0; j < len; j++) | 519 | for (j = 0; j < len; j++) |
510 | { | 520 | { |
511 | msgs[i].buf[j] = data[j + 5]; | 521 | msgs[i].buf[j] = data[j + 5]; |
512 | // printk("0x%02x ", data[j + 5]); | 522 | if (dvb_usb_az6007_debug & 2) |
523 | printk(KERN_CONT | ||
524 | "0x%02x ", data[j + 5]); | ||
513 | } | 525 | } |
514 | } | 526 | } |
515 | // printk("\n"); | 527 | if (dvb_usb_az6007_debug & 2) |
528 | printk(KERN_CONT "\n"); | ||
516 | if (ret < 0) | 529 | if (ret < 0) |
517 | goto err; | 530 | goto err; |
518 | } | 531 | } |