]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ASoC: SDCA: Add support for Entity 0
authorCharles Keepax <ckeepax@opensource.cirrus.com>
Wed, 5 Feb 2025 11:37:55 +0000 (11:37 +0000)
committerMark Brown <broonie@kernel.org>
Fri, 7 Feb 2025 17:34:03 +0000 (17:34 +0000)
Within SDCA there is a special Entity called Entity 0 which is used
to hold Function level controls. Whilst Entity 0 isn't a full SDCA
Entity, it is helpful to add an sdca_entity structure for it. This
will allow it to be treated identically in the code that handles
SDCA Controls.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>
Link: https://patch.msgid.link/20250205113801.3699902-5-ckeepax@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
include/sound/sdca_function.h
sound/soc/sdca/sdca_functions.c

index 47fc1da8e4f3323ff45b5b4e0bc9b0cfcc43a388..a51e3a459e361667d4acfe2d66933b16c03a480a 100644 (file)
@@ -117,6 +117,9 @@ enum sdca_entity0_controls {
 
 /**
  * enum sdca_entity_type - SDCA Entity Type codes
+ * @SDCA_ENTITY_TYPE_ENTITY_0: Entity 0, not actually from the
+ * specification but useful internally as an Entity structure
+ * is allocated for Entity 0, to hold Entity 0 controls.
  * @SDCA_ENTITY_TYPE_IT: Input Terminal.
  * @SDCA_ENTITY_TYPE_OT: Output Terminal.
  * @SDCA_ENTITY_TYPE_MU: Mixer Unit.
@@ -141,6 +144,7 @@ enum sdca_entity0_controls {
  * all Entity Types not described are reserved.
  */
 enum sdca_entity_type {
+       SDCA_ENTITY_TYPE_ENTITY_0                       = 0x00,
        SDCA_ENTITY_TYPE_IT                             = 0x02,
        SDCA_ENTITY_TYPE_OT                             = 0x03,
        SDCA_ENTITY_TYPE_MU                             = 0x05,
index f914ec3f86c9ac794b722caffabce26343762e79..b0ca92f1bc57ff7d3931834e4eabf55305d0b0a7 100644 (file)
@@ -293,7 +293,8 @@ static int find_sdca_entities(struct device *dev,
                return -EINVAL;
        }
 
-       entities = devm_kcalloc(dev, num_entities, sizeof(*entities), GFP_KERNEL);
+       /* Add 1 to make space for Entity 0 */
+       entities = devm_kcalloc(dev, num_entities + 1, sizeof(*entities), GFP_KERNEL);
        if (!entities)
                return -ENOMEM;
 
@@ -331,7 +332,13 @@ static int find_sdca_entities(struct device *dev,
                        return ret;
        }
 
-       function->num_entities = num_entities;
+       /*
+        * Add Entity 0 at end of the array, makes it easy to skip during
+        * all the Entity searches involved in creating connections.
+        */
+       entities[num_entities].label = "entity0";
+
+       function->num_entities = num_entities + 1;
        function->entities = entities;
 
        return 0;
@@ -440,7 +447,8 @@ static int find_sdca_connections(struct device *dev,
 {
        int i;
 
-       for (i = 0; i < function->num_entities; i++) {
+       /* Entity 0 cannot have connections */
+       for (i = 0; i < function->num_entities - 1; i++) {
                struct sdca_entity *entity = &function->entities[i];
                char entity_property[SDCA_PROPERTY_LENGTH];
                struct fwnode_handle *entity_node;