mirror of
https://github.com/LineageOS/android_kernel_samsung_msm8226.git
synced 2026-09-28 00:00:22 +02:00
ASoC: msm: Remove hardcoded frame size dependency on sample rate.
The driver has hardcoded dependency for period size on sample rate. This restricts driver from being used for all sample rate and period size combinations. The driver also introduces an unnecessary delay in giving the first buffer to dsp both for playback and record case. resulting in delay in start of session. Change-Id: I9e0eb9b426e4f77c161dc7ef72b152d081979013 Signed-off-by: Asish Bhattacharya <asishb@codeaurora.org>
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
#include <sound/apr_audio.h>
|
||||
#include <sound/q6afe.h>
|
||||
#include <sound/msm-dai-q6.h>
|
||||
#include <sound/pcm_params.h>
|
||||
#include <mach/clk.h>
|
||||
|
||||
enum {
|
||||
@@ -286,27 +287,6 @@ static int msm_dai_q6_auxpcm_hw_params(
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_frame_size(u16 rate, u16 ch)
|
||||
{
|
||||
if (rate == 8000) {
|
||||
if (ch == 1)
|
||||
return 128 * 2;
|
||||
else
|
||||
return 128 * 2 * 2;
|
||||
} else if (rate == 16000) {
|
||||
if (ch == 1)
|
||||
return 128 * 2 * 2;
|
||||
else
|
||||
return 128 * 2 * 4;
|
||||
} else if (rate == 48000) {
|
||||
if (ch == 1)
|
||||
return 128 * 2 * 6;
|
||||
else
|
||||
return 128 * 2 * 12;
|
||||
} else
|
||||
return 128 * 2 * 12;
|
||||
}
|
||||
|
||||
static int msm_dai_q6_afe_rtproxy_hw_params(struct snd_pcm_hw_params *params,
|
||||
struct snd_soc_dai *dai)
|
||||
{
|
||||
@@ -321,8 +301,7 @@ static int msm_dai_q6_afe_rtproxy_hw_params(struct snd_pcm_hw_params *params,
|
||||
|
||||
dai_data->port_config.rtproxy.bitwidth = 16; /* Q6 only supports 16 */
|
||||
dai_data->port_config.rtproxy.interleaved = 1;
|
||||
dai_data->port_config.rtproxy.frame_sz = get_frame_size(dai_data->rate,
|
||||
dai_data->port_config.rtproxy.num_ch);
|
||||
dai_data->port_config.rtproxy.frame_sz = params_period_bytes(params);
|
||||
dai_data->port_config.rtproxy.jitter =
|
||||
dai_data->port_config.rtproxy.frame_sz/2;
|
||||
dai_data->port_config.rtproxy.lw_mark = 0;
|
||||
|
||||
+15
-23
@@ -63,7 +63,6 @@ static enum hrtimer_restart afe_hrtimer_callback(struct hrtimer *hrt)
|
||||
struct snd_pcm_substream *substream = prtd->substream;
|
||||
struct snd_pcm_runtime *runtime = substream->runtime;
|
||||
if (prtd->start) {
|
||||
snd_pcm_period_elapsed(prtd->substream);
|
||||
pr_debug("sending frame to DSP: poll_time: %d\n",
|
||||
prtd->poll_time);
|
||||
if (prtd->dsp_cnt == runtime->periods)
|
||||
@@ -74,10 +73,6 @@ static enum hrtimer_restart afe_hrtimer_callback(struct hrtimer *hrt)
|
||||
snd_pcm_lib_period_bytes(prtd->substream))),
|
||||
snd_pcm_lib_period_bytes(prtd->substream));
|
||||
prtd->dsp_cnt++;
|
||||
prtd->poll_time = ((unsigned long)((
|
||||
snd_pcm_lib_period_bytes(prtd->substream)
|
||||
* 1000 * 1000)/(runtime->rate
|
||||
* runtime->channels * 2)));
|
||||
hrtimer_forward_now(hrt, ns_to_ktime(prtd->poll_time
|
||||
* 1000));
|
||||
|
||||
@@ -99,10 +94,6 @@ static enum hrtimer_restart afe_hrtimer_rec_callback(struct hrtimer *hrt)
|
||||
* snd_pcm_lib_period_bytes(prtd->substream))),
|
||||
snd_pcm_lib_period_bytes(prtd->substream));
|
||||
prtd->dsp_cnt++;
|
||||
prtd->poll_time = ((unsigned long)((
|
||||
snd_pcm_lib_period_bytes(prtd->substream)
|
||||
* 1000 * 1000)/(runtime->rate
|
||||
* runtime->channels * 2)));
|
||||
pr_debug("sending frame rec to DSP: poll_time: %d\n",
|
||||
prtd->poll_time);
|
||||
hrtimer_forward_now(hrt, ns_to_ktime(prtd->poll_time
|
||||
@@ -140,11 +131,11 @@ static void pcm_afe_process_tx_pkt(uint32_t opcode,
|
||||
1000 * 1000)/
|
||||
(runtime->rate *
|
||||
runtime->channels * 2)));
|
||||
pr_info("prtd->poll_time: %d",
|
||||
pr_debug("prtd->poll_time: %d",
|
||||
prtd->poll_time);
|
||||
hrtimer_start(&prtd->hrt,
|
||||
ns_to_ktime(prtd->poll_time * 1000),
|
||||
HRTIMER_MODE_REL);
|
||||
ns_to_ktime(0),
|
||||
HRTIMER_MODE_REL);
|
||||
break;
|
||||
}
|
||||
case AFE_EVENT_RTPORT_STOP:
|
||||
@@ -169,6 +160,7 @@ static void pcm_afe_process_tx_pkt(uint32_t opcode,
|
||||
pr_debug("write done\n");
|
||||
prtd->pcm_irq_pos += snd_pcm_lib_period_bytes
|
||||
(prtd->substream);
|
||||
snd_pcm_period_elapsed(prtd->substream);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -208,9 +200,9 @@ static void pcm_afe_process_rx_pkt(uint32_t opcode,
|
||||
* 1000 * 1000)/(runtime->rate
|
||||
* runtime->channels * 2)));
|
||||
hrtimer_start(&prtd->hrt,
|
||||
ns_to_ktime(prtd->poll_time * 1000),
|
||||
HRTIMER_MODE_REL);
|
||||
pr_info("prtd->poll_time : %d", prtd->poll_time);
|
||||
ns_to_ktime(0),
|
||||
HRTIMER_MODE_REL);
|
||||
pr_debug("prtd->poll_time : %d", prtd->poll_time);
|
||||
break;
|
||||
}
|
||||
case AFE_EVENT_RTPORT_STOP:
|
||||
@@ -265,7 +257,7 @@ static int msm_afe_playback_prepare(struct snd_pcm_substream *substream)
|
||||
pr_err("afe-pcm:register for events failed\n");
|
||||
return ret;
|
||||
}
|
||||
pr_info("%s:success\n", __func__);
|
||||
pr_debug("%s:success\n", __func__);
|
||||
prtd->prepared++;
|
||||
return ret;
|
||||
}
|
||||
@@ -287,7 +279,7 @@ static int msm_afe_capture_prepare(struct snd_pcm_substream *substream)
|
||||
pr_err("afe-pcm:register for events failed\n");
|
||||
return ret;
|
||||
}
|
||||
pr_info("%s:success\n", __func__);
|
||||
pr_debug("%s:success\n", __func__);
|
||||
prtd->prepared++;
|
||||
return 0;
|
||||
}
|
||||
@@ -526,7 +518,7 @@ static int msm_asoc_pcm_new(struct snd_soc_pcm_runtime *rtd)
|
||||
struct snd_card *card = rtd->card->snd_card;
|
||||
int ret = 0;
|
||||
|
||||
pr_err("%s\n", __func__);
|
||||
pr_debug("%s\n", __func__);
|
||||
if (!card->dev->coherent_dma_mask)
|
||||
card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
|
||||
return ret;
|
||||
@@ -534,7 +526,7 @@ static int msm_asoc_pcm_new(struct snd_soc_pcm_runtime *rtd)
|
||||
|
||||
static int msm_afe_afe_probe(struct snd_soc_platform *platform)
|
||||
{
|
||||
pr_err("%s\n", __func__);
|
||||
pr_debug("%s\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -546,14 +538,14 @@ static struct snd_soc_platform_driver msm_soc_platform = {
|
||||
|
||||
static __devinit int msm_afe_probe(struct platform_device *pdev)
|
||||
{
|
||||
pr_info("%s: dev name %s\n", __func__, dev_name(&pdev->dev));
|
||||
pr_debug("%s: dev name %s\n", __func__, dev_name(&pdev->dev));
|
||||
return snd_soc_register_platform(&pdev->dev,
|
||||
&msm_soc_platform);
|
||||
}
|
||||
|
||||
static int msm_afe_remove(struct platform_device *pdev)
|
||||
{
|
||||
pr_err("%s\n", __func__);
|
||||
pr_debug("%s\n", __func__);
|
||||
snd_soc_unregister_platform(&pdev->dev);
|
||||
return 0;
|
||||
}
|
||||
@@ -569,14 +561,14 @@ static struct platform_driver msm_afe_driver = {
|
||||
|
||||
static int __init msm_soc_platform_init(void)
|
||||
{
|
||||
pr_err("%s\n", __func__);
|
||||
pr_debug("%s\n", __func__);
|
||||
return platform_driver_register(&msm_afe_driver);
|
||||
}
|
||||
module_init(msm_soc_platform_init);
|
||||
|
||||
static void __exit msm_soc_platform_exit(void)
|
||||
{
|
||||
pr_err("%s\n", __func__);
|
||||
pr_debug("%s\n", __func__);
|
||||
platform_driver_unregister(&msm_afe_driver);
|
||||
}
|
||||
module_exit(msm_soc_platform_exit);
|
||||
|
||||
Reference in New Issue
Block a user