Alan Cox | 6a227d5 | 2011-11-03 18:22:37 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2006-2011 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 | * Authors: |
| 24 | * jim liu <jim.liu@intel.com> |
| 25 | * |
| 26 | * FIXME: |
| 27 | * We should probably make this generic and share it with Medfield |
| 28 | */ |
| 29 | |
| 30 | #include <drm/drmP.h> |
| 31 | #include <drm/drm.h> |
| 32 | #include <drm/drm_crtc.h> |
| 33 | #include <drm/drm_edid.h> |
| 34 | #include "psb_intel_drv.h" |
| 35 | #include "psb_drv.h" |
| 36 | #include "psb_intel_reg.h" |
Kirill A. Shutemov | 455b9e9 | 2012-03-08 16:10:38 +0000 | [diff] [blame] | 37 | #include "cdv_device.h" |
Alan Cox | 6a227d5 | 2011-11-03 18:22:37 +0000 | [diff] [blame] | 38 | #include <linux/pm_runtime.h> |
| 39 | |
| 40 | /* hdmi control bits */ |
| 41 | #define HDMI_NULL_PACKETS_DURING_VSYNC (1 << 9) |
| 42 | #define HDMI_BORDER_ENABLE (1 << 7) |
| 43 | #define HDMI_AUDIO_ENABLE (1 << 6) |
| 44 | #define HDMI_VSYNC_ACTIVE_HIGH (1 << 4) |
| 45 | #define HDMI_HSYNC_ACTIVE_HIGH (1 << 3) |
| 46 | /* hdmi-b control bits */ |
| 47 | #define HDMIB_PIPE_B_SELECT (1 << 30) |
| 48 | |
| 49 | |
| 50 | struct mid_intel_hdmi_priv { |
| 51 | u32 hdmi_reg; |
| 52 | u32 save_HDMIB; |
| 53 | bool has_hdmi_sink; |
| 54 | bool has_hdmi_audio; |
| 55 | /* Should set this when detect hotplug */ |
| 56 | bool hdmi_device_connected; |
| 57 | struct mdfld_hdmi_i2c *i2c_bus; |
| 58 | struct i2c_adapter *hdmi_i2c_adapter; /* for control functions */ |
| 59 | struct drm_device *dev; |
| 60 | }; |
| 61 | |
| 62 | static void cdv_hdmi_mode_set(struct drm_encoder *encoder, |
| 63 | struct drm_display_mode *mode, |
| 64 | struct drm_display_mode *adjusted_mode) |
| 65 | { |
| 66 | struct drm_device *dev = encoder->dev; |
Patrik Jakobsson | 367e440 | 2013-07-22 17:45:26 +0200 | [diff] [blame] | 67 | struct gma_encoder *gma_encoder = to_gma_encoder(encoder); |
| 68 | struct mid_intel_hdmi_priv *hdmi_priv = gma_encoder->dev_priv; |
Alan Cox | 6a227d5 | 2011-11-03 18:22:37 +0000 | [diff] [blame] | 69 | u32 hdmib; |
| 70 | struct drm_crtc *crtc = encoder->crtc; |
Patrik Jakobsson | 6306865 | 2013-07-22 01:31:23 +0200 | [diff] [blame] | 71 | struct gma_crtc *gma_crtc = to_gma_crtc(crtc); |
Alan Cox | 6a227d5 | 2011-11-03 18:22:37 +0000 | [diff] [blame] | 72 | |
| 73 | hdmib = (2 << 10); |
| 74 | |
| 75 | if (adjusted_mode->flags & DRM_MODE_FLAG_PVSYNC) |
| 76 | hdmib |= HDMI_VSYNC_ACTIVE_HIGH; |
| 77 | if (adjusted_mode->flags & DRM_MODE_FLAG_PHSYNC) |
| 78 | hdmib |= HDMI_HSYNC_ACTIVE_HIGH; |
| 79 | |
Patrik Jakobsson | 6306865 | 2013-07-22 01:31:23 +0200 | [diff] [blame] | 80 | if (gma_crtc->pipe == 1) |
Alan Cox | 6a227d5 | 2011-11-03 18:22:37 +0000 | [diff] [blame] | 81 | hdmib |= HDMIB_PIPE_B_SELECT; |
| 82 | |
| 83 | if (hdmi_priv->has_hdmi_audio) { |
| 84 | hdmib |= HDMI_AUDIO_ENABLE; |
| 85 | hdmib |= HDMI_NULL_PACKETS_DURING_VSYNC; |
| 86 | } |
| 87 | |
| 88 | REG_WRITE(hdmi_priv->hdmi_reg, hdmib); |
| 89 | REG_READ(hdmi_priv->hdmi_reg); |
| 90 | } |
| 91 | |
Alan Cox | 6a227d5 | 2011-11-03 18:22:37 +0000 | [diff] [blame] | 92 | static void cdv_hdmi_dpms(struct drm_encoder *encoder, int mode) |
| 93 | { |
| 94 | struct drm_device *dev = encoder->dev; |
Patrik Jakobsson | 367e440 | 2013-07-22 17:45:26 +0200 | [diff] [blame] | 95 | struct gma_encoder *gma_encoder = to_gma_encoder(encoder); |
| 96 | struct mid_intel_hdmi_priv *hdmi_priv = gma_encoder->dev_priv; |
Alan Cox | 6a227d5 | 2011-11-03 18:22:37 +0000 | [diff] [blame] | 97 | u32 hdmib; |
| 98 | |
| 99 | hdmib = REG_READ(hdmi_priv->hdmi_reg); |
| 100 | |
| 101 | if (mode != DRM_MODE_DPMS_ON) |
| 102 | REG_WRITE(hdmi_priv->hdmi_reg, hdmib & ~HDMIB_PORT_EN); |
| 103 | else |
| 104 | REG_WRITE(hdmi_priv->hdmi_reg, hdmib | HDMIB_PORT_EN); |
| 105 | REG_READ(hdmi_priv->hdmi_reg); |
| 106 | } |
| 107 | |
| 108 | static void cdv_hdmi_save(struct drm_connector *connector) |
| 109 | { |
| 110 | struct drm_device *dev = connector->dev; |
Patrik Jakobsson | 367e440 | 2013-07-22 17:45:26 +0200 | [diff] [blame] | 111 | struct gma_encoder *gma_encoder = gma_attached_encoder(connector); |
| 112 | struct mid_intel_hdmi_priv *hdmi_priv = gma_encoder->dev_priv; |
Alan Cox | 6a227d5 | 2011-11-03 18:22:37 +0000 | [diff] [blame] | 113 | |
| 114 | hdmi_priv->save_HDMIB = REG_READ(hdmi_priv->hdmi_reg); |
| 115 | } |
| 116 | |
| 117 | static void cdv_hdmi_restore(struct drm_connector *connector) |
| 118 | { |
| 119 | struct drm_device *dev = connector->dev; |
Patrik Jakobsson | 367e440 | 2013-07-22 17:45:26 +0200 | [diff] [blame] | 120 | struct gma_encoder *gma_encoder = gma_attached_encoder(connector); |
| 121 | struct mid_intel_hdmi_priv *hdmi_priv = gma_encoder->dev_priv; |
Alan Cox | 6a227d5 | 2011-11-03 18:22:37 +0000 | [diff] [blame] | 122 | |
| 123 | REG_WRITE(hdmi_priv->hdmi_reg, hdmi_priv->save_HDMIB); |
| 124 | REG_READ(hdmi_priv->hdmi_reg); |
| 125 | } |
| 126 | |
| 127 | static enum drm_connector_status cdv_hdmi_detect( |
| 128 | struct drm_connector *connector, bool force) |
| 129 | { |
Patrik Jakobsson | 367e440 | 2013-07-22 17:45:26 +0200 | [diff] [blame] | 130 | struct gma_encoder *gma_encoder = gma_attached_encoder(connector); |
| 131 | struct mid_intel_hdmi_priv *hdmi_priv = gma_encoder->dev_priv; |
Alan Cox | 6a227d5 | 2011-11-03 18:22:37 +0000 | [diff] [blame] | 132 | struct edid *edid = NULL; |
| 133 | enum drm_connector_status status = connector_status_disconnected; |
| 134 | |
Patrik Jakobsson | 367e440 | 2013-07-22 17:45:26 +0200 | [diff] [blame] | 135 | edid = drm_get_edid(connector, &gma_encoder->i2c_bus->adapter); |
Alan Cox | 6a227d5 | 2011-11-03 18:22:37 +0000 | [diff] [blame] | 136 | |
| 137 | hdmi_priv->has_hdmi_sink = false; |
| 138 | hdmi_priv->has_hdmi_audio = false; |
| 139 | if (edid) { |
| 140 | if (edid->input & DRM_EDID_INPUT_DIGITAL) { |
| 141 | status = connector_status_connected; |
| 142 | hdmi_priv->has_hdmi_sink = |
| 143 | drm_detect_hdmi_monitor(edid); |
| 144 | hdmi_priv->has_hdmi_audio = |
| 145 | drm_detect_monitor_audio(edid); |
| 146 | } |
Alan Cox | 6a227d5 | 2011-11-03 18:22:37 +0000 | [diff] [blame] | 147 | kfree(edid); |
| 148 | } |
| 149 | return status; |
| 150 | } |
| 151 | |
| 152 | static int cdv_hdmi_set_property(struct drm_connector *connector, |
| 153 | struct drm_property *property, |
| 154 | uint64_t value) |
| 155 | { |
| 156 | struct drm_encoder *encoder = connector->encoder; |
| 157 | |
| 158 | if (!strcmp(property->name, "scaling mode") && encoder) { |
Patrik Jakobsson | 6306865 | 2013-07-22 01:31:23 +0200 | [diff] [blame] | 159 | struct gma_crtc *crtc = to_gma_crtc(encoder->crtc); |
Alan Cox | 6a227d5 | 2011-11-03 18:22:37 +0000 | [diff] [blame] | 160 | bool centre; |
| 161 | uint64_t curValue; |
| 162 | |
| 163 | if (!crtc) |
| 164 | return -1; |
| 165 | |
| 166 | switch (value) { |
| 167 | case DRM_MODE_SCALE_FULLSCREEN: |
| 168 | break; |
| 169 | case DRM_MODE_SCALE_NO_SCALE: |
| 170 | break; |
| 171 | case DRM_MODE_SCALE_ASPECT: |
| 172 | break; |
| 173 | default: |
| 174 | return -1; |
| 175 | } |
| 176 | |
Rob Clark | a69ac9e | 2012-10-11 20:38:23 -0500 | [diff] [blame] | 177 | if (drm_object_property_get_value(&connector->base, |
Alan Cox | 6a227d5 | 2011-11-03 18:22:37 +0000 | [diff] [blame] | 178 | property, &curValue)) |
| 179 | return -1; |
| 180 | |
| 181 | if (curValue == value) |
| 182 | return 0; |
| 183 | |
Rob Clark | a69ac9e | 2012-10-11 20:38:23 -0500 | [diff] [blame] | 184 | if (drm_object_property_set_value(&connector->base, |
Alan Cox | 6a227d5 | 2011-11-03 18:22:37 +0000 | [diff] [blame] | 185 | property, value)) |
| 186 | return -1; |
| 187 | |
| 188 | centre = (curValue == DRM_MODE_SCALE_NO_SCALE) || |
| 189 | (value == DRM_MODE_SCALE_NO_SCALE); |
| 190 | |
| 191 | if (crtc->saved_mode.hdisplay != 0 && |
| 192 | crtc->saved_mode.vdisplay != 0) { |
| 193 | if (centre) { |
| 194 | if (!drm_crtc_helper_set_mode(encoder->crtc, &crtc->saved_mode, |
Matt Roper | f4510a2 | 2014-04-01 15:22:40 -0700 | [diff] [blame] | 195 | encoder->crtc->x, encoder->crtc->y, encoder->crtc->primary->fb)) |
Alan Cox | 6a227d5 | 2011-11-03 18:22:37 +0000 | [diff] [blame] | 196 | return -1; |
| 197 | } else { |
Jani Nikula | 45fe734 | 2015-03-11 11:51:01 +0200 | [diff] [blame] | 198 | const struct drm_encoder_helper_funcs *helpers |
Alan Cox | 6a227d5 | 2011-11-03 18:22:37 +0000 | [diff] [blame] | 199 | = encoder->helper_private; |
| 200 | helpers->mode_set(encoder, &crtc->saved_mode, |
| 201 | &crtc->saved_adjusted_mode); |
| 202 | } |
| 203 | } |
| 204 | } |
| 205 | return 0; |
| 206 | } |
| 207 | |
| 208 | /* |
| 209 | * Return the list of HDMI DDC modes if available. |
| 210 | */ |
| 211 | static int cdv_hdmi_get_modes(struct drm_connector *connector) |
| 212 | { |
Patrik Jakobsson | 367e440 | 2013-07-22 17:45:26 +0200 | [diff] [blame] | 213 | struct gma_encoder *gma_encoder = gma_attached_encoder(connector); |
Alan Cox | 6a227d5 | 2011-11-03 18:22:37 +0000 | [diff] [blame] | 214 | struct edid *edid = NULL; |
| 215 | int ret = 0; |
| 216 | |
Patrik Jakobsson | 367e440 | 2013-07-22 17:45:26 +0200 | [diff] [blame] | 217 | edid = drm_get_edid(connector, &gma_encoder->i2c_bus->adapter); |
Alan Cox | 6a227d5 | 2011-11-03 18:22:37 +0000 | [diff] [blame] | 218 | if (edid) { |
Patrik Jakobsson | a12d6a0 | 2011-12-19 21:41:22 +0000 | [diff] [blame] | 219 | drm_mode_connector_update_edid_property(connector, edid); |
| 220 | ret = drm_add_edid_modes(connector, edid); |
Alan Cox | 6a227d5 | 2011-11-03 18:22:37 +0000 | [diff] [blame] | 221 | kfree(edid); |
| 222 | } |
| 223 | return ret; |
| 224 | } |
| 225 | |
| 226 | static int cdv_hdmi_mode_valid(struct drm_connector *connector, |
| 227 | struct drm_display_mode *mode) |
| 228 | { |
Alan Cox | 6a227d5 | 2011-11-03 18:22:37 +0000 | [diff] [blame] | 229 | if (mode->clock > 165000) |
| 230 | return MODE_CLOCK_HIGH; |
| 231 | if (mode->clock < 20000) |
| 232 | return MODE_CLOCK_HIGH; |
| 233 | |
| 234 | /* just in case */ |
| 235 | if (mode->flags & DRM_MODE_FLAG_DBLSCAN) |
| 236 | return MODE_NO_DBLESCAN; |
| 237 | |
| 238 | /* just in case */ |
| 239 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) |
| 240 | return MODE_NO_INTERLACE; |
| 241 | |
Alan Cox | 6a227d5 | 2011-11-03 18:22:37 +0000 | [diff] [blame] | 242 | return MODE_OK; |
| 243 | } |
| 244 | |
| 245 | static void cdv_hdmi_destroy(struct drm_connector *connector) |
| 246 | { |
Patrik Jakobsson | 367e440 | 2013-07-22 17:45:26 +0200 | [diff] [blame] | 247 | struct gma_encoder *gma_encoder = gma_attached_encoder(connector); |
Alan Cox | 6a227d5 | 2011-11-03 18:22:37 +0000 | [diff] [blame] | 248 | |
Markus Elfring | 44fb4b8 | 2016-07-22 10:30:30 +0200 | [diff] [blame] | 249 | psb_intel_i2c_destroy(gma_encoder->i2c_bus); |
Thomas Wood | 34ea3d3 | 2014-05-29 16:57:41 +0100 | [diff] [blame] | 250 | drm_connector_unregister(connector); |
Alan Cox | 6a227d5 | 2011-11-03 18:22:37 +0000 | [diff] [blame] | 251 | drm_connector_cleanup(connector); |
| 252 | kfree(connector); |
| 253 | } |
| 254 | |
| 255 | static const struct drm_encoder_helper_funcs cdv_hdmi_helper_funcs = { |
| 256 | .dpms = cdv_hdmi_dpms, |
Patrik Jakobsson | c9d4959 | 2013-07-11 01:02:01 +0200 | [diff] [blame] | 257 | .prepare = gma_encoder_prepare, |
Alan Cox | 6a227d5 | 2011-11-03 18:22:37 +0000 | [diff] [blame] | 258 | .mode_set = cdv_hdmi_mode_set, |
Patrik Jakobsson | c9d4959 | 2013-07-11 01:02:01 +0200 | [diff] [blame] | 259 | .commit = gma_encoder_commit, |
Alan Cox | 6a227d5 | 2011-11-03 18:22:37 +0000 | [diff] [blame] | 260 | }; |
| 261 | |
| 262 | static const struct drm_connector_helper_funcs |
| 263 | cdv_hdmi_connector_helper_funcs = { |
| 264 | .get_modes = cdv_hdmi_get_modes, |
| 265 | .mode_valid = cdv_hdmi_mode_valid, |
Patrik Jakobsson | c9d4959 | 2013-07-11 01:02:01 +0200 | [diff] [blame] | 266 | .best_encoder = gma_best_encoder, |
Alan Cox | 6a227d5 | 2011-11-03 18:22:37 +0000 | [diff] [blame] | 267 | }; |
| 268 | |
| 269 | static const struct drm_connector_funcs cdv_hdmi_connector_funcs = { |
| 270 | .dpms = drm_helper_connector_dpms, |
Alan Cox | 6a227d5 | 2011-11-03 18:22:37 +0000 | [diff] [blame] | 271 | .detect = cdv_hdmi_detect, |
| 272 | .fill_modes = drm_helper_probe_single_connector_modes, |
| 273 | .set_property = cdv_hdmi_set_property, |
| 274 | .destroy = cdv_hdmi_destroy, |
| 275 | }; |
| 276 | |
| 277 | void cdv_hdmi_init(struct drm_device *dev, |
| 278 | struct psb_intel_mode_device *mode_dev, int reg) |
| 279 | { |
Patrik Jakobsson | 367e440 | 2013-07-22 17:45:26 +0200 | [diff] [blame] | 280 | struct gma_encoder *gma_encoder; |
Patrik Jakobsson | a3d5d75 | 2013-07-22 17:05:25 +0200 | [diff] [blame] | 281 | struct gma_connector *gma_connector; |
Alan Cox | 6a227d5 | 2011-11-03 18:22:37 +0000 | [diff] [blame] | 282 | struct drm_connector *connector; |
| 283 | struct drm_encoder *encoder; |
| 284 | struct mid_intel_hdmi_priv *hdmi_priv; |
| 285 | int ddc_bus; |
| 286 | |
Patrik Jakobsson | 367e440 | 2013-07-22 17:45:26 +0200 | [diff] [blame] | 287 | gma_encoder = kzalloc(sizeof(struct gma_encoder), GFP_KERNEL); |
Patrik Jakobsson | a12d6a0 | 2011-12-19 21:41:22 +0000 | [diff] [blame] | 288 | |
Patrik Jakobsson | 367e440 | 2013-07-22 17:45:26 +0200 | [diff] [blame] | 289 | if (!gma_encoder) |
Alan Cox | 6a227d5 | 2011-11-03 18:22:37 +0000 | [diff] [blame] | 290 | return; |
| 291 | |
Patrik Jakobsson | a3d5d75 | 2013-07-22 17:05:25 +0200 | [diff] [blame] | 292 | gma_connector = kzalloc(sizeof(struct gma_connector), |
Patrik Jakobsson | a12d6a0 | 2011-12-19 21:41:22 +0000 | [diff] [blame] | 293 | GFP_KERNEL); |
| 294 | |
Patrik Jakobsson | a3d5d75 | 2013-07-22 17:05:25 +0200 | [diff] [blame] | 295 | if (!gma_connector) |
Patrik Jakobsson | a12d6a0 | 2011-12-19 21:41:22 +0000 | [diff] [blame] | 296 | goto err_connector; |
| 297 | |
| 298 | hdmi_priv = kzalloc(sizeof(struct mid_intel_hdmi_priv), GFP_KERNEL); |
| 299 | |
| 300 | if (!hdmi_priv) |
| 301 | goto err_priv; |
| 302 | |
Patrik Jakobsson | a3d5d75 | 2013-07-22 17:05:25 +0200 | [diff] [blame] | 303 | connector = &gma_connector->base; |
Kero van Gelder | bda5003 | 2013-03-31 13:38:44 +0200 | [diff] [blame] | 304 | connector->polled = DRM_CONNECTOR_POLL_HPD; |
Daniel Vetter | d56f57a | 2015-12-04 09:45:53 +0100 | [diff] [blame] | 305 | gma_connector->save = cdv_hdmi_save; |
| 306 | gma_connector->restore = cdv_hdmi_restore; |
| 307 | |
Patrik Jakobsson | 367e440 | 2013-07-22 17:45:26 +0200 | [diff] [blame] | 308 | encoder = &gma_encoder->base; |
Patrik Jakobsson | a12d6a0 | 2011-12-19 21:41:22 +0000 | [diff] [blame] | 309 | drm_connector_init(dev, connector, |
Alan Cox | 6a227d5 | 2011-11-03 18:22:37 +0000 | [diff] [blame] | 310 | &cdv_hdmi_connector_funcs, |
| 311 | DRM_MODE_CONNECTOR_DVID); |
| 312 | |
Patrik Jakobsson | a12d6a0 | 2011-12-19 21:41:22 +0000 | [diff] [blame] | 313 | drm_encoder_init(dev, encoder, &psb_intel_lvds_enc_funcs, |
Ville Syrjälä | 13a3d91 | 2015-12-09 16:20:18 +0200 | [diff] [blame] | 314 | DRM_MODE_ENCODER_TMDS, NULL); |
Alan Cox | 6a227d5 | 2011-11-03 18:22:37 +0000 | [diff] [blame] | 315 | |
Patrik Jakobsson | 367e440 | 2013-07-22 17:45:26 +0200 | [diff] [blame] | 316 | gma_connector_attach_encoder(gma_connector, gma_encoder); |
| 317 | gma_encoder->type = INTEL_OUTPUT_HDMI; |
Alan Cox | 6a227d5 | 2011-11-03 18:22:37 +0000 | [diff] [blame] | 318 | hdmi_priv->hdmi_reg = reg; |
| 319 | hdmi_priv->has_hdmi_sink = false; |
Patrik Jakobsson | 367e440 | 2013-07-22 17:45:26 +0200 | [diff] [blame] | 320 | gma_encoder->dev_priv = hdmi_priv; |
Alan Cox | 6a227d5 | 2011-11-03 18:22:37 +0000 | [diff] [blame] | 321 | |
| 322 | drm_encoder_helper_add(encoder, &cdv_hdmi_helper_funcs); |
| 323 | drm_connector_helper_add(connector, |
| 324 | &cdv_hdmi_connector_helper_funcs); |
| 325 | connector->display_info.subpixel_order = SubPixelHorizontalRGB; |
| 326 | connector->interlace_allowed = false; |
| 327 | connector->doublescan_allowed = false; |
| 328 | |
Rob Clark | a69ac9e | 2012-10-11 20:38:23 -0500 | [diff] [blame] | 329 | drm_object_attach_property(&connector->base, |
Patrik Jakobsson | a12d6a0 | 2011-12-19 21:41:22 +0000 | [diff] [blame] | 330 | dev->mode_config.scaling_mode_property, |
| 331 | DRM_MODE_SCALE_FULLSCREEN); |
Alan Cox | 6a227d5 | 2011-11-03 18:22:37 +0000 | [diff] [blame] | 332 | |
| 333 | switch (reg) { |
| 334 | case SDVOB: |
| 335 | ddc_bus = GPIOE; |
Patrik Jakobsson | 367e440 | 2013-07-22 17:45:26 +0200 | [diff] [blame] | 336 | gma_encoder->ddi_select = DDI0_SELECT; |
Alan Cox | 6a227d5 | 2011-11-03 18:22:37 +0000 | [diff] [blame] | 337 | break; |
| 338 | case SDVOC: |
| 339 | ddc_bus = GPIOD; |
Patrik Jakobsson | 367e440 | 2013-07-22 17:45:26 +0200 | [diff] [blame] | 340 | gma_encoder->ddi_select = DDI1_SELECT; |
Alan Cox | 6a227d5 | 2011-11-03 18:22:37 +0000 | [diff] [blame] | 341 | break; |
| 342 | default: |
| 343 | DRM_ERROR("unknown reg 0x%x for HDMI\n", reg); |
| 344 | goto failed_ddc; |
| 345 | break; |
| 346 | } |
| 347 | |
Patrik Jakobsson | 367e440 | 2013-07-22 17:45:26 +0200 | [diff] [blame] | 348 | gma_encoder->i2c_bus = psb_intel_i2c_create(dev, |
Alan Cox | 6a227d5 | 2011-11-03 18:22:37 +0000 | [diff] [blame] | 349 | ddc_bus, (reg == SDVOB) ? "HDMIB" : "HDMIC"); |
| 350 | |
Patrik Jakobsson | 367e440 | 2013-07-22 17:45:26 +0200 | [diff] [blame] | 351 | if (!gma_encoder->i2c_bus) { |
Alan Cox | 6a227d5 | 2011-11-03 18:22:37 +0000 | [diff] [blame] | 352 | dev_err(dev->dev, "No ddc adapter available!\n"); |
| 353 | goto failed_ddc; |
| 354 | } |
Patrik Jakobsson | a12d6a0 | 2011-12-19 21:41:22 +0000 | [diff] [blame] | 355 | |
Patrik Jakobsson | 367e440 | 2013-07-22 17:45:26 +0200 | [diff] [blame] | 356 | hdmi_priv->hdmi_i2c_adapter = &(gma_encoder->i2c_bus->adapter); |
Alan Cox | 6a227d5 | 2011-11-03 18:22:37 +0000 | [diff] [blame] | 357 | hdmi_priv->dev = dev; |
Thomas Wood | 34ea3d3 | 2014-05-29 16:57:41 +0100 | [diff] [blame] | 358 | drm_connector_register(connector); |
Alan Cox | 6a227d5 | 2011-11-03 18:22:37 +0000 | [diff] [blame] | 359 | return; |
| 360 | |
| 361 | failed_ddc: |
Patrik Jakobsson | a12d6a0 | 2011-12-19 21:41:22 +0000 | [diff] [blame] | 362 | drm_encoder_cleanup(encoder); |
| 363 | drm_connector_cleanup(connector); |
| 364 | err_priv: |
Patrik Jakobsson | a3d5d75 | 2013-07-22 17:05:25 +0200 | [diff] [blame] | 365 | kfree(gma_connector); |
Patrik Jakobsson | a12d6a0 | 2011-12-19 21:41:22 +0000 | [diff] [blame] | 366 | err_connector: |
Patrik Jakobsson | 367e440 | 2013-07-22 17:45:26 +0200 | [diff] [blame] | 367 | kfree(gma_encoder); |
Alan Cox | 6a227d5 | 2011-11-03 18:22:37 +0000 | [diff] [blame] | 368 | } |