aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/hda_hwdep.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2008-07-30 09:01:46 -0400
committerTakashi Iwai <tiwai@suse.de>2008-10-12 20:43:04 -0400
commit1e1be4329f2aec6a8ec63737a69258fedf34c55d (patch)
treec75bec16e7d23f7025fb6f37b8a9b00225750903 /sound/pci/hda/hda_hwdep.c
parent11aeff082ad9bd00e8475bf1630c3264344d3764 (diff)
ALSA: hda - Add hints for reconfig
This patch adds the "hints" for reconfiguring codecs. The hints are simply string arrays and can be freely used/parsed by the codec patch. The hints can be input via hwdep sysfs files. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda/hda_hwdep.c')
-rw-r--r--sound/pci/hda/hda_hwdep.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/sound/pci/hda/hda_hwdep.c b/sound/pci/hda/hda_hwdep.c
index f3400d75eba4..653da1d3e4df 100644
--- a/sound/pci/hda/hda_hwdep.c
+++ b/sound/pci/hda/hda_hwdep.c
@@ -23,6 +23,7 @@
23#include <linux/pci.h> 23#include <linux/pci.h>
24#include <linux/compat.h> 24#include <linux/compat.h>
25#include <linux/mutex.h> 25#include <linux/mutex.h>
26#include <linux/ctype.h>
26#include <sound/core.h> 27#include <sound/core.h>
27#include "hda_codec.h" 28#include "hda_codec.h"
28#include "hda_local.h" 29#include "hda_local.h"
@@ -98,8 +99,16 @@ static int hda_hwdep_open(struct snd_hwdep *hw, struct file *file)
98 99
99static void clear_hwdep_elements(struct hda_codec *codec) 100static void clear_hwdep_elements(struct hda_codec *codec)
100{ 101{
102 char **head;
103 int i;
104
101 /* clear init verbs */ 105 /* clear init verbs */
102 snd_array_free(&codec->init_verbs); 106 snd_array_free(&codec->init_verbs);
107 /* clear hints */
108 head = codec->hints.list;
109 for (i = 0; i < codec->hints.used; i++, head++)
110 kfree(*head);
111 snd_array_free(&codec->hints);
103} 112}
104 113
105static void hwdep_free(struct snd_hwdep *hwdep) 114static void hwdep_free(struct snd_hwdep *hwdep)
@@ -131,6 +140,7 @@ int __devinit snd_hda_create_hwdep(struct hda_codec *codec)
131#endif 140#endif
132 141
133 snd_array_init(&codec->init_verbs, sizeof(struct hda_verb), 32); 142 snd_array_init(&codec->init_verbs, sizeof(struct hda_verb), 32);
143 snd_array_init(&codec->hints, sizeof(char *), 32);
134 144
135 return 0; 145 return 0;
136} 146}
@@ -280,6 +290,29 @@ static ssize_t init_verbs_store(struct device *dev,
280 return count; 290 return count;
281} 291}
282 292
293static ssize_t hints_store(struct device *dev,
294 struct device_attribute *attr,
295 const char *buf, size_t count)
296{
297 struct snd_hwdep *hwdep = dev_get_drvdata(dev);
298 struct hda_codec *codec = hwdep->private_data;
299 char *p;
300 char **hint;
301
302 if (!*buf || isspace(*buf) || *buf == '#' || *buf == '\n')
303 return count;
304 p = kstrndup_noeol(buf, 1024);
305 if (!p)
306 return -ENOMEM;
307 hint = snd_array_new(&codec->hints);
308 if (!hint) {
309 kfree(p);
310 return -ENOMEM;
311 }
312 *hint = p;
313 return count;
314}
315
283#define CODEC_ATTR_RW(type) \ 316#define CODEC_ATTR_RW(type) \
284 __ATTR(type, 0644, type##_show, type##_store) 317 __ATTR(type, 0644, type##_show, type##_store)
285#define CODEC_ATTR_RO(type) \ 318#define CODEC_ATTR_RO(type) \
@@ -296,6 +329,7 @@ static struct device_attribute codec_attrs[] = {
296 CODEC_ATTR_RW(name), 329 CODEC_ATTR_RW(name),
297 CODEC_ATTR_RW(modelname), 330 CODEC_ATTR_RW(modelname),
298 CODEC_ATTR_WO(init_verbs), 331 CODEC_ATTR_WO(init_verbs),
332 CODEC_ATTR_WO(hints),
299 CODEC_ATTR_WO(reconfig), 333 CODEC_ATTR_WO(reconfig),
300 CODEC_ATTR_WO(clear), 334 CODEC_ATTR_WO(clear),
301}; 335};