Unverified Commit 2c8b3a8e authored by Charles Keepax's avatar Charles Keepax Committed by Mark Brown
Browse files

ASoC: SDCA: Create DAPM widgets and routes from DisCo



Use the previously parsed DisCo information from ACPI to create DAPM
widgets and routes representing a SDCA Function. For the most part SDCA
maps well to the DAPM abstractions.

The primary point of interest is the SDCA Power Domain Entities
(PDEs), which actually control the power status of the device. Whilst
these PDEs are the primary widgets the other parts of the SDCA graph
are added to maintain a consistency with the hardware abstract,
and allow routing to take effect. As for the PDEs themselves the
code currently only handle PS0 and PS3 (basically on and off),
the two intermediate power states are not commonly used and don't
map well to ASoC/DAPM.

Other minor points of slightly complexity include, the Group Entities
(GEs) these set the value of several other controls, typically
Selector Units (SUs) for enabling a cetain jack configuration. Multiple
SUs being controlled by a GE are easily modelled creating a single
control and sharing it among the controlled muxes.

SDCA also has a slight habit of having fully connected paths, relying
more on activating the PDEs to enable functionality. This doesn't
map quite so perfectly to DAPM which considers the path a reason to
power the PDE. Whilst in the current specification Mixer Units are
defined as fixed-function, in DAPM we create a virtual control for
each input (which defaults to connected). This allows paths to be
connected/disconnected, providing a more ASoC style approach to
managing the power. PIN_SWITCHs will also be added for non-dataport
terminal entities in a later patch along with the other ALSA controls,
providing greater flexibility in power management.

A top level helper sdca_asoc_populate_component() is exported that
counts and allocates everything, however, the intermediate counting and
population functions are also exported. This will allow end drivers to
do allocation and add custom handling, which is probably fairly likely
for the early SDCA devices.

Clock muxes are currently not fully supported, so some future work will
also be required there.

Signed-off-by: default avatarCharles Keepax <ckeepax@opensource.cirrus.com>
Reviewed-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.dev>
Link: https://patch.msgid.link/20250516131011.221310-6-ckeepax@opensource.cirrus.com


Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 737379e5
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * The MIPI SDCA specification is available for public downloads at
 * https://www.mipi.org/mipi-sdca-v1-0-download
 *
 * Copyright (C) 2025 Cirrus Logic, Inc. and
 *                    Cirrus Logic International Semiconductor Ltd.
 */

#ifndef __SDCA_ASOC_H__
#define __SDCA_ASOC_H__

struct device;
struct sdca_function_data;
struct snd_soc_component_driver;
struct snd_soc_dapm_route;
struct snd_soc_dapm_widget;

int sdca_asoc_count_component(struct device *dev, struct sdca_function_data *function,
			      int *num_widgets, int *num_routes);

int sdca_asoc_populate_dapm(struct device *dev, struct sdca_function_data *function,
			    struct snd_soc_dapm_widget *widgets,
			    struct snd_soc_dapm_route *routes);

int sdca_asoc_populate_component(struct device *dev,
				 struct sdca_function_data *function,
				 struct snd_soc_component_driver *component_drv);

#endif // __SDCA_ASOC_H__
+36 −0
Original line number Diff line number Diff line
@@ -257,6 +257,14 @@ enum sdca_pde_controls {
	SDCA_CTL_PDE_ACTUAL_PS				= 0x10,
};

/**
 * enum sdca_requested_ps_range - Column definitions for Requested PS
 */
enum sdca_requested_ps_range {
	SDCA_REQUESTED_PS_STATE				= 0,
	SDCA_REQUESTED_PS_NCOLS				= 1,
};

/**
 * enum sdca_ge_controls - SDCA Controls for Group Unit
 *
@@ -268,6 +276,15 @@ enum sdca_ge_controls {
	SDCA_CTL_GE_DETECTED_MODE			= 0x02,
};

/**
 * enum sdca_selected_mode_range - Column definitions for Selected Mode
 */
enum sdca_selected_mode_range {
	SDCA_SELECTED_MODE_INDEX			= 0,
	SDCA_SELECTED_MODE_TERM_TYPE			= 1,
	SDCA_SELECTED_MODE_NCOLS			= 2,
};

/**
 * enum sdca_spe_controls - SDCA Controls for Security & Privacy Unit
 *
@@ -773,6 +790,25 @@ enum sdca_terminal_type {
	SDCA_TERM_TYPE_PRIVACY_INDICATORS		= 0x747,
};

#define SDCA_TERM_TYPE_LINEIN_STEREO_NAME		"LineIn Stereo"
#define SDCA_TERM_TYPE_LINEIN_FRONT_LR_NAME		"LineIn Front-LR"
#define SDCA_TERM_TYPE_LINEIN_CENTER_LFE_NAME		"LineIn Center-LFE"
#define SDCA_TERM_TYPE_LINEIN_SURROUND_LR_NAME		"LineIn Surround-LR"
#define SDCA_TERM_TYPE_LINEIN_REAR_LR_NAME		"LineIn Rear-LR"
#define SDCA_TERM_TYPE_LINEOUT_STEREO_NAME		"LineOut Stereo"
#define SDCA_TERM_TYPE_LINEOUT_FRONT_LR_NAME		"LineOut Front-LR"
#define SDCA_TERM_TYPE_LINEOUT_CENTER_LFE_NAME		"LineOut Center-LFE"
#define SDCA_TERM_TYPE_LINEOUT_SURROUND_LR_NAME		"LineOut Surround-LR"
#define SDCA_TERM_TYPE_LINEOUT_REAR_LR_NAME		"LineOut Rear-LR"
#define SDCA_TERM_TYPE_MIC_JACK_NAME			"Microphone"
#define SDCA_TERM_TYPE_STEREO_JACK_NAME			"Speaker Stereo"
#define SDCA_TERM_TYPE_FRONT_LR_JACK_NAME		"Speaker Front-LR"
#define SDCA_TERM_TYPE_CENTER_LFE_JACK_NAME		"Speaker Center-LFE"
#define SDCA_TERM_TYPE_SURROUND_LR_JACK_NAME		"Speaker Surround-LR"
#define SDCA_TERM_TYPE_REAR_LR_JACK_NAME		"Speaker Rear-LR"
#define SDCA_TERM_TYPE_HEADPHONE_JACK_NAME		"Headphone"
#define SDCA_TERM_TYPE_HEADSET_JACK_NAME		"Headset"

/**
 * enum sdca_connector_type - SDCA Connector Types
 *
+1 −1
Original line number Diff line number Diff line
# SPDX-License-Identifier: GPL-2.0-only

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

obj-$(CONFIG_SND_SOC_SDCA)	+= snd-soc-sdca.o
+844 −0

File added.

Preview size limit exceeded, changes collapsed.