firesat: update isochronous interface, add CI support
[linux-2.6/mini2440.git] / drivers / media / dvb / firesat / firesat_iso.c
blob15e23cf7d503f24bc14684b5001059b84981e2b6
1 /*
2 * FireSAT DVB driver
4 * Copyright (c) 2008 Henrik Kurelid <henrik@kurelid.se>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of
9 * the License, or (at your option) any later version.
12 #include "firesat.h"
14 static void rawiso_activity_cb(struct hpsb_iso *iso);
16 void tear_down_iso_channel(struct firesat *firesat)
18 if (firesat->iso_handle != NULL) {
19 hpsb_iso_stop(firesat->iso_handle);
20 hpsb_iso_shutdown(firesat->iso_handle);
22 firesat->iso_handle = NULL;
25 int setup_iso_channel(struct firesat *firesat)
27 int result;
28 firesat->iso_handle =
29 hpsb_iso_recv_init(firesat->host,
30 256 * 200, //data_buf_size,
31 256, //buf_packets,
32 firesat->isochannel,
33 HPSB_ISO_DMA_DEFAULT, //dma_mode,
34 -1, //stat.config.irq_interval,
35 rawiso_activity_cb);
36 if (firesat->iso_handle == NULL) {
37 printk(KERN_ERR "Cannot initialize iso receive.\n");
38 return -EINVAL;
40 result = hpsb_iso_recv_start(firesat->iso_handle, -1, -1, 0);
41 if (result != 0) {
42 printk(KERN_ERR "Cannot start iso receive.\n");
43 return -EINVAL;
45 return 0;
48 static void rawiso_activity_cb(struct hpsb_iso *iso)
50 unsigned int num;
51 unsigned int i;
52 /* unsigned int j; */
53 unsigned int packet;
54 unsigned long flags;
55 struct firesat *firesat = NULL;
56 struct firesat *firesat_iterator;
58 spin_lock_irqsave(&firesat_list_lock, flags);
59 list_for_each_entry(firesat_iterator, &firesat_list, list) {
60 if(firesat_iterator->iso_handle == iso) {
61 firesat = firesat_iterator;
62 break;
65 spin_unlock_irqrestore(&firesat_list_lock, flags);
67 if (firesat) {
68 packet = iso->first_packet;
69 num = hpsb_iso_n_ready(iso);
70 for (i = 0; i < num; i++,
71 packet = (packet + 1) % iso->buf_packets) {
72 unsigned char *buf =
73 dma_region_i(&iso->data_buf, unsigned char,
74 iso->infos[packet].offset +
75 sizeof(struct CIPHeader));
76 int count = (iso->infos[packet].len -
77 sizeof(struct CIPHeader)) /
78 (188 + sizeof(struct firewireheader));
79 if (iso->infos[packet].len <= sizeof(struct CIPHeader))
80 continue; // ignore empty packet
81 /* printk("%s: Handling packets (%d): ", __func__, */
82 /* iso->infos[packet].len); */
83 /* for (j = 0; j < iso->infos[packet].len - */
84 /* sizeof(struct CIPHeader); j++) */
85 /* printk("%02X,", buf[j]); */
86 /* printk("\n"); */
87 while (count --) {
88 if (buf[sizeof(struct firewireheader)] == 0x47)
89 dvb_dmx_swfilter_packets(&firesat->demux,
90 &buf[sizeof(struct firewireheader)], 1);
91 else
92 printk("%s: invalid packet, skipping\n", __func__);
93 buf += 188 + sizeof(struct firewireheader);
98 hpsb_iso_recv_release_packets(iso, num);
100 else {
101 printk("%s: packets for unknown iso channel, skipping\n",
102 __func__);
103 hpsb_iso_recv_release_packets(iso, hpsb_iso_n_ready(iso));