Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp2802626rwl; Fri, 6 Jan 2023 11:01:00 -0800 (PST) X-Google-Smtp-Source: AMrXdXu5IHLeR+fYGNE1EcnwplAjKI74Qh25yxzjdYjJLIDJHWV0ihY2Ua2NATi1aldzKV0csFMQ X-Received: by 2002:a17:903:40cb:b0:192:8502:77f9 with SMTP id t11-20020a17090340cb00b00192850277f9mr42558339pld.27.1673031659829; Fri, 06 Jan 2023 11:00:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673031659; cv=none; d=google.com; s=arc-20160816; b=IYYwo74EV76XdyidlGCee/dZ41nxrW+Jl5JzHOgxmgpXl9XMSb7TTQjQvoUW1o5kYE VskHbZ3Jl6ACBAHvJJB5ZwOPWG20VtAi8yV9ac8+KEkGhkSYFIIIvEvxUQm4+v30M7LL SMNjXi1D+XhGzjUJUlYLHh1EHKVIfz7nyx5BWZxyfcvbTyKJUgs1T90q+12idtmWQNs+ +h7EjCStal3XR2BNg6U+YoZLzrIVhooMF8tiMhY2HZlTePsUEAzZ/ix+VYzhrNMrwmle DdAEwBbuwzyXHMLWKm5+FIUpwlMTYxBbnMwLkSXnN5/dN5XLfTIjAw3X+FeGTxiSjRbJ sRjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to :dkim-signature:from; bh=cmuSZI2wSW+SHZPdnbO0emuwaThGtTGOIMyX+UN5J0g=; b=r3OVK+akuGfGk+hlcj81fsdjvMImgAKke4bESlqqHnc6wjMV4c2cBPFyOhUaphDVOD aaor7Rvcwx3OpkwhiReITm+MkZwh66IUYEgLRa+9iO7g4BOs+UauDWjD2KU95IrA3mPt z8ck6+99XfmAIL67gKQsbgtzrR2gPOrByirmHiyrGpxcsW9/A5qLRiyPlEMtKUTrrKfK f/s5mx2OQUMH1cFMeXh/XMuK8MvxjCbSQOz6ykX7KPCtAG3WAQUZ3z9aczEYh3lu5HSq ykz0tDiRXr19KxATLuQbqZFG2LdPLdF4A3jEj2aMbgI4KOzkbVsk8ST/gNu5BMndYwth aduQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mutex.one header.s=default header.b=KaFu8EOn; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i15-20020a17090332cf00b00189c10f6b4csi1923026plr.417.2023.01.06.11.00.53; Fri, 06 Jan 2023 11:00:59 -0800 (PST) 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=@mutex.one header.s=default header.b=KaFu8EOn; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236305AbjAFS6P (ORCPT + 54 others); Fri, 6 Jan 2023 13:58:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236070AbjAFS56 (ORCPT ); Fri, 6 Jan 2023 13:57:58 -0500 Received: from mail.mutex.one (mail.mutex.one [62.77.152.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8F7077D0B for ; Fri, 6 Jan 2023 10:57:57 -0800 (PST) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.mutex.one (Postfix) with ESMTP id C20F116C0002; Fri, 6 Jan 2023 20:39:20 +0200 (EET) X-Virus-Scanned: Debian amavisd-new at mail.mutex.one Received: from mail.mutex.one ([127.0.0.1]) by localhost (mail.mutex.one [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XVre5n-Ey0QP; Fri, 6 Jan 2023 20:39:20 +0200 (EET) From: Marian Postevca DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mutex.one; s=default; t=1673030359; bh=fNmEoimusZ9c7AY5q2dIdtrOELvykZSuN250etZkQkg=; h=From:To:Cc:Subject:Date:From; b=KaFu8EOnvce2XH3yt5bmGi2blDxWmHjswwhiRHFMrpaHjkCtnYFx6q7tc41OZiZ2K 18NDuqIFK7sHWEc/kbPohuETJxP0a/O+bnFQBsu6QFz6jRZPpeYVtmKGsgMNRuHR2Y 4G0IDCZPSXeTAzAk8pWoNVeR1BDompfiajHf4nBE= To: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Cc: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Vijendar Mukunda , Ajit Kumar Pandey , Mario Limonciello , V sujith kumar Reddy , syed sabakareem , Dan Carpenter Subject: [RFC] Sound support for Huawei line of AMD laptops using ACP and ES8336 codec Date: Fri, 06 Jan 2023 20:39:17 +0200 Message-ID: <874jt3fqy2.fsf@mutex.one> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS 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 I have a Huawei Matebook 14 AMD 2021 laptop for which the sound isn't supported on Linux. On further investigation in Windows and ACPI tables I could determine that this particular SKU has an ES8336 codec connected to the CPU ACP module. The CPU of my laptop is an AMD Ryzen 5 5500U which seems to be codenamed Lucienne and is a derivation of the Renoir family. Acording to lspci the ACP is revision 1: 03:00.5 Multimedia controller [0480]: Advanced Micro Devices, Inc. [AMD] Raven/Raven2/FireFlight/Renoir Audio Processor [1022:15e2] (rev 01) Subsystem: Device [1e83:3e4d] Kernel driver in use: snd_rn_pci_acp3x Kernel modules: snd_pci_acp3x, snd_rn_pci_acp3x, snd_pci_acp5x, snd_pci_acp6x, snd_acp_pci, snd_rpl_pci_acp6x, snd_sof_amd_renoir I have written a machine driver for this platform and managed to make the sound and internal microphone work. I am looking to integrate this support but there are some issues with the current implementation of ACP support. As far as I can tell there are 4 directions I could take to add support: 1. A standalone machine driver in sound/soc/amd that uses the platform drivers from sound/soc/amd/raven/ 2. An embedded driver in sound/soc/amd/acp/acp-legacy-mach.c 3. A standalone machine driver in sound/soc/amd that uses the platform drivers from sound/soc/amd/renoir 4. Use the SOF infrastructure Now as far as I can tell, all of these directions have issues: 1. The pci driver from sound/soc/amd/raven/pci-acp3x.c doesn't support Lucienne since it blocks rev 1 devices in : /* Raven device detection */ if (pci->revision != 0x00) return -ENODEV; This is the approach I took and just changed the check to add support for rev 1. The sound and internal microphone worked ok and I didn't encounter any issues with it. Of course I don't know the internals of ACP and don't know what are the differences between rev 0 and rev 1. 2. This approach could work but I would need to change the structure acp_card_drvdata and struct snd_soc_dapm_widget acp_widgets, to add proper support for jack handling (and maybe some other modifications). This driver seems to support rev 1 (in sound/soc/amd/acp/acp-pci.c): switch (pci->revision) { case 0x01: chip->name = "acp_asoc_renoir"; chip->acp_rev = ACP3X_DEV; break; Also from the module description it seems that these drivers are meant only for chromebook support. 3. This seems like it would the best approach in theory, but the problem is that the drivers inside only seem to add support for DMIC. 4. I tried to use SOF early when I started tinkering, but I always got a timeout during init phase when loading the renoir firmware. So the reason for this email is to get some idea, on how to best add support for these laptops.