From patchwork Tue Oct 8 09:33:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?U2h1bWluZyBb6IyD5pu46YqYXQ==?= X-Patchwork-Id: 11179237 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5739F1668 for ; Tue, 8 Oct 2019 09:34:29 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C5EA4217D7 for ; Tue, 8 Oct 2019 09:34:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="mHbzjPAo" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C5EA4217D7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=realtek.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 027B51660; Tue, 8 Oct 2019 11:33:37 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 027B51660 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1570527267; bh=1u70P/1r9CflW2MgtRqjj6kqm+bjex5jSHZaCAUXq7M=; h=From:To:Date:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=mHbzjPAogAOAfB0evfXGZrvCLKnFNPn9ZBbCDX3F0/hHdeSB0Xz4VfenxAM9Zh9kh FNfFkxCfk8h58fMC5DXbsXZlqJZYgF4ZPMcnOmvKVzkvserGKb1tJQkEOrVKmvlr8r EBveg+u7T37EPy37HyOrxxiaLWfRKfo4CFnn09qk= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 91A8AF80322; Tue, 8 Oct 2019 11:33:36 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 99347F8045E; Tue, 8 Oct 2019 11:33:34 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from rtits2.realtek.com.tw (rtits2.realtek.com [211.75.126.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id ABCC3F800BF for ; Tue, 8 Oct 2019 11:33:29 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz ABCC3F800BF Authenticated-By: X-SpamFilter-By: BOX Solutions SpamTrap 5.62 with qID x989XPsG019190, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (RTITCAS11.realtek.com.tw[172.21.6.12]) by rtits2.realtek.com.tw (8.15.2/2.57/5.78) with ESMTPS id x989XPsG019190 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 8 Oct 2019 17:33:26 +0800 Received: from RTEXMB01.realtek.com.tw (172.21.6.94) by RTITCAS11.realtek.com.tw (172.21.6.12) with Microsoft SMTP Server (TLS) id 14.3.468.0; Tue, 8 Oct 2019 17:33:25 +0800 Received: from RTEXMB01.realtek.com.tw (172.21.6.94) by RTEXMB01.realtek.com.tw (172.21.6.94) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1779.2; Tue, 8 Oct 2019 17:33:24 +0800 Received: from RTEXMB01.realtek.com.tw ([fe80::6d88:58e2:6d4b:ff7c]) by RTEXMB01.realtek.com.tw ([fe80::6d88:58e2:6d4b:ff7c%13]) with mapi id 15.01.1779.005; Tue, 8 Oct 2019 17:33:24 +0800 From: =?big5_tw?b?U2h1bWluZyBbrVOu0bvKXQ==?= To: "broonie@kernel.org" , "lgirdwood@gmail.com" Thread-Topic: [PATCH] ASoC: rt1011: export r0 and temperature config Thread-Index: AdV9u26p1DMGwkqZTrmPc4068Rp6yQ== Date: Tue, 8 Oct 2019 09:33:24 +0000 Message-ID: <8f933cee57fc4420875e1e2ba14f1937@realtek.com> Accept-Language: zh-TW, en-US Content-Language: zh-TW X-MS-Has-Attach: X-MS-TNEF-Correlator: <8f933cee57fc4420875e1e2ba14f1937@realtek.com> x-originating-ip: [172.22.102.105] MIME-Version: 1.0 Cc: Oder Chiou , Jack Yu , "alsa-devel@alsa-project.org" , "lars@metafoo.de" , "cychiang@google.com" , =?big5_tw?b?RGVyZWsgW6TovHe4cV0=?= , =?big5_tw?b?U2h1?= =?big5_tw?b?bWluZyBbrVOu0bvKXQ==?= , "Flove\(HsinFu\)" Subject: [alsa-devel] [PATCH] ASoC: rt1011: export r0 and temperature config X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" In chromebook case, the machine driver will get the r0 calibration data and temperature from VPD. Therefore, the codec exports r0 and temperature config API for it. Signed-off-by: Shuming Fan --- sound/soc/codecs/rt1011.c | 41 +++++++++++++++++++++++++++++++++++++++ sound/soc/codecs/rt1011.h | 5 +++++ 2 files changed, 46 insertions(+) diff --git a/sound/soc/codecs/rt1011.c b/sound/soc/codecs/rt1011.c index a92a0bacd812..a992bb2224b2 100644 --- a/sound/soc/codecs/rt1011.c +++ b/sound/soc/codecs/rt1011.c @@ -1325,6 +1325,47 @@ static int rt1011_r0_load_info(struct snd_kcontrol *kcontrol, .put = rt1011_r0_load_mode_put \ } +int rt1011_r0_config(struct snd_soc_component *component, unsigned int r0) +{ + struct rt1011_priv *rt1011 = + snd_soc_component_get_drvdata(component); + struct device *dev; + unsigned int r0_integer, r0_factor, format; + + if (!component->card->instantiated) + return 0; + + if (!r0) + return -EINVAL; + + dev = regmap_get_device(rt1011->regmap); + rt1011->r0_reg = r0; + + format = 2147483648U; /* 2^24 * 128 */ + r0_integer = format / rt1011->r0_reg / 128; + r0_factor = ((format / rt1011->r0_reg * 100) / 128) + - (r0_integer * 100); + dev_dbg(dev, "New r0 resistance about %d.%02d ohm, reg=0x%X\n", + r0_integer, r0_factor, rt1011->r0_reg); + + if (rt1011->r0_reg) + rt1011_r0_load(rt1011); + + return 0; +} +EXPORT_SYMBOL_GPL(rt1011_r0_config); + +int rt1011_temperature_config(struct snd_soc_component *component, + unsigned int temp) +{ + snd_soc_component_update_bits(component, + RT1011_STP_INITIAL_RESISTANCE_TEMP, 0x3ff, + (temp << 2)); + + return 0; +} +EXPORT_SYMBOL_GPL(rt1011_temperature_config); + static const struct snd_kcontrol_new rt1011_snd_controls[] = { /* I2S Data In Selection */ SOC_ENUM("DIN Source", rt1011_din_source_enum), diff --git a/sound/soc/codecs/rt1011.h b/sound/soc/codecs/rt1011.h index 2d65983f3d0f..b99df334be14 100644 --- a/sound/soc/codecs/rt1011.h +++ b/sound/soc/codecs/rt1011.h @@ -670,4 +670,9 @@ struct rt1011_priv { int recv_spk_mode; }; +int rt1011_r0_config(struct snd_soc_component *component, unsigned int r0); +int rt1011_temperature_config(struct snd_soc_component *component, + unsigned int temp); + + #endif /* end of _RT1011_H_ */