Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4670490ioa; Wed, 27 Apr 2022 08:36:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzXhmWoHTFrTFDwKinf41gwITz2+AgUowH1xthy6+9R+XZ5SYbs9NfxtXDY7NWNbLMwdJ+q X-Received: by 2002:a17:902:f70a:b0:153:88c7:774 with SMTP id h10-20020a170902f70a00b0015388c70774mr29029210plo.166.1651073802627; Wed, 27 Apr 2022 08:36:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651073802; cv=none; d=google.com; s=arc-20160816; b=v+1ZP3SfbawlJETd4RPFakRECupCWqC4DulPtNZWRZOuFpBbUGLemIxiadQTND7yql 0Q47K8g7tyYOiGdmYDHOjxKm6DwdYm0XatJcSTL44We+qltZNNgBUadfLUHar6t4QgSM C1V/j2Q1MJu3uWm+ZORx/xs59QdAPBzKcPAWce6WirtuUt2BZdCUAiZmnUys96YKPa8v fxz0OJ9mIH/Oyms6nl3SlxOz0cCciWs2jVvFSt4k+s9hj0dAWwA53vxmtdNbBfUj8pt0 I4tbddmez+IHAt/MUq3zVK92djRjhah7+xbIGYx3rpXgvJZgGU1VMkyQmsta1n9CKEtv C+bA== 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 :dkim-signature; bh=kYJ0UjX6J6u7JIoQW7OiahYsdEK0VU8/EmGk5ydBq8g=; b=wPhmxOcO6NpFrMB7XfbfUEwfeUFdZrMzU9OdaMGTxN1/HIJmoDHRR9h6hk8cxaTTOd P+5fv2deO+LkbLAfvU9Hb7ZdKsBi8qHOwwDmBa54urZH92/4ggH5zuf2YDpvtw2COTI1 PjyptmGRHten1xhy6R2zguOIwdwCLmWbZPWKGOVtlMIVrz9yViT3pFO0B8JlWdSDXsiF T71Y8yavox02OS4+2iFREaBbZ3JR8cX9S45HAto1ZIfujuU/84cDUOpGJ4sBoZUI2Y0Q F9Bjki2cbzWjgWfZaW2x4PJO6FFH6dH6OQuuLfDdPazROoC2irGqg+DX9BmgbLrbzL84 f3kA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=AzahhFEh; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id x6-20020a170902ec8600b0015d282e938csi2094310plg.266.2022.04.27.08.36.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 08:36:42 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=AzahhFEh; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 080EE2A8E88; Wed, 27 Apr 2022 08:09:16 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239070AbiD0PMK (ORCPT + 99 others); Wed, 27 Apr 2022 11:12:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239105AbiD0PLC (ORCPT ); Wed, 27 Apr 2022 11:11:02 -0400 Received: from mx0b-001ae601.pphosted.com (mx0b-001ae601.pphosted.com [67.231.152.168]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D9AC54BCD for ; Wed, 27 Apr 2022 08:07:50 -0700 (PDT) Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 23RBg6qI022428; Wed, 27 Apr 2022 10:07:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=PODMain02222019; bh=kYJ0UjX6J6u7JIoQW7OiahYsdEK0VU8/EmGk5ydBq8g=; b=AzahhFEhToPiOfMI1zE0HB41grRd7Ogayl62DRuW1wiRt2573sQov7ArZKuA7G2WE1FN RGjAXgk6PzMp3aAmY3GYvDQ7dyAuXGvxDmCP9fA8LdRuyO9M7dhD4vz9ce15DjRz2Dy+ SmhnRKayInx4XntflAjUgr6VqebRQnJgkOC5UpRK1aJMXz9fa1uDwOm1/nvY9QDMEwpv u7on1o4zTRFrdKck8kf99QR077ZkVW5xMCz9aFNqT7189lDYhQG105cdd+wcUiHLjJPU 87OxdtZ9SYQtEFeI6aeIrDEPHCsHJ3rptrwJwyRsXU/6OOOFkI0A2lemZ44hgmZm7XiE 0A== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0b-001ae601.pphosted.com (PPS) with ESMTPS id 3fprt60xte-11 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Wed, 27 Apr 2022 10:07:39 -0500 Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 27 Apr 2022 16:07:29 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.2375.24 via Frontend Transport; Wed, 27 Apr 2022 16:07:29 +0100 Received: from vitaly-Legion-7-16ACHg6.ad.cirrus.com (unknown [198.90.238.170]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id C9133B1A; Wed, 27 Apr 2022 15:07:28 +0000 (UTC) From: Vitaly Rodionov To: Jaroslav Kysela , Takashi Iwai , Mark Brown CC: , , , Stefan Binding Subject: [PATCH 15/26] ALSA: hda: cs35l41: Support reading subsystem id from ACPI Date: Wed, 27 Apr 2022 16:07:09 +0100 Message-ID: <20220427150720.9194-16-vitalyr@opensource.cirrus.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220427150720.9194-1-vitalyr@opensource.cirrus.com> References: <20220427150720.9194-1-vitalyr@opensource.cirrus.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: 98aHNdMZZKH0i8E_Q_K7eU8fk1HTDA4U X-Proofpoint-ORIG-GUID: 98aHNdMZZKH0i8E_Q_K7eU8fk1HTDA4U X-Proofpoint-Spam-Reason: safe X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stefan Binding On some laptop models, the ACPI contains the unique Subsystem ID, and this value should be preferred over the value from the HDA driver. Signed-off-by: Stefan Binding Signed-off-by: Vitaly Rodionov --- sound/pci/hda/cs35l41_hda.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/sound/pci/hda/cs35l41_hda.c b/sound/pci/hda/cs35l41_hda.c index c235b899aa04..81d6f4cf0166 100644 --- a/sound/pci/hda/cs35l41_hda.c +++ b/sound/pci/hda/cs35l41_hda.c @@ -533,6 +533,36 @@ static int cs35l41_hda_apply_properties(struct cs35l41_hda *cs35l41) return cs35l41_hda_channel_map(cs35l41->dev, 0, NULL, 1, &hw_cfg->spk_pos); } +static int cs35l41_get_acpi_sub_string(struct device *dev, struct acpi_device *adev, + const char **subsysid) +{ + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; + union acpi_object *obj; + acpi_status status; + int ret = 0; + + status = acpi_evaluate_object(adev->handle, "_SUB", NULL, &buffer); + if (ACPI_SUCCESS(status)) { + obj = buffer.pointer; + if (obj->type == ACPI_TYPE_STRING) { + *subsysid = devm_kstrdup(dev, obj->string.pointer, GFP_KERNEL); + if (*subsysid == NULL) { + dev_err(dev, "Cannot allocate Subsystem ID"); + ret = -ENOMEM; + } + } else { + dev_warn(dev, "Warning ACPI _SUB did not return a string\n"); + ret = -ENODEV; + } + acpi_os_free(buffer.pointer); + } else { + dev_dbg(dev, "Warning ACPI _SUB failed: %#x\n", status); + ret = -ENODEV; + } + + return ret; +} + static int cs35l41_hda_read_acpi(struct cs35l41_hda *cs35l41, const char *hid, int id) { struct cs35l41_hw_cfg *hw_cfg = &cs35l41->hw_cfg; @@ -552,6 +582,12 @@ static int cs35l41_hda_read_acpi(struct cs35l41_hda *cs35l41, const char *hid, i physdev = get_device(acpi_get_first_physical_node(adev)); acpi_dev_put(adev); + ret = cs35l41_get_acpi_sub_string(cs35l41->dev, adev, &cs35l41->acpi_subsystem_id); + if (ret) + dev_info(cs35l41->dev, "No Subsystem ID found in ACPI: %d", ret); + else + dev_dbg(cs35l41->dev, "Subsystem ID %s found", cs35l41->acpi_subsystem_id); + property = "cirrus,dev-index"; ret = device_property_count_u32(physdev, property); if (ret <= 0) -- 2.32.0