Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions sound/soc/soc-compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ static int soc_compr_open(struct snd_compr_stream *cstream)
static int soc_compr_alloc_fe_runtime(struct snd_soc_pcm_runtime *fe, int stream)
{
struct snd_pcm_substream *fe_substream = snd_soc_dpcm_get_substream(fe, stream);
struct snd_pcm_hw_constraints *constrs;
int i;

if (!fe_substream || fe_substream->runtime)
return 0;
Expand All @@ -154,6 +156,23 @@ static int soc_compr_alloc_fe_runtime(struct snd_soc_pcm_runtime *fe, int stream
if (!fe_substream->runtime)
return -ENOMEM;

/*
* snd_pcm_open() initializes the constraints of a PCM runtime to
* 'anything goes'. A zeroed one means an empty mask and a [0, 0]
* interval instead, which the constraint helpers refine against and
* reject, so initialize them the same way the PCM core does.
*
* The hw rules snd_pcm_hw_constraints_init() installs on top are only
* evaluated by snd_pcm_hw_refine(), which never runs for this
* substream, so they are not needed here.
*/
constrs = &fe_substream->runtime->hw_constraints;
for (i = SNDRV_PCM_HW_PARAM_FIRST_MASK; i <= SNDRV_PCM_HW_PARAM_LAST_MASK; i++)
snd_mask_any(constrs_mask(constrs, i));

for (i = SNDRV_PCM_HW_PARAM_FIRST_INTERVAL; i <= SNDRV_PCM_HW_PARAM_LAST_INTERVAL; i++)
snd_interval_any(constrs_interval(constrs, i));

Comment on lines +173 to +175

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The integer flag has a single consumer, snd_interval_refine(), where it only collapses openmin/openmax into closed bounds and propagates itself. The immediate helpers a BE startup() can call (snd_pcm_hw_constraint_minmax(), _integer(), _mask64()) all refine against a closed interval, so the result is identical with or without the flag pre-set, and snd_interval_refine() sets it itself for a closed single point interval.

Beyond that it only matters to snd_pcm_hw_refine(), which never runs for this substream, same as the hw rules the comment already mentions.

no followup for the change as of yet planned.

return 0;
}

Expand Down
Loading