Lines Matching +full:audio +full:- +full:hdmi

1 // SPDX-License-Identifier: GPL-2.0-only
7 #include <linux/hdmi.h>
8 #include "hdmi.h"
10 /* maps MSM_HDMI_AUDIO_CHANNEL_n consts used by audio driver to # of channels: */
13 /* Supported HDMI Audio sample rates */
36 /* Audio constants lookup table for hdmi_msm_audio_acr_setup */
37 /* Valid Pixel-Clock rates: 25.2MHz, 27MHz, 27.03MHz, 74.25MHz, 148.5MHz */
67 if (arcs->pixclock == pixclock) in get_arcs()
74 int msm_hdmi_audio_update(struct hdmi *hdmi) in msm_hdmi_audio_update() argument
76 struct hdmi_audio *audio = &hdmi->audio; in msm_hdmi_audio_update() local
77 struct hdmi_audio_infoframe *info = &audio->infoframe; in msm_hdmi_audio_update()
79 bool enabled = audio->enabled; in msm_hdmi_audio_update()
83 DBG("audio: enabled=%d, channels=%d, channel_allocation=0x%x, " in msm_hdmi_audio_update()
85 audio->enabled, info->channels, info->channel_allocation, in msm_hdmi_audio_update()
86 info->level_shift_value, info->downmix_inhibit, audio->rate); in msm_hdmi_audio_update()
87 DBG("video: power_on=%d, pixclock=%lu", hdmi->power_on, hdmi->pixclock); in msm_hdmi_audio_update()
89 if (enabled && !(hdmi->power_on && hdmi->pixclock)) { in msm_hdmi_audio_update()
90 DBG("disabling audio: no video"); in msm_hdmi_audio_update()
95 arcs = get_arcs(hdmi->pixclock); in msm_hdmi_audio_update()
97 DBG("disabling audio: unsupported pixclock: %lu", in msm_hdmi_audio_update()
98 hdmi->pixclock); in msm_hdmi_audio_update()
104 acr_pkt_ctrl = hdmi_read(hdmi, REG_HDMI_ACR_PKT_CTRL); in msm_hdmi_audio_update()
105 vbi_pkt_ctrl = hdmi_read(hdmi, REG_HDMI_VBI_PKT_CTRL); in msm_hdmi_audio_update()
106 aud_pkt_ctrl = hdmi_read(hdmi, REG_HDMI_AUDIO_PKT_CTRL1); in msm_hdmi_audio_update()
107 infofrm_ctrl = hdmi_read(hdmi, REG_HDMI_INFOFRAME_CTRL0); in msm_hdmi_audio_update()
108 audio_config = hdmi_read(hdmi, REG_HDMI_AUDIO_CFG); in msm_hdmi_audio_update()
118 n = arcs->lut[audio->rate].n; in msm_hdmi_audio_update()
119 cts = arcs->lut[audio->rate].cts; in msm_hdmi_audio_update()
121 if ((MSM_HDMI_SAMPLE_RATE_192KHZ == audio->rate) || in msm_hdmi_audio_update()
122 (MSM_HDMI_SAMPLE_RATE_176_4KHZ == audio->rate)) { in msm_hdmi_audio_update()
125 } else if ((MSM_HDMI_SAMPLE_RATE_96KHZ == audio->rate) || in msm_hdmi_audio_update()
126 (MSM_HDMI_SAMPLE_RATE_88_2KHZ == audio->rate)) { in msm_hdmi_audio_update()
139 if ((MSM_HDMI_SAMPLE_RATE_48KHZ == audio->rate) || in msm_hdmi_audio_update()
140 (MSM_HDMI_SAMPLE_RATE_96KHZ == audio->rate) || in msm_hdmi_audio_update()
141 (MSM_HDMI_SAMPLE_RATE_192KHZ == audio->rate)) in msm_hdmi_audio_update()
143 else if ((MSM_HDMI_SAMPLE_RATE_44_1KHZ == audio->rate) || in msm_hdmi_audio_update()
144 (MSM_HDMI_SAMPLE_RATE_88_2KHZ == audio->rate) || in msm_hdmi_audio_update()
145 (MSM_HDMI_SAMPLE_RATE_176_4KHZ == audio->rate)) in msm_hdmi_audio_update()
152 hdmi_write(hdmi, REG_HDMI_ACR_0(select - 1), in msm_hdmi_audio_update()
154 hdmi_write(hdmi, REG_HDMI_ACR_1(select - 1), in msm_hdmi_audio_update()
157 hdmi_write(hdmi, REG_HDMI_AUDIO_PKT_CTRL2, in msm_hdmi_audio_update()
158 COND(info->channels != 2, HDMI_AUDIO_PKT_CTRL2_LAYOUT) | in msm_hdmi_audio_update()
166 hdmi_write(hdmi, REG_HDMI_AUDIO_INFO0, in msm_hdmi_audio_update()
169 hdmi_write(hdmi, REG_HDMI_AUDIO_INFO1, in msm_hdmi_audio_update()
172 hdmi_write(hdmi, REG_HDMI_GC, 0); in msm_hdmi_audio_update()
200 hdmi_write(hdmi, REG_HDMI_ACR_PKT_CTRL, acr_pkt_ctrl); in msm_hdmi_audio_update()
201 hdmi_write(hdmi, REG_HDMI_VBI_PKT_CTRL, vbi_pkt_ctrl); in msm_hdmi_audio_update()
202 hdmi_write(hdmi, REG_HDMI_AUDIO_PKT_CTRL1, aud_pkt_ctrl); in msm_hdmi_audio_update()
203 hdmi_write(hdmi, REG_HDMI_INFOFRAME_CTRL0, infofrm_ctrl); in msm_hdmi_audio_update()
205 hdmi_write(hdmi, REG_HDMI_AUD_INT, in msm_hdmi_audio_update()
209 hdmi_write(hdmi, REG_HDMI_AUDIO_CFG, audio_config); in msm_hdmi_audio_update()
212 DBG("audio %sabled", enabled ? "en" : "dis"); in msm_hdmi_audio_update()
217 int msm_hdmi_audio_info_setup(struct hdmi *hdmi, bool enabled, in msm_hdmi_audio_info_setup() argument
221 struct hdmi_audio *audio; in msm_hdmi_audio_info_setup() local
223 if (!hdmi) in msm_hdmi_audio_info_setup()
224 return -ENXIO; in msm_hdmi_audio_info_setup()
226 audio = &hdmi->audio; in msm_hdmi_audio_info_setup()
229 return -EINVAL; in msm_hdmi_audio_info_setup()
231 audio->enabled = enabled; in msm_hdmi_audio_info_setup()
232 audio->infoframe.channels = nchannels[num_of_channels]; in msm_hdmi_audio_info_setup()
233 audio->infoframe.channel_allocation = channel_allocation; in msm_hdmi_audio_info_setup()
234 audio->infoframe.level_shift_value = level_shift; in msm_hdmi_audio_info_setup()
235 audio->infoframe.downmix_inhibit = down_mix; in msm_hdmi_audio_info_setup()
237 return msm_hdmi_audio_update(hdmi); in msm_hdmi_audio_info_setup()
240 void msm_hdmi_audio_set_sample_rate(struct hdmi *hdmi, int rate) in msm_hdmi_audio_set_sample_rate() argument
242 struct hdmi_audio *audio; in msm_hdmi_audio_set_sample_rate() local
244 if (!hdmi) in msm_hdmi_audio_set_sample_rate()
247 audio = &hdmi->audio; in msm_hdmi_audio_set_sample_rate()
252 audio->rate = rate; in msm_hdmi_audio_set_sample_rate()
253 msm_hdmi_audio_update(hdmi); in msm_hdmi_audio_set_sample_rate()