Re: [PATCH v2 26/28] ASoC: codecs: Add support for the framer codec

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 1 Aug 2023 12:30:26 +0200
Andrew Lunn <andrew@xxxxxxx> wrote:

> 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 <herve.codina@xxxxxxxxxxx>
> > ---
> >  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 <herve.codina@xxxxxxxxxxx>
> > +
> > +#include <linux/clk.h>
> > +#include <linux/framer/framer.h>
> > +#include <linux/module.h>
> > +#include <linux/notifier.h>
> > +#include <linux/platform_device.h>
> > +#include <linux/slab.h>
> > +#include <sound/jack.h>
> > +#include <sound/pcm_params.h>
> > +#include <sound/soc.h>
> > +#include <sound/tlv.h>
> > +
> > +#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".

Yes, will be fixed.

Regards,
Hervé



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux