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 <linux/errno.h>
13 #include <linux/kernel.h>
14 #include <linux/list.h>
15 #include <linux/spinlock.h>
17 #include <dvb_demux.h>
25 static void rawiso_activity_cb(struct hpsb_iso *iso);
27 void tear_down_iso_channel(struct firesat *firesat)
29 if (firesat->iso_handle != NULL) {
30 hpsb_iso_stop(firesat->iso_handle);
31 hpsb_iso_shutdown(firesat->iso_handle);
33 firesat->iso_handle = NULL;
36 int setup_iso_channel(struct firesat *firesat)
40 hpsb_iso_recv_init(firesat->ud->ne->host,
41 256 * 200, //data_buf_size,
44 HPSB_ISO_DMA_DEFAULT, //dma_mode,
45 -1, //stat.config.irq_interval,
47 if (firesat->iso_handle == NULL) {
48 printk(KERN_ERR "Cannot initialize iso receive.\n");
51 result = hpsb_iso_recv_start(firesat->iso_handle, -1, -1, 0);
53 printk(KERN_ERR "Cannot start iso receive.\n");
59 static void rawiso_activity_cb(struct hpsb_iso *iso)
65 struct firesat *firesat = NULL;
66 struct firesat *firesat_iterator;
68 spin_lock_irqsave(&firesat_list_lock, flags);
69 list_for_each_entry(firesat_iterator, &firesat_list, list) {
70 if(firesat_iterator->iso_handle == iso) {
71 firesat = firesat_iterator;
75 spin_unlock_irqrestore(&firesat_list_lock, flags);
78 packet = iso->first_packet;
79 num = hpsb_iso_n_ready(iso);
80 for (i = 0; i < num; i++,
81 packet = (packet + 1) % iso->buf_packets) {
83 dma_region_i(&iso->data_buf, unsigned char,
84 iso->infos[packet].offset +
85 sizeof(struct CIPHeader));
86 int count = (iso->infos[packet].len -
87 sizeof(struct CIPHeader)) /
88 (188 + sizeof(struct firewireheader));
89 if (iso->infos[packet].len <= sizeof(struct CIPHeader))
90 continue; // ignore empty packet
93 if (buf[sizeof(struct firewireheader)] == 0x47)
94 dvb_dmx_swfilter_packets(&firesat->demux,
95 &buf[sizeof(struct firewireheader)], 1);
97 printk("%s: invalid packet, skipping\n", __func__);
98 buf += 188 + sizeof(struct firewireheader);
103 hpsb_iso_recv_release_packets(iso, num);
106 printk("%s: packets for unknown iso channel, skipping\n",
108 hpsb_iso_recv_release_packets(iso, hpsb_iso_n_ready(iso));