diff options
-rw-r--r-- | sound/soc/codecs/tpa6130a2.c | 69 | ||||
-rw-r--r-- | sound/soc/codecs/tpa6130a2.h | 1 |
2 files changed, 12 insertions, 58 deletions
diff --git a/sound/soc/codecs/tpa6130a2.c b/sound/soc/codecs/tpa6130a2.c index c97badfac540..0a99f313e218 100644 --- a/sound/soc/codecs/tpa6130a2.c +++ b/sound/soc/codecs/tpa6130a2.c | |||
@@ -317,65 +317,24 @@ static void tpa6130a2_channel_enable(u8 channel, int enable) | |||
317 | } | 317 | } |
318 | } | 318 | } |
319 | 319 | ||
320 | static int tpa6130a2_pga_event(struct snd_soc_dapm_widget *w, | 320 | int tpa6130a2_stereo_enable(struct snd_soc_codec *codec, int enable) |
321 | struct snd_kcontrol *kcontrol, int event) | ||
322 | { | ||
323 | switch (event) { | ||
324 | case SND_SOC_DAPM_POST_PMU: | ||
325 | tpa6130a2_channel_enable(w->shift, 1); | ||
326 | break; | ||
327 | case SND_SOC_DAPM_POST_PMD: | ||
328 | tpa6130a2_channel_enable(w->shift, 0); | ||
329 | break; | ||
330 | } | ||
331 | return 0; | ||
332 | } | ||
333 | |||
334 | static int tpa6130a2_supply_event(struct snd_soc_dapm_widget *w, | ||
335 | struct snd_kcontrol *kcontrol, int event) | ||
336 | { | 321 | { |
337 | int ret = 0; | 322 | int ret = 0; |
338 | 323 | if (enable) { | |
339 | switch (event) { | ||
340 | case SND_SOC_DAPM_POST_PMU: | ||
341 | ret = tpa6130a2_power(1); | 324 | ret = tpa6130a2_power(1); |
342 | break; | 325 | if (ret < 0) |
343 | case SND_SOC_DAPM_POST_PMD: | 326 | return ret; |
327 | tpa6130a2_channel_enable(TPA6130A2_HP_EN_R | TPA6130A2_HP_EN_L, | ||
328 | 1); | ||
329 | } else { | ||
330 | tpa6130a2_channel_enable(TPA6130A2_HP_EN_R | TPA6130A2_HP_EN_L, | ||
331 | 0); | ||
344 | ret = tpa6130a2_power(0); | 332 | ret = tpa6130a2_power(0); |
345 | break; | ||
346 | } | 333 | } |
334 | |||
347 | return ret; | 335 | return ret; |
348 | } | 336 | } |
349 | 337 | EXPORT_SYMBOL_GPL(tpa6130a2_stereo_enable); | |
350 | static const struct snd_soc_dapm_widget tpa6130a2_dapm_widgets[] = { | ||
351 | SND_SOC_DAPM_PGA_E("TPA6130A2 Left", SND_SOC_NOPM, | ||
352 | TPA6130A2_HP_EN_L, 0, NULL, 0, tpa6130a2_pga_event, | ||
353 | SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD), | ||
354 | SND_SOC_DAPM_PGA_E("TPA6130A2 Right", SND_SOC_NOPM, | ||
355 | TPA6130A2_HP_EN_R, 0, NULL, 0, tpa6130a2_pga_event, | ||
356 | SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD), | ||
357 | SND_SOC_DAPM_PGA_E("TPA6130A2 Stereo", SND_SOC_NOPM, | ||
358 | TPA6130A2_HP_EN_L | TPA6130A2_HP_EN_R, 0, NULL, 0, | ||
359 | tpa6130a2_pga_event, | ||
360 | SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD), | ||
361 | SND_SOC_DAPM_SUPPLY("TPA6130A2 Enable", SND_SOC_NOPM, | ||
362 | 0, 0, tpa6130a2_supply_event, | ||
363 | SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD), | ||
364 | /* Outputs */ | ||
365 | SND_SOC_DAPM_OUTPUT("TPA6130A2 Headphone Left"), | ||
366 | SND_SOC_DAPM_OUTPUT("TPA6130A2 Headphone Right"), | ||
367 | SND_SOC_DAPM_OUTPUT("TPA6130A2 Headphone Stereo"), | ||
368 | }; | ||
369 | |||
370 | static const struct snd_soc_dapm_route audio_map[] = { | ||
371 | {"TPA6130A2 Headphone Left", NULL, "TPA6130A2 Left"}, | ||
372 | {"TPA6130A2 Headphone Right", NULL, "TPA6130A2 Right"}, | ||
373 | {"TPA6130A2 Headphone Stereo", NULL, "TPA6130A2 Stereo"}, | ||
374 | |||
375 | {"TPA6130A2 Headphone Left", NULL, "TPA6130A2 Enable"}, | ||
376 | {"TPA6130A2 Headphone Right", NULL, "TPA6130A2 Enable"}, | ||
377 | {"TPA6130A2 Headphone Stereo", NULL, "TPA6130A2 Enable"}, | ||
378 | }; | ||
379 | 338 | ||
380 | int tpa6130a2_add_controls(struct snd_soc_codec *codec) | 339 | int tpa6130a2_add_controls(struct snd_soc_codec *codec) |
381 | { | 340 | { |
@@ -387,18 +346,12 @@ int tpa6130a2_add_controls(struct snd_soc_codec *codec) | |||
387 | 346 | ||
388 | data = i2c_get_clientdata(tpa6130a2_client); | 347 | data = i2c_get_clientdata(tpa6130a2_client); |
389 | 348 | ||
390 | snd_soc_dapm_new_controls(dapm, tpa6130a2_dapm_widgets, | ||
391 | ARRAY_SIZE(tpa6130a2_dapm_widgets)); | ||
392 | |||
393 | snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map)); | ||
394 | |||
395 | if (data->id == TPA6140A2) | 349 | if (data->id == TPA6140A2) |
396 | return snd_soc_add_controls(codec, tpa6140a2_controls, | 350 | return snd_soc_add_controls(codec, tpa6140a2_controls, |
397 | ARRAY_SIZE(tpa6140a2_controls)); | 351 | ARRAY_SIZE(tpa6140a2_controls)); |
398 | else | 352 | else |
399 | return snd_soc_add_controls(codec, tpa6130a2_controls, | 353 | return snd_soc_add_controls(codec, tpa6130a2_controls, |
400 | ARRAY_SIZE(tpa6130a2_controls)); | 354 | ARRAY_SIZE(tpa6130a2_controls)); |
401 | |||
402 | } | 355 | } |
403 | EXPORT_SYMBOL_GPL(tpa6130a2_add_controls); | 356 | EXPORT_SYMBOL_GPL(tpa6130a2_add_controls); |
404 | 357 | ||
diff --git a/sound/soc/codecs/tpa6130a2.h b/sound/soc/codecs/tpa6130a2.h index 57e867fd86d1..5df49c8756b2 100644 --- a/sound/soc/codecs/tpa6130a2.h +++ b/sound/soc/codecs/tpa6130a2.h | |||
@@ -57,5 +57,6 @@ | |||
57 | #define TPA6130A2_VERSION_MASK (0x0f) | 57 | #define TPA6130A2_VERSION_MASK (0x0f) |
58 | 58 | ||
59 | extern int tpa6130a2_add_controls(struct snd_soc_codec *codec); | 59 | extern int tpa6130a2_add_controls(struct snd_soc_codec *codec); |
60 | extern int tpa6130a2_stereo_enable(struct snd_soc_codec *codec, int enable); | ||
60 | 61 | ||
61 | #endif /* __TPA6130A2_H__ */ | 62 | #endif /* __TPA6130A2_H__ */ |