Re: [PATCH] xc5000, rework xc_write_reg
Em 24-05-2010 22:49, Dmitri Belimov escreveu: Hi Devin On Tue, May 18, 2010 at 3:30 AM, Dmitri Belimov d.beli...@gmail.com wrote: Hi Rework xc_write_reg function for correct read register of the xc5000. It is very useful for tm6000. Tested for tm6000 and for saa7134 works well. Hi Dmitri, I've put this on my list of patches to review. My concern is that the xc_wait logic is pretty nasty since it's related to timing of the bus (it took several weeks as well as a dozen emails with the people at Xceive), and hence I am loathed to change it since it took quite a bit of time to test against all the different cards that use xc5000 (and in some cases there were bugs exposed in various bridge's i2c implementations). That said, I think I actually did attempt to implement a patch comparable to what you did here, but I backed it out for some reason. I will need to review my trees and my notes to see what the rationale was for doing such. Ok. I can test your solution on our hardware. XC5000+SAA7134 XC5000+TM6010 Devin/Dmitri, Any progress about this patch? Cheers, Mauro -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] xc5000, rework xc_write_reg
On Mon, Jul 5, 2010 at 12:11 PM, Mauro Carvalho Chehab mche...@redhat.com wrote: Devin/Dmitri, Any progress about this patch? Cheers, Mauro Sorry for the delay. I did some testing with it today, and it looks fine. Acked-by: Devin Heitmueller dheitmuel...@kernellabs.com Thanks, Devin -- Devin J. Heitmueller - Kernel Labs http://www.kernellabs.com -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] xc5000, rework xc_write_reg
Hi Devin On Tue, May 18, 2010 at 3:30 AM, Dmitri Belimov d.beli...@gmail.com wrote: Hi Rework xc_write_reg function for correct read register of the xc5000. It is very useful for tm6000. Tested for tm6000 and for saa7134 works well. Hi Dmitri, I've put this on my list of patches to review. My concern is that the xc_wait logic is pretty nasty since it's related to timing of the bus (it took several weeks as well as a dozen emails with the people at Xceive), and hence I am loathed to change it since it took quite a bit of time to test against all the different cards that use xc5000 (and in some cases there were bugs exposed in various bridge's i2c implementations). That said, I think I actually did attempt to implement a patch comparable to what you did here, but I backed it out for some reason. I will need to review my trees and my notes to see what the rationale was for doing such. Ok. I can test your solution on our hardware. XC5000+SAA7134 XC5000+TM6010 With my best regards, Dmitry. Devin -- Devin J. Heitmueller - Kernel Labs http://www.kernellabs.com -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] xc5000, rework xc_write_reg
On Tue, May 18, 2010 at 3:30 AM, Dmitri Belimov d.beli...@gmail.com wrote: Hi Rework xc_write_reg function for correct read register of the xc5000. It is very useful for tm6000. Tested for tm6000 and for saa7134 works well. Hi Dmitri, I've put this on my list of patches to review. My concern is that the xc_wait logic is pretty nasty since it's related to timing of the bus (it took several weeks as well as a dozen emails with the people at Xceive), and hence I am loathed to change it since it took quite a bit of time to test against all the different cards that use xc5000 (and in some cases there were bugs exposed in various bridge's i2c implementations). That said, I think I actually did attempt to implement a patch comparable to what you did here, but I backed it out for some reason. I will need to review my trees and my notes to see what the rationale was for doing such. Devin -- Devin J. Heitmueller - Kernel Labs http://www.kernellabs.com -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] xc5000, rework xc_write_reg
Hi Rework xc_write_reg function for correct read register of the xc5000. It is very useful for tm6000. Tested for tm6000 and for saa7134 works well. diff -r 8f5129efe974 linux/drivers/media/common/tuners/xc5000.c --- a/linux/drivers/media/common/tuners/xc5000.cSun May 16 18:48:01 2010 -0300 +++ b/linux/drivers/media/common/tuners/xc5000.cTue May 18 11:14:55 2010 +1000 @@ -232,6 +232,26 @@ return 0; } +static int xc5000_readreg(struct xc5000_priv *priv, u16 reg, u16 *val) +{ + u8 buf[2] = { reg 8, reg 0xff }; + u8 bval[2] = { 0, 0 }; + struct i2c_msg msg[2] = { + { .addr = priv-i2c_props.addr, + .flags = 0, .buf = buf[0], .len = 2 }, + { .addr = priv-i2c_props.addr, + .flags = I2C_M_RD, .buf = bval[0], .len = 2 }, + }; + + if (i2c_transfer(priv-i2c_props.adap, msg, 2) != 2) { + printk(KERN_WARNING xc5000: I2C read failed\n); + return -EREMOTEIO; + } + + *val = (bval[0] 8) | bval[1]; + return XC_RESULT_SUCCESS; +} + static void xc_wait(int wait_ms) { msleep(wait_ms); @@ -275,20 +295,14 @@ if (result == XC_RESULT_SUCCESS) { /* wait for busy flag to clear */ while ((WatchDogTimer 0) (result == XC_RESULT_SUCCESS)) { - buf[0] = 0; - buf[1] = XREG_BUSY; - - result = xc_send_i2c_data(priv, buf, 2); + result = xc5000_readreg(priv, XREG_BUSY, buf); if (result == XC_RESULT_SUCCESS) { - result = xc_read_i2c_data(priv, buf, 2); - if (result == XC_RESULT_SUCCESS) { - if ((buf[0] == 0) (buf[1] == 0)) { - /* busy flag cleared */ + if ((buf[0] == 0) (buf[1] == 0)) { + /* busy flag cleared */ break; - } else { - xc_wait(5); /* wait 5 ms */ - WatchDogTimer--; - } + } else { + xc_wait(5); /* wait 5 ms */ + WatchDogTimer--; } } } @@ -534,25 +548,6 @@ return found; } -static int xc5000_readreg(struct xc5000_priv *priv, u16 reg, u16 *val) -{ - u8 buf[2] = { reg 8, reg 0xff }; - u8 bval[2] = { 0, 0 }; - struct i2c_msg msg[2] = { - { .addr = priv-i2c_props.addr, - .flags = 0, .buf = buf[0], .len = 2 }, - { .addr = priv-i2c_props.addr, - .flags = I2C_M_RD, .buf = bval[0], .len = 2 }, - }; - - if (i2c_transfer(priv-i2c_props.adap, msg, 2) != 2) { - printk(KERN_WARNING xc5000: I2C read failed\n); - return -EREMOTEIO; - } - - *val = (bval[0] 8) | bval[1]; - return XC_RESULT_SUCCESS; -} static int xc5000_fwupload(struct dvb_frontend *fe) { Signed-off-by: Beholder Intl. Ltd. Dmitry Belimov d.beli...@gmail.com With my best regards, Dmitry. diff -r 8f5129efe974 linux/drivers/media/common/tuners/xc5000.c --- a/linux/drivers/media/common/tuners/xc5000.c Sun May 16 18:48:01 2010 -0300 +++ b/linux/drivers/media/common/tuners/xc5000.c Tue May 18 11:14:55 2010 +1000 @@ -232,6 +232,26 @@ return 0; } +static int xc5000_readreg(struct xc5000_priv *priv, u16 reg, u16 *val) +{ + u8 buf[2] = { reg 8, reg 0xff }; + u8 bval[2] = { 0, 0 }; + struct i2c_msg msg[2] = { + { .addr = priv-i2c_props.addr, + .flags = 0, .buf = buf[0], .len = 2 }, + { .addr = priv-i2c_props.addr, + .flags = I2C_M_RD, .buf = bval[0], .len = 2 }, + }; + + if (i2c_transfer(priv-i2c_props.adap, msg, 2) != 2) { + printk(KERN_WARNING xc5000: I2C read failed\n); + return -EREMOTEIO; + } + + *val = (bval[0] 8) | bval[1]; + return XC_RESULT_SUCCESS; +} + static void xc_wait(int wait_ms) { msleep(wait_ms); @@ -275,20 +295,14 @@ if (result == XC_RESULT_SUCCESS) { /* wait for busy flag to clear */ while ((WatchDogTimer 0) (result == XC_RESULT_SUCCESS)) { - buf[0] = 0; - buf[1] = XREG_BUSY; - - result = xc_send_i2c_data(priv, buf, 2); + result = xc5000_readreg(priv, XREG_BUSY, buf); if (result == XC_RESULT_SUCCESS) { -result = xc_read_i2c_data(priv, buf, 2); -if (result == XC_RESULT_SUCCESS) { - if ((buf[0] == 0) (buf[1] == 0)) { - /* busy flag cleared */ +if ((buf[0] == 0) (buf[1] == 0)) { + /* busy flag cleared */ break; - } else { - xc_wait(5); /* wait 5 ms */ - WatchDogTimer--; - } +} else { +