Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp216826pxb; Tue, 19 Oct 2021 01:06:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXy3EWvL1wAzFW9lTAYob4Ak7X9+XIjbjD0ENkdxuJ9z7q2WKwdll2dDxf0dtlAxt3V6p3 X-Received: by 2002:a63:7055:: with SMTP id a21mr21751906pgn.338.1634630786576; Tue, 19 Oct 2021 01:06:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634630786; cv=none; d=google.com; s=arc-20160816; b=b+/7lUnJlpj+QHHuvyA2I+EXBpp5W2kahAhTwf4U6KqQ9cgX/1rv8UFbdGOEYha1dn QV6Bbyv/WxAi0/XXREw0S35Q9n0dsUGNzmzC23Cfkj7uO1uFV8Dc6ar9J225XqXmJzIS us837O+44tPOgwDpK9IztVxuwlrwEJfHZ2bP+nsQSEtPiHVIjvOTSfreTb76XUBHjG5p Nucvp14XDnYmoxZHBqnxT8cAgJaT3tpJD2QW/g///0kdxP8XTy/KX9cBfUsxjDkAiWZ7 njVkZBDa309PtrynIm0ZstqFdBwDKajQZIYkYPQrOc3BaX+q5L5wQu20+uEoDKJR8+qx m/pQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=rvujNHOj1t8QiVSByTPZavIjP84RiwYLaebUhvt0+Mk=; b=VUpMGxlJpXrqhY8XdxWgEvhpeDsmb3LO65hh7gSHJTtOZIw8EmETUKAOWlCKTwTD6n 1bNKJ/yCoC/OjjCkKkDBcgtz+1kTm2h4uNzzv5DVA97H/PUCIye/hGjbsCOxBpddfhIn fT7JPPhJUUToQXK3V++lpbVnz2lHd46TS4Muluox18rBCCUW6BOWc/Mj+jiCmxCMxxRq kdNpBivdiccWXPMHIhF4WF3dMAl2U9d6lUq1i1ley7yQOQ9cdMbESHWPfZaYHe2GnHTz Li12JcHxfWUjn3MQFo7ML4waajN5DtCB1qZibloLn4TpL2YHN2a+h5l1mwnTfNE+ZdLp h6tQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c3si9226493pgv.541.2021.10.19.01.06.14; Tue, 19 Oct 2021 01:06:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234673AbhJSIFZ (ORCPT + 99 others); Tue, 19 Oct 2021 04:05:25 -0400 Received: from mga11.intel.com ([192.55.52.93]:3757 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231187AbhJSIFY (ORCPT ); Tue, 19 Oct 2021 04:05:24 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10141"; a="225910322" X-IronPort-AV: E=Sophos;i="5.85,383,1624345200"; d="scan'208";a="225910322" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Oct 2021 01:02:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,383,1624345200"; d="scan'208";a="493984253" Received: from brentlu-brix.itwn.intel.com ([10.5.253.56]) by orsmga008.jf.intel.com with ESMTP; 19 Oct 2021 01:02:40 -0700 From: Brent Lu To: alsa-devel@alsa-project.org Cc: Cezary Rojewski , Pierre-Louis Bossart , Liam Girdwood , Jie Yang , Mark Brown , Jaroslav Kysela , Takashi Iwai , Kai Vehmanen , Rander Wang , Paul Olaru , Guennadi Liakhovetski , Brent Lu , Mac Chiang , Curtis Malainey , linux-kernel@vger.kernel.org, Yong Zhi , Vamshi Krishna Gopal , Bard Liao , Libin Yang , Christophe JAILLET , Gongjun Song , Liam Girdwood , Rander Wang , Hans de Goede Subject: [PATCH v3 1/6] ASoC: soc-acpi: add comp_ids field for machine driver matching Date: Tue, 19 Oct 2021 15:59:36 +0800 Message-Id: <20211019075941.2037787-2-brent.lu@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211019075941.2037787-1-brent.lu@intel.com> References: <20211019075941.2037787-1-brent.lu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A machine driver needs to be enumerated by more than one ACPI HID if it supports second headphone driver (i.e. rt5682 and rt5682s). However, the id field in snd_soc_acpi_mach structure could contain only one HID. By adding a 'comp_ids' field which can contain several HIDs, we can enumerate a machine driver by multiple ACPI HIDs. Signed-off-by: Brent Lu --- include/sound/soc-acpi.h | 3 +++ sound/soc/soc-acpi.c | 24 ++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/include/sound/soc-acpi.h b/include/sound/soc-acpi.h index 2f3fa385c092..31f4c4f9aeea 100644 --- a/include/sound/soc-acpi.h +++ b/include/sound/soc-acpi.h @@ -129,6 +129,8 @@ struct snd_soc_acpi_link_adr { * all firmware/topology related fields. * * @id: ACPI ID (usually the codec's) used to find a matching machine driver. + * @comp_ids: list of compatible audio codecs using the same machine driver, + * firmware and topology * @link_mask: describes required board layout, e.g. for SoundWire. * @links: array of link _ADR descriptors, null terminated. * @drv_name: machine driver name @@ -146,6 +148,7 @@ struct snd_soc_acpi_link_adr { /* Descriptor for SST ASoC machine driver */ struct snd_soc_acpi_mach { const u8 id[ACPI_ID_LEN]; + const struct snd_soc_acpi_codecs *comp_ids; const u32 link_mask; const struct snd_soc_acpi_link_adr *links; const char *drv_name; diff --git a/sound/soc/soc-acpi.c b/sound/soc/soc-acpi.c index 395229bf5c51..2ae99b49d3f5 100644 --- a/sound/soc/soc-acpi.c +++ b/sound/soc/soc-acpi.c @@ -8,14 +8,34 @@ #include #include +static bool snd_soc_acpi_id_present(struct snd_soc_acpi_mach *machine) +{ + const struct snd_soc_acpi_codecs *comp_ids = machine->comp_ids; + int i; + + if (machine->id[0]) { + if (acpi_dev_present(machine->id, NULL, -1)) + return true; + } + + if (comp_ids) { + for (i = 0; i < comp_ids->num_codecs; i++) { + if (acpi_dev_present(comp_ids->codecs[i], NULL, -1)) + return true; + } + } + + return false; +} + struct snd_soc_acpi_mach * snd_soc_acpi_find_machine(struct snd_soc_acpi_mach *machines) { struct snd_soc_acpi_mach *mach; struct snd_soc_acpi_mach *mach_alt; - for (mach = machines; mach->id[0]; mach++) { - if (acpi_dev_present(mach->id, NULL, -1)) { + for (mach = machines; mach->id[0] || mach->comp_ids; mach++) { + if (snd_soc_acpi_id_present(mach)) { if (mach->machine_quirk) { mach_alt = mach->machine_quirk(mach); if (!mach_alt) -- 2.25.1