Ben Dooks | 14412ac | 2009-08-20 22:50:40 +0100 | [diff] [blame] | 1 | /* sound/soc/s3c24xx/s3c24xx_simtec_tlv320aic23.c |
| 2 | * |
| 3 | * Copyright 2009 Simtec Electronics |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License version 2 as |
| 7 | * published by the Free Software Foundation. |
| 8 | */ |
| 9 | |
| 10 | #include <linux/module.h> |
| 11 | #include <linux/clk.h> |
| 12 | #include <linux/platform_device.h> |
| 13 | |
| 14 | #include <sound/core.h> |
| 15 | #include <sound/pcm.h> |
| 16 | #include <sound/soc.h> |
Ben Dooks | 14412ac | 2009-08-20 22:50:40 +0100 | [diff] [blame] | 17 | |
| 18 | #include <plat/audio-simtec.h> |
| 19 | |
Jassi Brar | d3ff5a3 | 2009-11-17 16:53:31 +0900 | [diff] [blame] | 20 | #include "s3c-dma.h" |
Ben Dooks | 14412ac | 2009-08-20 22:50:40 +0100 | [diff] [blame] | 21 | #include "s3c24xx-i2s.h" |
| 22 | #include "s3c24xx_simtec.h" |
| 23 | |
| 24 | #include "../codecs/tlv320aic23.h" |
| 25 | |
| 26 | /* supported machines: |
| 27 | * |
| 28 | * Machine Connections AMP |
| 29 | * ------- ----------- --- |
| 30 | * BAST MIC, HPOUT, LOUT, LIN TPA2001D1 (HPOUTL,R) (gain hardwired) |
| 31 | * VR1000 HPOUT, LIN None |
| 32 | * VR2000 LIN, LOUT, MIC, HP LM4871 (HPOUTL,R) |
| 33 | * DePicture LIN, LOUT, MIC, HP LM4871 (HPOUTL,R) |
| 34 | * Anubis LIN, LOUT, MIC, HP TPA2001D1 (HPOUTL,R) |
| 35 | */ |
| 36 | |
| 37 | static const struct snd_soc_dapm_widget dapm_widgets[] = { |
| 38 | SND_SOC_DAPM_HP("Headphone Jack", NULL), |
| 39 | SND_SOC_DAPM_LINE("Line In", NULL), |
| 40 | SND_SOC_DAPM_LINE("Line Out", NULL), |
| 41 | SND_SOC_DAPM_MIC("Mic Jack", NULL), |
| 42 | }; |
| 43 | |
| 44 | static const struct snd_soc_dapm_route base_map[] = { |
| 45 | { "Headphone Jack", NULL, "LHPOUT"}, |
| 46 | { "Headphone Jack", NULL, "RHPOUT"}, |
| 47 | |
| 48 | { "Line Out", NULL, "LOUT" }, |
| 49 | { "Line Out", NULL, "ROUT" }, |
| 50 | |
| 51 | { "LLINEIN", NULL, "Line In"}, |
| 52 | { "RLINEIN", NULL, "Line In"}, |
| 53 | |
| 54 | { "MICIN", NULL, "Mic Jack"}, |
| 55 | }; |
| 56 | |
| 57 | /** |
| 58 | * simtec_tlv320aic23_init - initialise and add controls |
| 59 | * @codec; The codec instance to attach to. |
| 60 | * |
| 61 | * Attach our controls and configure the necessary codec |
| 62 | * mappings for our sound card instance. |
| 63 | */ |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 64 | static int simtec_tlv320aic23_init(struct snd_soc_pcm_runtime *rtd) |
Ben Dooks | 14412ac | 2009-08-20 22:50:40 +0100 | [diff] [blame] | 65 | { |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 66 | struct snd_soc_codec *codec = rtd->codec; |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 67 | struct snd_soc_dapm_context *dapm = &codec->dapm; |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 68 | |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 69 | snd_soc_dapm_new_controls(dapm, dapm_widgets, |
Ben Dooks | 14412ac | 2009-08-20 22:50:40 +0100 | [diff] [blame] | 70 | ARRAY_SIZE(dapm_widgets)); |
| 71 | |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 72 | snd_soc_dapm_add_routes(dapm, base_map, ARRAY_SIZE(base_map)); |
Ben Dooks | 14412ac | 2009-08-20 22:50:40 +0100 | [diff] [blame] | 73 | |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 74 | snd_soc_dapm_enable_pin(dapm, "Headphone Jack"); |
| 75 | snd_soc_dapm_enable_pin(dapm, "Line In"); |
| 76 | snd_soc_dapm_enable_pin(dapm, "Line Out"); |
| 77 | snd_soc_dapm_enable_pin(dapm, "Mic Jack"); |
Ben Dooks | 14412ac | 2009-08-20 22:50:40 +0100 | [diff] [blame] | 78 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 79 | simtec_audio_init(rtd); |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 80 | snd_soc_dapm_sync(dapm); |
Ben Dooks | 14412ac | 2009-08-20 22:50:40 +0100 | [diff] [blame] | 81 | |
| 82 | return 0; |
| 83 | } |
| 84 | |
| 85 | static struct snd_soc_dai_link simtec_dai_aic23 = { |
| 86 | .name = "tlv320aic23", |
| 87 | .stream_name = "TLV320AIC23", |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 88 | .codec_name = "tlv320aic3x-codec.0-0x1a", |
| 89 | .cpu_dai_name = "s3c24xx-i2s", |
| 90 | .codec_dai_name = "tlv320aic3x-hifi", |
Jassi Brar | 58bb407 | 2010-11-22 15:35:50 +0900 | [diff] [blame^] | 91 | .platform_name = "samsung-audio", |
Ben Dooks | 14412ac | 2009-08-20 22:50:40 +0100 | [diff] [blame] | 92 | .init = simtec_tlv320aic23_init, |
| 93 | }; |
| 94 | |
| 95 | /* simtec audio machine driver */ |
| 96 | static struct snd_soc_card snd_soc_machine_simtec_aic23 = { |
| 97 | .name = "Simtec", |
Ben Dooks | 14412ac | 2009-08-20 22:50:40 +0100 | [diff] [blame] | 98 | .dai_link = &simtec_dai_aic23, |
| 99 | .num_links = 1, |
| 100 | }; |
| 101 | |
Ben Dooks | 14412ac | 2009-08-20 22:50:40 +0100 | [diff] [blame] | 102 | static int __devinit simtec_audio_tlv320aic23_probe(struct platform_device *pd) |
| 103 | { |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 104 | return simtec_audio_core_probe(pd, &snd_soc_machine_simtec_aic23); |
Ben Dooks | 14412ac | 2009-08-20 22:50:40 +0100 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | static struct platform_driver simtec_audio_tlv320aic23_platdrv = { |
| 108 | .driver = { |
| 109 | .owner = THIS_MODULE, |
| 110 | .name = "s3c24xx-simtec-tlv320aic23", |
| 111 | .pm = simtec_audio_pm, |
| 112 | }, |
| 113 | .probe = simtec_audio_tlv320aic23_probe, |
| 114 | .remove = __devexit_p(simtec_audio_remove), |
| 115 | }; |
| 116 | |
| 117 | MODULE_ALIAS("platform:s3c24xx-simtec-tlv320aic23"); |
| 118 | |
| 119 | static int __init simtec_tlv320aic23_modinit(void) |
| 120 | { |
| 121 | return platform_driver_register(&simtec_audio_tlv320aic23_platdrv); |
| 122 | } |
| 123 | |
| 124 | static void __exit simtec_tlv320aic23_modexit(void) |
| 125 | { |
| 126 | platform_driver_unregister(&simtec_audio_tlv320aic23_platdrv); |
| 127 | } |
| 128 | |
| 129 | module_init(simtec_tlv320aic23_modinit); |
| 130 | module_exit(simtec_tlv320aic23_modexit); |
| 131 | |
| 132 | MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>"); |
| 133 | MODULE_DESCRIPTION("ALSA SoC Simtec Audio support"); |
| 134 | MODULE_LICENSE("GPL"); |