From: Charles Keepax <ckeepax@opensource.cirrus.com>
To: broonie@kernel.org
Cc: lgirdwood@gmail.com, yung-chuan.liao@linux.intel.com,
pierre-louis.bossart@linux.dev, linux-sound@vger.kernel.org,
linux-kernel@vger.kernel.org, patches@opensource.cirrus.com
Subject: [PATCH 1/2] ASoC: SDCA: Factor out helper for creating mask of Cluster channels
Date: Thu, 5 Nov 2026 13:49:51 +0000 [thread overview]
Message-ID: <20261105134952.1728147-2-ckeepax@opensource.cirrus.com> (raw)
In-Reply-To: <20261105134952.1728147-1-ckeepax@opensource.cirrus.com>
Factor out the code that builds a mask of the allowed channels from the
Cluster information. This is slightly cleaner and prepares for
additional constraints to be added to sdca_asoc_set_constraints().
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
sound/soc/sdca/sdca_asoc.c | 64 +++++++++++++++++++++++---------------
1 file changed, 39 insertions(+), 25 deletions(-)
diff --git a/sound/soc/sdca/sdca_asoc.c b/sound/soc/sdca/sdca_asoc.c
index ccc579f878ff1..b801cb92cc3db 100644
--- a/sound/soc/sdca/sdca_asoc.c
+++ b/sound/soc/sdca/sdca_asoc.c
@@ -1434,6 +1434,37 @@ int sdca_asoc_populate_component(struct device *dev,
}
EXPORT_SYMBOL_NS(sdca_asoc_populate_component, "SND_SOC_SDCA");
+static int get_cluster_mask(struct device *dev, struct sdca_function_data *function,
+ struct sdca_entity *entity, unsigned int *ch_mask)
+{
+ struct sdca_control_range *range;
+ struct sdca_control *control;
+ int i;
+
+ control = sdca_selector_find_control(dev, entity, SDCA_CTL_IT_CLUSTERINDEX);
+ if (!control)
+ return -EINVAL;
+
+ range = sdca_control_find_range(dev, entity, control, SDCA_CLUSTER_NCOLS, 0);
+ if (!range)
+ return -EINVAL;
+
+ *ch_mask = 0;
+
+ for (i = 0; i < range->rows; i++) {
+ int clusterid = sdca_range(range, SDCA_CLUSTER_CLUSTERID, i);
+ struct sdca_cluster *cluster;
+
+ cluster = sdca_id_find_cluster(dev, function, clusterid);
+ if (!cluster)
+ return -ENODEV;
+
+ *ch_mask |= (1 << (cluster->num_channels - 1));
+ }
+
+ return 0;
+}
+
/**
* sdca_asoc_set_constraints - constrain channels available on a DAI
* @dev: Pointer to the device, used for error messages.
@@ -1457,38 +1488,21 @@ int sdca_asoc_set_constraints(struct device *dev, struct regmap *regmap,
};
struct sdca_entity *entity = &function->entities[dai->id];
struct snd_pcm_hw_constraint_list *constraint;
- struct sdca_control_range *range;
- struct sdca_control *control;
- unsigned int channel_mask = 0;
- int i, ret;
+ unsigned int cluster_ch_mask;
+ int ret;
static_assert(ARRAY_SIZE(channel_list) == SDCA_MAX_CHANNEL_COUNT);
- static_assert(sizeof(channel_mask) * BITS_PER_BYTE >= SDCA_MAX_CHANNEL_COUNT);
+ static_assert(sizeof(cluster_ch_mask) * BITS_PER_BYTE >= SDCA_MAX_CHANNEL_COUNT);
if (entity->type != SDCA_ENTITY_TYPE_IT)
return 0;
- control = sdca_selector_find_control(dev, entity, SDCA_CTL_IT_CLUSTERINDEX);
- if (!control)
- return -EINVAL;
-
- range = sdca_control_find_range(dev, entity, control, SDCA_CLUSTER_NCOLS, 0);
- if (!range)
- return -EINVAL;
-
- for (i = 0; i < range->rows; i++) {
- int clusterid = sdca_range(range, SDCA_CLUSTER_CLUSTERID, i);
- struct sdca_cluster *cluster;
-
- cluster = sdca_id_find_cluster(dev, function, clusterid);
- if (!cluster)
- return -ENODEV;
-
- channel_mask |= (1 << (cluster->num_channels - 1));
- }
+ ret = get_cluster_mask(dev, function, entity, &cluster_ch_mask);
+ if (ret)
+ return ret;
dev_dbg(dev, "%s: set channel constraint mask: %#x\n",
- entity->label, channel_mask);
+ entity->label, cluster_ch_mask);
constraint = kzalloc_obj(*constraint);
if (!constraint)
@@ -1496,7 +1510,7 @@ int sdca_asoc_set_constraints(struct device *dev, struct regmap *regmap,
constraint->count = ARRAY_SIZE(channel_list);
constraint->list = channel_list;
- constraint->mask = channel_mask;
+ constraint->mask = cluster_ch_mask;
ret = snd_pcm_hw_constraint_list(substream->runtime, 0,
SNDRV_PCM_HW_PARAM_CHANNELS,
--
2.47.3
next prev parent reply other threads:[~2026-11-05 13:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-05 13:49 [PATCH 0/2] Add SoundWire port constraints into SDCA stream Charles Keepax
2026-11-05 13:49 ` Charles Keepax [this message]
2026-11-05 13:49 ` [PATCH 2/2] ASoC: SDCA: Add port constraints into sdca_asoc_set_constraints() Charles Keepax
2026-11-05 14:27 ` Charles Keepax
2026-11-05 19:49 ` Pierre-Louis Bossart
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261105134952.1728147-2-ckeepax@opensource.cirrus.com \
--to=ckeepax@opensource.cirrus.com \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=patches@opensource.cirrus.com \
--cc=pierre-louis.bossart@linux.dev \
--cc=yung-chuan.liao@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®