Message ID | 1512634956-17760-3-git-send-email-jiada_wang@mentor.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 2e2d53da81af6b2222c6b4e025a5d01b37b4449b |
Headers | show |
Hi Jiada > Further more, if the passed 'byte' amount to > rsnd_ssi_pointer_update() is more than byte_per_period. > the calculation of next_period_byte isn't correct. Is it really happen ?? Basically, I have no objection about this patch, but this explanation is very strange for me... Best regards --- Kuninori Morimoto
Hi Morimoto-san On 12/07/2017 01:58 AM, Kuninori Morimoto wrote: > Hi Jiada > >> Further more, if the passed 'byte' amount to >> rsnd_ssi_pointer_update() is more than byte_per_period. >> the calculation of next_period_byte isn't correct. > Is it really happen ?? > > Basically, I have no objection about this patch, > but this explanation is very strange for me... No, I didn't see the issue, but the implementation of rsnd_ssi_pointer_update(), behaves like it knows all caller will always pass 'byte' no larger than byte_per_period, without any check internally. I am ok to remove this explanation from commit message, what do you think? Thanks, Jiada > Best regards > --- > Kuninori Morimoto
Hi Jiada Thank you for your feedback > >> Further more, if the passed 'byte' amount to > >> rsnd_ssi_pointer_update() is more than byte_per_period. > >> the calculation of next_period_byte isn't correct. > > Is it really happen ?? > > > > Basically, I have no objection about this patch, > > but this explanation is very strange for me... > No, I didn't see the issue, > but the implementation of rsnd_ssi_pointer_update(), behaves like > it knows all caller will always pass 'byte' no larger than byte_per_period, > without any check internally. > > I am ok to remove this explanation from commit message, > what do you think? This function is used from PIO mode only now, and "byte" is sizeof(u32) (Its size was "byte_per_period" when DMA mode used). This "Further more" case never happen. Removing from commit message is better for reader, IMO. Best regards --- Kuninori Morimoto
diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index cbf3bf3..f212024 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c @@ -80,7 +80,6 @@ struct rsnd_ssi { unsigned int usrcnt; int byte_pos; - int period_pos; int byte_per_period; int next_period_byte; }; @@ -421,7 +420,6 @@ static void rsnd_ssi_pointer_init(struct rsnd_mod *mod, struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io); ssi->byte_pos = 0; - ssi->period_pos = 0; ssi->byte_per_period = runtime->period_size * runtime->channels * samples_to_bytes(runtime, 1); @@ -453,13 +451,12 @@ static bool rsnd_ssi_pointer_update(struct rsnd_mod *mod, if (byte_pos >= ssi->next_period_byte) { struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io); + int period_pos = byte_pos / ssi->byte_per_period; - ssi->period_pos++; - ssi->next_period_byte += ssi->byte_per_period; + ssi->next_period_byte = (period_pos + 1) * ssi->byte_per_period; - if (ssi->period_pos >= runtime->periods) { + if (period_pos >= runtime->periods) { byte_pos = 0; - ssi->period_pos = 0; ssi->next_period_byte = ssi->byte_per_period; }