Linux Sound subsystem development
 help / color / mirror / Atom feed
* [PATCH RESEND 0/4] ALSA/hda: intel-sdw-acpi: add support for sdw-manager-list property read
@ 2024-10-01  7:06 Bard Liao
  2024-10-01  7:06 ` [PATCH RESEND 1/4] ALSA/hda: intel-sdw-acpi: cleanup sdw_intel_scan_controller Bard Liao
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Bard Liao @ 2024-10-01  7:06 UTC (permalink / raw)
  To: broonie, tiwai
  Cc: linux-sound, pierre-louis.bossart, bard.liao, peter.ujfalusi

The DisCo for SoundWire 2.0 spec adds support for a new sdw-manager-list
property.  Add it in backwards-compatible mode with 'sdw-master-count'

Takashi, this series can go via ALSA tree now.

Reviewed-by: Takashi Iwai <tiwai@suse.de>

Pierre-Louis Bossart (4):
  ALSA/hda: intel-sdw-acpi: cleanup sdw_intel_scan_controller
  ALSA/hda: intel-sdw-acpi: fetch fwnode once in
    sdw_intel_scan_controller()
  ALSA/hda: intel-sdw-acpi: simplify sdw-master-count property read
  ALSA/hda: intel-sdw-acpi: add support for sdw-manager-list property
    read

 include/linux/soundwire/sdw_intel.h |  2 +-
 sound/hda/intel-sdw-acpi.c          | 33 +++++++++++++++++++----------
 2 files changed, 23 insertions(+), 12 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH RESEND 1/4] ALSA/hda: intel-sdw-acpi: cleanup sdw_intel_scan_controller
  2024-10-01  7:06 [PATCH RESEND 0/4] ALSA/hda: intel-sdw-acpi: add support for sdw-manager-list property read Bard Liao
@ 2024-10-01  7:06 ` Bard Liao
  2024-10-01  7:06 ` [PATCH RESEND 2/4] ALSA/hda: intel-sdw-acpi: fetch fwnode once in sdw_intel_scan_controller() Bard Liao
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Bard Liao @ 2024-10-01  7:06 UTC (permalink / raw)
  To: broonie, tiwai
  Cc: linux-sound, pierre-louis.bossart, bard.liao, peter.ujfalusi

From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

Remove unnecessary initialization and un-shadow return code.

Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
---
 sound/hda/intel-sdw-acpi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sound/hda/intel-sdw-acpi.c b/sound/hda/intel-sdw-acpi.c
index 04d6b6beabca..770dabe0124f 100644
--- a/sound/hda/intel-sdw-acpi.c
+++ b/sound/hda/intel-sdw-acpi.c
@@ -63,7 +63,6 @@ sdw_intel_scan_controller(struct sdw_intel_acpi_info *info)
 		return -EINVAL;
 
 	/* Found controller, find links supported */
-	count = 0;
 	ret = fwnode_property_read_u8_array(acpi_fwnode_handle(adev),
 					    "mipi-sdw-master-count", &count, 1);
 
@@ -82,7 +81,7 @@ sdw_intel_scan_controller(struct sdw_intel_acpi_info *info)
 	if (ret) {
 		dev_err(&adev->dev,
 			"Failed to read mipi-sdw-master-count: %d\n", ret);
-		return -EINVAL;
+		return ret;
 	}
 
 	/* Check count is within bounds */
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH RESEND 2/4] ALSA/hda: intel-sdw-acpi: fetch fwnode once in sdw_intel_scan_controller()
  2024-10-01  7:06 [PATCH RESEND 0/4] ALSA/hda: intel-sdw-acpi: add support for sdw-manager-list property read Bard Liao
  2024-10-01  7:06 ` [PATCH RESEND 1/4] ALSA/hda: intel-sdw-acpi: cleanup sdw_intel_scan_controller Bard Liao
@ 2024-10-01  7:06 ` Bard Liao
  2024-10-01  7:06 ` [PATCH RESEND 3/4] ALSA/hda: intel-sdw-acpi: simplify sdw-master-count property read Bard Liao
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Bard Liao @ 2024-10-01  7:06 UTC (permalink / raw)
  To: broonie, tiwai
  Cc: linux-sound, pierre-louis.bossart, bard.liao, peter.ujfalusi

From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

Optimize a bit by using an intermediate 'fwnode' variable.

Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
---
 sound/hda/intel-sdw-acpi.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/sound/hda/intel-sdw-acpi.c b/sound/hda/intel-sdw-acpi.c
index 770dabe0124f..7a3735e94545 100644
--- a/sound/hda/intel-sdw-acpi.c
+++ b/sound/hda/intel-sdw-acpi.c
@@ -56,15 +56,17 @@ static int
 sdw_intel_scan_controller(struct sdw_intel_acpi_info *info)
 {
 	struct acpi_device *adev = acpi_fetch_acpi_dev(info->handle);
+	struct fwnode_handle *fwnode;
 	u8 count, i;
 	int ret;
 
 	if (!adev)
 		return -EINVAL;
 
+	fwnode = acpi_fwnode_handle(adev);
+
 	/* Found controller, find links supported */
-	ret = fwnode_property_read_u8_array(acpi_fwnode_handle(adev),
-					    "mipi-sdw-master-count", &count, 1);
+	ret = fwnode_property_read_u8_array(fwnode, "mipi-sdw-master-count", &count, 1);
 
 	/*
 	 * In theory we could check the number of links supported in
@@ -107,7 +109,7 @@ sdw_intel_scan_controller(struct sdw_intel_acpi_info *info)
 			continue;
 		}
 
-		if (!is_link_enabled(acpi_fwnode_handle(adev), i)) {
+		if (!is_link_enabled(fwnode, i)) {
 			dev_dbg(&adev->dev,
 				"Link %d not selected in firmware\n", i);
 			continue;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH RESEND 3/4] ALSA/hda: intel-sdw-acpi: simplify sdw-master-count property read
  2024-10-01  7:06 [PATCH RESEND 0/4] ALSA/hda: intel-sdw-acpi: add support for sdw-manager-list property read Bard Liao
  2024-10-01  7:06 ` [PATCH RESEND 1/4] ALSA/hda: intel-sdw-acpi: cleanup sdw_intel_scan_controller Bard Liao
  2024-10-01  7:06 ` [PATCH RESEND 2/4] ALSA/hda: intel-sdw-acpi: fetch fwnode once in sdw_intel_scan_controller() Bard Liao
@ 2024-10-01  7:06 ` Bard Liao
  2024-10-01  7:06 ` [PATCH RESEND 4/4] ALSA/hda: intel-sdw-acpi: add support for sdw-manager-list " Bard Liao
  2024-10-15  5:54 ` [PATCH RESEND 0/4] " Takashi Iwai
  4 siblings, 0 replies; 6+ messages in thread
From: Bard Liao @ 2024-10-01  7:06 UTC (permalink / raw)
  To: broonie, tiwai
  Cc: linux-sound, pierre-louis.bossart, bard.liao, peter.ujfalusi

From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

For some reason we used an array of one u8 when the specification
requires a u32.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
---
 sound/hda/intel-sdw-acpi.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/sound/hda/intel-sdw-acpi.c b/sound/hda/intel-sdw-acpi.c
index 7a3735e94545..582e761e7b9f 100644
--- a/sound/hda/intel-sdw-acpi.c
+++ b/sound/hda/intel-sdw-acpi.c
@@ -57,7 +57,8 @@ sdw_intel_scan_controller(struct sdw_intel_acpi_info *info)
 {
 	struct acpi_device *adev = acpi_fetch_acpi_dev(info->handle);
 	struct fwnode_handle *fwnode;
-	u8 count, i;
+	unsigned int i;
+	u32 count;
 	int ret;
 
 	if (!adev)
@@ -66,7 +67,7 @@ sdw_intel_scan_controller(struct sdw_intel_acpi_info *info)
 	fwnode = acpi_fwnode_handle(adev);
 
 	/* Found controller, find links supported */
-	ret = fwnode_property_read_u8_array(fwnode, "mipi-sdw-master-count", &count, 1);
+	ret = fwnode_property_read_u32(fwnode, "mipi-sdw-master-count", &count);
 
 	/*
 	 * In theory we could check the number of links supported in
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH RESEND 4/4] ALSA/hda: intel-sdw-acpi: add support for sdw-manager-list property read
  2024-10-01  7:06 [PATCH RESEND 0/4] ALSA/hda: intel-sdw-acpi: add support for sdw-manager-list property read Bard Liao
                   ` (2 preceding siblings ...)
  2024-10-01  7:06 ` [PATCH RESEND 3/4] ALSA/hda: intel-sdw-acpi: simplify sdw-master-count property read Bard Liao
@ 2024-10-01  7:06 ` Bard Liao
  2024-10-15  5:54 ` [PATCH RESEND 0/4] " Takashi Iwai
  4 siblings, 0 replies; 6+ messages in thread
From: Bard Liao @ 2024-10-01  7:06 UTC (permalink / raw)
  To: broonie, tiwai
  Cc: linux-sound, pierre-louis.bossart, bard.liao, peter.ujfalusi

From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

The DisCo for SoundWire 2.0 spec adds support for a new
sdw-manager-list property.  Add it in backwards-compatible mode with
'sdw-master-count', which assumed that all links between 0..count-1
exist.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
---
 include/linux/soundwire/sdw_intel.h |  2 +-
 sound/hda/intel-sdw-acpi.c          | 25 +++++++++++++++++--------
 2 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/include/linux/soundwire/sdw_intel.h b/include/linux/soundwire/sdw_intel.h
index 37ae69365fe2..734dc1fa3b5b 100644
--- a/include/linux/soundwire/sdw_intel.h
+++ b/include/linux/soundwire/sdw_intel.h
@@ -227,7 +227,7 @@ struct sdw_intel_ops {
 /**
  * struct sdw_intel_acpi_info - Soundwire Intel information found in ACPI tables
  * @handle: ACPI controller handle
- * @count: link count found with "sdw-master-count" property
+ * @count: link count found with "sdw-master-count" or "sdw-manager-list" property
  * @link_mask: bit-wise mask listing links enabled by BIOS menu
  *
  * this structure could be expanded to e.g. provide all the _ADR
diff --git a/sound/hda/intel-sdw-acpi.c b/sound/hda/intel-sdw-acpi.c
index 582e761e7b9f..ed530e0dd4dd 100644
--- a/sound/hda/intel-sdw-acpi.c
+++ b/sound/hda/intel-sdw-acpi.c
@@ -57,8 +57,10 @@ sdw_intel_scan_controller(struct sdw_intel_acpi_info *info)
 {
 	struct acpi_device *adev = acpi_fetch_acpi_dev(info->handle);
 	struct fwnode_handle *fwnode;
+	unsigned long list;
 	unsigned int i;
 	u32 count;
+	u32 tmp;
 	int ret;
 
 	if (!adev)
@@ -66,10 +68,9 @@ sdw_intel_scan_controller(struct sdw_intel_acpi_info *info)
 
 	fwnode = acpi_fwnode_handle(adev);
 
-	/* Found controller, find links supported */
-	ret = fwnode_property_read_u32(fwnode, "mipi-sdw-master-count", &count);
-
 	/*
+	 * Found controller, find links supported
+	 *
 	 * In theory we could check the number of links supported in
 	 * hardware, but in that step we cannot assume SoundWire IP is
 	 * powered.
@@ -80,11 +81,19 @@ sdw_intel_scan_controller(struct sdw_intel_acpi_info *info)
 	 *
 	 * We will check the hardware capabilities in the startup() step
 	 */
-
+	ret = fwnode_property_read_u32(fwnode, "mipi-sdw-manager-list", &tmp);
 	if (ret) {
-		dev_err(&adev->dev,
-			"Failed to read mipi-sdw-master-count: %d\n", ret);
-		return ret;
+		ret = fwnode_property_read_u32(fwnode, "mipi-sdw-master-count", &count);
+		if (ret) {
+			dev_err(&adev->dev,
+				"Failed to read mipi-sdw-master-count: %d\n",
+				ret);
+			return ret;
+		}
+		list = GENMASK(count - 1, 0);
+	} else {
+		list = tmp;
+		count = hweight32(list);
 	}
 
 	/* Check count is within bounds */
@@ -103,7 +112,7 @@ sdw_intel_scan_controller(struct sdw_intel_acpi_info *info)
 	info->count = count;
 	info->link_mask = 0;
 
-	for (i = 0; i < count; i++) {
+	for_each_set_bit(i, &list, SDW_INTEL_MAX_LINKS) {
 		if (ctrl_link_mask && !(ctrl_link_mask & BIT(i))) {
 			dev_dbg(&adev->dev,
 				"Link %d masked, will not be enabled\n", i);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH RESEND 0/4] ALSA/hda: intel-sdw-acpi: add support for sdw-manager-list property read
  2024-10-01  7:06 [PATCH RESEND 0/4] ALSA/hda: intel-sdw-acpi: add support for sdw-manager-list property read Bard Liao
                   ` (3 preceding siblings ...)
  2024-10-01  7:06 ` [PATCH RESEND 4/4] ALSA/hda: intel-sdw-acpi: add support for sdw-manager-list " Bard Liao
@ 2024-10-15  5:54 ` Takashi Iwai
  4 siblings, 0 replies; 6+ messages in thread
From: Takashi Iwai @ 2024-10-15  5:54 UTC (permalink / raw)
  To: Bard Liao
  Cc: broonie, tiwai, linux-sound, pierre-louis.bossart, bard.liao,
	peter.ujfalusi

On Tue, 01 Oct 2024 09:06:07 +0200,
Bard Liao wrote:
> 
> The DisCo for SoundWire 2.0 spec adds support for a new sdw-manager-list
> property.  Add it in backwards-compatible mode with 'sdw-master-count'
> 
> Takashi, this series can go via ALSA tree now.
> 
> Reviewed-by: Takashi Iwai <tiwai@suse.de>
> 
> Pierre-Louis Bossart (4):
>   ALSA/hda: intel-sdw-acpi: cleanup sdw_intel_scan_controller
>   ALSA/hda: intel-sdw-acpi: fetch fwnode once in
>     sdw_intel_scan_controller()
>   ALSA/hda: intel-sdw-acpi: simplify sdw-master-count property read
>   ALSA/hda: intel-sdw-acpi: add support for sdw-manager-list property
>     read

Applied now to for-linus branch.  Thanks!


Takashi

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-10-15  5:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-01  7:06 [PATCH RESEND 0/4] ALSA/hda: intel-sdw-acpi: add support for sdw-manager-list property read Bard Liao
2024-10-01  7:06 ` [PATCH RESEND 1/4] ALSA/hda: intel-sdw-acpi: cleanup sdw_intel_scan_controller Bard Liao
2024-10-01  7:06 ` [PATCH RESEND 2/4] ALSA/hda: intel-sdw-acpi: fetch fwnode once in sdw_intel_scan_controller() Bard Liao
2024-10-01  7:06 ` [PATCH RESEND 3/4] ALSA/hda: intel-sdw-acpi: simplify sdw-master-count property read Bard Liao
2024-10-01  7:06 ` [PATCH RESEND 4/4] ALSA/hda: intel-sdw-acpi: add support for sdw-manager-list " Bard Liao
2024-10-15  5:54 ` [PATCH RESEND 0/4] " Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox