diff options
author | Takashi Iwai <tiwai@suse.de> | 2006-09-06 12:27:46 (GMT) |
---|---|---|
committer | Jaroslav Kysela <perex@suse.cz> | 2006-09-23 08:46:32 (GMT) |
commit | 9d19f48cfe2570562c2c6226780a7ca627b0f1f1 (patch) | |
tree | dffe11da7daa0b27225c08badee58628923d961b /sound/core/pcm.c | |
parent | a7da6ce564a80952d9c0b210deca5a8cd3474a31 (diff) | |
download | linux-fsl-qoriq-9d19f48cfe2570562c2c6226780a7ca627b0f1f1.tar.xz |
[ALSA] Add pcm_class attribute to PCM sysfs entry
This patch adds a new attribute, pcm_class, to each PCM sysfs entry.
It's useful to detect what kind of PCM stream is, for example, HAL
can check whether it's a modem or not.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>
Diffstat (limited to 'sound/core/pcm.c')
-rw-r--r-- | sound/core/pcm.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/sound/core/pcm.c b/sound/core/pcm.c index ed3b094..bf8f412 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c @@ -907,6 +907,28 @@ void snd_pcm_detach_substream(struct snd_pcm_substream *substream) 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(pcm_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 snd_device *device) mutex_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); } |