From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 657102ECE99; Tue, 17 Jun 2025 15:49:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750175397; cv=none; b=rkJzq2Fb03fenK8rbQ/27uvaFfGlJLZ31tORo5ThmJe4Z6YBbyZaS87iQQhxdwQjwPvX8RUj7+qrNGgWuZtaR9fpvmCNeOR/C73EmTzPvj5LwyCgDF1Pf64fmCun08EKQRDNRFXxEUUoRYmBQOeCP9lge7XxSGXxIHYlIvqUiqk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750175397; c=relaxed/simple; bh=c7mkup13KOb2pv0emSUK7+lp9mIgXr1v5VtYJ534n4Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kxBTEEw0NIQpW/Awn6XDzA4QtemUfj+dzi41EN3SBwTThv63ahnGeF/pogqrIEp7gyyKHTlI2tDgYQ0zgfJ5jVXRgKlNONrtvQX4NKs3uWuMwftkM0qLN6tGhZUxbtKC89TAu612Ef5UQZKeq6aA0dPJ6p8HmqDdbbYyAlIjKb8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=0RKL842n; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="0RKL842n" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3B3CC4CEE3; Tue, 17 Jun 2025 15:49:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1750175397; bh=c7mkup13KOb2pv0emSUK7+lp9mIgXr1v5VtYJ534n4Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0RKL842nNd3KG6HcepB8Qr4NIb9dydV58bAAGqQy9neY61ClGDhWK9PMFM5vwNbG3 BvHaHlN8dQ9JV+heWJzdlEVoYMXJoGsWJoHEGYp39pQ6y55kZZO9osf2J+2oyhtk1L WJ5qZeLaSoePlevNIr4BZYdyapSTbRtlln6lZyTg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, =?UTF-8?q?Martin=20Povi=C5=A1er?= , James Calligeros , Mark Brown , Sasha Levin Subject: [PATCH 6.15 084/780] ASoC: apple: mca: Constrain channels according to TDM mask Date: Tue, 17 Jun 2025 17:16:32 +0200 Message-ID: <20250617152454.939116027@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250617152451.485330293@linuxfoundation.org> References: <20250617152451.485330293@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Martin Povišer [ Upstream commit e717c661e2d1a660e96c40b0fe9933e23a1d7747 ] We don't (and can't) configure the hardware correctly if the number of channels exceeds the weight of the TDM mask. Report that constraint in startup of FE. Fixes: 3df5d0d97289 ("ASoC: apple: mca: Start new platform driver") Signed-off-by: Martin Povišer Signed-off-by: James Calligeros Link: https://patch.msgid.link/20250518-mca-fixes-v1-1-ee1015a695f6@gmail.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/apple/mca.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/sound/soc/apple/mca.c b/sound/soc/apple/mca.c index b4f4696809dd2..5dd24ab90d0f0 100644 --- a/sound/soc/apple/mca.c +++ b/sound/soc/apple/mca.c @@ -464,6 +464,28 @@ static int mca_configure_serdes(struct mca_cluster *cl, int serdes_unit, return -EINVAL; } +static int mca_fe_startup(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct mca_cluster *cl = mca_dai_to_cluster(dai); + unsigned int mask, nchannels; + + if (cl->tdm_slots) { + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + mask = cl->tdm_tx_mask; + else + mask = cl->tdm_rx_mask; + + nchannels = hweight32(mask); + } else { + nchannels = 2; + } + + return snd_pcm_hw_constraint_minmax(substream->runtime, + SNDRV_PCM_HW_PARAM_CHANNELS, + 1, nchannels); +} + static int mca_fe_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) { @@ -680,6 +702,7 @@ static int mca_fe_hw_params(struct snd_pcm_substream *substream, } static const struct snd_soc_dai_ops mca_fe_ops = { + .startup = mca_fe_startup, .set_fmt = mca_fe_set_fmt, .set_bclk_ratio = mca_set_bclk_ratio, .set_tdm_slot = mca_fe_set_tdm_slot, -- 2.39.5