summaryrefslogtreecommitdiffstats
path: root/sound/pci/hda
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2008-07-30 15:01:46 +0200
committerTakashi Iwai <tiwai@suse.de>2008-10-13 02:43:04 +0200
commit1e1be4329f2aec6a8ec63737a69258fedf34c55d (patch)
treec75bec16e7d23f7025fb6f37b8a9b00225750903 /sound/pci/hda
parent11aeff082ad9bd00e8475bf1630c3264344d3764 (diff)
downloadop-kernel-dev-1e1be4329f2aec6a8ec63737a69258fedf34c55d.zip
op-kernel-dev-1e1be4329f2aec6a8ec63737a69258fedf34c55d.tar.gz
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')
-rw-r--r--sound/pci/hda/hda_codec.h1
-rw-r--r--sound/pci/hda/hda_hwdep.c34
2 files changed, 35 insertions, 0 deletions
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
index 38a9bb6..a77ba22 100644
--- a/sound/pci/hda/hda_codec.h
+++ b/sound/pci/hda/hda_codec.h
@@ -754,6 +754,7 @@ struct hda_codec {
#ifdef CONFIG_SND_HDA_HWDEP
struct snd_hwdep *hwdep; /* assigned hwdep device */
struct snd_array init_verbs; /* additional init verbs */
+ struct snd_array hints; /* additional hints */
#endif
/* misc flags */
diff --git a/sound/pci/hda/hda_hwdep.c b/sound/pci/hda/hda_hwdep.c
index f3400d7..653da1d 100644
--- a/sound/pci/hda/hda_hwdep.c
+++ b/sound/pci/hda/hda_hwdep.c
@@ -23,6 +23,7 @@
#include <linux/pci.h>
#include <linux/compat.h>
#include <linux/mutex.h>
+#include <linux/ctype.h>
#include <sound/core.h>
#include "hda_codec.h"
#include "hda_local.h"
@@ -98,8 +99,16 @@ static int hda_hwdep_open(struct snd_hwdep *hw, struct file *file)
static void clear_hwdep_elements(struct hda_codec *codec)
{
+ char **head;
+ int i;
+
/* clear init verbs */
snd_array_free(&codec->init_verbs);
+ /* clear hints */
+ head = codec->hints.list;
+ for (i = 0; i < codec->hints.used; i++, head++)
+ kfree(*head);
+ snd_array_free(&codec->hints);
}
static void hwdep_free(struct snd_hwdep *hwdep)
@@ -131,6 +140,7 @@ int __devinit snd_hda_create_hwdep(struct hda_codec *codec)
#endif
snd_array_init(&codec->init_verbs, sizeof(struct hda_verb), 32);
+ snd_array_init(&codec->hints, sizeof(char *), 32);
return 0;
}
@@ -280,6 +290,29 @@ static ssize_t init_verbs_store(struct device *dev,
return count;
}
+static ssize_t hints_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct snd_hwdep *hwdep = dev_get_drvdata(dev);
+ struct hda_codec *codec = hwdep->private_data;
+ char *p;
+ char **hint;
+
+ if (!*buf || isspace(*buf) || *buf == '#' || *buf == '\n')
+ return count;
+ p = kstrndup_noeol(buf, 1024);
+ if (!p)
+ return -ENOMEM;
+ hint = snd_array_new(&codec->hints);
+ if (!hint) {
+ kfree(p);
+ return -ENOMEM;
+ }
+ *hint = p;
+ return count;
+}
+
#define CODEC_ATTR_RW(type) \
__ATTR(type, 0644, type##_show, type##_store)
#define CODEC_ATTR_RO(type) \
@@ -296,6 +329,7 @@ static struct device_attribute codec_attrs[] = {
CODEC_ATTR_RW(name),
CODEC_ATTR_RW(modelname),
CODEC_ATTR_WO(init_verbs),
+ CODEC_ATTR_WO(hints),
CODEC_ATTR_WO(reconfig),
CODEC_ATTR_WO(clear),
};
OpenPOWER on IntegriCloud