* [PATCH 0/2] More minor SDCA changes
@ 2025-07-18 13:54 Charles Keepax
2025-07-18 13:54 ` [PATCH 1/2] ASoC: SDCA: Fix some holes in the regmap readable/writeable helpers Charles Keepax
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Charles Keepax @ 2025-07-18 13:54 UTC (permalink / raw)
To: broonie
Cc: lgirdwood, yung-chuan.liao, pierre-louis.bossart, peter.ujfalusi,
shumingf, linux-sound, patches
A small chain with some patches that seem to have got lost in the
process. One small additional bug fix for the regmap callbacks, and one
small feature addition for the control parsing.
Charles Keepax (2):
ASoC: SDCA: Fix some holes in the regmap readable/writeable helpers
ASoC: SDCA: Add support for -cn- value properties
include/sound/sdca_function.h | 14 ++---
sound/soc/sdca/sdca_functions.c | 99 +++++++++++++++++++++------------
sound/soc/sdca/sdca_regmap.c | 29 ++++++++--
3 files changed, 92 insertions(+), 50 deletions(-)
--
2.39.5
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] ASoC: SDCA: Fix some holes in the regmap readable/writeable helpers
2025-07-18 13:54 [PATCH 0/2] More minor SDCA changes Charles Keepax
@ 2025-07-18 13:54 ` Charles Keepax
2025-07-18 13:54 ` [PATCH 2/2] ASoC: SDCA: Add support for -cn- value properties Charles Keepax
2025-07-24 22:05 ` [PATCH 0/2] More minor SDCA changes Mark Brown
2 siblings, 0 replies; 4+ messages in thread
From: Charles Keepax @ 2025-07-18 13:54 UTC (permalink / raw)
To: broonie
Cc: lgirdwood, yung-chuan.liao, pierre-louis.bossart, peter.ujfalusi,
shumingf, linux-sound, patches
The current regmap readable/writeable helper functions always
allow the Next flag and allows any Control Number. Mask the Next
flag based on SDCA_ACCESS_MODE_DUAL which is the only Mode that
supports it. Also check that the Control Number is valid for
the given control.
Fixes: e3f7caf74b79 ("ASoC: SDCA: Add generic regmap SDCA helpers")
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
sound/soc/sdca/sdca_regmap.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/sound/soc/sdca/sdca_regmap.c b/sound/soc/sdca/sdca_regmap.c
index 66e7eee7d7f49..c41c67c2204a4 100644
--- a/sound/soc/sdca/sdca_regmap.c
+++ b/sound/soc/sdca/sdca_regmap.c
@@ -72,12 +72,18 @@ bool sdca_regmap_readable(struct sdca_function_data *function, unsigned int reg)
if (!control)
return false;
+ if (!(BIT(SDW_SDCA_CTL_CNUM(reg)) & control->cn_list))
+ return false;
+
switch (control->mode) {
case SDCA_ACCESS_MODE_RW:
case SDCA_ACCESS_MODE_RO:
- case SDCA_ACCESS_MODE_DUAL:
case SDCA_ACCESS_MODE_RW1S:
case SDCA_ACCESS_MODE_RW1C:
+ if (SDW_SDCA_NEXT_CTL(0) & reg)
+ return false;
+ fallthrough;
+ case SDCA_ACCESS_MODE_DUAL:
/* No access to registers marked solely for device use */
return control->layers & ~SDCA_ACCESS_LAYER_DEVICE;
default:
@@ -104,11 +110,17 @@ bool sdca_regmap_writeable(struct sdca_function_data *function, unsigned int reg
if (!control)
return false;
+ if (!(BIT(SDW_SDCA_CTL_CNUM(reg)) & control->cn_list))
+ return false;
+
switch (control->mode) {
case SDCA_ACCESS_MODE_RW:
- case SDCA_ACCESS_MODE_DUAL:
case SDCA_ACCESS_MODE_RW1S:
case SDCA_ACCESS_MODE_RW1C:
+ if (SDW_SDCA_NEXT_CTL(0) & reg)
+ return false;
+ fallthrough;
+ case SDCA_ACCESS_MODE_DUAL:
/* No access to registers marked solely for device use */
return control->layers & ~SDCA_ACCESS_LAYER_DEVICE;
default:
--
2.39.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] ASoC: SDCA: Add support for -cn- value properties
2025-07-18 13:54 [PATCH 0/2] More minor SDCA changes Charles Keepax
2025-07-18 13:54 ` [PATCH 1/2] ASoC: SDCA: Fix some holes in the regmap readable/writeable helpers Charles Keepax
@ 2025-07-18 13:54 ` Charles Keepax
2025-07-24 22:05 ` [PATCH 0/2] More minor SDCA changes Mark Brown
2 siblings, 0 replies; 4+ messages in thread
From: Charles Keepax @ 2025-07-18 13:54 UTC (permalink / raw)
To: broonie
Cc: lgirdwood, yung-chuan.liao, pierre-louis.bossart, peter.ujfalusi,
shumingf, linux-sound, patches
Many of the DisCo properties that specify Control values have an
additional variant that specifies a separate value for each Control
Number. Add support for these.
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
include/sound/sdca_function.h | 14 ++---
sound/soc/sdca/sdca_functions.c | 99 +++++++++++++++++++++------------
sound/soc/sdca/sdca_regmap.c | 13 +++--
3 files changed, 78 insertions(+), 48 deletions(-)
diff --git a/include/sound/sdca_function.h b/include/sound/sdca_function.h
index 90d77fc46416b..06ec126cdcc34 100644
--- a/include/sound/sdca_function.h
+++ b/include/sound/sdca_function.h
@@ -742,14 +742,14 @@ struct sdca_control_range {
* struct sdca_control - information for one SDCA Control
* @label: Name for the Control, from SDCA Specification v1.0, section 7.1.7.
* @sel: Identifier used for addressing.
- * @value: Holds the Control value for constants and defaults.
* @nbits: Number of bits used in the Control.
- * @interrupt_position: SCDA interrupt line that will alert to changes on this
- * Control.
+ * @values: Holds the Control value for constants and defaults.
* @cn_list: A bitmask showing the valid Control Numbers within this Control,
* Control Numbers typically represent channels.
- * @range: Buffer describing valid range of values for the Control.
+ * @interrupt_position: SCDA interrupt line that will alert to changes on this
+ * Control.
* @type: Format of the data in the Control.
+ * @range: Buffer describing valid range of values for the Control.
* @mode: Access mode of the Control.
* @layers: Bitmask of access layers of the Control.
* @deferrable: Indicates if the access to the Control can be deferred.
@@ -760,13 +760,13 @@ struct sdca_control {
const char *label;
int sel;
- int value;
int nbits;
- int interrupt_position;
+ int *values;
u64 cn_list;
+ int interrupt_position;
- struct sdca_control_range range;
enum sdca_control_datatype type;
+ struct sdca_control_range range;
enum sdca_access_mode mode;
u8 layers;
diff --git a/sound/soc/sdca/sdca_functions.c b/sound/soc/sdca/sdca_functions.c
index 4b6da587c4ac3..0faee522b3af2 100644
--- a/sound/soc/sdca/sdca_functions.c
+++ b/sound/soc/sdca/sdca_functions.c
@@ -814,6 +814,43 @@ static int find_sdca_control_range(struct device *dev,
return 0;
}
+static int find_sdca_control_value(struct device *dev, struct sdca_entity *entity,
+ struct fwnode_handle *control_node,
+ struct sdca_control *control,
+ const char * const label)
+{
+ char property[SDCA_PROPERTY_LENGTH];
+ bool global = true;
+ int ret, cn, i;
+ u32 tmp;
+
+ snprintf(property, sizeof(property), "mipi-sdca-control-%s", label);
+
+ ret = fwnode_property_read_u32(control_node, property, &tmp);
+ if (ret == -EINVAL)
+ global = false;
+ else if (ret)
+ return ret;
+
+ i = 0;
+ for_each_set_bit(cn, (unsigned long *)&control->cn_list,
+ BITS_PER_TYPE(control->cn_list)) {
+ if (!global) {
+ snprintf(property, sizeof(property),
+ "mipi-sdca-control-cn-%d-%s", cn, label);
+
+ ret = fwnode_property_read_u32(control_node, property, &tmp);
+ if (ret)
+ return ret;
+ }
+
+ control->values[i] = tmp;
+ i++;
+ }
+
+ return 0;
+}
+
/*
* TODO: Add support for -cn- properties, allowing different channels to have
* different defaults etc.
@@ -843,44 +880,44 @@ static int find_sdca_entity_control(struct device *dev, struct sdca_entity *enti
control->layers = tmp;
+ ret = fwnode_property_read_u64(control_node, "mipi-sdca-control-cn-list",
+ &control->cn_list);
+ if (ret == -EINVAL) {
+ /* Spec allows not specifying cn-list if only the first number is used */
+ control->cn_list = 0x1;
+ } else if (ret || !control->cn_list) {
+ dev_err(dev, "%s: control %#x: cn list missing: %d\n",
+ entity->label, control->sel, ret);
+ return ret;
+ }
+
+ control->values = devm_kzalloc(dev, hweight64(control->cn_list), GFP_KERNEL);
+ if (!control->values)
+ return -ENOMEM;
+
switch (control->mode) {
case SDCA_ACCESS_MODE_DC:
- ret = fwnode_property_read_u32(control_node,
- "mipi-sdca-control-dc-value",
- &tmp);
+ ret = find_sdca_control_value(dev, entity, control_node, control,
+ "dc-value");
if (ret) {
dev_err(dev, "%s: control %#x: dc value missing: %d\n",
entity->label, control->sel, ret);
return ret;
}
- control->value = tmp;
control->has_fixed = true;
break;
case SDCA_ACCESS_MODE_RW:
case SDCA_ACCESS_MODE_DUAL:
- ret = fwnode_property_read_u32(control_node,
- "mipi-sdca-control-default-value",
- &tmp);
- if (!ret) {
- control->value = tmp;
+ ret = find_sdca_control_value(dev, entity, control_node, control,
+ "default-value");
+ if (!ret)
control->has_default = true;
- }
-
- ret = fwnode_property_read_u32(control_node,
- "mipi-sdca-control-fixed-value",
- &tmp);
- if (!ret) {
- if (control->has_default && control->value != tmp) {
- dev_err(dev,
- "%s: control %#x: default and fixed value don't match\n",
- entity->label, control->sel);
- return -EINVAL;
- }
- control->value = tmp;
+ ret = find_sdca_control_value(dev, entity, control_node, control,
+ "fixed-value");
+ if (!ret)
control->has_fixed = true;
- }
fallthrough;
case SDCA_ACCESS_MODE_RO:
control->deferrable = fwnode_property_read_bool(control_node,
@@ -897,17 +934,6 @@ static int find_sdca_entity_control(struct device *dev, struct sdca_entity *enti
return ret;
}
- ret = fwnode_property_read_u64(control_node, "mipi-sdca-control-cn-list",
- &control->cn_list);
- if (ret == -EINVAL) {
- /* Spec allows not specifying cn-list if only the first number is used */
- control->cn_list = 0x1;
- } else if (ret || !control->cn_list) {
- dev_err(dev, "%s: control %#x: cn list missing: %d\n",
- entity->label, control->sel, ret);
- return ret;
- }
-
ret = fwnode_property_read_u32(control_node,
"mipi-sdca-control-interrupt-position",
&tmp);
@@ -923,11 +949,10 @@ static int find_sdca_entity_control(struct device *dev, struct sdca_entity *enti
control->type = find_sdca_control_datatype(entity, control);
control->nbits = find_sdca_control_bits(entity, control);
- dev_info(dev, "%s: %s: control %#x mode %#x layers %#x cn %#llx int %d value %#x %s\n",
+ dev_info(dev, "%s: %s: control %#x mode %#x layers %#x cn %#llx int %d %s\n",
entity->label, control->label, control->sel,
control->mode, control->layers, control->cn_list,
- control->interrupt_position, control->value,
- control->deferrable ? "deferrable" : "");
+ control->interrupt_position, control->deferrable ? "deferrable" : "");
return 0;
}
diff --git a/sound/soc/sdca/sdca_regmap.c b/sound/soc/sdca/sdca_regmap.c
index c41c67c2204a4..5cb3048ea8cfc 100644
--- a/sound/soc/sdca/sdca_regmap.c
+++ b/sound/soc/sdca/sdca_regmap.c
@@ -253,7 +253,7 @@ int sdca_regmap_populate_constants(struct device *dev,
struct sdca_function_data *function,
struct reg_default *consts)
{
- int i, j, k;
+ int i, j, k, l;
for (i = 0, k = 0; i < function->num_entities; i++) {
struct sdca_entity *entity = &function->entities[i];
@@ -265,13 +265,15 @@ int sdca_regmap_populate_constants(struct device *dev,
if (control->mode != SDCA_ACCESS_MODE_DC)
continue;
+ l = 0;
for_each_set_bit(cn, (unsigned long *)&control->cn_list,
BITS_PER_TYPE(control->cn_list)) {
consts[k].reg = SDW_SDCA_CTL(function->desc->adr,
entity->id,
control->sel, cn);
- consts[k].def = control->value;
+ consts[k].def = control->values[l];
k++;
+ l++;
}
}
}
@@ -295,7 +297,7 @@ EXPORT_SYMBOL_NS(sdca_regmap_populate_constants, "SND_SOC_SDCA");
int sdca_regmap_write_defaults(struct device *dev, struct regmap *regmap,
struct sdca_function_data *function)
{
- int i, j;
+ int i, j, k;
int ret;
for (i = 0; i < function->num_entities; i++) {
@@ -311,6 +313,7 @@ int sdca_regmap_write_defaults(struct device *dev, struct regmap *regmap,
if (!control->has_default && !control->has_fixed)
continue;
+ k = 0;
for_each_set_bit(cn, (unsigned long *)&control->cn_list,
BITS_PER_TYPE(control->cn_list)) {
unsigned int reg;
@@ -318,9 +321,11 @@ int sdca_regmap_write_defaults(struct device *dev, struct regmap *regmap,
reg = SDW_SDCA_CTL(function->desc->adr, entity->id,
control->sel, cn);
- ret = regmap_write(regmap, reg, control->value);
+ ret = regmap_write(regmap, reg, control->values[k]);
if (ret)
return ret;
+
+ k++;
}
}
}
--
2.39.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] More minor SDCA changes
2025-07-18 13:54 [PATCH 0/2] More minor SDCA changes Charles Keepax
2025-07-18 13:54 ` [PATCH 1/2] ASoC: SDCA: Fix some holes in the regmap readable/writeable helpers Charles Keepax
2025-07-18 13:54 ` [PATCH 2/2] ASoC: SDCA: Add support for -cn- value properties Charles Keepax
@ 2025-07-24 22:05 ` Mark Brown
2 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2025-07-24 22:05 UTC (permalink / raw)
To: Charles Keepax
Cc: lgirdwood, yung-chuan.liao, pierre-louis.bossart, peter.ujfalusi,
shumingf, linux-sound, patches
On Fri, 18 Jul 2025 14:54:30 +0100, Charles Keepax wrote:
> A small chain with some patches that seem to have got lost in the
> process. One small additional bug fix for the regmap callbacks, and one
> small feature addition for the control parsing.
>
> Charles Keepax (2):
> ASoC: SDCA: Fix some holes in the regmap readable/writeable helpers
> ASoC: SDCA: Add support for -cn- value properties
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/2] ASoC: SDCA: Fix some holes in the regmap readable/writeable helpers
commit: 061fade7a67f6cdfe918a675270d84107abbef61
[2/2] ASoC: SDCA: Add support for -cn- value properties
commit: 50a479527ef01f9b36dde1803a7e81741a222509
All 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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-07-24 22:06 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-18 13:54 [PATCH 0/2] More minor SDCA changes Charles Keepax
2025-07-18 13:54 ` [PATCH 1/2] ASoC: SDCA: Fix some holes in the regmap readable/writeable helpers Charles Keepax
2025-07-18 13:54 ` [PATCH 2/2] ASoC: SDCA: Add support for -cn- value properties Charles Keepax
2025-07-24 22:05 ` [PATCH 0/2] More minor SDCA changes Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).