aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core/pcm.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2006-09-06 08:27:46 -0400
committerJaroslav Kysela <perex@suse.cz>2006-09-23 04:46:32 -0400
commit9d19f48cfe2570562c2c6226780a7ca627b0f1f1 (patch)
treedffe11da7daa0b27225c08badee58628923d961b /sound/core/pcm.c
parenta7da6ce564a80952d9c0b210deca5a8cd3474a31 (diff)
[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.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/sound/core/pcm.c b/sound/core/pcm.c
index ed3b09469560..bf8f412988b8 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)
907 substream->pstr->substream_opened--; 907 substream->pstr->substream_opened--;
908} 908}
909 909
910static ssize_t show_pcm_class(struct class_device *class_device, char *buf)
911{
912 struct snd_pcm *pcm;
913 const char *str;
914 static const char *strs[SNDRV_PCM_CLASS_LAST + 1] = {
915 [SNDRV_PCM_CLASS_GENERIC] = "generic",
916 [SNDRV_PCM_CLASS_MULTI] = "multi",
917 [SNDRV_PCM_CLASS_MODEM] = "modem",
918 [SNDRV_PCM_CLASS_DIGITIZER] = "digitizer",
919 };
920
921 if (! (pcm = class_get_devdata(class_device)) ||
922 pcm->dev_class > SNDRV_PCM_CLASS_LAST)
923 str = "none";
924 else
925 str = strs[pcm->dev_class];
926 return snprintf(buf, PAGE_SIZE, "%s\n", str);
927}
928
929static struct class_device_attribute pcm_attrs =
930 __ATTR(pcm_class, S_IRUGO, show_pcm_class, NULL);
931
910static int snd_pcm_dev_register(struct snd_device *device) 932static int snd_pcm_dev_register(struct snd_device *device)
911{ 933{
912 int cidx, err; 934 int cidx, err;
@@ -945,6 +967,8 @@ static int snd_pcm_dev_register(struct snd_device *device)
945 mutex_unlock(&register_mutex); 967 mutex_unlock(&register_mutex);
946 return err; 968 return err;
947 } 969 }
970 snd_add_device_sysfs_file(devtype, pcm->card, pcm->device,
971 &pcm_attrs);
948 for (substream = pcm->streams[cidx].substream; substream; substream = substream->next) 972 for (substream = pcm->streams[cidx].substream; substream; substream = substream->next)
949 snd_pcm_timer_init(substream); 973 snd_pcm_timer_init(substream);
950 } 974 }