diff options
author | Peter Ujfalusi <peter.ujfalusi@ti.com> | 2011-09-26 09:05:58 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2011-09-26 17:23:32 -0400 |
commit | 89b0d550a6800793b917ce2290ddcd55374d7df6 (patch) | |
tree | 2521e9d63ec2be7f997c9d3e990355122cae7c14 /sound/soc/omap | |
parent | db4aabcc1f2ac32de290510bcc895a960886779d (diff) |
ASoC: omap-mcpdm: API to configure offset cancellation
The offset cancellation values can be different from board to board, even
on the same HW platform.
Provide a way for the machine drivers to configure the McPDM offset
cancellation.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/omap')
-rw-r--r-- | sound/soc/omap/omap-mcpdm.c | 25 | ||||
-rw-r--r-- | sound/soc/omap/omap-mcpdm.h | 12 |
2 files changed, 37 insertions, 0 deletions
diff --git a/sound/soc/omap/omap-mcpdm.c b/sound/soc/omap/omap-mcpdm.c index 2c9fa5105fd2..41d17067cc73 100644 --- a/sound/soc/omap/omap-mcpdm.c +++ b/sound/soc/omap/omap-mcpdm.c | |||
@@ -59,6 +59,9 @@ struct omap_mcpdm { | |||
59 | /* McPDM FIFO thresholds */ | 59 | /* McPDM FIFO thresholds */ |
60 | u32 dn_threshold; | 60 | u32 dn_threshold; |
61 | u32 up_threshold; | 61 | u32 up_threshold; |
62 | |||
63 | /* McPDM dn offsets for rx1, and 2 channels */ | ||
64 | u32 dn_rx_offset; | ||
62 | }; | 65 | }; |
63 | 66 | ||
64 | /* | 67 | /* |
@@ -183,6 +186,15 @@ static void omap_mcpdm_open_streams(struct omap_mcpdm *mcpdm) | |||
183 | MCPDM_DN_IRQ_EMPTY | MCPDM_DN_IRQ_FULL | | 186 | MCPDM_DN_IRQ_EMPTY | MCPDM_DN_IRQ_FULL | |
184 | MCPDM_UP_IRQ_EMPTY | MCPDM_UP_IRQ_FULL); | 187 | MCPDM_UP_IRQ_EMPTY | MCPDM_UP_IRQ_FULL); |
185 | 188 | ||
189 | /* Enable DN RX1/2 offset cancellation feature, if configured */ | ||
190 | if (mcpdm->dn_rx_offset) { | ||
191 | u32 dn_offset = mcpdm->dn_rx_offset; | ||
192 | |||
193 | omap_mcpdm_write(mcpdm, MCPDM_REG_DN_OFFSET, dn_offset); | ||
194 | dn_offset |= (MCPDM_DN_OFST_RX1_EN | MCPDM_DN_OFST_RX2_EN); | ||
195 | omap_mcpdm_write(mcpdm, MCPDM_REG_DN_OFFSET, dn_offset); | ||
196 | } | ||
197 | |||
186 | omap_mcpdm_write(mcpdm, MCPDM_REG_FIFO_CTRL_DN, mcpdm->dn_threshold); | 198 | omap_mcpdm_write(mcpdm, MCPDM_REG_FIFO_CTRL_DN, mcpdm->dn_threshold); |
187 | omap_mcpdm_write(mcpdm, MCPDM_REG_FIFO_CTRL_UP, mcpdm->up_threshold); | 199 | omap_mcpdm_write(mcpdm, MCPDM_REG_FIFO_CTRL_UP, mcpdm->up_threshold); |
188 | 200 | ||
@@ -209,6 +221,10 @@ static void omap_mcpdm_close_streams(struct omap_mcpdm *mcpdm) | |||
209 | 221 | ||
210 | /* Disable DMA request generation for uplink */ | 222 | /* Disable DMA request generation for uplink */ |
211 | omap_mcpdm_write(mcpdm, MCPDM_REG_DMAENABLE_CLR, MCPDM_DMA_UP_ENABLE); | 223 | omap_mcpdm_write(mcpdm, MCPDM_REG_DMAENABLE_CLR, MCPDM_DMA_UP_ENABLE); |
224 | |||
225 | /* Disable RX1/2 offset cancellation */ | ||
226 | if (mcpdm->dn_rx_offset) | ||
227 | omap_mcpdm_write(mcpdm, MCPDM_REG_DN_OFFSET, 0); | ||
212 | } | 228 | } |
213 | 229 | ||
214 | static irqreturn_t omap_mcpdm_irq_handler(int irq, void *dev_id) | 230 | static irqreturn_t omap_mcpdm_irq_handler(int irq, void *dev_id) |
@@ -418,6 +434,15 @@ static struct snd_soc_dai_driver omap_mcpdm_dai = { | |||
418 | .ops = &omap_mcpdm_dai_ops, | 434 | .ops = &omap_mcpdm_dai_ops, |
419 | }; | 435 | }; |
420 | 436 | ||
437 | void omap_mcpdm_configure_dn_offsets(struct snd_soc_pcm_runtime *rtd, | ||
438 | u8 rx1, u8 rx2) | ||
439 | { | ||
440 | struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(rtd->cpu_dai); | ||
441 | |||
442 | mcpdm->dn_rx_offset = MCPDM_DNOFST_RX1(rx1) | MCPDM_DNOFST_RX2(rx2); | ||
443 | } | ||
444 | EXPORT_SYMBOL_GPL(omap_mcpdm_configure_dn_offsets); | ||
445 | |||
421 | static __devinit int asoc_mcpdm_probe(struct platform_device *pdev) | 446 | static __devinit int asoc_mcpdm_probe(struct platform_device *pdev) |
422 | { | 447 | { |
423 | struct omap_mcpdm *mcpdm; | 448 | struct omap_mcpdm *mcpdm; |
diff --git a/sound/soc/omap/omap-mcpdm.h b/sound/soc/omap/omap-mcpdm.h index d23122afdb10..de8cf26595b1 100644 --- a/sound/soc/omap/omap-mcpdm.h +++ b/sound/soc/omap/omap-mcpdm.h | |||
@@ -92,4 +92,16 @@ | |||
92 | #define MCPDM_UP_THRES_MAX 0xF | 92 | #define MCPDM_UP_THRES_MAX 0xF |
93 | #define MCPDM_DN_THRES_MAX 0xF | 93 | #define MCPDM_DN_THRES_MAX 0xF |
94 | 94 | ||
95 | /* | ||
96 | * MCPDM_DN_OFFSET bit fields | ||
97 | */ | ||
98 | |||
99 | #define MCPDM_DN_OFST_RX1_EN (1 << 0) | ||
100 | #define MCPDM_DNOFST_RX1(x) ((x & 0x1f) << 1) | ||
101 | #define MCPDM_DN_OFST_RX2_EN (1 << 8) | ||
102 | #define MCPDM_DNOFST_RX2(x) ((x & 0x1f) << 9) | ||
103 | |||
104 | void omap_mcpdm_configure_dn_offsets(struct snd_soc_pcm_runtime *rtd, | ||
105 | u8 rx1, u8 rx2); | ||
106 | |||
95 | #endif /* End of __OMAP_MCPDM_H__ */ | 107 | #endif /* End of __OMAP_MCPDM_H__ */ |