From patchwork Fri Oct 20 09:50:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ChiYuan Huang X-Patchwork-Id: 155945 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp938931vqb; Fri, 20 Oct 2023 02:51:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEpD/JmXk7RhVT2k+Fqo1ILqSk2fkGefcsVsyyskT4FFGp9huw9a/3X0l5kndZJrmxKf0JQ X-Received: by 2002:a92:c048:0:b0:357:3d82:2d48 with SMTP id o8-20020a92c048000000b003573d822d48mr1410518ilf.8.1697795508153; Fri, 20 Oct 2023 02:51:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697795508; cv=none; d=google.com; s=arc-20160816; b=NiobCyOFZNcOoRSZuuS6SafpfDpyjNSaZZyT7SnZLLHSR7Nin/nDiWxeBJi507ICe8 bUFON/ATutVBtl/vIYTFNimAO+LOSyFxPs0fR82ckazp3sWlNzHzbt3vBXCSPlzlWgOH ZNWGTHVyoPvXmluyNmnzognkTknXzw+75mnJmhkqAPJ3OT28hfs2SGz2W/2IP5pog/OA M8hMAzhDmaaJ0lafqFAWAQz60aKlX0XvE0uZfFN+RsZQjqbtBTEX7vrNZHTZh/ef+7zc WHRdAGZzRIRPeJD6FeIyv251/ZDCDbEtrRw7QmBD90X5dsgJGbcw3f2fbe2f7CmcZy4z BmOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=8b8SZqSxpzSsRASHjK+Zv35pCFwQSCSmIFhf4GQxDjE=; fh=gCuEpdnQLg4vssKdE7Wt3Rbe5N+ut+NBWC9tWnKbW6Q=; b=FCLSnmN/zmAYeQSYgV2NAcYB64mnl3wkSXO7lGTw+iAad2YygI7pPLeWzaNHBM4QaF oD45QGmejVWJsOR6Cw0kZojSchkKN3TtPKhkUzT1X2m+V1aWpkYhK+geLj2u7eTiYF5a YNn313N7wOjij+eW4N9oUNAcofO+kya7pvKGst7mtBVE24Av4B/KTzR8e+QmyXPrROr8 OvLgON27jmqiNCJSwfVG5btf4H8By4oQywsFzF5htU5nk4bNzTD0LpS8D321PtQMQ1Bo 1KDO7EICHK3vRxlMagIlsYhi1yy6RHTx7H5PA0gF7bfroe3h/yKp48gGe43uzrVKa0r1 eVMQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id m190-20020a6326c7000000b0055be9543340si1459821pgm.872.2023.10.20.02.51.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 02:51:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id B9EE380990D8; Fri, 20 Oct 2023 02:51:38 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376752AbjJTJvW (ORCPT + 25 others); Fri, 20 Oct 2023 05:51:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376736AbjJTJvP (ORCPT ); Fri, 20 Oct 2023 05:51:15 -0400 Received: from mg.richtek.com (mg.richtek.com [220.130.44.152]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 305691A6 for ; Fri, 20 Oct 2023 02:51:09 -0700 (PDT) X-MailGates: (SIP:2,PASS,NONE)(compute_score:DELIVER,40,3) Received: from 192.168.10.46 by mg.richtek.com with MailGates ESMTPS Server V6.0(1461660:0:AUTH_RELAY) (envelope-from ) (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256/256); Fri, 20 Oct 2023 17:50:37 +0800 (CST) Received: from ex4.rt.l (192.168.10.47) by ex3.rt.l (192.168.10.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.25; Fri, 20 Oct 2023 17:50:36 +0800 Received: from linuxcarl2.richtek.com (192.168.10.154) by ex4.rt.l (192.168.10.45) with Microsoft SMTP Server id 15.2.1118.25 via Frontend Transport; Fri, 20 Oct 2023 17:50:36 +0800 From: To: Mark Brown CC: Liam Girdwood , Jaroslav Kysela , Takashi Iwai , ChiYuan Huang , Allen Lin , , Subject: [PATCH 1/3] ASoC: codecs: rtq9128: Fix string compare in DAPM event callback Date: Fri, 20 Oct 2023 17:50:33 +0800 Message-ID: <1697795435-5858-2-git-send-email-cy_huang@richtek.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1697795435-5858-1-git-send-email-cy_huang@richtek.com> References: <1697795435-5858-1-git-send-email-cy_huang@richtek.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Fri, 20 Oct 2023 02:51:38 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780267622570978223 X-GMAIL-MSGID: 1780267622570978223 From: ChiYuan Huang Since widget name may concatenate the component prefix. To compare the the name with 'strcmp' function in shared DAPM event callback will cause the wrong RG field control. Use 'strstr' function, instead. Signed-off-by: ChiYuan Huang --- sound/soc/codecs/rtq9128.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/rtq9128.c b/sound/soc/codecs/rtq9128.c index 371d622c6214..8c1c3c65475e 100644 --- a/sound/soc/codecs/rtq9128.c +++ b/sound/soc/codecs/rtq9128.c @@ -291,11 +291,11 @@ static int rtq9128_dac_power_event(struct snd_soc_dapm_widget *w, struct snd_kco dev_dbg(comp->dev, "%s: %s event %d\n", __func__, w->name, event); - if (strcmp(w->name, "DAC1") == 0) + if (strstr(w->name, "DAC1")) shift = 6; - else if (strcmp(w->name, "DAC2") == 0) + else if (strstr(w->name, "DAC2")) shift = 4; - else if (strcmp(w->name, "DAC3") == 0) + else if (strstr(w->name, "DAC3")) shift = 2; else shift = 0; From patchwork Fri Oct 20 09:50:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ChiYuan Huang X-Patchwork-Id: 155946 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp939196vqb; Fri, 20 Oct 2023 02:52:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGE/P9/NJcbb/f/ukQ6j5tY6tFT8cwzd3w6Kv/t3FEKIzliZYACFEHH50B3uXfcujC1kTem X-Received: by 2002:a05:6871:4909:b0:1e9:a70c:1323 with SMTP id tw9-20020a056871490900b001e9a70c1323mr1255237oab.39.1697795557298; Fri, 20 Oct 2023 02:52:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697795557; cv=none; d=google.com; s=arc-20160816; b=ogZuVLuqg1dtmsCkVBiizL/dTAgm5ob15R9HDOpmGWtZs+zBpj+KFE9qzFK+0N2DrX CcRfDv7zteYmmRNrSSwOc4a8DAqEVbZV+SFYi4IXtZ12IzGLbsZD9v7XIzuOYMPtO2Ma Wcr01O1ueNUS575kPonmZLLxUYwZb6xH8R9yXHXerGJaBYbYUnNOjpw0n6gKc+xVWisJ MtAeShoD90SQCUL2eZaaC9XuL69tIhmGoIOfu7SHZR2e7cg5OPs/U3Mb+9n3MaGlIK/m w8mHY9fxP9WhvA6tpN6+gTWZksutKYwApvoehgaqesCxiTAC4t+iEdtAAy5spusEnt+q 2+1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=pNr/1DCFp3OGZHbMno9rN7HNBDUZkvBFG/cYJYpKnoQ=; fh=gCuEpdnQLg4vssKdE7Wt3Rbe5N+ut+NBWC9tWnKbW6Q=; b=TThMPQIelrCzyNCqtBIkh4q4AHocPrnEYOMtc72sVVRFU2S/Y6Okui49w3B6e9llPF JpQNwNkY0m7HQbeNpKXdNfSrYpIcxnYISoX69FUpW60nbcWSK50q1Hka02ffo36AH8o3 F8zaNlkE7qR847S6PYeNba2J+Qb9XpctPj/9P9EFAx2TeqOvJ5VBNdXm05WecCmdCL8Q XrQ3sFuHSN/iZ57fvJpjtznx99SRPWzoSWJeIK+mjn7LE2MBKciEd/BswgSnAdFDc1tq YCBVLHosbYzKOnoyb1Fk4zeKouvL4JVODPAe6lFz5Pyo+yHk2kElKvZ1/WnYpmXBCfc6 x/NQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id k2-20020a633d02000000b0056da0ae25cfsi1523845pga.196.2023.10.20.02.52.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 02:52:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id E6CC5808690D; Fri, 20 Oct 2023 02:51:48 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376771AbjJTJvZ (ORCPT + 25 others); Fri, 20 Oct 2023 05:51:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376678AbjJTJvP (ORCPT ); Fri, 20 Oct 2023 05:51:15 -0400 Received: from mg.richtek.com (mg.richtek.com [220.130.44.152]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3006318F for ; Fri, 20 Oct 2023 02:51:09 -0700 (PDT) X-MailGates: (SIP:2,PASS,NONE)(compute_score:DELIVER,40,3) Received: from 192.168.10.46 by mg.richtek.com with MailGates ESMTPS Server V6.0(1461492:0:AUTH_RELAY) (envelope-from ) (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256/256); Fri, 20 Oct 2023 17:50:37 +0800 (CST) Received: from ex4.rt.l (192.168.10.47) by ex3.rt.l (192.168.10.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.25; Fri, 20 Oct 2023 17:50:36 +0800 Received: from linuxcarl2.richtek.com (192.168.10.154) by ex4.rt.l (192.168.10.45) with Microsoft SMTP Server id 15.2.1118.25 via Frontend Transport; Fri, 20 Oct 2023 17:50:36 +0800 From: To: Mark Brown CC: Liam Girdwood , Jaroslav Kysela , Takashi Iwai , ChiYuan Huang , Allen Lin , , Subject: [PATCH 2/3] ASoC: codecs: rtq9128: Fix TDM enable and DAI format control flow Date: Fri, 20 Oct 2023 17:50:34 +0800 Message-ID: <1697795435-5858-3-git-send-email-cy_huang@richtek.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1697795435-5858-1-git-send-email-cy_huang@richtek.com> References: <1697795435-5858-1-git-send-email-cy_huang@richtek.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Fri, 20 Oct 2023 02:51:49 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780267673977180354 X-GMAIL-MSGID: 1780267673977180354 From: ChiYuan Huang To enable TDM mode, the current control flow limits the function calling order should be 'set_tdm_slot->set_dai_fmt'. But not all platform sound card like as simeple card to follow this design. To bypass this limit, adjust the DAI format setting in runtime 'hw_param' callback. Signed-off-by: ChiYuan Huang --- sound/soc/codecs/rtq9128.c | 67 ++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/sound/soc/codecs/rtq9128.c b/sound/soc/codecs/rtq9128.c index 8c1c3c65475e..8a61a8a32db1 100644 --- a/sound/soc/codecs/rtq9128.c +++ b/sound/soc/codecs/rtq9128.c @@ -59,6 +59,7 @@ struct rtq9128_data { struct gpio_desc *enable; + unsigned int daifmt; int tdm_slots; int tdm_slot_width; bool tdm_input_data2_select; @@ -437,10 +438,7 @@ static const struct snd_soc_component_driver rtq9128_comp_driver = { static int rtq9128_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { struct rtq9128_data *data = snd_soc_dai_get_drvdata(dai); - struct snd_soc_component *comp = dai->component; struct device *dev = dai->dev; - unsigned int audfmt, fmtval; - int ret; dev_dbg(dev, "%s: fmt 0x%8x\n", __func__, fmt); @@ -450,35 +448,10 @@ static int rtq9128_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) return -EINVAL; } - fmtval = fmt & SND_SOC_DAIFMT_FORMAT_MASK; - if (data->tdm_slots && fmtval != SND_SOC_DAIFMT_DSP_A && fmtval != SND_SOC_DAIFMT_DSP_B) { - dev_err(dev, "TDM is used, format only support DSP_A or DSP_B\n"); - return -EINVAL; - } + /* Store here and will be used in runtime hw_params for DAI format setting */ + data->daifmt = fmt; - switch (fmtval) { - case SND_SOC_DAIFMT_I2S: - audfmt = 8; - break; - case SND_SOC_DAIFMT_LEFT_J: - audfmt = 9; - break; - case SND_SOC_DAIFMT_RIGHT_J: - audfmt = 10; - break; - case SND_SOC_DAIFMT_DSP_A: - audfmt = data->tdm_slots ? 12 : 11; - break; - case SND_SOC_DAIFMT_DSP_B: - audfmt = data->tdm_slots ? 4 : 3; - break; - default: - dev_err(dev, "Unsupported format 0x%8x\n", fmt); - return -EINVAL; - } - - ret = snd_soc_component_write_field(comp, RTQ9128_REG_I2S_OPT, RTQ9128_AUDFMT_MASK, audfmt); - return ret < 0 ? ret : 0; + return 0; } static int rtq9128_dai_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, @@ -554,10 +527,38 @@ static int rtq9128_dai_hw_params(struct snd_pcm_substream *stream, struct snd_pc unsigned int width, slot_width, bitrate, audbit, dolen; struct snd_soc_component *comp = dai->component; struct device *dev = dai->dev; + unsigned int fmtval, audfmt; int ret; dev_dbg(dev, "%s: width %d\n", __func__, params_width(param)); + fmtval = FIELD_GET(SND_SOC_DAIFMT_FORMAT_MASK, data->daifmt); + if (data->tdm_slots && fmtval != SND_SOC_DAIFMT_DSP_A && fmtval != SND_SOC_DAIFMT_DSP_B) { + dev_err(dev, "TDM is used, format only support DSP_A or DSP_B\n"); + return -EINVAL; + } + + switch (fmtval) { + case SND_SOC_DAIFMT_I2S: + audfmt = 8; + break; + case SND_SOC_DAIFMT_LEFT_J: + audfmt = 9; + break; + case SND_SOC_DAIFMT_RIGHT_J: + audfmt = 10; + break; + case SND_SOC_DAIFMT_DSP_A: + audfmt = data->tdm_slots ? 12 : 11; + break; + case SND_SOC_DAIFMT_DSP_B: + audfmt = data->tdm_slots ? 4 : 3; + break; + default: + dev_err(dev, "Unsupported format 0x%8x\n", fmtval); + return -EINVAL; + } + switch (width = params_width(param)) { case 16: audbit = 0; @@ -611,6 +612,10 @@ static int rtq9128_dai_hw_params(struct snd_pcm_substream *stream, struct snd_pc return -EINVAL; } + ret = snd_soc_component_write_field(comp, RTQ9128_REG_I2S_OPT, RTQ9128_AUDFMT_MASK, audfmt); + if (ret < 0) + return ret; + ret = snd_soc_component_write_field(comp, RTQ9128_REG_I2S_OPT, RTQ9128_AUDBIT_MASK, audbit); if (ret < 0) return ret; From patchwork Fri Oct 20 09:50:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ChiYuan Huang X-Patchwork-Id: 155944 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp938921vqb; Fri, 20 Oct 2023 02:51:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGbRgZw8guI+/LCkEbBw0aMrN5f0csTnitfW3XH2KZFnNhrXLc9sXXl7kCwcMYfrq4UX6py X-Received: by 2002:a05:6358:5927:b0:168:a3b2:945a with SMTP id g39-20020a056358592700b00168a3b2945amr1373939rwf.0.1697795505503; Fri, 20 Oct 2023 02:51:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697795505; cv=none; d=google.com; s=arc-20160816; b=LvogcdDrY/qB9O1taeCksKytryL2sNu+euOQX96tyqN25pPqySoBuMMKbvIVan3J+4 Vn8Aq/4xjiE+y0iFjWjZ9L5PUcBKz679kmoj/cHZnzS42MSD0aefO/IX2LTc/fC8Uz3X q+AARJZ0aCiV9WuXEPYwP1Kkwue1Y0wPerunPCU+Yv400erbHegAmgl7Qd6b1+1MFT+J WgUo3SiB5x9VhAiKyfwo21aCFJ0AvXQRGKxAwFqmcgs0ski8g73qw3hp/VBBPukbpB4c SBNTV8M2cwf2zkRRTIg6VT2Icf+b2HGr6ufM7mv9/xStLhW2AMJUWEQnXwjuDS+ZazPi HEvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=zGcee2Q5SJOkWPNWNOL4X25nb221QEPXjQx/mI3wawI=; fh=gCuEpdnQLg4vssKdE7Wt3Rbe5N+ut+NBWC9tWnKbW6Q=; b=CTOyv/T7oawwL5F4SlXMEloih1MGnvSDmY4ZW6k4o3eIqMB/EPdG7Q72RpEQ4KZs75 yfaqsaUB5w497YVta6xJMUTOZfu+0dxbWVUA/4sDslbMPyHE5+FzafwupxN4+D0SqfYR rnp2qmjOCmD8GyGPlr3wz0ShWjK0CxQHm5raIsytssIcmaptrsp8u+pqAYk3zy4yjnMd 0yva2QBksIyH0pNEcvlckLh62n2aNFdC6Yj5UYmE2hYuC5XnOHVIoqRQNo62HUWEvhgU fR8AwSkAEw48FGhUujHsxB7TwY6kg3xP7IUzLL6j7IfNsb7FnvCnTdA6iFfx71K8oN7v dKQg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id p23-20020a639517000000b005b43f17562fsi1542579pgd.266.2023.10.20.02.51.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 02:51:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 59F7183C6374; Fri, 20 Oct 2023 02:51:42 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376736AbjJTJv1 (ORCPT + 25 others); Fri, 20 Oct 2023 05:51:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376739AbjJTJvP (ORCPT ); Fri, 20 Oct 2023 05:51:15 -0400 Received: from mg.richtek.com (mg.richtek.com [220.130.44.152]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 306DF1AE for ; Fri, 20 Oct 2023 02:51:09 -0700 (PDT) X-MailGates: (SIP:2,PASS,NONE)(compute_score:DELIVER,40,3) Received: from 192.168.10.46 by mg.richtek.com with MailGates ESMTPS Server V6.0(1461490:0:AUTH_RELAY) (envelope-from ) (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256/256); Fri, 20 Oct 2023 17:50:37 +0800 (CST) Received: from ex4.rt.l (192.168.10.47) by ex3.rt.l (192.168.10.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.25; Fri, 20 Oct 2023 17:50:36 +0800 Received: from linuxcarl2.richtek.com (192.168.10.154) by ex4.rt.l (192.168.10.45) with Microsoft SMTP Server id 15.2.1118.25 via Frontend Transport; Fri, 20 Oct 2023 17:50:36 +0800 From: To: Mark Brown CC: Liam Girdwood , Jaroslav Kysela , Takashi Iwai , ChiYuan Huang , Allen Lin , , Subject: [PATCH 3/3] ASoC: codecs: rtq9128: Fix TKA470B E1 version amp on sequence Date: Fri, 20 Oct 2023 17:50:35 +0800 Message-ID: <1697795435-5858-4-git-send-email-cy_huang@richtek.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1697795435-5858-1-git-send-email-cy_huang@richtek.com> References: <1697795435-5858-1-git-send-email-cy_huang@richtek.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Fri, 20 Oct 2023 02:51:42 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780267620143024703 X-GMAIL-MSGID: 1780267620143024703 From: ChiYuan Huang For E1 sample, there's the current bias issue. Some undocumented RGs should be runtime controlled during the DAPM flow to prevent the abnormal false alarm protection latchup. Signed-off-by: ChiYuan Huang --- Hi, Our E1 sample is evaluated by some end customer. Alghouth it's not the final MP version. But to be compatible with the engineering sample, this fix can solve the amp on issue. --- sound/soc/codecs/rtq9128.c | 57 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/rtq9128.c b/sound/soc/codecs/rtq9128.c index 8a61a8a32db1..5d75dc63492b 100644 --- a/sound/soc/codecs/rtq9128.c +++ b/sound/soc/codecs/rtq9128.c @@ -63,6 +63,7 @@ struct rtq9128_data { int tdm_slots; int tdm_slot_width; bool tdm_input_data2_select; + bool tka470b_e1_ver; }; struct rtq9128_init_reg { @@ -171,7 +172,7 @@ static bool rtq9128_is_writeable_reg(struct device *dev, unsigned int reg) case 0x80 ... 0x8B: case 0xA0 ... 0xAD: case 0xB0 ... 0xBA: - case 0xC0: + case 0xC0 ... 0xC1: case 0xD0 ... 0xDE: case 0xE0 ... 0xE5: case 0xF0 ... 0xF3: @@ -283,6 +284,33 @@ static const struct snd_kcontrol_new rtq9128_snd_ctrls[] = { SOC_ENUM("DVDD UV Threshold Select", rtq9128_dvdduv_select_enum), }; +static int rtq9128_int_power_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, + int event) +{ + struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); + struct rtq9128_data *data = snd_soc_component_get_drvdata(comp); + int ret; + + dev_dbg(comp->dev, "%s: event %d, ver %d\n", __func__, event, data->tka470b_e1_ver); + + if (!data->tka470b_e1_ver) + return 0; + + if (event == SND_SOC_DAPM_POST_PMU) { + ret = snd_soc_component_write(comp, 0xB9, 0x03); + if (ret) + return ret; + + return snd_soc_component_write(comp, 0xC1, 0); + } + + ret = snd_soc_component_write(comp, 0xA1, 0x02); + if (ret) + return ret; + + return snd_soc_component_write(comp, 0xA8, 0x01); +} + static int rtq9128_dac_power_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { @@ -320,6 +348,8 @@ static int rtq9128_dac_power_event(struct snd_soc_dapm_widget *w, struct snd_kco } static const struct snd_soc_dapm_widget rtq9128_dapm_widgets[] = { + SND_SOC_DAPM_SUPPLY("PWR", SND_SOC_NOPM, 0, 0, rtq9128_int_power_event, + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), SND_SOC_DAPM_DAC_E("DAC1", NULL, SND_SOC_NOPM, 0, 0, rtq9128_dac_power_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), SND_SOC_DAPM_DAC_E("DAC2", NULL, SND_SOC_NOPM, 0, 0, rtq9128_dac_power_event, @@ -339,6 +369,10 @@ static const struct snd_soc_dapm_route rtq9128_dapm_routes[] = { { "DAC2", NULL, "Playback" }, { "DAC3", NULL, "Playback" }, { "DAC4", NULL, "Playback" }, + { "DAC1", NULL, "PWR" }, + { "DAC2", NULL, "PWR" }, + { "DAC3", NULL, "PWR" }, + { "DAC4", NULL, "PWR" }, { "OUT1", NULL, "DAC1" }, { "OUT2", NULL, "DAC2" }, { "OUT3", NULL, "DAC3" }, @@ -358,9 +392,7 @@ static const struct rtq9128_init_reg rtq9128_tka470b_tables[] = { { 0x70, 0x11 }, { 0x75, 0x1F }, { 0xB6, 0x03 }, - { 0xB9, 0x03 }, { 0xB8, 0x03 }, - { 0xC1, 0xFF }, { 0xF8, 0x72 }, { 0x30, 0x180 }, }; @@ -387,6 +419,7 @@ static const struct rtq9128_init_reg rtq9128_dl_tables[] = { static int rtq9128_component_probe(struct snd_soc_component *comp) { + struct rtq9128_data *data = snd_soc_component_get_drvdata(comp); const struct rtq9128_init_reg *table, *curr; size_t table_size; unsigned int val; @@ -398,6 +431,7 @@ static int rtq9128_component_probe(struct snd_soc_component *comp) switch (FIELD_GET(RTQ9128_DIE_CHECK_MASK, val)) { case RTQ9128_TKA470B_VAL: + data->tka470b_e1_ver = true; table = rtq9128_tka470b_tables; table_size = ARRAY_SIZE(rtq9128_tka470b_tables); break; @@ -626,12 +660,29 @@ static int rtq9128_dai_hw_params(struct snd_pcm_substream *stream, struct snd_pc static int rtq9128_dai_mute_stream(struct snd_soc_dai *dai, int mute, int stream) { + struct rtq9128_data *data = snd_soc_dai_get_drvdata(dai); struct snd_soc_component *comp = dai->component; struct device *dev = dai->dev; int ret; dev_dbg(dev, "%s: mute (%d), stream (%d)\n", __func__, mute, stream); + if (data->tka470b_e1_ver && !mute) { + ret = snd_soc_component_write(comp, 0xB9, 0x02); + if (ret) + return ret; + + usleep_range(10000, 11000); + + ret = snd_soc_component_write(comp, 0xA1, 0xF2); + if (ret) + return ret; + + ret = snd_soc_component_write(comp, 0xA8, 0x00); + if (ret) + return ret; + } + ret = snd_soc_component_write_field(comp, RTQ9128_REG_DSP_EN, RTQ9128_MSMUTE_MASK, mute ? 1 : 0); return ret < 0 ? ret : 0;