From 139e63bbb6a4666560f6e79ebb5db57e0681bb00 Mon Sep 17 00:00:00 2001 From: Ge Lei Date: Thu, 15 Nov 2012 14:46:19 +0800 Subject: [PATCH] ENGR00233570-1 ASRC: Use hook to add support for ASRC loadable ASoC ESAI machine driver and pcm platform driver use the APIs from mxc_asrc.c, but once ASRC is used as a loadable module, these files can't find the APIs from this ko. In this patch, we use 'asrc_p2p_hook' to hook the APIs which will be used in ASoC ESAI machine driver and pcm platform driver. Signed-off-by: Ge Lei --- drivers/mxc/asrc/mxc_asrc.c | 16 ++++++++++++++++ include/linux/mxc_asrc.h | 13 +++++++++++++ 2 files changed, 29 insertions(+) diff --git a/drivers/mxc/asrc/mxc_asrc.c b/drivers/mxc/asrc/mxc_asrc.c index d7edf78cc87d..6c5daed7ce53 100644 --- a/drivers/mxc/asrc/mxc_asrc.c +++ b/drivers/mxc/asrc/mxc_asrc.c @@ -154,6 +154,8 @@ static unsigned char output_clk_map_v2[] = { static unsigned char *input_clk_map, *output_clk_map; +struct asrc_p2p_ops asrc_pcm_p2p_ops_asrc; + static struct dma_chan *imx_asrc_dma_alloc(u32 dma_req); static int imx_asrc_dma_config( struct asrc_pair_params *params, @@ -2060,6 +2062,18 @@ static struct platform_driver mxc_asrc_driver = { static __init int asrc_init(void) { int ret; + + asrc_pcm_p2p_ops_asrc.asrc_p2p_start_conv = asrc_start_conv; + asrc_pcm_p2p_ops_asrc.asrc_p2p_stop_conv = asrc_stop_conv; + asrc_pcm_p2p_ops_asrc.asrc_p2p_get_dma_request = asrc_get_dma_request; + asrc_pcm_p2p_ops_asrc.asrc_p2p_per_addr = asrc_get_per_addr; + asrc_pcm_p2p_ops_asrc.asrc_p2p_req_pair = asrc_req_pair; + asrc_pcm_p2p_ops_asrc.asrc_p2p_config_pair = asrc_config_pair; + asrc_pcm_p2p_ops_asrc.asrc_p2p_release_pair = asrc_release_pair; + asrc_pcm_p2p_ops_asrc.asrc_p2p_finish_conv = asrc_finish_conv; + + asrc_p2p_hook(&asrc_pcm_p2p_ops_asrc); + ret = platform_driver_register(&mxc_asrc_driver); return ret; } @@ -2069,6 +2083,8 @@ static __init int asrc_init(void) * */ static void __exit asrc_exit(void) { + asrc_p2p_hook(NULL); + platform_driver_unregister(&mxc_asrc_driver); return; } diff --git a/include/linux/mxc_asrc.h b/include/linux/mxc_asrc.h index 72817e6ece0f..37c64b7c2200 100644 --- a/include/linux/mxc_asrc.h +++ b/include/linux/mxc_asrc.h @@ -259,6 +259,19 @@ struct asrc_data { struct device *dev; }; +struct asrc_p2p_ops { + void (*asrc_p2p_start_conv)(enum asrc_pair_index); + void (*asrc_p2p_stop_conv)(enum asrc_pair_index); + int (*asrc_p2p_get_dma_request)(enum asrc_pair_index, bool); + u32 (*asrc_p2p_per_addr)(enum asrc_pair_index, bool); + int (*asrc_p2p_req_pair)(int, enum asrc_pair_index *index); + int (*asrc_p2p_config_pair)(struct asrc_config *config); + void (*asrc_p2p_release_pair)(enum asrc_pair_index); + void (*asrc_p2p_finish_conv)(enum asrc_pair_index); +}; + +extern void asrc_p2p_hook(struct asrc_p2p_ops *asrc_p2p_ct); + extern int asrc_req_pair(int chn_num, enum asrc_pair_index *index); extern void asrc_release_pair(enum asrc_pair_index index); extern int asrc_config_pair(struct asrc_config *config); -- 2.39.5