From patchwork Fri Mar 4 03:36:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Louis Bossart X-Patchwork-Id: 8498241 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7E4779F314 for ; Fri, 4 Mar 2016 03:39:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 96A632021F for ; Fri, 4 Mar 2016 03:39:06 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 5DD882017D for ; Fri, 4 Mar 2016 03:39:05 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 6DE37266918; Fri, 4 Mar 2016 04:39:04 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM, RCVD_IN_DNSWL_NONE,UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 4585F265932; Fri, 4 Mar 2016 04:37:01 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 1F718265854; Fri, 4 Mar 2016 04:36:59 +0100 (CET) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by alsa0.perex.cz (Postfix) with ESMTP id 0A4372652AC for ; Fri, 4 Mar 2016 04:36:49 +0100 (CET) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP; 03 Mar 2016 19:36:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,534,1449561600"; d="scan'208";a="757857406" Received: from vjmorale-mobl3.amr.corp.intel.com (HELO pbossart-mobl2.amr.corp.intel.com) ([10.255.35.28]) by orsmga003.jf.intel.com with ESMTP; 03 Mar 2016 19:36:46 -0800 From: Pierre-Louis Bossart To: alsa-devel@alsa-project.org Date: Thu, 3 Mar 2016 21:36:36 -0600 Message-Id: <1457062599-10032-5-git-send-email-pierre-louis.bossart@linux.intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1457062599-10032-1-git-send-email-pierre-louis.bossart@linux.intel.com> References: <1457062599-10032-1-git-send-email-pierre-louis.bossart@linux.intel.com> Cc: tiwai@suse.de, broonie@kernel.org, Pierre-Louis Bossart Subject: [alsa-devel] [PATCH 3/6] ASoC: Intel: common: add translation from HID to codec-name X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Signed-off-by: Pierre-Louis Bossart --- 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 +/* 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) {