Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2006 Dave Airlie <airlied@linux.ie> |
| 3 | * Copyright © 2006-2009 Intel Corporation |
| 4 | * |
| 5 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 6 | * copy of this software and associated documentation files (the "Software"), |
| 7 | * to deal in the Software without restriction, including without limitation |
| 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 9 | * and/or sell copies of the Software, and to permit persons to whom the |
| 10 | * Software is furnished to do so, subject to the following conditions: |
| 11 | * |
| 12 | * The above copyright notice and this permission notice (including the next |
| 13 | * paragraph) shall be included in all copies or substantial portions of the |
| 14 | * Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 22 | * DEALINGS IN THE SOFTWARE. |
| 23 | * |
| 24 | * Authors: |
| 25 | * Eric Anholt <eric@anholt.net> |
| 26 | * Jesse Barnes <jesse.barnes@intel.com> |
| 27 | */ |
| 28 | |
| 29 | #include <linux/i2c.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 30 | #include <linux/slab.h> |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 31 | #include <linux/delay.h> |
Damien Lespiau | 178f736 | 2013-08-06 20:32:18 +0100 | [diff] [blame] | 32 | #include <linux/hdmi.h> |
David Howells | 760285e | 2012-10-02 18:01:07 +0100 | [diff] [blame] | 33 | #include <drm/drmP.h> |
Matt Roper | c6f95f2 | 2015-01-22 16:50:32 -0800 | [diff] [blame] | 34 | #include <drm/drm_atomic_helper.h> |
David Howells | 760285e | 2012-10-02 18:01:07 +0100 | [diff] [blame] | 35 | #include <drm/drm_crtc.h> |
| 36 | #include <drm/drm_edid.h> |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 37 | #include "intel_drv.h" |
David Howells | 760285e | 2012-10-02 18:01:07 +0100 | [diff] [blame] | 38 | #include <drm/i915_drm.h> |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 39 | #include "i915_drv.h" |
| 40 | |
Paulo Zanoni | 30add22 | 2012-10-26 19:05:45 -0200 | [diff] [blame] | 41 | static struct drm_device *intel_hdmi_to_dev(struct intel_hdmi *intel_hdmi) |
| 42 | { |
Paulo Zanoni | da63a9f | 2012-10-26 19:05:46 -0200 | [diff] [blame] | 43 | return hdmi_to_dig_port(intel_hdmi)->base.base.dev; |
Paulo Zanoni | 30add22 | 2012-10-26 19:05:45 -0200 | [diff] [blame] | 44 | } |
| 45 | |
Daniel Vetter | afba018 | 2012-06-12 16:36:45 +0200 | [diff] [blame] | 46 | static void |
| 47 | assert_hdmi_port_disabled(struct intel_hdmi *intel_hdmi) |
| 48 | { |
Paulo Zanoni | 30add22 | 2012-10-26 19:05:45 -0200 | [diff] [blame] | 49 | struct drm_device *dev = intel_hdmi_to_dev(intel_hdmi); |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 50 | struct drm_i915_private *dev_priv = to_i915(dev); |
Daniel Vetter | afba018 | 2012-06-12 16:36:45 +0200 | [diff] [blame] | 51 | uint32_t enabled_bits; |
| 52 | |
Tvrtko Ursulin | 4f8036a | 2016-10-13 11:02:52 +0100 | [diff] [blame] | 53 | enabled_bits = HAS_DDI(dev_priv) ? DDI_BUF_CTL_ENABLE : SDVO_ENABLE; |
Daniel Vetter | afba018 | 2012-06-12 16:36:45 +0200 | [diff] [blame] | 54 | |
Paulo Zanoni | b242b7f | 2013-02-18 19:00:26 -0300 | [diff] [blame] | 55 | WARN(I915_READ(intel_hdmi->hdmi_reg) & enabled_bits, |
Daniel Vetter | afba018 | 2012-06-12 16:36:45 +0200 | [diff] [blame] | 56 | "HDMI port enabled, expecting disabled\n"); |
| 57 | } |
| 58 | |
Eugeni Dodonov | f5bbfca | 2012-05-09 15:37:30 -0300 | [diff] [blame] | 59 | struct intel_hdmi *enc_to_intel_hdmi(struct drm_encoder *encoder) |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 60 | { |
Paulo Zanoni | da63a9f | 2012-10-26 19:05:46 -0200 | [diff] [blame] | 61 | struct intel_digital_port *intel_dig_port = |
| 62 | container_of(encoder, struct intel_digital_port, base.base); |
| 63 | return &intel_dig_port->hdmi; |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 64 | } |
| 65 | |
Chris Wilson | df0e924 | 2010-09-09 16:20:55 +0100 | [diff] [blame] | 66 | static struct intel_hdmi *intel_attached_hdmi(struct drm_connector *connector) |
| 67 | { |
Paulo Zanoni | da63a9f | 2012-10-26 19:05:46 -0200 | [diff] [blame] | 68 | return enc_to_intel_hdmi(&intel_attached_encoder(connector)->base); |
Chris Wilson | df0e924 | 2010-09-09 16:20:55 +0100 | [diff] [blame] | 69 | } |
| 70 | |
Damien Lespiau | 178f736 | 2013-08-06 20:32:18 +0100 | [diff] [blame] | 71 | static u32 g4x_infoframe_index(enum hdmi_infoframe_type type) |
David Härdeman | 3c17fe4 | 2010-09-24 21:44:32 +0200 | [diff] [blame] | 72 | { |
Damien Lespiau | 178f736 | 2013-08-06 20:32:18 +0100 | [diff] [blame] | 73 | switch (type) { |
| 74 | case HDMI_INFOFRAME_TYPE_AVI: |
Paulo Zanoni | ed517fb | 2012-05-14 17:12:50 -0300 | [diff] [blame] | 75 | return VIDEO_DIP_SELECT_AVI; |
Damien Lespiau | 178f736 | 2013-08-06 20:32:18 +0100 | [diff] [blame] | 76 | case HDMI_INFOFRAME_TYPE_SPD: |
Paulo Zanoni | ed517fb | 2012-05-14 17:12:50 -0300 | [diff] [blame] | 77 | return VIDEO_DIP_SELECT_SPD; |
Lespiau, Damien | c8bb75a | 2013-08-19 16:59:04 +0100 | [diff] [blame] | 78 | case HDMI_INFOFRAME_TYPE_VENDOR: |
| 79 | return VIDEO_DIP_SELECT_VENDOR; |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 80 | default: |
Ville Syrjälä | ffc85da | 2015-12-16 18:10:00 +0200 | [diff] [blame] | 81 | MISSING_CASE(type); |
Paulo Zanoni | ed517fb | 2012-05-14 17:12:50 -0300 | [diff] [blame] | 82 | return 0; |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 83 | } |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 84 | } |
| 85 | |
Damien Lespiau | 178f736 | 2013-08-06 20:32:18 +0100 | [diff] [blame] | 86 | static u32 g4x_infoframe_enable(enum hdmi_infoframe_type type) |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 87 | { |
Damien Lespiau | 178f736 | 2013-08-06 20:32:18 +0100 | [diff] [blame] | 88 | switch (type) { |
| 89 | case HDMI_INFOFRAME_TYPE_AVI: |
Paulo Zanoni | ed517fb | 2012-05-14 17:12:50 -0300 | [diff] [blame] | 90 | return VIDEO_DIP_ENABLE_AVI; |
Damien Lespiau | 178f736 | 2013-08-06 20:32:18 +0100 | [diff] [blame] | 91 | case HDMI_INFOFRAME_TYPE_SPD: |
Paulo Zanoni | ed517fb | 2012-05-14 17:12:50 -0300 | [diff] [blame] | 92 | return VIDEO_DIP_ENABLE_SPD; |
Lespiau, Damien | c8bb75a | 2013-08-19 16:59:04 +0100 | [diff] [blame] | 93 | case HDMI_INFOFRAME_TYPE_VENDOR: |
| 94 | return VIDEO_DIP_ENABLE_VENDOR; |
Paulo Zanoni | fa193ff | 2012-05-04 17:18:20 -0300 | [diff] [blame] | 95 | default: |
Ville Syrjälä | ffc85da | 2015-12-16 18:10:00 +0200 | [diff] [blame] | 96 | MISSING_CASE(type); |
Paulo Zanoni | ed517fb | 2012-05-14 17:12:50 -0300 | [diff] [blame] | 97 | return 0; |
Paulo Zanoni | fa193ff | 2012-05-04 17:18:20 -0300 | [diff] [blame] | 98 | } |
Paulo Zanoni | fa193ff | 2012-05-04 17:18:20 -0300 | [diff] [blame] | 99 | } |
| 100 | |
Damien Lespiau | 178f736 | 2013-08-06 20:32:18 +0100 | [diff] [blame] | 101 | static u32 hsw_infoframe_enable(enum hdmi_infoframe_type type) |
Paulo Zanoni | 2da8af5 | 2012-05-14 17:12:51 -0300 | [diff] [blame] | 102 | { |
Damien Lespiau | 178f736 | 2013-08-06 20:32:18 +0100 | [diff] [blame] | 103 | switch (type) { |
| 104 | case HDMI_INFOFRAME_TYPE_AVI: |
Paulo Zanoni | 2da8af5 | 2012-05-14 17:12:51 -0300 | [diff] [blame] | 105 | return VIDEO_DIP_ENABLE_AVI_HSW; |
Damien Lespiau | 178f736 | 2013-08-06 20:32:18 +0100 | [diff] [blame] | 106 | case HDMI_INFOFRAME_TYPE_SPD: |
Paulo Zanoni | 2da8af5 | 2012-05-14 17:12:51 -0300 | [diff] [blame] | 107 | return VIDEO_DIP_ENABLE_SPD_HSW; |
Lespiau, Damien | c8bb75a | 2013-08-19 16:59:04 +0100 | [diff] [blame] | 108 | case HDMI_INFOFRAME_TYPE_VENDOR: |
| 109 | return VIDEO_DIP_ENABLE_VS_HSW; |
Paulo Zanoni | 2da8af5 | 2012-05-14 17:12:51 -0300 | [diff] [blame] | 110 | default: |
Ville Syrjälä | ffc85da | 2015-12-16 18:10:00 +0200 | [diff] [blame] | 111 | MISSING_CASE(type); |
Paulo Zanoni | 2da8af5 | 2012-05-14 17:12:51 -0300 | [diff] [blame] | 112 | return 0; |
| 113 | } |
| 114 | } |
| 115 | |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 116 | static i915_reg_t |
| 117 | hsw_dip_data_reg(struct drm_i915_private *dev_priv, |
| 118 | enum transcoder cpu_transcoder, |
| 119 | enum hdmi_infoframe_type type, |
| 120 | int i) |
Paulo Zanoni | 2da8af5 | 2012-05-14 17:12:51 -0300 | [diff] [blame] | 121 | { |
Damien Lespiau | 178f736 | 2013-08-06 20:32:18 +0100 | [diff] [blame] | 122 | switch (type) { |
| 123 | case HDMI_INFOFRAME_TYPE_AVI: |
Ville Syrjälä | 436c6d4 | 2015-09-18 20:03:37 +0300 | [diff] [blame] | 124 | return HSW_TVIDEO_DIP_AVI_DATA(cpu_transcoder, i); |
Damien Lespiau | 178f736 | 2013-08-06 20:32:18 +0100 | [diff] [blame] | 125 | case HDMI_INFOFRAME_TYPE_SPD: |
Ville Syrjälä | 436c6d4 | 2015-09-18 20:03:37 +0300 | [diff] [blame] | 126 | return HSW_TVIDEO_DIP_SPD_DATA(cpu_transcoder, i); |
Lespiau, Damien | c8bb75a | 2013-08-19 16:59:04 +0100 | [diff] [blame] | 127 | case HDMI_INFOFRAME_TYPE_VENDOR: |
Ville Syrjälä | 436c6d4 | 2015-09-18 20:03:37 +0300 | [diff] [blame] | 128 | return HSW_TVIDEO_DIP_VS_DATA(cpu_transcoder, i); |
Paulo Zanoni | 2da8af5 | 2012-05-14 17:12:51 -0300 | [diff] [blame] | 129 | default: |
Ville Syrjälä | ffc85da | 2015-12-16 18:10:00 +0200 | [diff] [blame] | 130 | MISSING_CASE(type); |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 131 | return INVALID_MMIO_REG; |
Paulo Zanoni | 2da8af5 | 2012-05-14 17:12:51 -0300 | [diff] [blame] | 132 | } |
| 133 | } |
| 134 | |
Daniel Vetter | a3da1df | 2012-05-08 15:19:06 +0200 | [diff] [blame] | 135 | static void g4x_write_infoframe(struct drm_encoder *encoder, |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 136 | const struct intel_crtc_state *crtc_state, |
Damien Lespiau | 178f736 | 2013-08-06 20:32:18 +0100 | [diff] [blame] | 137 | enum hdmi_infoframe_type type, |
Ville Syrjälä | fff6386 | 2013-12-10 15:19:08 +0200 | [diff] [blame] | 138 | const void *frame, ssize_t len) |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 139 | { |
Ville Syrjälä | fff6386 | 2013-12-10 15:19:08 +0200 | [diff] [blame] | 140 | const uint32_t *data = frame; |
David Härdeman | 3c17fe4 | 2010-09-24 21:44:32 +0200 | [diff] [blame] | 141 | struct drm_device *dev = encoder->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 142 | struct drm_i915_private *dev_priv = to_i915(dev); |
Paulo Zanoni | 22509ec | 2012-05-04 17:18:17 -0300 | [diff] [blame] | 143 | u32 val = I915_READ(VIDEO_DIP_CTL); |
Damien Lespiau | 178f736 | 2013-08-06 20:32:18 +0100 | [diff] [blame] | 144 | int i; |
David Härdeman | 3c17fe4 | 2010-09-24 21:44:32 +0200 | [diff] [blame] | 145 | |
Paulo Zanoni | 822974a | 2012-05-28 16:42:51 -0300 | [diff] [blame] | 146 | WARN(!(val & VIDEO_DIP_ENABLE), "Writing DIP with CTL reg disabled\n"); |
| 147 | |
Paulo Zanoni | 1d4f85a | 2012-05-04 17:18:18 -0300 | [diff] [blame] | 148 | val &= ~(VIDEO_DIP_SELECT_MASK | 0xf); /* clear DIP data offset */ |
Damien Lespiau | 178f736 | 2013-08-06 20:32:18 +0100 | [diff] [blame] | 149 | val |= g4x_infoframe_index(type); |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 150 | |
Damien Lespiau | 178f736 | 2013-08-06 20:32:18 +0100 | [diff] [blame] | 151 | val &= ~g4x_infoframe_enable(type); |
Paulo Zanoni | 22509ec | 2012-05-04 17:18:17 -0300 | [diff] [blame] | 152 | |
| 153 | I915_WRITE(VIDEO_DIP_CTL, val); |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 154 | |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 155 | mmiowb(); |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 156 | for (i = 0; i < len; i += 4) { |
David Härdeman | 3c17fe4 | 2010-09-24 21:44:32 +0200 | [diff] [blame] | 157 | I915_WRITE(VIDEO_DIP_DATA, *data); |
| 158 | data++; |
| 159 | } |
Paulo Zanoni | adf00b2 | 2012-09-25 13:23:34 -0300 | [diff] [blame] | 160 | /* Write every possible data byte to force correct ECC calculation. */ |
| 161 | for (; i < VIDEO_DIP_DATA_SIZE; i += 4) |
| 162 | I915_WRITE(VIDEO_DIP_DATA, 0); |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 163 | mmiowb(); |
David Härdeman | 3c17fe4 | 2010-09-24 21:44:32 +0200 | [diff] [blame] | 164 | |
Damien Lespiau | 178f736 | 2013-08-06 20:32:18 +0100 | [diff] [blame] | 165 | val |= g4x_infoframe_enable(type); |
Paulo Zanoni | 60c5ea2 | 2012-05-04 17:18:22 -0300 | [diff] [blame] | 166 | val &= ~VIDEO_DIP_FREQ_MASK; |
Daniel Vetter | 4b24c93 | 2012-05-08 14:41:00 +0200 | [diff] [blame] | 167 | val |= VIDEO_DIP_FREQ_VSYNC; |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 168 | |
Paulo Zanoni | 22509ec | 2012-05-04 17:18:17 -0300 | [diff] [blame] | 169 | I915_WRITE(VIDEO_DIP_CTL, val); |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 170 | POSTING_READ(VIDEO_DIP_CTL); |
David Härdeman | 3c17fe4 | 2010-09-24 21:44:32 +0200 | [diff] [blame] | 171 | } |
| 172 | |
Ville Syrjälä | cda0aaa | 2015-11-26 18:27:07 +0200 | [diff] [blame] | 173 | static bool g4x_infoframe_enabled(struct drm_encoder *encoder, |
| 174 | const struct intel_crtc_state *pipe_config) |
Jesse Barnes | e43823e | 2014-11-05 14:26:08 -0800 | [diff] [blame] | 175 | { |
Ville Syrjälä | cda0aaa | 2015-11-26 18:27:07 +0200 | [diff] [blame] | 176 | struct drm_i915_private *dev_priv = to_i915(encoder->dev); |
Jesse Barnes | 89a35ec | 2014-11-20 13:24:13 -0800 | [diff] [blame] | 177 | struct intel_digital_port *intel_dig_port = enc_to_dig_port(encoder); |
Jesse Barnes | e43823e | 2014-11-05 14:26:08 -0800 | [diff] [blame] | 178 | u32 val = I915_READ(VIDEO_DIP_CTL); |
| 179 | |
Ville Syrjälä | ec1dc60 | 2015-05-05 17:06:25 +0300 | [diff] [blame] | 180 | if ((val & VIDEO_DIP_ENABLE) == 0) |
| 181 | return false; |
Jesse Barnes | 89a35ec | 2014-11-20 13:24:13 -0800 | [diff] [blame] | 182 | |
Ville Syrjälä | ec1dc60 | 2015-05-05 17:06:25 +0300 | [diff] [blame] | 183 | if ((val & VIDEO_DIP_PORT_MASK) != VIDEO_DIP_PORT(intel_dig_port->port)) |
| 184 | return false; |
| 185 | |
| 186 | return val & (VIDEO_DIP_ENABLE_AVI | |
| 187 | VIDEO_DIP_ENABLE_VENDOR | VIDEO_DIP_ENABLE_SPD); |
Jesse Barnes | e43823e | 2014-11-05 14:26:08 -0800 | [diff] [blame] | 188 | } |
| 189 | |
Paulo Zanoni | fdf1250 | 2012-05-04 17:18:24 -0300 | [diff] [blame] | 190 | static void ibx_write_infoframe(struct drm_encoder *encoder, |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 191 | const struct intel_crtc_state *crtc_state, |
Damien Lespiau | 178f736 | 2013-08-06 20:32:18 +0100 | [diff] [blame] | 192 | enum hdmi_infoframe_type type, |
Ville Syrjälä | fff6386 | 2013-12-10 15:19:08 +0200 | [diff] [blame] | 193 | const void *frame, ssize_t len) |
Paulo Zanoni | fdf1250 | 2012-05-04 17:18:24 -0300 | [diff] [blame] | 194 | { |
Ville Syrjälä | fff6386 | 2013-12-10 15:19:08 +0200 | [diff] [blame] | 195 | const uint32_t *data = frame; |
Paulo Zanoni | fdf1250 | 2012-05-04 17:18:24 -0300 | [diff] [blame] | 196 | struct drm_device *dev = encoder->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 197 | struct drm_i915_private *dev_priv = to_i915(dev); |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 198 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc_state->base.crtc); |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 199 | i915_reg_t reg = TVIDEO_DIP_CTL(intel_crtc->pipe); |
Paulo Zanoni | fdf1250 | 2012-05-04 17:18:24 -0300 | [diff] [blame] | 200 | u32 val = I915_READ(reg); |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 201 | int i; |
Paulo Zanoni | fdf1250 | 2012-05-04 17:18:24 -0300 | [diff] [blame] | 202 | |
Paulo Zanoni | 822974a | 2012-05-28 16:42:51 -0300 | [diff] [blame] | 203 | WARN(!(val & VIDEO_DIP_ENABLE), "Writing DIP with CTL reg disabled\n"); |
| 204 | |
Paulo Zanoni | fdf1250 | 2012-05-04 17:18:24 -0300 | [diff] [blame] | 205 | val &= ~(VIDEO_DIP_SELECT_MASK | 0xf); /* clear DIP data offset */ |
Damien Lespiau | 178f736 | 2013-08-06 20:32:18 +0100 | [diff] [blame] | 206 | val |= g4x_infoframe_index(type); |
Paulo Zanoni | fdf1250 | 2012-05-04 17:18:24 -0300 | [diff] [blame] | 207 | |
Damien Lespiau | 178f736 | 2013-08-06 20:32:18 +0100 | [diff] [blame] | 208 | val &= ~g4x_infoframe_enable(type); |
Paulo Zanoni | fdf1250 | 2012-05-04 17:18:24 -0300 | [diff] [blame] | 209 | |
| 210 | I915_WRITE(reg, val); |
| 211 | |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 212 | mmiowb(); |
Paulo Zanoni | fdf1250 | 2012-05-04 17:18:24 -0300 | [diff] [blame] | 213 | for (i = 0; i < len; i += 4) { |
| 214 | I915_WRITE(TVIDEO_DIP_DATA(intel_crtc->pipe), *data); |
| 215 | data++; |
| 216 | } |
Paulo Zanoni | adf00b2 | 2012-09-25 13:23:34 -0300 | [diff] [blame] | 217 | /* Write every possible data byte to force correct ECC calculation. */ |
| 218 | for (; i < VIDEO_DIP_DATA_SIZE; i += 4) |
| 219 | I915_WRITE(TVIDEO_DIP_DATA(intel_crtc->pipe), 0); |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 220 | mmiowb(); |
Paulo Zanoni | fdf1250 | 2012-05-04 17:18:24 -0300 | [diff] [blame] | 221 | |
Damien Lespiau | 178f736 | 2013-08-06 20:32:18 +0100 | [diff] [blame] | 222 | val |= g4x_infoframe_enable(type); |
Paulo Zanoni | fdf1250 | 2012-05-04 17:18:24 -0300 | [diff] [blame] | 223 | val &= ~VIDEO_DIP_FREQ_MASK; |
Daniel Vetter | 4b24c93 | 2012-05-08 14:41:00 +0200 | [diff] [blame] | 224 | val |= VIDEO_DIP_FREQ_VSYNC; |
Paulo Zanoni | fdf1250 | 2012-05-04 17:18:24 -0300 | [diff] [blame] | 225 | |
| 226 | I915_WRITE(reg, val); |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 227 | POSTING_READ(reg); |
Paulo Zanoni | fdf1250 | 2012-05-04 17:18:24 -0300 | [diff] [blame] | 228 | } |
| 229 | |
Ville Syrjälä | cda0aaa | 2015-11-26 18:27:07 +0200 | [diff] [blame] | 230 | static bool ibx_infoframe_enabled(struct drm_encoder *encoder, |
| 231 | const struct intel_crtc_state *pipe_config) |
Jesse Barnes | e43823e | 2014-11-05 14:26:08 -0800 | [diff] [blame] | 232 | { |
Ville Syrjälä | cda0aaa | 2015-11-26 18:27:07 +0200 | [diff] [blame] | 233 | struct drm_i915_private *dev_priv = to_i915(encoder->dev); |
Jani Nikula | 052f62f | 2015-04-29 15:30:07 +0300 | [diff] [blame] | 234 | struct intel_digital_port *intel_dig_port = enc_to_dig_port(encoder); |
Ville Syrjälä | cda0aaa | 2015-11-26 18:27:07 +0200 | [diff] [blame] | 235 | enum pipe pipe = to_intel_crtc(pipe_config->base.crtc)->pipe; |
| 236 | i915_reg_t reg = TVIDEO_DIP_CTL(pipe); |
Jesse Barnes | e43823e | 2014-11-05 14:26:08 -0800 | [diff] [blame] | 237 | u32 val = I915_READ(reg); |
| 238 | |
Ville Syrjälä | ec1dc60 | 2015-05-05 17:06:25 +0300 | [diff] [blame] | 239 | if ((val & VIDEO_DIP_ENABLE) == 0) |
| 240 | return false; |
Jani Nikula | 052f62f | 2015-04-29 15:30:07 +0300 | [diff] [blame] | 241 | |
Ville Syrjälä | ec1dc60 | 2015-05-05 17:06:25 +0300 | [diff] [blame] | 242 | if ((val & VIDEO_DIP_PORT_MASK) != VIDEO_DIP_PORT(intel_dig_port->port)) |
| 243 | return false; |
| 244 | |
| 245 | return val & (VIDEO_DIP_ENABLE_AVI | |
| 246 | VIDEO_DIP_ENABLE_VENDOR | VIDEO_DIP_ENABLE_GAMUT | |
| 247 | VIDEO_DIP_ENABLE_SPD | VIDEO_DIP_ENABLE_GCP); |
Jesse Barnes | e43823e | 2014-11-05 14:26:08 -0800 | [diff] [blame] | 248 | } |
| 249 | |
Paulo Zanoni | fdf1250 | 2012-05-04 17:18:24 -0300 | [diff] [blame] | 250 | static void cpt_write_infoframe(struct drm_encoder *encoder, |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 251 | const struct intel_crtc_state *crtc_state, |
Damien Lespiau | 178f736 | 2013-08-06 20:32:18 +0100 | [diff] [blame] | 252 | enum hdmi_infoframe_type type, |
Ville Syrjälä | fff6386 | 2013-12-10 15:19:08 +0200 | [diff] [blame] | 253 | const void *frame, ssize_t len) |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 254 | { |
Ville Syrjälä | fff6386 | 2013-12-10 15:19:08 +0200 | [diff] [blame] | 255 | const uint32_t *data = frame; |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 256 | struct drm_device *dev = encoder->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 257 | struct drm_i915_private *dev_priv = to_i915(dev); |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 258 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc_state->base.crtc); |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 259 | i915_reg_t reg = TVIDEO_DIP_CTL(intel_crtc->pipe); |
Paulo Zanoni | 22509ec | 2012-05-04 17:18:17 -0300 | [diff] [blame] | 260 | u32 val = I915_READ(reg); |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 261 | int i; |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 262 | |
Paulo Zanoni | 822974a | 2012-05-28 16:42:51 -0300 | [diff] [blame] | 263 | WARN(!(val & VIDEO_DIP_ENABLE), "Writing DIP with CTL reg disabled\n"); |
| 264 | |
Jesse Barnes | 64a8fc0 | 2011-09-22 11:16:00 +0530 | [diff] [blame] | 265 | val &= ~(VIDEO_DIP_SELECT_MASK | 0xf); /* clear DIP data offset */ |
Damien Lespiau | 178f736 | 2013-08-06 20:32:18 +0100 | [diff] [blame] | 266 | val |= g4x_infoframe_index(type); |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 267 | |
Paulo Zanoni | ecb9785 | 2012-05-04 17:18:21 -0300 | [diff] [blame] | 268 | /* The DIP control register spec says that we need to update the AVI |
| 269 | * infoframe without clearing its enable bit */ |
Damien Lespiau | 178f736 | 2013-08-06 20:32:18 +0100 | [diff] [blame] | 270 | if (type != HDMI_INFOFRAME_TYPE_AVI) |
| 271 | val &= ~g4x_infoframe_enable(type); |
Paulo Zanoni | ecb9785 | 2012-05-04 17:18:21 -0300 | [diff] [blame] | 272 | |
Paulo Zanoni | 22509ec | 2012-05-04 17:18:17 -0300 | [diff] [blame] | 273 | I915_WRITE(reg, val); |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 274 | |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 275 | mmiowb(); |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 276 | for (i = 0; i < len; i += 4) { |
| 277 | I915_WRITE(TVIDEO_DIP_DATA(intel_crtc->pipe), *data); |
| 278 | data++; |
| 279 | } |
Paulo Zanoni | adf00b2 | 2012-09-25 13:23:34 -0300 | [diff] [blame] | 280 | /* Write every possible data byte to force correct ECC calculation. */ |
| 281 | for (; i < VIDEO_DIP_DATA_SIZE; i += 4) |
| 282 | I915_WRITE(TVIDEO_DIP_DATA(intel_crtc->pipe), 0); |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 283 | mmiowb(); |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 284 | |
Damien Lespiau | 178f736 | 2013-08-06 20:32:18 +0100 | [diff] [blame] | 285 | val |= g4x_infoframe_enable(type); |
Paulo Zanoni | 60c5ea2 | 2012-05-04 17:18:22 -0300 | [diff] [blame] | 286 | val &= ~VIDEO_DIP_FREQ_MASK; |
Daniel Vetter | 4b24c93 | 2012-05-08 14:41:00 +0200 | [diff] [blame] | 287 | val |= VIDEO_DIP_FREQ_VSYNC; |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 288 | |
Paulo Zanoni | 22509ec | 2012-05-04 17:18:17 -0300 | [diff] [blame] | 289 | I915_WRITE(reg, val); |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 290 | POSTING_READ(reg); |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 291 | } |
Shobhit Kumar | 90b107c | 2012-03-28 13:39:32 -0700 | [diff] [blame] | 292 | |
Ville Syrjälä | cda0aaa | 2015-11-26 18:27:07 +0200 | [diff] [blame] | 293 | static bool cpt_infoframe_enabled(struct drm_encoder *encoder, |
| 294 | const struct intel_crtc_state *pipe_config) |
Jesse Barnes | e43823e | 2014-11-05 14:26:08 -0800 | [diff] [blame] | 295 | { |
Ville Syrjälä | cda0aaa | 2015-11-26 18:27:07 +0200 | [diff] [blame] | 296 | struct drm_i915_private *dev_priv = to_i915(encoder->dev); |
| 297 | enum pipe pipe = to_intel_crtc(pipe_config->base.crtc)->pipe; |
| 298 | u32 val = I915_READ(TVIDEO_DIP_CTL(pipe)); |
Jesse Barnes | e43823e | 2014-11-05 14:26:08 -0800 | [diff] [blame] | 299 | |
Ville Syrjälä | ec1dc60 | 2015-05-05 17:06:25 +0300 | [diff] [blame] | 300 | if ((val & VIDEO_DIP_ENABLE) == 0) |
| 301 | return false; |
| 302 | |
| 303 | return val & (VIDEO_DIP_ENABLE_AVI | |
| 304 | VIDEO_DIP_ENABLE_VENDOR | VIDEO_DIP_ENABLE_GAMUT | |
| 305 | VIDEO_DIP_ENABLE_SPD | VIDEO_DIP_ENABLE_GCP); |
Jesse Barnes | e43823e | 2014-11-05 14:26:08 -0800 | [diff] [blame] | 306 | } |
| 307 | |
Shobhit Kumar | 90b107c | 2012-03-28 13:39:32 -0700 | [diff] [blame] | 308 | static void vlv_write_infoframe(struct drm_encoder *encoder, |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 309 | const struct intel_crtc_state *crtc_state, |
Damien Lespiau | 178f736 | 2013-08-06 20:32:18 +0100 | [diff] [blame] | 310 | enum hdmi_infoframe_type type, |
Ville Syrjälä | fff6386 | 2013-12-10 15:19:08 +0200 | [diff] [blame] | 311 | const void *frame, ssize_t len) |
Shobhit Kumar | 90b107c | 2012-03-28 13:39:32 -0700 | [diff] [blame] | 312 | { |
Ville Syrjälä | fff6386 | 2013-12-10 15:19:08 +0200 | [diff] [blame] | 313 | const uint32_t *data = frame; |
Shobhit Kumar | 90b107c | 2012-03-28 13:39:32 -0700 | [diff] [blame] | 314 | struct drm_device *dev = encoder->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 315 | struct drm_i915_private *dev_priv = to_i915(dev); |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 316 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc_state->base.crtc); |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 317 | i915_reg_t reg = VLV_TVIDEO_DIP_CTL(intel_crtc->pipe); |
Paulo Zanoni | 22509ec | 2012-05-04 17:18:17 -0300 | [diff] [blame] | 318 | u32 val = I915_READ(reg); |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 319 | int i; |
Shobhit Kumar | 90b107c | 2012-03-28 13:39:32 -0700 | [diff] [blame] | 320 | |
Paulo Zanoni | 822974a | 2012-05-28 16:42:51 -0300 | [diff] [blame] | 321 | WARN(!(val & VIDEO_DIP_ENABLE), "Writing DIP with CTL reg disabled\n"); |
| 322 | |
Shobhit Kumar | 90b107c | 2012-03-28 13:39:32 -0700 | [diff] [blame] | 323 | val &= ~(VIDEO_DIP_SELECT_MASK | 0xf); /* clear DIP data offset */ |
Damien Lespiau | 178f736 | 2013-08-06 20:32:18 +0100 | [diff] [blame] | 324 | val |= g4x_infoframe_index(type); |
Shobhit Kumar | 90b107c | 2012-03-28 13:39:32 -0700 | [diff] [blame] | 325 | |
Damien Lespiau | 178f736 | 2013-08-06 20:32:18 +0100 | [diff] [blame] | 326 | val &= ~g4x_infoframe_enable(type); |
Paulo Zanoni | 22509ec | 2012-05-04 17:18:17 -0300 | [diff] [blame] | 327 | |
| 328 | I915_WRITE(reg, val); |
Shobhit Kumar | 90b107c | 2012-03-28 13:39:32 -0700 | [diff] [blame] | 329 | |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 330 | mmiowb(); |
Shobhit Kumar | 90b107c | 2012-03-28 13:39:32 -0700 | [diff] [blame] | 331 | for (i = 0; i < len; i += 4) { |
| 332 | I915_WRITE(VLV_TVIDEO_DIP_DATA(intel_crtc->pipe), *data); |
| 333 | data++; |
| 334 | } |
Paulo Zanoni | adf00b2 | 2012-09-25 13:23:34 -0300 | [diff] [blame] | 335 | /* Write every possible data byte to force correct ECC calculation. */ |
| 336 | for (; i < VIDEO_DIP_DATA_SIZE; i += 4) |
| 337 | I915_WRITE(VLV_TVIDEO_DIP_DATA(intel_crtc->pipe), 0); |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 338 | mmiowb(); |
Shobhit Kumar | 90b107c | 2012-03-28 13:39:32 -0700 | [diff] [blame] | 339 | |
Damien Lespiau | 178f736 | 2013-08-06 20:32:18 +0100 | [diff] [blame] | 340 | val |= g4x_infoframe_enable(type); |
Paulo Zanoni | 60c5ea2 | 2012-05-04 17:18:22 -0300 | [diff] [blame] | 341 | val &= ~VIDEO_DIP_FREQ_MASK; |
Daniel Vetter | 4b24c93 | 2012-05-08 14:41:00 +0200 | [diff] [blame] | 342 | val |= VIDEO_DIP_FREQ_VSYNC; |
Shobhit Kumar | 90b107c | 2012-03-28 13:39:32 -0700 | [diff] [blame] | 343 | |
Paulo Zanoni | 22509ec | 2012-05-04 17:18:17 -0300 | [diff] [blame] | 344 | I915_WRITE(reg, val); |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 345 | POSTING_READ(reg); |
Shobhit Kumar | 90b107c | 2012-03-28 13:39:32 -0700 | [diff] [blame] | 346 | } |
| 347 | |
Ville Syrjälä | cda0aaa | 2015-11-26 18:27:07 +0200 | [diff] [blame] | 348 | static bool vlv_infoframe_enabled(struct drm_encoder *encoder, |
| 349 | const struct intel_crtc_state *pipe_config) |
Jesse Barnes | e43823e | 2014-11-05 14:26:08 -0800 | [diff] [blame] | 350 | { |
Ville Syrjälä | cda0aaa | 2015-11-26 18:27:07 +0200 | [diff] [blame] | 351 | struct drm_i915_private *dev_priv = to_i915(encoder->dev); |
Jesse Barnes | 535afa2 | 2015-04-15 16:52:29 -0700 | [diff] [blame] | 352 | struct intel_digital_port *intel_dig_port = enc_to_dig_port(encoder); |
Ville Syrjälä | cda0aaa | 2015-11-26 18:27:07 +0200 | [diff] [blame] | 353 | enum pipe pipe = to_intel_crtc(pipe_config->base.crtc)->pipe; |
| 354 | u32 val = I915_READ(VLV_TVIDEO_DIP_CTL(pipe)); |
Jesse Barnes | e43823e | 2014-11-05 14:26:08 -0800 | [diff] [blame] | 355 | |
Ville Syrjälä | ec1dc60 | 2015-05-05 17:06:25 +0300 | [diff] [blame] | 356 | if ((val & VIDEO_DIP_ENABLE) == 0) |
| 357 | return false; |
Jesse Barnes | 535afa2 | 2015-04-15 16:52:29 -0700 | [diff] [blame] | 358 | |
Ville Syrjälä | ec1dc60 | 2015-05-05 17:06:25 +0300 | [diff] [blame] | 359 | if ((val & VIDEO_DIP_PORT_MASK) != VIDEO_DIP_PORT(intel_dig_port->port)) |
| 360 | return false; |
| 361 | |
| 362 | return val & (VIDEO_DIP_ENABLE_AVI | |
| 363 | VIDEO_DIP_ENABLE_VENDOR | VIDEO_DIP_ENABLE_GAMUT | |
| 364 | VIDEO_DIP_ENABLE_SPD | VIDEO_DIP_ENABLE_GCP); |
Jesse Barnes | e43823e | 2014-11-05 14:26:08 -0800 | [diff] [blame] | 365 | } |
| 366 | |
Eugeni Dodonov | 8c5f5f7 | 2012-05-10 10:18:02 -0300 | [diff] [blame] | 367 | static void hsw_write_infoframe(struct drm_encoder *encoder, |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 368 | const struct intel_crtc_state *crtc_state, |
Damien Lespiau | 178f736 | 2013-08-06 20:32:18 +0100 | [diff] [blame] | 369 | enum hdmi_infoframe_type type, |
Ville Syrjälä | fff6386 | 2013-12-10 15:19:08 +0200 | [diff] [blame] | 370 | const void *frame, ssize_t len) |
Eugeni Dodonov | 8c5f5f7 | 2012-05-10 10:18:02 -0300 | [diff] [blame] | 371 | { |
Ville Syrjälä | fff6386 | 2013-12-10 15:19:08 +0200 | [diff] [blame] | 372 | const uint32_t *data = frame; |
Paulo Zanoni | 2da8af5 | 2012-05-14 17:12:51 -0300 | [diff] [blame] | 373 | struct drm_device *dev = encoder->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 374 | struct drm_i915_private *dev_priv = to_i915(dev); |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 375 | enum transcoder cpu_transcoder = crtc_state->cpu_transcoder; |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 376 | i915_reg_t ctl_reg = HSW_TVIDEO_DIP_CTL(cpu_transcoder); |
| 377 | i915_reg_t data_reg; |
Damien Lespiau | 178f736 | 2013-08-06 20:32:18 +0100 | [diff] [blame] | 378 | int i; |
Paulo Zanoni | 2da8af5 | 2012-05-14 17:12:51 -0300 | [diff] [blame] | 379 | u32 val = I915_READ(ctl_reg); |
Eugeni Dodonov | 8c5f5f7 | 2012-05-10 10:18:02 -0300 | [diff] [blame] | 380 | |
Ville Syrjälä | 436c6d4 | 2015-09-18 20:03:37 +0300 | [diff] [blame] | 381 | data_reg = hsw_dip_data_reg(dev_priv, cpu_transcoder, type, 0); |
Eugeni Dodonov | 8c5f5f7 | 2012-05-10 10:18:02 -0300 | [diff] [blame] | 382 | |
Damien Lespiau | 178f736 | 2013-08-06 20:32:18 +0100 | [diff] [blame] | 383 | val &= ~hsw_infoframe_enable(type); |
Paulo Zanoni | 2da8af5 | 2012-05-14 17:12:51 -0300 | [diff] [blame] | 384 | I915_WRITE(ctl_reg, val); |
| 385 | |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 386 | mmiowb(); |
Paulo Zanoni | 2da8af5 | 2012-05-14 17:12:51 -0300 | [diff] [blame] | 387 | for (i = 0; i < len; i += 4) { |
Ville Syrjälä | 436c6d4 | 2015-09-18 20:03:37 +0300 | [diff] [blame] | 388 | I915_WRITE(hsw_dip_data_reg(dev_priv, cpu_transcoder, |
| 389 | type, i >> 2), *data); |
Paulo Zanoni | 2da8af5 | 2012-05-14 17:12:51 -0300 | [diff] [blame] | 390 | data++; |
| 391 | } |
Paulo Zanoni | adf00b2 | 2012-09-25 13:23:34 -0300 | [diff] [blame] | 392 | /* Write every possible data byte to force correct ECC calculation. */ |
| 393 | for (; i < VIDEO_DIP_DATA_SIZE; i += 4) |
Ville Syrjälä | 436c6d4 | 2015-09-18 20:03:37 +0300 | [diff] [blame] | 394 | I915_WRITE(hsw_dip_data_reg(dev_priv, cpu_transcoder, |
| 395 | type, i >> 2), 0); |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 396 | mmiowb(); |
Paulo Zanoni | 2da8af5 | 2012-05-14 17:12:51 -0300 | [diff] [blame] | 397 | |
Damien Lespiau | 178f736 | 2013-08-06 20:32:18 +0100 | [diff] [blame] | 398 | val |= hsw_infoframe_enable(type); |
Paulo Zanoni | 2da8af5 | 2012-05-14 17:12:51 -0300 | [diff] [blame] | 399 | I915_WRITE(ctl_reg, val); |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 400 | POSTING_READ(ctl_reg); |
Eugeni Dodonov | 8c5f5f7 | 2012-05-10 10:18:02 -0300 | [diff] [blame] | 401 | } |
| 402 | |
Ville Syrjälä | cda0aaa | 2015-11-26 18:27:07 +0200 | [diff] [blame] | 403 | static bool hsw_infoframe_enabled(struct drm_encoder *encoder, |
| 404 | const struct intel_crtc_state *pipe_config) |
Jesse Barnes | e43823e | 2014-11-05 14:26:08 -0800 | [diff] [blame] | 405 | { |
Ville Syrjälä | cda0aaa | 2015-11-26 18:27:07 +0200 | [diff] [blame] | 406 | struct drm_i915_private *dev_priv = to_i915(encoder->dev); |
| 407 | u32 val = I915_READ(HSW_TVIDEO_DIP_CTL(pipe_config->cpu_transcoder)); |
Jesse Barnes | e43823e | 2014-11-05 14:26:08 -0800 | [diff] [blame] | 408 | |
Ville Syrjälä | ec1dc60 | 2015-05-05 17:06:25 +0300 | [diff] [blame] | 409 | return val & (VIDEO_DIP_ENABLE_VSC_HSW | VIDEO_DIP_ENABLE_AVI_HSW | |
| 410 | VIDEO_DIP_ENABLE_GCP_HSW | VIDEO_DIP_ENABLE_VS_HSW | |
| 411 | VIDEO_DIP_ENABLE_GMP_HSW | VIDEO_DIP_ENABLE_SPD_HSW); |
Jesse Barnes | e43823e | 2014-11-05 14:26:08 -0800 | [diff] [blame] | 412 | } |
| 413 | |
Damien Lespiau | 5adaea7 | 2013-08-06 20:32:19 +0100 | [diff] [blame] | 414 | /* |
| 415 | * The data we write to the DIP data buffer registers is 1 byte bigger than the |
| 416 | * HDMI infoframe size because of an ECC/reserved byte at position 3 (starting |
| 417 | * at 0). It's also a byte used by DisplayPort so the same DIP registers can be |
| 418 | * used for both technologies. |
| 419 | * |
| 420 | * DW0: Reserved/ECC/DP | HB2 | HB1 | HB0 |
| 421 | * DW1: DB3 | DB2 | DB1 | DB0 |
| 422 | * DW2: DB7 | DB6 | DB5 | DB4 |
| 423 | * DW3: ... |
| 424 | * |
| 425 | * (HB is Header Byte, DB is Data Byte) |
| 426 | * |
| 427 | * The hdmi pack() functions don't know about that hardware specific hole so we |
| 428 | * trick them by giving an offset into the buffer and moving back the header |
| 429 | * bytes by one. |
| 430 | */ |
Damien Lespiau | 9198ee5 | 2013-08-06 20:32:24 +0100 | [diff] [blame] | 431 | static void intel_write_infoframe(struct drm_encoder *encoder, |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 432 | const struct intel_crtc_state *crtc_state, |
Damien Lespiau | 9198ee5 | 2013-08-06 20:32:24 +0100 | [diff] [blame] | 433 | union hdmi_infoframe *frame) |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 434 | { |
| 435 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder); |
Damien Lespiau | 5adaea7 | 2013-08-06 20:32:19 +0100 | [diff] [blame] | 436 | uint8_t buffer[VIDEO_DIP_DATA_SIZE]; |
| 437 | ssize_t len; |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 438 | |
Damien Lespiau | 5adaea7 | 2013-08-06 20:32:19 +0100 | [diff] [blame] | 439 | /* see comment above for the reason for this offset */ |
| 440 | len = hdmi_infoframe_pack(frame, buffer + 1, sizeof(buffer) - 1); |
| 441 | if (len < 0) |
| 442 | return; |
| 443 | |
| 444 | /* Insert the 'hole' (see big comment above) at position 3 */ |
| 445 | buffer[0] = buffer[1]; |
| 446 | buffer[1] = buffer[2]; |
| 447 | buffer[2] = buffer[3]; |
| 448 | buffer[3] = 0; |
| 449 | len++; |
| 450 | |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 451 | intel_hdmi->write_infoframe(encoder, crtc_state, frame->any.type, buffer, len); |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 452 | } |
| 453 | |
Paulo Zanoni | 687f4d0 | 2012-05-28 16:42:48 -0300 | [diff] [blame] | 454 | static void intel_hdmi_set_avi_infoframe(struct drm_encoder *encoder, |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 455 | const struct intel_crtc_state *crtc_state) |
Jesse Barnes | b055c8f | 2011-07-08 11:31:57 -0700 | [diff] [blame] | 456 | { |
Ville Syrjälä | abedc07 | 2013-01-17 16:31:31 +0200 | [diff] [blame] | 457 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder); |
Ville Syrjälä | 779c4c2 | 2017-01-11 14:57:24 +0200 | [diff] [blame] | 458 | const struct drm_display_mode *adjusted_mode = |
| 459 | &crtc_state->base.adjusted_mode; |
Damien Lespiau | 5adaea7 | 2013-08-06 20:32:19 +0100 | [diff] [blame] | 460 | union hdmi_infoframe frame; |
| 461 | int ret; |
Jesse Barnes | b055c8f | 2011-07-08 11:31:57 -0700 | [diff] [blame] | 462 | |
Damien Lespiau | 5adaea7 | 2013-08-06 20:32:19 +0100 | [diff] [blame] | 463 | ret = drm_hdmi_avi_infoframe_from_display_mode(&frame.avi, |
Ville Syrjälä | 779c4c2 | 2017-01-11 14:57:24 +0200 | [diff] [blame] | 464 | adjusted_mode); |
Damien Lespiau | 5adaea7 | 2013-08-06 20:32:19 +0100 | [diff] [blame] | 465 | if (ret < 0) { |
| 466 | DRM_ERROR("couldn't fill AVI infoframe\n"); |
| 467 | return; |
| 468 | } |
Paulo Zanoni | c846b61 | 2012-04-13 16:31:41 -0300 | [diff] [blame] | 469 | |
Ville Syrjälä | 779c4c2 | 2017-01-11 14:57:24 +0200 | [diff] [blame] | 470 | drm_hdmi_avi_infoframe_quant_range(&frame.avi, adjusted_mode, |
Ville Syrjälä | a2ce26f | 2017-01-11 14:57:23 +0200 | [diff] [blame] | 471 | crtc_state->limited_color_range ? |
| 472 | HDMI_QUANTIZATION_RANGE_LIMITED : |
| 473 | HDMI_QUANTIZATION_RANGE_FULL, |
| 474 | intel_hdmi->rgb_quant_range_selectable); |
Ville Syrjälä | abedc07 | 2013-01-17 16:31:31 +0200 | [diff] [blame] | 475 | |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 476 | intel_write_infoframe(encoder, crtc_state, &frame); |
Jesse Barnes | b055c8f | 2011-07-08 11:31:57 -0700 | [diff] [blame] | 477 | } |
| 478 | |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 479 | static void intel_hdmi_set_spd_infoframe(struct drm_encoder *encoder, |
| 480 | const struct intel_crtc_state *crtc_state) |
Jesse Barnes | c0864cb | 2011-08-03 09:22:56 -0700 | [diff] [blame] | 481 | { |
Damien Lespiau | 5adaea7 | 2013-08-06 20:32:19 +0100 | [diff] [blame] | 482 | union hdmi_infoframe frame; |
| 483 | int ret; |
Jesse Barnes | c0864cb | 2011-08-03 09:22:56 -0700 | [diff] [blame] | 484 | |
Damien Lespiau | 5adaea7 | 2013-08-06 20:32:19 +0100 | [diff] [blame] | 485 | ret = hdmi_spd_infoframe_init(&frame.spd, "Intel", "Integrated gfx"); |
| 486 | if (ret < 0) { |
| 487 | DRM_ERROR("couldn't fill SPD infoframe\n"); |
| 488 | return; |
| 489 | } |
Jesse Barnes | c0864cb | 2011-08-03 09:22:56 -0700 | [diff] [blame] | 490 | |
Damien Lespiau | 5adaea7 | 2013-08-06 20:32:19 +0100 | [diff] [blame] | 491 | frame.spd.sdi = HDMI_SPD_SDI_PC; |
| 492 | |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 493 | intel_write_infoframe(encoder, crtc_state, &frame); |
Jesse Barnes | c0864cb | 2011-08-03 09:22:56 -0700 | [diff] [blame] | 494 | } |
| 495 | |
Lespiau, Damien | c8bb75a | 2013-08-19 16:59:04 +0100 | [diff] [blame] | 496 | static void |
| 497 | intel_hdmi_set_hdmi_infoframe(struct drm_encoder *encoder, |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 498 | const struct intel_crtc_state *crtc_state) |
Lespiau, Damien | c8bb75a | 2013-08-19 16:59:04 +0100 | [diff] [blame] | 499 | { |
| 500 | union hdmi_infoframe frame; |
| 501 | int ret; |
| 502 | |
| 503 | ret = drm_hdmi_vendor_infoframe_from_display_mode(&frame.vendor.hdmi, |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 504 | &crtc_state->base.adjusted_mode); |
Lespiau, Damien | c8bb75a | 2013-08-19 16:59:04 +0100 | [diff] [blame] | 505 | if (ret < 0) |
| 506 | return; |
| 507 | |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 508 | intel_write_infoframe(encoder, crtc_state, &frame); |
Lespiau, Damien | c8bb75a | 2013-08-19 16:59:04 +0100 | [diff] [blame] | 509 | } |
| 510 | |
Paulo Zanoni | 687f4d0 | 2012-05-28 16:42:48 -0300 | [diff] [blame] | 511 | static void g4x_set_infoframes(struct drm_encoder *encoder, |
Daniel Vetter | 6897b4b5 | 2014-04-24 23:54:47 +0200 | [diff] [blame] | 512 | bool enable, |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 513 | const struct intel_crtc_state *crtc_state, |
| 514 | const struct drm_connector_state *conn_state) |
Paulo Zanoni | 687f4d0 | 2012-05-28 16:42:48 -0300 | [diff] [blame] | 515 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 516 | struct drm_i915_private *dev_priv = to_i915(encoder->dev); |
Ville Syrjälä | 69fde0a | 2013-01-24 15:29:26 +0200 | [diff] [blame] | 517 | struct intel_digital_port *intel_dig_port = enc_to_dig_port(encoder); |
| 518 | struct intel_hdmi *intel_hdmi = &intel_dig_port->hdmi; |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 519 | i915_reg_t reg = VIDEO_DIP_CTL; |
Paulo Zanoni | 0c14c7f | 2012-05-28 16:42:49 -0300 | [diff] [blame] | 520 | u32 val = I915_READ(reg); |
Ville Syrjälä | 822cdc5 | 2014-01-23 23:15:34 +0200 | [diff] [blame] | 521 | u32 port = VIDEO_DIP_PORT(intel_dig_port->port); |
Paulo Zanoni | 0c14c7f | 2012-05-28 16:42:49 -0300 | [diff] [blame] | 522 | |
Daniel Vetter | afba018 | 2012-06-12 16:36:45 +0200 | [diff] [blame] | 523 | assert_hdmi_port_disabled(intel_hdmi); |
| 524 | |
Paulo Zanoni | 0c14c7f | 2012-05-28 16:42:49 -0300 | [diff] [blame] | 525 | /* If the registers were not initialized yet, they might be zeroes, |
| 526 | * which means we're selecting the AVI DIP and we're setting its |
| 527 | * frequency to once. This seems to really confuse the HW and make |
| 528 | * things stop working (the register spec says the AVI always needs to |
| 529 | * be sent every VSync). So here we avoid writing to the register more |
| 530 | * than we need and also explicitly select the AVI DIP and explicitly |
| 531 | * set its frequency to every VSync. Avoiding to write it twice seems to |
| 532 | * be enough to solve the problem, but being defensive shouldn't hurt us |
| 533 | * either. */ |
| 534 | val |= VIDEO_DIP_SELECT_AVI | VIDEO_DIP_FREQ_VSYNC; |
| 535 | |
Daniel Vetter | 6897b4b5 | 2014-04-24 23:54:47 +0200 | [diff] [blame] | 536 | if (!enable) { |
Paulo Zanoni | 0c14c7f | 2012-05-28 16:42:49 -0300 | [diff] [blame] | 537 | if (!(val & VIDEO_DIP_ENABLE)) |
| 538 | return; |
Ville Syrjälä | 0be6f0c | 2015-05-05 17:06:24 +0300 | [diff] [blame] | 539 | if (port != (val & VIDEO_DIP_PORT_MASK)) { |
| 540 | DRM_DEBUG_KMS("video DIP still enabled on port %c\n", |
| 541 | (val & VIDEO_DIP_PORT_MASK) >> 29); |
| 542 | return; |
| 543 | } |
| 544 | val &= ~(VIDEO_DIP_ENABLE | VIDEO_DIP_ENABLE_AVI | |
| 545 | VIDEO_DIP_ENABLE_VENDOR | VIDEO_DIP_ENABLE_SPD); |
Paulo Zanoni | 0c14c7f | 2012-05-28 16:42:49 -0300 | [diff] [blame] | 546 | I915_WRITE(reg, val); |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 547 | POSTING_READ(reg); |
Paulo Zanoni | 0c14c7f | 2012-05-28 16:42:49 -0300 | [diff] [blame] | 548 | return; |
| 549 | } |
| 550 | |
Paulo Zanoni | 72b78c9 | 2012-05-28 16:42:54 -0300 | [diff] [blame] | 551 | if (port != (val & VIDEO_DIP_PORT_MASK)) { |
| 552 | if (val & VIDEO_DIP_ENABLE) { |
Ville Syrjälä | 0be6f0c | 2015-05-05 17:06:24 +0300 | [diff] [blame] | 553 | DRM_DEBUG_KMS("video DIP already enabled on port %c\n", |
| 554 | (val & VIDEO_DIP_PORT_MASK) >> 29); |
| 555 | return; |
Paulo Zanoni | 72b78c9 | 2012-05-28 16:42:54 -0300 | [diff] [blame] | 556 | } |
| 557 | val &= ~VIDEO_DIP_PORT_MASK; |
| 558 | val |= port; |
| 559 | } |
| 560 | |
Paulo Zanoni | 822974a | 2012-05-28 16:42:51 -0300 | [diff] [blame] | 561 | val |= VIDEO_DIP_ENABLE; |
Ville Syrjälä | 0be6f0c | 2015-05-05 17:06:24 +0300 | [diff] [blame] | 562 | val &= ~(VIDEO_DIP_ENABLE_AVI | |
| 563 | VIDEO_DIP_ENABLE_VENDOR | VIDEO_DIP_ENABLE_SPD); |
Paulo Zanoni | 822974a | 2012-05-28 16:42:51 -0300 | [diff] [blame] | 564 | |
Paulo Zanoni | f278d97 | 2012-05-28 16:42:50 -0300 | [diff] [blame] | 565 | I915_WRITE(reg, val); |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 566 | POSTING_READ(reg); |
Paulo Zanoni | f278d97 | 2012-05-28 16:42:50 -0300 | [diff] [blame] | 567 | |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 568 | intel_hdmi_set_avi_infoframe(encoder, crtc_state); |
| 569 | intel_hdmi_set_spd_infoframe(encoder, crtc_state); |
| 570 | intel_hdmi_set_hdmi_infoframe(encoder, crtc_state); |
Paulo Zanoni | 687f4d0 | 2012-05-28 16:42:48 -0300 | [diff] [blame] | 571 | } |
| 572 | |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 573 | static bool hdmi_sink_is_deep_color(const struct drm_connector_state *conn_state) |
Ville Syrjälä | 6d67415 | 2015-05-05 17:06:20 +0300 | [diff] [blame] | 574 | { |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 575 | struct drm_connector *connector = conn_state->connector; |
Ville Syrjälä | 6d67415 | 2015-05-05 17:06:20 +0300 | [diff] [blame] | 576 | |
| 577 | /* |
| 578 | * HDMI cloning is only supported on g4x which doesn't |
| 579 | * support deep color or GCP infoframes anyway so no |
| 580 | * need to worry about multiple HDMI sinks here. |
| 581 | */ |
Ville Syrjälä | 6d67415 | 2015-05-05 17:06:20 +0300 | [diff] [blame] | 582 | |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 583 | return connector->display_info.bpc > 8; |
Ville Syrjälä | 6d67415 | 2015-05-05 17:06:20 +0300 | [diff] [blame] | 584 | } |
| 585 | |
Ville Syrjälä | 12aa329 | 2015-05-05 17:06:21 +0300 | [diff] [blame] | 586 | /* |
| 587 | * Determine if default_phase=1 can be indicated in the GCP infoframe. |
| 588 | * |
| 589 | * From HDMI specification 1.4a: |
| 590 | * - The first pixel of each Video Data Period shall always have a pixel packing phase of 0 |
| 591 | * - The first pixel following each Video Data Period shall have a pixel packing phase of 0 |
| 592 | * - The PP bits shall be constant for all GCPs and will be equal to the last packing phase |
| 593 | * - The first pixel following every transition of HSYNC or VSYNC shall have a pixel packing |
| 594 | * phase of 0 |
| 595 | */ |
| 596 | static bool gcp_default_phase_possible(int pipe_bpp, |
| 597 | const struct drm_display_mode *mode) |
| 598 | { |
| 599 | unsigned int pixels_per_group; |
| 600 | |
| 601 | switch (pipe_bpp) { |
| 602 | case 30: |
| 603 | /* 4 pixels in 5 clocks */ |
| 604 | pixels_per_group = 4; |
| 605 | break; |
| 606 | case 36: |
| 607 | /* 2 pixels in 3 clocks */ |
| 608 | pixels_per_group = 2; |
| 609 | break; |
| 610 | case 48: |
| 611 | /* 1 pixel in 2 clocks */ |
| 612 | pixels_per_group = 1; |
| 613 | break; |
| 614 | default: |
| 615 | /* phase information not relevant for 8bpc */ |
| 616 | return false; |
| 617 | } |
| 618 | |
| 619 | return mode->crtc_hdisplay % pixels_per_group == 0 && |
| 620 | mode->crtc_htotal % pixels_per_group == 0 && |
| 621 | mode->crtc_hblank_start % pixels_per_group == 0 && |
| 622 | mode->crtc_hblank_end % pixels_per_group == 0 && |
| 623 | mode->crtc_hsync_start % pixels_per_group == 0 && |
| 624 | mode->crtc_hsync_end % pixels_per_group == 0 && |
| 625 | ((mode->flags & DRM_MODE_FLAG_INTERLACE) == 0 || |
| 626 | mode->crtc_htotal/2 % pixels_per_group == 0); |
| 627 | } |
| 628 | |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 629 | static bool intel_hdmi_set_gcp_infoframe(struct drm_encoder *encoder, |
| 630 | const struct intel_crtc_state *crtc_state, |
| 631 | const struct drm_connector_state *conn_state) |
Ville Syrjälä | 6d67415 | 2015-05-05 17:06:20 +0300 | [diff] [blame] | 632 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 633 | struct drm_i915_private *dev_priv = to_i915(encoder->dev); |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 634 | struct intel_crtc *crtc = to_intel_crtc(crtc_state->base.crtc); |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 635 | i915_reg_t reg; |
| 636 | u32 val = 0; |
Ville Syrjälä | 6d67415 | 2015-05-05 17:06:20 +0300 | [diff] [blame] | 637 | |
| 638 | if (HAS_DDI(dev_priv)) |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 639 | reg = HSW_TVIDEO_DIP_GCP(crtc_state->cpu_transcoder); |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 640 | else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) |
Ville Syrjälä | 6d67415 | 2015-05-05 17:06:20 +0300 | [diff] [blame] | 641 | reg = VLV_TVIDEO_DIP_GCP(crtc->pipe); |
Joonas Lahtinen | 2d1fe07 | 2016-04-07 11:08:05 +0300 | [diff] [blame] | 642 | else if (HAS_PCH_SPLIT(dev_priv)) |
Ville Syrjälä | 6d67415 | 2015-05-05 17:06:20 +0300 | [diff] [blame] | 643 | reg = TVIDEO_DIP_GCP(crtc->pipe); |
| 644 | else |
| 645 | return false; |
| 646 | |
| 647 | /* Indicate color depth whenever the sink supports deep color */ |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 648 | if (hdmi_sink_is_deep_color(conn_state)) |
Ville Syrjälä | 6d67415 | 2015-05-05 17:06:20 +0300 | [diff] [blame] | 649 | val |= GCP_COLOR_INDICATION; |
| 650 | |
Ville Syrjälä | 12aa329 | 2015-05-05 17:06:21 +0300 | [diff] [blame] | 651 | /* Enable default_phase whenever the display mode is suitably aligned */ |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 652 | if (gcp_default_phase_possible(crtc_state->pipe_bpp, |
| 653 | &crtc_state->base.adjusted_mode)) |
Ville Syrjälä | 12aa329 | 2015-05-05 17:06:21 +0300 | [diff] [blame] | 654 | val |= GCP_DEFAULT_PHASE_ENABLE; |
| 655 | |
Ville Syrjälä | 6d67415 | 2015-05-05 17:06:20 +0300 | [diff] [blame] | 656 | I915_WRITE(reg, val); |
| 657 | |
| 658 | return val != 0; |
| 659 | } |
| 660 | |
Paulo Zanoni | 687f4d0 | 2012-05-28 16:42:48 -0300 | [diff] [blame] | 661 | static void ibx_set_infoframes(struct drm_encoder *encoder, |
Daniel Vetter | 6897b4b5 | 2014-04-24 23:54:47 +0200 | [diff] [blame] | 662 | bool enable, |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 663 | const struct intel_crtc_state *crtc_state, |
| 664 | const struct drm_connector_state *conn_state) |
Paulo Zanoni | 687f4d0 | 2012-05-28 16:42:48 -0300 | [diff] [blame] | 665 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 666 | struct drm_i915_private *dev_priv = to_i915(encoder->dev); |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 667 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc_state->base.crtc); |
Ville Syrjälä | 69fde0a | 2013-01-24 15:29:26 +0200 | [diff] [blame] | 668 | struct intel_digital_port *intel_dig_port = enc_to_dig_port(encoder); |
| 669 | struct intel_hdmi *intel_hdmi = &intel_dig_port->hdmi; |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 670 | i915_reg_t reg = TVIDEO_DIP_CTL(intel_crtc->pipe); |
Paulo Zanoni | 0c14c7f | 2012-05-28 16:42:49 -0300 | [diff] [blame] | 671 | u32 val = I915_READ(reg); |
Ville Syrjälä | 822cdc5 | 2014-01-23 23:15:34 +0200 | [diff] [blame] | 672 | u32 port = VIDEO_DIP_PORT(intel_dig_port->port); |
Paulo Zanoni | 0c14c7f | 2012-05-28 16:42:49 -0300 | [diff] [blame] | 673 | |
Daniel Vetter | afba018 | 2012-06-12 16:36:45 +0200 | [diff] [blame] | 674 | assert_hdmi_port_disabled(intel_hdmi); |
| 675 | |
Paulo Zanoni | 0c14c7f | 2012-05-28 16:42:49 -0300 | [diff] [blame] | 676 | /* See the big comment in g4x_set_infoframes() */ |
| 677 | val |= VIDEO_DIP_SELECT_AVI | VIDEO_DIP_FREQ_VSYNC; |
| 678 | |
Daniel Vetter | 6897b4b5 | 2014-04-24 23:54:47 +0200 | [diff] [blame] | 679 | if (!enable) { |
Paulo Zanoni | 0c14c7f | 2012-05-28 16:42:49 -0300 | [diff] [blame] | 680 | if (!(val & VIDEO_DIP_ENABLE)) |
| 681 | return; |
Ville Syrjälä | 0be6f0c | 2015-05-05 17:06:24 +0300 | [diff] [blame] | 682 | val &= ~(VIDEO_DIP_ENABLE | VIDEO_DIP_ENABLE_AVI | |
| 683 | VIDEO_DIP_ENABLE_VENDOR | VIDEO_DIP_ENABLE_GAMUT | |
| 684 | VIDEO_DIP_ENABLE_SPD | VIDEO_DIP_ENABLE_GCP); |
Paulo Zanoni | 0c14c7f | 2012-05-28 16:42:49 -0300 | [diff] [blame] | 685 | I915_WRITE(reg, val); |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 686 | POSTING_READ(reg); |
Paulo Zanoni | 0c14c7f | 2012-05-28 16:42:49 -0300 | [diff] [blame] | 687 | return; |
| 688 | } |
| 689 | |
Paulo Zanoni | 72b78c9 | 2012-05-28 16:42:54 -0300 | [diff] [blame] | 690 | if (port != (val & VIDEO_DIP_PORT_MASK)) { |
Ville Syrjälä | 0be6f0c | 2015-05-05 17:06:24 +0300 | [diff] [blame] | 691 | WARN(val & VIDEO_DIP_ENABLE, |
| 692 | "DIP already enabled on port %c\n", |
| 693 | (val & VIDEO_DIP_PORT_MASK) >> 29); |
Paulo Zanoni | 72b78c9 | 2012-05-28 16:42:54 -0300 | [diff] [blame] | 694 | val &= ~VIDEO_DIP_PORT_MASK; |
| 695 | val |= port; |
| 696 | } |
| 697 | |
Paulo Zanoni | 822974a | 2012-05-28 16:42:51 -0300 | [diff] [blame] | 698 | val |= VIDEO_DIP_ENABLE; |
Ville Syrjälä | 0be6f0c | 2015-05-05 17:06:24 +0300 | [diff] [blame] | 699 | val &= ~(VIDEO_DIP_ENABLE_AVI | |
| 700 | VIDEO_DIP_ENABLE_VENDOR | VIDEO_DIP_ENABLE_GAMUT | |
| 701 | VIDEO_DIP_ENABLE_SPD | VIDEO_DIP_ENABLE_GCP); |
Paulo Zanoni | 822974a | 2012-05-28 16:42:51 -0300 | [diff] [blame] | 702 | |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 703 | if (intel_hdmi_set_gcp_infoframe(encoder, crtc_state, conn_state)) |
Ville Syrjälä | 6d67415 | 2015-05-05 17:06:20 +0300 | [diff] [blame] | 704 | val |= VIDEO_DIP_ENABLE_GCP; |
| 705 | |
Paulo Zanoni | f278d97 | 2012-05-28 16:42:50 -0300 | [diff] [blame] | 706 | I915_WRITE(reg, val); |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 707 | POSTING_READ(reg); |
Paulo Zanoni | f278d97 | 2012-05-28 16:42:50 -0300 | [diff] [blame] | 708 | |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 709 | intel_hdmi_set_avi_infoframe(encoder, crtc_state); |
| 710 | intel_hdmi_set_spd_infoframe(encoder, crtc_state); |
| 711 | intel_hdmi_set_hdmi_infoframe(encoder, crtc_state); |
Paulo Zanoni | 687f4d0 | 2012-05-28 16:42:48 -0300 | [diff] [blame] | 712 | } |
| 713 | |
| 714 | static void cpt_set_infoframes(struct drm_encoder *encoder, |
Daniel Vetter | 6897b4b5 | 2014-04-24 23:54:47 +0200 | [diff] [blame] | 715 | bool enable, |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 716 | const struct intel_crtc_state *crtc_state, |
| 717 | const struct drm_connector_state *conn_state) |
Paulo Zanoni | 687f4d0 | 2012-05-28 16:42:48 -0300 | [diff] [blame] | 718 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 719 | struct drm_i915_private *dev_priv = to_i915(encoder->dev); |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 720 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc_state->base.crtc); |
Paulo Zanoni | 0c14c7f | 2012-05-28 16:42:49 -0300 | [diff] [blame] | 721 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder); |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 722 | i915_reg_t reg = TVIDEO_DIP_CTL(intel_crtc->pipe); |
Paulo Zanoni | 0c14c7f | 2012-05-28 16:42:49 -0300 | [diff] [blame] | 723 | u32 val = I915_READ(reg); |
| 724 | |
Daniel Vetter | afba018 | 2012-06-12 16:36:45 +0200 | [diff] [blame] | 725 | assert_hdmi_port_disabled(intel_hdmi); |
| 726 | |
Paulo Zanoni | 0c14c7f | 2012-05-28 16:42:49 -0300 | [diff] [blame] | 727 | /* See the big comment in g4x_set_infoframes() */ |
| 728 | val |= VIDEO_DIP_SELECT_AVI | VIDEO_DIP_FREQ_VSYNC; |
| 729 | |
Daniel Vetter | 6897b4b5 | 2014-04-24 23:54:47 +0200 | [diff] [blame] | 730 | if (!enable) { |
Paulo Zanoni | 0c14c7f | 2012-05-28 16:42:49 -0300 | [diff] [blame] | 731 | if (!(val & VIDEO_DIP_ENABLE)) |
| 732 | return; |
Ville Syrjälä | 0be6f0c | 2015-05-05 17:06:24 +0300 | [diff] [blame] | 733 | val &= ~(VIDEO_DIP_ENABLE | VIDEO_DIP_ENABLE_AVI | |
| 734 | VIDEO_DIP_ENABLE_VENDOR | VIDEO_DIP_ENABLE_GAMUT | |
| 735 | VIDEO_DIP_ENABLE_SPD | VIDEO_DIP_ENABLE_GCP); |
Paulo Zanoni | 0c14c7f | 2012-05-28 16:42:49 -0300 | [diff] [blame] | 736 | I915_WRITE(reg, val); |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 737 | POSTING_READ(reg); |
Paulo Zanoni | 0c14c7f | 2012-05-28 16:42:49 -0300 | [diff] [blame] | 738 | return; |
| 739 | } |
| 740 | |
Paulo Zanoni | 822974a | 2012-05-28 16:42:51 -0300 | [diff] [blame] | 741 | /* Set both together, unset both together: see the spec. */ |
| 742 | val |= VIDEO_DIP_ENABLE | VIDEO_DIP_ENABLE_AVI; |
Paulo Zanoni | 0dd87d2 | 2012-05-28 16:42:53 -0300 | [diff] [blame] | 743 | val &= ~(VIDEO_DIP_ENABLE_VENDOR | VIDEO_DIP_ENABLE_GAMUT | |
Ville Syrjälä | 0be6f0c | 2015-05-05 17:06:24 +0300 | [diff] [blame] | 744 | VIDEO_DIP_ENABLE_SPD | VIDEO_DIP_ENABLE_GCP); |
Paulo Zanoni | 822974a | 2012-05-28 16:42:51 -0300 | [diff] [blame] | 745 | |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 746 | if (intel_hdmi_set_gcp_infoframe(encoder, crtc_state, conn_state)) |
Ville Syrjälä | 6d67415 | 2015-05-05 17:06:20 +0300 | [diff] [blame] | 747 | val |= VIDEO_DIP_ENABLE_GCP; |
| 748 | |
Paulo Zanoni | 822974a | 2012-05-28 16:42:51 -0300 | [diff] [blame] | 749 | I915_WRITE(reg, val); |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 750 | POSTING_READ(reg); |
Paulo Zanoni | 822974a | 2012-05-28 16:42:51 -0300 | [diff] [blame] | 751 | |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 752 | intel_hdmi_set_avi_infoframe(encoder, crtc_state); |
| 753 | intel_hdmi_set_spd_infoframe(encoder, crtc_state); |
| 754 | intel_hdmi_set_hdmi_infoframe(encoder, crtc_state); |
Paulo Zanoni | 687f4d0 | 2012-05-28 16:42:48 -0300 | [diff] [blame] | 755 | } |
| 756 | |
| 757 | static void vlv_set_infoframes(struct drm_encoder *encoder, |
Daniel Vetter | 6897b4b5 | 2014-04-24 23:54:47 +0200 | [diff] [blame] | 758 | bool enable, |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 759 | const struct intel_crtc_state *crtc_state, |
| 760 | const struct drm_connector_state *conn_state) |
Paulo Zanoni | 687f4d0 | 2012-05-28 16:42:48 -0300 | [diff] [blame] | 761 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 762 | struct drm_i915_private *dev_priv = to_i915(encoder->dev); |
Jesse Barnes | 6a2b802 | 2014-04-02 10:08:51 -0700 | [diff] [blame] | 763 | struct intel_digital_port *intel_dig_port = enc_to_dig_port(encoder); |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 764 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc_state->base.crtc); |
Paulo Zanoni | 0c14c7f | 2012-05-28 16:42:49 -0300 | [diff] [blame] | 765 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder); |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 766 | i915_reg_t reg = VLV_TVIDEO_DIP_CTL(intel_crtc->pipe); |
Paulo Zanoni | 0c14c7f | 2012-05-28 16:42:49 -0300 | [diff] [blame] | 767 | u32 val = I915_READ(reg); |
Jesse Barnes | 6a2b802 | 2014-04-02 10:08:51 -0700 | [diff] [blame] | 768 | u32 port = VIDEO_DIP_PORT(intel_dig_port->port); |
Paulo Zanoni | 0c14c7f | 2012-05-28 16:42:49 -0300 | [diff] [blame] | 769 | |
Daniel Vetter | afba018 | 2012-06-12 16:36:45 +0200 | [diff] [blame] | 770 | assert_hdmi_port_disabled(intel_hdmi); |
| 771 | |
Paulo Zanoni | 0c14c7f | 2012-05-28 16:42:49 -0300 | [diff] [blame] | 772 | /* See the big comment in g4x_set_infoframes() */ |
| 773 | val |= VIDEO_DIP_SELECT_AVI | VIDEO_DIP_FREQ_VSYNC; |
| 774 | |
Daniel Vetter | 6897b4b5 | 2014-04-24 23:54:47 +0200 | [diff] [blame] | 775 | if (!enable) { |
Paulo Zanoni | 0c14c7f | 2012-05-28 16:42:49 -0300 | [diff] [blame] | 776 | if (!(val & VIDEO_DIP_ENABLE)) |
| 777 | return; |
Ville Syrjälä | 0be6f0c | 2015-05-05 17:06:24 +0300 | [diff] [blame] | 778 | val &= ~(VIDEO_DIP_ENABLE | VIDEO_DIP_ENABLE_AVI | |
| 779 | VIDEO_DIP_ENABLE_VENDOR | VIDEO_DIP_ENABLE_GAMUT | |
| 780 | VIDEO_DIP_ENABLE_SPD | VIDEO_DIP_ENABLE_GCP); |
Paulo Zanoni | 0c14c7f | 2012-05-28 16:42:49 -0300 | [diff] [blame] | 781 | I915_WRITE(reg, val); |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 782 | POSTING_READ(reg); |
Paulo Zanoni | 0c14c7f | 2012-05-28 16:42:49 -0300 | [diff] [blame] | 783 | return; |
| 784 | } |
| 785 | |
Jesse Barnes | 6a2b802 | 2014-04-02 10:08:51 -0700 | [diff] [blame] | 786 | if (port != (val & VIDEO_DIP_PORT_MASK)) { |
Ville Syrjälä | 0be6f0c | 2015-05-05 17:06:24 +0300 | [diff] [blame] | 787 | WARN(val & VIDEO_DIP_ENABLE, |
| 788 | "DIP already enabled on port %c\n", |
| 789 | (val & VIDEO_DIP_PORT_MASK) >> 29); |
Jesse Barnes | 6a2b802 | 2014-04-02 10:08:51 -0700 | [diff] [blame] | 790 | val &= ~VIDEO_DIP_PORT_MASK; |
| 791 | val |= port; |
| 792 | } |
| 793 | |
Paulo Zanoni | 822974a | 2012-05-28 16:42:51 -0300 | [diff] [blame] | 794 | val |= VIDEO_DIP_ENABLE; |
Ville Syrjälä | 0be6f0c | 2015-05-05 17:06:24 +0300 | [diff] [blame] | 795 | val &= ~(VIDEO_DIP_ENABLE_AVI | |
| 796 | VIDEO_DIP_ENABLE_VENDOR | VIDEO_DIP_ENABLE_GAMUT | |
| 797 | VIDEO_DIP_ENABLE_SPD | VIDEO_DIP_ENABLE_GCP); |
Paulo Zanoni | 822974a | 2012-05-28 16:42:51 -0300 | [diff] [blame] | 798 | |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 799 | if (intel_hdmi_set_gcp_infoframe(encoder, crtc_state, conn_state)) |
Ville Syrjälä | 6d67415 | 2015-05-05 17:06:20 +0300 | [diff] [blame] | 800 | val |= VIDEO_DIP_ENABLE_GCP; |
| 801 | |
Paulo Zanoni | 822974a | 2012-05-28 16:42:51 -0300 | [diff] [blame] | 802 | I915_WRITE(reg, val); |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 803 | POSTING_READ(reg); |
Paulo Zanoni | 822974a | 2012-05-28 16:42:51 -0300 | [diff] [blame] | 804 | |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 805 | intel_hdmi_set_avi_infoframe(encoder, crtc_state); |
| 806 | intel_hdmi_set_spd_infoframe(encoder, crtc_state); |
| 807 | intel_hdmi_set_hdmi_infoframe(encoder, crtc_state); |
Paulo Zanoni | 687f4d0 | 2012-05-28 16:42:48 -0300 | [diff] [blame] | 808 | } |
| 809 | |
| 810 | static void hsw_set_infoframes(struct drm_encoder *encoder, |
Daniel Vetter | 6897b4b5 | 2014-04-24 23:54:47 +0200 | [diff] [blame] | 811 | bool enable, |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 812 | const struct intel_crtc_state *crtc_state, |
| 813 | const struct drm_connector_state *conn_state) |
Paulo Zanoni | 687f4d0 | 2012-05-28 16:42:48 -0300 | [diff] [blame] | 814 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 815 | struct drm_i915_private *dev_priv = to_i915(encoder->dev); |
Paulo Zanoni | 0c14c7f | 2012-05-28 16:42:49 -0300 | [diff] [blame] | 816 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder); |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 817 | i915_reg_t reg = HSW_TVIDEO_DIP_CTL(crtc_state->cpu_transcoder); |
Paulo Zanoni | 0dd87d2 | 2012-05-28 16:42:53 -0300 | [diff] [blame] | 818 | u32 val = I915_READ(reg); |
Paulo Zanoni | 0c14c7f | 2012-05-28 16:42:49 -0300 | [diff] [blame] | 819 | |
Daniel Vetter | afba018 | 2012-06-12 16:36:45 +0200 | [diff] [blame] | 820 | assert_hdmi_port_disabled(intel_hdmi); |
| 821 | |
Ville Syrjälä | 0be6f0c | 2015-05-05 17:06:24 +0300 | [diff] [blame] | 822 | val &= ~(VIDEO_DIP_ENABLE_VSC_HSW | VIDEO_DIP_ENABLE_AVI_HSW | |
| 823 | VIDEO_DIP_ENABLE_GCP_HSW | VIDEO_DIP_ENABLE_VS_HSW | |
| 824 | VIDEO_DIP_ENABLE_GMP_HSW | VIDEO_DIP_ENABLE_SPD_HSW); |
| 825 | |
Daniel Vetter | 6897b4b5 | 2014-04-24 23:54:47 +0200 | [diff] [blame] | 826 | if (!enable) { |
Ville Syrjälä | 0be6f0c | 2015-05-05 17:06:24 +0300 | [diff] [blame] | 827 | I915_WRITE(reg, val); |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 828 | POSTING_READ(reg); |
Paulo Zanoni | 0c14c7f | 2012-05-28 16:42:49 -0300 | [diff] [blame] | 829 | return; |
| 830 | } |
| 831 | |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 832 | if (intel_hdmi_set_gcp_infoframe(encoder, crtc_state, conn_state)) |
Ville Syrjälä | 6d67415 | 2015-05-05 17:06:20 +0300 | [diff] [blame] | 833 | val |= VIDEO_DIP_ENABLE_GCP_HSW; |
| 834 | |
Paulo Zanoni | 0dd87d2 | 2012-05-28 16:42:53 -0300 | [diff] [blame] | 835 | I915_WRITE(reg, val); |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 836 | POSTING_READ(reg); |
Paulo Zanoni | 0dd87d2 | 2012-05-28 16:42:53 -0300 | [diff] [blame] | 837 | |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 838 | intel_hdmi_set_avi_infoframe(encoder, crtc_state); |
| 839 | intel_hdmi_set_spd_infoframe(encoder, crtc_state); |
| 840 | intel_hdmi_set_hdmi_infoframe(encoder, crtc_state); |
Paulo Zanoni | 687f4d0 | 2012-05-28 16:42:48 -0300 | [diff] [blame] | 841 | } |
| 842 | |
Ville Syrjälä | b2ccb82 | 2016-05-02 22:08:24 +0300 | [diff] [blame] | 843 | void intel_dp_dual_mode_set_tmds_output(struct intel_hdmi *hdmi, bool enable) |
| 844 | { |
| 845 | struct drm_i915_private *dev_priv = to_i915(intel_hdmi_to_dev(hdmi)); |
| 846 | struct i2c_adapter *adapter = |
| 847 | intel_gmbus_get_adapter(dev_priv, hdmi->ddc_bus); |
| 848 | |
| 849 | if (hdmi->dp_dual_mode.type < DRM_DP_DUAL_MODE_TYPE2_DVI) |
| 850 | return; |
| 851 | |
| 852 | DRM_DEBUG_KMS("%s DP dual mode adaptor TMDS output\n", |
| 853 | enable ? "Enabling" : "Disabling"); |
| 854 | |
| 855 | drm_dp_dual_mode_set_tmds_output(hdmi->dp_dual_mode.type, |
| 856 | adapter, enable); |
| 857 | } |
| 858 | |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 859 | static void intel_hdmi_prepare(struct intel_encoder *encoder, |
| 860 | const struct intel_crtc_state *crtc_state) |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 861 | { |
Daniel Vetter | c59423a | 2013-07-21 21:37:04 +0200 | [diff] [blame] | 862 | struct drm_device *dev = encoder->base.dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 863 | struct drm_i915_private *dev_priv = to_i915(dev); |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 864 | struct intel_crtc *crtc = to_intel_crtc(crtc_state->base.crtc); |
Daniel Vetter | c59423a | 2013-07-21 21:37:04 +0200 | [diff] [blame] | 865 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&encoder->base); |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 866 | const struct drm_display_mode *adjusted_mode = &crtc_state->base.adjusted_mode; |
Paulo Zanoni | b242b7f | 2013-02-18 19:00:26 -0300 | [diff] [blame] | 867 | u32 hdmi_val; |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 868 | |
Ville Syrjälä | b2ccb82 | 2016-05-02 22:08:24 +0300 | [diff] [blame] | 869 | intel_dp_dual_mode_set_tmds_output(intel_hdmi, true); |
| 870 | |
Paulo Zanoni | b242b7f | 2013-02-18 19:00:26 -0300 | [diff] [blame] | 871 | hdmi_val = SDVO_ENCODING_HDMI; |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 872 | if (!HAS_PCH_SPLIT(dev_priv) && crtc_state->limited_color_range) |
Ville Syrjälä | 0f2a2a7 | 2015-07-06 15:10:00 +0300 | [diff] [blame] | 873 | hdmi_val |= HDMI_COLOR_RANGE_16_235; |
Adam Jackson | b599c0b | 2010-07-16 14:46:31 -0400 | [diff] [blame] | 874 | if (adjusted_mode->flags & DRM_MODE_FLAG_PVSYNC) |
Paulo Zanoni | b242b7f | 2013-02-18 19:00:26 -0300 | [diff] [blame] | 875 | hdmi_val |= SDVO_VSYNC_ACTIVE_HIGH; |
Adam Jackson | b599c0b | 2010-07-16 14:46:31 -0400 | [diff] [blame] | 876 | if (adjusted_mode->flags & DRM_MODE_FLAG_PHSYNC) |
Paulo Zanoni | b242b7f | 2013-02-18 19:00:26 -0300 | [diff] [blame] | 877 | hdmi_val |= SDVO_HSYNC_ACTIVE_HIGH; |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 878 | |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 879 | if (crtc_state->pipe_bpp > 24) |
Paulo Zanoni | 4f3a8bc | 2013-02-19 16:21:47 -0300 | [diff] [blame] | 880 | hdmi_val |= HDMI_COLOR_FORMAT_12bpc; |
Jesse Barnes | 020f670 | 2011-06-24 12:19:25 -0700 | [diff] [blame] | 881 | else |
Paulo Zanoni | 4f3a8bc | 2013-02-19 16:21:47 -0300 | [diff] [blame] | 882 | hdmi_val |= SDVO_COLOR_FORMAT_8bpc; |
Jesse Barnes | 020f670 | 2011-06-24 12:19:25 -0700 | [diff] [blame] | 883 | |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 884 | if (crtc_state->has_hdmi_sink) |
Paulo Zanoni | dc0fa71 | 2013-02-19 16:21:46 -0300 | [diff] [blame] | 885 | hdmi_val |= HDMI_MODE_SELECT_HDMI; |
Zhenyu Wang | 2e3d600 | 2010-09-10 10:39:40 +0800 | [diff] [blame] | 886 | |
Tvrtko Ursulin | 6e26695 | 2016-10-13 11:02:53 +0100 | [diff] [blame] | 887 | if (HAS_PCH_CPT(dev_priv)) |
Daniel Vetter | c59423a | 2013-07-21 21:37:04 +0200 | [diff] [blame] | 888 | hdmi_val |= SDVO_PIPE_SEL_CPT(crtc->pipe); |
Tvrtko Ursulin | 920a14b | 2016-10-14 10:13:44 +0100 | [diff] [blame] | 889 | else if (IS_CHERRYVIEW(dev_priv)) |
Chon Ming Lee | 44f37d1 | 2014-04-09 13:28:21 +0300 | [diff] [blame] | 890 | hdmi_val |= SDVO_PIPE_SEL_CHV(crtc->pipe); |
Paulo Zanoni | dc0fa71 | 2013-02-19 16:21:46 -0300 | [diff] [blame] | 891 | else |
Daniel Vetter | c59423a | 2013-07-21 21:37:04 +0200 | [diff] [blame] | 892 | hdmi_val |= SDVO_PIPE_SEL(crtc->pipe); |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 893 | |
Paulo Zanoni | b242b7f | 2013-02-18 19:00:26 -0300 | [diff] [blame] | 894 | I915_WRITE(intel_hdmi->hdmi_reg, hdmi_val); |
| 895 | POSTING_READ(intel_hdmi->hdmi_reg); |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 896 | } |
| 897 | |
Daniel Vetter | 85234cd | 2012-07-02 13:27:29 +0200 | [diff] [blame] | 898 | static bool intel_hdmi_get_hw_state(struct intel_encoder *encoder, |
| 899 | enum pipe *pipe) |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 900 | { |
Daniel Vetter | 85234cd | 2012-07-02 13:27:29 +0200 | [diff] [blame] | 901 | struct drm_device *dev = encoder->base.dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 902 | struct drm_i915_private *dev_priv = to_i915(dev); |
Daniel Vetter | 85234cd | 2012-07-02 13:27:29 +0200 | [diff] [blame] | 903 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&encoder->base); |
Imre Deak | 6d129be | 2014-03-05 16:20:54 +0200 | [diff] [blame] | 904 | enum intel_display_power_domain power_domain; |
Daniel Vetter | 85234cd | 2012-07-02 13:27:29 +0200 | [diff] [blame] | 905 | u32 tmp; |
Imre Deak | 5b09217 | 2016-02-12 18:55:20 +0200 | [diff] [blame] | 906 | bool ret; |
Daniel Vetter | 85234cd | 2012-07-02 13:27:29 +0200 | [diff] [blame] | 907 | |
Imre Deak | 6d129be | 2014-03-05 16:20:54 +0200 | [diff] [blame] | 908 | power_domain = intel_display_port_power_domain(encoder); |
Imre Deak | 5b09217 | 2016-02-12 18:55:20 +0200 | [diff] [blame] | 909 | if (!intel_display_power_get_if_enabled(dev_priv, power_domain)) |
Imre Deak | 6d129be | 2014-03-05 16:20:54 +0200 | [diff] [blame] | 910 | return false; |
| 911 | |
Imre Deak | 5b09217 | 2016-02-12 18:55:20 +0200 | [diff] [blame] | 912 | ret = false; |
| 913 | |
Paulo Zanoni | b242b7f | 2013-02-18 19:00:26 -0300 | [diff] [blame] | 914 | tmp = I915_READ(intel_hdmi->hdmi_reg); |
Daniel Vetter | 85234cd | 2012-07-02 13:27:29 +0200 | [diff] [blame] | 915 | |
| 916 | if (!(tmp & SDVO_ENABLE)) |
Imre Deak | 5b09217 | 2016-02-12 18:55:20 +0200 | [diff] [blame] | 917 | goto out; |
Daniel Vetter | 85234cd | 2012-07-02 13:27:29 +0200 | [diff] [blame] | 918 | |
Tvrtko Ursulin | 6e26695 | 2016-10-13 11:02:53 +0100 | [diff] [blame] | 919 | if (HAS_PCH_CPT(dev_priv)) |
Daniel Vetter | 85234cd | 2012-07-02 13:27:29 +0200 | [diff] [blame] | 920 | *pipe = PORT_TO_PIPE_CPT(tmp); |
Tvrtko Ursulin | 920a14b | 2016-10-14 10:13:44 +0100 | [diff] [blame] | 921 | else if (IS_CHERRYVIEW(dev_priv)) |
Ville Syrjälä | 71485e0 | 2014-04-09 13:28:55 +0300 | [diff] [blame] | 922 | *pipe = SDVO_PORT_TO_PIPE_CHV(tmp); |
Daniel Vetter | 85234cd | 2012-07-02 13:27:29 +0200 | [diff] [blame] | 923 | else |
| 924 | *pipe = PORT_TO_PIPE(tmp); |
| 925 | |
Imre Deak | 5b09217 | 2016-02-12 18:55:20 +0200 | [diff] [blame] | 926 | ret = true; |
| 927 | |
| 928 | out: |
| 929 | intel_display_power_put(dev_priv, power_domain); |
| 930 | |
| 931 | return ret; |
Daniel Vetter | 85234cd | 2012-07-02 13:27:29 +0200 | [diff] [blame] | 932 | } |
| 933 | |
Jesse Barnes | 045ac3b | 2013-05-14 17:08:26 -0700 | [diff] [blame] | 934 | static void intel_hdmi_get_config(struct intel_encoder *encoder, |
Ander Conselvan de Oliveira | 5cec258 | 2015-01-15 14:55:21 +0200 | [diff] [blame] | 935 | struct intel_crtc_state *pipe_config) |
Jesse Barnes | 045ac3b | 2013-05-14 17:08:26 -0700 | [diff] [blame] | 936 | { |
| 937 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&encoder->base); |
Ville Syrjälä | 8c875fc | 2014-09-12 15:46:29 +0300 | [diff] [blame] | 938 | struct drm_device *dev = encoder->base.dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 939 | struct drm_i915_private *dev_priv = to_i915(dev); |
Jesse Barnes | 045ac3b | 2013-05-14 17:08:26 -0700 | [diff] [blame] | 940 | u32 tmp, flags = 0; |
Ville Syrjälä | 18442d0 | 2013-09-13 16:00:08 +0300 | [diff] [blame] | 941 | int dotclock; |
Jesse Barnes | 045ac3b | 2013-05-14 17:08:26 -0700 | [diff] [blame] | 942 | |
| 943 | tmp = I915_READ(intel_hdmi->hdmi_reg); |
| 944 | |
| 945 | if (tmp & SDVO_HSYNC_ACTIVE_HIGH) |
| 946 | flags |= DRM_MODE_FLAG_PHSYNC; |
| 947 | else |
| 948 | flags |= DRM_MODE_FLAG_NHSYNC; |
| 949 | |
| 950 | if (tmp & SDVO_VSYNC_ACTIVE_HIGH) |
| 951 | flags |= DRM_MODE_FLAG_PVSYNC; |
| 952 | else |
| 953 | flags |= DRM_MODE_FLAG_NVSYNC; |
| 954 | |
Daniel Vetter | 6897b4b5 | 2014-04-24 23:54:47 +0200 | [diff] [blame] | 955 | if (tmp & HDMI_MODE_SELECT_HDMI) |
| 956 | pipe_config->has_hdmi_sink = true; |
| 957 | |
Ville Syrjälä | cda0aaa | 2015-11-26 18:27:07 +0200 | [diff] [blame] | 958 | if (intel_hdmi->infoframe_enabled(&encoder->base, pipe_config)) |
Jesse Barnes | e43823e | 2014-11-05 14:26:08 -0800 | [diff] [blame] | 959 | pipe_config->has_infoframe = true; |
| 960 | |
Jani Nikula | c84db77 | 2014-09-17 15:34:58 +0300 | [diff] [blame] | 961 | if (tmp & SDVO_AUDIO_ENABLE) |
Daniel Vetter | 9ed109a | 2014-04-24 23:54:52 +0200 | [diff] [blame] | 962 | pipe_config->has_audio = true; |
| 963 | |
Tvrtko Ursulin | 6e26695 | 2016-10-13 11:02:53 +0100 | [diff] [blame] | 964 | if (!HAS_PCH_SPLIT(dev_priv) && |
Ville Syrjälä | 8c875fc | 2014-09-12 15:46:29 +0300 | [diff] [blame] | 965 | tmp & HDMI_COLOR_RANGE_16_235) |
| 966 | pipe_config->limited_color_range = true; |
| 967 | |
Ander Conselvan de Oliveira | 2d112de | 2015-01-15 14:55:22 +0200 | [diff] [blame] | 968 | pipe_config->base.adjusted_mode.flags |= flags; |
Ville Syrjälä | 18442d0 | 2013-09-13 16:00:08 +0300 | [diff] [blame] | 969 | |
| 970 | if ((tmp & SDVO_COLOR_FORMAT_MASK) == HDMI_COLOR_FORMAT_12bpc) |
| 971 | dotclock = pipe_config->port_clock * 2 / 3; |
| 972 | else |
| 973 | dotclock = pipe_config->port_clock; |
| 974 | |
Ville Syrjälä | be69a13 | 2015-05-05 17:06:26 +0300 | [diff] [blame] | 975 | if (pipe_config->pixel_multiplier) |
| 976 | dotclock /= pipe_config->pixel_multiplier; |
| 977 | |
Ander Conselvan de Oliveira | 2d112de | 2015-01-15 14:55:22 +0200 | [diff] [blame] | 978 | pipe_config->base.adjusted_mode.crtc_clock = dotclock; |
Ander Conselvan de Oliveira | d4d6279 | 2016-04-27 15:44:16 +0300 | [diff] [blame] | 979 | |
| 980 | pipe_config->lane_count = 4; |
Jesse Barnes | 045ac3b | 2013-05-14 17:08:26 -0700 | [diff] [blame] | 981 | } |
| 982 | |
Maarten Lankhorst | df18e72 | 2016-11-08 13:55:37 +0100 | [diff] [blame] | 983 | static void intel_enable_hdmi_audio(struct intel_encoder *encoder, |
| 984 | struct intel_crtc_state *pipe_config, |
| 985 | struct drm_connector_state *conn_state) |
Ville Syrjälä | d1b1589 | 2015-05-05 17:06:19 +0300 | [diff] [blame] | 986 | { |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 987 | struct intel_crtc *crtc = to_intel_crtc(pipe_config->base.crtc); |
Ville Syrjälä | d1b1589 | 2015-05-05 17:06:19 +0300 | [diff] [blame] | 988 | |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 989 | WARN_ON(!pipe_config->has_hdmi_sink); |
Ville Syrjälä | d1b1589 | 2015-05-05 17:06:19 +0300 | [diff] [blame] | 990 | DRM_DEBUG_DRIVER("Enabling HDMI audio on pipe %c\n", |
| 991 | pipe_name(crtc->pipe)); |
Maarten Lankhorst | bbf35e9 | 2016-11-08 13:55:38 +0100 | [diff] [blame] | 992 | intel_audio_codec_enable(encoder, pipe_config, conn_state); |
Ville Syrjälä | d1b1589 | 2015-05-05 17:06:19 +0300 | [diff] [blame] | 993 | } |
| 994 | |
Maarten Lankhorst | fd6bbda | 2016-08-09 17:04:04 +0200 | [diff] [blame] | 995 | static void g4x_enable_hdmi(struct intel_encoder *encoder, |
| 996 | struct intel_crtc_state *pipe_config, |
| 997 | struct drm_connector_state *conn_state) |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 998 | { |
Daniel Vetter | 5ab432e | 2012-06-30 08:59:56 +0200 | [diff] [blame] | 999 | struct drm_device *dev = encoder->base.dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 1000 | struct drm_i915_private *dev_priv = to_i915(dev); |
Daniel Vetter | 5ab432e | 2012-06-30 08:59:56 +0200 | [diff] [blame] | 1001 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&encoder->base); |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 1002 | u32 temp; |
| 1003 | |
Paulo Zanoni | b242b7f | 2013-02-18 19:00:26 -0300 | [diff] [blame] | 1004 | temp = I915_READ(intel_hdmi->hdmi_reg); |
Zhenyu Wang | d8a2d0e | 2009-11-02 07:52:30 +0000 | [diff] [blame] | 1005 | |
Ville Syrjälä | bf868c7 | 2015-05-05 17:06:23 +0300 | [diff] [blame] | 1006 | temp |= SDVO_ENABLE; |
Maarten Lankhorst | df18e72 | 2016-11-08 13:55:37 +0100 | [diff] [blame] | 1007 | if (pipe_config->has_audio) |
Ville Syrjälä | bf868c7 | 2015-05-05 17:06:23 +0300 | [diff] [blame] | 1008 | temp |= SDVO_AUDIO_ENABLE; |
Daniel Vetter | 5ab432e | 2012-06-30 08:59:56 +0200 | [diff] [blame] | 1009 | |
Paulo Zanoni | b242b7f | 2013-02-18 19:00:26 -0300 | [diff] [blame] | 1010 | I915_WRITE(intel_hdmi->hdmi_reg, temp); |
| 1011 | POSTING_READ(intel_hdmi->hdmi_reg); |
Daniel Vetter | 5ab432e | 2012-06-30 08:59:56 +0200 | [diff] [blame] | 1012 | |
Maarten Lankhorst | df18e72 | 2016-11-08 13:55:37 +0100 | [diff] [blame] | 1013 | if (pipe_config->has_audio) |
| 1014 | intel_enable_hdmi_audio(encoder, pipe_config, conn_state); |
Ville Syrjälä | bf868c7 | 2015-05-05 17:06:23 +0300 | [diff] [blame] | 1015 | } |
| 1016 | |
Maarten Lankhorst | fd6bbda | 2016-08-09 17:04:04 +0200 | [diff] [blame] | 1017 | static void ibx_enable_hdmi(struct intel_encoder *encoder, |
| 1018 | struct intel_crtc_state *pipe_config, |
| 1019 | struct drm_connector_state *conn_state) |
Ville Syrjälä | bf868c7 | 2015-05-05 17:06:23 +0300 | [diff] [blame] | 1020 | { |
| 1021 | struct drm_device *dev = encoder->base.dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 1022 | struct drm_i915_private *dev_priv = to_i915(dev); |
Ville Syrjälä | bf868c7 | 2015-05-05 17:06:23 +0300 | [diff] [blame] | 1023 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&encoder->base); |
| 1024 | u32 temp; |
| 1025 | |
| 1026 | temp = I915_READ(intel_hdmi->hdmi_reg); |
| 1027 | |
| 1028 | temp |= SDVO_ENABLE; |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 1029 | if (pipe_config->has_audio) |
Ville Syrjälä | bf868c7 | 2015-05-05 17:06:23 +0300 | [diff] [blame] | 1030 | temp |= SDVO_AUDIO_ENABLE; |
| 1031 | |
| 1032 | /* |
| 1033 | * HW workaround, need to write this twice for issue |
| 1034 | * that may result in first write getting masked. |
Daniel Vetter | 5ab432e | 2012-06-30 08:59:56 +0200 | [diff] [blame] | 1035 | */ |
Ville Syrjälä | bf868c7 | 2015-05-05 17:06:23 +0300 | [diff] [blame] | 1036 | I915_WRITE(intel_hdmi->hdmi_reg, temp); |
| 1037 | POSTING_READ(intel_hdmi->hdmi_reg); |
| 1038 | I915_WRITE(intel_hdmi->hdmi_reg, temp); |
| 1039 | POSTING_READ(intel_hdmi->hdmi_reg); |
| 1040 | |
| 1041 | /* |
| 1042 | * HW workaround, need to toggle enable bit off and on |
| 1043 | * for 12bpc with pixel repeat. |
| 1044 | * |
| 1045 | * FIXME: BSpec says this should be done at the end of |
| 1046 | * of the modeset sequence, so not sure if this isn't too soon. |
| 1047 | */ |
Maarten Lankhorst | df18e72 | 2016-11-08 13:55:37 +0100 | [diff] [blame] | 1048 | if (pipe_config->pipe_bpp > 24 && |
| 1049 | pipe_config->pixel_multiplier > 1) { |
Ville Syrjälä | bf868c7 | 2015-05-05 17:06:23 +0300 | [diff] [blame] | 1050 | I915_WRITE(intel_hdmi->hdmi_reg, temp & ~SDVO_ENABLE); |
| 1051 | POSTING_READ(intel_hdmi->hdmi_reg); |
| 1052 | |
| 1053 | /* |
| 1054 | * HW workaround, need to write this twice for issue |
| 1055 | * that may result in first write getting masked. |
| 1056 | */ |
| 1057 | I915_WRITE(intel_hdmi->hdmi_reg, temp); |
| 1058 | POSTING_READ(intel_hdmi->hdmi_reg); |
Paulo Zanoni | b242b7f | 2013-02-18 19:00:26 -0300 | [diff] [blame] | 1059 | I915_WRITE(intel_hdmi->hdmi_reg, temp); |
| 1060 | POSTING_READ(intel_hdmi->hdmi_reg); |
Daniel Vetter | 5ab432e | 2012-06-30 08:59:56 +0200 | [diff] [blame] | 1061 | } |
Jani Nikula | c1dec79 | 2014-10-27 16:26:56 +0200 | [diff] [blame] | 1062 | |
Maarten Lankhorst | df18e72 | 2016-11-08 13:55:37 +0100 | [diff] [blame] | 1063 | if (pipe_config->has_audio) |
| 1064 | intel_enable_hdmi_audio(encoder, pipe_config, conn_state); |
Ville Syrjälä | d1b1589 | 2015-05-05 17:06:19 +0300 | [diff] [blame] | 1065 | } |
| 1066 | |
Maarten Lankhorst | fd6bbda | 2016-08-09 17:04:04 +0200 | [diff] [blame] | 1067 | static void cpt_enable_hdmi(struct intel_encoder *encoder, |
| 1068 | struct intel_crtc_state *pipe_config, |
| 1069 | struct drm_connector_state *conn_state) |
Ville Syrjälä | d1b1589 | 2015-05-05 17:06:19 +0300 | [diff] [blame] | 1070 | { |
| 1071 | struct drm_device *dev = encoder->base.dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 1072 | struct drm_i915_private *dev_priv = to_i915(dev); |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 1073 | struct intel_crtc *crtc = to_intel_crtc(pipe_config->base.crtc); |
Ville Syrjälä | d1b1589 | 2015-05-05 17:06:19 +0300 | [diff] [blame] | 1074 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&encoder->base); |
| 1075 | enum pipe pipe = crtc->pipe; |
| 1076 | u32 temp; |
| 1077 | |
| 1078 | temp = I915_READ(intel_hdmi->hdmi_reg); |
| 1079 | |
| 1080 | temp |= SDVO_ENABLE; |
Maarten Lankhorst | df18e72 | 2016-11-08 13:55:37 +0100 | [diff] [blame] | 1081 | if (pipe_config->has_audio) |
Ville Syrjälä | d1b1589 | 2015-05-05 17:06:19 +0300 | [diff] [blame] | 1082 | temp |= SDVO_AUDIO_ENABLE; |
| 1083 | |
| 1084 | /* |
| 1085 | * WaEnableHDMI8bpcBefore12bpc:snb,ivb |
| 1086 | * |
| 1087 | * The procedure for 12bpc is as follows: |
| 1088 | * 1. disable HDMI clock gating |
| 1089 | * 2. enable HDMI with 8bpc |
| 1090 | * 3. enable HDMI with 12bpc |
| 1091 | * 4. enable HDMI clock gating |
| 1092 | */ |
| 1093 | |
Maarten Lankhorst | df18e72 | 2016-11-08 13:55:37 +0100 | [diff] [blame] | 1094 | if (pipe_config->pipe_bpp > 24) { |
Ville Syrjälä | d1b1589 | 2015-05-05 17:06:19 +0300 | [diff] [blame] | 1095 | I915_WRITE(TRANS_CHICKEN1(pipe), |
| 1096 | I915_READ(TRANS_CHICKEN1(pipe)) | |
| 1097 | TRANS_CHICKEN1_HDMIUNIT_GC_DISABLE); |
| 1098 | |
| 1099 | temp &= ~SDVO_COLOR_FORMAT_MASK; |
| 1100 | temp |= SDVO_COLOR_FORMAT_8bpc; |
Jani Nikula | c1dec79 | 2014-10-27 16:26:56 +0200 | [diff] [blame] | 1101 | } |
Ville Syrjälä | d1b1589 | 2015-05-05 17:06:19 +0300 | [diff] [blame] | 1102 | |
| 1103 | I915_WRITE(intel_hdmi->hdmi_reg, temp); |
| 1104 | POSTING_READ(intel_hdmi->hdmi_reg); |
| 1105 | |
Maarten Lankhorst | df18e72 | 2016-11-08 13:55:37 +0100 | [diff] [blame] | 1106 | if (pipe_config->pipe_bpp > 24) { |
Ville Syrjälä | d1b1589 | 2015-05-05 17:06:19 +0300 | [diff] [blame] | 1107 | temp &= ~SDVO_COLOR_FORMAT_MASK; |
| 1108 | temp |= HDMI_COLOR_FORMAT_12bpc; |
| 1109 | |
| 1110 | I915_WRITE(intel_hdmi->hdmi_reg, temp); |
| 1111 | POSTING_READ(intel_hdmi->hdmi_reg); |
| 1112 | |
| 1113 | I915_WRITE(TRANS_CHICKEN1(pipe), |
| 1114 | I915_READ(TRANS_CHICKEN1(pipe)) & |
| 1115 | ~TRANS_CHICKEN1_HDMIUNIT_GC_DISABLE); |
| 1116 | } |
| 1117 | |
Maarten Lankhorst | df18e72 | 2016-11-08 13:55:37 +0100 | [diff] [blame] | 1118 | if (pipe_config->has_audio) |
| 1119 | intel_enable_hdmi_audio(encoder, pipe_config, conn_state); |
Jani Nikula | b76cf76 | 2013-07-30 12:20:31 +0300 | [diff] [blame] | 1120 | } |
Jesse Barnes | 89b667f | 2013-04-18 14:51:36 -0700 | [diff] [blame] | 1121 | |
Maarten Lankhorst | fd6bbda | 2016-08-09 17:04:04 +0200 | [diff] [blame] | 1122 | static void vlv_enable_hdmi(struct intel_encoder *encoder, |
| 1123 | struct intel_crtc_state *pipe_config, |
| 1124 | struct drm_connector_state *conn_state) |
Jani Nikula | b76cf76 | 2013-07-30 12:20:31 +0300 | [diff] [blame] | 1125 | { |
Daniel Vetter | 5ab432e | 2012-06-30 08:59:56 +0200 | [diff] [blame] | 1126 | } |
| 1127 | |
Maarten Lankhorst | fd6bbda | 2016-08-09 17:04:04 +0200 | [diff] [blame] | 1128 | static void intel_disable_hdmi(struct intel_encoder *encoder, |
| 1129 | struct intel_crtc_state *old_crtc_state, |
| 1130 | struct drm_connector_state *old_conn_state) |
Daniel Vetter | 5ab432e | 2012-06-30 08:59:56 +0200 | [diff] [blame] | 1131 | { |
| 1132 | struct drm_device *dev = encoder->base.dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 1133 | struct drm_i915_private *dev_priv = to_i915(dev); |
Daniel Vetter | 5ab432e | 2012-06-30 08:59:56 +0200 | [diff] [blame] | 1134 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&encoder->base); |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 1135 | struct intel_crtc *crtc = to_intel_crtc(old_crtc_state->base.crtc); |
Daniel Vetter | 5ab432e | 2012-06-30 08:59:56 +0200 | [diff] [blame] | 1136 | u32 temp; |
Daniel Vetter | 5ab432e | 2012-06-30 08:59:56 +0200 | [diff] [blame] | 1137 | |
Paulo Zanoni | b242b7f | 2013-02-18 19:00:26 -0300 | [diff] [blame] | 1138 | temp = I915_READ(intel_hdmi->hdmi_reg); |
Daniel Vetter | 5ab432e | 2012-06-30 08:59:56 +0200 | [diff] [blame] | 1139 | |
Ville Syrjälä | 1612c8b | 2015-05-05 17:17:34 +0300 | [diff] [blame] | 1140 | temp &= ~(SDVO_ENABLE | SDVO_AUDIO_ENABLE); |
Paulo Zanoni | b242b7f | 2013-02-18 19:00:26 -0300 | [diff] [blame] | 1141 | I915_WRITE(intel_hdmi->hdmi_reg, temp); |
| 1142 | POSTING_READ(intel_hdmi->hdmi_reg); |
Ville Syrjälä | 1612c8b | 2015-05-05 17:17:34 +0300 | [diff] [blame] | 1143 | |
| 1144 | /* |
| 1145 | * HW workaround for IBX, we need to move the port |
| 1146 | * to transcoder A after disabling it to allow the |
| 1147 | * matching DP port to be enabled on transcoder A. |
| 1148 | */ |
Tvrtko Ursulin | 6e26695 | 2016-10-13 11:02:53 +0100 | [diff] [blame] | 1149 | if (HAS_PCH_IBX(dev_priv) && crtc->pipe == PIPE_B) { |
Ville Syrjälä | 0c241d5 | 2015-10-30 19:23:22 +0200 | [diff] [blame] | 1150 | /* |
| 1151 | * We get CPU/PCH FIFO underruns on the other pipe when |
| 1152 | * doing the workaround. Sweep them under the rug. |
| 1153 | */ |
| 1154 | intel_set_cpu_fifo_underrun_reporting(dev_priv, PIPE_A, false); |
| 1155 | intel_set_pch_fifo_underrun_reporting(dev_priv, PIPE_A, false); |
| 1156 | |
Ville Syrjälä | 1612c8b | 2015-05-05 17:17:34 +0300 | [diff] [blame] | 1157 | temp &= ~SDVO_PIPE_B_SELECT; |
| 1158 | temp |= SDVO_ENABLE; |
| 1159 | /* |
| 1160 | * HW workaround, need to write this twice for issue |
| 1161 | * that may result in first write getting masked. |
| 1162 | */ |
| 1163 | I915_WRITE(intel_hdmi->hdmi_reg, temp); |
| 1164 | POSTING_READ(intel_hdmi->hdmi_reg); |
| 1165 | I915_WRITE(intel_hdmi->hdmi_reg, temp); |
| 1166 | POSTING_READ(intel_hdmi->hdmi_reg); |
| 1167 | |
| 1168 | temp &= ~SDVO_ENABLE; |
| 1169 | I915_WRITE(intel_hdmi->hdmi_reg, temp); |
| 1170 | POSTING_READ(intel_hdmi->hdmi_reg); |
Ville Syrjälä | 0c241d5 | 2015-10-30 19:23:22 +0200 | [diff] [blame] | 1171 | |
Ville Syrjälä | 0f0f74b | 2016-10-31 22:37:06 +0200 | [diff] [blame] | 1172 | intel_wait_for_vblank_if_active(dev_priv, PIPE_A); |
Ville Syrjälä | 0c241d5 | 2015-10-30 19:23:22 +0200 | [diff] [blame] | 1173 | intel_set_cpu_fifo_underrun_reporting(dev_priv, PIPE_A, true); |
| 1174 | intel_set_pch_fifo_underrun_reporting(dev_priv, PIPE_A, true); |
Ville Syrjälä | 1612c8b | 2015-05-05 17:17:34 +0300 | [diff] [blame] | 1175 | } |
Ville Syrjälä | 6d67415 | 2015-05-05 17:06:20 +0300 | [diff] [blame] | 1176 | |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 1177 | intel_hdmi->set_infoframes(&encoder->base, false, old_crtc_state, old_conn_state); |
Ville Syrjälä | b2ccb82 | 2016-05-02 22:08:24 +0300 | [diff] [blame] | 1178 | |
| 1179 | intel_dp_dual_mode_set_tmds_output(intel_hdmi, false); |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 1180 | } |
| 1181 | |
Maarten Lankhorst | fd6bbda | 2016-08-09 17:04:04 +0200 | [diff] [blame] | 1182 | static void g4x_disable_hdmi(struct intel_encoder *encoder, |
| 1183 | struct intel_crtc_state *old_crtc_state, |
| 1184 | struct drm_connector_state *old_conn_state) |
Ville Syrjälä | a4790ce | 2015-05-05 17:17:35 +0300 | [diff] [blame] | 1185 | { |
Maarten Lankhorst | df18e72 | 2016-11-08 13:55:37 +0100 | [diff] [blame] | 1186 | if (old_crtc_state->has_audio) |
Ville Syrjälä | a4790ce | 2015-05-05 17:17:35 +0300 | [diff] [blame] | 1187 | intel_audio_codec_disable(encoder); |
| 1188 | |
Maarten Lankhorst | fd6bbda | 2016-08-09 17:04:04 +0200 | [diff] [blame] | 1189 | intel_disable_hdmi(encoder, old_crtc_state, old_conn_state); |
Ville Syrjälä | a4790ce | 2015-05-05 17:17:35 +0300 | [diff] [blame] | 1190 | } |
| 1191 | |
Maarten Lankhorst | fd6bbda | 2016-08-09 17:04:04 +0200 | [diff] [blame] | 1192 | static void pch_disable_hdmi(struct intel_encoder *encoder, |
| 1193 | struct intel_crtc_state *old_crtc_state, |
| 1194 | struct drm_connector_state *old_conn_state) |
Ville Syrjälä | a4790ce | 2015-05-05 17:17:35 +0300 | [diff] [blame] | 1195 | { |
Maarten Lankhorst | df18e72 | 2016-11-08 13:55:37 +0100 | [diff] [blame] | 1196 | if (old_crtc_state->has_audio) |
Ville Syrjälä | a4790ce | 2015-05-05 17:17:35 +0300 | [diff] [blame] | 1197 | intel_audio_codec_disable(encoder); |
| 1198 | } |
| 1199 | |
Maarten Lankhorst | fd6bbda | 2016-08-09 17:04:04 +0200 | [diff] [blame] | 1200 | static void pch_post_disable_hdmi(struct intel_encoder *encoder, |
| 1201 | struct intel_crtc_state *old_crtc_state, |
| 1202 | struct drm_connector_state *old_conn_state) |
Ville Syrjälä | a4790ce | 2015-05-05 17:17:35 +0300 | [diff] [blame] | 1203 | { |
Maarten Lankhorst | fd6bbda | 2016-08-09 17:04:04 +0200 | [diff] [blame] | 1204 | intel_disable_hdmi(encoder, old_crtc_state, old_conn_state); |
Ville Syrjälä | a4790ce | 2015-05-05 17:17:35 +0300 | [diff] [blame] | 1205 | } |
| 1206 | |
Ville Syrjälä | b1ba124 | 2016-05-02 22:08:23 +0300 | [diff] [blame] | 1207 | static int intel_hdmi_source_max_tmds_clock(struct drm_i915_private *dev_priv) |
Daniel Vetter | 7d148ef | 2013-07-22 18:02:39 +0200 | [diff] [blame] | 1208 | { |
Ville Syrjälä | b1ba124 | 2016-05-02 22:08:23 +0300 | [diff] [blame] | 1209 | if (IS_G4X(dev_priv)) |
Daniel Vetter | 7d148ef | 2013-07-22 18:02:39 +0200 | [diff] [blame] | 1210 | return 165000; |
Ville Syrjälä | b1ba124 | 2016-05-02 22:08:23 +0300 | [diff] [blame] | 1211 | else if (IS_HASWELL(dev_priv) || INTEL_INFO(dev_priv)->gen >= 8) |
Daniel Vetter | 7d148ef | 2013-07-22 18:02:39 +0200 | [diff] [blame] | 1212 | return 300000; |
| 1213 | else |
| 1214 | return 225000; |
| 1215 | } |
| 1216 | |
Ville Syrjälä | b1ba124 | 2016-05-02 22:08:23 +0300 | [diff] [blame] | 1217 | static int hdmi_port_clock_limit(struct intel_hdmi *hdmi, |
| 1218 | bool respect_downstream_limits) |
| 1219 | { |
| 1220 | struct drm_device *dev = intel_hdmi_to_dev(hdmi); |
| 1221 | int max_tmds_clock = intel_hdmi_source_max_tmds_clock(to_i915(dev)); |
| 1222 | |
| 1223 | if (respect_downstream_limits) { |
Ville Syrjälä | 8cadab0 | 2016-09-28 16:51:43 +0300 | [diff] [blame] | 1224 | struct intel_connector *connector = hdmi->attached_connector; |
| 1225 | const struct drm_display_info *info = &connector->base.display_info; |
| 1226 | |
Ville Syrjälä | b1ba124 | 2016-05-02 22:08:23 +0300 | [diff] [blame] | 1227 | if (hdmi->dp_dual_mode.max_tmds_clock) |
| 1228 | max_tmds_clock = min(max_tmds_clock, |
| 1229 | hdmi->dp_dual_mode.max_tmds_clock); |
Ville Syrjälä | 8cadab0 | 2016-09-28 16:51:43 +0300 | [diff] [blame] | 1230 | |
| 1231 | if (info->max_tmds_clock) |
| 1232 | max_tmds_clock = min(max_tmds_clock, |
| 1233 | info->max_tmds_clock); |
| 1234 | else if (!hdmi->has_hdmi_sink) |
Ville Syrjälä | b1ba124 | 2016-05-02 22:08:23 +0300 | [diff] [blame] | 1235 | max_tmds_clock = min(max_tmds_clock, 165000); |
| 1236 | } |
| 1237 | |
| 1238 | return max_tmds_clock; |
| 1239 | } |
| 1240 | |
Damien Lespiau | c19de8e | 2013-11-28 15:29:18 +0000 | [diff] [blame] | 1241 | static enum drm_mode_status |
Ville Syrjälä | e64e739 | 2015-06-30 19:23:59 +0300 | [diff] [blame] | 1242 | hdmi_port_clock_valid(struct intel_hdmi *hdmi, |
Ville Syrjälä | b1ba124 | 2016-05-02 22:08:23 +0300 | [diff] [blame] | 1243 | int clock, bool respect_downstream_limits) |
Ville Syrjälä | e64e739 | 2015-06-30 19:23:59 +0300 | [diff] [blame] | 1244 | { |
Tvrtko Ursulin | e2d214a | 2016-10-13 11:03:04 +0100 | [diff] [blame] | 1245 | struct drm_i915_private *dev_priv = to_i915(intel_hdmi_to_dev(hdmi)); |
Ville Syrjälä | e64e739 | 2015-06-30 19:23:59 +0300 | [diff] [blame] | 1246 | |
| 1247 | if (clock < 25000) |
| 1248 | return MODE_CLOCK_LOW; |
Ville Syrjälä | b1ba124 | 2016-05-02 22:08:23 +0300 | [diff] [blame] | 1249 | if (clock > hdmi_port_clock_limit(hdmi, respect_downstream_limits)) |
Ville Syrjälä | e64e739 | 2015-06-30 19:23:59 +0300 | [diff] [blame] | 1250 | return MODE_CLOCK_HIGH; |
| 1251 | |
Ville Syrjälä | 5e6ccc0 | 2015-07-06 14:44:11 +0300 | [diff] [blame] | 1252 | /* BXT DPLL can't generate 223-240 MHz */ |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 1253 | if (IS_GEN9_LP(dev_priv) && clock > 223333 && clock < 240000) |
Ville Syrjälä | 5e6ccc0 | 2015-07-06 14:44:11 +0300 | [diff] [blame] | 1254 | return MODE_CLOCK_RANGE; |
| 1255 | |
| 1256 | /* CHV DPLL can't generate 216-240 MHz */ |
Tvrtko Ursulin | e2d214a | 2016-10-13 11:03:04 +0100 | [diff] [blame] | 1257 | if (IS_CHERRYVIEW(dev_priv) && clock > 216000 && clock < 240000) |
Ville Syrjälä | e64e739 | 2015-06-30 19:23:59 +0300 | [diff] [blame] | 1258 | return MODE_CLOCK_RANGE; |
| 1259 | |
| 1260 | return MODE_OK; |
| 1261 | } |
| 1262 | |
| 1263 | static enum drm_mode_status |
Damien Lespiau | c19de8e | 2013-11-28 15:29:18 +0000 | [diff] [blame] | 1264 | intel_hdmi_mode_valid(struct drm_connector *connector, |
| 1265 | struct drm_display_mode *mode) |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 1266 | { |
Ville Syrjälä | e64e739 | 2015-06-30 19:23:59 +0300 | [diff] [blame] | 1267 | struct intel_hdmi *hdmi = intel_attached_hdmi(connector); |
| 1268 | struct drm_device *dev = intel_hdmi_to_dev(hdmi); |
Tvrtko Ursulin | 49cff96 | 2016-10-13 11:02:54 +0100 | [diff] [blame] | 1269 | struct drm_i915_private *dev_priv = to_i915(dev); |
Ville Syrjälä | e64e739 | 2015-06-30 19:23:59 +0300 | [diff] [blame] | 1270 | enum drm_mode_status status; |
| 1271 | int clock; |
Mika Kahola | 587bf49 | 2016-02-02 15:16:39 +0200 | [diff] [blame] | 1272 | int max_dotclk = to_i915(connector->dev)->max_dotclk_freq; |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 1273 | |
| 1274 | if (mode->flags & DRM_MODE_FLAG_DBLSCAN) |
| 1275 | return MODE_NO_DBLESCAN; |
| 1276 | |
Ville Syrjälä | e64e739 | 2015-06-30 19:23:59 +0300 | [diff] [blame] | 1277 | clock = mode->clock; |
Mika Kahola | 587bf49 | 2016-02-02 15:16:39 +0200 | [diff] [blame] | 1278 | |
| 1279 | if ((mode->flags & DRM_MODE_FLAG_3D_MASK) == DRM_MODE_FLAG_3D_FRAME_PACKING) |
| 1280 | clock *= 2; |
| 1281 | |
| 1282 | if (clock > max_dotclk) |
| 1283 | return MODE_CLOCK_HIGH; |
| 1284 | |
Ville Syrjälä | e64e739 | 2015-06-30 19:23:59 +0300 | [diff] [blame] | 1285 | if (mode->flags & DRM_MODE_FLAG_DBLCLK) |
| 1286 | clock *= 2; |
| 1287 | |
| 1288 | /* check if we can do 8bpc */ |
| 1289 | status = hdmi_port_clock_valid(hdmi, clock, true); |
| 1290 | |
| 1291 | /* if we can't do 8bpc we may still be able to do 12bpc */ |
Tvrtko Ursulin | 49cff96 | 2016-10-13 11:02:54 +0100 | [diff] [blame] | 1292 | if (!HAS_GMCH_DISPLAY(dev_priv) && status != MODE_OK) |
Ville Syrjälä | e64e739 | 2015-06-30 19:23:59 +0300 | [diff] [blame] | 1293 | status = hdmi_port_clock_valid(hdmi, clock * 3 / 2, true); |
| 1294 | |
| 1295 | return status; |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 1296 | } |
| 1297 | |
Ander Conselvan de Oliveira | 77f06c8 | 2015-03-20 16:18:11 +0200 | [diff] [blame] | 1298 | static bool hdmi_12bpc_possible(struct intel_crtc_state *crtc_state) |
Ville Syrjälä | 7180063 | 2014-03-03 16:15:29 +0200 | [diff] [blame] | 1299 | { |
Ander Conselvan de Oliveira | 77f06c8 | 2015-03-20 16:18:11 +0200 | [diff] [blame] | 1300 | struct drm_device *dev = crtc_state->base.crtc->dev; |
Ville Syrjälä | 7180063 | 2014-03-03 16:15:29 +0200 | [diff] [blame] | 1301 | |
Tvrtko Ursulin | 49cff96 | 2016-10-13 11:02:54 +0100 | [diff] [blame] | 1302 | if (HAS_GMCH_DISPLAY(to_i915(dev))) |
Ville Syrjälä | 7180063 | 2014-03-03 16:15:29 +0200 | [diff] [blame] | 1303 | return false; |
| 1304 | |
Ville Syrjälä | 7180063 | 2014-03-03 16:15:29 +0200 | [diff] [blame] | 1305 | /* |
| 1306 | * HDMI 12bpc affects the clocks, so it's only possible |
| 1307 | * when not cloning with other encoder types. |
| 1308 | */ |
Ville Syrjälä | 3f1c928 | 2016-06-22 21:57:08 +0300 | [diff] [blame] | 1309 | return crtc_state->output_types == 1 << INTEL_OUTPUT_HDMI; |
Ville Syrjälä | 7180063 | 2014-03-03 16:15:29 +0200 | [diff] [blame] | 1310 | } |
| 1311 | |
Daniel Vetter | 5bfe2ac | 2013-03-27 00:44:55 +0100 | [diff] [blame] | 1312 | bool intel_hdmi_compute_config(struct intel_encoder *encoder, |
Maarten Lankhorst | 0a478c2 | 2016-08-09 17:04:05 +0200 | [diff] [blame] | 1313 | struct intel_crtc_state *pipe_config, |
| 1314 | struct drm_connector_state *conn_state) |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 1315 | { |
Daniel Vetter | 5bfe2ac | 2013-03-27 00:44:55 +0100 | [diff] [blame] | 1316 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&encoder->base); |
Tvrtko Ursulin | 4f8036a | 2016-10-13 11:02:52 +0100 | [diff] [blame] | 1317 | struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); |
Ander Conselvan de Oliveira | 2d112de | 2015-01-15 14:55:22 +0200 | [diff] [blame] | 1318 | struct drm_display_mode *adjusted_mode = &pipe_config->base.adjusted_mode; |
Ville Syrjälä | e64e739 | 2015-06-30 19:23:59 +0300 | [diff] [blame] | 1319 | int clock_8bpc = pipe_config->base.adjusted_mode.crtc_clock; |
| 1320 | int clock_12bpc = clock_8bpc * 3 / 2; |
Daniel Vetter | e29c22c | 2013-02-21 00:00:16 +0100 | [diff] [blame] | 1321 | int desired_bpp; |
Ville Syrjälä | 3685a8f | 2013-01-17 16:31:28 +0200 | [diff] [blame] | 1322 | |
Daniel Vetter | 6897b4b5 | 2014-04-24 23:54:47 +0200 | [diff] [blame] | 1323 | pipe_config->has_hdmi_sink = intel_hdmi->has_hdmi_sink; |
| 1324 | |
Jesse Barnes | e43823e | 2014-11-05 14:26:08 -0800 | [diff] [blame] | 1325 | if (pipe_config->has_hdmi_sink) |
| 1326 | pipe_config->has_infoframe = true; |
| 1327 | |
Ville Syrjälä | 55bc60d | 2013-01-17 16:31:29 +0200 | [diff] [blame] | 1328 | if (intel_hdmi->color_range_auto) { |
| 1329 | /* See CEA-861-E - 5.1 Default Encoding Parameters */ |
Ville Syrjälä | 0f2a2a7 | 2015-07-06 15:10:00 +0300 | [diff] [blame] | 1330 | pipe_config->limited_color_range = |
| 1331 | pipe_config->has_hdmi_sink && |
Ville Syrjälä | c8127cf0 | 2017-01-11 16:18:35 +0200 | [diff] [blame] | 1332 | drm_default_rgb_quant_range(adjusted_mode) == |
| 1333 | HDMI_QUANTIZATION_RANGE_LIMITED; |
Ville Syrjälä | 0f2a2a7 | 2015-07-06 15:10:00 +0300 | [diff] [blame] | 1334 | } else { |
| 1335 | pipe_config->limited_color_range = |
| 1336 | intel_hdmi->limited_color_range; |
Ville Syrjälä | 55bc60d | 2013-01-17 16:31:29 +0200 | [diff] [blame] | 1337 | } |
| 1338 | |
Clint Taylor | 697c407 | 2014-09-02 17:03:36 -0700 | [diff] [blame] | 1339 | if (adjusted_mode->flags & DRM_MODE_FLAG_DBLCLK) { |
| 1340 | pipe_config->pixel_multiplier = 2; |
Ville Syrjälä | e64e739 | 2015-06-30 19:23:59 +0300 | [diff] [blame] | 1341 | clock_8bpc *= 2; |
Ville Syrjälä | 3320e37 | 2015-05-05 17:06:27 +0300 | [diff] [blame] | 1342 | clock_12bpc *= 2; |
Clint Taylor | 697c407 | 2014-09-02 17:03:36 -0700 | [diff] [blame] | 1343 | } |
| 1344 | |
Tvrtko Ursulin | 4f8036a | 2016-10-13 11:02:52 +0100 | [diff] [blame] | 1345 | if (HAS_PCH_SPLIT(dev_priv) && !HAS_DDI(dev_priv)) |
Daniel Vetter | 5bfe2ac | 2013-03-27 00:44:55 +0100 | [diff] [blame] | 1346 | pipe_config->has_pch_encoder = true; |
| 1347 | |
Daniel Vetter | 9ed109a | 2014-04-24 23:54:52 +0200 | [diff] [blame] | 1348 | if (pipe_config->has_hdmi_sink && intel_hdmi->has_audio) |
| 1349 | pipe_config->has_audio = true; |
| 1350 | |
Daniel Vetter | 4e53c2e | 2013-03-27 00:44:58 +0100 | [diff] [blame] | 1351 | /* |
| 1352 | * HDMI is either 12 or 8, so if the display lets 10bpc sneak |
| 1353 | * through, clamp it down. Note that g4x/vlv don't support 12bpc hdmi |
Daniel Vetter | 325b9d0 | 2013-04-19 11:24:33 +0200 | [diff] [blame] | 1354 | * outputs. We also need to check that the higher clock still fits |
| 1355 | * within limits. |
Daniel Vetter | 4e53c2e | 2013-03-27 00:44:58 +0100 | [diff] [blame] | 1356 | */ |
Daniel Vetter | 6897b4b5 | 2014-04-24 23:54:47 +0200 | [diff] [blame] | 1357 | if (pipe_config->pipe_bpp > 8*3 && pipe_config->has_hdmi_sink && |
Ville Syrjälä | b1ba124 | 2016-05-02 22:08:23 +0300 | [diff] [blame] | 1358 | hdmi_port_clock_valid(intel_hdmi, clock_12bpc, true) == MODE_OK && |
Ville Syrjälä | 7a0baa6 | 2015-06-30 15:33:54 +0300 | [diff] [blame] | 1359 | hdmi_12bpc_possible(pipe_config)) { |
Daniel Vetter | e29c22c | 2013-02-21 00:00:16 +0100 | [diff] [blame] | 1360 | DRM_DEBUG_KMS("picking bpc to 12 for HDMI output\n"); |
| 1361 | desired_bpp = 12*3; |
Daniel Vetter | 325b9d0 | 2013-04-19 11:24:33 +0200 | [diff] [blame] | 1362 | |
| 1363 | /* Need to adjust the port link by 1.5x for 12bpc. */ |
Daniel Vetter | ff9a675 | 2013-06-01 17:16:21 +0200 | [diff] [blame] | 1364 | pipe_config->port_clock = clock_12bpc; |
Daniel Vetter | 4e53c2e | 2013-03-27 00:44:58 +0100 | [diff] [blame] | 1365 | } else { |
Daniel Vetter | e29c22c | 2013-02-21 00:00:16 +0100 | [diff] [blame] | 1366 | DRM_DEBUG_KMS("picking bpc to 8 for HDMI output\n"); |
| 1367 | desired_bpp = 8*3; |
Ville Syrjälä | e64e739 | 2015-06-30 19:23:59 +0300 | [diff] [blame] | 1368 | |
| 1369 | pipe_config->port_clock = clock_8bpc; |
Daniel Vetter | e29c22c | 2013-02-21 00:00:16 +0100 | [diff] [blame] | 1370 | } |
| 1371 | |
| 1372 | if (!pipe_config->bw_constrained) { |
| 1373 | DRM_DEBUG_KMS("forcing pipe bpc to %i for HDMI\n", desired_bpp); |
| 1374 | pipe_config->pipe_bpp = desired_bpp; |
Daniel Vetter | 4e53c2e | 2013-03-27 00:44:58 +0100 | [diff] [blame] | 1375 | } |
| 1376 | |
Ville Syrjälä | e64e739 | 2015-06-30 19:23:59 +0300 | [diff] [blame] | 1377 | if (hdmi_port_clock_valid(intel_hdmi, pipe_config->port_clock, |
| 1378 | false) != MODE_OK) { |
| 1379 | DRM_DEBUG_KMS("unsupported HDMI clock, rejecting mode\n"); |
Daniel Vetter | 325b9d0 | 2013-04-19 11:24:33 +0200 | [diff] [blame] | 1380 | return false; |
| 1381 | } |
| 1382 | |
Ville Syrjälä | 28b468a | 2015-09-08 13:40:48 +0300 | [diff] [blame] | 1383 | /* Set user selected PAR to incoming mode's member */ |
| 1384 | adjusted_mode->picture_aspect_ratio = intel_hdmi->aspect_ratio; |
| 1385 | |
Ander Conselvan de Oliveira | d4d6279 | 2016-04-27 15:44:16 +0300 | [diff] [blame] | 1386 | pipe_config->lane_count = 4; |
| 1387 | |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 1388 | return true; |
| 1389 | } |
| 1390 | |
Chris Wilson | 953ece697 | 2014-09-02 20:04:01 +0100 | [diff] [blame] | 1391 | static void |
| 1392 | intel_hdmi_unset_edid(struct drm_connector *connector) |
Ma Ling | 9dff6af | 2009-04-02 13:13:26 +0800 | [diff] [blame] | 1393 | { |
Chris Wilson | df0e924 | 2010-09-09 16:20:55 +0100 | [diff] [blame] | 1394 | struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector); |
Imre Deak | 671dedd | 2014-03-05 16:20:53 +0200 | [diff] [blame] | 1395 | |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 1396 | intel_hdmi->has_hdmi_sink = false; |
Zhenyu Wang | 2e3d600 | 2010-09-10 10:39:40 +0800 | [diff] [blame] | 1397 | intel_hdmi->has_audio = false; |
Ville Syrjälä | abedc07 | 2013-01-17 16:31:31 +0200 | [diff] [blame] | 1398 | intel_hdmi->rgb_quant_range_selectable = false; |
ling.ma@intel.com | 2ded9e274 | 2009-07-16 17:23:09 +0800 | [diff] [blame] | 1399 | |
Ville Syrjälä | b1ba124 | 2016-05-02 22:08:23 +0300 | [diff] [blame] | 1400 | intel_hdmi->dp_dual_mode.type = DRM_DP_DUAL_MODE_NONE; |
| 1401 | intel_hdmi->dp_dual_mode.max_tmds_clock = 0; |
| 1402 | |
Chris Wilson | 953ece697 | 2014-09-02 20:04:01 +0100 | [diff] [blame] | 1403 | kfree(to_intel_connector(connector)->detect_edid); |
| 1404 | to_intel_connector(connector)->detect_edid = NULL; |
Ma Ling | 9dff6af | 2009-04-02 13:13:26 +0800 | [diff] [blame] | 1405 | } |
| 1406 | |
Ville Syrjälä | b1ba124 | 2016-05-02 22:08:23 +0300 | [diff] [blame] | 1407 | static void |
Ville Syrjälä | d619925 | 2016-05-04 14:45:22 +0300 | [diff] [blame] | 1408 | intel_hdmi_dp_dual_mode_detect(struct drm_connector *connector, bool has_edid) |
Ville Syrjälä | b1ba124 | 2016-05-02 22:08:23 +0300 | [diff] [blame] | 1409 | { |
| 1410 | struct drm_i915_private *dev_priv = to_i915(connector->dev); |
| 1411 | struct intel_hdmi *hdmi = intel_attached_hdmi(connector); |
Ville Syrjälä | d619925 | 2016-05-04 14:45:22 +0300 | [diff] [blame] | 1412 | enum port port = hdmi_to_dig_port(hdmi)->port; |
Ville Syrjälä | b1ba124 | 2016-05-02 22:08:23 +0300 | [diff] [blame] | 1413 | struct i2c_adapter *adapter = |
| 1414 | intel_gmbus_get_adapter(dev_priv, hdmi->ddc_bus); |
| 1415 | enum drm_dp_dual_mode_type type = drm_dp_dual_mode_detect(adapter); |
| 1416 | |
Ville Syrjälä | d619925 | 2016-05-04 14:45:22 +0300 | [diff] [blame] | 1417 | /* |
| 1418 | * Type 1 DVI adaptors are not required to implement any |
| 1419 | * registers, so we can't always detect their presence. |
| 1420 | * Ideally we should be able to check the state of the |
| 1421 | * CONFIG1 pin, but no such luck on our hardware. |
| 1422 | * |
| 1423 | * The only method left to us is to check the VBT to see |
| 1424 | * if the port is a dual mode capable DP port. But let's |
| 1425 | * only do that when we sucesfully read the EDID, to avoid |
| 1426 | * confusing log messages about DP dual mode adaptors when |
| 1427 | * there's nothing connected to the port. |
| 1428 | */ |
| 1429 | if (type == DRM_DP_DUAL_MODE_UNKNOWN) { |
| 1430 | if (has_edid && |
| 1431 | intel_bios_is_port_dp_dual_mode(dev_priv, port)) { |
| 1432 | DRM_DEBUG_KMS("Assuming DP dual mode adaptor presence based on VBT\n"); |
| 1433 | type = DRM_DP_DUAL_MODE_TYPE1_DVI; |
| 1434 | } else { |
| 1435 | type = DRM_DP_DUAL_MODE_NONE; |
| 1436 | } |
| 1437 | } |
| 1438 | |
| 1439 | if (type == DRM_DP_DUAL_MODE_NONE) |
Ville Syrjälä | b1ba124 | 2016-05-02 22:08:23 +0300 | [diff] [blame] | 1440 | return; |
| 1441 | |
| 1442 | hdmi->dp_dual_mode.type = type; |
| 1443 | hdmi->dp_dual_mode.max_tmds_clock = |
| 1444 | drm_dp_dual_mode_max_tmds_clock(type, adapter); |
| 1445 | |
| 1446 | DRM_DEBUG_KMS("DP dual mode adaptor (%s) detected (max TMDS clock: %d kHz)\n", |
| 1447 | drm_dp_get_dual_mode_type_name(type), |
| 1448 | hdmi->dp_dual_mode.max_tmds_clock); |
| 1449 | } |
| 1450 | |
Chris Wilson | 953ece697 | 2014-09-02 20:04:01 +0100 | [diff] [blame] | 1451 | static bool |
David Weinehall | 23f889b | 2016-08-17 15:47:48 +0300 | [diff] [blame] | 1452 | intel_hdmi_set_edid(struct drm_connector *connector) |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 1453 | { |
Chris Wilson | 953ece697 | 2014-09-02 20:04:01 +0100 | [diff] [blame] | 1454 | struct drm_i915_private *dev_priv = to_i915(connector->dev); |
| 1455 | struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector); |
David Weinehall | 23f889b | 2016-08-17 15:47:48 +0300 | [diff] [blame] | 1456 | struct edid *edid; |
Chris Wilson | 953ece697 | 2014-09-02 20:04:01 +0100 | [diff] [blame] | 1457 | bool connected = false; |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 1458 | |
David Weinehall | 23f889b | 2016-08-17 15:47:48 +0300 | [diff] [blame] | 1459 | intel_display_power_get(dev_priv, POWER_DOMAIN_GMBUS); |
Imre Deak | 671dedd | 2014-03-05 16:20:53 +0200 | [diff] [blame] | 1460 | |
David Weinehall | 23f889b | 2016-08-17 15:47:48 +0300 | [diff] [blame] | 1461 | edid = drm_get_edid(connector, |
| 1462 | intel_gmbus_get_adapter(dev_priv, |
| 1463 | intel_hdmi->ddc_bus)); |
Imre Deak | 671dedd | 2014-03-05 16:20:53 +0200 | [diff] [blame] | 1464 | |
David Weinehall | 23f889b | 2016-08-17 15:47:48 +0300 | [diff] [blame] | 1465 | intel_hdmi_dp_dual_mode_detect(connector, edid != NULL); |
Ville Syrjälä | b1ba124 | 2016-05-02 22:08:23 +0300 | [diff] [blame] | 1466 | |
David Weinehall | 23f889b | 2016-08-17 15:47:48 +0300 | [diff] [blame] | 1467 | intel_display_power_put(dev_priv, POWER_DOMAIN_GMBUS); |
Imre Deak | 671dedd | 2014-03-05 16:20:53 +0200 | [diff] [blame] | 1468 | |
Chris Wilson | 953ece697 | 2014-09-02 20:04:01 +0100 | [diff] [blame] | 1469 | to_intel_connector(connector)->detect_edid = edid; |
| 1470 | if (edid && edid->input & DRM_EDID_INPUT_DIGITAL) { |
| 1471 | intel_hdmi->rgb_quant_range_selectable = |
| 1472 | drm_rgb_quant_range_selectable(edid); |
| 1473 | |
| 1474 | intel_hdmi->has_audio = drm_detect_monitor_audio(edid); |
| 1475 | if (intel_hdmi->force_audio != HDMI_AUDIO_AUTO) |
| 1476 | intel_hdmi->has_audio = |
| 1477 | intel_hdmi->force_audio == HDMI_AUDIO_ON; |
| 1478 | |
| 1479 | if (intel_hdmi->force_audio != HDMI_AUDIO_OFF_DVI) |
| 1480 | intel_hdmi->has_hdmi_sink = |
| 1481 | drm_detect_hdmi_monitor(edid); |
| 1482 | |
| 1483 | connected = true; |
| 1484 | } |
| 1485 | |
| 1486 | return connected; |
| 1487 | } |
| 1488 | |
Daniel Vetter | 8166fce | 2015-10-08 21:50:57 +0200 | [diff] [blame] | 1489 | static enum drm_connector_status |
| 1490 | intel_hdmi_detect(struct drm_connector *connector, bool force) |
Chris Wilson | 953ece697 | 2014-09-02 20:04:01 +0100 | [diff] [blame] | 1491 | { |
Daniel Vetter | 8166fce | 2015-10-08 21:50:57 +0200 | [diff] [blame] | 1492 | enum drm_connector_status status; |
Daniel Vetter | 8166fce | 2015-10-08 21:50:57 +0200 | [diff] [blame] | 1493 | struct drm_i915_private *dev_priv = to_i915(connector->dev); |
Chris Wilson | 953ece697 | 2014-09-02 20:04:01 +0100 | [diff] [blame] | 1494 | |
Daniel Vetter | 8166fce | 2015-10-08 21:50:57 +0200 | [diff] [blame] | 1495 | DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n", |
| 1496 | connector->base.id, connector->name); |
| 1497 | |
Imre Deak | 29bb94b | 2015-11-19 20:55:01 +0200 | [diff] [blame] | 1498 | intel_display_power_get(dev_priv, POWER_DOMAIN_GMBUS); |
| 1499 | |
Daniel Vetter | 8166fce | 2015-10-08 21:50:57 +0200 | [diff] [blame] | 1500 | intel_hdmi_unset_edid(connector); |
Chris Wilson | 953ece697 | 2014-09-02 20:04:01 +0100 | [diff] [blame] | 1501 | |
David Weinehall | 23f889b | 2016-08-17 15:47:48 +0300 | [diff] [blame] | 1502 | if (intel_hdmi_set_edid(connector)) { |
Chris Wilson | 953ece697 | 2014-09-02 20:04:01 +0100 | [diff] [blame] | 1503 | struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector); |
| 1504 | |
| 1505 | hdmi_to_dig_port(intel_hdmi)->base.type = INTEL_OUTPUT_HDMI; |
| 1506 | status = connector_status_connected; |
Daniel Vetter | 8166fce | 2015-10-08 21:50:57 +0200 | [diff] [blame] | 1507 | } else |
Chris Wilson | 953ece697 | 2014-09-02 20:04:01 +0100 | [diff] [blame] | 1508 | status = connector_status_disconnected; |
| 1509 | |
Imre Deak | 29bb94b | 2015-11-19 20:55:01 +0200 | [diff] [blame] | 1510 | intel_display_power_put(dev_priv, POWER_DOMAIN_GMBUS); |
| 1511 | |
Chris Wilson | 953ece697 | 2014-09-02 20:04:01 +0100 | [diff] [blame] | 1512 | return status; |
| 1513 | } |
| 1514 | |
| 1515 | static void |
| 1516 | intel_hdmi_force(struct drm_connector *connector) |
| 1517 | { |
| 1518 | struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector); |
| 1519 | |
| 1520 | DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n", |
| 1521 | connector->base.id, connector->name); |
| 1522 | |
| 1523 | intel_hdmi_unset_edid(connector); |
| 1524 | |
| 1525 | if (connector->status != connector_status_connected) |
| 1526 | return; |
| 1527 | |
David Weinehall | 23f889b | 2016-08-17 15:47:48 +0300 | [diff] [blame] | 1528 | intel_hdmi_set_edid(connector); |
Chris Wilson | 953ece697 | 2014-09-02 20:04:01 +0100 | [diff] [blame] | 1529 | hdmi_to_dig_port(intel_hdmi)->base.type = INTEL_OUTPUT_HDMI; |
| 1530 | } |
| 1531 | |
| 1532 | static int intel_hdmi_get_modes(struct drm_connector *connector) |
| 1533 | { |
| 1534 | struct edid *edid; |
| 1535 | |
| 1536 | edid = to_intel_connector(connector)->detect_edid; |
| 1537 | if (edid == NULL) |
| 1538 | return 0; |
| 1539 | |
| 1540 | return intel_connector_update_modes(connector, edid); |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 1541 | } |
| 1542 | |
Chris Wilson | 1aad7ac | 2011-02-09 18:46:58 +0000 | [diff] [blame] | 1543 | static bool |
| 1544 | intel_hdmi_detect_audio(struct drm_connector *connector) |
| 1545 | { |
Chris Wilson | 1aad7ac | 2011-02-09 18:46:58 +0000 | [diff] [blame] | 1546 | bool has_audio = false; |
Chris Wilson | 953ece697 | 2014-09-02 20:04:01 +0100 | [diff] [blame] | 1547 | struct edid *edid; |
Chris Wilson | 1aad7ac | 2011-02-09 18:46:58 +0000 | [diff] [blame] | 1548 | |
Chris Wilson | 953ece697 | 2014-09-02 20:04:01 +0100 | [diff] [blame] | 1549 | edid = to_intel_connector(connector)->detect_edid; |
| 1550 | if (edid && edid->input & DRM_EDID_INPUT_DIGITAL) |
| 1551 | has_audio = drm_detect_monitor_audio(edid); |
Imre Deak | 671dedd | 2014-03-05 16:20:53 +0200 | [diff] [blame] | 1552 | |
Chris Wilson | 1aad7ac | 2011-02-09 18:46:58 +0000 | [diff] [blame] | 1553 | return has_audio; |
| 1554 | } |
| 1555 | |
Chris Wilson | 55b7d6e8 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 1556 | static int |
| 1557 | intel_hdmi_set_property(struct drm_connector *connector, |
Paulo Zanoni | ed517fb | 2012-05-14 17:12:50 -0300 | [diff] [blame] | 1558 | struct drm_property *property, |
| 1559 | uint64_t val) |
Chris Wilson | 55b7d6e8 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 1560 | { |
| 1561 | struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector); |
Paulo Zanoni | da63a9f | 2012-10-26 19:05:46 -0200 | [diff] [blame] | 1562 | struct intel_digital_port *intel_dig_port = |
| 1563 | hdmi_to_dig_port(intel_hdmi); |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 1564 | struct drm_i915_private *dev_priv = to_i915(connector->dev); |
Chris Wilson | 55b7d6e8 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 1565 | int ret; |
| 1566 | |
Rob Clark | 662595d | 2012-10-11 20:36:04 -0500 | [diff] [blame] | 1567 | ret = drm_object_property_set_value(&connector->base, property, val); |
Chris Wilson | 55b7d6e8 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 1568 | if (ret) |
| 1569 | return ret; |
| 1570 | |
Chris Wilson | 3f43c48 | 2011-05-12 22:17:24 +0100 | [diff] [blame] | 1571 | if (property == dev_priv->force_audio_property) { |
Wu Fengguang | b1d7e4b | 2012-02-14 11:45:36 +0800 | [diff] [blame] | 1572 | enum hdmi_force_audio i = val; |
Chris Wilson | 1aad7ac | 2011-02-09 18:46:58 +0000 | [diff] [blame] | 1573 | bool has_audio; |
| 1574 | |
| 1575 | if (i == intel_hdmi->force_audio) |
Chris Wilson | 55b7d6e8 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 1576 | return 0; |
| 1577 | |
Chris Wilson | 1aad7ac | 2011-02-09 18:46:58 +0000 | [diff] [blame] | 1578 | intel_hdmi->force_audio = i; |
Chris Wilson | 55b7d6e8 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 1579 | |
Wu Fengguang | b1d7e4b | 2012-02-14 11:45:36 +0800 | [diff] [blame] | 1580 | if (i == HDMI_AUDIO_AUTO) |
Chris Wilson | 1aad7ac | 2011-02-09 18:46:58 +0000 | [diff] [blame] | 1581 | has_audio = intel_hdmi_detect_audio(connector); |
| 1582 | else |
Wu Fengguang | b1d7e4b | 2012-02-14 11:45:36 +0800 | [diff] [blame] | 1583 | has_audio = (i == HDMI_AUDIO_ON); |
Chris Wilson | 1aad7ac | 2011-02-09 18:46:58 +0000 | [diff] [blame] | 1584 | |
Wu Fengguang | b1d7e4b | 2012-02-14 11:45:36 +0800 | [diff] [blame] | 1585 | if (i == HDMI_AUDIO_OFF_DVI) |
| 1586 | intel_hdmi->has_hdmi_sink = 0; |
Chris Wilson | 55b7d6e8 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 1587 | |
Chris Wilson | 1aad7ac | 2011-02-09 18:46:58 +0000 | [diff] [blame] | 1588 | intel_hdmi->has_audio = has_audio; |
Chris Wilson | 55b7d6e8 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 1589 | goto done; |
| 1590 | } |
| 1591 | |
Chris Wilson | e953fd7 | 2011-02-21 22:23:52 +0000 | [diff] [blame] | 1592 | if (property == dev_priv->broadcast_rgb_property) { |
Daniel Vetter | ae4edb8 | 2013-04-22 17:07:23 +0200 | [diff] [blame] | 1593 | bool old_auto = intel_hdmi->color_range_auto; |
Ville Syrjälä | 0f2a2a7 | 2015-07-06 15:10:00 +0300 | [diff] [blame] | 1594 | bool old_range = intel_hdmi->limited_color_range; |
Daniel Vetter | ae4edb8 | 2013-04-22 17:07:23 +0200 | [diff] [blame] | 1595 | |
Ville Syrjälä | 55bc60d | 2013-01-17 16:31:29 +0200 | [diff] [blame] | 1596 | switch (val) { |
| 1597 | case INTEL_BROADCAST_RGB_AUTO: |
| 1598 | intel_hdmi->color_range_auto = true; |
| 1599 | break; |
| 1600 | case INTEL_BROADCAST_RGB_FULL: |
| 1601 | intel_hdmi->color_range_auto = false; |
Ville Syrjälä | 0f2a2a7 | 2015-07-06 15:10:00 +0300 | [diff] [blame] | 1602 | intel_hdmi->limited_color_range = false; |
Ville Syrjälä | 55bc60d | 2013-01-17 16:31:29 +0200 | [diff] [blame] | 1603 | break; |
| 1604 | case INTEL_BROADCAST_RGB_LIMITED: |
| 1605 | intel_hdmi->color_range_auto = false; |
Ville Syrjälä | 0f2a2a7 | 2015-07-06 15:10:00 +0300 | [diff] [blame] | 1606 | intel_hdmi->limited_color_range = true; |
Ville Syrjälä | 55bc60d | 2013-01-17 16:31:29 +0200 | [diff] [blame] | 1607 | break; |
| 1608 | default: |
| 1609 | return -EINVAL; |
| 1610 | } |
Daniel Vetter | ae4edb8 | 2013-04-22 17:07:23 +0200 | [diff] [blame] | 1611 | |
| 1612 | if (old_auto == intel_hdmi->color_range_auto && |
Ville Syrjälä | 0f2a2a7 | 2015-07-06 15:10:00 +0300 | [diff] [blame] | 1613 | old_range == intel_hdmi->limited_color_range) |
Daniel Vetter | ae4edb8 | 2013-04-22 17:07:23 +0200 | [diff] [blame] | 1614 | return 0; |
| 1615 | |
Chris Wilson | e953fd7 | 2011-02-21 22:23:52 +0000 | [diff] [blame] | 1616 | goto done; |
| 1617 | } |
| 1618 | |
Vandana Kannan | 94a11dd | 2014-06-11 11:06:01 +0530 | [diff] [blame] | 1619 | if (property == connector->dev->mode_config.aspect_ratio_property) { |
| 1620 | switch (val) { |
| 1621 | case DRM_MODE_PICTURE_ASPECT_NONE: |
| 1622 | intel_hdmi->aspect_ratio = HDMI_PICTURE_ASPECT_NONE; |
| 1623 | break; |
| 1624 | case DRM_MODE_PICTURE_ASPECT_4_3: |
| 1625 | intel_hdmi->aspect_ratio = HDMI_PICTURE_ASPECT_4_3; |
| 1626 | break; |
| 1627 | case DRM_MODE_PICTURE_ASPECT_16_9: |
| 1628 | intel_hdmi->aspect_ratio = HDMI_PICTURE_ASPECT_16_9; |
| 1629 | break; |
| 1630 | default: |
| 1631 | return -EINVAL; |
| 1632 | } |
| 1633 | goto done; |
| 1634 | } |
| 1635 | |
Chris Wilson | 55b7d6e8 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 1636 | return -EINVAL; |
| 1637 | |
| 1638 | done: |
Chris Wilson | c0c36b94 | 2012-12-19 16:08:43 +0000 | [diff] [blame] | 1639 | if (intel_dig_port->base.base.crtc) |
| 1640 | intel_crtc_restore_mode(intel_dig_port->base.base.crtc); |
Chris Wilson | 55b7d6e8 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 1641 | |
| 1642 | return 0; |
| 1643 | } |
| 1644 | |
Maarten Lankhorst | fd6bbda | 2016-08-09 17:04:04 +0200 | [diff] [blame] | 1645 | static void intel_hdmi_pre_enable(struct intel_encoder *encoder, |
| 1646 | struct intel_crtc_state *pipe_config, |
| 1647 | struct drm_connector_state *conn_state) |
Jesse Barnes | 13732ba | 2014-04-05 11:51:35 -0700 | [diff] [blame] | 1648 | { |
| 1649 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&encoder->base); |
Jesse Barnes | 13732ba | 2014-04-05 11:51:35 -0700 | [diff] [blame] | 1650 | |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 1651 | intel_hdmi_prepare(encoder, pipe_config); |
Daniel Vetter | 4cde8a2 | 2014-04-24 23:54:56 +0200 | [diff] [blame] | 1652 | |
Daniel Vetter | 6897b4b5 | 2014-04-24 23:54:47 +0200 | [diff] [blame] | 1653 | intel_hdmi->set_infoframes(&encoder->base, |
Maarten Lankhorst | df18e72 | 2016-11-08 13:55:37 +0100 | [diff] [blame] | 1654 | pipe_config->has_hdmi_sink, |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 1655 | pipe_config, conn_state); |
Jesse Barnes | 13732ba | 2014-04-05 11:51:35 -0700 | [diff] [blame] | 1656 | } |
| 1657 | |
Maarten Lankhorst | fd6bbda | 2016-08-09 17:04:04 +0200 | [diff] [blame] | 1658 | static void vlv_hdmi_pre_enable(struct intel_encoder *encoder, |
| 1659 | struct intel_crtc_state *pipe_config, |
| 1660 | struct drm_connector_state *conn_state) |
Jesse Barnes | 89b667f | 2013-04-18 14:51:36 -0700 | [diff] [blame] | 1661 | { |
| 1662 | struct intel_digital_port *dport = enc_to_dig_port(&encoder->base); |
Jesse Barnes | 13732ba | 2014-04-05 11:51:35 -0700 | [diff] [blame] | 1663 | struct intel_hdmi *intel_hdmi = &dport->hdmi; |
Jesse Barnes | 89b667f | 2013-04-18 14:51:36 -0700 | [diff] [blame] | 1664 | struct drm_device *dev = encoder->base.dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 1665 | struct drm_i915_private *dev_priv = to_i915(dev); |
Jesse Barnes | 89b667f | 2013-04-18 14:51:36 -0700 | [diff] [blame] | 1666 | |
Ander Conselvan de Oliveira | 5f68c27 | 2016-04-27 15:44:24 +0300 | [diff] [blame] | 1667 | vlv_phy_pre_encoder_enable(encoder); |
Jani Nikula | b76cf76 | 2013-07-30 12:20:31 +0300 | [diff] [blame] | 1668 | |
Ander Conselvan de Oliveira | 53d9872 | 2016-04-27 15:44:22 +0300 | [diff] [blame] | 1669 | /* HDMI 1.0V-2dB */ |
| 1670 | vlv_set_phy_signal_level(encoder, 0x2b245f5f, 0x00002000, 0x5578b83a, |
| 1671 | 0x2b247878); |
| 1672 | |
Daniel Vetter | 6897b4b5 | 2014-04-24 23:54:47 +0200 | [diff] [blame] | 1673 | intel_hdmi->set_infoframes(&encoder->base, |
Maarten Lankhorst | df18e72 | 2016-11-08 13:55:37 +0100 | [diff] [blame] | 1674 | pipe_config->has_hdmi_sink, |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 1675 | pipe_config, conn_state); |
Jesse Barnes | 13732ba | 2014-04-05 11:51:35 -0700 | [diff] [blame] | 1676 | |
Maarten Lankhorst | fd6bbda | 2016-08-09 17:04:04 +0200 | [diff] [blame] | 1677 | g4x_enable_hdmi(encoder, pipe_config, conn_state); |
Jani Nikula | b76cf76 | 2013-07-30 12:20:31 +0300 | [diff] [blame] | 1678 | |
Ville Syrjälä | 9b6de0a | 2015-04-10 18:21:31 +0300 | [diff] [blame] | 1679 | vlv_wait_port_ready(dev_priv, dport, 0x0); |
Jesse Barnes | 89b667f | 2013-04-18 14:51:36 -0700 | [diff] [blame] | 1680 | } |
| 1681 | |
Maarten Lankhorst | fd6bbda | 2016-08-09 17:04:04 +0200 | [diff] [blame] | 1682 | static void vlv_hdmi_pre_pll_enable(struct intel_encoder *encoder, |
| 1683 | struct intel_crtc_state *pipe_config, |
| 1684 | struct drm_connector_state *conn_state) |
Jesse Barnes | 89b667f | 2013-04-18 14:51:36 -0700 | [diff] [blame] | 1685 | { |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 1686 | intel_hdmi_prepare(encoder, pipe_config); |
Daniel Vetter | 4cde8a2 | 2014-04-24 23:54:56 +0200 | [diff] [blame] | 1687 | |
Ander Conselvan de Oliveira | 6da2e61 | 2016-04-27 15:44:23 +0300 | [diff] [blame] | 1688 | vlv_phy_pre_pll_enable(encoder); |
Jesse Barnes | 89b667f | 2013-04-18 14:51:36 -0700 | [diff] [blame] | 1689 | } |
| 1690 | |
Maarten Lankhorst | fd6bbda | 2016-08-09 17:04:04 +0200 | [diff] [blame] | 1691 | static void chv_hdmi_pre_pll_enable(struct intel_encoder *encoder, |
| 1692 | struct intel_crtc_state *pipe_config, |
| 1693 | struct drm_connector_state *conn_state) |
Ville Syrjälä | 9197c88 | 2014-04-09 13:29:05 +0300 | [diff] [blame] | 1694 | { |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 1695 | intel_hdmi_prepare(encoder, pipe_config); |
Ville Syrjälä | 625695f | 2014-06-28 02:04:02 +0300 | [diff] [blame] | 1696 | |
Ander Conselvan de Oliveira | 419b1b7 | 2016-04-27 15:44:19 +0300 | [diff] [blame] | 1697 | chv_phy_pre_pll_enable(encoder); |
Ville Syrjälä | 9197c88 | 2014-04-09 13:29:05 +0300 | [diff] [blame] | 1698 | } |
| 1699 | |
Maarten Lankhorst | fd6bbda | 2016-08-09 17:04:04 +0200 | [diff] [blame] | 1700 | static void chv_hdmi_post_pll_disable(struct intel_encoder *encoder, |
| 1701 | struct intel_crtc_state *old_crtc_state, |
| 1702 | struct drm_connector_state *old_conn_state) |
Ville Syrjälä | d6db995 | 2015-07-08 23:45:49 +0300 | [diff] [blame] | 1703 | { |
Ander Conselvan de Oliveira | 204970b | 2016-04-27 15:44:21 +0300 | [diff] [blame] | 1704 | chv_phy_post_pll_disable(encoder); |
Ville Syrjälä | d6db995 | 2015-07-08 23:45:49 +0300 | [diff] [blame] | 1705 | } |
| 1706 | |
Maarten Lankhorst | fd6bbda | 2016-08-09 17:04:04 +0200 | [diff] [blame] | 1707 | static void vlv_hdmi_post_disable(struct intel_encoder *encoder, |
| 1708 | struct intel_crtc_state *old_crtc_state, |
| 1709 | struct drm_connector_state *old_conn_state) |
Jesse Barnes | 89b667f | 2013-04-18 14:51:36 -0700 | [diff] [blame] | 1710 | { |
Jesse Barnes | 89b667f | 2013-04-18 14:51:36 -0700 | [diff] [blame] | 1711 | /* Reset lanes to avoid HDMI flicker (VLV w/a) */ |
Ander Conselvan de Oliveira | 0f572eb | 2016-04-27 15:44:25 +0300 | [diff] [blame] | 1712 | vlv_phy_reset_lanes(encoder); |
Jesse Barnes | 89b667f | 2013-04-18 14:51:36 -0700 | [diff] [blame] | 1713 | } |
| 1714 | |
Maarten Lankhorst | fd6bbda | 2016-08-09 17:04:04 +0200 | [diff] [blame] | 1715 | static void chv_hdmi_post_disable(struct intel_encoder *encoder, |
| 1716 | struct intel_crtc_state *old_crtc_state, |
| 1717 | struct drm_connector_state *old_conn_state) |
Ville Syrjälä | 580d381 | 2014-04-09 13:29:00 +0300 | [diff] [blame] | 1718 | { |
Ville Syrjälä | 580d381 | 2014-04-09 13:29:00 +0300 | [diff] [blame] | 1719 | struct drm_device *dev = encoder->base.dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 1720 | struct drm_i915_private *dev_priv = to_i915(dev); |
Ville Syrjälä | 580d381 | 2014-04-09 13:29:00 +0300 | [diff] [blame] | 1721 | |
Ville Syrjälä | a580516 | 2015-05-26 20:42:30 +0300 | [diff] [blame] | 1722 | mutex_lock(&dev_priv->sb_lock); |
Ville Syrjälä | 580d381 | 2014-04-09 13:29:00 +0300 | [diff] [blame] | 1723 | |
Ville Syrjälä | a8f327f | 2015-07-09 20:14:11 +0300 | [diff] [blame] | 1724 | /* Assert data lane reset */ |
| 1725 | chv_data_lane_soft_reset(encoder, true); |
Ville Syrjälä | 580d381 | 2014-04-09 13:29:00 +0300 | [diff] [blame] | 1726 | |
Ville Syrjälä | a580516 | 2015-05-26 20:42:30 +0300 | [diff] [blame] | 1727 | mutex_unlock(&dev_priv->sb_lock); |
Ville Syrjälä | 580d381 | 2014-04-09 13:29:00 +0300 | [diff] [blame] | 1728 | } |
| 1729 | |
Maarten Lankhorst | fd6bbda | 2016-08-09 17:04:04 +0200 | [diff] [blame] | 1730 | static void chv_hdmi_pre_enable(struct intel_encoder *encoder, |
| 1731 | struct intel_crtc_state *pipe_config, |
| 1732 | struct drm_connector_state *conn_state) |
Chon Ming Lee | e4a1d84 | 2014-04-09 13:28:20 +0300 | [diff] [blame] | 1733 | { |
| 1734 | struct intel_digital_port *dport = enc_to_dig_port(&encoder->base); |
Clint Taylor | b4eb156 | 2014-11-21 11:13:02 -0800 | [diff] [blame] | 1735 | struct intel_hdmi *intel_hdmi = &dport->hdmi; |
Chon Ming Lee | e4a1d84 | 2014-04-09 13:28:20 +0300 | [diff] [blame] | 1736 | struct drm_device *dev = encoder->base.dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 1737 | struct drm_i915_private *dev_priv = to_i915(dev); |
Chon Ming Lee | e4a1d84 | 2014-04-09 13:28:20 +0300 | [diff] [blame] | 1738 | |
Ander Conselvan de Oliveira | e7d2a717 | 2016-04-27 15:44:20 +0300 | [diff] [blame] | 1739 | chv_phy_pre_encoder_enable(encoder); |
Ville Syrjälä | a02ef3c | 2014-08-18 14:42:45 +0300 | [diff] [blame] | 1740 | |
Chon Ming Lee | e4a1d84 | 2014-04-09 13:28:20 +0300 | [diff] [blame] | 1741 | /* FIXME: Program the support xxx V-dB */ |
| 1742 | /* Use 800mV-0dB */ |
Ander Conselvan de Oliveira | b7fa22d | 2016-04-27 15:44:17 +0300 | [diff] [blame] | 1743 | chv_set_phy_signal_level(encoder, 128, 102, false); |
Chon Ming Lee | e4a1d84 | 2014-04-09 13:28:20 +0300 | [diff] [blame] | 1744 | |
Clint Taylor | b4eb156 | 2014-11-21 11:13:02 -0800 | [diff] [blame] | 1745 | intel_hdmi->set_infoframes(&encoder->base, |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 1746 | pipe_config->has_hdmi_sink, |
| 1747 | pipe_config, conn_state); |
Clint Taylor | b4eb156 | 2014-11-21 11:13:02 -0800 | [diff] [blame] | 1748 | |
Maarten Lankhorst | fd6bbda | 2016-08-09 17:04:04 +0200 | [diff] [blame] | 1749 | g4x_enable_hdmi(encoder, pipe_config, conn_state); |
Chon Ming Lee | e4a1d84 | 2014-04-09 13:28:20 +0300 | [diff] [blame] | 1750 | |
Ville Syrjälä | 9b6de0a | 2015-04-10 18:21:31 +0300 | [diff] [blame] | 1751 | vlv_wait_port_ready(dev_priv, dport, 0x0); |
Ville Syrjälä | b0b3384 | 2015-07-08 23:45:55 +0300 | [diff] [blame] | 1752 | |
| 1753 | /* Second common lane will stay alive on its own now */ |
Ander Conselvan de Oliveira | e7d2a717 | 2016-04-27 15:44:20 +0300 | [diff] [blame] | 1754 | chv_phy_release_cl2_override(encoder); |
Chon Ming Lee | e4a1d84 | 2014-04-09 13:28:20 +0300 | [diff] [blame] | 1755 | } |
| 1756 | |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 1757 | static void intel_hdmi_destroy(struct drm_connector *connector) |
| 1758 | { |
Chris Wilson | 10e972d | 2014-09-04 21:43:45 +0100 | [diff] [blame] | 1759 | kfree(to_intel_connector(connector)->detect_edid); |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 1760 | drm_connector_cleanup(connector); |
Zhenyu Wang | 674e2d0 | 2010-03-29 15:57:42 +0800 | [diff] [blame] | 1761 | kfree(connector); |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 1762 | } |
| 1763 | |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 1764 | static const struct drm_connector_funcs intel_hdmi_connector_funcs = { |
Maarten Lankhorst | 4d688a2 | 2015-08-05 12:37:06 +0200 | [diff] [blame] | 1765 | .dpms = drm_atomic_helper_connector_dpms, |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 1766 | .detect = intel_hdmi_detect, |
Chris Wilson | 953ece697 | 2014-09-02 20:04:01 +0100 | [diff] [blame] | 1767 | .force = intel_hdmi_force, |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 1768 | .fill_modes = drm_helper_probe_single_connector_modes, |
Chris Wilson | 55b7d6e8 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 1769 | .set_property = intel_hdmi_set_property, |
Matt Roper | 2545e4a | 2015-01-22 16:51:27 -0800 | [diff] [blame] | 1770 | .atomic_get_property = intel_connector_atomic_get_property, |
Chris Wilson | 1ebaa0b | 2016-06-24 14:00:15 +0100 | [diff] [blame] | 1771 | .late_register = intel_connector_register, |
Chris Wilson | c191eca | 2016-06-17 11:40:33 +0100 | [diff] [blame] | 1772 | .early_unregister = intel_connector_unregister, |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 1773 | .destroy = intel_hdmi_destroy, |
Matt Roper | c6f95f2 | 2015-01-22 16:50:32 -0800 | [diff] [blame] | 1774 | .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, |
Ander Conselvan de Oliveira | 9896972 | 2015-03-20 16:18:06 +0200 | [diff] [blame] | 1775 | .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 1776 | }; |
| 1777 | |
| 1778 | static const struct drm_connector_helper_funcs intel_hdmi_connector_helper_funcs = { |
| 1779 | .get_modes = intel_hdmi_get_modes, |
| 1780 | .mode_valid = intel_hdmi_mode_valid, |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 1781 | }; |
| 1782 | |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 1783 | static const struct drm_encoder_funcs intel_hdmi_enc_funcs = { |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 1784 | .destroy = intel_encoder_destroy, |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 1785 | }; |
| 1786 | |
Chris Wilson | 55b7d6e8 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 1787 | static void |
| 1788 | intel_hdmi_add_properties(struct intel_hdmi *intel_hdmi, struct drm_connector *connector) |
| 1789 | { |
Chris Wilson | 3f43c48 | 2011-05-12 22:17:24 +0100 | [diff] [blame] | 1790 | intel_attach_force_audio_property(connector); |
Chris Wilson | e953fd7 | 2011-02-21 22:23:52 +0000 | [diff] [blame] | 1791 | intel_attach_broadcast_rgb_property(connector); |
Ville Syrjälä | 55bc60d | 2013-01-17 16:31:29 +0200 | [diff] [blame] | 1792 | intel_hdmi->color_range_auto = true; |
Vandana Kannan | 94a11dd | 2014-06-11 11:06:01 +0530 | [diff] [blame] | 1793 | intel_attach_aspect_ratio_property(connector); |
| 1794 | intel_hdmi->aspect_ratio = HDMI_PICTURE_ASPECT_NONE; |
Chris Wilson | 55b7d6e8 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 1795 | } |
| 1796 | |
Ville Syrjälä | e4ab73a | 2016-10-11 20:52:46 +0300 | [diff] [blame] | 1797 | static u8 intel_hdmi_ddc_pin(struct drm_i915_private *dev_priv, |
| 1798 | enum port port) |
| 1799 | { |
| 1800 | const struct ddi_vbt_port_info *info = |
| 1801 | &dev_priv->vbt.ddi_port_info[port]; |
| 1802 | u8 ddc_pin; |
| 1803 | |
| 1804 | if (info->alternate_ddc_pin) { |
| 1805 | DRM_DEBUG_KMS("Using DDC pin 0x%x for port %c (VBT)\n", |
| 1806 | info->alternate_ddc_pin, port_name(port)); |
| 1807 | return info->alternate_ddc_pin; |
| 1808 | } |
| 1809 | |
| 1810 | switch (port) { |
| 1811 | case PORT_B: |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 1812 | if (IS_GEN9_LP(dev_priv)) |
Ville Syrjälä | e4ab73a | 2016-10-11 20:52:46 +0300 | [diff] [blame] | 1813 | ddc_pin = GMBUS_PIN_1_BXT; |
| 1814 | else |
| 1815 | ddc_pin = GMBUS_PIN_DPB; |
| 1816 | break; |
| 1817 | case PORT_C: |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 1818 | if (IS_GEN9_LP(dev_priv)) |
Ville Syrjälä | e4ab73a | 2016-10-11 20:52:46 +0300 | [diff] [blame] | 1819 | ddc_pin = GMBUS_PIN_2_BXT; |
| 1820 | else |
| 1821 | ddc_pin = GMBUS_PIN_DPC; |
| 1822 | break; |
| 1823 | case PORT_D: |
| 1824 | if (IS_CHERRYVIEW(dev_priv)) |
| 1825 | ddc_pin = GMBUS_PIN_DPD_CHV; |
| 1826 | else |
| 1827 | ddc_pin = GMBUS_PIN_DPD; |
| 1828 | break; |
| 1829 | default: |
| 1830 | MISSING_CASE(port); |
| 1831 | ddc_pin = GMBUS_PIN_DPB; |
| 1832 | break; |
| 1833 | } |
| 1834 | |
| 1835 | DRM_DEBUG_KMS("Using DDC pin 0x%x for port %c (platform default)\n", |
| 1836 | ddc_pin, port_name(port)); |
| 1837 | |
| 1838 | return ddc_pin; |
| 1839 | } |
| 1840 | |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 1841 | void intel_hdmi_init_connector(struct intel_digital_port *intel_dig_port, |
| 1842 | struct intel_connector *intel_connector) |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 1843 | { |
Paulo Zanoni | b9cb234 | 2012-10-26 19:05:47 -0200 | [diff] [blame] | 1844 | struct drm_connector *connector = &intel_connector->base; |
| 1845 | struct intel_hdmi *intel_hdmi = &intel_dig_port->hdmi; |
| 1846 | struct intel_encoder *intel_encoder = &intel_dig_port->base; |
| 1847 | struct drm_device *dev = intel_encoder->base.dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 1848 | struct drm_i915_private *dev_priv = to_i915(dev); |
Paulo Zanoni | 174edf1 | 2012-10-26 19:05:50 -0200 | [diff] [blame] | 1849 | enum port port = intel_dig_port->port; |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 1850 | |
Ville Syrjälä | 22f35042 | 2016-06-03 12:17:43 +0300 | [diff] [blame] | 1851 | DRM_DEBUG_KMS("Adding HDMI connector on port %c\n", |
| 1852 | port_name(port)); |
| 1853 | |
Ville Syrjälä | ccb1a83 | 2015-12-08 19:59:38 +0200 | [diff] [blame] | 1854 | if (WARN(intel_dig_port->max_lanes < 4, |
| 1855 | "Not enough lanes (%d) for HDMI on port %c\n", |
| 1856 | intel_dig_port->max_lanes, port_name(port))) |
| 1857 | return; |
| 1858 | |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 1859 | drm_connector_init(dev, connector, &intel_hdmi_connector_funcs, |
Adam Jackson | 8d91104 | 2009-09-23 15:08:29 -0400 | [diff] [blame] | 1860 | DRM_MODE_CONNECTOR_HDMIA); |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 1861 | drm_connector_helper_add(connector, &intel_hdmi_connector_helper_funcs); |
| 1862 | |
Peter Ross | c3febcc | 2012-01-28 14:49:26 +0100 | [diff] [blame] | 1863 | connector->interlace_allowed = 1; |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 1864 | connector->doublescan_allowed = 0; |
Damien Lespiau | 573e74a | 2013-09-25 16:45:40 +0100 | [diff] [blame] | 1865 | connector->stereo_allowed = 1; |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 1866 | |
Ville Syrjälä | e4ab73a | 2016-10-11 20:52:46 +0300 | [diff] [blame] | 1867 | intel_hdmi->ddc_bus = intel_hdmi_ddc_pin(dev_priv, port); |
| 1868 | |
Daniel Vetter | 08d644a | 2012-07-12 20:19:59 +0200 | [diff] [blame] | 1869 | switch (port) { |
| 1870 | case PORT_B: |
Ander Conselvan de Oliveira | ca4c389 | 2017-02-03 16:03:13 +0200 | [diff] [blame] | 1871 | intel_encoder->hpd_pin = HPD_PORT_B; |
Daniel Vetter | 08d644a | 2012-07-12 20:19:59 +0200 | [diff] [blame] | 1872 | break; |
| 1873 | case PORT_C: |
Egbert Eich | 1d843f9 | 2013-02-25 12:06:49 -0500 | [diff] [blame] | 1874 | intel_encoder->hpd_pin = HPD_PORT_C; |
Daniel Vetter | 08d644a | 2012-07-12 20:19:59 +0200 | [diff] [blame] | 1875 | break; |
| 1876 | case PORT_D: |
Egbert Eich | 1d843f9 | 2013-02-25 12:06:49 -0500 | [diff] [blame] | 1877 | intel_encoder->hpd_pin = HPD_PORT_D; |
Daniel Vetter | 08d644a | 2012-07-12 20:19:59 +0200 | [diff] [blame] | 1878 | break; |
Xiong Zhang | 11c1b65 | 2015-08-17 16:04:04 +0800 | [diff] [blame] | 1879 | case PORT_E: |
Xiong Zhang | 11c1b65 | 2015-08-17 16:04:04 +0800 | [diff] [blame] | 1880 | intel_encoder->hpd_pin = HPD_PORT_E; |
| 1881 | break; |
Daniel Vetter | 08d644a | 2012-07-12 20:19:59 +0200 | [diff] [blame] | 1882 | default: |
Ville Syrjälä | e4ab73a | 2016-10-11 20:52:46 +0300 | [diff] [blame] | 1883 | MISSING_CASE(port); |
| 1884 | return; |
Ma Ling | f8aed70 | 2009-08-24 13:50:24 +0800 | [diff] [blame] | 1885 | } |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 1886 | |
Tvrtko Ursulin | 920a14b | 2016-10-14 10:13:44 +0100 | [diff] [blame] | 1887 | if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) { |
Shobhit Kumar | 90b107c | 2012-03-28 13:39:32 -0700 | [diff] [blame] | 1888 | intel_hdmi->write_infoframe = vlv_write_infoframe; |
Paulo Zanoni | 687f4d0 | 2012-05-28 16:42:48 -0300 | [diff] [blame] | 1889 | intel_hdmi->set_infoframes = vlv_set_infoframes; |
Jesse Barnes | e43823e | 2014-11-05 14:26:08 -0800 | [diff] [blame] | 1890 | intel_hdmi->infoframe_enabled = vlv_infoframe_enabled; |
Tvrtko Ursulin | 9beb5fe | 2016-10-13 11:03:06 +0100 | [diff] [blame] | 1891 | } else if (IS_G4X(dev_priv)) { |
Jesse Barnes | 7637bfd | 2013-03-08 10:46:01 -0800 | [diff] [blame] | 1892 | intel_hdmi->write_infoframe = g4x_write_infoframe; |
| 1893 | intel_hdmi->set_infoframes = g4x_set_infoframes; |
Jesse Barnes | e43823e | 2014-11-05 14:26:08 -0800 | [diff] [blame] | 1894 | intel_hdmi->infoframe_enabled = g4x_infoframe_enabled; |
Tvrtko Ursulin | 4f8036a | 2016-10-13 11:02:52 +0100 | [diff] [blame] | 1895 | } else if (HAS_DDI(dev_priv)) { |
Eugeni Dodonov | 8c5f5f7 | 2012-05-10 10:18:02 -0300 | [diff] [blame] | 1896 | intel_hdmi->write_infoframe = hsw_write_infoframe; |
Paulo Zanoni | 687f4d0 | 2012-05-28 16:42:48 -0300 | [diff] [blame] | 1897 | intel_hdmi->set_infoframes = hsw_set_infoframes; |
Jesse Barnes | e43823e | 2014-11-05 14:26:08 -0800 | [diff] [blame] | 1898 | intel_hdmi->infoframe_enabled = hsw_infoframe_enabled; |
Tvrtko Ursulin | 6e26695 | 2016-10-13 11:02:53 +0100 | [diff] [blame] | 1899 | } else if (HAS_PCH_IBX(dev_priv)) { |
Paulo Zanoni | fdf1250 | 2012-05-04 17:18:24 -0300 | [diff] [blame] | 1900 | intel_hdmi->write_infoframe = ibx_write_infoframe; |
Paulo Zanoni | 687f4d0 | 2012-05-28 16:42:48 -0300 | [diff] [blame] | 1901 | intel_hdmi->set_infoframes = ibx_set_infoframes; |
Jesse Barnes | e43823e | 2014-11-05 14:26:08 -0800 | [diff] [blame] | 1902 | intel_hdmi->infoframe_enabled = ibx_infoframe_enabled; |
Paulo Zanoni | fdf1250 | 2012-05-04 17:18:24 -0300 | [diff] [blame] | 1903 | } else { |
| 1904 | intel_hdmi->write_infoframe = cpt_write_infoframe; |
Paulo Zanoni | 687f4d0 | 2012-05-28 16:42:48 -0300 | [diff] [blame] | 1905 | intel_hdmi->set_infoframes = cpt_set_infoframes; |
Jesse Barnes | e43823e | 2014-11-05 14:26:08 -0800 | [diff] [blame] | 1906 | intel_hdmi->infoframe_enabled = cpt_infoframe_enabled; |
Jesse Barnes | 64a8fc0 | 2011-09-22 11:16:00 +0530 | [diff] [blame] | 1907 | } |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 1908 | |
Tvrtko Ursulin | 4f8036a | 2016-10-13 11:02:52 +0100 | [diff] [blame] | 1909 | if (HAS_DDI(dev_priv)) |
Paulo Zanoni | bcbc889 | 2012-10-26 19:05:51 -0200 | [diff] [blame] | 1910 | intel_connector->get_hw_state = intel_ddi_connector_get_hw_state; |
| 1911 | else |
| 1912 | intel_connector->get_hw_state = intel_connector_get_hw_state; |
Paulo Zanoni | b9cb234 | 2012-10-26 19:05:47 -0200 | [diff] [blame] | 1913 | |
| 1914 | intel_hdmi_add_properties(intel_hdmi, connector); |
| 1915 | |
| 1916 | intel_connector_attach_encoder(intel_connector, intel_encoder); |
Shashank Sharma | d8b4c43 | 2015-09-04 18:56:11 +0530 | [diff] [blame] | 1917 | intel_hdmi->attached_connector = intel_connector; |
Paulo Zanoni | b9cb234 | 2012-10-26 19:05:47 -0200 | [diff] [blame] | 1918 | |
| 1919 | /* For G4X desktop chip, PEG_BAND_GAP_DATA 3:0 must first be written |
| 1920 | * 0xd. Failure to do so will result in spurious interrupts being |
| 1921 | * generated on the port when a cable is not attached. |
| 1922 | */ |
Tvrtko Ursulin | 50a0bc9 | 2016-10-13 11:02:58 +0100 | [diff] [blame] | 1923 | if (IS_G4X(dev_priv) && !IS_GM45(dev_priv)) { |
Paulo Zanoni | b9cb234 | 2012-10-26 19:05:47 -0200 | [diff] [blame] | 1924 | u32 temp = I915_READ(PEG_BAND_GAP_DATA); |
| 1925 | I915_WRITE(PEG_BAND_GAP_DATA, (temp & ~0xf) | 0xd); |
| 1926 | } |
| 1927 | } |
| 1928 | |
Ander Conselvan de Oliveira | c39055b | 2016-11-23 16:21:44 +0200 | [diff] [blame] | 1929 | void intel_hdmi_init(struct drm_i915_private *dev_priv, |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 1930 | i915_reg_t hdmi_reg, enum port port) |
Paulo Zanoni | b9cb234 | 2012-10-26 19:05:47 -0200 | [diff] [blame] | 1931 | { |
| 1932 | struct intel_digital_port *intel_dig_port; |
| 1933 | struct intel_encoder *intel_encoder; |
Paulo Zanoni | b9cb234 | 2012-10-26 19:05:47 -0200 | [diff] [blame] | 1934 | struct intel_connector *intel_connector; |
| 1935 | |
Daniel Vetter | b14c567 | 2013-09-19 12:18:32 +0200 | [diff] [blame] | 1936 | intel_dig_port = kzalloc(sizeof(*intel_dig_port), GFP_KERNEL); |
Paulo Zanoni | b9cb234 | 2012-10-26 19:05:47 -0200 | [diff] [blame] | 1937 | if (!intel_dig_port) |
| 1938 | return; |
| 1939 | |
Ander Conselvan de Oliveira | 08d9bc9 | 2015-04-10 10:59:10 +0300 | [diff] [blame] | 1940 | intel_connector = intel_connector_alloc(); |
Paulo Zanoni | b9cb234 | 2012-10-26 19:05:47 -0200 | [diff] [blame] | 1941 | if (!intel_connector) { |
| 1942 | kfree(intel_dig_port); |
| 1943 | return; |
| 1944 | } |
| 1945 | |
| 1946 | intel_encoder = &intel_dig_port->base; |
Paulo Zanoni | b9cb234 | 2012-10-26 19:05:47 -0200 | [diff] [blame] | 1947 | |
Ander Conselvan de Oliveira | c39055b | 2016-11-23 16:21:44 +0200 | [diff] [blame] | 1948 | drm_encoder_init(&dev_priv->drm, &intel_encoder->base, |
| 1949 | &intel_hdmi_enc_funcs, DRM_MODE_ENCODER_TMDS, |
| 1950 | "HDMI %c", port_name(port)); |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 1951 | |
Daniel Vetter | 5bfe2ac | 2013-03-27 00:44:55 +0100 | [diff] [blame] | 1952 | intel_encoder->compute_config = intel_hdmi_compute_config; |
Tvrtko Ursulin | 6e26695 | 2016-10-13 11:02:53 +0100 | [diff] [blame] | 1953 | if (HAS_PCH_SPLIT(dev_priv)) { |
Ville Syrjälä | a4790ce | 2015-05-05 17:17:35 +0300 | [diff] [blame] | 1954 | intel_encoder->disable = pch_disable_hdmi; |
| 1955 | intel_encoder->post_disable = pch_post_disable_hdmi; |
| 1956 | } else { |
| 1957 | intel_encoder->disable = g4x_disable_hdmi; |
| 1958 | } |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 1959 | intel_encoder->get_hw_state = intel_hdmi_get_hw_state; |
Jesse Barnes | 045ac3b | 2013-05-14 17:08:26 -0700 | [diff] [blame] | 1960 | intel_encoder->get_config = intel_hdmi_get_config; |
Tvrtko Ursulin | 920a14b | 2016-10-14 10:13:44 +0100 | [diff] [blame] | 1961 | if (IS_CHERRYVIEW(dev_priv)) { |
Ville Syrjälä | 9197c88 | 2014-04-09 13:29:05 +0300 | [diff] [blame] | 1962 | intel_encoder->pre_pll_enable = chv_hdmi_pre_pll_enable; |
Chon Ming Lee | e4a1d84 | 2014-04-09 13:28:20 +0300 | [diff] [blame] | 1963 | intel_encoder->pre_enable = chv_hdmi_pre_enable; |
| 1964 | intel_encoder->enable = vlv_enable_hdmi; |
Ville Syrjälä | 580d381 | 2014-04-09 13:29:00 +0300 | [diff] [blame] | 1965 | intel_encoder->post_disable = chv_hdmi_post_disable; |
Ville Syrjälä | d6db995 | 2015-07-08 23:45:49 +0300 | [diff] [blame] | 1966 | intel_encoder->post_pll_disable = chv_hdmi_post_pll_disable; |
Tvrtko Ursulin | 11a914c | 2016-10-13 11:03:08 +0100 | [diff] [blame] | 1967 | } else if (IS_VALLEYVIEW(dev_priv)) { |
Chon Ming Lee | 9514ac6 | 2013-10-16 17:07:41 +0800 | [diff] [blame] | 1968 | intel_encoder->pre_pll_enable = vlv_hdmi_pre_pll_enable; |
| 1969 | intel_encoder->pre_enable = vlv_hdmi_pre_enable; |
Jani Nikula | b76cf76 | 2013-07-30 12:20:31 +0300 | [diff] [blame] | 1970 | intel_encoder->enable = vlv_enable_hdmi; |
Chon Ming Lee | 9514ac6 | 2013-10-16 17:07:41 +0800 | [diff] [blame] | 1971 | intel_encoder->post_disable = vlv_hdmi_post_disable; |
Jani Nikula | b76cf76 | 2013-07-30 12:20:31 +0300 | [diff] [blame] | 1972 | } else { |
Jesse Barnes | 13732ba | 2014-04-05 11:51:35 -0700 | [diff] [blame] | 1973 | intel_encoder->pre_enable = intel_hdmi_pre_enable; |
Tvrtko Ursulin | 6e26695 | 2016-10-13 11:02:53 +0100 | [diff] [blame] | 1974 | if (HAS_PCH_CPT(dev_priv)) |
Ville Syrjälä | d1b1589 | 2015-05-05 17:06:19 +0300 | [diff] [blame] | 1975 | intel_encoder->enable = cpt_enable_hdmi; |
Tvrtko Ursulin | 6e26695 | 2016-10-13 11:02:53 +0100 | [diff] [blame] | 1976 | else if (HAS_PCH_IBX(dev_priv)) |
Ville Syrjälä | bf868c7 | 2015-05-05 17:06:23 +0300 | [diff] [blame] | 1977 | intel_encoder->enable = ibx_enable_hdmi; |
Ville Syrjälä | d1b1589 | 2015-05-05 17:06:19 +0300 | [diff] [blame] | 1978 | else |
Ville Syrjälä | bf868c7 | 2015-05-05 17:06:23 +0300 | [diff] [blame] | 1979 | intel_encoder->enable = g4x_enable_hdmi; |
Jesse Barnes | 89b667f | 2013-04-18 14:51:36 -0700 | [diff] [blame] | 1980 | } |
Daniel Vetter | 5ab432e | 2012-06-30 08:59:56 +0200 | [diff] [blame] | 1981 | |
Paulo Zanoni | b9cb234 | 2012-10-26 19:05:47 -0200 | [diff] [blame] | 1982 | intel_encoder->type = INTEL_OUTPUT_HDMI; |
Pandiyan, Dhinakaran | 03cdc1d | 2016-09-19 18:24:38 -0700 | [diff] [blame] | 1983 | intel_encoder->port = port; |
Tvrtko Ursulin | 920a14b | 2016-10-14 10:13:44 +0100 | [diff] [blame] | 1984 | if (IS_CHERRYVIEW(dev_priv)) { |
Ville Syrjälä | 882ec38 | 2014-04-28 14:07:43 +0300 | [diff] [blame] | 1985 | if (port == PORT_D) |
| 1986 | intel_encoder->crtc_mask = 1 << 2; |
| 1987 | else |
| 1988 | intel_encoder->crtc_mask = (1 << 0) | (1 << 1); |
| 1989 | } else { |
| 1990 | intel_encoder->crtc_mask = (1 << 0) | (1 << 1) | (1 << 2); |
| 1991 | } |
Ville Syrjälä | 301ea74 | 2014-03-03 16:15:30 +0200 | [diff] [blame] | 1992 | intel_encoder->cloneable = 1 << INTEL_OUTPUT_ANALOG; |
Ville Syrjälä | c6f1495 | 2014-03-03 16:15:31 +0200 | [diff] [blame] | 1993 | /* |
| 1994 | * BSpec is unclear about HDMI+HDMI cloning on g4x, but it seems |
| 1995 | * to work on real hardware. And since g4x can send infoframes to |
| 1996 | * only one port anyway, nothing is lost by allowing it. |
| 1997 | */ |
Tvrtko Ursulin | 9beb5fe | 2016-10-13 11:03:06 +0100 | [diff] [blame] | 1998 | if (IS_G4X(dev_priv)) |
Ville Syrjälä | c6f1495 | 2014-03-03 16:15:31 +0200 | [diff] [blame] | 1999 | intel_encoder->cloneable |= 1 << INTEL_OUTPUT_HDMI; |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 2000 | |
Paulo Zanoni | 174edf1 | 2012-10-26 19:05:50 -0200 | [diff] [blame] | 2001 | intel_dig_port->port = port; |
Paulo Zanoni | b242b7f | 2013-02-18 19:00:26 -0300 | [diff] [blame] | 2002 | intel_dig_port->hdmi.hdmi_reg = hdmi_reg; |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 2003 | intel_dig_port->dp.output_reg = INVALID_MMIO_REG; |
Ville Syrjälä | ccb1a83 | 2015-12-08 19:59:38 +0200 | [diff] [blame] | 2004 | intel_dig_port->max_lanes = 4; |
Chris Wilson | 55b7d6e8 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 2005 | |
Paulo Zanoni | b9cb234 | 2012-10-26 19:05:47 -0200 | [diff] [blame] | 2006 | intel_hdmi_init_connector(intel_dig_port, intel_connector); |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 2007 | } |