diff options
Diffstat (limited to 'sound/soc/soc-jack.c')
-rw-r--r-- | sound/soc/soc-jack.c | 58 |
1 files changed, 56 insertions, 2 deletions
diff --git a/sound/soc/soc-jack.c b/sound/soc/soc-jack.c index ac5a5bc7375a..fcab80b36a37 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); |
@@ -100,7 +101,7 @@ void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask) | |||
100 | } | 101 | } |
101 | 102 | ||
102 | /* Report before the DAPM sync to help users updating micbias status */ | 103 | /* Report before the DAPM sync to help users updating micbias status */ |
103 | blocking_notifier_call_chain(&jack->notifier, status, NULL); | 104 | blocking_notifier_call_chain(&jack->notifier, status, jack); |
104 | 105 | ||
105 | snd_soc_dapm_sync(dapm); | 106 | snd_soc_dapm_sync(dapm); |
106 | 107 | ||
@@ -112,6 +113,51 @@ out: | |||
112 | EXPORT_SYMBOL_GPL(snd_soc_jack_report); | 113 | EXPORT_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 | */ | ||
125 | int 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 | } | ||
136 | EXPORT_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 | */ | ||
147 | int 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 | } | ||
158 | EXPORT_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 |
@@ -194,7 +240,7 @@ static void snd_soc_jack_gpio_detect(struct snd_soc_jack_gpio *gpio) | |||
194 | int enable; | 240 | int enable; |
195 | int report; | 241 | int report; |
196 | 242 | ||
197 | enable = gpio_get_value(gpio->gpio); | 243 | enable = gpio_get_value_cansleep(gpio->gpio); |
198 | if (gpio->invert) | 244 | if (gpio->invert) |
199 | enable = !enable; | 245 | enable = !enable; |
200 | 246 | ||
@@ -284,6 +330,14 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count, | |||
284 | if (ret) | 330 | if (ret) |
285 | goto err; | 331 | goto err; |
286 | 332 | ||
333 | if (gpios[i].wake) { | ||
334 | ret = set_irq_wake(gpio_to_irq(gpios[i].gpio), 1); | ||
335 | if (ret != 0) | ||
336 | printk(KERN_ERR | ||
337 | "Failed to mark GPIO %d as wake source: %d\n", | ||
338 | gpios[i].gpio, ret); | ||
339 | } | ||
340 | |||
287 | #ifdef CONFIG_GPIO_SYSFS | 341 | #ifdef CONFIG_GPIO_SYSFS |
288 | /* Expose GPIO value over sysfs for diagnostic purposes */ | 342 | /* Expose GPIO value over sysfs for diagnostic purposes */ |
289 | gpio_export(gpios[i].gpio, false); | 343 | gpio_export(gpios[i].gpio, false); |