From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: alsa-devel@alsa-project.org
Cc: tiwai@suse.de, broonie@kernel.org,
Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Subject: [PATCH 3/6] ASoC: Intel: common: add translation from HID to codec-name
Date: Thu, 3 Mar 2016 21:36:36 -0600 [thread overview]
Message-ID: <1457062599-10032-5-git-send-email-pierre-louis.bossart@linux.intel.com> (raw)
In-Reply-To: <1457062599-10032-1-git-send-email-pierre-louis.bossart@linux.intel.com>
BIOS vendors sometimes declare multiple devices in the DSDT
table that all refer to the same HID. This is not very smart
but not illegal as long as only one device reports present with
the _STA method. The ACPI subsystem tracks each device with an
extension, e.g. 10EC5640:00 and 10EC5640:01
In the ASoC machine driver, the DAI codec name needs to refer to the
ACPI device that reported present, e.g. "i2c-10EC5640:01". The
extension will vary depending on how the BIOS is written and which
ACPI device is activated.
This patch adds a translation function that provides the codec
name from the ACPI HID to avoid any hard-coded values in the
machine driver.
Suggested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
sound/soc/intel/common/sst-acpi.h | 3 +++
sound/soc/intel/common/sst-match-acpi.c | 33 +++++++++++++++++++++++++++++++++
2 files changed, 36 insertions(+)
diff --git a/sound/soc/intel/common/sst-acpi.h b/sound/soc/intel/common/sst-acpi.h
index 3ee3b7a..4dcfb7e 100644
--- a/sound/soc/intel/common/sst-acpi.h
+++ b/sound/soc/intel/common/sst-acpi.h
@@ -14,6 +14,9 @@
#include <linux/acpi.h>
+/* translation fron HID to I2C name, needed for DAI codec_name */
+const char *sst_acpi_find_name_from_hid(const u8 hid[ACPI_ID_LEN]);
+
/* acpi match */
struct sst_acpi_mach *sst_acpi_find_machine(struct sst_acpi_mach *machines);
diff --git a/sound/soc/intel/common/sst-match-acpi.c b/sound/soc/intel/common/sst-match-acpi.c
index 7452360..7898433 100644
--- a/sound/soc/intel/common/sst-match-acpi.c
+++ b/sound/soc/intel/common/sst-match-acpi.c
@@ -16,6 +16,39 @@
#include "sst-acpi.h"
+static acpi_status sst_acpi_find_name(acpi_handle handle, u32 level,
+ void *context, void **ret)
+{
+ struct acpi_device *adev;
+ const char *name = NULL;
+
+ if (acpi_bus_get_device(handle, &adev))
+ return AE_OK;
+
+ if (adev->status.present && adev->status.functional) {
+ name = acpi_dev_name(adev);
+ *(const char **)ret = name;
+ return AE_CTRL_TERMINATE;
+ }
+
+ return AE_OK;
+}
+
+const char *sst_acpi_find_name_from_hid(const u8 hid[ACPI_ID_LEN])
+{
+ const char *name = NULL;
+ acpi_status status;
+
+ status = acpi_get_devices(hid, sst_acpi_find_name, NULL,
+ (void **)&name);
+
+ if (ACPI_FAILURE(status) || name[0] == '\0')
+ return NULL;
+
+ return name;
+}
+EXPORT_SYMBOL_GPL(sst_acpi_find_name_from_hid);
+
static acpi_status sst_acpi_mach_match(acpi_handle handle, u32 level,
void *context, void **ret)
{
--
1.9.1
next prev parent reply other threads:[~2016-03-04 3:36 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-04 3:36 [PATCH 0/6] Support for CherryTrail devices Pierre-Louis Bossart
2016-03-04 3:36 ` [PATCH 1/6] ASoC: Intel: allow for DW_DMAC_CORE as module Pierre-Louis Bossart
2016-03-05 4:03 ` Mark Brown
2016-03-07 17:49 ` Pierre-Louis Bossart
2016-03-09 2:43 ` Mark Brown
2016-03-09 17:06 ` Pierre-Louis Bossart
2016-03-09 17:19 ` Takashi Iwai
2016-03-10 5:45 ` Mark Brown
2016-03-04 3:36 ` [PATCH 2/6] ASoC: Intel: common: filter ACPI devices with _STA return value Pierre-Louis Bossart
2016-03-05 12:25 ` Applied "ASoC: Intel: common: filter ACPI devices with _STA return value" to the asoc tree Mark Brown
2016-03-04 3:36 ` [PATCH 2/6] ASoC: Intel: filter ACPI devices based on _STA return value Pierre-Louis Bossart
2016-03-04 3:36 ` Pierre-Louis Bossart [this message]
2016-03-05 12:25 ` Applied "ASoC: Intel: common: add translation from HID to codec-name" to the asoc tree Mark Brown
2016-03-04 3:36 ` [PATCH 4/6] ASoC: Intel: bytcr_rt5640: change quirk position Pierre-Louis Bossart
2016-03-05 12:25 ` Applied "ASoC: Intel: bytcr_rt5640: change quirk position" to the asoc tree Mark Brown
2016-03-04 3:36 ` [PATCH 5/6] ASoC: Intel: bytcr_rt5640: use HID translation util Pierre-Louis Bossart
2016-03-05 12:25 ` Applied "ASoC: Intel: bytcr_rt5640: use HID translation util" to the asoc tree Mark Brown
2016-03-04 3:36 ` [PATCH 6/6] ASoC: Intel: Atom: add support for CHT w/ RT5640 Pierre-Louis Bossart
2016-03-05 12:24 ` Applied "ASoC: Intel: Atom: add support for CHT w/ RT5640" to the asoc tree Mark Brown
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=1457062599-10032-5-git-send-email-pierre-louis.bossart@linux.intel.com \
--to=pierre-louis.bossart@linux.intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=tiwai@suse.de \
/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;
as well as URLs for NNTP newsgroup(s).