4 * Copyright (C) 2003-2004 Alex Woods <linux-dvb@giblets.org>
5 * IR support by Peter Beutner <p.beutner@gmx.net>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include <asm/semaphore.h>
24 #include <linux/list.h>
25 #include <linux/module.h>
26 #include <linux/moduleparam.h>
27 #include <linux/pci.h>
28 #include <linux/slab.h>
29 #include <linux/spinlock.h>
30 #include <linux/usb.h>
31 #include <linux/version.h>
32 #include <linux/interrupt.h>
33 #include <linux/firmware.h>
34 #include <linux/crc32.h>
35 #include <linux/init.h>
36 #include <linux/input.h>
39 #include "dvb_demux.h"
40 #include "dvb_filter.h"
41 #include "dvb_frontend.h"
43 #include "ttusbdecfe.h"
46 static int output_pva
;
49 module_param(debug
, int, 0644);
50 MODULE_PARM_DESC(debug
, "Turn on/off debugging (default:off).");
51 module_param(output_pva
, int, 0444);
52 MODULE_PARM_DESC(output_pva
, "Output PVA from dvr device (default:off)");
53 module_param(enable_rc
, int, 0644);
54 MODULE_PARM_DESC(enable_rc
, "Turn on/off IR remote control(default: off)");
56 #define dprintk if (debug) printk
58 #define DRIVER_NAME "TechnoTrend/Hauppauge DEC USB"
60 #define COMMAND_PIPE 0x03
61 #define RESULT_PIPE 0x04
66 #define COMMAND_PACKET_SIZE 0x3c
67 #define ARM_PACKET_SIZE 0x1000
68 #define IRQ_PACKET_SIZE 0x8
70 #define ISO_BUF_COUNT 0x04
71 #define FRAMES_PER_ISO_BUF 0x04
72 #define ISO_FRAME_SIZE 0x0380
74 #define MAX_PVA_LENGTH 6144
76 enum ttusb_dec_model
{
82 enum ttusb_dec_packet_type
{
84 TTUSB_DEC_PACKET_SECTION
,
85 TTUSB_DEC_PACKET_EMPTY
88 enum ttusb_dec_interface
{
89 TTUSB_DEC_INTERFACE_INITIAL
,
90 TTUSB_DEC_INTERFACE_IN
,
91 TTUSB_DEC_INTERFACE_OUT
95 enum ttusb_dec_model model
;
101 struct dvb_adapter adapter
;
102 struct dmxdev dmxdev
;
103 struct dvb_demux demux
;
104 struct dmx_frontend frontend
;
105 struct dvb_net dvb_net
;
106 struct dvb_frontend
* fe
;
108 u16 pid
[DMX_PES_OTHER
];
111 struct usb_device
*udev
;
113 unsigned int command_pipe
;
114 unsigned int result_pipe
;
115 unsigned int in_pipe
;
116 unsigned int out_pipe
;
117 unsigned int irq_pipe
;
118 enum ttusb_dec_interface interface
;
119 struct semaphore usb_sem
;
123 dma_addr_t irq_dma_handle
;
125 dma_addr_t iso_dma_handle
;
126 struct urb
*iso_urb
[ISO_BUF_COUNT
];
127 int iso_stream_count
;
128 struct semaphore iso_sem
;
130 u8 packet
[MAX_PVA_LENGTH
+ 4];
131 enum ttusb_dec_packet_type packet_type
;
134 int packet_payload_length
;
137 int pva_stream_count
;
138 int filter_stream_count
;
140 struct dvb_filter_pes2ts a_pes2ts
;
141 struct dvb_filter_pes2ts v_pes2ts
;
143 u8 v_pes
[16 + MAX_PVA_LENGTH
];
147 struct list_head urb_frame_list
;
148 struct tasklet_struct urb_tasklet
;
149 spinlock_t urb_frame_list_lock
;
151 struct dvb_demux_filter
*audio_filter
;
152 struct dvb_demux_filter
*video_filter
;
153 struct list_head filter_info_list
;
154 spinlock_t filter_info_list_lock
;
156 struct input_dev rc_input_dev
;
158 int active
; /* Loaded successfully */
162 u8 data
[ISO_FRAME_SIZE
];
164 struct list_head urb_frame_list
;
169 struct dvb_demux_filter
*filter
;
170 struct list_head filter_info_list
;
173 static u16 rc_keys
[] = {
202 static void ttusb_dec_set_model(struct ttusb_dec
*dec
,
203 enum ttusb_dec_model model
);
205 static void ttusb_dec_handle_irq( struct urb
*urb
, struct pt_regs
*regs
)
207 struct ttusb_dec
* dec
= urb
->context
;
208 char *buffer
= dec
->irq_buffer
;
211 switch(urb
->status
) {
218 /* this urb is dead, cleanup */
219 dprintk("%s:urb shutting down with status: %d\n",
220 __FUNCTION__
, urb
->status
);
223 dprintk("%s:nonzero status received: %d\n",
224 __FUNCTION__
,urb
->status
);
228 if( (buffer
[0] == 0x1) && (buffer
[2] == 0x15) ) {
230 /* this is an fact a bit too simple implementation;
231 * the box also reports a keyrepeat signal
232 * (with buffer[3] == 0x40) in an intervall of ~100ms.
233 * But to handle this correctly we had to imlemenent some
234 * kind of timer which signals a 'key up' event if no
235 * keyrepeat signal is recieved for lets say 200ms.
236 * this should/could be added later ...
237 * for now lets report each signal as a key down and up*/
238 dprintk("%s:rc signal:%d\n", __FUNCTION__
, buffer
[4]);
239 input_report_key(&dec
->rc_input_dev
,rc_keys
[buffer
[4]-1],1);
240 input_report_key(&dec
->rc_input_dev
,rc_keys
[buffer
[4]-1],0);
241 input_sync(&dec
->rc_input_dev
);
244 exit
: retval
= usb_submit_urb(urb
, GFP_ATOMIC
);
246 printk("%s - usb_commit_urb failed with result: %d\n",
247 __FUNCTION__
, retval
);
250 static u16
crc16(u16 crc
, const u8
*buf
, size_t len
)
258 crc
^= (tmp
^ (tmp
<< 1)) << 4;
263 static int ttusb_dec_send_command(struct ttusb_dec
*dec
, const u8 command
,
264 int param_length
, const u8 params
[],
265 int *result_length
, u8 cmd_result
[])
267 int result
, actual_len
, i
;
270 dprintk("%s\n", __FUNCTION__
);
272 b
= kmalloc(COMMAND_PACKET_SIZE
+ 4, GFP_KERNEL
);
276 if ((result
= down_interruptible(&dec
->usb_sem
))) {
278 printk("%s: Failed to down usb semaphore.\n", __FUNCTION__
);
283 b
[1] = ++dec
->trans_count
;
288 memcpy(&b
[4], params
, param_length
);
291 printk("%s: command: ", __FUNCTION__
);
292 for (i
= 0; i
< param_length
+ 4; i
++)
293 printk("0x%02X ", b
[i
]);
297 result
= usb_bulk_msg(dec
->udev
, dec
->command_pipe
, b
,
298 COMMAND_PACKET_SIZE
+ 4, &actual_len
, 1000);
301 printk("%s: command bulk message failed: error %d\n",
302 __FUNCTION__
, result
);
308 result
= usb_bulk_msg(dec
->udev
, dec
->result_pipe
, b
,
309 COMMAND_PACKET_SIZE
+ 4, &actual_len
, 1000);
312 printk("%s: result bulk message failed: error %d\n",
313 __FUNCTION__
, result
);
319 printk("%s: result: ", __FUNCTION__
);
320 for (i
= 0; i
< actual_len
; i
++)
321 printk("0x%02X ", b
[i
]);
326 *result_length
= b
[3];
327 if (cmd_result
&& b
[3] > 0)
328 memcpy(cmd_result
, &b
[4], b
[3]);
337 static int ttusb_dec_get_stb_state (struct ttusb_dec
*dec
, unsigned int *mode
,
338 unsigned int *model
, unsigned int *version
)
340 u8 c
[COMMAND_PACKET_SIZE
];
345 dprintk("%s\n", __FUNCTION__
);
347 result
= ttusb_dec_send_command(dec
, 0x08, 0, NULL
, &c_length
, c
);
351 if (c_length
>= 0x0c) {
357 memcpy(&tmp
, &c
[4], 4);
360 if (version
!= NULL
) {
361 memcpy(&tmp
, &c
[8], 4);
362 *version
= ntohl(tmp
);
370 static int ttusb_dec_audio_pes2ts_cb(void *priv
, unsigned char *data
)
372 struct ttusb_dec
*dec
= (struct ttusb_dec
*)priv
;
374 dec
->audio_filter
->feed
->cb
.ts(data
, 188, NULL
, 0,
375 &dec
->audio_filter
->feed
->feed
.ts
,
381 static int ttusb_dec_video_pes2ts_cb(void *priv
, unsigned char *data
)
383 struct ttusb_dec
*dec
= (struct ttusb_dec
*)priv
;
385 dec
->video_filter
->feed
->cb
.ts(data
, 188, NULL
, 0,
386 &dec
->video_filter
->feed
->feed
.ts
,
392 static void ttusb_dec_set_pids(struct ttusb_dec
*dec
)
394 u8 b
[] = { 0x00, 0x00, 0x00, 0x00,
395 0x00, 0x00, 0xff, 0xff,
396 0xff, 0xff, 0xff, 0xff };
398 u16 pcr
= htons(dec
->pid
[DMX_PES_PCR
]);
399 u16 audio
= htons(dec
->pid
[DMX_PES_AUDIO
]);
400 u16 video
= htons(dec
->pid
[DMX_PES_VIDEO
]);
402 dprintk("%s\n", __FUNCTION__
);
404 memcpy(&b
[0], &pcr
, 2);
405 memcpy(&b
[2], &audio
, 2);
406 memcpy(&b
[4], &video
, 2);
408 ttusb_dec_send_command(dec
, 0x50, sizeof(b
), b
, NULL
, NULL
);
410 dvb_filter_pes2ts_init(&dec
->a_pes2ts
, dec
->pid
[DMX_PES_AUDIO
],
411 ttusb_dec_audio_pes2ts_cb
, dec
);
412 dvb_filter_pes2ts_init(&dec
->v_pes2ts
, dec
->pid
[DMX_PES_VIDEO
],
413 ttusb_dec_video_pes2ts_cb
, dec
);
414 dec
->v_pes_length
= 0;
415 dec
->v_pes_postbytes
= 0;
418 static void ttusb_dec_process_pva(struct ttusb_dec
*dec
, u8
*pva
, int length
)
421 printk("%s: packet too short - discarding\n", __FUNCTION__
);
425 if (length
> 8 + MAX_PVA_LENGTH
) {
426 printk("%s: packet too long - discarding\n", __FUNCTION__
);
432 case 0x01: { /* VideoStream */
433 int prebytes
= pva
[5] & 0x03;
434 int postbytes
= (pva
[5] & 0x0c) >> 2;
435 u16 v_pes_payload_length
;
438 dec
->video_filter
->feed
->cb
.ts(pva
, length
, NULL
, 0,
439 &dec
->video_filter
->feed
->feed
.ts
, DMX_OK
);
443 if (dec
->v_pes_postbytes
> 0 &&
444 dec
->v_pes_postbytes
== prebytes
) {
445 memcpy(&dec
->v_pes
[dec
->v_pes_length
],
448 dvb_filter_pes2ts(&dec
->v_pes2ts
, dec
->v_pes
,
449 dec
->v_pes_length
+ prebytes
, 1);
453 dec
->v_pes
[7] = 0x80;
454 dec
->v_pes
[8] = 0x05;
456 dec
->v_pes
[9] = 0x21 | ((pva
[8] & 0xc0) >> 5);
457 dec
->v_pes
[10] = ((pva
[8] & 0x3f) << 2) |
458 ((pva
[9] & 0xc0) >> 6);
459 dec
->v_pes
[11] = 0x01 |
460 ((pva
[9] & 0x3f) << 2) |
461 ((pva
[10] & 0x80) >> 6);
462 dec
->v_pes
[12] = ((pva
[10] & 0x7f) << 1) |
463 ((pva
[11] & 0xc0) >> 7);
464 dec
->v_pes
[13] = 0x01 | ((pva
[11] & 0x7f) << 1);
466 memcpy(&dec
->v_pes
[14], &pva
[12 + prebytes
],
467 length
- 12 - prebytes
);
468 dec
->v_pes_length
= 14 + length
- 12 - prebytes
;
470 dec
->v_pes
[7] = 0x00;
471 dec
->v_pes
[8] = 0x00;
473 memcpy(&dec
->v_pes
[9], &pva
[8], length
- 8);
474 dec
->v_pes_length
= 9 + length
- 8;
477 dec
->v_pes_postbytes
= postbytes
;
479 if (dec
->v_pes
[9 + dec
->v_pes
[8]] == 0x00 &&
480 dec
->v_pes
[10 + dec
->v_pes
[8]] == 0x00 &&
481 dec
->v_pes
[11 + dec
->v_pes
[8]] == 0x01)
482 dec
->v_pes
[6] = 0x84;
484 dec
->v_pes
[6] = 0x80;
486 v_pes_payload_length
= htons(dec
->v_pes_length
- 6 +
488 memcpy(&dec
->v_pes
[4], &v_pes_payload_length
, 2);
491 dvb_filter_pes2ts(&dec
->v_pes2ts
, dec
->v_pes
,
492 dec
->v_pes_length
, 1);
497 case 0x02: /* MainAudioStream */
499 dec
->audio_filter
->feed
->cb
.ts(pva
, length
, NULL
, 0,
500 &dec
->audio_filter
->feed
->feed
.ts
, DMX_OK
);
504 dvb_filter_pes2ts(&dec
->a_pes2ts
, &pva
[8], length
- 8,
509 printk("%s: unknown PVA type: %02x.\n", __FUNCTION__
,
515 static void ttusb_dec_process_filter(struct ttusb_dec
*dec
, u8
*packet
,
518 struct list_head
*item
;
519 struct filter_info
*finfo
;
520 struct dvb_demux_filter
*filter
= NULL
;
525 spin_lock_irqsave(&dec
->filter_info_list_lock
, flags
);
526 for (item
= dec
->filter_info_list
.next
; item
!= &dec
->filter_info_list
;
528 finfo
= list_entry(item
, struct filter_info
, filter_info_list
);
529 if (finfo
->stream_id
== sid
) {
530 filter
= finfo
->filter
;
534 spin_unlock_irqrestore(&dec
->filter_info_list_lock
, flags
);
537 filter
->feed
->cb
.sec(&packet
[2], length
- 2, NULL
, 0,
538 &filter
->filter
, DMX_OK
);
541 static void ttusb_dec_process_packet(struct ttusb_dec
*dec
)
547 if (dec
->packet_length
% 2) {
548 printk("%s: odd sized packet - discarding\n", __FUNCTION__
);
552 for (i
= 0; i
< dec
->packet_length
; i
+= 2)
553 csum
^= ((dec
->packet
[i
] << 8) + dec
->packet
[i
+ 1]);
556 printk("%s: checksum failed - discarding\n", __FUNCTION__
);
560 packet_id
= dec
->packet
[dec
->packet_length
- 4] << 8;
561 packet_id
+= dec
->packet
[dec
->packet_length
- 3];
563 if ((packet_id
!= dec
->next_packet_id
) && dec
->next_packet_id
) {
564 printk("%s: warning: lost packets between %u and %u\n",
565 __FUNCTION__
, dec
->next_packet_id
- 1, packet_id
);
568 if (packet_id
== 0xffff)
569 dec
->next_packet_id
= 0x8000;
571 dec
->next_packet_id
= packet_id
+ 1;
573 switch (dec
->packet_type
) {
574 case TTUSB_DEC_PACKET_PVA
:
575 if (dec
->pva_stream_count
)
576 ttusb_dec_process_pva(dec
, dec
->packet
,
577 dec
->packet_payload_length
);
580 case TTUSB_DEC_PACKET_SECTION
:
581 if (dec
->filter_stream_count
)
582 ttusb_dec_process_filter(dec
, dec
->packet
,
583 dec
->packet_payload_length
);
586 case TTUSB_DEC_PACKET_EMPTY
:
591 static void swap_bytes(u8
*b
, int length
)
595 length
-= length
% 2;
596 for (; length
; b
+= 2, length
-= 2) {
603 static void ttusb_dec_process_urb_frame(struct ttusb_dec
*dec
, u8
*b
,
606 swap_bytes(b
, length
);
609 switch (dec
->packet_state
) {
617 dec
->packet_state
= 0;
625 dec
->packet_length
= 0;
626 } else if (*b
!= 0xaa) {
627 dec
->packet_state
= 0;
635 dec
->packet
[dec
->packet_length
++] = *b
++;
637 if (dec
->packet_length
== 2) {
638 if (dec
->packet
[0] == 'A' &&
639 dec
->packet
[1] == 'V') {
641 TTUSB_DEC_PACKET_PVA
;
643 } else if (dec
->packet
[0] == 'S') {
645 TTUSB_DEC_PACKET_SECTION
;
647 } else if (dec
->packet
[0] == 0x00) {
649 TTUSB_DEC_PACKET_EMPTY
;
650 dec
->packet_payload_length
= 2;
651 dec
->packet_state
= 7;
653 printk("%s: unknown packet type: "
654 "%02x%02x\n", __FUNCTION__
,
655 dec
->packet
[0], dec
->packet
[1]);
656 dec
->packet_state
= 0;
664 dec
->packet
[dec
->packet_length
++] = *b
++;
666 if (dec
->packet_type
== TTUSB_DEC_PACKET_PVA
&&
667 dec
->packet_length
== 8) {
669 dec
->packet_payload_length
= 8 +
670 (dec
->packet
[6] << 8) +
672 } else if (dec
->packet_type
==
673 TTUSB_DEC_PACKET_SECTION
&&
674 dec
->packet_length
== 5) {
676 dec
->packet_payload_length
= 5 +
677 ((dec
->packet
[3] & 0x0f) << 8) +
685 int remainder
= dec
->packet_payload_length
-
688 if (length
>= remainder
) {
689 memcpy(dec
->packet
+ dec
->packet_length
,
691 dec
->packet_length
+= remainder
;
696 memcpy(&dec
->packet
[dec
->packet_length
],
698 dec
->packet_length
+= length
;
708 dec
->packet
[dec
->packet_length
++] = *b
++;
710 if (dec
->packet_type
== TTUSB_DEC_PACKET_SECTION
&&
711 dec
->packet_payload_length
% 2)
714 if (dec
->packet_length
==
715 dec
->packet_payload_length
+ tail
) {
716 ttusb_dec_process_packet(dec
);
717 dec
->packet_state
= 0;
725 printk("%s: illegal packet state encountered.\n",
727 dec
->packet_state
= 0;
732 static void ttusb_dec_process_urb_frame_list(unsigned long data
)
734 struct ttusb_dec
*dec
= (struct ttusb_dec
*)data
;
735 struct list_head
*item
;
736 struct urb_frame
*frame
;
740 spin_lock_irqsave(&dec
->urb_frame_list_lock
, flags
);
741 if ((item
= dec
->urb_frame_list
.next
) != &dec
->urb_frame_list
) {
742 frame
= list_entry(item
, struct urb_frame
,
744 list_del(&frame
->urb_frame_list
);
746 spin_unlock_irqrestore(&dec
->urb_frame_list_lock
,
750 spin_unlock_irqrestore(&dec
->urb_frame_list_lock
, flags
);
752 ttusb_dec_process_urb_frame(dec
, frame
->data
, frame
->length
);
757 static void ttusb_dec_process_urb(struct urb
*urb
, struct pt_regs
*ptregs
)
759 struct ttusb_dec
*dec
= urb
->context
;
764 for (i
= 0; i
< FRAMES_PER_ISO_BUF
; i
++) {
765 struct usb_iso_packet_descriptor
*d
;
768 struct urb_frame
*frame
;
770 d
= &urb
->iso_frame_desc
[i
];
771 b
= urb
->transfer_buffer
+ d
->offset
;
772 length
= d
->actual_length
;
774 if ((frame
= kmalloc(sizeof(struct urb_frame
),
778 memcpy(frame
->data
, b
, length
);
779 frame
->length
= length
;
781 spin_lock_irqsave(&dec
->urb_frame_list_lock
,
783 list_add_tail(&frame
->urb_frame_list
,
784 &dec
->urb_frame_list
);
785 spin_unlock_irqrestore(&dec
->urb_frame_list_lock
,
788 tasklet_schedule(&dec
->urb_tasklet
);
792 /* -ENOENT is expected when unlinking urbs */
793 if (urb
->status
!= -ENOENT
)
794 dprintk("%s: urb error: %d\n", __FUNCTION__
,
798 if (dec
->iso_stream_count
)
799 usb_submit_urb(urb
, GFP_ATOMIC
);
802 static void ttusb_dec_setup_urbs(struct ttusb_dec
*dec
)
804 int i
, j
, buffer_offset
= 0;
806 dprintk("%s\n", __FUNCTION__
);
808 for (i
= 0; i
< ISO_BUF_COUNT
; i
++) {
809 int frame_offset
= 0;
810 struct urb
*urb
= dec
->iso_urb
[i
];
812 urb
->dev
= dec
->udev
;
814 urb
->complete
= ttusb_dec_process_urb
;
815 urb
->pipe
= dec
->in_pipe
;
816 urb
->transfer_flags
= URB_ISO_ASAP
;
818 urb
->number_of_packets
= FRAMES_PER_ISO_BUF
;
819 urb
->transfer_buffer_length
= ISO_FRAME_SIZE
*
821 urb
->transfer_buffer
= dec
->iso_buffer
+ buffer_offset
;
822 buffer_offset
+= ISO_FRAME_SIZE
* FRAMES_PER_ISO_BUF
;
824 for (j
= 0; j
< FRAMES_PER_ISO_BUF
; j
++) {
825 urb
->iso_frame_desc
[j
].offset
= frame_offset
;
826 urb
->iso_frame_desc
[j
].length
= ISO_FRAME_SIZE
;
827 frame_offset
+= ISO_FRAME_SIZE
;
832 static void ttusb_dec_stop_iso_xfer(struct ttusb_dec
*dec
)
836 dprintk("%s\n", __FUNCTION__
);
838 if (down_interruptible(&dec
->iso_sem
))
841 dec
->iso_stream_count
--;
843 if (!dec
->iso_stream_count
) {
844 for (i
= 0; i
< ISO_BUF_COUNT
; i
++)
845 usb_kill_urb(dec
->iso_urb
[i
]);
851 /* Setting the interface of the DEC tends to take down the USB communications
852 * for a short period, so it's important not to call this function just before
853 * trying to talk to it.
855 static int ttusb_dec_set_interface(struct ttusb_dec
*dec
,
856 enum ttusb_dec_interface interface
)
861 if (interface
!= dec
->interface
) {
863 case TTUSB_DEC_INTERFACE_INITIAL
:
864 result
= usb_set_interface(dec
->udev
, 0, 0);
866 case TTUSB_DEC_INTERFACE_IN
:
867 result
= ttusb_dec_send_command(dec
, 0x80, sizeof(b
),
871 result
= usb_set_interface(dec
->udev
, 0, 8);
873 case TTUSB_DEC_INTERFACE_OUT
:
874 result
= usb_set_interface(dec
->udev
, 0, 1);
881 dec
->interface
= interface
;
887 static int ttusb_dec_start_iso_xfer(struct ttusb_dec
*dec
)
891 dprintk("%s\n", __FUNCTION__
);
893 if (down_interruptible(&dec
->iso_sem
))
896 if (!dec
->iso_stream_count
) {
897 ttusb_dec_setup_urbs(dec
);
899 dec
->packet_state
= 0;
900 dec
->v_pes_postbytes
= 0;
901 dec
->next_packet_id
= 0;
903 for (i
= 0; i
< ISO_BUF_COUNT
; i
++) {
904 if ((result
= usb_submit_urb(dec
->iso_urb
[i
],
906 printk("%s: failed urb submission %d: "
907 "error %d\n", __FUNCTION__
, i
, result
);
910 usb_kill_urb(dec
->iso_urb
[i
- 1]);
920 dec
->iso_stream_count
++;
927 static int ttusb_dec_start_ts_feed(struct dvb_demux_feed
*dvbdmxfeed
)
929 struct dvb_demux
*dvbdmx
= dvbdmxfeed
->demux
;
930 struct ttusb_dec
*dec
= dvbdmx
->priv
;
934 dprintk("%s\n", __FUNCTION__
);
936 dprintk(" ts_type:");
938 if (dvbdmxfeed
->ts_type
& TS_DECODER
)
939 dprintk(" TS_DECODER");
941 if (dvbdmxfeed
->ts_type
& TS_PACKET
)
942 dprintk(" TS_PACKET");
944 if (dvbdmxfeed
->ts_type
& TS_PAYLOAD_ONLY
)
945 dprintk(" TS_PAYLOAD_ONLY");
949 switch (dvbdmxfeed
->pes_type
) {
951 case DMX_TS_PES_VIDEO
:
952 dprintk(" pes_type: DMX_TS_PES_VIDEO\n");
953 dec
->pid
[DMX_PES_PCR
] = dvbdmxfeed
->pid
;
954 dec
->pid
[DMX_PES_VIDEO
] = dvbdmxfeed
->pid
;
955 dec
->video_filter
= dvbdmxfeed
->filter
;
956 ttusb_dec_set_pids(dec
);
959 case DMX_TS_PES_AUDIO
:
960 dprintk(" pes_type: DMX_TS_PES_AUDIO\n");
961 dec
->pid
[DMX_PES_AUDIO
] = dvbdmxfeed
->pid
;
962 dec
->audio_filter
= dvbdmxfeed
->filter
;
963 ttusb_dec_set_pids(dec
);
966 case DMX_TS_PES_TELETEXT
:
967 dec
->pid
[DMX_PES_TELETEXT
] = dvbdmxfeed
->pid
;
968 dprintk(" pes_type: DMX_TS_PES_TELETEXT\n");
972 dprintk(" pes_type: DMX_TS_PES_PCR\n");
973 dec
->pid
[DMX_PES_PCR
] = dvbdmxfeed
->pid
;
974 ttusb_dec_set_pids(dec
);
977 case DMX_TS_PES_OTHER
:
978 dprintk(" pes_type: DMX_TS_PES_OTHER\n");
982 dprintk(" pes_type: unknown (%d)\n", dvbdmxfeed
->pes_type
);
987 result
= ttusb_dec_send_command(dec
, 0x80, sizeof(b0
), b0
, NULL
, NULL
);
991 dec
->pva_stream_count
++;
992 return ttusb_dec_start_iso_xfer(dec
);
995 static int ttusb_dec_start_sec_feed(struct dvb_demux_feed
*dvbdmxfeed
)
997 struct ttusb_dec
*dec
= dvbdmxfeed
->demux
->priv
;
998 u8 b0
[] = { 0x00, 0x00, 0x00, 0x01,
999 0x00, 0x00, 0x00, 0x00,
1000 0x00, 0x00, 0x00, 0x00,
1001 0x00, 0x00, 0x00, 0x00,
1002 0x00, 0xff, 0x00, 0x00,
1003 0x00, 0x00, 0x00, 0x00,
1004 0x00, 0x00, 0x00, 0x00,
1007 u8 c
[COMMAND_PACKET_SIZE
];
1010 struct filter_info
*finfo
;
1011 unsigned long flags
;
1014 dprintk("%s\n", __FUNCTION__
);
1016 pid
= htons(dvbdmxfeed
->pid
);
1017 memcpy(&b0
[0], &pid
, 2);
1018 memcpy(&b0
[4], &x
, 1);
1019 memcpy(&b0
[5], &dvbdmxfeed
->filter
->filter
.filter_value
[0], 1);
1021 result
= ttusb_dec_send_command(dec
, 0x60, sizeof(b0
), b0
,
1025 if (c_length
== 2) {
1026 if (!(finfo
= kmalloc(sizeof(struct filter_info
),
1030 finfo
->stream_id
= c
[1];
1031 finfo
->filter
= dvbdmxfeed
->filter
;
1033 spin_lock_irqsave(&dec
->filter_info_list_lock
, flags
);
1034 list_add_tail(&finfo
->filter_info_list
,
1035 &dec
->filter_info_list
);
1036 spin_unlock_irqrestore(&dec
->filter_info_list_lock
,
1039 dvbdmxfeed
->priv
= finfo
;
1041 dec
->filter_stream_count
++;
1042 return ttusb_dec_start_iso_xfer(dec
);
1050 static int ttusb_dec_start_feed(struct dvb_demux_feed
*dvbdmxfeed
)
1052 struct dvb_demux
*dvbdmx
= dvbdmxfeed
->demux
;
1054 dprintk("%s\n", __FUNCTION__
);
1056 if (!dvbdmx
->dmx
.frontend
)
1059 dprintk(" pid: 0x%04X\n", dvbdmxfeed
->pid
);
1061 switch (dvbdmxfeed
->type
) {
1064 return ttusb_dec_start_ts_feed(dvbdmxfeed
);
1068 return ttusb_dec_start_sec_feed(dvbdmxfeed
);
1072 dprintk(" type: unknown (%d)\n", dvbdmxfeed
->type
);
1078 static int ttusb_dec_stop_ts_feed(struct dvb_demux_feed
*dvbdmxfeed
)
1080 struct ttusb_dec
*dec
= dvbdmxfeed
->demux
->priv
;
1083 ttusb_dec_send_command(dec
, 0x81, sizeof(b0
), b0
, NULL
, NULL
);
1085 dec
->pva_stream_count
--;
1087 ttusb_dec_stop_iso_xfer(dec
);
1092 static int ttusb_dec_stop_sec_feed(struct dvb_demux_feed
*dvbdmxfeed
)
1094 struct ttusb_dec
*dec
= dvbdmxfeed
->demux
->priv
;
1095 u8 b0
[] = { 0x00, 0x00 };
1096 struct filter_info
*finfo
= (struct filter_info
*)dvbdmxfeed
->priv
;
1097 unsigned long flags
;
1099 b0
[1] = finfo
->stream_id
;
1100 spin_lock_irqsave(&dec
->filter_info_list_lock
, flags
);
1101 list_del(&finfo
->filter_info_list
);
1102 spin_unlock_irqrestore(&dec
->filter_info_list_lock
, flags
);
1104 ttusb_dec_send_command(dec
, 0x62, sizeof(b0
), b0
, NULL
, NULL
);
1106 dec
->filter_stream_count
--;
1108 ttusb_dec_stop_iso_xfer(dec
);
1113 static int ttusb_dec_stop_feed(struct dvb_demux_feed
*dvbdmxfeed
)
1115 dprintk("%s\n", __FUNCTION__
);
1117 switch (dvbdmxfeed
->type
) {
1119 return ttusb_dec_stop_ts_feed(dvbdmxfeed
);
1123 return ttusb_dec_stop_sec_feed(dvbdmxfeed
);
1130 static void ttusb_dec_free_iso_urbs(struct ttusb_dec
*dec
)
1134 dprintk("%s\n", __FUNCTION__
);
1136 for (i
= 0; i
< ISO_BUF_COUNT
; i
++)
1137 if (dec
->iso_urb
[i
])
1138 usb_free_urb(dec
->iso_urb
[i
]);
1140 pci_free_consistent(NULL
,
1141 ISO_FRAME_SIZE
* (FRAMES_PER_ISO_BUF
*
1143 dec
->iso_buffer
, dec
->iso_dma_handle
);
1146 static int ttusb_dec_alloc_iso_urbs(struct ttusb_dec
*dec
)
1150 dprintk("%s\n", __FUNCTION__
);
1152 dec
->iso_buffer
= pci_alloc_consistent(NULL
,
1154 (FRAMES_PER_ISO_BUF
*
1156 &dec
->iso_dma_handle
);
1158 memset(dec
->iso_buffer
, 0,
1159 ISO_FRAME_SIZE
* (FRAMES_PER_ISO_BUF
* ISO_BUF_COUNT
));
1161 for (i
= 0; i
< ISO_BUF_COUNT
; i
++) {
1164 if (!(urb
= usb_alloc_urb(FRAMES_PER_ISO_BUF
, GFP_ATOMIC
))) {
1165 ttusb_dec_free_iso_urbs(dec
);
1169 dec
->iso_urb
[i
] = urb
;
1172 ttusb_dec_setup_urbs(dec
);
1177 static void ttusb_dec_init_tasklet(struct ttusb_dec
*dec
)
1179 spin_lock_init(&dec
->urb_frame_list_lock
);
1180 INIT_LIST_HEAD(&dec
->urb_frame_list
);
1181 tasklet_init(&dec
->urb_tasklet
, ttusb_dec_process_urb_frame_list
,
1182 (unsigned long)dec
);
1185 static void ttusb_init_rc( struct ttusb_dec
*dec
)
1187 u8 b
[] = { 0x00, 0x01 };
1190 init_input_dev(&dec
->rc_input_dev
);
1192 dec
->rc_input_dev
.name
= "ttusb_dec remote control";
1193 dec
->rc_input_dev
.evbit
[0] = BIT(EV_KEY
);
1194 dec
->rc_input_dev
.keycodesize
= sizeof(u16
);
1195 dec
->rc_input_dev
.keycodemax
= 0x1a;
1196 dec
->rc_input_dev
.keycode
= rc_keys
;
1198 for (i
= 0; i
< sizeof(rc_keys
)/sizeof(rc_keys
[0]); i
++)
1199 set_bit(rc_keys
[i
], dec
->rc_input_dev
.keybit
);
1201 input_register_device(&dec
->rc_input_dev
);
1203 if(usb_submit_urb(dec
->irq_urb
,GFP_KERNEL
)) {
1204 printk("%s: usb_submit_urb failed\n",__FUNCTION__
);
1206 /* enable irq pipe */
1207 ttusb_dec_send_command(dec
,0xb0,sizeof(b
),b
,NULL
,NULL
);
1210 static void ttusb_dec_init_v_pes(struct ttusb_dec
*dec
)
1212 dprintk("%s\n", __FUNCTION__
);
1214 dec
->v_pes
[0] = 0x00;
1215 dec
->v_pes
[1] = 0x00;
1216 dec
->v_pes
[2] = 0x01;
1217 dec
->v_pes
[3] = 0xe0;
1220 static int ttusb_dec_init_usb(struct ttusb_dec
*dec
)
1222 dprintk("%s\n", __FUNCTION__
);
1224 sema_init(&dec
->usb_sem
, 1);
1225 sema_init(&dec
->iso_sem
, 1);
1227 dec
->command_pipe
= usb_sndbulkpipe(dec
->udev
, COMMAND_PIPE
);
1228 dec
->result_pipe
= usb_rcvbulkpipe(dec
->udev
, RESULT_PIPE
);
1229 dec
->in_pipe
= usb_rcvisocpipe(dec
->udev
, IN_PIPE
);
1230 dec
->out_pipe
= usb_sndisocpipe(dec
->udev
, OUT_PIPE
);
1231 dec
->irq_pipe
= usb_rcvintpipe(dec
->udev
, IRQ_PIPE
);
1234 dec
->irq_urb
= usb_alloc_urb(0, GFP_KERNEL
);
1238 dec
->irq_buffer
= usb_buffer_alloc(dec
->udev
,IRQ_PACKET_SIZE
,
1239 SLAB_ATOMIC
, &dec
->irq_dma_handle
);
1240 if(!dec
->irq_buffer
) {
1243 usb_fill_int_urb(dec
->irq_urb
, dec
->udev
,dec
->irq_pipe
,
1244 dec
->irq_buffer
, IRQ_PACKET_SIZE
,
1245 ttusb_dec_handle_irq
, dec
, 1);
1246 dec
->irq_urb
->transfer_dma
= dec
->irq_dma_handle
;
1247 dec
->irq_urb
->transfer_flags
|= URB_NO_TRANSFER_DMA_MAP
;
1250 return ttusb_dec_alloc_iso_urbs(dec
);
1253 static int ttusb_dec_boot_dsp(struct ttusb_dec
*dec
)
1255 int i
, j
, actual_len
, result
, size
, trans_count
;
1256 u8 b0
[] = { 0x00, 0x00, 0x00, 0x00,
1257 0x00, 0x00, 0x00, 0x00,
1262 u8
*firmware
= NULL
;
1263 size_t firmware_size
= 0;
1264 u16 firmware_csum
= 0;
1265 u16 firmware_csum_ns
;
1266 u32 firmware_size_nl
;
1267 u32 crc32_csum
, crc32_check
, tmp
;
1268 const struct firmware
*fw_entry
= NULL
;
1270 dprintk("%s\n", __FUNCTION__
);
1272 if (request_firmware(&fw_entry
, dec
->firmware_name
, &dec
->udev
->dev
)) {
1273 printk(KERN_ERR
"%s: Firmware (%s) unavailable.\n",
1274 __FUNCTION__
, dec
->firmware_name
);
1278 firmware
= fw_entry
->data
;
1279 firmware_size
= fw_entry
->size
;
1281 if (firmware_size
< 60) {
1282 printk("%s: firmware size too small for DSP code (%zu < 60).\n",
1283 __FUNCTION__
, firmware_size
);
1287 /* a 32 bit checksum over the first 56 bytes of the DSP Code is stored
1288 at offset 56 of file, so use it to check if the firmware file is
1290 crc32_csum
= crc32(~0L, firmware
, 56) ^ ~0L;
1291 memcpy(&tmp
, &firmware
[56], 4);
1292 crc32_check
= htonl(tmp
);
1293 if (crc32_csum
!= crc32_check
) {
1294 printk("%s: crc32 check of DSP code failed (calculated "
1295 "0x%08x != 0x%08x in file), file invalid.\n",
1296 __FUNCTION__
, crc32_csum
, crc32_check
);
1299 memcpy(idstring
, &firmware
[36], 20);
1300 idstring
[20] = '\0';
1301 printk(KERN_INFO
"ttusb_dec: found DSP code \"%s\".\n", idstring
);
1303 firmware_size_nl
= htonl(firmware_size
);
1304 memcpy(b0
, &firmware_size_nl
, 4);
1305 firmware_csum
= crc16(~0, firmware
, firmware_size
) ^ ~0;
1306 firmware_csum_ns
= htons(firmware_csum
);
1307 memcpy(&b0
[6], &firmware_csum_ns
, 2);
1309 result
= ttusb_dec_send_command(dec
, 0x41, sizeof(b0
), b0
, NULL
, NULL
);
1317 b
= kmalloc(ARM_PACKET_SIZE
, GFP_KERNEL
);
1321 for (i
= 0; i
< firmware_size
; i
+= COMMAND_PACKET_SIZE
) {
1322 size
= firmware_size
- i
;
1323 if (size
> COMMAND_PACKET_SIZE
)
1324 size
= COMMAND_PACKET_SIZE
;
1327 b
[j
+ 1] = trans_count
++;
1330 memcpy(&b
[j
+ 4], &firmware
[i
], size
);
1332 j
+= COMMAND_PACKET_SIZE
+ 4;
1334 if (j
>= ARM_PACKET_SIZE
) {
1335 result
= usb_bulk_msg(dec
->udev
, dec
->command_pipe
, b
,
1336 ARM_PACKET_SIZE
, &actual_len
,
1339 } else if (size
< COMMAND_PACKET_SIZE
) {
1340 result
= usb_bulk_msg(dec
->udev
, dec
->command_pipe
, b
,
1341 j
- COMMAND_PACKET_SIZE
+ size
,
1346 result
= ttusb_dec_send_command(dec
, 0x43, sizeof(b1
), b1
, NULL
, NULL
);
1353 static int ttusb_dec_init_stb(struct ttusb_dec
*dec
)
1356 unsigned int mode
, model
, version
;
1358 dprintk("%s\n", __FUNCTION__
);
1360 result
= ttusb_dec_get_stb_state(dec
, &mode
, &model
, &version
);
1364 if (version
== 0xABCDEFAB)
1365 printk(KERN_INFO
"ttusb_dec: no version "
1366 "info in Firmware\n");
1368 printk(KERN_INFO
"ttusb_dec: Firmware "
1370 version
>> 24, (version
>> 16) & 0xff,
1371 (version
>> 8) & 0xff, version
& 0xff);
1373 result
= ttusb_dec_boot_dsp(dec
);
1379 /* We can't trust the USB IDs that some firmwares
1384 ttusb_dec_set_model(dec
, TTUSB_DEC3000S
);
1388 ttusb_dec_set_model(dec
, TTUSB_DEC2000T
);
1391 ttusb_dec_set_model(dec
, TTUSB_DEC2540T
);
1394 printk(KERN_ERR
"%s: unknown model returned "
1395 "by firmware (%08x) - please report\n",
1396 __FUNCTION__
, model
);
1401 if (version
>= 0x01770000)
1402 dec
->can_playback
= 1;
1411 static int ttusb_dec_init_dvb(struct ttusb_dec
*dec
)
1415 dprintk("%s\n", __FUNCTION__
);
1417 if ((result
= dvb_register_adapter(&dec
->adapter
,
1418 dec
->model_name
, THIS_MODULE
)) < 0) {
1419 printk("%s: dvb_register_adapter failed: error %d\n",
1420 __FUNCTION__
, result
);
1425 dec
->demux
.dmx
.capabilities
= DMX_TS_FILTERING
| DMX_SECTION_FILTERING
;
1427 dec
->demux
.priv
= (void *)dec
;
1428 dec
->demux
.filternum
= 31;
1429 dec
->demux
.feednum
= 31;
1430 dec
->demux
.start_feed
= ttusb_dec_start_feed
;
1431 dec
->demux
.stop_feed
= ttusb_dec_stop_feed
;
1432 dec
->demux
.write_to_decoder
= NULL
;
1434 if ((result
= dvb_dmx_init(&dec
->demux
)) < 0) {
1435 printk("%s: dvb_dmx_init failed: error %d\n", __FUNCTION__
,
1438 dvb_unregister_adapter(&dec
->adapter
);
1443 dec
->dmxdev
.filternum
= 32;
1444 dec
->dmxdev
.demux
= &dec
->demux
.dmx
;
1445 dec
->dmxdev
.capabilities
= 0;
1447 if ((result
= dvb_dmxdev_init(&dec
->dmxdev
, &dec
->adapter
)) < 0) {
1448 printk("%s: dvb_dmxdev_init failed: error %d\n",
1449 __FUNCTION__
, result
);
1451 dvb_dmx_release(&dec
->demux
);
1452 dvb_unregister_adapter(&dec
->adapter
);
1457 dec
->frontend
.source
= DMX_FRONTEND_0
;
1459 if ((result
= dec
->demux
.dmx
.add_frontend(&dec
->demux
.dmx
,
1460 &dec
->frontend
)) < 0) {
1461 printk("%s: dvb_dmx_init failed: error %d\n", __FUNCTION__
,
1464 dvb_dmxdev_release(&dec
->dmxdev
);
1465 dvb_dmx_release(&dec
->demux
);
1466 dvb_unregister_adapter(&dec
->adapter
);
1471 if ((result
= dec
->demux
.dmx
.connect_frontend(&dec
->demux
.dmx
,
1472 &dec
->frontend
)) < 0) {
1473 printk("%s: dvb_dmx_init failed: error %d\n", __FUNCTION__
,
1476 dec
->demux
.dmx
.remove_frontend(&dec
->demux
.dmx
, &dec
->frontend
);
1477 dvb_dmxdev_release(&dec
->dmxdev
);
1478 dvb_dmx_release(&dec
->demux
);
1479 dvb_unregister_adapter(&dec
->adapter
);
1484 dvb_net_init(&dec
->adapter
, &dec
->dvb_net
, &dec
->demux
.dmx
);
1489 static void ttusb_dec_exit_dvb(struct ttusb_dec
*dec
)
1491 dprintk("%s\n", __FUNCTION__
);
1493 dvb_net_release(&dec
->dvb_net
);
1494 dec
->demux
.dmx
.close(&dec
->demux
.dmx
);
1495 dec
->demux
.dmx
.remove_frontend(&dec
->demux
.dmx
, &dec
->frontend
);
1496 dvb_dmxdev_release(&dec
->dmxdev
);
1497 dvb_dmx_release(&dec
->demux
);
1498 if (dec
->fe
) dvb_unregister_frontend(dec
->fe
);
1499 dvb_unregister_adapter(&dec
->adapter
);
1502 static void ttusb_dec_exit_rc(struct ttusb_dec
*dec
)
1505 dprintk("%s\n", __FUNCTION__
);
1506 /* we have to check whether the irq URB is already submitted.
1507 * As the irq is submitted after the interface is changed,
1508 * this is the best method i figured out.
1510 if(dec
->interface
== TTUSB_DEC_INTERFACE_IN
)
1511 usb_kill_urb(dec
->irq_urb
);
1513 usb_free_urb(dec
->irq_urb
);
1515 usb_buffer_free(dec
->udev
,IRQ_PACKET_SIZE
,
1516 dec
->irq_buffer
, dec
->irq_dma_handle
);
1518 input_unregister_device(&dec
->rc_input_dev
);
1522 static void ttusb_dec_exit_usb(struct ttusb_dec
*dec
)
1526 dprintk("%s\n", __FUNCTION__
);
1528 dec
->iso_stream_count
= 0;
1530 for (i
= 0; i
< ISO_BUF_COUNT
; i
++)
1531 usb_kill_urb(dec
->iso_urb
[i
]);
1533 ttusb_dec_free_iso_urbs(dec
);
1536 static void ttusb_dec_exit_tasklet(struct ttusb_dec
*dec
)
1538 struct list_head
*item
;
1539 struct urb_frame
*frame
;
1541 tasklet_kill(&dec
->urb_tasklet
);
1543 while ((item
= dec
->urb_frame_list
.next
) != &dec
->urb_frame_list
) {
1544 frame
= list_entry(item
, struct urb_frame
, urb_frame_list
);
1545 list_del(&frame
->urb_frame_list
);
1550 static void ttusb_dec_init_filters(struct ttusb_dec
*dec
)
1552 INIT_LIST_HEAD(&dec
->filter_info_list
);
1553 spin_lock_init(&dec
->filter_info_list_lock
);
1556 static void ttusb_dec_exit_filters(struct ttusb_dec
*dec
)
1558 struct list_head
*item
;
1559 struct filter_info
*finfo
;
1561 while ((item
= dec
->filter_info_list
.next
) != &dec
->filter_info_list
) {
1562 finfo
= list_entry(item
, struct filter_info
, filter_info_list
);
1563 list_del(&finfo
->filter_info_list
);
1568 static int fe_send_command(struct dvb_frontend
* fe
, const u8 command
,
1569 int param_length
, const u8 params
[],
1570 int *result_length
, u8 cmd_result
[])
1572 struct ttusb_dec
* dec
= (struct ttusb_dec
*) fe
->dvb
->priv
;
1573 return ttusb_dec_send_command(dec
, command
, param_length
, params
, result_length
, cmd_result
);
1576 static struct ttusbdecfe_config fe_config
= {
1577 .send_command
= fe_send_command
1580 static int ttusb_dec_probe(struct usb_interface
*intf
,
1581 const struct usb_device_id
*id
)
1583 struct usb_device
*udev
;
1584 struct ttusb_dec
*dec
;
1586 dprintk("%s\n", __FUNCTION__
);
1588 udev
= interface_to_usbdev(intf
);
1590 if (!(dec
= kmalloc(sizeof(struct ttusb_dec
), GFP_KERNEL
))) {
1591 printk("%s: couldn't allocate memory.\n", __FUNCTION__
);
1595 usb_set_intfdata(intf
, (void *)dec
);
1597 memset(dec
, 0, sizeof(struct ttusb_dec
));
1599 switch (le16_to_cpu(id
->idProduct
)) {
1601 ttusb_dec_set_model(dec
, TTUSB_DEC3000S
);
1605 ttusb_dec_set_model(dec
, TTUSB_DEC2000T
);
1609 ttusb_dec_set_model(dec
, TTUSB_DEC2540T
);
1615 if (ttusb_dec_init_usb(dec
))
1617 if (ttusb_dec_init_stb(dec
)) {
1618 ttusb_dec_exit_usb(dec
);
1621 ttusb_dec_init_dvb(dec
);
1623 dec
->adapter
.priv
= dec
;
1624 switch (le16_to_cpu(id
->idProduct
)) {
1626 dec
->fe
= ttusbdecfe_dvbs_attach(&fe_config
);
1631 dec
->fe
= ttusbdecfe_dvbt_attach(&fe_config
);
1635 if (dec
->fe
== NULL
) {
1636 printk("dvb-ttusb-dec: A frontend driver was not found for device %04x/%04x\n",
1637 le16_to_cpu(dec
->udev
->descriptor
.idVendor
),
1638 le16_to_cpu(dec
->udev
->descriptor
.idProduct
));
1640 if (dvb_register_frontend(&dec
->adapter
, dec
->fe
)) {
1641 printk("budget-ci: Frontend registration failed!\n");
1642 if (dec
->fe
->ops
->release
)
1643 dec
->fe
->ops
->release(dec
->fe
);
1648 ttusb_dec_init_v_pes(dec
);
1649 ttusb_dec_init_filters(dec
);
1650 ttusb_dec_init_tasklet(dec
);
1654 ttusb_dec_set_interface(dec
, TTUSB_DEC_INTERFACE_IN
);
1662 static void ttusb_dec_disconnect(struct usb_interface
*intf
)
1664 struct ttusb_dec
*dec
= usb_get_intfdata(intf
);
1666 usb_set_intfdata(intf
, NULL
);
1668 dprintk("%s\n", __FUNCTION__
);
1671 ttusb_dec_exit_tasklet(dec
);
1672 ttusb_dec_exit_filters(dec
);
1674 ttusb_dec_exit_rc(dec
);
1675 ttusb_dec_exit_usb(dec
);
1676 ttusb_dec_exit_dvb(dec
);
1682 static void ttusb_dec_set_model(struct ttusb_dec
*dec
,
1683 enum ttusb_dec_model model
)
1688 case TTUSB_DEC2000T
:
1689 dec
->model_name
= "DEC2000-t";
1690 dec
->firmware_name
= "dvb-ttusb-dec-2000t.fw";
1693 case TTUSB_DEC2540T
:
1694 dec
->model_name
= "DEC2540-t";
1695 dec
->firmware_name
= "dvb-ttusb-dec-2540t.fw";
1698 case TTUSB_DEC3000S
:
1699 dec
->model_name
= "DEC3000-s";
1700 dec
->firmware_name
= "dvb-ttusb-dec-3000s.fw";
1705 static struct usb_device_id ttusb_dec_table
[] = {
1706 {USB_DEVICE(0x0b48, 0x1006)}, /* DEC3000-s */
1707 /*{USB_DEVICE(0x0b48, 0x1007)}, Unconfirmed */
1708 {USB_DEVICE(0x0b48, 0x1008)}, /* DEC2000-t */
1709 {USB_DEVICE(0x0b48, 0x1009)}, /* DEC2540-t */
1713 static struct usb_driver ttusb_dec_driver
= {
1714 .name
= "ttusb-dec",
1715 .probe
= ttusb_dec_probe
,
1716 .disconnect
= ttusb_dec_disconnect
,
1717 .id_table
= ttusb_dec_table
,
1720 static int __init
ttusb_dec_init(void)
1724 if ((result
= usb_register(&ttusb_dec_driver
)) < 0) {
1725 printk("%s: initialisation failed: error %d.\n", __FUNCTION__
,
1733 static void __exit
ttusb_dec_exit(void)
1735 usb_deregister(&ttusb_dec_driver
);
1738 module_init(ttusb_dec_init
);
1739 module_exit(ttusb_dec_exit
);
1741 MODULE_AUTHOR("Alex Woods <linux-dvb@giblets.org>");
1742 MODULE_DESCRIPTION(DRIVER_NAME
);
1743 MODULE_LICENSE("GPL");
1744 MODULE_DEVICE_TABLE(usb
, ttusb_dec_table
);