From: tskd08@gmail.com
To: linux-media@vger.kernel.org
Cc: crope@iki.fi, sean@mess.org, mchehab@kernel.org,
Akihiro Tsukada <tskd08@gmail.com>
Subject: [PATCH v2 3/4] dvb-frontends/tc90522: extend i2c algo to support some devices
Date: Thu, 29 Aug 2019 17:38:21 +0900 [thread overview]
Message-ID: <20190829083822.3670-4-tskd08@gmail.com> (raw)
In-Reply-To: <20190829083822.3670-1-tskd08@gmail.com>
From: Akihiro Tsukada <tskd08@gmail.com>
This demod implements an i2c adapter for attached tuner
and relays i2c messages from users (dvb adapters / bridge chips).
Some of them, such as Friio dvb card using gl861,
require each pair of i2c messages for one read to be issued as
two separate transactions.
This patch adds a configuration option to enable this split.
Signed-off-by: Akihiro Tsukada <tskd08@gmail.com>
---
drivers/media/dvb-frontends/tc90522.c | 25 ++++++++++++++++++++++++-
drivers/media/dvb-frontends/tc90522.h | 3 +++
2 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/drivers/media/dvb-frontends/tc90522.c b/drivers/media/dvb-frontends/tc90522.c
index 849d63dbc27..4c61b977466 100644
--- a/drivers/media/dvb-frontends/tc90522.c
+++ b/drivers/media/dvb-frontends/tc90522.c
@@ -687,8 +687,31 @@ tc90522_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
if (i < num)
ret = -ENOMEM;
- else
+ else if (!state->cfg.split_tuner_read_i2c || rd_num == 0)
ret = i2c_transfer(state->i2c_client->adapter, new_msgs, j);
+ else {
+ /*
+ * Split transactions at each I2C_M_RD message.
+ * Some of the parent device require this,
+ * such as Friio (see. dvb-usb-gl861).
+ */
+ int from, to;
+
+ ret = 0;
+ from = 0;
+ do {
+ int r;
+
+ to = from + 1;
+ while (to < j && !(new_msgs[to].flags & I2C_M_RD))
+ to++;
+ r = i2c_transfer(state->i2c_client->adapter,
+ &new_msgs[from], to - from);
+ ret = (r <= 0) ? r : ret + r;
+ from = to;
+ } while (from < j && ret > 0);
+ }
+
if (ret >= 0 && ret < j)
ret = -EIO;
kfree(new_msgs);
diff --git a/drivers/media/dvb-frontends/tc90522.h b/drivers/media/dvb-frontends/tc90522.h
index ac0e2ab5192..07e3813bf59 100644
--- a/drivers/media/dvb-frontends/tc90522.h
+++ b/drivers/media/dvb-frontends/tc90522.h
@@ -28,6 +28,9 @@ struct tc90522_config {
/* [OUT] tuner I2C adapter returned by driver */
struct i2c_adapter *tuner_i2c;
+
+ /* [IN] use two separate I2C transactions for one tuner read */
+ bool split_tuner_read_i2c;
};
#endif /* TC90522_H */
--
2.23.0
next prev parent reply other threads:[~2019-08-29 8:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-29 8:38 [PATCH v2 0/4] dvb-usb-gl861, tc90522: remove device-specific i2c algo tskd08
2019-08-29 8:38 ` [PATCH v2 1/4] dvb-usb-v2/gl861: " tskd08
2019-08-29 8:38 ` [PATCH v2 2/4] dvb-usb-v2/gl861: remove an un-used header file tskd08
2019-08-29 8:38 ` tskd08 [this message]
2019-08-29 8:38 ` [PATCH v2 4/4] dvb-usb-gl861: support I2C read from tuner via demod tskd08
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=20190829083822.3670-4-tskd08@gmail.com \
--to=tskd08@gmail.com \
--cc=crope@iki.fi \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=sean@mess.org \
/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;
as well as URLs for NNTP newsgroup(s).