* [PATCH] media: af9035 I2C combined write + read transaction fix
@ 2016-04-05 22:23 Alessandro Radicati
2016-06-01 7:04 ` Antti Palosaari
0 siblings, 1 reply; 2+ messages in thread
From: Alessandro Radicati @ 2016-04-05 22:23 UTC (permalink / raw)
To: crope; +Cc: linux-media
This patch will modify the af9035 driver to use the register address
fields of the I2C read command for the combined write/read transaction
case. Without this change, the firmware issues just a I2C read transaction
without the preceding write transaction to select the register.
Signed-off-by: Alessandro Radicati <alessandro@radicati.net>
---
drivers/media/usb/dvb-usb-v2/af9035.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c b/drivers/media/usb/dvb-usb-v2/af9035.c
index 2638e32..09a549b 100644
--- a/drivers/media/usb/dvb-usb-v2/af9035.c
+++ b/drivers/media/usb/dvb-usb-v2/af9035.c
@@ -367,10 +367,25 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap,
memcpy(&buf[3], msg[0].buf, msg[0].len);
} else {
buf[1] = msg[0].addr << 1;
- buf[2] = 0x00; /* reg addr len */
buf[3] = 0x00; /* reg addr MSB */
buf[4] = 0x00; /* reg addr LSB */
- memcpy(&buf[5], msg[0].buf, msg[0].len);
+
+ /* Keep prev behavior for write req len > 2*/
+ if (msg[0].len > 2) {
+ buf[2] = 0x00; /* reg addr len */
+ memcpy(&buf[5], msg[0].buf, msg[0].len);
+
+ /* Use reg addr fields if write req len <= 2 */
+ } else {
+ req.wlen = 5;
+ buf[2] = msg[0].len;
+ if (msg[0].len == 2) {
+ buf[3] = msg[0].buf[0];
+ buf[4] = msg[0].buf[1];
+ } else if (msg[0].len == 1) {
+ buf[4] = msg[0].buf[0];
+ }
+ }
}
ret = af9035_ctrl_msg(d, &req);
}
--
2.5.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] media: af9035 I2C combined write + read transaction fix
2016-04-05 22:23 [PATCH] media: af9035 I2C combined write + read transaction fix Alessandro Radicati
@ 2016-06-01 7:04 ` Antti Palosaari
0 siblings, 0 replies; 2+ messages in thread
From: Antti Palosaari @ 2016-06-01 7:04 UTC (permalink / raw)
To: Alessandro Radicati; +Cc: linux-media
Applied for 4.8, thanks!
Antti
On 04/06/2016 01:23 AM, Alessandro Radicati wrote:
> This patch will modify the af9035 driver to use the register address
> fields of the I2C read command for the combined write/read transaction
> case. Without this change, the firmware issues just a I2C read transaction
> without the preceding write transaction to select the register.
>
> Signed-off-by: Alessandro Radicati <alessandro@radicati.net>
> ---
> drivers/media/usb/dvb-usb-v2/af9035.c | 19 +++++++++++++++++--
> 1 file changed, 17 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c b/drivers/media/usb/dvb-usb-v2/af9035.c
> index 2638e32..09a549b 100644
> --- a/drivers/media/usb/dvb-usb-v2/af9035.c
> +++ b/drivers/media/usb/dvb-usb-v2/af9035.c
> @@ -367,10 +367,25 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap,
> memcpy(&buf[3], msg[0].buf, msg[0].len);
> } else {
> buf[1] = msg[0].addr << 1;
> - buf[2] = 0x00; /* reg addr len */
> buf[3] = 0x00; /* reg addr MSB */
> buf[4] = 0x00; /* reg addr LSB */
> - memcpy(&buf[5], msg[0].buf, msg[0].len);
> +
> + /* Keep prev behavior for write req len > 2*/
> + if (msg[0].len > 2) {
> + buf[2] = 0x00; /* reg addr len */
> + memcpy(&buf[5], msg[0].buf, msg[0].len);
> +
> + /* Use reg addr fields if write req len <= 2 */
> + } else {
> + req.wlen = 5;
> + buf[2] = msg[0].len;
> + if (msg[0].len == 2) {
> + buf[3] = msg[0].buf[0];
> + buf[4] = msg[0].buf[1];
> + } else if (msg[0].len == 1) {
> + buf[4] = msg[0].buf[0];
> + }
> + }
> }
> ret = af9035_ctrl_msg(d, &req);
> }
>
--
http://palosaari.fi/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-06-01 7:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-05 22:23 [PATCH] media: af9035 I2C combined write + read transaction fix Alessandro Radicati
2016-06-01 7:04 ` Antti Palosaari
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).