Skip to content

Commit b81cfa6

Browse files
hcodinabroonie
authored andcommitted
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 <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 33a6969 commit b81cfa6

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

sound/soc/fsl/fsl_qmc_audio.c

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -436,24 +436,14 @@ static int qmc_dai_hw_rule_capture_format_by_channels(struct snd_pcm_hw_params *
436436
return qmc_dai_hw_rule_format_by_channels(qmc_dai, params, qmc_dai->nb_rx_ts);
437437
}
438438

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)
441441
{
442-
struct qmc_dai_prtd *prtd = substream->runtime->private_data;
443442
snd_pcm_hw_rule_func_t hw_rule_channels_by_format;
444443
snd_pcm_hw_rule_func_t hw_rule_format_by_channels;
445-
struct qmc_dai *qmc_dai;
446444
unsigned int frame_bits;
447445
int ret;
448446

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-
457447
if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
458448
hw_rule_channels_by_format = qmc_dai_hw_rule_capture_channels_by_format;
459449
hw_rule_format_by_channels = qmc_dai_hw_rule_capture_format_by_channels;
@@ -468,29 +458,46 @@ static int qmc_dai_startup(struct snd_pcm_substream *substream,
468458
hw_rule_channels_by_format, qmc_dai,
469459
SNDRV_PCM_HW_PARAM_FORMAT, -1);
470460
if (ret) {
471-
dev_err(dai->dev, "Failed to add channels rule (%d)\n", ret);
461+
dev_err(qmc_dai->dev, "Failed to add channels rule (%d)\n", ret);
472462
return ret;
473463
}
474464

475465
ret = snd_pcm_hw_rule_add(substream->runtime, 0, SNDRV_PCM_HW_PARAM_FORMAT,
476466
hw_rule_format_by_channels, qmc_dai,
477467
SNDRV_PCM_HW_PARAM_CHANNELS, -1);
478468
if (ret) {
479-
dev_err(dai->dev, "Failed to add format rule (%d)\n", ret);
469+
dev_err(qmc_dai->dev, "Failed to add format rule (%d)\n", ret);
480470
return ret;
481471
}
482472

483473
ret = snd_pcm_hw_constraint_single(substream->runtime,
484474
SNDRV_PCM_HW_PARAM_FRAME_BITS,
485475
frame_bits);
486476
if (ret < 0) {
487-
dev_err(dai->dev, "Failed to add frame_bits constraint (%d)\n", ret);
477+
dev_err(qmc_dai->dev, "Failed to add frame_bits constraint (%d)\n", ret);
488478
return ret;
489479
}
490480

491481
return 0;
492482
}
493483

484+
static int qmc_dai_startup(struct snd_pcm_substream *substream,
485+
struct snd_soc_dai *dai)
486+
{
487+
struct qmc_dai_prtd *prtd = substream->runtime->private_data;
488+
struct qmc_dai *qmc_dai;
489+
490+
qmc_dai = qmc_dai_get_data(dai);
491+
if (!qmc_dai) {
492+
dev_err(dai->dev, "Invalid dai\n");
493+
return -EINVAL;
494+
}
495+
496+
prtd->qmc_dai = qmc_dai;
497+
498+
return qmc_dai_constraints_interleaved(substream, qmc_dai);
499+
}
500+
494501
static int qmc_dai_hw_params(struct snd_pcm_substream *substream,
495502
struct snd_pcm_hw_params *params,
496503
struct snd_soc_dai *dai)

0 commit comments

Comments
 (0)