Commit b6990291 authored by Malcolm Priestley's avatar Malcolm Priestley Committed by Mauro Carvalho Chehab

[media] dvb-usb/it913x: multi firmware loader

Multi firmware loader
 This uses scatter write firmware headers
 The firmware must start with 03 XX 00
 and be the extract firmware length.

 I have tried all available firmwares with this loader.
Signed-off-by: default avatarMalcolm Priestley <tvboxspy@gmail.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent c725ff69
......@@ -485,35 +485,40 @@ static int it913x_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
return ret;
}
static int it913x_download_firmware(struct usb_device *udev,
const struct firmware *fw)
{
int ret = 0, i;
u8 packet_size, dlen;
int ret = 0, i = 0, pos = 0;
u8 packet_size;
u8 *fw_data;
packet_size = 0x29;
ret = it913x_wr_reg(udev, DEV_0, I2C_CLK, I2C_CLK_100);
info("FRM Starting Firmware Download");
/* This uses scatter write firmware headers follow */
/* 03 XX 00 XX = chip number? */
for (i = 0; i < fw->size; i += packet_size) {
if (i > 0)
packet_size = 0x39;
fw_data = (u8 *)(fw->data + i);
dlen = ((i + packet_size) > fw->size)
? (fw->size - i) : packet_size;
ret |= it913x_io(udev, WRITE_DATA, DEV_0,
CMD_SCATTER_WRITE, 0, 0, fw_data, dlen);
/* Multi firmware loader */
/* This uses scatter write firmware headers */
/* The firmware must start with 03 XX 00 */
/* and be the extact firmware length */
while (i <= fw->size) {
if (((fw->data[i] == 0x3) && (fw->data[i + 2] == 0x0))
|| (i == fw->size)) {
packet_size = i - pos;
if ((packet_size > 0x19) || (i == fw->size)) {
fw_data = (u8 *)(fw->data + pos);
pos += packet_size;
if (packet_size > 0)
ret |= it913x_io(udev, WRITE_DATA,
DEV_0, CMD_SCATTER_WRITE, 0,
0, fw_data, packet_size);
udelay(1000);
}
}
i++;
}
ret |= it913x_io(udev, WRITE_CMD, DEV_0,
CMD_BOOT, 0, 0, NULL, 0);
ret |= it913x_io(udev, WRITE_CMD, DEV_0, CMD_BOOT, 0, 0, NULL, 0);
msleep(100);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment