Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4640939ybi; Tue, 30 Jul 2019 05:42:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqyGAQuy1gI4B5EyOOj2cDS8d0wdIKu0EHI+Vl2N0917/ecshOjGCHq3awShVGNeka3+XcmF X-Received: by 2002:aa7:8b51:: with SMTP id i17mr42300128pfd.33.1564490520949; Tue, 30 Jul 2019 05:42:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564490520; cv=none; d=google.com; s=arc-20160816; b=kEHgbgJ9J11uGkh/HHntJvMBFnWvLXYQan+EMm/e54ViMKnDzD1IyeAe/Ty9QnApKa a6kkT5qv13LdQFLk+FvM/Bc2Jiv2d/8Fq0f0B2A/UmttGlEG9lIpQFlfXttsdYhhF8Hl 0NtMA4tZ6coR2LPMl2i9lQEAelEyAAz/Y217Qbiv+zbaMvEVB2bSbm+nXc2wT+almLXA /KirwHYZ3ENvk6P4J+qCFdtEuVubKZCvEj4KaQkNymZOUdkCOeIDwsE3T8hmA848QebN fRVIpXyyfzLctuqHeq4UeF8sCz8vPoUJAaR26oqejx6fcQ0cJrvOJe2bTaOP1fTfFC72 TYDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=6HCkdIwaoyyCwQknwT42TOpVmmhCKXspp52zKlcFeyo=; b=UI5OalYH3HfapBXFtuy4RRmn4qFyDnyezo4zjRkflwnJ3wIN9I5BJBdc7pUyfgJAsp gdngq5A76LHrFMRBW6KwC4eQQbUgZqfEO4tqG+kMwWN2dB3U/t5qJ1Gq5qtkxXDZMImm 7ODSOrdGQk59Dk9hLzPBNEUOEA/uj3ro923KyDS1zwMxSlSBV3XhLYlj/usI4aH4eaYt UKMht5UFjK7iiaTZ1+da7Yc04hPeJbcfC+WadF6NSBhfQqAojLeN0grJu/wiWrMwsK7x yEfh6YJArLJk+OL5ouNoeoPB0k6FE4B3n1deOSWqESK3V9Q4tPvayHswReMaGGGCnwI6 DlPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=fqB7AJK2; 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=pass (p=NONE sp=NONE dis=NONE) header.from=opensource.cirrus.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m11si30876564pgd.261.2019.07.30.05.41.45; Tue, 30 Jul 2019 05:42:00 -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; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=fqB7AJK2; 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=pass (p=NONE sp=NONE dis=NONE) header.from=opensource.cirrus.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730317AbfG3Mkt (ORCPT + 99 others); Tue, 30 Jul 2019 08:40:49 -0400 Received: from mx0a-001ae601.pphosted.com ([67.231.149.25]:33370 "EHLO mx0b-001ae601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727937AbfG3Mks (ORCPT ); Tue, 30 Jul 2019 08:40:48 -0400 Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x6UCXjXq021707; Tue, 30 Jul 2019 07:38:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=PODMain02222019; bh=6HCkdIwaoyyCwQknwT42TOpVmmhCKXspp52zKlcFeyo=; b=fqB7AJK2Us/yKa/m8XKIw+52gadnVyb7wkhGgZXZ7B7AtnaZ9G/IZieauUPQrSJIFunq AVcakZwFCfHMgrFZ2RGeUTwk6pYHPudLaO+4zgRBe2PrKUBUQlnvEYCna7j1Rka6S5aH WFtQmNDnSn5f9NbdnGelbYXAPzzjtxiKyMxgKecCnFzOwf9lng5uZbnf/r3IJzM1XZgH FJBk5wko7bplEmNTgYs5FqwZX6dDZweqQKIaaNy8RyT99epPf7l+OuKRIavO3NTIPO+L KK1RUHmNHWBgthQ7AnA/tJdtpZd0fSJAGRIVQHKSTC+uBmnG7d+FFJAxAqTZ+TXnBY2o cA== Authentication-Results: ppops.net; spf=fail smtp.mailfrom=ckeepax@opensource.cirrus.com Received: from ediex01.ad.cirrus.com ([87.246.76.36]) by mx0a-001ae601.pphosted.com with ESMTP id 2u0mapmtdu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Tue, 30 Jul 2019 07:38:28 -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.1591.10; Tue, 30 Jul 2019 13:38:25 +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.1591.10 via Frontend Transport; Tue, 30 Jul 2019 13:38:25 +0100 Received: from ediswmail.ad.cirrus.com (ediswmail.ad.cirrus.com [198.61.86.93]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 06F0745; Tue, 30 Jul 2019 13:38:25 +0100 (BST) Date: Tue, 30 Jul 2019 13:38:25 +0100 From: Charles Keepax To: Thomas Preston CC: Liam Girdwood , Mark Brown , Rob Herring , Mark Rutland , Jaroslav Kysela , Takashi Iwai , Jerome Brunet , Srinivas Kandagatla , Marco Felsch , Paul Cercueil , Kirill Marinushkin , Cheng-Yi Chiang , Kuninori Morimoto , Vinod Koul , Annaliese McDermond , , , , Patrick Glaser , Rob Duncan , Nate Case Subject: Re: [PATCH v2 2/3] ASoC: Add codec driver for ST TDA7802 Message-ID: <20190730123825.GG54126@ediswmail.ad.cirrus.com> References: <20190730120937.16271-1-thomas.preston@codethink.co.uk> <20190730120937.16271-3-thomas.preston@codethink.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20190730120937.16271-3-thomas.preston@codethink.co.uk> User-Agent: Mutt/1.5.21 (2010-09-15) X-Proofpoint-SPF-Result: fail X-Proofpoint-SPF-Record: v=spf1 include:spf-001ae601.pphosted.com include:spf.protection.outlook.com -all X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 phishscore=0 impostorscore=0 clxscore=1015 suspectscore=0 spamscore=0 lowpriorityscore=0 mlxlogscore=999 priorityscore=1501 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1906280000 definitions=main-1907300132 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > +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. > + } > + 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; > +} Thanks, Charles