]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ENGR00233570-2 ASRC: Use function pointer and hook to support ASRC loadable
authorGe Lei <b42127@freescale.com>
Thu, 15 Nov 2012 06:53:40 +0000 (14:53 +0800)
committerLothar Waßmann <LW@KARO-electronics.de>
Fri, 24 May 2013 06:35:43 +0000 (08:35 +0200)
In ASoC pcm platform driver, use function pointer(ASRC ops) and hook to call
the APIs in ASRC driver, so that the ASoC platform driver can support ASRC
loadable.

Signed-off-by: Ge Lei <b42127@freescale.com>
sound/soc/imx/imx-pcm-dma-mx2.c
sound/soc/imx/imx-pcm.h

index 3065dfd38b71084630a171a2157c0f88933f7e60..047a5db6c4919299ebb425155bfd8bc9ec63b87b 100644 (file)
 #include "imx-ssi.h"
 #include "imx-pcm.h"
 
+struct asrc_p2p_ops *asrc_pcm_p2p_ops;
+
+void asrc_p2p_hook(struct asrc_p2p_ops *asrc_p2p_ct)
+{
+       asrc_pcm_p2p_ops = asrc_p2p_ct;
+       return ;
+}
+EXPORT_SYMBOL(asrc_p2p_hook);
 
 static void audio_dma_irq(void *data)
 {
@@ -109,14 +117,16 @@ static int imx_ssi_asrc_dma_alloc(struct snd_pcm_substream *substream,
        iprtd->asrc_dma_data.peripheral_type = IMX_DMATYPE_ASRC;
        iprtd->asrc_dma_data.priority = DMA_PRIO_HIGH;
        iprtd->asrc_dma_data.dma_request =
-                       asrc_get_dma_request(iprtd->asrc_index, 1);
+                       iprtd->asrc_pcm_p2p_ops_ko->
+                               asrc_p2p_get_dma_request(iprtd->asrc_index, 1);
        iprtd->asrc_dma_chan = dma_request_channel(mask, asrc_filter, iprtd);
 
        if (!iprtd->asrc_dma_chan)
                goto error;
 
        slave_config.direction = DMA_TO_DEVICE;
-       slave_config.dst_addr = asrc_get_per_addr(iprtd->asrc_index, 1);
+       slave_config.dst_addr = iprtd->asrc_pcm_p2p_ops_ko->
+                                       asrc_p2p_per_addr(iprtd->asrc_index, 1);
        slave_config.dst_addr_width = buswidth;
        slave_config.dst_maxburst = dma_params->burstsize * buswidth;
 
@@ -127,7 +137,8 @@ static int imx_ssi_asrc_dma_alloc(struct snd_pcm_substream *substream,
        iprtd->asrc_p2p_dma_data.peripheral_type = IMX_DMATYPE_ASRC;
        iprtd->asrc_p2p_dma_data.priority = DMA_PRIO_HIGH;
        iprtd->asrc_p2p_dma_data.dma_request =
-                       asrc_get_dma_request(iprtd->asrc_index, 0);
+                       iprtd->asrc_pcm_p2p_ops_ko->
+                               asrc_p2p_get_dma_request(iprtd->asrc_index, 0);
        iprtd->asrc_p2p_dma_data.dma_request_p2p = dma_params->dma;
        iprtd->asrc_p2p_dma_chan =
                dma_request_channel(mask, asrc_p2p_filter, iprtd);
@@ -146,7 +157,8 @@ static int imx_ssi_asrc_dma_alloc(struct snd_pcm_substream *substream,
        }
 
        slave_config.direction = DMA_DEV_TO_DEV;
-       slave_config.src_addr = asrc_get_per_addr(iprtd->asrc_index, 0);
+       slave_config.src_addr = iprtd->asrc_pcm_p2p_ops_ko->
+                                       asrc_p2p_per_addr(iprtd->asrc_index, 0);
        slave_config.src_addr_width = buswidth;
        slave_config.src_maxburst = dma_params->burstsize * buswidth;
        slave_config.dst_addr = dma_params->dma_addr;
@@ -358,7 +370,8 @@ static int snd_imx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
                if (iprtd->asrc_enable) {
                        dmaengine_submit(iprtd->asrc_p2p_desc);
                        dmaengine_submit(iprtd->asrc_desc);
-                       asrc_start_conv(iprtd->asrc_index);
+                       iprtd->asrc_pcm_p2p_ops_ko->
+                                       asrc_p2p_start_conv(iprtd->asrc_index);
                        mdelay(1);
                } else {
                        dmaengine_submit(iprtd->desc);
@@ -371,7 +384,8 @@ static int snd_imx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
                if (iprtd->asrc_enable) {
                        dmaengine_terminate_all(iprtd->asrc_dma_chan);
                        dmaengine_terminate_all(iprtd->asrc_p2p_dma_chan);
-                       asrc_stop_conv(iprtd->asrc_index);
+                       iprtd->asrc_pcm_p2p_ops_ko->
+                                       asrc_p2p_stop_conv(iprtd->asrc_index);
                } else {
                        dmaengine_terminate_all(iprtd->dma_chan);
                }
@@ -428,6 +442,11 @@ static int snd_imx_open(struct snd_pcm_substream *substream)
                iprtd->p2p =
                        (struct asrc_p2p_params *)snd_soc_pcm_get_drvdata(rtd);
                iprtd->asrc_index = -1;
+               if (!asrc_pcm_p2p_ops) {
+                       pr_err("ASRC is not loaded!\n");
+                       return -EINVAL;
+               }
+               iprtd->asrc_pcm_p2p_ops_ko = asrc_pcm_p2p_ops;
        }
 
        runtime->private_data = iprtd;
index 9b5e1e03fd4024490a9a826997565644475a24dc..1b126be7a592bdc9435e05fb9dc1b91fe93fc292 100644 (file)
@@ -60,6 +60,7 @@ struct imx_pcm_runtime_data {
        struct dma_chan *dma_chan;
        struct imx_dma_data dma_data;
        int asrc_enable;
+       struct asrc_p2p_ops *asrc_pcm_p2p_ops_ko;
 
 #if defined(CONFIG_MXC_ASRC) || defined(CONFIG_IMX_HAVE_PLATFORM_IMX_ASRC)
        enum asrc_pair_index asrc_index;