aboutsummaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorAndy Green <andy@openmoko.com>2008-11-19 17:09:46 +0000
committerAndy Green <agreen@pads.home.warmcat.com>2008-11-19 17:09:46 +0000
commitb4ba78cb85c1305ffe9f95100a578679437497f0 (patch)
treea92e7d995555c6c076e121549292a3c7b72d90e4 /sound
parentfeb93198c9bfed1a0e07e421328e8f270e8fb788 (diff)
debug-codec-register-setting-sysfs.patch
Allow direct setting of codec registers for super mega meddling power Signed-off-by: Andy Green <andy@openmoko.com>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/soc-core.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 16c7453f494..23167a79c33 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1003,6 +1003,38 @@ static ssize_t codec_reg_show(struct device *dev,
}
static DEVICE_ATTR(codec_reg, 0444, codec_reg_show, NULL);
+
+static ssize_t codec_reg_write(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ u32 address;
+ u32 data;
+ char * end;
+ size_t left = count;
+ struct snd_soc_device *devdata = dev_get_drvdata(dev);
+ struct snd_soc_codec *codec = devdata->codec;
+
+ address = simple_strtoul(buf, &end, 16);
+ left -= (int)(end - buf);
+ while ((*end == ' ') && (left)) {
+ end++;
+ left--;
+ }
+ if (!left)
+ return count;
+ data = simple_strtoul(end, &end, 16);
+
+ printk(KERN_INFO"user writes Codec reg 0x%02X with Data 0x%04X\n",
+ address, data);
+
+ codec->write(codec, address, data);
+
+ return count;
+}
+
+static DEVICE_ATTR(codec_reg_write, 0644, NULL, codec_reg_write);
+
/**
* snd_soc_new_ac97_codec - initailise AC97 device
* @codec: audio codec
@@ -1218,6 +1250,9 @@ int snd_soc_register_card(struct snd_soc_device *socdev)
mutex_unlock(&codec->mutex);
+ err = device_create_file(socdev->dev, &dev_attr_codec_reg_write);
+ if (err < 0)
+ printk(KERN_WARNING "asoc: failed to add codec sysfs entries\n");
out:
return ret;
}