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>
22 #define HDMI_CODEC_CHMAP_IDX_UNKNOWN -1
60 { .channels = 2,
65 /* Channel maps for multi-channel playbacks, up to 8 n_ch */
67 { .channels = 2, /* CA_ID 0x00 */
69 { .channels = 4, /* CA_ID 0x01 */
72 { .channels = 4, /* CA_ID 0x02 */
75 { .channels = 4, /* CA_ID 0x03 */
78 { .channels = 6, /* CA_ID 0x04 */
81 { .channels = 6, /* CA_ID 0x05 */
84 { .channels = 6, /* CA_ID 0x06 */
87 { .channels = 6, /* CA_ID 0x07 */
90 { .channels = 6, /* CA_ID 0x08 */
93 { .channels = 6, /* CA_ID 0x09 */
96 { .channels = 6, /* CA_ID 0x0A */
99 { .channels = 6, /* CA_ID 0x0B */
102 { .channels = 8, /* CA_ID 0x0C */
106 { .channels = 8, /* CA_ID 0x0D */
110 { .channels = 8, /* CA_ID 0x0E */
114 { .channels = 8, /* CA_ID 0x0F */
118 { .channels = 8, /* CA_ID 0x10 */
122 { .channels = 8, /* CA_ID 0x11 */
126 { .channels = 8, /* CA_ID 0x12 */
130 { .channels = 8, /* CA_ID 0x13 */
134 { .channels = 8, /* CA_ID 0x14 */
138 { .channels = 8, /* CA_ID 0x15 */
142 { .channels = 8, /* CA_ID 0x16 */
146 { .channels = 8, /* CA_ID 0x17 */
150 { .channels = 8, /* CA_ID 0x18 */
154 { .channels = 8, /* CA_ID 0x19 */
158 { .channels = 8, /* CA_ID 0x1A */
162 { .channels = 8, /* CA_ID 0x1B */
166 { .channels = 8, /* CA_ID 0x1C */
170 { .channels = 8, /* CA_ID 0x1D */
174 { .channels = 8, /* CA_ID 0x1E */
178 { .channels = 8, /* CA_ID 0x1F */
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()
345 spk_alloc = drm_eld_get_spk_alloc(hcp->eld); in hdmi_codec_eld_chmap()
348 /* Detect if only stereo supported, else return 8 channels mappings */ 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()
356 unsigned char channels) in hdmi_codec_get_ch_alloc_table_idx() argument
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()
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()
509 unsigned int channels, in hdmi_codec_fill_codec_params() argument
515 bool pcm_audio = !(hcp->iec_status[0] & IEC958_AES0_NONAUDIO); in hdmi_codec_fill_codec_params()
518 /* Select a channel allocation that matches with ELD and pcm channels */ in hdmi_codec_fill_codec_params()
519 idx = hdmi_codec_get_ch_alloc_table_idx(hcp, channels); 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() local
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()
618 width, rate, channels); in hdmi_codec_prepare()
620 ret = hdmi_codec_fill_codec_params(dai, width, rate, channels, &hp); 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),
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",
952 .playback = {
953 .stream_name = "I2S Playback",
972 .name = "spdif-hifi",
974 .playback = {
975 .stream_name = "SPDIF Playback",
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()
1081 memset(&daidrv[i].playback, 0, in hdmi_codec_probe()
1082 sizeof(daidrv[i].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()
1092 memset(&daidrv[i].playback, 0, in hdmi_codec_probe()
1093 sizeof(daidrv[i].playback)); in hdmi_codec_probe()
1094 if (hcd->no_spdif_capture) in hdmi_codec_probe()