aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb
diff options
context:
space:
mode:
authorOlivier Grenie <olivier.grenie@dibcom.fr>2011-01-03 13:30:14 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-03-21 19:31:41 -0400
commit7757ddda6f4febbc52342d82440dd4f7a7d4f14f (patch)
tree4245ad7c6e4e30089c793466dd72db9a0ade7188 /drivers/media/dvb
parentf8e2e3eab8f70103fb4680e2da202e14199c199a (diff)
[media] DiB0700: add function to change I2C-speed
This commit adds a function to the DiB0700 USB driver which allows drivers to change the I2C clock speed. Signed-off-by: Olivier Grenie <olivier.grenie@dibcom.fr> Signed-off-by: Patrick Boettcher <patrick.boettcher@dibcom.fr> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb')
-rw-r--r--drivers/media/dvb/dvb-usb/dib0700.h2
-rw-r--r--drivers/media/dvb/dvb-usb/dib0700_core.c42
2 files changed, 40 insertions, 4 deletions
diff --git a/drivers/media/dvb/dvb-usb/dib0700.h b/drivers/media/dvb/dvb-usb/dib0700.h
index 3537d65c04bc..b2a87f2c2c3e 100644
--- a/drivers/media/dvb/dvb-usb/dib0700.h
+++ b/drivers/media/dvb/dvb-usb/dib0700.h
@@ -32,6 +32,7 @@ extern int dvb_usb_dib0700_debug;
32 // 1 Byte: 4MSB(1 = enable streaming, 0 = disable streaming) 4LSB(Video Mode: 0 = MPEG2 188Bytes, 1 = Analog) 32 // 1 Byte: 4MSB(1 = enable streaming, 0 = disable streaming) 4LSB(Video Mode: 0 = MPEG2 188Bytes, 1 = Analog)
33 // 2 Byte: MPEG2 mode: 4MSB(1 = Master Mode, 0 = Slave Mode) 4LSB(Channel 1 = bit0, Channel 2 = bit1) 33 // 2 Byte: MPEG2 mode: 4MSB(1 = Master Mode, 0 = Slave Mode) 4LSB(Channel 1 = bit0, Channel 2 = bit1)
34 // 2 Byte: Analog mode: 4MSB(0 = 625 lines, 1 = 525 lines) 4LSB( " " ) 34 // 2 Byte: Analog mode: 4MSB(0 = 625 lines, 1 = 525 lines) 4LSB( " " )
35#define REQUEST_SET_I2C_PARAM 0x10
35#define REQUEST_SET_RC 0x11 36#define REQUEST_SET_RC 0x11
36#define REQUEST_NEW_I2C_READ 0x12 37#define REQUEST_NEW_I2C_READ 0x12
37#define REQUEST_NEW_I2C_WRITE 0x13 38#define REQUEST_NEW_I2C_WRITE 0x13
@@ -61,6 +62,7 @@ extern struct i2c_algorithm dib0700_i2c_algo;
61extern int dib0700_identify_state(struct usb_device *udev, struct dvb_usb_device_properties *props, 62extern int dib0700_identify_state(struct usb_device *udev, struct dvb_usb_device_properties *props,
62 struct dvb_usb_device_description **desc, int *cold); 63 struct dvb_usb_device_description **desc, int *cold);
63extern int dib0700_change_protocol(struct rc_dev *dev, u64 rc_type); 64extern int dib0700_change_protocol(struct rc_dev *dev, u64 rc_type);
65extern int dib0700_set_i2c_speed(struct dvb_usb_device *d, u16 scl_kHz);
64 66
65extern int dib0700_device_count; 67extern int dib0700_device_count;
66extern int dvb_usb_dib0700_ir_proto; 68extern int dvb_usb_dib0700_ir_proto;
diff --git a/drivers/media/dvb/dvb-usb/dib0700_core.c b/drivers/media/dvb/dvb-usb/dib0700_core.c
index 98ffb40728e3..ebda77dde97e 100644
--- a/drivers/media/dvb/dvb-usb/dib0700_core.c
+++ b/drivers/media/dvb/dvb-usb/dib0700_core.c
@@ -328,6 +328,30 @@ static int dib0700_set_clock(struct dvb_usb_device *d, u8 en_pll,
328 return dib0700_ctrl_wr(d, b, 10); 328 return dib0700_ctrl_wr(d, b, 10);
329} 329}
330 330
331int dib0700_set_i2c_speed(struct dvb_usb_device *d, u16 scl_kHz)
332{
333 u16 divider;
334 u8 b[8];
335
336 if (scl_kHz == 0)
337 return -EINVAL;
338
339 b[0] = REQUEST_SET_I2C_PARAM;
340 divider = (u16) (30000 / scl_kHz);
341 b[2] = (u8) (divider >> 8);
342 b[3] = (u8) (divider & 0xff);
343 divider = (u16) (72000 / scl_kHz);
344 b[4] = (u8) (divider >> 8);
345 b[5] = (u8) (divider & 0xff);
346 divider = (u16) (72000 / scl_kHz); /* clock: 72MHz */
347 b[6] = (u8) (divider >> 8);
348 b[7] = (u8) (divider & 0xff);
349
350 deb_info("setting I2C speed: %04x %04x %04x (%d kHz).", (b[2] << 8) | (b[3]), (b[4] << 8) | b[5], (b[6] << 8) | b[7], scl_kHz);
351 return dib0700_ctrl_wr(d, b, 8);
352}
353
354
331int dib0700_ctrl_clock(struct dvb_usb_device *d, u32 clk_MHz, u8 clock_out_gp3) 355int dib0700_ctrl_clock(struct dvb_usb_device *d, u32 clk_MHz, u8 clock_out_gp3)
332{ 356{
333 switch (clk_MHz) { 357 switch (clk_MHz) {
@@ -459,10 +483,20 @@ int dib0700_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
459 483
460 deb_info("modifying (%d) streaming state for %d\n", onoff, adap->id); 484 deb_info("modifying (%d) streaming state for %d\n", onoff, adap->id);
461 485
462 if (onoff) 486 st->channel_state &= ~0x3;
463 st->channel_state |= 1 << adap->id; 487 if ((adap->stream.props.endpoint != 2) && (adap->stream.props.endpoint != 3)) {
464 else 488 deb_info("the endpoint number (%i) is not correct, use the adapter id instead", adap->stream.props.endpoint);
465 st->channel_state &= ~(1 << adap->id); 489 if (onoff)
490 st->channel_state |= 1 << (adap->id);
491 else
492 st->channel_state |= 1 << ~(adap->id);
493 }
494 else {
495 if (onoff)
496 st->channel_state |= 1 << (adap->stream.props.endpoint-2);
497 else
498 st->channel_state |= 1 << (3-adap->stream.props.endpoint);
499 }
466 500
467 b[2] |= st->channel_state; 501 b[2] |= st->channel_state;
468 502