[PATCH] ASoC: intel: skylake: Drop superfluous mmap callback

Cezary Rojewski cezary.rojewski at intel.com
Mon Aug 2 10:07:12 CEST 2021


On 2021-07-30 8:20 PM, Takashi Iwai wrote:
> On Fri, 30 Jul 2021 15:59:54 +0200,
> Cezary Rojewski wrote:

...

>>
>> Thanks for the input, Takashi.
>> While I welcome the change, have two quick questions:
>>
>> 1) Does this impact hw_support_mmap() and its user behavior? i.e. is
>> there some implicit behavior change that skylake-users may experience
>> along the way?
> 
> hw_support_mmap() must return true for this case as long as you've set
> up the buffer in the right way (either preallocation or managed).

hw_support_mmap() has an 'if' checking substream->ops->mmap. ASoC 
framework won't assign snd_soc_pcm_component_mmap as mmap-ops in 
soc_new_pcm() if component_driver didn't provided custom handler.

This makes me believe function's behavior may change but I might as well 
be missing something here.

>> 2) Since snd_pcm_mmap_data() defaults to snd_pcm_lib_default_mmap()
>> why not update ops assignment - snd_pcm_set_ops() - in such a way that
>> if/else is no longer needed in the former?
> 
> Simply put: when the buffer is allocated via
> snd_pcm_set_managed_buffer*(), you can omit the mmap callback.
> The only case you need the mmap callback is only when a special buffer
> is used or it needs a special way of mmap itself.

Comment of my was more of a suggestion i.e. snd_pcm_mmap_data() has an 
if-statement:

if (substream->ops->mmap)
	err = substream->ops->mmap(substream, area);
else
	err = snd_pcm_lib-default_mmap(substream, area);

I believe this could be replaced by one-liner with snd_pcm_set_ops() 
modified: do the validity check + default assignment there instead.


Czarek


More information about the Alsa-devel mailing list