diff mbox series

[1/3] ASoC: omap-mcbsp: Fix latency value calculation for pm_qos

Message ID 20181114110623.30932-2-peter.ujfalusi@ti.com (mailing list archive)
State New, archived
Headers show
Series ASoC: omap: Fix and add pm_qos configuration | expand

Commit Message

Peter Ujfalusi Nov. 14, 2018, 11:06 a.m. UTC
The latency number is in usec for the pm_qos. Correct the calculation to
give us the time in usec

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 sound/soc/omap/omap-mcbsp.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Jarkko Nikula Nov. 18, 2018, 5:04 p.m. UTC | #1
On 11/14/18 1:06 PM, Peter Ujfalusi wrote:
> The latency number is in usec for the pm_qos. Correct the calculation to
> give us the time in usec
> 
> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
> ---
>  sound/soc/omap/omap-mcbsp.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c
> index e0ef4774c710..a395598f1f20 100644
> --- a/sound/soc/omap/omap-mcbsp.c
> +++ b/sound/soc/omap/omap-mcbsp.c
> @@ -999,9 +999,9 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
>  			pkt_size = channels;
>  		}
>  
> -		latency = ((((buffer_size - pkt_size) / channels) * 1000)
> -				 / (params->rate_num / params->rate_den));
> -
> +		latency = (buffer_size - pkt_size) / channels;
> +		latency = latency * USEC_PER_SEC /
> +			  (params->rate_num / params->rate_den);

Did I understand correctly this doesn't fix any audio issue but allows
CPU sleep longer or reach deeper sleep?
Peter Ujfalusi Nov. 19, 2018, 2:14 p.m. UTC | #2
On 2018-11-18 19:04, Jarkko Nikula wrote:
> On 11/14/18 1:06 PM, Peter Ujfalusi wrote:
>> The latency number is in usec for the pm_qos. Correct the calculation to
>> give us the time in usec
>>
>> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
>> ---
>>  sound/soc/omap/omap-mcbsp.c | 6 +++---
>>  1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c
>> index e0ef4774c710..a395598f1f20 100644
>> --- a/sound/soc/omap/omap-mcbsp.c
>> +++ b/sound/soc/omap/omap-mcbsp.c
>> @@ -999,9 +999,9 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
>>  			pkt_size = channels;
>>  		}
>>  
>> -		latency = ((((buffer_size - pkt_size) / channels) * 1000)
>> -				 / (params->rate_num / params->rate_den));
>> -
>> +		latency = (buffer_size - pkt_size) / channels;
>> +		latency = latency * USEC_PER_SEC /
>> +			  (params->rate_num / params->rate_den);
> 
> Did I understand correctly this doesn't fix any audio issue but allows
> CPU sleep longer or reach deeper sleep?

PM core will block any power state from where the wake-up would take
longer than the latency value.

The latency is in usec, this patch just fixing the calculation to get
the time in usec.

- Péter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
diff mbox series

Patch

diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c
index e0ef4774c710..a395598f1f20 100644
--- a/sound/soc/omap/omap-mcbsp.c
+++ b/sound/soc/omap/omap-mcbsp.c
@@ -999,9 +999,9 @@  static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
 			pkt_size = channels;
 		}
 
-		latency = ((((buffer_size - pkt_size) / channels) * 1000)
-				 / (params->rate_num / params->rate_den));
-
+		latency = (buffer_size - pkt_size) / channels;
+		latency = latency * USEC_PER_SEC /
+			  (params->rate_num / params->rate_den);
 		mcbsp->latency[substream->stream] = latency;
 
 		omap_mcbsp_set_threshold(substream, pkt_size);