From d3707add6158803b6463292178cd1a041857b91b Mon Sep 17 00:00:00 2001 From: Patrick Boettcher Date: Mon, 9 Jan 2006 15:25:04 -0200 Subject: DVB (2420): Makes integration of future devices easier - To make the integration of future devices easier - modified the dvb-usb-part to allow a device-specific firmware download - added an option to specify whether a device reconnects after a firmware download or not. Signed-off-by: Patrick Boettcher Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/dvb-usb/dvb-usb-firmware.c | 151 +++++++++++++++++---------- 1 file changed, 98 insertions(+), 53 deletions(-) (limited to 'drivers/media/dvb/dvb-usb/dvb-usb-firmware.c') diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-firmware.c b/drivers/media/dvb/dvb-usb/dvb-usb-firmware.c index 5244e39770a..ab87af99d36 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-firmware.c +++ b/drivers/media/dvb/dvb-usb/dvb-usb-firmware.c @@ -9,7 +9,6 @@ */ #include "dvb-usb-common.h" -#include #include struct usb_cypress_controller { @@ -19,9 +18,10 @@ struct usb_cypress_controller { }; static struct usb_cypress_controller cypress[] = { - { .id = CYPRESS_AN2135, .name = "Cypress AN2135", .cpu_cs_register = 0x7f92 }, - { .id = CYPRESS_AN2235, .name = "Cypress AN2235", .cpu_cs_register = 0x7f92 }, - { .id = CYPRESS_FX2, .name = "Cypress FX2", .cpu_cs_register = 0xe600 }, + { .id = DEVICE_SPECIFIC, .name = "Device specific", .cpu_cs_register = 0 }, + { .id = CYPRESS_AN2135, .name = "Cypress AN2135", .cpu_cs_register = 0x7f92 }, + { .id = CYPRESS_AN2235, .name = "Cypress AN2235", .cpu_cs_register = 0x7f92 }, + { .id = CYPRESS_FX2, .name = "Cypress FX2", .cpu_cs_register = 0xe600 }, }; /* @@ -33,68 +33,113 @@ static int usb_cypress_writemem(struct usb_device *udev,u16 addr,u8 *data, u8 le 0xa0, USB_TYPE_VENDOR, addr, 0x00, data, len, 5*HZ); } -int usb_cypress_load_firmware(struct usb_device *udev, const char *filename, int type) +static int usb_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw, int type) { - const struct firmware *fw = NULL; - u16 addr; - u8 *b,*p; - int ret = 0,i; + struct hexline hx; + u8 reset; + int ret,pos=0; - if ((ret = request_firmware(&fw, filename, &udev->dev)) != 0) { - err("did not find the firmware file. (%s) " - "Please see linux/Documentation/dvb/ for more details on firmware-problems.", - filename); + /* stop the CPU */ + reset = 1; + if ((ret = usb_cypress_writemem(udev,cypress[type].cpu_cs_register,&reset,1)) != 1) + err("could not stop the USB controller CPU."); + + while ((ret = dvb_usb_get_hexline(fw,&hx,&pos)) > 0) { + deb_fw("writing to address 0x%04x (buffer: 0x%02x %02x)\n",hx.addr,hx.len,hx.chk); + ret = usb_cypress_writemem(udev,hx.addr,hx.data,hx.len); + + if (ret != hx.len) { + err("error while transferring firmware " + "(transferred size: %d, block size: %d)", + ret,hx.len); + ret = -EINVAL; + break; + } + } + if (ret < 0) { + err("firmware download failed at %d with %d",pos,ret); return ret; } - info("downloading firmware from file '%s' to the '%s'",filename,cypress[type].name); - - p = kmalloc(fw->size,GFP_KERNEL); - if (p != NULL) { - u8 reset; - /* - * you cannot use the fw->data as buffer for - * usb_control_msg, a new buffer has to be - * created - */ - memcpy(p,fw->data,fw->size); - - /* stop the CPU */ - reset = 1; - if ((ret = usb_cypress_writemem(udev,cypress[type].cpu_cs_register,&reset,1)) != 1) - err("could not stop the USB controller CPU."); - for(i = 0; p[i+3] == 0 && i < fw->size; ) { - b = (u8 *) &p[i]; - addr = cpu_to_le16( *((u16 *) &b[1]) ); - - deb_fw("writing to address 0x%04x (buffer: 0x%02x%02x)\n",addr,b[1],b[2]); - - ret = usb_cypress_writemem(udev,addr,&b[4],b[0]); - - if (ret != b[0]) { - err("error while transferring firmware " - "(transferred size: %d, block size: %d)", - ret,b[0]); - ret = -EINVAL; - break; - } - i += 5 + b[0]; - } - /* length in ret */ - if (ret > 0) - ret = 0; + if (ret == 0) { /* restart the CPU */ reset = 0; if (ret || usb_cypress_writemem(udev,cypress[type].cpu_cs_register,&reset,1) != 1) { err("could not restart the USB controller CPU."); ret = -EINVAL; } + } else + ret = -EIO; - kfree(p); - } else { - ret = -ENOMEM; + return ret; +} + +int dvb_usb_download_firmware(struct usb_device *udev, struct dvb_usb_properties *props) +{ + int ret; + const struct firmware *fw = NULL; + + if ((ret = request_firmware(&fw, props->firmware, &udev->dev)) != 0) { + err("did not find the firmware file. (%s) " + "Please see linux/Documentation/dvb/ for more details on firmware-problems. (%d)", + props->firmware,ret); + return ret; } - release_firmware(fw); + info("downloading firmware from file '%s'",props->firmware); + + switch (props->usb_ctrl) { + case CYPRESS_AN2135: + case CYPRESS_AN2235: + case CYPRESS_FX2: + ret = usb_cypress_load_firmware(udev, fw, props->usb_ctrl); + break; + case DEVICE_SPECIFIC: + if (props->download_firmware) + ret = props->download_firmware(udev,fw); + else { + err("BUG: driver didn't specified a download_firmware-callback, although it claims to have a DEVICE_SPECIFIC one."); + ret = -EINVAL; + } + break; + default: + ret = -EINVAL; + break; + } + + release_firmware(fw); return ret; } + +int dvb_usb_get_hexline(const struct firmware *fw, struct hexline *hx, int *pos) +{ + u8 *b = (u8 *) &fw->data[*pos]; + int data_offs = 4; + if (*pos >= fw->size) + return 0; + + memset(hx,0,sizeof(struct hexline)); + + hx->len = b[0]; + + if ((*pos + hx->len + 4) >= fw->size) + return -EINVAL; + + hx->addr = le16_to_cpu( *((u16 *) &b[1]) ); + hx->type = b[3]; + + if (hx->type == 0x04) { + /* b[4] and b[5] are the Extended linear address record data field */ + hx->addr |= (b[4] << 24) | (b[5] << 16); +/* hx->len -= 2; + data_offs += 2; */ + } + memcpy(hx->data,&b[data_offs],hx->len); + hx->chk = b[hx->len + data_offs]; + + *pos += hx->len + 5; + + return *pos; +} +EXPORT_SYMBOL(dvb_usb_get_hexline); + -- cgit v1.2.3-70-g09d2 From 4302c15ea237a649780894e263125fcd8c548998 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Mon, 9 Jan 2006 15:25:22 -0200 Subject: V4L/DVB (3145): syncronizes some changes between v4l and dvb - digitv_ctrl_msg() if (wo) test is reversed. fixed. - usb timeout is in Hz, not in jiffies. - NULL replaced by 0 to be coherent. - removed uneeded headers. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/b2c2/flexcop-reg.h | 4 +++- drivers/media/dvb/dvb-usb/digitv.c | 2 +- drivers/media/dvb/dvb-usb/dtt200u.c | 4 ++-- drivers/media/dvb/dvb-usb/dvb-usb-firmware.c | 2 +- drivers/media/dvb/dvb-usb/dvb-usb.h | 1 - drivers/media/dvb/dvb-usb/vp7045.c | 2 +- drivers/media/dvb/frontends/cx24110.c | 1 - drivers/media/dvb/frontends/lgdt330x.c | 2 ++ 8 files changed, 10 insertions(+), 8 deletions(-) (limited to 'drivers/media/dvb/dvb-usb/dvb-usb-firmware.c') diff --git a/drivers/media/dvb/b2c2/flexcop-reg.h b/drivers/media/dvb/b2c2/flexcop-reg.h index 23cc6431e2b..3153f9513c6 100644 --- a/drivers/media/dvb/b2c2/flexcop-reg.h +++ b/drivers/media/dvb/b2c2/flexcop-reg.h @@ -39,11 +39,13 @@ extern const char *flexcop_device_names[]; /* FlexCop IBI Registers */ #if defined(__LITTLE_ENDIAN) #include "flexcop_ibi_value_le.h" -#elif defined(__BIG_ENDIAN) +#else +#if defined(__BIG_ENDIAN) #include "flexcop_ibi_value_be.h" #else #error no endian defined #endif +#endif #define fc_data_Tag_ID_DVB 0x3e #define fc_data_Tag_ID_ATSC 0x3f diff --git a/drivers/media/dvb/dvb-usb/digitv.c b/drivers/media/dvb/dvb-usb/digitv.c index 450417a9e64..e6c55c9c941 100644 --- a/drivers/media/dvb/dvb-usb/digitv.c +++ b/drivers/media/dvb/dvb-usb/digitv.c @@ -32,7 +32,7 @@ static int digitv_ctrl_msg(struct dvb_usb_device *d, sndbuf[1] = vv; sndbuf[2] = wo ? wlen : rlen; - if (!wo) { + if (wo) { memcpy(&sndbuf[3],wbuf,wlen); dvb_usb_generic_write(d,sndbuf,7); } else { diff --git a/drivers/media/dvb/dvb-usb/dtt200u.c b/drivers/media/dvb/dvb-usb/dtt200u.c index 6e2bac87344..54c43699651 100644 --- a/drivers/media/dvb/dvb-usb/dtt200u.c +++ b/drivers/media/dvb/dvb-usb/dtt200u.c @@ -151,7 +151,7 @@ static struct dvb_usb_properties dtt200u_properties = { .cold_ids = { &dtt200u_usb_table[0], NULL }, .warm_ids = { &dtt200u_usb_table[1], NULL }, }, - { NULL }, + { 0 }, } }; @@ -192,7 +192,7 @@ static struct dvb_usb_properties wt220u_properties = { .cold_ids = { &dtt200u_usb_table[2], NULL }, .warm_ids = { &dtt200u_usb_table[3], NULL }, }, - { NULL }, + { 0 }, } }; diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-firmware.c b/drivers/media/dvb/dvb-usb/dvb-usb-firmware.c index ab87af99d36..51ce7403999 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-firmware.c +++ b/drivers/media/dvb/dvb-usb/dvb-usb-firmware.c @@ -30,7 +30,7 @@ static struct usb_cypress_controller cypress[] = { static int usb_cypress_writemem(struct usb_device *udev,u16 addr,u8 *data, u8 len) { return usb_control_msg(udev, usb_sndctrlpipe(udev,0), - 0xa0, USB_TYPE_VENDOR, addr, 0x00, data, len, 5*HZ); + 0xa0, USB_TYPE_VENDOR, addr, 0x00, data, len, 5000); } static int usb_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw, int type) diff --git a/drivers/media/dvb/dvb-usb/dvb-usb.h b/drivers/media/dvb/dvb-usb/dvb-usb.h index cd510fba60e..4060fe1ca08 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb.h @@ -10,7 +10,6 @@ #include #include -#include #include #include diff --git a/drivers/media/dvb/dvb-usb/vp7045.c b/drivers/media/dvb/dvb-usb/vp7045.c index 3835235b68d..028204956bb 100644 --- a/drivers/media/dvb/dvb-usb/vp7045.c +++ b/drivers/media/dvb/dvb-usb/vp7045.c @@ -247,7 +247,7 @@ static struct dvb_usb_properties vp7045_properties = { .cold_ids = { &vp7045_usb_table[2], NULL }, .warm_ids = { &vp7045_usb_table[3], NULL }, }, - { NULL }, + { 0 }, } }; diff --git a/drivers/media/dvb/frontends/cx24110.c b/drivers/media/dvb/frontends/cx24110.c index 0c4db80ec33..ecd056e951f 100644 --- a/drivers/media/dvb/frontends/cx24110.c +++ b/drivers/media/dvb/frontends/cx24110.c @@ -27,7 +27,6 @@ #include #include #include -#include #include "dvb_frontend.h" #include "cx24110.h" diff --git a/drivers/media/dvb/frontends/lgdt330x.c b/drivers/media/dvb/frontends/lgdt330x.c index cb5301865d0..56fcb9e97b5 100644 --- a/drivers/media/dvb/frontends/lgdt330x.c +++ b/drivers/media/dvb/frontends/lgdt330x.c @@ -402,6 +402,8 @@ static int lgdt330x_set_parameters(struct dvb_frontend* fe, state->config->pll_set(fe, param); /* Keep track of the new frequency */ + /* FIXME this is the wrong way to do this... */ + /* The tuner is shared with the video4linux analog API */ state->current_frequency = param->frequency; lgdt330x_SwReset(state); -- cgit v1.2.3-70-g09d2 From 0029ee143d66ca89d0e8b074abb452cf4ca2c53c Mon Sep 17 00:00:00 2001 From: Chris Pascoe Date: Mon, 9 Jan 2006 18:21:28 -0200 Subject: V4L/DVB (3310): DViCO Dual Digital DVB-T / USB bluebird updates - Add support for the USB portion of the DViCO Dual Digital board. Patch correct "warm" USB IDs into bluebird firmware before download. Signed-off-by: Chris Pascoe Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/dvb-usb/cxusb.c | 95 +++++++++++++++++++++++++++- drivers/media/dvb/dvb-usb/dvb-usb-firmware.c | 27 ++++++++ drivers/media/dvb/dvb-usb/dvb-usb-ids.h | 12 ++-- 3 files changed, 128 insertions(+), 6 deletions(-) (limited to 'drivers/media/dvb/dvb-usb/dvb-usb-firmware.c') diff --git a/drivers/media/dvb/dvb-usb/cxusb.c b/drivers/media/dvb/dvb-usb/cxusb.c index 2c1b1e5992a..9622a79d6e6 100644 --- a/drivers/media/dvb/dvb-usb/cxusb.c +++ b/drivers/media/dvb/dvb-usb/cxusb.c @@ -26,6 +26,8 @@ #include "cx22702.h" #include "lgdt330x.h" +#include "mt352.h" +#include "mt352_priv.h" /* debug */ int dvb_usb_cxusb_debug; @@ -157,6 +159,27 @@ static int cxusb_streaming_ctrl(struct dvb_usb_device *d, int onoff) return 0; } +static int cxusb_dee1601_demod_init(struct dvb_frontend* fe) +{ + static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x38 }; + static u8 reset [] = { RESET, 0x80 }; + static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 }; + static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 }; + static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 }; + static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 }; + + mt352_write(fe, clock_config, sizeof(clock_config)); + udelay(200); + mt352_write(fe, reset, sizeof(reset)); + mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg)); + + mt352_write(fe, agc_cfg, sizeof(agc_cfg)); + mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg)); + mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg)); + + return 0; +} + struct cx22702_config cxusb_cx22702_config = { .demod_address = 0x63, @@ -172,6 +195,12 @@ struct lgdt330x_config cxusb_lgdt330x_config = { .pll_set = dvb_usb_pll_set_i2c, }; +struct mt352_config cxusb_dee1601_config = { + .demod_address = 0x0f, + .demod_init = cxusb_dee1601_demod_init, + .pll_set = dvb_usb_pll_set, +}; + /* Callbacks for DVB USB */ static int cxusb_fmd1216me_tuner_attach(struct dvb_usb_device *d) { @@ -193,6 +222,13 @@ static int cxusb_lgh064f_tuner_attach(struct dvb_usb_device *d) return 0; } +static int cxusb_dee1601_tuner_attach(struct dvb_usb_device *d) +{ + d->pll_addr = 0x61; + d->pll_desc = &dvb_pll_thomson_dtt7579; + return 0; +} + static int cxusb_cx22702_frontend_attach(struct dvb_usb_device *d) { u8 b; @@ -220,15 +256,31 @@ static int cxusb_lgdt330x_frontend_attach(struct dvb_usb_device *d) return -EIO; } +static int cxusb_dee1601_frontend_attach(struct dvb_usb_device *d) +{ + if (usb_set_interface(d->udev,0,0) < 0) + err("set interface failed"); + + cxusb_ctrl_msg(d,CMD_DIGITAL, NULL, 0, NULL, 0); + + if ((d->fe = mt352_attach(&cxusb_dee1601_config, &d->i2c_adap)) != NULL) + return 0; + + return -EIO; +} + /* DVB USB Driver stuff */ static struct dvb_usb_properties cxusb_medion_properties; static struct dvb_usb_properties cxusb_bluebird_lgh064f_properties; +static struct dvb_usb_properties cxusb_bluebird_dee1601_properties; static int cxusb_probe(struct usb_interface *intf, const struct usb_device_id *id) { if (dvb_usb_device_init(intf,&cxusb_medion_properties,THIS_MODULE,NULL) == 0 || - dvb_usb_device_init(intf,&cxusb_bluebird_lgh064f_properties,THIS_MODULE,NULL) == 0) { + dvb_usb_device_init(intf,&cxusb_bluebird_lgh064f_properties,THIS_MODULE,NULL) == 0 || + dvb_usb_device_init(intf,&cxusb_bluebird_dee1601_properties,THIS_MODULE,NULL) == 0 + ){ return 0; } @@ -239,6 +291,8 @@ static struct usb_device_id cxusb_table [] = { { USB_DEVICE(USB_VID_MEDION, USB_PID_MEDION_MD95700) }, { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_COLD) }, { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_WARM) }, + { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DEE1601_COLD) }, + { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DEE1601_WARM) }, {} /* Terminating entry */ }; MODULE_DEVICE_TABLE (usb, cxusb_table); @@ -318,6 +372,45 @@ static struct dvb_usb_properties cxusb_bluebird_lgh064f_properties = { } }; +static struct dvb_usb_properties cxusb_bluebird_dee1601_properties = { + .caps = DVB_USB_IS_AN_I2C_ADAPTER, + + .usb_ctrl = CYPRESS_FX2, + .firmware = "dvb-usb-bluebird-01.fw", + /* use usb alt setting 0 for EP4 transfer (dvb-t), + use usb alt setting 7 for EP2 transfer (atsc) */ + + .size_of_priv = sizeof(struct cxusb_state), + + .streaming_ctrl = cxusb_streaming_ctrl, + .power_ctrl = cxusb_power_ctrl, + .frontend_attach = cxusb_dee1601_frontend_attach, + .tuner_attach = cxusb_dee1601_tuner_attach, + + .i2c_algo = &cxusb_i2c_algo, + + .generic_bulk_ctrl_endpoint = 0x01, + /* parameter for the MPEG2-data transfer */ + .urb = { + .type = DVB_USB_BULK, + .count = 5, + .endpoint = 0x04, + .u = { + .bulk = { + .buffersize = 8192, + } + } + }, + + .num_device_descs = 1, + .devices = { + { "DViCO FusionHDTV DVB-T Dual USB", + { &cxusb_table[3], NULL }, + { &cxusb_table[4], NULL }, + }, + } +}; + static struct usb_driver cxusb_driver = { .name = "dvb_usb_cxusb", .probe = cxusb_probe, diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-firmware.c b/drivers/media/dvb/dvb-usb/dvb-usb-firmware.c index 51ce7403999..b2670476c3f 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-firmware.c +++ b/drivers/media/dvb/dvb-usb/dvb-usb-firmware.c @@ -74,6 +74,27 @@ static int usb_cypress_load_firmware(struct usb_device *udev, const struct firmw return ret; } +/* + * DViCO bluebird firmware needs the "warm" product ID to be patched into the + * firmware file before download. + */ +#define BLUEBIRD_01_ID_OFFSET 6638 +static int dvb_usb_patch_dvico_firmware(struct usb_device *udev, const struct firmware *fw) +{ + if (fw->size < BLUEBIRD_01_ID_OFFSET + 4) + return -EINVAL; + + if (fw->data[BLUEBIRD_01_ID_OFFSET] == (USB_VID_DVICO & 0xff) && + fw->data[BLUEBIRD_01_ID_OFFSET + 1] == USB_VID_DVICO >> 8) { + fw->data[BLUEBIRD_01_ID_OFFSET + 2] = udev->descriptor.idProduct + 1; + fw->data[BLUEBIRD_01_ID_OFFSET + 3] = udev->descriptor.idProduct >> 8; + + return 0; + } + + return -EINVAL; +} + int dvb_usb_download_firmware(struct usb_device *udev, struct dvb_usb_properties *props) { int ret; @@ -88,6 +109,12 @@ int dvb_usb_download_firmware(struct usb_device *udev, struct dvb_usb_properties info("downloading firmware from file '%s'",props->firmware); + if (le16_to_cpu(udev->descriptor.idVendor) == USB_VID_DVICO) { + ret = dvb_usb_patch_dvico_firmware(udev, fw); + if (ret != 0) + warn("this firmware file not recognised"); + } + switch (props->usb_ctrl) { case CYPRESS_AN2135: case CYPRESS_AN2235: diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h index 784adfe1c07..d2293438322 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h @@ -86,13 +86,15 @@ #define USB_PID_WINTV_NOVA_T_USB2_COLD 0x9300 #define USB_PID_WINTV_NOVA_T_USB2_WARM 0x9301 #define USB_PID_NEBULA_DIGITV 0x0201 -#define USB_PID_DVICO_BLUEBIRD_LGZ201 0xdb00 -#define USB_PID_DVICO_BLUEBIRD_TH7579 0xdb10 #define USB_PID_DVICO_BLUEBIRD_LGDT 0xd820 -#define USB_PID_DVICO_BLUEBIRD_LGZ201_1 0xdb01 -#define USB_PID_DVICO_BLUEBIRD_TH7579_2 0xdb11 #define USB_PID_DVICO_BLUEBIRD_LG064F_COLD 0xd500 -#define USB_PID_DVICO_BLUEBIRD_LG064F_WARM 0xd700 +#define USB_PID_DVICO_BLUEBIRD_LG064F_WARM 0xd501 +#define USB_PID_DVICO_BLUEBIRD_LGZ201_COLD 0xdb00 +#define USB_PID_DVICO_BLUEBIRD_LGZ201_WARM 0xdb01 +#define USB_PID_DVICO_BLUEBIRD_TH7579_COLD 0xdb10 +#define USB_PID_DVICO_BLUEBIRD_TH7579_WARM 0xdb11 +#define USB_PID_DVICO_BLUEBIRD_DEE1601_COLD 0xdb50 +#define USB_PID_DVICO_BLUEBIRD_DEE1601_WARM 0xdb51 #define USB_PID_MEDION_MD95700 0x0932 #define USB_PID_KYE_DVB_T_COLD 0x701e #define USB_PID_KYE_DVB_T_WARM 0x701f -- cgit v1.2.3-70-g09d2 From f53737882e26ff08022fec6ad79f061c49dadda2 Mon Sep 17 00:00:00 2001 From: Patrick Boettcher Date: Mon, 9 Jan 2006 18:21:38 -0200 Subject: V4L/DVB (3327): Remove DViCO specific firmware hacks from the generic code. - Move the code that patches bluebird firmware before upload from the generic code into the cxusb driver itself. Signed-off-by: Patrick Boettcher Signed-off-by: Michael Krufky Signed-off-by: Chris Pascoe Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/dvb-usb/cxusb.c | 37 +++++++++++++++++++++++----- drivers/media/dvb/dvb-usb/dvb-usb-firmware.c | 30 ++-------------------- drivers/media/dvb/dvb-usb/dvb-usb.h | 1 + 3 files changed, 34 insertions(+), 34 deletions(-) (limited to 'drivers/media/dvb/dvb-usb/dvb-usb-firmware.c') diff --git a/drivers/media/dvb/dvb-usb/cxusb.c b/drivers/media/dvb/dvb-usb/cxusb.c index 3100ce91ccd..9d69f822537 100644 --- a/drivers/media/dvb/dvb-usb/cxusb.c +++ b/drivers/media/dvb/dvb-usb/cxusb.c @@ -11,8 +11,7 @@ * design, so it can be reused for the "analogue-only" device (if it will * appear at all). * - * TODO: check if the cx25840-driver (from ivtv) can be used for the analogue - * part + * Use the cx25840-driver for the analogue part * * Copyright (C) 2005 Patrick Boettcher (patrick.boettcher@desy.de) * Copyright (C) 2005 Michael Krufky (mkrufky@m1k.net) @@ -343,6 +342,30 @@ static int cxusb_dee1601_frontend_attach(struct dvb_usb_device *d) return -EIO; } +/* + * DViCO bluebird firmware needs the "warm" product ID to be patched into the + * firmware file before download. + */ + +#define BLUEBIRD_01_ID_OFFSET 6638 +static int bluebird_patch_dvico_firmware_download(struct usb_device *udev, const struct firmware *fw) +{ + if (fw->size < BLUEBIRD_01_ID_OFFSET + 4) + return -EINVAL; + + if (fw->data[BLUEBIRD_01_ID_OFFSET] == (USB_VID_DVICO & 0xff) && + fw->data[BLUEBIRD_01_ID_OFFSET + 1] == USB_VID_DVICO >> 8) { + + /* FIXME: are we allowed to change the fw-data ? */ + fw->data[BLUEBIRD_01_ID_OFFSET + 2] = udev->descriptor.idProduct + 1; + fw->data[BLUEBIRD_01_ID_OFFSET + 3] = udev->descriptor.idProduct >> 8; + + return usb_cypress_load_firmware(udev,fw,CYPRESS_FX2); + } + + return -EINVAL; +} + /* DVB USB Driver stuff */ static struct dvb_usb_properties cxusb_medion_properties; static struct dvb_usb_properties cxusb_bluebird_lgh064f_properties; @@ -409,8 +432,9 @@ static struct dvb_usb_properties cxusb_medion_properties = { static struct dvb_usb_properties cxusb_bluebird_lgh064f_properties = { .caps = DVB_USB_IS_AN_I2C_ADAPTER, - .usb_ctrl = CYPRESS_FX2, - .firmware = "dvb-usb-bluebird-01.fw", + .usb_ctrl = DEVICE_SPECIFIC, + .firmware = "dvb-usb-bluebird-01.fw", + .download_firmware = bluebird_patch_dvico_firmware_download, /* use usb alt setting 0 for EP4 transfer (dvb-t), use usb alt setting 7 for EP2 transfer (atsc) */ @@ -448,8 +472,9 @@ static struct dvb_usb_properties cxusb_bluebird_lgh064f_properties = { static struct dvb_usb_properties cxusb_bluebird_dee1601_properties = { .caps = DVB_USB_IS_AN_I2C_ADAPTER, - .usb_ctrl = CYPRESS_FX2, - .firmware = "dvb-usb-bluebird-01.fw", + .usb_ctrl = DEVICE_SPECIFIC, + .firmware = "dvb-usb-bluebird-01.fw", + .download_firmware = bluebird_patch_dvico_firmware_download, /* use usb alt setting 0 for EP4 transfer (dvb-t), use usb alt setting 7 for EP2 transfer (atsc) */ diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-firmware.c b/drivers/media/dvb/dvb-usb/dvb-usb-firmware.c index b2670476c3f..8535895819f 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-firmware.c +++ b/drivers/media/dvb/dvb-usb/dvb-usb-firmware.c @@ -33,7 +33,7 @@ static int usb_cypress_writemem(struct usb_device *udev,u16 addr,u8 *data, u8 le 0xa0, USB_TYPE_VENDOR, addr, 0x00, data, len, 5000); } -static int usb_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw, int type) +int usb_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw, int type) { struct hexline hx; u8 reset; @@ -73,27 +73,7 @@ static int usb_cypress_load_firmware(struct usb_device *udev, const struct firmw return ret; } - -/* - * DViCO bluebird firmware needs the "warm" product ID to be patched into the - * firmware file before download. - */ -#define BLUEBIRD_01_ID_OFFSET 6638 -static int dvb_usb_patch_dvico_firmware(struct usb_device *udev, const struct firmware *fw) -{ - if (fw->size < BLUEBIRD_01_ID_OFFSET + 4) - return -EINVAL; - - if (fw->data[BLUEBIRD_01_ID_OFFSET] == (USB_VID_DVICO & 0xff) && - fw->data[BLUEBIRD_01_ID_OFFSET + 1] == USB_VID_DVICO >> 8) { - fw->data[BLUEBIRD_01_ID_OFFSET + 2] = udev->descriptor.idProduct + 1; - fw->data[BLUEBIRD_01_ID_OFFSET + 3] = udev->descriptor.idProduct >> 8; - - return 0; - } - - return -EINVAL; -} +EXPORT_SYMBOL(usb_cypress_load_firmware); int dvb_usb_download_firmware(struct usb_device *udev, struct dvb_usb_properties *props) { @@ -109,12 +89,6 @@ int dvb_usb_download_firmware(struct usb_device *udev, struct dvb_usb_properties info("downloading firmware from file '%s'",props->firmware); - if (le16_to_cpu(udev->descriptor.idVendor) == USB_VID_DVICO) { - ret = dvb_usb_patch_dvico_firmware(udev, fw); - if (ret != 0) - warn("this firmware file not recognised"); - } - switch (props->usb_ctrl) { case CYPRESS_AN2135: case CYPRESS_AN2235: diff --git a/drivers/media/dvb/dvb-usb/dvb-usb.h b/drivers/media/dvb/dvb-usb/dvb-usb.h index 4060fe1ca08..dd568396e59 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb.h @@ -342,5 +342,6 @@ struct hexline { u8 chk; }; extern int dvb_usb_get_hexline(const struct firmware *, struct hexline *, int *); +extern int usb_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw, int type); #endif -- cgit v1.2.3-70-g09d2