Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ASoC: fsl: fsl_qmc_audio: Introduce qmc_dai_constraints_interleaved()

Constraints are set by qmc_dai_startup(). These constraints are specific
to the interleaved mode.

With the future introduction of support for non-interleaved mode, a new
set of constraints will be set. To make the code clear and keep
qmc_dai_startup() simple, extract the current interleaved mode
constraints settings to a specific function.

Signed-off-by: Herve Codina <herve.codina@bootlin.com>
Link: https://patch.msgid.link/20240701113038.55144-7-herve.codina@bootlin.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Herve Codina and committed by
Mark Brown
b81cfa66 33a6969f

+22 -15
+22 -15
sound/soc/fsl/fsl_qmc_audio.c
··· 436 436 return qmc_dai_hw_rule_format_by_channels(qmc_dai, params, qmc_dai->nb_rx_ts); 437 437 } 438 438 439 - static int qmc_dai_startup(struct snd_pcm_substream *substream, 440 - struct snd_soc_dai *dai) 439 + static int qmc_dai_constraints_interleaved(struct snd_pcm_substream *substream, 440 + struct qmc_dai *qmc_dai) 441 441 { 442 - struct qmc_dai_prtd *prtd = substream->runtime->private_data; 443 442 snd_pcm_hw_rule_func_t hw_rule_channels_by_format; 444 443 snd_pcm_hw_rule_func_t hw_rule_format_by_channels; 445 - struct qmc_dai *qmc_dai; 446 444 unsigned int frame_bits; 447 445 int ret; 448 - 449 - qmc_dai = qmc_dai_get_data(dai); 450 - if (!qmc_dai) { 451 - dev_err(dai->dev, "Invalid dai\n"); 452 - return -EINVAL; 453 - } 454 - 455 - prtd->qmc_dai = qmc_dai; 456 446 457 447 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { 458 448 hw_rule_channels_by_format = qmc_dai_hw_rule_capture_channels_by_format; ··· 458 468 hw_rule_channels_by_format, qmc_dai, 459 469 SNDRV_PCM_HW_PARAM_FORMAT, -1); 460 470 if (ret) { 461 - dev_err(dai->dev, "Failed to add channels rule (%d)\n", ret); 471 + dev_err(qmc_dai->dev, "Failed to add channels rule (%d)\n", ret); 462 472 return ret; 463 473 } 464 474 ··· 466 476 hw_rule_format_by_channels, qmc_dai, 467 477 SNDRV_PCM_HW_PARAM_CHANNELS, -1); 468 478 if (ret) { 469 - dev_err(dai->dev, "Failed to add format rule (%d)\n", ret); 479 + dev_err(qmc_dai->dev, "Failed to add format rule (%d)\n", ret); 470 480 return ret; 471 481 } 472 482 ··· 474 484 SNDRV_PCM_HW_PARAM_FRAME_BITS, 475 485 frame_bits); 476 486 if (ret < 0) { 477 - dev_err(dai->dev, "Failed to add frame_bits constraint (%d)\n", ret); 487 + dev_err(qmc_dai->dev, "Failed to add frame_bits constraint (%d)\n", ret); 478 488 return ret; 479 489 } 480 490 481 491 return 0; 492 + } 493 + 494 + static int qmc_dai_startup(struct snd_pcm_substream *substream, 495 + struct snd_soc_dai *dai) 496 + { 497 + struct qmc_dai_prtd *prtd = substream->runtime->private_data; 498 + struct qmc_dai *qmc_dai; 499 + 500 + qmc_dai = qmc_dai_get_data(dai); 501 + if (!qmc_dai) { 502 + dev_err(dai->dev, "Invalid dai\n"); 503 + return -EINVAL; 504 + } 505 + 506 + prtd->qmc_dai = qmc_dai; 507 + 508 + return qmc_dai_constraints_interleaved(substream, qmc_dai); 482 509 } 483 510 484 511 static int qmc_dai_hw_params(struct snd_pcm_substream *substream,