Skip to content

Commit 0d2992d

Browse files
committed
Add DAPM/ASoC helpers to create SDCA drivers
Merge series from Charles Keepax <ckeepax@opensource.cirrus.com>: Add helper functions to add DAPM widgets, routes, ALSA controls, and DAI drivers, these will be used to create SDCA function device drivers. This series should provide most of the core functionality needed to get a device registered and have a working DAPM graph within the device. There are some features that still need additional work, these are marked with FIXMEs in the code. The two main things are SDCA Clock Muxes (not used in our devices and needs some ASoC core work), and better support for more complex SDCA volume control definitions (our parts have fairly simple volumes, and SDCA has a large amount of flexibility in how the volume control is specified). The next steps in the process are to add helpers for the DAI ops themselves, some IRQ handling, and firmware download. And finally we should be able to actually add the SDCA class driver itself.
2 parents 828497f + 108f878 commit 0d2992d

File tree

8 files changed

+1502
-25
lines changed

8 files changed

+1502
-25
lines changed

include/sound/sdca_asoc.h

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/*
3+
* The MIPI SDCA specification is available for public downloads at
4+
* https://www.mipi.org/mipi-sdca-v1-0-download
5+
*
6+
* Copyright (C) 2025 Cirrus Logic, Inc. and
7+
* Cirrus Logic International Semiconductor Ltd.
8+
*/
9+
10+
#ifndef __SDCA_ASOC_H__
11+
#define __SDCA_ASOC_H__
12+
13+
struct device;
14+
struct sdca_function_data;
15+
struct snd_kcontrol_new;
16+
struct snd_soc_component_driver;
17+
struct snd_soc_dai_driver;
18+
struct snd_soc_dai_ops;
19+
struct snd_soc_dapm_route;
20+
struct snd_soc_dapm_widget;
21+
22+
int sdca_asoc_count_component(struct device *dev, struct sdca_function_data *function,
23+
int *num_widgets, int *num_routes, int *num_controls,
24+
int *num_dais);
25+
26+
int sdca_asoc_populate_dapm(struct device *dev, struct sdca_function_data *function,
27+
struct snd_soc_dapm_widget *widgets,
28+
struct snd_soc_dapm_route *routes);
29+
int sdca_asoc_populate_controls(struct device *dev,
30+
struct sdca_function_data *function,
31+
struct snd_kcontrol_new *kctl);
32+
int sdca_asoc_populate_dais(struct device *dev, struct sdca_function_data *function,
33+
struct snd_soc_dai_driver *dais,
34+
const struct snd_soc_dai_ops *ops);
35+
36+
int sdca_asoc_populate_component(struct device *dev,
37+
struct sdca_function_data *function,
38+
struct snd_soc_component_driver *component_drv,
39+
struct snd_soc_dai_driver **dai_drv, int *num_dai_drv,
40+
const struct snd_soc_dai_ops *ops);
41+
42+
#endif // __SDCA_ASOC_H__

include/sound/sdca_function.h

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ struct sdca_init_write {
125125
* macros.
126126
*
127127
* Short hand to specific a Control type statically for example:
128-
* SDAC_CTL_TYPE_S(IT, MIC_BIAS).
128+
* SDCA_CTL_TYPE_S(IT, MIC_BIAS).
129129
*/
130130
#define SDCA_CTL_TYPE_S(ent, sel) SDCA_CTL_TYPE(SDCA_ENTITY_TYPE_##ent, \
131131
SDCA_CTL_##ent##_##sel)
@@ -168,6 +168,20 @@ enum sdca_ot_controls {
168168
SDCA_CTL_OT_NDAI_PACKETTYPE = 0x17,
169169
};
170170

171+
/**
172+
* enum sdca_usage_range - Column definitions for Usage
173+
*/
174+
enum sdca_usage_range {
175+
SDCA_USAGE_NUMBER = 0,
176+
SDCA_USAGE_CBN = 1,
177+
SDCA_USAGE_SAMPLE_RATE = 2,
178+
SDCA_USAGE_SAMPLE_WIDTH = 3,
179+
SDCA_USAGE_FULL_SCALE = 4,
180+
SDCA_USAGE_NOISE_FLOOR = 5,
181+
SDCA_USAGE_TAG = 6,
182+
SDCA_USAGE_NCOLS = 7,
183+
};
184+
171185
/**
172186
* enum sdca_mu_controls - SDCA Controls for Mixer Unit
173187
*
@@ -206,6 +220,16 @@ enum sdca_fu_controls {
206220
SDCA_CTL_FU_LATENCY = 0x10,
207221
};
208222

223+
/**
224+
* enum sdca_volume_range - Column definitions for Q7.8dB volumes/gains
225+
*/
226+
enum sdca_volume_range {
227+
SDCA_VOLUME_LINEAR_MIN = 0,
228+
SDCA_VOLUME_LINEAR_MAX = 1,
229+
SDCA_VOLUME_LINEAR_STEP = 2,
230+
SDCA_VOLUME_LINEAR_NCOLS = 3,
231+
};
232+
209233
/**
210234
* enum sdca_xu_controls - SDCA Controls for Extension Unit
211235
*
@@ -236,6 +260,15 @@ enum sdca_cs_controls {
236260
SDCA_CTL_CS_SAMPLERATEINDEX = 0x10,
237261
};
238262

263+
/**
264+
* enum sdca_samplerateindex_range - Column definitions for SampleRateIndex
265+
*/
266+
enum sdca_samplerateindex_range {
267+
SDCA_SAMPLERATEINDEX_INDEX = 0,
268+
SDCA_SAMPLERATEINDEX_RATE = 1,
269+
SDCA_SAMPLERATEINDEX_NCOLS = 2,
270+
};
271+
239272
/**
240273
* enum sdca_cx_controls - SDCA Controls for Clock Selector
241274
*
@@ -257,6 +290,14 @@ enum sdca_pde_controls {
257290
SDCA_CTL_PDE_ACTUAL_PS = 0x10,
258291
};
259292

293+
/**
294+
* enum sdca_requested_ps_range - Column definitions for Requested PS
295+
*/
296+
enum sdca_requested_ps_range {
297+
SDCA_REQUESTED_PS_STATE = 0,
298+
SDCA_REQUESTED_PS_NCOLS = 1,
299+
};
300+
260301
/**
261302
* enum sdca_ge_controls - SDCA Controls for Group Unit
262303
*
@@ -268,6 +309,15 @@ enum sdca_ge_controls {
268309
SDCA_CTL_GE_DETECTED_MODE = 0x02,
269310
};
270311

312+
/**
313+
* enum sdca_selected_mode_range - Column definitions for Selected Mode
314+
*/
315+
enum sdca_selected_mode_range {
316+
SDCA_SELECTED_MODE_INDEX = 0,
317+
SDCA_SELECTED_MODE_TERM_TYPE = 1,
318+
SDCA_SELECTED_MODE_NCOLS = 2,
319+
};
320+
271321
/**
272322
* enum sdca_spe_controls - SDCA Controls for Security & Privacy Unit
273323
*
@@ -773,6 +823,25 @@ enum sdca_terminal_type {
773823
SDCA_TERM_TYPE_PRIVACY_INDICATORS = 0x747,
774824
};
775825

826+
#define SDCA_TERM_TYPE_LINEIN_STEREO_NAME "LineIn Stereo"
827+
#define SDCA_TERM_TYPE_LINEIN_FRONT_LR_NAME "LineIn Front-LR"
828+
#define SDCA_TERM_TYPE_LINEIN_CENTER_LFE_NAME "LineIn Center-LFE"
829+
#define SDCA_TERM_TYPE_LINEIN_SURROUND_LR_NAME "LineIn Surround-LR"
830+
#define SDCA_TERM_TYPE_LINEIN_REAR_LR_NAME "LineIn Rear-LR"
831+
#define SDCA_TERM_TYPE_LINEOUT_STEREO_NAME "LineOut Stereo"
832+
#define SDCA_TERM_TYPE_LINEOUT_FRONT_LR_NAME "LineOut Front-LR"
833+
#define SDCA_TERM_TYPE_LINEOUT_CENTER_LFE_NAME "LineOut Center-LFE"
834+
#define SDCA_TERM_TYPE_LINEOUT_SURROUND_LR_NAME "LineOut Surround-LR"
835+
#define SDCA_TERM_TYPE_LINEOUT_REAR_LR_NAME "LineOut Rear-LR"
836+
#define SDCA_TERM_TYPE_MIC_JACK_NAME "Microphone"
837+
#define SDCA_TERM_TYPE_STEREO_JACK_NAME "Speaker Stereo"
838+
#define SDCA_TERM_TYPE_FRONT_LR_JACK_NAME "Speaker Front-LR"
839+
#define SDCA_TERM_TYPE_CENTER_LFE_JACK_NAME "Speaker Center-LFE"
840+
#define SDCA_TERM_TYPE_SURROUND_LR_JACK_NAME "Speaker Surround-LR"
841+
#define SDCA_TERM_TYPE_REAR_LR_JACK_NAME "Speaker Rear-LR"
842+
#define SDCA_TERM_TYPE_HEADPHONE_JACK_NAME "Headphone"
843+
#define SDCA_TERM_TYPE_HEADSET_JACK_NAME "Headset"
844+
776845
/**
777846
* enum sdca_connector_type - SDCA Connector Types
778847
*

include/sound/soc-dapm.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,10 @@ int snd_soc_dapm_get_pin_switch(struct snd_kcontrol *kcontrol,
445445
struct snd_ctl_elem_value *uncontrol);
446446
int snd_soc_dapm_put_pin_switch(struct snd_kcontrol *kcontrol,
447447
struct snd_ctl_elem_value *uncontrol);
448+
int snd_soc_dapm_get_component_pin_switch(struct snd_kcontrol *kcontrol,
449+
struct snd_ctl_elem_value *uncontrol);
450+
int snd_soc_dapm_put_component_pin_switch(struct snd_kcontrol *kcontrol,
451+
struct snd_ctl_elem_value *uncontrol);
448452
int snd_soc_dapm_new_controls(struct snd_soc_dapm_context *dapm,
449453
const struct snd_soc_dapm_widget *widget, unsigned int num);
450454
struct snd_soc_dapm_widget *snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,

sound/soc/sdca/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# SPDX-License-Identifier: GPL-2.0-only
22

3-
snd-soc-sdca-y := sdca_functions.o sdca_device.o sdca_regmap.o
3+
snd-soc-sdca-y := sdca_functions.o sdca_device.o sdca_regmap.o sdca_asoc.o
44

55
obj-$(CONFIG_SND_SOC_SDCA) += snd-soc-sdca.o

0 commit comments

Comments
 (0)