Skip to content

ASoC: SOF: ipc4-pcm: Look for best matching hw_config for SSP#5395

Merged
ranj063 merged 1 commit intothesofproject:topic/sof-devfrom
ujfalusi:peter/sof/pr/ipc4-pcm-clever-ssp-01
May 6, 2025
Merged

ASoC: SOF: ipc4-pcm: Look for best matching hw_config for SSP#5395
ranj063 merged 1 commit intothesofproject:topic/sof-devfrom
ujfalusi:peter/sof/pr/ipc4-pcm-clever-ssp-01

Conversation

@ujfalusi
Copy link
Collaborator

Instead of just looking for a hw_config with matching rate only it sounds better to try to find the best matching configuration.

If we have multiple hw_configurations with the same rate, but each with different format for example then we have been picking the first config with the matching rate, which can be a problem and it wil depend on how the configs are ordered.

Instead we should be trying to find the best match out of the configs

  1. rate + format + channels are matching
  2. rate + format are matching
  3. rate matching

/* best match found */
break;
} else if (matching_params < 2 &&
params_rate(params) == le32_to_cpu(hw_config->fsync_rate) &&
Copy link
Collaborator

Choose a reason for hiding this comment

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

Change second level to rate and channels and remove third level? Fail if first or second level match is not found. Copier can convert sample format but not rate and channels count.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

let me think about it a bit, this function was not able to fail before, even if it has not found the config.

Copy link

Choose a reason for hiding this comment

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

There could of course be some simple ranking about the formats if exact match is not found to prefer higher precision over lower, but in practice (only having s32 format available) this hardly matters.

Copy link
Collaborator Author

@ujfalusi ujfalusi Apr 30, 2025

Choose a reason for hiding this comment

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

I think with this we will find the exact match and if no exact config available then we pick the first one which have matching rate and channels. It can be up to debate which non exact match is the best one, but I feel that if we don't have the exact match available then we are already in a 'this is not going to end up right' space..

@ujfalusi ujfalusi force-pushed the peter/sof/pr/ipc4-pcm-clever-ssp-01 branch from 69e23a6 to bcba576 Compare April 29, 2025 10:46
Instead of just looking for a hw_config with matching rate only it sounds
better to try to find the best matching configuration.

If we have multiple hw_configurations with the same rate, but each with
different format for example then we have been picking the first config
with the matching rate, which can be a problem and it wil depend on how
the configs are ordered.

Instead we should be trying to find the best match out of the configs
1. rate + format + channels are matching
2. rate + format are matching
3. rate matching

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
@ujfalusi
Copy link
Collaborator Author

Changes since v1:

  • only two levels of match: full (rate, channels, format) and partial (rate, channels)
  • fail the match function if neither full or partial match is found.

/* best match found */
break;
} else if (matching_params < 2 &&
params_rate(params) == le32_to_cpu(hw_config->fsync_rate) &&
Copy link

Choose a reason for hiding this comment

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

There could of course be some simple ranking about the formats if exact match is not found to prefer higher precision over lower, but in practice (only having s32 format available) this hardly matters.

@ranj063 ranj063 merged commit 6c8d63d into thesofproject:topic/sof-dev May 6, 2025
8 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants