Skip to content

ASoC: Intel: catpt: Overhaul volume and mute control operations

Cezary Rojewski linux-sound 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest5 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5ASoC: Intel: catpt: Synchronize stream accesssound/soc/intel/catpt/core.h sound/soc/intel/catpt/device.c sound/soc/intel/catpt/ipc.c +2 more+22 -120 replies
2/5ASoC: Intel: catpt: New volume and mute control operationssound/soc/intel/catpt/messages.h sound/soc/intel/catpt/pcm.c+152 -00 replies
3/5ASoC: Intel: catpt: Simplify procedure of applying user settingssound/soc/intel/catpt/pcm.c+33 -310 replies
4/5ASoC: Intel: catpt: Do not wake DSP just for volume setupsound/soc/intel/catpt/pcm.c+9 -00 replies
5/5ASoC: Intel: catpt: Migrate to the new control operationssound/soc/intel/catpt/pcm.c+6 -2370 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/5] ASoC: Intel: catpt: Overhaul volume and mute control operations

Short summary first, longer description later:

- fix the return code for kctl->put() - currently the driver returns '0' even if changes were done
- lower power consumption for kctl operations by waking the DSP only when some streaming is done. No streaming? Cache the values and inform the AudioDSP firmware later.
- drop the existing code duplication between individual and master volume controls

The very first patch addresses synchronization problem that exists when an individual control and its paired stream are manipulated by a user simultaneously. As the refactor integrates the fix in its new code, most of it gets shuffled but in case of a "refactor problem" I've decided to have it separated and leading the series. This way the problem is fixed even if refactor, for whatever reason, would be reverted.

--
More of in-depth explanation for the refactor, taken from commit 2:

The catpt-driver's volume and mute control operations always return '0' regardless if a change occurred or not. To conform to ALSA's interface, value '1' shall be returned when a change occurred.

The second major point is power consumption. Existing control operations always wake the DSP even if no streams are running. In such case waking the DSP just for the sake of updating the volume (or mute) settings on the firmware side is a waste of power. The provided implementation caches the values and updates the settings only when streams are being opened for streaming or are already running.

As changing existing code is non-trivial, provide new operations instead. The put() operation, which interests us the most, takes the following shape:

	// two values provided to put():
	// @pin_id - which stream given control relates to
	// @value_to_apply - the value from user

	if (control->existing_val == value_to_apply)
		return 0;

	runtime_stream = get_running_stream(pin_id);
	if (runtime_stream != NULL) {
		ret = send_ipc();
		if (ret)
			return ret;
	}

	control->existing_val = value_to_apply;
	return 1;

Adheres to ALSA's expectation and avoids sending IPCs if there is no change to be made.

Cezary Rojewski (5):
ASoC: Intel: catpt: Synchronize stream access
ASoC: Intel: catpt: New volume and mute control operations
ASoC: Intel: catpt: Simplify procedure of applying user settings
ASoC: Intel: catpt: Do not wake DSP just for volume setup
ASoC: Intel: catpt: Migrate to the new control operations

 sound/soc/intel/catpt/core.h     |   2 +-
 sound/soc/intel/catpt/device.c   |   2 +-
 sound/soc/intel/catpt/ipc.c      |   3 +
 sound/soc/intel/catpt/loader.c   |   2 +
 sound/soc/intel/catpt/messages.h |   3 +
 sound/soc/intel/catpt/pcm.c      | 394 +++++++++++++------------------
 6 files changed, 174 insertions(+), 232 deletions(-)
Signature · 1 line
2.34.1