Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[linux-dvb] Re: MT352 i2c register writing patch



Hi Patrick,

oops, sorry -- I misunderstood the problem, forget my other mail. Your patch looks ok.
sorry again,

Holger



Patrick Boettcher wrote:

Hi again,

I'm adding support for a new USB2.0 device to the dibusb-driver (HanfTek UMT 010).

This device is currently equipped with a MT352 demodulator, thanks to OpenSource and the help of volunteers, this frontend is already supported :).

This device uses a similar protocol to control itself as all the other dibusb-devices. The problem is, that the dibusb-protocol doesn't allow to write to more than one i2c-register within one i2c-write-process, but the mt352 is doing exactly that.

I think to put the splitting of connected mt352-writes into the dibusb driver is the wrong place. IMHO it would be better to change the i2c_write of the mt352. The attached patch does this, for me with success. I don't know if raising the number of i2c-writes would produce any problems with e.g. the airstar2 cards.

If no one is going to protest, I will commit this change along with the dibusb changes when I the device is working.

regards,
Patrick.

--
Mail: patrick.boettcher@desy.de
WWW: http://www.wi-bw.tfh-wildau.de/~pboettch/

------------------------------------------------------------------------

Index: mt352.c
===================================================================
RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/frontends/mt352.c,v
retrieving revision 1.20
diff -u -3 -p -r1.20 mt352.c
--- mt352.c 19 Nov 2004 01:11:42 -0000 1.20
+++ mt352.c 5 Jan 2005 12:20:29 -0000
@@ -58,17 +58,27 @@ static int debug;
if (debug) printk(KERN_DEBUG "mt352: " args); \
} while (0)

-int mt352_write(struct dvb_frontend* fe, u8* ibuf, int ilen)
+static int mt352_single_write(struct dvb_frontend *fe, u8 reg, u8 val)
{
struct mt352_state* state = (struct mt352_state*) fe->demodulator_priv;
+ u8 buf[2] = { reg, val };
struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0,
- .buf = ibuf, .len = ilen };
+ .buf = buf, .len = 2 };
int err = i2c_transfer(state->i2c, &msg, 1);
if (err != 1) {
- dprintk("mt352_write() failed (err = %d)!\n", err);
+ dprintk("mt352_write() to reg %x failed (err = %d)!\n", reg, err);
return err;
}
+ return 0; +}

+int mt352_write(struct dvb_frontend* fe, u8* ibuf, int ilen)
+{
+ int err,i;
+ for (i=0; i < ilen-1; i++)
+ if ((err = mt352_single_write(fe,ibuf[0]+i,ibuf[i+1]))) + return err;
+
return 0;
}






Home | Main Index | Thread Index