[alsa-devel] [PATCH 2/2] Davinci: DM365: Enable DaVinci Voice Codec support for DM365 EVM
From: Miguel Aguilar miguel.aguilar@ridgerun.com
It sets up one single card for the DM365 EVM with two subdevices: the AIC3x and the Voice Codec.
The general structures are defined at DM365 SoC file and the specific platform data structure for the EVM is defined at board file.
Signed-off-by: Miguel Aguilar miguel.aguilar@ridgerun.com --- arch/arm/mach-davinci/board-dm365-evm.c | 39 +++++++++++++++++++++++++++- arch/arm/mach-davinci/dm365.c | 37 ++++++++++++++++++++++++-- arch/arm/mach-davinci/include/mach/asp.h | 1 + arch/arm/mach-davinci/include/mach/dm365.h | 5 +++ arch/arm/mach-davinci/include/mach/mux.h | 2 + 5 files changed, 80 insertions(+), 4 deletions(-)
diff --git a/arch/arm/mach-davinci/board-dm365-evm.c b/arch/arm/mach-davinci/board-dm365-evm.c index 8d23972..74f3519 100644 --- a/arch/arm/mach-davinci/board-dm365-evm.c +++ b/arch/arm/mach-davinci/board-dm365-evm.c @@ -175,7 +175,43 @@ static struct at24_platform_data eeprom_info = { .context = (void *)0x7f00, };
-static struct snd_platform_data dm365_evm_snd_data; +static int dm365_snd_dma_event_mux(int device, int enable, int playback) +{ + static int tx_dma_mux = 0; + static int rx_dma_mux = 0; + + if (!enable) { + if (playback) + tx_dma_mux = 0; + else + rx_dma_mux = 0; + return 0; + } + + if (playback) { + if (tx_dma_mux == 1) + return -EBUSY; + if (device == 0) + davinci_cfg_reg(DM365_EVT2_ASP_TX); + else + davinci_cfg_reg(DM365_EVT2_VC_TX); + tx_dma_mux = 1; + } else { + if (rx_dma_mux == 1) + return -EBUSY; + if (device == 0) + davinci_cfg_reg(DM365_EVT3_ASP_RX); + else + davinci_cfg_reg(DM365_EVT3_VC_RX); + rx_dma_mux = 1; + } + + return 0; +} + +static struct snd_platform_data dm365_evm_snd_data = { + .dma_event_mux = &dm365_snd_dma_event_mux, +};
static struct i2c_board_info i2c_info[] = { { @@ -513,6 +549,7 @@ static __init void dm365_evm_init(void) evm_init_cpld();
dm365_init_asp(&dm365_evm_snd_data); + dm365_init_vc(&dm365_evm_snd_data); dm365_init_rtc();
#ifdef CONFIG_KEYBOARD_DAVINCI diff --git a/arch/arm/mach-davinci/dm365.c b/arch/arm/mach-davinci/dm365.c index cc3bae4..024cbab 100644 --- a/arch/arm/mach-davinci/dm365.c +++ b/arch/arm/mach-davinci/dm365.c @@ -455,7 +455,7 @@ static struct davinci_clk dm365_clks[] = { CLK(NULL, "timer3", &timer3_clk), CLK(NULL, "usb", &usb_clk), CLK("davinci_emac.1", NULL, &emac_clk), - CLK("voice_codec", NULL, &voicecodec_clk), + CLK("davinci_voicecodec", NULL, &voicecodec_clk), CLK("davinci-asp.0", NULL, &asp0_clk), CLK(NULL, "rto", &rto_clk), CLK(NULL, "mjcp", &mjcp_clk), @@ -604,6 +604,8 @@ INT_CFG(DM365, INT_IMX1_DISABLE, 24, 1, 0, false) INT_CFG(DM365, INT_NSF_ENABLE, 25, 1, 1, false) INT_CFG(DM365, INT_NSF_DISABLE, 25, 1, 0, false)
+EVT_CFG(DM365, EVT2_VC_TX, 0, 1, 1, false) +EVT_CFG(DM365, EVT3_VC_RX, 1, 1, 1, false) EVT_CFG(DM365, EVT2_ASP_TX, 0, 1, 0, false) EVT_CFG(DM365, EVT3_ASP_RX, 1, 1, 0, false) #endif @@ -835,6 +837,31 @@ static struct platform_device dm365_asp_device = { .resource = dm365_asp_resources, };
+static struct resource dm365_vc_resources[] = { + { + .start = DAVINCI_DM365_VC_BASE, + .end = DAVINCI_DM365_VC_BASE + SZ_1K - 1, + .flags = IORESOURCE_MEM, + }, + { + .start = DAVINCI_DMA_VC_TX, + .end = DAVINCI_DMA_VC_TX, + .flags = IORESOURCE_DMA, + }, + { + .start = DAVINCI_DMA_VC_RX, + .end = DAVINCI_DMA_VC_RX, + .flags = IORESOURCE_DMA, + }, +}; + +static struct platform_device dm365_vc_device = { + .name = "davinci_voicecodec", + .id = -1, + .num_resources = ARRAY_SIZE(dm365_vc_resources), + .resource = dm365_vc_resources, +}; + static struct resource dm365_rtc_resources[] = { { .start = DM365_RTC_BASE, @@ -985,12 +1012,16 @@ void __init dm365_init_asp(struct snd_platform_data *pdata) davinci_cfg_reg(DM365_MCBSP0_BDR); davinci_cfg_reg(DM365_MCBSP0_R); davinci_cfg_reg(DM365_MCBSP0_BFSR); - davinci_cfg_reg(DM365_EVT2_ASP_TX); - davinci_cfg_reg(DM365_EVT3_ASP_RX); dm365_asp_device.dev.platform_data = pdata; platform_device_register(&dm365_asp_device); }
+void __init dm365_init_vc(struct snd_platform_data *pdata) +{ + dm365_vc_device.dev.platform_data = pdata; + platform_device_register(&dm365_vc_device); +} + void __init dm365_init_ks(struct davinci_ks_platform_data *pdata) { davinci_cfg_reg(DM365_KEYSCAN); diff --git a/arch/arm/mach-davinci/include/mach/asp.h b/arch/arm/mach-davinci/include/mach/asp.h index 834725f..6a175eb 100644 --- a/arch/arm/mach-davinci/include/mach/asp.h +++ b/arch/arm/mach-davinci/include/mach/asp.h @@ -50,6 +50,7 @@ #define DAVINCI_ASP1_TX_INT IRQ_MBXINT
struct snd_platform_data { + int (*dma_event_mux)(int, int, int); u32 tx_dma_offset; u32 rx_dma_offset; enum dma_event_q eventq_no; /* event queue number */ diff --git a/arch/arm/mach-davinci/include/mach/dm365.h b/arch/arm/mach-davinci/include/mach/dm365.h index 3c07a88..50aeaec 100644 --- a/arch/arm/mach-davinci/include/mach/dm365.h +++ b/arch/arm/mach-davinci/include/mach/dm365.h @@ -31,8 +31,13 @@
#define DM365_RTC_BASE (0x01C69000)
+#define DAVINCI_DM365_VC_BASE (0x01D0C000) +#define DAVINCI_DMA_VC_TX 2 +#define DAVINCI_DMA_VC_RX 3 + void __init dm365_init(void); void __init dm365_init_asp(struct snd_platform_data *pdata); +void __init dm365_init_vc(struct snd_platform_data *pdata); void __init dm365_init_ks(struct davinci_ks_platform_data *pdata); void __init dm365_init_rtc(void);
diff --git a/arch/arm/mach-davinci/include/mach/mux.h b/arch/arm/mach-davinci/include/mach/mux.h index b60c693..2937c51 100644 --- a/arch/arm/mach-davinci/include/mach/mux.h +++ b/arch/arm/mach-davinci/include/mach/mux.h @@ -325,6 +325,8 @@ enum davinci_dm365_index { DM365_INT_NSF_DISABLE,
/* EDMA event muxing */ + DM365_EVT2_VC_TX, + DM365_EVT3_VC_RX, DM365_EVT2_ASP_TX, DM365_EVT3_ASP_RX, DM365_EVT26_MMC0_RX,
On Thu, Jan 07, 2010 at 04:17:21PM -0600, miguel.aguilar@ridgerun.com wrote:
if (device == 0)
davinci_cfg_reg(DM365_EVT2_ASP_TX);
else
davinci_cfg_reg(DM365_EVT2_VC_TX);
I'd be a bit more comfortable with this if it were using something more symbolic like a #define or enum rather than checking a bare number to work out which device it's talking to.
Otherwise this looks good, but I've no familiarity with DaVinci specifics so...
Mark Brown wrote:
On Thu, Jan 07, 2010 at 04:17:21PM -0600, miguel.aguilar@ridgerun.com wrote:
if (device == 0)
davinci_cfg_reg(DM365_EVT2_ASP_TX);
else
davinci_cfg_reg(DM365_EVT2_VC_TX);
I'd be a bit more comfortable with this if it were using something more symbolic like a #define or enum rather than checking a bare number to work out which device it's talking to.
Otherwise this looks good, but I've no familiarity with DaVinci specifics so...
The idea of these function is check at runtime if the user space application is requesting the AIC3x or the voice codec, then it will set the proper source for the dma channels, since the ASP and the Voice Codec share the same dma channels, so that's why use a #define doesn't make sense.
Can you check the part of this patch related to registering both codecs AIC3x and the voice codec?
Thank you,
Miguel Aguilar
On Fri, Jan 08, 2010 at 11:36:59AM -0600, Miguel Aguilar wrote:
Mark Brown wrote:
On Thu, Jan 07, 2010 at 04:17:21PM -0600, miguel.aguilar@ridgerun.com wrote:
if (device == 0)
davinci_cfg_reg(DM365_EVT2_ASP_TX);
else
davinci_cfg_reg(DM365_EVT2_VC_TX);
I'd be a bit more comfortable with this if it were using something more symbolic like a #define or enum rather than checking a bare number to work out which device it's talking to.
The idea of these function is check at runtime if the user space application is requesting the AIC3x or the voice codec, then it will set the proper source for the dma channels, since the ASP and the Voice Codec share the same dma channels, so that's why use a #define doesn't make sense.
I see what your code is doing but at the minute it's making this decision based on the device number that's being passed in by comparing it as a pure number. This seems fragile - something symbolic that joined things up a bit more wouldn't raise eyebrows in the same way.
Can you check the part of this patch related to registering both codecs AIC3x and the voice codec?
Like I say that all looks fine to me but I can't really check if the DaVinci code is idiomatic.
Mark Brown wrote:
On Fri, Jan 08, 2010 at 11:36:59AM -0600, Miguel Aguilar wrote:
Mark Brown wrote:
On Thu, Jan 07, 2010 at 04:17:21PM -0600, miguel.aguilar@ridgerun.com wrote:
if (device == 0)
davinci_cfg_reg(DM365_EVT2_ASP_TX);
else
davinci_cfg_reg(DM365_EVT2_VC_TX);
I'd be a bit more comfortable with this if it were using something more symbolic like a #define or enum rather than checking a bare number to work out which device it's talking to.
The idea of these function is check at runtime if the user space application is requesting the AIC3x or the voice codec, then it will set the proper source for the dma channels, since the ASP and the Voice Codec share the same dma channels, so that's why use a #define doesn't make sense.
I see what your code is doing but at the minute it's making this decision based on the device number that's being passed in by comparing it as a pure number. This seems fragile - something symbolic that joined things up a bit more wouldn't raise eyebrows in the same way.
Can you check the part of this patch related to registering both codecs AIC3x and the voice codec?
Like I say that all looks fine to me but I can't really check if the DaVinci code is idiomatic.
Is there any way to tell alsamixer to use the controls of one subdevice or the other?
On Mon, Jan 11, 2010 at 09:11:19AM -0600, Miguel Aguilar wrote:
Mark Brown wrote:
Can you check the part of this patch related to registering both codecs AIC3x and the voice codec?
Like I say that all looks fine to me but I can't really check if the DaVinci code is idiomatic.
Is there any way to tell alsamixer to use the controls of one subdevice or the other?
Not from the arch/arm stuff, but that's a machine driver issue anyway. If you really only want to use a single device then just don't hook up the other device in the machine driver and it'll never appear.
Mark Brown wrote:
On Mon, Jan 11, 2010 at 09:11:19AM -0600, Miguel Aguilar wrote:
Mark Brown wrote:
Can you check the part of this patch related to registering both codecs AIC3x and the voice codec?
Like I say that all looks fine to me but I can't really check if the DaVinci code is idiomatic.
Is there any way to tell alsamixer to use the controls of one subdevice or the other?
Not from the arch/arm stuff, but that's a machine driver issue anyway. If you really only want to use a single device then just don't hook up the other device in the machine driver and it'll never appear.
Do you think that I still using the approach of having both codecs registered in the same kernel? or should I get back to the initial approach of selecting the wanted codec from the configuration menu?
On Mon, Jan 11, 2010 at 09:53:43AM -0600, Miguel Aguilar wrote:
Do you think that I still using the approach of having both codecs registered in the same kernel? or should I get back to the initial approach of selecting the wanted codec from the configuration menu?
I certainly think that this is the best approach at least up until the machine driver in sound/soc/davinci. At that point we're currently going to be forced to make a decision, though for reference boards with both hooked up it'd be much better to make this a runtime decision.
Hi Mark,
I have a specific doubt about the codec_dev element snd_soc_device struct of the DM365 EVM.
Since I have two codecs on the EVM, I have two snd_soc_codec_device structures:
* AIC3x
struct snd_soc_codec_device soc_codec_dev_aic3x = { .probe = aic3x_probe, .remove = aic3x_remove, .suspend = aic3x_suspend, .resume = aic3x_resume, };
* Voice Codec
struct snd_soc_codec_device soc_codec_dev_cq93vc = { .probe = cq93vc_probe, .remove = cq93vc_remove, .suspend = cq93vc_suspend, .resume = cq93vc_resume, };
But I can set only one at a time in the dm365_evm_snd_devdata:
/* evm audio subsystem */ static struct snd_soc_device dm365_evm_snd_devdata = { .card = &dm365_snd_soc_card_evm, *** .codec_dev = &soc_codec_dev_aic3x, or .codec_dev = &soc_codec_dev_cq93vc, *** .codec_data = &aic3x_setup, };
So in case what is the proper way to do this?
Thanks,
Miguel Aguilar
On Tue, Jan 19, 2010 at 02:47:16PM -0600, Miguel Aguilar wrote:
But I can set only one at a time in the dm365_evm_snd_devdata:
...
So in case what is the proper way to do this?
For now use an ifdef in the machine driver. There's some work due to begin fairly shortly (I've CCed in my co-maintainer Liam who's actually going to be doing the work) to allow multiple CODECs to work simultaneously, if you put the ifdef in the machine driver now then it should be straightforward to update the machine driver to make use of this new feature when it's ready.
Mark Brown wrote:
On Tue, Jan 19, 2010 at 02:47:16PM -0600, Miguel Aguilar wrote:
But I can set only one at a time in the dm365_evm_snd_devdata:
...
So in case what is the proper way to do this?
For now use an ifdef in the machine driver. There's some work due to begin fairly shortly (I've CCed in my co-maintainer Liam who's actually going to be doing the work) to allow multiple CODECs to work simultaneously, if you put the ifdef in the machine driver now then it should be straightforward to update the machine driver to make use of this new feature when it's ready.
Ok, machine driver you mean sound/soc/davinci/davinci-evm.c file?
So at the moment I will use ifdef to choose by using the configuration menu one codec or the other one at time, as you said it should be straightforward to enable the AIC3x and the Voice Codec simultaneously.
Thanks, Miguel Aguilar
On Wed, Jan 20, 2010 at 08:32:17AM -0600, Miguel Aguilar wrote:
Ok, machine driver you mean sound/soc/davinci/davinci-evm.c file?
Yes.
So at the moment I will use ifdef to choose by using the configuration menu one codec or the other one at time, as you said it should be straightforward to enable the AIC3x and the Voice Codec simultaneously.
Sounds like a plan - hopefully even just as part of the generic update work.
miguel.aguilar@ridgerun.com writes:
From: Miguel Aguilar miguel.aguilar@ridgerun.com
It sets up one single card for the DM365 EVM with two subdevices: the AIC3x and the Voice Codec.
The general structures are defined at DM365 SoC file and the specific platform data structure for the EVM is defined at board file.
You don't describe how you changed the muxing to be dynamic etc.
Could also use a bit more description about how/when the new callback is intended to be used.
Signed-off-by: Miguel Aguilar miguel.aguilar@ridgerun.com
arch/arm/mach-davinci/board-dm365-evm.c | 39 +++++++++++++++++++++++++++- arch/arm/mach-davinci/dm365.c | 37 ++++++++++++++++++++++++-- arch/arm/mach-davinci/include/mach/asp.h | 1 + arch/arm/mach-davinci/include/mach/dm365.h | 5 +++ arch/arm/mach-davinci/include/mach/mux.h | 2 + 5 files changed, 80 insertions(+), 4 deletions(-)
diff --git a/arch/arm/mach-davinci/board-dm365-evm.c b/arch/arm/mach-davinci/board-dm365-evm.c index 8d23972..74f3519 100644 --- a/arch/arm/mach-davinci/board-dm365-evm.c +++ b/arch/arm/mach-davinci/board-dm365-evm.c @@ -175,7 +175,43 @@ static struct at24_platform_data eeprom_info = { .context = (void *)0x7f00, };
-static struct snd_platform_data dm365_evm_snd_data; +static int dm365_snd_dma_event_mux(int device, int enable, int playback)
I think enable and playback should be bool, no?
+{
- static int tx_dma_mux = 0;
- static int rx_dma_mux = 0;
these should be bool also.
also, scripts/checkpatch.pl should tell you you don't need to assign these statics to zero
- if (!enable) {
if (playback)
tx_dma_mux = 0;
else
rx_dma_mux = 0;
return 0;
- }
- if (playback) {
if (tx_dma_mux == 1)
return -EBUSY;
if (device == 0)
As Mark pointed out, for readability, rather than zero you should have some symbolic name, either a #define or enum of the options would greatly improve readability.
Kevin
davinci_cfg_reg(DM365_EVT2_ASP_TX);
else
davinci_cfg_reg(DM365_EVT2_VC_TX);
tx_dma_mux = 1;
- } else {
if (rx_dma_mux == 1)
return -EBUSY;
if (device == 0)
davinci_cfg_reg(DM365_EVT3_ASP_RX);
else
davinci_cfg_reg(DM365_EVT3_VC_RX);
rx_dma_mux = 1;
- }
- return 0;
+}
+static struct snd_platform_data dm365_evm_snd_data = {
- .dma_event_mux = &dm365_snd_dma_event_mux,
+};
static struct i2c_board_info i2c_info[] = { { @@ -513,6 +549,7 @@ static __init void dm365_evm_init(void) evm_init_cpld();
dm365_init_asp(&dm365_evm_snd_data);
- dm365_init_vc(&dm365_evm_snd_data); dm365_init_rtc();
#ifdef CONFIG_KEYBOARD_DAVINCI diff --git a/arch/arm/mach-davinci/dm365.c b/arch/arm/mach-davinci/dm365.c index cc3bae4..024cbab 100644 --- a/arch/arm/mach-davinci/dm365.c +++ b/arch/arm/mach-davinci/dm365.c @@ -455,7 +455,7 @@ static struct davinci_clk dm365_clks[] = { CLK(NULL, "timer3", &timer3_clk), CLK(NULL, "usb", &usb_clk), CLK("davinci_emac.1", NULL, &emac_clk),
- CLK("voice_codec", NULL, &voicecodec_clk),
- CLK("davinci_voicecodec", NULL, &voicecodec_clk), CLK("davinci-asp.0", NULL, &asp0_clk), CLK(NULL, "rto", &rto_clk), CLK(NULL, "mjcp", &mjcp_clk),
@@ -604,6 +604,8 @@ INT_CFG(DM365, INT_IMX1_DISABLE, 24, 1, 0, false) INT_CFG(DM365, INT_NSF_ENABLE, 25, 1, 1, false) INT_CFG(DM365, INT_NSF_DISABLE, 25, 1, 0, false)
+EVT_CFG(DM365, EVT2_VC_TX, 0, 1, 1, false) +EVT_CFG(DM365, EVT3_VC_RX, 1, 1, 1, false) EVT_CFG(DM365, EVT2_ASP_TX, 0, 1, 0, false) EVT_CFG(DM365, EVT3_ASP_RX, 1, 1, 0, false) #endif @@ -835,6 +837,31 @@ static struct platform_device dm365_asp_device = { .resource = dm365_asp_resources, };
+static struct resource dm365_vc_resources[] = {
- {
.start = DAVINCI_DM365_VC_BASE,
.end = DAVINCI_DM365_VC_BASE + SZ_1K - 1,
.flags = IORESOURCE_MEM,
- },
- {
.start = DAVINCI_DMA_VC_TX,
.end = DAVINCI_DMA_VC_TX,
.flags = IORESOURCE_DMA,
- },
- {
.start = DAVINCI_DMA_VC_RX,
.end = DAVINCI_DMA_VC_RX,
.flags = IORESOURCE_DMA,
- },
+};
+static struct platform_device dm365_vc_device = {
- .name = "davinci_voicecodec",
- .id = -1,
- .num_resources = ARRAY_SIZE(dm365_vc_resources),
- .resource = dm365_vc_resources,
+};
static struct resource dm365_rtc_resources[] = { { .start = DM365_RTC_BASE, @@ -985,12 +1012,16 @@ void __init dm365_init_asp(struct snd_platform_data *pdata) davinci_cfg_reg(DM365_MCBSP0_BDR); davinci_cfg_reg(DM365_MCBSP0_R); davinci_cfg_reg(DM365_MCBSP0_BFSR);
- davinci_cfg_reg(DM365_EVT2_ASP_TX);
- davinci_cfg_reg(DM365_EVT3_ASP_RX); dm365_asp_device.dev.platform_data = pdata; platform_device_register(&dm365_asp_device);
}
+void __init dm365_init_vc(struct snd_platform_data *pdata) +{
- dm365_vc_device.dev.platform_data = pdata;
- platform_device_register(&dm365_vc_device);
+}
void __init dm365_init_ks(struct davinci_ks_platform_data *pdata) { davinci_cfg_reg(DM365_KEYSCAN); diff --git a/arch/arm/mach-davinci/include/mach/asp.h b/arch/arm/mach-davinci/include/mach/asp.h index 834725f..6a175eb 100644 --- a/arch/arm/mach-davinci/include/mach/asp.h +++ b/arch/arm/mach-davinci/include/mach/asp.h @@ -50,6 +50,7 @@ #define DAVINCI_ASP1_TX_INT IRQ_MBXINT
struct snd_platform_data {
- int (*dma_event_mux)(int, int, int); u32 tx_dma_offset; u32 rx_dma_offset; enum dma_event_q eventq_no; /* event queue number */
diff --git a/arch/arm/mach-davinci/include/mach/dm365.h b/arch/arm/mach-davinci/include/mach/dm365.h index 3c07a88..50aeaec 100644 --- a/arch/arm/mach-davinci/include/mach/dm365.h +++ b/arch/arm/mach-davinci/include/mach/dm365.h @@ -31,8 +31,13 @@
#define DM365_RTC_BASE (0x01C69000)
+#define DAVINCI_DM365_VC_BASE (0x01D0C000) +#define DAVINCI_DMA_VC_TX 2 +#define DAVINCI_DMA_VC_RX 3
void __init dm365_init(void); void __init dm365_init_asp(struct snd_platform_data *pdata); +void __init dm365_init_vc(struct snd_platform_data *pdata); void __init dm365_init_ks(struct davinci_ks_platform_data *pdata); void __init dm365_init_rtc(void);
diff --git a/arch/arm/mach-davinci/include/mach/mux.h b/arch/arm/mach-davinci/include/mach/mux.h index b60c693..2937c51 100644 --- a/arch/arm/mach-davinci/include/mach/mux.h +++ b/arch/arm/mach-davinci/include/mach/mux.h @@ -325,6 +325,8 @@ enum davinci_dm365_index { DM365_INT_NSF_DISABLE,
/* EDMA event muxing */
- DM365_EVT2_VC_TX,
- DM365_EVT3_VC_RX, DM365_EVT2_ASP_TX, DM365_EVT3_ASP_RX, DM365_EVT26_MMC0_RX,
-- 1.6.0.4
Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Kevin Hilman wrote:
miguel.aguilar@ridgerun.com writes:
From: Miguel Aguilar miguel.aguilar@ridgerun.com
It sets up one single card for the DM365 EVM with two subdevices: the AIC3x and the Voice Codec.
The general structures are defined at DM365 SoC file and the specific platform data structure for the EVM is defined at board file.
You don't describe how you changed the muxing to be dynamic etc.
Could also use a bit more description about how/when the new callback is intended to be used.
Signed-off-by: Miguel Aguilar miguel.aguilar@ridgerun.com
arch/arm/mach-davinci/board-dm365-evm.c | 39 +++++++++++++++++++++++++++- arch/arm/mach-davinci/dm365.c | 37 ++++++++++++++++++++++++-- arch/arm/mach-davinci/include/mach/asp.h | 1 + arch/arm/mach-davinci/include/mach/dm365.h | 5 +++ arch/arm/mach-davinci/include/mach/mux.h | 2 + 5 files changed, 80 insertions(+), 4 deletions(-)
diff --git a/arch/arm/mach-davinci/board-dm365-evm.c b/arch/arm/mach-davinci/board-dm365-evm.c index 8d23972..74f3519 100644 --- a/arch/arm/mach-davinci/board-dm365-evm.c +++ b/arch/arm/mach-davinci/board-dm365-evm.c @@ -175,7 +175,43 @@ static struct at24_platform_data eeprom_info = { .context = (void *)0x7f00, };
-static struct snd_platform_data dm365_evm_snd_data; +static int dm365_snd_dma_event_mux(int device, int enable, int playback)
I think enable and playback should be bool, no?
+{
- static int tx_dma_mux = 0;
- static int rx_dma_mux = 0;
these should be bool also.
[MA]Your are right bool would be better
also, scripts/checkpatch.pl should tell you you don't need to assign these statics to zero
- if (!enable) {
if (playback)
tx_dma_mux = 0;
else
rx_dma_mux = 0;
return 0;
- }
- if (playback) {
if (tx_dma_mux == 1)
return -EBUSY;
if (device == 0)
As Mark pointed out, for readability, rather than zero you should have some symbolic name, either a #define or enum of the options would greatly improve readability.
Got it, I will do that, thanks.
Kevin
davinci_cfg_reg(DM365_EVT2_ASP_TX);
else
davinci_cfg_reg(DM365_EVT2_VC_TX);
tx_dma_mux = 1;
- } else {
if (rx_dma_mux == 1)
return -EBUSY;
if (device == 0)
davinci_cfg_reg(DM365_EVT3_ASP_RX);
else
davinci_cfg_reg(DM365_EVT3_VC_RX);
rx_dma_mux = 1;
- }
- return 0;
+}
+static struct snd_platform_data dm365_evm_snd_data = {
- .dma_event_mux = &dm365_snd_dma_event_mux,
+};
static struct i2c_board_info i2c_info[] = { { @@ -513,6 +549,7 @@ static __init void dm365_evm_init(void) evm_init_cpld();
dm365_init_asp(&dm365_evm_snd_data);
- dm365_init_vc(&dm365_evm_snd_data); dm365_init_rtc();
#ifdef CONFIG_KEYBOARD_DAVINCI diff --git a/arch/arm/mach-davinci/dm365.c b/arch/arm/mach-davinci/dm365.c index cc3bae4..024cbab 100644 --- a/arch/arm/mach-davinci/dm365.c +++ b/arch/arm/mach-davinci/dm365.c @@ -455,7 +455,7 @@ static struct davinci_clk dm365_clks[] = { CLK(NULL, "timer3", &timer3_clk), CLK(NULL, "usb", &usb_clk), CLK("davinci_emac.1", NULL, &emac_clk),
- CLK("voice_codec", NULL, &voicecodec_clk),
- CLK("davinci_voicecodec", NULL, &voicecodec_clk), CLK("davinci-asp.0", NULL, &asp0_clk), CLK(NULL, "rto", &rto_clk), CLK(NULL, "mjcp", &mjcp_clk),
@@ -604,6 +604,8 @@ INT_CFG(DM365, INT_IMX1_DISABLE, 24, 1, 0, false) INT_CFG(DM365, INT_NSF_ENABLE, 25, 1, 1, false) INT_CFG(DM365, INT_NSF_DISABLE, 25, 1, 0, false)
+EVT_CFG(DM365, EVT2_VC_TX, 0, 1, 1, false) +EVT_CFG(DM365, EVT3_VC_RX, 1, 1, 1, false) EVT_CFG(DM365, EVT2_ASP_TX, 0, 1, 0, false) EVT_CFG(DM365, EVT3_ASP_RX, 1, 1, 0, false) #endif @@ -835,6 +837,31 @@ static struct platform_device dm365_asp_device = { .resource = dm365_asp_resources, };
+static struct resource dm365_vc_resources[] = {
- {
.start = DAVINCI_DM365_VC_BASE,
.end = DAVINCI_DM365_VC_BASE + SZ_1K - 1,
.flags = IORESOURCE_MEM,
- },
- {
.start = DAVINCI_DMA_VC_TX,
.end = DAVINCI_DMA_VC_TX,
.flags = IORESOURCE_DMA,
- },
- {
.start = DAVINCI_DMA_VC_RX,
.end = DAVINCI_DMA_VC_RX,
.flags = IORESOURCE_DMA,
- },
+};
+static struct platform_device dm365_vc_device = {
- .name = "davinci_voicecodec",
- .id = -1,
- .num_resources = ARRAY_SIZE(dm365_vc_resources),
- .resource = dm365_vc_resources,
+};
static struct resource dm365_rtc_resources[] = { { .start = DM365_RTC_BASE, @@ -985,12 +1012,16 @@ void __init dm365_init_asp(struct snd_platform_data *pdata) davinci_cfg_reg(DM365_MCBSP0_BDR); davinci_cfg_reg(DM365_MCBSP0_R); davinci_cfg_reg(DM365_MCBSP0_BFSR);
- davinci_cfg_reg(DM365_EVT2_ASP_TX);
- davinci_cfg_reg(DM365_EVT3_ASP_RX); dm365_asp_device.dev.platform_data = pdata; platform_device_register(&dm365_asp_device);
}
+void __init dm365_init_vc(struct snd_platform_data *pdata) +{
- dm365_vc_device.dev.platform_data = pdata;
- platform_device_register(&dm365_vc_device);
+}
void __init dm365_init_ks(struct davinci_ks_platform_data *pdata) { davinci_cfg_reg(DM365_KEYSCAN); diff --git a/arch/arm/mach-davinci/include/mach/asp.h b/arch/arm/mach-davinci/include/mach/asp.h index 834725f..6a175eb 100644 --- a/arch/arm/mach-davinci/include/mach/asp.h +++ b/arch/arm/mach-davinci/include/mach/asp.h @@ -50,6 +50,7 @@ #define DAVINCI_ASP1_TX_INT IRQ_MBXINT
struct snd_platform_data {
- int (*dma_event_mux)(int, int, int); u32 tx_dma_offset; u32 rx_dma_offset; enum dma_event_q eventq_no; /* event queue number */
diff --git a/arch/arm/mach-davinci/include/mach/dm365.h b/arch/arm/mach-davinci/include/mach/dm365.h index 3c07a88..50aeaec 100644 --- a/arch/arm/mach-davinci/include/mach/dm365.h +++ b/arch/arm/mach-davinci/include/mach/dm365.h @@ -31,8 +31,13 @@
#define DM365_RTC_BASE (0x01C69000)
+#define DAVINCI_DM365_VC_BASE (0x01D0C000) +#define DAVINCI_DMA_VC_TX 2 +#define DAVINCI_DMA_VC_RX 3
void __init dm365_init(void); void __init dm365_init_asp(struct snd_platform_data *pdata); +void __init dm365_init_vc(struct snd_platform_data *pdata); void __init dm365_init_ks(struct davinci_ks_platform_data *pdata); void __init dm365_init_rtc(void);
diff --git a/arch/arm/mach-davinci/include/mach/mux.h b/arch/arm/mach-davinci/include/mach/mux.h index b60c693..2937c51 100644 --- a/arch/arm/mach-davinci/include/mach/mux.h +++ b/arch/arm/mach-davinci/include/mach/mux.h @@ -325,6 +325,8 @@ enum davinci_dm365_index { DM365_INT_NSF_DISABLE,
/* EDMA event muxing */
- DM365_EVT2_VC_TX,
- DM365_EVT3_VC_RX, DM365_EVT2_ASP_TX, DM365_EVT3_ASP_RX, DM365_EVT26_MMC0_RX,
-- 1.6.0.4
Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
participants (4)
-
Kevin Hilman
-
Mark Brown
-
Miguel Aguilar
-
miguel.aguilar@ridgerun.com