Skip to content

Commit f537378

Browse files
pboettchMauro Carvalho Chehab
authored andcommitted
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 <[email protected]> Signed-off-by: Michael Krufky <[email protected]> Signed-off-by: Chris Pascoe <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent 5af0c8f commit f537378

File tree

3 files changed

+34
-34
lines changed

3 files changed

+34
-34
lines changed

drivers/media/dvb/dvb-usb/cxusb.c

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
* design, so it can be reused for the "analogue-only" device (if it will
1212
* appear at all).
1313
*
14-
* TODO: check if the cx25840-driver (from ivtv) can be used for the analogue
15-
* part
14+
* Use the cx25840-driver for the analogue part
1615
*
1716
* Copyright (C) 2005 Patrick Boettcher ([email protected])
1817
* Copyright (C) 2005 Michael Krufky ([email protected])
@@ -343,6 +342,30 @@ static int cxusb_dee1601_frontend_attach(struct dvb_usb_device *d)
343342
return -EIO;
344343
}
345344

345+
/*
346+
* DViCO bluebird firmware needs the "warm" product ID to be patched into the
347+
* firmware file before download.
348+
*/
349+
350+
#define BLUEBIRD_01_ID_OFFSET 6638
351+
static int bluebird_patch_dvico_firmware_download(struct usb_device *udev, const struct firmware *fw)
352+
{
353+
if (fw->size < BLUEBIRD_01_ID_OFFSET + 4)
354+
return -EINVAL;
355+
356+
if (fw->data[BLUEBIRD_01_ID_OFFSET] == (USB_VID_DVICO & 0xff) &&
357+
fw->data[BLUEBIRD_01_ID_OFFSET + 1] == USB_VID_DVICO >> 8) {
358+
359+
/* FIXME: are we allowed to change the fw-data ? */
360+
fw->data[BLUEBIRD_01_ID_OFFSET + 2] = udev->descriptor.idProduct + 1;
361+
fw->data[BLUEBIRD_01_ID_OFFSET + 3] = udev->descriptor.idProduct >> 8;
362+
363+
return usb_cypress_load_firmware(udev,fw,CYPRESS_FX2);
364+
}
365+
366+
return -EINVAL;
367+
}
368+
346369
/* DVB USB Driver stuff */
347370
static struct dvb_usb_properties cxusb_medion_properties;
348371
static struct dvb_usb_properties cxusb_bluebird_lgh064f_properties;
@@ -409,8 +432,9 @@ static struct dvb_usb_properties cxusb_medion_properties = {
409432
static struct dvb_usb_properties cxusb_bluebird_lgh064f_properties = {
410433
.caps = DVB_USB_IS_AN_I2C_ADAPTER,
411434

412-
.usb_ctrl = CYPRESS_FX2,
413-
.firmware = "dvb-usb-bluebird-01.fw",
435+
.usb_ctrl = DEVICE_SPECIFIC,
436+
.firmware = "dvb-usb-bluebird-01.fw",
437+
.download_firmware = bluebird_patch_dvico_firmware_download,
414438
/* use usb alt setting 0 for EP4 transfer (dvb-t),
415439
use usb alt setting 7 for EP2 transfer (atsc) */
416440

@@ -448,8 +472,9 @@ static struct dvb_usb_properties cxusb_bluebird_lgh064f_properties = {
448472
static struct dvb_usb_properties cxusb_bluebird_dee1601_properties = {
449473
.caps = DVB_USB_IS_AN_I2C_ADAPTER,
450474

451-
.usb_ctrl = CYPRESS_FX2,
452-
.firmware = "dvb-usb-bluebird-01.fw",
475+
.usb_ctrl = DEVICE_SPECIFIC,
476+
.firmware = "dvb-usb-bluebird-01.fw",
477+
.download_firmware = bluebird_patch_dvico_firmware_download,
453478
/* use usb alt setting 0 for EP4 transfer (dvb-t),
454479
use usb alt setting 7 for EP2 transfer (atsc) */
455480

drivers/media/dvb/dvb-usb/dvb-usb-firmware.c

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static int usb_cypress_writemem(struct usb_device *udev,u16 addr,u8 *data, u8 le
3333
0xa0, USB_TYPE_VENDOR, addr, 0x00, data, len, 5000);
3434
}
3535

36-
static int usb_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw, int type)
36+
int usb_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw, int type)
3737
{
3838
struct hexline hx;
3939
u8 reset;
@@ -73,27 +73,7 @@ static int usb_cypress_load_firmware(struct usb_device *udev, const struct firmw
7373

7474
return ret;
7575
}
76-
77-
/*
78-
* DViCO bluebird firmware needs the "warm" product ID to be patched into the
79-
* firmware file before download.
80-
*/
81-
#define BLUEBIRD_01_ID_OFFSET 6638
82-
static int dvb_usb_patch_dvico_firmware(struct usb_device *udev, const struct firmware *fw)
83-
{
84-
if (fw->size < BLUEBIRD_01_ID_OFFSET + 4)
85-
return -EINVAL;
86-
87-
if (fw->data[BLUEBIRD_01_ID_OFFSET] == (USB_VID_DVICO & 0xff) &&
88-
fw->data[BLUEBIRD_01_ID_OFFSET + 1] == USB_VID_DVICO >> 8) {
89-
fw->data[BLUEBIRD_01_ID_OFFSET + 2] = udev->descriptor.idProduct + 1;
90-
fw->data[BLUEBIRD_01_ID_OFFSET + 3] = udev->descriptor.idProduct >> 8;
91-
92-
return 0;
93-
}
94-
95-
return -EINVAL;
96-
}
76+
EXPORT_SYMBOL(usb_cypress_load_firmware);
9777

9878
int dvb_usb_download_firmware(struct usb_device *udev, struct dvb_usb_properties *props)
9979
{
@@ -109,12 +89,6 @@ int dvb_usb_download_firmware(struct usb_device *udev, struct dvb_usb_properties
10989

11090
info("downloading firmware from file '%s'",props->firmware);
11191

112-
if (le16_to_cpu(udev->descriptor.idVendor) == USB_VID_DVICO) {
113-
ret = dvb_usb_patch_dvico_firmware(udev, fw);
114-
if (ret != 0)
115-
warn("this firmware file not recognised");
116-
}
117-
11892
switch (props->usb_ctrl) {
11993
case CYPRESS_AN2135:
12094
case CYPRESS_AN2235:

drivers/media/dvb/dvb-usb/dvb-usb.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,5 +342,6 @@ struct hexline {
342342
u8 chk;
343343
};
344344
extern int dvb_usb_get_hexline(const struct firmware *, struct hexline *, int *);
345+
extern int usb_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw, int type);
345346

346347
#endif

0 commit comments

Comments
 (0)