Message ID | 1517304885-16750-1-git-send-email-sriramx.periyasamy@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Hi, On Jan 30 2018 18:34, Sriram Periyasamy wrote: > From: Ramesh Babu <ramesh.babu@intel.com> > > The "no-rewind" flag is introduced in alsa. > Application can use this flag to assure kernel driver > that rewind won't be exercised. Driver could use this > flag to alter it's buffering scheme to optimize power > and performance. > > Signed-off-by: Ramesh Babu <ramesh.babu@intel.com> > Signed-off-by: Sriram Periyasamy <sriramx.periyasamy@intel.com> > --- > aplay/aplay.c | 14 +++++++++++++- > 1 file changed, 13 insertions(+), 1 deletion(-) Current implementation of 'aplay' doesn't perform rewinding/forwarding, thus an additional of this option is surplus. > diff --git a/aplay/aplay.c b/aplay/aplay.c > index 6b740c281f8e..b50602a59024 100644 > --- a/aplay/aplay.c > +++ b/aplay/aplay.c > @@ -108,6 +108,7 @@ static snd_pcm_stream_t stream = SND_PCM_STREAM_PLAYBACK; > static int mmap_flag = 0; > static int interleaved = 1; > static int nonblock = 0; > +static int no_rewind = 0; > static volatile sig_atomic_t in_aborting = 0; > static u_char *audiobuf = NULL; > static snd_pcm_uframes_t chunk_size = 0; > @@ -229,6 +230,7 @@ _("Usage: %s [OPTION]... [FILE]...\n" > "-I, --separate-channels one file for each channel\n" > "-i, --interactive allow interactive operation from stdin\n" > "-m, --chmap=ch1,ch2,.. Give the channel map to override or follow\n" > +"-w, --no-rewind enables no rewind mode\n" > " --disable-resample disable automatic rate resample\n" > " --disable-channels disable automatic channel conversions\n" > " --disable-format disable automatic format conversions\n" > @@ -470,7 +472,7 @@ int main(int argc, char *argv[]) > { > int duration_or_sample = 0; > int option_index; > - static const char short_options[] = "hnlLD:qt:c:f:r:d:s:MNF:A:R:T:B:vV:IPCi" > + static const char short_options[] = "hnlLD:qt:c:f:r:d:s:w:MNF:A:R:T:B:vV:IPCi" > #ifdef CONFIG_SUPPORT_CHMAP > "m:" > #endif > @@ -514,6 +516,7 @@ int main(int argc, char *argv[]) > {"process-id-file", 1, 0, OPT_PROCESS_ID_FILE}, > {"use-strftime", 0, 0, OPT_USE_STRFTIME}, > {"interactive", 0, 0, 'i'}, > + {"no-rewind", 0, 0, 'w'}, > {"dump-hw-params", 0, 0, OPT_DUMP_HWPARAMS}, > {"fatal-errors", 0, 0, OPT_FATAL_ERRORS}, > #ifdef CONFIG_SUPPORT_CHMAP > @@ -753,6 +756,9 @@ int main(int argc, char *argv[]) > case 'i': > interactive = 1; > break; > + case 'w': > + no_rewind = 1; > + break; > case OPT_DISABLE_RESAMPLE: > open_mode |= SND_PCM_NO_AUTO_RESAMPLE; > break; > @@ -1396,6 +1402,12 @@ static void set_params(void) > &buffer_frames); > } > assert(err >= 0); > + > + if (no_rewind) { > + err = snd_pcm_hw_params_set_no_rewind(handle, params, 1); > + assert(err >= 0); > + } > + > monotonic = snd_pcm_hw_params_is_monotonic(params); > can_pause = snd_pcm_hw_params_can_pause(params); > err = snd_pcm_hw_params(handle, params); Regards Takashi Sakamoto
On 1/30/18 11:40 AM, Takashi Sakamoto wrote: > Hi, > > On Jan 30 2018 18:34, Sriram Periyasamy wrote: >> From: Ramesh Babu <ramesh.babu@intel.com> >> >> The "no-rewind" flag is introduced in alsa. >> Application can use this flag to assure kernel driver >> that rewind won't be exercised. Driver could use this >> flag to alter it's buffering scheme to optimize power >> and performance. >> >> Signed-off-by: Ramesh Babu <ramesh.babu@intel.com> >> Signed-off-by: Sriram Periyasamy <sriramx.periyasamy@intel.com> >> --- >> aplay/aplay.c | 14 +++++++++++++- >> 1 file changed, 13 insertions(+), 1 deletion(-) > > Current implementation of 'aplay' doesn't perform rewinding/forwarding, > thus an additional of this option is surplus. It helps tell the driver that rewinds won't be used and indirectly that the appl_ptr updates are passed to the hardware. Removing the option or making the functionality unconditional removes the freedom to test with or without this option. > >> diff --git a/aplay/aplay.c b/aplay/aplay.c >> index 6b740c281f8e..b50602a59024 100644 >> --- a/aplay/aplay.c >> +++ b/aplay/aplay.c >> @@ -108,6 +108,7 @@ static snd_pcm_stream_t stream = SND_PCM_STREAM_PLAYBACK; >> static int mmap_flag = 0; >> static int interleaved = 1; >> static int nonblock = 0; >> +static int no_rewind = 0; >> static volatile sig_atomic_t in_aborting = 0; >> static u_char *audiobuf = NULL; >> static snd_pcm_uframes_t chunk_size = 0; >> @@ -229,6 +230,7 @@ _("Usage: %s [OPTION]... [FILE]...\n" >> "-I, --separate-channels one file for each channel\n" >> "-i, --interactive allow interactive operation from stdin\n" >> "-m, --chmap=ch1,ch2,.. Give the channel map to override or follow\n" >> +"-w, --no-rewind enables no rewind mode\n" >> " --disable-resample disable automatic rate resample\n" >> " --disable-channels disable automatic channel conversions\n" >> " --disable-format disable automatic format conversions\n" >> @@ -470,7 +472,7 @@ int main(int argc, char *argv[]) >> { >> int duration_or_sample = 0; >> int option_index; >> - static const char short_options[] = "hnlLD:qt:c:f:r:d:s:MNF:A:R:T:B:vV:IPCi" >> + static const char short_options[] = "hnlLD:qt:c:f:r:d:s:w:MNF:A:R:T:B:vV:IPCi" >> #ifdef CONFIG_SUPPORT_CHMAP >> "m:" >> #endif >> @@ -514,6 +516,7 @@ int main(int argc, char *argv[]) >> {"process-id-file", 1, 0, OPT_PROCESS_ID_FILE}, >> {"use-strftime", 0, 0, OPT_USE_STRFTIME}, >> {"interactive", 0, 0, 'i'}, >> + {"no-rewind", 0, 0, 'w'}, >> {"dump-hw-params", 0, 0, OPT_DUMP_HWPARAMS}, >> {"fatal-errors", 0, 0, OPT_FATAL_ERRORS}, >> #ifdef CONFIG_SUPPORT_CHMAP >> @@ -753,6 +756,9 @@ int main(int argc, char *argv[]) >> case 'i': >> interactive = 1; >> break; >> + case 'w': >> + no_rewind = 1; >> + break; >> case OPT_DISABLE_RESAMPLE: >> open_mode |= SND_PCM_NO_AUTO_RESAMPLE; >> break; >> @@ -1396,6 +1402,12 @@ static void set_params(void) >> &buffer_frames); >> } >> assert(err >= 0); >> + >> + if (no_rewind) { >> + err = snd_pcm_hw_params_set_no_rewind(handle, params, 1); >> + assert(err >= 0); >> + } >> + >> monotonic = snd_pcm_hw_params_is_monotonic(params); >> can_pause = snd_pcm_hw_params_can_pause(params); >> err = snd_pcm_hw_params(handle, params); > > > Regards > > Takashi Sakamoto > _______________________________________________ > Alsa-devel mailing list > Alsa-devel@alsa-project.org > http://mailman.alsa-project.org/mailman/listinfo/alsa-devel >
Hi, On Jan 31 2018 09:14, Pierre-Louis Bossart wrote: > On 1/30/18 11:40 AM, Takashi Sakamoto wrote: >> Hi, >> >> On Jan 30 2018 18:34, Sriram Periyasamy wrote: >>> From: Ramesh Babu <ramesh.babu@intel.com> >>> >>> The "no-rewind" flag is introduced in alsa. >>> Application can use this flag to assure kernel driver >>> that rewind won't be exercised. Driver could use this >>> flag to alter it's buffering scheme to optimize power >>> and performance. >>> >>> Signed-off-by: Ramesh Babu <ramesh.babu@intel.com> >>> Signed-off-by: Sriram Periyasamy <sriramx.periyasamy@intel.com> >>> --- >>> aplay/aplay.c | 14 +++++++++++++- >>> 1 file changed, 13 insertions(+), 1 deletion(-) >> >> Current implementation of 'aplay' doesn't perform rewinding/forwarding, >> thus an additional of this option is surplus. > > It helps tell the driver that rewinds won't be used and indirectly that > the appl_ptr updates are passed to the hardware. > Removing the option or making the functionality unconditional removes > the freedom to test with or without this option. From name of this option, I understand that your intension is to set hardware parameter with your new flag 'SND_PCM_HW_PARAMS_NO_REWINDS' so that ALSA PCM core doesn't allow applications to perform rewinding/forwarding requests because your drivers for Intel ATOM platform with SSP (without HDA) and DSP core and specific firmwares including blobs for ALSA topology interface are not allowed to invalidate queued PCM frames in buffer dedicated to DMA transmission due to restrictions of the hardware. However, aplay is _not_ written to perform the rewinding/forwarding requests, thus we never check actual effects of the flag because it never kick your driver for the invalidation. Your new option for aplay has no practical meaning for running PCM runtime. I oppose an addition of this flag to keep this basic utility readable, understandable and being small for easy maintainance. At least, I'd not like to explain about an aim of this makeshift option every time to be asked by developers and users, instead of you. >>> diff --git a/aplay/aplay.c b/aplay/aplay.c >>> index 6b740c281f8e..b50602a59024 100644 >>> --- a/aplay/aplay.c >>> +++ b/aplay/aplay.c >>> @@ -108,6 +108,7 @@ static snd_pcm_stream_t stream = >>> SND_PCM_STREAM_PLAYBACK; >>> static int mmap_flag = 0; >>> static int interleaved = 1; >>> static int nonblock = 0; >>> +static int no_rewind = 0; >>> static volatile sig_atomic_t in_aborting = 0; >>> static u_char *audiobuf = NULL; >>> static snd_pcm_uframes_t chunk_size = 0; >>> @@ -229,6 +230,7 @@ _("Usage: %s [OPTION]... [FILE]...\n" >>> "-I, --separate-channels one file for each channel\n" >>> "-i, --interactive allow interactive operation from stdin\n" >>> "-m, --chmap=ch1,ch2,.. Give the channel map to override or follow\n" >>> +"-w, --no-rewind enables no rewind mode\n" >>> " --disable-resample disable automatic rate resample\n" >>> " --disable-channels disable automatic channel conversions\n" >>> " --disable-format disable automatic format conversions\n" >>> @@ -470,7 +472,7 @@ int main(int argc, char *argv[]) >>> { >>> int duration_or_sample = 0; >>> int option_index; >>> - static const char short_options[] = >>> "hnlLD:qt:c:f:r:d:s:MNF:A:R:T:B:vV:IPCi" >>> + static const char short_options[] = >>> "hnlLD:qt:c:f:r:d:s:w:MNF:A:R:T:B:vV:IPCi" >>> #ifdef CONFIG_SUPPORT_CHMAP >>> "m:" >>> #endif >>> @@ -514,6 +516,7 @@ int main(int argc, char *argv[]) >>> {"process-id-file", 1, 0, OPT_PROCESS_ID_FILE}, >>> {"use-strftime", 0, 0, OPT_USE_STRFTIME}, >>> {"interactive", 0, 0, 'i'}, >>> + {"no-rewind", 0, 0, 'w'}, >>> {"dump-hw-params", 0, 0, OPT_DUMP_HWPARAMS}, >>> {"fatal-errors", 0, 0, OPT_FATAL_ERRORS}, >>> #ifdef CONFIG_SUPPORT_CHMAP >>> @@ -753,6 +756,9 @@ int main(int argc, char *argv[]) >>> case 'i': >>> interactive = 1; >>> break; >>> + case 'w': >>> + no_rewind = 1; >>> + break; >>> case OPT_DISABLE_RESAMPLE: >>> open_mode |= SND_PCM_NO_AUTO_RESAMPLE; >>> break; >>> @@ -1396,6 +1402,12 @@ static void set_params(void) >>> &buffer_frames); >>> } >>> assert(err >= 0); >>> + >>> + if (no_rewind) { >>> + err = snd_pcm_hw_params_set_no_rewind(handle, params, 1); >>> + assert(err >= 0); >>> + } >>> + >>> monotonic = snd_pcm_hw_params_is_monotonic(params); >>> can_pause = snd_pcm_hw_params_can_pause(params); >>> err = snd_pcm_hw_params(handle, params); Takashi Sakamoto
On 2/6/18 6:41 PM, Takashi Sakamoto wrote: > Hi, > > On Jan 31 2018 09:14, Pierre-Louis Bossart wrote: >> On 1/30/18 11:40 AM, Takashi Sakamoto wrote: >>> Hi, >>> >>> On Jan 30 2018 18:34, Sriram Periyasamy wrote: >>>> From: Ramesh Babu <ramesh.babu@intel.com> >>>> >>>> The "no-rewind" flag is introduced in alsa. >>>> Application can use this flag to assure kernel driver >>>> that rewind won't be exercised. Driver could use this >>>> flag to alter it's buffering scheme to optimize power >>>> and performance. >>>> >>>> Signed-off-by: Ramesh Babu <ramesh.babu@intel.com> >>>> Signed-off-by: Sriram Periyasamy <sriramx.periyasamy@intel.com> >>>> --- >>>> aplay/aplay.c | 14 +++++++++++++- >>>> 1 file changed, 13 insertions(+), 1 deletion(-) >>> >>> Current implementation of 'aplay' doesn't perform rewinding/forwarding, >>> thus an additional of this option is surplus. >> >> It helps tell the driver that rewinds won't be used and indirectly >> that the appl_ptr updates are passed to the hardware. >> Removing the option or making the functionality unconditional removes >> the freedom to test with or without this option. > From name of this option, I understand that your intension is to set > hardware parameter with your new flag 'SND_PCM_HW_PARAMS_NO_REWINDS' so > that ALSA PCM core doesn't allow applications to perform > rewinding/forwarding requests because your drivers for Intel ATOM > platform with SSP (without HDA) and DSP core and specific firmwares > including blobs for ALSA topology interface are not allowed to > invalidate queued PCM frames in buffer dedicated to DMA transmission due > to restrictions of the hardware. This is actually for platforms using an HDaudio DMA (but not necessarily with an HDAUdio codec). And applications have the freedom to do whatever they want, it's just that the combination of optimized DMA handling and rewinds is not supported. We are not breaking applications, just enabling them to do better use of the platform. > > However, aplay is _not_ written to perform the rewinding/forwarding > requests, thus we never check actual effects of the flag because it > never kick your driver for the invalidation. Your new option for aplay > has no practical meaning for running PCM runtime. Your logic is only partially correct. Yes we don't test for the unsupported configuration (what would be the point?) but no the effect can be seen since the driver behavior changes and with the basic aplay since with this flag set the DMA handling is different. > > I oppose an addition of this flag to keep this basic utility readable, > understandable and being small for easy maintainance. At least, I'd not > like to explain about an aim of this makeshift option every time to be > asked by developers and users, instead of you. You suggested not so long ago to rewrite aplay and extend it to support the no-irq mode - not a simple option at all - , so I don't quite understand why you would object to a flag which makes better use of the hardware. Either all the flags are exposed or none are exposed. > >>>> diff --git a/aplay/aplay.c b/aplay/aplay.c >>>> index 6b740c281f8e..b50602a59024 100644 >>>> --- a/aplay/aplay.c >>>> +++ b/aplay/aplay.c >>>> @@ -108,6 +108,7 @@ static snd_pcm_stream_t stream = >>>> SND_PCM_STREAM_PLAYBACK; >>>> static int mmap_flag = 0; >>>> static int interleaved = 1; >>>> static int nonblock = 0; >>>> +static int no_rewind = 0; >>>> static volatile sig_atomic_t in_aborting = 0; >>>> static u_char *audiobuf = NULL; >>>> static snd_pcm_uframes_t chunk_size = 0; >>>> @@ -229,6 +230,7 @@ _("Usage: %s [OPTION]... [FILE]...\n" >>>> "-I, --separate-channels one file for each channel\n" >>>> "-i, --interactive allow interactive operation from stdin\n" >>>> "-m, --chmap=ch1,ch2,.. Give the channel map to override or >>>> follow\n" >>>> +"-w, --no-rewind enables no rewind mode\n" >>>> " --disable-resample disable automatic rate resample\n" >>>> " --disable-channels disable automatic channel conversions\n" >>>> " --disable-format disable automatic format conversions\n" >>>> @@ -470,7 +472,7 @@ int main(int argc, char *argv[]) >>>> { >>>> int duration_or_sample = 0; >>>> int option_index; >>>> - static const char short_options[] = >>>> "hnlLD:qt:c:f:r:d:s:MNF:A:R:T:B:vV:IPCi" >>>> + static const char short_options[] = >>>> "hnlLD:qt:c:f:r:d:s:w:MNF:A:R:T:B:vV:IPCi" >>>> #ifdef CONFIG_SUPPORT_CHMAP >>>> "m:" >>>> #endif >>>> @@ -514,6 +516,7 @@ int main(int argc, char *argv[]) >>>> {"process-id-file", 1, 0, OPT_PROCESS_ID_FILE}, >>>> {"use-strftime", 0, 0, OPT_USE_STRFTIME}, >>>> {"interactive", 0, 0, 'i'}, >>>> + {"no-rewind", 0, 0, 'w'}, >>>> {"dump-hw-params", 0, 0, OPT_DUMP_HWPARAMS}, >>>> {"fatal-errors", 0, 0, OPT_FATAL_ERRORS}, >>>> #ifdef CONFIG_SUPPORT_CHMAP >>>> @@ -753,6 +756,9 @@ int main(int argc, char *argv[]) >>>> case 'i': >>>> interactive = 1; >>>> break; >>>> + case 'w': >>>> + no_rewind = 1; >>>> + break; >>>> case OPT_DISABLE_RESAMPLE: >>>> open_mode |= SND_PCM_NO_AUTO_RESAMPLE; >>>> break; >>>> @@ -1396,6 +1402,12 @@ static void set_params(void) >>>> &buffer_frames); >>>> } >>>> assert(err >= 0); >>>> + >>>> + if (no_rewind) { >>>> + err = snd_pcm_hw_params_set_no_rewind(handle, params, 1); >>>> + assert(err >= 0); >>>> + } >>>> + >>>> monotonic = snd_pcm_hw_params_is_monotonic(params); >>>> can_pause = snd_pcm_hw_params_can_pause(params); >>>> err = snd_pcm_hw_params(handle, params); > > > Takashi Sakamoto
diff --git a/aplay/aplay.c b/aplay/aplay.c index 6b740c281f8e..b50602a59024 100644 --- a/aplay/aplay.c +++ b/aplay/aplay.c @@ -108,6 +108,7 @@ static snd_pcm_stream_t stream = SND_PCM_STREAM_PLAYBACK; static int mmap_flag = 0; static int interleaved = 1; static int nonblock = 0; +static int no_rewind = 0; static volatile sig_atomic_t in_aborting = 0; static u_char *audiobuf = NULL; static snd_pcm_uframes_t chunk_size = 0; @@ -229,6 +230,7 @@ _("Usage: %s [OPTION]... [FILE]...\n" "-I, --separate-channels one file for each channel\n" "-i, --interactive allow interactive operation from stdin\n" "-m, --chmap=ch1,ch2,.. Give the channel map to override or follow\n" +"-w, --no-rewind enables no rewind mode\n" " --disable-resample disable automatic rate resample\n" " --disable-channels disable automatic channel conversions\n" " --disable-format disable automatic format conversions\n" @@ -470,7 +472,7 @@ int main(int argc, char *argv[]) { int duration_or_sample = 0; int option_index; - static const char short_options[] = "hnlLD:qt:c:f:r:d:s:MNF:A:R:T:B:vV:IPCi" + static const char short_options[] = "hnlLD:qt:c:f:r:d:s:w:MNF:A:R:T:B:vV:IPCi" #ifdef CONFIG_SUPPORT_CHMAP "m:" #endif @@ -514,6 +516,7 @@ int main(int argc, char *argv[]) {"process-id-file", 1, 0, OPT_PROCESS_ID_FILE}, {"use-strftime", 0, 0, OPT_USE_STRFTIME}, {"interactive", 0, 0, 'i'}, + {"no-rewind", 0, 0, 'w'}, {"dump-hw-params", 0, 0, OPT_DUMP_HWPARAMS}, {"fatal-errors", 0, 0, OPT_FATAL_ERRORS}, #ifdef CONFIG_SUPPORT_CHMAP @@ -753,6 +756,9 @@ int main(int argc, char *argv[]) case 'i': interactive = 1; break; + case 'w': + no_rewind = 1; + break; case OPT_DISABLE_RESAMPLE: open_mode |= SND_PCM_NO_AUTO_RESAMPLE; break; @@ -1396,6 +1402,12 @@ static void set_params(void) &buffer_frames); } assert(err >= 0); + + if (no_rewind) { + err = snd_pcm_hw_params_set_no_rewind(handle, params, 1); + assert(err >= 0); + } + monotonic = snd_pcm_hw_params_is_monotonic(params); can_pause = snd_pcm_hw_params_can_pause(params); err = snd_pcm_hw_params(handle, params);