diff options
author | Takashi Iwai <tiwai@suse.de> | 2010-05-20 06:00:43 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2010-05-20 06:00:43 -0400 |
commit | d71f4cece4bd97d05592836202fc04ff2e7817e3 (patch) | |
tree | 6c877c7a938758b1323d9c97d46b9c536e618c69 /sound/soc/omap | |
parent | 19008bdacb9f7841166ebafe0aef361ee582ffbf (diff) | |
parent | ad8332c1302bcb4f80d593fd3eb477be9d7f5604 (diff) |
Merge branch 'topic/asoc' into for-linus
Conflicts:
sound/soc/codecs/ad1938.c
Diffstat (limited to 'sound/soc/omap')
-rw-r--r-- | sound/soc/omap/Kconfig | 19 | ||||
-rw-r--r-- | sound/soc/omap/Makefile | 4 | ||||
-rw-r--r-- | sound/soc/omap/mcpdm.c | 548 | ||||
-rw-r--r-- | sound/soc/omap/omap-mcbsp.c | 66 | ||||
-rw-r--r-- | sound/soc/omap/omap3pandora.c | 2 | ||||
-rw-r--r-- | sound/soc/omap/rx51.c | 294 | ||||
-rw-r--r-- | sound/soc/omap/sdp4430.c | 233 | ||||
-rw-r--r-- | sound/soc/omap/zoom2.c | 3 |
8 files changed, 885 insertions, 284 deletions
diff --git a/sound/soc/omap/Kconfig b/sound/soc/omap/Kconfig index f11963c2187..d542ea2ff6b 100644 --- a/sound/soc/omap/Kconfig +++ b/sound/soc/omap/Kconfig | |||
@@ -18,6 +18,16 @@ config SND_OMAP_SOC_N810 | |||
18 | help | 18 | help |
19 | Say Y if you want to add support for SoC audio on Nokia N810. | 19 | Say Y if you want to add support for SoC audio on Nokia N810. |
20 | 20 | ||
21 | config SND_OMAP_SOC_RX51 | ||
22 | tristate "SoC Audio support for Nokia RX-51" | ||
23 | depends on SND_OMAP_SOC && MACH_NOKIA_RX51 | ||
24 | select OMAP_MCBSP | ||
25 | select SND_OMAP_SOC_MCBSP | ||
26 | select SND_SOC_TLV320AIC3X | ||
27 | help | ||
28 | Say Y if you want to add support for SoC audio on Nokia RX-51 | ||
29 | hardware. This is also known as Nokia N900 product. | ||
30 | |||
21 | config SND_OMAP_SOC_AMS_DELTA | 31 | config SND_OMAP_SOC_AMS_DELTA |
22 | tristate "SoC Audio support for Amstrad E3 (Delta) videophone" | 32 | tristate "SoC Audio support for Amstrad E3 (Delta) videophone" |
23 | depends on SND_OMAP_SOC && MACH_AMS_DELTA | 33 | depends on SND_OMAP_SOC && MACH_AMS_DELTA |
@@ -88,6 +98,15 @@ config SND_OMAP_SOC_SDP3430 | |||
88 | Say Y if you want to add support for SoC audio on Texas Instruments | 98 | Say Y if you want to add support for SoC audio on Texas Instruments |
89 | SDP3430. | 99 | SDP3430. |
90 | 100 | ||
101 | config SND_OMAP_SOC_SDP4430 | ||
102 | tristate "SoC Audio support for Texas Instruments SDP4430" | ||
103 | depends on TWL4030_CORE && SND_OMAP_SOC && MACH_OMAP_4430SDP | ||
104 | select SND_OMAP_SOC_MCPDM | ||
105 | select SND_SOC_TWL6040 | ||
106 | help | ||
107 | Say Y if you want to add support for SoC audio on Texas Instruments | ||
108 | SDP4430. | ||
109 | |||
91 | config SND_OMAP_SOC_OMAP3_PANDORA | 110 | config SND_OMAP_SOC_OMAP3_PANDORA |
92 | tristate "SoC Audio support for OMAP3 Pandora" | 111 | tristate "SoC Audio support for OMAP3 Pandora" |
93 | depends on TWL4030_CORE && SND_OMAP_SOC && MACH_OMAP3_PANDORA | 112 | depends on TWL4030_CORE && SND_OMAP_SOC && MACH_OMAP3_PANDORA |
diff --git a/sound/soc/omap/Makefile b/sound/soc/omap/Makefile index 0bc00ca14b3..ba9fc650db2 100644 --- a/sound/soc/omap/Makefile +++ b/sound/soc/omap/Makefile | |||
@@ -9,6 +9,7 @@ obj-$(CONFIG_SND_OMAP_SOC_MCPDM) += snd-soc-omap-mcpdm.o | |||
9 | 9 | ||
10 | # OMAP Machine Support | 10 | # OMAP Machine Support |
11 | snd-soc-n810-objs := n810.o | 11 | snd-soc-n810-objs := n810.o |
12 | snd-soc-rx51-objs := rx51.o | ||
12 | snd-soc-ams-delta-objs := ams-delta.o | 13 | snd-soc-ams-delta-objs := ams-delta.o |
13 | snd-soc-osk5912-objs := osk5912.o | 14 | snd-soc-osk5912-objs := osk5912.o |
14 | snd-soc-overo-objs := overo.o | 15 | snd-soc-overo-objs := overo.o |
@@ -16,12 +17,14 @@ snd-soc-omap2evm-objs := omap2evm.o | |||
16 | snd-soc-omap3evm-objs := omap3evm.o | 17 | snd-soc-omap3evm-objs := omap3evm.o |
17 | snd-soc-am3517evm-objs := am3517evm.o | 18 | snd-soc-am3517evm-objs := am3517evm.o |
18 | snd-soc-sdp3430-objs := sdp3430.o | 19 | snd-soc-sdp3430-objs := sdp3430.o |
20 | snd-soc-sdp4430-objs := sdp4430.o | ||
19 | snd-soc-omap3pandora-objs := omap3pandora.o | 21 | snd-soc-omap3pandora-objs := omap3pandora.o |
20 | snd-soc-omap3beagle-objs := omap3beagle.o | 22 | snd-soc-omap3beagle-objs := omap3beagle.o |
21 | snd-soc-zoom2-objs := zoom2.o | 23 | snd-soc-zoom2-objs := zoom2.o |
22 | snd-soc-igep0020-objs := igep0020.o | 24 | snd-soc-igep0020-objs := igep0020.o |
23 | 25 | ||
24 | obj-$(CONFIG_SND_OMAP_SOC_N810) += snd-soc-n810.o | 26 | obj-$(CONFIG_SND_OMAP_SOC_N810) += snd-soc-n810.o |
27 | obj-$(CONFIG_SND_OMAP_SOC_RX51) += snd-soc-rx51.o | ||
25 | obj-$(CONFIG_SND_OMAP_SOC_AMS_DELTA) += snd-soc-ams-delta.o | 28 | obj-$(CONFIG_SND_OMAP_SOC_AMS_DELTA) += snd-soc-ams-delta.o |
26 | obj-$(CONFIG_SND_OMAP_SOC_OSK5912) += snd-soc-osk5912.o | 29 | obj-$(CONFIG_SND_OMAP_SOC_OSK5912) += snd-soc-osk5912.o |
27 | obj-$(CONFIG_SND_OMAP_SOC_OVERO) += snd-soc-overo.o | 30 | obj-$(CONFIG_SND_OMAP_SOC_OVERO) += snd-soc-overo.o |
@@ -29,6 +32,7 @@ obj-$(CONFIG_SND_OMAP_SOC_OMAP2EVM) += snd-soc-omap2evm.o | |||
29 | obj-$(CONFIG_SND_OMAP_SOC_OMAP3EVM) += snd-soc-omap3evm.o | 32 | obj-$(CONFIG_SND_OMAP_SOC_OMAP3EVM) += snd-soc-omap3evm.o |
30 | obj-$(CONFIG_SND_OMAP_SOC_AM3517EVM) += snd-soc-am3517evm.o | 33 | obj-$(CONFIG_SND_OMAP_SOC_AM3517EVM) += snd-soc-am3517evm.o |
31 | obj-$(CONFIG_SND_OMAP_SOC_SDP3430) += snd-soc-sdp3430.o | 34 | obj-$(CONFIG_SND_OMAP_SOC_SDP3430) += snd-soc-sdp3430.o |
35 | obj-$(CONFIG_SND_OMAP_SOC_SDP4430) += snd-soc-sdp4430.o | ||
32 | obj-$(CONFIG_SND_OMAP_SOC_OMAP3_PANDORA) += snd-soc-omap3pandora.o | 36 | obj-$(CONFIG_SND_OMAP_SOC_OMAP3_PANDORA) += snd-soc-omap3pandora.o |
33 | obj-$(CONFIG_SND_OMAP_SOC_OMAP3_BEAGLE) += snd-soc-omap3beagle.o | 37 | obj-$(CONFIG_SND_OMAP_SOC_OMAP3_BEAGLE) += snd-soc-omap3beagle.o |
34 | obj-$(CONFIG_SND_OMAP_SOC_ZOOM2) += snd-soc-zoom2.o | 38 | obj-$(CONFIG_SND_OMAP_SOC_ZOOM2) += snd-soc-zoom2.o |
diff --git a/sound/soc/omap/mcpdm.c b/sound/soc/omap/mcpdm.c index 1dab4c14874..90b8bf71c89 100644 --- a/sound/soc/omap/mcpdm.c +++ b/sound/soc/omap/mcpdm.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * mcpdm.c -- McPDM interface driver | 2 | * mcpdm.c -- McPDM interface driver |
3 | * | 3 | * |
4 | * Author: Jorge Eduardo Candelaria <x0107209@ti.com> | 4 | * Author: Jorge Eduardo Candelaria <x0107209@ti.com> |
5 | * Copyright (C) 2009 - Texas Instruments, Inc. | 5 | * Copyright (C) 2009 - Texas Instruments, Inc. |
@@ -39,46 +39,46 @@ static struct omap_mcpdm *mcpdm; | |||
39 | 39 | ||
40 | static inline void omap_mcpdm_write(u16 reg, u32 val) | 40 | static inline void omap_mcpdm_write(u16 reg, u32 val) |
41 | { | 41 | { |
42 | __raw_writel(val, mcpdm->io_base + reg); | 42 | __raw_writel(val, mcpdm->io_base + reg); |
43 | } | 43 | } |
44 | 44 | ||
45 | static inline int omap_mcpdm_read(u16 reg) | 45 | static inline int omap_mcpdm_read(u16 reg) |
46 | { | 46 | { |
47 | return __raw_readl(mcpdm->io_base + reg); | 47 | return __raw_readl(mcpdm->io_base + reg); |
48 | } | 48 | } |
49 | 49 | ||
50 | static void omap_mcpdm_reg_dump(void) | 50 | static void omap_mcpdm_reg_dump(void) |
51 | { | 51 | { |
52 | dev_dbg(mcpdm->dev, "***********************\n"); | 52 | dev_dbg(mcpdm->dev, "***********************\n"); |
53 | dev_dbg(mcpdm->dev, "IRQSTATUS_RAW: 0x%04x\n", | 53 | dev_dbg(mcpdm->dev, "IRQSTATUS_RAW: 0x%04x\n", |
54 | omap_mcpdm_read(MCPDM_IRQSTATUS_RAW)); | 54 | omap_mcpdm_read(MCPDM_IRQSTATUS_RAW)); |
55 | dev_dbg(mcpdm->dev, "IRQSTATUS: 0x%04x\n", | 55 | dev_dbg(mcpdm->dev, "IRQSTATUS: 0x%04x\n", |
56 | omap_mcpdm_read(MCPDM_IRQSTATUS)); | 56 | omap_mcpdm_read(MCPDM_IRQSTATUS)); |
57 | dev_dbg(mcpdm->dev, "IRQENABLE_SET: 0x%04x\n", | 57 | dev_dbg(mcpdm->dev, "IRQENABLE_SET: 0x%04x\n", |
58 | omap_mcpdm_read(MCPDM_IRQENABLE_SET)); | 58 | omap_mcpdm_read(MCPDM_IRQENABLE_SET)); |
59 | dev_dbg(mcpdm->dev, "IRQENABLE_CLR: 0x%04x\n", | 59 | dev_dbg(mcpdm->dev, "IRQENABLE_CLR: 0x%04x\n", |
60 | omap_mcpdm_read(MCPDM_IRQENABLE_CLR)); | 60 | omap_mcpdm_read(MCPDM_IRQENABLE_CLR)); |
61 | dev_dbg(mcpdm->dev, "IRQWAKE_EN: 0x%04x\n", | 61 | dev_dbg(mcpdm->dev, "IRQWAKE_EN: 0x%04x\n", |
62 | omap_mcpdm_read(MCPDM_IRQWAKE_EN)); | 62 | omap_mcpdm_read(MCPDM_IRQWAKE_EN)); |
63 | dev_dbg(mcpdm->dev, "DMAENABLE_SET: 0x%04x\n", | 63 | dev_dbg(mcpdm->dev, "DMAENABLE_SET: 0x%04x\n", |
64 | omap_mcpdm_read(MCPDM_DMAENABLE_SET)); | 64 | omap_mcpdm_read(MCPDM_DMAENABLE_SET)); |
65 | dev_dbg(mcpdm->dev, "DMAENABLE_CLR: 0x%04x\n", | 65 | dev_dbg(mcpdm->dev, "DMAENABLE_CLR: 0x%04x\n", |
66 | omap_mcpdm_read(MCPDM_DMAENABLE_CLR)); | 66 | omap_mcpdm_read(MCPDM_DMAENABLE_CLR)); |
67 | dev_dbg(mcpdm->dev, "DMAWAKEEN: 0x%04x\n", | 67 | dev_dbg(mcpdm->dev, "DMAWAKEEN: 0x%04x\n", |
68 | omap_mcpdm_read(MCPDM_DMAWAKEEN)); | 68 | omap_mcpdm_read(MCPDM_DMAWAKEEN)); |
69 | dev_dbg(mcpdm->dev, "CTRL: 0x%04x\n", | 69 | dev_dbg(mcpdm->dev, "CTRL: 0x%04x\n", |
70 | omap_mcpdm_read(MCPDM_CTRL)); | 70 | omap_mcpdm_read(MCPDM_CTRL)); |
71 | dev_dbg(mcpdm->dev, "DN_DATA: 0x%04x\n", | 71 | dev_dbg(mcpdm->dev, "DN_DATA: 0x%04x\n", |
72 | omap_mcpdm_read(MCPDM_DN_DATA)); | 72 | omap_mcpdm_read(MCPDM_DN_DATA)); |
73 | dev_dbg(mcpdm->dev, "UP_DATA: 0x%04x\n", | 73 | dev_dbg(mcpdm->dev, "UP_DATA: 0x%04x\n", |
74 | omap_mcpdm_read(MCPDM_UP_DATA)); | 74 | omap_mcpdm_read(MCPDM_UP_DATA)); |
75 | dev_dbg(mcpdm->dev, "FIFO_CTRL_DN: 0x%04x\n", | 75 | dev_dbg(mcpdm->dev, "FIFO_CTRL_DN: 0x%04x\n", |
76 | omap_mcpdm_read(MCPDM_FIFO_CTRL_DN)); | 76 | omap_mcpdm_read(MCPDM_FIFO_CTRL_DN)); |
77 | dev_dbg(mcpdm->dev, "FIFO_CTRL_UP: 0x%04x\n", | 77 | dev_dbg(mcpdm->dev, "FIFO_CTRL_UP: 0x%04x\n", |
78 | omap_mcpdm_read(MCPDM_FIFO_CTRL_UP)); | 78 | omap_mcpdm_read(MCPDM_FIFO_CTRL_UP)); |
79 | dev_dbg(mcpdm->dev, "DN_OFFSET: 0x%04x\n", | 79 | dev_dbg(mcpdm->dev, "DN_OFFSET: 0x%04x\n", |
80 | omap_mcpdm_read(MCPDM_DN_OFFSET)); | 80 | omap_mcpdm_read(MCPDM_DN_OFFSET)); |
81 | dev_dbg(mcpdm->dev, "***********************\n"); | 81 | dev_dbg(mcpdm->dev, "***********************\n"); |
82 | } | 82 | } |
83 | 83 | ||
84 | /* | 84 | /* |
@@ -87,26 +87,26 @@ static void omap_mcpdm_reg_dump(void) | |||
87 | */ | 87 | */ |
88 | static void omap_mcpdm_reset_capture(int reset) | 88 | static void omap_mcpdm_reset_capture(int reset) |
89 | { | 89 | { |
90 | int ctrl = omap_mcpdm_read(MCPDM_CTRL); | 90 | int ctrl = omap_mcpdm_read(MCPDM_CTRL); |
91 | 91 | ||
92 | if (reset) | 92 | if (reset) |
93 | ctrl |= SW_UP_RST; | 93 | ctrl |= SW_UP_RST; |
94 | else | 94 | else |
95 | ctrl &= ~SW_UP_RST; | 95 | ctrl &= ~SW_UP_RST; |
96 | 96 | ||
97 | omap_mcpdm_write(MCPDM_CTRL, ctrl); | 97 | omap_mcpdm_write(MCPDM_CTRL, ctrl); |
98 | } | 98 | } |
99 | 99 | ||
100 | static void omap_mcpdm_reset_playback(int reset) | 100 | static void omap_mcpdm_reset_playback(int reset) |
101 | { | 101 | { |
102 | int ctrl = omap_mcpdm_read(MCPDM_CTRL); | 102 | int ctrl = omap_mcpdm_read(MCPDM_CTRL); |
103 | 103 | ||
104 | if (reset) | 104 | if (reset) |
105 | ctrl |= SW_DN_RST; | 105 | ctrl |= SW_DN_RST; |
106 | else | 106 | else |
107 | ctrl &= ~SW_DN_RST; | 107 | ctrl &= ~SW_DN_RST; |
108 | 108 | ||
109 | omap_mcpdm_write(MCPDM_CTRL, ctrl); | 109 | omap_mcpdm_write(MCPDM_CTRL, ctrl); |
110 | } | 110 | } |
111 | 111 | ||
112 | /* | 112 | /* |
@@ -115,14 +115,14 @@ static void omap_mcpdm_reset_playback(int reset) | |||
115 | */ | 115 | */ |
116 | void omap_mcpdm_start(int stream) | 116 | void omap_mcpdm_start(int stream) |
117 | { | 117 | { |
118 | int ctrl = omap_mcpdm_read(MCPDM_CTRL); | 118 | int ctrl = omap_mcpdm_read(MCPDM_CTRL); |
119 | 119 | ||
120 | if (stream) | 120 | if (stream) |
121 | ctrl |= mcpdm->up_channels; | 121 | ctrl |= mcpdm->up_channels; |
122 | else | 122 | else |
123 | ctrl |= mcpdm->dn_channels; | 123 | ctrl |= mcpdm->dn_channels; |
124 | 124 | ||
125 | omap_mcpdm_write(MCPDM_CTRL, ctrl); | 125 | omap_mcpdm_write(MCPDM_CTRL, ctrl); |
126 | } | 126 | } |
127 | 127 | ||
128 | /* | 128 | /* |
@@ -131,14 +131,14 @@ void omap_mcpdm_start(int stream) | |||
131 | */ | 131 | */ |
132 | void omap_mcpdm_stop(int stream) | 132 | void omap_mcpdm_stop(int stream) |
133 | { | 133 | { |
134 | int ctrl = omap_mcpdm_read(MCPDM_CTRL); | 134 | int ctrl = omap_mcpdm_read(MCPDM_CTRL); |
135 | 135 | ||
136 | if (stream) | 136 | if (stream) |
137 | ctrl &= ~mcpdm->up_channels; | 137 | ctrl &= ~mcpdm->up_channels; |
138 | else | 138 | else |
139 | ctrl &= ~mcpdm->dn_channels; | 139 | ctrl &= ~mcpdm->dn_channels; |
140 | 140 | ||
141 | omap_mcpdm_write(MCPDM_CTRL, ctrl); | 141 | omap_mcpdm_write(MCPDM_CTRL, ctrl); |
142 | } | 142 | } |
143 | 143 | ||
144 | /* | 144 | /* |
@@ -147,38 +147,38 @@ void omap_mcpdm_stop(int stream) | |||
147 | */ | 147 | */ |
148 | int omap_mcpdm_capture_open(struct omap_mcpdm_link *uplink) | 148 | int omap_mcpdm_capture_open(struct omap_mcpdm_link *uplink) |
149 | { | 149 | { |
150 | int irq_mask = 0; | 150 | int irq_mask = 0; |
151 | int ctrl; | 151 | int ctrl; |
152 | 152 | ||
153 | if (!uplink) | 153 | if (!uplink) |
154 | return -EINVAL; | 154 | return -EINVAL; |
155 | 155 | ||
156 | mcpdm->uplink = uplink; | 156 | mcpdm->uplink = uplink; |
157 | 157 | ||
158 | /* Enable irq request generation */ | 158 | /* Enable irq request generation */ |
159 | irq_mask |= uplink->irq_mask & MCPDM_UPLINK_IRQ_MASK; | 159 | irq_mask |= uplink->irq_mask & MCPDM_UPLINK_IRQ_MASK; |
160 | omap_mcpdm_write(MCPDM_IRQENABLE_SET, irq_mask); | 160 | omap_mcpdm_write(MCPDM_IRQENABLE_SET, irq_mask); |
161 | 161 | ||
162 | /* Configure uplink threshold */ | 162 | /* Configure uplink threshold */ |
163 | if (uplink->threshold > UP_THRES_MAX) | 163 | if (uplink->threshold > UP_THRES_MAX) |
164 | uplink->threshold = UP_THRES_MAX; | 164 | uplink->threshold = UP_THRES_MAX; |
165 | 165 | ||
166 | omap_mcpdm_write(MCPDM_FIFO_CTRL_UP, uplink->threshold); | 166 | omap_mcpdm_write(MCPDM_FIFO_CTRL_UP, uplink->threshold); |
167 | 167 | ||
168 | /* Configure DMA controller */ | 168 | /* Configure DMA controller */ |
169 | omap_mcpdm_write(MCPDM_DMAENABLE_SET, DMA_UP_ENABLE); | 169 | omap_mcpdm_write(MCPDM_DMAENABLE_SET, DMA_UP_ENABLE); |
170 | 170 | ||
171 | /* Set pdm out format */ | 171 | /* Set pdm out format */ |
172 | ctrl = omap_mcpdm_read(MCPDM_CTRL); | 172 | ctrl = omap_mcpdm_read(MCPDM_CTRL); |
173 | ctrl &= ~PDMOUTFORMAT; | 173 | ctrl &= ~PDMOUTFORMAT; |
174 | ctrl |= uplink->format & PDMOUTFORMAT; | 174 | ctrl |= uplink->format & PDMOUTFORMAT; |
175 | 175 | ||
176 | /* Uplink channels */ | 176 | /* Uplink channels */ |
177 | mcpdm->up_channels = uplink->channels & (PDM_UP_MASK | PDM_STATUS_MASK); | 177 | mcpdm->up_channels = uplink->channels & (PDM_UP_MASK | PDM_STATUS_MASK); |
178 | 178 | ||
179 | omap_mcpdm_write(MCPDM_CTRL, ctrl); | 179 | omap_mcpdm_write(MCPDM_CTRL, ctrl); |
180 | 180 | ||
181 | return 0; | 181 | return 0; |
182 | } | 182 | } |
183 | 183 | ||
184 | /* | 184 | /* |
@@ -187,38 +187,38 @@ int omap_mcpdm_capture_open(struct omap_mcpdm_link *uplink) | |||
187 | */ | 187 | */ |
188 | int omap_mcpdm_playback_open(struct omap_mcpdm_link *downlink) | 188 | int omap_mcpdm_playback_open(struct omap_mcpdm_link *downlink) |
189 | { | 189 | { |
190 | int irq_mask = 0; | 190 | int irq_mask = 0; |
191 | int ctrl; | 191 | int ctrl; |
192 | 192 | ||
193 | if (!downlink) | 193 | if (!downlink) |
194 | return -EINVAL; | 194 | return -EINVAL; |
195 | 195 | ||
196 | mcpdm->downlink = downlink; | 196 | mcpdm->downlink = downlink; |
197 | 197 | ||
198 | /* Enable irq request generation */ | 198 | /* Enable irq request generation */ |
199 | irq_mask |= downlink->irq_mask & MCPDM_DOWNLINK_IRQ_MASK; | 199 | irq_mask |= downlink->irq_mask & MCPDM_DOWNLINK_IRQ_MASK; |
200 | omap_mcpdm_write(MCPDM_IRQENABLE_SET, irq_mask); | 200 | omap_mcpdm_write(MCPDM_IRQENABLE_SET, irq_mask); |
201 | 201 | ||
202 | /* Configure uplink threshold */ | 202 | /* Configure uplink threshold */ |
203 | if (downlink->threshold > DN_THRES_MAX) | 203 | if (downlink->threshold > DN_THRES_MAX) |
204 | downlink->threshold = DN_THRES_MAX; | 204 | downlink->threshold = DN_THRES_MAX; |
205 | 205 | ||
206 | omap_mcpdm_write(MCPDM_FIFO_CTRL_DN, downlink->threshold); | 206 | omap_mcpdm_write(MCPDM_FIFO_CTRL_DN, downlink->threshold); |
207 | 207 | ||
208 | /* Enable DMA request generation */ | 208 | /* Enable DMA request generation */ |
209 | omap_mcpdm_write(MCPDM_DMAENABLE_SET, DMA_DN_ENABLE); | 209 | omap_mcpdm_write(MCPDM_DMAENABLE_SET, DMA_DN_ENABLE); |
210 | 210 | ||
211 | /* Set pdm out format */ | 211 | /* Set pdm out format */ |
212 | ctrl = omap_mcpdm_read(MCPDM_CTRL); | 212 | ctrl = omap_mcpdm_read(MCPDM_CTRL); |
213 | ctrl &= ~PDMOUTFORMAT; | 213 | ctrl &= ~PDMOUTFORMAT; |
214 | ctrl |= downlink->format & PDMOUTFORMAT; | 214 | ctrl |= downlink->format & PDMOUTFORMAT; |
215 | 215 | ||
216 | /* Downlink channels */ | 216 | /* Downlink channels */ |
217 | mcpdm->dn_channels = downlink->channels & (PDM_DN_MASK | PDM_CMD_MASK); | 217 | mcpdm->dn_channels = downlink->channels & (PDM_DN_MASK | PDM_CMD_MASK); |
218 | 218 | ||
219 | omap_mcpdm_write(MCPDM_CTRL, ctrl); | 219 | omap_mcpdm_write(MCPDM_CTRL, ctrl); |
220 | 220 | ||
221 | return 0; | 221 | return 0; |
222 | } | 222 | } |
223 | 223 | ||
224 | /* | 224 | /* |
@@ -227,24 +227,24 @@ int omap_mcpdm_playback_open(struct omap_mcpdm_link *downlink) | |||
227 | */ | 227 | */ |
228 | int omap_mcpdm_capture_close(struct omap_mcpdm_link *uplink) | 228 | int omap_mcpdm_capture_close(struct omap_mcpdm_link *uplink) |
229 | { | 229 | { |
230 | int irq_mask = 0; | 230 | int irq_mask = 0; |
231 | 231 | ||
232 | if (!uplink) | 232 | if (!uplink) |
233 | return -EINVAL; | 233 | return -EINVAL; |
234 | 234 | ||
235 | /* Disable irq request generation */ | 235 | /* Disable irq request generation */ |
236 | irq_mask |= uplink->irq_mask & MCPDM_UPLINK_IRQ_MASK; | 236 | irq_mask |= uplink->irq_mask & MCPDM_UPLINK_IRQ_MASK; |
237 | omap_mcpdm_write(MCPDM_IRQENABLE_CLR, irq_mask); | 237 | omap_mcpdm_write(MCPDM_IRQENABLE_CLR, irq_mask); |
238 | 238 | ||
239 | /* Disable DMA request generation */ | 239 | /* Disable DMA request generation */ |
240 | omap_mcpdm_write(MCPDM_DMAENABLE_CLR, DMA_UP_ENABLE); | 240 | omap_mcpdm_write(MCPDM_DMAENABLE_CLR, DMA_UP_ENABLE); |
241 | 241 | ||
242 | /* Clear Downlink channels */ | 242 | /* Clear Downlink channels */ |
243 | mcpdm->up_channels = 0; | 243 | mcpdm->up_channels = 0; |
244 | 244 | ||
245 | mcpdm->uplink = NULL; | 245 | mcpdm->uplink = NULL; |
246 | 246 | ||
247 | return 0; | 247 | return 0; |
248 | } | 248 | } |
249 | 249 | ||
250 | /* | 250 | /* |
@@ -253,124 +253,124 @@ int omap_mcpdm_capture_close(struct omap_mcpdm_link *uplink) | |||
253 | */ | 253 | */ |
254 | int omap_mcpdm_playback_close(struct omap_mcpdm_link *downlink) | 254 | int omap_mcpdm_playback_close(struct omap_mcpdm_link *downlink) |
255 | { | 255 | { |
256 | int irq_mask = 0; | 256 | int irq_mask = 0; |
257 | 257 | ||
258 | if (!downlink) | 258 | if (!downlink) |
259 | return -EINVAL; | 259 | return -EINVAL; |
260 | 260 | ||
261 | /* Disable irq request generation */ | 261 | /* Disable irq request generation */ |
262 | irq_mask |= downlink->irq_mask & MCPDM_DOWNLINK_IRQ_MASK; | 262 | irq_mask |= downlink->irq_mask & MCPDM_DOWNLINK_IRQ_MASK; |
263 | omap_mcpdm_write(MCPDM_IRQENABLE_CLR, irq_mask); | 263 | omap_mcpdm_write(MCPDM_IRQENABLE_CLR, irq_mask); |
264 | 264 | ||
265 | /* Disable DMA request generation */ | 265 | /* Disable DMA request generation */ |
266 | omap_mcpdm_write(MCPDM_DMAENABLE_CLR, DMA_DN_ENABLE); | 266 | omap_mcpdm_write(MCPDM_DMAENABLE_CLR, DMA_DN_ENABLE); |
267 | 267 | ||
268 | /* clear Downlink channels */ | 268 | /* clear Downlink channels */ |
269 | mcpdm->dn_channels = 0; | 269 | mcpdm->dn_channels = 0; |
270 | 270 | ||
271 | mcpdm->downlink = NULL; | 271 | mcpdm->downlink = NULL; |
272 | 272 | ||
273 | return 0; | 273 | return 0; |
274 | } | 274 | } |
275 | 275 | ||
276 | static irqreturn_t omap_mcpdm_irq_handler(int irq, void *dev_id) | 276 | static irqreturn_t omap_mcpdm_irq_handler(int irq, void *dev_id) |
277 | { | 277 | { |
278 | struct omap_mcpdm *mcpdm_irq = dev_id; | 278 | struct omap_mcpdm *mcpdm_irq = dev_id; |
279 | int irq_status; | 279 | int irq_status; |
280 | 280 | ||
281 | irq_status = omap_mcpdm_read(MCPDM_IRQSTATUS); | 281 | irq_status = omap_mcpdm_read(MCPDM_IRQSTATUS); |
282 | 282 | ||
283 | /* Acknowledge irq event */ | 283 | /* Acknowledge irq event */ |
284 | omap_mcpdm_write(MCPDM_IRQSTATUS, irq_status); | 284 | omap_mcpdm_write(MCPDM_IRQSTATUS, irq_status); |
285 | 285 | ||
286 | if (irq & MCPDM_DN_IRQ_FULL) { | 286 | if (irq & MCPDM_DN_IRQ_FULL) { |
287 | dev_err(mcpdm_irq->dev, "DN FIFO error %x\n", irq_status); | 287 | dev_err(mcpdm_irq->dev, "DN FIFO error %x\n", irq_status); |
288 | omap_mcpdm_reset_playback(1); | 288 | omap_mcpdm_reset_playback(1); |
289 | omap_mcpdm_playback_open(mcpdm_irq->downlink); | 289 | omap_mcpdm_playback_open(mcpdm_irq->downlink); |
290 | omap_mcpdm_reset_playback(0); | 290 | omap_mcpdm_reset_playback(0); |
291 | } | 291 | } |
292 | 292 | ||
293 | if (irq & MCPDM_DN_IRQ_EMPTY) { | 293 | if (irq & MCPDM_DN_IRQ_EMPTY) { |
294 | dev_err(mcpdm_irq->dev, "DN FIFO error %x\n", irq_status); | 294 | dev_err(mcpdm_irq->dev, "DN FIFO error %x\n", irq_status); |
295 | omap_mcpdm_reset_playback(1); | 295 | omap_mcpdm_reset_playback(1); |
296 | omap_mcpdm_playback_open(mcpdm_irq->downlink); | 296 | omap_mcpdm_playback_open(mcpdm_irq->downlink); |
297 | omap_mcpdm_reset_playback(0); | 297 | omap_mcpdm_reset_playback(0); |
298 | } | 298 | } |
299 | 299 | ||
300 | if (irq & MCPDM_DN_IRQ) { | 300 | if (irq & MCPDM_DN_IRQ) { |
301 | dev_dbg(mcpdm_irq->dev, "DN write request\n"); | 301 | dev_dbg(mcpdm_irq->dev, "DN write request\n"); |
302 | } | 302 | } |
303 | 303 | ||
304 | if (irq & MCPDM_UP_IRQ_FULL) { | 304 | if (irq & MCPDM_UP_IRQ_FULL) { |
305 | dev_err(mcpdm_irq->dev, "UP FIFO error %x\n", irq_status); | 305 | dev_err(mcpdm_irq->dev, "UP FIFO error %x\n", irq_status); |
306 | omap_mcpdm_reset_capture(1); | 306 | omap_mcpdm_reset_capture(1); |
307 | omap_mcpdm_capture_open(mcpdm_irq->uplink); | 307 | omap_mcpdm_capture_open(mcpdm_irq->uplink); |
308 | omap_mcpdm_reset_capture(0); | 308 | omap_mcpdm_reset_capture(0); |
309 | } | 309 | } |
310 | 310 | ||
311 | if (irq & MCPDM_UP_IRQ_EMPTY) { | 311 | if (irq & MCPDM_UP_IRQ_EMPTY) { |
312 | dev_err(mcpdm_irq->dev, "UP FIFO error %x\n", irq_status); | 312 | dev_err(mcpdm_irq->dev, "UP FIFO error %x\n", irq_status); |
313 | omap_mcpdm_reset_capture(1); | 313 | omap_mcpdm_reset_capture(1); |
314 | omap_mcpdm_capture_open(mcpdm_irq->uplink); | 314 | omap_mcpdm_capture_open(mcpdm_irq->uplink); |
315 | omap_mcpdm_reset_capture(0); | 315 | omap_mcpdm_reset_capture(0); |
316 | } | 316 | } |
317 | 317 | ||
318 | if (irq & MCPDM_UP_IRQ) { | 318 | if (irq & MCPDM_UP_IRQ) { |
319 | dev_dbg(mcpdm_irq->dev, "UP write request\n"); | 319 | dev_dbg(mcpdm_irq->dev, "UP write request\n"); |
320 | } | 320 | } |
321 | 321 | ||
322 | return IRQ_HANDLED; | 322 | return IRQ_HANDLED; |
323 | } | 323 | } |
324 | 324 | ||
325 | int omap_mcpdm_request(void) | 325 | int omap_mcpdm_request(void) |
326 | { | 326 | { |
327 | int ret; | 327 | int ret; |
328 | 328 | ||
329 | clk_enable(mcpdm->clk); | 329 | clk_enable(mcpdm->clk); |
330 | 330 | ||
331 | spin_lock(&mcpdm->lock); | 331 | spin_lock(&mcpdm->lock); |
332 | 332 | ||
333 | if (!mcpdm->free) { | 333 | if (!mcpdm->free) { |
334 | dev_err(mcpdm->dev, "McPDM interface is in use\n"); | 334 | dev_err(mcpdm->dev, "McPDM interface is in use\n"); |
335 | spin_unlock(&mcpdm->lock); | 335 | spin_unlock(&mcpdm->lock); |
336 | ret = -EBUSY; | 336 | ret = -EBUSY; |
337 | goto err; | 337 | goto err; |
338 | } | 338 | } |
339 | mcpdm->free = 0; | 339 | mcpdm->free = 0; |
340 | 340 | ||
341 | spin_unlock(&mcpdm->lock); | 341 | spin_unlock(&mcpdm->lock); |
342 | 342 | ||
343 | /* Disable lines while request is ongoing */ | 343 | /* Disable lines while request is ongoing */ |
344 | omap_mcpdm_write(MCPDM_CTRL, 0x00); | 344 | omap_mcpdm_write(MCPDM_CTRL, 0x00); |
345 | 345 | ||
346 | ret = request_irq(mcpdm->irq, omap_mcpdm_irq_handler, | 346 | ret = request_irq(mcpdm->irq, omap_mcpdm_irq_handler, |
347 | 0, "McPDM", (void *)mcpdm); | 347 | 0, "McPDM", (void *)mcpdm); |
348 | if (ret) { | 348 | if (ret) { |
349 | dev_err(mcpdm->dev, "Request for McPDM IRQ failed\n"); | 349 | dev_err(mcpdm->dev, "Request for McPDM IRQ failed\n"); |
350 | goto err; | 350 | goto err; |
351 | } | 351 | } |
352 | 352 | ||
353 | return 0; | 353 | return 0; |
354 | 354 | ||
355 | err: | 355 | err: |
356 | clk_disable(mcpdm->clk); | 356 | clk_disable(mcpdm->clk); |
357 | return ret; | 357 | return ret; |
358 | } | 358 | } |
359 | 359 | ||
360 | void omap_mcpdm_free(void) | 360 | void omap_mcpdm_free(void) |
361 | { | 361 | { |
362 | spin_lock(&mcpdm->lock); | 362 | spin_lock(&mcpdm->lock); |
363 | if (mcpdm->free) { | 363 | if (mcpdm->free) { |
364 | dev_err(mcpdm->dev, "McPDM interface is already free\n"); | 364 | dev_err(mcpdm->dev, "McPDM interface is already free\n"); |
365 | spin_unlock(&mcpdm->lock); | 365 | spin_unlock(&mcpdm->lock); |
366 | return; | 366 | return; |
367 | } | 367 | } |
368 | mcpdm->free = 1; | 368 | mcpdm->free = 1; |
369 | spin_unlock(&mcpdm->lock); | 369 | spin_unlock(&mcpdm->lock); |
370 | 370 | ||
371 | clk_disable(mcpdm->clk); | 371 | clk_disable(mcpdm->clk); |
372 | 372 | ||
373 | free_irq(mcpdm->irq, (void *)mcpdm); | 373 | free_irq(mcpdm->irq, (void *)mcpdm); |
374 | } | 374 | } |
375 | 375 | ||
376 | /* Enable/disable DC offset cancelation for the analog | 376 | /* Enable/disable DC offset cancelation for the analog |
@@ -378,108 +378,108 @@ void omap_mcpdm_free(void) | |||
378 | */ | 378 | */ |
379 | int omap_mcpdm_set_offset(int offset1, int offset2) | 379 | int omap_mcpdm_set_offset(int offset1, int offset2) |
380 | { | 380 | { |
381 | int offset; | 381 | int offset; |
382 | 382 | ||
383 | if ((offset1 > DN_OFST_MAX) || (offset2 > DN_OFST_MAX)) | 383 | if ((offset1 > DN_OFST_MAX) || (offset2 > DN_OFST_MAX)) |
384 | return -EINVAL; | 384 | return -EINVAL; |
385 | 385 | ||
386 | offset = (offset1 << DN_OFST_RX1) | (offset2 << DN_OFST_RX2); | 386 | offset = (offset1 << DN_OFST_RX1) | (offset2 << DN_OFST_RX2); |
387 | 387 | ||
388 | /* offset cancellation for channel 1 */ | 388 | /* offset cancellation for channel 1 */ |
389 | if (offset1) | 389 | if (offset1) |
390 | offset |= DN_OFST_RX1_EN; | 390 | offset |= DN_OFST_RX1_EN; |
391 | else | 391 | else |
392 | offset &= ~DN_OFST_RX1_EN; | 392 | offset &= ~DN_OFST_RX1_EN; |
393 | 393 | ||
394 | /* offset cancellation for channel 2 */ | 394 | /* offset cancellation for channel 2 */ |
395 | if (offset2) | 395 | if (offset2) |
396 | offset |= DN_OFST_RX2_EN; | 396 | offset |= DN_OFST_RX2_EN; |
397 | else | 397 | else |
398 | offset &= ~DN_OFST_RX2_EN; | 398 | offset &= ~DN_OFST_RX2_EN; |
399 | 399 | ||
400 | omap_mcpdm_write(MCPDM_DN_OFFSET, offset); | 400 | omap_mcpdm_write(MCPDM_DN_OFFSET, offset); |
401 | 401 | ||
402 | return 0; | 402 | return 0; |
403 | } | 403 | } |
404 | 404 | ||
405 | static int __devinit omap_mcpdm_probe(struct platform_device *pdev) | 405 | static int __devinit omap_mcpdm_probe(struct platform_device *pdev) |
406 | { | 406 | { |
407 | struct resource *res; | 407 | struct resource *res; |
408 | int ret = 0; | 408 | int ret = 0; |
409 | 409 | ||
410 | mcpdm = kzalloc(sizeof(struct omap_mcpdm), GFP_KERNEL); | 410 | mcpdm = kzalloc(sizeof(struct omap_mcpdm), GFP_KERNEL); |
411 | if (!mcpdm) { | 411 | if (!mcpdm) { |
412 | ret = -ENOMEM; | 412 | ret = -ENOMEM; |
413 | goto exit; | 413 | goto exit; |
414 | } | 414 | } |
415 | 415 | ||
416 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 416 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
417 | if (res == NULL) { | 417 | if (res == NULL) { |
418 | dev_err(&pdev->dev, "no resource\n"); | 418 | dev_err(&pdev->dev, "no resource\n"); |
419 | goto err_resource; | 419 | goto err_resource; |
420 | } | 420 | } |
421 | 421 | ||
422 | spin_lock_init(&mcpdm->lock); | 422 | spin_lock_init(&mcpdm->lock); |
423 | mcpdm->free = 1; | 423 | mcpdm->free = 1; |
424 | mcpdm->io_base = ioremap(res->start, resource_size(res)); | 424 | mcpdm->io_base = ioremap(res->start, resource_size(res)); |
425 | if (!mcpdm->io_base) { | 425 | if (!mcpdm->io_base) { |
426 | ret = -ENOMEM; | 426 | ret = -ENOMEM; |
427 | goto err_resource; | 427 | goto err_resource; |
428 | } | 428 | } |
429 | 429 | ||
430 | mcpdm->irq = platform_get_irq(pdev, 0); | 430 | mcpdm->irq = platform_get_irq(pdev, 0); |
431 | 431 | ||
432 | mcpdm->clk = clk_get(&pdev->dev, "pdm_ck"); | 432 | mcpdm->clk = clk_get(&pdev->dev, "pdm_ck"); |
433 | if (IS_ERR(mcpdm->clk)) { | 433 | if (IS_ERR(mcpdm->clk)) { |
434 | ret = PTR_ERR(mcpdm->clk); | 434 | ret = PTR_ERR(mcpdm->clk); |
435 | dev_err(&pdev->dev, "unable to get pdm_ck: %d\n", ret); | 435 | dev_err(&pdev->dev, "unable to get pdm_ck: %d\n", ret); |
436 | goto err_clk; | 436 | goto err_clk; |
437 | } | 437 | } |
438 | 438 | ||
439 | mcpdm->dev = &pdev->dev; | 439 | mcpdm->dev = &pdev->dev; |
440 | platform_set_drvdata(pdev, mcpdm); | 440 | platform_set_drvdata(pdev, mcpdm); |
441 | 441 | ||
442 | return 0; | 442 | return 0; |
443 | 443 | ||
444 | err_clk: | 444 | err_clk: |
445 | iounmap(mcpdm->io_base); | 445 | iounmap(mcpdm->io_base); |
446 | err_resource: | 446 | err_resource: |
447 | kfree(mcpdm); | 447 | kfree(mcpdm); |
448 | exit: | 448 | exit: |
449 | return ret; | 449 | return ret; |
450 | } | 450 | } |
451 | 451 | ||
452 | static int __devexit omap_mcpdm_remove(struct platform_device *pdev) | 452 | static int __devexit omap_mcpdm_remove(struct platform_device *pdev) |
453 | { | 453 | { |
454 | struct omap_mcpdm *mcpdm_ptr = platform_get_drvdata(pdev); | 454 | struct omap_mcpdm *mcpdm_ptr = platform_get_drvdata(pdev); |
455 | 455 | ||
456 | platform_set_drvdata(pdev, NULL); | 456 | platform_set_drvdata(pdev, NULL); |
457 | 457 | ||
458 | clk_put(mcpdm_ptr->clk); | 458 | clk_put(mcpdm_ptr->clk); |
459 | 459 | ||
460 | iounmap(mcpdm_ptr->io_base); | 460 | iounmap(mcpdm_ptr->io_base); |
461 | 461 | ||
462 | mcpdm_ptr->clk = NULL; | 462 | mcpdm_ptr->clk = NULL; |
463 | mcpdm_ptr->free = 0; | 463 | mcpdm_ptr->free = 0; |
464 | mcpdm_ptr->dev = NULL; | 464 | mcpdm_ptr->dev = NULL; |
465 | 465 | ||
466 | kfree(mcpdm_ptr); | 466 | kfree(mcpdm_ptr); |
467 | 467 | ||
468 | return 0; | 468 | return 0; |
469 | } | 469 | } |
470 | 470 | ||
471 | static struct platform_driver omap_mcpdm_driver = { | 471 | static struct platform_driver omap_mcpdm_driver = { |
472 | .probe = omap_mcpdm_probe, | 472 | .probe = omap_mcpdm_probe, |
473 | .remove = __devexit_p(omap_mcpdm_remove), | 473 | .remove = __devexit_p(omap_mcpdm_remove), |
474 | .driver = { | 474 | .driver = { |
475 | .name = "omap-mcpdm", | 475 | .name = "omap-mcpdm", |
476 | }, | 476 | }, |
477 | }; | 477 | }; |
478 | 478 | ||
479 | static struct platform_device *omap_mcpdm_device; | 479 | static struct platform_device *omap_mcpdm_device; |
480 | 480 | ||
481 | static int __init omap_mcpdm_init(void) | 481 | static int __init omap_mcpdm_init(void) |
482 | { | 482 | { |
483 | return platform_driver_register(&omap_mcpdm_driver); | 483 | return platform_driver_register(&omap_mcpdm_driver); |
484 | } | 484 | } |
485 | arch_initcall(omap_mcpdm_init); | 485 | arch_initcall(omap_mcpdm_init); |
diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c index 8ad9dc90100..6f44cb4d30b 100644 --- a/sound/soc/omap/omap-mcbsp.c +++ b/sound/soc/omap/omap-mcbsp.c | |||
@@ -256,6 +256,31 @@ static int omap_mcbsp_dai_trigger(struct snd_pcm_substream *substream, int cmd, | |||
256 | return err; | 256 | return err; |
257 | } | 257 | } |
258 | 258 | ||
259 | static snd_pcm_sframes_t omap_mcbsp_dai_delay( | ||
260 | struct snd_pcm_substream *substream, | ||
261 | struct snd_soc_dai *dai) | ||
262 | { | ||
263 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
264 | struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; | ||
265 | struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data); | ||
266 | u16 fifo_use; | ||
267 | snd_pcm_sframes_t delay; | ||
268 | |||
269 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | ||
270 | fifo_use = omap_mcbsp_get_tx_delay(mcbsp_data->bus_id); | ||
271 | else | ||
272 | fifo_use = omap_mcbsp_get_rx_delay(mcbsp_data->bus_id); | ||
273 | |||
274 | /* | ||
275 | * Divide the used locations with the channel count to get the | ||
276 | * FIFO usage in samples (don't care about partial samples in the | ||
277 | * buffer). | ||
278 | */ | ||
279 | delay = fifo_use / substream->runtime->channels; | ||
280 | |||
281 | return delay; | ||
282 | } | ||
283 | |||
259 | static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, | 284 | static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, |
260 | struct snd_pcm_hw_params *params, | 285 | struct snd_pcm_hw_params *params, |
261 | struct snd_soc_dai *dai) | 286 | struct snd_soc_dai *dai) |
@@ -295,8 +320,18 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, | |||
295 | omap_mcbsp_dai_dma_params[id][substream->stream].dma_req = dma; | 320 | omap_mcbsp_dai_dma_params[id][substream->stream].dma_req = dma; |
296 | omap_mcbsp_dai_dma_params[id][substream->stream].port_addr = port; | 321 | omap_mcbsp_dai_dma_params[id][substream->stream].port_addr = port; |
297 | omap_mcbsp_dai_dma_params[id][substream->stream].sync_mode = sync_mode; | 322 | omap_mcbsp_dai_dma_params[id][substream->stream].sync_mode = sync_mode; |
298 | omap_mcbsp_dai_dma_params[id][substream->stream].data_type = | 323 | switch (params_format(params)) { |
299 | OMAP_DMA_DATA_TYPE_S16; | 324 | case SNDRV_PCM_FORMAT_S16_LE: |
325 | omap_mcbsp_dai_dma_params[id][substream->stream].data_type = | ||
326 | OMAP_DMA_DATA_TYPE_S16; | ||
327 | break; | ||
328 | case SNDRV_PCM_FORMAT_S32_LE: | ||
329 | omap_mcbsp_dai_dma_params[id][substream->stream].data_type = | ||
330 | OMAP_DMA_DATA_TYPE_S32; | ||
331 | break; | ||
332 | default: | ||
333 | return -EINVAL; | ||
334 | } | ||
300 | 335 | ||
301 | snd_soc_dai_set_dma_data(cpu_dai, substream, | 336 | snd_soc_dai_set_dma_data(cpu_dai, substream, |
302 | &omap_mcbsp_dai_dma_params[id][substream->stream]); | 337 | &omap_mcbsp_dai_dma_params[id][substream->stream]); |
@@ -308,7 +343,8 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, | |||
308 | 343 | ||
309 | format = mcbsp_data->fmt & SND_SOC_DAIFMT_FORMAT_MASK; | 344 | format = mcbsp_data->fmt & SND_SOC_DAIFMT_FORMAT_MASK; |
310 | wpf = channels = params_channels(params); | 345 | wpf = channels = params_channels(params); |
311 | if (channels == 2 && format == SND_SOC_DAIFMT_I2S) { | 346 | if (channels == 2 && (format == SND_SOC_DAIFMT_I2S || |
347 | format == SND_SOC_DAIFMT_LEFT_J)) { | ||
312 | /* Use dual-phase frames */ | 348 | /* Use dual-phase frames */ |
313 | regs->rcr2 |= RPHASE; | 349 | regs->rcr2 |= RPHASE; |
314 | regs->xcr2 |= XPHASE; | 350 | regs->xcr2 |= XPHASE; |
@@ -330,6 +366,14 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, | |||
330 | regs->xcr2 |= XWDLEN2(OMAP_MCBSP_WORD_16); | 366 | regs->xcr2 |= XWDLEN2(OMAP_MCBSP_WORD_16); |
331 | regs->xcr1 |= XWDLEN1(OMAP_MCBSP_WORD_16); | 367 | regs->xcr1 |= XWDLEN1(OMAP_MCBSP_WORD_16); |
332 | break; | 368 | break; |
369 | case SNDRV_PCM_FORMAT_S32_LE: | ||
370 | /* Set word lengths */ | ||
371 | wlen = 32; | ||
372 | regs->rcr2 |= RWDLEN2(OMAP_MCBSP_WORD_32); | ||
373 | regs->rcr1 |= RWDLEN1(OMAP_MCBSP_WORD_32); | ||
374 | regs->xcr2 |= XWDLEN2(OMAP_MCBSP_WORD_32); | ||
375 | regs->xcr1 |= XWDLEN1(OMAP_MCBSP_WORD_32); | ||
376 | break; | ||
333 | default: | 377 | default: |
334 | /* Unsupported PCM format */ | 378 | /* Unsupported PCM format */ |
335 | return -EINVAL; | 379 | return -EINVAL; |
@@ -353,6 +397,7 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, | |||
353 | /* Set FS period and length in terms of bit clock periods */ | 397 | /* Set FS period and length in terms of bit clock periods */ |
354 | switch (format) { | 398 | switch (format) { |
355 | case SND_SOC_DAIFMT_I2S: | 399 | case SND_SOC_DAIFMT_I2S: |
400 | case SND_SOC_DAIFMT_LEFT_J: | ||
356 | regs->srgr2 |= FPER(framesize - 1); | 401 | regs->srgr2 |= FPER(framesize - 1); |
357 | regs->srgr1 |= FWID((framesize >> 1) - 1); | 402 | regs->srgr1 |= FWID((framesize >> 1) - 1); |
358 | break; | 403 | break; |
@@ -404,6 +449,14 @@ static int omap_mcbsp_dai_set_dai_fmt(struct snd_soc_dai *cpu_dai, | |||
404 | regs->rcr2 |= RDATDLY(1); | 449 | regs->rcr2 |= RDATDLY(1); |
405 | regs->xcr2 |= XDATDLY(1); | 450 | regs->xcr2 |= XDATDLY(1); |
406 | break; | 451 | break; |
452 | case SND_SOC_DAIFMT_LEFT_J: | ||
453 | /* 0-bit data delay */ | ||
454 | regs->rcr2 |= RDATDLY(0); | ||
455 | regs->xcr2 |= XDATDLY(0); | ||
456 | regs->spcr1 |= RJUST(2); | ||
457 | /* Invert FS polarity configuration */ | ||
458 | temp_fmt ^= SND_SOC_DAIFMT_NB_IF; | ||
459 | break; | ||
407 | case SND_SOC_DAIFMT_DSP_A: | 460 | case SND_SOC_DAIFMT_DSP_A: |
408 | /* 1-bit data delay */ | 461 | /* 1-bit data delay */ |
409 | regs->rcr2 |= RDATDLY(1); | 462 | regs->rcr2 |= RDATDLY(1); |
@@ -609,6 +662,7 @@ static struct snd_soc_dai_ops omap_mcbsp_dai_ops = { | |||
609 | .startup = omap_mcbsp_dai_startup, | 662 | .startup = omap_mcbsp_dai_startup, |
610 | .shutdown = omap_mcbsp_dai_shutdown, | 663 | .shutdown = omap_mcbsp_dai_shutdown, |
611 | .trigger = omap_mcbsp_dai_trigger, | 664 | .trigger = omap_mcbsp_dai_trigger, |
665 | .delay = omap_mcbsp_dai_delay, | ||
612 | .hw_params = omap_mcbsp_dai_hw_params, | 666 | .hw_params = omap_mcbsp_dai_hw_params, |
613 | .set_fmt = omap_mcbsp_dai_set_dai_fmt, | 667 | .set_fmt = omap_mcbsp_dai_set_dai_fmt, |
614 | .set_clkdiv = omap_mcbsp_dai_set_clkdiv, | 668 | .set_clkdiv = omap_mcbsp_dai_set_clkdiv, |
@@ -623,13 +677,15 @@ static struct snd_soc_dai_ops omap_mcbsp_dai_ops = { | |||
623 | .channels_min = 1, \ | 677 | .channels_min = 1, \ |
624 | .channels_max = 16, \ | 678 | .channels_max = 16, \ |
625 | .rates = OMAP_MCBSP_RATES, \ | 679 | .rates = OMAP_MCBSP_RATES, \ |
626 | .formats = SNDRV_PCM_FMTBIT_S16_LE, \ | 680 | .formats = SNDRV_PCM_FMTBIT_S16_LE | \ |
681 | SNDRV_PCM_FMTBIT_S32_LE, \ | ||
627 | }, \ | 682 | }, \ |
628 | .capture = { \ | 683 | .capture = { \ |
629 | .channels_min = 1, \ | 684 | .channels_min = 1, \ |
630 | .channels_max = 16, \ | 685 | .channels_max = 16, \ |
631 | .rates = OMAP_MCBSP_RATES, \ | 686 | .rates = OMAP_MCBSP_RATES, \ |
632 | .formats = SNDRV_PCM_FMTBIT_S16_LE, \ | 687 | .formats = SNDRV_PCM_FMTBIT_S16_LE | \ |
688 | SNDRV_PCM_FMTBIT_S32_LE, \ | ||
633 | }, \ | 689 | }, \ |
634 | .ops = &omap_mcbsp_dai_ops, \ | 690 | .ops = &omap_mcbsp_dai_ops, \ |
635 | .private_data = &mcbsp_data[(link_id)].bus_id, \ | 691 | .private_data = &mcbsp_data[(link_id)].bus_id, \ |
diff --git a/sound/soc/omap/omap3pandora.c b/sound/soc/omap/omap3pandora.c index de10f76bade..87ce842fa2e 100644 --- a/sound/soc/omap/omap3pandora.c +++ b/sound/soc/omap/omap3pandora.c | |||
@@ -188,8 +188,6 @@ static int omap3pandora_out_init(struct snd_soc_codec *codec) | |||
188 | int ret; | 188 | int ret; |
189 | 189 | ||
190 | /* All TWL4030 output pins are floating */ | 190 | /* All TWL4030 output pins are floating */ |
191 | snd_soc_dapm_nc_pin(codec, "OUTL"); | ||
192 | snd_soc_dapm_nc_pin(codec, "OUTR"); | ||
193 | snd_soc_dapm_nc_pin(codec, "EARPIECE"); | 191 | snd_soc_dapm_nc_pin(codec, "EARPIECE"); |
194 | snd_soc_dapm_nc_pin(codec, "PREDRIVEL"); | 192 | snd_soc_dapm_nc_pin(codec, "PREDRIVEL"); |
195 | snd_soc_dapm_nc_pin(codec, "PREDRIVER"); | 193 | snd_soc_dapm_nc_pin(codec, "PREDRIVER"); |
diff --git a/sound/soc/omap/rx51.c b/sound/soc/omap/rx51.c new file mode 100644 index 00000000000..47d831ef2db --- /dev/null +++ b/sound/soc/omap/rx51.c | |||
@@ -0,0 +1,294 @@ | |||
1 | /* | ||
2 | * rx51.c -- SoC audio for Nokia RX-51 | ||
3 | * | ||
4 | * Copyright (C) 2008 - 2009 Nokia Corporation | ||
5 | * | ||
6 | * Contact: Peter Ujfalusi <peter.ujfalusi@nokia.com> | ||
7 | * Eduardo Valentin <eduardo.valentin@nokia.com> | ||
8 | * Jarkko Nikula <jhnikula@gmail.com> | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or | ||
11 | * modify it under the terms of the GNU General Public License | ||
12 | * version 2 as published by the Free Software Foundation. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, but | ||
15 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | * General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program; if not, write to the Free Software | ||
21 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
22 | * 02110-1301 USA | ||
23 | * | ||
24 | */ | ||
25 | |||
26 | #include <linux/delay.h> | ||
27 | #include <linux/gpio.h> | ||
28 | #include <linux/platform_device.h> | ||
29 | #include <sound/core.h> | ||
30 | #include <sound/pcm.h> | ||
31 | #include <sound/soc.h> | ||
32 | #include <sound/soc-dapm.h> | ||
33 | |||
34 | #include <asm/mach-types.h> | ||
35 | |||
36 | #include "omap-mcbsp.h" | ||
37 | #include "omap-pcm.h" | ||
38 | #include "../codecs/tlv320aic3x.h" | ||
39 | |||
40 | /* | ||
41 | * REVISIT: TWL4030 GPIO base in RX-51. Now statically defined to 192. This | ||
42 | * gpio is reserved in arch/arm/mach-omap2/board-rx51-peripherals.c | ||
43 | */ | ||
44 | #define RX51_SPEAKER_AMP_TWL_GPIO (192 + 7) | ||
45 | |||
46 | static int rx51_spk_func; | ||
47 | static int rx51_dmic_func; | ||
48 | |||
49 | static void rx51_ext_control(struct snd_soc_codec *codec) | ||
50 | { | ||
51 | if (rx51_spk_func) | ||
52 | snd_soc_dapm_enable_pin(codec, "Ext Spk"); | ||
53 | else | ||
54 | snd_soc_dapm_disable_pin(codec, "Ext Spk"); | ||
55 | if (rx51_dmic_func) | ||
56 | snd_soc_dapm_enable_pin(codec, "DMic"); | ||
57 | else | ||
58 | snd_soc_dapm_disable_pin(codec, "DMic"); | ||
59 | |||
60 | snd_soc_dapm_sync(codec); | ||
61 | } | ||
62 | |||
63 | static int rx51_startup(struct snd_pcm_substream *substream) | ||
64 | { | ||
65 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
66 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
67 | struct snd_soc_codec *codec = rtd->socdev->card->codec; | ||
68 | |||
69 | snd_pcm_hw_constraint_minmax(runtime, | ||
70 | SNDRV_PCM_HW_PARAM_CHANNELS, 2, 2); | ||
71 | rx51_ext_control(codec); | ||
72 | |||
73 | return 0; | ||
74 | } | ||
75 | |||
76 | static int rx51_hw_params(struct snd_pcm_substream *substream, | ||
77 | struct snd_pcm_hw_params *params) | ||
78 | { | ||
79 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
80 | struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; | ||
81 | struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; | ||
82 | int err; | ||
83 | |||
84 | /* Set codec DAI configuration */ | ||
85 | err = snd_soc_dai_set_fmt(codec_dai, | ||
86 | SND_SOC_DAIFMT_DSP_A | | ||
87 | SND_SOC_DAIFMT_IB_NF | | ||
88 | SND_SOC_DAIFMT_CBM_CFM); | ||
89 | if (err < 0) | ||
90 | return err; | ||
91 | |||
92 | /* Set cpu DAI configuration */ | ||
93 | err = snd_soc_dai_set_fmt(cpu_dai, | ||
94 | SND_SOC_DAIFMT_DSP_A | | ||
95 | SND_SOC_DAIFMT_IB_NF | | ||
96 | SND_SOC_DAIFMT_CBM_CFM); | ||
97 | if (err < 0) | ||
98 | return err; | ||
99 | |||
100 | /* Set the codec system clock for DAC and ADC */ | ||
101 | return snd_soc_dai_set_sysclk(codec_dai, 0, 19200000, | ||
102 | SND_SOC_CLOCK_IN); | ||
103 | } | ||
104 | |||
105 | static struct snd_soc_ops rx51_ops = { | ||
106 | .startup = rx51_startup, | ||
107 | .hw_params = rx51_hw_params, | ||
108 | }; | ||
109 | |||
110 | static int rx51_get_spk(struct snd_kcontrol *kcontrol, | ||
111 | struct snd_ctl_elem_value *ucontrol) | ||
112 | { | ||
113 | ucontrol->value.integer.value[0] = rx51_spk_func; | ||
114 | |||
115 | return 0; | ||
116 | } | ||
117 | |||
118 | static int rx51_set_spk(struct snd_kcontrol *kcontrol, | ||
119 | struct snd_ctl_elem_value *ucontrol) | ||
120 | { | ||
121 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | ||
122 | |||
123 | if (rx51_spk_func == ucontrol->value.integer.value[0]) | ||
124 | return 0; | ||
125 | |||
126 | rx51_spk_func = ucontrol->value.integer.value[0]; | ||
127 | rx51_ext_control(codec); | ||
128 | |||
129 | return 1; | ||
130 | } | ||
131 | |||
132 | static int rx51_spk_event(struct snd_soc_dapm_widget *w, | ||
133 | struct snd_kcontrol *k, int event) | ||
134 | { | ||
135 | if (SND_SOC_DAPM_EVENT_ON(event)) | ||
136 | gpio_set_value(RX51_SPEAKER_AMP_TWL_GPIO, 1); | ||
137 | else | ||
138 | gpio_set_value(RX51_SPEAKER_AMP_TWL_GPIO, 0); | ||
139 | |||
140 | return 0; | ||
141 | } | ||
142 | |||
143 | static int rx51_get_input(struct snd_kcontrol *kcontrol, | ||
144 | struct snd_ctl_elem_value *ucontrol) | ||
145 | { | ||
146 | ucontrol->value.integer.value[0] = rx51_dmic_func; | ||
147 | |||
148 | return 0; | ||
149 | } | ||
150 | |||
151 | static int rx51_set_input(struct snd_kcontrol *kcontrol, | ||
152 | struct snd_ctl_elem_value *ucontrol) | ||
153 | { | ||
154 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | ||
155 | |||
156 | if (rx51_dmic_func == ucontrol->value.integer.value[0]) | ||
157 | return 0; | ||
158 | |||
159 | rx51_dmic_func = ucontrol->value.integer.value[0]; | ||
160 | rx51_ext_control(codec); | ||
161 | |||
162 | return 1; | ||
163 | } | ||
164 | |||
165 | static const struct snd_soc_dapm_widget aic34_dapm_widgets[] = { | ||
166 | SND_SOC_DAPM_SPK("Ext Spk", rx51_spk_event), | ||
167 | SND_SOC_DAPM_MIC("DMic", NULL), | ||
168 | }; | ||
169 | |||
170 | static const struct snd_soc_dapm_route audio_map[] = { | ||
171 | {"Ext Spk", NULL, "HPLOUT"}, | ||
172 | {"Ext Spk", NULL, "HPROUT"}, | ||
173 | |||
174 | {"DMic Rate 64", NULL, "Mic Bias 2V"}, | ||
175 | {"Mic Bias 2V", NULL, "DMic"}, | ||
176 | }; | ||
177 | |||
178 | static const char *spk_function[] = {"Off", "On"}; | ||
179 | static const char *input_function[] = {"ADC", "Digital Mic"}; | ||
180 | |||
181 | static const struct soc_enum rx51_enum[] = { | ||
182 | SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(spk_function), spk_function), | ||
183 | SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(input_function), input_function), | ||
184 | }; | ||
185 | |||
186 | static const struct snd_kcontrol_new aic34_rx51_controls[] = { | ||
187 | SOC_ENUM_EXT("Speaker Function", rx51_enum[0], | ||
188 | rx51_get_spk, rx51_set_spk), | ||
189 | SOC_ENUM_EXT("Input Select", rx51_enum[1], | ||
190 | rx51_get_input, rx51_set_input), | ||
191 | }; | ||
192 | |||
193 | static int rx51_aic34_init(struct snd_soc_codec *codec) | ||
194 | { | ||
195 | int err; | ||
196 | |||
197 | /* Set up NC codec pins */ | ||
198 | snd_soc_dapm_nc_pin(codec, "MIC3L"); | ||
199 | snd_soc_dapm_nc_pin(codec, "MIC3R"); | ||
200 | snd_soc_dapm_nc_pin(codec, "LINE1R"); | ||
201 | |||
202 | /* Add RX-51 specific controls */ | ||
203 | err = snd_soc_add_controls(codec, aic34_rx51_controls, | ||
204 | ARRAY_SIZE(aic34_rx51_controls)); | ||
205 | if (err < 0) | ||
206 | return err; | ||
207 | |||
208 | /* Add RX-51 specific widgets */ | ||
209 | snd_soc_dapm_new_controls(codec, aic34_dapm_widgets, | ||
210 | ARRAY_SIZE(aic34_dapm_widgets)); | ||
211 | |||
212 | /* Set up RX-51 specific audio path audio_map */ | ||
213 | snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); | ||
214 | |||
215 | snd_soc_dapm_sync(codec); | ||
216 | |||
217 | return 0; | ||
218 | } | ||
219 | |||
220 | /* Digital audio interface glue - connects codec <--> CPU */ | ||
221 | static struct snd_soc_dai_link rx51_dai[] = { | ||
222 | { | ||
223 | .name = "TLV320AIC34", | ||
224 | .stream_name = "AIC34", | ||
225 | .cpu_dai = &omap_mcbsp_dai[0], | ||
226 | .codec_dai = &aic3x_dai, | ||
227 | .init = rx51_aic34_init, | ||
228 | .ops = &rx51_ops, | ||
229 | }, | ||
230 | }; | ||
231 | |||
232 | /* Audio private data */ | ||
233 | static struct aic3x_setup_data rx51_aic34_setup = { | ||
234 | .gpio_func[0] = AIC3X_GPIO1_FUNC_DISABLED, | ||
235 | .gpio_func[1] = AIC3X_GPIO2_FUNC_DIGITAL_MIC_INPUT, | ||
236 | }; | ||
237 | |||
238 | /* Audio card */ | ||
239 | static struct snd_soc_card rx51_sound_card = { | ||
240 | .name = "RX-51", | ||
241 | .dai_link = rx51_dai, | ||
242 | .num_links = ARRAY_SIZE(rx51_dai), | ||
243 | .platform = &omap_soc_platform, | ||
244 | }; | ||
245 | |||
246 | /* Audio subsystem */ | ||
247 | static struct snd_soc_device rx51_snd_devdata = { | ||
248 | .card = &rx51_sound_card, | ||
249 | .codec_dev = &soc_codec_dev_aic3x, | ||
250 | .codec_data = &rx51_aic34_setup, | ||
251 | }; | ||
252 | |||
253 | static struct platform_device *rx51_snd_device; | ||
254 | |||
255 | static int __init rx51_soc_init(void) | ||
256 | { | ||
257 | int err; | ||
258 | |||
259 | if (!machine_is_nokia_rx51()) | ||
260 | return -ENODEV; | ||
261 | |||
262 | rx51_snd_device = platform_device_alloc("soc-audio", -1); | ||
263 | if (!rx51_snd_device) { | ||
264 | err = -ENOMEM; | ||
265 | goto err1; | ||
266 | } | ||
267 | |||
268 | platform_set_drvdata(rx51_snd_device, &rx51_snd_devdata); | ||
269 | rx51_snd_devdata.dev = &rx51_snd_device->dev; | ||
270 | *(unsigned int *)rx51_dai[0].cpu_dai->private_data = 1; /* McBSP2 */ | ||
271 | |||
272 | err = platform_device_add(rx51_snd_device); | ||
273 | if (err) | ||
274 | goto err2; | ||
275 | |||
276 | return 0; | ||
277 | err2: | ||
278 | platform_device_put(rx51_snd_device); | ||
279 | err1: | ||
280 | |||
281 | return err; | ||
282 | } | ||
283 | |||
284 | static void __exit rx51_soc_exit(void) | ||
285 | { | ||
286 | platform_device_unregister(rx51_snd_device); | ||
287 | } | ||
288 | |||
289 | module_init(rx51_soc_init); | ||
290 | module_exit(rx51_soc_exit); | ||
291 | |||
292 | MODULE_AUTHOR("Nokia Corporation"); | ||
293 | MODULE_DESCRIPTION("ALSA SoC Nokia RX-51"); | ||
294 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/omap/sdp4430.c b/sound/soc/omap/sdp4430.c new file mode 100644 index 00000000000..4ebbde6b565 --- /dev/null +++ b/sound/soc/omap/sdp4430.c | |||
@@ -0,0 +1,233 @@ | |||
1 | /* | ||
2 | * sdp4430.c -- SoC audio for TI OMAP4430 SDP | ||
3 | * | ||
4 | * Author: Misael Lopez Cruz <x0052729@ti.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * version 2 as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, but | ||
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | * General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
18 | * 02110-1301 USA | ||
19 | * | ||
20 | */ | ||
21 | |||
22 | #include <linux/clk.h> | ||
23 | #include <linux/platform_device.h> | ||
24 | #include <sound/core.h> | ||
25 | #include <sound/pcm.h> | ||
26 | #include <sound/soc.h> | ||
27 | #include <sound/soc-dapm.h> | ||
28 | |||
29 | #include <asm/mach-types.h> | ||
30 | #include <plat/hardware.h> | ||
31 | #include <plat/mux.h> | ||
32 | |||
33 | #include "mcpdm.h" | ||
34 | #include "omap-mcpdm.h" | ||
35 | #include "omap-pcm.h" | ||
36 | #include "../codecs/twl6040.h" | ||
37 | |||
38 | static int twl6040_power_mode; | ||
39 | |||
40 | static int sdp4430_hw_params(struct snd_pcm_substream *substream, | ||
41 | struct snd_pcm_hw_params *params) | ||
42 | { | ||
43 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
44 | struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; | ||
45 | int clk_id, freq; | ||
46 | int ret; | ||
47 | |||
48 | if (twl6040_power_mode) { | ||
49 | clk_id = TWL6040_SYSCLK_SEL_HPPLL; | ||
50 | freq = 38400000; | ||
51 | } else { | ||
52 | clk_id = TWL6040_SYSCLK_SEL_LPPLL; | ||
53 | freq = 32768; | ||
54 | } | ||
55 | |||
56 | /* set the codec mclk */ | ||
57 | ret = snd_soc_dai_set_sysclk(codec_dai, clk_id, freq, | ||
58 | SND_SOC_CLOCK_IN); | ||
59 | if (ret) { | ||
60 | printk(KERN_ERR "can't set codec system clock\n"); | ||
61 | return ret; | ||
62 | } | ||
63 | } | ||
64 | |||
65 | static struct snd_soc_ops sdp4430_ops = { | ||
66 | .hw_params = sdp4430_hw_params, | ||
67 | }; | ||
68 | |||
69 | static int sdp4430_get_power_mode(struct snd_kcontrol *kcontrol, | ||
70 | struct snd_ctl_elem_value *ucontrol) | ||
71 | { | ||
72 | ucontrol->value.integer.value[0] = twl6040_power_mode; | ||
73 | return 0; | ||
74 | } | ||
75 | |||
76 | static int sdp4430_set_power_mode(struct snd_kcontrol *kcontrol, | ||
77 | struct snd_ctl_elem_value *ucontrol) | ||
78 | { | ||
79 | if (twl6040_power_mode == ucontrol->value.integer.value[0]) | ||
80 | return 0; | ||
81 | |||
82 | twl6040_power_mode = ucontrol->value.integer.value[0]; | ||
83 | |||
84 | return 1; | ||
85 | } | ||
86 | |||
87 | static const char *power_texts[] = {"Low-Power", "High-Performance"}; | ||
88 | |||
89 | static const struct soc_enum sdp4430_enum[] = { | ||
90 | SOC_ENUM_SINGLE_EXT(2, power_texts), | ||
91 | }; | ||
92 | |||
93 | static const struct snd_kcontrol_new sdp4430_controls[] = { | ||
94 | SOC_ENUM_EXT("TWL6040 Power Mode", sdp4430_enum[0], | ||
95 | sdp4430_get_power_mode, sdp4430_set_power_mode), | ||
96 | }; | ||
97 | |||
98 | /* SDP4430 machine DAPM */ | ||
99 | static const struct snd_soc_dapm_widget sdp4430_twl6040_dapm_widgets[] = { | ||
100 | SND_SOC_DAPM_MIC("Ext Mic", NULL), | ||
101 | SND_SOC_DAPM_SPK("Ext Spk", NULL), | ||
102 | SND_SOC_DAPM_MIC("Headset Mic", NULL), | ||
103 | SND_SOC_DAPM_HP("Headset Stereophone", NULL), | ||
104 | SND_SOC_DAPM_SPK("Earphone Spk", NULL), | ||
105 | }; | ||
106 | |||
107 | static const struct snd_soc_dapm_route audio_map[] = { | ||
108 | /* External Mics: MAINMIC, SUBMIC with bias*/ | ||
109 | {"MAINMIC", NULL, "Main Mic Bias"}, | ||
110 | {"SUBMIC", NULL, "Main Mic Bias"}, | ||
111 | {"Main Mic Bias", NULL, "Ext Mic"}, | ||
112 | |||
113 | /* External Speakers: HFL, HFR */ | ||
114 | {"Ext Spk", NULL, "HFL"}, | ||
115 | {"Ext Spk", NULL, "HFR"}, | ||
116 | |||
117 | /* Headset Mic: HSMIC with bias */ | ||
118 | {"HSMIC", NULL, "Headset Mic Bias"}, | ||
119 | {"Headset Mic Bias", NULL, "Headset Mic"}, | ||
120 | |||
121 | /* Headset Stereophone (Headphone): HSOL, HSOR */ | ||
122 | {"Headset Stereophone", NULL, "HSOL"}, | ||
123 | {"Headset Stereophone", NULL, "HSOR"}, | ||
124 | |||
125 | /* Earphone speaker */ | ||
126 | {"Earphone Spk", NULL, "EP"}, | ||
127 | }; | ||
128 | |||
129 | static int sdp4430_twl6040_init(struct snd_soc_codec *codec) | ||
130 | { | ||
131 | int ret; | ||
132 | |||
133 | /* Add SDP4430 specific controls */ | ||
134 | ret = snd_soc_add_controls(codec, sdp4430_controls, | ||
135 | ARRAY_SIZE(sdp4430_controls)); | ||
136 | if (ret) | ||
137 | return ret; | ||
138 | |||
139 | /* Add SDP4430 specific widgets */ | ||
140 | ret = snd_soc_dapm_new_controls(codec, sdp4430_twl6040_dapm_widgets, | ||
141 | ARRAY_SIZE(sdp4430_twl6040_dapm_widgets)); | ||
142 | if (ret) | ||
143 | return ret; | ||
144 | |||
145 | /* Set up SDP4430 specific audio path audio_map */ | ||
146 | snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); | ||
147 | |||
148 | /* SDP4430 connected pins */ | ||
149 | snd_soc_dapm_enable_pin(codec, "Ext Mic"); | ||
150 | snd_soc_dapm_enable_pin(codec, "Ext Spk"); | ||
151 | snd_soc_dapm_enable_pin(codec, "Headset Mic"); | ||
152 | snd_soc_dapm_enable_pin(codec, "Headset Stereophone"); | ||
153 | |||
154 | /* TWL6040 not connected pins */ | ||
155 | snd_soc_dapm_nc_pin(codec, "AFML"); | ||
156 | snd_soc_dapm_nc_pin(codec, "AFMR"); | ||
157 | |||
158 | ret = snd_soc_dapm_sync(codec); | ||
159 | |||
160 | return ret; | ||
161 | } | ||
162 | |||
163 | /* Digital audio interface glue - connects codec <--> CPU */ | ||
164 | static struct snd_soc_dai_link sdp4430_dai = { | ||
165 | .name = "TWL6040", | ||
166 | .stream_name = "TWL6040", | ||
167 | .cpu_dai = &omap_mcpdm_dai, | ||
168 | .codec_dai = &twl6040_dai, | ||
169 | .init = sdp4430_twl6040_init, | ||
170 | .ops = &sdp4430_ops, | ||
171 | }; | ||
172 | |||
173 | /* Audio machine driver */ | ||
174 | static struct snd_soc_card snd_soc_sdp4430 = { | ||
175 | .name = "SDP4430", | ||
176 | .platform = &omap_soc_platform, | ||
177 | .dai_link = &sdp4430_dai, | ||
178 | .num_links = 1, | ||
179 | }; | ||
180 | |||
181 | /* Audio subsystem */ | ||
182 | static struct snd_soc_device sdp4430_snd_devdata = { | ||
183 | .card = &snd_soc_sdp4430, | ||
184 | .codec_dev = &soc_codec_dev_twl6040, | ||
185 | }; | ||
186 | |||
187 | static struct platform_device *sdp4430_snd_device; | ||
188 | |||
189 | static int __init sdp4430_soc_init(void) | ||
190 | { | ||
191 | int ret; | ||
192 | |||
193 | if (!machine_is_omap_4430sdp()) { | ||
194 | pr_debug("Not SDP4430!\n"); | ||
195 | return -ENODEV; | ||
196 | } | ||
197 | printk(KERN_INFO "SDP4430 SoC init\n"); | ||
198 | |||
199 | sdp4430_snd_device = platform_device_alloc("soc-audio", -1); | ||
200 | if (!sdp4430_snd_device) { | ||
201 | printk(KERN_ERR "Platform device allocation failed\n"); | ||
202 | return -ENOMEM; | ||
203 | } | ||
204 | |||
205 | platform_set_drvdata(sdp4430_snd_device, &sdp4430_snd_devdata); | ||
206 | sdp4430_snd_devdata.dev = &sdp4430_snd_device->dev; | ||
207 | |||
208 | ret = platform_device_add(sdp4430_snd_device); | ||
209 | if (ret) | ||
210 | goto err; | ||
211 | |||
212 | /* Codec starts in HP mode */ | ||
213 | twl6040_power_mode = 1; | ||
214 | |||
215 | return 0; | ||
216 | |||
217 | err: | ||
218 | printk(KERN_ERR "Unable to add platform device\n"); | ||
219 | platform_device_put(sdp4430_snd_device); | ||
220 | return ret; | ||
221 | } | ||
222 | module_init(sdp4430_soc_init); | ||
223 | |||
224 | static void __exit sdp4430_soc_exit(void) | ||
225 | { | ||
226 | platform_device_unregister(sdp4430_snd_device); | ||
227 | } | ||
228 | module_exit(sdp4430_soc_exit); | ||
229 | |||
230 | MODULE_AUTHOR("Misael Lopez Cruz <x0052729@ti.com>"); | ||
231 | MODULE_DESCRIPTION("ALSA SoC SDP4430"); | ||
232 | MODULE_LICENSE("GPL"); | ||
233 | |||
diff --git a/sound/soc/omap/zoom2.c b/sound/soc/omap/zoom2.c index f90a2ac888c..50a94ee76ec 100644 --- a/sound/soc/omap/zoom2.c +++ b/sound/soc/omap/zoom2.c | |||
@@ -181,9 +181,6 @@ static int zoom2_twl4030_init(struct snd_soc_codec *codec) | |||
181 | snd_soc_dapm_nc_pin(codec, "CARKITMIC"); | 181 | snd_soc_dapm_nc_pin(codec, "CARKITMIC"); |
182 | snd_soc_dapm_nc_pin(codec, "DIGIMIC0"); | 182 | snd_soc_dapm_nc_pin(codec, "DIGIMIC0"); |
183 | snd_soc_dapm_nc_pin(codec, "DIGIMIC1"); | 183 | snd_soc_dapm_nc_pin(codec, "DIGIMIC1"); |
184 | |||
185 | snd_soc_dapm_nc_pin(codec, "OUTL"); | ||
186 | snd_soc_dapm_nc_pin(codec, "OUTR"); | ||
187 | snd_soc_dapm_nc_pin(codec, "EARPIECE"); | 184 | snd_soc_dapm_nc_pin(codec, "EARPIECE"); |
188 | snd_soc_dapm_nc_pin(codec, "PREDRIVEL"); | 185 | snd_soc_dapm_nc_pin(codec, "PREDRIVEL"); |
189 | snd_soc_dapm_nc_pin(codec, "PREDRIVER"); | 186 | snd_soc_dapm_nc_pin(codec, "PREDRIVER"); |