Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp5540049rwb; Tue, 1 Aug 2023 04:28:10 -0700 (PDT) X-Google-Smtp-Source: APBJJlE0zfRwXqFluEPjVyBXytaxJJmZ0BGiGldoBp2/5V/iasJ4GhAaQVEwtzQ1dXzc91TqNkEN X-Received: by 2002:aa7:cd72:0:b0:521:ad49:8493 with SMTP id ca18-20020aa7cd72000000b00521ad498493mr3106629edb.6.1690889289872; Tue, 01 Aug 2023 04:28:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690889289; cv=none; d=google.com; s=arc-20160816; b=mezEc4n2LtS26CCQC8N0oTH1YB2JKpa4KLbOpU5OMvLkzLN/ZM4geCIsEIdnO3J5bY fCwFIe3oeBjvNnnr920JtKc98TPTLfiGxA65DZgJg3FJnTWXd0r2Rp2/1kq6IW201yZT N65d0Giklm6pI2HpJxA9iovigwt/IobZrZQ4Q6YxJc5wYLjKet6ct7P+AL5TOAgTF8rN K2/GmdEqqQiClUq/RcAjW5T+xCMm9DAGaULkFVG97MMM2FqLS9PspIO+fN7+igJcJZOG e+Hsdc180ezfGCuh6NP8cSRN704ecfrofs7m3rDWcVvugU3Lg6/k/wI/xgWey2zrGk09 n8Dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=KeOeZN8j1Kv4rdUg/08Xyr1q7VbFfZ43LqMnjplQud8=; fh=u5USNaHO4dqQSGHgaAwRuPmXzitTZs97zzxHNuywu58=; b=rbUaQbIYWeU6SDfk/LuOpr9FI2CepiqsNDRUDVGiBcLpCOU2ogkqgeXcRi8msuVqJx nppHwRZ8Jo1Wtvvf7E/GrV05hUiN6kJs+7o1lSQEBg3/Nnbt9nl37Qhpu/OkyyN5h3DX ddMcLS3hXnJQQ+J/pX5d1Xzlj77+7NgqGVJBW5fk6QSd9B43SHSNtRZnGoGgTFIXS7E3 eHTPLS6b4vunRrCkFXO4/Ov2f170t9PcSSksA7fbFRH3CFpny5ujgpJZ8LTU+nWNXfWJ jDeS8Pq4aYGBu53HIISLVfjRax85+xrEqqJHgbW5uAoV7AUvz0l6K8JzzFurkHlP52Zx VNag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=eiy6XJ1+; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f20-20020a056402161400b0051ffa9193f8si8031082edv.445.2023.08.01.04.27.45; Tue, 01 Aug 2023 04:28:09 -0700 (PDT) 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=@lunn.ch header.s=20171124 header.b=eiy6XJ1+; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232540AbjHAKao (ORCPT + 99 others); Tue, 1 Aug 2023 06:30:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232493AbjHAKam (ORCPT ); Tue, 1 Aug 2023 06:30:42 -0400 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 602E492; Tue, 1 Aug 2023 03:30:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=KeOeZN8j1Kv4rdUg/08Xyr1q7VbFfZ43LqMnjplQud8=; b=eiy6XJ1+OayMv3ZjecdJgWMT9C Uv5GOK/vQES7nI9CpL7KwfXjXVd5FKQnbNysWgmJl1slR3hFYDF+ttduAxM75xNKTR3wYVnCt6KOh oJmD9ziJMqaYZvpmHWHL2O+EqtZWvujJfqSoTNm77Ddkj4YFYzYuus4k8aBdjREqinVo=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1qQme2-002n9O-R9; Tue, 01 Aug 2023 12:30:26 +0200 Date: Tue, 1 Aug 2023 12:30:26 +0200 From: Andrew Lunn To: Herve Codina Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Lee Jones , Linus Walleij , Qiang Zhao , Li Yang , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Shengjiu Wang , Xiubo Li , Fabio Estevam , Nicolin Chen , Christophe Leroy , Randy Dunlap , netdev@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, alsa-devel@alsa-project.org, Thomas Petazzoni Subject: Re: [PATCH v2 26/28] ASoC: codecs: Add support for the framer codec Message-ID: <2e253048-a36e-4fee-b2f4-22f19230cf54@lunn.ch> References: <20230726150225.483464-1-herve.codina@bootlin.com> <20230726150225.483464-27-herve.codina@bootlin.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230726150225.483464-27-herve.codina@bootlin.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 On Wed, Jul 26, 2023 at 05:02:22PM +0200, Herve Codina wrote: > The framer codec interracts with a framer. > It allows to use some of the framer timeslots as audio channels to > transport audio data over the framer E1/T1/J1 lines. > It also reports line carrier detection events through the ALSA jack > detection feature. > > Signed-off-by: Herve Codina > --- > sound/soc/codecs/Kconfig | 15 ++ > sound/soc/codecs/Makefile | 2 + > sound/soc/codecs/framer-codec.c | 423 ++++++++++++++++++++++++++++++++ > 3 files changed, 440 insertions(+) > create mode 100644 sound/soc/codecs/framer-codec.c > > diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig > index f99203ef9b03..a86cdac39b72 100644 > --- a/sound/soc/codecs/Kconfig > +++ b/sound/soc/codecs/Kconfig > @@ -110,6 +110,7 @@ config SND_SOC_ALL_CODECS > imply SND_SOC_ES8328_I2C > imply SND_SOC_ES7134 > imply SND_SOC_ES7241 > + imply SND_SOC_FRAMER > imply SND_SOC_GTM601 > imply SND_SOC_HDAC_HDMI > imply SND_SOC_HDAC_HDA > @@ -1043,6 +1044,20 @@ config SND_SOC_ES8328_SPI > depends on SPI_MASTER > select SND_SOC_ES8328 > > +config SND_SOC_FRAMER > + tristate "Framer codec" > + depends on GENERIC_FRAMER > + help > + Enable support for the framer codec. > + The framer codec uses the generic framer infrastructure to transport > + some audio data over an analog E1/T1/J1 line. > + This codec allows to use some of the time slots available on the TDM > + bus on which the framer is connected to transport the audio data. > + > + To compile this driver as a module, choose M here: the module > + will be called snd-soc-framer. > + > + > config SND_SOC_GTM601 > tristate 'GTM601 UMTS modem audio codec' > > diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile > index 32dcc6de58bd..54667274a0f6 100644 > --- a/sound/soc/codecs/Makefile > +++ b/sound/soc/codecs/Makefile > @@ -116,6 +116,7 @@ snd-soc-es8326-objs := es8326.o > snd-soc-es8328-objs := es8328.o > snd-soc-es8328-i2c-objs := es8328-i2c.o > snd-soc-es8328-spi-objs := es8328-spi.o > +snd-soc-framer-objs := framer-codec.o > snd-soc-gtm601-objs := gtm601.o > snd-soc-hdac-hdmi-objs := hdac_hdmi.o > snd-soc-hdac-hda-objs := hdac_hda.o > @@ -499,6 +500,7 @@ obj-$(CONFIG_SND_SOC_ES8326) += snd-soc-es8326.o > obj-$(CONFIG_SND_SOC_ES8328) += snd-soc-es8328.o > obj-$(CONFIG_SND_SOC_ES8328_I2C)+= snd-soc-es8328-i2c.o > obj-$(CONFIG_SND_SOC_ES8328_SPI)+= snd-soc-es8328-spi.o > +obj-$(CONFIG_SND_SOC_FRAMER) += snd-soc-framer.o > obj-$(CONFIG_SND_SOC_GTM601) += snd-soc-gtm601.o > obj-$(CONFIG_SND_SOC_HDAC_HDMI) += snd-soc-hdac-hdmi.o > obj-$(CONFIG_SND_SOC_HDAC_HDA) += snd-soc-hdac-hda.o > diff --git a/sound/soc/codecs/framer-codec.c b/sound/soc/codecs/framer-codec.c > new file mode 100644 > index 000000000000..52b4546a61ee > --- /dev/null > +++ b/sound/soc/codecs/framer-codec.c > @@ -0,0 +1,423 @@ > +// SPDX-License-Identifier: GPL-2.0 > +// > +// Framer ALSA SoC driver > +// > +// Copyright 2023 CS GROUP France > +// > +// Author: Herve Codina > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#define FRAMER_NB_CHANNEL 32 > +#define FRAMER_JACK_MASK (SND_JACK_LINEIN | SND_JACK_LINEOUT) > + > +struct framer_codec { > + struct framer *framer; > + struct device *dev; > + struct snd_soc_jack jack; > + struct notifier_block nb; > + struct work_struct carrier_work; > + int max_chan_playback; > + int max_chan_capture; > +}; > + > +static int framer_dai_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, > + unsigned int rx_mask, int slots, int width) > +{ > + struct framer_codec *framer = snd_soc_component_get_drvdata(dai->component); > + > + switch (width) { > + case 0: > + /* Not set -> default 8 */ > + case 8: > + break; > + default: > + dev_err(dai->dev, "tdm slot width %d not supported\n", width); > + return -EINVAL; > + } > + > + framer->max_chan_playback = hweight32(tx_mask); > + if (framer->max_chan_playback > FRAMER_NB_CHANNEL) { > + dev_err(dai->dev, "too much tx slots defined (mask = 0x%x) support max %d\n", "many", not "much". Also, "supported". Andrew