Lines Matching refs:dec

246 static void ttusb_dec_set_model(struct ttusb_dec *dec,
251 struct ttusb_dec *dec = urb->context; in ttusb_dec_handle_irq() local
252 char *buffer = dec->irq_buffer; in ttusb_dec_handle_irq()
288 input_report_key(dec->rc_input_dev, rc_keys[index - 1], 1); in ttusb_dec_handle_irq()
289 input_sync(dec->rc_input_dev); in ttusb_dec_handle_irq()
290 input_report_key(dec->rc_input_dev, rc_keys[index - 1], 0); in ttusb_dec_handle_irq()
291 input_sync(dec->rc_input_dev); in ttusb_dec_handle_irq()
315 static int ttusb_dec_send_command(struct ttusb_dec *dec, const u8 command, in ttusb_dec_send_command() argument
328 result = mutex_lock_interruptible(&dec->usb_mutex); in ttusb_dec_send_command()
335 b[1] = ++dec->trans_count; in ttusb_dec_send_command()
347 result = usb_bulk_msg(dec->udev, dec->command_pipe, b, in ttusb_dec_send_command()
356 result = usb_bulk_msg(dec->udev, dec->result_pipe, b, in ttusb_dec_send_command()
376 mutex_unlock(&dec->usb_mutex); in ttusb_dec_send_command()
382 static int ttusb_dec_get_stb_state (struct ttusb_dec *dec, unsigned int *mode, in ttusb_dec_get_stb_state() argument
392 result = ttusb_dec_send_command(dec, 0x08, 0, NULL, &c_length, c); in ttusb_dec_get_stb_state()
417 struct ttusb_dec *dec = priv; in ttusb_dec_audio_pes2ts_cb() local
419 dec->audio_filter->feed->cb.ts(data, 188, NULL, 0, in ttusb_dec_audio_pes2ts_cb()
420 &dec->audio_filter->feed->feed.ts, NULL); in ttusb_dec_audio_pes2ts_cb()
427 struct ttusb_dec *dec = priv; in ttusb_dec_video_pes2ts_cb() local
429 dec->video_filter->feed->cb.ts(data, 188, NULL, 0, in ttusb_dec_video_pes2ts_cb()
430 &dec->video_filter->feed->feed.ts, NULL); in ttusb_dec_video_pes2ts_cb()
435 static void ttusb_dec_set_pids(struct ttusb_dec *dec) in ttusb_dec_set_pids() argument
441 __be16 pcr = htons(dec->pid[DMX_PES_PCR]); in ttusb_dec_set_pids()
442 __be16 audio = htons(dec->pid[DMX_PES_AUDIO]); in ttusb_dec_set_pids()
443 __be16 video = htons(dec->pid[DMX_PES_VIDEO]); in ttusb_dec_set_pids()
451 ttusb_dec_send_command(dec, 0x50, sizeof(b), b, NULL, NULL); in ttusb_dec_set_pids()
453 dvb_filter_pes2ts_init(&dec->a_pes2ts, dec->pid[DMX_PES_AUDIO], in ttusb_dec_set_pids()
454 ttusb_dec_audio_pes2ts_cb, dec); in ttusb_dec_set_pids()
455 dvb_filter_pes2ts_init(&dec->v_pes2ts, dec->pid[DMX_PES_VIDEO], in ttusb_dec_set_pids()
456 ttusb_dec_video_pes2ts_cb, dec); in ttusb_dec_set_pids()
457 dec->v_pes_length = 0; in ttusb_dec_set_pids()
458 dec->v_pes_postbytes = 0; in ttusb_dec_set_pids()
461 static void ttusb_dec_process_pva(struct ttusb_dec *dec, u8 *pva, int length) in ttusb_dec_process_pva() argument
481 dec->video_filter->feed->cb.ts(pva, length, NULL, 0, in ttusb_dec_process_pva()
482 &dec->video_filter->feed->feed.ts, NULL); in ttusb_dec_process_pva()
486 if (dec->v_pes_postbytes > 0 && in ttusb_dec_process_pva()
487 dec->v_pes_postbytes == prebytes) { in ttusb_dec_process_pva()
488 memcpy(&dec->v_pes[dec->v_pes_length], in ttusb_dec_process_pva()
491 dvb_filter_pes2ts(&dec->v_pes2ts, dec->v_pes, in ttusb_dec_process_pva()
492 dec->v_pes_length + prebytes, 1); in ttusb_dec_process_pva()
496 dec->v_pes[7] = 0x80; in ttusb_dec_process_pva()
497 dec->v_pes[8] = 0x05; in ttusb_dec_process_pva()
499 dec->v_pes[9] = 0x21 | ((pva[8] & 0xc0) >> 5); in ttusb_dec_process_pva()
500 dec->v_pes[10] = ((pva[8] & 0x3f) << 2) | in ttusb_dec_process_pva()
502 dec->v_pes[11] = 0x01 | in ttusb_dec_process_pva()
505 dec->v_pes[12] = ((pva[10] & 0x7f) << 1) | in ttusb_dec_process_pva()
507 dec->v_pes[13] = 0x01 | ((pva[11] & 0x7f) << 1); in ttusb_dec_process_pva()
509 memcpy(&dec->v_pes[14], &pva[12 + prebytes], in ttusb_dec_process_pva()
511 dec->v_pes_length = 14 + length - 12 - prebytes; in ttusb_dec_process_pva()
513 dec->v_pes[7] = 0x00; in ttusb_dec_process_pva()
514 dec->v_pes[8] = 0x00; in ttusb_dec_process_pva()
516 memcpy(&dec->v_pes[9], &pva[8], length - 8); in ttusb_dec_process_pva()
517 dec->v_pes_length = 9 + length - 8; in ttusb_dec_process_pva()
520 dec->v_pes_postbytes = postbytes; in ttusb_dec_process_pva()
522 if (dec->v_pes[9 + dec->v_pes[8]] == 0x00 && in ttusb_dec_process_pva()
523 dec->v_pes[10 + dec->v_pes[8]] == 0x00 && in ttusb_dec_process_pva()
524 dec->v_pes[11 + dec->v_pes[8]] == 0x01) in ttusb_dec_process_pva()
525 dec->v_pes[6] = 0x84; in ttusb_dec_process_pva()
527 dec->v_pes[6] = 0x80; in ttusb_dec_process_pva()
529 v_pes_payload_length = htons(dec->v_pes_length - 6 + in ttusb_dec_process_pva()
531 memcpy(&dec->v_pes[4], &v_pes_payload_length, 2); in ttusb_dec_process_pva()
534 dvb_filter_pes2ts(&dec->v_pes2ts, dec->v_pes, in ttusb_dec_process_pva()
535 dec->v_pes_length, 1); in ttusb_dec_process_pva()
542 dec->audio_filter->feed->cb.ts(pva, length, NULL, 0, in ttusb_dec_process_pva()
543 &dec->audio_filter->feed->feed.ts, NULL); in ttusb_dec_process_pva()
547 dvb_filter_pes2ts(&dec->a_pes2ts, &pva[8], length - 8, in ttusb_dec_process_pva()
558 static void ttusb_dec_process_filter(struct ttusb_dec *dec, u8 *packet, in ttusb_dec_process_filter() argument
568 spin_lock_irqsave(&dec->filter_info_list_lock, flags); in ttusb_dec_process_filter()
569 for (item = dec->filter_info_list.next; item != &dec->filter_info_list; in ttusb_dec_process_filter()
577 spin_unlock_irqrestore(&dec->filter_info_list_lock, flags); in ttusb_dec_process_filter()
584 static void ttusb_dec_process_packet(struct ttusb_dec *dec) in ttusb_dec_process_packet() argument
590 if (dec->packet_length % 2) { in ttusb_dec_process_packet()
595 for (i = 0; i < dec->packet_length; i += 2) in ttusb_dec_process_packet()
596 csum ^= ((dec->packet[i] << 8) + dec->packet[i + 1]); in ttusb_dec_process_packet()
603 packet_id = dec->packet[dec->packet_length - 4] << 8; in ttusb_dec_process_packet()
604 packet_id += dec->packet[dec->packet_length - 3]; in ttusb_dec_process_packet()
606 if ((packet_id != dec->next_packet_id) && dec->next_packet_id) { in ttusb_dec_process_packet()
608 __func__, dec->next_packet_id - 1, packet_id); in ttusb_dec_process_packet()
612 dec->next_packet_id = 0x8000; in ttusb_dec_process_packet()
614 dec->next_packet_id = packet_id + 1; in ttusb_dec_process_packet()
616 switch (dec->packet_type) { in ttusb_dec_process_packet()
618 if (dec->pva_stream_count) in ttusb_dec_process_packet()
619 ttusb_dec_process_pva(dec, dec->packet, in ttusb_dec_process_packet()
620 dec->packet_payload_length); in ttusb_dec_process_packet()
624 if (dec->filter_stream_count) in ttusb_dec_process_packet()
625 ttusb_dec_process_filter(dec, dec->packet, in ttusb_dec_process_packet()
626 dec->packet_payload_length); in ttusb_dec_process_packet()
641 static void ttusb_dec_process_urb_frame(struct ttusb_dec *dec, u8 *b, in ttusb_dec_process_urb_frame() argument
647 switch (dec->packet_state) { in ttusb_dec_process_urb_frame()
653 dec->packet_state++; in ttusb_dec_process_urb_frame()
655 dec->packet_state = 0; in ttusb_dec_process_urb_frame()
662 dec->packet_state++; in ttusb_dec_process_urb_frame()
663 dec->packet_length = 0; in ttusb_dec_process_urb_frame()
665 dec->packet_state = 0; in ttusb_dec_process_urb_frame()
673 dec->packet[dec->packet_length++] = *b++; in ttusb_dec_process_urb_frame()
675 if (dec->packet_length == 2) { in ttusb_dec_process_urb_frame()
676 if (dec->packet[0] == 'A' && in ttusb_dec_process_urb_frame()
677 dec->packet[1] == 'V') { in ttusb_dec_process_urb_frame()
678 dec->packet_type = in ttusb_dec_process_urb_frame()
680 dec->packet_state++; in ttusb_dec_process_urb_frame()
681 } else if (dec->packet[0] == 'S') { in ttusb_dec_process_urb_frame()
682 dec->packet_type = in ttusb_dec_process_urb_frame()
684 dec->packet_state++; in ttusb_dec_process_urb_frame()
685 } else if (dec->packet[0] == 0x00) { in ttusb_dec_process_urb_frame()
686 dec->packet_type = in ttusb_dec_process_urb_frame()
688 dec->packet_payload_length = 2; in ttusb_dec_process_urb_frame()
689 dec->packet_state = 7; in ttusb_dec_process_urb_frame()
693 dec->packet[0], dec->packet[1]); in ttusb_dec_process_urb_frame()
694 dec->packet_state = 0; in ttusb_dec_process_urb_frame()
702 dec->packet[dec->packet_length++] = *b++; in ttusb_dec_process_urb_frame()
704 if (dec->packet_type == TTUSB_DEC_PACKET_PVA && in ttusb_dec_process_urb_frame()
705 dec->packet_length == 8) { in ttusb_dec_process_urb_frame()
706 dec->packet_state++; in ttusb_dec_process_urb_frame()
707 dec->packet_payload_length = 8 + in ttusb_dec_process_urb_frame()
708 (dec->packet[6] << 8) + in ttusb_dec_process_urb_frame()
709 dec->packet[7]; in ttusb_dec_process_urb_frame()
710 } else if (dec->packet_type == in ttusb_dec_process_urb_frame()
712 dec->packet_length == 5) { in ttusb_dec_process_urb_frame()
713 dec->packet_state++; in ttusb_dec_process_urb_frame()
714 dec->packet_payload_length = 5 + in ttusb_dec_process_urb_frame()
715 ((dec->packet[3] & 0x0f) << 8) + in ttusb_dec_process_urb_frame()
716 dec->packet[4]; in ttusb_dec_process_urb_frame()
723 int remainder = dec->packet_payload_length - in ttusb_dec_process_urb_frame()
724 dec->packet_length; in ttusb_dec_process_urb_frame()
727 memcpy(dec->packet + dec->packet_length, in ttusb_dec_process_urb_frame()
729 dec->packet_length += remainder; in ttusb_dec_process_urb_frame()
732 dec->packet_state++; in ttusb_dec_process_urb_frame()
734 memcpy(&dec->packet[dec->packet_length], in ttusb_dec_process_urb_frame()
736 dec->packet_length += length; in ttusb_dec_process_urb_frame()
746 dec->packet[dec->packet_length++] = *b++; in ttusb_dec_process_urb_frame()
748 if (dec->packet_type == TTUSB_DEC_PACKET_SECTION && in ttusb_dec_process_urb_frame()
749 dec->packet_payload_length % 2) in ttusb_dec_process_urb_frame()
752 if (dec->packet_length == in ttusb_dec_process_urb_frame()
753 dec->packet_payload_length + tail) { in ttusb_dec_process_urb_frame()
754 ttusb_dec_process_packet(dec); in ttusb_dec_process_urb_frame()
755 dec->packet_state = 0; in ttusb_dec_process_urb_frame()
765 dec->packet_state = 0; in ttusb_dec_process_urb_frame()
772 struct ttusb_dec *dec = from_work(dec, t, urb_bh_work); in ttusb_dec_process_urb_frame_list() local
778 spin_lock_irqsave(&dec->urb_frame_list_lock, flags); in ttusb_dec_process_urb_frame_list()
779 if ((item = dec->urb_frame_list.next) != &dec->urb_frame_list) { in ttusb_dec_process_urb_frame_list()
784 spin_unlock_irqrestore(&dec->urb_frame_list_lock, in ttusb_dec_process_urb_frame_list()
788 spin_unlock_irqrestore(&dec->urb_frame_list_lock, flags); in ttusb_dec_process_urb_frame_list()
790 ttusb_dec_process_urb_frame(dec, frame->data, frame->length); in ttusb_dec_process_urb_frame_list()
797 struct ttusb_dec *dec = urb->context; in ttusb_dec_process_urb() local
819 spin_lock_irqsave(&dec->urb_frame_list_lock, in ttusb_dec_process_urb()
822 &dec->urb_frame_list); in ttusb_dec_process_urb()
823 spin_unlock_irqrestore(&dec->urb_frame_list_lock, in ttusb_dec_process_urb()
826 queue_work(system_bh_wq, &dec->urb_bh_work); in ttusb_dec_process_urb()
836 if (dec->iso_stream_count) in ttusb_dec_process_urb()
840 static void ttusb_dec_setup_urbs(struct ttusb_dec *dec) in ttusb_dec_setup_urbs() argument
848 struct urb *urb = dec->iso_urb[i]; in ttusb_dec_setup_urbs()
850 urb->dev = dec->udev; in ttusb_dec_setup_urbs()
851 urb->context = dec; in ttusb_dec_setup_urbs()
853 urb->pipe = dec->in_pipe; in ttusb_dec_setup_urbs()
859 urb->transfer_buffer = dec->iso_buffer + buffer_offset; in ttusb_dec_setup_urbs()
870 static void ttusb_dec_stop_iso_xfer(struct ttusb_dec *dec) in ttusb_dec_stop_iso_xfer() argument
876 if (mutex_lock_interruptible(&dec->iso_mutex)) in ttusb_dec_stop_iso_xfer()
879 dec->iso_stream_count--; in ttusb_dec_stop_iso_xfer()
881 if (!dec->iso_stream_count) { in ttusb_dec_stop_iso_xfer()
883 usb_kill_urb(dec->iso_urb[i]); in ttusb_dec_stop_iso_xfer()
886 mutex_unlock(&dec->iso_mutex); in ttusb_dec_stop_iso_xfer()
893 static int ttusb_dec_set_interface(struct ttusb_dec *dec, in ttusb_dec_set_interface() argument
899 if (interface != dec->interface) { in ttusb_dec_set_interface()
902 result = usb_set_interface(dec->udev, 0, 0); in ttusb_dec_set_interface()
905 result = ttusb_dec_send_command(dec, 0x80, sizeof(b), in ttusb_dec_set_interface()
909 result = usb_set_interface(dec->udev, 0, 8); in ttusb_dec_set_interface()
912 result = usb_set_interface(dec->udev, 0, 1); in ttusb_dec_set_interface()
919 dec->interface = interface; in ttusb_dec_set_interface()
925 static int ttusb_dec_start_iso_xfer(struct ttusb_dec *dec) in ttusb_dec_start_iso_xfer() argument
931 if (mutex_lock_interruptible(&dec->iso_mutex)) in ttusb_dec_start_iso_xfer()
934 if (!dec->iso_stream_count) { in ttusb_dec_start_iso_xfer()
935 ttusb_dec_setup_urbs(dec); in ttusb_dec_start_iso_xfer()
937 dec->packet_state = 0; in ttusb_dec_start_iso_xfer()
938 dec->v_pes_postbytes = 0; in ttusb_dec_start_iso_xfer()
939 dec->next_packet_id = 0; in ttusb_dec_start_iso_xfer()
942 if ((result = usb_submit_urb(dec->iso_urb[i], in ttusb_dec_start_iso_xfer()
948 usb_kill_urb(dec->iso_urb[i - 1]); in ttusb_dec_start_iso_xfer()
952 mutex_unlock(&dec->iso_mutex); in ttusb_dec_start_iso_xfer()
958 dec->iso_stream_count++; in ttusb_dec_start_iso_xfer()
960 mutex_unlock(&dec->iso_mutex); in ttusb_dec_start_iso_xfer()
968 struct ttusb_dec *dec = dvbdmx->priv; in ttusb_dec_start_ts_feed() local
991 dec->pid[DMX_PES_PCR] = dvbdmxfeed->pid; in ttusb_dec_start_ts_feed()
992 dec->pid[DMX_PES_VIDEO] = dvbdmxfeed->pid; in ttusb_dec_start_ts_feed()
993 dec->video_filter = dvbdmxfeed->filter; in ttusb_dec_start_ts_feed()
994 ttusb_dec_set_pids(dec); in ttusb_dec_start_ts_feed()
999 dec->pid[DMX_PES_AUDIO] = dvbdmxfeed->pid; in ttusb_dec_start_ts_feed()
1000 dec->audio_filter = dvbdmxfeed->filter; in ttusb_dec_start_ts_feed()
1001 ttusb_dec_set_pids(dec); in ttusb_dec_start_ts_feed()
1005 dec->pid[DMX_PES_TELETEXT] = dvbdmxfeed->pid; in ttusb_dec_start_ts_feed()
1011 dec->pid[DMX_PES_PCR] = dvbdmxfeed->pid; in ttusb_dec_start_ts_feed()
1012 ttusb_dec_set_pids(dec); in ttusb_dec_start_ts_feed()
1025 result = ttusb_dec_send_command(dec, 0x80, sizeof(b0), b0, NULL, NULL); in ttusb_dec_start_ts_feed()
1029 dec->pva_stream_count++; in ttusb_dec_start_ts_feed()
1030 return ttusb_dec_start_iso_xfer(dec); in ttusb_dec_start_ts_feed()
1035 struct ttusb_dec *dec = dvbdmxfeed->demux->priv; in ttusb_dec_start_sec_feed() local
1059 result = ttusb_dec_send_command(dec, 0x60, sizeof(b0), b0, in ttusb_dec_start_sec_feed()
1071 spin_lock_irqsave(&dec->filter_info_list_lock, flags); in ttusb_dec_start_sec_feed()
1073 &dec->filter_info_list); in ttusb_dec_start_sec_feed()
1074 spin_unlock_irqrestore(&dec->filter_info_list_lock, in ttusb_dec_start_sec_feed()
1079 dec->filter_stream_count++; in ttusb_dec_start_sec_feed()
1080 return ttusb_dec_start_iso_xfer(dec); in ttusb_dec_start_sec_feed()
1116 struct ttusb_dec *dec = dvbdmxfeed->demux->priv; in ttusb_dec_stop_ts_feed() local
1119 ttusb_dec_send_command(dec, 0x81, sizeof(b0), b0, NULL, NULL); in ttusb_dec_stop_ts_feed()
1121 dec->pva_stream_count--; in ttusb_dec_stop_ts_feed()
1123 ttusb_dec_stop_iso_xfer(dec); in ttusb_dec_stop_ts_feed()
1130 struct ttusb_dec *dec = dvbdmxfeed->demux->priv; in ttusb_dec_stop_sec_feed() local
1136 spin_lock_irqsave(&dec->filter_info_list_lock, flags); in ttusb_dec_stop_sec_feed()
1138 spin_unlock_irqrestore(&dec->filter_info_list_lock, flags); in ttusb_dec_stop_sec_feed()
1140 ttusb_dec_send_command(dec, 0x62, sizeof(b0), b0, NULL, NULL); in ttusb_dec_stop_sec_feed()
1142 dec->filter_stream_count--; in ttusb_dec_stop_sec_feed()
1144 ttusb_dec_stop_iso_xfer(dec); in ttusb_dec_stop_sec_feed()
1164 static void ttusb_dec_free_iso_urbs(struct ttusb_dec *dec) in ttusb_dec_free_iso_urbs() argument
1171 usb_free_urb(dec->iso_urb[i]); in ttusb_dec_free_iso_urbs()
1172 kfree(dec->iso_buffer); in ttusb_dec_free_iso_urbs()
1175 static int ttusb_dec_alloc_iso_urbs(struct ttusb_dec *dec) in ttusb_dec_alloc_iso_urbs() argument
1181 dec->iso_buffer = kcalloc(FRAMES_PER_ISO_BUF * ISO_BUF_COUNT, in ttusb_dec_alloc_iso_urbs()
1183 if (!dec->iso_buffer) in ttusb_dec_alloc_iso_urbs()
1190 ttusb_dec_free_iso_urbs(dec); in ttusb_dec_alloc_iso_urbs()
1194 dec->iso_urb[i] = urb; in ttusb_dec_alloc_iso_urbs()
1197 ttusb_dec_setup_urbs(dec); in ttusb_dec_alloc_iso_urbs()
1202 static void ttusb_dec_init_bh_work(struct ttusb_dec *dec) in ttusb_dec_init_bh_work() argument
1204 spin_lock_init(&dec->urb_frame_list_lock); in ttusb_dec_init_bh_work()
1205 INIT_LIST_HEAD(&dec->urb_frame_list); in ttusb_dec_init_bh_work()
1206 INIT_WORK(&dec->urb_bh_work, ttusb_dec_process_urb_frame_list); in ttusb_dec_init_bh_work()
1209 static int ttusb_init_rc( struct ttusb_dec *dec) in ttusb_init_rc() argument
1216 usb_make_path(dec->udev, dec->rc_phys, sizeof(dec->rc_phys)); in ttusb_init_rc()
1217 strlcat(dec->rc_phys, "/input0", sizeof(dec->rc_phys)); in ttusb_init_rc()
1224 input_dev->phys = dec->rc_phys; in ttusb_init_rc()
1239 dec->rc_input_dev = input_dev; in ttusb_init_rc()
1240 if (usb_submit_urb(dec->irq_urb, GFP_KERNEL)) in ttusb_init_rc()
1243 ttusb_dec_send_command(dec,0xb0,sizeof(b),b,NULL,NULL); in ttusb_init_rc()
1248 static void ttusb_dec_init_v_pes(struct ttusb_dec *dec) in ttusb_dec_init_v_pes() argument
1252 dec->v_pes[0] = 0x00; in ttusb_dec_init_v_pes()
1253 dec->v_pes[1] = 0x00; in ttusb_dec_init_v_pes()
1254 dec->v_pes[2] = 0x01; in ttusb_dec_init_v_pes()
1255 dec->v_pes[3] = 0xe0; in ttusb_dec_init_v_pes()
1258 static int ttusb_dec_init_usb(struct ttusb_dec *dec) in ttusb_dec_init_usb() argument
1264 mutex_init(&dec->usb_mutex); in ttusb_dec_init_usb()
1265 mutex_init(&dec->iso_mutex); in ttusb_dec_init_usb()
1267 dec->command_pipe = usb_sndbulkpipe(dec->udev, COMMAND_PIPE); in ttusb_dec_init_usb()
1268 dec->result_pipe = usb_rcvbulkpipe(dec->udev, RESULT_PIPE); in ttusb_dec_init_usb()
1269 dec->in_pipe = usb_rcvisocpipe(dec->udev, IN_PIPE); in ttusb_dec_init_usb()
1270 dec->out_pipe = usb_sndisocpipe(dec->udev, OUT_PIPE); in ttusb_dec_init_usb()
1271 dec->irq_pipe = usb_rcvintpipe(dec->udev, IRQ_PIPE); in ttusb_dec_init_usb()
1274 dec->irq_urb = usb_alloc_urb(0, GFP_KERNEL); in ttusb_dec_init_usb()
1275 if(!dec->irq_urb) { in ttusb_dec_init_usb()
1278 dec->irq_buffer = usb_alloc_coherent(dec->udev,IRQ_PACKET_SIZE, in ttusb_dec_init_usb()
1279 GFP_KERNEL, &dec->irq_dma_handle); in ttusb_dec_init_usb()
1280 if(!dec->irq_buffer) { in ttusb_dec_init_usb()
1281 usb_free_urb(dec->irq_urb); in ttusb_dec_init_usb()
1284 usb_fill_int_urb(dec->irq_urb, dec->udev,dec->irq_pipe, in ttusb_dec_init_usb()
1285 dec->irq_buffer, IRQ_PACKET_SIZE, in ttusb_dec_init_usb()
1286 ttusb_dec_handle_irq, dec, 1); in ttusb_dec_init_usb()
1287 dec->irq_urb->transfer_dma = dec->irq_dma_handle; in ttusb_dec_init_usb()
1288 dec->irq_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in ttusb_dec_init_usb()
1291 result = ttusb_dec_alloc_iso_urbs(dec); in ttusb_dec_init_usb()
1293 usb_free_urb(dec->irq_urb); in ttusb_dec_init_usb()
1294 usb_free_coherent(dec->udev, IRQ_PACKET_SIZE, in ttusb_dec_init_usb()
1295 dec->irq_buffer, dec->irq_dma_handle); in ttusb_dec_init_usb()
1300 static int ttusb_dec_boot_dsp(struct ttusb_dec *dec) in ttusb_dec_boot_dsp() argument
1320 result = request_firmware(&fw_entry, dec->firmware_name, &dec->udev->dev); in ttusb_dec_boot_dsp()
1323 __func__, dec->firmware_name); in ttusb_dec_boot_dsp()
1359 result = ttusb_dec_send_command(dec, 0x41, sizeof(b0), b0, NULL, NULL); in ttusb_dec_boot_dsp()
1389 result = usb_bulk_msg(dec->udev, dec->command_pipe, b, in ttusb_dec_boot_dsp()
1394 result = usb_bulk_msg(dec->udev, dec->command_pipe, b, in ttusb_dec_boot_dsp()
1400 result = ttusb_dec_send_command(dec, 0x43, sizeof(b1), b1, NULL, NULL); in ttusb_dec_boot_dsp()
1408 static int ttusb_dec_init_stb(struct ttusb_dec *dec) in ttusb_dec_init_stb() argument
1415 result = ttusb_dec_get_stb_state(dec, &mode, &model, &version); in ttusb_dec_init_stb()
1427 result = ttusb_dec_boot_dsp(dec); in ttusb_dec_init_stb()
1437 ttusb_dec_set_model(dec, TTUSB_DEC3000S); in ttusb_dec_init_stb()
1441 ttusb_dec_set_model(dec, TTUSB_DEC2000T); in ttusb_dec_init_stb()
1444 ttusb_dec_set_model(dec, TTUSB_DEC2540T); in ttusb_dec_init_stb()
1452 dec->can_playback = 1; in ttusb_dec_init_stb()
1457 static int ttusb_dec_init_dvb(struct ttusb_dec *dec) in ttusb_dec_init_dvb() argument
1463 if ((result = dvb_register_adapter(&dec->adapter, in ttusb_dec_init_dvb()
1464 dec->model_name, THIS_MODULE, in ttusb_dec_init_dvb()
1465 &dec->udev->dev, in ttusb_dec_init_dvb()
1473 dec->demux.dmx.capabilities = DMX_TS_FILTERING | DMX_SECTION_FILTERING; in ttusb_dec_init_dvb()
1475 dec->demux.priv = (void *)dec; in ttusb_dec_init_dvb()
1476 dec->demux.filternum = 31; in ttusb_dec_init_dvb()
1477 dec->demux.feednum = 31; in ttusb_dec_init_dvb()
1478 dec->demux.start_feed = ttusb_dec_start_feed; in ttusb_dec_init_dvb()
1479 dec->demux.stop_feed = ttusb_dec_stop_feed; in ttusb_dec_init_dvb()
1480 dec->demux.write_to_decoder = NULL; in ttusb_dec_init_dvb()
1482 if ((result = dvb_dmx_init(&dec->demux)) < 0) { in ttusb_dec_init_dvb()
1486 dvb_unregister_adapter(&dec->adapter); in ttusb_dec_init_dvb()
1491 dec->dmxdev.filternum = 32; in ttusb_dec_init_dvb()
1492 dec->dmxdev.demux = &dec->demux.dmx; in ttusb_dec_init_dvb()
1493 dec->dmxdev.capabilities = 0; in ttusb_dec_init_dvb()
1495 if ((result = dvb_dmxdev_init(&dec->dmxdev, &dec->adapter)) < 0) { in ttusb_dec_init_dvb()
1499 dvb_dmx_release(&dec->demux); in ttusb_dec_init_dvb()
1500 dvb_unregister_adapter(&dec->adapter); in ttusb_dec_init_dvb()
1505 dec->frontend.source = DMX_FRONTEND_0; in ttusb_dec_init_dvb()
1507 if ((result = dec->demux.dmx.add_frontend(&dec->demux.dmx, in ttusb_dec_init_dvb()
1508 &dec->frontend)) < 0) { in ttusb_dec_init_dvb()
1512 dvb_dmxdev_release(&dec->dmxdev); in ttusb_dec_init_dvb()
1513 dvb_dmx_release(&dec->demux); in ttusb_dec_init_dvb()
1514 dvb_unregister_adapter(&dec->adapter); in ttusb_dec_init_dvb()
1519 if ((result = dec->demux.dmx.connect_frontend(&dec->demux.dmx, in ttusb_dec_init_dvb()
1520 &dec->frontend)) < 0) { in ttusb_dec_init_dvb()
1524 dec->demux.dmx.remove_frontend(&dec->demux.dmx, &dec->frontend); in ttusb_dec_init_dvb()
1525 dvb_dmxdev_release(&dec->dmxdev); in ttusb_dec_init_dvb()
1526 dvb_dmx_release(&dec->demux); in ttusb_dec_init_dvb()
1527 dvb_unregister_adapter(&dec->adapter); in ttusb_dec_init_dvb()
1532 dvb_net_init(&dec->adapter, &dec->dvb_net, &dec->demux.dmx); in ttusb_dec_init_dvb()
1537 static void ttusb_dec_exit_dvb(struct ttusb_dec *dec) in ttusb_dec_exit_dvb() argument
1541 dvb_net_release(&dec->dvb_net); in ttusb_dec_exit_dvb()
1542 dec->demux.dmx.close(&dec->demux.dmx); in ttusb_dec_exit_dvb()
1543 dec->demux.dmx.remove_frontend(&dec->demux.dmx, &dec->frontend); in ttusb_dec_exit_dvb()
1544 dvb_dmxdev_release(&dec->dmxdev); in ttusb_dec_exit_dvb()
1545 dvb_dmx_release(&dec->demux); in ttusb_dec_exit_dvb()
1546 if (dec->fe) { in ttusb_dec_exit_dvb()
1547 dvb_unregister_frontend(dec->fe); in ttusb_dec_exit_dvb()
1548 dvb_frontend_detach(dec->fe); in ttusb_dec_exit_dvb()
1550 dvb_unregister_adapter(&dec->adapter); in ttusb_dec_exit_dvb()
1553 static void ttusb_dec_exit_rc(struct ttusb_dec *dec) in ttusb_dec_exit_rc() argument
1557 if (dec->rc_input_dev) { in ttusb_dec_exit_rc()
1558 input_unregister_device(dec->rc_input_dev); in ttusb_dec_exit_rc()
1559 dec->rc_input_dev = NULL; in ttusb_dec_exit_rc()
1564 static void ttusb_dec_exit_usb(struct ttusb_dec *dec) in ttusb_dec_exit_usb() argument
1575 if (dec->interface == TTUSB_DEC_INTERFACE_IN) in ttusb_dec_exit_usb()
1576 usb_kill_urb(dec->irq_urb); in ttusb_dec_exit_usb()
1578 usb_free_urb(dec->irq_urb); in ttusb_dec_exit_usb()
1580 usb_free_coherent(dec->udev, IRQ_PACKET_SIZE, in ttusb_dec_exit_usb()
1581 dec->irq_buffer, dec->irq_dma_handle); in ttusb_dec_exit_usb()
1584 dec->iso_stream_count = 0; in ttusb_dec_exit_usb()
1587 usb_kill_urb(dec->iso_urb[i]); in ttusb_dec_exit_usb()
1589 ttusb_dec_free_iso_urbs(dec); in ttusb_dec_exit_usb()
1592 static void ttusb_dec_exit_bh_work(struct ttusb_dec *dec) in ttusb_dec_exit_bh_work() argument
1597 cancel_work_sync(&dec->urb_bh_work); in ttusb_dec_exit_bh_work()
1599 while ((item = dec->urb_frame_list.next) != &dec->urb_frame_list) { in ttusb_dec_exit_bh_work()
1606 static void ttusb_dec_init_filters(struct ttusb_dec *dec) in ttusb_dec_init_filters() argument
1608 INIT_LIST_HEAD(&dec->filter_info_list); in ttusb_dec_init_filters()
1609 spin_lock_init(&dec->filter_info_list_lock); in ttusb_dec_init_filters()
1612 static void ttusb_dec_exit_filters(struct ttusb_dec *dec) in ttusb_dec_exit_filters() argument
1617 while ((item = dec->filter_info_list.next) != &dec->filter_info_list) { in ttusb_dec_exit_filters()
1628 struct ttusb_dec* dec = fe->dvb->priv; in fe_send_command() local
1629 return ttusb_dec_send_command(dec, command, param_length, params, result_length, cmd_result); in fe_send_command()
1640 struct ttusb_dec *dec; in ttusb_dec_probe() local
1647 if (!(dec = kzalloc(sizeof(struct ttusb_dec), GFP_KERNEL))) { in ttusb_dec_probe()
1652 usb_set_intfdata(intf, (void *)dec); in ttusb_dec_probe()
1656 ttusb_dec_set_model(dec, TTUSB_DEC3000S); in ttusb_dec_probe()
1660 ttusb_dec_set_model(dec, TTUSB_DEC2000T); in ttusb_dec_probe()
1664 ttusb_dec_set_model(dec, TTUSB_DEC2540T); in ttusb_dec_probe()
1668 dec->udev = udev; in ttusb_dec_probe()
1670 result = ttusb_dec_init_usb(dec); in ttusb_dec_probe()
1673 result = ttusb_dec_init_stb(dec); in ttusb_dec_probe()
1676 result = ttusb_dec_init_dvb(dec); in ttusb_dec_probe()
1680 dec->adapter.priv = dec; in ttusb_dec_probe()
1683 dec->fe = ttusbdecfe_dvbs_attach(&fe_config); in ttusb_dec_probe()
1688 dec->fe = ttusbdecfe_dvbt_attach(&fe_config); in ttusb_dec_probe()
1692 if (dec->fe == NULL) { in ttusb_dec_probe()
1694 le16_to_cpu(dec->udev->descriptor.idVendor), in ttusb_dec_probe()
1695 le16_to_cpu(dec->udev->descriptor.idProduct)); in ttusb_dec_probe()
1697 if (dvb_register_frontend(&dec->adapter, dec->fe)) { in ttusb_dec_probe()
1699 if (dec->fe->ops.release) in ttusb_dec_probe()
1700 dec->fe->ops.release(dec->fe); in ttusb_dec_probe()
1701 dec->fe = NULL; in ttusb_dec_probe()
1705 ttusb_dec_init_v_pes(dec); in ttusb_dec_probe()
1706 ttusb_dec_init_filters(dec); in ttusb_dec_probe()
1707 ttusb_dec_init_bh_work(dec); in ttusb_dec_probe()
1709 dec->active = 1; in ttusb_dec_probe()
1711 ttusb_dec_set_interface(dec, TTUSB_DEC_INTERFACE_IN); in ttusb_dec_probe()
1714 ttusb_init_rc(dec); in ttusb_dec_probe()
1718 ttusb_dec_exit_usb(dec); in ttusb_dec_probe()
1720 kfree(dec); in ttusb_dec_probe()
1726 struct ttusb_dec *dec = usb_get_intfdata(intf); in ttusb_dec_disconnect() local
1732 if (dec->active) { in ttusb_dec_disconnect()
1733 ttusb_dec_exit_bh_work(dec); in ttusb_dec_disconnect()
1734 ttusb_dec_exit_filters(dec); in ttusb_dec_disconnect()
1736 ttusb_dec_exit_rc(dec); in ttusb_dec_disconnect()
1737 ttusb_dec_exit_usb(dec); in ttusb_dec_disconnect()
1738 ttusb_dec_exit_dvb(dec); in ttusb_dec_disconnect()
1741 kfree(dec); in ttusb_dec_disconnect()
1744 static void ttusb_dec_set_model(struct ttusb_dec *dec, in ttusb_dec_set_model() argument
1747 dec->model = model; in ttusb_dec_set_model()
1751 dec->model_name = "DEC2000-t"; in ttusb_dec_set_model()
1752 dec->firmware_name = "dvb-ttusb-dec-2000t.fw"; in ttusb_dec_set_model()
1756 dec->model_name = "DEC2540-t"; in ttusb_dec_set_model()
1757 dec->firmware_name = "dvb-ttusb-dec-2540t.fw"; in ttusb_dec_set_model()
1761 dec->model_name = "DEC3000-s"; in ttusb_dec_set_model()
1762 dec->firmware_name = "dvb-ttusb-dec-3000s.fw"; in ttusb_dec_set_model()