Lines Matching +full:max +full:- +full:sample +full:- +full:rate +full:- +full:hz

1 // SPDX-License-Identifier: GPL-2.0
3 // soc-dai.c
10 #include <sound/soc-dai.h>
11 #include <sound/soc-link.h>
17 return snd_soc_ret(dai->dev, ret,
18 "at %s() on %s\n", func, dai->name);
25 #define soc_dai_mark_push(dai, substream, tgt) ((dai)->mark_##tgt = substream)
26 #define soc_dai_mark_pop(dai, tgt) ((dai)->mark_##tgt = NULL)
27 #define soc_dai_mark_match(dai, substream, tgt) ((dai)->mark_##tgt == substream)
30 * snd_soc_dai_set_sysclk - configure DAI system or master clock.
33 * @freq: new clock frequency in Hz
43 if (dai->driver->ops &&
44 dai->driver->ops->set_sysclk)
45 ret = dai->driver->ops->set_sysclk(dai, clk_id, freq, dir);
47 ret = snd_soc_component_set_sysclk(dai->component, clk_id, 0,
55 * snd_soc_dai_set_clkdiv - configure DAI clock dividers.
67 int ret = -EINVAL;
69 if (dai->driver->ops &&
70 dai->driver->ops->set_clkdiv)
71 ret = dai->driver->ops->set_clkdiv(dai, div_id, div);
78 * snd_soc_dai_set_pll - configure DAI PLL.
82 * @freq_in: PLL input clock frequency in Hz
83 * @freq_out: requested PLL output clock frequency in Hz
92 if (dai->driver->ops &&
93 dai->driver->ops->set_pll)
94 ret = dai->driver->ops->set_pll(dai, pll_id, source,
97 ret = snd_soc_component_set_pll(dai->component, pll_id, source,
105 * snd_soc_dai_set_bclk_ratio - configure BCLK to sample rate ratio.
107 * @ratio: Ratio of BCLK to Sample rate.
109 * Configures the DAI for a preset BCLK to sample rate ratio.
113 int ret = -ENOTSUPP;
115 if (dai->driver->ops &&
116 dai->driver->ops->set_bclk_ratio)
117 ret = dai->driver->ops->set_bclk_ratio(dai, ratio);
126 int i, max = 0;
129 * return max num if *ALL* DAIs have .auto_selectable_formats
132 if (dai->driver->ops &&
133 dai->driver->ops->num_auto_selectable_formats)
134 max = max(max, dai->driver->ops->num_auto_selectable_formats);
139 return max;
143 * snd_soc_dai_get_fmt - get supported audio format.
157 const struct snd_soc_dai_ops *ops = dai->driver->ops;
159 int i, max = 0, until = priority;
175 max = ops->num_auto_selectable_formats;
177 if (max < until)
178 until = max;
181 fmt |= ops->auto_selectable_formats[i];
187 * snd_soc_dai_set_fmt - configure DAI hardware audio format.
195 int ret = -ENOTSUPP;
197 if (dai->driver->ops && dai->driver->ops->set_fmt)
198 ret = dai->driver->ops->set_fmt(dai, fmt);
205 * snd_soc_xlate_tdm_slot_mask - generate tx/rx slot mask.
220 return -EINVAL;
222 *tx_mask = (1 << slots) - 1;
223 *rx_mask = (1 << slots) - 1;
229 * snd_soc_dai_set_tdm_slot() - Configures a DAI for TDM operation
255 int ret = -ENOTSUPP;
263 if (dai->driver->ops &&
264 dai->driver->ops->xlate_tdm_slot_mask)
265 ret = dai->driver->ops->xlate_tdm_slot_mask(slots, &tx_mask, &rx_mask);
275 if (dai->driver->ops &&
276 dai->driver->ops->set_tdm_slot)
277 ret = dai->driver->ops->set_tdm_slot(dai, tx_mask, rx_mask,
285 * snd_soc_dai_set_channel_map - configure DAI audio channel map
289 * 0~num-1 uses
292 * 0~num-1 uses
300 int ret = -ENOTSUPP;
302 if (dai->driver->ops &&
303 dai->driver->ops->set_channel_map)
304 ret = dai->driver->ops->set_channel_map(dai, tx_num, tx_slot,
311 * snd_soc_dai_get_channel_map - Get DAI audio channel map
315 * 0~num-1 uses
318 * 0~num-1 uses
324 int ret = -ENOTSUPP;
326 if (dai->driver->ops &&
327 dai->driver->ops->get_channel_map)
328 ret = dai->driver->ops->get_channel_map(dai, tx_num, tx_slot,
335 * snd_soc_dai_set_tristate - configure DAI system or master clock.
343 int ret = -EINVAL;
345 if (dai->driver->ops &&
346 dai->driver->ops->set_tristate)
347 ret = dai->driver->ops->set_tristate(dai, tristate);
358 if (!snd_soc_dai_stream_valid(dai, substream->stream))
361 if (dai->driver->ops &&
362 dai->driver->ops->prepare)
363 ret = dai->driver->ops->prepare(substream, dai);
371 if (dai->driver->ops)
372 return dai->driver->ops->mute_unmute_on_trigger;
378 * snd_soc_dai_digital_mute - configure DAI system or master clock.
388 int ret = -ENOTSUPP;
394 if (dai->driver->ops &&
395 dai->driver->ops->mute_stream &&
397 !dai->driver->ops->no_capture_mute))
398 ret = dai->driver->ops->mute_stream(dai, mute, direction);
410 if (dai->driver->ops &&
411 dai->driver->ops->hw_params)
412 ret = dai->driver->ops->hw_params(substream, params, dai);
428 if (dai->driver->ops &&
429 dai->driver->ops->hw_free)
430 dai->driver->ops->hw_free(substream, dai);
441 if (!snd_soc_dai_stream_valid(dai, substream->stream))
444 if (dai->driver->ops &&
445 dai->driver->ops->startup)
446 ret = dai->driver->ops->startup(substream, dai);
459 if (!snd_soc_dai_stream_valid(dai, substream->stream))
465 if (dai->driver->ops &&
466 dai->driver->ops->shutdown)
467 dai->driver->ops->shutdown(substream, dai);
476 int ret = -ENOTSUPP;
477 if (dai->driver->ops &&
478 dai->driver->ops->compress_new)
479 ret = dai->driver->ops->compress_new(rtd);
484 * snd_soc_dai_stream_valid() - check if a DAI supports the given stream
493 return stream->channels_min;
500 dai->stream[stream].active += action;
503 dai->component->active += action;
513 active += dai->stream[stream].active;
525 if (dai->probed)
528 if (dai->driver->ops) {
529 if (dai->driver->ops->probe_order != order)
532 if (dai->driver->ops->probe) {
533 int ret = dai->driver->ops->probe(dai);
539 dai->probed = 1;
551 if (!dai->probed)
554 if (dai->driver->ops) {
555 if (dai->driver->ops->remove_order != order)
558 if (dai->driver->ops->remove) {
559 r = dai->driver->ops->remove(dai);
564 dai->probed = 0;
576 if (dai->driver->ops &&
577 dai->driver->ops->pcm_new) {
578 int ret = dai->driver->ops->pcm_new(rtd, dai);
607 if (!snd_soc_dai_stream_valid(dai, substream->stream))
610 if (dai->driver->ops &&
611 dai->driver->ops->trigger)
612 ret = dai->driver->ops->trigger(substream, cmd, dai);
634 snd_soc_dai_digital_mute(dai, 0, substream->stream);
647 snd_soc_dai_digital_mute(dai, 1, substream->stream);
676 if (dai->driver->ops &&
677 dai->driver->ops->delay)
678 *cpu_delay = max(*cpu_delay, dai->driver->ops->delay(substream, dai));
682 if (dai->driver->ops &&
683 dai->driver->ops->delay)
684 *codec_delay = max(*codec_delay, dai->driver->ops->delay(substream, dai));
692 if (dai->driver->cops &&
693 dai->driver->cops->startup)
694 ret = dai->driver->cops->startup(cstream, dai);
711 if (dai->driver->cops &&
712 dai->driver->cops->shutdown)
713 dai->driver->cops->shutdown(cstream, dai);
725 if (dai->driver->cops &&
726 dai->driver->cops->trigger)
727 ret = dai->driver->cops->trigger(cstream, cmd, dai);
739 if (dai->driver->cops &&
740 dai->driver->cops->set_params)
741 ret = dai->driver->cops->set_params(cstream, params, dai);
753 if (dai->driver->cops &&
754 dai->driver->cops->get_params)
755 ret = dai->driver->cops->get_params(cstream, params, dai);
767 if (dai->driver->cops &&
768 dai->driver->cops->ack)
769 ret = dai->driver->cops->ack(cstream, bytes, dai);
781 if (dai->driver->cops &&
782 dai->driver->cops->pointer)
783 ret = dai->driver->cops->pointer(cstream, tstamp, dai);
795 if (dai->driver->cops &&
796 dai->driver->cops->set_metadata)
797 ret = dai->driver->cops->set_metadata(cstream, metadata, dai);
809 if (dai->driver->cops &&
810 dai->driver->cops->get_metadata)
811 ret = dai->driver->cops->get_metadata(cstream, metadata, dai);