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>
24 static void rawiso_activity_cb(struct hpsb_iso *iso);
26 void tear_down_iso_channel(struct firesat *firesat)
28 if (firesat->iso_handle != NULL) {
29 hpsb_iso_stop(firesat->iso_handle);
30 hpsb_iso_shutdown(firesat->iso_handle);
32 firesat->iso_handle = NULL;
35 int setup_iso_channel(struct firesat *firesat)
39 hpsb_iso_recv_init(firesat->host,
40 256 * 200, //data_buf_size,
43 HPSB_ISO_DMA_DEFAULT, //dma_mode,
44 -1, //stat.config.irq_interval,
46 if (firesat->iso_handle == NULL) {
47 printk(KERN_ERR "Cannot initialize iso receive.\n");
50 result = hpsb_iso_recv_start(firesat->iso_handle, -1, -1, 0);
52 printk(KERN_ERR "Cannot start iso receive.\n");
58 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
91 /* printk("%s: Handling packets (%d): ", __func__, */
92 /* iso->infos[packet].len); */
93 /* for (j = 0; j < iso->infos[packet].len - */
94 /* sizeof(struct CIPHeader); j++) */
95 /* printk("%02X,", buf[j]); */
98 if (buf[sizeof(struct firewireheader)] == 0x47)
99 dvb_dmx_swfilter_packets(&firesat->demux,
100 &buf[sizeof(struct firewireheader)], 1);
102 printk("%s: invalid packet, skipping\n", __func__);
103 buf += 188 + sizeof(struct firewireheader);
108 hpsb_iso_recv_release_packets(iso, num);
111 printk("%s: packets for unknown iso channel, skipping\n",
113 hpsb_iso_recv_release_packets(iso, hpsb_iso_n_ready(iso));