Lines Matching +full:dai +full:- +full:format

1 // SPDX-License-Identifier: GPL-2.0
33 static int framer_dai_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, in framer_dai_set_tdm_slot() argument
36 struct framer_codec *framer = snd_soc_component_get_drvdata(dai->component); in framer_dai_set_tdm_slot()
40 /* Not set -> default 8 */ in framer_dai_set_tdm_slot()
44 dev_err(dai->dev, "tdm slot width %d not supported\n", width); in framer_dai_set_tdm_slot()
45 return -EINVAL; in framer_dai_set_tdm_slot()
48 framer->max_chan_playback = hweight32(tx_mask); in framer_dai_set_tdm_slot()
49 if (framer->max_chan_playback > FRAMER_NB_CHANNEL) { in framer_dai_set_tdm_slot()
50 dev_err(dai->dev, "too many tx slots defined (mask = 0x%x) supported max %d\n", in framer_dai_set_tdm_slot()
52 return -EINVAL; in framer_dai_set_tdm_slot()
55 framer->max_chan_capture = hweight32(rx_mask); in framer_dai_set_tdm_slot()
56 if (framer->max_chan_capture > FRAMER_NB_CHANNEL) { in framer_dai_set_tdm_slot()
57 dev_err(dai->dev, "too many rx slots defined (mask = 0x%x) supported max %d\n", in framer_dai_set_tdm_slot()
59 return -EINVAL; in framer_dai_set_tdm_slot()
66 * The constraints for format/channel is to match with the number of 8bit
67 * time-slots available.
69 static int framer_dai_hw_rule_channels_by_format(struct snd_soc_dai *dai, in framer_dai_hw_rule_channels_by_format() argument
74 snd_pcm_format_t format = params_format(params); in framer_dai_hw_rule_channels_by_format() local
78 width = snd_pcm_format_physical_width(format); in framer_dai_hw_rule_channels_by_format()
82 dev_err(dai->dev, "format physical width %d not supported\n", width); in framer_dai_hw_rule_channels_by_format()
83 return -EINVAL; in framer_dai_hw_rule_channels_by_format()
94 struct snd_soc_dai *dai = rule->private; in framer_dai_hw_rule_playback_channels_by_format() local
95 struct framer_codec *framer = snd_soc_component_get_drvdata(dai->component); in framer_dai_hw_rule_playback_channels_by_format()
97 return framer_dai_hw_rule_channels_by_format(dai, params, framer->max_chan_playback); in framer_dai_hw_rule_playback_channels_by_format()
103 struct snd_soc_dai *dai = rule->private; in framer_dai_hw_rule_capture_channels_by_format() local
104 struct framer_codec *framer = snd_soc_component_get_drvdata(dai->component); in framer_dai_hw_rule_capture_channels_by_format()
106 return framer_dai_hw_rule_channels_by_format(dai, params, framer->max_chan_capture); in framer_dai_hw_rule_capture_channels_by_format()
109 static int framer_dai_hw_rule_format_by_channels(struct snd_soc_dai *dai, in framer_dai_hw_rule_format_by_channels() argument
116 snd_pcm_format_t format; in framer_dai_hw_rule_format_by_channels() local
120 dev_err(dai->dev, "channels %u not supported\n", nb_ts); in framer_dai_hw_rule_format_by_channels()
121 return -EINVAL; in framer_dai_hw_rule_format_by_channels()
127 pcm_for_each_format(format) { in framer_dai_hw_rule_format_by_channels()
128 if (snd_mask_test_format(f_old, format)) { in framer_dai_hw_rule_format_by_channels()
129 if (snd_pcm_format_physical_width(format) <= slot_width) in framer_dai_hw_rule_format_by_channels()
130 snd_mask_set_format(&f_new, format); in framer_dai_hw_rule_format_by_channels()
140 struct snd_soc_dai *dai = rule->private; in framer_dai_hw_rule_playback_format_by_channels() local
141 struct framer_codec *framer = snd_soc_component_get_drvdata(dai->component); in framer_dai_hw_rule_playback_format_by_channels()
143 return framer_dai_hw_rule_format_by_channels(dai, params, framer->max_chan_playback); in framer_dai_hw_rule_playback_format_by_channels()
149 struct snd_soc_dai *dai = rule->private; in framer_dai_hw_rule_capture_format_by_channels() local
150 struct framer_codec *framer = snd_soc_component_get_drvdata(dai->component); in framer_dai_hw_rule_capture_format_by_channels()
152 return framer_dai_hw_rule_format_by_channels(dai, params, framer->max_chan_capture); in framer_dai_hw_rule_capture_format_by_channels()
159 snd_pcm_format_t format; in framer_formats() local
167 pcm_for_each_format(format) { in framer_formats()
169 format_width = snd_pcm_format_physical_width(format); in framer_formats()
180 formats_mask |= pcm_format_to_bits(format); in framer_formats()
186 struct snd_soc_dai *dai) in framer_dai_startup() argument
188 struct framer_codec *framer = snd_soc_component_get_drvdata(dai->component); in framer_dai_startup()
192 u64 format; in framer_dai_startup() local
195 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { in framer_dai_startup()
196 format = framer_formats(framer->max_chan_capture); in framer_dai_startup()
199 frame_bits = framer->max_chan_capture * 8; in framer_dai_startup()
201 format = framer_formats(framer->max_chan_playback); in framer_dai_startup()
204 frame_bits = framer->max_chan_playback * 8; in framer_dai_startup()
207 ret = snd_pcm_hw_constraint_mask64(substream->runtime, in framer_dai_startup()
208 SNDRV_PCM_HW_PARAM_FORMAT, format); in framer_dai_startup()
210 dev_err(dai->dev, "Failed to add format constraint (%d)\n", ret); in framer_dai_startup()
214 ret = snd_pcm_hw_rule_add(substream->runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, in framer_dai_startup()
215 hw_rule_channels_by_format, dai, in framer_dai_startup()
216 SNDRV_PCM_HW_PARAM_FORMAT, -1); in framer_dai_startup()
218 dev_err(dai->dev, "Failed to add channels rule (%d)\n", ret); in framer_dai_startup()
222 ret = snd_pcm_hw_rule_add(substream->runtime, 0, SNDRV_PCM_HW_PARAM_FORMAT, in framer_dai_startup()
223 hw_rule_format_by_channels, dai, in framer_dai_startup()
224 SNDRV_PCM_HW_PARAM_CHANNELS, -1); in framer_dai_startup()
226 dev_err(dai->dev, "Failed to add format rule (%d)\n", ret); in framer_dai_startup()
230 ret = snd_pcm_hw_constraint_single(substream->runtime, in framer_dai_startup()
234 dev_err(dai->dev, "Failed to add frame_bits constraint (%d)\n", ret); in framer_dai_startup()
259 .formats = U64_MAX, /* Will be refined on DAI .startup() */
266 .formats = U64_MAX, /* Will be refined on DAI .startup() */
278 ret = framer_get_status(framer->framer, &framer_status); in framer_carrier_work()
280 dev_err(framer->dev, "get framer status failed (%d)\n", ret); in framer_carrier_work()
285 snd_soc_jack_report(&framer->jack, jack_status, FRAMER_JACK_MASK); in framer_carrier_work()
295 queue_work(system_power_efficient_wq, &framer->carrier_work); in framer_carrier_notifier()
311 INIT_WORK(&framer->carrier_work, framer_carrier_work); in framer_component_probe()
314 if (component->name_prefix) { in framer_component_probe()
315 name = kasprintf(GFP_KERNEL, "%s carrier", component->name_prefix); in framer_component_probe()
317 return -ENOMEM; in framer_component_probe()
320 ret = snd_soc_card_jack_new(component->card, name, FRAMER_JACK_MASK, &framer->jack); in framer_component_probe()
321 if (component->name_prefix) in framer_component_probe()
324 dev_err(component->dev, "Cannot create jack\n"); in framer_component_probe()
328 ret = framer_init(framer->framer); in framer_component_probe()
330 dev_err(component->dev, "framer init failed (%d)\n", ret); in framer_component_probe()
334 ret = framer_power_on(framer->framer); in framer_component_probe()
336 dev_err(component->dev, "framer power-on failed (%d)\n", ret); in framer_component_probe()
341 ret = framer_get_status(framer->framer, &status); in framer_component_probe()
343 dev_err(component->dev, "get framer status failed (%d)\n", ret); in framer_component_probe()
347 framer->nb.notifier_call = framer_carrier_notifier; in framer_component_probe()
348 ret = framer_notifier_register(framer->framer, &framer->nb); in framer_component_probe()
350 dev_err(component->dev, "Cannot register event notifier\n"); in framer_component_probe()
355 queue_work(system_power_efficient_wq, &framer->carrier_work); in framer_component_probe()
360 framer_power_off(framer->framer); in framer_component_probe()
362 framer_exit(framer->framer); in framer_component_probe()
370 framer_notifier_unregister(framer->framer, &framer->nb); in framer_component_remove()
371 cancel_work_sync(&framer->carrier_work); in framer_component_remove()
372 framer_power_off(framer->framer); in framer_component_remove()
373 framer_exit(framer->framer); in framer_component_remove()
386 framer = devm_kzalloc(&pdev->dev, sizeof(*framer), GFP_KERNEL); in framer_codec_probe()
388 return -ENOMEM; in framer_codec_probe()
390 framer->dev = &pdev->dev; in framer_codec_probe()
393 framer->framer = devm_framer_get(&pdev->dev, NULL); in framer_codec_probe()
394 if (IS_ERR(framer->framer)) in framer_codec_probe()
395 return dev_err_probe(&pdev->dev, PTR_ERR(framer->framer), "get framer failed\n"); in framer_codec_probe()
399 return devm_snd_soc_register_component(&pdev->dev, &framer_component_driver, in framer_codec_probe()
405 .name = "framer-codec",