Lines Matching +full:rc +full:- +full:map +full:- +full:name
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
24 unsigned char map; /* ALSA API channel map position */ member
35 * RL RLC RC RRC RR
46 RC = BIT(6), /* Rear Center */ enumerator
65 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR } },
69 /* Channel maps for multi-channel playbacks, up to 8 n_ch */
72 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR } },
74 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_LFE,
77 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_NA,
80 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_LFE,
83 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_NA,
86 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_LFE,
89 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_NA,
92 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_LFE,
95 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_NA,
98 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_LFE,
101 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_NA,
104 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_LFE,
107 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_NA,
111 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_LFE,
115 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_NA,
119 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_LFE,
123 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_NA,
127 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_LFE,
131 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_NA,
135 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_LFE,
139 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_NA,
143 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_LFE,
147 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_NA,
151 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_LFE,
155 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_NA,
159 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_LFE,
163 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_NA,
167 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_LFE,
171 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_NA,
175 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_LFE,
179 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_NA,
183 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_LFE,
219 .mask = FL | FR | LFE | FC | RL | RR | RC },
227 .mask = FL | FR | RC},
229 .mask = FL | FR | LFE | RC },
231 .mask = FL | FR | FC | RC },
233 .mask = FL | FR | LFE | FC | RC },
235 .mask = FL | FR | RC | RL | RR },
237 .mask = FL | FR | LFE | RL | RR | RC },
239 .mask = FL | FR | FC | RL | RR | RC },
255 .mask = FL | FR | RC | FLC | FRC },
257 .mask = FL | FR | LFE | RC | FLC | FRC },
259 .mask = FL | FR | RC | FC | FLC | FRC },
261 .mask = FL | FR | LFE | RC | FC | FLC | FRC },
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()
317 [4] = RC, [5] = FLC | FRC, [6] = RLC | RRC, in hdmi_codec_spk_mask_from_alloc()
334 spk_alloc = drm_eld_get_spk_alloc(hcp->eld); 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()
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()
371 unsigned const char *map; in hdmi_codec_chmap_ctl_get() local
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()
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()
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()
630 .name = "ELD", 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",
759 .name = "spdif-hifi",
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()
862 .name = HDMI_CODEC_DRV_NAME,