1 From 048fc250b2e3b27c80e9442e5a34a82f698da9d6 Mon Sep 17 00:00:00 2001
2 From: Andy Green <andy@openmoko.com>
3 Date: Fri, 25 Jul 2008 23:06:11 +0100
4 Subject: [PATCH] debug-codec-register-setting-sysfs.patch
5 Allow direct setting of codec registers for super mega meddling power
6 Signed-off-by: Andy Green <andy@openmoko.com>
9 sound/soc/soc-core.c | 35 +++++++++++++++++++++++++++++++++++
10 1 files changed, 35 insertions(+), 0 deletions(-)
12 diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
13 index e148db9..67223fe 100644
14 --- a/sound/soc/soc-core.c
15 +++ b/sound/soc/soc-core.c
16 @@ -935,6 +935,38 @@ static ssize_t codec_reg_show(struct device *dev,
18 static DEVICE_ATTR(codec_reg, 0444, codec_reg_show, NULL);
21 +static ssize_t codec_reg_write(struct device *dev,
22 + struct device_attribute *attr,
23 + const char *buf, size_t count)
28 + size_t left = count;
29 + struct snd_soc_device *devdata = dev_get_drvdata(dev);
30 + struct snd_soc_codec *codec = devdata->codec;
32 + address = simple_strtoul(buf, &end, 16);
33 + left -= (int)(end - buf);
34 + while ((*end == ' ') && (left)) {
40 + data = simple_strtoul(end, &end, 16);
42 + printk(KERN_INFO"user writes Codec reg 0x%02X with Data 0x%04X\n",
45 + codec->write(codec, address, data);
50 +static DEVICE_ATTR(codec_reg_write, 0644, NULL, codec_reg_write);
53 * snd_soc_new_ac97_codec - initailise AC97 device
55 @@ -1150,6 +1182,9 @@ int snd_soc_register_card(struct snd_soc_device *socdev)
57 mutex_unlock(&codec->mutex);
59 + err = device_create_file(socdev->dev, &dev_attr_codec_reg_write);
61 + printk(KERN_WARNING "asoc: failed to add codec sysfs entries\n");