From: Grazvydas Ignotas Date: Sun, 14 Sep 2014 13:50:06 +0000 (+0300) Subject: ALSA: buffer size override hack X-Git-Tag: sz_173~90 X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?p=pandora-kernel.git;a=commitdiff_plain;h=58a0e70de7f3ccbcae2c8e868a3cf4e48c78930d ALSA: buffer size override hack bsp managed to get very low latency audio in his program even with smaller buffers than FIFO size, so allow to override it. Not removing limits for everything by default as that breaks many programs.. --- diff --git a/include/sound/pcm.h b/include/sound/pcm.h index 0cf91b2f08ca..9b4b888c8cae 100644 --- a/include/sound/pcm.h +++ b/include/sound/pcm.h @@ -366,6 +366,12 @@ struct snd_pcm_group { /* keep linked substreams */ struct pid; +struct snd_pnd_hack_params { + unsigned int frames_min; + unsigned int frames_max; + unsigned int reserved[14]; +}; + struct snd_pcm_substream { struct snd_pcm *pcm; struct snd_pcm_str *pstr; @@ -413,6 +419,8 @@ struct snd_pcm_substream { #endif /* misc flags */ unsigned int hw_opened: 1; + /* pandora hack */ + struct snd_pnd_hack_params pnd_hack_params; }; #define SUBSTREAM_BUSY(substream) ((substream)->ref_count > 0) diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 638600bb0e27..650afef50470 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -2585,6 +2585,15 @@ static int snd_pcm_common_ioctl1(struct file *file, snd_pcm_stream_unlock_irq(substream); return res; } + case _IOW('A', 0xfe, struct snd_pnd_hack_params): + { + /* pandora HACK */ + if (copy_from_user(&substream->pnd_hack_params, arg, + sizeof(substream->pnd_hack_params))) + return -EFAULT; + printk(KERN_INFO "%s hack set\n", __func__); + return 0; + } } snd_printd("unknown ioctl = 0x%x\n", cmd); return -ENOTTY; diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c index f7ee0e8ead92..308339f2f1d1 100644 --- a/sound/soc/omap/omap-mcbsp.c +++ b/sound/soc/omap/omap-mcbsp.c @@ -59,6 +59,8 @@ struct omap_mcbsp_data { unsigned int in_freq; int clk_div; int wlen; + /* pandora hack */ + struct snd_pcm_substream *substream; }; static struct omap_mcbsp_data mcbsp_data[NUM_LINKS]; @@ -110,6 +112,7 @@ static int omap_mcbsp_hwrule_min_buffersize(struct snd_pcm_hw_params *params, struct snd_interval *channels = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); struct omap_mcbsp_data *mcbsp_data = rule->private; + struct snd_pcm_substream *substream = mcbsp_data->substream; struct snd_interval frames; int size; @@ -118,6 +121,15 @@ static int omap_mcbsp_hwrule_min_buffersize(struct snd_pcm_hw_params *params, frames.min = size / channels->min; frames.integer = 1; + + if (substream && substream->pnd_hack_params.frames_min > 0 + && substream->pnd_hack_params.frames_max + >= substream->pnd_hack_params.frames_min) + { + frames.min = substream->pnd_hack_params.frames_min; + frames.max = substream->pnd_hack_params.frames_max; + } + return snd_interval_refine(buffer_size, &frames); } @@ -128,8 +140,10 @@ static int omap_mcbsp_dai_startup(struct snd_pcm_substream *substream, int bus_id = mcbsp_data->bus_id; int err = 0; - if (!cpu_dai->active) + if (!cpu_dai->active) { err = omap_mcbsp_request(bus_id); + mcbsp_data->substream = substream; + } /* * OMAP3 McBSP FIFO is word structured. @@ -173,6 +187,11 @@ static void omap_mcbsp_dai_shutdown(struct snd_pcm_substream *substream, if (!cpu_dai->active) { omap_mcbsp_free(mcbsp_data->bus_id); mcbsp_data->configured = 0; + + /* undo pandora hack */ + mcbsp_data->substream = NULL; + substream->pnd_hack_params.frames_min = 0; + substream->pnd_hack_params.frames_max = 0; } }