aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/soc-jack.c
diff options
context:
space:
mode:
authorVinod Koul <vinod.koul@intel.com>2011-02-09 04:14:17 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2011-02-09 18:02:43 -0500
commitfa9879edebdaad4cfcd2dbe3eaa2ba0dc4f0a262 (patch)
tree47032fd4e879f7390999b180f0557261647742f8 /sound/soc/soc-jack.c
parent866fd9366a5b2c7d17eb10f7e7b1c17393ed0beb (diff)
ASoC: add support for multiple jack types
This patch adds soc-jack support for adding voltage zones and for detecting jack type Signed-off-by: Vinod Koul <vinod.koul@intel.com> Signed-off-by: Harsha Priya <priya.harsha@intel.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/soc-jack.c')
-rw-r--r--sound/soc/soc-jack.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/sound/soc/soc-jack.c b/sound/soc/soc-jack.c
index ac5a5bc7375a..99dbaf756b44 100644
--- a/sound/soc/soc-jack.c
+++ b/sound/soc/soc-jack.c
@@ -37,6 +37,7 @@ int snd_soc_jack_new(struct snd_soc_codec *codec, const char *id, int type,
37{ 37{
38 jack->codec = codec; 38 jack->codec = codec;
39 INIT_LIST_HEAD(&jack->pins); 39 INIT_LIST_HEAD(&jack->pins);
40 INIT_LIST_HEAD(&jack->jack_zones);
40 BLOCKING_INIT_NOTIFIER_HEAD(&jack->notifier); 41 BLOCKING_INIT_NOTIFIER_HEAD(&jack->notifier);
41 42
42 return snd_jack_new(codec->card->snd_card, id, type, &jack->jack); 43 return snd_jack_new(codec->card->snd_card, id, type, &jack->jack);
@@ -112,6 +113,51 @@ out:
112EXPORT_SYMBOL_GPL(snd_soc_jack_report); 113EXPORT_SYMBOL_GPL(snd_soc_jack_report);
113 114
114/** 115/**
116 * snd_soc_jack_add_zones - Associate voltage zones with jack
117 *
118 * @jack: ASoC jack
119 * @count: Number of zones
120 * @zone: Array of zones
121 *
122 * After this function has been called the zones specified in the
123 * array will be associated with the jack.
124 */
125int snd_soc_jack_add_zones(struct snd_soc_jack *jack, int count,
126 struct snd_soc_jack_zone *zones)
127{
128 int i;
129
130 for (i = 0; i < count; i++) {
131 INIT_LIST_HEAD(&zones[i].list);
132 list_add(&(zones[i].list), &jack->jack_zones);
133 }
134 return 0;
135}
136EXPORT_SYMBOL_GPL(snd_soc_jack_add_zones);
137
138/**
139 * snd_soc_jack_get_type - Based on the mic bias value, this function returns
140 * the type of jack from the zones delcared in the jack type
141 *
142 * @micbias_voltage: mic bias voltage at adc channel when jack is plugged in
143 *
144 * Based on the mic bias value passed, this function helps identify
145 * the type of jack from the already delcared jack zones
146 */
147int snd_soc_jack_get_type(struct snd_soc_jack *jack, int micbias_voltage)
148{
149 struct snd_soc_jack_zone *zone;
150
151 list_for_each_entry(zone, &jack->jack_zones, list) {
152 if (micbias_voltage >= zone->min_mv &&
153 micbias_voltage < zone->max_mv)
154 return zone->jack_type;
155 }
156 return 0;
157}
158EXPORT_SYMBOL_GPL(snd_soc_jack_get_type);
159
160/**
115 * snd_soc_jack_add_pins - Associate DAPM pins with an ASoC jack 161 * snd_soc_jack_add_pins - Associate DAPM pins with an ASoC jack
116 * 162 *
117 * @jack: ASoC jack 163 * @jack: ASoC jack