From: Daniel Vetter Date: Wed, 7 Oct 2015 13:34:15 +0000 (+0200) Subject: Merge remote-tracking branch 'takashi/topic/drm-sync-audio-rate' into drm-intel-next... X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=2844659842017c981f6e6f74aca3a7ebe10edebb;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git Merge remote-tracking branch 'takashi/topic/drm-sync-audio-rate' into drm-intel-next-queued Pull in the i915/hda changes for N/CTS setting so I can apply the follow-up documentation work for drm/i915. Some conflicts because ofc we had to rework i915 while that N/CTS work was going on. But not more than adjacent changes really. Signed-off-by: Daniel Vetter --- 2844659842017c981f6e6f74aca3a7ebe10edebb diff --cc drivers/gpu/drm/i915/intel_audio.c index b08b4a7fae49,dffd0b4c5f17..72d696b0e7d4 --- a/drivers/gpu/drm/i915/intel_audio.c +++ b/drivers/gpu/drm/i915/intel_audio.c @@@ -68,8 -68,33 +68,33 @@@ static const struct { 148500, AUD_CONFIG_PIXEL_CLOCK_HDMI_148500 }, }; + /* HDMI N/CTS table */ + #define TMDS_297M 297000 + #define TMDS_296M DIV_ROUND_UP(297000 * 1000, 1001) + static const struct { + int sample_rate; + int clock; + int n; + int cts; + } aud_ncts[] = { + { 44100, TMDS_296M, 4459, 234375 }, + { 44100, TMDS_297M, 4704, 247500 }, + { 48000, TMDS_296M, 5824, 281250 }, + { 48000, TMDS_297M, 5120, 247500 }, + { 32000, TMDS_296M, 5824, 421875 }, + { 32000, TMDS_297M, 3072, 222750 }, + { 88200, TMDS_296M, 8918, 234375 }, + { 88200, TMDS_297M, 9408, 247500 }, + { 96000, TMDS_296M, 11648, 281250 }, + { 96000, TMDS_297M, 10240, 247500 }, + { 176400, TMDS_296M, 17836, 234375 }, + { 176400, TMDS_297M, 18816, 247500 }, + { 192000, TMDS_296M, 23296, 281250 }, + { 192000, TMDS_297M, 20480, 247500 }, + }; + /* get AUD_CONFIG_PIXEL_CLOCK_HDMI_* value for mode */ -static u32 audio_config_hdmi_pixel_clock(struct drm_display_mode *mode) +static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted_mode) { int i; @@@ -252,8 -325,28 +326,28 @@@ static void hsw_audio_codec_enable(stru if (intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DISPLAYPORT)) tmp |= AUD_CONFIG_N_VALUE_INDEX; else - tmp |= audio_config_hdmi_pixel_clock(mode); + tmp |= audio_config_hdmi_pixel_clock(adjusted_mode); + + tmp &= ~AUD_CONFIG_N_PROG_ENABLE; - if (audio_rate_need_prog(intel_crtc, mode)) { ++ if (audio_rate_need_prog(intel_crtc, adjusted_mode)) { + if (!acomp) + rate = 0; + else if (port >= PORT_A && port <= PORT_E) + rate = acomp->aud_sample_rate[port]; + else { + DRM_ERROR("invalid port: %d\n", port); + rate = 0; + } - n = audio_config_get_n(mode, rate); ++ n = audio_config_get_n(adjusted_mode, rate); + if (n != 0) + tmp = audio_config_setup_n_reg(n, tmp); + else + DRM_DEBUG_KMS("no suitable N value is found\n"); + } + I915_WRITE(HSW_AUD_CFG(pipe), tmp); + + mutex_unlock(&dev_priv->av_mutex); } static void ilk_audio_codec_disable(struct intel_encoder *encoder)