Skip to content

Commit 94ef278

Browse files
committed
Merge patch series "ASoC: Intel: catpt: Overhaul volume and mute control operations"
Cezary Rojewski <cezary.rojewski@intel.com> says: 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.
2 parents 4ba5c63 + 8a99ccb commit 94ef278

6 files changed

Lines changed: 169 additions & 227 deletions

File tree

sound/soc/intel/catpt/core.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ struct catpt_dev {
9696
struct catpt_module_type modules[CATPT_MODULE_COUNT];
9797
struct catpt_ssp_device_format devfmt[CATPT_SSP_COUNT];
9898
struct list_head stream_list;
99-
spinlock_t list_lock;
99+
struct mutex stream_mutex;
100100
struct mutex clk_mutex;
101101

102102
struct catpt_dx_context dx_ctx;

sound/soc/intel/catpt/device.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ static void catpt_dev_init(struct catpt_dev *cdev, struct device *dev,
226226
cdev->spec = spec;
227227
init_completion(&cdev->fw_ready);
228228
INIT_LIST_HEAD(&cdev->stream_list);
229-
spin_lock_init(&cdev->list_lock);
229+
mutex_init(&cdev->stream_mutex);
230230
mutex_init(&cdev->clk_mutex);
231231

232232
/*

sound/soc/intel/catpt/ipc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// Author: Cezary Rojewski <cezary.rojewski@intel.com>
66
//
77

8+
#include <linux/cleanup.h>
89
#include <linux/irqreturn.h>
910
#include "core.h"
1011
#include "messages.h"
@@ -151,6 +152,8 @@ catpt_dsp_notify_stream(struct catpt_dev *cdev, union catpt_notify_msg msg)
151152
struct catpt_notify_position pos;
152153
struct catpt_notify_glitch glitch;
153154

155+
guard(mutex)(&cdev->stream_mutex);
156+
154157
stream = catpt_stream_find(cdev, msg.stream_hw_id);
155158
if (!stream) {
156159
dev_warn(cdev->dev, "notify %d for non-existent stream %d\n",

sound/soc/intel/catpt/loader.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ int catpt_store_streams_context(struct catpt_dev *cdev, struct dma_chan *chan)
9090
{
9191
struct catpt_stream_runtime *stream;
9292

93+
/* Lockless as no streams can be added or removed during D3 -> D0 transition. */
9394
list_for_each_entry(stream, &cdev->stream_list, node) {
9495
u32 off, size;
9596
int ret;
@@ -180,6 +181,7 @@ catpt_restore_streams_context(struct catpt_dev *cdev, struct dma_chan *chan)
180181
{
181182
struct catpt_stream_runtime *stream;
182183

184+
/* Lockless as no streams can be added or removed during D3 -> D0 transition. */
183185
list_for_each_entry(stream, &cdev->stream_list, node) {
184186
u32 off, size;
185187
int ret;

sound/soc/intel/catpt/messages.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ struct catpt_fw_version {
6969
int catpt_ipc_get_fw_version(struct catpt_dev *cdev,
7070
struct catpt_fw_version *version);
7171

72+
/* PIN_IDs represent both, individual streams and the general mixer. */
7273
enum catpt_pin_id {
7374
CATPT_PIN_ID_SYSTEM = 0,
7475
CATPT_PIN_ID_REFERENCE = 1,
@@ -79,6 +80,8 @@ enum catpt_pin_id {
7980
CATPT_PIN_ID_MIXER = 7,
8081
CATPT_PIN_ID_BLUETOOTH_CAPTURE = 8,
8182
CATPT_PIN_ID_BLUETOOTH_RENDER = 9,
83+
/* 10 is reserved */
84+
CATPT_PIN_ID_INVALID = 11,
8285
};
8386

8487
enum catpt_path_id {

0 commit comments

Comments
 (0)