Addition of sysfs file for PCM
RFC 1/1 Addition of sysfs file for PCM
Hi,
I've discussed with HAL guys about the current problem of sound configuration over HAL. One issue is that both audio and modem PCM devices appear on the same card (e.g. HD-audio), and can't be distinguished from the device name itself.
For solving this, I made a patch to add a sysfs file in /sys/class/sound/pcm* directories indicating the PCM device class.
If anyone has better idea or implementation, let me know.
Another qustion regarding this is whether we push it to the public HG repo right now, or wait until 1.0.12-final is released. As usual, I have no idea when we reach 1.0.12-final, hence I prefer pushing it as soon as possible, but this would bring of course a possibility of regression (especially for building with the older kernels).
Takashi
core/pcm.c +24 -0
@@ -907,6 +907,28 @@ void snd_pcm_detach_substream(struct snd substream->pstr->substream_opened--; } +static ssize_t show_pcm_class (struct class_device *class_device,char *buf) +{ +struct snd_pcm *pcm; +const char *str; +static const char *strs[SNDRV_PCM_CLASS_LAST +1 ] = { + [SNDRV_PCM_CLASS_GENERIC ] ="generic" , + [SNDRV_PCM_CLASS_MULTI ] ="multi" , + [SNDRV_PCM_CLASS_MODEM ] ="modem" , + [SNDRV_PCM_CLASS_DIGITIZER ] ="digitizer" , + }; + +if (! (pcm =class_get_devdata (class_device)) || + pcm->dev_class >SNDRV_PCM_CLASS_LAST ) + str ="none" ; +else + str = strs[pcm->dev_class]; +return snprintf (buf,PAGE_SIZE ,"%s\n" , str); +} + +static struct class_device_attribute pcm_attrs = +__ATTR (class,S_IRUGO , show_pcm_class,NULL ); +static int snd_pcm_dev_register (struct snd_device *device) {int cidx, err;
@@ -945,6 +967,8 @@ static int snd_pcm_dev_register(struct smutex_unlock (®ister_mutex);return err; } +snd_add_device_sysfs_file (devtype, pcm->card, pcm->device, + &pcm_attrs);for (substream = pcm->streams[cidx].substream; substream; substream = substream->next)snd_pcm_timer_init (substream); }
core/sound.c +46 -14
90 lines not on this page · raw message
include/core.h +3 -0
@@ -186,6 +186,7 @@ struct snd_minor {int device;/* device number */ const struct file_operations *f_ops;/* file operations */ void *private_data;/* private data for f_ops->open */ +struct class_device *class_dev;/* class device for sysfs */ };/* sound.c */
@@ -200,6 +201,8 @@ int snd_register_device(int type, struct const char *name);int snd_unregister_device (int type,struct snd_card *card,int dev);void *snd_lookup_minor_data (unsigned int minor,int type); +int snd_add_device_sysfs_file (int type,struct snd_card *card,int dev, +const struct class_device_attribute *attr);#ifdef CONFIG_SND_OSSEMUL int snd_register_oss_device(int type, struct snd_card *card, int dev,
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
Quoted 9 lines · Takashi Iwai
Hi,
I've discussed with HAL guys about the current problem of sound configuration over HAL. One issue is that both audio and modem PCM devices appear on the same card (e.g. HD-audio), and can't be distinguished from the device name itself.
For solving this, I made a patch to add a sysfs file in
/sys/class/sound/pcm*directories indicating the PCM device class.
I'd suggest discussing this with Greg Kroah-Hartman.
Quoted 8 lines
If anyone has better idea or implementation, let me know.
Another qustion regarding this is whether we push it to the public HG repo right now, or wait until 1.0.12-final is released. As usual, I have no idea when we reach 1.0.12-final, hence I prefer pushing it as soon as possible, but this would bring of course a possibility of regression (especially for building with the older kernels).
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
At Tue, 08 Aug 2006 18:51:18 +0200,
Quoted 10 lines · Thierry Vignaud
Quoted 7 lines · Takashi Iwai
Hi,
I've discussed with HAL guys about the current problem of sound configuration over HAL. One issue is that both audio and modem PCM devices appear on the same card (e.g. HD-audio), and can't be distinguished from the device name itself.
Quoted 4 lines
Quoted 2 lines
For solving this, I made a patch to add a sysfs file in
/sys/class/sound/pcm*directories indicating the PCM device class.I'd suggest discussing this with Greg Kroah-Hartman.
I'm sure he'd have nothing against such a stuff.
The major player of sysfs is udev and HAL, and this is the very request from HAL developers.
But, anyway it's a good idea to involve him.
thanks,
Takashi
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642