Thread (91 messages) flat view 91 messages, 8 authors, 2023-08-08

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

From: Herve Codina <herve.codina@bootlin.com>
Date: 2023-08-08 17:20:40
Also in: alsa-devel, linux-arm-kernel, linux-devicetree, linux-gpio, lkml, netdev

On Tue, 8 Aug 2023 08:26:16 +0000
Christophe Leroy [off-list ref] wrote:
Le 26/07/2023 à 17:02, Herve Codina a écrit :
quoted
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@bootlin.com>  
Reviewed-by: Christophe Leroy <redacted>

See below
quoted
+static int framer_dai_hw_rule_channels_by_format(struct snd_soc_dai *dai,
+						 struct snd_pcm_hw_params *params,
+						 unsigned int nb_ts)
+{
+	struct snd_interval *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
+	snd_pcm_format_t format = params_format(params);
+	struct snd_interval ch = {0};
+
+	switch (snd_pcm_format_physical_width(format)) {
+	case 8:
+		ch.max = nb_ts;
+		break;
+	case 16:
+		ch.max = nb_ts / 2;
+		break;
+	case 32:
+		ch.max = nb_ts / 4;
+		break;
+	case 64:
+		ch.max = nb_ts / 8;
+		break;
+	default:
+		dev_err(dai->dev, "format physical width %u not supported\n",
+			snd_pcm_format_physical_width(format));
+		return -EINVAL;
+	}  
What about

	width = snd_pcm_format_physical_width(format);

	if (width == 8 || width == 16 || width == 32 || width == 64) {
		ch.max = nb_ts * 8 / width;
	} else {
		dev_err(dai->dev, "format physical width %u not supported\n", width);
		return -EINVAL;
	}
Yes, indeed.
Will be changed in the next iteration.

Regards,
Hervé
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help