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>
22 #define HDMI_CODEC_CHMAP_IDX_UNKNOWN -1
31 * RL RLC RC RRC RR
42 RC = BIT(6), /* Rear Center */ enumerator
61 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR } },
65 /* Channel maps for multi-channel playbacks, up to 8 n_ch */
68 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR } },
70 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_LFE,
73 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_NA,
76 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_LFE,
79 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_NA,
82 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_LFE,
85 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_NA,
88 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_LFE,
91 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_NA,
94 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_LFE,
97 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_NA,
100 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_LFE,
103 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_NA,
107 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_LFE,
111 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_NA,
115 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_LFE,
119 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_NA,
123 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_LFE,
127 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_NA,
131 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_LFE,
135 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_NA,
139 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_LFE,
143 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_NA,
147 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_LFE,
151 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_NA,
155 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_LFE,
159 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_NA,
163 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_LFE,
167 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_NA,
171 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_LFE,
175 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_NA,
179 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_LFE,
210 .mask = FL | FR | LFE | FC | RC },
212 .mask = FL | FR | FC | RC },
214 .mask = FL | FR | LFE | RC },
216 .mask = FL | FR | RC },
234 .mask = FL | FR | LFE | FC | RL | RR | RC },
236 .mask = FL | FR | LFE | RC | FC | FLC | FRC },
238 .mask = FL | FR | FC | RL | RR | RC },
240 .mask = FL | FR | RC | FC | FLC | FRC },
242 .mask = FL | FR | LFE | RL | RR | RC },
244 .mask = FL | FR | LFE | RC | FLC | FRC },
246 .mask = FL | FR | RC | RL | RR },
248 .mask = FL | FR | RC | FLC | FRC },
266 .mask = FL | FR | LFE | FC | RC },
268 .mask = FL | FR | FC | RC },
270 .mask = FL | FR | LFE | RC },
272 .mask = FL | FR | RC },
306 uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES; in hdmi_eld_ctl_info()
307 uinfo->count = sizeof_field(struct hdmi_codec_priv, eld); in hdmi_eld_ctl_info()
318 memcpy(ucontrol->value.bytes.data, hcp->eld, sizeof(hcp->eld)); in hdmi_eld_ctl_get()
328 [4] = RC, [5] = FLC | FRC, [6] = RLC | RRC, in hdmi_codec_spk_mask_from_alloc()
345 spk_alloc = drm_eld_get_spk_alloc(hcp->eld); in hdmi_codec_eld_chmap()
349 if ((spk_mask & ~(FL | FR)) && hcp->chmap_info->max_channels > 2) in hdmi_codec_eld_chmap()
350 hcp->chmap_info->chmap = hdmi_codec_8ch_chmaps; in hdmi_codec_eld_chmap()
352 hcp->chmap_info->chmap = hdmi_codec_stereo_chmaps; in hdmi_codec_eld_chmap()
363 spk_alloc = drm_eld_get_spk_alloc(hcp->eld); in hdmi_codec_get_ch_alloc_table_idx()
368 if (!spk_alloc && cap->ca_id == 0) in hdmi_codec_get_ch_alloc_table_idx()
370 if (cap->n_ch != channels) in hdmi_codec_get_ch_alloc_table_idx()
372 if (!(cap->mask == (spk_mask & cap->mask))) in hdmi_codec_get_ch_alloc_table_idx()
377 return -EINVAL; in hdmi_codec_get_ch_alloc_table_idx()
382 unsigned const char *map; in hdmi_codec_chmap_ctl_get() local
385 struct hdmi_codec_priv *hcp = info->private_data; in hdmi_codec_chmap_ctl_get()
387 if (hcp->chmap_idx != HDMI_CODEC_CHMAP_IDX_UNKNOWN) in hdmi_codec_chmap_ctl_get()
388 map = info->chmap[hcp->chmap_idx].map; in hdmi_codec_chmap_ctl_get()
390 for (i = 0; i < info->max_channels; i++) { in hdmi_codec_chmap_ctl_get()
391 if (hcp->chmap_idx == HDMI_CODEC_CHMAP_IDX_UNKNOWN) in hdmi_codec_chmap_ctl_get()
392 ucontrol->value.integer.value[i] = 0; in hdmi_codec_chmap_ctl_get()
394 ucontrol->value.integer.value[i] = map[i]; in hdmi_codec_chmap_ctl_get()
403 uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; in hdmi_codec_iec958_info()
404 uinfo->count = 1; in hdmi_codec_iec958_info()
414 memcpy(ucontrol->value.iec958.status, hcp->iec_status, in hdmi_codec_iec958_default_get()
415 sizeof(hcp->iec_status)); in hdmi_codec_iec958_default_get()
426 memcpy(hcp->iec_status, ucontrol->value.iec958.status, in hdmi_codec_iec958_default_put()
427 sizeof(hcp->iec_status)); in hdmi_codec_iec958_default_put()
435 memset(ucontrol->value.iec958.status, 0xff, in hdmi_codec_iec958_mask_get()
445 bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; in hdmi_codec_startup()
446 bool has_capture = !hcp->hcd.no_i2s_capture; in hdmi_codec_startup()
447 bool has_playback = !hcp->hcd.no_i2s_playback; in hdmi_codec_startup()
453 mutex_lock(&hcp->lock); in hdmi_codec_startup()
454 if (hcp->busy) { in hdmi_codec_startup()
455 dev_err(dai->dev, "Only one simultaneous stream supported!\n"); in hdmi_codec_startup()
456 mutex_unlock(&hcp->lock); in hdmi_codec_startup()
457 return -EINVAL; in hdmi_codec_startup()
460 if (hcp->hcd.ops->audio_startup) { in hdmi_codec_startup()
461 ret = hcp->hcd.ops->audio_startup(dai->dev->parent, hcp->hcd.data); in hdmi_codec_startup()
466 if (tx && hcp->hcd.ops->get_eld) { in hdmi_codec_startup()
467 ret = hcp->hcd.ops->get_eld(dai->dev->parent, hcp->hcd.data, in hdmi_codec_startup()
468 hcp->eld, sizeof(hcp->eld)); in hdmi_codec_startup()
472 ret = snd_pcm_hw_constraint_eld(substream->runtime, hcp->eld); in hdmi_codec_startup()
480 hcp->busy = true; in hdmi_codec_startup()
483 mutex_unlock(&hcp->lock); in hdmi_codec_startup()
491 bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; in hdmi_codec_shutdown()
492 bool has_capture = !hcp->hcd.no_i2s_capture; in hdmi_codec_shutdown()
493 bool has_playback = !hcp->hcd.no_i2s_playback; in hdmi_codec_shutdown()
498 hcp->chmap_idx = HDMI_CODEC_CHMAP_IDX_UNKNOWN; in hdmi_codec_shutdown()
499 hcp->hcd.ops->audio_shutdown(dai->dev->parent, hcp->hcd.data); in hdmi_codec_shutdown()
501 mutex_lock(&hcp->lock); in hdmi_codec_shutdown()
502 hcp->busy = false; in hdmi_codec_shutdown()
503 mutex_unlock(&hcp->lock); in hdmi_codec_shutdown()
515 bool pcm_audio = !(hcp->iec_status[0] & IEC958_AES0_NONAUDIO); in hdmi_codec_fill_codec_params()
522 dev_err(dai->dev, "Not able to map channels to speakers (%d)\n", in hdmi_codec_fill_codec_params()
524 hcp->chmap_idx = HDMI_CODEC_CHMAP_IDX_UNKNOWN; in hdmi_codec_fill_codec_params()
533 hdmi_audio_infoframe_init(&hp->cea); in hdmi_codec_fill_codec_params()
536 hp->cea.channels = channels; in hdmi_codec_fill_codec_params()
538 hp->cea.channels = 0; in hdmi_codec_fill_codec_params()
540 hp->cea.coding_type = HDMI_AUDIO_CODING_TYPE_STREAM; in hdmi_codec_fill_codec_params()
541 hp->cea.sample_size = HDMI_AUDIO_SAMPLE_SIZE_STREAM; in hdmi_codec_fill_codec_params()
542 hp->cea.sample_frequency = HDMI_AUDIO_SAMPLE_FREQUENCY_STREAM; in hdmi_codec_fill_codec_params()
543 hp->cea.channel_allocation = ca_id; in hdmi_codec_fill_codec_params()
545 hp->sample_width = sample_width; in hdmi_codec_fill_codec_params()
546 hp->sample_rate = sample_rate; in hdmi_codec_fill_codec_params()
547 hp->channels = channels; in hdmi_codec_fill_codec_params()
550 hcp->chmap_idx = ca_id; in hdmi_codec_fill_codec_params()
552 hcp->chmap_idx = HDMI_CODEC_CHMAP_IDX_UNKNOWN; in hdmi_codec_fill_codec_params()
573 if (!hcp->hcd.ops->hw_params) in hdmi_codec_hw_params()
576 dev_dbg(dai->dev, "%s() width %d rate %d channels %d\n", __func__, in hdmi_codec_hw_params()
588 memcpy(hp.iec.status, hcp->iec_status, sizeof(hp.iec.status)); in hdmi_codec_hw_params()
592 dev_err(dai->dev, "Creating IEC958 channel status failed %d\n", in hdmi_codec_hw_params()
597 cf->bit_fmt = params_format(params); in hdmi_codec_hw_params()
598 return hcp->hcd.ops->hw_params(dai->dev->parent, hcp->hcd.data, in hdmi_codec_hw_params()
607 struct snd_pcm_runtime *runtime = substream->runtime; in hdmi_codec_prepare()
608 unsigned int channels = runtime->channels; in hdmi_codec_prepare()
609 unsigned int width = snd_pcm_format_width(runtime->format); in hdmi_codec_prepare()
610 unsigned int rate = runtime->rate; in hdmi_codec_prepare()
614 if (!hcp->hcd.ops->prepare) in hdmi_codec_prepare()
617 dev_dbg(dai->dev, "%s() width %d rate %d channels %d\n", __func__, in hdmi_codec_prepare()
624 memcpy(hp.iec.status, hcp->iec_status, sizeof(hp.iec.status)); in hdmi_codec_prepare()
628 dev_err(dai->dev, "Creating IEC958 channel status failed %d\n", in hdmi_codec_prepare()
633 cf->bit_fmt = runtime->format; in hdmi_codec_prepare()
634 return hcp->hcd.ops->prepare(dai->dev->parent, hcp->hcd.data, in hdmi_codec_prepare()
648 cf->bit_clk_provider = 1; in hdmi_codec_i2s_set_fmt()
649 cf->frame_clk_provider = 1; in hdmi_codec_i2s_set_fmt()
652 cf->frame_clk_provider = 1; in hdmi_codec_i2s_set_fmt()
655 cf->bit_clk_provider = 1; in hdmi_codec_i2s_set_fmt()
660 return -EINVAL; in hdmi_codec_i2s_set_fmt()
667 cf->frame_clk_inv = 1; in hdmi_codec_i2s_set_fmt()
670 cf->bit_clk_inv = 1; in hdmi_codec_i2s_set_fmt()
673 cf->frame_clk_inv = 1; in hdmi_codec_i2s_set_fmt()
674 cf->bit_clk_inv = 1; in hdmi_codec_i2s_set_fmt()
680 cf->fmt = HDMI_I2S; in hdmi_codec_i2s_set_fmt()
683 cf->fmt = HDMI_DSP_A; in hdmi_codec_i2s_set_fmt()
686 cf->fmt = HDMI_DSP_B; in hdmi_codec_i2s_set_fmt()
689 cf->fmt = HDMI_RIGHT_J; in hdmi_codec_i2s_set_fmt()
692 cf->fmt = HDMI_LEFT_J; in hdmi_codec_i2s_set_fmt()
695 cf->fmt = HDMI_AC97; in hdmi_codec_i2s_set_fmt()
698 dev_err(dai->dev, "Invalid DAI interface format\n"); in hdmi_codec_i2s_set_fmt()
699 return -EINVAL; in hdmi_codec_i2s_set_fmt()
715 if (hcp->hcd.ops->mute_stream && in hdmi_codec_mute()
717 !hcp->hcd.no_capture_mute)) in hdmi_codec_mute()
718 return hcp->hcd.ops->mute_stream(dai->dev->parent, in hdmi_codec_mute()
719 hcp->hcd.data, in hdmi_codec_mute()
722 return -ENOTSUPP; in hdmi_codec_mute()
730 * ${LINUX}/drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c
755 * instance allowing the 32-bit formats enables 24-precision with CPU
756 * DAIs that do not support 24-bit formats. If the extra formats cause
768 .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, MASK),
774 .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, DEFAULT),
783 .name = "ELD",
792 struct snd_soc_dai_driver *drv = dai->driver; in hdmi_codec_pcm_new()
797 ret = snd_pcm_add_chmap_ctls(rtd->pcm, SNDRV_PCM_STREAM_PLAYBACK, in hdmi_codec_pcm_new()
798 NULL, drv->playback.channels_max, 0, in hdmi_codec_pcm_new()
799 &hcp->chmap_info); in hdmi_codec_pcm_new()
804 hcp->chmap_info->private_data = hcp; in hdmi_codec_pcm_new()
805 hcp->chmap_info->kctl->get = hdmi_codec_chmap_ctl_get; in hdmi_codec_pcm_new()
808 hcp->chmap_info->chmap = hdmi_codec_stereo_chmaps; in hdmi_codec_pcm_new()
809 hcp->chmap_idx = HDMI_CODEC_CHMAP_IDX_UNKNOWN; in hdmi_codec_pcm_new()
815 kctl = snd_ctl_new1(&hdmi_codec_controls[i], dai->component); in hdmi_codec_pcm_new()
817 return -ENOMEM; in hdmi_codec_pcm_new()
819 kctl->id.device = rtd->pcm->device; in hdmi_codec_pcm_new()
820 ret = snd_ctl_add(rtd->card->snd_card, kctl); in hdmi_codec_pcm_new()
835 .source = dai->driver->playback.stream_name, in hdmi_dai_probe()
838 .sink = dai->driver->capture.stream_name, in hdmi_dai_probe()
844 dapm = snd_soc_component_get_dapm(dai->component); in hdmi_dai_probe()
856 daifmt = devm_kzalloc(dai->dev, sizeof(*daifmt), GFP_KERNEL); in hdmi_dai_probe()
858 return -ENOMEM; in hdmi_dai_probe()
868 if (jack_status != hcp->jack_status) { in hdmi_codec_jack_report()
869 if (hcp->jack) in hdmi_codec_jack_report()
870 snd_soc_jack_report(hcp->jack, jack_status, SND_JACK_LINEOUT); in hdmi_codec_jack_report()
871 hcp->jack_status = jack_status; in hdmi_codec_jack_report()
880 if (hcp->hcd.ops->get_eld) { in plugged_cb()
881 hcp->hcd.ops->get_eld(dev->parent, hcp->hcd.data, in plugged_cb()
882 hcp->eld, sizeof(hcp->eld)); in plugged_cb()
887 memset(hcp->eld, 0, sizeof(hcp->eld)); in plugged_cb()
897 if (hcp->hcd.ops->hook_plugged_cb) { in hdmi_codec_set_jack()
898 hcp->jack = jack; in hdmi_codec_set_jack()
904 snd_soc_jack_report(jack, hcp->jack_status, SND_JACK_LINEOUT); in hdmi_codec_set_jack()
909 return -ENOTSUPP; in hdmi_codec_set_jack()
922 cf->fmt = HDMI_SPDIF; in hdmi_dai_spdif_probe()
950 .name = "i2s-hifi",
972 .name = "spdif-hifi",
995 int ret = -ENOTSUPP; /* see snd_soc_get_dai_id() */ in hdmi_of_xlate_dai_id()
997 if (hcp->hcd.ops->get_dai_id) in hdmi_of_xlate_dai_id()
998 ret = hcp->hcd.ops->get_dai_id(component, endpoint, hcp->hcd.data); in hdmi_of_xlate_dai_id()
1008 if (hcp->hcd.ops->hook_plugged_cb) { in hdmi_probe()
1009 ret = hcp->hcd.ops->hook_plugged_cb(component->dev->parent, in hdmi_probe()
1010 hcp->hcd.data, in hdmi_probe()
1012 component->dev); in hdmi_probe()
1022 if (hcp->hcd.ops->hook_plugged_cb) in hdmi_remove()
1023 hcp->hcd.ops->hook_plugged_cb(component->dev->parent, in hdmi_remove()
1024 hcp->hcd.data, NULL, NULL); in hdmi_remove()
1041 struct hdmi_codec_pdata *hcd = pdev->dev.platform_data; in hdmi_codec_probe()
1043 struct device *dev = &pdev->dev; in hdmi_codec_probe()
1050 return -EINVAL; in hdmi_codec_probe()
1053 dai_count = hcd->i2s + hcd->spdif; in hdmi_codec_probe()
1054 if (dai_count < 1 || !hcd->ops || in hdmi_codec_probe()
1055 (!hcd->ops->hw_params && !hcd->ops->prepare) || in hdmi_codec_probe()
1056 !hcd->ops->audio_shutdown) { in hdmi_codec_probe()
1058 return -EINVAL; in hdmi_codec_probe()
1063 return -ENOMEM; in hdmi_codec_probe()
1065 hcp->hcd = *hcd; in hdmi_codec_probe()
1066 mutex_init(&hcp->lock); in hdmi_codec_probe()
1068 ret = snd_pcm_create_iec958_consumer_default(hcp->iec_status, in hdmi_codec_probe()
1069 sizeof(hcp->iec_status)); in hdmi_codec_probe()
1075 return -ENOMEM; in hdmi_codec_probe()
1077 if (hcd->i2s) { in hdmi_codec_probe()
1079 daidrv[i].playback.channels_max = hcd->max_i2s_channels; in hdmi_codec_probe()
1080 if (hcd->no_i2s_playback) in hdmi_codec_probe()
1083 if (hcd->no_i2s_capture) in hdmi_codec_probe()
1089 if (hcd->spdif) { in hdmi_codec_probe()
1091 if (hcd->no_spdif_playback) in hdmi_codec_probe()
1094 if (hcd->no_spdif_capture) in hdmi_codec_probe()
1113 .name = HDMI_CODEC_DRV_NAME,