[linux-dvb] [PATCH] add device node locking possibility to dvb core

Markus Rechberger markus.rechberger at amd.com
Thu Aug 9 16:27:42 CEST 2007


Following patch adds a rather primitive way to temporary lock dvb 
devicenodes, this can be useful for hybrid devices which use the 
video4linux framework for the analogue TV part and the dvb framework for 
digital TV if only one mode can be accessed at a time.

Signed-off-by: Markus Rechberger <markus.rechberger at amd.com>

http://mcentral.de/~mrec/patches/dvb_device_node_locking.diff

(this patch requires [1] which has been posted earlier already to apply 
properly)

[1] http://mcentral.de/~mrec/patches/dvb_net_fixes.diff

diff -r 8cab88ff59a1 linux/drivers/media/dvb/dvb-core/dmxdev.c
--- a/linux/drivers/media/dvb/dvb-core/dmxdev.c Thu Aug 09 16:14:51 2007 
+0200
+++ b/linux/drivers/media/dvb/dvb-core/dmxdev.c Thu Aug 09 16:16:14 2007 
+0200
@@ -127,6 +127,9 @@ static int dvb_dvr_open(struct inode *in
        struct dmxdev *dmxdev = dvbdev->priv;
        struct dmx_frontend *front;
 
+       if (dmxdev->dvb_lock)
+               return -EBUSY;
+
        dprintk("function : %s\n", __FUNCTION__);
 
        if (mutex_lock_interruptible(&dmxdev->mutex))
@@ -665,6 +668,9 @@ static int dvb_demux_open(struct inode *
        int i;
        struct dmxdev_filter *dmxdevfilter;
 
+       if (dmxdev->dvb_lock)
+               return -EBUSY;
+
        if (!dmxdev->filter)
                return -EINVAL;
 
diff -r 8cab88ff59a1 linux/drivers/media/dvb/dvb-core/dmxdev.h
--- a/linux/drivers/media/dvb/dvb-core/dmxdev.h Thu Aug 09 16:14:51 2007 
+0200
+++ b/linux/drivers/media/dvb/dvb-core/dmxdev.h Thu Aug 09 16:16:46 2007 
+0200
@@ -101,6 +101,7 @@ struct dmxdev {
 
        unsigned int exit:1;
 #define DMXDEV_CAP_DUPLEX 1
+       unsigned int dvb_lock:1;
        struct dmx_frontend *dvr_orig_fe;
 
        struct dvb_ringbuffer dvr_buffer;
diff -r 8cab88ff59a1 linux/drivers/media/dvb/dvb-core/dvb_demux.c
--- a/linux/drivers/media/dvb/dvb-core/dvb_demux.c      Thu Aug 09 
16:14:51 2007 +0200
+++ b/linux/drivers/media/dvb/dvb-core/dvb_demux.c      Thu Aug 09 
16:17:14 2007 +0200
@@ -1040,6 +1040,9 @@ static int dvbdmx_open(struct dmx_demux
 {
        struct dvb_demux *dvbdemux = (struct dvb_demux *)demux;
 
+       if (dvbdemux->dvb_lock)
+               return -EBUSY;
+
        if (dvbdemux->users >= MAX_DVB_DEMUX_USERS)
                return -EUSERS;
 
diff -r 8cab88ff59a1 linux/drivers/media/dvb/dvb-core/dvb_demux.h
--- a/linux/drivers/media/dvb/dvb-core/dvb_demux.h      Thu Aug 09 
16:14:51 2007 +0200
+++ b/linux/drivers/media/dvb/dvb-core/dvb_demux.h      Thu Aug 09 
16:17:30 2007 +0200
@@ -128,6 +128,8 @@ struct dvb_demux {
        u8 tsbuf[204];
        int tsbufp;
 
+       unsigned int dvb_lock:1;
+
 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,15)
        struct mutex mutex;
 #else
diff -r 8cab88ff59a1 linux/drivers/media/dvb/dvb-core/dvb_frontend.c
--- a/linux/drivers/media/dvb/dvb-core/dvb_frontend.c   Thu Aug 09 
16:14:51 2007 +0200
+++ b/linux/drivers/media/dvb/dvb-core/dvb_frontend.c   Thu Aug 09 
16:18:06 2007 +0200
@@ -1060,6 +1060,9 @@ static int dvb_frontend_open(struct inod
        struct dvb_frontend_private *fepriv = fe->frontend_priv;
        int ret;
 
+       if (fe->dvb_lock)
+               return -EBUSY;
+
        dprintk ("%s\n", __FUNCTION__);
 
        if ((ret = dvb_generic_open (inode, file)) < 0)
diff -r 8cab88ff59a1 linux/drivers/media/dvb/dvb-core/dvb_frontend.h
--- a/linux/drivers/media/dvb/dvb-core/dvb_frontend.h   Thu Aug 09 
16:14:51 2007 +0200
+++ b/linux/drivers/media/dvb/dvb-core/dvb_frontend.h   Thu Aug 09 
16:18:43 2007 +0200
@@ -155,6 +155,7 @@ struct dvb_frontend {
 struct dvb_frontend {
        struct dvb_frontend_ops ops;
        struct dvb_adapter *dvb;
+       unsigned int dvb_lock:1;
        void* demodulator_priv;
        void* tuner_priv;
        void* frontend_priv;
diff -r 8cab88ff59a1 linux/drivers/media/dvb/dvb-core/dvb_net.c
--- a/linux/drivers/media/dvb/dvb-core/dvb_net.c        Thu Aug 09 
16:14:51 2007 +0200
+++ b/linux/drivers/media/dvb/dvb-core/dvb_net.c        Thu Aug 09 
16:19:24 2007 +0200
@@ -1533,6 +1533,9 @@ static int dvb_net_open_node(struct inod
                return -ENODEV;
 
        dvbnet = dvbdev->priv;
+
+       if (dvbnet->dvb_lock)
+               return -EBUSY;
       
        if (dvbnet->exit)
                return -ENODEV;
diff -r 8cab88ff59a1 linux/drivers/media/dvb/dvb-core/dvb_net.h
--- a/linux/drivers/media/dvb/dvb-core/dvb_net.h        Thu Aug 09 
16:14:51 2007 +0200
+++ b/linux/drivers/media/dvb/dvb-core/dvb_net.h        Thu Aug 09 
16:19:40 2007 +0200
@@ -37,6 +37,7 @@ struct dvb_net {
        struct net_device *device[DVB_NET_DEVICES_MAX];
        int state[DVB_NET_DEVICES_MAX];
        unsigned int exit:1;
+       unsigned int dvb_lock:1;
        struct dmx_demux *demux;
 };
 






More information about the linux-dvb mailing list