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