Add SDCA DAI ops helpers
Subsystems (3)
Charles Keepax
maintainercover Add SDCA DAI ops helpers
First, a couple of minor code fixups to already submitted code. Then some patches to add new DAI ops helpers for the SDCA stuff, these allow configuring things like the sample rate and finding out which SoundWire port should be used for a specific SDCA streaming input/output terminal. Still a few bits of outstanding work here (propogation of Cluster information particularly) but his should be good enough to get some basic use-cases working.
Hopefully we are getting fairly close to completing a first version of the SDCA work now. Should be one more series to add FDL (firmware downloading), then we should be able to send a first version of the actual SDCA class driver itself.
Thanks,
Charles
Charles Keepax (7):
ASoC: SDCA: Allow read-only controls to be deferrable
ASoC: SDCA: Remove overly chatty input pin list warning
ASoC: SDCA: Move SDCA search functions and export
ASoC: soc-dai: Add private data to snd_soc_dai
ASoC: SDCA: Add helper to add DAI constraints
ASoC: SDCA: Add a helper to get the SoundWire port number
ASoC: SDCA: Add hw_params() helper function
include/sound/sdca_asoc.h | 19 ++ include/sound/sdca_function.h | 31 +++ include/sound/soc-dai.h | 3 + sound/soc/sdca/sdca_asoc.c | 427 +++++++++++++++++++++++++++----- sound/soc/sdca/sdca_functions.c | 72 +++++- 5 files changed, 490 insertions(+), 62 deletions(-)
Signature · 1 line
2.39.5
Charles Keepax
maintainerPATCH 1/7 ASoC: SDCA: Allow read-only controls to be deferrable
The current SDCA Control parsing only checks the deferrable flag for Read/Write and Dual Ranked controls. However, reads can defer as well as writes so Read Only controls should also check for the deferrable flag. Add the handling for this into find_sdca_entity_control().
--- sound/soc/sdca/sdca_functions.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
sound/soc/sdca/sdca_functions.c +2 -1
@@ -881,7 +881,8 @@ static int find_sdca_entity_control(struct device *dev, struct sdca_entity *enti control->value = tmp; control->has_fixed = true; } - + fallthrough; +case SDCA_ACCESS_MODE_RO : control->deferrable =fwnode_property_read_bool (control_node,"mipi-sdca-control-deferrable" );break ;
Signature · 1 line
2.39.5
Charles Keepax
maintainerPATCH 2/7 ASoC: SDCA: Remove overly chatty input pin list warning
In reply to Charles KeepaxAn input pin list is not generally required, so a warning on the absence of one is a little extreme, remove this warning message.
--- sound/soc/sdca/sdca_functions.c | 1 - 1 file changed, 1 deletion(-)
sound/soc/sdca/sdca_functions.c +0 -1
@@ -1635,7 +1635,6 @@ static int find_sdca_entity_connection(struct device *dev, ret =fwnode_property_read_u64 (entity_node,"mipi-sdca-input-pin-list" , &pin_list);if (ret == -EINVAL ) {/* Allow missing pin lists, assume no pins. */ -dev_warn (dev,"%s: missing pin list\n" , entity->label);return 0 ; }else if (ret) {dev_err (dev,"%s: failed to read pin list: %d\n" , entity->label, ret);
Signature · 1 line
2.39.5
Charles Keepax
maintainerPATCH 3/7 ASoC: SDCA: Move SDCA search functions and export
In reply to Charles KeepaxThe ASoC code for SDCA contains several helper functions that search for controls/ranges/etc. As the code evolves these helpers are likely to be useful to anything interacting with the stored DisCo data. Move the helpers into sdca_function.c and export them so other modules can also use them.
--- include/sound/sdca_function.h | 11 +++++ sound/soc/sdca/sdca_asoc.c | 73 ++++++--------------------------- sound/soc/sdca/sdca_functions.c | 50 ++++++++++++++++++++++ 3 files changed, 74 insertions(+), 60 deletions(-)
include/sound/sdca_function.h +11 -0
@@ -1316,4 +1316,15 @@ int sdca_parse_function(struct device *dev,struct sdca_function_desc *desc, struct sdca_function_data *function); +struct sdca_control *sdca_selector_find_control (struct device *dev, +struct sdca_entity *entity, +const int sel); +struct sdca_control_range *sdca_control_find_range (struct device *dev, +struct sdca_entity *entity, +struct sdca_control *control, +int cols,int rows); +struct sdca_control_range *sdca_selector_find_range (struct device *dev, +struct sdca_entity *entity, +int sel,int cols,int rows); +#endif
sound/soc/sdca/sdca_asoc.c +13 -60
139 lines not on this page · raw message
sound/soc/sdca/sdca_functions.c +50 -0
56 lines not on this page · raw message
Signature · 1 line
2.39.5
Charles Keepax
maintainerPATCH 4/7 ASoC: soc-dai: Add private data to snd_soc_dai
In reply to Charles KeepaxAdd a private data pointer that can be used to store context along with the DAI. This will be useful to allow the SDCA class library to store data separately from the CODEC driver itself.
--- include/sound/soc-dai.h | 3 +++ 1 file changed, 3 insertions(+)
include/sound/soc-dai.h +3 -0
@@ -463,6 +463,9 @@ struct snd_soc_dai {/* bit field */ unsigned int probed:1; + +/* DAI private data */ +void *priv; }; static inline const struct snd_soc_pcm_stream *
Signature · 1 line
2.39.5
Charles Keepax
maintainerPATCH 5/7 ASoC: SDCA: Add helper to add DAI constraints
In reply to Charles KeepaxCurrently the core SDCA code simply creates a place holder available channels from 1 to SDCA_MAX_CHANNEL_COUNT. Add a helper function that will constrain the number of channels based on the actual available SDCA Clusters in DisCo. Currently this code only handles Input Terminal Entities as they directly specify the Cluster. More work will be required later for Output Terminals which inherit their Cluster. Typically this new helper would be called from the DAIs startup callback.
--- include/sound/sdca_asoc.h | 10 ++++ include/sound/sdca_function.h | 12 ++++ sound/soc/sdca/sdca_asoc.c | 99 +++++++++++++++++++++++++++++++++ sound/soc/sdca/sdca_functions.c | 18 ++++++ 4 files changed, 139 insertions(+)
include/sound/sdca_asoc.h +10 -0
@@ -11,9 +11,12 @@#define __SDCA_ASOC_H__struct device ; +struct regmap ;struct sdca_function_data ;struct snd_kcontrol_new ; +struct snd_pcm_substream ;struct snd_soc_component_driver ; +struct snd_soc_dai ;struct snd_soc_dai_driver ;struct snd_soc_dai_ops ;struct snd_soc_dapm_route ;
@@ -39,4 +42,11 @@ int sdca_asoc_populate_component(struct device *dev, struct snd_soc_dai_driver **dai_drv, int *num_dai_drv, const struct snd_soc_dai_ops *ops); +int sdca_asoc_set_constraints (struct device *dev,struct regmap *regmap, +struct sdca_function_data *function, +struct snd_pcm_substream *substream, +struct snd_soc_dai *dai); +void sdca_asoc_free_constraints (struct snd_pcm_substream *substream, +struct snd_soc_dai *dai); +#endif // __SDCA_ASOC_H__
include/sound/sdca_function.h +12 -0
@@ -1268,6 +1268,15 @@ struct sdca_cluster {struct sdca_channel *channels; }; +/** +* enum sdca_cluster_range - SDCA Range column definitions for ClusterIndex +*/ +enum sdca_cluster_range { +SDCA_CLUSTER_BYTEINDEX =0 , +SDCA_CLUSTER_CLUSTERID =1 , +SDCA_CLUSTER_NCOLS =2 , +}; +/** * struct sdca_function_data - top-level information for one SDCA function * @desc: Pointer to short descriptor from initial parsing.
@@ -1326,5 +1335,8 @@ struct sdca_control_range *sdca_control_find_range(struct device *dev,struct sdca_control_range *sdca_selector_find_range (struct device *dev,struct sdca_entity *entity,int sel,int cols,int rows); +struct sdca_cluster *sdca_id_find_cluster (struct device *dev, +struct sdca_function_data *function, +const int id);#endif
sound/soc/sdca/sdca_asoc.c +99 -0
118 lines not on this page · raw message
sound/soc/sdca/sdca_functions.c +18 -0
@@ -1991,6 +1991,24 @@ struct sdca_control_range *sdca_selector_find_range(struct device *dev, }EXPORT_SYMBOL_NS (sdca_selector_find_range,"SND_SOC_SDCA" ); +struct sdca_cluster *sdca_id_find_cluster (struct device *dev, +struct sdca_function_data *function, +const int id) +{ +int i; + +for (i =0 ; i < function->num_clusters; i++) { +struct sdca_cluster *cluster = &function->clusters[i]; + +if (cluster->id == id) +return cluster; + } + +dev_err (dev,"%s: cluster %#x: missing\n" , function->desc->name, id); +return NULL ; +} +EXPORT_SYMBOL_NS (sdca_id_find_cluster,"SND_SOC_SDCA" ); +MODULE_LICENSE ("Dual BSD/GPL" );MODULE_DESCRIPTION ("SDCA library" );MODULE_IMPORT_NS ("SND_SOC_SDCA_HID" );
Signature · 1 line
2.39.5
Charles Keepax
maintainerPATCH 6/7 ASoC: SDCA: Add a helper to get the SoundWire port number
In reply to Charles KeepaxAdd a helper function to extract the SoundWire hardware port number from the SDCA DataPort Selector Control. Typically this would be called from hw_params() and used to call sdw_stream_add_slave().
--- include/sound/sdca_asoc.h | 3 ++ include/sound/sdca_function.h | 8 ++++ sound/soc/sdca/sdca_asoc.c | 75 +++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+)
include/sound/sdca_asoc.h +3 -0
@@ -48,5 +48,8 @@ int sdca_asoc_set_constraints(struct device *dev, struct regmap *regmap, struct snd_soc_dai *dai);void sdca_asoc_free_constraints (struct snd_pcm_substream *substream,struct snd_soc_dai *dai); +int sdca_asoc_get_port (struct device *dev,struct regmap *regmap, +struct sdca_function_data *function, +struct snd_soc_dai *dai);#endif // __SDCA_ASOC_H__
include/sound/sdca_function.h +8 -0
@@ -185,6 +185,14 @@ enum sdca_usage_range { SDCA_USAGE_NCOLS = 7, }; +/** +* enum sdca_dataport_selector_range - Column definitions for DataPort_Selector +*/ +enum sdca_dataport_selector_range { +SDCA_DATAPORT_SELECTOR_NCOLS =16 , +SDCA_DATAPORT_SELECTOR_NROWS =4 , +}; +/** * enum sdca_mu_controls - SDCA Controls for Mixer Unit *
sound/soc/sdca/sdca_asoc.c +75 -0
84 lines not on this page · raw message
Signature · 1 line
2.39.5
Charles Keepax
maintainerPATCH 7/7 ASoC: SDCA: Add hw_params() helper function
In reply to Charles KeepaxAdd a helper function that can be called from hw_params() in the DAI ops to configure the SDCA Cluster, Clock and Usage controls. These setup the channels, sample rate, and bit depths that will be used by the Terminal.
--- include/sound/sdca_asoc.h | 6 ++ sound/soc/sdca/sdca_asoc.c | 180 +++++++++++++++++++++++++++++++++++++ 2 files changed, 186 insertions(+)
include/sound/sdca_asoc.h +6 -0
@@ -14,6 +14,7 @@ struct device;struct regmap ;struct sdca_function_data ;struct snd_kcontrol_new ; +struct snd_pcm_hw_params ;struct snd_pcm_substream ;struct snd_soc_component_driver ;struct snd_soc_dai ;
@@ -51,5 +52,10 @@ void sdca_asoc_free_constraints(struct snd_pcm_substream *substream,int sdca_asoc_get_port (struct device *dev,struct regmap *regmap,struct sdca_function_data *function,struct snd_soc_dai *dai); +int sdca_asoc_hw_params (struct device *dev,struct regmap *regmap, +struct sdca_function_data *function, +struct snd_pcm_substream *substream, +struct snd_pcm_hw_params *params, +struct snd_soc_dai *dai);#endif // __SDCA_ASOC_H__
sound/soc/sdca/sdca_asoc.c +180 -0
189 lines not on this page · raw message
Signature · 1 line
2.39.5
Quoted 7 lines · Charles Keepax
First, a couple of minor code fixups to already submitted code. Then some patches to add new DAI ops helpers for the SDCA stuff, these allow configuring things like the sample rate and finding out which SoundWire port should be used for a specific SDCA streaming input/output terminal. Still a few bits of outstanding work here (propogation of Cluster information particularly) but his should be good enough to get some basic use-cases working.
For the patchset:
Quoted 4 lines
Hopefully we are getting fairly close to completing a first version of the SDCA work now. Should be one more series to add FDL (firmware downloading), then we should be able to send a first version of the actual SDCA class driver itself.
FDL is a very desirable feature, but shouldn't there be an UMP (Universal Message Passing) layer first? HID and FDL rely on UMP. I would have expected the ownership changes to be handled in a shared UMP library or set of helpers, no?
Charles Keepax
maintainerQuoted 18 lines · Pierre-Louis Bossart
Quoted 7 lines · Charles Keepax
First, a couple of minor code fixups to already submitted code. Then some patches to add new DAI ops helpers for the SDCA stuff, these allow configuring things like the sample rate and finding out which SoundWire port should be used for a specific SDCA streaming input/output terminal. Still a few bits of outstanding work here (propogation of Cluster information particularly) but his should be good enough to get some basic use-cases working.
For the patchset:
Reviewed-by Pierre-Louis Bossart <[email protected]>Quoted 4 lines
Hopefully we are getting fairly close to completing a first version of the SDCA work now. Should be one more series to add FDL (firmware downloading), then we should be able to send a first version of the actual SDCA class driver itself.
Quoted 4 lines
FDL is a very desirable feature, but shouldn't there be an UMP (Universal Message Passing) layer first? HID and FDL rely on UMP. I would have expected the ownership changes to be handled in a shared UMP library or set of helpers, no?
Yeah we are still working through the last iterations internally on the FDL stuff. I think it probably does make sense to pull out some UMP helpers (indeed I was have a look at it yesterday) although they should be pretty simple so I imagine we will just send them as part of the FDL set (subject to change as we work through it).
Thanks,
Charles
Pierre-Louis Bossart
reviewerQuoted 24 lines · Charles Keepax
Quoted 18 lines · Pierre-Louis Bossart
Quoted 7 lines · Charles Keepax
First, a couple of minor code fixups to already submitted code. Then some patches to add new DAI ops helpers for the SDCA stuff, these allow configuring things like the sample rate and finding out which SoundWire port should be used for a specific SDCA streaming input/output terminal. Still a few bits of outstanding work here (propogation of Cluster information particularly) but his should be good enough to get some basic use-cases working.
For the patchset:
Reviewed-by Pierre-Louis Bossart <[email protected]>Quoted 4 lines
Hopefully we are getting fairly close to completing a first version of the SDCA work now. Should be one more series to add FDL (firmware downloading), then we should be able to send a first version of the actual SDCA class driver itself.
Quoted 4 lines
FDL is a very desirable feature, but shouldn't there be an UMP (Universal Message Passing) layer first? HID and FDL rely on UMP. I would have expected the ownership changes to be handled in a shared UMP library or set of helpers, no?
Quoted 6 lines
Yeah we are still working through the last iterations internally on the FDL stuff. I think it probably does make sense to pull out some UMP helpers (indeed I was have a look at it yesterday) although they should be pretty simple so I imagine we will just send them as part of the FDL set (subject to change as we work through it).
Indeed UMP is pretty simple on paper, but as usual there will be corner cases of the ownership change never happening. I vaguely remember there was a sequence required for the HID used by Realtek. FDL is another order of magnitude in terms of error handling, the state machine is rather complicated and it'll fun to see how implementations map to the spec :-)
Mark Brown
maintainerQuoted 9 lines · Charles Keepax
First, a couple of minor code fixups to already submitted code. Then some patches to add new DAI ops helpers for the SDCA stuff, these allow configuring things like the sample rate and finding out which SoundWire port should be used for a specific SDCA streaming input/output terminal. Still a few bits of outstanding work here (propogation of Cluster information particularly) but his should be good enough to get some basic use-cases working.
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/7] ASoC: SDCA: Allow read-only controls to be deferrable
commit: 4eb6ad5d2080681b531db2c1764246f9a868062f
[2/7] ASoC: SDCA: Remove overly chatty input pin list warning
commit: cbcb5f5c2be523ef0908df290b3033138bd4c185
[3/7] ASoC: SDCA: Move SDCA search functions and export
commit: c57ad862462f064c0bd943a5828f5e0eca469ca5
[4/7] ASoC: soc-dai: Add private data to snd_soc_dai
commit: 5f86d41d0410b072b5f4875ef5d38bf8d18eed55
[5/7] ASoC: SDCA: Add helper to add DAI constraints
commit: 7b0d60dbb468fa82e9053292cdc8a5436400bfaf
[6/7] ASoC: SDCA: Add a helper to get the SoundWire port number
commit: 264d3d776fb1a428706b0ca0f679bbed876fe7c9
[7/7] ASoC: SDCA: Add hw_params() helper function
commit: 4ed357f72a0e0a691304e5f14a3323811c8ce862All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark