From: Dmitri Belimov <d.belimov@gmail.com>
To: Linux Media Mailing List <linux-media@vger.kernel.org>,
Stefan Ringel <stefan.ringel@arcor.de>,
Mauro Carvalho Chehab <mchehab@redhat.com>,
Bee Hock Goh <beehock@gmail.com>,
Devin Heitmueller <dheitmueller@kernellabs.com>
Subject: [PATCH] xc5000, rework xc_write_reg
Date: Tue, 18 May 2010 17:30:11 +1000 [thread overview]
Message-ID: <20100518173011.5d9c7f2c@glory.loctelecom.ru> (raw)
[-- Attachment #1: Type: text/plain, Size: 2524 bytes --]
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.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 {
+ 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.belimov@gmail.com>
With my best regards, Dmitry.
[-- Attachment #2: xc5000_write_read.patch --]
[-- Type: text/x-patch, Size: 2340 bytes --]
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 {
+ 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.belimov@gmail.com>
next reply other threads:[~2010-05-18 7:29 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-18 7:30 Dmitri Belimov [this message]
2010-05-24 2:38 ` [PATCH] xc5000, rework xc_write_reg Devin Heitmueller
2010-05-25 1:49 ` Dmitri Belimov
2010-07-05 16:11 ` Mauro Carvalho Chehab
2010-07-05 19:07 ` Devin Heitmueller
2010-10-06 19:52 ` xc5000 and switch RF input Dmitri Belimov
2010-10-06 12:25 ` Mauro Carvalho Chehab
2010-10-06 12:40 ` [RFC] Resource reservation for frontend - Was: " Mauro Carvalho Chehab
2010-10-07 13:00 ` Dmitri Belimov
2010-10-07 0:28 ` Mauro Carvalho Chehab
2010-10-12 18:32 ` Dmitri Belimov
2010-10-14 8:33 ` Antti Palosaari
2010-10-14 8:41 ` Devin Heitmueller
2010-10-15 15:33 ` Antti Palosaari
2010-10-13 21:30 ` [PATCH] " Dmitri Belimov
2010-10-14 0:50 ` Devin Heitmueller
2010-10-14 16:12 ` Dmitri Belimov
2010-10-14 19:27 ` hermann pitton
2010-10-26 3:31 ` [PATCH] saa7134 behold A7 and H7 Dmitri Belimov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100518173011.5d9c7f2c@glory.loctelecom.ru \
--to=d.belimov@gmail.com \
--cc=beehock@gmail.com \
--cc=dheitmueller@kernellabs.com \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@redhat.com \
--cc=stefan.ringel@arcor.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox