Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2006 Dave Airlie <airlied@linux.ie> |
| 3 | * Copyright © 2006-2007 Intel Corporation |
| 4 | * Jesse Barnes <jesse.barnes@intel.com> |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 7 | * copy of this software and associated documentation files (the "Software"), |
| 8 | * to deal in the Software without restriction, including without limitation |
| 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 10 | * and/or sell copies of the Software, and to permit persons to whom the |
| 11 | * Software is furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice (including the next |
| 14 | * paragraph) shall be included in all copies or substantial portions of the |
| 15 | * Software. |
| 16 | * |
| 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 20 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 23 | * DEALINGS IN THE SOFTWARE. |
| 24 | * |
| 25 | * Authors: |
| 26 | * Eric Anholt <eric@anholt.net> |
| 27 | */ |
| 28 | #include <linux/i2c.h> |
| 29 | #include <linux/delay.h> |
| 30 | #include "drmP.h" |
| 31 | #include "drm.h" |
| 32 | #include "drm_crtc.h" |
| 33 | #include "intel_drv.h" |
ling.ma@intel.com | 2b8d33f7 | 2009-07-29 11:31:18 +0800 | [diff] [blame] | 34 | #include "drm_edid.h" |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 35 | #include "i915_drm.h" |
| 36 | #include "i915_drv.h" |
| 37 | #include "intel_sdvo_regs.h" |
Zhao Yakui | 6070a4a | 2010-02-08 21:35:12 +0800 | [diff] [blame] | 38 | #include <linux/dmi.h> |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 39 | |
Zhao Yakui | ce6feab | 2009-08-24 13:50:26 +0800 | [diff] [blame] | 40 | static char *tv_format_names[] = { |
| 41 | "NTSC_M" , "NTSC_J" , "NTSC_443", |
| 42 | "PAL_B" , "PAL_D" , "PAL_G" , |
| 43 | "PAL_H" , "PAL_I" , "PAL_M" , |
| 44 | "PAL_N" , "PAL_NC" , "PAL_60" , |
| 45 | "SECAM_B" , "SECAM_D" , "SECAM_G" , |
| 46 | "SECAM_K" , "SECAM_K1", "SECAM_L" , |
| 47 | "SECAM_60" |
| 48 | }; |
| 49 | |
| 50 | #define TV_FORMAT_NUM (sizeof(tv_format_names) / sizeof(*tv_format_names)) |
| 51 | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 52 | struct intel_sdvo_priv { |
Keith Packard | f9c10a9 | 2009-05-30 12:16:25 -0700 | [diff] [blame] | 53 | u8 slave_addr; |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 54 | |
| 55 | /* Register for the SDVO device: SDVOB or SDVOC */ |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 56 | int sdvo_reg; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 57 | |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 58 | /* Active outputs controlled by this SDVO output */ |
| 59 | uint16_t controlled_output; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 60 | |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 61 | /* |
| 62 | * Capabilities of the SDVO device returned by |
| 63 | * i830_sdvo_get_capabilities() |
| 64 | */ |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 65 | struct intel_sdvo_caps caps; |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 66 | |
| 67 | /* Pixel clock limitations reported by the SDVO device, in kHz */ |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 68 | int pixel_clock_min, pixel_clock_max; |
| 69 | |
ling.ma@intel.com | fb7a46f | 2009-07-23 17:11:34 +0800 | [diff] [blame] | 70 | /* |
| 71 | * For multiple function SDVO device, |
| 72 | * this is for current attached outputs. |
| 73 | */ |
| 74 | uint16_t attached_output; |
| 75 | |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 76 | /** |
| 77 | * This is set if we're going to treat the device as TV-out. |
| 78 | * |
| 79 | * While we have these nice friendly flags for output types that ought |
| 80 | * to decide this for us, the S-Video output on our HDMI+S-Video card |
| 81 | * shows up as RGB1 (VGA). |
| 82 | */ |
| 83 | bool is_tv; |
| 84 | |
Zhao Yakui | ce6feab | 2009-08-24 13:50:26 +0800 | [diff] [blame] | 85 | /* This is for current tv format name */ |
| 86 | char *tv_format_name; |
| 87 | |
| 88 | /* This contains all current supported TV format */ |
| 89 | char *tv_format_supported[TV_FORMAT_NUM]; |
| 90 | int format_supported_num; |
| 91 | struct drm_property *tv_format_property; |
| 92 | struct drm_property *tv_format_name_property[TV_FORMAT_NUM]; |
| 93 | |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 94 | /** |
| 95 | * This is set if we treat the device as HDMI, instead of DVI. |
| 96 | */ |
| 97 | bool is_hdmi; |
ling.ma@intel.com | 12682a9 | 2009-06-30 11:35:35 +0800 | [diff] [blame] | 98 | |
Ma Ling | 7086c87 | 2009-05-13 11:20:06 +0800 | [diff] [blame] | 99 | /** |
| 100 | * This is set if we detect output of sdvo device as LVDS. |
| 101 | */ |
| 102 | bool is_lvds; |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 103 | |
| 104 | /** |
ling.ma@intel.com | 12682a9 | 2009-06-30 11:35:35 +0800 | [diff] [blame] | 105 | * This is sdvo flags for input timing. |
| 106 | */ |
| 107 | uint8_t sdvo_flags; |
| 108 | |
| 109 | /** |
| 110 | * This is sdvo fixed pannel mode pointer |
| 111 | */ |
| 112 | struct drm_display_mode *sdvo_lvds_fixed_mode; |
| 113 | |
| 114 | /** |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 115 | * Returned SDTV resolutions allowed for the current format, if the |
| 116 | * device reported it. |
| 117 | */ |
| 118 | struct intel_sdvo_sdtv_resolution_reply sdtv_resolutions; |
| 119 | |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 120 | /* |
| 121 | * supported encoding mode, used to determine whether HDMI is |
| 122 | * supported |
| 123 | */ |
| 124 | struct intel_sdvo_encode encode; |
| 125 | |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 126 | /* DDC bus used by this SDVO encoder */ |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 127 | uint8_t ddc_bus; |
| 128 | |
Keith Packard | 57cdaf9 | 2009-09-04 13:07:54 +0800 | [diff] [blame] | 129 | /* Mac mini hack -- use the same DDC as the analog connector */ |
| 130 | struct i2c_adapter *analog_ddc_bus; |
| 131 | |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 132 | /* add the property for the SDVO-TV */ |
| 133 | struct drm_property *left_property; |
| 134 | struct drm_property *right_property; |
| 135 | struct drm_property *top_property; |
| 136 | struct drm_property *bottom_property; |
| 137 | struct drm_property *hpos_property; |
| 138 | struct drm_property *vpos_property; |
| 139 | |
| 140 | /* add the property for the SDVO-TV/LVDS */ |
| 141 | struct drm_property *brightness_property; |
| 142 | struct drm_property *contrast_property; |
| 143 | struct drm_property *saturation_property; |
| 144 | struct drm_property *hue_property; |
| 145 | |
| 146 | /* Add variable to record current setting for the above property */ |
| 147 | u32 left_margin, right_margin, top_margin, bottom_margin; |
| 148 | /* this is to get the range of margin.*/ |
| 149 | u32 max_hscan, max_vscan; |
| 150 | u32 max_hpos, cur_hpos; |
| 151 | u32 max_vpos, cur_vpos; |
| 152 | u32 cur_brightness, max_brightness; |
| 153 | u32 cur_contrast, max_contrast; |
| 154 | u32 cur_saturation, max_saturation; |
| 155 | u32 cur_hue, max_hue; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 156 | }; |
| 157 | |
ling.ma@intel.com | fb7a46f | 2009-07-23 17:11:34 +0800 | [diff] [blame] | 158 | static bool |
Zhenyu Wang | d2a82a6 | 2010-03-29 21:22:55 +0800 | [diff] [blame^] | 159 | intel_sdvo_output_setup(struct intel_encoder *intel_encoder, |
| 160 | struct intel_connector *intel_connector, |
| 161 | uint16_t flags); |
ling.ma@intel.com | fb7a46f | 2009-07-23 17:11:34 +0800 | [diff] [blame] | 162 | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 163 | /** |
| 164 | * Writes the SDVOB or SDVOC with the given value, but always writes both |
| 165 | * SDVOB and SDVOC to work around apparent hardware issues (according to |
| 166 | * comments in the BIOS). |
| 167 | */ |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 168 | static void intel_sdvo_write_sdvox(struct intel_encoder *intel_encoder, u32 val) |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 169 | { |
Zhenyu Wang | d2a82a6 | 2010-03-29 21:22:55 +0800 | [diff] [blame^] | 170 | struct drm_device *dev = intel_encoder->enc.dev; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 171 | struct drm_i915_private *dev_priv = dev->dev_private; |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 172 | struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 173 | u32 bval = val, cval = val; |
| 174 | int i; |
| 175 | |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 176 | if (sdvo_priv->sdvo_reg == SDVOB) { |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 177 | cval = I915_READ(SDVOC); |
| 178 | } else { |
| 179 | bval = I915_READ(SDVOB); |
| 180 | } |
| 181 | /* |
| 182 | * Write the registers twice for luck. Sometimes, |
| 183 | * writing them only once doesn't appear to 'stick'. |
| 184 | * The BIOS does this too. Yay, magic |
| 185 | */ |
| 186 | for (i = 0; i < 2; i++) |
| 187 | { |
| 188 | I915_WRITE(SDVOB, bval); |
| 189 | I915_READ(SDVOB); |
| 190 | I915_WRITE(SDVOC, cval); |
| 191 | I915_READ(SDVOC); |
| 192 | } |
| 193 | } |
| 194 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 195 | static bool intel_sdvo_read_byte(struct intel_encoder *intel_encoder, u8 addr, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 196 | u8 *ch) |
| 197 | { |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 198 | struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 199 | u8 out_buf[2]; |
| 200 | u8 buf[2]; |
| 201 | int ret; |
| 202 | |
| 203 | struct i2c_msg msgs[] = { |
| 204 | { |
Keith Packard | f9c10a9 | 2009-05-30 12:16:25 -0700 | [diff] [blame] | 205 | .addr = sdvo_priv->slave_addr >> 1, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 206 | .flags = 0, |
| 207 | .len = 1, |
| 208 | .buf = out_buf, |
| 209 | }, |
| 210 | { |
Keith Packard | f9c10a9 | 2009-05-30 12:16:25 -0700 | [diff] [blame] | 211 | .addr = sdvo_priv->slave_addr >> 1, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 212 | .flags = I2C_M_RD, |
| 213 | .len = 1, |
| 214 | .buf = buf, |
| 215 | } |
| 216 | }; |
| 217 | |
| 218 | out_buf[0] = addr; |
| 219 | out_buf[1] = 0; |
| 220 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 221 | if ((ret = i2c_transfer(intel_encoder->i2c_bus, msgs, 2)) == 2) |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 222 | { |
| 223 | *ch = buf[0]; |
| 224 | return true; |
| 225 | } |
| 226 | |
Zhao Yakui | 8a4c47f | 2009-07-20 13:48:04 +0800 | [diff] [blame] | 227 | DRM_DEBUG_KMS("i2c transfer returned %d\n", ret); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 228 | return false; |
| 229 | } |
| 230 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 231 | static bool intel_sdvo_write_byte(struct intel_encoder *intel_encoder, int addr, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 232 | u8 ch) |
| 233 | { |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 234 | struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 235 | u8 out_buf[2]; |
| 236 | struct i2c_msg msgs[] = { |
| 237 | { |
Keith Packard | f9c10a9 | 2009-05-30 12:16:25 -0700 | [diff] [blame] | 238 | .addr = sdvo_priv->slave_addr >> 1, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 239 | .flags = 0, |
| 240 | .len = 2, |
| 241 | .buf = out_buf, |
| 242 | } |
| 243 | }; |
| 244 | |
| 245 | out_buf[0] = addr; |
| 246 | out_buf[1] = ch; |
| 247 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 248 | if (i2c_transfer(intel_encoder->i2c_bus, msgs, 1) == 1) |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 249 | { |
| 250 | return true; |
| 251 | } |
| 252 | return false; |
| 253 | } |
| 254 | |
| 255 | #define SDVO_CMD_NAME_ENTRY(cmd) {cmd, #cmd} |
| 256 | /** Mapping of command numbers to names, for debug output */ |
Tobias Klauser | 005568b | 2009-02-09 22:02:42 +0100 | [diff] [blame] | 257 | static const struct _sdvo_cmd_name { |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 258 | u8 cmd; |
| 259 | char *name; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 260 | } sdvo_cmd_names[] = { |
| 261 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_RESET), |
| 262 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_DEVICE_CAPS), |
| 263 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_FIRMWARE_REV), |
| 264 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_TRAINED_INPUTS), |
| 265 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_ACTIVE_OUTPUTS), |
| 266 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_ACTIVE_OUTPUTS), |
| 267 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_IN_OUT_MAP), |
| 268 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_IN_OUT_MAP), |
| 269 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_ATTACHED_DISPLAYS), |
| 270 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_HOT_PLUG_SUPPORT), |
| 271 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_ACTIVE_HOT_PLUG), |
| 272 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_ACTIVE_HOT_PLUG), |
| 273 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_INTERRUPT_EVENT_SOURCE), |
| 274 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_TARGET_INPUT), |
| 275 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_TARGET_OUTPUT), |
| 276 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_INPUT_TIMINGS_PART1), |
| 277 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_INPUT_TIMINGS_PART2), |
| 278 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_INPUT_TIMINGS_PART1), |
| 279 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_INPUT_TIMINGS_PART2), |
| 280 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_INPUT_TIMINGS_PART1), |
| 281 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_OUTPUT_TIMINGS_PART1), |
| 282 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_OUTPUT_TIMINGS_PART2), |
| 283 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_OUTPUT_TIMINGS_PART1), |
| 284 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_OUTPUT_TIMINGS_PART2), |
| 285 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_CREATE_PREFERRED_INPUT_TIMING), |
| 286 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_PREFERRED_INPUT_TIMING_PART1), |
| 287 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_PREFERRED_INPUT_TIMING_PART2), |
| 288 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_INPUT_PIXEL_CLOCK_RANGE), |
| 289 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_OUTPUT_PIXEL_CLOCK_RANGE), |
| 290 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_SUPPORTED_CLOCK_RATE_MULTS), |
| 291 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_CLOCK_RATE_MULT), |
| 292 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_CLOCK_RATE_MULT), |
| 293 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_SUPPORTED_TV_FORMATS), |
| 294 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_TV_FORMAT), |
| 295 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_TV_FORMAT), |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 296 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_SUPPORTED_POWER_STATES), |
| 297 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_POWER_STATE), |
| 298 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_ENCODER_POWER_STATE), |
| 299 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_DISPLAY_POWER_STATE), |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 300 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_CONTROL_BUS_SWITCH), |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 301 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_SDTV_RESOLUTION_SUPPORT), |
| 302 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_SCALED_HDTV_RESOLUTION_SUPPORT), |
| 303 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_SUPPORTED_ENHANCEMENTS), |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 304 | /* Add the op code for SDVO enhancements */ |
| 305 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_MAX_POSITION_H), |
| 306 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_POSITION_H), |
| 307 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_POSITION_H), |
| 308 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_MAX_POSITION_V), |
| 309 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_POSITION_V), |
| 310 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_POSITION_V), |
| 311 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_MAX_SATURATION), |
| 312 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_SATURATION), |
| 313 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_SATURATION), |
| 314 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_MAX_HUE), |
| 315 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_HUE), |
| 316 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_HUE), |
| 317 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_MAX_CONTRAST), |
| 318 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_CONTRAST), |
| 319 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_CONTRAST), |
| 320 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_MAX_BRIGHTNESS), |
| 321 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_BRIGHTNESS), |
| 322 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_BRIGHTNESS), |
| 323 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_MAX_OVERSCAN_H), |
| 324 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_OVERSCAN_H), |
| 325 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_OVERSCAN_H), |
| 326 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_MAX_OVERSCAN_V), |
| 327 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_OVERSCAN_V), |
| 328 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_OVERSCAN_V), |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 329 | /* HDMI op code */ |
| 330 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_SUPP_ENCODE), |
| 331 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_ENCODE), |
| 332 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_ENCODE), |
| 333 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_PIXEL_REPLI), |
| 334 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_PIXEL_REPLI), |
| 335 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_COLORIMETRY_CAP), |
| 336 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_COLORIMETRY), |
| 337 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_COLORIMETRY), |
| 338 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_AUDIO_ENCRYPT_PREFER), |
| 339 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_AUDIO_STAT), |
| 340 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_AUDIO_STAT), |
| 341 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_HBUF_INDEX), |
| 342 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_HBUF_INDEX), |
| 343 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_HBUF_INFO), |
| 344 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_HBUF_AV_SPLIT), |
| 345 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_HBUF_AV_SPLIT), |
| 346 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_HBUF_TXRATE), |
| 347 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_HBUF_TXRATE), |
| 348 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_HBUF_DATA), |
| 349 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_HBUF_DATA), |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 350 | }; |
| 351 | |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 352 | #define SDVO_NAME(dev_priv) ((dev_priv)->sdvo_reg == SDVOB ? "SDVOB" : "SDVOC") |
| 353 | #define SDVO_PRIV(encoder) ((struct intel_sdvo_priv *) (encoder)->dev_priv) |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 354 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 355 | static void intel_sdvo_debug_write(struct intel_encoder *intel_encoder, u8 cmd, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 356 | void *args, int args_len) |
| 357 | { |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 358 | struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 359 | int i; |
| 360 | |
Zhao Yakui | 8a4c47f | 2009-07-20 13:48:04 +0800 | [diff] [blame] | 361 | DRM_DEBUG_KMS("%s: W: %02X ", |
yakui_zhao | 342dc38 | 2009-06-02 14:12:00 +0800 | [diff] [blame] | 362 | SDVO_NAME(sdvo_priv), cmd); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 363 | for (i = 0; i < args_len; i++) |
yakui_zhao | 342dc38 | 2009-06-02 14:12:00 +0800 | [diff] [blame] | 364 | DRM_LOG_KMS("%02X ", ((u8 *)args)[i]); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 365 | for (; i < 8; i++) |
yakui_zhao | 342dc38 | 2009-06-02 14:12:00 +0800 | [diff] [blame] | 366 | DRM_LOG_KMS(" "); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 367 | for (i = 0; i < sizeof(sdvo_cmd_names) / sizeof(sdvo_cmd_names[0]); i++) { |
| 368 | if (cmd == sdvo_cmd_names[i].cmd) { |
yakui_zhao | 342dc38 | 2009-06-02 14:12:00 +0800 | [diff] [blame] | 369 | DRM_LOG_KMS("(%s)", sdvo_cmd_names[i].name); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 370 | break; |
| 371 | } |
| 372 | } |
| 373 | if (i == sizeof(sdvo_cmd_names)/ sizeof(sdvo_cmd_names[0])) |
yakui_zhao | 342dc38 | 2009-06-02 14:12:00 +0800 | [diff] [blame] | 374 | DRM_LOG_KMS("(%02X)", cmd); |
| 375 | DRM_LOG_KMS("\n"); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 376 | } |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 377 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 378 | static void intel_sdvo_write_cmd(struct intel_encoder *intel_encoder, u8 cmd, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 379 | void *args, int args_len) |
| 380 | { |
| 381 | int i; |
| 382 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 383 | intel_sdvo_debug_write(intel_encoder, cmd, args, args_len); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 384 | |
| 385 | for (i = 0; i < args_len; i++) { |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 386 | intel_sdvo_write_byte(intel_encoder, SDVO_I2C_ARG_0 - i, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 387 | ((u8*)args)[i]); |
| 388 | } |
| 389 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 390 | intel_sdvo_write_byte(intel_encoder, SDVO_I2C_OPCODE, cmd); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 391 | } |
| 392 | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 393 | static const char *cmd_status_names[] = { |
| 394 | "Power on", |
| 395 | "Success", |
| 396 | "Not supported", |
| 397 | "Invalid arg", |
| 398 | "Pending", |
| 399 | "Target not specified", |
| 400 | "Scaling not supported" |
| 401 | }; |
| 402 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 403 | static void intel_sdvo_debug_response(struct intel_encoder *intel_encoder, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 404 | void *response, int response_len, |
| 405 | u8 status) |
| 406 | { |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 407 | struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv; |
Zhenyu Wang | 33b5296 | 2009-03-24 14:02:40 +0800 | [diff] [blame] | 408 | int i; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 409 | |
Zhao Yakui | 8a4c47f | 2009-07-20 13:48:04 +0800 | [diff] [blame] | 410 | DRM_DEBUG_KMS("%s: R: ", SDVO_NAME(sdvo_priv)); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 411 | for (i = 0; i < response_len; i++) |
yakui_zhao | 342dc38 | 2009-06-02 14:12:00 +0800 | [diff] [blame] | 412 | DRM_LOG_KMS("%02X ", ((u8 *)response)[i]); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 413 | for (; i < 8; i++) |
yakui_zhao | 342dc38 | 2009-06-02 14:12:00 +0800 | [diff] [blame] | 414 | DRM_LOG_KMS(" "); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 415 | if (status <= SDVO_CMD_STATUS_SCALING_NOT_SUPP) |
yakui_zhao | 342dc38 | 2009-06-02 14:12:00 +0800 | [diff] [blame] | 416 | DRM_LOG_KMS("(%s)", cmd_status_names[status]); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 417 | else |
yakui_zhao | 342dc38 | 2009-06-02 14:12:00 +0800 | [diff] [blame] | 418 | DRM_LOG_KMS("(??? %d)", status); |
| 419 | DRM_LOG_KMS("\n"); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 420 | } |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 421 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 422 | static u8 intel_sdvo_read_response(struct intel_encoder *intel_encoder, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 423 | void *response, int response_len) |
| 424 | { |
| 425 | int i; |
| 426 | u8 status; |
| 427 | u8 retry = 50; |
| 428 | |
| 429 | while (retry--) { |
| 430 | /* Read the command response */ |
| 431 | for (i = 0; i < response_len; i++) { |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 432 | intel_sdvo_read_byte(intel_encoder, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 433 | SDVO_I2C_RETURN_0 + i, |
| 434 | &((u8 *)response)[i]); |
| 435 | } |
| 436 | |
| 437 | /* read the return status */ |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 438 | intel_sdvo_read_byte(intel_encoder, SDVO_I2C_CMD_STATUS, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 439 | &status); |
| 440 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 441 | intel_sdvo_debug_response(intel_encoder, response, response_len, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 442 | status); |
| 443 | if (status != SDVO_CMD_STATUS_PENDING) |
| 444 | return status; |
| 445 | |
| 446 | mdelay(50); |
| 447 | } |
| 448 | |
| 449 | return status; |
| 450 | } |
| 451 | |
Hannes Eder | b358d0a | 2008-12-18 21:18:47 +0100 | [diff] [blame] | 452 | static int intel_sdvo_get_pixel_multiplier(struct drm_display_mode *mode) |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 453 | { |
| 454 | if (mode->clock >= 100000) |
| 455 | return 1; |
| 456 | else if (mode->clock >= 50000) |
| 457 | return 2; |
| 458 | else |
| 459 | return 4; |
| 460 | } |
| 461 | |
| 462 | /** |
Zhao Yakui | 6a304ca | 2010-01-08 10:58:19 +0800 | [diff] [blame] | 463 | * Try to read the response after issuie the DDC switch command. But it |
| 464 | * is noted that we must do the action of reading response and issuing DDC |
| 465 | * switch command in one I2C transaction. Otherwise when we try to start |
| 466 | * another I2C transaction after issuing the DDC bus switch, it will be |
| 467 | * switched to the internal SDVO register. |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 468 | */ |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 469 | static void intel_sdvo_set_control_bus_switch(struct intel_encoder *intel_encoder, |
Hannes Eder | b358d0a | 2008-12-18 21:18:47 +0100 | [diff] [blame] | 470 | u8 target) |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 471 | { |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 472 | struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv; |
Zhao Yakui | 6a304ca | 2010-01-08 10:58:19 +0800 | [diff] [blame] | 473 | u8 out_buf[2], cmd_buf[2], ret_value[2], ret; |
| 474 | struct i2c_msg msgs[] = { |
| 475 | { |
| 476 | .addr = sdvo_priv->slave_addr >> 1, |
| 477 | .flags = 0, |
| 478 | .len = 2, |
| 479 | .buf = out_buf, |
| 480 | }, |
| 481 | /* the following two are to read the response */ |
| 482 | { |
| 483 | .addr = sdvo_priv->slave_addr >> 1, |
| 484 | .flags = 0, |
| 485 | .len = 1, |
| 486 | .buf = cmd_buf, |
| 487 | }, |
| 488 | { |
| 489 | .addr = sdvo_priv->slave_addr >> 1, |
| 490 | .flags = I2C_M_RD, |
| 491 | .len = 1, |
| 492 | .buf = ret_value, |
| 493 | }, |
| 494 | }; |
| 495 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 496 | intel_sdvo_debug_write(intel_encoder, SDVO_CMD_SET_CONTROL_BUS_SWITCH, |
Zhao Yakui | 6a304ca | 2010-01-08 10:58:19 +0800 | [diff] [blame] | 497 | &target, 1); |
| 498 | /* write the DDC switch command argument */ |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 499 | intel_sdvo_write_byte(intel_encoder, SDVO_I2C_ARG_0, target); |
Zhao Yakui | 6a304ca | 2010-01-08 10:58:19 +0800 | [diff] [blame] | 500 | |
| 501 | out_buf[0] = SDVO_I2C_OPCODE; |
| 502 | out_buf[1] = SDVO_CMD_SET_CONTROL_BUS_SWITCH; |
| 503 | cmd_buf[0] = SDVO_I2C_CMD_STATUS; |
| 504 | cmd_buf[1] = 0; |
| 505 | ret_value[0] = 0; |
| 506 | ret_value[1] = 0; |
| 507 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 508 | ret = i2c_transfer(intel_encoder->i2c_bus, msgs, 3); |
Zhao Yakui | 6a304ca | 2010-01-08 10:58:19 +0800 | [diff] [blame] | 509 | if (ret != 3) { |
| 510 | /* failure in I2C transfer */ |
| 511 | DRM_DEBUG_KMS("I2c transfer returned %d\n", ret); |
| 512 | return; |
| 513 | } |
| 514 | if (ret_value[0] != SDVO_CMD_STATUS_SUCCESS) { |
| 515 | DRM_DEBUG_KMS("DDC switch command returns response %d\n", |
| 516 | ret_value[0]); |
| 517 | return; |
| 518 | } |
| 519 | return; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 520 | } |
| 521 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 522 | static bool intel_sdvo_set_target_input(struct intel_encoder *intel_encoder, bool target_0, bool target_1) |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 523 | { |
| 524 | struct intel_sdvo_set_target_input_args targets = {0}; |
| 525 | u8 status; |
| 526 | |
| 527 | if (target_0 && target_1) |
| 528 | return SDVO_CMD_STATUS_NOTSUPP; |
| 529 | |
| 530 | if (target_1) |
| 531 | targets.target_1 = 1; |
| 532 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 533 | intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_SET_TARGET_INPUT, &targets, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 534 | sizeof(targets)); |
| 535 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 536 | status = intel_sdvo_read_response(intel_encoder, NULL, 0); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 537 | |
| 538 | return (status == SDVO_CMD_STATUS_SUCCESS); |
| 539 | } |
| 540 | |
| 541 | /** |
| 542 | * Return whether each input is trained. |
| 543 | * |
| 544 | * This function is making an assumption about the layout of the response, |
| 545 | * which should be checked against the docs. |
| 546 | */ |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 547 | static bool intel_sdvo_get_trained_inputs(struct intel_encoder *intel_encoder, bool *input_1, bool *input_2) |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 548 | { |
| 549 | struct intel_sdvo_get_trained_inputs_response response; |
| 550 | u8 status; |
| 551 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 552 | intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_GET_TRAINED_INPUTS, NULL, 0); |
| 553 | status = intel_sdvo_read_response(intel_encoder, &response, sizeof(response)); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 554 | if (status != SDVO_CMD_STATUS_SUCCESS) |
| 555 | return false; |
| 556 | |
| 557 | *input_1 = response.input0_trained; |
| 558 | *input_2 = response.input1_trained; |
| 559 | return true; |
| 560 | } |
| 561 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 562 | static bool intel_sdvo_set_active_outputs(struct intel_encoder *intel_encoder, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 563 | u16 outputs) |
| 564 | { |
| 565 | u8 status; |
| 566 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 567 | intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_SET_ACTIVE_OUTPUTS, &outputs, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 568 | sizeof(outputs)); |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 569 | status = intel_sdvo_read_response(intel_encoder, NULL, 0); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 570 | return (status == SDVO_CMD_STATUS_SUCCESS); |
| 571 | } |
| 572 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 573 | static bool intel_sdvo_set_encoder_power_state(struct intel_encoder *intel_encoder, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 574 | int mode) |
| 575 | { |
| 576 | u8 status, state = SDVO_ENCODER_STATE_ON; |
| 577 | |
| 578 | switch (mode) { |
| 579 | case DRM_MODE_DPMS_ON: |
| 580 | state = SDVO_ENCODER_STATE_ON; |
| 581 | break; |
| 582 | case DRM_MODE_DPMS_STANDBY: |
| 583 | state = SDVO_ENCODER_STATE_STANDBY; |
| 584 | break; |
| 585 | case DRM_MODE_DPMS_SUSPEND: |
| 586 | state = SDVO_ENCODER_STATE_SUSPEND; |
| 587 | break; |
| 588 | case DRM_MODE_DPMS_OFF: |
| 589 | state = SDVO_ENCODER_STATE_OFF; |
| 590 | break; |
| 591 | } |
| 592 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 593 | intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_SET_ENCODER_POWER_STATE, &state, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 594 | sizeof(state)); |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 595 | status = intel_sdvo_read_response(intel_encoder, NULL, 0); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 596 | |
| 597 | return (status == SDVO_CMD_STATUS_SUCCESS); |
| 598 | } |
| 599 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 600 | static bool intel_sdvo_get_input_pixel_clock_range(struct intel_encoder *intel_encoder, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 601 | int *clock_min, |
| 602 | int *clock_max) |
| 603 | { |
| 604 | struct intel_sdvo_pixel_clock_range clocks; |
| 605 | u8 status; |
| 606 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 607 | intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_GET_INPUT_PIXEL_CLOCK_RANGE, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 608 | NULL, 0); |
| 609 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 610 | status = intel_sdvo_read_response(intel_encoder, &clocks, sizeof(clocks)); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 611 | |
| 612 | if (status != SDVO_CMD_STATUS_SUCCESS) |
| 613 | return false; |
| 614 | |
| 615 | /* Convert the values from units of 10 kHz to kHz. */ |
| 616 | *clock_min = clocks.min * 10; |
| 617 | *clock_max = clocks.max * 10; |
| 618 | |
| 619 | return true; |
| 620 | } |
| 621 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 622 | static bool intel_sdvo_set_target_output(struct intel_encoder *intel_encoder, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 623 | u16 outputs) |
| 624 | { |
| 625 | u8 status; |
| 626 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 627 | intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_SET_TARGET_OUTPUT, &outputs, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 628 | sizeof(outputs)); |
| 629 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 630 | status = intel_sdvo_read_response(intel_encoder, NULL, 0); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 631 | return (status == SDVO_CMD_STATUS_SUCCESS); |
| 632 | } |
| 633 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 634 | static bool intel_sdvo_set_timing(struct intel_encoder *intel_encoder, u8 cmd, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 635 | struct intel_sdvo_dtd *dtd) |
| 636 | { |
| 637 | u8 status; |
| 638 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 639 | intel_sdvo_write_cmd(intel_encoder, cmd, &dtd->part1, sizeof(dtd->part1)); |
| 640 | status = intel_sdvo_read_response(intel_encoder, NULL, 0); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 641 | if (status != SDVO_CMD_STATUS_SUCCESS) |
| 642 | return false; |
| 643 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 644 | intel_sdvo_write_cmd(intel_encoder, cmd + 1, &dtd->part2, sizeof(dtd->part2)); |
| 645 | status = intel_sdvo_read_response(intel_encoder, NULL, 0); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 646 | if (status != SDVO_CMD_STATUS_SUCCESS) |
| 647 | return false; |
| 648 | |
| 649 | return true; |
| 650 | } |
| 651 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 652 | static bool intel_sdvo_set_input_timing(struct intel_encoder *intel_encoder, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 653 | struct intel_sdvo_dtd *dtd) |
| 654 | { |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 655 | return intel_sdvo_set_timing(intel_encoder, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 656 | SDVO_CMD_SET_INPUT_TIMINGS_PART1, dtd); |
| 657 | } |
| 658 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 659 | static bool intel_sdvo_set_output_timing(struct intel_encoder *intel_encoder, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 660 | struct intel_sdvo_dtd *dtd) |
| 661 | { |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 662 | return intel_sdvo_set_timing(intel_encoder, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 663 | SDVO_CMD_SET_OUTPUT_TIMINGS_PART1, dtd); |
| 664 | } |
| 665 | |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 666 | static bool |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 667 | intel_sdvo_create_preferred_input_timing(struct intel_encoder *intel_encoder, |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 668 | uint16_t clock, |
| 669 | uint16_t width, |
| 670 | uint16_t height) |
| 671 | { |
| 672 | struct intel_sdvo_preferred_input_timing_args args; |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 673 | struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv; |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 674 | uint8_t status; |
| 675 | |
Zhenyu Wang | e642c6f | 2009-03-24 14:02:42 +0800 | [diff] [blame] | 676 | memset(&args, 0, sizeof(args)); |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 677 | args.clock = clock; |
| 678 | args.width = width; |
| 679 | args.height = height; |
Zhenyu Wang | e642c6f | 2009-03-24 14:02:42 +0800 | [diff] [blame] | 680 | args.interlace = 0; |
ling.ma@intel.com | 12682a9 | 2009-06-30 11:35:35 +0800 | [diff] [blame] | 681 | |
| 682 | if (sdvo_priv->is_lvds && |
| 683 | (sdvo_priv->sdvo_lvds_fixed_mode->hdisplay != width || |
| 684 | sdvo_priv->sdvo_lvds_fixed_mode->vdisplay != height)) |
| 685 | args.scaled = 1; |
| 686 | |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 687 | intel_sdvo_write_cmd(intel_encoder, |
| 688 | SDVO_CMD_CREATE_PREFERRED_INPUT_TIMING, |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 689 | &args, sizeof(args)); |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 690 | status = intel_sdvo_read_response(intel_encoder, NULL, 0); |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 691 | if (status != SDVO_CMD_STATUS_SUCCESS) |
| 692 | return false; |
| 693 | |
| 694 | return true; |
| 695 | } |
| 696 | |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 697 | static bool intel_sdvo_get_preferred_input_timing(struct intel_encoder *intel_encoder, |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 698 | struct intel_sdvo_dtd *dtd) |
| 699 | { |
| 700 | bool status; |
| 701 | |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 702 | intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_GET_PREFERRED_INPUT_TIMING_PART1, |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 703 | NULL, 0); |
| 704 | |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 705 | status = intel_sdvo_read_response(intel_encoder, &dtd->part1, |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 706 | sizeof(dtd->part1)); |
| 707 | if (status != SDVO_CMD_STATUS_SUCCESS) |
| 708 | return false; |
| 709 | |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 710 | intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_GET_PREFERRED_INPUT_TIMING_PART2, |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 711 | NULL, 0); |
| 712 | |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 713 | status = intel_sdvo_read_response(intel_encoder, &dtd->part2, |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 714 | sizeof(dtd->part2)); |
| 715 | if (status != SDVO_CMD_STATUS_SUCCESS) |
| 716 | return false; |
| 717 | |
| 718 | return false; |
| 719 | } |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 720 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 721 | static bool intel_sdvo_set_clock_rate_mult(struct intel_encoder *intel_encoder, u8 val) |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 722 | { |
| 723 | u8 status; |
| 724 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 725 | intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_SET_CLOCK_RATE_MULT, &val, 1); |
| 726 | status = intel_sdvo_read_response(intel_encoder, NULL, 0); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 727 | if (status != SDVO_CMD_STATUS_SUCCESS) |
| 728 | return false; |
| 729 | |
| 730 | return true; |
| 731 | } |
| 732 | |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 733 | static void intel_sdvo_get_dtd_from_mode(struct intel_sdvo_dtd *dtd, |
| 734 | struct drm_display_mode *mode) |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 735 | { |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 736 | uint16_t width, height; |
| 737 | uint16_t h_blank_len, h_sync_len, v_blank_len, v_sync_len; |
| 738 | uint16_t h_sync_offset, v_sync_offset; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 739 | |
| 740 | width = mode->crtc_hdisplay; |
| 741 | height = mode->crtc_vdisplay; |
| 742 | |
| 743 | /* do some mode translations */ |
| 744 | h_blank_len = mode->crtc_hblank_end - mode->crtc_hblank_start; |
| 745 | h_sync_len = mode->crtc_hsync_end - mode->crtc_hsync_start; |
| 746 | |
| 747 | v_blank_len = mode->crtc_vblank_end - mode->crtc_vblank_start; |
| 748 | v_sync_len = mode->crtc_vsync_end - mode->crtc_vsync_start; |
| 749 | |
| 750 | h_sync_offset = mode->crtc_hsync_start - mode->crtc_hblank_start; |
| 751 | v_sync_offset = mode->crtc_vsync_start - mode->crtc_vblank_start; |
| 752 | |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 753 | dtd->part1.clock = mode->clock / 10; |
| 754 | dtd->part1.h_active = width & 0xff; |
| 755 | dtd->part1.h_blank = h_blank_len & 0xff; |
| 756 | dtd->part1.h_high = (((width >> 8) & 0xf) << 4) | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 757 | ((h_blank_len >> 8) & 0xf); |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 758 | dtd->part1.v_active = height & 0xff; |
| 759 | dtd->part1.v_blank = v_blank_len & 0xff; |
| 760 | dtd->part1.v_high = (((height >> 8) & 0xf) << 4) | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 761 | ((v_blank_len >> 8) & 0xf); |
| 762 | |
Zhenyu Wang | 171a9e9 | 2009-03-24 14:02:41 +0800 | [diff] [blame] | 763 | dtd->part2.h_sync_off = h_sync_offset & 0xff; |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 764 | dtd->part2.h_sync_width = h_sync_len & 0xff; |
| 765 | dtd->part2.v_sync_off_width = (v_sync_offset & 0xf) << 4 | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 766 | (v_sync_len & 0xf); |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 767 | dtd->part2.sync_off_width_high = ((h_sync_offset & 0x300) >> 2) | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 768 | ((h_sync_len & 0x300) >> 4) | ((v_sync_offset & 0x30) >> 2) | |
| 769 | ((v_sync_len & 0x30) >> 4); |
| 770 | |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 771 | dtd->part2.dtd_flags = 0x18; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 772 | if (mode->flags & DRM_MODE_FLAG_PHSYNC) |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 773 | dtd->part2.dtd_flags |= 0x2; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 774 | if (mode->flags & DRM_MODE_FLAG_PVSYNC) |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 775 | dtd->part2.dtd_flags |= 0x4; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 776 | |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 777 | dtd->part2.sdvo_flags = 0; |
| 778 | dtd->part2.v_sync_off_high = v_sync_offset & 0xc0; |
| 779 | dtd->part2.reserved = 0; |
| 780 | } |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 781 | |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 782 | static void intel_sdvo_get_mode_from_dtd(struct drm_display_mode * mode, |
| 783 | struct intel_sdvo_dtd *dtd) |
| 784 | { |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 785 | mode->hdisplay = dtd->part1.h_active; |
| 786 | mode->hdisplay += ((dtd->part1.h_high >> 4) & 0x0f) << 8; |
| 787 | mode->hsync_start = mode->hdisplay + dtd->part2.h_sync_off; |
Zhenyu Wang | 171a9e9 | 2009-03-24 14:02:41 +0800 | [diff] [blame] | 788 | mode->hsync_start += (dtd->part2.sync_off_width_high & 0xc0) << 2; |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 789 | mode->hsync_end = mode->hsync_start + dtd->part2.h_sync_width; |
| 790 | mode->hsync_end += (dtd->part2.sync_off_width_high & 0x30) << 4; |
| 791 | mode->htotal = mode->hdisplay + dtd->part1.h_blank; |
| 792 | mode->htotal += (dtd->part1.h_high & 0xf) << 8; |
| 793 | |
| 794 | mode->vdisplay = dtd->part1.v_active; |
| 795 | mode->vdisplay += ((dtd->part1.v_high >> 4) & 0x0f) << 8; |
| 796 | mode->vsync_start = mode->vdisplay; |
| 797 | mode->vsync_start += (dtd->part2.v_sync_off_width >> 4) & 0xf; |
Zhenyu Wang | 171a9e9 | 2009-03-24 14:02:41 +0800 | [diff] [blame] | 798 | mode->vsync_start += (dtd->part2.sync_off_width_high & 0x0c) << 2; |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 799 | mode->vsync_start += dtd->part2.v_sync_off_high & 0xc0; |
| 800 | mode->vsync_end = mode->vsync_start + |
| 801 | (dtd->part2.v_sync_off_width & 0xf); |
| 802 | mode->vsync_end += (dtd->part2.sync_off_width_high & 0x3) << 4; |
| 803 | mode->vtotal = mode->vdisplay + dtd->part1.v_blank; |
| 804 | mode->vtotal += (dtd->part1.v_high & 0xf) << 8; |
| 805 | |
| 806 | mode->clock = dtd->part1.clock * 10; |
| 807 | |
Zhenyu Wang | 171a9e9 | 2009-03-24 14:02:41 +0800 | [diff] [blame] | 808 | mode->flags &= ~(DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC); |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 809 | if (dtd->part2.dtd_flags & 0x2) |
| 810 | mode->flags |= DRM_MODE_FLAG_PHSYNC; |
| 811 | if (dtd->part2.dtd_flags & 0x4) |
| 812 | mode->flags |= DRM_MODE_FLAG_PVSYNC; |
| 813 | } |
| 814 | |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 815 | static bool intel_sdvo_get_supp_encode(struct intel_encoder *intel_encoder, |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 816 | struct intel_sdvo_encode *encode) |
| 817 | { |
| 818 | uint8_t status; |
| 819 | |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 820 | intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_GET_SUPP_ENCODE, NULL, 0); |
| 821 | status = intel_sdvo_read_response(intel_encoder, encode, sizeof(*encode)); |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 822 | if (status != SDVO_CMD_STATUS_SUCCESS) { /* non-support means DVI */ |
| 823 | memset(encode, 0, sizeof(*encode)); |
| 824 | return false; |
| 825 | } |
| 826 | |
| 827 | return true; |
| 828 | } |
| 829 | |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 830 | static bool intel_sdvo_set_encode(struct intel_encoder *intel_encoder, |
| 831 | uint8_t mode) |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 832 | { |
| 833 | uint8_t status; |
| 834 | |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 835 | intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_SET_ENCODE, &mode, 1); |
| 836 | status = intel_sdvo_read_response(intel_encoder, NULL, 0); |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 837 | |
| 838 | return (status == SDVO_CMD_STATUS_SUCCESS); |
| 839 | } |
| 840 | |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 841 | static bool intel_sdvo_set_colorimetry(struct intel_encoder *intel_encoder, |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 842 | uint8_t mode) |
| 843 | { |
| 844 | uint8_t status; |
| 845 | |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 846 | intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_SET_COLORIMETRY, &mode, 1); |
| 847 | status = intel_sdvo_read_response(intel_encoder, NULL, 0); |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 848 | |
| 849 | return (status == SDVO_CMD_STATUS_SUCCESS); |
| 850 | } |
| 851 | |
| 852 | #if 0 |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 853 | static void intel_sdvo_dump_hdmi_buf(struct intel_encoder *intel_encoder) |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 854 | { |
| 855 | int i, j; |
| 856 | uint8_t set_buf_index[2]; |
| 857 | uint8_t av_split; |
| 858 | uint8_t buf_size; |
| 859 | uint8_t buf[48]; |
| 860 | uint8_t *pos; |
| 861 | |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 862 | intel_sdvo_write_cmd(encoder, SDVO_CMD_GET_HBUF_AV_SPLIT, NULL, 0); |
| 863 | intel_sdvo_read_response(encoder, &av_split, 1); |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 864 | |
| 865 | for (i = 0; i <= av_split; i++) { |
| 866 | set_buf_index[0] = i; set_buf_index[1] = 0; |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 867 | intel_sdvo_write_cmd(encoder, SDVO_CMD_SET_HBUF_INDEX, |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 868 | set_buf_index, 2); |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 869 | intel_sdvo_write_cmd(encoder, SDVO_CMD_GET_HBUF_INFO, NULL, 0); |
| 870 | intel_sdvo_read_response(encoder, &buf_size, 1); |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 871 | |
| 872 | pos = buf; |
| 873 | for (j = 0; j <= buf_size; j += 8) { |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 874 | intel_sdvo_write_cmd(encoder, SDVO_CMD_GET_HBUF_DATA, |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 875 | NULL, 0); |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 876 | intel_sdvo_read_response(encoder, pos, 8); |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 877 | pos += 8; |
| 878 | } |
| 879 | } |
| 880 | } |
| 881 | #endif |
| 882 | |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 883 | static void intel_sdvo_set_hdmi_buf(struct intel_encoder *intel_encoder, |
| 884 | int index, |
| 885 | uint8_t *data, int8_t size, uint8_t tx_rate) |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 886 | { |
| 887 | uint8_t set_buf_index[2]; |
| 888 | |
| 889 | set_buf_index[0] = index; |
| 890 | set_buf_index[1] = 0; |
| 891 | |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 892 | intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_SET_HBUF_INDEX, |
| 893 | set_buf_index, 2); |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 894 | |
| 895 | for (; size > 0; size -= 8) { |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 896 | intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_SET_HBUF_DATA, data, 8); |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 897 | data += 8; |
| 898 | } |
| 899 | |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 900 | intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_SET_HBUF_TXRATE, &tx_rate, 1); |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 901 | } |
| 902 | |
| 903 | static uint8_t intel_sdvo_calc_hbuf_csum(uint8_t *data, uint8_t size) |
| 904 | { |
| 905 | uint8_t csum = 0; |
| 906 | int i; |
| 907 | |
| 908 | for (i = 0; i < size; i++) |
| 909 | csum += data[i]; |
| 910 | |
| 911 | return 0x100 - csum; |
| 912 | } |
| 913 | |
| 914 | #define DIP_TYPE_AVI 0x82 |
| 915 | #define DIP_VERSION_AVI 0x2 |
| 916 | #define DIP_LEN_AVI 13 |
| 917 | |
| 918 | struct dip_infoframe { |
| 919 | uint8_t type; |
| 920 | uint8_t version; |
| 921 | uint8_t len; |
| 922 | uint8_t checksum; |
| 923 | union { |
| 924 | struct { |
| 925 | /* Packet Byte #1 */ |
| 926 | uint8_t S:2; |
| 927 | uint8_t B:2; |
| 928 | uint8_t A:1; |
| 929 | uint8_t Y:2; |
| 930 | uint8_t rsvd1:1; |
| 931 | /* Packet Byte #2 */ |
| 932 | uint8_t R:4; |
| 933 | uint8_t M:2; |
| 934 | uint8_t C:2; |
| 935 | /* Packet Byte #3 */ |
| 936 | uint8_t SC:2; |
| 937 | uint8_t Q:2; |
| 938 | uint8_t EC:3; |
| 939 | uint8_t ITC:1; |
| 940 | /* Packet Byte #4 */ |
| 941 | uint8_t VIC:7; |
| 942 | uint8_t rsvd2:1; |
| 943 | /* Packet Byte #5 */ |
| 944 | uint8_t PR:4; |
| 945 | uint8_t rsvd3:4; |
| 946 | /* Packet Byte #6~13 */ |
| 947 | uint16_t top_bar_end; |
| 948 | uint16_t bottom_bar_start; |
| 949 | uint16_t left_bar_end; |
| 950 | uint16_t right_bar_start; |
| 951 | } avi; |
| 952 | struct { |
| 953 | /* Packet Byte #1 */ |
| 954 | uint8_t channel_count:3; |
| 955 | uint8_t rsvd1:1; |
| 956 | uint8_t coding_type:4; |
| 957 | /* Packet Byte #2 */ |
| 958 | uint8_t sample_size:2; /* SS0, SS1 */ |
| 959 | uint8_t sample_frequency:3; |
| 960 | uint8_t rsvd2:3; |
| 961 | /* Packet Byte #3 */ |
| 962 | uint8_t coding_type_private:5; |
| 963 | uint8_t rsvd3:3; |
| 964 | /* Packet Byte #4 */ |
| 965 | uint8_t channel_allocation; |
| 966 | /* Packet Byte #5 */ |
| 967 | uint8_t rsvd4:3; |
| 968 | uint8_t level_shift:4; |
| 969 | uint8_t downmix_inhibit:1; |
| 970 | } audio; |
| 971 | uint8_t payload[28]; |
| 972 | } __attribute__ ((packed)) u; |
| 973 | } __attribute__((packed)); |
| 974 | |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 975 | static void intel_sdvo_set_avi_infoframe(struct intel_encoder *intel_encoder, |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 976 | struct drm_display_mode * mode) |
| 977 | { |
| 978 | struct dip_infoframe avi_if = { |
| 979 | .type = DIP_TYPE_AVI, |
| 980 | .version = DIP_VERSION_AVI, |
| 981 | .len = DIP_LEN_AVI, |
| 982 | }; |
| 983 | |
| 984 | avi_if.checksum = intel_sdvo_calc_hbuf_csum((uint8_t *)&avi_if, |
| 985 | 4 + avi_if.len); |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 986 | intel_sdvo_set_hdmi_buf(intel_encoder, 1, (uint8_t *)&avi_if, |
| 987 | 4 + avi_if.len, |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 988 | SDVO_HBUF_TX_VSYNC); |
| 989 | } |
| 990 | |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 991 | static void intel_sdvo_set_tv_format(struct intel_encoder *intel_encoder) |
Zhenyu Wang | 7026d4a | 2009-03-24 14:02:43 +0800 | [diff] [blame] | 992 | { |
Zhenyu Wang | 7026d4a | 2009-03-24 14:02:43 +0800 | [diff] [blame] | 993 | |
Zhao Yakui | ce6feab | 2009-08-24 13:50:26 +0800 | [diff] [blame] | 994 | struct intel_sdvo_tv_format format; |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 995 | struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv; |
Zhao Yakui | ce6feab | 2009-08-24 13:50:26 +0800 | [diff] [blame] | 996 | uint32_t format_map, i; |
| 997 | uint8_t status; |
| 998 | |
| 999 | for (i = 0; i < TV_FORMAT_NUM; i++) |
| 1000 | if (tv_format_names[i] == sdvo_priv->tv_format_name) |
| 1001 | break; |
| 1002 | |
| 1003 | format_map = 1 << i; |
| 1004 | memset(&format, 0, sizeof(format)); |
| 1005 | memcpy(&format, &format_map, sizeof(format_map) > sizeof(format) ? |
| 1006 | sizeof(format) : sizeof(format_map)); |
| 1007 | |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 1008 | intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_SET_TV_FORMAT, &format_map, |
Zhao Yakui | ce6feab | 2009-08-24 13:50:26 +0800 | [diff] [blame] | 1009 | sizeof(format)); |
| 1010 | |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 1011 | status = intel_sdvo_read_response(intel_encoder, NULL, 0); |
Zhao Yakui | ce6feab | 2009-08-24 13:50:26 +0800 | [diff] [blame] | 1012 | if (status != SDVO_CMD_STATUS_SUCCESS) |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 1013 | DRM_DEBUG_KMS("%s: Failed to set TV format\n", |
Zhao Yakui | ce6feab | 2009-08-24 13:50:26 +0800 | [diff] [blame] | 1014 | SDVO_NAME(sdvo_priv)); |
Zhenyu Wang | 7026d4a | 2009-03-24 14:02:43 +0800 | [diff] [blame] | 1015 | } |
| 1016 | |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1017 | static bool intel_sdvo_mode_fixup(struct drm_encoder *encoder, |
| 1018 | struct drm_display_mode *mode, |
| 1019 | struct drm_display_mode *adjusted_mode) |
| 1020 | { |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 1021 | struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder); |
| 1022 | struct intel_sdvo_priv *dev_priv = intel_encoder->dev_priv; |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1023 | |
ling.ma@intel.com | 12682a9 | 2009-06-30 11:35:35 +0800 | [diff] [blame] | 1024 | if (dev_priv->is_tv) { |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1025 | struct intel_sdvo_dtd output_dtd; |
| 1026 | bool success; |
| 1027 | |
| 1028 | /* We need to construct preferred input timings based on our |
| 1029 | * output timings. To do that, we have to set the output |
| 1030 | * timings, even though this isn't really the right place in |
| 1031 | * the sequence to do it. Oh well. |
| 1032 | */ |
| 1033 | |
| 1034 | |
| 1035 | /* Set output timings */ |
| 1036 | intel_sdvo_get_dtd_from_mode(&output_dtd, mode); |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 1037 | intel_sdvo_set_target_output(intel_encoder, |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1038 | dev_priv->controlled_output); |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 1039 | intel_sdvo_set_output_timing(intel_encoder, &output_dtd); |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1040 | |
| 1041 | /* Set the input timing to the screen. Assume always input 0. */ |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 1042 | intel_sdvo_set_target_input(intel_encoder, true, false); |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1043 | |
| 1044 | |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 1045 | success = intel_sdvo_create_preferred_input_timing(intel_encoder, |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1046 | mode->clock / 10, |
| 1047 | mode->hdisplay, |
| 1048 | mode->vdisplay); |
| 1049 | if (success) { |
| 1050 | struct intel_sdvo_dtd input_dtd; |
| 1051 | |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 1052 | intel_sdvo_get_preferred_input_timing(intel_encoder, |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1053 | &input_dtd); |
| 1054 | intel_sdvo_get_mode_from_dtd(adjusted_mode, &input_dtd); |
ling.ma@intel.com | 12682a9 | 2009-06-30 11:35:35 +0800 | [diff] [blame] | 1055 | dev_priv->sdvo_flags = input_dtd.part2.sdvo_flags; |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1056 | |
Zhenyu Wang | 7026d4a | 2009-03-24 14:02:43 +0800 | [diff] [blame] | 1057 | drm_mode_set_crtcinfo(adjusted_mode, 0); |
| 1058 | |
| 1059 | mode->clock = adjusted_mode->clock; |
| 1060 | |
| 1061 | adjusted_mode->clock *= |
| 1062 | intel_sdvo_get_pixel_multiplier(mode); |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1063 | } else { |
| 1064 | return false; |
| 1065 | } |
ling.ma@intel.com | 12682a9 | 2009-06-30 11:35:35 +0800 | [diff] [blame] | 1066 | } else if (dev_priv->is_lvds) { |
| 1067 | struct intel_sdvo_dtd output_dtd; |
| 1068 | bool success; |
| 1069 | |
| 1070 | drm_mode_set_crtcinfo(dev_priv->sdvo_lvds_fixed_mode, 0); |
| 1071 | /* Set output timings */ |
| 1072 | intel_sdvo_get_dtd_from_mode(&output_dtd, |
| 1073 | dev_priv->sdvo_lvds_fixed_mode); |
| 1074 | |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 1075 | intel_sdvo_set_target_output(intel_encoder, |
ling.ma@intel.com | 12682a9 | 2009-06-30 11:35:35 +0800 | [diff] [blame] | 1076 | dev_priv->controlled_output); |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 1077 | intel_sdvo_set_output_timing(intel_encoder, &output_dtd); |
ling.ma@intel.com | 12682a9 | 2009-06-30 11:35:35 +0800 | [diff] [blame] | 1078 | |
| 1079 | /* Set the input timing to the screen. Assume always input 0. */ |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 1080 | intel_sdvo_set_target_input(intel_encoder, true, false); |
ling.ma@intel.com | 12682a9 | 2009-06-30 11:35:35 +0800 | [diff] [blame] | 1081 | |
| 1082 | |
| 1083 | success = intel_sdvo_create_preferred_input_timing( |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 1084 | intel_encoder, |
ling.ma@intel.com | 12682a9 | 2009-06-30 11:35:35 +0800 | [diff] [blame] | 1085 | mode->clock / 10, |
| 1086 | mode->hdisplay, |
| 1087 | mode->vdisplay); |
| 1088 | |
| 1089 | if (success) { |
| 1090 | struct intel_sdvo_dtd input_dtd; |
| 1091 | |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 1092 | intel_sdvo_get_preferred_input_timing(intel_encoder, |
ling.ma@intel.com | 12682a9 | 2009-06-30 11:35:35 +0800 | [diff] [blame] | 1093 | &input_dtd); |
| 1094 | intel_sdvo_get_mode_from_dtd(adjusted_mode, &input_dtd); |
| 1095 | dev_priv->sdvo_flags = input_dtd.part2.sdvo_flags; |
| 1096 | |
| 1097 | drm_mode_set_crtcinfo(adjusted_mode, 0); |
| 1098 | |
| 1099 | mode->clock = adjusted_mode->clock; |
| 1100 | |
| 1101 | adjusted_mode->clock *= |
| 1102 | intel_sdvo_get_pixel_multiplier(mode); |
| 1103 | } else { |
| 1104 | return false; |
| 1105 | } |
| 1106 | |
| 1107 | } else { |
| 1108 | /* Make the CRTC code factor in the SDVO pixel multiplier. The |
| 1109 | * SDVO device will be told of the multiplier during mode_set. |
| 1110 | */ |
| 1111 | adjusted_mode->clock *= intel_sdvo_get_pixel_multiplier(mode); |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1112 | } |
| 1113 | return true; |
| 1114 | } |
| 1115 | |
| 1116 | static void intel_sdvo_mode_set(struct drm_encoder *encoder, |
| 1117 | struct drm_display_mode *mode, |
| 1118 | struct drm_display_mode *adjusted_mode) |
| 1119 | { |
| 1120 | struct drm_device *dev = encoder->dev; |
| 1121 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1122 | struct drm_crtc *crtc = encoder->crtc; |
| 1123 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 1124 | struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder); |
| 1125 | struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv; |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1126 | u32 sdvox = 0; |
| 1127 | int sdvo_pixel_multiply; |
| 1128 | struct intel_sdvo_in_out_map in_out; |
| 1129 | struct intel_sdvo_dtd input_dtd; |
| 1130 | u8 status; |
| 1131 | |
| 1132 | if (!mode) |
| 1133 | return; |
| 1134 | |
| 1135 | /* First, set the input mapping for the first input to our controlled |
| 1136 | * output. This is only correct if we're a single-input device, in |
| 1137 | * which case the first input is the output from the appropriate SDVO |
| 1138 | * channel on the motherboard. In a two-input device, the first input |
| 1139 | * will be SDVOB and the second SDVOC. |
| 1140 | */ |
| 1141 | in_out.in0 = sdvo_priv->controlled_output; |
| 1142 | in_out.in1 = 0; |
| 1143 | |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 1144 | intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_SET_IN_OUT_MAP, |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1145 | &in_out, sizeof(in_out)); |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 1146 | status = intel_sdvo_read_response(intel_encoder, NULL, 0); |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1147 | |
| 1148 | if (sdvo_priv->is_hdmi) { |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 1149 | intel_sdvo_set_avi_infoframe(intel_encoder, mode); |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1150 | sdvox |= SDVO_AUDIO_ENABLE; |
| 1151 | } |
| 1152 | |
Zhenyu Wang | 7026d4a | 2009-03-24 14:02:43 +0800 | [diff] [blame] | 1153 | /* We have tried to get input timing in mode_fixup, and filled into |
| 1154 | adjusted_mode */ |
ling.ma@intel.com | 12682a9 | 2009-06-30 11:35:35 +0800 | [diff] [blame] | 1155 | if (sdvo_priv->is_tv || sdvo_priv->is_lvds) { |
Zhenyu Wang | 7026d4a | 2009-03-24 14:02:43 +0800 | [diff] [blame] | 1156 | intel_sdvo_get_dtd_from_mode(&input_dtd, adjusted_mode); |
ling.ma@intel.com | 12682a9 | 2009-06-30 11:35:35 +0800 | [diff] [blame] | 1157 | input_dtd.part2.sdvo_flags = sdvo_priv->sdvo_flags; |
| 1158 | } else |
Zhenyu Wang | 7026d4a | 2009-03-24 14:02:43 +0800 | [diff] [blame] | 1159 | intel_sdvo_get_dtd_from_mode(&input_dtd, mode); |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1160 | |
| 1161 | /* If it's a TV, we already set the output timing in mode_fixup. |
| 1162 | * Otherwise, the output timing is equal to the input timing. |
| 1163 | */ |
ling.ma@intel.com | 12682a9 | 2009-06-30 11:35:35 +0800 | [diff] [blame] | 1164 | if (!sdvo_priv->is_tv && !sdvo_priv->is_lvds) { |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1165 | /* Set the output timing to the screen */ |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 1166 | intel_sdvo_set_target_output(intel_encoder, |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1167 | sdvo_priv->controlled_output); |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 1168 | intel_sdvo_set_output_timing(intel_encoder, &input_dtd); |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1169 | } |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1170 | |
| 1171 | /* Set the input timing to the screen. Assume always input 0. */ |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 1172 | intel_sdvo_set_target_input(intel_encoder, true, false); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1173 | |
Zhenyu Wang | 7026d4a | 2009-03-24 14:02:43 +0800 | [diff] [blame] | 1174 | if (sdvo_priv->is_tv) |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 1175 | intel_sdvo_set_tv_format(intel_encoder); |
Zhenyu Wang | 7026d4a | 2009-03-24 14:02:43 +0800 | [diff] [blame] | 1176 | |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1177 | /* We would like to use intel_sdvo_create_preferred_input_timing() to |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1178 | * provide the device with a timing it can support, if it supports that |
| 1179 | * feature. However, presumably we would need to adjust the CRTC to |
| 1180 | * output the preferred timing, and we don't support that currently. |
| 1181 | */ |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1182 | #if 0 |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 1183 | success = intel_sdvo_create_preferred_input_timing(encoder, clock, |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1184 | width, height); |
| 1185 | if (success) { |
| 1186 | struct intel_sdvo_dtd *input_dtd; |
| 1187 | |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 1188 | intel_sdvo_get_preferred_input_timing(encoder, &input_dtd); |
| 1189 | intel_sdvo_set_input_timing(encoder, &input_dtd); |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1190 | } |
| 1191 | #else |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 1192 | intel_sdvo_set_input_timing(intel_encoder, &input_dtd); |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1193 | #endif |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1194 | |
| 1195 | switch (intel_sdvo_get_pixel_multiplier(mode)) { |
| 1196 | case 1: |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 1197 | intel_sdvo_set_clock_rate_mult(intel_encoder, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1198 | SDVO_CLOCK_RATE_MULT_1X); |
| 1199 | break; |
| 1200 | case 2: |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 1201 | intel_sdvo_set_clock_rate_mult(intel_encoder, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1202 | SDVO_CLOCK_RATE_MULT_2X); |
| 1203 | break; |
| 1204 | case 4: |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 1205 | intel_sdvo_set_clock_rate_mult(intel_encoder, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1206 | SDVO_CLOCK_RATE_MULT_4X); |
| 1207 | break; |
| 1208 | } |
| 1209 | |
| 1210 | /* Set the SDVO control regs. */ |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1211 | if (IS_I965G(dev)) { |
| 1212 | sdvox |= SDVO_BORDER_ENABLE | |
| 1213 | SDVO_VSYNC_ACTIVE_HIGH | |
| 1214 | SDVO_HSYNC_ACTIVE_HIGH; |
| 1215 | } else { |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 1216 | sdvox |= I915_READ(sdvo_priv->sdvo_reg); |
| 1217 | switch (sdvo_priv->sdvo_reg) { |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1218 | case SDVOB: |
| 1219 | sdvox &= SDVOB_PRESERVE_MASK; |
| 1220 | break; |
| 1221 | case SDVOC: |
| 1222 | sdvox &= SDVOC_PRESERVE_MASK; |
| 1223 | break; |
| 1224 | } |
| 1225 | sdvox |= (9 << 19) | SDVO_BORDER_ENABLE; |
| 1226 | } |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1227 | if (intel_crtc->pipe == 1) |
| 1228 | sdvox |= SDVO_PIPE_B_SELECT; |
| 1229 | |
| 1230 | sdvo_pixel_multiply = intel_sdvo_get_pixel_multiplier(mode); |
| 1231 | if (IS_I965G(dev)) { |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1232 | /* done in crtc_mode_set as the dpll_md reg must be written early */ |
| 1233 | } else if (IS_I945G(dev) || IS_I945GM(dev) || IS_G33(dev)) { |
| 1234 | /* done in crtc_mode_set as it lives inside the dpll register */ |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1235 | } else { |
| 1236 | sdvox |= (sdvo_pixel_multiply - 1) << SDVO_PORT_MULTIPLY_SHIFT; |
| 1237 | } |
| 1238 | |
ling.ma@intel.com | 12682a9 | 2009-06-30 11:35:35 +0800 | [diff] [blame] | 1239 | if (sdvo_priv->sdvo_flags & SDVO_NEED_TO_STALL) |
| 1240 | sdvox |= SDVO_STALL_SELECT; |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 1241 | intel_sdvo_write_sdvox(intel_encoder, sdvox); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1242 | } |
| 1243 | |
| 1244 | static void intel_sdvo_dpms(struct drm_encoder *encoder, int mode) |
| 1245 | { |
| 1246 | struct drm_device *dev = encoder->dev; |
| 1247 | struct drm_i915_private *dev_priv = dev->dev_private; |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 1248 | struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder); |
| 1249 | struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1250 | u32 temp; |
| 1251 | |
| 1252 | if (mode != DRM_MODE_DPMS_ON) { |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 1253 | intel_sdvo_set_active_outputs(intel_encoder, 0); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1254 | if (0) |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 1255 | intel_sdvo_set_encoder_power_state(intel_encoder, mode); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1256 | |
| 1257 | if (mode == DRM_MODE_DPMS_OFF) { |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 1258 | temp = I915_READ(sdvo_priv->sdvo_reg); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1259 | if ((temp & SDVO_ENABLE) != 0) { |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 1260 | intel_sdvo_write_sdvox(intel_encoder, temp & ~SDVO_ENABLE); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1261 | } |
| 1262 | } |
| 1263 | } else { |
| 1264 | bool input1, input2; |
| 1265 | int i; |
| 1266 | u8 status; |
| 1267 | |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 1268 | temp = I915_READ(sdvo_priv->sdvo_reg); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1269 | if ((temp & SDVO_ENABLE) == 0) |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 1270 | intel_sdvo_write_sdvox(intel_encoder, temp | SDVO_ENABLE); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1271 | for (i = 0; i < 2; i++) |
| 1272 | intel_wait_for_vblank(dev); |
| 1273 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 1274 | status = intel_sdvo_get_trained_inputs(intel_encoder, &input1, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1275 | &input2); |
| 1276 | |
| 1277 | |
| 1278 | /* Warn if the device reported failure to sync. |
| 1279 | * A lot of SDVO devices fail to notify of sync, but it's |
| 1280 | * a given it the status is a success, we succeeded. |
| 1281 | */ |
| 1282 | if (status == SDVO_CMD_STATUS_SUCCESS && !input1) { |
Zhao Yakui | 8a4c47f | 2009-07-20 13:48:04 +0800 | [diff] [blame] | 1283 | DRM_DEBUG_KMS("First %s output reported failure to " |
| 1284 | "sync\n", SDVO_NAME(sdvo_priv)); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1285 | } |
| 1286 | |
| 1287 | if (0) |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 1288 | intel_sdvo_set_encoder_power_state(intel_encoder, mode); |
| 1289 | intel_sdvo_set_active_outputs(intel_encoder, sdvo_priv->controlled_output); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1290 | } |
| 1291 | return; |
| 1292 | } |
| 1293 | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1294 | static int intel_sdvo_mode_valid(struct drm_connector *connector, |
| 1295 | struct drm_display_mode *mode) |
| 1296 | { |
Zhenyu Wang | d2a82a6 | 2010-03-29 21:22:55 +0800 | [diff] [blame^] | 1297 | struct drm_encoder *encoder = intel_attached_encoder(connector); |
| 1298 | struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder); |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 1299 | struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1300 | |
| 1301 | if (mode->flags & DRM_MODE_FLAG_DBLSCAN) |
| 1302 | return MODE_NO_DBLESCAN; |
| 1303 | |
| 1304 | if (sdvo_priv->pixel_clock_min > mode->clock) |
| 1305 | return MODE_CLOCK_LOW; |
| 1306 | |
| 1307 | if (sdvo_priv->pixel_clock_max < mode->clock) |
| 1308 | return MODE_CLOCK_HIGH; |
| 1309 | |
ling.ma@intel.com | 12682a9 | 2009-06-30 11:35:35 +0800 | [diff] [blame] | 1310 | if (sdvo_priv->is_lvds == true) { |
| 1311 | if (sdvo_priv->sdvo_lvds_fixed_mode == NULL) |
| 1312 | return MODE_PANEL; |
| 1313 | |
| 1314 | if (mode->hdisplay > sdvo_priv->sdvo_lvds_fixed_mode->hdisplay) |
| 1315 | return MODE_PANEL; |
| 1316 | |
| 1317 | if (mode->vdisplay > sdvo_priv->sdvo_lvds_fixed_mode->vdisplay) |
| 1318 | return MODE_PANEL; |
| 1319 | } |
| 1320 | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1321 | return MODE_OK; |
| 1322 | } |
| 1323 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 1324 | static bool intel_sdvo_get_capabilities(struct intel_encoder *intel_encoder, struct intel_sdvo_caps *caps) |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1325 | { |
| 1326 | u8 status; |
| 1327 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 1328 | intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_GET_DEVICE_CAPS, NULL, 0); |
| 1329 | status = intel_sdvo_read_response(intel_encoder, caps, sizeof(*caps)); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1330 | if (status != SDVO_CMD_STATUS_SUCCESS) |
| 1331 | return false; |
| 1332 | |
| 1333 | return true; |
| 1334 | } |
| 1335 | |
Zhenyu Wang | d2a82a6 | 2010-03-29 21:22:55 +0800 | [diff] [blame^] | 1336 | /* No use! */ |
| 1337 | #if 0 |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1338 | struct drm_connector* intel_sdvo_find(struct drm_device *dev, int sdvoB) |
| 1339 | { |
| 1340 | struct drm_connector *connector = NULL; |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 1341 | struct intel_encoder *iout = NULL; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1342 | struct intel_sdvo_priv *sdvo; |
| 1343 | |
| 1344 | /* find the sdvo connector */ |
| 1345 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 1346 | iout = to_intel_encoder(connector); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1347 | |
| 1348 | if (iout->type != INTEL_OUTPUT_SDVO) |
| 1349 | continue; |
| 1350 | |
| 1351 | sdvo = iout->dev_priv; |
| 1352 | |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 1353 | if (sdvo->sdvo_reg == SDVOB && sdvoB) |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1354 | return connector; |
| 1355 | |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 1356 | if (sdvo->sdvo_reg == SDVOC && !sdvoB) |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1357 | return connector; |
| 1358 | |
| 1359 | } |
| 1360 | |
| 1361 | return NULL; |
| 1362 | } |
| 1363 | |
| 1364 | int intel_sdvo_supports_hotplug(struct drm_connector *connector) |
| 1365 | { |
| 1366 | u8 response[2]; |
| 1367 | u8 status; |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 1368 | struct intel_encoder *intel_encoder; |
Zhao Yakui | 8a4c47f | 2009-07-20 13:48:04 +0800 | [diff] [blame] | 1369 | DRM_DEBUG_KMS("\n"); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1370 | |
| 1371 | if (!connector) |
| 1372 | return 0; |
| 1373 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 1374 | intel_encoder = to_intel_encoder(connector); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1375 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 1376 | intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_GET_HOT_PLUG_SUPPORT, NULL, 0); |
| 1377 | status = intel_sdvo_read_response(intel_encoder, &response, 2); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1378 | |
| 1379 | if (response[0] !=0) |
| 1380 | return 1; |
| 1381 | |
| 1382 | return 0; |
| 1383 | } |
| 1384 | |
| 1385 | void intel_sdvo_set_hotplug(struct drm_connector *connector, int on) |
| 1386 | { |
| 1387 | u8 response[2]; |
| 1388 | u8 status; |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 1389 | struct intel_encoder *intel_encoder = to_intel_encoder(connector); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1390 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 1391 | intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_GET_ACTIVE_HOT_PLUG, NULL, 0); |
| 1392 | intel_sdvo_read_response(intel_encoder, &response, 2); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1393 | |
| 1394 | if (on) { |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 1395 | intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_GET_HOT_PLUG_SUPPORT, NULL, 0); |
| 1396 | status = intel_sdvo_read_response(intel_encoder, &response, 2); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1397 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 1398 | intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_SET_ACTIVE_HOT_PLUG, &response, 2); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1399 | } else { |
| 1400 | response[0] = 0; |
| 1401 | response[1] = 0; |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 1402 | intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_SET_ACTIVE_HOT_PLUG, &response, 2); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1403 | } |
| 1404 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 1405 | intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_GET_ACTIVE_HOT_PLUG, NULL, 0); |
| 1406 | intel_sdvo_read_response(intel_encoder, &response, 2); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1407 | } |
Zhenyu Wang | d2a82a6 | 2010-03-29 21:22:55 +0800 | [diff] [blame^] | 1408 | #endif |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1409 | |
ling.ma@intel.com | fb7a46f | 2009-07-23 17:11:34 +0800 | [diff] [blame] | 1410 | static bool |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 1411 | intel_sdvo_multifunc_encoder(struct intel_encoder *intel_encoder) |
ling.ma@intel.com | fb7a46f | 2009-07-23 17:11:34 +0800 | [diff] [blame] | 1412 | { |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 1413 | struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv; |
ling.ma@intel.com | fb7a46f | 2009-07-23 17:11:34 +0800 | [diff] [blame] | 1414 | int caps = 0; |
| 1415 | |
| 1416 | if (sdvo_priv->caps.output_flags & |
| 1417 | (SDVO_OUTPUT_TMDS0 | SDVO_OUTPUT_TMDS1)) |
| 1418 | caps++; |
| 1419 | if (sdvo_priv->caps.output_flags & |
| 1420 | (SDVO_OUTPUT_RGB0 | SDVO_OUTPUT_RGB1)) |
| 1421 | caps++; |
| 1422 | if (sdvo_priv->caps.output_flags & |
Roel Kluin | 19e1f88 | 2009-08-09 13:50:53 +0200 | [diff] [blame] | 1423 | (SDVO_OUTPUT_SVID0 | SDVO_OUTPUT_SVID1)) |
ling.ma@intel.com | fb7a46f | 2009-07-23 17:11:34 +0800 | [diff] [blame] | 1424 | caps++; |
| 1425 | if (sdvo_priv->caps.output_flags & |
| 1426 | (SDVO_OUTPUT_CVBS0 | SDVO_OUTPUT_CVBS1)) |
| 1427 | caps++; |
| 1428 | if (sdvo_priv->caps.output_flags & |
| 1429 | (SDVO_OUTPUT_YPRPB0 | SDVO_OUTPUT_YPRPB1)) |
| 1430 | caps++; |
| 1431 | |
| 1432 | if (sdvo_priv->caps.output_flags & |
| 1433 | (SDVO_OUTPUT_SCART0 | SDVO_OUTPUT_SCART1)) |
| 1434 | caps++; |
| 1435 | |
| 1436 | if (sdvo_priv->caps.output_flags & |
| 1437 | (SDVO_OUTPUT_LVDS0 | SDVO_OUTPUT_LVDS1)) |
| 1438 | caps++; |
| 1439 | |
| 1440 | return (caps > 1); |
| 1441 | } |
| 1442 | |
Keith Packard | 57cdaf9 | 2009-09-04 13:07:54 +0800 | [diff] [blame] | 1443 | static struct drm_connector * |
| 1444 | intel_find_analog_connector(struct drm_device *dev) |
| 1445 | { |
| 1446 | struct drm_connector *connector; |
Zhenyu Wang | d2a82a6 | 2010-03-29 21:22:55 +0800 | [diff] [blame^] | 1447 | struct drm_encoder *encoder; |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 1448 | struct intel_encoder *intel_encoder; |
Keith Packard | 57cdaf9 | 2009-09-04 13:07:54 +0800 | [diff] [blame] | 1449 | |
Zhenyu Wang | d2a82a6 | 2010-03-29 21:22:55 +0800 | [diff] [blame^] | 1450 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { |
| 1451 | intel_encoder = enc_to_intel_encoder(encoder); |
| 1452 | if (intel_encoder->type == INTEL_OUTPUT_ANALOG) { |
| 1453 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { |
| 1454 | if (connector && encoder == intel_attached_encoder(connector)) |
| 1455 | return connector; |
| 1456 | } |
| 1457 | } |
Keith Packard | 57cdaf9 | 2009-09-04 13:07:54 +0800 | [diff] [blame] | 1458 | } |
| 1459 | return NULL; |
| 1460 | } |
| 1461 | |
| 1462 | static int |
| 1463 | intel_analog_is_connected(struct drm_device *dev) |
| 1464 | { |
| 1465 | struct drm_connector *analog_connector; |
| 1466 | analog_connector = intel_find_analog_connector(dev); |
| 1467 | |
| 1468 | if (!analog_connector) |
| 1469 | return false; |
| 1470 | |
| 1471 | if (analog_connector->funcs->detect(analog_connector) == |
| 1472 | connector_status_disconnected) |
| 1473 | return false; |
| 1474 | |
| 1475 | return true; |
| 1476 | } |
| 1477 | |
ling.ma@intel.com | 2b8d33f7 | 2009-07-29 11:31:18 +0800 | [diff] [blame] | 1478 | enum drm_connector_status |
| 1479 | intel_sdvo_hdmi_sink_detect(struct drm_connector *connector, u16 response) |
Ma Ling | 9dff6af | 2009-04-02 13:13:26 +0800 | [diff] [blame] | 1480 | { |
Zhenyu Wang | d2a82a6 | 2010-03-29 21:22:55 +0800 | [diff] [blame^] | 1481 | struct drm_encoder *encoder = intel_attached_encoder(connector); |
| 1482 | struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder); |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 1483 | struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv; |
ling.ma@intel.com | 2b8d33f7 | 2009-07-29 11:31:18 +0800 | [diff] [blame] | 1484 | enum drm_connector_status status = connector_status_connected; |
Ma Ling | 9dff6af | 2009-04-02 13:13:26 +0800 | [diff] [blame] | 1485 | struct edid *edid = NULL; |
| 1486 | |
Zhenyu Wang | d2a82a6 | 2010-03-29 21:22:55 +0800 | [diff] [blame^] | 1487 | edid = drm_get_edid(connector, |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 1488 | intel_encoder->ddc_bus); |
Keith Packard | 57cdaf9 | 2009-09-04 13:07:54 +0800 | [diff] [blame] | 1489 | |
Zhao Yakui | 7c3f0a2 | 2010-01-08 10:58:20 +0800 | [diff] [blame] | 1490 | /* This is only applied to SDVO cards with multiple outputs */ |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 1491 | if (edid == NULL && intel_sdvo_multifunc_encoder(intel_encoder)) { |
Zhao Yakui | 7c3f0a2 | 2010-01-08 10:58:20 +0800 | [diff] [blame] | 1492 | uint8_t saved_ddc, temp_ddc; |
| 1493 | saved_ddc = sdvo_priv->ddc_bus; |
| 1494 | temp_ddc = sdvo_priv->ddc_bus >> 1; |
| 1495 | /* |
| 1496 | * Don't use the 1 as the argument of DDC bus switch to get |
| 1497 | * the EDID. It is used for SDVO SPD ROM. |
| 1498 | */ |
| 1499 | while(temp_ddc > 1) { |
| 1500 | sdvo_priv->ddc_bus = temp_ddc; |
Zhenyu Wang | d2a82a6 | 2010-03-29 21:22:55 +0800 | [diff] [blame^] | 1501 | edid = drm_get_edid(connector, |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 1502 | intel_encoder->ddc_bus); |
Zhao Yakui | 7c3f0a2 | 2010-01-08 10:58:20 +0800 | [diff] [blame] | 1503 | if (edid) { |
| 1504 | /* |
| 1505 | * When we can get the EDID, maybe it is the |
| 1506 | * correct DDC bus. Update it. |
| 1507 | */ |
| 1508 | sdvo_priv->ddc_bus = temp_ddc; |
| 1509 | break; |
| 1510 | } |
| 1511 | temp_ddc >>= 1; |
| 1512 | } |
| 1513 | if (edid == NULL) |
| 1514 | sdvo_priv->ddc_bus = saved_ddc; |
| 1515 | } |
Keith Packard | 57cdaf9 | 2009-09-04 13:07:54 +0800 | [diff] [blame] | 1516 | /* when there is no edid and no monitor is connected with VGA |
| 1517 | * port, try to use the CRT ddc to read the EDID for DVI-connector |
| 1518 | */ |
| 1519 | if (edid == NULL && |
| 1520 | sdvo_priv->analog_ddc_bus && |
Zhenyu Wang | d2a82a6 | 2010-03-29 21:22:55 +0800 | [diff] [blame^] | 1521 | !intel_analog_is_connected(connector->dev)) |
| 1522 | edid = drm_get_edid(connector, |
Keith Packard | 57cdaf9 | 2009-09-04 13:07:54 +0800 | [diff] [blame] | 1523 | sdvo_priv->analog_ddc_bus); |
Ma Ling | 9dff6af | 2009-04-02 13:13:26 +0800 | [diff] [blame] | 1524 | if (edid != NULL) { |
ling.ma@intel.com | 2b8d33f7 | 2009-07-29 11:31:18 +0800 | [diff] [blame] | 1525 | /* Don't report the output as connected if it's a DVI-I |
| 1526 | * connector with a non-digital EDID coming out. |
| 1527 | */ |
| 1528 | if (response & (SDVO_OUTPUT_TMDS0 | SDVO_OUTPUT_TMDS1)) { |
| 1529 | if (edid->input & DRM_EDID_INPUT_DIGITAL) |
| 1530 | sdvo_priv->is_hdmi = |
| 1531 | drm_detect_hdmi_monitor(edid); |
| 1532 | else |
| 1533 | status = connector_status_disconnected; |
| 1534 | } |
| 1535 | |
Ma Ling | 9dff6af | 2009-04-02 13:13:26 +0800 | [diff] [blame] | 1536 | kfree(edid); |
Zhenyu Wang | d2a82a6 | 2010-03-29 21:22:55 +0800 | [diff] [blame^] | 1537 | connector->display_info.raw_edid = NULL; |
ling.ma@intel.com | 2b8d33f7 | 2009-07-29 11:31:18 +0800 | [diff] [blame] | 1538 | |
| 1539 | } else if (response & (SDVO_OUTPUT_TMDS0 | SDVO_OUTPUT_TMDS1)) |
| 1540 | status = connector_status_disconnected; |
| 1541 | |
| 1542 | return status; |
Ma Ling | 9dff6af | 2009-04-02 13:13:26 +0800 | [diff] [blame] | 1543 | } |
| 1544 | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1545 | static enum drm_connector_status intel_sdvo_detect(struct drm_connector *connector) |
| 1546 | { |
ling.ma@intel.com | fb7a46f | 2009-07-23 17:11:34 +0800 | [diff] [blame] | 1547 | uint16_t response; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1548 | u8 status; |
Zhenyu Wang | d2a82a6 | 2010-03-29 21:22:55 +0800 | [diff] [blame^] | 1549 | struct drm_encoder *encoder = intel_attached_encoder(connector); |
| 1550 | struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder); |
| 1551 | struct intel_connector *intel_connector = to_intel_connector(connector); |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 1552 | struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1553 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 1554 | intel_sdvo_write_cmd(intel_encoder, |
Zhao Yakui | ce6feab | 2009-08-24 13:50:26 +0800 | [diff] [blame] | 1555 | SDVO_CMD_GET_ATTACHED_DISPLAYS, NULL, 0); |
Zhao Yakui | d09c23d | 2009-11-06 15:39:56 +0800 | [diff] [blame] | 1556 | if (sdvo_priv->is_tv) { |
| 1557 | /* add 30ms delay when the output type is SDVO-TV */ |
| 1558 | mdelay(30); |
| 1559 | } |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 1560 | status = intel_sdvo_read_response(intel_encoder, &response, 2); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1561 | |
Dave Airlie | 51c8b40 | 2009-08-20 13:38:04 +1000 | [diff] [blame] | 1562 | DRM_DEBUG_KMS("SDVO response %d %d\n", response & 0xff, response >> 8); |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1563 | |
| 1564 | if (status != SDVO_CMD_STATUS_SUCCESS) |
| 1565 | return connector_status_unknown; |
| 1566 | |
ling.ma@intel.com | fb7a46f | 2009-07-23 17:11:34 +0800 | [diff] [blame] | 1567 | if (response == 0) |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1568 | return connector_status_disconnected; |
ling.ma@intel.com | fb7a46f | 2009-07-23 17:11:34 +0800 | [diff] [blame] | 1569 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 1570 | if (intel_sdvo_multifunc_encoder(intel_encoder) && |
ling.ma@intel.com | fb7a46f | 2009-07-23 17:11:34 +0800 | [diff] [blame] | 1571 | sdvo_priv->attached_output != response) { |
| 1572 | if (sdvo_priv->controlled_output != response && |
Zhenyu Wang | d2a82a6 | 2010-03-29 21:22:55 +0800 | [diff] [blame^] | 1573 | intel_sdvo_output_setup(intel_encoder, intel_connector, |
| 1574 | response) != true) |
ling.ma@intel.com | fb7a46f | 2009-07-23 17:11:34 +0800 | [diff] [blame] | 1575 | return connector_status_unknown; |
| 1576 | sdvo_priv->attached_output = response; |
| 1577 | } |
ling.ma@intel.com | 2b8d33f7 | 2009-07-29 11:31:18 +0800 | [diff] [blame] | 1578 | return intel_sdvo_hdmi_sink_detect(connector, response); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1579 | } |
| 1580 | |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1581 | static void intel_sdvo_get_ddc_modes(struct drm_connector *connector) |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1582 | { |
Zhenyu Wang | d2a82a6 | 2010-03-29 21:22:55 +0800 | [diff] [blame^] | 1583 | struct drm_encoder *encoder = intel_attached_encoder(connector); |
| 1584 | struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder); |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 1585 | struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv; |
Keith Packard | 57cdaf9 | 2009-09-04 13:07:54 +0800 | [diff] [blame] | 1586 | int num_modes; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1587 | |
| 1588 | /* set the bus switch and get the modes */ |
Zhenyu Wang | 335af9a | 2010-03-30 14:39:31 +0800 | [diff] [blame] | 1589 | num_modes = intel_ddc_get_modes(connector, intel_encoder->ddc_bus); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1590 | |
Keith Packard | 57cdaf9 | 2009-09-04 13:07:54 +0800 | [diff] [blame] | 1591 | /* |
| 1592 | * Mac mini hack. On this device, the DVI-I connector shares one DDC |
| 1593 | * link between analog and digital outputs. So, if the regular SDVO |
| 1594 | * DDC fails, check to see if the analog output is disconnected, in |
| 1595 | * which case we'll look there for the digital DDC data. |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1596 | */ |
Keith Packard | 57cdaf9 | 2009-09-04 13:07:54 +0800 | [diff] [blame] | 1597 | if (num_modes == 0 && |
| 1598 | sdvo_priv->analog_ddc_bus && |
Zhenyu Wang | d2a82a6 | 2010-03-29 21:22:55 +0800 | [diff] [blame^] | 1599 | !intel_analog_is_connected(connector->dev)) { |
Keith Packard | 57cdaf9 | 2009-09-04 13:07:54 +0800 | [diff] [blame] | 1600 | /* Switch to the analog ddc bus and try that |
| 1601 | */ |
Zhenyu Wang | 335af9a | 2010-03-30 14:39:31 +0800 | [diff] [blame] | 1602 | (void) intel_ddc_get_modes(connector, sdvo_priv->analog_ddc_bus); |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1603 | } |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1604 | } |
| 1605 | |
| 1606 | /* |
| 1607 | * Set of SDVO TV modes. |
| 1608 | * Note! This is in reply order (see loop in get_tv_modes). |
| 1609 | * XXX: all 60Hz refresh? |
| 1610 | */ |
| 1611 | struct drm_display_mode sdvo_tv_modes[] = { |
Zhenyu Wang | 7026d4a | 2009-03-24 14:02:43 +0800 | [diff] [blame] | 1612 | { DRM_MODE("320x200", DRM_MODE_TYPE_DRIVER, 5815, 320, 321, 384, |
| 1613 | 416, 0, 200, 201, 232, 233, 0, |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1614 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Zhenyu Wang | 7026d4a | 2009-03-24 14:02:43 +0800 | [diff] [blame] | 1615 | { DRM_MODE("320x240", DRM_MODE_TYPE_DRIVER, 6814, 320, 321, 384, |
| 1616 | 416, 0, 240, 241, 272, 273, 0, |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1617 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Zhenyu Wang | 7026d4a | 2009-03-24 14:02:43 +0800 | [diff] [blame] | 1618 | { DRM_MODE("400x300", DRM_MODE_TYPE_DRIVER, 9910, 400, 401, 464, |
| 1619 | 496, 0, 300, 301, 332, 333, 0, |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1620 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Zhenyu Wang | 7026d4a | 2009-03-24 14:02:43 +0800 | [diff] [blame] | 1621 | { DRM_MODE("640x350", DRM_MODE_TYPE_DRIVER, 16913, 640, 641, 704, |
| 1622 | 736, 0, 350, 351, 382, 383, 0, |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1623 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Zhenyu Wang | 7026d4a | 2009-03-24 14:02:43 +0800 | [diff] [blame] | 1624 | { DRM_MODE("640x400", DRM_MODE_TYPE_DRIVER, 19121, 640, 641, 704, |
| 1625 | 736, 0, 400, 401, 432, 433, 0, |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1626 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Zhenyu Wang | 7026d4a | 2009-03-24 14:02:43 +0800 | [diff] [blame] | 1627 | { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 22654, 640, 641, 704, |
| 1628 | 736, 0, 480, 481, 512, 513, 0, |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1629 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Zhenyu Wang | 7026d4a | 2009-03-24 14:02:43 +0800 | [diff] [blame] | 1630 | { DRM_MODE("704x480", DRM_MODE_TYPE_DRIVER, 24624, 704, 705, 768, |
| 1631 | 800, 0, 480, 481, 512, 513, 0, |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1632 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Zhenyu Wang | 7026d4a | 2009-03-24 14:02:43 +0800 | [diff] [blame] | 1633 | { DRM_MODE("704x576", DRM_MODE_TYPE_DRIVER, 29232, 704, 705, 768, |
| 1634 | 800, 0, 576, 577, 608, 609, 0, |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1635 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Zhenyu Wang | 7026d4a | 2009-03-24 14:02:43 +0800 | [diff] [blame] | 1636 | { DRM_MODE("720x350", DRM_MODE_TYPE_DRIVER, 18751, 720, 721, 784, |
| 1637 | 816, 0, 350, 351, 382, 383, 0, |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1638 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Zhenyu Wang | 7026d4a | 2009-03-24 14:02:43 +0800 | [diff] [blame] | 1639 | { DRM_MODE("720x400", DRM_MODE_TYPE_DRIVER, 21199, 720, 721, 784, |
| 1640 | 816, 0, 400, 401, 432, 433, 0, |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1641 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Zhenyu Wang | 7026d4a | 2009-03-24 14:02:43 +0800 | [diff] [blame] | 1642 | { DRM_MODE("720x480", DRM_MODE_TYPE_DRIVER, 25116, 720, 721, 784, |
| 1643 | 816, 0, 480, 481, 512, 513, 0, |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1644 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Zhenyu Wang | 7026d4a | 2009-03-24 14:02:43 +0800 | [diff] [blame] | 1645 | { DRM_MODE("720x540", DRM_MODE_TYPE_DRIVER, 28054, 720, 721, 784, |
| 1646 | 816, 0, 540, 541, 572, 573, 0, |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1647 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Zhenyu Wang | 7026d4a | 2009-03-24 14:02:43 +0800 | [diff] [blame] | 1648 | { DRM_MODE("720x576", DRM_MODE_TYPE_DRIVER, 29816, 720, 721, 784, |
| 1649 | 816, 0, 576, 577, 608, 609, 0, |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1650 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Zhenyu Wang | 7026d4a | 2009-03-24 14:02:43 +0800 | [diff] [blame] | 1651 | { DRM_MODE("768x576", DRM_MODE_TYPE_DRIVER, 31570, 768, 769, 832, |
| 1652 | 864, 0, 576, 577, 608, 609, 0, |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1653 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Zhenyu Wang | 7026d4a | 2009-03-24 14:02:43 +0800 | [diff] [blame] | 1654 | { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 34030, 800, 801, 864, |
| 1655 | 896, 0, 600, 601, 632, 633, 0, |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1656 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Zhenyu Wang | 7026d4a | 2009-03-24 14:02:43 +0800 | [diff] [blame] | 1657 | { DRM_MODE("832x624", DRM_MODE_TYPE_DRIVER, 36581, 832, 833, 896, |
| 1658 | 928, 0, 624, 625, 656, 657, 0, |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1659 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Zhenyu Wang | 7026d4a | 2009-03-24 14:02:43 +0800 | [diff] [blame] | 1660 | { DRM_MODE("920x766", DRM_MODE_TYPE_DRIVER, 48707, 920, 921, 984, |
| 1661 | 1016, 0, 766, 767, 798, 799, 0, |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1662 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Zhenyu Wang | 7026d4a | 2009-03-24 14:02:43 +0800 | [diff] [blame] | 1663 | { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 53827, 1024, 1025, 1088, |
| 1664 | 1120, 0, 768, 769, 800, 801, 0, |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1665 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Zhenyu Wang | 7026d4a | 2009-03-24 14:02:43 +0800 | [diff] [blame] | 1666 | { DRM_MODE("1280x1024", DRM_MODE_TYPE_DRIVER, 87265, 1280, 1281, 1344, |
| 1667 | 1376, 0, 1024, 1025, 1056, 1057, 0, |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1668 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
| 1669 | }; |
| 1670 | |
| 1671 | static void intel_sdvo_get_tv_modes(struct drm_connector *connector) |
| 1672 | { |
Zhenyu Wang | d2a82a6 | 2010-03-29 21:22:55 +0800 | [diff] [blame^] | 1673 | struct drm_encoder *encoder = intel_attached_encoder(connector); |
| 1674 | struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder); |
| 1675 | struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv; |
Zhenyu Wang | 7026d4a | 2009-03-24 14:02:43 +0800 | [diff] [blame] | 1676 | struct intel_sdvo_sdtv_resolution_request tv_res; |
Zhao Yakui | ce6feab | 2009-08-24 13:50:26 +0800 | [diff] [blame] | 1677 | uint32_t reply = 0, format_map = 0; |
| 1678 | int i; |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1679 | uint8_t status; |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1680 | |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1681 | |
| 1682 | /* Read the list of supported input resolutions for the selected TV |
| 1683 | * format. |
| 1684 | */ |
Zhao Yakui | ce6feab | 2009-08-24 13:50:26 +0800 | [diff] [blame] | 1685 | for (i = 0; i < TV_FORMAT_NUM; i++) |
| 1686 | if (tv_format_names[i] == sdvo_priv->tv_format_name) |
| 1687 | break; |
| 1688 | |
| 1689 | format_map = (1 << i); |
| 1690 | memcpy(&tv_res, &format_map, |
| 1691 | sizeof(struct intel_sdvo_sdtv_resolution_request) > |
| 1692 | sizeof(format_map) ? sizeof(format_map) : |
| 1693 | sizeof(struct intel_sdvo_sdtv_resolution_request)); |
| 1694 | |
Zhenyu Wang | d2a82a6 | 2010-03-29 21:22:55 +0800 | [diff] [blame^] | 1695 | intel_sdvo_set_target_output(intel_encoder, sdvo_priv->controlled_output); |
Zhao Yakui | ce6feab | 2009-08-24 13:50:26 +0800 | [diff] [blame] | 1696 | |
Zhenyu Wang | d2a82a6 | 2010-03-29 21:22:55 +0800 | [diff] [blame^] | 1697 | intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_GET_SDTV_RESOLUTION_SUPPORT, |
Zhenyu Wang | 7026d4a | 2009-03-24 14:02:43 +0800 | [diff] [blame] | 1698 | &tv_res, sizeof(tv_res)); |
Zhenyu Wang | d2a82a6 | 2010-03-29 21:22:55 +0800 | [diff] [blame^] | 1699 | status = intel_sdvo_read_response(intel_encoder, &reply, 3); |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1700 | if (status != SDVO_CMD_STATUS_SUCCESS) |
| 1701 | return; |
| 1702 | |
| 1703 | for (i = 0; i < ARRAY_SIZE(sdvo_tv_modes); i++) |
Zhenyu Wang | 7026d4a | 2009-03-24 14:02:43 +0800 | [diff] [blame] | 1704 | if (reply & (1 << i)) { |
| 1705 | struct drm_display_mode *nmode; |
| 1706 | nmode = drm_mode_duplicate(connector->dev, |
| 1707 | &sdvo_tv_modes[i]); |
| 1708 | if (nmode) |
| 1709 | drm_mode_probed_add(connector, nmode); |
| 1710 | } |
Zhao Yakui | ce6feab | 2009-08-24 13:50:26 +0800 | [diff] [blame] | 1711 | |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1712 | } |
| 1713 | |
Ma Ling | 7086c87 | 2009-05-13 11:20:06 +0800 | [diff] [blame] | 1714 | static void intel_sdvo_get_lvds_modes(struct drm_connector *connector) |
| 1715 | { |
Zhenyu Wang | d2a82a6 | 2010-03-29 21:22:55 +0800 | [diff] [blame^] | 1716 | struct drm_encoder *encoder = intel_attached_encoder(connector); |
| 1717 | struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder); |
Ma Ling | 7086c87 | 2009-05-13 11:20:06 +0800 | [diff] [blame] | 1718 | struct drm_i915_private *dev_priv = connector->dev->dev_private; |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 1719 | struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv; |
ling.ma@intel.com | 12682a9 | 2009-06-30 11:35:35 +0800 | [diff] [blame] | 1720 | struct drm_display_mode *newmode; |
Ma Ling | 7086c87 | 2009-05-13 11:20:06 +0800 | [diff] [blame] | 1721 | |
| 1722 | /* |
| 1723 | * Attempt to get the mode list from DDC. |
| 1724 | * Assume that the preferred modes are |
| 1725 | * arranged in priority order. |
| 1726 | */ |
Zhenyu Wang | 335af9a | 2010-03-30 14:39:31 +0800 | [diff] [blame] | 1727 | intel_ddc_get_modes(connector, intel_encoder->ddc_bus); |
Ma Ling | 7086c87 | 2009-05-13 11:20:06 +0800 | [diff] [blame] | 1728 | if (list_empty(&connector->probed_modes) == false) |
ling.ma@intel.com | 12682a9 | 2009-06-30 11:35:35 +0800 | [diff] [blame] | 1729 | goto end; |
Ma Ling | 7086c87 | 2009-05-13 11:20:06 +0800 | [diff] [blame] | 1730 | |
| 1731 | /* Fetch modes from VBT */ |
| 1732 | if (dev_priv->sdvo_lvds_vbt_mode != NULL) { |
Ma Ling | 7086c87 | 2009-05-13 11:20:06 +0800 | [diff] [blame] | 1733 | newmode = drm_mode_duplicate(connector->dev, |
| 1734 | dev_priv->sdvo_lvds_vbt_mode); |
| 1735 | if (newmode != NULL) { |
| 1736 | /* Guarantee the mode is preferred */ |
| 1737 | newmode->type = (DRM_MODE_TYPE_PREFERRED | |
| 1738 | DRM_MODE_TYPE_DRIVER); |
| 1739 | drm_mode_probed_add(connector, newmode); |
| 1740 | } |
| 1741 | } |
ling.ma@intel.com | 12682a9 | 2009-06-30 11:35:35 +0800 | [diff] [blame] | 1742 | |
| 1743 | end: |
| 1744 | list_for_each_entry(newmode, &connector->probed_modes, head) { |
| 1745 | if (newmode->type & DRM_MODE_TYPE_PREFERRED) { |
| 1746 | sdvo_priv->sdvo_lvds_fixed_mode = |
| 1747 | drm_mode_duplicate(connector->dev, newmode); |
| 1748 | break; |
| 1749 | } |
| 1750 | } |
| 1751 | |
Ma Ling | 7086c87 | 2009-05-13 11:20:06 +0800 | [diff] [blame] | 1752 | } |
| 1753 | |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1754 | static int intel_sdvo_get_modes(struct drm_connector *connector) |
| 1755 | { |
Zhenyu Wang | d2a82a6 | 2010-03-29 21:22:55 +0800 | [diff] [blame^] | 1756 | struct drm_encoder *encoder = intel_attached_encoder(connector); |
| 1757 | struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder); |
| 1758 | struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv; |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1759 | |
| 1760 | if (sdvo_priv->is_tv) |
| 1761 | intel_sdvo_get_tv_modes(connector); |
Ma Ling | 7086c87 | 2009-05-13 11:20:06 +0800 | [diff] [blame] | 1762 | else if (sdvo_priv->is_lvds == true) |
| 1763 | intel_sdvo_get_lvds_modes(connector); |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 1764 | else |
| 1765 | intel_sdvo_get_ddc_modes(connector); |
| 1766 | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1767 | if (list_empty(&connector->probed_modes)) |
| 1768 | return 0; |
| 1769 | return 1; |
| 1770 | } |
| 1771 | |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 1772 | static |
| 1773 | void intel_sdvo_destroy_enhance_property(struct drm_connector *connector) |
| 1774 | { |
Zhenyu Wang | d2a82a6 | 2010-03-29 21:22:55 +0800 | [diff] [blame^] | 1775 | struct drm_encoder *encoder = intel_attached_encoder(connector); |
| 1776 | struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder); |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 1777 | struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv; |
Zhenyu Wang | d2a82a6 | 2010-03-29 21:22:55 +0800 | [diff] [blame^] | 1778 | struct drm_device *dev = encoder->dev; |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 1779 | |
| 1780 | if (sdvo_priv->is_tv) { |
| 1781 | if (sdvo_priv->left_property) |
| 1782 | drm_property_destroy(dev, sdvo_priv->left_property); |
| 1783 | if (sdvo_priv->right_property) |
| 1784 | drm_property_destroy(dev, sdvo_priv->right_property); |
| 1785 | if (sdvo_priv->top_property) |
| 1786 | drm_property_destroy(dev, sdvo_priv->top_property); |
| 1787 | if (sdvo_priv->bottom_property) |
| 1788 | drm_property_destroy(dev, sdvo_priv->bottom_property); |
| 1789 | if (sdvo_priv->hpos_property) |
| 1790 | drm_property_destroy(dev, sdvo_priv->hpos_property); |
| 1791 | if (sdvo_priv->vpos_property) |
| 1792 | drm_property_destroy(dev, sdvo_priv->vpos_property); |
| 1793 | } |
| 1794 | if (sdvo_priv->is_tv) { |
| 1795 | if (sdvo_priv->saturation_property) |
| 1796 | drm_property_destroy(dev, |
| 1797 | sdvo_priv->saturation_property); |
| 1798 | if (sdvo_priv->contrast_property) |
| 1799 | drm_property_destroy(dev, |
| 1800 | sdvo_priv->contrast_property); |
| 1801 | if (sdvo_priv->hue_property) |
| 1802 | drm_property_destroy(dev, sdvo_priv->hue_property); |
| 1803 | } |
Zhao Yakui | d0cbde9 | 2009-09-10 15:45:47 +0800 | [diff] [blame] | 1804 | if (sdvo_priv->is_tv || sdvo_priv->is_lvds) { |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 1805 | if (sdvo_priv->brightness_property) |
| 1806 | drm_property_destroy(dev, |
| 1807 | sdvo_priv->brightness_property); |
| 1808 | } |
| 1809 | return; |
| 1810 | } |
| 1811 | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1812 | static void intel_sdvo_destroy(struct drm_connector *connector) |
| 1813 | { |
Zhenyu Wang | d2a82a6 | 2010-03-29 21:22:55 +0800 | [diff] [blame^] | 1814 | intel_sdvo_destroy_enhance_property(connector); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1815 | drm_sysfs_connector_remove(connector); |
| 1816 | drm_connector_cleanup(connector); |
Zhenyu Wang | d2a82a6 | 2010-03-29 21:22:55 +0800 | [diff] [blame^] | 1817 | kfree(connector); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1818 | } |
| 1819 | |
Zhao Yakui | ce6feab | 2009-08-24 13:50:26 +0800 | [diff] [blame] | 1820 | static int |
| 1821 | intel_sdvo_set_property(struct drm_connector *connector, |
| 1822 | struct drm_property *property, |
| 1823 | uint64_t val) |
| 1824 | { |
Zhenyu Wang | d2a82a6 | 2010-03-29 21:22:55 +0800 | [diff] [blame^] | 1825 | struct drm_encoder *encoder = intel_attached_encoder(connector); |
| 1826 | struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder); |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 1827 | struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv; |
Zhao Yakui | ce6feab | 2009-08-24 13:50:26 +0800 | [diff] [blame] | 1828 | struct drm_crtc *crtc = encoder->crtc; |
| 1829 | int ret = 0; |
| 1830 | bool changed = false; |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 1831 | uint8_t cmd, status; |
| 1832 | uint16_t temp_value; |
Zhao Yakui | ce6feab | 2009-08-24 13:50:26 +0800 | [diff] [blame] | 1833 | |
| 1834 | ret = drm_connector_property_set_value(connector, property, val); |
| 1835 | if (ret < 0) |
| 1836 | goto out; |
| 1837 | |
| 1838 | if (property == sdvo_priv->tv_format_property) { |
| 1839 | if (val >= TV_FORMAT_NUM) { |
| 1840 | ret = -EINVAL; |
| 1841 | goto out; |
| 1842 | } |
| 1843 | if (sdvo_priv->tv_format_name == |
| 1844 | sdvo_priv->tv_format_supported[val]) |
| 1845 | goto out; |
| 1846 | |
| 1847 | sdvo_priv->tv_format_name = sdvo_priv->tv_format_supported[val]; |
| 1848 | changed = true; |
Zhao Yakui | ce6feab | 2009-08-24 13:50:26 +0800 | [diff] [blame] | 1849 | } |
| 1850 | |
Zhao Yakui | d0cbde9 | 2009-09-10 15:45:47 +0800 | [diff] [blame] | 1851 | if (sdvo_priv->is_tv || sdvo_priv->is_lvds) { |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 1852 | cmd = 0; |
| 1853 | temp_value = val; |
| 1854 | if (sdvo_priv->left_property == property) { |
| 1855 | drm_connector_property_set_value(connector, |
| 1856 | sdvo_priv->right_property, val); |
| 1857 | if (sdvo_priv->left_margin == temp_value) |
| 1858 | goto out; |
| 1859 | |
| 1860 | sdvo_priv->left_margin = temp_value; |
| 1861 | sdvo_priv->right_margin = temp_value; |
| 1862 | temp_value = sdvo_priv->max_hscan - |
| 1863 | sdvo_priv->left_margin; |
| 1864 | cmd = SDVO_CMD_SET_OVERSCAN_H; |
| 1865 | } else if (sdvo_priv->right_property == property) { |
| 1866 | drm_connector_property_set_value(connector, |
| 1867 | sdvo_priv->left_property, val); |
| 1868 | if (sdvo_priv->right_margin == temp_value) |
| 1869 | goto out; |
| 1870 | |
| 1871 | sdvo_priv->left_margin = temp_value; |
| 1872 | sdvo_priv->right_margin = temp_value; |
| 1873 | temp_value = sdvo_priv->max_hscan - |
| 1874 | sdvo_priv->left_margin; |
| 1875 | cmd = SDVO_CMD_SET_OVERSCAN_H; |
| 1876 | } else if (sdvo_priv->top_property == property) { |
| 1877 | drm_connector_property_set_value(connector, |
| 1878 | sdvo_priv->bottom_property, val); |
| 1879 | if (sdvo_priv->top_margin == temp_value) |
| 1880 | goto out; |
| 1881 | |
| 1882 | sdvo_priv->top_margin = temp_value; |
| 1883 | sdvo_priv->bottom_margin = temp_value; |
| 1884 | temp_value = sdvo_priv->max_vscan - |
| 1885 | sdvo_priv->top_margin; |
| 1886 | cmd = SDVO_CMD_SET_OVERSCAN_V; |
| 1887 | } else if (sdvo_priv->bottom_property == property) { |
| 1888 | drm_connector_property_set_value(connector, |
| 1889 | sdvo_priv->top_property, val); |
| 1890 | if (sdvo_priv->bottom_margin == temp_value) |
| 1891 | goto out; |
| 1892 | sdvo_priv->top_margin = temp_value; |
| 1893 | sdvo_priv->bottom_margin = temp_value; |
| 1894 | temp_value = sdvo_priv->max_vscan - |
| 1895 | sdvo_priv->top_margin; |
| 1896 | cmd = SDVO_CMD_SET_OVERSCAN_V; |
| 1897 | } else if (sdvo_priv->hpos_property == property) { |
| 1898 | if (sdvo_priv->cur_hpos == temp_value) |
| 1899 | goto out; |
| 1900 | |
| 1901 | cmd = SDVO_CMD_SET_POSITION_H; |
| 1902 | sdvo_priv->cur_hpos = temp_value; |
| 1903 | } else if (sdvo_priv->vpos_property == property) { |
| 1904 | if (sdvo_priv->cur_vpos == temp_value) |
| 1905 | goto out; |
| 1906 | |
| 1907 | cmd = SDVO_CMD_SET_POSITION_V; |
| 1908 | sdvo_priv->cur_vpos = temp_value; |
| 1909 | } else if (sdvo_priv->saturation_property == property) { |
| 1910 | if (sdvo_priv->cur_saturation == temp_value) |
| 1911 | goto out; |
| 1912 | |
| 1913 | cmd = SDVO_CMD_SET_SATURATION; |
| 1914 | sdvo_priv->cur_saturation = temp_value; |
| 1915 | } else if (sdvo_priv->contrast_property == property) { |
| 1916 | if (sdvo_priv->cur_contrast == temp_value) |
| 1917 | goto out; |
| 1918 | |
| 1919 | cmd = SDVO_CMD_SET_CONTRAST; |
| 1920 | sdvo_priv->cur_contrast = temp_value; |
| 1921 | } else if (sdvo_priv->hue_property == property) { |
| 1922 | if (sdvo_priv->cur_hue == temp_value) |
| 1923 | goto out; |
| 1924 | |
| 1925 | cmd = SDVO_CMD_SET_HUE; |
| 1926 | sdvo_priv->cur_hue = temp_value; |
| 1927 | } else if (sdvo_priv->brightness_property == property) { |
| 1928 | if (sdvo_priv->cur_brightness == temp_value) |
| 1929 | goto out; |
| 1930 | |
| 1931 | cmd = SDVO_CMD_SET_BRIGHTNESS; |
| 1932 | sdvo_priv->cur_brightness = temp_value; |
| 1933 | } |
| 1934 | if (cmd) { |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 1935 | intel_sdvo_write_cmd(intel_encoder, cmd, &temp_value, 2); |
| 1936 | status = intel_sdvo_read_response(intel_encoder, |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 1937 | NULL, 0); |
| 1938 | if (status != SDVO_CMD_STATUS_SUCCESS) { |
| 1939 | DRM_DEBUG_KMS("Incorrect SDVO command \n"); |
| 1940 | return -EINVAL; |
| 1941 | } |
| 1942 | changed = true; |
| 1943 | } |
| 1944 | } |
Zhao Yakui | ce6feab | 2009-08-24 13:50:26 +0800 | [diff] [blame] | 1945 | if (changed && crtc) |
| 1946 | drm_crtc_helper_set_mode(crtc, &crtc->mode, crtc->x, |
| 1947 | crtc->y, crtc->fb); |
| 1948 | out: |
| 1949 | return ret; |
| 1950 | } |
| 1951 | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1952 | static const struct drm_encoder_helper_funcs intel_sdvo_helper_funcs = { |
| 1953 | .dpms = intel_sdvo_dpms, |
| 1954 | .mode_fixup = intel_sdvo_mode_fixup, |
| 1955 | .prepare = intel_encoder_prepare, |
| 1956 | .mode_set = intel_sdvo_mode_set, |
| 1957 | .commit = intel_encoder_commit, |
| 1958 | }; |
| 1959 | |
| 1960 | static const struct drm_connector_funcs intel_sdvo_connector_funcs = { |
Keith Packard | c9fb15f | 2009-05-30 20:42:28 -0700 | [diff] [blame] | 1961 | .dpms = drm_helper_connector_dpms, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1962 | .detect = intel_sdvo_detect, |
| 1963 | .fill_modes = drm_helper_probe_single_connector_modes, |
Zhao Yakui | ce6feab | 2009-08-24 13:50:26 +0800 | [diff] [blame] | 1964 | .set_property = intel_sdvo_set_property, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1965 | .destroy = intel_sdvo_destroy, |
| 1966 | }; |
| 1967 | |
| 1968 | static const struct drm_connector_helper_funcs intel_sdvo_connector_helper_funcs = { |
| 1969 | .get_modes = intel_sdvo_get_modes, |
| 1970 | .mode_valid = intel_sdvo_mode_valid, |
Zhenyu Wang | d2a82a6 | 2010-03-29 21:22:55 +0800 | [diff] [blame^] | 1971 | .best_encoder = intel_attached_encoder, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1972 | }; |
| 1973 | |
Hannes Eder | b358d0a | 2008-12-18 21:18:47 +0100 | [diff] [blame] | 1974 | static void intel_sdvo_enc_destroy(struct drm_encoder *encoder) |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1975 | { |
Zhenyu Wang | d2a82a6 | 2010-03-29 21:22:55 +0800 | [diff] [blame^] | 1976 | struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder); |
| 1977 | struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv; |
| 1978 | |
| 1979 | if (intel_encoder->i2c_bus) |
| 1980 | intel_i2c_destroy(intel_encoder->i2c_bus); |
| 1981 | if (intel_encoder->ddc_bus) |
| 1982 | intel_i2c_destroy(intel_encoder->ddc_bus); |
| 1983 | if (sdvo_priv->analog_ddc_bus) |
| 1984 | intel_i2c_destroy(sdvo_priv->analog_ddc_bus); |
| 1985 | |
| 1986 | if (sdvo_priv->sdvo_lvds_fixed_mode != NULL) |
| 1987 | drm_mode_destroy(encoder->dev, |
| 1988 | sdvo_priv->sdvo_lvds_fixed_mode); |
| 1989 | |
| 1990 | if (sdvo_priv->tv_format_property) |
| 1991 | drm_property_destroy(encoder->dev, |
| 1992 | sdvo_priv->tv_format_property); |
| 1993 | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1994 | drm_encoder_cleanup(encoder); |
Zhenyu Wang | d2a82a6 | 2010-03-29 21:22:55 +0800 | [diff] [blame^] | 1995 | kfree(intel_encoder); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1996 | } |
| 1997 | |
| 1998 | static const struct drm_encoder_funcs intel_sdvo_enc_funcs = { |
| 1999 | .destroy = intel_sdvo_enc_destroy, |
| 2000 | }; |
| 2001 | |
| 2002 | |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 2003 | /** |
| 2004 | * Choose the appropriate DDC bus for control bus switch command for this |
| 2005 | * SDVO output based on the controlled output. |
| 2006 | * |
| 2007 | * DDC bus number assignment is in a priority order of RGB outputs, then TMDS |
| 2008 | * outputs, then LVDS outputs. |
| 2009 | */ |
| 2010 | static void |
| 2011 | intel_sdvo_select_ddc_bus(struct intel_sdvo_priv *dev_priv) |
| 2012 | { |
| 2013 | uint16_t mask = 0; |
| 2014 | unsigned int num_bits; |
| 2015 | |
| 2016 | /* Make a mask of outputs less than or equal to our own priority in the |
| 2017 | * list. |
| 2018 | */ |
| 2019 | switch (dev_priv->controlled_output) { |
| 2020 | case SDVO_OUTPUT_LVDS1: |
| 2021 | mask |= SDVO_OUTPUT_LVDS1; |
| 2022 | case SDVO_OUTPUT_LVDS0: |
| 2023 | mask |= SDVO_OUTPUT_LVDS0; |
| 2024 | case SDVO_OUTPUT_TMDS1: |
| 2025 | mask |= SDVO_OUTPUT_TMDS1; |
| 2026 | case SDVO_OUTPUT_TMDS0: |
| 2027 | mask |= SDVO_OUTPUT_TMDS0; |
| 2028 | case SDVO_OUTPUT_RGB1: |
| 2029 | mask |= SDVO_OUTPUT_RGB1; |
| 2030 | case SDVO_OUTPUT_RGB0: |
| 2031 | mask |= SDVO_OUTPUT_RGB0; |
| 2032 | break; |
| 2033 | } |
| 2034 | |
| 2035 | /* Count bits to find what number we are in the priority list. */ |
| 2036 | mask &= dev_priv->caps.output_flags; |
| 2037 | num_bits = hweight16(mask); |
| 2038 | if (num_bits > 3) { |
| 2039 | /* if more than 3 outputs, default to DDC bus 3 for now */ |
| 2040 | num_bits = 3; |
| 2041 | } |
| 2042 | |
| 2043 | /* Corresponds to SDVO_CONTROL_BUS_DDCx */ |
| 2044 | dev_priv->ddc_bus = 1 << num_bits; |
| 2045 | } |
| 2046 | |
| 2047 | static bool |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2048 | intel_sdvo_get_digital_encoding_mode(struct intel_encoder *output) |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 2049 | { |
| 2050 | struct intel_sdvo_priv *sdvo_priv = output->dev_priv; |
| 2051 | uint8_t status; |
| 2052 | |
| 2053 | intel_sdvo_set_target_output(output, sdvo_priv->controlled_output); |
| 2054 | |
| 2055 | intel_sdvo_write_cmd(output, SDVO_CMD_GET_ENCODE, NULL, 0); |
| 2056 | status = intel_sdvo_read_response(output, &sdvo_priv->is_hdmi, 1); |
| 2057 | if (status != SDVO_CMD_STATUS_SUCCESS) |
| 2058 | return false; |
| 2059 | return true; |
| 2060 | } |
| 2061 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2062 | static struct intel_encoder * |
| 2063 | intel_sdvo_chan_to_intel_encoder(struct intel_i2c_chan *chan) |
Ma Ling | 619ac3b | 2009-05-18 16:12:46 +0800 | [diff] [blame] | 2064 | { |
| 2065 | struct drm_device *dev = chan->drm_dev; |
Zhenyu Wang | d2a82a6 | 2010-03-29 21:22:55 +0800 | [diff] [blame^] | 2066 | struct drm_encoder *encoder; |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2067 | struct intel_encoder *intel_encoder = NULL; |
Ma Ling | 619ac3b | 2009-05-18 16:12:46 +0800 | [diff] [blame] | 2068 | |
Zhenyu Wang | d2a82a6 | 2010-03-29 21:22:55 +0800 | [diff] [blame^] | 2069 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { |
| 2070 | intel_encoder = enc_to_intel_encoder(encoder); |
| 2071 | if (intel_encoder->ddc_bus == &chan->adapter) |
Ma Ling | 619ac3b | 2009-05-18 16:12:46 +0800 | [diff] [blame] | 2072 | break; |
Ma Ling | 619ac3b | 2009-05-18 16:12:46 +0800 | [diff] [blame] | 2073 | } |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2074 | return intel_encoder; |
Ma Ling | 619ac3b | 2009-05-18 16:12:46 +0800 | [diff] [blame] | 2075 | } |
| 2076 | |
| 2077 | static int intel_sdvo_master_xfer(struct i2c_adapter *i2c_adap, |
| 2078 | struct i2c_msg msgs[], int num) |
| 2079 | { |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2080 | struct intel_encoder *intel_encoder; |
Ma Ling | 619ac3b | 2009-05-18 16:12:46 +0800 | [diff] [blame] | 2081 | struct intel_sdvo_priv *sdvo_priv; |
| 2082 | struct i2c_algo_bit_data *algo_data; |
Keith Packard | f9c10a9 | 2009-05-30 12:16:25 -0700 | [diff] [blame] | 2083 | const struct i2c_algorithm *algo; |
Ma Ling | 619ac3b | 2009-05-18 16:12:46 +0800 | [diff] [blame] | 2084 | |
| 2085 | algo_data = (struct i2c_algo_bit_data *)i2c_adap->algo_data; |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2086 | intel_encoder = |
| 2087 | intel_sdvo_chan_to_intel_encoder( |
Ma Ling | 619ac3b | 2009-05-18 16:12:46 +0800 | [diff] [blame] | 2088 | (struct intel_i2c_chan *)(algo_data->data)); |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2089 | if (intel_encoder == NULL) |
Ma Ling | 619ac3b | 2009-05-18 16:12:46 +0800 | [diff] [blame] | 2090 | return -EINVAL; |
| 2091 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2092 | sdvo_priv = intel_encoder->dev_priv; |
| 2093 | algo = intel_encoder->i2c_bus->algo; |
Ma Ling | 619ac3b | 2009-05-18 16:12:46 +0800 | [diff] [blame] | 2094 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2095 | intel_sdvo_set_control_bus_switch(intel_encoder, sdvo_priv->ddc_bus); |
Ma Ling | 619ac3b | 2009-05-18 16:12:46 +0800 | [diff] [blame] | 2096 | return algo->master_xfer(i2c_adap, msgs, num); |
| 2097 | } |
| 2098 | |
| 2099 | static struct i2c_algorithm intel_sdvo_i2c_bit_algo = { |
| 2100 | .master_xfer = intel_sdvo_master_xfer, |
| 2101 | }; |
| 2102 | |
yakui_zhao | 714605e | 2009-05-31 17:18:07 +0800 | [diff] [blame] | 2103 | static u8 |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 2104 | intel_sdvo_get_slave_addr(struct drm_device *dev, int sdvo_reg) |
yakui_zhao | 714605e | 2009-05-31 17:18:07 +0800 | [diff] [blame] | 2105 | { |
| 2106 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2107 | struct sdvo_device_mapping *my_mapping, *other_mapping; |
| 2108 | |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 2109 | if (sdvo_reg == SDVOB) { |
yakui_zhao | 714605e | 2009-05-31 17:18:07 +0800 | [diff] [blame] | 2110 | my_mapping = &dev_priv->sdvo_mappings[0]; |
| 2111 | other_mapping = &dev_priv->sdvo_mappings[1]; |
| 2112 | } else { |
| 2113 | my_mapping = &dev_priv->sdvo_mappings[1]; |
| 2114 | other_mapping = &dev_priv->sdvo_mappings[0]; |
| 2115 | } |
| 2116 | |
| 2117 | /* If the BIOS described our SDVO device, take advantage of it. */ |
| 2118 | if (my_mapping->slave_addr) |
| 2119 | return my_mapping->slave_addr; |
| 2120 | |
| 2121 | /* If the BIOS only described a different SDVO device, use the |
| 2122 | * address that it isn't using. |
| 2123 | */ |
| 2124 | if (other_mapping->slave_addr) { |
| 2125 | if (other_mapping->slave_addr == 0x70) |
| 2126 | return 0x72; |
| 2127 | else |
| 2128 | return 0x70; |
| 2129 | } |
| 2130 | |
| 2131 | /* No SDVO device info is found for another DVO port, |
| 2132 | * so use mapping assumption we had before BIOS parsing. |
| 2133 | */ |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 2134 | if (sdvo_reg == SDVOB) |
yakui_zhao | 714605e | 2009-05-31 17:18:07 +0800 | [diff] [blame] | 2135 | return 0x70; |
| 2136 | else |
| 2137 | return 0x72; |
| 2138 | } |
| 2139 | |
Zhao Yakui | 6070a4a | 2010-02-08 21:35:12 +0800 | [diff] [blame] | 2140 | static int intel_sdvo_bad_tv_callback(const struct dmi_system_id *id) |
| 2141 | { |
| 2142 | DRM_DEBUG_KMS("Ignoring bad SDVO TV connector for %s\n", id->ident); |
| 2143 | return 1; |
| 2144 | } |
| 2145 | |
| 2146 | static struct dmi_system_id intel_sdvo_bad_tv[] = { |
| 2147 | { |
| 2148 | .callback = intel_sdvo_bad_tv_callback, |
| 2149 | .ident = "IntelG45/ICH10R/DME1737", |
| 2150 | .matches = { |
| 2151 | DMI_MATCH(DMI_SYS_VENDOR, "IBM CORPORATION"), |
| 2152 | DMI_MATCH(DMI_PRODUCT_NAME, "4800784"), |
| 2153 | }, |
| 2154 | }, |
| 2155 | |
| 2156 | { } /* terminating entry */ |
| 2157 | }; |
| 2158 | |
ling.ma@intel.com | fb7a46f | 2009-07-23 17:11:34 +0800 | [diff] [blame] | 2159 | static bool |
Zhenyu Wang | d2a82a6 | 2010-03-29 21:22:55 +0800 | [diff] [blame^] | 2160 | intel_sdvo_output_setup(struct intel_encoder *intel_encoder, |
| 2161 | struct intel_connector *intel_connector, |
| 2162 | uint16_t flags) |
ling.ma@intel.com | fb7a46f | 2009-07-23 17:11:34 +0800 | [diff] [blame] | 2163 | { |
Zhenyu Wang | d2a82a6 | 2010-03-29 21:22:55 +0800 | [diff] [blame^] | 2164 | struct drm_connector *connector = &intel_connector->base; |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2165 | struct drm_encoder *encoder = &intel_encoder->enc; |
| 2166 | struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv; |
ling.ma@intel.com | fb7a46f | 2009-07-23 17:11:34 +0800 | [diff] [blame] | 2167 | bool ret = true, registered = false; |
| 2168 | |
| 2169 | sdvo_priv->is_tv = false; |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2170 | intel_encoder->needs_tv_clock = false; |
ling.ma@intel.com | fb7a46f | 2009-07-23 17:11:34 +0800 | [diff] [blame] | 2171 | sdvo_priv->is_lvds = false; |
| 2172 | |
| 2173 | if (device_is_registered(&connector->kdev)) { |
| 2174 | drm_sysfs_connector_remove(connector); |
| 2175 | registered = true; |
| 2176 | } |
| 2177 | |
| 2178 | if (flags & |
| 2179 | (SDVO_OUTPUT_TMDS0 | SDVO_OUTPUT_TMDS1)) { |
| 2180 | if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_TMDS0) |
| 2181 | sdvo_priv->controlled_output = SDVO_OUTPUT_TMDS0; |
| 2182 | else |
| 2183 | sdvo_priv->controlled_output = SDVO_OUTPUT_TMDS1; |
| 2184 | |
| 2185 | encoder->encoder_type = DRM_MODE_ENCODER_TMDS; |
| 2186 | connector->connector_type = DRM_MODE_CONNECTOR_DVID; |
| 2187 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2188 | if (intel_sdvo_get_supp_encode(intel_encoder, |
ling.ma@intel.com | fb7a46f | 2009-07-23 17:11:34 +0800 | [diff] [blame] | 2189 | &sdvo_priv->encode) && |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2190 | intel_sdvo_get_digital_encoding_mode(intel_encoder) && |
ling.ma@intel.com | fb7a46f | 2009-07-23 17:11:34 +0800 | [diff] [blame] | 2191 | sdvo_priv->is_hdmi) { |
| 2192 | /* enable hdmi encoding mode if supported */ |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2193 | intel_sdvo_set_encode(intel_encoder, SDVO_ENCODE_HDMI); |
| 2194 | intel_sdvo_set_colorimetry(intel_encoder, |
ling.ma@intel.com | fb7a46f | 2009-07-23 17:11:34 +0800 | [diff] [blame] | 2195 | SDVO_COLORIMETRY_RGB256); |
| 2196 | connector->connector_type = DRM_MODE_CONNECTOR_HDMIA; |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2197 | intel_encoder->clone_mask = |
Ma Ling | f8aed70 | 2009-08-24 13:50:24 +0800 | [diff] [blame] | 2198 | (1 << INTEL_SDVO_NON_TV_CLONE_BIT) | |
| 2199 | (1 << INTEL_ANALOG_CLONE_BIT); |
ling.ma@intel.com | fb7a46f | 2009-07-23 17:11:34 +0800 | [diff] [blame] | 2200 | } |
Zhao Yakui | 6070a4a | 2010-02-08 21:35:12 +0800 | [diff] [blame] | 2201 | } else if ((flags & SDVO_OUTPUT_SVID0) && |
| 2202 | !dmi_check_system(intel_sdvo_bad_tv)) { |
ling.ma@intel.com | fb7a46f | 2009-07-23 17:11:34 +0800 | [diff] [blame] | 2203 | |
| 2204 | sdvo_priv->controlled_output = SDVO_OUTPUT_SVID0; |
| 2205 | encoder->encoder_type = DRM_MODE_ENCODER_TVDAC; |
| 2206 | connector->connector_type = DRM_MODE_CONNECTOR_SVIDEO; |
| 2207 | sdvo_priv->is_tv = true; |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2208 | intel_encoder->needs_tv_clock = true; |
| 2209 | intel_encoder->clone_mask = 1 << INTEL_SDVO_TV_CLONE_BIT; |
ling.ma@intel.com | fb7a46f | 2009-07-23 17:11:34 +0800 | [diff] [blame] | 2210 | } else if (flags & SDVO_OUTPUT_RGB0) { |
| 2211 | |
| 2212 | sdvo_priv->controlled_output = SDVO_OUTPUT_RGB0; |
| 2213 | encoder->encoder_type = DRM_MODE_ENCODER_DAC; |
| 2214 | connector->connector_type = DRM_MODE_CONNECTOR_VGA; |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2215 | intel_encoder->clone_mask = (1 << INTEL_SDVO_NON_TV_CLONE_BIT) | |
Ma Ling | f8aed70 | 2009-08-24 13:50:24 +0800 | [diff] [blame] | 2216 | (1 << INTEL_ANALOG_CLONE_BIT); |
ling.ma@intel.com | fb7a46f | 2009-07-23 17:11:34 +0800 | [diff] [blame] | 2217 | } else if (flags & SDVO_OUTPUT_RGB1) { |
| 2218 | |
| 2219 | sdvo_priv->controlled_output = SDVO_OUTPUT_RGB1; |
| 2220 | encoder->encoder_type = DRM_MODE_ENCODER_DAC; |
| 2221 | connector->connector_type = DRM_MODE_CONNECTOR_VGA; |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2222 | intel_encoder->clone_mask = (1 << INTEL_SDVO_NON_TV_CLONE_BIT) | |
Zhao Yakui | e270846 | 2009-09-10 15:45:48 +0800 | [diff] [blame] | 2223 | (1 << INTEL_ANALOG_CLONE_BIT); |
Zhao Yakui | 2dd8738 | 2010-01-27 16:32:46 +0800 | [diff] [blame] | 2224 | } else if (flags & SDVO_OUTPUT_CVBS0) { |
| 2225 | |
| 2226 | sdvo_priv->controlled_output = SDVO_OUTPUT_CVBS0; |
| 2227 | encoder->encoder_type = DRM_MODE_ENCODER_TVDAC; |
| 2228 | connector->connector_type = DRM_MODE_CONNECTOR_SVIDEO; |
| 2229 | sdvo_priv->is_tv = true; |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2230 | intel_encoder->needs_tv_clock = true; |
| 2231 | intel_encoder->clone_mask = 1 << INTEL_SDVO_TV_CLONE_BIT; |
ling.ma@intel.com | fb7a46f | 2009-07-23 17:11:34 +0800 | [diff] [blame] | 2232 | } else if (flags & SDVO_OUTPUT_LVDS0) { |
| 2233 | |
| 2234 | sdvo_priv->controlled_output = SDVO_OUTPUT_LVDS0; |
| 2235 | encoder->encoder_type = DRM_MODE_ENCODER_LVDS; |
| 2236 | connector->connector_type = DRM_MODE_CONNECTOR_LVDS; |
| 2237 | sdvo_priv->is_lvds = true; |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2238 | intel_encoder->clone_mask = (1 << INTEL_ANALOG_CLONE_BIT) | |
Ma Ling | f8aed70 | 2009-08-24 13:50:24 +0800 | [diff] [blame] | 2239 | (1 << INTEL_SDVO_LVDS_CLONE_BIT); |
ling.ma@intel.com | fb7a46f | 2009-07-23 17:11:34 +0800 | [diff] [blame] | 2240 | } else if (flags & SDVO_OUTPUT_LVDS1) { |
| 2241 | |
| 2242 | sdvo_priv->controlled_output = SDVO_OUTPUT_LVDS1; |
| 2243 | encoder->encoder_type = DRM_MODE_ENCODER_LVDS; |
| 2244 | connector->connector_type = DRM_MODE_CONNECTOR_LVDS; |
| 2245 | sdvo_priv->is_lvds = true; |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2246 | intel_encoder->clone_mask = (1 << INTEL_ANALOG_CLONE_BIT) | |
Ma Ling | f8aed70 | 2009-08-24 13:50:24 +0800 | [diff] [blame] | 2247 | (1 << INTEL_SDVO_LVDS_CLONE_BIT); |
ling.ma@intel.com | fb7a46f | 2009-07-23 17:11:34 +0800 | [diff] [blame] | 2248 | } else { |
| 2249 | |
| 2250 | unsigned char bytes[2]; |
| 2251 | |
| 2252 | sdvo_priv->controlled_output = 0; |
| 2253 | memcpy(bytes, &sdvo_priv->caps.output_flags, 2); |
Dave Airlie | 51c8b40 | 2009-08-20 13:38:04 +1000 | [diff] [blame] | 2254 | DRM_DEBUG_KMS("%s: Unknown SDVO output type (0x%02x%02x)\n", |
| 2255 | SDVO_NAME(sdvo_priv), |
| 2256 | bytes[0], bytes[1]); |
ling.ma@intel.com | fb7a46f | 2009-07-23 17:11:34 +0800 | [diff] [blame] | 2257 | ret = false; |
| 2258 | } |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2259 | intel_encoder->crtc_mask = (1 << 0) | (1 << 1); |
ling.ma@intel.com | fb7a46f | 2009-07-23 17:11:34 +0800 | [diff] [blame] | 2260 | |
| 2261 | if (ret && registered) |
| 2262 | ret = drm_sysfs_connector_add(connector) == 0 ? true : false; |
| 2263 | |
| 2264 | |
| 2265 | return ret; |
| 2266 | |
| 2267 | } |
| 2268 | |
Zhao Yakui | ce6feab | 2009-08-24 13:50:26 +0800 | [diff] [blame] | 2269 | static void intel_sdvo_tv_create_property(struct drm_connector *connector) |
| 2270 | { |
Zhenyu Wang | d2a82a6 | 2010-03-29 21:22:55 +0800 | [diff] [blame^] | 2271 | struct drm_encoder *encoder = intel_attached_encoder(connector); |
| 2272 | struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder); |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2273 | struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv; |
Zhao Yakui | ce6feab | 2009-08-24 13:50:26 +0800 | [diff] [blame] | 2274 | struct intel_sdvo_tv_format format; |
| 2275 | uint32_t format_map, i; |
| 2276 | uint8_t status; |
| 2277 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2278 | intel_sdvo_set_target_output(intel_encoder, |
Zhao Yakui | ce6feab | 2009-08-24 13:50:26 +0800 | [diff] [blame] | 2279 | sdvo_priv->controlled_output); |
| 2280 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2281 | intel_sdvo_write_cmd(intel_encoder, |
Zhao Yakui | ce6feab | 2009-08-24 13:50:26 +0800 | [diff] [blame] | 2282 | SDVO_CMD_GET_SUPPORTED_TV_FORMATS, NULL, 0); |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2283 | status = intel_sdvo_read_response(intel_encoder, |
Zhao Yakui | ce6feab | 2009-08-24 13:50:26 +0800 | [diff] [blame] | 2284 | &format, sizeof(format)); |
| 2285 | if (status != SDVO_CMD_STATUS_SUCCESS) |
| 2286 | return; |
| 2287 | |
| 2288 | memcpy(&format_map, &format, sizeof(format) > sizeof(format_map) ? |
| 2289 | sizeof(format_map) : sizeof(format)); |
| 2290 | |
| 2291 | if (format_map == 0) |
| 2292 | return; |
| 2293 | |
| 2294 | sdvo_priv->format_supported_num = 0; |
| 2295 | for (i = 0 ; i < TV_FORMAT_NUM; i++) |
| 2296 | if (format_map & (1 << i)) { |
| 2297 | sdvo_priv->tv_format_supported |
| 2298 | [sdvo_priv->format_supported_num++] = |
| 2299 | tv_format_names[i]; |
| 2300 | } |
| 2301 | |
| 2302 | |
| 2303 | sdvo_priv->tv_format_property = |
| 2304 | drm_property_create( |
| 2305 | connector->dev, DRM_MODE_PROP_ENUM, |
| 2306 | "mode", sdvo_priv->format_supported_num); |
| 2307 | |
| 2308 | for (i = 0; i < sdvo_priv->format_supported_num; i++) |
| 2309 | drm_property_add_enum( |
| 2310 | sdvo_priv->tv_format_property, i, |
| 2311 | i, sdvo_priv->tv_format_supported[i]); |
| 2312 | |
| 2313 | sdvo_priv->tv_format_name = sdvo_priv->tv_format_supported[0]; |
| 2314 | drm_connector_attach_property( |
| 2315 | connector, sdvo_priv->tv_format_property, 0); |
| 2316 | |
| 2317 | } |
| 2318 | |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 2319 | static void intel_sdvo_create_enhance_property(struct drm_connector *connector) |
| 2320 | { |
Zhenyu Wang | d2a82a6 | 2010-03-29 21:22:55 +0800 | [diff] [blame^] | 2321 | struct drm_encoder *encoder = intel_attached_encoder(connector); |
| 2322 | struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder); |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2323 | struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv; |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 2324 | struct intel_sdvo_enhancements_reply sdvo_data; |
| 2325 | struct drm_device *dev = connector->dev; |
| 2326 | uint8_t status; |
| 2327 | uint16_t response, data_value[2]; |
| 2328 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2329 | intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_GET_SUPPORTED_ENHANCEMENTS, |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 2330 | NULL, 0); |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2331 | status = intel_sdvo_read_response(intel_encoder, &sdvo_data, |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 2332 | sizeof(sdvo_data)); |
| 2333 | if (status != SDVO_CMD_STATUS_SUCCESS) { |
| 2334 | DRM_DEBUG_KMS(" incorrect response is returned\n"); |
| 2335 | return; |
| 2336 | } |
| 2337 | response = *((uint16_t *)&sdvo_data); |
| 2338 | if (!response) { |
| 2339 | DRM_DEBUG_KMS("No enhancement is supported\n"); |
| 2340 | return; |
| 2341 | } |
| 2342 | if (sdvo_priv->is_tv) { |
| 2343 | /* when horizontal overscan is supported, Add the left/right |
| 2344 | * property |
| 2345 | */ |
| 2346 | if (sdvo_data.overscan_h) { |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2347 | intel_sdvo_write_cmd(intel_encoder, |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 2348 | SDVO_CMD_GET_MAX_OVERSCAN_H, NULL, 0); |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2349 | status = intel_sdvo_read_response(intel_encoder, |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 2350 | &data_value, 4); |
| 2351 | if (status != SDVO_CMD_STATUS_SUCCESS) { |
| 2352 | DRM_DEBUG_KMS("Incorrect SDVO max " |
| 2353 | "h_overscan\n"); |
| 2354 | return; |
| 2355 | } |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2356 | intel_sdvo_write_cmd(intel_encoder, |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 2357 | SDVO_CMD_GET_OVERSCAN_H, NULL, 0); |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2358 | status = intel_sdvo_read_response(intel_encoder, |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 2359 | &response, 2); |
| 2360 | if (status != SDVO_CMD_STATUS_SUCCESS) { |
| 2361 | DRM_DEBUG_KMS("Incorrect SDVO h_overscan\n"); |
| 2362 | return; |
| 2363 | } |
| 2364 | sdvo_priv->max_hscan = data_value[0]; |
| 2365 | sdvo_priv->left_margin = data_value[0] - response; |
| 2366 | sdvo_priv->right_margin = sdvo_priv->left_margin; |
| 2367 | sdvo_priv->left_property = |
| 2368 | drm_property_create(dev, DRM_MODE_PROP_RANGE, |
| 2369 | "left_margin", 2); |
| 2370 | sdvo_priv->left_property->values[0] = 0; |
| 2371 | sdvo_priv->left_property->values[1] = data_value[0]; |
| 2372 | drm_connector_attach_property(connector, |
| 2373 | sdvo_priv->left_property, |
| 2374 | sdvo_priv->left_margin); |
| 2375 | sdvo_priv->right_property = |
| 2376 | drm_property_create(dev, DRM_MODE_PROP_RANGE, |
| 2377 | "right_margin", 2); |
| 2378 | sdvo_priv->right_property->values[0] = 0; |
| 2379 | sdvo_priv->right_property->values[1] = data_value[0]; |
| 2380 | drm_connector_attach_property(connector, |
| 2381 | sdvo_priv->right_property, |
| 2382 | sdvo_priv->right_margin); |
| 2383 | DRM_DEBUG_KMS("h_overscan: max %d, " |
| 2384 | "default %d, current %d\n", |
| 2385 | data_value[0], data_value[1], response); |
| 2386 | } |
| 2387 | if (sdvo_data.overscan_v) { |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2388 | intel_sdvo_write_cmd(intel_encoder, |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 2389 | SDVO_CMD_GET_MAX_OVERSCAN_V, NULL, 0); |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2390 | status = intel_sdvo_read_response(intel_encoder, |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 2391 | &data_value, 4); |
| 2392 | if (status != SDVO_CMD_STATUS_SUCCESS) { |
| 2393 | DRM_DEBUG_KMS("Incorrect SDVO max " |
| 2394 | "v_overscan\n"); |
| 2395 | return; |
| 2396 | } |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2397 | intel_sdvo_write_cmd(intel_encoder, |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 2398 | SDVO_CMD_GET_OVERSCAN_V, NULL, 0); |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2399 | status = intel_sdvo_read_response(intel_encoder, |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 2400 | &response, 2); |
| 2401 | if (status != SDVO_CMD_STATUS_SUCCESS) { |
| 2402 | DRM_DEBUG_KMS("Incorrect SDVO v_overscan\n"); |
| 2403 | return; |
| 2404 | } |
| 2405 | sdvo_priv->max_vscan = data_value[0]; |
| 2406 | sdvo_priv->top_margin = data_value[0] - response; |
| 2407 | sdvo_priv->bottom_margin = sdvo_priv->top_margin; |
| 2408 | sdvo_priv->top_property = |
| 2409 | drm_property_create(dev, DRM_MODE_PROP_RANGE, |
| 2410 | "top_margin", 2); |
| 2411 | sdvo_priv->top_property->values[0] = 0; |
| 2412 | sdvo_priv->top_property->values[1] = data_value[0]; |
| 2413 | drm_connector_attach_property(connector, |
| 2414 | sdvo_priv->top_property, |
| 2415 | sdvo_priv->top_margin); |
| 2416 | sdvo_priv->bottom_property = |
| 2417 | drm_property_create(dev, DRM_MODE_PROP_RANGE, |
| 2418 | "bottom_margin", 2); |
| 2419 | sdvo_priv->bottom_property->values[0] = 0; |
| 2420 | sdvo_priv->bottom_property->values[1] = data_value[0]; |
| 2421 | drm_connector_attach_property(connector, |
| 2422 | sdvo_priv->bottom_property, |
| 2423 | sdvo_priv->bottom_margin); |
| 2424 | DRM_DEBUG_KMS("v_overscan: max %d, " |
| 2425 | "default %d, current %d\n", |
| 2426 | data_value[0], data_value[1], response); |
| 2427 | } |
| 2428 | if (sdvo_data.position_h) { |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2429 | intel_sdvo_write_cmd(intel_encoder, |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 2430 | SDVO_CMD_GET_MAX_POSITION_H, NULL, 0); |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2431 | status = intel_sdvo_read_response(intel_encoder, |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 2432 | &data_value, 4); |
| 2433 | if (status != SDVO_CMD_STATUS_SUCCESS) { |
| 2434 | DRM_DEBUG_KMS("Incorrect SDVO Max h_pos\n"); |
| 2435 | return; |
| 2436 | } |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2437 | intel_sdvo_write_cmd(intel_encoder, |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 2438 | SDVO_CMD_GET_POSITION_H, NULL, 0); |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2439 | status = intel_sdvo_read_response(intel_encoder, |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 2440 | &response, 2); |
| 2441 | if (status != SDVO_CMD_STATUS_SUCCESS) { |
| 2442 | DRM_DEBUG_KMS("Incorrect SDVO get h_postion\n"); |
| 2443 | return; |
| 2444 | } |
| 2445 | sdvo_priv->max_hpos = data_value[0]; |
| 2446 | sdvo_priv->cur_hpos = response; |
| 2447 | sdvo_priv->hpos_property = |
| 2448 | drm_property_create(dev, DRM_MODE_PROP_RANGE, |
| 2449 | "hpos", 2); |
| 2450 | sdvo_priv->hpos_property->values[0] = 0; |
| 2451 | sdvo_priv->hpos_property->values[1] = data_value[0]; |
| 2452 | drm_connector_attach_property(connector, |
| 2453 | sdvo_priv->hpos_property, |
| 2454 | sdvo_priv->cur_hpos); |
| 2455 | DRM_DEBUG_KMS("h_position: max %d, " |
| 2456 | "default %d, current %d\n", |
| 2457 | data_value[0], data_value[1], response); |
| 2458 | } |
| 2459 | if (sdvo_data.position_v) { |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2460 | intel_sdvo_write_cmd(intel_encoder, |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 2461 | SDVO_CMD_GET_MAX_POSITION_V, NULL, 0); |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2462 | status = intel_sdvo_read_response(intel_encoder, |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 2463 | &data_value, 4); |
| 2464 | if (status != SDVO_CMD_STATUS_SUCCESS) { |
| 2465 | DRM_DEBUG_KMS("Incorrect SDVO Max v_pos\n"); |
| 2466 | return; |
| 2467 | } |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2468 | intel_sdvo_write_cmd(intel_encoder, |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 2469 | SDVO_CMD_GET_POSITION_V, NULL, 0); |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2470 | status = intel_sdvo_read_response(intel_encoder, |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 2471 | &response, 2); |
| 2472 | if (status != SDVO_CMD_STATUS_SUCCESS) { |
| 2473 | DRM_DEBUG_KMS("Incorrect SDVO get v_postion\n"); |
| 2474 | return; |
| 2475 | } |
| 2476 | sdvo_priv->max_vpos = data_value[0]; |
| 2477 | sdvo_priv->cur_vpos = response; |
| 2478 | sdvo_priv->vpos_property = |
| 2479 | drm_property_create(dev, DRM_MODE_PROP_RANGE, |
| 2480 | "vpos", 2); |
| 2481 | sdvo_priv->vpos_property->values[0] = 0; |
| 2482 | sdvo_priv->vpos_property->values[1] = data_value[0]; |
| 2483 | drm_connector_attach_property(connector, |
| 2484 | sdvo_priv->vpos_property, |
| 2485 | sdvo_priv->cur_vpos); |
| 2486 | DRM_DEBUG_KMS("v_position: max %d, " |
| 2487 | "default %d, current %d\n", |
| 2488 | data_value[0], data_value[1], response); |
| 2489 | } |
| 2490 | } |
| 2491 | if (sdvo_priv->is_tv) { |
| 2492 | if (sdvo_data.saturation) { |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2493 | intel_sdvo_write_cmd(intel_encoder, |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 2494 | SDVO_CMD_GET_MAX_SATURATION, NULL, 0); |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2495 | status = intel_sdvo_read_response(intel_encoder, |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 2496 | &data_value, 4); |
| 2497 | if (status != SDVO_CMD_STATUS_SUCCESS) { |
| 2498 | DRM_DEBUG_KMS("Incorrect SDVO Max sat\n"); |
| 2499 | return; |
| 2500 | } |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2501 | intel_sdvo_write_cmd(intel_encoder, |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 2502 | SDVO_CMD_GET_SATURATION, NULL, 0); |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2503 | status = intel_sdvo_read_response(intel_encoder, |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 2504 | &response, 2); |
| 2505 | if (status != SDVO_CMD_STATUS_SUCCESS) { |
| 2506 | DRM_DEBUG_KMS("Incorrect SDVO get sat\n"); |
| 2507 | return; |
| 2508 | } |
| 2509 | sdvo_priv->max_saturation = data_value[0]; |
| 2510 | sdvo_priv->cur_saturation = response; |
| 2511 | sdvo_priv->saturation_property = |
| 2512 | drm_property_create(dev, DRM_MODE_PROP_RANGE, |
| 2513 | "saturation", 2); |
| 2514 | sdvo_priv->saturation_property->values[0] = 0; |
| 2515 | sdvo_priv->saturation_property->values[1] = |
| 2516 | data_value[0]; |
| 2517 | drm_connector_attach_property(connector, |
| 2518 | sdvo_priv->saturation_property, |
| 2519 | sdvo_priv->cur_saturation); |
| 2520 | DRM_DEBUG_KMS("saturation: max %d, " |
| 2521 | "default %d, current %d\n", |
| 2522 | data_value[0], data_value[1], response); |
| 2523 | } |
| 2524 | if (sdvo_data.contrast) { |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2525 | intel_sdvo_write_cmd(intel_encoder, |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 2526 | SDVO_CMD_GET_MAX_CONTRAST, NULL, 0); |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2527 | status = intel_sdvo_read_response(intel_encoder, |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 2528 | &data_value, 4); |
| 2529 | if (status != SDVO_CMD_STATUS_SUCCESS) { |
| 2530 | DRM_DEBUG_KMS("Incorrect SDVO Max contrast\n"); |
| 2531 | return; |
| 2532 | } |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2533 | intel_sdvo_write_cmd(intel_encoder, |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 2534 | SDVO_CMD_GET_CONTRAST, NULL, 0); |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2535 | status = intel_sdvo_read_response(intel_encoder, |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 2536 | &response, 2); |
| 2537 | if (status != SDVO_CMD_STATUS_SUCCESS) { |
| 2538 | DRM_DEBUG_KMS("Incorrect SDVO get contrast\n"); |
| 2539 | return; |
| 2540 | } |
| 2541 | sdvo_priv->max_contrast = data_value[0]; |
| 2542 | sdvo_priv->cur_contrast = response; |
| 2543 | sdvo_priv->contrast_property = |
| 2544 | drm_property_create(dev, DRM_MODE_PROP_RANGE, |
| 2545 | "contrast", 2); |
| 2546 | sdvo_priv->contrast_property->values[0] = 0; |
| 2547 | sdvo_priv->contrast_property->values[1] = data_value[0]; |
| 2548 | drm_connector_attach_property(connector, |
| 2549 | sdvo_priv->contrast_property, |
| 2550 | sdvo_priv->cur_contrast); |
| 2551 | DRM_DEBUG_KMS("contrast: max %d, " |
| 2552 | "default %d, current %d\n", |
| 2553 | data_value[0], data_value[1], response); |
| 2554 | } |
| 2555 | if (sdvo_data.hue) { |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2556 | intel_sdvo_write_cmd(intel_encoder, |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 2557 | SDVO_CMD_GET_MAX_HUE, NULL, 0); |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2558 | status = intel_sdvo_read_response(intel_encoder, |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 2559 | &data_value, 4); |
| 2560 | if (status != SDVO_CMD_STATUS_SUCCESS) { |
| 2561 | DRM_DEBUG_KMS("Incorrect SDVO Max hue\n"); |
| 2562 | return; |
| 2563 | } |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2564 | intel_sdvo_write_cmd(intel_encoder, |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 2565 | SDVO_CMD_GET_HUE, NULL, 0); |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2566 | status = intel_sdvo_read_response(intel_encoder, |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 2567 | &response, 2); |
| 2568 | if (status != SDVO_CMD_STATUS_SUCCESS) { |
| 2569 | DRM_DEBUG_KMS("Incorrect SDVO get hue\n"); |
| 2570 | return; |
| 2571 | } |
| 2572 | sdvo_priv->max_hue = data_value[0]; |
| 2573 | sdvo_priv->cur_hue = response; |
| 2574 | sdvo_priv->hue_property = |
| 2575 | drm_property_create(dev, DRM_MODE_PROP_RANGE, |
| 2576 | "hue", 2); |
| 2577 | sdvo_priv->hue_property->values[0] = 0; |
| 2578 | sdvo_priv->hue_property->values[1] = |
| 2579 | data_value[0]; |
| 2580 | drm_connector_attach_property(connector, |
| 2581 | sdvo_priv->hue_property, |
| 2582 | sdvo_priv->cur_hue); |
| 2583 | DRM_DEBUG_KMS("hue: max %d, default %d, current %d\n", |
| 2584 | data_value[0], data_value[1], response); |
| 2585 | } |
| 2586 | } |
Zhao Yakui | d0cbde9 | 2009-09-10 15:45:47 +0800 | [diff] [blame] | 2587 | if (sdvo_priv->is_tv || sdvo_priv->is_lvds) { |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 2588 | if (sdvo_data.brightness) { |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2589 | intel_sdvo_write_cmd(intel_encoder, |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 2590 | SDVO_CMD_GET_MAX_BRIGHTNESS, NULL, 0); |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2591 | status = intel_sdvo_read_response(intel_encoder, |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 2592 | &data_value, 4); |
| 2593 | if (status != SDVO_CMD_STATUS_SUCCESS) { |
| 2594 | DRM_DEBUG_KMS("Incorrect SDVO Max bright\n"); |
| 2595 | return; |
| 2596 | } |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2597 | intel_sdvo_write_cmd(intel_encoder, |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 2598 | SDVO_CMD_GET_BRIGHTNESS, NULL, 0); |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2599 | status = intel_sdvo_read_response(intel_encoder, |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 2600 | &response, 2); |
| 2601 | if (status != SDVO_CMD_STATUS_SUCCESS) { |
| 2602 | DRM_DEBUG_KMS("Incorrect SDVO get brigh\n"); |
| 2603 | return; |
| 2604 | } |
| 2605 | sdvo_priv->max_brightness = data_value[0]; |
| 2606 | sdvo_priv->cur_brightness = response; |
| 2607 | sdvo_priv->brightness_property = |
| 2608 | drm_property_create(dev, DRM_MODE_PROP_RANGE, |
| 2609 | "brightness", 2); |
| 2610 | sdvo_priv->brightness_property->values[0] = 0; |
| 2611 | sdvo_priv->brightness_property->values[1] = |
| 2612 | data_value[0]; |
| 2613 | drm_connector_attach_property(connector, |
| 2614 | sdvo_priv->brightness_property, |
| 2615 | sdvo_priv->cur_brightness); |
| 2616 | DRM_DEBUG_KMS("brightness: max %d, " |
| 2617 | "default %d, current %d\n", |
| 2618 | data_value[0], data_value[1], response); |
| 2619 | } |
| 2620 | } |
| 2621 | return; |
| 2622 | } |
| 2623 | |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 2624 | bool intel_sdvo_init(struct drm_device *dev, int sdvo_reg) |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 2625 | { |
Jesse Barnes | b01f2c3 | 2009-12-11 11:07:17 -0800 | [diff] [blame] | 2626 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 2627 | struct drm_connector *connector; |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2628 | struct intel_encoder *intel_encoder; |
Zhenyu Wang | d2a82a6 | 2010-03-29 21:22:55 +0800 | [diff] [blame^] | 2629 | struct intel_connector *intel_connector; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 2630 | struct intel_sdvo_priv *sdvo_priv; |
Keith Packard | f9c10a9 | 2009-05-30 12:16:25 -0700 | [diff] [blame] | 2631 | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 2632 | u8 ch[0x40]; |
| 2633 | int i; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 2634 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2635 | intel_encoder = kcalloc(sizeof(struct intel_encoder)+sizeof(struct intel_sdvo_priv), 1, GFP_KERNEL); |
| 2636 | if (!intel_encoder) { |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 2637 | return false; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 2638 | } |
| 2639 | |
Zhenyu Wang | d2a82a6 | 2010-03-29 21:22:55 +0800 | [diff] [blame^] | 2640 | intel_connector = kzalloc(sizeof(struct intel_connector), GFP_KERNEL); |
| 2641 | if (!intel_connector) { |
| 2642 | kfree(intel_encoder); |
| 2643 | return false; |
| 2644 | } |
| 2645 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2646 | sdvo_priv = (struct intel_sdvo_priv *)(intel_encoder + 1); |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 2647 | sdvo_priv->sdvo_reg = sdvo_reg; |
Keith Packard | 308cd3a | 2009-06-14 11:56:18 -0700 | [diff] [blame] | 2648 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2649 | intel_encoder->dev_priv = sdvo_priv; |
| 2650 | intel_encoder->type = INTEL_OUTPUT_SDVO; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 2651 | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 2652 | /* setup the DDC bus. */ |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 2653 | if (sdvo_reg == SDVOB) |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2654 | intel_encoder->i2c_bus = intel_i2c_create(dev, GPIOE, "SDVOCTRL_E for SDVOB"); |
Keith Packard | 308cd3a | 2009-06-14 11:56:18 -0700 | [diff] [blame] | 2655 | else |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2656 | intel_encoder->i2c_bus = intel_i2c_create(dev, GPIOE, "SDVOCTRL_E for SDVOC"); |
Keith Packard | 308cd3a | 2009-06-14 11:56:18 -0700 | [diff] [blame] | 2657 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2658 | if (!intel_encoder->i2c_bus) |
Jonas Bonn | ad5b2a6 | 2009-05-15 09:10:41 +0200 | [diff] [blame] | 2659 | goto err_inteloutput; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 2660 | |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 2661 | sdvo_priv->slave_addr = intel_sdvo_get_slave_addr(dev, sdvo_reg); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 2662 | |
Keith Packard | 308cd3a | 2009-06-14 11:56:18 -0700 | [diff] [blame] | 2663 | /* Save the bit-banging i2c functionality for use by the DDC wrapper */ |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2664 | intel_sdvo_i2c_bit_algo.functionality = intel_encoder->i2c_bus->algo->functionality; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 2665 | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 2666 | /* Read the regs to test if we can talk to the device */ |
| 2667 | for (i = 0; i < 0x40; i++) { |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2668 | if (!intel_sdvo_read_byte(intel_encoder, i, &ch[i])) { |
Zhao Yakui | 8a4c47f | 2009-07-20 13:48:04 +0800 | [diff] [blame] | 2669 | DRM_DEBUG_KMS("No SDVO device found on SDVO%c\n", |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 2670 | sdvo_reg == SDVOB ? 'B' : 'C'); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 2671 | goto err_i2c; |
| 2672 | } |
| 2673 | } |
| 2674 | |
Ma Ling | 619ac3b | 2009-05-18 16:12:46 +0800 | [diff] [blame] | 2675 | /* setup the DDC bus. */ |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 2676 | if (sdvo_reg == SDVOB) { |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2677 | intel_encoder->ddc_bus = intel_i2c_create(dev, GPIOE, "SDVOB DDC BUS"); |
Keith Packard | 57cdaf9 | 2009-09-04 13:07:54 +0800 | [diff] [blame] | 2678 | sdvo_priv->analog_ddc_bus = intel_i2c_create(dev, GPIOA, |
| 2679 | "SDVOB/VGA DDC BUS"); |
Jesse Barnes | b01f2c3 | 2009-12-11 11:07:17 -0800 | [diff] [blame] | 2680 | dev_priv->hotplug_supported_mask |= SDVOB_HOTPLUG_INT_STATUS; |
Keith Packard | 57cdaf9 | 2009-09-04 13:07:54 +0800 | [diff] [blame] | 2681 | } else { |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2682 | intel_encoder->ddc_bus = intel_i2c_create(dev, GPIOE, "SDVOC DDC BUS"); |
Keith Packard | 57cdaf9 | 2009-09-04 13:07:54 +0800 | [diff] [blame] | 2683 | sdvo_priv->analog_ddc_bus = intel_i2c_create(dev, GPIOA, |
| 2684 | "SDVOC/VGA DDC BUS"); |
Jesse Barnes | b01f2c3 | 2009-12-11 11:07:17 -0800 | [diff] [blame] | 2685 | dev_priv->hotplug_supported_mask |= SDVOC_HOTPLUG_INT_STATUS; |
Keith Packard | 57cdaf9 | 2009-09-04 13:07:54 +0800 | [diff] [blame] | 2686 | } |
Ma Ling | 619ac3b | 2009-05-18 16:12:46 +0800 | [diff] [blame] | 2687 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2688 | if (intel_encoder->ddc_bus == NULL) |
Ma Ling | 619ac3b | 2009-05-18 16:12:46 +0800 | [diff] [blame] | 2689 | goto err_i2c; |
| 2690 | |
Keith Packard | 308cd3a | 2009-06-14 11:56:18 -0700 | [diff] [blame] | 2691 | /* Wrap with our custom algo which switches to DDC mode */ |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2692 | intel_encoder->ddc_bus->algo = &intel_sdvo_i2c_bit_algo; |
Ma Ling | 619ac3b | 2009-05-18 16:12:46 +0800 | [diff] [blame] | 2693 | |
André Goddard Rosa | af901ca | 2009-11-14 13:09:05 -0200 | [diff] [blame] | 2694 | /* In default case sdvo lvds is false */ |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2695 | intel_sdvo_get_capabilities(intel_encoder, &sdvo_priv->caps); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 2696 | |
Zhenyu Wang | d2a82a6 | 2010-03-29 21:22:55 +0800 | [diff] [blame^] | 2697 | if (intel_sdvo_output_setup(intel_encoder, intel_connector, |
ling.ma@intel.com | fb7a46f | 2009-07-23 17:11:34 +0800 | [diff] [blame] | 2698 | sdvo_priv->caps.output_flags) != true) { |
Dave Airlie | 51c8b40 | 2009-08-20 13:38:04 +1000 | [diff] [blame] | 2699 | DRM_DEBUG_KMS("SDVO output failed to setup on SDVO%c\n", |
Eric Anholt | c751ce4 | 2010-03-25 11:48:48 -0700 | [diff] [blame] | 2700 | sdvo_reg == SDVOB ? 'B' : 'C'); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 2701 | goto err_i2c; |
| 2702 | } |
| 2703 | |
ling.ma@intel.com | fb7a46f | 2009-07-23 17:11:34 +0800 | [diff] [blame] | 2704 | |
Zhenyu Wang | d2a82a6 | 2010-03-29 21:22:55 +0800 | [diff] [blame^] | 2705 | connector = &intel_connector->base; |
Jonas Bonn | ad5b2a6 | 2009-05-15 09:10:41 +0200 | [diff] [blame] | 2706 | drm_connector_init(dev, connector, &intel_sdvo_connector_funcs, |
ling.ma@intel.com | fb7a46f | 2009-07-23 17:11:34 +0800 | [diff] [blame] | 2707 | connector->connector_type); |
| 2708 | |
Jonas Bonn | ad5b2a6 | 2009-05-15 09:10:41 +0200 | [diff] [blame] | 2709 | drm_connector_helper_add(connector, &intel_sdvo_connector_helper_funcs); |
| 2710 | connector->interlace_allowed = 0; |
| 2711 | connector->doublescan_allowed = 0; |
| 2712 | connector->display_info.subpixel_order = SubPixelHorizontalRGB; |
| 2713 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2714 | drm_encoder_init(dev, &intel_encoder->enc, |
| 2715 | &intel_sdvo_enc_funcs, intel_encoder->enc.encoder_type); |
ling.ma@intel.com | fb7a46f | 2009-07-23 17:11:34 +0800 | [diff] [blame] | 2716 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2717 | drm_encoder_helper_add(&intel_encoder->enc, &intel_sdvo_helper_funcs); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 2718 | |
Zhenyu Wang | d2a82a6 | 2010-03-29 21:22:55 +0800 | [diff] [blame^] | 2719 | drm_mode_connector_attach_encoder(&intel_connector->base, &intel_encoder->enc); |
Zhao Yakui | d0cbde9 | 2009-09-10 15:45:47 +0800 | [diff] [blame] | 2720 | if (sdvo_priv->is_tv) |
Zhao Yakui | ce6feab | 2009-08-24 13:50:26 +0800 | [diff] [blame] | 2721 | intel_sdvo_tv_create_property(connector); |
Zhao Yakui | d0cbde9 | 2009-09-10 15:45:47 +0800 | [diff] [blame] | 2722 | |
| 2723 | if (sdvo_priv->is_tv || sdvo_priv->is_lvds) |
Zhao Yakui | b9219c5 | 2009-09-10 15:45:46 +0800 | [diff] [blame] | 2724 | intel_sdvo_create_enhance_property(connector); |
Zhao Yakui | d0cbde9 | 2009-09-10 15:45:47 +0800 | [diff] [blame] | 2725 | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 2726 | drm_sysfs_connector_add(connector); |
| 2727 | |
Jesse Barnes | e2f0ba9 | 2009-02-02 15:11:52 -0800 | [diff] [blame] | 2728 | intel_sdvo_select_ddc_bus(sdvo_priv); |
| 2729 | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 2730 | /* Set the input timing to the screen. Assume always input 0. */ |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2731 | intel_sdvo_set_target_input(intel_encoder, true, false); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 2732 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2733 | intel_sdvo_get_input_pixel_clock_range(intel_encoder, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 2734 | &sdvo_priv->pixel_clock_min, |
| 2735 | &sdvo_priv->pixel_clock_max); |
| 2736 | |
| 2737 | |
Zhao Yakui | 8a4c47f | 2009-07-20 13:48:04 +0800 | [diff] [blame] | 2738 | DRM_DEBUG_KMS("%s device VID/DID: %02X:%02X.%02X, " |
yakui_zhao | 342dc38 | 2009-06-02 14:12:00 +0800 | [diff] [blame] | 2739 | "clock range %dMHz - %dMHz, " |
| 2740 | "input 1: %c, input 2: %c, " |
| 2741 | "output 1: %c, output 2: %c\n", |
| 2742 | SDVO_NAME(sdvo_priv), |
| 2743 | sdvo_priv->caps.vendor_id, sdvo_priv->caps.device_id, |
| 2744 | sdvo_priv->caps.device_rev_id, |
| 2745 | sdvo_priv->pixel_clock_min / 1000, |
| 2746 | sdvo_priv->pixel_clock_max / 1000, |
| 2747 | (sdvo_priv->caps.sdvo_inputs_mask & 0x1) ? 'Y' : 'N', |
| 2748 | (sdvo_priv->caps.sdvo_inputs_mask & 0x2) ? 'Y' : 'N', |
| 2749 | /* check currently supported outputs */ |
| 2750 | sdvo_priv->caps.output_flags & |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 2751 | (SDVO_OUTPUT_TMDS0 | SDVO_OUTPUT_RGB0) ? 'Y' : 'N', |
yakui_zhao | 342dc38 | 2009-06-02 14:12:00 +0800 | [diff] [blame] | 2752 | sdvo_priv->caps.output_flags & |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 2753 | (SDVO_OUTPUT_TMDS1 | SDVO_OUTPUT_RGB1) ? 'Y' : 'N'); |
| 2754 | |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 2755 | return true; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 2756 | |
| 2757 | err_i2c: |
Keith Packard | 57cdaf9 | 2009-09-04 13:07:54 +0800 | [diff] [blame] | 2758 | if (sdvo_priv->analog_ddc_bus != NULL) |
| 2759 | intel_i2c_destroy(sdvo_priv->analog_ddc_bus); |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2760 | if (intel_encoder->ddc_bus != NULL) |
| 2761 | intel_i2c_destroy(intel_encoder->ddc_bus); |
| 2762 | if (intel_encoder->i2c_bus != NULL) |
| 2763 | intel_i2c_destroy(intel_encoder->i2c_bus); |
Jonas Bonn | ad5b2a6 | 2009-05-15 09:10:41 +0200 | [diff] [blame] | 2764 | err_inteloutput: |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2765 | kfree(intel_encoder); |
Zhenyu Wang | d2a82a6 | 2010-03-29 21:22:55 +0800 | [diff] [blame^] | 2766 | kfree(intel_connector); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 2767 | |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 2768 | return false; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 2769 | } |