diff options
Diffstat (limited to 'sound/soc/samsung/neo1973_wm8753.c')
-rw-r--r-- | sound/soc/samsung/neo1973_wm8753.c | 148 |
1 files changed, 11 insertions, 137 deletions
diff --git a/sound/soc/samsung/neo1973_wm8753.c b/sound/soc/samsung/neo1973_wm8753.c index d3cd6888a810..fe929467f93c 100644 --- a/sound/soc/samsung/neo1973_wm8753.c +++ b/sound/soc/samsung/neo1973_wm8753.c | |||
@@ -37,17 +37,6 @@ | |||
37 | #include "dma.h" | 37 | #include "dma.h" |
38 | #include "s3c24xx-i2s.h" | 38 | #include "s3c24xx-i2s.h" |
39 | 39 | ||
40 | /* define the scenarios */ | ||
41 | #define NEO_AUDIO_OFF 0 | ||
42 | #define NEO_GSM_CALL_AUDIO_HANDSET 1 | ||
43 | #define NEO_GSM_CALL_AUDIO_HEADSET 2 | ||
44 | #define NEO_GSM_CALL_AUDIO_BLUETOOTH 3 | ||
45 | #define NEO_STEREO_TO_SPEAKERS 4 | ||
46 | #define NEO_STEREO_TO_HEADPHONES 5 | ||
47 | #define NEO_CAPTURE_HANDSET 6 | ||
48 | #define NEO_CAPTURE_HEADSET 7 | ||
49 | #define NEO_CAPTURE_BLUETOOTH 8 | ||
50 | |||
51 | static struct snd_soc_card neo1973; | 40 | static struct snd_soc_card neo1973; |
52 | static struct i2c_client *i2c; | 41 | static struct i2c_client *i2c; |
53 | 42 | ||
@@ -224,113 +213,6 @@ static struct snd_soc_ops neo1973_voice_ops = { | |||
224 | .hw_free = neo1973_voice_hw_free, | 213 | .hw_free = neo1973_voice_hw_free, |
225 | }; | 214 | }; |
226 | 215 | ||
227 | static int neo1973_scenario; | ||
228 | |||
229 | static int neo1973_get_scenario(struct snd_kcontrol *kcontrol, | ||
230 | struct snd_ctl_elem_value *ucontrol) | ||
231 | { | ||
232 | ucontrol->value.integer.value[0] = neo1973_scenario; | ||
233 | return 0; | ||
234 | } | ||
235 | |||
236 | static int set_scenario_endpoints(struct snd_soc_codec *codec, int scenario) | ||
237 | { | ||
238 | struct snd_soc_dapm_context *dapm = &codec->dapm; | ||
239 | |||
240 | pr_debug("Entered %s\n", __func__); | ||
241 | |||
242 | switch (neo1973_scenario) { | ||
243 | case NEO_AUDIO_OFF: | ||
244 | snd_soc_dapm_disable_pin(dapm, "Audio Out"); | ||
245 | snd_soc_dapm_disable_pin(dapm, "GSM Line Out"); | ||
246 | snd_soc_dapm_disable_pin(dapm, "GSM Line In"); | ||
247 | snd_soc_dapm_disable_pin(dapm, "Headset Mic"); | ||
248 | snd_soc_dapm_disable_pin(dapm, "Call Mic"); | ||
249 | break; | ||
250 | case NEO_GSM_CALL_AUDIO_HANDSET: | ||
251 | snd_soc_dapm_enable_pin(dapm, "Audio Out"); | ||
252 | snd_soc_dapm_enable_pin(dapm, "GSM Line Out"); | ||
253 | snd_soc_dapm_enable_pin(dapm, "GSM Line In"); | ||
254 | snd_soc_dapm_disable_pin(dapm, "Headset Mic"); | ||
255 | snd_soc_dapm_enable_pin(dapm, "Call Mic"); | ||
256 | break; | ||
257 | case NEO_GSM_CALL_AUDIO_HEADSET: | ||
258 | snd_soc_dapm_enable_pin(dapm, "Audio Out"); | ||
259 | snd_soc_dapm_enable_pin(dapm, "GSM Line Out"); | ||
260 | snd_soc_dapm_enable_pin(dapm, "GSM Line In"); | ||
261 | snd_soc_dapm_enable_pin(dapm, "Headset Mic"); | ||
262 | snd_soc_dapm_disable_pin(dapm, "Call Mic"); | ||
263 | break; | ||
264 | case NEO_GSM_CALL_AUDIO_BLUETOOTH: | ||
265 | snd_soc_dapm_disable_pin(dapm, "Audio Out"); | ||
266 | snd_soc_dapm_enable_pin(dapm, "GSM Line Out"); | ||
267 | snd_soc_dapm_enable_pin(dapm, "GSM Line In"); | ||
268 | snd_soc_dapm_disable_pin(dapm, "Headset Mic"); | ||
269 | snd_soc_dapm_disable_pin(dapm, "Call Mic"); | ||
270 | break; | ||
271 | case NEO_STEREO_TO_SPEAKERS: | ||
272 | snd_soc_dapm_enable_pin(dapm, "Audio Out"); | ||
273 | snd_soc_dapm_disable_pin(dapm, "GSM Line Out"); | ||
274 | snd_soc_dapm_disable_pin(dapm, "GSM Line In"); | ||
275 | snd_soc_dapm_disable_pin(dapm, "Headset Mic"); | ||
276 | snd_soc_dapm_disable_pin(dapm, "Call Mic"); | ||
277 | break; | ||
278 | case NEO_STEREO_TO_HEADPHONES: | ||
279 | snd_soc_dapm_enable_pin(dapm, "Audio Out"); | ||
280 | snd_soc_dapm_disable_pin(dapm, "GSM Line Out"); | ||
281 | snd_soc_dapm_disable_pin(dapm, "GSM Line In"); | ||
282 | snd_soc_dapm_disable_pin(dapm, "Headset Mic"); | ||
283 | snd_soc_dapm_disable_pin(dapm, "Call Mic"); | ||
284 | break; | ||
285 | case NEO_CAPTURE_HANDSET: | ||
286 | snd_soc_dapm_disable_pin(dapm, "Audio Out"); | ||
287 | snd_soc_dapm_disable_pin(dapm, "GSM Line Out"); | ||
288 | snd_soc_dapm_disable_pin(dapm, "GSM Line In"); | ||
289 | snd_soc_dapm_disable_pin(dapm, "Headset Mic"); | ||
290 | snd_soc_dapm_enable_pin(dapm, "Call Mic"); | ||
291 | break; | ||
292 | case NEO_CAPTURE_HEADSET: | ||
293 | snd_soc_dapm_disable_pin(dapm, "Audio Out"); | ||
294 | snd_soc_dapm_disable_pin(dapm, "GSM Line Out"); | ||
295 | snd_soc_dapm_disable_pin(dapm, "GSM Line In"); | ||
296 | snd_soc_dapm_enable_pin(dapm, "Headset Mic"); | ||
297 | snd_soc_dapm_disable_pin(dapm, "Call Mic"); | ||
298 | break; | ||
299 | case NEO_CAPTURE_BLUETOOTH: | ||
300 | snd_soc_dapm_disable_pin(dapm, "Audio Out"); | ||
301 | snd_soc_dapm_disable_pin(dapm, "GSM Line Out"); | ||
302 | snd_soc_dapm_disable_pin(dapm, "GSM Line In"); | ||
303 | snd_soc_dapm_disable_pin(dapm, "Headset Mic"); | ||
304 | snd_soc_dapm_disable_pin(dapm, "Call Mic"); | ||
305 | break; | ||
306 | default: | ||
307 | snd_soc_dapm_disable_pin(dapm, "Audio Out"); | ||
308 | snd_soc_dapm_disable_pin(dapm, "GSM Line Out"); | ||
309 | snd_soc_dapm_disable_pin(dapm, "GSM Line In"); | ||
310 | snd_soc_dapm_disable_pin(dapm, "Headset Mic"); | ||
311 | snd_soc_dapm_disable_pin(dapm, "Call Mic"); | ||
312 | } | ||
313 | |||
314 | snd_soc_dapm_sync(dapm); | ||
315 | |||
316 | return 0; | ||
317 | } | ||
318 | |||
319 | static int neo1973_set_scenario(struct snd_kcontrol *kcontrol, | ||
320 | struct snd_ctl_elem_value *ucontrol) | ||
321 | { | ||
322 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | ||
323 | |||
324 | pr_debug("Entered %s\n", __func__); | ||
325 | |||
326 | if (neo1973_scenario == ucontrol->value.integer.value[0]) | ||
327 | return 0; | ||
328 | |||
329 | neo1973_scenario = ucontrol->value.integer.value[0]; | ||
330 | set_scenario_endpoints(codec, neo1973_scenario); | ||
331 | return 1; | ||
332 | } | ||
333 | |||
334 | static u8 lm4857_regs[4] = {0x00, 0x40, 0x80, 0xC0}; | 216 | static u8 lm4857_regs[4] = {0x00, 0x40, 0x80, 0xC0}; |
335 | 217 | ||
336 | static void lm4857_write_regs(void) | 218 | static void lm4857_write_regs(void) |
@@ -454,26 +336,16 @@ static const struct soc_enum lm4857_mode_enum[] = { | |||
454 | SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(lm4857_mode), lm4857_mode), | 336 | SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(lm4857_mode), lm4857_mode), |
455 | }; | 337 | }; |
456 | 338 | ||
457 | static const char *neo_scenarios[] = { | ||
458 | "Off", | ||
459 | "GSM Handset", | ||
460 | "GSM Headset", | ||
461 | "GSM Bluetooth", | ||
462 | "Speakers", | ||
463 | "Headphones", | ||
464 | "Capture Handset", | ||
465 | "Capture Headset", | ||
466 | "Capture Bluetooth" | ||
467 | }; | ||
468 | |||
469 | static const struct soc_enum neo_scenario_enum[] = { | ||
470 | SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(neo_scenarios), neo_scenarios), | ||
471 | }; | ||
472 | |||
473 | static const DECLARE_TLV_DB_SCALE(stereo_tlv, -4050, 150, 0); | 339 | static const DECLARE_TLV_DB_SCALE(stereo_tlv, -4050, 150, 0); |
474 | static const DECLARE_TLV_DB_SCALE(mono_tlv, -3450, 150, 0); | 340 | static const DECLARE_TLV_DB_SCALE(mono_tlv, -3450, 150, 0); |
475 | 341 | ||
476 | static const struct snd_kcontrol_new wm8753_neo1973_controls[] = { | 342 | static const struct snd_kcontrol_new wm8753_neo1973_controls[] = { |
343 | SOC_DAPM_PIN_SWITCH("Audio Out"), | ||
344 | SOC_DAPM_PIN_SWITCH("GSM Line Out"), | ||
345 | SOC_DAPM_PIN_SWITCH("GSM Line In"), | ||
346 | SOC_DAPM_PIN_SWITCH("Headset Mic"), | ||
347 | SOC_DAPM_PIN_SWITCH("Call Mic"), | ||
348 | |||
477 | SOC_SINGLE_EXT_TLV("Amp Left Playback Volume", LM4857_LVOL, 0, 31, 0, | 349 | SOC_SINGLE_EXT_TLV("Amp Left Playback Volume", LM4857_LVOL, 0, 31, 0, |
478 | lm4857_get_reg, lm4857_set_reg, stereo_tlv), | 350 | lm4857_get_reg, lm4857_set_reg, stereo_tlv), |
479 | SOC_SINGLE_EXT_TLV("Amp Right Playback Volume", LM4857_RVOL, 0, 31, 0, | 351 | SOC_SINGLE_EXT_TLV("Amp Right Playback Volume", LM4857_RVOL, 0, 31, 0, |
@@ -482,8 +354,6 @@ static const struct snd_kcontrol_new wm8753_neo1973_controls[] = { | |||
482 | lm4857_get_reg, lm4857_set_reg, mono_tlv), | 354 | lm4857_get_reg, lm4857_set_reg, mono_tlv), |
483 | SOC_ENUM_EXT("Amp Mode", lm4857_mode_enum[0], | 355 | SOC_ENUM_EXT("Amp Mode", lm4857_mode_enum[0], |
484 | lm4857_get_mode, lm4857_set_mode), | 356 | lm4857_get_mode, lm4857_set_mode), |
485 | SOC_ENUM_EXT("Neo Mode", neo_scenario_enum[0], | ||
486 | neo1973_get_scenario, neo1973_set_scenario), | ||
487 | SOC_SINGLE_EXT("Amp Spk 3D Playback Switch", LM4857_LVOL, 5, 1, 0, | 357 | SOC_SINGLE_EXT("Amp Spk 3D Playback Switch", LM4857_LVOL, 5, 1, 0, |
488 | lm4857_get_reg, lm4857_set_reg), | 358 | lm4857_get_reg, lm4857_set_reg), |
489 | SOC_SINGLE_EXT("Amp HP 3d Playback Switch", LM4857_RVOL, 5, 1, 0, | 359 | SOC_SINGLE_EXT("Amp HP 3d Playback Switch", LM4857_RVOL, 5, 1, 0, |
@@ -520,7 +390,11 @@ static int neo1973_wm8753_init(struct snd_soc_pcm_runtime *rtd) | |||
520 | ARRAY_SIZE(wm8753_dapm_widgets)); | 390 | ARRAY_SIZE(wm8753_dapm_widgets)); |
521 | 391 | ||
522 | /* set endpoints to default mode */ | 392 | /* set endpoints to default mode */ |
523 | set_scenario_endpoints(codec, NEO_AUDIO_OFF); | 393 | snd_soc_dapm_disable_pin(dapm, "Audio Out"); |
394 | snd_soc_dapm_disable_pin(dapm, "GSM Line Out"); | ||
395 | snd_soc_dapm_disable_pin(dapm, "GSM Line In"); | ||
396 | snd_soc_dapm_disable_pin(dapm, "Headset Mic"); | ||
397 | snd_soc_dapm_disable_pin(dapm, "Call Mic"); | ||
524 | 398 | ||
525 | /* add neo1973 specific controls */ | 399 | /* add neo1973 specific controls */ |
526 | err = snd_soc_add_controls(codec, wm8753_neo1973_controls, | 400 | err = snd_soc_add_controls(codec, wm8753_neo1973_controls, |