Skip to contentSkip to conversation

sysfs sound class patches - [0/2]

PATCH In review Greg KH 4 participants 8 messages Jan 7, 2004 – Jan 9, 2004 Sound

lore
Share & tools
lore

Greg KH

author
#0 lore raw

PATCH 1/1 sysfs sound class patches - [0/2]

Here are 2 sysfs sound class patches against 2.6.1-rc2 (but should apply to 2.6.0) that add sysfs support for OSS and ALSA drivers. This enables udev to see sound devices and create nodes for them.

I've divided it up into 2 patches:
- sound support for OSS drivers
- sound support for ALSA drivers

The ALSA driver patch requires the OSS driver (due to where struct sound_class is declared), and it also modifies the i810 ALSA sound driver to provide a symlink in sysfs to the pci device being controlled by the device node.

I can provide patches to the other ALSA drivers to also add this information, as it's quite useful if you have more than one sound device in your system at once.

These patches require the sysfs simple class patch that is currently in the -mm tree.

Andrew, can you please add these two patches to your -mm tree?

thanks,

greg k-h

-------------------------------------------------------
This SF.net email is sponsored by: Perforce Software. Perforce is the Fast Software Configuration Management System offering advanced branching capabilities and atomic changes on 50+ platforms. Free Eval! http://www.perforce.com/perforce/loadprog.html
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

author
#1 lore raw

PATCH 1/1 sysfs sound class patch for OSS drivers - [1/2]

Adds sysfs sound class support for all OSS drivers

Note, this is based on a previous patch from Leann Ogasawara <[email protected]>, but modified a lot by me.

sound/oss/soundcard.c +12 -1
diff -Nru a/sound/oss/soundcard.c b/sound/oss/soundcard.c
@@ -73,6 +73,7 @@
 
 
 unsigned long seq_time = 0;	/* Time for /dev/sequencer */
+extern struct class sound_class;
 
 /*
  * Table for configurable mixer volume handling
@@ -569,6 +570,9 @@
 		devfs_mk_cdev(MKDEV(SOUND_MAJOR, dev_list[i].minor),
 				S_IFCHR | dev_list[i].mode,
 				"sound/%s", dev_list[i].name);
+		simple_add_class_device(&sound_class, 
+					MKDEV(SOUND_MAJOR, dev_list[i].minor),
+					NULL, "%s", dev_list[i].name);
 
 		if (!dev_list[i].num)
 			continue;
@@ -578,6 +582,10 @@
 						dev_list[i].minor + (j*0x10)),
 					S_IFCHR | dev_list[i].mode,
 					"sound/%s%d", dev_list[i].name, j);
+			simple_add_class_device(&sound_class,
+					MKDEV(SOUND_MAJOR, dev_list[i].minor + (j*0x10)),
+					NULL,
+					"%s%d", dev_list[i].name, j);
 		}
 	}
 
@@ -593,10 +601,13 @@
 
 	for (i = 0; i < sizeof (dev_list) / sizeof *dev_list; i++) {
 		devfs_remove("sound/%s", dev_list[i].name);
+		simple_remove_class_device(MKDEV(SOUND_MAJOR, dev_list[i].minor));
 		if (!dev_list[i].num)
 			continue;
-		for (j = 1; j < *dev_list[i].num; j++)
+		for (j = 1; j < *dev_list[i].num; j++) {
 			devfs_remove("sound/%s%d", dev_list[i].name, j);
+			simple_remove_class_device(MKDEV(SOUND_MAJOR, dev_list[i].minor + (j*0x10)));
+		}
 	}
 	
 	unregister_sound_special(1);
sound/sound_core.c +10 -0
diff -Nru a/sound/sound_core.c b/sound/sound_core.c
@@ -65,6 +65,11 @@
 extern int msnd_pinnacle_init(void);
 #endif
 
+struct class sound_class = {
+	.name = "sound",
+};
+EXPORT_SYMBOL(sound_class);
+
 /*
  *	Low level list operator. Scan the ordered list, find a hole and
  *	join into it. Called with the lock asserted
@@ -171,6 +176,8 @@
 
 	devfs_mk_cdev(MKDEV(SOUND_MAJOR, s->unit_minor),
 			S_IFCHR | mode, s->name);
+	simple_add_class_device(&sound_class, MKDEV(SOUND_MAJOR, s->unit_minor),
+				NULL, s->name+6);
 	return r;
 
  fail:
@@ -193,6 +200,7 @@
 	spin_unlock(&sound_loader_lock);
 	if (p) {
 		devfs_remove(p->name);
+		simple_remove_class_device(MKDEV(SOUND_MAJOR, p->unit_minor));
 		kfree(p);
 	}
 }
@@ -556,6 +564,7 @@
 	   empty */
 	unregister_chrdev(SOUND_MAJOR, "sound");
 	devfs_remove("sound");
+	class_unregister(&sound_class);
 }
 
 static int __init init_soundcore(void)
@@ -565,6 +574,7 @@
 		return -EBUSY;
 	}
 	devfs_mk_dir ("sound");
+	class_register(&sound_class);
 
 	return 0;
 }

-------------------------------------------------------
This SF.net email is sponsored by: Perforce Software. Perforce is the Fast Software Configuration Management System offering advanced branching capabilities and atomic changes on 50+ platforms. Free Eval! http://www.perforce.com/perforce/loadprog.html
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

author
#2 lore raw

PATCH 1/1 sysfs sound class patch for ALSA drivers - [2/2]

Adds sysfs sound class support for all ALSA drivers

Note, this is based on a previous patch from Leann Ogasawara <[email protected]>, but modified a lot by me.

include/sound/core.h +1 -0
diff -Nru a/include/sound/core.h b/include/sound/core.h
@@ -160,6 +160,7 @@
 	int shutdown;			/* this card is going down */
 	wait_queue_head_t shutdown_sleep;
 	struct work_struct free_workq;	/* for free in workqueue */
+	struct device *dev;
 
 #ifdef CONFIG_PM
 	int (*set_power_state) (snd_card_t *card, unsigned int state);
sound/core/sound.c +20 -14
diff -Nru a/sound/core/sound.c b/sound/core/sound.c
@@ -38,9 +38,7 @@
 static int major = CONFIG_SND_MAJOR;
 int snd_major;
 static int cards_limit = SNDRV_CARDS;
-#ifdef CONFIG_DEVFS_FS
 static int device_mode = S_IFCHR | S_IRUGO | S_IWUGO;
-#endif
 
 MODULE_AUTHOR("Jaroslav Kysela <[email protected]>");
 MODULE_DESCRIPTION("Advanced Linux Sound Architecture driver for soundcards.");
@@ -66,6 +64,7 @@
 
 static DECLARE_MUTEX(sound_mutex);
 
+extern struct class sound_class;
 #ifdef CONFIG_KMOD
 
 /**
@@ -203,6 +202,7 @@
 {
 	int minor = snd_kernel_minor(type, card, dev);
 	snd_minor_t *preg;
+	struct device *device = NULL;
 
 	if (minor < 0)
 		return minor;
@@ -221,10 +221,14 @@
 		return -EBUSY;
 	}
 	list_add_tail(&preg->list, &snd_minors_hash[SNDRV_MINOR_CARD(minor)]);
-#ifdef CONFIG_DEVFS_FS
-	if (strncmp(name, "controlC", 8))     /* created in sound.c */
+
+	if (strncmp(name, "controlC", 8)) {	/* created in sound.c */
 		devfs_mk_cdev(MKDEV(major, minor), S_IFCHR | device_mode, "snd/%s", name);
-#endif
+		if (card)
+			device = card->dev;
+		simple_add_class_device(&sound_class, MKDEV(major, minor), device, name);
+	}
+
 	up(&sound_mutex);
 	return 0;
 }
@@ -252,10 +256,12 @@
 		up(&sound_mutex);
 		return -EINVAL;
 	}
-#ifdef CONFIG_DEVFS_FS
-	if (strncmp(mptr->name, "controlC", 8))	/* created in sound.c */
+
+	if (strncmp(mptr->name, "controlC", 8)) {	/* created in sound.c */
 		devfs_remove("snd/%s", mptr->name);
-#endif
+		simple_remove_class_device(MKDEV(major, minor));
+	}
+
 	list_del(&mptr->list);
 	up(&sound_mutex);
 	kfree(mptr);
@@ -322,9 +328,7 @@
 
 static int __init alsa_sound_init(void)
 {
-#ifdef CONFIG_DEVFS_FS
 	short controlnum;
-#endif
 #ifdef CONFIG_SND_OSSEMUL
 	int err;
 #endif
@@ -358,10 +362,10 @@
 #ifdef CONFIG_SND_OSSEMUL
 	snd_info_minor_register();
 #endif
-#ifdef CONFIG_DEVFS_FS
-	for (controlnum = 0; controlnum < cards_limit; controlnum++) 
+	for (controlnum = 0; controlnum < cards_limit; controlnum++) {
 		devfs_mk_cdev(MKDEV(major, controlnum<<5), S_IFCHR | device_mode, "snd/controlC%d", controlnum);
-#endif
+		simple_add_class_device(&sound_class, MKDEV(major, controlnum<<5), NULL, "controlC%d", controlnum);
+	}
 #ifndef MODULE
 	printk(KERN_INFO "Advanced Linux Sound Architecture Driver Version " CONFIG_SND_VERSION CONFIG_SND_DATE ".\n");
 #endif
@@ -372,8 +376,10 @@
 {
 	short controlnum;
 
-	for (controlnum = 0; controlnum < cards_limit; controlnum++)
+	for (controlnum = 0; controlnum < cards_limit; controlnum++) {
 		devfs_remove("snd/controlC%d", controlnum);
+		simple_remove_class_device(MKDEV(major, controlnum<<5));
+	}
 
 #ifdef CONFIG_SND_OSSEMUL
 	snd_info_minor_unregister();
sound/pci/intel8x0.c +1 -0
diff -Nru a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
@@ -2591,6 +2591,7 @@
 			break;
 		}
 	}
+	card->dev = &pci->dev;
 
 	if ((err = snd_intel8x0_create(card, pci, pci_id->driver_data, &chip)) < 0) {
 		snd_card_free(card);

-------------------------------------------------------
This SF.net email is sponsored by: Perforce Software. Perforce is the Fast Software Configuration Management System offering advanced branching capabilities and atomic changes on 50+ platforms. Free Eval! http://www.perforce.com/perforce/loadprog.html
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#3 lore raw

Re: [PATCH] sysfs sound class patch for OSS drivers - [1/2]

In reply to Greg KH
Quoted 1 line · Greg KH

Adds sysfs sound class support for all OSS drivers

what is the best way to get all current patches? wait for the next mm kernel? or do you have a directory with the latest patches somewhere?

Regards, Andreas

-------------------------------------------------------
This SF.net email is sponsored by: Perforce Software. Perforce is the Fast Software Configuration Management System offering advanced branching capabilities and atomic changes on 50+ platforms. Free Eval! http://www.perforce.com/perforce/loadprog.html
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#4 lore raw
In reply to Greg KH

Some people should test of the modules still work with kernel 2.4 Other wise alsa will not merge the patch in there package.

Op do 08-01-2004, om 00:21 schreef Greg KH:

Quoted 36 lines

Here are 2 sysfs sound class patches against 2.6.1-rc2 (but should apply to 2.6.0) that add sysfs support for OSS and ALSA drivers. This enables udev to see sound devices and create nodes for them.

I've divided it up into 2 patches:
- sound support for OSS drivers
- sound support for ALSA drivers

The ALSA driver patch requires the OSS driver (due to where struct sound_class is declared), and it also modifies the i810 ALSA sound driver to provide a symlink in sysfs to the pci device being controlled by the device node.

I can provide patches to the other ALSA drivers to also add this information, as it's quite useful if you have more than one sound device in your system at once.

These patches require the sysfs simple class patch that is currently in the -mm tree.

Andrew, can you please add these two patches to your -mm tree?

thanks,

greg k-h

-------------------------------------------------------
This SF.net email is sponsored by: Perforce Software. Perforce is the Fast Software Configuration Management System offering advanced branching capabilities and atomic changes on 50+ platforms. Free Eval! http://www.perforce.com/perforce/loadprog.html
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

Signature · 13 lines
lupus  (Kristof Vansant Belgium)



-------------------------------------------------------
This SF.net email is sponsored by: Perforce Software.
Perforce is the Fast Software Configuration Management System offering
advanced branching capabilities and atomic changes on 50+ platforms.
Free Eval! http://www.perforce.com/perforce/loadprog.html
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#5 lore raw
In reply to Greg KH

nm what I said got the answer :)

Quoted 8 lines

it can be added. we have a patch system in the alsa-driver tree. the incompatible part can be patched with ifdef conditions automatically, and 2.6 code can be kept clean.

the sysfs patch is pending yet, because it's not urgent yet. it will be included likely after 1.0.0 is released.

Takashi

Op do 08-01-2004, om 13:41 schreef Kristof vansant:

Quoted 40 lines

Some people should test of the modules still work with kernel 2.4 Other wise alsa will not merge the patch in there package.

Op do 08-01-2004, om 00:21 schreef Greg KH:

Quoted 36 lines

Here are 2 sysfs sound class patches against 2.6.1-rc2 (but should apply to 2.6.0) that add sysfs support for OSS and ALSA drivers. This enables udev to see sound devices and create nodes for them.

I've divided it up into 2 patches:
- sound support for OSS drivers
- sound support for ALSA drivers

The ALSA driver patch requires the OSS driver (due to where struct sound_class is declared), and it also modifies the i810 ALSA sound driver to provide a symlink in sysfs to the pci device being controlled by the device node.

I can provide patches to the other ALSA drivers to also add this information, as it's quite useful if you have more than one sound device in your system at once.

These patches require the sysfs simple class patch that is currently in the -mm tree.

Andrew, can you please add these two patches to your -mm tree?

thanks,

greg k-h

-------------------------------------------------------
This SF.net email is sponsored by: Perforce Software. Perforce is the Fast Software Configuration Management System offering advanced branching capabilities and atomic changes on 50+ platforms. Free Eval! http://www.perforce.com/perforce/loadprog.html
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

Signature · 13 lines
lupus  (Kristof Vansant Belgium)



-------------------------------------------------------
This SF.net email is sponsored by: Perforce Software.
Perforce is the Fast Software Configuration Management System offering
advanced branching capabilities and atomic changes on 50+ platforms.
Free Eval! http://www.perforce.com/perforce/loadprog.html
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#6 lore raw
In reply to Greg KH

At Wed, 7 Jan 2004 15:21:37 -0800,

Quoted 11 lines · Greg KH

Here are 2 sysfs sound class patches against 2.6.1-rc2 (but should apply to 2.6.0) that add sysfs support for OSS and ALSA drivers. This enables udev to see sound devices and create nodes for them.

I've divided it up into 2 patches:
- sound support for OSS drivers
- sound support for ALSA drivers

The ALSA driver patch requires the OSS driver (due to where struct sound_class is declared),

oh, sound_core.c is not the OSS driver ;)

Quoted 3 lines

and it also modifies the i810 ALSA sound
driver to provide a symlink in sysfs to the pci device being controlled by the device node.

it looks nice and easy. i'll do that for all pci drivers, too, once when these patches are merged.

Quoted 3 lines

I can provide patches to the other ALSA drivers to also add this information, as it's quite useful if you have more than one sound device in your system at once.

not only pci but also isapnp devices can provide dev pointer. in that case, should the driver gives symlinks of each isapnp devices, too? a module usually holds one isapnp card struct and several isapnp devices below it. but, hmm, it will need far more codes...

--
Takashi Iwai <[email protected]> ALSA Developer - www.alsa-project.org

-------------------------------------------------------
This SF.net email is sponsored by: Perforce Software. Perforce is the Fast Software Configuration Management System offering advanced branching capabilities and atomic changes on 50+ platforms. Free Eval! http://www.perforce.com/perforce/loadprog.html
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

author
#7 lore raw
Quoted 7 lines · Takashi Iwai

At Wed, 7 Jan 2004 15:21:37 -0800,

Quoted 5 lines · Greg KH

Here are 2 sysfs sound class patches against 2.6.1-rc2 (but should apply to 2.6.0) that add sysfs support for OSS and ALSA drivers. This enables udev to see sound devices and create nodes for them.

Quoted 8 lines
Quoted 6 lines

I've divided it up into 2 patches:
- sound support for OSS drivers
- sound support for ALSA drivers

The ALSA driver patch requires the OSS driver (due to where struct sound_class is declared),

oh, sound_core.c is not the OSS driver ;)

Heh, but the changes I made to it are in the OSS specific parts :)

Quoted 6 lines
Quoted 3 lines

and it also modifies the i810 ALSA sound
driver to provide a symlink in sysfs to the pci device being controlled by the device node.

it looks nice and easy. i'll do that for all pci drivers, too, once when these patches are merged.

Thanks.

Quoted 5 lines
Quoted 3 lines

I can provide patches to the other ALSA drivers to also add this information, as it's quite useful if you have more than one sound device in your system at once.

not only pci but also isapnp devices can provide dev pointer.

Exactly. So does USB.

Quoted 2 lines

in that case, should the driver gives symlinks of each isapnp devices, too?

Yes. If the dev pointer is valid, the driver core will create the symlinks.

Quoted 2 lines

a module usually holds one isapnp card struct and several isapnp devices below it. but, hmm, it will need far more codes...

Just set the dev pointer to the device that is associated with the sound device. That's the best you can do.

thanks,

greg k-h

-------------------------------------------------------
This SF.net email is sponsored by: Perforce Software. Perforce is the Fast Software Configuration Management System offering advanced branching capabilities and atomic changes on 50+ platforms. Free Eval! http://www.perforce.com/perforce/loadprog.html
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel