[MPlayer-matrox] PATCH udev support for mga_vid 2.6.12 + api change

Colin Harrison colin.harrison at virgin.net
Tue Jun 28 10:08:00 CEST 2005


Hi,

udev support for mga_vid on kernels 2.6.12-git(x) etc.

After kernel 2.6.12 (with later git patches) the api is removed for
"class_simple" to unify all on "class".
I've reworked Gergely Tamas's patch to suit, and tried and tested against
Attila Kinali's version "mga_vid-2.6.12-2005-06-18".

--- >>> --- >>> --- >>> ---
--- old_mga_vid.c       2005-06-28 08:37:30.000000000 +0100
+++ mga_vid.c   2005-06-28 08:37:39.000000000 +0100
@@ -57,6 +57,8 @@
 #include <linux/string.h>
 #include <linux/errno.h>

+#include <linux/device.h>
+
 #include <linux/pci.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
@@ -254,6 +256,9 @@
 #define ICLEAR     0x1e18
 #define STATUS      0x1e14

+struct class *mga_vid_class;
+int mga_vid_major;
+
 /* Global handles for cdev */
 static struct cdev *mga_vid_cdev;
 static dev_t mga_cdev_handle;
@@ -1129,8 +1134,14 @@
                else
                {
                        mga_cdev_handle = MKDEV(major,0);
-                       if(!register_chrdev_region(mga_cdev_handle,
mga_cards_num, "mga_vid"))
+                       if(!register_chrdev_region(mga_cdev_handle,
mga_cards_num, "mga_vid")) {
+                               mga_vid_major = major;
+
+                               mga_vid_class = class_create(THIS_MODULE,
"mga_vid");
+                               class_device_create(mga_vid_class, MKDEV
(mga_vid_major, 0), NULL, "mga_vid");
+
                                printk(KERN_INFO "mga_vid: using major: %d
(assigned or default!)\n", major);
+                       }
                }
                /* Allocate a cdev for this character device, and fill in
some parameters it needs */
                mga_vid_cdev = cdev_alloc();
@@ -1179,6 +1190,9 @@
                }
        }

+       class_device_destroy(mga_vid_class, MKDEV(mga_vid_major, 0));
+       class_destroy(mga_vid_class);
+
        //FIXME turn off BES
        cdev_del(mga_vid_cdev);
        unregister_chrdev_region(mga_cdev_handle, mga_cards_num);
--- <<< --- <<< --- <<< ---

And access permissions can be set at before ie.:

$ cat /etc/udev/rules.d/mga_vid.rules
KERNEL="mga_vid", NAME="%k", MODE="0660", GROUP="video"

Thanks
Colin Harrison







More information about the MPlayer-matrox mailing list