diff options
author | Alex Woods <devnull@localhost> | 2003-07-12 00:00:05 +0000 |
---|---|---|
committer | Alex Woods <devnull@localhost> | 2003-07-12 00:00:05 +0000 |
commit | 0cc7d35a040aef25bc708d37b4ac67922cda8592 (patch) | |
tree | bfb6043510390e7951858a6eeef8e4506eb1bf0b /linux | |
parent | 2d9644e7d5b953b53a7eed78af6fea55cfb4cff6 (diff) | |
download | mediapointer-dvb-s2-0cc7d35a040aef25bc708d37b4ac67922cda8592.tar.gz mediapointer-dvb-s2-0cc7d35a040aef25bc708d37b4ac67922cda8592.tar.bz2 |
Beautify code (hopefully - it's in the eye of the beholder after all)
Stop oops on redetection of dec after firmware upload
Diffstat (limited to 'linux')
-rw-r--r-- | linux/drivers/media/dvb/ttusb-dec/dec2000_frontend.c | 60 | ||||
-rw-r--r-- | linux/drivers/media/dvb/ttusb-dec/ttusb_dec.c | 436 | ||||
-rw-r--r-- | linux/drivers/media/dvb/ttusb-dec/ttusb_dec.h | 2 |
3 files changed, 136 insertions, 362 deletions
diff --git a/linux/drivers/media/dvb/ttusb-dec/dec2000_frontend.c b/linux/drivers/media/dvb/ttusb-dec/dec2000_frontend.c index fd07e7b4c..d8ef46d67 100644 --- a/linux/drivers/media/dvb/ttusb-dec/dec2000_frontend.c +++ b/linux/drivers/media/dvb/ttusb-dec/dec2000_frontend.c @@ -30,7 +30,6 @@ static int debug = 0; #define dprintk if (debug) printk static struct dvb_frontend_info dec2000_frontend_info = { - name: "TechnoTrend/Hauppauge DEC-2000-t Frontend", type: FE_OFDM, frequency_min: 51000000, @@ -41,13 +40,11 @@ static struct dvb_frontend_info dec2000_frontend_info = { FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO | FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_GUARD_INTERVAL_AUTO | FE_CAN_HIERARCHY_AUTO, - }; -static int -dec2000_frontend_ioctl(struct dvb_frontend *fe, unsigned int cmd, void *arg) +static int dec2000_frontend_ioctl(struct dvb_frontend *fe, unsigned int cmd, + void *arg) { - dprintk("%s\n", __FUNCTION__); switch (cmd) { @@ -58,51 +55,49 @@ dec2000_frontend_ioctl(struct dvb_frontend *fe, unsigned int cmd, void *arg) sizeof (struct dvb_frontend_info)); break; - case FE_READ_STATUS:{ - fe_status_t *status = (fe_status_t *) arg; + case FE_READ_STATUS: { + fe_status_t *status = (fe_status_t *)arg; dprintk("%s: FE_READ_STATUS\n", __FUNCTION__); - *status = - FE_HAS_SIGNAL | FE_HAS_VITERBI | FE_HAS_SYNC | - FE_HAS_CARRIER | FE_HAS_LOCK; + *status = FE_HAS_SIGNAL | FE_HAS_VITERBI | + FE_HAS_SYNC | FE_HAS_CARRIER | FE_HAS_LOCK; break; } - case FE_READ_BER:{ - u32 *ber = (u32 *) arg; + case FE_READ_BER: { + u32 *ber = (u32 *)arg; dprintk("%s: FE_READ_BER\n", __FUNCTION__); *ber = 0; return -ENOSYS; break; } - case FE_READ_SIGNAL_STRENGTH:{ + case FE_READ_SIGNAL_STRENGTH: { dprintk("%s: FE_READ_SIGNAL_STRENGTH\n", __FUNCTION__); - *(s32 *) arg = 0xFF; + *(s32 *)arg = 0xFF; return -ENOSYS; break; } case FE_READ_SNR: dprintk("%s: FE_READ_SNR\n", __FUNCTION__); - *(s32 *) arg = 0; + *(s32 *)arg = 0; return -ENOSYS; break; case FE_READ_UNCORRECTED_BLOCKS: dprintk("%s: FE_READ_UNCORRECTED_BLOCKS\n", __FUNCTION__); - *(u32 *) arg = 0; + *(u32 *)arg = 0; return -ENOSYS; break; case FE_SET_FRONTEND:{ struct dvb_frontend_parameters *p = - (struct dvb_frontend_parameters *) arg; - u8 b[] = - { 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xff, - 0x00, 0x00, 0x00, 0xff }; + (struct dvb_frontend_parameters *)arg; + u8 b[] = { 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0xff, 0x00, 0x00, 0x00, 0xff }; u32 freq; - struct i2c_msg msg = { addr: 0x71, flags: 0, len:20 }; + struct i2c_msg msg = { addr: 0x71, flags: 0, len:20 }; dprintk("%s: FE_SET_FRONTEND\n", __FUNCTION__); @@ -143,47 +138,34 @@ dec2000_frontend_ioctl(struct dvb_frontend *fe, unsigned int cmd, void *arg) } return 0; - } -static int -dec2000_frontend_attach(struct dvb_i2c_bus *i2c) +static int dec2000_frontend_attach(struct dvb_i2c_bus *i2c) { - dprintk("%s\n", __FUNCTION__); dvb_register_frontend(dec2000_frontend_ioctl, i2c, NULL, &dec2000_frontend_info); return 0; - } -static void -dec2000_frontend_detach(struct dvb_i2c_bus *i2c) +static void dec2000_frontend_detach(struct dvb_i2c_bus *i2c) { - dprintk("%s\n", __FUNCTION__); dvb_unregister_frontend(dec2000_frontend_ioctl, i2c); - } -static int __init -dec2000_frontend_init(void) +static int __init dec2000_frontend_init(void) { - return dvb_register_i2c_device(THIS_MODULE, dec2000_frontend_attach, dec2000_frontend_detach); - } -static void __exit -dec2000_frontend_exit(void) +static void __exit dec2000_frontend_exit(void) { - dvb_unregister_i2c_device(dec2000_frontend_attach); - } module_init(dec2000_frontend_init); diff --git a/linux/drivers/media/dvb/ttusb-dec/ttusb_dec.c b/linux/drivers/media/dvb/ttusb-dec/ttusb_dec.c index 3f625e12e..cf4a8dc8d 100644 --- a/linux/drivers/media/dvb/ttusb-dec/ttusb_dec.c +++ b/linux/drivers/media/dvb/ttusb-dec/ttusb_dec.c @@ -32,11 +32,10 @@ static int debug = 0; #define dprintk if (debug) printk -static int -ttusb_dec_send_command(struct ttusb_dec * dec, const u8 command, int param_length, - const u8 params[], int *result_length, u8 cmd_result[]) +static int ttusb_dec_send_command(struct ttusb_dec *dec, const u8 command, + int param_length, const u8 params[], + int *result_length, u8 cmd_result[]) { - int result, actual_len, i; u8 b[COMMAND_PACKET_SIZE + 4]; u8 c[COMMAND_PACKET_SIZE + 4]; @@ -44,10 +43,8 @@ ttusb_dec_send_command(struct ttusb_dec * dec, const u8 command, int param_lengt dprintk("%s\n", __FUNCTION__); if ((result = down_interruptible(&dec->usb_sem))) { - printk("%s: Failed to down usb semaphore.\n", __FUNCTION__); return result; - } b[0] = 0xaa; @@ -59,47 +56,36 @@ ttusb_dec_send_command(struct ttusb_dec * dec, const u8 command, int param_lengt memcpy(&b[4], params, param_length); if (debug) { - printk("%s: command: ", __FUNCTION__); for (i = 0; i < param_length + 4; i++) printk("0x%02X ", b[i]); printk("\n"); - } - result = - usb_bulk_msg(dec->udev, dec->command_pipe, b, sizeof (b), - &actual_len, HZ); + result = usb_bulk_msg(dec->udev, dec->command_pipe, b, sizeof(b), + &actual_len, HZ); if (result) { - printk("%s: command bulk message failed: error %d\n", __FUNCTION__, result); up(&dec->usb_sem); return result; - } - result = - usb_bulk_msg(dec->udev, dec->result_pipe, c, sizeof (c), - &actual_len, HZ); + result = usb_bulk_msg(dec->udev, dec->result_pipe, c, sizeof(c), + &actual_len, HZ); if (result) { - printk("%s: result bulk message failed: error %d\n", __FUNCTION__, result); up(&dec->usb_sem); return result; - } else { - if (debug) { - printk("%s: result: ", __FUNCTION__); for (i = 0; i < actual_len; i++) printk("0x%02X ", c[i]); printk("\n"); - } if (result_length) @@ -108,31 +94,24 @@ ttusb_dec_send_command(struct ttusb_dec * dec, const u8 command, int param_lengt memcpy(cmd_result, &c[4], c[3]); up(&dec->usb_sem); - return 0; + return 0; } - } -static int -ttusb_dec_av_pes2ts_cb(void *priv, unsigned char *data) +static int ttusb_dec_av_pes2ts_cb(void *priv, unsigned char *data) { - - struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *) priv; + struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)priv; dvbdmxfeed->cb.ts(data, 188, 0, 0, &dvbdmxfeed->feed.ts, DMX_OK); return 0; - } -static void -ttusb_dec_set_pids(struct ttusb_dec * dec) +static void ttusb_dec_set_pids(struct ttusb_dec *dec) { - - u8 b[] = - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff }; + u8 b[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff }; u16 pcr = htons(dec->pid[DMX_PES_PCR]); u16 audio = htons(dec->pid[DMX_PES_AUDIO]); @@ -144,101 +123,81 @@ ttusb_dec_set_pids(struct ttusb_dec * dec) memcpy(&b[2], &audio, 2); memcpy(&b[4], &video, 2); - ttusb_dec_send_command(dec, 0x50, sizeof (b), b, NULL, NULL); + ttusb_dec_send_command(dec, 0x50, sizeof(b), b, NULL, NULL); if (!down_interruptible(&dec->pes2ts_sem)) { - dvb_filter_pes2ts_init(&dec->a_pes2ts, dec->pid[DMX_PES_AUDIO], ttusb_dec_av_pes2ts_cb, dec->demux.feed); dvb_filter_pes2ts_init(&dec->v_pes2ts, dec->pid[DMX_PES_VIDEO], ttusb_dec_av_pes2ts_cb, dec->demux.feed); up(&dec->pes2ts_sem); - } - } -static int -ttusb_dec_i2c_master_xfer(struct dvb_i2c_bus *i2c, const struct i2c_msg msgs[], - int num) +static int ttusb_dec_i2c_master_xfer(struct dvb_i2c_bus *i2c, + const struct i2c_msg msgs[], int num) { - int result, i; dprintk("%s\n", __FUNCTION__); for (i = 0; i < num; i++) - if ((result = - ttusb_dec_send_command(i2c->data, msgs[i].addr, - msgs[i].len, msgs[i].buf, - NULL, NULL))) + if ((result = ttusb_dec_send_command(i2c->data, msgs[i].addr, + msgs[i].len, msgs[i].buf, + NULL, NULL))) return result; return 0; - } -static void -ttusb_dec_process_av_pes(struct ttusb_dec * dec, u8 * av_pes, int length) +static void ttusb_dec_process_av_pes(struct ttusb_dec * dec, u8 * av_pes, + int length) { - int i; u16 csum = 0; u8 c; if (length < 16) { - printk("%s: packet too short.\n", __FUNCTION__); return; - } for (i = 0; i < length; i += 2) { - - csum ^= le16_to_cpup((u16 *) (av_pes + i)); + csum ^= le16_to_cpup((u16 *)(av_pes + i)); c = av_pes[i]; av_pes[i] = av_pes[i + 1]; av_pes[i + 1] = c; - } if (csum) { - printk("%s: checksum failed.\n", __FUNCTION__); return; - } if (length > 8 + MAX_AV_PES_LENGTH + 4) { - printk("%s: packet too long.\n", __FUNCTION__); return; - } if (!(av_pes[0] == 'A' && av_pes[1] == 'V')) { - printk("%s: invalid AV_PES packet.\n", __FUNCTION__); return; - } switch (av_pes[2]) { - case 0x01:{ /* VideoStream */ + case 0x01: { /* VideoStream */ int prebytes = av_pes[5] & 0x03; int postbytes = (av_pes[5] & 0x0c) >> 2; u16 v_pes_payload_length; - if (dec->v_pes_postbytes > 0 - && dec->v_pes_postbytes == prebytes) { - + if (dec->v_pes_postbytes > 0 && + dec->v_pes_postbytes == prebytes) { memcpy(&dec->v_pes[dec->v_pes_length], &av_pes[12], prebytes); if (!down_interruptible(&dec->pes2ts_sem)) { - dvb_filter_pes2ts(&dec->v_pes2ts, dec->v_pes, dec->v_pes_length + @@ -246,71 +205,59 @@ ttusb_dec_process_av_pes(struct ttusb_dec * dec, u8 * av_pes, int length) up(&dec->pes2ts_sem); } - } if (av_pes[5] & 0x10) { - dec->v_pes[7] = 0x80; dec->v_pes[8] = 0x05; - dec->v_pes[9] = - 0x21 | ((av_pes[8] & 0xc0) >> 5); - dec->v_pes[10] = - ((av_pes[8] & 0x3f) << 2) | - ((av_pes[9] & 0xc0) >> 6); - dec->v_pes[11] = - 0x01 | ((av_pes[9] & 0x3f) << 2) | - ((av_pes[10] & 0x80) >> 6); - dec->v_pes[12] = - ((av_pes[10] & 0x7f) << 1) | - ((av_pes[11] & 0xc0) >> 7); - dec->v_pes[13] = - 0x01 | ((av_pes[11] & 0x7f) << 1); + dec->v_pes[9] = 0x21 | + ((av_pes[8] & 0xc0) >> 5); + dec->v_pes[10] = ((av_pes[8] & 0x3f) << 2) | + ((av_pes[9] & 0xc0) >> 6); + dec->v_pes[11] = 0x01 | + ((av_pes[9] & 0x3f) << 2) | + ((av_pes[10] & 0x80) >> 6); + dec->v_pes[12] = ((av_pes[10] & 0x7f) << 1) | + ((av_pes[11] & 0xc0) >> 7); + dec->v_pes[13] = 0x01 | + ((av_pes[11] & 0x7f) << 1); memcpy(&dec->v_pes[14], &av_pes[12 + prebytes], length - 16 - prebytes); dec->v_pes_length = 14 + length - 16 - prebytes; - } else { - dec->v_pes[7] = 0x00; dec->v_pes[8] = 0x00; memcpy(&dec->v_pes[9], &av_pes[8], length - 12); dec->v_pes_length = 9 + length - 12; - } dec->v_pes_postbytes = postbytes; - if (dec->v_pes[9 + dec->v_pes[8]] == 0x00 - && dec->v_pes[10 + dec->v_pes[8]] == 0x00 - && dec->v_pes[11 + dec->v_pes[8]] == 0x01) + if (dec->v_pes[9 + dec->v_pes[8]] == 0x00 && + dec->v_pes[10 + dec->v_pes[8]] == 0x00 && + dec->v_pes[11 + dec->v_pes[8]] == 0x01) dec->v_pes[6] = 0x84; else dec->v_pes[6] = 0x80; - v_pes_payload_length = - htons(dec->v_pes_length - 6 + postbytes); + v_pes_payload_length = htons(dec->v_pes_length - 6 + + postbytes); memcpy(&dec->v_pes[4], &v_pes_payload_length, 2); if (postbytes == 0) { - if (!down_interruptible(&dec->pes2ts_sem)) { - dvb_filter_pes2ts(&dec->v_pes2ts, dec->v_pes, dec->v_pes_length); up(&dec->pes2ts_sem); - } - } break; - } case 0x02: /* MainAudioStream */ @@ -323,30 +270,23 @@ ttusb_dec_process_av_pes(struct ttusb_dec * dec, u8 * av_pes, int length) break; } - } -static void -ttusb_dec_process_urb_frame(struct ttusb_dec * dec, u8 * b, int length) +static void ttusb_dec_process_urb_frame(struct ttusb_dec * dec, u8 * b, + int length) { - while (length) { - switch (dec->av_pes_state) { case 0: case 1: case 3: if (*b++ == 0xaa) { - dec->av_pes_state++; if (dec->av_pes_state == 4) dec->av_pes_length = 0; - } else { - dec->av_pes_state = 0; - } length--; @@ -354,13 +294,9 @@ ttusb_dec_process_urb_frame(struct ttusb_dec * dec, u8 * b, int length) case 2: if (*b++ == 0x00) { - dec->av_pes_state++; - } else { - dec->av_pes_state = 0; - } length--; @@ -370,40 +306,33 @@ ttusb_dec_process_urb_frame(struct ttusb_dec * dec, u8 * b, int length) dec->av_pes[dec->av_pes_length++] = *b++; if (dec->av_pes_length == 8) { - dec->av_pes_state++; - dec->av_pes_payload_length = - le16_to_cpup((u16 *) (dec->av_pes + 6)); - + dec->av_pes_payload_length = le16_to_cpup( + (u16 *)(dec->av_pes + 6)); } length--; break; - case 5:{ - - int remainder = - dec->av_pes_payload_length + 8 - - dec->av_pes_length; + case 5: { + int remainder = dec->av_pes_payload_length + + 8 - dec->av_pes_length; if (length >= remainder) { - memcpy(dec->av_pes + dec->av_pes_length, b, remainder); dec->av_pes_length += remainder; b += remainder; length -= remainder; dec->av_pes_state++; - } else { memcpy(&dec->av_pes[dec->av_pes_length], b, length); dec->av_pes_length += length; length = 0; - } - break; + break; } case 6: @@ -411,11 +340,9 @@ ttusb_dec_process_urb_frame(struct ttusb_dec * dec, u8 * b, int length) if (dec->av_pes_length == 8 + dec->av_pes_payload_length + 4) { - ttusb_dec_process_av_pes(dec, dec->av_pes, dec->av_pes_length); dec->av_pes_state = 0; - } length--; @@ -429,26 +356,20 @@ ttusb_dec_process_urb_frame(struct ttusb_dec * dec, u8 * b, int length) } } - } #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) -static void -ttusb_dec_process_urb(struct urb *urb) +static void ttusb_dec_process_urb(struct urb *urb) #else -static void -ttusb_dec_process_urb(struct urb *urb, struct pt_regs *ptregs) +static void ttusb_dec_process_urb(struct urb *urb, struct pt_regs *ptregs) #endif { - struct ttusb_dec *dec = urb->context; if (!urb->status) { - int i; for (i = 0; i < FRAMES_PER_ISO_BUF; i++) { - struct usb_iso_packet_descriptor *d; u8 *b; int length; @@ -458,34 +379,26 @@ ttusb_dec_process_urb(struct urb *urb, struct pt_regs *ptregs) length = d->actual_length; ttusb_dec_process_urb_frame(dec, b, length); - } - } else { - /* -ENOENT is expected when unlinking urbs */ if (urb->status != -ENOENT) dprintk("%s: urb error: %d\n", __FUNCTION__, urb->status); - } #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) usb_submit_urb(urb URB_MEM_FLAG); #endif - } -static void -ttusb_dec_setup_urbs(struct ttusb_dec * dec) +static void ttusb_dec_setup_urbs(struct ttusb_dec *dec) { - int i, j, buffer_offset = 0; dprintk("%s\n", __FUNCTION__); for (i = 0; i < ISO_BUF_COUNT; i++) { - int frame_offset = 0; struct urb *urb = dec->iso_urb[i]; @@ -498,27 +411,21 @@ ttusb_dec_setup_urbs(struct ttusb_dec * dec) urb->interval = 1; #endif urb->number_of_packets = FRAMES_PER_ISO_BUF; - urb->transfer_buffer_length = - ISO_FRAME_SIZE * FRAMES_PER_ISO_BUF; + urb->transfer_buffer_length = ISO_FRAME_SIZE * + FRAMES_PER_ISO_BUF; urb->transfer_buffer = dec->iso_buffer + buffer_offset; buffer_offset += ISO_FRAME_SIZE * FRAMES_PER_ISO_BUF; for (j = 0; j < FRAMES_PER_ISO_BUF; j++) { - urb->iso_frame_desc[j].offset = frame_offset; urb->iso_frame_desc[j].length = ISO_FRAME_SIZE; frame_offset += ISO_FRAME_SIZE; - } - } - } -static void -ttusb_dec_stop_iso_xfer(struct ttusb_dec * dec) +static void ttusb_dec_stop_iso_xfer(struct ttusb_dec *dec) { - int i; dprintk("%s\n", __FUNCTION__); @@ -529,24 +436,19 @@ ttusb_dec_stop_iso_xfer(struct ttusb_dec * dec) dec->iso_stream_count--; if (!dec->iso_stream_count) { - u8 b0[] = { 0x00 }; for (i = 0; i < ISO_BUF_COUNT; i++) usb_unlink_urb(dec->iso_urb[i]); - ttusb_dec_send_command(dec, 0x81, sizeof (b0), b0, NULL, NULL); - + ttusb_dec_send_command(dec, 0x81, sizeof(b0), b0, NULL, NULL); } up(&dec->iso_sem); - } -static int -ttusb_dec_start_iso_xfer(struct ttusb_dec *dec) +static int ttusb_dec_start_iso_xfer(struct ttusb_dec *dec) { - int i, result; dprintk("%s\n", __FUNCTION__); @@ -556,48 +458,39 @@ ttusb_dec_start_iso_xfer(struct ttusb_dec *dec) #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) if (!dec->interface) { - /* Can't do this at mod init time - weird. * Seems to work up here for 2.5 */ usb_set_interface(dec->udev, 0, 8); dec->interface = 8; - } #endif if (!dec->iso_stream_count) { - u8 b0[] = { 0x05 }; - ttusb_dec_send_command(dec, 0x80, sizeof (b0), b0, NULL, NULL); + ttusb_dec_send_command(dec, 0x80, sizeof(b0), b0, NULL, NULL); ttusb_dec_setup_urbs(dec); for (i = 0; i < ISO_BUF_COUNT; i++) { - - if ((result = usb_submit_urb(dec->iso_urb[i] URB_MEM_FLAG))) { - - printk("%s: failed urb submission %d: error %d\n", - __FUNCTION__, i, result); + if ((result = usb_submit_urb(dec->iso_urb[i] + URB_MEM_FLAG))) { + printk("%s: failed urb submission %d: " + "error %d\n", __FUNCTION__, i, result); while (i) { - usb_unlink_urb(dec->iso_urb[i - 1]); i--; - } up(&dec->iso_sem); return result; - } - } dec->av_pes_state = 0; dec->v_pes_postbytes = 0; - } dec->iso_stream_count++; @@ -606,7 +499,6 @@ ttusb_dec_start_iso_xfer(struct ttusb_dec *dec) #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) if (!dec->interface) { - /* Can't do this at mod init time - weird. * Don't stick this at the top of this function either - * it will cause the send_command to time out trying to get @@ -614,19 +506,14 @@ ttusb_dec_start_iso_xfer(struct ttusb_dec *dec) */ usb_set_interface(dec->udev, 0, 8); dec->interface = 8; - } #endif - return 0; - } -static int -ttusb_dec_start_feed(struct dvb_demux_feed *dvbdmxfeed) +static int ttusb_dec_start_feed(struct dvb_demux_feed *dvbdmxfeed) { - struct dvb_demux *dvbdmx = dvbdmxfeed->demux; struct ttusb_dec *dec = dvbdmx->priv; @@ -705,13 +592,10 @@ ttusb_dec_start_feed(struct dvb_demux_feed *dvbdmxfeed) ttusb_dec_start_iso_xfer(dec); return 0; - } -static int -ttusb_dec_stop_feed(struct dvb_demux_feed *dvbdmxfeed) +static int ttusb_dec_stop_feed(struct dvb_demux_feed *dvbdmxfeed) { - struct ttusb_dec *dec = dvbdmxfeed->demux->priv; dprintk("%s\n", __FUNCTION__); @@ -719,13 +603,10 @@ ttusb_dec_stop_feed(struct dvb_demux_feed *dvbdmxfeed) ttusb_dec_stop_iso_xfer(dec); return 0; - } -static void -ttusb_dec_free_iso_urbs(struct ttusb_dec * dec) +static void ttusb_dec_free_iso_urbs(struct ttusb_dec *dec) { - int i; dprintk("%s\n", __FUNCTION__); @@ -736,75 +617,60 @@ ttusb_dec_free_iso_urbs(struct ttusb_dec * dec) pci_free_consistent(NULL, ISO_FRAME_SIZE * (FRAMES_PER_ISO_BUF * - ISO_BUF_COUNT), dec->iso_buffer, - dec->iso_dma_handle); - + ISO_BUF_COUNT), + dec->iso_buffer, dec->iso_dma_handle); } -static int -ttusb_dec_alloc_iso_urbs(struct ttusb_dec * dec) +static int ttusb_dec_alloc_iso_urbs(struct ttusb_dec *dec) { - int i; dprintk("%s\n", __FUNCTION__); - dec->iso_buffer = - pci_alloc_consistent(NULL, - ISO_FRAME_SIZE * (FRAMES_PER_ISO_BUF * - ISO_BUF_COUNT), - &dec->iso_dma_handle); + dec->iso_buffer = pci_alloc_consistent(NULL, + ISO_FRAME_SIZE * + (FRAMES_PER_ISO_BUF * + ISO_BUF_COUNT), + &dec->iso_dma_handle); memset(dec->iso_buffer, 0, - sizeof (ISO_FRAME_SIZE * (FRAMES_PER_ISO_BUF * ISO_BUF_COUNT))); + sizeof(ISO_FRAME_SIZE * (FRAMES_PER_ISO_BUF * ISO_BUF_COUNT))); for (i = 0; i < ISO_BUF_COUNT; i++) { - struct urb *urb; if (!(urb = usb_alloc_urb(FRAMES_PER_ISO_BUF URB_MEM_FLAG))) { - ttusb_dec_free_iso_urbs(dec); return -ENOMEM; - } dec->iso_urb[i] = urb; - } ttusb_dec_setup_urbs(dec); #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) for (i = 0; i < ISO_BUF_COUNT; i++) { - int next = (i + 1) % ISO_BUF_COUNT; dec->iso_urb[i]->next = dec->iso_urb[next]; - } #endif return 0; - } -static void -ttusb_dec_init_v_pes(struct ttusb_dec * dec) +static void ttusb_dec_init_v_pes(struct ttusb_dec *dec) { - dprintk("%s\n", __FUNCTION__); dec->v_pes[0] = 0x00; dec->v_pes[1] = 0x00; dec->v_pes[2] = 0x01; dec->v_pes[3] = 0xe0; - } -static void -ttusb_dec_init_usb(struct ttusb_dec * dec) +static void ttusb_dec_init_usb(struct ttusb_dec *dec) { - dprintk("%s\n", __FUNCTION__); sema_init(&dec->usb_sem, 1); @@ -815,27 +681,24 @@ ttusb_dec_init_usb(struct ttusb_dec * dec) dec->stream_pipe = usb_rcvisocpipe(dec->udev, STREAM_PIPE); ttusb_dec_alloc_iso_urbs(dec); - } #include "dsp_dec2000.h" -static int -ttusb_dec_boot_dsp(struct ttusb_dec * dec) +static int ttusb_dec_boot_dsp(struct ttusb_dec *dec) { - int i, j, actual_len, result, size, trans_count; - u8 b0[] = - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1b, 0xc8, 0x61, 0x00 }; + u8 b0[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1b, 0xc8, 0x61, + 0x00 }; u8 b1[] = { 0x61 }; u8 b[ARM_PACKET_SIZE]; - u32 dsp_length = htonl(sizeof (dsp_dec2000)); + u32 dsp_length = htonl(sizeof(dsp_dec2000)); dprintk("%s\n", __FUNCTION__); memcpy(b0, &dsp_length, 4); - result = ttusb_dec_send_command(dec, 0x41, sizeof (b0), b0, NULL, NULL); + result = ttusb_dec_send_command(dec, 0x41, sizeof(b0), b0, NULL, NULL); if (result) return result; @@ -843,9 +706,8 @@ ttusb_dec_boot_dsp(struct ttusb_dec * dec) trans_count = 0; j = 0; - for (i = 0; i < sizeof (dsp_dec2000); i += COMMAND_PACKET_SIZE) { - - size = sizeof (dsp_dec2000) - i; + for (i = 0; i < sizeof(dsp_dec2000); i += COMMAND_PACKET_SIZE) { + size = sizeof(dsp_dec2000) - i; if (size > COMMAND_PACKET_SIZE) size = COMMAND_PACKET_SIZE; @@ -858,33 +720,24 @@ ttusb_dec_boot_dsp(struct ttusb_dec * dec) j += COMMAND_PACKET_SIZE + 4; if (j >= ARM_PACKET_SIZE) { - - result = - usb_bulk_msg(dec->udev, dec->command_pipe, b, - ARM_PACKET_SIZE, &actual_len, HZ / 10); + result = usb_bulk_msg(dec->udev, dec->command_pipe, b, + ARM_PACKET_SIZE, &actual_len, + HZ / 10); j = 0; - } else if (size < COMMAND_PACKET_SIZE) { - - result = - usb_bulk_msg(dec->udev, dec->command_pipe, b, - j - COMMAND_PACKET_SIZE + size, - &actual_len, HZ / 10); - + result = usb_bulk_msg(dec->udev, dec->command_pipe, b, + j - COMMAND_PACKET_SIZE + size, + &actual_len, HZ / 10); } - } - result = ttusb_dec_send_command(dec, 0x43, sizeof (b1), b1, NULL, NULL); + result = ttusb_dec_send_command(dec, 0x43, sizeof(b1), b1, NULL, NULL); return result; - } -static void -ttusb_dec_init_stb(struct ttusb_dec * dec) +static void ttusb_dec_init_stb(struct ttusb_dec *dec) { - u8 c[COMMAND_PACKET_SIZE]; int c_length; int result; @@ -895,44 +748,35 @@ ttusb_dec_init_stb(struct ttusb_dec * dec) if (!result) if (c_length == 0x10 || /* f/w v0.78 */ - (c_length == 0x0c && c[9] != 0x42)) /* f/w v1.05 */ + (c_length == 0x0c && c[0] != 0xff)) /* f/w v1.05 */ ttusb_dec_boot_dsp(dec); - } -static int -ttusb_dec_init_dvb(struct ttusb_dec * dec) +static int ttusb_dec_init_dvb(struct ttusb_dec *dec) { - int result; dprintk("%s\n", __FUNCTION__); if ((result = dvb_register_adapter(&dec->adapter, "dec2000")) < 0) { - printk("%s: dvb_register_adapter failed: error %d\n", __FUNCTION__, result); return result; - } - if (! - (dec->i2c_bus = - dvb_register_i2c_bus(ttusb_dec_i2c_master_xfer, dec, dec->adapter, - 0))) { - + if (!(dec->i2c_bus = dvb_register_i2c_bus(ttusb_dec_i2c_master_xfer, + dec, dec->adapter, 0))) { printk("%s: dvb_register_i2c_bus failed\n", __FUNCTION__); dvb_unregister_adapter(dec->adapter); return -ENOMEM; - } dec->demux.dmx.capabilities = DMX_TS_FILTERING | DMX_SECTION_FILTERING; - dec->demux.priv = (void *) dec; + dec->demux.priv = (void *)dec; dec->demux.filternum = 31; dec->demux.feednum = 31; dec->demux.start_feed = ttusb_dec_start_feed; @@ -940,7 +784,6 @@ ttusb_dec_init_dvb(struct ttusb_dec * dec) dec->demux.write_to_decoder = NULL; if ((result = dvb_dmx_init(&dec->demux)) < 0) { - printk("%s: dvb_dmx_init failed: error %d\n", __FUNCTION__, result); @@ -949,7 +792,6 @@ ttusb_dec_init_dvb(struct ttusb_dec * dec) dvb_unregister_adapter(dec->adapter); return result; - } dec->dmxdev.filternum = 32; @@ -957,7 +799,6 @@ ttusb_dec_init_dvb(struct ttusb_dec * dec) dec->dmxdev.capabilities = 0; if ((result = dvb_dmxdev_init(&dec->dmxdev, dec->adapter)) < 0) { - printk("%s: dvb_dmxdev_init failed: error %d\n", __FUNCTION__, result); @@ -967,15 +808,12 @@ ttusb_dec_init_dvb(struct ttusb_dec * dec) dvb_unregister_adapter(dec->adapter); return result; - } dec->frontend.source = DMX_FRONTEND_0; - if ((result = - dec->demux.dmx.add_frontend(&dec->demux.dmx, - &dec->frontend)) < 0) { - + if ((result = dec->demux.dmx.add_frontend(&dec->demux.dmx, + &dec->frontend)) < 0) { printk("%s: dvb_dmx_init failed: error %d\n", __FUNCTION__, result); @@ -986,13 +824,10 @@ ttusb_dec_init_dvb(struct ttusb_dec * dec) dvb_unregister_adapter(dec->adapter); return result; - } - if ((result = - dec->demux.dmx.connect_frontend(&dec->demux.dmx, - &dec->frontend)) < 0) { - + if ((result = dec->demux.dmx.connect_frontend(&dec->demux.dmx, + &dec->frontend)) < 0) { printk("%s: dvb_dmx_init failed: error %d\n", __FUNCTION__, result); @@ -1004,7 +839,6 @@ ttusb_dec_init_dvb(struct ttusb_dec * dec) dvb_unregister_adapter(dec->adapter); return result; - } sema_init(&dec->pes2ts_sem, 1); @@ -1012,13 +846,10 @@ ttusb_dec_init_dvb(struct ttusb_dec * dec) dvb_net_init(dec->adapter, &dec->dvb_net, &dec->demux.dmx); return 0; - } -static void -ttusb_dec_exit_dvb(struct ttusb_dec * dec) +static void ttusb_dec_exit_dvb(struct ttusb_dec *dec) { - dprintk("%s\n", __FUNCTION__); dvb_net_release(&dec->dvb_net); @@ -1028,13 +859,10 @@ ttusb_dec_exit_dvb(struct ttusb_dec * dec) dvb_dmx_release(&dec->demux); dvb_unregister_i2c_bus(ttusb_dec_i2c_master_xfer, dec->adapter, 0); dvb_unregister_adapter(dec->adapter); - } -static void -ttusb_dec_exit_usb(struct ttusb_dec * dec) +static void ttusb_dec_exit_usb(struct ttusb_dec *dec) { - int i; dprintk("%s\n", __FUNCTION__); @@ -1043,15 +871,12 @@ ttusb_dec_exit_usb(struct ttusb_dec * dec) usb_unlink_urb(dec->iso_urb[i]); ttusb_dec_free_iso_urbs(dec); - } #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) -static void * -ttusb_dec_probe(struct usb_device *udev, unsigned int ifnum, - const struct usb_device_id *id) +static void *ttusb_dec_probe(struct usb_device *udev, unsigned int ifnum, + const struct usb_device_id *id) { - struct ttusb_dec *dec; dprintk("%s\n", __FUNCTION__); @@ -1059,33 +884,26 @@ ttusb_dec_probe(struct usb_device *udev, unsigned int ifnum, if (ifnum != 0) return NULL; - if (!(dec = kmalloc(sizeof (struct ttusb_dec), GFP_KERNEL))) { - + if (!(dec = kmalloc(sizeof(struct ttusb_dec), GFP_KERNEL))) { printk("%s: couldn't allocate memory.\n", __FUNCTION__); return NULL; - } - memset(dec, 0, sizeof (struct ttusb_dec)); + memset(dec, 0, sizeof(struct ttusb_dec)); dec->udev = udev; ttusb_dec_init_usb(dec); - ttusb_dec_init_stb(dec); - ttusb_dec_init_dvb(dec); - ttusb_dec_init_v_pes(dec); - return (void *) dec; - + return (void *)dec; } #else -static int -ttusb_dec_probe(struct usb_interface *intf, const struct usb_device_id *id) +static int ttusb_dec_probe(struct usb_interface *intf, + const struct usb_device_id *id) { - struct usb_device *udev; struct ttusb_dec *dec; @@ -1093,43 +911,33 @@ ttusb_dec_probe(struct usb_interface *intf, const struct usb_device_id *id) udev = interface_to_usbdev(intf); - if (!(dec = kmalloc(sizeof (struct ttusb_dec), GFP_KERNEL))) { - + if (!(dec = kmalloc(sizeof(struct ttusb_dec), GFP_KERNEL))) { printk("%s: couldn't allocate memory.\n", __FUNCTION__); return -ENOMEM; - } - memset(dec, 0, sizeof (struct ttusb_dec)); + memset(dec, 0, sizeof(struct ttusb_dec)); dec->udev = udev; ttusb_dec_init_usb(dec); - ttusb_dec_init_stb(dec); - ttusb_dec_init_dvb(dec); - ttusb_dec_init_v_pes(dec); usb_set_intfdata(intf, (void *)dec); return 0; - } #endif #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) -static void -ttusb_dec_disconnect(struct usb_device *udev, void *data) +static void ttusb_dec_disconnect(struct usb_device *udev, void *data) { - struct ttusb_dec *dec = data; #else -static void -ttusb_dec_disconnect(struct usb_interface *intf) +static void ttusb_dec_disconnect(struct usb_interface *intf) { - struct ttusb_dec *dec = usb_get_intfdata(intf); usb_set_intfdata(intf, NULL); @@ -1138,55 +946,41 @@ ttusb_dec_disconnect(struct usb_interface *intf) dprintk("%s\n", __FUNCTION__); ttusb_dec_exit_usb(dec); - ttusb_dec_exit_dvb(dec); kfree(dec); - } static struct usb_device_id ttusb_dec_table[] = { - {USB_DEVICE(0x0b48, 0x1006)}, /* Unconfirmed */ {USB_DEVICE(0x0b48, 0x1007)}, /* Unconfirmed */ {USB_DEVICE(0x0b48, 0x1008)}, /* DEC 2000 t */ {} - }; static struct usb_driver ttusb_dec_driver = { - name: DRIVER_NAME, probe: ttusb_dec_probe, disconnect: ttusb_dec_disconnect, id_table: ttusb_dec_table, - }; -static int __init -ttusb_dec_init(void) +static int __init ttusb_dec_init(void) { - int result; if ((result = usb_register(&ttusb_dec_driver)) < 0) { - printk("%s: initialisation failed: error %d.\n", __FUNCTION__, result); return result; - } return 0; - } -static void __exit -ttusb_dec_exit(void) +static void __exit ttusb_dec_exit(void) { - usb_deregister(&ttusb_dec_driver); - } module_init(ttusb_dec_init); diff --git a/linux/drivers/media/dvb/ttusb-dec/ttusb_dec.h b/linux/drivers/media/dvb/ttusb-dec/ttusb_dec.h index e0b9097be..7268803d2 100644 --- a/linux/drivers/media/dvb/ttusb-dec/ttusb_dec.h +++ b/linux/drivers/media/dvb/ttusb-dec/ttusb_dec.h @@ -45,7 +45,6 @@ #define MAX_AV_PES_LENGTH 6144 struct ttusb_dec { - /* DVB bits */ struct dvb_adapter *adapter; struct dmxdev dmxdev; @@ -83,7 +82,6 @@ struct ttusb_dec { u8 v_pes[16 + MAX_AV_PES_LENGTH]; int v_pes_length; int v_pes_postbytes; - }; #endif |