From e4b450ae2328d372ab0c6ccdbe883ee7f8b4a066 Mon Sep 17 00:00:00 2001 From: Alex Woods Date: Mon, 19 Jan 2004 21:42:22 +0000 Subject: Check for presence of crc32 function. Make unknown types of packet less likely to cause packet loss. --- linux/drivers/media/dvb/ttusb-dec/ttusb_dec.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'linux/drivers') diff --git a/linux/drivers/media/dvb/ttusb-dec/ttusb_dec.c b/linux/drivers/media/dvb/ttusb-dec/ttusb_dec.c index 0a2b388d8..93debe50e 100644 --- a/linux/drivers/media/dvb/ttusb-dec/ttusb_dec.c +++ b/linux/drivers/media/dvb/ttusb-dec/ttusb_dec.c @@ -20,7 +20,6 @@ */ #include -#include #include #include #include @@ -32,6 +31,11 @@ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) #include #endif +#if defined(CONFIG_CRC32) || defined(CONFIG_CRC32_MODULE) +#include +#else +#warning "CRC checking of firmware not available" +#endif #include "dmxdev.h" #include "dvb_demux.h" @@ -553,13 +557,14 @@ static void ttusb_dec_process_urb_frame(struct ttusb_dec *dec, u8 *b, break; case 3: - if (*b++ == 0x00) { + if (*b == 0x00) { dec->packet_state++; dec->packet_length = 0; - } else { + } else if (*b != 0xaa) { dec->packet_state = 0; } + b++; length--; break; @@ -1188,7 +1193,9 @@ static int ttusb_dec_boot_dsp(struct ttusb_dec *dec) u16 firmware_csum = 0; u16 firmware_csum_ns; u32 firmware_size_nl; +#if defined(CONFIG_CRC32) || defined(CONFIG_CRC32_MODULE) u32 crc32_csum, crc32_check, tmp; +#endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) const struct firmware *fw_entry = NULL; #endif @@ -1232,6 +1239,7 @@ static int ttusb_dec_boot_dsp(struct ttusb_dec *dec) /* a 32 bit checksum over the first 56 bytes of the DSP Code is stored at offset 56 of file, so use it to check if the firmware file is valid. */ +#if defined(CONFIG_CRC32) || defined(CONFIG_CRC32_MODULE) crc32_csum = crc32(~0L, firmware, 56) ^ ~0L; memcpy(&tmp, &firmware[56], 4); crc32_check = htonl(tmp); @@ -1241,6 +1249,7 @@ static int ttusb_dec_boot_dsp(struct ttusb_dec *dec) __FUNCTION__, crc32_csum, crc32_check); return -1; } +#endif memcpy(idstring, &firmware[36], 20); idstring[20] = '\0'; printk(KERN_INFO "ttusb_dec: found DSP code \"%s\".\n", idstring); -- cgit v1.2.3