aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/firewire
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/dvb/firewire')
-rw-r--r--drivers/media/dvb/firewire/Kconfig8
-rw-r--r--drivers/media/dvb/firewire/Makefile5
-rw-r--r--drivers/media/dvb/firewire/firedtv-1394.c300
-rw-r--r--drivers/media/dvb/firewire/firedtv-avc.c89
-rw-r--r--drivers/media/dvb/firewire/firedtv-ci.c1
-rw-r--r--drivers/media/dvb/firewire/firedtv-dvb.c135
-rw-r--r--drivers/media/dvb/firewire/firedtv-fe.c44
-rw-r--r--drivers/media/dvb/firewire/firedtv-fw.c147
-rw-r--r--drivers/media/dvb/firewire/firedtv-rc.c9
-rw-r--r--drivers/media/dvb/firewire/firedtv.h45
10 files changed, 237 insertions, 546 deletions
diff --git a/drivers/media/dvb/firewire/Kconfig b/drivers/media/dvb/firewire/Kconfig
index 4afa29256df1..f3e9448c3955 100644
--- a/drivers/media/dvb/firewire/Kconfig
+++ b/drivers/media/dvb/firewire/Kconfig
@@ -1,6 +1,6 @@
1config DVB_FIREDTV 1config DVB_FIREDTV
2 tristate "FireDTV and FloppyDTV" 2 tristate "FireDTV and FloppyDTV"
3 depends on DVB_CORE && (FIREWIRE || IEEE1394) 3 depends on DVB_CORE && FIREWIRE
4 help 4 help
5 Support for DVB receivers from Digital Everywhere 5 Support for DVB receivers from Digital Everywhere
6 which are connected via IEEE 1394 (FireWire). 6 which are connected via IEEE 1394 (FireWire).
@@ -13,12 +13,6 @@ config DVB_FIREDTV
13 13
14if DVB_FIREDTV 14if DVB_FIREDTV
15 15
16config DVB_FIREDTV_FIREWIRE
17 def_bool FIREWIRE = y || (FIREWIRE = m && DVB_FIREDTV = m)
18
19config DVB_FIREDTV_IEEE1394
20 def_bool IEEE1394 = y || (IEEE1394 = m && DVB_FIREDTV = m)
21
22config DVB_FIREDTV_INPUT 16config DVB_FIREDTV_INPUT
23 def_bool INPUT = y || (INPUT = m && DVB_FIREDTV = m) 17 def_bool INPUT = y || (INPUT = m && DVB_FIREDTV = m)
24 18
diff --git a/drivers/media/dvb/firewire/Makefile b/drivers/media/dvb/firewire/Makefile
index da84203d51c6..357b3aab186b 100644
--- a/drivers/media/dvb/firewire/Makefile
+++ b/drivers/media/dvb/firewire/Makefile
@@ -1,9 +1,6 @@
1obj-$(CONFIG_DVB_FIREDTV) += firedtv.o 1obj-$(CONFIG_DVB_FIREDTV) += firedtv.o
2 2
3firedtv-y := firedtv-avc.o firedtv-ci.o firedtv-dvb.o firedtv-fe.o 3firedtv-y := firedtv-avc.o firedtv-ci.o firedtv-dvb.o firedtv-fe.o firedtv-fw.o
4firedtv-$(CONFIG_DVB_FIREDTV_FIREWIRE) += firedtv-fw.o
5firedtv-$(CONFIG_DVB_FIREDTV_IEEE1394) += firedtv-1394.o
6firedtv-$(CONFIG_DVB_FIREDTV_INPUT) += firedtv-rc.o 4firedtv-$(CONFIG_DVB_FIREDTV_INPUT) += firedtv-rc.o
7 5
8ccflags-y += -Idrivers/media/dvb/dvb-core 6ccflags-y += -Idrivers/media/dvb/dvb-core
9ccflags-$(CONFIG_DVB_FIREDTV_IEEE1394) += -Idrivers/ieee1394
diff --git a/drivers/media/dvb/firewire/firedtv-1394.c b/drivers/media/dvb/firewire/firedtv-1394.c
deleted file mode 100644
index b34ca7afb0e6..000000000000
--- a/drivers/media/dvb/firewire/firedtv-1394.c
+++ /dev/null
@@ -1,300 +0,0 @@
1/*
2 * FireDTV driver -- ieee1394 I/O backend
3 *
4 * Copyright (C) 2004 Andreas Monitzer <andy@monitzer.com>
5 * Copyright (C) 2007-2008 Ben Backx <ben@bbackx.com>
6 * Copyright (C) 2008 Henrik Kurelid <henrik@kurelid.se>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 */
13
14#include <linux/device.h>
15#include <linux/errno.h>
16#include <linux/kernel.h>
17#include <linux/list.h>
18#include <linux/slab.h>
19#include <linux/spinlock.h>
20#include <linux/types.h>
21
22#include <dma.h>
23#include <csr1212.h>
24#include <highlevel.h>
25#include <hosts.h>
26#include <ieee1394.h>
27#include <iso.h>
28#include <nodemgr.h>
29
30#include <dvb_demux.h>
31
32#include "firedtv.h"
33
34static LIST_HEAD(node_list);
35static DEFINE_SPINLOCK(node_list_lock);
36
37#define CIP_HEADER_SIZE 8
38#define MPEG2_TS_HEADER_SIZE 4
39#define MPEG2_TS_SOURCE_PACKET_SIZE (4 + 188)
40
41static void rawiso_activity_cb(struct hpsb_iso *iso)
42{
43 struct firedtv *f, *fdtv = NULL;
44 unsigned int i, num, packet;
45 unsigned char *buf;
46 unsigned long flags;
47 int count;
48
49 spin_lock_irqsave(&node_list_lock, flags);
50 list_for_each_entry(f, &node_list, list)
51 if (f->backend_data == iso) {
52 fdtv = f;
53 break;
54 }
55 spin_unlock_irqrestore(&node_list_lock, flags);
56
57 packet = iso->first_packet;
58 num = hpsb_iso_n_ready(iso);
59
60 if (!fdtv) {
61 pr_err("received at unknown iso channel\n");
62 goto out;
63 }
64
65 for (i = 0; i < num; i++, packet = (packet + 1) % iso->buf_packets) {
66 buf = dma_region_i(&iso->data_buf, unsigned char,
67 iso->infos[packet].offset + CIP_HEADER_SIZE);
68 count = (iso->infos[packet].len - CIP_HEADER_SIZE) /
69 MPEG2_TS_SOURCE_PACKET_SIZE;
70
71 /* ignore empty packet */
72 if (iso->infos[packet].len <= CIP_HEADER_SIZE)
73 continue;
74
75 while (count--) {
76 if (buf[MPEG2_TS_HEADER_SIZE] == 0x47)
77 dvb_dmx_swfilter_packets(&fdtv->demux,
78 &buf[MPEG2_TS_HEADER_SIZE], 1);
79 else
80 dev_err(fdtv->device,
81 "skipping invalid packet\n");
82 buf += MPEG2_TS_SOURCE_PACKET_SIZE;
83 }
84 }
85out:
86 hpsb_iso_recv_release_packets(iso, num);
87}
88
89static inline struct node_entry *node_of(struct firedtv *fdtv)
90{
91 return container_of(fdtv->device, struct unit_directory, device)->ne;
92}
93
94static int node_lock(struct firedtv *fdtv, u64 addr, void *data)
95{
96 quadlet_t *d = data;
97 int ret;
98
99 ret = hpsb_node_lock(node_of(fdtv), addr,
100 EXTCODE_COMPARE_SWAP, &d[1], d[0]);
101 d[0] = d[1];
102
103 return ret;
104}
105
106static int node_read(struct firedtv *fdtv, u64 addr, void *data)
107{
108 return hpsb_node_read(node_of(fdtv), addr, data, 4);
109}
110
111static int node_write(struct firedtv *fdtv, u64 addr, void *data, size_t len)
112{
113 return hpsb_node_write(node_of(fdtv), addr, data, len);
114}
115
116#define FDTV_ISO_BUFFER_PACKETS 256
117#define FDTV_ISO_BUFFER_SIZE (FDTV_ISO_BUFFER_PACKETS * 200)
118
119static int start_iso(struct firedtv *fdtv)
120{
121 struct hpsb_iso *iso_handle;
122 int ret;
123
124 iso_handle = hpsb_iso_recv_init(node_of(fdtv)->host,
125 FDTV_ISO_BUFFER_SIZE, FDTV_ISO_BUFFER_PACKETS,
126 fdtv->isochannel, HPSB_ISO_DMA_DEFAULT,
127 -1, /* stat.config.irq_interval */
128 rawiso_activity_cb);
129 if (iso_handle == NULL) {
130 dev_err(fdtv->device, "cannot initialize iso receive\n");
131 return -ENOMEM;
132 }
133 fdtv->backend_data = iso_handle;
134
135 ret = hpsb_iso_recv_start(iso_handle, -1, -1, 0);
136 if (ret != 0) {
137 dev_err(fdtv->device, "cannot start iso receive\n");
138 hpsb_iso_shutdown(iso_handle);
139 fdtv->backend_data = NULL;
140 }
141 return ret;
142}
143
144static void stop_iso(struct firedtv *fdtv)
145{
146 struct hpsb_iso *iso_handle = fdtv->backend_data;
147
148 if (iso_handle != NULL) {
149 hpsb_iso_stop(iso_handle);
150 hpsb_iso_shutdown(iso_handle);
151 }
152 fdtv->backend_data = NULL;
153}
154
155static const struct firedtv_backend fdtv_1394_backend = {
156 .lock = node_lock,
157 .read = node_read,
158 .write = node_write,
159 .start_iso = start_iso,
160 .stop_iso = stop_iso,
161};
162
163static void fcp_request(struct hpsb_host *host, int nodeid, int direction,
164 int cts, u8 *data, size_t length)
165{
166 struct firedtv *f, *fdtv = NULL;
167 unsigned long flags;
168 int su;
169
170 if (length == 0 || (data[0] & 0xf0) != 0)
171 return;
172
173 su = data[1] & 0x7;
174
175 spin_lock_irqsave(&node_list_lock, flags);
176 list_for_each_entry(f, &node_list, list)
177 if (node_of(f)->host == host &&
178 node_of(f)->nodeid == nodeid &&
179 (f->subunit == su || (f->subunit == 0 && su == 0x7))) {
180 fdtv = f;
181 break;
182 }
183 spin_unlock_irqrestore(&node_list_lock, flags);
184
185 if (fdtv)
186 avc_recv(fdtv, data, length);
187}
188
189static int node_probe(struct device *dev)
190{
191 struct unit_directory *ud =
192 container_of(dev, struct unit_directory, device);
193 struct firedtv *fdtv;
194 int kv_len, err;
195 void *kv_str;
196
197 if (ud->model_name_kv) {
198 kv_len = (ud->model_name_kv->value.leaf.len - 2) * 4;
199 kv_str = CSR1212_TEXTUAL_DESCRIPTOR_LEAF_DATA(ud->model_name_kv);
200 } else {
201 kv_len = 0;
202 kv_str = NULL;
203 }
204 fdtv = fdtv_alloc(dev, &fdtv_1394_backend, kv_str, kv_len);
205 if (!fdtv)
206 return -ENOMEM;
207
208 /*
209 * Work around a bug in udev's path_id script: Use the fw-host's dev
210 * instead of the unit directory's dev as parent of the input device.
211 */
212 err = fdtv_register_rc(fdtv, dev->parent->parent);
213 if (err)
214 goto fail_free;
215
216 spin_lock_irq(&node_list_lock);
217 list_add_tail(&fdtv->list, &node_list);
218 spin_unlock_irq(&node_list_lock);
219
220 err = avc_identify_subunit(fdtv);
221 if (err)
222 goto fail;
223
224 err = fdtv_dvb_register(fdtv);
225 if (err)
226 goto fail;
227
228 avc_register_remote_control(fdtv);
229
230 return 0;
231fail:
232 spin_lock_irq(&node_list_lock);
233 list_del(&fdtv->list);
234 spin_unlock_irq(&node_list_lock);
235 fdtv_unregister_rc(fdtv);
236fail_free:
237 kfree(fdtv);
238
239 return err;
240}
241
242static int node_remove(struct device *dev)
243{
244 struct firedtv *fdtv = dev_get_drvdata(dev);
245
246 fdtv_dvb_unregister(fdtv);
247
248 spin_lock_irq(&node_list_lock);
249 list_del(&fdtv->list);
250 spin_unlock_irq(&node_list_lock);
251
252 fdtv_unregister_rc(fdtv);
253 kfree(fdtv);
254
255 return 0;
256}
257
258static int node_update(struct unit_directory *ud)
259{
260 struct firedtv *fdtv = dev_get_drvdata(&ud->device);
261
262 if (fdtv->isochannel >= 0)
263 cmp_establish_pp_connection(fdtv, fdtv->subunit,
264 fdtv->isochannel);
265 return 0;
266}
267
268static struct hpsb_protocol_driver fdtv_driver = {
269 .name = "firedtv",
270 .id_table = fdtv_id_table,
271 .update = node_update,
272 .driver = {
273 .probe = node_probe,
274 .remove = node_remove,
275 },
276};
277
278static struct hpsb_highlevel fdtv_highlevel = {
279 .name = "firedtv",
280 .fcp_request = fcp_request,
281};
282
283int __init fdtv_1394_init(void)
284{
285 int ret;
286
287 hpsb_register_highlevel(&fdtv_highlevel);
288 ret = hpsb_register_protocol(&fdtv_driver);
289 if (ret) {
290 printk(KERN_ERR "firedtv: failed to register protocol\n");
291 hpsb_unregister_highlevel(&fdtv_highlevel);
292 }
293 return ret;
294}
295
296void __exit fdtv_1394_exit(void)
297{
298 hpsb_unregister_protocol(&fdtv_driver);
299 hpsb_unregister_highlevel(&fdtv_highlevel);
300}
diff --git a/drivers/media/dvb/firewire/firedtv-avc.c b/drivers/media/dvb/firewire/firedtv-avc.c
index 28294af752db..21c52e3b522e 100644
--- a/drivers/media/dvb/firewire/firedtv-avc.c
+++ b/drivers/media/dvb/firewire/firedtv-avc.c
@@ -24,6 +24,8 @@
24#include <linux/wait.h> 24#include <linux/wait.h>
25#include <linux/workqueue.h> 25#include <linux/workqueue.h>
26 26
27#include <dvb_frontend.h>
28
27#include "firedtv.h" 29#include "firedtv.h"
28 30
29#define FCP_COMMAND_REGISTER 0xfffff0000b00ULL 31#define FCP_COMMAND_REGISTER 0xfffff0000b00ULL
@@ -130,6 +132,20 @@ MODULE_PARM_DESC(debug, "Verbose logging (none = 0"
130 ", FCP payloads = " __stringify(AVC_DEBUG_FCP_PAYLOADS) 132 ", FCP payloads = " __stringify(AVC_DEBUG_FCP_PAYLOADS)
131 ", or a combination, or all = -1)"); 133 ", or a combination, or all = -1)");
132 134
135/*
136 * This is a workaround since there is no vendor specific command to retrieve
137 * ca_info using AVC. If this parameter is not used, ca_system_id will be
138 * filled with application_manufacturer from ca_app_info.
139 * Digital Everywhere have said that adding ca_info is on their TODO list.
140 */
141static unsigned int num_fake_ca_system_ids;
142static int fake_ca_system_ids[4] = { -1, -1, -1, -1 };
143module_param_array(fake_ca_system_ids, int, &num_fake_ca_system_ids, 0644);
144MODULE_PARM_DESC(fake_ca_system_ids, "If your CAM application manufacturer "
145 "does not have the same ca_system_id as your CAS, you can "
146 "override what ca_system_ids are presented to the "
147 "application by setting this field to an array of ids.");
148
133static const char *debug_fcp_ctype(unsigned int ctype) 149static const char *debug_fcp_ctype(unsigned int ctype)
134{ 150{
135 static const char *ctypes[] = { 151 static const char *ctypes[] = {
@@ -225,8 +241,8 @@ static int avc_write(struct firedtv *fdtv)
225 if (unlikely(avc_debug)) 241 if (unlikely(avc_debug))
226 debug_fcp(fdtv->avc_data, fdtv->avc_data_length); 242 debug_fcp(fdtv->avc_data, fdtv->avc_data_length);
227 243
228 err = fdtv->backend->write(fdtv, FCP_COMMAND_REGISTER, 244 err = fdtv_write(fdtv, FCP_COMMAND_REGISTER,
229 fdtv->avc_data, fdtv->avc_data_length); 245 fdtv->avc_data, fdtv->avc_data_length);
230 if (err) { 246 if (err) {
231 dev_err(fdtv->device, "FCP command write failed\n"); 247 dev_err(fdtv->device, "FCP command write failed\n");
232 248
@@ -368,10 +384,30 @@ static int avc_tuner_tuneqpsk(struct firedtv *fdtv,
368 c->operand[12] = 0; 384 c->operand[12] = 0;
369 385
370 if (fdtv->type == FIREDTV_DVB_S2) { 386 if (fdtv->type == FIREDTV_DVB_S2) {
371 c->operand[13] = 0x1; 387 if (fdtv->fe.dtv_property_cache.delivery_system == SYS_DVBS2) {
372 c->operand[14] = 0xff; 388 switch (fdtv->fe.dtv_property_cache.modulation) {
373 c->operand[15] = 0xff; 389 case QAM_16: c->operand[13] = 0x1; break;
374 390 case QPSK: c->operand[13] = 0x2; break;
391 case PSK_8: c->operand[13] = 0x3; break;
392 default: c->operand[13] = 0x2; break;
393 }
394 switch (fdtv->fe.dtv_property_cache.rolloff) {
395 case ROLLOFF_AUTO: c->operand[14] = 0x2; break;
396 case ROLLOFF_35: c->operand[14] = 0x2; break;
397 case ROLLOFF_20: c->operand[14] = 0x0; break;
398 case ROLLOFF_25: c->operand[14] = 0x1; break;
399 /* case ROLLOFF_NONE: c->operand[14] = 0xff; break; */
400 }
401 switch (fdtv->fe.dtv_property_cache.pilot) {
402 case PILOT_AUTO: c->operand[15] = 0x0; break;
403 case PILOT_OFF: c->operand[15] = 0x0; break;
404 case PILOT_ON: c->operand[15] = 0x1; break;
405 }
406 } else {
407 c->operand[13] = 0x1; /* auto modulation */
408 c->operand[14] = 0xff; /* disable rolloff */
409 c->operand[15] = 0xff; /* disable pilot */
410 }
375 return 16; 411 return 16;
376 } else { 412 } else {
377 return 13; 413 return 13;
@@ -977,7 +1013,7 @@ int avc_ca_info(struct firedtv *fdtv, char *app_info, unsigned int *len)
977{ 1013{
978 struct avc_command_frame *c = (void *)fdtv->avc_data; 1014 struct avc_command_frame *c = (void *)fdtv->avc_data;
979 struct avc_response_frame *r = (void *)fdtv->avc_data; 1015 struct avc_response_frame *r = (void *)fdtv->avc_data;
980 int pos, ret; 1016 int i, pos, ret;
981 1017
982 mutex_lock(&fdtv->avc_mutex); 1018 mutex_lock(&fdtv->avc_mutex);
983 1019
@@ -1004,9 +1040,18 @@ int avc_ca_info(struct firedtv *fdtv, char *app_info, unsigned int *len)
1004 app_info[0] = (EN50221_TAG_CA_INFO >> 16) & 0xff; 1040 app_info[0] = (EN50221_TAG_CA_INFO >> 16) & 0xff;
1005 app_info[1] = (EN50221_TAG_CA_INFO >> 8) & 0xff; 1041 app_info[1] = (EN50221_TAG_CA_INFO >> 8) & 0xff;
1006 app_info[2] = (EN50221_TAG_CA_INFO >> 0) & 0xff; 1042 app_info[2] = (EN50221_TAG_CA_INFO >> 0) & 0xff;
1007 app_info[3] = 2; 1043 if (num_fake_ca_system_ids == 0) {
1008 app_info[4] = r->operand[pos + 0]; 1044 app_info[3] = 2;
1009 app_info[5] = r->operand[pos + 1]; 1045 app_info[4] = r->operand[pos + 0];
1046 app_info[5] = r->operand[pos + 1];
1047 } else {
1048 app_info[3] = num_fake_ca_system_ids * 2;
1049 for (i = 0; i < num_fake_ca_system_ids; i++) {
1050 app_info[4 + i * 2] =
1051 (fake_ca_system_ids[i] >> 8) & 0xff;
1052 app_info[5 + i * 2] = fake_ca_system_ids[i] & 0xff;
1053 }
1054 }
1010 *len = app_info[3] + 4; 1055 *len = app_info[3] + 4;
1011out: 1056out:
1012 mutex_unlock(&fdtv->avc_mutex); 1057 mutex_unlock(&fdtv->avc_mutex);
@@ -1275,14 +1320,10 @@ static int cmp_read(struct firedtv *fdtv, u64 addr, __be32 *data)
1275{ 1320{
1276 int ret; 1321 int ret;
1277 1322
1278 mutex_lock(&fdtv->avc_mutex); 1323 ret = fdtv_read(fdtv, addr, data);
1279
1280 ret = fdtv->backend->read(fdtv, addr, data);
1281 if (ret < 0) 1324 if (ret < 0)
1282 dev_err(fdtv->device, "CMP: read I/O error\n"); 1325 dev_err(fdtv->device, "CMP: read I/O error\n");
1283 1326
1284 mutex_unlock(&fdtv->avc_mutex);
1285
1286 return ret; 1327 return ret;
1287} 1328}
1288 1329
@@ -1290,18 +1331,9 @@ static int cmp_lock(struct firedtv *fdtv, u64 addr, __be32 data[])
1290{ 1331{
1291 int ret; 1332 int ret;
1292 1333
1293 mutex_lock(&fdtv->avc_mutex); 1334 ret = fdtv_lock(fdtv, addr, data);
1294
1295 /* data[] is stack-allocated and should not be DMA-mapped. */
1296 memcpy(fdtv->avc_data, data, 8);
1297
1298 ret = fdtv->backend->lock(fdtv, addr, fdtv->avc_data);
1299 if (ret < 0) 1335 if (ret < 0)
1300 dev_err(fdtv->device, "CMP: lock I/O error\n"); 1336 dev_err(fdtv->device, "CMP: lock I/O error\n");
1301 else
1302 memcpy(data, fdtv->avc_data, 8);
1303
1304 mutex_unlock(&fdtv->avc_mutex);
1305 1337
1306 return ret; 1338 return ret;
1307} 1339}
@@ -1360,10 +1392,7 @@ repeat:
1360 /* FIXME: this is for the worst case - optimize */ 1392 /* FIXME: this is for the worst case - optimize */
1361 set_opcr_overhead_id(opcr, 0); 1393 set_opcr_overhead_id(opcr, 0);
1362 1394
1363 /* 1395 /* FIXME: allocate isochronous channel and bandwidth at IRM */
1364 * FIXME: allocate isochronous channel and bandwidth at IRM
1365 * fdtv->backend->alloc_resources(fdtv, channels_mask, bw);
1366 */
1367 } 1396 }
1368 1397
1369 set_opcr_p2p_connections(opcr, get_opcr_p2p_connections(*opcr) + 1); 1398 set_opcr_p2p_connections(opcr, get_opcr_p2p_connections(*opcr) + 1);
@@ -1379,8 +1408,6 @@ repeat:
1379 /* 1408 /*
1380 * FIXME: if old_opcr.P2P_Connections > 0, 1409 * FIXME: if old_opcr.P2P_Connections > 0,
1381 * deallocate isochronous channel and bandwidth at IRM 1410 * deallocate isochronous channel and bandwidth at IRM
1382 * if (...)
1383 * fdtv->backend->dealloc_resources(fdtv, channel, bw);
1384 */ 1411 */
1385 1412
1386 if (++attempts < 6) /* arbitrary limit */ 1413 if (++attempts < 6) /* arbitrary limit */
diff --git a/drivers/media/dvb/firewire/firedtv-ci.c b/drivers/media/dvb/firewire/firedtv-ci.c
index d3c2cf60de76..8ffb565f0704 100644
--- a/drivers/media/dvb/firewire/firedtv-ci.c
+++ b/drivers/media/dvb/firewire/firedtv-ci.c
@@ -220,6 +220,7 @@ static const struct file_operations fdtv_ca_fops = {
220 .open = dvb_generic_open, 220 .open = dvb_generic_open,
221 .release = dvb_generic_release, 221 .release = dvb_generic_release,
222 .poll = fdtv_ca_io_poll, 222 .poll = fdtv_ca_io_poll,
223 .llseek = noop_llseek,
223}; 224};
224 225
225static struct dvb_device fdtv_ca = { 226static struct dvb_device fdtv_ca = {
diff --git a/drivers/media/dvb/firewire/firedtv-dvb.c b/drivers/media/dvb/firewire/firedtv-dvb.c
index 079e8c5b0475..fd8bbbfa5c59 100644
--- a/drivers/media/dvb/firewire/firedtv-dvb.c
+++ b/drivers/media/dvb/firewire/firedtv-dvb.c
@@ -14,14 +14,9 @@
14#include <linux/device.h> 14#include <linux/device.h>
15#include <linux/errno.h> 15#include <linux/errno.h>
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/mod_devicetable.h>
18#include <linux/module.h> 17#include <linux/module.h>
19#include <linux/mutex.h> 18#include <linux/mutex.h>
20#include <linux/slab.h>
21#include <linux/string.h>
22#include <linux/types.h> 19#include <linux/types.h>
23#include <linux/wait.h>
24#include <linux/workqueue.h>
25 20
26#include <dmxdev.h> 21#include <dmxdev.h>
27#include <dvb_demux.h> 22#include <dvb_demux.h>
@@ -166,11 +161,11 @@ int fdtv_stop_feed(struct dvb_demux_feed *dvbdmxfeed)
166 161
167DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); 162DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
168 163
169int fdtv_dvb_register(struct firedtv *fdtv) 164int fdtv_dvb_register(struct firedtv *fdtv, const char *name)
170{ 165{
171 int err; 166 int err;
172 167
173 err = dvb_register_adapter(&fdtv->adapter, fdtv_model_names[fdtv->type], 168 err = dvb_register_adapter(&fdtv->adapter, name,
174 THIS_MODULE, fdtv->device, adapter_nr); 169 THIS_MODULE, fdtv->device, adapter_nr);
175 if (err < 0) 170 if (err < 0)
176 goto fail_log; 171 goto fail_log;
@@ -210,7 +205,7 @@ int fdtv_dvb_register(struct firedtv *fdtv)
210 205
211 dvb_net_init(&fdtv->adapter, &fdtv->dvbnet, &fdtv->demux.dmx); 206 dvb_net_init(&fdtv->adapter, &fdtv->dvbnet, &fdtv->demux.dmx);
212 207
213 fdtv_frontend_init(fdtv); 208 fdtv_frontend_init(fdtv, name);
214 err = dvb_register_frontend(&fdtv->adapter, &fdtv->fe); 209 err = dvb_register_frontend(&fdtv->adapter, &fdtv->fe);
215 if (err) 210 if (err)
216 goto fail_net_release; 211 goto fail_net_release;
@@ -248,127 +243,3 @@ void fdtv_dvb_unregister(struct firedtv *fdtv)
248 dvb_dmx_release(&fdtv->demux); 243 dvb_dmx_release(&fdtv->demux);
249 dvb_unregister_adapter(&fdtv->adapter); 244 dvb_unregister_adapter(&fdtv->adapter);
250} 245}
251
252const char *fdtv_model_names[] = {
253 [FIREDTV_UNKNOWN] = "unknown type",
254 [FIREDTV_DVB_S] = "FireDTV S/CI",
255 [FIREDTV_DVB_C] = "FireDTV C/CI",
256 [FIREDTV_DVB_T] = "FireDTV T/CI",
257 [FIREDTV_DVB_S2] = "FireDTV S2 ",
258};
259
260struct firedtv *fdtv_alloc(struct device *dev,
261 const struct firedtv_backend *backend,
262 const char *name, size_t name_len)
263{
264 struct firedtv *fdtv;
265 int i;
266
267 fdtv = kzalloc(sizeof(*fdtv), GFP_KERNEL);
268 if (!fdtv)
269 return NULL;
270
271 dev_set_drvdata(dev, fdtv);
272 fdtv->device = dev;
273 fdtv->isochannel = -1;
274 fdtv->voltage = 0xff;
275 fdtv->tone = 0xff;
276 fdtv->backend = backend;
277
278 mutex_init(&fdtv->avc_mutex);
279 init_waitqueue_head(&fdtv->avc_wait);
280 mutex_init(&fdtv->demux_mutex);
281 INIT_WORK(&fdtv->remote_ctrl_work, avc_remote_ctrl_work);
282
283 for (i = ARRAY_SIZE(fdtv_model_names); --i; )
284 if (strlen(fdtv_model_names[i]) <= name_len &&
285 strncmp(name, fdtv_model_names[i], name_len) == 0)
286 break;
287 fdtv->type = i;
288
289 return fdtv;
290}
291
292#define MATCH_FLAGS (IEEE1394_MATCH_VENDOR_ID | IEEE1394_MATCH_MODEL_ID | \
293 IEEE1394_MATCH_SPECIFIER_ID | IEEE1394_MATCH_VERSION)
294
295#define DIGITAL_EVERYWHERE_OUI 0x001287
296#define AVC_UNIT_SPEC_ID_ENTRY 0x00a02d
297#define AVC_SW_VERSION_ENTRY 0x010001
298
299const struct ieee1394_device_id fdtv_id_table[] = {
300 {
301 /* FloppyDTV S/CI and FloppyDTV S2 */
302 .match_flags = MATCH_FLAGS,
303 .vendor_id = DIGITAL_EVERYWHERE_OUI,
304 .model_id = 0x000024,
305 .specifier_id = AVC_UNIT_SPEC_ID_ENTRY,
306 .version = AVC_SW_VERSION_ENTRY,
307 }, {
308 /* FloppyDTV T/CI */
309 .match_flags = MATCH_FLAGS,
310 .vendor_id = DIGITAL_EVERYWHERE_OUI,
311 .model_id = 0x000025,
312 .specifier_id = AVC_UNIT_SPEC_ID_ENTRY,
313 .version = AVC_SW_VERSION_ENTRY,
314 }, {
315 /* FloppyDTV C/CI */
316 .match_flags = MATCH_FLAGS,
317 .vendor_id = DIGITAL_EVERYWHERE_OUI,
318 .model_id = 0x000026,
319 .specifier_id = AVC_UNIT_SPEC_ID_ENTRY,
320 .version = AVC_SW_VERSION_ENTRY,
321 }, {
322 /* FireDTV S/CI and FloppyDTV S2 */
323 .match_flags = MATCH_FLAGS,
324 .vendor_id = DIGITAL_EVERYWHERE_OUI,
325 .model_id = 0x000034,
326 .specifier_id = AVC_UNIT_SPEC_ID_ENTRY,
327 .version = AVC_SW_VERSION_ENTRY,
328 }, {
329 /* FireDTV T/CI */
330 .match_flags = MATCH_FLAGS,
331 .vendor_id = DIGITAL_EVERYWHERE_OUI,
332 .model_id = 0x000035,
333 .specifier_id = AVC_UNIT_SPEC_ID_ENTRY,
334 .version = AVC_SW_VERSION_ENTRY,
335 }, {
336 /* FireDTV C/CI */
337 .match_flags = MATCH_FLAGS,
338 .vendor_id = DIGITAL_EVERYWHERE_OUI,
339 .model_id = 0x000036,
340 .specifier_id = AVC_UNIT_SPEC_ID_ENTRY,
341 .version = AVC_SW_VERSION_ENTRY,
342 }, {}
343};
344MODULE_DEVICE_TABLE(ieee1394, fdtv_id_table);
345
346static int __init fdtv_init(void)
347{
348 int ret;
349
350 ret = fdtv_fw_init();
351 if (ret < 0)
352 return ret;
353
354 ret = fdtv_1394_init();
355 if (ret < 0)
356 fdtv_fw_exit();
357
358 return ret;
359}
360
361static void __exit fdtv_exit(void)
362{
363 fdtv_1394_exit();
364 fdtv_fw_exit();
365}
366
367module_init(fdtv_init);
368module_exit(fdtv_exit);
369
370MODULE_AUTHOR("Andreas Monitzer <andy@monitzer.com>");
371MODULE_AUTHOR("Ben Backx <ben@bbackx.com>");
372MODULE_DESCRIPTION("FireDTV DVB Driver");
373MODULE_LICENSE("GPL");
374MODULE_SUPPORTED_DEVICE("FireDTV DVB");
diff --git a/drivers/media/dvb/firewire/firedtv-fe.c b/drivers/media/dvb/firewire/firedtv-fe.c
index e49cdc88b0c7..8748a61be73d 100644
--- a/drivers/media/dvb/firewire/firedtv-fe.c
+++ b/drivers/media/dvb/firewire/firedtv-fe.c
@@ -36,14 +36,14 @@ static int fdtv_dvb_init(struct dvb_frontend *fe)
36 return err; 36 return err;
37 } 37 }
38 38
39 return fdtv->backend->start_iso(fdtv); 39 return fdtv_start_iso(fdtv);
40} 40}
41 41
42static int fdtv_sleep(struct dvb_frontend *fe) 42static int fdtv_sleep(struct dvb_frontend *fe)
43{ 43{
44 struct firedtv *fdtv = fe->sec_priv; 44 struct firedtv *fdtv = fe->sec_priv;
45 45
46 fdtv->backend->stop_iso(fdtv); 46 fdtv_stop_iso(fdtv);
47 cmp_break_pp_connection(fdtv, fdtv->subunit, fdtv->isochannel); 47 cmp_break_pp_connection(fdtv, fdtv->subunit, fdtv->isochannel);
48 fdtv->isochannel = -1; 48 fdtv->isochannel = -1;
49 return 0; 49 return 0;
@@ -155,7 +155,17 @@ static int fdtv_get_frontend(struct dvb_frontend *fe,
155 return -EOPNOTSUPP; 155 return -EOPNOTSUPP;
156} 156}
157 157
158void fdtv_frontend_init(struct firedtv *fdtv) 158static int fdtv_get_property(struct dvb_frontend *fe, struct dtv_property *tvp)
159{
160 return 0;
161}
162
163static int fdtv_set_property(struct dvb_frontend *fe, struct dtv_property *tvp)
164{
165 return 0;
166}
167
168void fdtv_frontend_init(struct firedtv *fdtv, const char *name)
159{ 169{
160 struct dvb_frontend_ops *ops = &fdtv->fe.ops; 170 struct dvb_frontend_ops *ops = &fdtv->fe.ops;
161 struct dvb_frontend_info *fi = &ops->info; 171 struct dvb_frontend_info *fi = &ops->info;
@@ -166,6 +176,9 @@ void fdtv_frontend_init(struct firedtv *fdtv)
166 ops->set_frontend = fdtv_set_frontend; 176 ops->set_frontend = fdtv_set_frontend;
167 ops->get_frontend = fdtv_get_frontend; 177 ops->get_frontend = fdtv_get_frontend;
168 178
179 ops->get_property = fdtv_get_property;
180 ops->set_property = fdtv_set_property;
181
169 ops->read_status = fdtv_read_status; 182 ops->read_status = fdtv_read_status;
170 ops->read_ber = fdtv_read_ber; 183 ops->read_ber = fdtv_read_ber;
171 ops->read_signal_strength = fdtv_read_signal_strength; 184 ops->read_signal_strength = fdtv_read_signal_strength;
@@ -179,7 +192,6 @@ void fdtv_frontend_init(struct firedtv *fdtv)
179 192
180 switch (fdtv->type) { 193 switch (fdtv->type) {
181 case FIREDTV_DVB_S: 194 case FIREDTV_DVB_S:
182 case FIREDTV_DVB_S2:
183 fi->type = FE_QPSK; 195 fi->type = FE_QPSK;
184 196
185 fi->frequency_min = 950000; 197 fi->frequency_min = 950000;
@@ -188,7 +200,7 @@ void fdtv_frontend_init(struct firedtv *fdtv)
188 fi->symbol_rate_min = 1000000; 200 fi->symbol_rate_min = 1000000;
189 fi->symbol_rate_max = 40000000; 201 fi->symbol_rate_max = 40000000;
190 202
191 fi->caps = FE_CAN_INVERSION_AUTO | 203 fi->caps = FE_CAN_INVERSION_AUTO |
192 FE_CAN_FEC_1_2 | 204 FE_CAN_FEC_1_2 |
193 FE_CAN_FEC_2_3 | 205 FE_CAN_FEC_2_3 |
194 FE_CAN_FEC_3_4 | 206 FE_CAN_FEC_3_4 |
@@ -198,6 +210,26 @@ void fdtv_frontend_init(struct firedtv *fdtv)
198 FE_CAN_QPSK; 210 FE_CAN_QPSK;
199 break; 211 break;
200 212
213 case FIREDTV_DVB_S2:
214 fi->type = FE_QPSK;
215
216 fi->frequency_min = 950000;
217 fi->frequency_max = 2150000;
218 fi->frequency_stepsize = 125;
219 fi->symbol_rate_min = 1000000;
220 fi->symbol_rate_max = 40000000;
221
222 fi->caps = FE_CAN_INVERSION_AUTO |
223 FE_CAN_FEC_1_2 |
224 FE_CAN_FEC_2_3 |
225 FE_CAN_FEC_3_4 |
226 FE_CAN_FEC_5_6 |
227 FE_CAN_FEC_7_8 |
228 FE_CAN_FEC_AUTO |
229 FE_CAN_QPSK |
230 FE_CAN_2G_MODULATION;
231 break;
232
201 case FIREDTV_DVB_C: 233 case FIREDTV_DVB_C:
202 fi->type = FE_QAM; 234 fi->type = FE_QAM;
203 235
@@ -234,7 +266,7 @@ void fdtv_frontend_init(struct firedtv *fdtv)
234 dev_err(fdtv->device, "no frontend for model type %d\n", 266 dev_err(fdtv->device, "no frontend for model type %d\n",
235 fdtv->type); 267 fdtv->type);
236 } 268 }
237 strcpy(fi->name, fdtv_model_names[fdtv->type]); 269 strcpy(fi->name, name);
238 270
239 fdtv->fe.dvb = &fdtv->adapter; 271 fdtv->fe.dvb = &fdtv->adapter;
240 fdtv->fe.sec_priv = fdtv; 272 fdtv->fe.sec_priv = fdtv;
diff --git a/drivers/media/dvb/firewire/firedtv-fw.c b/drivers/media/dvb/firewire/firedtv-fw.c
index 7424b0493f9d..864b6274c729 100644
--- a/drivers/media/dvb/firewire/firedtv-fw.c
+++ b/drivers/media/dvb/firewire/firedtv-fw.c
@@ -9,11 +9,18 @@
9#include <linux/kernel.h> 9#include <linux/kernel.h>
10#include <linux/list.h> 10#include <linux/list.h>
11#include <linux/mm.h> 11#include <linux/mm.h>
12#include <linux/mod_devicetable.h>
13#include <linux/module.h>
14#include <linux/mutex.h>
12#include <linux/slab.h> 15#include <linux/slab.h>
13#include <linux/spinlock.h> 16#include <linux/spinlock.h>
17#include <linux/string.h>
14#include <linux/types.h> 18#include <linux/types.h>
19#include <linux/wait.h>
20#include <linux/workqueue.h>
15 21
16#include <asm/page.h> 22#include <asm/page.h>
23#include <asm/system.h>
17 24
18#include <dvb_demux.h> 25#include <dvb_demux.h>
19 26
@@ -41,17 +48,17 @@ static int node_req(struct firedtv *fdtv, u64 addr, void *data, size_t len,
41 return rcode != RCODE_COMPLETE ? -EIO : 0; 48 return rcode != RCODE_COMPLETE ? -EIO : 0;
42} 49}
43 50
44static int node_lock(struct firedtv *fdtv, u64 addr, void *data) 51int fdtv_lock(struct firedtv *fdtv, u64 addr, void *data)
45{ 52{
46 return node_req(fdtv, addr, data, 8, TCODE_LOCK_COMPARE_SWAP); 53 return node_req(fdtv, addr, data, 8, TCODE_LOCK_COMPARE_SWAP);
47} 54}
48 55
49static int node_read(struct firedtv *fdtv, u64 addr, void *data) 56int fdtv_read(struct firedtv *fdtv, u64 addr, void *data)
50{ 57{
51 return node_req(fdtv, addr, data, 4, TCODE_READ_QUADLET_REQUEST); 58 return node_req(fdtv, addr, data, 4, TCODE_READ_QUADLET_REQUEST);
52} 59}
53 60
54static int node_write(struct firedtv *fdtv, u64 addr, void *data, size_t len) 61int fdtv_write(struct firedtv *fdtv, u64 addr, void *data, size_t len)
55{ 62{
56 return node_req(fdtv, addr, data, len, TCODE_WRITE_BLOCK_REQUEST); 63 return node_req(fdtv, addr, data, len, TCODE_WRITE_BLOCK_REQUEST);
57} 64}
@@ -67,7 +74,7 @@ static int node_write(struct firedtv *fdtv, u64 addr, void *data, size_t len)
67#define N_PAGES DIV_ROUND_UP(N_PACKETS, PACKETS_PER_PAGE) 74#define N_PAGES DIV_ROUND_UP(N_PACKETS, PACKETS_PER_PAGE)
68#define IRQ_INTERVAL 16 75#define IRQ_INTERVAL 16
69 76
70struct firedtv_receive_context { 77struct fdtv_ir_context {
71 struct fw_iso_context *context; 78 struct fw_iso_context *context;
72 struct fw_iso_buffer buffer; 79 struct fw_iso_buffer buffer;
73 int interrupt_packet; 80 int interrupt_packet;
@@ -75,7 +82,7 @@ struct firedtv_receive_context {
75 char *pages[N_PAGES]; 82 char *pages[N_PAGES];
76}; 83};
77 84
78static int queue_iso(struct firedtv_receive_context *ctx, int index) 85static int queue_iso(struct fdtv_ir_context *ctx, int index)
79{ 86{
80 struct fw_iso_packet p; 87 struct fw_iso_packet p;
81 88
@@ -92,7 +99,7 @@ static void handle_iso(struct fw_iso_context *context, u32 cycle,
92 size_t header_length, void *header, void *data) 99 size_t header_length, void *header, void *data)
93{ 100{
94 struct firedtv *fdtv = data; 101 struct firedtv *fdtv = data;
95 struct firedtv_receive_context *ctx = fdtv->backend_data; 102 struct fdtv_ir_context *ctx = fdtv->ir_context;
96 __be32 *h, *h_end; 103 __be32 *h, *h_end;
97 int length, err, i = ctx->current_packet; 104 int length, err, i = ctx->current_packet;
98 char *p, *p_end; 105 char *p, *p_end;
@@ -118,12 +125,13 @@ static void handle_iso(struct fw_iso_context *context, u32 cycle,
118 125
119 i = (i + 1) & (N_PACKETS - 1); 126 i = (i + 1) & (N_PACKETS - 1);
120 } 127 }
128 fw_iso_context_queue_flush(ctx->context);
121 ctx->current_packet = i; 129 ctx->current_packet = i;
122} 130}
123 131
124static int start_iso(struct firedtv *fdtv) 132int fdtv_start_iso(struct firedtv *fdtv)
125{ 133{
126 struct firedtv_receive_context *ctx; 134 struct fdtv_ir_context *ctx;
127 struct fw_device *device = device_of(fdtv); 135 struct fw_device *device = device_of(fdtv);
128 int i, err; 136 int i, err;
129 137
@@ -161,7 +169,7 @@ static int start_iso(struct firedtv *fdtv)
161 if (err) 169 if (err)
162 goto fail; 170 goto fail;
163 171
164 fdtv->backend_data = ctx; 172 fdtv->ir_context = ctx;
165 173
166 return 0; 174 return 0;
167fail: 175fail:
@@ -174,9 +182,9 @@ fail_free:
174 return err; 182 return err;
175} 183}
176 184
177static void stop_iso(struct firedtv *fdtv) 185void fdtv_stop_iso(struct firedtv *fdtv)
178{ 186{
179 struct firedtv_receive_context *ctx = fdtv->backend_data; 187 struct fdtv_ir_context *ctx = fdtv->ir_context;
180 188
181 fw_iso_context_stop(ctx->context); 189 fw_iso_context_stop(ctx->context);
182 fw_iso_buffer_destroy(&ctx->buffer, device_of(fdtv)->card); 190 fw_iso_buffer_destroy(&ctx->buffer, device_of(fdtv)->card);
@@ -184,14 +192,6 @@ static void stop_iso(struct firedtv *fdtv)
184 kfree(ctx); 192 kfree(ctx);
185} 193}
186 194
187static const struct firedtv_backend backend = {
188 .lock = node_lock,
189 .read = node_read,
190 .write = node_write,
191 .start_iso = start_iso,
192 .stop_iso = stop_iso,
193};
194
195static void handle_fcp(struct fw_card *card, struct fw_request *request, 195static void handle_fcp(struct fw_card *card, struct fw_request *request,
196 int tcode, int destination, int source, int generation, 196 int tcode, int destination, int source, int generation,
197 unsigned long long offset, void *payload, size_t length, 197 unsigned long long offset, void *payload, size_t length,
@@ -238,6 +238,14 @@ static const struct fw_address_region fcp_region = {
238 .end = CSR_REGISTER_BASE + CSR_FCP_END, 238 .end = CSR_REGISTER_BASE + CSR_FCP_END,
239}; 239};
240 240
241static const char * const model_names[] = {
242 [FIREDTV_UNKNOWN] = "unknown type",
243 [FIREDTV_DVB_S] = "FireDTV S/CI",
244 [FIREDTV_DVB_C] = "FireDTV C/CI",
245 [FIREDTV_DVB_T] = "FireDTV T/CI",
246 [FIREDTV_DVB_S2] = "FireDTV S2 ",
247};
248
241/* Adjust the template string if models with longer names appear. */ 249/* Adjust the template string if models with longer names appear. */
242#define MAX_MODEL_NAME_LEN sizeof("FireDTV ????") 250#define MAX_MODEL_NAME_LEN sizeof("FireDTV ????")
243 251
@@ -245,15 +253,31 @@ static int node_probe(struct device *dev)
245{ 253{
246 struct firedtv *fdtv; 254 struct firedtv *fdtv;
247 char name[MAX_MODEL_NAME_LEN]; 255 char name[MAX_MODEL_NAME_LEN];
248 int name_len, err; 256 int name_len, i, err;
249
250 name_len = fw_csr_string(fw_unit(dev)->directory, CSR_MODEL,
251 name, sizeof(name));
252 257
253 fdtv = fdtv_alloc(dev, &backend, name, name_len >= 0 ? name_len : 0); 258 fdtv = kzalloc(sizeof(*fdtv), GFP_KERNEL);
254 if (!fdtv) 259 if (!fdtv)
255 return -ENOMEM; 260 return -ENOMEM;
256 261
262 dev_set_drvdata(dev, fdtv);
263 fdtv->device = dev;
264 fdtv->isochannel = -1;
265 fdtv->voltage = 0xff;
266 fdtv->tone = 0xff;
267
268 mutex_init(&fdtv->avc_mutex);
269 init_waitqueue_head(&fdtv->avc_wait);
270 mutex_init(&fdtv->demux_mutex);
271 INIT_WORK(&fdtv->remote_ctrl_work, avc_remote_ctrl_work);
272
273 name_len = fw_csr_string(fw_unit(dev)->directory, CSR_MODEL,
274 name, sizeof(name));
275 for (i = ARRAY_SIZE(model_names); --i; )
276 if (strlen(model_names[i]) <= name_len &&
277 strncmp(name, model_names[i], name_len) == 0)
278 break;
279 fdtv->type = i;
280
257 err = fdtv_register_rc(fdtv, dev); 281 err = fdtv_register_rc(fdtv, dev);
258 if (err) 282 if (err)
259 goto fail_free; 283 goto fail_free;
@@ -266,7 +290,7 @@ static int node_probe(struct device *dev)
266 if (err) 290 if (err)
267 goto fail; 291 goto fail;
268 292
269 err = fdtv_dvb_register(fdtv); 293 err = fdtv_dvb_register(fdtv, model_names[fdtv->type]);
270 if (err) 294 if (err)
271 goto fail; 295 goto fail;
272 296
@@ -309,6 +333,60 @@ static void node_update(struct fw_unit *unit)
309 fdtv->isochannel); 333 fdtv->isochannel);
310} 334}
311 335
336#define MATCH_FLAGS (IEEE1394_MATCH_VENDOR_ID | IEEE1394_MATCH_MODEL_ID | \
337 IEEE1394_MATCH_SPECIFIER_ID | IEEE1394_MATCH_VERSION)
338
339#define DIGITAL_EVERYWHERE_OUI 0x001287
340#define AVC_UNIT_SPEC_ID_ENTRY 0x00a02d
341#define AVC_SW_VERSION_ENTRY 0x010001
342
343static const struct ieee1394_device_id fdtv_id_table[] = {
344 {
345 /* FloppyDTV S/CI and FloppyDTV S2 */
346 .match_flags = MATCH_FLAGS,
347 .vendor_id = DIGITAL_EVERYWHERE_OUI,
348 .model_id = 0x000024,
349 .specifier_id = AVC_UNIT_SPEC_ID_ENTRY,
350 .version = AVC_SW_VERSION_ENTRY,
351 }, {
352 /* FloppyDTV T/CI */
353 .match_flags = MATCH_FLAGS,
354 .vendor_id = DIGITAL_EVERYWHERE_OUI,
355 .model_id = 0x000025,
356 .specifier_id = AVC_UNIT_SPEC_ID_ENTRY,
357 .version = AVC_SW_VERSION_ENTRY,
358 }, {
359 /* FloppyDTV C/CI */
360 .match_flags = MATCH_FLAGS,
361 .vendor_id = DIGITAL_EVERYWHERE_OUI,
362 .model_id = 0x000026,
363 .specifier_id = AVC_UNIT_SPEC_ID_ENTRY,
364 .version = AVC_SW_VERSION_ENTRY,
365 }, {
366 /* FireDTV S/CI and FloppyDTV S2 */
367 .match_flags = MATCH_FLAGS,
368 .vendor_id = DIGITAL_EVERYWHERE_OUI,
369 .model_id = 0x000034,
370 .specifier_id = AVC_UNIT_SPEC_ID_ENTRY,
371 .version = AVC_SW_VERSION_ENTRY,
372 }, {
373 /* FireDTV T/CI */
374 .match_flags = MATCH_FLAGS,
375 .vendor_id = DIGITAL_EVERYWHERE_OUI,
376 .model_id = 0x000035,
377 .specifier_id = AVC_UNIT_SPEC_ID_ENTRY,
378 .version = AVC_SW_VERSION_ENTRY,
379 }, {
380 /* FireDTV C/CI */
381 .match_flags = MATCH_FLAGS,
382 .vendor_id = DIGITAL_EVERYWHERE_OUI,
383 .model_id = 0x000036,
384 .specifier_id = AVC_UNIT_SPEC_ID_ENTRY,
385 .version = AVC_SW_VERSION_ENTRY,
386 }, {}
387};
388MODULE_DEVICE_TABLE(ieee1394, fdtv_id_table);
389
312static struct fw_driver fdtv_driver = { 390static struct fw_driver fdtv_driver = {
313 .driver = { 391 .driver = {
314 .owner = THIS_MODULE, 392 .owner = THIS_MODULE,
@@ -321,7 +399,7 @@ static struct fw_driver fdtv_driver = {
321 .id_table = fdtv_id_table, 399 .id_table = fdtv_id_table,
322}; 400};
323 401
324int __init fdtv_fw_init(void) 402static int __init fdtv_init(void)
325{ 403{
326 int ret; 404 int ret;
327 405
@@ -329,11 +407,24 @@ int __init fdtv_fw_init(void)
329 if (ret < 0) 407 if (ret < 0)
330 return ret; 408 return ret;
331 409
332 return driver_register(&fdtv_driver.driver); 410 ret = driver_register(&fdtv_driver.driver);
411 if (ret < 0)
412 fw_core_remove_address_handler(&fcp_handler);
413
414 return ret;
333} 415}
334 416
335void fdtv_fw_exit(void) 417static void __exit fdtv_exit(void)
336{ 418{
337 driver_unregister(&fdtv_driver.driver); 419 driver_unregister(&fdtv_driver.driver);
338 fw_core_remove_address_handler(&fcp_handler); 420 fw_core_remove_address_handler(&fcp_handler);
339} 421}
422
423module_init(fdtv_init);
424module_exit(fdtv_exit);
425
426MODULE_AUTHOR("Andreas Monitzer <andy@monitzer.com>");
427MODULE_AUTHOR("Ben Backx <ben@bbackx.com>");
428MODULE_DESCRIPTION("FireDTV DVB Driver");
429MODULE_LICENSE("GPL");
430MODULE_SUPPORTED_DEVICE("FireDTV DVB");
diff --git a/drivers/media/dvb/firewire/firedtv-rc.c b/drivers/media/dvb/firewire/firedtv-rc.c
index fcf3828472b8..f82d4a93feb3 100644
--- a/drivers/media/dvb/firewire/firedtv-rc.c
+++ b/drivers/media/dvb/firewire/firedtv-rc.c
@@ -172,7 +172,8 @@ void fdtv_unregister_rc(struct firedtv *fdtv)
172 172
173void fdtv_handle_rc(struct firedtv *fdtv, unsigned int code) 173void fdtv_handle_rc(struct firedtv *fdtv, unsigned int code)
174{ 174{
175 u16 *keycode = fdtv->remote_ctrl_dev->keycode; 175 struct input_dev *idev = fdtv->remote_ctrl_dev;
176 u16 *keycode = idev->keycode;
176 177
177 if (code >= 0x0300 && code <= 0x031f) 178 if (code >= 0x0300 && code <= 0x031f)
178 code = keycode[code - 0x0300]; 179 code = keycode[code - 0x0300];
@@ -188,6 +189,8 @@ void fdtv_handle_rc(struct firedtv *fdtv, unsigned int code)
188 return; 189 return;
189 } 190 }
190 191
191 input_report_key(fdtv->remote_ctrl_dev, code, 1); 192 input_report_key(idev, code, 1);
192 input_report_key(fdtv->remote_ctrl_dev, code, 0); 193 input_sync(idev);
194 input_report_key(idev, code, 0);
195 input_sync(idev);
193} 196}
diff --git a/drivers/media/dvb/firewire/firedtv.h b/drivers/media/dvb/firewire/firedtv.h
index 78cc28f36914..bd00b04e079d 100644
--- a/drivers/media/dvb/firewire/firedtv.h
+++ b/drivers/media/dvb/firewire/firedtv.h
@@ -70,15 +70,7 @@ enum model_type {
70 70
71struct device; 71struct device;
72struct input_dev; 72struct input_dev;
73struct firedtv; 73struct fdtv_ir_context;
74
75struct firedtv_backend {
76 int (*lock)(struct firedtv *fdtv, u64 addr, void *data);
77 int (*read)(struct firedtv *fdtv, u64 addr, void *data);
78 int (*write)(struct firedtv *fdtv, u64 addr, void *data, size_t len);
79 int (*start_iso)(struct firedtv *fdtv);
80 void (*stop_iso)(struct firedtv *fdtv);
81};
82 74
83struct firedtv { 75struct firedtv {
84 struct device *device; 76 struct device *device;
@@ -104,12 +96,11 @@ struct firedtv {
104 enum model_type type; 96 enum model_type type;
105 char subunit; 97 char subunit;
106 char isochannel; 98 char isochannel;
99 struct fdtv_ir_context *ir_context;
100
107 fe_sec_voltage_t voltage; 101 fe_sec_voltage_t voltage;
108 fe_sec_tone_mode_t tone; 102 fe_sec_tone_mode_t tone;
109 103
110 const struct firedtv_backend *backend;
111 void *backend_data;
112
113 struct mutex demux_mutex; 104 struct mutex demux_mutex;
114 unsigned long channel_active; 105 unsigned long channel_active;
115 u16 channel_pid[16]; 106 u16 channel_pid[16];
@@ -118,15 +109,6 @@ struct firedtv {
118 u8 avc_data[512]; 109 u8 avc_data[512];
119}; 110};
120 111
121/* firedtv-1394.c */
122#ifdef CONFIG_DVB_FIREDTV_IEEE1394
123int fdtv_1394_init(void);
124void fdtv_1394_exit(void);
125#else
126static inline int fdtv_1394_init(void) { return 0; }
127static inline void fdtv_1394_exit(void) {}
128#endif
129
130/* firedtv-avc.c */ 112/* firedtv-avc.c */
131int avc_recv(struct firedtv *fdtv, void *data, size_t length); 113int avc_recv(struct firedtv *fdtv, void *data, size_t length);
132int avc_tuner_status(struct firedtv *fdtv, struct firedtv_tuner_status *stat); 114int avc_tuner_status(struct firedtv *fdtv, struct firedtv_tuner_status *stat);
@@ -158,25 +140,18 @@ void fdtv_ca_release(struct firedtv *fdtv);
158/* firedtv-dvb.c */ 140/* firedtv-dvb.c */
159int fdtv_start_feed(struct dvb_demux_feed *dvbdmxfeed); 141int fdtv_start_feed(struct dvb_demux_feed *dvbdmxfeed);
160int fdtv_stop_feed(struct dvb_demux_feed *dvbdmxfeed); 142int fdtv_stop_feed(struct dvb_demux_feed *dvbdmxfeed);
161int fdtv_dvb_register(struct firedtv *fdtv); 143int fdtv_dvb_register(struct firedtv *fdtv, const char *name);
162void fdtv_dvb_unregister(struct firedtv *fdtv); 144void fdtv_dvb_unregister(struct firedtv *fdtv);
163struct firedtv *fdtv_alloc(struct device *dev,
164 const struct firedtv_backend *backend,
165 const char *name, size_t name_len);
166extern const char *fdtv_model_names[];
167extern const struct ieee1394_device_id fdtv_id_table[];
168 145
169/* firedtv-fe.c */ 146/* firedtv-fe.c */
170void fdtv_frontend_init(struct firedtv *fdtv); 147void fdtv_frontend_init(struct firedtv *fdtv, const char *name);
171 148
172/* firedtv-fw.c */ 149/* firedtv-fw.c */
173#ifdef CONFIG_DVB_FIREDTV_FIREWIRE 150int fdtv_lock(struct firedtv *fdtv, u64 addr, void *data);
174int fdtv_fw_init(void); 151int fdtv_read(struct firedtv *fdtv, u64 addr, void *data);
175void fdtv_fw_exit(void); 152int fdtv_write(struct firedtv *fdtv, u64 addr, void *data, size_t len);
176#else 153int fdtv_start_iso(struct firedtv *fdtv);
177static inline int fdtv_fw_init(void) { return 0; } 154void fdtv_stop_iso(struct firedtv *fdtv);
178static inline void fdtv_fw_exit(void) {}
179#endif
180 155
181/* firedtv-rc.c */ 156/* firedtv-rc.c */
182#ifdef CONFIG_DVB_FIREDTV_INPUT 157#ifdef CONFIG_DVB_FIREDTV_INPUT