Lines Matching +full:playback +full:- +full:channels
1 // SPDX-License-Identifier: GPL-2.0-only
4 * Copyright (C) 2015 Texas Instruments Incorporated - https://www.ti.com/
16 #include <sound/hdmi-codec.h>
21 #define HDMI_CODEC_CHMAP_IDX_UNKNOWN -1
64 { .channels = 2,
69 /* Channel maps for multi-channel playbacks, up to 8 n_ch */
71 { .channels = 2, /* CA_ID 0x00 */
73 { .channels = 4, /* CA_ID 0x01 */
76 { .channels = 4, /* CA_ID 0x02 */
79 { .channels = 4, /* CA_ID 0x03 */
82 { .channels = 6, /* CA_ID 0x04 */
85 { .channels = 6, /* CA_ID 0x05 */
88 { .channels = 6, /* CA_ID 0x06 */
91 { .channels = 6, /* CA_ID 0x07 */
94 { .channels = 6, /* CA_ID 0x08 */
97 { .channels = 6, /* CA_ID 0x09 */
100 { .channels = 6, /* CA_ID 0x0A */
103 { .channels = 6, /* CA_ID 0x0B */
106 { .channels = 8, /* CA_ID 0x0C */
110 { .channels = 8, /* CA_ID 0x0D */
114 { .channels = 8, /* CA_ID 0x0E */
118 { .channels = 8, /* CA_ID 0x0F */
122 { .channels = 8, /* CA_ID 0x10 */
126 { .channels = 8, /* CA_ID 0x11 */
130 { .channels = 8, /* CA_ID 0x12 */
134 { .channels = 8, /* CA_ID 0x13 */
138 { .channels = 8, /* CA_ID 0x14 */
142 { .channels = 8, /* CA_ID 0x15 */
146 { .channels = 8, /* CA_ID 0x16 */
150 { .channels = 8, /* CA_ID 0x17 */
154 { .channels = 8, /* CA_ID 0x18 */
158 { .channels = 8, /* CA_ID 0x19 */
162 { .channels = 8, /* CA_ID 0x1A */
166 { .channels = 8, /* CA_ID 0x1B */
170 { .channels = 8, /* CA_ID 0x1C */
174 { .channels = 8, /* CA_ID 0x1D */
178 { .channels = 8, /* CA_ID 0x1E */
182 { .channels = 8, /* CA_ID 0x1F */
295 uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES; in hdmi_eld_ctl_info()
296 uinfo->count = sizeof_field(struct hdmi_codec_priv, eld); in hdmi_eld_ctl_info()
307 memcpy(ucontrol->value.bytes.data, hcp->eld, sizeof(hcp->eld)); in hdmi_eld_ctl_get()
334 spk_alloc = drm_eld_get_spk_alloc(hcp->eld); in hdmi_codec_eld_chmap()
337 /* Detect if only stereo supported, else return 8 channels mappings */ in hdmi_codec_eld_chmap()
338 if ((spk_mask & ~(FL | FR)) && hcp->chmap_info->max_channels > 2) in hdmi_codec_eld_chmap()
339 hcp->chmap_info->chmap = hdmi_codec_8ch_chmaps; in hdmi_codec_eld_chmap()
341 hcp->chmap_info->chmap = hdmi_codec_stereo_chmaps; in hdmi_codec_eld_chmap()
345 unsigned char channels) in hdmi_codec_get_ch_alloc_table_idx() argument
352 spk_alloc = drm_eld_get_spk_alloc(hcp->eld); in hdmi_codec_get_ch_alloc_table_idx()
357 if (!spk_alloc && cap->ca_id == 0) in hdmi_codec_get_ch_alloc_table_idx()
359 if (cap->n_ch != channels) in hdmi_codec_get_ch_alloc_table_idx()
361 if (!(cap->mask == (spk_mask & cap->mask))) in hdmi_codec_get_ch_alloc_table_idx()
366 return -EINVAL; in hdmi_codec_get_ch_alloc_table_idx()
374 struct hdmi_codec_priv *hcp = info->private_data; in hdmi_codec_chmap_ctl_get()
376 map = info->chmap[hcp->chmap_idx].map; in hdmi_codec_chmap_ctl_get()
378 for (i = 0; i < info->max_channels; i++) { in hdmi_codec_chmap_ctl_get()
379 if (hcp->chmap_idx == HDMI_CODEC_CHMAP_IDX_UNKNOWN) in hdmi_codec_chmap_ctl_get()
380 ucontrol->value.integer.value[i] = 0; in hdmi_codec_chmap_ctl_get()
382 ucontrol->value.integer.value[i] = map[i]; in hdmi_codec_chmap_ctl_get()
394 mutex_lock(&hcp->lock); in hdmi_codec_startup()
395 if (hcp->busy) { in hdmi_codec_startup()
396 dev_err(dai->dev, "Only one simultaneous stream supported!\n"); in hdmi_codec_startup()
397 mutex_unlock(&hcp->lock); in hdmi_codec_startup()
398 return -EINVAL; in hdmi_codec_startup()
401 if (hcp->hcd.ops->audio_startup) { in hdmi_codec_startup()
402 ret = hcp->hcd.ops->audio_startup(dai->dev->parent, hcp->hcd.data); in hdmi_codec_startup()
407 if (hcp->hcd.ops->get_eld) { in hdmi_codec_startup()
408 ret = hcp->hcd.ops->get_eld(dai->dev->parent, hcp->hcd.data, in hdmi_codec_startup()
409 hcp->eld, sizeof(hcp->eld)); in hdmi_codec_startup()
413 ret = snd_pcm_hw_constraint_eld(substream->runtime, hcp->eld); in hdmi_codec_startup()
421 hcp->busy = true; in hdmi_codec_startup()
424 mutex_unlock(&hcp->lock); in hdmi_codec_startup()
433 hcp->chmap_idx = HDMI_CODEC_CHMAP_IDX_UNKNOWN; in hdmi_codec_shutdown()
434 hcp->hcd.ops->audio_shutdown(dai->dev->parent, hcp->hcd.data); in hdmi_codec_shutdown()
436 mutex_lock(&hcp->lock); in hdmi_codec_shutdown()
437 hcp->busy = false; in hdmi_codec_shutdown()
438 mutex_unlock(&hcp->lock); in hdmi_codec_shutdown()
446 struct hdmi_codec_daifmt *cf = dai->playback_dma_data; in hdmi_codec_hw_params()
457 dev_dbg(dai->dev, "%s() width %d rate %d channels %d\n", __func__, in hdmi_codec_hw_params()
464 dev_err(dai->dev, "Creating IEC958 channel status failed %d\n", in hdmi_codec_hw_params()
470 hp.cea.channels = params_channels(params); in hdmi_codec_hw_params()
475 /* Select a channel allocation that matches with ELD and pcm channels */ in hdmi_codec_hw_params()
476 idx = hdmi_codec_get_ch_alloc_table_idx(hcp, hp.cea.channels); in hdmi_codec_hw_params()
478 dev_err(dai->dev, "Not able to map channels to speakers (%d)\n", in hdmi_codec_hw_params()
480 hcp->chmap_idx = HDMI_CODEC_CHMAP_IDX_UNKNOWN; in hdmi_codec_hw_params()
484 hcp->chmap_idx = hdmi_codec_channel_alloc[idx].ca_id; in hdmi_codec_hw_params()
488 hp.channels = params_channels(params); in hdmi_codec_hw_params()
490 return hcp->hcd.ops->hw_params(dai->dev->parent, hcp->hcd.data, in hdmi_codec_hw_params()
497 struct hdmi_codec_daifmt *cf = dai->playback_dma_data; in hdmi_codec_i2s_set_fmt()
504 cf->bit_clk_master = 1; in hdmi_codec_i2s_set_fmt()
505 cf->frame_clk_master = 1; in hdmi_codec_i2s_set_fmt()
508 cf->frame_clk_master = 1; in hdmi_codec_i2s_set_fmt()
511 cf->bit_clk_master = 1; in hdmi_codec_i2s_set_fmt()
516 return -EINVAL; in hdmi_codec_i2s_set_fmt()
523 cf->frame_clk_inv = 1; in hdmi_codec_i2s_set_fmt()
526 cf->bit_clk_inv = 1; in hdmi_codec_i2s_set_fmt()
529 cf->frame_clk_inv = 1; in hdmi_codec_i2s_set_fmt()
530 cf->bit_clk_inv = 1; in hdmi_codec_i2s_set_fmt()
536 cf->fmt = HDMI_I2S; in hdmi_codec_i2s_set_fmt()
539 cf->fmt = HDMI_DSP_A; in hdmi_codec_i2s_set_fmt()
542 cf->fmt = HDMI_DSP_B; in hdmi_codec_i2s_set_fmt()
545 cf->fmt = HDMI_RIGHT_J; in hdmi_codec_i2s_set_fmt()
548 cf->fmt = HDMI_LEFT_J; in hdmi_codec_i2s_set_fmt()
551 cf->fmt = HDMI_AC97; in hdmi_codec_i2s_set_fmt()
554 dev_err(dai->dev, "Invalid DAI interface format\n"); in hdmi_codec_i2s_set_fmt()
555 return -EINVAL; in hdmi_codec_i2s_set_fmt()
571 if (hcp->hcd.ops->mute_stream && in hdmi_codec_mute()
573 !hcp->hcd.ops->no_capture_mute)) in hdmi_codec_mute()
574 return hcp->hcd.ops->mute_stream(dai->dev->parent, in hdmi_codec_mute()
575 hcp->hcd.data, in hdmi_codec_mute()
578 return -ENOTSUPP; in hdmi_codec_mute()
609 * instance allowing the 32-bit formats enables 24-precision with CPU
610 * DAIs that do not support 24-bit formats. If the extra formats cause
623 struct snd_soc_dai_driver *drv = dai->driver; in hdmi_codec_pcm_new()
633 .device = rtd->pcm->device, in hdmi_codec_pcm_new()
637 ret = snd_pcm_add_chmap_ctls(rtd->pcm, SNDRV_PCM_STREAM_PLAYBACK, in hdmi_codec_pcm_new()
638 NULL, drv->playback.channels_max, 0, in hdmi_codec_pcm_new()
639 &hcp->chmap_info); in hdmi_codec_pcm_new()
644 hcp->chmap_info->private_data = hcp; in hdmi_codec_pcm_new()
645 hcp->chmap_info->kctl->get = hdmi_codec_chmap_ctl_get; in hdmi_codec_pcm_new()
648 hcp->chmap_info->chmap = hdmi_codec_stereo_chmaps; in hdmi_codec_pcm_new()
649 hcp->chmap_idx = HDMI_CODEC_CHMAP_IDX_UNKNOWN; in hdmi_codec_pcm_new()
652 kctl = snd_ctl_new1(&hdmi_eld_ctl, dai->component); in hdmi_codec_pcm_new()
654 return -ENOMEM; in hdmi_codec_pcm_new()
656 return snd_ctl_add(rtd->card->snd_card, kctl); in hdmi_codec_pcm_new()
665 .source = dai->driver->playback.stream_name, in hdmi_dai_probe()
669 dapm = snd_soc_component_get_dapm(dai->component); in hdmi_dai_probe()
676 return -ENOMEM; in hdmi_dai_probe()
678 dai->playback_dma_data = daifmt; in hdmi_dai_probe()
685 if (hcp->jack && jack_status != hcp->jack_status) { in hdmi_codec_jack_report()
686 snd_soc_jack_report(hcp->jack, jack_status, SND_JACK_LINEOUT); in hdmi_codec_jack_report()
687 hcp->jack_status = jack_status; in hdmi_codec_jack_report()
706 int ret = -EOPNOTSUPP; in hdmi_codec_set_jack()
708 if (hcp->hcd.ops->hook_plugged_cb) { in hdmi_codec_set_jack()
709 hcp->jack = jack; in hdmi_codec_set_jack()
710 ret = hcp->hcd.ops->hook_plugged_cb(component->dev->parent, in hdmi_codec_set_jack()
711 hcp->hcd.data, in hdmi_codec_set_jack()
713 component->dev); in hdmi_codec_set_jack()
715 hcp->jack = NULL; in hdmi_codec_set_jack()
722 struct hdmi_codec_daifmt *cf = dai->playback_dma_data; in hdmi_dai_spdif_probe()
729 cf = dai->playback_dma_data; in hdmi_dai_spdif_probe()
730 cf->fmt = HDMI_SPDIF; in hdmi_dai_spdif_probe()
737 kfree(dai->playback_dma_data); in hdmi_codec_dai_remove()
742 .name = "i2s-hifi",
746 .playback = {
747 .stream_name = "I2S Playback",
759 .name = "spdif-hifi",
763 .playback = {
764 .stream_name = "SPDIF Playback",
778 int ret = -ENOTSUPP; /* see snd_soc_get_dai_id() */ in hdmi_of_xlate_dai_id()
780 if (hcp->hcd.ops->get_dai_id) in hdmi_of_xlate_dai_id()
781 ret = hcp->hcd.ops->get_dai_id(component, endpoint); in hdmi_of_xlate_dai_id()
790 if (hcp->hcd.ops->hook_plugged_cb) in hdmi_remove()
791 hcp->hcd.ops->hook_plugged_cb(component->dev->parent, in hdmi_remove()
792 hcp->hcd.data, NULL, NULL); in hdmi_remove()
809 struct hdmi_codec_pdata *hcd = pdev->dev.platform_data; in hdmi_codec_probe()
811 struct device *dev = &pdev->dev; in hdmi_codec_probe()
818 return -EINVAL; in hdmi_codec_probe()
821 dai_count = hcd->i2s + hcd->spdif; in hdmi_codec_probe()
822 if (dai_count < 1 || !hcd->ops || !hcd->ops->hw_params || in hdmi_codec_probe()
823 !hcd->ops->audio_shutdown) { in hdmi_codec_probe()
825 return -EINVAL; in hdmi_codec_probe()
830 return -ENOMEM; in hdmi_codec_probe()
832 hcp->hcd = *hcd; in hdmi_codec_probe()
833 mutex_init(&hcp->lock); in hdmi_codec_probe()
837 return -ENOMEM; in hdmi_codec_probe()
839 if (hcd->i2s) { in hdmi_codec_probe()
841 daidrv[i].playback.channels_max = hcd->max_i2s_channels; in hdmi_codec_probe()
845 if (hcd->spdif) in hdmi_codec_probe()