From 405b89ed8458f95f924537d5dbe8517318fe7c9e Mon Sep 17 00:00:00 2001 From: Misael Lopez Cruz Date: Tue, 15 Feb 2011 01:25:49 -0600 Subject: [PATCH 35/60] ASoC: McPDM: Add offset cancellation commit 4f5e543867c6e61af6dc74c16913513376bc5f8a upstream McPDM interface supports an offset cancellation feature to eliminate the offset of the analog headset downlink path. External audio companion chip should provide the offset values. Offset values are fixed in this implementation. Change-Id: Iafbdb719b5d693bdae707717224c4be503567eeb Signed-off-by: Liam Girdwood Signed-off-by: Misael Lopez Cruz Integrated-by: Jingdong Lu --- sound/soc/omap/omap-mcpdm.c | 21 +++++++++++++++------ sound/soc/omap/omap-mcpdm.h | 5 ----- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/sound/soc/omap/omap-mcpdm.c b/sound/soc/omap/omap-mcpdm.c index 67ce001..f420ad0 100644 --- a/sound/soc/omap/omap-mcpdm.c +++ b/sound/soc/omap/omap-mcpdm.c @@ -69,6 +69,10 @@ struct omap_mcpdm { int up_channels; int dl_active; int ul_active; + + /* DC offset */ + int dl1_offset; + int dl2_offset; }; static struct omap_mcpdm_link omap_mcpdm_links[] = { @@ -455,24 +459,25 @@ static void omap_mcpdm_free(struct omap_mcpdm *mcpdm) /* Enable/disable DC offset cancelation for the analog * headset path (PDM channels 1 and 2). */ -static int omap_mcpdm_set_offset(struct omap_mcpdm *mcpdm, - int offset1, int offset2) +static int omap_mcpdm_set_offset(struct omap_mcpdm *mcpdm) { int offset; - if ((offset1 > DN_OFST_MAX) || (offset2 > DN_OFST_MAX)) + if ((mcpdm->dl1_offset > DN_OFST_MAX) || + (mcpdm->dl2_offset > DN_OFST_MAX)) return -EINVAL; - offset = (offset1 << DN_OFST_RX1) | (offset2 << DN_OFST_RX2); + offset = (mcpdm->dl1_offset << DN_OFST_RX1) | + (mcpdm->dl2_offset << DN_OFST_RX2); /* offset cancellation for channel 1 */ - if (offset1) + if (mcpdm->dl1_offset) offset |= DN_OFST_RX1_EN; else offset &= ~DN_OFST_RX1_EN; /* offset cancellation for channel 2 */ - if (offset2) + if (mcpdm->dl2_offset) offset |= DN_OFST_RX2_EN; else offset &= ~DN_OFST_RX2_EN; @@ -681,6 +686,10 @@ static __devinit int asoc_mcpdm_probe(struct platform_device *pdev) mcpdm->dev = &pdev->dev; + /* TODO: values will be different per device, read from FS */ + mcpdm->dl1_offset = 0x1F; + mcpdm->dl2_offset = 0x1F; + ret = snd_soc_register_dais(&pdev->dev, omap_mcpdm_dai, ARRAY_SIZE(omap_mcpdm_dai)); if (ret == 0) diff --git a/sound/soc/omap/omap-mcpdm.h b/sound/soc/omap/omap-mcpdm.h index 108e434..4f2d292 100644 --- a/sound/soc/omap/omap-mcpdm.h +++ b/sound/soc/omap/omap-mcpdm.h @@ -125,9 +125,4 @@ struct omap_mcpdm_link { struct omap_mcpdm; -/* -extern int omap_mcpdm_set_offset(struct omap_mcpdm *mcpdm, - int offset1, int offset2); -*/ - #endif /* End of __OMAP_MCPDM_H__ */ -- 1.7.4.1