From: apatard@mandriva.com
To: alsa-devel@alsa-project.org
Cc: nico@fluxnic.net, broonie@opensource.wolfsonmicro.com,
saeed@marvell.com, Arnaud Patard <apatard@mandriva.com>,
tbm@cyrius.com, linux-arm-kernel@lists.infradead.org
Subject: [patch 3/6] ASoC: Add SOC_DOUBLE_R_SX_TLV control
Date: Sat, 15 May 2010 17:30:01 +0200 [thread overview]
Message-ID: <20100515153130.338630785@mandriva.com> (raw)
In-Reply-To: 20100515152958.899927802@mandriva.com
[-- Attachment #1: add_soc_double_r_sx_tlv.patch --]
[-- Type: text/plain, Size: 4847 bytes --]
This patch is adding a new control which has the following capabilities:
- tlv
- variable data size (for instance, 7 ou 8 bit)
- double mixer
- data range centered around 0
Signed-off-by: Arnaud Patard <apatard@mandriva.com>
Index: sound-2.6/include/sound/soc.h
===================================================================
--- sound-2.6.orig/include/sound/soc.h 2010-05-14 09:28:38.152498194 +0200
+++ sound-2.6/include/sound/soc.h 2010-05-14 09:31:47.204499340 +0200
@@ -170,6 +170,21 @@
.get = xhandler_get, .put = xhandler_put, \
.private_value = (unsigned long)&xenum }
+#define SOC_DOUBLE_R_SX_TLV(xname, xreg_left, xreg_right, xshift,\
+ xmin, xmax, tlv_array) \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
+ .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
+ SNDRV_CTL_ELEM_ACCESS_READWRITE, \
+ .tlv.p = (tlv_array), \
+ .info = snd_soc_info_volsw_2r_sx, \
+ .get = snd_soc_get_volsw_2r_sx, \
+ .put = snd_soc_put_volsw_2r_sx, \
+ .private_value = (unsigned long)&(struct soc_mixer_control) \
+ {.reg = xreg_left, \
+ .rreg = xreg_right, .shift = xshift, \
+ .min = xmin, .max = xmax} }
+
+
/*
* Simplified versions of above macros, declaring a struct and calculating
* ARRAY_SIZE internally
@@ -329,6 +344,12 @@ int snd_soc_put_volsw_s8(struct snd_kcon
struct snd_ctl_elem_value *ucontrol);
int snd_soc_limit_volume(struct snd_soc_codec *codec,
const char *name, int max);
+int snd_soc_info_volsw_2r_sx(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_info *uinfo);
+int snd_soc_get_volsw_2r_sx(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol);
+int snd_soc_put_volsw_2r_sx(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol);
/**
* struct snd_soc_jack_pin - Describes a pin to update based on jack detection
Index: sound-2.6/sound/soc/soc-core.c
===================================================================
--- sound-2.6.orig/sound/soc/soc-core.c 2010-05-14 09:28:38.180548514 +0200
+++ sound-2.6/sound/soc/soc-core.c 2010-05-14 09:31:47.264497529 +0200
@@ -2352,6 +2352,101 @@ int snd_soc_limit_volume(struct snd_soc_
EXPORT_SYMBOL_GPL(snd_soc_limit_volume);
/**
+ * snd_soc_info_volsw_2r_sx - double with tlv and variable data size
+ * mixer info callback
+ * @kcontrol: mixer control
+ * @uinfo: control element information
+ *
+ * Returns 0 for success.
+ */
+int snd_soc_info_volsw_2r_sx(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_info *uinfo)
+{
+ struct soc_mixer_control *mc =
+ (struct soc_mixer_control *)kcontrol->private_value;
+ int max = mc->max;
+ int min = mc->min;
+
+ uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
+ uinfo->count = 2;
+ uinfo->value.integer.min = 0;
+ uinfo->value.integer.max = max-min;
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_info_volsw_2r_sx);
+
+/**
+ * snd_soc_get_volsw_2r_sx - double with tlv and variable data size
+ * mixer get callback
+ * @kcontrol: mixer control
+ * @uinfo: control element information
+ *
+ * Returns 0 for success.
+ */
+int snd_soc_get_volsw_2r_sx(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ struct soc_mixer_control *mc =
+ (struct soc_mixer_control *)kcontrol->private_value;
+ struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+ unsigned int mask = (1<<mc->shift)-1;
+ int min = mc->min;
+ int val = snd_soc_read(codec, mc->reg) & mask;
+ int valr = snd_soc_read(codec, mc->rreg) & mask;
+
+ ucontrol->value.integer.value[0] = ((val & 0xff)-min);
+ ucontrol->value.integer.value[1] = ((valr & 0xff)-min);
+ return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_get_volsw_2r_sx);
+
+/**
+ * snd_soc_put_volsw_2r_sx - double with tlv and variable data size
+ * mixer put callback
+ * @kcontrol: mixer control
+ * @uinfo: control element information
+ *
+ * Returns 0 for success.
+ */
+int snd_soc_put_volsw_2r_sx(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ struct soc_mixer_control *mc =
+ (struct soc_mixer_control *)kcontrol->private_value;
+ struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+ unsigned int mask = (1<<mc->shift)-1;
+ int min = mc->min;
+ int ret;
+ unsigned int val, valr, oval, ovalr;
+
+ val = ((ucontrol->value.integer.value[0]+min) & 0xff);
+ val &= mask;
+ valr = ((ucontrol->value.integer.value[1]+min) & 0xff);
+ valr &= mask;
+
+ oval = snd_soc_read(codec, mc->reg) & mask;
+ ovalr = snd_soc_read(codec, mc->rreg) & mask;
+
+ ret = 0;
+ if (oval != val) {
+ ret = snd_soc_write(codec, mc->reg, val);
+ if (ret < 0)
+ return 0;
+ ret = 1;
+ }
+ if (ovalr != valr) {
+ ret = snd_soc_write(codec, mc->rreg, valr);
+ if (ret < 0)
+ return 0;
+ ret = 1;
+ }
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_put_volsw_2r_sx);
+
+/**
* snd_soc_dai_set_sysclk - configure DAI system or master clock.
* @dai: DAI
* @clk_id: DAI specific clock ID
WARNING: multiple messages have this Message-ID (diff)
From: apatard@mandriva.com (apatard at mandriva.com)
To: linux-arm-kernel@lists.infradead.org
Subject: [patch 3/6] ASoC: Add SOC_DOUBLE_R_SX_TLV control
Date: Sat, 15 May 2010 17:30:01 +0200 [thread overview]
Message-ID: <20100515153130.338630785@mandriva.com> (raw)
In-Reply-To: 20100515152958.899927802@mandriva.com
An embedded and charset-unspecified text was scrubbed...
Name: add_soc_double_r_sx_tlv.patch
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20100515/1b796907/attachment.el>
next prev parent reply other threads:[~2010-05-15 15:31 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-15 15:29 [patch 0/6] kirkwood openrd client audio support - v2 apatard
2010-05-15 15:29 ` apatard at mandriva.com
2010-05-15 15:29 ` [patch 1/6] orion/kirkwood: add audio functions apatard
2010-05-15 15:29 ` apatard at mandriva.com
2010-05-16 17:35 ` Mark Brown
2010-05-16 17:35 ` Mark Brown
2010-05-15 15:30 ` [patch 2/6] openrd-client: initialise audio apatard
2010-05-15 15:30 ` apatard at mandriva.com
2010-05-16 17:36 ` Mark Brown
2010-05-16 17:36 ` Mark Brown
2010-05-15 15:30 ` apatard [this message]
2010-05-15 15:30 ` [patch 3/6] ASoC: Add SOC_DOUBLE_R_SX_TLV control apatard at mandriva.com
2010-05-16 17:09 ` Mark Brown
2010-05-16 17:09 ` Mark Brown
2010-05-15 15:30 ` [patch 4/6] cs42l51: add asoc driver apatard
2010-05-15 15:30 ` apatard at mandriva.com
2010-05-16 17:27 ` Mark Brown
2010-05-16 17:27 ` Mark Brown
2010-05-15 15:30 ` [patch 5/6] orion/kirkwood: Add i2s support apatard
2010-05-15 15:30 ` apatard at mandriva.com
2010-05-16 17:31 ` Mark Brown
2010-05-16 17:31 ` Mark Brown
2010-05-17 5:23 ` saeed bishara
2010-05-17 5:23 ` [alsa-devel] " saeed bishara
2010-05-15 15:30 ` [patch 6/6] kirkwood: Add audio support to openrd client platforms apatard
2010-05-15 15:30 ` apatard at mandriva.com
2010-05-15 16:52 ` [patch 6/6] kirkwood: Add audio support to openrd?client platforms Alexander Clouter
2010-05-15 16:52 ` Alexander Clouter
2010-05-16 17:32 ` [patch 6/6] kirkwood: Add audio support to openrd client platforms Mark Brown
2010-05-16 17:32 ` Mark Brown
-- strict thread matches above, loose matches on Subject: below --
2010-05-11 16:23 [patch 0/6] kirkwood openrd client audio support apatard
2010-05-11 16:23 ` [patch 3/6] asoc: Add SOC_DOUBLE_R_SX_TLV control apatard
2010-05-12 8:59 ` Mark Brown
2010-05-13 9:30 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100515153130.338630785@mandriva.com \
--to=apatard@mandriva.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=nico@fluxnic.net \
--cc=saeed@marvell.com \
--cc=tbm@cyrius.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.