Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4880240ybi; Tue, 30 Jul 2019 09:43:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqyS7dv6PrWLaUmtMSzM8C0QVAy7va+ReFW8xJ6ZwgIIjuWfLbKN4oNUU++gl2thoW/U4VT/ X-Received: by 2002:a63:7455:: with SMTP id e21mr104810752pgn.439.1564505019756; Tue, 30 Jul 2019 09:43:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564505019; cv=none; d=google.com; s=arc-20160816; b=LqwgVgylkjn3TuAExqDYMwaA1NmL//PzwR0KDoU4iqbZCcULvDNC6mXm4lWSzYZDEC CoTEJm7+vxdgex0wWiQ6WIqAm5wEPRsHiVLZ/RY7hqw4p9fJ2F5ZloxElJHGqw3wq28y tefsEpykihLBwTdfX3GT+2b0RaaJOYHFex1rgQsqtLyxwHle/tzG56WTPJvlXjT6pbTP LlbRgzKlgy1HrFcmkvPusMBCU5CbFptdmLbNC1cmTw0qqlv1SMxRDo/NEFkLUfMTUfcQ jPBadKqfTiZKRr3UYrj09ks/u38pomRFt72VhHMknXKwzdQcJFe4o2/68cWj+65eiJh2 lTkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=LBkQlLC/Gb+S6rq5Lt1jRKvz9X+q4sH0ET1I6GLCMKI=; b=oPtuJKyCqBkH0TOyQx7o+poDJAT3Xq56U7ey0TMC/V/IYVWhcMVCuG5h0ARMuiLZi+ mXBXx5BMugH2DoBa0ZirBXLRjew5RWH5nt9ddpkBDT9AtGyYpUgEKje8MPIxZ6KrNSgl L58l/u9qkhu0gq4ppZLf/n8NMwytbkBNxszNgbbEExoY7jBPeRG4MKQFgJUjy+sWcBLV Tb8+ebmTaTdd6HtR9uGVdvPam7Fz2gdYyRB9LXFQQSTNv+ZRKyo9+ZwZPuh8+Dtv/VJj +++USad5WvKkNuMQZsNcv7KP/xi7JJv4Qj++NJqNr4Ow3kzb27PiJ/P11pmSdrn8R5pk fT9w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=codethink.co.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q10si31733317pgm.225.2019.07.30.09.43.24; Tue, 30 Jul 2019 09:43:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=codethink.co.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732612AbfG3Ptw (ORCPT + 99 others); Tue, 30 Jul 2019 11:49:52 -0400 Received: from imap1.codethink.co.uk ([176.9.8.82]:51548 "EHLO imap1.codethink.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727534AbfG3Pts (ORCPT ); Tue, 30 Jul 2019 11:49:48 -0400 Received: from [167.98.27.226] (helo=[10.35.6.253]) by imap1.codethink.co.uk with esmtpsa (Exim 4.84_2 #1 (Debian)) id 1hsUNZ-0001X8-C3; Tue, 30 Jul 2019 16:49:33 +0100 Subject: Re: [alsa-devel] [PATCH v2 2/3] ASoC: Add codec driver for ST TDA7802 To: Charles Keepax Cc: Mark Rutland , devicetree@vger.kernel.org, alsa-devel@alsa-project.org, Marco Felsch , Kuninori Morimoto , Kirill Marinushkin , Cheng-Yi Chiang , linux-kernel@vger.kernel.org, Nate Case , Takashi Iwai , Rob Herring , Liam Girdwood , Paul Cercueil , Vinod Koul , Mark Brown , Srinivas Kandagatla , Annaliese McDermond , Rob Duncan , Patrick Glaser , Jerome Brunet References: <20190730120937.16271-1-thomas.preston@codethink.co.uk> <20190730120937.16271-3-thomas.preston@codethink.co.uk> <20190730123825.GG54126@ediswmail.ad.cirrus.com> From: Thomas Preston Message-ID: <4285701d-ae61-208b-8f38-ac44e77ad9b5@codethink.co.uk> Date: Tue, 30 Jul 2019 16:49:32 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190730123825.GG54126@ediswmail.ad.cirrus.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 30/07/2019 13:38, Charles Keepax wrote: > On Tue, Jul 30, 2019 at 01:09:36PM +0100, Thomas Preston wrote: >> Add an I2C based codec driver for ST TDA7802 amplifier. The amplifier >> supports 4 audio channels but can support up to 16 with multiple >> devices. >> >> Signed-off-by: Thomas Preston >> Cc: Patrick Glaser >> Cc: Rob Duncan >> Cc: Nate Case >> --- >> Changes since v1: >> - Use ALSA kcontrol interface to expose device controls to userland >> - Gain >> - Channel diagnostic mode >> - Impedance efficiency optimiser. I decided against setting this >> as a DT property since it seems like something that can be >> changed on the fly. >> - Add regmap default values >> - Channel unmute by default is added in a downstream patch. >> - I'm not sure if I should keep this since they're all zero, >> although there are other drivers will all-zero reg_defaults. >> - I believe the "//" style is used for SPDX headers in normal C source files. >> https://lwn.net/Articles/739183/ >> - Drop the "enable" sysfs device attribute. >> - Don't set TDM format using magic numbers. >> - Set sample rate using hw_params. >> - Remove unecessary defines. >> - Use DAPM to handle AMP_ON. >> - Cosmetic fixups >> >> sound/soc/codecs/Kconfig | 6 + >> sound/soc/codecs/Makefile | 2 + >> sound/soc/codecs/tda7802.c | 509 +++++++++++++++++++++++++++++++++++++ >> 3 files changed, 517 insertions(+) >> create mode 100644 sound/soc/codecs/tda7802.c >> >> +++ b/sound/soc/codecs/tda7802.c >> @@ -0,0 +1,509 @@ >> +// SPDX-License-Identifier: GPL-2.0 >> +/* >> + * tda7802.c -- codec driver for ST TDA7802 >> + * >> + * Copyright (C) 2016-2019 Tesla Motors, Inc. >> + */ > > Better to make the whole comment // see something like > sound/soc/codecs/cs47l35.c for an example. > I will update to "//" style. Is this a new standard? There aren't many comments like that in 4.14 (my target kernel) - I can see a lot more in 5.3. My intention was: 1. Apply the SPDX rules to SPDX bit. Documentation/process/license-rules.rst 2. Use multi-line comments for the rest. Documentation/process/coding-style.rst >> +static int tda7802_set_bias_level(struct snd_soc_component *component, >> + enum snd_soc_bias_level level) >> +{ >> + const struct tda7802_priv *tda7802 = >> + snd_soc_component_get_drvdata(component); >> + struct snd_soc_dapm_context *dapm_context = >> + snd_soc_component_get_dapm(component); >> + const enum snd_soc_bias_level oldlevel = >> + snd_soc_dapm_get_bias_level(dapm_context); >> + int err = 0; >> + >> + dev_dbg(component->dev, "%s level %d\n", __func__, level); >> + >> + switch (level) { >> + case SND_SOC_BIAS_ON: >> + break; >> + case SND_SOC_BIAS_PREPARE: >> + break; >> + case SND_SOC_BIAS_STANDBY: >> + err = regulator_enable(tda7802->enable_reg); >> + if (err < 0) { >> + dev_err(component->dev, "Could not enable.\n"); >> + return err; >> + } >> + dev_dbg(component->dev, "Regulator enabled\n"); >> + msleep(ENABLE_DELAY_MS); >> + >> + if (oldlevel == SND_SOC_BIAS_OFF) { >> + dev_dbg(component->dev, "Syncing regcache\n"); >> + err = regcache_sync(component->regmap); >> + if (err < 0) >> + dev_err(component->dev, >> + "Could not sync regcache, %d\n", err); > > If your doing a regcache_sync I would probably have expected to > see calls to regcache_cache_only. > > If the device needs syncing that implies the hardware registers > have lost state, so there is little point in writing to them > if they are unavailable/about to loose their state. > Ah, from the comments I thought I only needed to call regcache_mark_dirty... >> + } >> + break; >> + case SND_SOC_BIAS_OFF: >> + regcache_mark_dirty(component->regmap); >> + err = regulator_disable(tda7802->enable_reg); >> + if (err < 0) >> + dev_err(component->dev, "Could not disable.\n"); >> + break; >> + } >> + >> + return err; >> +} So I think the correct order is: device_off: regcache_cache_only power-off (enable) regcache_mark_dirty device_on: power-on (enable) regcache_sync I will double-check the register state is actually lost too. Fiddling with the cache might be completely unnecessary. Many thanks