Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp5430415iob; Mon, 9 May 2022 16:35:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJybD8vCsfalAh/4cK1qhx9sd+CrGXlrgSyqvTbOM4vC+8KRjUoucd6mPHD19Bnsp/ektYZA X-Received: by 2002:a05:6a00:4091:b0:510:71b1:963e with SMTP id bw17-20020a056a00409100b0051071b1963emr18114288pfb.31.1652139313149; Mon, 09 May 2022 16:35:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652139313; cv=none; d=google.com; s=arc-20160816; b=BaZJcXogOH3QJ3DyastR1+XEs8NijaNqsaZ/m3Hi+8ztzshUeggwYYZ7WoopT8chtL 8CFYOq3LF6nc4LTBHlJI3jiWd0nlIvTF2L7XvpzPp8ipDaG/mv4nVzyTp/HzEyOOKq5K iWw0WCDUZwk1jWeHQW5YsTcavn4uY+6yJ7By8z6/cpgb9KenyRvmHSmJpdNUrHVLsKP1 D6wuAdANLtteXJB/N6HpUjXx6HTj0aMJHK1Bkij75Qry0GmT+Wko2LPKEGqAA2W2tQKb iofQ0/Fhs2iKN8gfuYwjaFN+y/4Gbt3i0fG0xZHYMR+aazC0xJy+V9JW0FQ1YbJ1Zwn4 5KHA== 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=cg8Z72bZzSUa4fOqu2MXM+DpOt9HsvCXWVuD2oBsUw8=; b=HnZH9ZpinTRYm5xsqe9VkWkbdwtpHqqviB51kdJbjMPzOqwI9y4FhGuqn/3CyCA9BM zTSmsCDgK1l5Rdw8/Xmjzbi31uCXbGJtvOWS3GRNuHJPPElHui2gu0AHzTN+aSObBYzv KS8S8nWdEXkjpbZxLgTOs1PyZZm1txRF04XyWd/z6c4z+/ZKeuPkYYi2hgpDC+BR1fM4 UAQll1jYrwZwdr50ICVmkQLdQ26mKzI8bOVLhUTwoBLR4MILLIxFjYC5SPblUM7p/EOS AyIuBXHUjtHN6LC0Xcjyb1bMjJBwY5GzNfb/ddSbRzXKwWAsrXkxaqIcwCEo1oNViLpg t7Cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=T4OFion7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b15-20020a63930f000000b003c605064adesi7470815pge.811.2022.05.09.16.34.57; Mon, 09 May 2022 16:35:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=T4OFion7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230219AbiEIVw0 (ORCPT + 99 others); Mon, 9 May 2022 17:52:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230254AbiEIVvR (ORCPT ); Mon, 9 May 2022 17:51:17 -0400 Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE13D2725E8 for ; Mon, 9 May 2022 14:47:22 -0700 (PDT) Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 249Bt3ZB026043; Mon, 9 May 2022 16:47:13 -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=cg8Z72bZzSUa4fOqu2MXM+DpOt9HsvCXWVuD2oBsUw8=; b=T4OFion7xS5jU9XaxzD5uj3LiDCdwbm1WLpj+qjuVZLDB20VBrGHJ5usvgkKkqm201Mr hqBP887I1Dm8fTVeHbn3UcorlKmqWsTA2iL+/d2VakCwuw9xGbjjb4HuZjDAG/H5gcpN HvpyRExtA/Z6VwTku/RFjCASgyUEtzbSuLtDgVjzFGaJECmvZsbgsfBjnbXSmEAuKzdR RHnpmPqbVbW7kIKr2ySq/ZRPW64p/Y9LPmojd1dVOG9XbJUbAtyElYFSfYYpJInhO4fu jaykoEZEr7Y5S80cp1HnjSJIkM9O/P+PezWEL4P3S4lRv0YRl0ZsuR+Me8PYt0oqxBN8 bg== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3fwp613jeu-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Mon, 09 May 2022 16:47:12 -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; Mon, 9 May 2022 22:47:10 +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; Mon, 9 May 2022 22:47:10 +0100 Received: from vitaly-Legion-7-16ACHg6.ad.cirrus.com (unknown [198.90.238.55]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 03BA5475; Mon, 9 May 2022 21:47:09 +0000 (UTC) From: Vitaly Rodionov To: Jaroslav Kysela , Takashi Iwai , Mark Brown CC: , , , Stefan Binding Subject: [PATCH v2 15/26] ALSA: hda: cs35l41: Support reading subsystem id from ACPI Date: Mon, 9 May 2022 22:46:52 +0100 Message-ID: <20220509214703.4482-16-vitalyr@opensource.cirrus.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220509214703.4482-1-vitalyr@opensource.cirrus.com> References: <20220509214703.4482-1-vitalyr@opensource.cirrus.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: iS6TYpYz2HX96uY2j7aYZxjRSmnNcHxc X-Proofpoint-ORIG-GUID: iS6TYpYz2HX96uY2j7aYZxjRSmnNcHxc X-Proofpoint-Spam-Reason: safe X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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.34.1