Jani Nikula | 4e64649 | 2013-08-27 15:12:20 +0300 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2013 Intel Corporation |
| 3 | * |
| 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 5 | * copy of this software and associated documentation files (the "Software"), |
| 6 | * to deal in the Software without restriction, including without limitation |
| 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 | * and/or sell copies of the Software, and to permit persons to whom the |
| 9 | * Software is furnished to do so, subject to the following conditions: |
| 10 | * |
| 11 | * The above copyright notice and this permission notice (including the next |
| 12 | * paragraph) shall be included in all copies or substantial portions of the |
| 13 | * Software. |
| 14 | * |
| 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 21 | * DEALINGS IN THE SOFTWARE. |
| 22 | * |
| 23 | * Author: Jani Nikula <jani.nikula@intel.com> |
| 24 | */ |
| 25 | |
| 26 | #include <drm/drmP.h> |
| 27 | #include <drm/drm_crtc.h> |
| 28 | #include <drm/drm_edid.h> |
| 29 | #include <drm/i915_drm.h> |
| 30 | #include <linux/slab.h> |
| 31 | #include "i915_drv.h" |
| 32 | #include "intel_drv.h" |
| 33 | #include "intel_dsi.h" |
| 34 | #include "intel_dsi_cmd.h" |
| 35 | |
| 36 | /* the sub-encoders aka panel drivers */ |
| 37 | static const struct intel_dsi_device intel_dsi_devices[] = { |
| 38 | }; |
| 39 | |
Shobhit Kumar | e9fe51c | 2013-12-10 12:14:55 +0530 | [diff] [blame] | 40 | static void band_gap_reset(struct drm_i915_private *dev_priv) |
Shobhit Kumar | 4ce8c9a | 2013-08-27 15:12:24 +0300 | [diff] [blame] | 41 | { |
| 42 | mutex_lock(&dev_priv->dpio_lock); |
| 43 | |
Shobhit Kumar | e9fe51c | 2013-12-10 12:14:55 +0530 | [diff] [blame] | 44 | vlv_flisdsi_write(dev_priv, 0x08, 0x0001); |
| 45 | vlv_flisdsi_write(dev_priv, 0x0F, 0x0005); |
| 46 | vlv_flisdsi_write(dev_priv, 0x0F, 0x0025); |
| 47 | udelay(150); |
| 48 | vlv_flisdsi_write(dev_priv, 0x0F, 0x0000); |
| 49 | vlv_flisdsi_write(dev_priv, 0x08, 0x0000); |
Shobhit Kumar | 4ce8c9a | 2013-08-27 15:12:24 +0300 | [diff] [blame] | 50 | |
| 51 | mutex_unlock(&dev_priv->dpio_lock); |
Shobhit Kumar | 4ce8c9a | 2013-08-27 15:12:24 +0300 | [diff] [blame] | 52 | } |
| 53 | |
Jani Nikula | 4e64649 | 2013-08-27 15:12:20 +0300 | [diff] [blame] | 54 | static struct intel_dsi *intel_attached_dsi(struct drm_connector *connector) |
| 55 | { |
| 56 | return container_of(intel_attached_encoder(connector), |
| 57 | struct intel_dsi, base); |
| 58 | } |
| 59 | |
| 60 | static inline bool is_vid_mode(struct intel_dsi *intel_dsi) |
| 61 | { |
Shobhit Kumar | dfba2e2 | 2014-04-14 11:18:24 +0530 | [diff] [blame] | 62 | return intel_dsi->operation_mode == INTEL_DSI_VIDEO_MODE; |
Jani Nikula | 4e64649 | 2013-08-27 15:12:20 +0300 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | static inline bool is_cmd_mode(struct intel_dsi *intel_dsi) |
| 66 | { |
Shobhit Kumar | dfba2e2 | 2014-04-14 11:18:24 +0530 | [diff] [blame] | 67 | return intel_dsi->operation_mode == INTEL_DSI_COMMAND_MODE; |
Jani Nikula | 4e64649 | 2013-08-27 15:12:20 +0300 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | static void intel_dsi_hot_plug(struct intel_encoder *encoder) |
| 71 | { |
| 72 | DRM_DEBUG_KMS("\n"); |
| 73 | } |
| 74 | |
| 75 | static bool intel_dsi_compute_config(struct intel_encoder *encoder, |
| 76 | struct intel_crtc_config *config) |
| 77 | { |
| 78 | struct intel_dsi *intel_dsi = container_of(encoder, struct intel_dsi, |
| 79 | base); |
| 80 | struct intel_connector *intel_connector = intel_dsi->attached_connector; |
| 81 | struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode; |
| 82 | struct drm_display_mode *adjusted_mode = &config->adjusted_mode; |
| 83 | struct drm_display_mode *mode = &config->requested_mode; |
| 84 | |
| 85 | DRM_DEBUG_KMS("\n"); |
| 86 | |
| 87 | if (fixed_mode) |
| 88 | intel_fixed_panel_mode(fixed_mode, adjusted_mode); |
| 89 | |
| 90 | if (intel_dsi->dev.dev_ops->mode_fixup) |
| 91 | return intel_dsi->dev.dev_ops->mode_fixup(&intel_dsi->dev, |
| 92 | mode, adjusted_mode); |
| 93 | |
| 94 | return true; |
| 95 | } |
| 96 | |
Shobhit Kumar | 1dbd7cb | 2013-12-11 17:52:05 +0530 | [diff] [blame] | 97 | static void intel_dsi_device_ready(struct intel_encoder *encoder) |
| 98 | { |
| 99 | struct drm_i915_private *dev_priv = encoder->base.dev->dev_private; |
| 100 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc); |
| 101 | int pipe = intel_crtc->pipe; |
| 102 | u32 val; |
| 103 | |
| 104 | DRM_DEBUG_KMS("\n"); |
| 105 | |
Shobhit Kumar | 2095f9f | 2014-04-09 13:59:30 +0530 | [diff] [blame] | 106 | mutex_lock(&dev_priv->dpio_lock); |
| 107 | /* program rcomp for compliance, reduce from 50 ohms to 45 ohms |
| 108 | * needed everytime after power gate */ |
| 109 | vlv_flisdsi_write(dev_priv, 0x04, 0x0004); |
| 110 | mutex_unlock(&dev_priv->dpio_lock); |
| 111 | |
| 112 | /* bandgap reset is needed after everytime we do power gate */ |
| 113 | band_gap_reset(dev_priv); |
| 114 | |
Shobhit Kumar | 1dbd7cb | 2013-12-11 17:52:05 +0530 | [diff] [blame] | 115 | val = I915_READ(MIPI_PORT_CTRL(pipe)); |
| 116 | I915_WRITE(MIPI_PORT_CTRL(pipe), val | LP_OUTPUT_HOLD); |
| 117 | usleep_range(1000, 1500); |
| 118 | I915_WRITE(MIPI_DEVICE_READY(pipe), DEVICE_READY | ULPS_STATE_EXIT); |
| 119 | usleep_range(2000, 2500); |
| 120 | I915_WRITE(MIPI_DEVICE_READY(pipe), DEVICE_READY); |
| 121 | usleep_range(2000, 2500); |
| 122 | I915_WRITE(MIPI_DEVICE_READY(pipe), 0x00); |
| 123 | usleep_range(2000, 2500); |
| 124 | I915_WRITE(MIPI_DEVICE_READY(pipe), DEVICE_READY); |
| 125 | usleep_range(2000, 2500); |
| 126 | } |
Jani Nikula | 4e64649 | 2013-08-27 15:12:20 +0300 | [diff] [blame] | 127 | |
| 128 | static void intel_dsi_enable(struct intel_encoder *encoder) |
| 129 | { |
Shobhit Kumar | 1dbd7cb | 2013-12-11 17:52:05 +0530 | [diff] [blame] | 130 | struct drm_device *dev = encoder->base.dev; |
| 131 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jani Nikula | 4e64649 | 2013-08-27 15:12:20 +0300 | [diff] [blame] | 132 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc); |
| 133 | struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base); |
| 134 | int pipe = intel_crtc->pipe; |
| 135 | u32 temp; |
| 136 | |
| 137 | DRM_DEBUG_KMS("\n"); |
| 138 | |
Jani Nikula | 4e64649 | 2013-08-27 15:12:20 +0300 | [diff] [blame] | 139 | if (is_cmd_mode(intel_dsi)) |
| 140 | I915_WRITE(MIPI_MAX_RETURN_PKT_SIZE(pipe), 8 * 4); |
Shobhit Kumar | 1dbd7cb | 2013-12-11 17:52:05 +0530 | [diff] [blame] | 141 | else { |
Jani Nikula | 4e64649 | 2013-08-27 15:12:20 +0300 | [diff] [blame] | 142 | msleep(20); /* XXX */ |
Shobhit Kumar | e104702 | 2014-04-09 13:59:35 +0530 | [diff] [blame] | 143 | dpi_send_cmd(intel_dsi, TURN_ON, DPI_LP_MODE_EN); |
Jani Nikula | 4e64649 | 2013-08-27 15:12:20 +0300 | [diff] [blame] | 144 | msleep(100); |
| 145 | |
Shobhit Kumar | 2634fd7 | 2014-04-09 13:59:31 +0530 | [diff] [blame] | 146 | if (intel_dsi->dev.dev_ops->enable) |
| 147 | intel_dsi->dev.dev_ops->enable(&intel_dsi->dev); |
| 148 | |
Jani Nikula | 4e64649 | 2013-08-27 15:12:20 +0300 | [diff] [blame] | 149 | /* assert ip_tg_enable signal */ |
Shobhit Kumar | f6da284 | 2013-12-10 12:15:00 +0530 | [diff] [blame] | 150 | temp = I915_READ(MIPI_PORT_CTRL(pipe)) & ~LANE_CONFIGURATION_MASK; |
| 151 | temp = temp | intel_dsi->port_bits; |
Jani Nikula | 4e64649 | 2013-08-27 15:12:20 +0300 | [diff] [blame] | 152 | I915_WRITE(MIPI_PORT_CTRL(pipe), temp | DPI_ENABLE); |
| 153 | POSTING_READ(MIPI_PORT_CTRL(pipe)); |
| 154 | } |
Shobhit Kumar | 2634fd7 | 2014-04-09 13:59:31 +0530 | [diff] [blame] | 155 | } |
Jani Nikula | 4e64649 | 2013-08-27 15:12:20 +0300 | [diff] [blame] | 156 | |
Shobhit Kumar | 2634fd7 | 2014-04-09 13:59:31 +0530 | [diff] [blame] | 157 | static void intel_dsi_pre_enable(struct intel_encoder *encoder) |
| 158 | { |
Shobhit Kumar | 20e5bf6 | 2014-04-09 13:59:32 +0530 | [diff] [blame] | 159 | struct drm_device *dev = encoder->base.dev; |
| 160 | struct drm_i915_private *dev_priv = dev->dev_private; |
Shobhit Kumar | 2634fd7 | 2014-04-09 13:59:31 +0530 | [diff] [blame] | 161 | struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base); |
Shobhit Kumar | 20e5bf6 | 2014-04-09 13:59:32 +0530 | [diff] [blame] | 162 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc); |
| 163 | enum pipe pipe = intel_crtc->pipe; |
| 164 | u32 tmp; |
Shobhit Kumar | 2634fd7 | 2014-04-09 13:59:31 +0530 | [diff] [blame] | 165 | |
| 166 | DRM_DEBUG_KMS("\n"); |
| 167 | |
Shobhit Kumar | 20e5bf6 | 2014-04-09 13:59:32 +0530 | [diff] [blame] | 168 | /* Disable DPOunit clock gating, can stall pipe |
| 169 | * and we need DPLL REFA always enabled */ |
| 170 | tmp = I915_READ(DPLL(pipe)); |
| 171 | tmp |= DPLL_REFA_CLK_ENABLE_VLV; |
| 172 | I915_WRITE(DPLL(pipe), tmp); |
| 173 | |
| 174 | tmp = I915_READ(DSPCLK_GATE_D); |
| 175 | tmp |= DPOUNIT_CLOCK_GATE_DISABLE; |
| 176 | I915_WRITE(DSPCLK_GATE_D, tmp); |
Shobhit Kumar | 2634fd7 | 2014-04-09 13:59:31 +0530 | [diff] [blame] | 177 | |
| 178 | /* put device in ready state */ |
| 179 | intel_dsi_device_ready(encoder); |
| 180 | |
Shobhit Kumar | df38e65 | 2014-04-14 11:18:26 +0530 | [diff] [blame] | 181 | msleep(intel_dsi->panel_on_delay); |
| 182 | |
Shobhit Kumar | 20e5bf6 | 2014-04-09 13:59:32 +0530 | [diff] [blame] | 183 | if (intel_dsi->dev.dev_ops->panel_reset) |
| 184 | intel_dsi->dev.dev_ops->panel_reset(&intel_dsi->dev); |
| 185 | |
Shobhit Kumar | 2634fd7 | 2014-04-09 13:59:31 +0530 | [diff] [blame] | 186 | if (intel_dsi->dev.dev_ops->send_otp_cmds) |
| 187 | intel_dsi->dev.dev_ops->send_otp_cmds(&intel_dsi->dev); |
| 188 | |
| 189 | /* Enable port in pre-enable phase itself because as per hw team |
| 190 | * recommendation, port should be enabled befor plane & pipe */ |
| 191 | intel_dsi_enable(encoder); |
| 192 | } |
| 193 | |
| 194 | static void intel_dsi_enable_nop(struct intel_encoder *encoder) |
| 195 | { |
| 196 | DRM_DEBUG_KMS("\n"); |
| 197 | |
| 198 | /* for DSI port enable has to be done before pipe |
| 199 | * and plane enable, so port enable is done in |
| 200 | * pre_enable phase itself unlike other encoders |
| 201 | */ |
Jani Nikula | 4e64649 | 2013-08-27 15:12:20 +0300 | [diff] [blame] | 202 | } |
| 203 | |
| 204 | static void intel_dsi_disable(struct intel_encoder *encoder) |
| 205 | { |
Shobhit Kumar | 1dbd7cb | 2013-12-11 17:52:05 +0530 | [diff] [blame] | 206 | struct drm_device *dev = encoder->base.dev; |
| 207 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jani Nikula | 4e64649 | 2013-08-27 15:12:20 +0300 | [diff] [blame] | 208 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc); |
| 209 | struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base); |
| 210 | int pipe = intel_crtc->pipe; |
| 211 | u32 temp; |
| 212 | |
| 213 | DRM_DEBUG_KMS("\n"); |
| 214 | |
Jani Nikula | 4e64649 | 2013-08-27 15:12:20 +0300 | [diff] [blame] | 215 | if (is_vid_mode(intel_dsi)) { |
Shobhit Kumar | e104702 | 2014-04-09 13:59:35 +0530 | [diff] [blame] | 216 | /* Send Shutdown command to the panel in LP mode */ |
| 217 | dpi_send_cmd(intel_dsi, SHUTDOWN, DPI_LP_MODE_EN); |
Jani Nikula | 4e64649 | 2013-08-27 15:12:20 +0300 | [diff] [blame] | 218 | msleep(10); |
| 219 | |
| 220 | /* de-assert ip_tg_enable signal */ |
| 221 | temp = I915_READ(MIPI_PORT_CTRL(pipe)); |
| 222 | I915_WRITE(MIPI_PORT_CTRL(pipe), temp & ~DPI_ENABLE); |
| 223 | POSTING_READ(MIPI_PORT_CTRL(pipe)); |
| 224 | |
| 225 | msleep(2); |
| 226 | } |
| 227 | |
Shobhit Kumar | 339023e | 2014-04-09 13:59:34 +0530 | [diff] [blame] | 228 | /* Panel commands can be sent when clock is in LP11 */ |
| 229 | I915_WRITE(MIPI_DEVICE_READY(pipe), 0x0); |
| 230 | |
| 231 | temp = I915_READ(MIPI_CTRL(pipe)); |
| 232 | temp &= ~ESCAPE_CLOCK_DIVIDER_MASK; |
| 233 | I915_WRITE(MIPI_CTRL(pipe), temp | |
| 234 | intel_dsi->escape_clk_div << |
| 235 | ESCAPE_CLOCK_DIVIDER_SHIFT); |
| 236 | |
| 237 | I915_WRITE(MIPI_EOT_DISABLE(pipe), CLOCKSTOP); |
| 238 | |
| 239 | temp = I915_READ(MIPI_DSI_FUNC_PRG(pipe)); |
| 240 | temp &= ~VID_MODE_FORMAT_MASK; |
| 241 | I915_WRITE(MIPI_DSI_FUNC_PRG(pipe), temp); |
| 242 | |
| 243 | I915_WRITE(MIPI_DEVICE_READY(pipe), 0x1); |
| 244 | |
Shobhit Kumar | 1dbd7cb | 2013-12-11 17:52:05 +0530 | [diff] [blame] | 245 | /* if disable packets are sent before sending shutdown packet then in |
| 246 | * some next enable sequence send turn on packet error is observed */ |
| 247 | if (intel_dsi->dev.dev_ops->disable) |
| 248 | intel_dsi->dev.dev_ops->disable(&intel_dsi->dev); |
Jani Nikula | 4e64649 | 2013-08-27 15:12:20 +0300 | [diff] [blame] | 249 | } |
| 250 | |
Shobhit Kumar | 1dbd7cb | 2013-12-11 17:52:05 +0530 | [diff] [blame] | 251 | static void intel_dsi_clear_device_ready(struct intel_encoder *encoder) |
Jani Nikula | 4e64649 | 2013-08-27 15:12:20 +0300 | [diff] [blame] | 252 | { |
Shobhit Kumar | 1dbd7cb | 2013-12-11 17:52:05 +0530 | [diff] [blame] | 253 | struct drm_i915_private *dev_priv = encoder->base.dev->dev_private; |
| 254 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc); |
| 255 | int pipe = intel_crtc->pipe; |
| 256 | u32 val; |
| 257 | |
Jani Nikula | 4e64649 | 2013-08-27 15:12:20 +0300 | [diff] [blame] | 258 | DRM_DEBUG_KMS("\n"); |
ymohanma | be4fc04 | 2013-08-27 23:40:56 +0300 | [diff] [blame] | 259 | |
Shobhit Kumar | 1dbd7cb | 2013-12-11 17:52:05 +0530 | [diff] [blame] | 260 | I915_WRITE(MIPI_DEVICE_READY(pipe), ULPS_STATE_ENTER); |
| 261 | usleep_range(2000, 2500); |
| 262 | |
| 263 | I915_WRITE(MIPI_DEVICE_READY(pipe), ULPS_STATE_EXIT); |
| 264 | usleep_range(2000, 2500); |
| 265 | |
| 266 | I915_WRITE(MIPI_DEVICE_READY(pipe), ULPS_STATE_ENTER); |
| 267 | usleep_range(2000, 2500); |
| 268 | |
| 269 | val = I915_READ(MIPI_PORT_CTRL(pipe)); |
| 270 | I915_WRITE(MIPI_PORT_CTRL(pipe), val & ~LP_OUTPUT_HOLD); |
| 271 | usleep_range(1000, 1500); |
| 272 | |
| 273 | if (wait_for(((I915_READ(MIPI_PORT_CTRL(pipe)) & AFE_LATCHOUT) |
| 274 | == 0x00000), 30)) |
| 275 | DRM_ERROR("DSI LP not going Low\n"); |
| 276 | |
| 277 | I915_WRITE(MIPI_DEVICE_READY(pipe), 0x00); |
| 278 | usleep_range(2000, 2500); |
| 279 | |
ymohanma | be4fc04 | 2013-08-27 23:40:56 +0300 | [diff] [blame] | 280 | vlv_disable_dsi_pll(encoder); |
Jani Nikula | 4e64649 | 2013-08-27 15:12:20 +0300 | [diff] [blame] | 281 | } |
Shobhit Kumar | 20e5bf6 | 2014-04-09 13:59:32 +0530 | [diff] [blame] | 282 | |
Shobhit Kumar | 1dbd7cb | 2013-12-11 17:52:05 +0530 | [diff] [blame] | 283 | static void intel_dsi_post_disable(struct intel_encoder *encoder) |
| 284 | { |
Shobhit Kumar | 20e5bf6 | 2014-04-09 13:59:32 +0530 | [diff] [blame] | 285 | struct drm_i915_private *dev_priv = encoder->base.dev->dev_private; |
Shobhit Kumar | 1dbd7cb | 2013-12-11 17:52:05 +0530 | [diff] [blame] | 286 | struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base); |
Shobhit Kumar | 20e5bf6 | 2014-04-09 13:59:32 +0530 | [diff] [blame] | 287 | u32 val; |
Shobhit Kumar | 1dbd7cb | 2013-12-11 17:52:05 +0530 | [diff] [blame] | 288 | |
| 289 | DRM_DEBUG_KMS("\n"); |
| 290 | |
| 291 | intel_dsi_clear_device_ready(encoder); |
| 292 | |
Shobhit Kumar | 20e5bf6 | 2014-04-09 13:59:32 +0530 | [diff] [blame] | 293 | val = I915_READ(DSPCLK_GATE_D); |
| 294 | val &= ~DPOUNIT_CLOCK_GATE_DISABLE; |
| 295 | I915_WRITE(DSPCLK_GATE_D, val); |
| 296 | |
Shobhit Kumar | 1dbd7cb | 2013-12-11 17:52:05 +0530 | [diff] [blame] | 297 | if (intel_dsi->dev.dev_ops->disable_panel_power) |
| 298 | intel_dsi->dev.dev_ops->disable_panel_power(&intel_dsi->dev); |
Shobhit Kumar | df38e65 | 2014-04-14 11:18:26 +0530 | [diff] [blame] | 299 | |
| 300 | msleep(intel_dsi->panel_off_delay); |
| 301 | msleep(intel_dsi->panel_pwr_cycle_delay); |
Shobhit Kumar | 1dbd7cb | 2013-12-11 17:52:05 +0530 | [diff] [blame] | 302 | } |
Jani Nikula | 4e64649 | 2013-08-27 15:12:20 +0300 | [diff] [blame] | 303 | |
| 304 | static bool intel_dsi_get_hw_state(struct intel_encoder *encoder, |
| 305 | enum pipe *pipe) |
| 306 | { |
| 307 | struct drm_i915_private *dev_priv = encoder->base.dev->dev_private; |
Imre Deak | 6d129be | 2014-03-05 16:20:54 +0200 | [diff] [blame] | 308 | enum intel_display_power_domain power_domain; |
Jani Nikula | 4e64649 | 2013-08-27 15:12:20 +0300 | [diff] [blame] | 309 | u32 port, func; |
| 310 | enum pipe p; |
| 311 | |
| 312 | DRM_DEBUG_KMS("\n"); |
| 313 | |
Imre Deak | 6d129be | 2014-03-05 16:20:54 +0200 | [diff] [blame] | 314 | power_domain = intel_display_port_power_domain(encoder); |
| 315 | if (!intel_display_power_enabled(dev_priv, power_domain)) |
| 316 | return false; |
| 317 | |
Jani Nikula | 4e64649 | 2013-08-27 15:12:20 +0300 | [diff] [blame] | 318 | /* XXX: this only works for one DSI output */ |
| 319 | for (p = PIPE_A; p <= PIPE_B; p++) { |
| 320 | port = I915_READ(MIPI_PORT_CTRL(p)); |
| 321 | func = I915_READ(MIPI_DSI_FUNC_PRG(p)); |
| 322 | |
| 323 | if ((port & DPI_ENABLE) || (func & CMD_MODE_DATA_WIDTH_MASK)) { |
| 324 | if (I915_READ(MIPI_DEVICE_READY(p)) & DEVICE_READY) { |
| 325 | *pipe = p; |
| 326 | return true; |
| 327 | } |
| 328 | } |
| 329 | } |
| 330 | |
| 331 | return false; |
| 332 | } |
| 333 | |
| 334 | static void intel_dsi_get_config(struct intel_encoder *encoder, |
| 335 | struct intel_crtc_config *pipe_config) |
| 336 | { |
| 337 | DRM_DEBUG_KMS("\n"); |
| 338 | |
| 339 | /* XXX: read flags, set to adjusted_mode */ |
| 340 | } |
| 341 | |
Damien Lespiau | c19de8e | 2013-11-28 15:29:18 +0000 | [diff] [blame] | 342 | static enum drm_mode_status |
| 343 | intel_dsi_mode_valid(struct drm_connector *connector, |
| 344 | struct drm_display_mode *mode) |
Jani Nikula | 4e64649 | 2013-08-27 15:12:20 +0300 | [diff] [blame] | 345 | { |
| 346 | struct intel_connector *intel_connector = to_intel_connector(connector); |
| 347 | struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode; |
| 348 | struct intel_dsi *intel_dsi = intel_attached_dsi(connector); |
| 349 | |
| 350 | DRM_DEBUG_KMS("\n"); |
| 351 | |
| 352 | if (mode->flags & DRM_MODE_FLAG_DBLSCAN) { |
| 353 | DRM_DEBUG_KMS("MODE_NO_DBLESCAN\n"); |
| 354 | return MODE_NO_DBLESCAN; |
| 355 | } |
| 356 | |
| 357 | if (fixed_mode) { |
| 358 | if (mode->hdisplay > fixed_mode->hdisplay) |
| 359 | return MODE_PANEL; |
| 360 | if (mode->vdisplay > fixed_mode->vdisplay) |
| 361 | return MODE_PANEL; |
| 362 | } |
| 363 | |
| 364 | return intel_dsi->dev.dev_ops->mode_valid(&intel_dsi->dev, mode); |
| 365 | } |
| 366 | |
| 367 | /* return txclkesc cycles in terms of divider and duration in us */ |
| 368 | static u16 txclkesc(u32 divider, unsigned int us) |
| 369 | { |
| 370 | switch (divider) { |
| 371 | case ESCAPE_CLOCK_DIVIDER_1: |
| 372 | default: |
| 373 | return 20 * us; |
| 374 | case ESCAPE_CLOCK_DIVIDER_2: |
| 375 | return 10 * us; |
| 376 | case ESCAPE_CLOCK_DIVIDER_4: |
| 377 | return 5 * us; |
| 378 | } |
| 379 | } |
| 380 | |
| 381 | /* return pixels in terms of txbyteclkhs */ |
| 382 | static u16 txbyteclkhs(u16 pixels, int bpp, int lane_count) |
| 383 | { |
| 384 | return DIV_ROUND_UP(DIV_ROUND_UP(pixels * bpp, 8), lane_count); |
| 385 | } |
| 386 | |
| 387 | static void set_dsi_timings(struct drm_encoder *encoder, |
| 388 | const struct drm_display_mode *mode) |
| 389 | { |
| 390 | struct drm_device *dev = encoder->dev; |
| 391 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 392 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); |
| 393 | struct intel_dsi *intel_dsi = enc_to_intel_dsi(encoder); |
| 394 | int pipe = intel_crtc->pipe; |
| 395 | unsigned int bpp = intel_crtc->config.pipe_bpp; |
| 396 | unsigned int lane_count = intel_dsi->lane_count; |
| 397 | |
| 398 | u16 hactive, hfp, hsync, hbp, vfp, vsync, vbp; |
| 399 | |
| 400 | hactive = mode->hdisplay; |
| 401 | hfp = mode->hsync_start - mode->hdisplay; |
| 402 | hsync = mode->hsync_end - mode->hsync_start; |
| 403 | hbp = mode->htotal - mode->hsync_end; |
| 404 | |
| 405 | vfp = mode->vsync_start - mode->vdisplay; |
| 406 | vsync = mode->vsync_end - mode->vsync_start; |
| 407 | vbp = mode->vtotal - mode->vsync_end; |
| 408 | |
| 409 | /* horizontal values are in terms of high speed byte clock */ |
| 410 | hactive = txbyteclkhs(hactive, bpp, lane_count); |
| 411 | hfp = txbyteclkhs(hfp, bpp, lane_count); |
| 412 | hsync = txbyteclkhs(hsync, bpp, lane_count); |
| 413 | hbp = txbyteclkhs(hbp, bpp, lane_count); |
| 414 | |
| 415 | I915_WRITE(MIPI_HACTIVE_AREA_COUNT(pipe), hactive); |
| 416 | I915_WRITE(MIPI_HFP_COUNT(pipe), hfp); |
| 417 | |
| 418 | /* meaningful for video mode non-burst sync pulse mode only, can be zero |
| 419 | * for non-burst sync events and burst modes */ |
| 420 | I915_WRITE(MIPI_HSYNC_PADDING_COUNT(pipe), hsync); |
| 421 | I915_WRITE(MIPI_HBP_COUNT(pipe), hbp); |
| 422 | |
| 423 | /* vertical values are in terms of lines */ |
| 424 | I915_WRITE(MIPI_VFP_COUNT(pipe), vfp); |
| 425 | I915_WRITE(MIPI_VSYNC_PADDING_COUNT(pipe), vsync); |
| 426 | I915_WRITE(MIPI_VBP_COUNT(pipe), vbp); |
| 427 | } |
| 428 | |
Daniel Vetter | 07e4fb9 | 2014-04-24 23:54:59 +0200 | [diff] [blame^] | 429 | static void intel_dsi_prepare(struct intel_encoder *intel_encoder) |
Jani Nikula | 4e64649 | 2013-08-27 15:12:20 +0300 | [diff] [blame] | 430 | { |
| 431 | struct drm_encoder *encoder = &intel_encoder->base; |
| 432 | struct drm_device *dev = encoder->dev; |
| 433 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 434 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); |
| 435 | struct intel_dsi *intel_dsi = enc_to_intel_dsi(encoder); |
| 436 | struct drm_display_mode *adjusted_mode = |
| 437 | &intel_crtc->config.adjusted_mode; |
| 438 | int pipe = intel_crtc->pipe; |
| 439 | unsigned int bpp = intel_crtc->config.pipe_bpp; |
| 440 | u32 val, tmp; |
| 441 | |
Damien Lespiau | 6f2bcce | 2013-10-16 12:29:54 +0100 | [diff] [blame] | 442 | DRM_DEBUG_KMS("pipe %c\n", pipe_name(pipe)); |
Jani Nikula | 4e64649 | 2013-08-27 15:12:20 +0300 | [diff] [blame] | 443 | |
Jani Nikula | 4e64649 | 2013-08-27 15:12:20 +0300 | [diff] [blame] | 444 | /* escape clock divider, 20MHz, shared for A and C. device ready must be |
| 445 | * off when doing this! txclkesc? */ |
| 446 | tmp = I915_READ(MIPI_CTRL(0)); |
| 447 | tmp &= ~ESCAPE_CLOCK_DIVIDER_MASK; |
| 448 | I915_WRITE(MIPI_CTRL(0), tmp | ESCAPE_CLOCK_DIVIDER_1); |
| 449 | |
| 450 | /* read request priority is per pipe */ |
| 451 | tmp = I915_READ(MIPI_CTRL(pipe)); |
| 452 | tmp &= ~READ_REQUEST_PRIORITY_MASK; |
| 453 | I915_WRITE(MIPI_CTRL(pipe), tmp | READ_REQUEST_PRIORITY_HIGH); |
| 454 | |
| 455 | /* XXX: why here, why like this? handling in irq handler?! */ |
| 456 | I915_WRITE(MIPI_INTR_STAT(pipe), 0xffffffff); |
| 457 | I915_WRITE(MIPI_INTR_EN(pipe), 0xffffffff); |
| 458 | |
Shobhit Kumar | f6da284 | 2013-12-10 12:15:00 +0530 | [diff] [blame] | 459 | I915_WRITE(MIPI_DPHY_PARAM(pipe), intel_dsi->dphy_reg); |
Jani Nikula | 4e64649 | 2013-08-27 15:12:20 +0300 | [diff] [blame] | 460 | |
| 461 | I915_WRITE(MIPI_DPI_RESOLUTION(pipe), |
| 462 | adjusted_mode->vdisplay << VERTICAL_ADDRESS_SHIFT | |
| 463 | adjusted_mode->hdisplay << HORIZONTAL_ADDRESS_SHIFT); |
| 464 | |
| 465 | set_dsi_timings(encoder, adjusted_mode); |
| 466 | |
| 467 | val = intel_dsi->lane_count << DATA_LANES_PRG_REG_SHIFT; |
| 468 | if (is_cmd_mode(intel_dsi)) { |
| 469 | val |= intel_dsi->channel << CMD_MODE_CHANNEL_NUMBER_SHIFT; |
| 470 | val |= CMD_MODE_DATA_WIDTH_8_BIT; /* XXX */ |
| 471 | } else { |
| 472 | val |= intel_dsi->channel << VID_MODE_CHANNEL_NUMBER_SHIFT; |
| 473 | |
| 474 | /* XXX: cross-check bpp vs. pixel format? */ |
| 475 | val |= intel_dsi->pixel_format; |
| 476 | } |
| 477 | I915_WRITE(MIPI_DSI_FUNC_PRG(pipe), val); |
| 478 | |
| 479 | /* timeouts for recovery. one frame IIUC. if counter expires, EOT and |
| 480 | * stop state. */ |
| 481 | |
| 482 | /* |
| 483 | * In burst mode, value greater than one DPI line Time in byte clock |
| 484 | * (txbyteclkhs) To timeout this timer 1+ of the above said value is |
| 485 | * recommended. |
| 486 | * |
| 487 | * In non-burst mode, Value greater than one DPI frame time in byte |
| 488 | * clock(txbyteclkhs) To timeout this timer 1+ of the above said value |
| 489 | * is recommended. |
| 490 | * |
| 491 | * In DBI only mode, value greater than one DBI frame time in byte |
| 492 | * clock(txbyteclkhs) To timeout this timer 1+ of the above said value |
| 493 | * is recommended. |
| 494 | */ |
| 495 | |
| 496 | if (is_vid_mode(intel_dsi) && |
| 497 | intel_dsi->video_mode_format == VIDEO_MODE_BURST) { |
| 498 | I915_WRITE(MIPI_HS_TX_TIMEOUT(pipe), |
| 499 | txbyteclkhs(adjusted_mode->htotal, bpp, |
| 500 | intel_dsi->lane_count) + 1); |
| 501 | } else { |
| 502 | I915_WRITE(MIPI_HS_TX_TIMEOUT(pipe), |
| 503 | txbyteclkhs(adjusted_mode->vtotal * |
| 504 | adjusted_mode->htotal, |
| 505 | bpp, intel_dsi->lane_count) + 1); |
| 506 | } |
Shobhit Kumar | f6da284 | 2013-12-10 12:15:00 +0530 | [diff] [blame] | 507 | I915_WRITE(MIPI_LP_RX_TIMEOUT(pipe), intel_dsi->lp_rx_timeout); |
| 508 | I915_WRITE(MIPI_TURN_AROUND_TIMEOUT(pipe), intel_dsi->turn_arnd_val); |
| 509 | I915_WRITE(MIPI_DEVICE_RESET_TIMER(pipe), intel_dsi->rst_timer_val); |
Jani Nikula | 4e64649 | 2013-08-27 15:12:20 +0300 | [diff] [blame] | 510 | |
| 511 | /* dphy stuff */ |
| 512 | |
| 513 | /* in terms of low power clock */ |
Shobhit Kumar | f1c79f1 | 2014-04-09 13:59:33 +0530 | [diff] [blame] | 514 | I915_WRITE(MIPI_INIT_COUNT(pipe), txclkesc(intel_dsi->escape_clk_div, 100)); |
| 515 | |
| 516 | val = 0; |
| 517 | if (intel_dsi->eotp_pkt == 0) |
| 518 | val |= EOT_DISABLE; |
| 519 | |
| 520 | if (intel_dsi->clock_stop) |
| 521 | val |= CLOCKSTOP; |
Jani Nikula | 4e64649 | 2013-08-27 15:12:20 +0300 | [diff] [blame] | 522 | |
| 523 | /* recovery disables */ |
Shobhit Kumar | f1c79f1 | 2014-04-09 13:59:33 +0530 | [diff] [blame] | 524 | I915_WRITE(MIPI_EOT_DISABLE(pipe), val); |
Jani Nikula | 4e64649 | 2013-08-27 15:12:20 +0300 | [diff] [blame] | 525 | |
Shobhit Kumar | cf4dbd2 | 2014-04-14 11:18:25 +0530 | [diff] [blame] | 526 | /* in terms of low power clock */ |
| 527 | I915_WRITE(MIPI_INIT_COUNT(pipe), intel_dsi->init_count); |
| 528 | |
Jani Nikula | 4e64649 | 2013-08-27 15:12:20 +0300 | [diff] [blame] | 529 | /* in terms of txbyteclkhs. actual high to low switch + |
| 530 | * MIPI_STOP_STATE_STALL * MIPI_LP_BYTECLK. |
| 531 | * |
| 532 | * XXX: write MIPI_STOP_STATE_STALL? |
| 533 | */ |
Shobhit Kumar | f6da284 | 2013-12-10 12:15:00 +0530 | [diff] [blame] | 534 | I915_WRITE(MIPI_HIGH_LOW_SWITCH_COUNT(pipe), |
| 535 | intel_dsi->hs_to_lp_count); |
Jani Nikula | 4e64649 | 2013-08-27 15:12:20 +0300 | [diff] [blame] | 536 | |
| 537 | /* XXX: low power clock equivalence in terms of byte clock. the number |
| 538 | * of byte clocks occupied in one low power clock. based on txbyteclkhs |
| 539 | * and txclkesc. txclkesc time / txbyteclk time * (105 + |
| 540 | * MIPI_STOP_STATE_STALL) / 105.??? |
| 541 | */ |
Shobhit Kumar | f6da284 | 2013-12-10 12:15:00 +0530 | [diff] [blame] | 542 | I915_WRITE(MIPI_LP_BYTECLK(pipe), intel_dsi->lp_byte_clk); |
Jani Nikula | 4e64649 | 2013-08-27 15:12:20 +0300 | [diff] [blame] | 543 | |
| 544 | /* the bw essential for transmitting 16 long packets containing 252 |
| 545 | * bytes meant for dcs write memory command is programmed in this |
| 546 | * register in terms of byte clocks. based on dsi transfer rate and the |
| 547 | * number of lanes configured the time taken to transmit 16 long packets |
| 548 | * in a dsi stream varies. */ |
Shobhit Kumar | f6da284 | 2013-12-10 12:15:00 +0530 | [diff] [blame] | 549 | I915_WRITE(MIPI_DBI_BW_CTRL(pipe), intel_dsi->bw_timer); |
Jani Nikula | 4e64649 | 2013-08-27 15:12:20 +0300 | [diff] [blame] | 550 | |
| 551 | I915_WRITE(MIPI_CLK_LANE_SWITCH_TIME_CNT(pipe), |
Shobhit Kumar | f6da284 | 2013-12-10 12:15:00 +0530 | [diff] [blame] | 552 | intel_dsi->clk_lp_to_hs_count << LP_HS_SSW_CNT_SHIFT | |
| 553 | intel_dsi->clk_hs_to_lp_count << HS_LP_PWR_SW_CNT_SHIFT); |
Jani Nikula | 4e64649 | 2013-08-27 15:12:20 +0300 | [diff] [blame] | 554 | |
| 555 | if (is_vid_mode(intel_dsi)) |
Shobhit Kumar | 24d9c40 | 2014-04-09 13:59:36 +0530 | [diff] [blame] | 556 | /* Some panels might have resolution which is not a multiple of |
| 557 | * 64 like 1366 x 768. Enable RANDOM resolution support for such |
| 558 | * panels by default */ |
Jani Nikula | 4e64649 | 2013-08-27 15:12:20 +0300 | [diff] [blame] | 559 | I915_WRITE(MIPI_VIDEO_MODE_FORMAT(pipe), |
Shobhit Kumar | f6da284 | 2013-12-10 12:15:00 +0530 | [diff] [blame] | 560 | intel_dsi->video_frmt_cfg_bits | |
Shobhit Kumar | 24d9c40 | 2014-04-09 13:59:36 +0530 | [diff] [blame] | 561 | intel_dsi->video_mode_format | |
| 562 | IP_TG_CONFIG | |
| 563 | RANDOM_DPI_DISPLAY_RESOLUTION); |
Jani Nikula | 4e64649 | 2013-08-27 15:12:20 +0300 | [diff] [blame] | 564 | } |
| 565 | |
Daniel Vetter | 07e4fb9 | 2014-04-24 23:54:59 +0200 | [diff] [blame^] | 566 | static void intel_dsi_pre_pll_enable(struct intel_encoder *encoder) |
| 567 | { |
| 568 | DRM_DEBUG_KMS("\n"); |
| 569 | |
| 570 | intel_dsi_prepare(encoder); |
| 571 | |
| 572 | vlv_enable_dsi_pll(encoder); |
| 573 | } |
| 574 | |
Jani Nikula | 4e64649 | 2013-08-27 15:12:20 +0300 | [diff] [blame] | 575 | static enum drm_connector_status |
| 576 | intel_dsi_detect(struct drm_connector *connector, bool force) |
| 577 | { |
| 578 | struct intel_dsi *intel_dsi = intel_attached_dsi(connector); |
Imre Deak | 671dedd | 2014-03-05 16:20:53 +0200 | [diff] [blame] | 579 | struct intel_encoder *intel_encoder = &intel_dsi->base; |
| 580 | enum intel_display_power_domain power_domain; |
| 581 | enum drm_connector_status connector_status; |
| 582 | struct drm_i915_private *dev_priv = intel_encoder->base.dev->dev_private; |
| 583 | |
Jani Nikula | 4e64649 | 2013-08-27 15:12:20 +0300 | [diff] [blame] | 584 | DRM_DEBUG_KMS("\n"); |
Imre Deak | 671dedd | 2014-03-05 16:20:53 +0200 | [diff] [blame] | 585 | power_domain = intel_display_port_power_domain(intel_encoder); |
| 586 | |
| 587 | intel_display_power_get(dev_priv, power_domain); |
| 588 | connector_status = intel_dsi->dev.dev_ops->detect(&intel_dsi->dev); |
| 589 | intel_display_power_put(dev_priv, power_domain); |
| 590 | |
| 591 | return connector_status; |
Jani Nikula | 4e64649 | 2013-08-27 15:12:20 +0300 | [diff] [blame] | 592 | } |
| 593 | |
| 594 | static int intel_dsi_get_modes(struct drm_connector *connector) |
| 595 | { |
| 596 | struct intel_connector *intel_connector = to_intel_connector(connector); |
| 597 | struct drm_display_mode *mode; |
| 598 | |
| 599 | DRM_DEBUG_KMS("\n"); |
| 600 | |
| 601 | if (!intel_connector->panel.fixed_mode) { |
| 602 | DRM_DEBUG_KMS("no fixed mode\n"); |
| 603 | return 0; |
| 604 | } |
| 605 | |
| 606 | mode = drm_mode_duplicate(connector->dev, |
| 607 | intel_connector->panel.fixed_mode); |
| 608 | if (!mode) { |
| 609 | DRM_DEBUG_KMS("drm_mode_duplicate failed\n"); |
| 610 | return 0; |
| 611 | } |
| 612 | |
| 613 | drm_mode_probed_add(connector, mode); |
| 614 | return 1; |
| 615 | } |
| 616 | |
| 617 | static void intel_dsi_destroy(struct drm_connector *connector) |
| 618 | { |
| 619 | struct intel_connector *intel_connector = to_intel_connector(connector); |
| 620 | |
| 621 | DRM_DEBUG_KMS("\n"); |
| 622 | intel_panel_fini(&intel_connector->panel); |
Jani Nikula | 4e64649 | 2013-08-27 15:12:20 +0300 | [diff] [blame] | 623 | drm_connector_cleanup(connector); |
| 624 | kfree(connector); |
| 625 | } |
| 626 | |
| 627 | static const struct drm_encoder_funcs intel_dsi_funcs = { |
| 628 | .destroy = intel_encoder_destroy, |
| 629 | }; |
| 630 | |
| 631 | static const struct drm_connector_helper_funcs intel_dsi_connector_helper_funcs = { |
| 632 | .get_modes = intel_dsi_get_modes, |
| 633 | .mode_valid = intel_dsi_mode_valid, |
| 634 | .best_encoder = intel_best_encoder, |
| 635 | }; |
| 636 | |
| 637 | static const struct drm_connector_funcs intel_dsi_connector_funcs = { |
| 638 | .dpms = intel_connector_dpms, |
| 639 | .detect = intel_dsi_detect, |
| 640 | .destroy = intel_dsi_destroy, |
| 641 | .fill_modes = drm_helper_probe_single_connector_modes, |
| 642 | }; |
| 643 | |
| 644 | bool intel_dsi_init(struct drm_device *dev) |
| 645 | { |
| 646 | struct intel_dsi *intel_dsi; |
| 647 | struct intel_encoder *intel_encoder; |
| 648 | struct drm_encoder *encoder; |
| 649 | struct intel_connector *intel_connector; |
| 650 | struct drm_connector *connector; |
| 651 | struct drm_display_mode *fixed_mode = NULL; |
| 652 | const struct intel_dsi_device *dsi; |
| 653 | unsigned int i; |
| 654 | |
| 655 | DRM_DEBUG_KMS("\n"); |
| 656 | |
| 657 | intel_dsi = kzalloc(sizeof(*intel_dsi), GFP_KERNEL); |
| 658 | if (!intel_dsi) |
| 659 | return false; |
| 660 | |
| 661 | intel_connector = kzalloc(sizeof(*intel_connector), GFP_KERNEL); |
| 662 | if (!intel_connector) { |
| 663 | kfree(intel_dsi); |
| 664 | return false; |
| 665 | } |
| 666 | |
| 667 | intel_encoder = &intel_dsi->base; |
| 668 | encoder = &intel_encoder->base; |
| 669 | intel_dsi->attached_connector = intel_connector; |
| 670 | |
| 671 | connector = &intel_connector->base; |
| 672 | |
| 673 | drm_encoder_init(dev, encoder, &intel_dsi_funcs, DRM_MODE_ENCODER_DSI); |
| 674 | |
| 675 | /* XXX: very likely not all of these are needed */ |
| 676 | intel_encoder->hot_plug = intel_dsi_hot_plug; |
| 677 | intel_encoder->compute_config = intel_dsi_compute_config; |
| 678 | intel_encoder->pre_pll_enable = intel_dsi_pre_pll_enable; |
| 679 | intel_encoder->pre_enable = intel_dsi_pre_enable; |
Shobhit Kumar | 2634fd7 | 2014-04-09 13:59:31 +0530 | [diff] [blame] | 680 | intel_encoder->enable = intel_dsi_enable_nop; |
Jani Nikula | 4e64649 | 2013-08-27 15:12:20 +0300 | [diff] [blame] | 681 | intel_encoder->disable = intel_dsi_disable; |
| 682 | intel_encoder->post_disable = intel_dsi_post_disable; |
| 683 | intel_encoder->get_hw_state = intel_dsi_get_hw_state; |
| 684 | intel_encoder->get_config = intel_dsi_get_config; |
| 685 | |
| 686 | intel_connector->get_hw_state = intel_connector_get_hw_state; |
Imre Deak | 4932e2c | 2014-02-11 17:12:48 +0200 | [diff] [blame] | 687 | intel_connector->unregister = intel_connector_unregister; |
Jani Nikula | 4e64649 | 2013-08-27 15:12:20 +0300 | [diff] [blame] | 688 | |
| 689 | for (i = 0; i < ARRAY_SIZE(intel_dsi_devices); i++) { |
| 690 | dsi = &intel_dsi_devices[i]; |
| 691 | intel_dsi->dev = *dsi; |
| 692 | |
| 693 | if (dsi->dev_ops->init(&intel_dsi->dev)) |
| 694 | break; |
| 695 | } |
| 696 | |
| 697 | if (i == ARRAY_SIZE(intel_dsi_devices)) { |
| 698 | DRM_DEBUG_KMS("no device found\n"); |
| 699 | goto err; |
| 700 | } |
| 701 | |
| 702 | intel_encoder->type = INTEL_OUTPUT_DSI; |
| 703 | intel_encoder->crtc_mask = (1 << 0); /* XXX */ |
| 704 | |
Ville Syrjälä | bc079e8 | 2014-03-03 16:15:28 +0200 | [diff] [blame] | 705 | intel_encoder->cloneable = 0; |
Jani Nikula | 4e64649 | 2013-08-27 15:12:20 +0300 | [diff] [blame] | 706 | drm_connector_init(dev, connector, &intel_dsi_connector_funcs, |
| 707 | DRM_MODE_CONNECTOR_DSI); |
| 708 | |
| 709 | drm_connector_helper_add(connector, &intel_dsi_connector_helper_funcs); |
| 710 | |
| 711 | connector->display_info.subpixel_order = SubPixelHorizontalRGB; /*XXX*/ |
| 712 | connector->interlace_allowed = false; |
| 713 | connector->doublescan_allowed = false; |
| 714 | |
| 715 | intel_connector_attach_encoder(intel_connector, intel_encoder); |
| 716 | |
| 717 | drm_sysfs_connector_add(connector); |
| 718 | |
| 719 | fixed_mode = dsi->dev_ops->get_modes(&intel_dsi->dev); |
| 720 | if (!fixed_mode) { |
| 721 | DRM_DEBUG_KMS("no fixed mode\n"); |
| 722 | goto err; |
| 723 | } |
| 724 | |
| 725 | fixed_mode->type |= DRM_MODE_TYPE_PREFERRED; |
Vandana Kannan | 4b6ed68 | 2014-02-11 14:26:36 +0530 | [diff] [blame] | 726 | intel_panel_init(&intel_connector->panel, fixed_mode, NULL); |
Jani Nikula | 4e64649 | 2013-08-27 15:12:20 +0300 | [diff] [blame] | 727 | |
| 728 | return true; |
| 729 | |
| 730 | err: |
| 731 | drm_encoder_cleanup(&intel_encoder->base); |
| 732 | kfree(intel_dsi); |
| 733 | kfree(intel_connector); |
| 734 | |
| 735 | return false; |
| 736 | } |