diff options
-rw-r--r-- | linux/Documentation/dvb/readme.txt | 3 | ||||
-rw-r--r-- | linux/Documentation/dvb/udev.txt | 44 | ||||
-rw-r--r-- | linux/drivers/media/dvb/dvb-core/dvbdev.c | 24 |
3 files changed, 66 insertions, 5 deletions
diff --git a/linux/Documentation/dvb/readme.txt b/linux/Documentation/dvb/readme.txt index e38016cf8..727e30470 100644 --- a/linux/Documentation/dvb/readme.txt +++ b/linux/Documentation/dvb/readme.txt @@ -45,4 +45,7 @@ various bt8xx based "budget" DVB cards contains detailed informations about the Visionplus VisionDTV USB-Ter DVB-T adapter. +"udev.txt" +how to get DVB and udev up and running. + Good luck and have fun! diff --git a/linux/Documentation/dvb/udev.txt b/linux/Documentation/dvb/udev.txt new file mode 100644 index 000000000..8ef0616ed --- /dev/null +++ b/linux/Documentation/dvb/udev.txt @@ -0,0 +1,44 @@ +The DVB subsystem currently registers to the sysfs subsystem using the +"class_simple" interface. + +This means that only the basic informations like module loading parameters +are presented through sysfs. Other things that might be interesting are +currently *not* available. + +Nevertheless it's now possible to add proper udev rules so that the +DVB device nodes are created automatically. + +We assume that you have udev already up and running and that have been +creating the DVB device nodes manually up to now due to the missing sysfs +support. + +0. Don't forget to disable your current method of creating the +device nodes manually. + +1. Unfortunately, you'll need a helper script to transform the kernel +sysfs device name into the well known dvb adapter / device naming scheme. +The script should be called "dvb.sh" and should be placed into a script +dir where udev can execute it, most likely /etc/udev/scripts/ + +So, create a new file /etc/udev/scripts/dvb.sh and add the following: +------------------------------schnipp------------------------------------------------ +#!/bin/sh +/bin/echo $1 | /bin/sed -e 's,dvb\([0-9]\)\.\([^0-9]*\)\([0-9]\),dvb/adapter\1/\2\3,' +------------------------------schnipp------------------------------------------------ + +Don't forget to make the script executable with "chmod". + +1. You need to add a proper rule to your udev rule file. The main +udev configuration file /etc/udev/udev.conf will tell you the +directory of the rules, most likely it's /etc/udev/rules.d/ + +Edit the main rule file and add the following rule to the end +of the file. + +KERNEL="dvb*", PROGRAM="/etc/udev/scripts/dvb.sh %k", NAME="%c" + +For every device that registers to the sysfs subsystem with a "dvb" prefix, +the helper script /etc/udev/scripts/dvb.sh is invoked, which will then +create the proper device name. + +Now udev will create the device node in your /dev/ device tree. diff --git a/linux/drivers/media/dvb/dvb-core/dvbdev.c b/linux/drivers/media/dvb/dvb-core/dvbdev.c index a41bd09f5..241cd24b4 100644 --- a/linux/drivers/media/dvb/dvb-core/dvbdev.c +++ b/linux/drivers/media/dvb/dvb-core/dvbdev.c @@ -29,6 +29,7 @@ #include <linux/sched.h> #include <linux/init.h> #include <linux/slab.h> +#include <linux/device.h> #include "dvbdev.h" #include "dvb_functions.h" @@ -43,16 +44,17 @@ MODULE_PARM_DESC(dvbdev_debug, "Turn on/off device debugging (default:off)."); static LIST_HEAD(dvb_adapter_list); static DECLARE_MUTEX(dvbdev_register_lock); - -static char *dnames[] = { +static const char * const dnames[] = { "video", "audio", "sec", "frontend", "demux", "dvr", "ca", "net", "osd" }; - #define DVB_MAX_IDS 4 #define nums2minor(num,type,id) ((num << 6) | (id << 4) | type) +struct class_simple *dvb_class; +EXPORT_SYMBOL(dvb_class); + static struct dvb_device* dvbdev_find_device (int minor) { struct list_head *entry; @@ -222,6 +224,9 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev, S_IFCHR | S_IRUSR | S_IWUSR, "dvb/adapter%d/%s%d", adap->num, dnames[type], id); + class_simple_device_add(dvb_class, MKDEV(DVB_MAJOR, nums2minor(adap->num, type, id)), + NULL, "dvb%d.%s%d", adap->num, dnames[type], id); + dprintk("DVB: register adapter%d/%s%d @ minor: %i (0x%02x)\n", adap->num, dnames[type], id, nums2minor(adap->num, type, id), nums2minor(adap->num, type, id)); @@ -238,6 +243,9 @@ void dvb_unregister_device(struct dvb_device *dvbdev) devfs_remove("dvb/adapter%d/%s%d", dvbdev->adapter->num, dnames[dvbdev->type], dvbdev->id); + class_simple_device_remove(MKDEV(DVB_MAJOR, nums2minor(dvbdev->adapter->num, + dvbdev->type, dvbdev->id))); + list_del (&dvbdev->list_head); kfree (dvbdev); } @@ -316,10 +324,15 @@ int dvb_unregister_adapter(struct dvb_adapter *adap) static int __init init_dvbdev(void) { int retval; - devfs_mk_dir("dvb"); if ((retval = register_chrdev(DVB_MAJOR,"DVB", &dvb_device_fops))) - printk("video_dev: unable to get major %d\n", DVB_MAJOR); + printk("dvb-core: unable to get major %d\n", DVB_MAJOR); + + devfs_mk_dir("dvb"); + + dvb_class = class_simple_create(THIS_MODULE, "dvb"); + if (IS_ERR(dvb_class)) + return PTR_ERR(dvb_class); return retval; } @@ -329,6 +342,7 @@ static void __exit exit_dvbdev(void) { unregister_chrdev(DVB_MAJOR, "DVB"); devfs_remove("dvb"); + class_simple_destroy(dvb_class); } module_init(init_dvbdev); |