aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/dvb-usb
diff options
context:
space:
mode:
authorOlivier Grenie <olivier.grenie@dibcom.fr>2009-12-07 06:22:53 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-12-15 21:18:17 -0500
commitacc5c9ee393952c00eb7fab8bdd529d45226f6ed (patch)
tree7adbd3a297eba26fee5757dcc4a5c961da9b2c83 /drivers/media/dvb/dvb-usb
parent9542f502cf5a51b34d1c04c25206a8d69d4b8d0f (diff)
V4L/DVB (13586): DiB0700: Add parameter to change the buffer size
Add parameter to change the buffer size. This buffer size is specified in number of Ts packet. This parameter is stored inside the state. For firmware higher than 1.21, the xfer buffer size can be changed inside the dib0700 usb bridge the firware version is stored inside the state Signed-off-by: Patrick Boettcher <pboettcher@kernellabs.com> Signed-off-by: Olivier Grenie <olivier.grenie@dibcom.fr> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb/dvb-usb')
-rw-r--r--drivers/media/dvb/dvb-usb/dib0700.h26
-rw-r--r--drivers/media/dvb/dvb-usb/dib0700_core.c101
2 files changed, 109 insertions, 18 deletions
diff --git a/drivers/media/dvb/dvb-usb/dib0700.h b/drivers/media/dvb/dvb-usb/dib0700.h
index 8b544fe79b0d..495a90577c5f 100644
--- a/drivers/media/dvb/dvb-usb/dib0700.h
+++ b/drivers/media/dvb/dvb-usb/dib0700.h
@@ -20,20 +20,22 @@ extern int dvb_usb_dib0700_debug;
20#define deb_fwdata(args...) dprintk(dvb_usb_dib0700_debug,0x04,args) 20#define deb_fwdata(args...) dprintk(dvb_usb_dib0700_debug,0x04,args)
21#define deb_data(args...) dprintk(dvb_usb_dib0700_debug,0x08,args) 21#define deb_data(args...) dprintk(dvb_usb_dib0700_debug,0x08,args)
22 22
23#define REQUEST_I2C_READ 0x2 23#define REQUEST_SET_USB_XFER_LEN 0x0 /* valid only for firmware version */
24#define REQUEST_I2C_WRITE 0x3 24 /* higher than 1.21 */
25#define REQUEST_POLL_RC 0x4 /* deprecated in firmware v1.20 */ 25#define REQUEST_I2C_READ 0x2
26#define REQUEST_JUMPRAM 0x8 26#define REQUEST_I2C_WRITE 0x3
27#define REQUEST_SET_CLOCK 0xB 27#define REQUEST_POLL_RC 0x4 /* deprecated in firmware v1.20 */
28#define REQUEST_SET_GPIO 0xC 28#define REQUEST_JUMPRAM 0x8
29#define REQUEST_ENABLE_VIDEO 0xF 29#define REQUEST_SET_CLOCK 0xB
30#define REQUEST_SET_GPIO 0xC
31#define REQUEST_ENABLE_VIDEO 0xF
30 // 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)
31 // 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)
32 // 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( " " )
33#define REQUEST_SET_RC 0x11 35#define REQUEST_SET_RC 0x11
34#define REQUEST_NEW_I2C_READ 0x12 36#define REQUEST_NEW_I2C_READ 0x12
35#define REQUEST_NEW_I2C_WRITE 0x13 37#define REQUEST_NEW_I2C_WRITE 0x13
36#define REQUEST_GET_VERSION 0x15 38#define REQUEST_GET_VERSION 0x15
37 39
38struct dib0700_state { 40struct dib0700_state {
39 u8 channel_state; 41 u8 channel_state;
@@ -44,6 +46,8 @@ struct dib0700_state {
44 u8 is_dib7000pc; 46 u8 is_dib7000pc;
45 u8 fw_use_new_i2c_api; 47 u8 fw_use_new_i2c_api;
46 u8 disable_streaming_master_mode; 48 u8 disable_streaming_master_mode;
49 u32 fw_version;
50 u32 nb_packet_buffer_size;
47}; 51};
48 52
49extern int dib0700_get_version(struct dvb_usb_device *d, u32 *hwversion, 53extern int dib0700_get_version(struct dvb_usb_device *d, u32 *hwversion,
diff --git a/drivers/media/dvb/dvb-usb/dib0700_core.c b/drivers/media/dvb/dvb-usb/dib0700_core.c
index db7f7f79a66c..0d3c9a9a33be 100644
--- a/drivers/media/dvb/dvb-usb/dib0700_core.c
+++ b/drivers/media/dvb/dvb-usb/dib0700_core.c
@@ -17,6 +17,14 @@ int dvb_usb_dib0700_ir_proto = 1;
17module_param(dvb_usb_dib0700_ir_proto, int, 0644); 17module_param(dvb_usb_dib0700_ir_proto, int, 0644);
18MODULE_PARM_DESC(dvb_usb_dib0700_ir_proto, "set ir protocol (0=NEC, 1=RC5 (default), 2=RC6)."); 18MODULE_PARM_DESC(dvb_usb_dib0700_ir_proto, "set ir protocol (0=NEC, 1=RC5 (default), 2=RC6).");
19 19
20static int nb_packet_buffer_size = 21;
21module_param(nb_packet_buffer_size, int, 0644);
22MODULE_PARM_DESC(nb_packet_buffer_size,
23 "Set the dib0700 driver data buffer size. This parameter "
24 "corresponds to the number of TS packets. The actual size of "
25 "the data buffer corresponds to this parameter "
26 "multiplied by 188 (default: 21)");
27
20DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); 28DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
21 29
22 30
@@ -28,10 +36,14 @@ int dib0700_get_version(struct dvb_usb_device *d, u32 *hwversion,
28 REQUEST_GET_VERSION, 36 REQUEST_GET_VERSION,
29 USB_TYPE_VENDOR | USB_DIR_IN, 0, 0, 37 USB_TYPE_VENDOR | USB_DIR_IN, 0, 0,
30 b, sizeof(b), USB_CTRL_GET_TIMEOUT); 38 b, sizeof(b), USB_CTRL_GET_TIMEOUT);
31 *hwversion = (b[0] << 24) | (b[1] << 16) | (b[2] << 8) | b[3]; 39 if (hwversion != NULL)
32 *romversion = (b[4] << 24) | (b[5] << 16) | (b[6] << 8) | b[7]; 40 *hwversion = (b[0] << 24) | (b[1] << 16) | (b[2] << 8) | b[3];
33 *ramversion = (b[8] << 24) | (b[9] << 16) | (b[10] << 8) | b[11]; 41 if (romversion != NULL)
34 *fwtype = (b[12] << 24) | (b[13] << 16) | (b[14] << 8) | b[15]; 42 *romversion = (b[4] << 24) | (b[5] << 16) | (b[6] << 8) | b[7];
43 if (ramversion != NULL)
44 *ramversion = (b[8] << 24) | (b[9] << 16) | (b[10] << 8) | b[11];
45 if (fwtype != NULL)
46 *fwtype = (b[12] << 24) | (b[13] << 16) | (b[14] << 8) | b[15];
35 return ret; 47 return ret;
36} 48}
37 49
@@ -97,6 +109,27 @@ int dib0700_set_gpio(struct dvb_usb_device *d, enum dib07x0_gpios gpio, u8 gpio_
97 return dib0700_ctrl_wr(d,buf,3); 109 return dib0700_ctrl_wr(d,buf,3);
98} 110}
99 111
112static int dib0700_set_usb_xfer_len(struct dvb_usb_device *d, u16 nb_ts_packets)
113{
114 struct dib0700_state *st = d->priv;
115 u8 b[3];
116 int ret;
117
118 if (st->fw_version >= 0x10201) {
119 b[0] = REQUEST_SET_USB_XFER_LEN;
120 b[1] = (nb_ts_packets >> 8)&0xff;
121 b[2] = nb_ts_packets & 0xff;
122
123 deb_info("set the USB xfer len to %i Ts packet\n", nb_ts_packets);
124
125 ret = dib0700_ctrl_wr(d, b, 3);
126 } else {
127 deb_info("this firmware does not allow to change the USB xfer len\n");
128 ret = -EIO;
129 }
130 return ret;
131}
132
100/* 133/*
101 * I2C master xfer function (supported in 1.20 firmware) 134 * I2C master xfer function (supported in 1.20 firmware)
102 */ 135 */
@@ -328,7 +361,9 @@ static int dib0700_jumpram(struct usb_device *udev, u32 address)
328int dib0700_download_firmware(struct usb_device *udev, const struct firmware *fw) 361int dib0700_download_firmware(struct usb_device *udev, const struct firmware *fw)
329{ 362{
330 struct hexline hx; 363 struct hexline hx;
331 int pos = 0, ret, act_len; 364 int pos = 0, ret, act_len, i, adap_num;
365 u8 b[16];
366 u32 fw_version;
332 367
333 u8 buf[260]; 368 u8 buf[260];
334 369
@@ -364,6 +399,34 @@ int dib0700_download_firmware(struct usb_device *udev, const struct firmware *fw
364 } else 399 } else
365 ret = -EIO; 400 ret = -EIO;
366 401
402 /* the number of ts packet has to be at least 1 */
403 if (nb_packet_buffer_size < 1)
404 nb_packet_buffer_size = 1;
405
406 /* get the fimware version */
407 usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
408 REQUEST_GET_VERSION,
409 USB_TYPE_VENDOR | USB_DIR_IN, 0, 0,
410 b, sizeof(b), USB_CTRL_GET_TIMEOUT);
411 fw_version = (b[8] << 24) | (b[9] << 16) | (b[10] << 8) | b[11];
412
413 /* set the buffer size - DVB-USB is allocating URB buffers
414 * only after the firwmare download was successful */
415 for (i = 0; i < dib0700_device_count; i++) {
416 for (adap_num = 0; adap_num < dib0700_devices[i].num_adapters;
417 adap_num++) {
418 if (fw_version >= 0x10201)
419 dib0700_devices[i].adapter[adap_num].stream.u.bulk.buffersize = 188*nb_packet_buffer_size;
420 else {
421 /* for fw version older than 1.20.1,
422 * the buffersize has to be n times 512 */
423 dib0700_devices[i].adapter[adap_num].stream.u.bulk.buffersize = ((188*nb_packet_buffer_size+188/2)/512)*512;
424 if (dib0700_devices[i].adapter[adap_num].stream.u.bulk.buffersize < 512)
425 dib0700_devices[i].adapter[adap_num].stream.u.bulk.buffersize = 512;
426 }
427 }
428 }
429
367 return ret; 430 return ret;
368} 431}
369 432
@@ -371,6 +434,18 @@ int dib0700_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
371{ 434{
372 struct dib0700_state *st = adap->dev->priv; 435 struct dib0700_state *st = adap->dev->priv;
373 u8 b[4]; 436 u8 b[4];
437 int ret;
438
439 if ((onoff != 0) && (st->fw_version >= 0x10201)) {
440 /* for firmware later than 1.20.1,
441 * the USB xfer length can be set */
442 ret = dib0700_set_usb_xfer_len(adap->dev,
443 st->nb_packet_buffer_size);
444 if (ret < 0) {
445 deb_info("can not set the USB xfer len\n");
446 return ret;
447 }
448 }
374 449
375 b[0] = REQUEST_ENABLE_VIDEO; 450 b[0] = REQUEST_ENABLE_VIDEO;
376 b[1] = (onoff << 4) | 0x00; /* this bit gives a kind of command, rather than enabling something or not */ 451 b[1] = (onoff << 4) | 0x00; /* this bit gives a kind of command, rather than enabling something or not */
@@ -415,9 +490,21 @@ static int dib0700_probe(struct usb_interface *intf,
415 490
416 for (i = 0; i < dib0700_device_count; i++) 491 for (i = 0; i < dib0700_device_count; i++)
417 if (dvb_usb_device_init(intf, &dib0700_devices[i], THIS_MODULE, 492 if (dvb_usb_device_init(intf, &dib0700_devices[i], THIS_MODULE,
418 &dev, adapter_nr) == 0) 493 &dev, adapter_nr) == 0) {
419 { 494 struct dib0700_state *st = dev->priv;
495 u32 hwversion, romversion, fw_version, fwtype;
496
497 dib0700_get_version(dev, &hwversion, &romversion,
498 &fw_version, &fwtype);
499
500 deb_info("Firmware version: %x, %d, 0x%x, %d\n",
501 hwversion, romversion, fw_version, fwtype);
502
503 st->fw_version = fw_version;
504 st->nb_packet_buffer_size = (u32)nb_packet_buffer_size;
505
420 dib0700_rc_setup(dev); 506 dib0700_rc_setup(dev);
507
421 return 0; 508 return 0;
422 } 509 }
423 510