Add DAPM/ASoC helpers to create SDCA drivers
Subsystems (3)
Charles Keepax
maintainercover Add DAPM/ASoC helpers to create SDCA drivers
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.
Thanks,
Charles
Charles Keepax (3):
ASoC: SDCA: Create DAPM widgets and routes from DisCo
ASoC: SDCA: Create ALSA controls from DisCo
ASoC: SDCA: Create DAI drivers from DisCo
include/sound/sdca_asoc.h | 42 ++ include/sound/sdca_function.h | 69 ++ sound/soc/sdca/Makefile | 2 +- sound/soc/sdca/sdca_asoc.c | 1183 +++++++++++++++++++++++++++++++++ 4 files changed, 1295 insertions(+), 1 deletion(-) create mode 100644 include/sound/sdca_asoc.h create mode 100644 sound/soc/sdca/sdca_asoc.c
Signature · 1 line
2.39.5
Charles Keepax
maintainerPATCH 1/3 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.
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. These 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. This allows paths to be connected/disconnected, providing a more ASoC style approach to managing the power.
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.
--- include/sound/sdca_asoc.h | 30 ++ include/sound/sdca_function.h | 36 ++ sound/soc/sdca/Makefile | 2 +- sound/soc/sdca/sdca_asoc.c | 799 ++++++++++++++++++++++++++++++++++ 4 files changed, 866 insertions(+), 1 deletion(-) create mode 100644 include/sound/sdca_asoc.h create mode 100644 sound/soc/sdca/sdca_asoc.c
include/sound/sdca_asoc.h new file +30 -0
@@ -0,0 +1,30 @@ +/* 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__
include/sound/sdca_function.h +36 -0
@@ -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 *
sound/soc/sdca/Makefile +1 -1
@@ -1,5 +1,5 @@ # 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
sound/soc/sdca/sdca_asoc.c new file +799 -0
799 lines not on this page · raw message
Signature · 1 line
2.39.5
Pierre-Louis Bossart
reviewerRe: [PATCH 1/3] ASoC: SDCA: Create DAPM widgets and routes from DisCo
Thanks for starting this Charles.
Quoted 3 lines
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.
except when it doesn't, eh?
Quoted 11 lines
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.
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. These are easily modelled creating a single control and sharing it among the controlled muxes.
It wasn't able to follow the last sentence, what are 'these'?
I am not sure we can expose and control any SUs since their configuration is set in hardware depending on the GE settings. IIRC the SU values should be considered as read-only.
Quoted 7 lines
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. This allows paths to be connected/disconnected, providing a more ASoC style approach to managing the power.
Humm, maybe my analysis was too naive but the SDCA PDE seemed like a DAPM power supply to me.
When a path becomes active, DAPM turns on the power for you, and power is turned off some time after the path becomes inactive.
Why would we need to have a control to force the power to be turned on?
And there are quite a few topologies without any Mixer Units so can we depend on a solution that's not applicable across all topologies? And last PDEs are typically related to terminals, while Mixer Units are usually for host-generated streams.
It would also help to define which power levels you wanted to control for PDEs. For me, only PS0 and PS3 can currently be modeled, I have no idea how PS1 with its degraded quality would be used, and PS2 depends on firmware.
Charles Keepax
maintainerRe: [PATCH 1/3] ASoC: SDCA: Create DAPM widgets and routes from DisCo
Quoted 6 lines · Pierre-Louis Bossart
Quoted 6 lines
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.
Quoted 7 lines
Quoted 5 lines
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. These are easily modelled creating a single control and sharing it among the controlled muxes.
It wasn't able to follow the last sentence, what are 'these'?
I will attempt to rephrase this paragraph a little, but 'these' are situations where you have a bunch of SUs controlled by a GE.
Quoted 3 lines
I am not sure we can expose and control any SUs since their configuration is set in hardware depending on the GE settings. IIRC the SU values should be considered as read-only.
The SUs are modelled as DAPM widgets but the control linked to all of the SUs is the GE control. So yes the SU registers are never accessed only the GE register.
Quoted 8 lines
Quoted 7 lines
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. This allows paths to be connected/disconnected, providing a more ASoC style approach to managing the power.
Quoted 4 lines
Humm, maybe my analysis was too naive but the SDCA PDE seemed like a DAPM power supply to me. When a path becomes active, DAPM turns on the power for you, and power is turned off some time after the path becomes inactive.
Correct, the PDEs are modeled as supply widgets and those are powered up when the path is active as normal. The problem alluded to in this paragraph is there a couple times where SDCA topologies just have a permanently connected path so things would always power up.
Quoted 1 line
Why would we need to have a control to force the power to be turned on?
We are not having a control to force the power on, that is me describing the SDCA view of the world, not the Linux ASoC view of the world.
Quoted 2 lines
And there are quite a few topologies without any Mixer Units so can we depend on a solution that's not applicable across all topologies?
Most of the time things are fine because most topologies generally go between a dataport terminal and a physical terminal, so the dataport can trigger power up. There are only two cases I am currently aware of where this happens at the moment, one is the side-tone path in the UAJ topology, which is primarily the one I was concerned about for now. The other is the sense path in the SmartAmp topology, which I am slightly less concerned about for now.
The sense path case can't be solved with the mixer switches. So eventually I think we will also need to add pin switches on the non-dataport terminals as well, but this is thinking I was hoping to delay for later.
However, we should really consider the wider mechanisms defined by the specification rather than just the given topologies. User-defined topologies are allowed and people will likely make small uncompliant diversions from the standard topologies as well.
My opinion is that even if we end up adding the pin switches as well it still makes sense to allow connecting and disconnecting the inputs of a Mixer Unit. These are typically where two audio streams come together and having the ability from the host side to say if you want that connection or not seems very valuable to me. As in SDCA land you basically make that choice by directly flipping the PDE.
Quoted 2 lines
And last PDEs are typically related to terminals, while Mixer Units are usually for host-generated streams.
From the view of DAPM I don't think we need to be too careful about that distinction. Its all just connections between widgets.
Quoted 4 lines
It would also help to define which power levels you wanted to control for PDEs. For me, only PS0 and PS3 can currently be modeled, I have no idea how PS1 with its degraded quality would be used, and PS2 depends on firmware.
Indeed, currently the code only deals with PS0 and PS3. I will update the commit message to call that out as well.
Thanks,
Charles
Pierre-Louis Bossart
reviewerRe: [PATCH 1/3] ASoC: SDCA: Create DAPM widgets and routes from DisCo
Quoted 13 lines · Charles Keepax
Quoted 12 lines · Pierre-Louis Bossart
Quoted 11 lines
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.
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. These are easily modelled creating a single control and sharing it among the controlled muxes.
Quoted 4 lines
Quoted 1 line
It wasn't able to follow the last sentence, what are 'these'?
I will attempt to rephrase this paragraph a little, but 'these' are situations where you have a bunch of SUs controlled by a GE.
In most cases the purpose of a GE is to control multiple SU states. However the SDCA spec took liberties with this concept and added new properties for the NDAI topologies, where a GE is present even if there is a single endpoint. It'd be worth double-checking that the way the GE is exposed in this patchset is forward-compatible with the 1.1 topologies.
Quoted 7 lines
Quoted 3 lines
I am not sure we can expose and control any SUs since their configuration is set in hardware depending on the GE settings. IIRC the SU values should be considered as read-only.
The SUs are modelled as DAPM widgets but the control linked to all of the SUs is the GE control. So yes the SU registers are never accessed only the GE register.
How would the state of those DAPM SU widgets be updated though? I think we need to 'translate' the GE settings to tell DAPM which paths can become active, but the SUs state is set by hardware so I could see a possible racy disconnect if we make a path activable but hardware hasn't done so yet.
Quoted 13 lines
Quoted 8 lines
Quoted 7 lines
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. This allows paths to be connected/disconnected, providing a more ASoC style approach to managing the power.
Quoted 4 lines
Humm, maybe my analysis was too naive but the SDCA PDE seemed like a DAPM power supply to me. When a path becomes active, DAPM turns on the power for you, and power is turned off some time after the path becomes inactive.
Quoted 5 lines
Correct, the PDEs are modeled as supply widgets and those are powered up when the path is active as normal. The problem alluded to in this paragraph is there a couple times where SDCA topologies just have a permanently connected path so things would always power up.
Ah yes those loops would indeed be problematic, but no more than in existing non-SDCA topologies where we used pin switches to disable such loops. All existing TDM-based solutions used pin switches, I was assuming we'd use them as well for SDCA.
Quoted 28 lines
Quoted 1 line
Why would we need to have a control to force the power to be turned on?
We are not having a control to force the power on, that is me describing the SDCA view of the world, not the Linux ASoC view of the world.
Quoted 2 lines
And there are quite a few topologies without any Mixer Units so can we depend on a solution that's not applicable across all topologies?
Most of the time things are fine because most topologies generally go between a dataport terminal and a physical terminal, so the dataport can trigger power up. There are only two cases I am currently aware of where this happens at the moment, one is the side-tone path in the UAJ topology, which is primarily the one I was concerned about for now. The other is the sense path in the SmartAmp topology, which I am slightly less concerned about for now.
The sense path case can't be solved with the mixer switches. So eventually I think we will also need to add pin switches on the non-dataport terminals as well, but this is thinking I was hoping to delay for later.
However, we should really consider the wider mechanisms defined by the specification rather than just the given topologies. User-defined topologies are allowed and people will likely make small uncompliant diversions from the standard topologies as well.
Quoted 7 lines
My opinion is that even if we end up adding the pin switches as well it still makes sense to allow connecting and disconnecting the inputs of a Mixer Unit. These are typically where two audio streams come together and having the ability from the host side to say if you want that connection or not seems very valuable to me. As in SDCA land you basically make that choice by directly flipping the PDE.
I have no objection if there are both pin switches and MU switches.
I view pin switches as a more generic mechanism that userpace has to set to use a specific endpoint.
The MU switches seem like debug capabilities to isolate which path has a problem. My experience fixing Baytrail issues is that you want a default mixer switch to be on, otherwise you'll get warnings on unconnected items or 'there is no sound' bug reports. In other words, the MU switches are a nice-to-have mechanism to disable default paths, so even if userspace doesn't touch those controls sound can be heard on endpoints.
Quoted 6 lines
Quoted 2 lines
And last PDEs are typically related to terminals, while Mixer Units are usually for host-generated streams.
From the view of DAPM I don't think we need to be too careful about that distinction. Its all just connections between widgets.
Quoted 7 lines
Quoted 4 lines
It would also help to define which power levels you wanted to control for PDEs. For me, only PS0 and PS3 can currently be modeled, I have no idea how PS1 with its degraded quality would be used, and PS2 depends on firmware.
Indeed, currently the code only deals with PS0 and PS3. I will update the commit message to call that out as well.
Sounds good.
Charles Keepax
maintainerRe: [PATCH 1/3] ASoC: SDCA: Create DAPM widgets and routes from DisCo
Quoted 8 lines · Pierre-Louis Bossart
Quoted 1 line · Charles Keepax
On Mon, Mar 24, 2025 at 04:15:24PM -0500, Pierre-Louis Bossart wrote:
In most cases the purpose of a GE is to control multiple SU states. However the SDCA spec took liberties with this concept and added new properties for the NDAI topologies, where a GE is present even if there is a single endpoint. It'd be worth double-checking that the way the GE is exposed in this patchset is forward-compatible with the 1.1 topologies.
I will go and double check but I can't see any reason why a GE controlling only a single entity would be a problem here.
Quoted 5 lines
How would the state of those DAPM SU widgets be updated though? I think we need to 'translate' the GE settings to tell DAPM which paths can become active, but the SUs state is set by hardware so I could see a possible racy disconnect if we make a path activable but hardware hasn't done so yet.
All the SU DAPM widgets are linked to the single GE control, the same ALSA control is shared across all the widgets. So all the paths are updated in a single DAPM sync, and on the hardware side with a single write to the GE control.
Quoted 19 lines
Quoted 13 lines
Quoted 8 lines
Quoted 7 lines
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. This allows paths to be connected/disconnected, providing a more ASoC style approach to managing the power.
Quoted 4 lines
Humm, maybe my analysis was too naive but the SDCA PDE seemed like a DAPM power supply to me. When a path becomes active, DAPM turns on the power for you, and power is turned off some time after the path becomes inactive.
Quoted 5 lines
Correct, the PDEs are modeled as supply widgets and those are powered up when the path is active as normal. The problem alluded to in this paragraph is there a couple times where SDCA topologies just have a permanently connected path so things would always power up.
Quoted 4 lines
Ah yes those loops would indeed be problematic, but no more than in existing non-SDCA topologies where we used pin switches to disable such loops. All existing TDM-based solutions used pin switches, I was assuming we'd use them as well for SDCA.
I wanted to do a little more thinking on it. The general concern I have is that typically the pin switches are added along with the "fabric" widgets in the machine driver. As this code here is effectively creating a single codec (function in SDCA land), it feels like it is probably inappropriate to hook up pin switchs at this level.
To put that as a more concrete example this code will create input widgets for IT 31, 32, 33 (the UAJ mics), however it would be unusual to hook a pin switch to those. Something should be creating an actual microphone widget, attaching that to the input widgets and attaching a pin switch to that. Typically those actions are handled in the machine driver, there is possibly an argument for handling them in the codec driver for SDCA but I felt it would make more sense to progress things a little further until resolving that one.
Quoted 13 lines
Quoted 7 lines
My opinion is that even if we end up adding the pin switches as well it still makes sense to allow connecting and disconnecting the inputs of a Mixer Unit. These are typically where two audio streams come together and having the ability from the host side to say if you want that connection or not seems very valuable to me. As in SDCA land you basically make that choice by directly flipping the PDE.
I have no objection if there are both pin switches and MU switches.
I view pin switches as a more generic mechanism that userpace has to set to use a specific endpoint.
Quoted 7 lines
The MU switches seem like debug capabilities to isolate which path has a problem. My experience fixing Baytrail issues is that you want a default mixer switch to be on, otherwise you'll get warnings on unconnected items or 'there is no sound' bug reports. In other words, the MU switches are a nice-to-have mechanism to disable default paths, so even if userspace doesn't touch those controls sound can be heard on endpoints.
The mixer switches do default to connected.
What I like about having mixer switches is it allows a clearer specification of intent. For example one can power the capture path and one can power the playback path, but the mixer switch makes it clear user-space has an intention to use the sidetone rather than just those two paths being powered coincidentally.
I could drop them for now and just have the mixers permanently connected, until we deal with pin switching, but I am inclined to leave it as is and we can revisit later if necessary.
Thanks,
Charles
Pierre-Louis Bossart
reviewerRe: [PATCH 1/3] ASoC: SDCA: Create DAPM widgets and routes from DisCo
Delayed answer, sorry...
Quoted 10 lines
Quoted 5 lines
How would the state of those DAPM SU widgets be updated though? I think we need to 'translate' the GE settings to tell DAPM which paths can become active, but the SUs state is set by hardware so I could see a possible racy disconnect if we make a path activable but hardware hasn't done so yet.
All the SU DAPM widgets are linked to the single GE control, the same ALSA control is shared across all the widgets. So all the paths are updated in a single DAPM sync, and on the hardware side with a single write to the GE control.
The race I am concerned about is between SU values represented in DAPM and actual values propagated inside the SDCA device. There could be a delay between writing a GE register and the SU register values changing.
Quoted 31 lines
Quoted 19 lines
Quoted 13 lines
Quoted 8 lines
Quoted 7 lines
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. This allows paths to be connected/disconnected, providing a more ASoC style approach to managing the power.
Quoted 4 lines
Humm, maybe my analysis was too naive but the SDCA PDE seemed like a DAPM power supply to me. When a path becomes active, DAPM turns on the power for you, and power is turned off some time after the path becomes inactive.
Quoted 5 lines
Correct, the PDEs are modeled as supply widgets and those are powered up when the path is active as normal. The problem alluded to in this paragraph is there a couple times where SDCA topologies just have a permanently connected path so things would always power up.
Quoted 4 lines
Ah yes those loops would indeed be problematic, but no more than in existing non-SDCA topologies where we used pin switches to disable such loops. All existing TDM-based solutions used pin switches, I was assuming we'd use them as well for SDCA.
I wanted to do a little more thinking on it. The general concern I have is that typically the pin switches are added along with the "fabric" widgets in the machine driver. As this code here is effectively creating a single codec (function in SDCA land), it feels like it is probably inappropriate to hook up pin switchs at this level.
Quoted 9 lines
To put that as a more concrete example this code will create input widgets for IT 31, 32, 33 (the UAJ mics), however it would be unusual to hook a pin switch to those. Something should be creating an actual microphone widget, attaching that to the input widgets and attaching a pin switch to that. Typically those actions are handled in the machine driver, there is possibly an argument for handling them in the codec driver for SDCA but I felt it would make more sense to progress things a little further until resolving that one.
The SDCA spec is supposed to describe what's physically connected, so when we parse the DisCo descriptors we should only see the level that is typically present in machine drivers. The codec descriptors are not generic at all, they should only describe a specific way of how a SDCA codec is used. The traditional split between codec and machine drivers does not really apply for SDCA, the SDCA descriptors represent the *machine* already.
Quoted 30 lines
Quoted 13 lines
Quoted 7 lines
My opinion is that even if we end up adding the pin switches as well it still makes sense to allow connecting and disconnecting the inputs of a Mixer Unit. These are typically where two audio streams come together and having the ability from the host side to say if you want that connection or not seems very valuable to me. As in SDCA land you basically make that choice by directly flipping the PDE.
I have no objection if there are both pin switches and MU switches.
I view pin switches as a more generic mechanism that userpace has to set to use a specific endpoint.
Quoted 7 lines
The MU switches seem like debug capabilities to isolate which path has a problem. My experience fixing Baytrail issues is that you want a default mixer switch to be on, otherwise you'll get warnings on unconnected items or 'there is no sound' bug reports. In other words, the MU switches are a nice-to-have mechanism to disable default paths, so even if userspace doesn't touch those controls sound can be heard on endpoints.
The mixer switches do default to connected.
What I like about having mixer switches is it allows a clearer specification of intent. For example one can power the capture path and one can power the playback path, but the mixer switch makes it clear user-space has an intention to use the sidetone rather than just those two paths being powered coincidentally.
Quoted 3 lines
I could drop them for now and just have the mixers permanently connected, until we deal with pin switching, but I am inclined to leave it as is and we can revisit later if necessary.
I bet we'll revisit this multiple times :-)
Charles Keepax
maintainerRe: [PATCH 1/3] ASoC: SDCA: Create DAPM widgets and routes from DisCo
Quoted 11 lines · Pierre-Louis Bossart
Quoted 10 lines
Quoted 5 lines
How would the state of those DAPM SU widgets be updated though? I think we need to 'translate' the GE settings to tell DAPM which paths can become active, but the SUs state is set by hardware so I could see a possible racy disconnect if we make a path activable but hardware hasn't done so yet.
All the SU DAPM widgets are linked to the single GE control, the same ALSA control is shared across all the widgets. So all the paths are updated in a single DAPM sync, and on the hardware side with a single write to the GE control.
Quoted 4 lines
The race I am concerned about is between SU values represented in DAPM and actual values propagated inside the SDCA device. There could be a delay between writing a GE register and the SU register values changing.
Fair enough, but I don't see why this matters. Those SU registers are device level, it is the devices business to manage them. Why does it matter if there is a delay updating them? All the widgets on the host side are controlled by the GE control.
Quoted 10 lines
Quoted 9 lines
To put that as a more concrete example this code will create input widgets for IT 31, 32, 33 (the UAJ mics), however it would be unusual to hook a pin switch to those. Something should be creating an actual microphone widget, attaching that to the input widgets and attaching a pin switch to that. Typically those actions are handled in the machine driver, there is possibly an argument for handling them in the codec driver for SDCA but I felt it would make more sense to progress things a little further until resolving that one.
Quoted 4 lines
The SDCA spec is supposed to describe what's physically connected, so when we parse the DisCo descriptors we should only see the level that is typically present in machine drivers.
That's not entirely true, none of the interconnections between codecs are contained. Microsoft invented that composition stuff to hold that sort of stuff. Although perhaps there is a strong case that the IT/OTs here are defined as having a mic/speaker connected so it is the right place to define them?
Quoted 5 lines
The codec descriptors are not generic at all, they should only describe a specific way of how a SDCA codec is used. The traditional split between codec and machine drivers does not really apply for SDCA, the SDCA descriptors represent the *machine* already.
I guess that makes your opinion very much that we do add the mic/speaker widgets at this level. I mean it wouldn't take long to add them. I am still not totally as sure, but we can probably live with a little more effort to back it out if we need it. I will do a v4 and see what adding those in looks like.
Thanks,
Charles
Charles Keepax
maintainerRe: [PATCH 1/3] ASoC: SDCA: Create DAPM widgets and routes from DisCo
In reply to Charles KeepaxQuoted 1 line · Charles Keepax
+#define
SDCA_TERM_TYPE_MIC_JACK_NAME"Microphone "
Whoops extra space in the string here, will fix in v2, when I update the commit message for Pierre's comments anyway.
Thanks,
Charles
Charles Keepax
maintainerPATCH 2/3 ASoC: SDCA: Create ALSA controls from DisCo
In reply to Charles KeepaxUse the previously parsed DisCo information from ACPI to create the ALSA controls required by an SDCA Function. This maps all User and Application level SDCA Controls to ALSA controls. Typically controls marked with those access levels are just volumes and mutes.
SDCA defines volume controls as an integer in 1/256ths of a dB and then provides a mechanism to specify what values are valid (range templates). Currently only a simple case of a single linear volume range with a power of 2 step size is supported. This allows the code to expose the volume control using a simple shift. This will need expanded in the future, to support more complex ranges and probably also some additional control types but this should be sufficient to for a first pass.
--- include/sound/sdca_asoc.h | 6 +- include/sound/sdca_function.h | 10 ++ sound/soc/sdca/sdca_asoc.c | 191 +++++++++++++++++++++++++++++++++- 3 files changed, 202 insertions(+), 5 deletions(-)
include/sound/sdca_asoc.h +5 -1
@@ -12,16 +12,20 @@struct device ;struct sdca_function_data ; +struct snd_kcontrol_new ;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 *num_widgets,int *num_routes,int *num_controls);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_controls (struct device *dev, +struct sdca_function_data *function, +struct snd_kcontrol_new *kctl); int sdca_asoc_populate_component(struct device *dev, struct sdca_function_data *function,
include/sound/sdca_function.h +10 -0
@@ -206,6 +206,16 @@ enum sdca_fu_controls { SDCA_CTL_FU_LATENCY = 0x10, }; +/** +* enum sdca_volume_range - Column definitions for Q7.8dB volumes/gains +*/ +enum sdca_volume_range { +SDCA_VOLUME_LINEAR_MIN =0 , +SDCA_VOLUME_LINEAR_MAX =1 , +SDCA_VOLUME_LINEAR_STEP =2 , +SDCA_VOLUME_LINEAR_NCOLS =3 , +}; +/** * enum sdca_xu_controls - SDCA Controls for Extension Unit *
sound/soc/sdca/sdca_asoc.c +187 -4
242 lines not on this page · raw message
Signature · 1 line
2.39.5
Charles Keepax
maintainerPATCH 3/3 ASoC: SDCA: Create DAI drivers from DisCo
In reply to Charles KeepaxUse the previously parsed DisCo information from ACPI to create the DAI drivers required to connect an SDCA Function into an ASoC soundcard.
Create DAI driver structures and populate the supported sample rates and sample widths into them based on the Input/Output Terminal and any attach Clock Source entities. More complex relationships with channels etc. will be added later as constraints as part of the DAI startup.
--- include/sound/sdca_asoc.h | 12 +- include/sound/sdca_function.h | 23 ++++ sound/soc/sdca/sdca_asoc.c | 209 +++++++++++++++++++++++++++++++++- 3 files changed, 238 insertions(+), 6 deletions(-)
include/sound/sdca_asoc.h +10 -2
@@ -14,11 +14,14 @@ struct device;struct sdca_function_data ;struct snd_kcontrol_new ;struct snd_soc_component_driver ; +struct snd_soc_dai_driver ; +struct snd_soc_dai_ops ;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 *num_controls); +int *num_widgets,int *num_routes,int *num_controls, +int *num_dais); int sdca_asoc_populate_dapm(struct device *dev, struct sdca_function_data *function, struct snd_soc_dapm_widget *widgets,
@@ -26,9 +29,14 @@ int sdca_asoc_populate_dapm(struct device *dev, struct sdca_function_data *functint sdca_asoc_populate_controls (struct device *dev,struct sdca_function_data *function,struct snd_kcontrol_new *kctl); +int sdca_asoc_populate_dais (struct device *dev,struct sdca_function_data *function, +struct snd_soc_dai_driver *dais, +const struct snd_soc_dai_ops *ops);int sdca_asoc_populate_component (struct device *dev,struct sdca_function_data *function, -struct snd_soc_component_driver *component_drv); +struct snd_soc_component_driver *component_drv, +struct snd_soc_dai_driver **dai_drv,int *num_dai_drv, +const struct snd_soc_dai_ops *ops);#endif // __SDCA_ASOC_H__
include/sound/sdca_function.h +23 -0
@@ -168,6 +168,20 @@ enum sdca_ot_controls { SDCA_CTL_OT_NDAI_PACKETTYPE = 0x17, }; +/** +* enum sdca_usage_range - Column definitions for Usage +*/ +enum sdca_usage_range { +SDCA_USAGE_NUMBER =0 , +SDCA_USAGE_CBN =1 , +SDCA_USAGE_SAMPLE_RATE =2 , +SDCA_USAGE_SAMPLE_WIDTH =3 , +SDCA_USAGE_FULL_SCALE =4 , +SDCA_USAGE_NOISE_FLOOR =5 , +SDCA_USAGE_TAG =6 , +SDCA_USAGE_NCOLS =7 , +}; +/** * enum sdca_mu_controls - SDCA Controls for Mixer Unit *
@@ -246,6 +260,15 @@ enum sdca_cs_controls { SDCA_CTL_CS_SAMPLERATEINDEX = 0x10, }; +/** +* enum sdca_samplerateindex_range - Column definitions for SampleRateIndex +*/ +enum sdca_samplerateindex_range { +SDCA_SAMPLERATEINDEX_INDEX =0 , +SDCA_SAMPLERATEINDEX_RATE =1 , +SDCA_SAMPLERATEINDEX_NCOLS =2 , +}; +/** * enum sdca_cx_controls - SDCA Controls for Clock Selector *
sound/soc/sdca/sdca_asoc.c +205 -4
260 lines not on this page · raw message
Signature · 1 line
2.39.5