Skip to contentSkip to conversation

add firedtv driver for FireWire-attached DVB receivers

PATCH In review Stefan Richter 2 participants 6 messages Feb 16, 2009 – Feb 20, 2009 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

cover add firedtv driver for FireWire-attached DVB receivers

The patch in the follow-up mail contains the firedtv driver for FireWire-attached DVB boxes from Digital Everywhere GmbH. The driver supports standard definition video reception (MPEG2-TS) of the DVB-C, DVB-S/S2, and DVB-T boxes known as FireDTV (external devices) and FloppyDTV (internal devices), their Common Interface for Conditional Access Modules, and input from their infrared remote control.

High definition support is not yet implemented but people have voiced interest to add it.

The driver is currently based on the ieee1394 driver stack but I started to adapt it to the new firewire driver stack.

The driver was originally written by Andreas Monitzer and hosted in linuxtv.org's v4l_experimental repository. From there it went through Greg KH's staging tree way before staging was added to mainline; from there I picked it up for kernel.org's linux1394-2.6.git through which it also was already exposed to linux-next for quite a while.

Manu Abraham, Ben Backx, and Henrik Kurelid updated and extended the driver; I did lots of trivial cleanups and some refactoring and small fixes.

The history of the driver sources beginning with its addition to staging can be looked at in linux1394-2.6.git; find the shortlog below.

The patch is available for 2.6.29-rc* in linux1394-2.6.git's firedtv branch:

    git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6.git firedtv

linux1394-2.6.git currently also contains backport branches:

    git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6.git firedtv-2.6.28
    git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6.git firedtv-2.6.27
    git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6.git firedtv-2.6.26
    git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6.git firedtv-2.6.25

Furthermore, firedtv is currently also available as patch tarballs and as quilt series at

    http://user.in-berlin.de/~s5r6/linux1394/firedtv/2.6.29-rc5/
    http://user.in-berlin.de/~s5r6/linux1394/firedtv/2.6.28/
    http://user.in-berlin.de/~s5r6/linux1394/firedtv/2.6.27/
    http://user.in-berlin.de/~s5r6/linux1394/firedtv/2.6.26/
    http://user.in-berlin.de/~s5r6/linux1394/firedtv/2.6.25/

The history as in linux1394-2.6.git is fully "bisectable" i.e. does not contain any known build bugs and a few minor known runtime bugs.

Addition of the interface with firewire-core will happen in linux1394-2.6.git, but I expect longer-term maintenance of the driver to be done via the DVB maintainers like with all other DVB drivers.

Comments on the patch in the following mail are very welcome. I target the pre 2.6.30-rc1 window for mainline merge request of the driver, but if feedback in this review round is positive I would even ask if the driver can already be included before 2.6.29.

Size of the patch is ~80 kB, I hope it fits through the mailing lists.

Shortlog and diffstat:

Ben Backx (2):
firesat: fix DVB-S2 device recognition
firesat: add DVB-S support for DVB-S2 devices

Greg Kroah-Hartman (1):
DVB: add firesat driver

Henrik Kurelid (5):
firesat: update isochronous interface, add CI support
firesat: avc resend
firedtv: fix returned struct for ca_info
firedtv: use length_field() of PMT as length
firedtv: fix registration - adapter number could only be zero

Julia Lawall (1):
firedtv: Use DEFINE_SPINLOCK

Rambaldi (2):
firedtv: rename files from firesat to firedtv
firedtv: rename variables and functions from firesat to firedtv

Stefan Richter (54):
firesat: add missing copyright notes
firesat: rename to firedtv
firedtv: nicer registration message and some initialization fixes
firedtv: some header cleanups
firedtv: replace semaphore by mutex
firedtv: move some code back to ieee1394 core
firedtv: replace tasklet by workqueue job
firedtv: fix remote control input
ieee1394: use correct barrier types between accesses of nodeid and generation
ieee1394: add hpsb_node_read() and hpsb_node_lock()
ieee1394: inherit ud vendor_id from node vendor_id
firedtv: use hpsb_node_read(), _write(), _lock()
firedtv: add vendor_id and version to driver match table
firedtv: remove unused dual subunit code from initialization
firedtv: fix initialization of dvb_frontend.ops
firedtv: remove unused struct members
firedtv: fix string comparison and a few sparse warnings
firedtv: register input device as child of a FireWire device
firedtv: remove various debug code
firedtv: remove AV/C debug code
firedtv: remove CA debug code
firedtv: trivial cleanups in firesat-ci
firedtv: trivial cleanups in cmp
firedtv: remove bitfield typedefs from cmp, fix for big endian CPUs
firedtv: don't retry oPCR updates endlessly
firedtv: trivial cleanups in avc_api
firedtv: trivial reorganization in avc_api
firedtv: replace mdelay by msleep
firedtv: increase FCP frame length for DVB-S2 tune QSPK
firedtv: iso: style changes and fixlets
firedtv: iso: remove unnecessary struct type definitions
firedtv: iso: move code to firedtv-1394
firedtv: cmp: move code to avc
firedtv: avc: reduce stack usage, remove two typedefs
firedtv: avc: fix offset in avc_tuner_get_ts
firedtv: avc: remove bitfields from FCP frame types
firedtv: avc: header file cleanup
firedtv: avc: remove bitfields from DSD command operands
firedtv: avc: remove bitfields from read descriptor response operands
firedtv: avc, ci: remove unused constants
firedtv: misc style touch-ups
firedtv: combine header files
firedtv: remove kernel version compatibility macro
firedtv: amend Kconfig menu prompt
firedtv: concentrate ieee1394 dependencies
firedtv: replace EXTRA_CFLAGS by ccflags
firedtv: allow build without input subsystem
firedtv: dvb demux: fix missing braces
firedtv: dvb demux: fix mutex protection
firedtv: dvb demux: remove a bogus loop
firedtv: dvb demux: some simplifications
firedtv: dvb demux: more compact channels backing store
firedtv: rename a file once more
firedtv: some more housekeeping

 drivers/ieee1394/dma.h                    |    1 +
 drivers/ieee1394/ieee1394_core.c          |    1 +
 drivers/ieee1394/ieee1394_transactions.c  |   29 +
 drivers/ieee1394/ieee1394_transactions.h  |    2 +
 drivers/ieee1394/iso.h                    |    1 +
 drivers/ieee1394/nodemgr.c                |   10 +-
 drivers/ieee1394/nodemgr.h                |   18 +
 drivers/media/dvb/Kconfig                 |    4 +
 drivers/media/dvb/Makefile                |    2 +
 drivers/media/dvb/firewire/Kconfig        |   22 +
 drivers/media/dvb/firewire/Makefile       |    8 +
 drivers/media/dvb/firewire/firedtv-1394.c |  285 +++++++
 drivers/media/dvb/firewire/firedtv-avc.c  | 1235 +++++++++++++++++++++++++++++
 drivers/media/dvb/firewire/firedtv-ci.c   |  260 ++++++
 drivers/media/dvb/firewire/firedtv-dvb.c  |  364 +++++++++
 drivers/media/dvb/firewire/firedtv-fe.c   |  246 ++++++
 drivers/media/dvb/firewire/firedtv-rc.c   |  190 +++++
 drivers/media/dvb/firewire/firedtv.h      |  182 +++++
 18 files changed, 2857 insertions(+), 3 deletions(-)
 create mode 100644 drivers/media/dvb/firewire/Kconfig
 create mode 100644 drivers/media/dvb/firewire/Makefile
 create mode 100644 drivers/media/dvb/firewire/firedtv-1394.c
 create mode 100644 drivers/media/dvb/firewire/firedtv-avc.c
 create mode 100644 drivers/media/dvb/firewire/firedtv-ci.c
 create mode 100644 drivers/media/dvb/firewire/firedtv-dvb.c
 create mode 100644 drivers/media/dvb/firewire/firedtv-fe.c
 create mode 100644 drivers/media/dvb/firewire/firedtv-rc.c
 create mode 100644 drivers/media/dvb/firewire/firedtv.h
Signature · 3 lines
Stefan Richter
-=====-==--= --=- =----
http://arcgraph.de/sr/
#1 lore raw

firedtv is a driver for FireWire-attached DVB receivers from Digital Everywhere GmbH. The devices are known as FireDTV (external boxes) and FloppyDTV (internal cards, also connected through FireWire). The driver supports
- the DVB-C, DVB-S/S2, and DVB-T range of FireDTV and FloppyDTV models,
- control and reception through Linux' common DVB userspace ABI,
- standard definition video reception (MPEG2-TS, to be decoded by userspace client software),
- Common Interface for Conditional Access Modules,
- input from infrared remote control.

High definition support has yet to be added. Also, firedtv still requires the ieee1394 kernel API but alternative support of the new firewire kernel API is in progress.

The driver, formerly known as firesat, was originally written by Andreas Monitzer. Manu Abraham, Ben Backx, and Henrik Kurelid updated and extended the driver; I did trivial cleanups, refactoring and small fixes.

---
The patch, including its entire history since it was picked up for Greg KH's staging tree, is also available at

    git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6.git firedtv

and also at alternative places as mentioned in the parent posting.

 drivers/ieee1394/dma.h                    |    1 +
 drivers/ieee1394/ieee1394_core.c          |    1 +
 drivers/ieee1394/ieee1394_transactions.c  |   29 +
 drivers/ieee1394/ieee1394_transactions.h  |    2 +
 drivers/ieee1394/iso.h                    |    1 +
 drivers/ieee1394/nodemgr.c                |   10 +-
 drivers/ieee1394/nodemgr.h                |   18 +
 drivers/media/dvb/Kconfig                 |    4 +
 drivers/media/dvb/Makefile                |    2 +
 drivers/media/dvb/firewire/Kconfig        |   22 +
 drivers/media/dvb/firewire/Makefile       |    8 +
 drivers/media/dvb/firewire/firedtv-1394.c |  285 +++++++
 drivers/media/dvb/firewire/firedtv-avc.c  | 1235 +++++++++++++++++++++++++++++
 drivers/media/dvb/firewire/firedtv-ci.c   |  260 ++++++
 drivers/media/dvb/firewire/firedtv-dvb.c  |  364 +++++++++
 drivers/media/dvb/firewire/firedtv-fe.c   |  246 ++++++
 drivers/media/dvb/firewire/firedtv-rc.c   |  190 +++++
 drivers/media/dvb/firewire/firedtv.h      |  182 +++++
 18 files changed, 2857 insertions(+), 3 deletions(-)
 create mode 100644 drivers/media/dvb/firewire/Kconfig
 create mode 100644 drivers/media/dvb/firewire/Makefile
 create mode 100644 drivers/media/dvb/firewire/firedtv-1394.c
 create mode 100644 drivers/media/dvb/firewire/firedtv-avc.c
 create mode 100644 drivers/media/dvb/firewire/firedtv-ci.c
 create mode 100644 drivers/media/dvb/firewire/firedtv-dvb.c
 create mode 100644 drivers/media/dvb/firewire/firedtv-fe.c
 create mode 100644 drivers/media/dvb/firewire/firedtv-rc.c
 create mode 100644 drivers/media/dvb/firewire/firedtv.h
drivers/ieee1394/dma.h +1 -0
index 2727bcd..467373c 100644
@@ -12,6 +12,7 @@
 
 #include <asm/types.h>
 
+struct file;
 struct pci_dev;
 struct scatterlist;
 struct vm_area_struct;
drivers/ieee1394/ieee1394_core.c +1 -0
index dcdb71a..9ee0a97 100644
@@ -1314,6 +1314,7 @@ EXPORT_SYMBOL(hpsb_make_lock64packet);
 EXPORT_SYMBOL(hpsb_make_phypacket);
 EXPORT_SYMBOL(hpsb_read);
 EXPORT_SYMBOL(hpsb_write);
+EXPORT_SYMBOL(hpsb_lock);
 EXPORT_SYMBOL(hpsb_packet_success);
 
 /** highlevel.c **/
drivers/ieee1394/ieee1394_transactions.c +29 -0
index 10c3d9f..24021d2 100644
@@ -570,3 +570,32 @@ int hpsb_write(struct hpsb_host *host, nodeid_t node, unsigned int generation,
 
 	return retval;
 }
+
+int hpsb_lock(struct hpsb_host *host, nodeid_t node, unsigned int generation,
+	      u64 addr, int extcode, quadlet_t *data, quadlet_t arg)
+{
+	struct hpsb_packet *packet;
+	int retval = 0;
+
+	BUG_ON(in_interrupt());
+
+	packet = hpsb_make_lockpacket(host, node, addr, extcode, data, arg);
+	if (!packet)
+		return -ENOMEM;
+
+	packet->generation = generation;
+	retval = hpsb_send_packet_and_wait(packet);
+	if (retval < 0)
+		goto hpsb_lock_fail;
+
+	retval = hpsb_packet_success(packet);
+
+	if (retval == 0)
+		*data = packet->data[0];
+
+hpsb_lock_fail:
+	hpsb_free_tlabel(packet);
+	hpsb_free_packet(packet);
+
+	return retval;
+}
drivers/ieee1394/ieee1394_transactions.h +2 -0
index d2d5bc3..20b693b 100644
@@ -30,6 +30,8 @@ int hpsb_read(struct hpsb_host *host, nodeid_t node, unsigned int generation,
 	      u64 addr, quadlet_t *buffer, size_t length);
 int hpsb_write(struct hpsb_host *host, nodeid_t node, unsigned int generation,
 	       u64 addr, quadlet_t *buffer, size_t length);
+int hpsb_lock(struct hpsb_host *host, nodeid_t node, unsigned int generation,
+	      u64 addr, int extcode, quadlet_t *data, quadlet_t arg);
 
 #ifdef HPSB_DEBUG_TLABELS
 extern spinlock_t hpsb_tlabel_lock;
drivers/ieee1394/iso.h +1 -0
index b5de5f2..c2089c0 100644
@@ -13,6 +13,7 @@
 #define IEEE1394_ISO_H
 
 #include <linux/spinlock_types.h>
+#include <linux/wait.h>
 #include <asm/atomic.h>
 #include <asm/types.h>
 
drivers/ieee1394/nodemgr.c +7 -3
index 906c5a9..53aada5 100644
@@ -971,6 +971,9 @@ static struct unit_directory *nodemgr_process_unit_directory
 	ud->ud_kv = ud_kv;
 	ud->id = (*id)++;
 
+	/* inherit vendor_id from root directory if none exists in unit dir */
+	ud->vendor_id = ne->vendor_id;
+
 	csr1212_for_each_dir_entry(ne->csr, kv, ud_kv, dentry) {
 		switch (kv->key.id) {
 		case CSR1212_KV_ID_VENDOR:
@@ -1265,7 +1268,8 @@ static void nodemgr_update_node(struct node_entry *ne, struct csr1212_csr *csr,
 		csr1212_destroy_csr(csr);
 	}
 
-	/* Mark the node current */
+	/* Finally, mark the node current */
+	smp_wmb();
 	ne->generation = generation;
 
 	if (ne->in_limbo) {
@@ -1798,7 +1802,7 @@ void hpsb_node_fill_packet(struct node_entry *ne, struct hpsb_packet *packet)
 {
 	packet->host = ne->host;
 	packet->generation = ne->generation;
-	barrier();
+	smp_rmb();
 	packet->node_id = ne->nodeid;
 }
 
@@ -1807,7 +1811,7 @@ int hpsb_node_write(struct node_entry *ne, u64 addr,
 {
 	unsigned int generation = ne->generation;
 
-	barrier();
+	smp_rmb();
 	return hpsb_write(ne->host, ne->nodeid, generation,
 			  addr, buffer, length);
 }
drivers/ieee1394/nodemgr.h +18 -0
index 15ea097..ee5acdb 100644
@@ -21,9 +21,11 @@
 #define _IEEE1394_NODEMGR_H
 
 #include <linux/device.h>
+#include <asm/system.h>
 #include <asm/types.h>
 
 #include "ieee1394_core.h"
+#include "ieee1394_transactions.h"
 #include "ieee1394_types.h"
 
 struct csr1212_csr;
@@ -154,6 +156,22 @@ static inline int hpsb_node_entry_valid(struct node_entry *ne)
 void hpsb_node_fill_packet(struct node_entry *ne, struct hpsb_packet *packet);
 int hpsb_node_write(struct node_entry *ne, u64 addr,
 		    quadlet_t *buffer, size_t length);
+static inline int hpsb_node_read(struct node_entry *ne, u64 addr,
+				 quadlet_t *buffer, size_t length)
+{
+	unsigned int g = ne->generation;
+
+	smp_rmb();
+	return hpsb_read(ne->host, ne->nodeid, g, addr, buffer, length);
+}
+static inline int hpsb_node_lock(struct node_entry *ne, u64 addr, int extcode,
+				 quadlet_t *buffer, quadlet_t arg)
+{
+	unsigned int g = ne->generation;
+
+	smp_rmb();
+	return hpsb_lock(ne->host, ne->nodeid, g, addr, extcode, buffer, arg);
+}
 int nodemgr_for_each_host(void *data, int (*cb)(struct hpsb_host *, void *));
 
 int init_ieee1394_nodemgr(void);
drivers/media/dvb/Kconfig +4 -0
index 40ebde5..b019869 100644
@@ -51,6 +51,10 @@ comment "Supported SDMC DM1105 Adapters"
 	depends on DVB_CORE && PCI && I2C
 source "drivers/media/dvb/dm1105/Kconfig"
 
+comment "Supported FireWire (IEEE 1394) Adapters"
+	depends on DVB_CORE && IEEE1394
+source "drivers/media/dvb/firewire/Kconfig"
+
 comment "Supported DVB Frontends"
 	depends on DVB_CORE
 source "drivers/media/dvb/frontends/Kconfig"
drivers/media/dvb/Makefile +2 -0
index f91e9eb..6092a5b 100644
@@ -3,3 +3,5 @@
 #
 
 obj-y        := dvb-core/ frontends/ ttpci/ ttusb-dec/ ttusb-budget/ b2c2/ bt8xx/ dvb-usb/ pluto2/ siano/ dm1105/
+
+obj-$(CONFIG_DVB_FIREDTV)	+= firewire/
drivers/media/dvb/firewire/Kconfig new file +22 -0
new file mode 100644
index 0000000..b0ab40f
@@ -0,0 +1,22 @@
+config DVB_FIREDTV
+	tristate "FireDTV and FloppyDTV"
+	depends on DVB_CORE && IEEE1394
+	help
+	  Support for DVB receivers from Digital Everywhere
+	  which are connected via IEEE 1394 (FireWire).
+
+	  These devices don't have an MPEG decoder built in,
+	  so you need an external software decoder to watch TV.
+
+	  To compile this driver as a module, say M here:
+	  the module will be called firedtv.
+
+if DVB_FIREDTV
+
+config DVB_FIREDTV_IEEE1394
+	def_bool IEEE1394
+
+config DVB_FIREDTV_INPUT
+	def_bool INPUT
+
+endif # DVB_FIREDTV
drivers/media/dvb/firewire/Makefile new file +8 -0
new file mode 100644
index 0000000..2034695
@@ -0,0 +1,8 @@
+obj-$(CONFIG_DVB_FIREDTV) += firedtv.o
+
+firedtv-y := firedtv-avc.o firedtv-ci.o firedtv-dvb.o firedtv-fe.o
+firedtv-$(CONFIG_DVB_FIREDTV_IEEE1394) += firedtv-1394.o
+firedtv-$(CONFIG_DVB_FIREDTV_INPUT)    += firedtv-rc.o
+
+ccflags-y += -Idrivers/media/dvb/dvb-core
+ccflags-$(CONFIG_DVB_FIREDTV_IEEE1394) += -Idrivers/ieee1394
drivers/media/dvb/firewire/firedtv-1394.c new file +285 -0

285 lines not on this page · raw message

drivers/media/dvb/firewire/firedtv-avc.c new file +1235 -0

1,235 lines not on this page · raw message

drivers/media/dvb/firewire/firedtv-ci.c new file +260 -0

260 lines not on this page · raw message

drivers/media/dvb/firewire/firedtv-dvb.c new file +364 -0

364 lines not on this page · raw message

drivers/media/dvb/firewire/firedtv-fe.c new file +246 -0

246 lines not on this page · raw message

drivers/media/dvb/firewire/firedtv-rc.c new file +190 -0

190 lines not on this page · raw message

drivers/media/dvb/firewire/firedtv.h new file +182 -0

182 lines not on this page · raw message

Signature · 3 lines
Stefan Richter
-=====-==--= --=- =----
http://arcgraph.de/sr/
#2 lore raw

The subject of <[email protected]> was meant to become [review patch 1/1]...

Signature · 3 lines
Stefan Richter
-=====-==--= --=- =----
http://arcgraph.de/sr/
#3 lore raw
In reply to Stefan Richter
Quoted 16 lines · On Mon, 16 Feb 2009 20:33:17 +0100 (CET) Stefan Richter…

firedtv is a driver for FireWire-attached DVB receivers from Digital Everywhere GmbH. The devices are known as FireDTV (external boxes) and FloppyDTV (internal cards, also connected through FireWire). The driver supports
- the DVB-C, DVB-S/S2, and DVB-T range of FireDTV and FloppyDTV models,
- control and reception through Linux' common DVB userspace ABI,
- standard definition video reception (MPEG2-TS, to be decoded by userspace client software),
- Common Interface for Conditional Access Modules,
- input from infrared remote control.

High definition support has yet to be added. Also, firedtv still requires the ieee1394 kernel API but alternative support of the new firewire kernel API is in progress.

Quoted 6 lines

The driver, formerly known as firesat, was originally written by Andreas Monitzer. Manu Abraham, Ben Backx, and Henrik Kurelid updated and extended the driver; I did trivial cleanups, refactoring and small fixes.

The driver looks sane to my eyes. I found just one minor issue (see bellow).

drivers/media/dvb/firewire/firedtv-avc.c line 116

Quoted 8 lines
drivers/media/dvb/firewire/firedtv-avc.c new file +8 -0
+
+		/*
+		 * AV/C specs say that answers should be sent within 150 ms.
+		 * Time out after 200 ms.
+		 */
+		if (wait_event_timeout(fdtv->avc_wait,
+				       fdtv->avc_reply_received,
+				       HZ / 5) != 0) {

Instead of using HZ, it would be better to use:

	msecs_to_jiffies(200)

Cheers,
Mauro

#4 lore raw
Quoted 2 lines · Mauro Carvalho Chehab

The driver looks sane to my eyes. I found just one minor issue (see bellow).

Thanks for checking.

Quoted 11 lines

drivers/media/dvb/firewire/firedtv-avc.c line 116

Quoted 8 lines
drivers/media/dvb/firewire/firedtv-avc.c new file +8 -0
+
+		/*
+		 * AV/C specs say that answers should be sent within 150 ms.
+		 * Time out after 200 ms.
+		 */
+		if (wait_event_timeout(fdtv->avc_wait,
+				       fdtv->avc_reply_received,
+				       HZ / 5) != 0) {

Instead of using HZ, it would be better to use:

	msecs_to_jiffies(200)

OK, I switch this.

(Hmm, what if msecs_to_jiffies could be rolled out to a constant expression if called on a constant argument...?)

Signature · 3 lines
Stefan Richter
-=====-==--= --=- =--==
http://arcgraph.de/sr/
#5 lore raw

PATCH 1/1 firedtv: build fix for INPUT=m and DVB_FIREDTV=y

In reply to Stefan Richter
---
 drivers/media/dvb/firewire/Kconfig |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/dvb/firewire/Kconfig +1 -1
Index: linux/drivers/media/dvb/firewire/Kconfig
===================================================================
@@ -17,6 +17,6 @@ config DVB_FIREDTV_IEEE1394
 	def_bool IEEE1394
 
 config DVB_FIREDTV_INPUT
-	def_bool INPUT
+	def_bool INPUT = y || (INPUT = m && DVB_FIREDTV = m)
 
 endif # DVB_FIREDTV
Signature · 3 lines
Stefan Richter
-=====-==--= --=- =-=--
http://arcgraph.de/sr/