2 * Copyright 2006 Dave Airlie <airlied@linux.ie>
3 * Copyright © 2006-2007 Intel Corporation
4 * Jesse Barnes <jesse.barnes@intel.com>
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:
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
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.
26 * Eric Anholt <eric@anholt.net>
28 #include <linux/i2c.h>
29 #include <linux/slab.h>
30 #include <linux/delay.h>
34 #include "intel_drv.h"
38 #include "intel_sdvo_regs.h"
39 #include <linux/dmi.h>
41 static char *tv_format_names
[] = {
42 "NTSC_M" , "NTSC_J" , "NTSC_443",
43 "PAL_B" , "PAL_D" , "PAL_G" ,
44 "PAL_H" , "PAL_I" , "PAL_M" ,
45 "PAL_N" , "PAL_NC" , "PAL_60" ,
46 "SECAM_B" , "SECAM_D" , "SECAM_G" ,
47 "SECAM_K" , "SECAM_K1", "SECAM_L" ,
51 #define TV_FORMAT_NUM (sizeof(tv_format_names) / sizeof(*tv_format_names))
53 struct intel_sdvo_priv
{
56 /* Register for the SDVO device: SDVOB or SDVOC */
59 /* Active outputs controlled by this SDVO output */
60 uint16_t controlled_output
;
63 * Capabilities of the SDVO device returned by
64 * i830_sdvo_get_capabilities()
66 struct intel_sdvo_caps caps
;
68 /* Pixel clock limitations reported by the SDVO device, in kHz */
69 int pixel_clock_min
, pixel_clock_max
;
72 * For multiple function SDVO device,
73 * this is for current attached outputs.
75 uint16_t attached_output
;
78 * This is set if we're going to treat the device as TV-out.
80 * While we have these nice friendly flags for output types that ought
81 * to decide this for us, the S-Video output on our HDMI+S-Video card
82 * shows up as RGB1 (VGA).
86 /* This is for current tv format name */
89 /* This contains all current supported TV format */
90 char *tv_format_supported
[TV_FORMAT_NUM
];
91 int format_supported_num
;
92 struct drm_property
*tv_format_property
;
93 struct drm_property
*tv_format_name_property
[TV_FORMAT_NUM
];
96 * This is set if we treat the device as HDMI, instead of DVI.
101 * This is set if we detect output of sdvo device as LVDS.
106 * This is sdvo flags for input timing.
111 * This is sdvo fixed pannel mode pointer
113 struct drm_display_mode
*sdvo_lvds_fixed_mode
;
116 * Returned SDTV resolutions allowed for the current format, if the
117 * device reported it.
119 struct intel_sdvo_sdtv_resolution_reply sdtv_resolutions
;
122 * supported encoding mode, used to determine whether HDMI is
125 struct intel_sdvo_encode encode
;
127 /* DDC bus used by this SDVO encoder */
130 /* Mac mini hack -- use the same DDC as the analog connector */
131 struct i2c_adapter
*analog_ddc_bus
;
134 u16 save_active_outputs
;
135 struct intel_sdvo_dtd save_input_dtd_1
, save_input_dtd_2
;
136 struct intel_sdvo_dtd save_output_dtd
[16];
138 /* add the property for the SDVO-TV */
139 struct drm_property
*left_property
;
140 struct drm_property
*right_property
;
141 struct drm_property
*top_property
;
142 struct drm_property
*bottom_property
;
143 struct drm_property
*hpos_property
;
144 struct drm_property
*vpos_property
;
146 /* add the property for the SDVO-TV/LVDS */
147 struct drm_property
*brightness_property
;
148 struct drm_property
*contrast_property
;
149 struct drm_property
*saturation_property
;
150 struct drm_property
*hue_property
;
152 /* Add variable to record current setting for the above property */
153 u32 left_margin
, right_margin
, top_margin
, bottom_margin
;
154 /* this is to get the range of margin.*/
155 u32 max_hscan
, max_vscan
;
156 u32 max_hpos
, cur_hpos
;
157 u32 max_vpos
, cur_vpos
;
158 u32 cur_brightness
, max_brightness
;
159 u32 cur_contrast
, max_contrast
;
160 u32 cur_saturation
, max_saturation
;
161 u32 cur_hue
, max_hue
;
165 intel_sdvo_output_setup(struct intel_encoder
*intel_encoder
, uint16_t flags
);
168 * Writes the SDVOB or SDVOC with the given value, but always writes both
169 * SDVOB and SDVOC to work around apparent hardware issues (according to
170 * comments in the BIOS).
172 static void intel_sdvo_write_sdvox(struct intel_encoder
*intel_encoder
, u32 val
)
174 struct drm_device
*dev
= intel_encoder
->base
.dev
;
175 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
176 struct intel_sdvo_priv
*sdvo_priv
= intel_encoder
->dev_priv
;
177 u32 bval
= val
, cval
= val
;
180 if (sdvo_priv
->sdvo_reg
== SDVOB
) {
181 cval
= I915_READ(SDVOC
);
183 bval
= I915_READ(SDVOB
);
186 * Write the registers twice for luck. Sometimes,
187 * writing them only once doesn't appear to 'stick'.
188 * The BIOS does this too. Yay, magic
190 for (i
= 0; i
< 2; i
++)
192 I915_WRITE(SDVOB
, bval
);
194 I915_WRITE(SDVOC
, cval
);
199 static bool intel_sdvo_read_byte(struct intel_encoder
*intel_encoder
, u8 addr
,
202 struct intel_sdvo_priv
*sdvo_priv
= intel_encoder
->dev_priv
;
207 struct i2c_msg msgs
[] = {
209 .addr
= sdvo_priv
->slave_addr
>> 1,
215 .addr
= sdvo_priv
->slave_addr
>> 1,
225 if ((ret
= i2c_transfer(intel_encoder
->i2c_bus
, msgs
, 2)) == 2)
231 DRM_DEBUG_KMS("i2c transfer returned %d\n", ret
);
235 static bool intel_sdvo_write_byte(struct intel_encoder
*intel_encoder
, int addr
,
238 struct intel_sdvo_priv
*sdvo_priv
= intel_encoder
->dev_priv
;
240 struct i2c_msg msgs
[] = {
242 .addr
= sdvo_priv
->slave_addr
>> 1,
252 if (i2c_transfer(intel_encoder
->i2c_bus
, msgs
, 1) == 1)
259 #define SDVO_CMD_NAME_ENTRY(cmd) {cmd, #cmd}
260 /** Mapping of command numbers to names, for debug output */
261 static const struct _sdvo_cmd_name
{
264 } sdvo_cmd_names
[] = {
265 SDVO_CMD_NAME_ENTRY(SDVO_CMD_RESET
),
266 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_DEVICE_CAPS
),
267 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_FIRMWARE_REV
),
268 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_TRAINED_INPUTS
),
269 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_ACTIVE_OUTPUTS
),
270 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_ACTIVE_OUTPUTS
),
271 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_IN_OUT_MAP
),
272 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_IN_OUT_MAP
),
273 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_ATTACHED_DISPLAYS
),
274 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_HOT_PLUG_SUPPORT
),
275 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_ACTIVE_HOT_PLUG
),
276 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_ACTIVE_HOT_PLUG
),
277 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_INTERRUPT_EVENT_SOURCE
),
278 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_TARGET_INPUT
),
279 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_TARGET_OUTPUT
),
280 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_INPUT_TIMINGS_PART1
),
281 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_INPUT_TIMINGS_PART2
),
282 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_INPUT_TIMINGS_PART1
),
283 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_INPUT_TIMINGS_PART2
),
284 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_INPUT_TIMINGS_PART1
),
285 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_OUTPUT_TIMINGS_PART1
),
286 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_OUTPUT_TIMINGS_PART2
),
287 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_OUTPUT_TIMINGS_PART1
),
288 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_OUTPUT_TIMINGS_PART2
),
289 SDVO_CMD_NAME_ENTRY(SDVO_CMD_CREATE_PREFERRED_INPUT_TIMING
),
290 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_PREFERRED_INPUT_TIMING_PART1
),
291 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_PREFERRED_INPUT_TIMING_PART2
),
292 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_INPUT_PIXEL_CLOCK_RANGE
),
293 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_OUTPUT_PIXEL_CLOCK_RANGE
),
294 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_SUPPORTED_CLOCK_RATE_MULTS
),
295 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_CLOCK_RATE_MULT
),
296 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_CLOCK_RATE_MULT
),
297 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_SUPPORTED_TV_FORMATS
),
298 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_TV_FORMAT
),
299 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_TV_FORMAT
),
300 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_SUPPORTED_POWER_STATES
),
301 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_POWER_STATE
),
302 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_ENCODER_POWER_STATE
),
303 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_DISPLAY_POWER_STATE
),
304 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_CONTROL_BUS_SWITCH
),
305 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_SDTV_RESOLUTION_SUPPORT
),
306 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_SCALED_HDTV_RESOLUTION_SUPPORT
),
307 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_SUPPORTED_ENHANCEMENTS
),
308 /* Add the op code for SDVO enhancements */
309 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_MAX_POSITION_H
),
310 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_POSITION_H
),
311 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_POSITION_H
),
312 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_MAX_POSITION_V
),
313 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_POSITION_V
),
314 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_POSITION_V
),
315 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_MAX_SATURATION
),
316 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_SATURATION
),
317 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_SATURATION
),
318 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_MAX_HUE
),
319 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_HUE
),
320 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_HUE
),
321 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_MAX_CONTRAST
),
322 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_CONTRAST
),
323 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_CONTRAST
),
324 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_MAX_BRIGHTNESS
),
325 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_BRIGHTNESS
),
326 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_BRIGHTNESS
),
327 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_MAX_OVERSCAN_H
),
328 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_OVERSCAN_H
),
329 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_OVERSCAN_H
),
330 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_MAX_OVERSCAN_V
),
331 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_OVERSCAN_V
),
332 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_OVERSCAN_V
),
334 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_SUPP_ENCODE
),
335 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_ENCODE
),
336 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_ENCODE
),
337 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_PIXEL_REPLI
),
338 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_PIXEL_REPLI
),
339 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_COLORIMETRY_CAP
),
340 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_COLORIMETRY
),
341 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_COLORIMETRY
),
342 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_AUDIO_ENCRYPT_PREFER
),
343 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_AUDIO_STAT
),
344 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_AUDIO_STAT
),
345 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_HBUF_INDEX
),
346 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_HBUF_INDEX
),
347 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_HBUF_INFO
),
348 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_HBUF_AV_SPLIT
),
349 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_HBUF_AV_SPLIT
),
350 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_HBUF_TXRATE
),
351 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_HBUF_TXRATE
),
352 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_HBUF_DATA
),
353 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_HBUF_DATA
),
356 #define SDVO_NAME(dev_priv) ((dev_priv)->sdvo_reg == SDVOB ? "SDVOB" : "SDVOC")
357 #define SDVO_PRIV(encoder) ((struct intel_sdvo_priv *) (encoder)->dev_priv)
359 static void intel_sdvo_debug_write(struct intel_encoder
*intel_encoder
, u8 cmd
,
360 void *args
, int args_len
)
362 struct intel_sdvo_priv
*sdvo_priv
= intel_encoder
->dev_priv
;
365 DRM_DEBUG_KMS("%s: W: %02X ",
366 SDVO_NAME(sdvo_priv
), cmd
);
367 for (i
= 0; i
< args_len
; i
++)
368 DRM_LOG_KMS("%02X ", ((u8
*)args
)[i
]);
371 for (i
= 0; i
< sizeof(sdvo_cmd_names
) / sizeof(sdvo_cmd_names
[0]); i
++) {
372 if (cmd
== sdvo_cmd_names
[i
].cmd
) {
373 DRM_LOG_KMS("(%s)", sdvo_cmd_names
[i
].name
);
377 if (i
== sizeof(sdvo_cmd_names
)/ sizeof(sdvo_cmd_names
[0]))
378 DRM_LOG_KMS("(%02X)", cmd
);
382 static void intel_sdvo_write_cmd(struct intel_encoder
*intel_encoder
, u8 cmd
,
383 void *args
, int args_len
)
387 intel_sdvo_debug_write(intel_encoder
, cmd
, args
, args_len
);
389 for (i
= 0; i
< args_len
; i
++) {
390 intel_sdvo_write_byte(intel_encoder
, SDVO_I2C_ARG_0
- i
,
394 intel_sdvo_write_byte(intel_encoder
, SDVO_I2C_OPCODE
, cmd
);
397 static const char *cmd_status_names
[] = {
403 "Target not specified",
404 "Scaling not supported"
407 static void intel_sdvo_debug_response(struct intel_encoder
*intel_encoder
,
408 void *response
, int response_len
,
411 struct intel_sdvo_priv
*sdvo_priv
= intel_encoder
->dev_priv
;
414 DRM_DEBUG_KMS("%s: R: ", SDVO_NAME(sdvo_priv
));
415 for (i
= 0; i
< response_len
; i
++)
416 DRM_LOG_KMS("%02X ", ((u8
*)response
)[i
]);
419 if (status
<= SDVO_CMD_STATUS_SCALING_NOT_SUPP
)
420 DRM_LOG_KMS("(%s)", cmd_status_names
[status
]);
422 DRM_LOG_KMS("(??? %d)", status
);
426 static u8
intel_sdvo_read_response(struct intel_encoder
*intel_encoder
,
427 void *response
, int response_len
)
434 /* Read the command response */
435 for (i
= 0; i
< response_len
; i
++) {
436 intel_sdvo_read_byte(intel_encoder
,
437 SDVO_I2C_RETURN_0
+ i
,
438 &((u8
*)response
)[i
]);
441 /* read the return status */
442 intel_sdvo_read_byte(intel_encoder
, SDVO_I2C_CMD_STATUS
,
445 intel_sdvo_debug_response(intel_encoder
, response
, response_len
,
447 if (status
!= SDVO_CMD_STATUS_PENDING
)
456 static int intel_sdvo_get_pixel_multiplier(struct drm_display_mode
*mode
)
458 if (mode
->clock
>= 100000)
460 else if (mode
->clock
>= 50000)
467 * Try to read the response after issuie the DDC switch command. But it
468 * is noted that we must do the action of reading response and issuing DDC
469 * switch command in one I2C transaction. Otherwise when we try to start
470 * another I2C transaction after issuing the DDC bus switch, it will be
471 * switched to the internal SDVO register.
473 static void intel_sdvo_set_control_bus_switch(struct intel_encoder
*intel_encoder
,
476 struct intel_sdvo_priv
*sdvo_priv
= intel_encoder
->dev_priv
;
477 u8 out_buf
[2], cmd_buf
[2], ret_value
[2], ret
;
478 struct i2c_msg msgs
[] = {
480 .addr
= sdvo_priv
->slave_addr
>> 1,
485 /* the following two are to read the response */
487 .addr
= sdvo_priv
->slave_addr
>> 1,
493 .addr
= sdvo_priv
->slave_addr
>> 1,
500 intel_sdvo_debug_write(intel_encoder
, SDVO_CMD_SET_CONTROL_BUS_SWITCH
,
502 /* write the DDC switch command argument */
503 intel_sdvo_write_byte(intel_encoder
, SDVO_I2C_ARG_0
, target
);
505 out_buf
[0] = SDVO_I2C_OPCODE
;
506 out_buf
[1] = SDVO_CMD_SET_CONTROL_BUS_SWITCH
;
507 cmd_buf
[0] = SDVO_I2C_CMD_STATUS
;
512 ret
= i2c_transfer(intel_encoder
->i2c_bus
, msgs
, 3);
514 /* failure in I2C transfer */
515 DRM_DEBUG_KMS("I2c transfer returned %d\n", ret
);
518 if (ret_value
[0] != SDVO_CMD_STATUS_SUCCESS
) {
519 DRM_DEBUG_KMS("DDC switch command returns response %d\n",
526 static bool intel_sdvo_set_target_input(struct intel_encoder
*intel_encoder
, bool target_0
, bool target_1
)
528 struct intel_sdvo_set_target_input_args targets
= {0};
531 if (target_0
&& target_1
)
532 return SDVO_CMD_STATUS_NOTSUPP
;
535 targets
.target_1
= 1;
537 intel_sdvo_write_cmd(intel_encoder
, SDVO_CMD_SET_TARGET_INPUT
, &targets
,
540 status
= intel_sdvo_read_response(intel_encoder
, NULL
, 0);
542 return (status
== SDVO_CMD_STATUS_SUCCESS
);
546 * Return whether each input is trained.
548 * This function is making an assumption about the layout of the response,
549 * which should be checked against the docs.
551 static bool intel_sdvo_get_trained_inputs(struct intel_encoder
*intel_encoder
, bool *input_1
, bool *input_2
)
553 struct intel_sdvo_get_trained_inputs_response response
;
556 intel_sdvo_write_cmd(intel_encoder
, SDVO_CMD_GET_TRAINED_INPUTS
, NULL
, 0);
557 status
= intel_sdvo_read_response(intel_encoder
, &response
, sizeof(response
));
558 if (status
!= SDVO_CMD_STATUS_SUCCESS
)
561 *input_1
= response
.input0_trained
;
562 *input_2
= response
.input1_trained
;
566 static bool intel_sdvo_get_active_outputs(struct intel_encoder
*intel_encoder
,
571 intel_sdvo_write_cmd(intel_encoder
, SDVO_CMD_GET_ACTIVE_OUTPUTS
, NULL
, 0);
572 status
= intel_sdvo_read_response(intel_encoder
, outputs
, sizeof(*outputs
));
574 return (status
== SDVO_CMD_STATUS_SUCCESS
);
577 static bool intel_sdvo_set_active_outputs(struct intel_encoder
*intel_encoder
,
582 intel_sdvo_write_cmd(intel_encoder
, SDVO_CMD_SET_ACTIVE_OUTPUTS
, &outputs
,
584 status
= intel_sdvo_read_response(intel_encoder
, NULL
, 0);
585 return (status
== SDVO_CMD_STATUS_SUCCESS
);
588 static bool intel_sdvo_set_encoder_power_state(struct intel_encoder
*intel_encoder
,
591 u8 status
, state
= SDVO_ENCODER_STATE_ON
;
594 case DRM_MODE_DPMS_ON
:
595 state
= SDVO_ENCODER_STATE_ON
;
597 case DRM_MODE_DPMS_STANDBY
:
598 state
= SDVO_ENCODER_STATE_STANDBY
;
600 case DRM_MODE_DPMS_SUSPEND
:
601 state
= SDVO_ENCODER_STATE_SUSPEND
;
603 case DRM_MODE_DPMS_OFF
:
604 state
= SDVO_ENCODER_STATE_OFF
;
608 intel_sdvo_write_cmd(intel_encoder
, SDVO_CMD_SET_ENCODER_POWER_STATE
, &state
,
610 status
= intel_sdvo_read_response(intel_encoder
, NULL
, 0);
612 return (status
== SDVO_CMD_STATUS_SUCCESS
);
615 static bool intel_sdvo_get_input_pixel_clock_range(struct intel_encoder
*intel_encoder
,
619 struct intel_sdvo_pixel_clock_range clocks
;
622 intel_sdvo_write_cmd(intel_encoder
, SDVO_CMD_GET_INPUT_PIXEL_CLOCK_RANGE
,
625 status
= intel_sdvo_read_response(intel_encoder
, &clocks
, sizeof(clocks
));
627 if (status
!= SDVO_CMD_STATUS_SUCCESS
)
630 /* Convert the values from units of 10 kHz to kHz. */
631 *clock_min
= clocks
.min
* 10;
632 *clock_max
= clocks
.max
* 10;
637 static bool intel_sdvo_set_target_output(struct intel_encoder
*intel_encoder
,
642 intel_sdvo_write_cmd(intel_encoder
, SDVO_CMD_SET_TARGET_OUTPUT
, &outputs
,
645 status
= intel_sdvo_read_response(intel_encoder
, NULL
, 0);
646 return (status
== SDVO_CMD_STATUS_SUCCESS
);
649 static bool intel_sdvo_get_timing(struct intel_encoder
*intel_encoder
, u8 cmd
,
650 struct intel_sdvo_dtd
*dtd
)
654 intel_sdvo_write_cmd(intel_encoder
, cmd
, NULL
, 0);
655 status
= intel_sdvo_read_response(intel_encoder
, &dtd
->part1
,
657 if (status
!= SDVO_CMD_STATUS_SUCCESS
)
660 intel_sdvo_write_cmd(intel_encoder
, cmd
+ 1, NULL
, 0);
661 status
= intel_sdvo_read_response(intel_encoder
, &dtd
->part2
,
663 if (status
!= SDVO_CMD_STATUS_SUCCESS
)
669 static bool intel_sdvo_get_input_timing(struct intel_encoder
*intel_encoder
,
670 struct intel_sdvo_dtd
*dtd
)
672 return intel_sdvo_get_timing(intel_encoder
,
673 SDVO_CMD_GET_INPUT_TIMINGS_PART1
, dtd
);
676 static bool intel_sdvo_get_output_timing(struct intel_encoder
*intel_encoder
,
677 struct intel_sdvo_dtd
*dtd
)
679 return intel_sdvo_get_timing(intel_encoder
,
680 SDVO_CMD_GET_OUTPUT_TIMINGS_PART1
, dtd
);
683 static bool intel_sdvo_set_timing(struct intel_encoder
*intel_encoder
, u8 cmd
,
684 struct intel_sdvo_dtd
*dtd
)
688 intel_sdvo_write_cmd(intel_encoder
, cmd
, &dtd
->part1
, sizeof(dtd
->part1
));
689 status
= intel_sdvo_read_response(intel_encoder
, NULL
, 0);
690 if (status
!= SDVO_CMD_STATUS_SUCCESS
)
693 intel_sdvo_write_cmd(intel_encoder
, cmd
+ 1, &dtd
->part2
, sizeof(dtd
->part2
));
694 status
= intel_sdvo_read_response(intel_encoder
, NULL
, 0);
695 if (status
!= SDVO_CMD_STATUS_SUCCESS
)
701 static bool intel_sdvo_set_input_timing(struct intel_encoder
*intel_encoder
,
702 struct intel_sdvo_dtd
*dtd
)
704 return intel_sdvo_set_timing(intel_encoder
,
705 SDVO_CMD_SET_INPUT_TIMINGS_PART1
, dtd
);
708 static bool intel_sdvo_set_output_timing(struct intel_encoder
*intel_encoder
,
709 struct intel_sdvo_dtd
*dtd
)
711 return intel_sdvo_set_timing(intel_encoder
,
712 SDVO_CMD_SET_OUTPUT_TIMINGS_PART1
, dtd
);
716 intel_sdvo_create_preferred_input_timing(struct intel_encoder
*intel_encoder
,
721 struct intel_sdvo_preferred_input_timing_args args
;
722 struct intel_sdvo_priv
*sdvo_priv
= intel_encoder
->dev_priv
;
725 memset(&args
, 0, sizeof(args
));
728 args
.height
= height
;
731 if (sdvo_priv
->is_lvds
&&
732 (sdvo_priv
->sdvo_lvds_fixed_mode
->hdisplay
!= width
||
733 sdvo_priv
->sdvo_lvds_fixed_mode
->vdisplay
!= height
))
736 intel_sdvo_write_cmd(intel_encoder
,
737 SDVO_CMD_CREATE_PREFERRED_INPUT_TIMING
,
738 &args
, sizeof(args
));
739 status
= intel_sdvo_read_response(intel_encoder
, NULL
, 0);
740 if (status
!= SDVO_CMD_STATUS_SUCCESS
)
746 static bool intel_sdvo_get_preferred_input_timing(struct intel_encoder
*intel_encoder
,
747 struct intel_sdvo_dtd
*dtd
)
751 intel_sdvo_write_cmd(intel_encoder
, SDVO_CMD_GET_PREFERRED_INPUT_TIMING_PART1
,
754 status
= intel_sdvo_read_response(intel_encoder
, &dtd
->part1
,
756 if (status
!= SDVO_CMD_STATUS_SUCCESS
)
759 intel_sdvo_write_cmd(intel_encoder
, SDVO_CMD_GET_PREFERRED_INPUT_TIMING_PART2
,
762 status
= intel_sdvo_read_response(intel_encoder
, &dtd
->part2
,
764 if (status
!= SDVO_CMD_STATUS_SUCCESS
)
770 static int intel_sdvo_get_clock_rate_mult(struct intel_encoder
*intel_encoder
)
774 intel_sdvo_write_cmd(intel_encoder
, SDVO_CMD_GET_CLOCK_RATE_MULT
, NULL
, 0);
775 status
= intel_sdvo_read_response(intel_encoder
, &response
, 1);
777 if (status
!= SDVO_CMD_STATUS_SUCCESS
) {
778 DRM_DEBUG_KMS("Couldn't get SDVO clock rate multiplier\n");
779 return SDVO_CLOCK_RATE_MULT_1X
;
781 DRM_DEBUG_KMS("Current clock rate multiplier: %d\n", response
);
787 static bool intel_sdvo_set_clock_rate_mult(struct intel_encoder
*intel_encoder
, u8 val
)
791 intel_sdvo_write_cmd(intel_encoder
, SDVO_CMD_SET_CLOCK_RATE_MULT
, &val
, 1);
792 status
= intel_sdvo_read_response(intel_encoder
, NULL
, 0);
793 if (status
!= SDVO_CMD_STATUS_SUCCESS
)
799 static void intel_sdvo_get_dtd_from_mode(struct intel_sdvo_dtd
*dtd
,
800 struct drm_display_mode
*mode
)
802 uint16_t width
, height
;
803 uint16_t h_blank_len
, h_sync_len
, v_blank_len
, v_sync_len
;
804 uint16_t h_sync_offset
, v_sync_offset
;
806 width
= mode
->crtc_hdisplay
;
807 height
= mode
->crtc_vdisplay
;
809 /* do some mode translations */
810 h_blank_len
= mode
->crtc_hblank_end
- mode
->crtc_hblank_start
;
811 h_sync_len
= mode
->crtc_hsync_end
- mode
->crtc_hsync_start
;
813 v_blank_len
= mode
->crtc_vblank_end
- mode
->crtc_vblank_start
;
814 v_sync_len
= mode
->crtc_vsync_end
- mode
->crtc_vsync_start
;
816 h_sync_offset
= mode
->crtc_hsync_start
- mode
->crtc_hblank_start
;
817 v_sync_offset
= mode
->crtc_vsync_start
- mode
->crtc_vblank_start
;
819 dtd
->part1
.clock
= mode
->clock
/ 10;
820 dtd
->part1
.h_active
= width
& 0xff;
821 dtd
->part1
.h_blank
= h_blank_len
& 0xff;
822 dtd
->part1
.h_high
= (((width
>> 8) & 0xf) << 4) |
823 ((h_blank_len
>> 8) & 0xf);
824 dtd
->part1
.v_active
= height
& 0xff;
825 dtd
->part1
.v_blank
= v_blank_len
& 0xff;
826 dtd
->part1
.v_high
= (((height
>> 8) & 0xf) << 4) |
827 ((v_blank_len
>> 8) & 0xf);
829 dtd
->part2
.h_sync_off
= h_sync_offset
& 0xff;
830 dtd
->part2
.h_sync_width
= h_sync_len
& 0xff;
831 dtd
->part2
.v_sync_off_width
= (v_sync_offset
& 0xf) << 4 |
833 dtd
->part2
.sync_off_width_high
= ((h_sync_offset
& 0x300) >> 2) |
834 ((h_sync_len
& 0x300) >> 4) | ((v_sync_offset
& 0x30) >> 2) |
835 ((v_sync_len
& 0x30) >> 4);
837 dtd
->part2
.dtd_flags
= 0x18;
838 if (mode
->flags
& DRM_MODE_FLAG_PHSYNC
)
839 dtd
->part2
.dtd_flags
|= 0x2;
840 if (mode
->flags
& DRM_MODE_FLAG_PVSYNC
)
841 dtd
->part2
.dtd_flags
|= 0x4;
843 dtd
->part2
.sdvo_flags
= 0;
844 dtd
->part2
.v_sync_off_high
= v_sync_offset
& 0xc0;
845 dtd
->part2
.reserved
= 0;
848 static void intel_sdvo_get_mode_from_dtd(struct drm_display_mode
* mode
,
849 struct intel_sdvo_dtd
*dtd
)
851 mode
->hdisplay
= dtd
->part1
.h_active
;
852 mode
->hdisplay
+= ((dtd
->part1
.h_high
>> 4) & 0x0f) << 8;
853 mode
->hsync_start
= mode
->hdisplay
+ dtd
->part2
.h_sync_off
;
854 mode
->hsync_start
+= (dtd
->part2
.sync_off_width_high
& 0xc0) << 2;
855 mode
->hsync_end
= mode
->hsync_start
+ dtd
->part2
.h_sync_width
;
856 mode
->hsync_end
+= (dtd
->part2
.sync_off_width_high
& 0x30) << 4;
857 mode
->htotal
= mode
->hdisplay
+ dtd
->part1
.h_blank
;
858 mode
->htotal
+= (dtd
->part1
.h_high
& 0xf) << 8;
860 mode
->vdisplay
= dtd
->part1
.v_active
;
861 mode
->vdisplay
+= ((dtd
->part1
.v_high
>> 4) & 0x0f) << 8;
862 mode
->vsync_start
= mode
->vdisplay
;
863 mode
->vsync_start
+= (dtd
->part2
.v_sync_off_width
>> 4) & 0xf;
864 mode
->vsync_start
+= (dtd
->part2
.sync_off_width_high
& 0x0c) << 2;
865 mode
->vsync_start
+= dtd
->part2
.v_sync_off_high
& 0xc0;
866 mode
->vsync_end
= mode
->vsync_start
+
867 (dtd
->part2
.v_sync_off_width
& 0xf);
868 mode
->vsync_end
+= (dtd
->part2
.sync_off_width_high
& 0x3) << 4;
869 mode
->vtotal
= mode
->vdisplay
+ dtd
->part1
.v_blank
;
870 mode
->vtotal
+= (dtd
->part1
.v_high
& 0xf) << 8;
872 mode
->clock
= dtd
->part1
.clock
* 10;
874 mode
->flags
&= ~(DRM_MODE_FLAG_PHSYNC
| DRM_MODE_FLAG_PVSYNC
);
875 if (dtd
->part2
.dtd_flags
& 0x2)
876 mode
->flags
|= DRM_MODE_FLAG_PHSYNC
;
877 if (dtd
->part2
.dtd_flags
& 0x4)
878 mode
->flags
|= DRM_MODE_FLAG_PVSYNC
;
881 static bool intel_sdvo_get_supp_encode(struct intel_encoder
*intel_encoder
,
882 struct intel_sdvo_encode
*encode
)
886 intel_sdvo_write_cmd(intel_encoder
, SDVO_CMD_GET_SUPP_ENCODE
, NULL
, 0);
887 status
= intel_sdvo_read_response(intel_encoder
, encode
, sizeof(*encode
));
888 if (status
!= SDVO_CMD_STATUS_SUCCESS
) { /* non-support means DVI */
889 memset(encode
, 0, sizeof(*encode
));
896 static bool intel_sdvo_set_encode(struct intel_encoder
*intel_encoder
,
901 intel_sdvo_write_cmd(intel_encoder
, SDVO_CMD_SET_ENCODE
, &mode
, 1);
902 status
= intel_sdvo_read_response(intel_encoder
, NULL
, 0);
904 return (status
== SDVO_CMD_STATUS_SUCCESS
);
907 static bool intel_sdvo_set_colorimetry(struct intel_encoder
*intel_encoder
,
912 intel_sdvo_write_cmd(intel_encoder
, SDVO_CMD_SET_COLORIMETRY
, &mode
, 1);
913 status
= intel_sdvo_read_response(intel_encoder
, NULL
, 0);
915 return (status
== SDVO_CMD_STATUS_SUCCESS
);
919 static void intel_sdvo_dump_hdmi_buf(struct intel_encoder
*intel_encoder
)
922 uint8_t set_buf_index
[2];
928 intel_sdvo_write_cmd(encoder
, SDVO_CMD_GET_HBUF_AV_SPLIT
, NULL
, 0);
929 intel_sdvo_read_response(encoder
, &av_split
, 1);
931 for (i
= 0; i
<= av_split
; i
++) {
932 set_buf_index
[0] = i
; set_buf_index
[1] = 0;
933 intel_sdvo_write_cmd(encoder
, SDVO_CMD_SET_HBUF_INDEX
,
935 intel_sdvo_write_cmd(encoder
, SDVO_CMD_GET_HBUF_INFO
, NULL
, 0);
936 intel_sdvo_read_response(encoder
, &buf_size
, 1);
939 for (j
= 0; j
<= buf_size
; j
+= 8) {
940 intel_sdvo_write_cmd(encoder
, SDVO_CMD_GET_HBUF_DATA
,
942 intel_sdvo_read_response(encoder
, pos
, 8);
949 static void intel_sdvo_set_hdmi_buf(struct intel_encoder
*intel_encoder
,
951 uint8_t *data
, int8_t size
, uint8_t tx_rate
)
953 uint8_t set_buf_index
[2];
955 set_buf_index
[0] = index
;
956 set_buf_index
[1] = 0;
958 intel_sdvo_write_cmd(intel_encoder
, SDVO_CMD_SET_HBUF_INDEX
,
961 for (; size
> 0; size
-= 8) {
962 intel_sdvo_write_cmd(intel_encoder
, SDVO_CMD_SET_HBUF_DATA
, data
, 8);
966 intel_sdvo_write_cmd(intel_encoder
, SDVO_CMD_SET_HBUF_TXRATE
, &tx_rate
, 1);
969 static uint8_t intel_sdvo_calc_hbuf_csum(uint8_t *data
, uint8_t size
)
974 for (i
= 0; i
< size
; i
++)
980 #define DIP_TYPE_AVI 0x82
981 #define DIP_VERSION_AVI 0x2
982 #define DIP_LEN_AVI 13
984 struct dip_infoframe
{
1001 /* Packet Byte #3 */
1006 /* Packet Byte #4 */
1009 /* Packet Byte #5 */
1012 /* Packet Byte #6~13 */
1013 uint16_t top_bar_end
;
1014 uint16_t bottom_bar_start
;
1015 uint16_t left_bar_end
;
1016 uint16_t right_bar_start
;
1019 /* Packet Byte #1 */
1020 uint8_t channel_count
:3;
1022 uint8_t coding_type
:4;
1023 /* Packet Byte #2 */
1024 uint8_t sample_size
:2; /* SS0, SS1 */
1025 uint8_t sample_frequency
:3;
1027 /* Packet Byte #3 */
1028 uint8_t coding_type_private
:5;
1030 /* Packet Byte #4 */
1031 uint8_t channel_allocation
;
1032 /* Packet Byte #5 */
1034 uint8_t level_shift
:4;
1035 uint8_t downmix_inhibit
:1;
1037 uint8_t payload
[28];
1038 } __attribute__ ((packed
)) u
;
1039 } __attribute__((packed
));
1041 static void intel_sdvo_set_avi_infoframe(struct intel_encoder
*intel_encoder
,
1042 struct drm_display_mode
* mode
)
1044 struct dip_infoframe avi_if
= {
1045 .type
= DIP_TYPE_AVI
,
1046 .version
= DIP_VERSION_AVI
,
1050 avi_if
.checksum
= intel_sdvo_calc_hbuf_csum((uint8_t *)&avi_if
,
1052 intel_sdvo_set_hdmi_buf(intel_encoder
, 1, (uint8_t *)&avi_if
,
1054 SDVO_HBUF_TX_VSYNC
);
1057 static void intel_sdvo_set_tv_format(struct intel_encoder
*intel_encoder
)
1060 struct intel_sdvo_tv_format format
;
1061 struct intel_sdvo_priv
*sdvo_priv
= intel_encoder
->dev_priv
;
1062 uint32_t format_map
, i
;
1065 for (i
= 0; i
< TV_FORMAT_NUM
; i
++)
1066 if (tv_format_names
[i
] == sdvo_priv
->tv_format_name
)
1069 format_map
= 1 << i
;
1070 memset(&format
, 0, sizeof(format
));
1071 memcpy(&format
, &format_map
, sizeof(format_map
) > sizeof(format
) ?
1072 sizeof(format
) : sizeof(format_map
));
1074 intel_sdvo_write_cmd(intel_encoder
, SDVO_CMD_SET_TV_FORMAT
, &format_map
,
1077 status
= intel_sdvo_read_response(intel_encoder
, NULL
, 0);
1078 if (status
!= SDVO_CMD_STATUS_SUCCESS
)
1079 DRM_DEBUG_KMS("%s: Failed to set TV format\n",
1080 SDVO_NAME(sdvo_priv
));
1083 static bool intel_sdvo_mode_fixup(struct drm_encoder
*encoder
,
1084 struct drm_display_mode
*mode
,
1085 struct drm_display_mode
*adjusted_mode
)
1087 struct intel_encoder
*intel_encoder
= enc_to_intel_encoder(encoder
);
1088 struct intel_sdvo_priv
*dev_priv
= intel_encoder
->dev_priv
;
1090 if (dev_priv
->is_tv
) {
1091 struct intel_sdvo_dtd output_dtd
;
1094 /* We need to construct preferred input timings based on our
1095 * output timings. To do that, we have to set the output
1096 * timings, even though this isn't really the right place in
1097 * the sequence to do it. Oh well.
1101 /* Set output timings */
1102 intel_sdvo_get_dtd_from_mode(&output_dtd
, mode
);
1103 intel_sdvo_set_target_output(intel_encoder
,
1104 dev_priv
->controlled_output
);
1105 intel_sdvo_set_output_timing(intel_encoder
, &output_dtd
);
1107 /* Set the input timing to the screen. Assume always input 0. */
1108 intel_sdvo_set_target_input(intel_encoder
, true, false);
1111 success
= intel_sdvo_create_preferred_input_timing(intel_encoder
,
1116 struct intel_sdvo_dtd input_dtd
;
1118 intel_sdvo_get_preferred_input_timing(intel_encoder
,
1120 intel_sdvo_get_mode_from_dtd(adjusted_mode
, &input_dtd
);
1121 dev_priv
->sdvo_flags
= input_dtd
.part2
.sdvo_flags
;
1123 drm_mode_set_crtcinfo(adjusted_mode
, 0);
1125 mode
->clock
= adjusted_mode
->clock
;
1127 adjusted_mode
->clock
*=
1128 intel_sdvo_get_pixel_multiplier(mode
);
1132 } else if (dev_priv
->is_lvds
) {
1133 struct intel_sdvo_dtd output_dtd
;
1136 drm_mode_set_crtcinfo(dev_priv
->sdvo_lvds_fixed_mode
, 0);
1137 /* Set output timings */
1138 intel_sdvo_get_dtd_from_mode(&output_dtd
,
1139 dev_priv
->sdvo_lvds_fixed_mode
);
1141 intel_sdvo_set_target_output(intel_encoder
,
1142 dev_priv
->controlled_output
);
1143 intel_sdvo_set_output_timing(intel_encoder
, &output_dtd
);
1145 /* Set the input timing to the screen. Assume always input 0. */
1146 intel_sdvo_set_target_input(intel_encoder
, true, false);
1149 success
= intel_sdvo_create_preferred_input_timing(
1156 struct intel_sdvo_dtd input_dtd
;
1158 intel_sdvo_get_preferred_input_timing(intel_encoder
,
1160 intel_sdvo_get_mode_from_dtd(adjusted_mode
, &input_dtd
);
1161 dev_priv
->sdvo_flags
= input_dtd
.part2
.sdvo_flags
;
1163 drm_mode_set_crtcinfo(adjusted_mode
, 0);
1165 mode
->clock
= adjusted_mode
->clock
;
1167 adjusted_mode
->clock
*=
1168 intel_sdvo_get_pixel_multiplier(mode
);
1174 /* Make the CRTC code factor in the SDVO pixel multiplier. The
1175 * SDVO device will be told of the multiplier during mode_set.
1177 adjusted_mode
->clock
*= intel_sdvo_get_pixel_multiplier(mode
);
1182 static void intel_sdvo_mode_set(struct drm_encoder
*encoder
,
1183 struct drm_display_mode
*mode
,
1184 struct drm_display_mode
*adjusted_mode
)
1186 struct drm_device
*dev
= encoder
->dev
;
1187 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1188 struct drm_crtc
*crtc
= encoder
->crtc
;
1189 struct intel_crtc
*intel_crtc
= to_intel_crtc(crtc
);
1190 struct intel_encoder
*intel_encoder
= enc_to_intel_encoder(encoder
);
1191 struct intel_sdvo_priv
*sdvo_priv
= intel_encoder
->dev_priv
;
1193 int sdvo_pixel_multiply
;
1194 struct intel_sdvo_in_out_map in_out
;
1195 struct intel_sdvo_dtd input_dtd
;
1201 /* First, set the input mapping for the first input to our controlled
1202 * output. This is only correct if we're a single-input device, in
1203 * which case the first input is the output from the appropriate SDVO
1204 * channel on the motherboard. In a two-input device, the first input
1205 * will be SDVOB and the second SDVOC.
1207 in_out
.in0
= sdvo_priv
->controlled_output
;
1210 intel_sdvo_write_cmd(intel_encoder
, SDVO_CMD_SET_IN_OUT_MAP
,
1211 &in_out
, sizeof(in_out
));
1212 status
= intel_sdvo_read_response(intel_encoder
, NULL
, 0);
1214 if (sdvo_priv
->is_hdmi
) {
1215 intel_sdvo_set_avi_infoframe(intel_encoder
, mode
);
1216 sdvox
|= SDVO_AUDIO_ENABLE
;
1219 /* We have tried to get input timing in mode_fixup, and filled into
1221 if (sdvo_priv
->is_tv
|| sdvo_priv
->is_lvds
) {
1222 intel_sdvo_get_dtd_from_mode(&input_dtd
, adjusted_mode
);
1223 input_dtd
.part2
.sdvo_flags
= sdvo_priv
->sdvo_flags
;
1225 intel_sdvo_get_dtd_from_mode(&input_dtd
, mode
);
1227 /* If it's a TV, we already set the output timing in mode_fixup.
1228 * Otherwise, the output timing is equal to the input timing.
1230 if (!sdvo_priv
->is_tv
&& !sdvo_priv
->is_lvds
) {
1231 /* Set the output timing to the screen */
1232 intel_sdvo_set_target_output(intel_encoder
,
1233 sdvo_priv
->controlled_output
);
1234 intel_sdvo_set_output_timing(intel_encoder
, &input_dtd
);
1237 /* Set the input timing to the screen. Assume always input 0. */
1238 intel_sdvo_set_target_input(intel_encoder
, true, false);
1240 if (sdvo_priv
->is_tv
)
1241 intel_sdvo_set_tv_format(intel_encoder
);
1243 /* We would like to use intel_sdvo_create_preferred_input_timing() to
1244 * provide the device with a timing it can support, if it supports that
1245 * feature. However, presumably we would need to adjust the CRTC to
1246 * output the preferred timing, and we don't support that currently.
1249 success
= intel_sdvo_create_preferred_input_timing(encoder
, clock
,
1252 struct intel_sdvo_dtd
*input_dtd
;
1254 intel_sdvo_get_preferred_input_timing(encoder
, &input_dtd
);
1255 intel_sdvo_set_input_timing(encoder
, &input_dtd
);
1258 intel_sdvo_set_input_timing(intel_encoder
, &input_dtd
);
1261 switch (intel_sdvo_get_pixel_multiplier(mode
)) {
1263 intel_sdvo_set_clock_rate_mult(intel_encoder
,
1264 SDVO_CLOCK_RATE_MULT_1X
);
1267 intel_sdvo_set_clock_rate_mult(intel_encoder
,
1268 SDVO_CLOCK_RATE_MULT_2X
);
1271 intel_sdvo_set_clock_rate_mult(intel_encoder
,
1272 SDVO_CLOCK_RATE_MULT_4X
);
1276 /* Set the SDVO control regs. */
1277 if (IS_I965G(dev
)) {
1278 sdvox
|= SDVO_BORDER_ENABLE
|
1279 SDVO_VSYNC_ACTIVE_HIGH
|
1280 SDVO_HSYNC_ACTIVE_HIGH
;
1282 sdvox
|= I915_READ(sdvo_priv
->sdvo_reg
);
1283 switch (sdvo_priv
->sdvo_reg
) {
1285 sdvox
&= SDVOB_PRESERVE_MASK
;
1288 sdvox
&= SDVOC_PRESERVE_MASK
;
1291 sdvox
|= (9 << 19) | SDVO_BORDER_ENABLE
;
1293 if (intel_crtc
->pipe
== 1)
1294 sdvox
|= SDVO_PIPE_B_SELECT
;
1296 sdvo_pixel_multiply
= intel_sdvo_get_pixel_multiplier(mode
);
1297 if (IS_I965G(dev
)) {
1298 /* done in crtc_mode_set as the dpll_md reg must be written early */
1299 } else if (IS_I945G(dev
) || IS_I945GM(dev
) || IS_G33(dev
)) {
1300 /* done in crtc_mode_set as it lives inside the dpll register */
1302 sdvox
|= (sdvo_pixel_multiply
- 1) << SDVO_PORT_MULTIPLY_SHIFT
;
1305 if (sdvo_priv
->sdvo_flags
& SDVO_NEED_TO_STALL
)
1306 sdvox
|= SDVO_STALL_SELECT
;
1307 intel_sdvo_write_sdvox(intel_encoder
, sdvox
);
1310 static void intel_sdvo_dpms(struct drm_encoder
*encoder
, int mode
)
1312 struct drm_device
*dev
= encoder
->dev
;
1313 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1314 struct intel_encoder
*intel_encoder
= enc_to_intel_encoder(encoder
);
1315 struct intel_sdvo_priv
*sdvo_priv
= intel_encoder
->dev_priv
;
1318 if (mode
!= DRM_MODE_DPMS_ON
) {
1319 intel_sdvo_set_active_outputs(intel_encoder
, 0);
1321 intel_sdvo_set_encoder_power_state(intel_encoder
, mode
);
1323 if (mode
== DRM_MODE_DPMS_OFF
) {
1324 temp
= I915_READ(sdvo_priv
->sdvo_reg
);
1325 if ((temp
& SDVO_ENABLE
) != 0) {
1326 intel_sdvo_write_sdvox(intel_encoder
, temp
& ~SDVO_ENABLE
);
1330 bool input1
, input2
;
1334 temp
= I915_READ(sdvo_priv
->sdvo_reg
);
1335 if ((temp
& SDVO_ENABLE
) == 0)
1336 intel_sdvo_write_sdvox(intel_encoder
, temp
| SDVO_ENABLE
);
1337 for (i
= 0; i
< 2; i
++)
1338 intel_wait_for_vblank(dev
);
1340 status
= intel_sdvo_get_trained_inputs(intel_encoder
, &input1
,
1344 /* Warn if the device reported failure to sync.
1345 * A lot of SDVO devices fail to notify of sync, but it's
1346 * a given it the status is a success, we succeeded.
1348 if (status
== SDVO_CMD_STATUS_SUCCESS
&& !input1
) {
1349 DRM_DEBUG_KMS("First %s output reported failure to "
1350 "sync\n", SDVO_NAME(sdvo_priv
));
1354 intel_sdvo_set_encoder_power_state(intel_encoder
, mode
);
1355 intel_sdvo_set_active_outputs(intel_encoder
, sdvo_priv
->controlled_output
);
1360 static void intel_sdvo_save(struct drm_connector
*connector
)
1362 struct drm_device
*dev
= connector
->dev
;
1363 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
1364 struct intel_encoder
*intel_encoder
= to_intel_encoder(connector
);
1365 struct intel_sdvo_priv
*sdvo_priv
= intel_encoder
->dev_priv
;
1368 sdvo_priv
->save_sdvo_mult
= intel_sdvo_get_clock_rate_mult(intel_encoder
);
1369 intel_sdvo_get_active_outputs(intel_encoder
, &sdvo_priv
->save_active_outputs
);
1371 if (sdvo_priv
->caps
.sdvo_inputs_mask
& 0x1) {
1372 intel_sdvo_set_target_input(intel_encoder
, true, false);
1373 intel_sdvo_get_input_timing(intel_encoder
,
1374 &sdvo_priv
->save_input_dtd_1
);
1377 if (sdvo_priv
->caps
.sdvo_inputs_mask
& 0x2) {
1378 intel_sdvo_set_target_input(intel_encoder
, false, true);
1379 intel_sdvo_get_input_timing(intel_encoder
,
1380 &sdvo_priv
->save_input_dtd_2
);
1383 for (o
= SDVO_OUTPUT_FIRST
; o
<= SDVO_OUTPUT_LAST
; o
++)
1385 u16 this_output
= (1 << o
);
1386 if (sdvo_priv
->caps
.output_flags
& this_output
)
1388 intel_sdvo_set_target_output(intel_encoder
, this_output
);
1389 intel_sdvo_get_output_timing(intel_encoder
,
1390 &sdvo_priv
->save_output_dtd
[o
]);
1393 if (sdvo_priv
->is_tv
) {
1394 /* XXX: Save TV format/enhancements. */
1397 sdvo_priv
->save_SDVOX
= I915_READ(sdvo_priv
->sdvo_reg
);
1400 static void intel_sdvo_restore(struct drm_connector
*connector
)
1402 struct drm_device
*dev
= connector
->dev
;
1403 struct intel_encoder
*intel_encoder
= to_intel_encoder(connector
);
1404 struct intel_sdvo_priv
*sdvo_priv
= intel_encoder
->dev_priv
;
1407 bool input1
, input2
;
1410 intel_sdvo_set_active_outputs(intel_encoder
, 0);
1412 for (o
= SDVO_OUTPUT_FIRST
; o
<= SDVO_OUTPUT_LAST
; o
++)
1414 u16 this_output
= (1 << o
);
1415 if (sdvo_priv
->caps
.output_flags
& this_output
) {
1416 intel_sdvo_set_target_output(intel_encoder
, this_output
);
1417 intel_sdvo_set_output_timing(intel_encoder
, &sdvo_priv
->save_output_dtd
[o
]);
1421 if (sdvo_priv
->caps
.sdvo_inputs_mask
& 0x1) {
1422 intel_sdvo_set_target_input(intel_encoder
, true, false);
1423 intel_sdvo_set_input_timing(intel_encoder
, &sdvo_priv
->save_input_dtd_1
);
1426 if (sdvo_priv
->caps
.sdvo_inputs_mask
& 0x2) {
1427 intel_sdvo_set_target_input(intel_encoder
, false, true);
1428 intel_sdvo_set_input_timing(intel_encoder
, &sdvo_priv
->save_input_dtd_2
);
1431 intel_sdvo_set_clock_rate_mult(intel_encoder
, sdvo_priv
->save_sdvo_mult
);
1433 if (sdvo_priv
->is_tv
) {
1434 /* XXX: Restore TV format/enhancements. */
1437 intel_sdvo_write_sdvox(intel_encoder
, sdvo_priv
->save_SDVOX
);
1439 if (sdvo_priv
->save_SDVOX
& SDVO_ENABLE
)
1441 for (i
= 0; i
< 2; i
++)
1442 intel_wait_for_vblank(dev
);
1443 status
= intel_sdvo_get_trained_inputs(intel_encoder
, &input1
, &input2
);
1444 if (status
== SDVO_CMD_STATUS_SUCCESS
&& !input1
)
1445 DRM_DEBUG_KMS("First %s output reported failure to "
1446 "sync\n", SDVO_NAME(sdvo_priv
));
1449 intel_sdvo_set_active_outputs(intel_encoder
, sdvo_priv
->save_active_outputs
);
1452 static int intel_sdvo_mode_valid(struct drm_connector
*connector
,
1453 struct drm_display_mode
*mode
)
1455 struct intel_encoder
*intel_encoder
= to_intel_encoder(connector
);
1456 struct intel_sdvo_priv
*sdvo_priv
= intel_encoder
->dev_priv
;
1458 if (mode
->flags
& DRM_MODE_FLAG_DBLSCAN
)
1459 return MODE_NO_DBLESCAN
;
1461 if (sdvo_priv
->pixel_clock_min
> mode
->clock
)
1462 return MODE_CLOCK_LOW
;
1464 if (sdvo_priv
->pixel_clock_max
< mode
->clock
)
1465 return MODE_CLOCK_HIGH
;
1467 if (sdvo_priv
->is_lvds
== true) {
1468 if (sdvo_priv
->sdvo_lvds_fixed_mode
== NULL
)
1471 if (mode
->hdisplay
> sdvo_priv
->sdvo_lvds_fixed_mode
->hdisplay
)
1474 if (mode
->vdisplay
> sdvo_priv
->sdvo_lvds_fixed_mode
->vdisplay
)
1481 static bool intel_sdvo_get_capabilities(struct intel_encoder
*intel_encoder
, struct intel_sdvo_caps
*caps
)
1485 intel_sdvo_write_cmd(intel_encoder
, SDVO_CMD_GET_DEVICE_CAPS
, NULL
, 0);
1486 status
= intel_sdvo_read_response(intel_encoder
, caps
, sizeof(*caps
));
1487 if (status
!= SDVO_CMD_STATUS_SUCCESS
)
1493 struct drm_connector
* intel_sdvo_find(struct drm_device
*dev
, int sdvoB
)
1495 struct drm_connector
*connector
= NULL
;
1496 struct intel_encoder
*iout
= NULL
;
1497 struct intel_sdvo_priv
*sdvo
;
1499 /* find the sdvo connector */
1500 list_for_each_entry(connector
, &dev
->mode_config
.connector_list
, head
) {
1501 iout
= to_intel_encoder(connector
);
1503 if (iout
->type
!= INTEL_OUTPUT_SDVO
)
1506 sdvo
= iout
->dev_priv
;
1508 if (sdvo
->sdvo_reg
== SDVOB
&& sdvoB
)
1511 if (sdvo
->sdvo_reg
== SDVOC
&& !sdvoB
)
1519 int intel_sdvo_supports_hotplug(struct drm_connector
*connector
)
1523 struct intel_encoder
*intel_encoder
;
1524 DRM_DEBUG_KMS("\n");
1529 intel_encoder
= to_intel_encoder(connector
);
1531 intel_sdvo_write_cmd(intel_encoder
, SDVO_CMD_GET_HOT_PLUG_SUPPORT
, NULL
, 0);
1532 status
= intel_sdvo_read_response(intel_encoder
, &response
, 2);
1534 if (response
[0] !=0)
1540 void intel_sdvo_set_hotplug(struct drm_connector
*connector
, int on
)
1544 struct intel_encoder
*intel_encoder
= to_intel_encoder(connector
);
1546 intel_sdvo_write_cmd(intel_encoder
, SDVO_CMD_GET_ACTIVE_HOT_PLUG
, NULL
, 0);
1547 intel_sdvo_read_response(intel_encoder
, &response
, 2);
1550 intel_sdvo_write_cmd(intel_encoder
, SDVO_CMD_GET_HOT_PLUG_SUPPORT
, NULL
, 0);
1551 status
= intel_sdvo_read_response(intel_encoder
, &response
, 2);
1553 intel_sdvo_write_cmd(intel_encoder
, SDVO_CMD_SET_ACTIVE_HOT_PLUG
, &response
, 2);
1557 intel_sdvo_write_cmd(intel_encoder
, SDVO_CMD_SET_ACTIVE_HOT_PLUG
, &response
, 2);
1560 intel_sdvo_write_cmd(intel_encoder
, SDVO_CMD_GET_ACTIVE_HOT_PLUG
, NULL
, 0);
1561 intel_sdvo_read_response(intel_encoder
, &response
, 2);
1565 intel_sdvo_multifunc_encoder(struct intel_encoder
*intel_encoder
)
1567 struct intel_sdvo_priv
*sdvo_priv
= intel_encoder
->dev_priv
;
1570 if (sdvo_priv
->caps
.output_flags
&
1571 (SDVO_OUTPUT_TMDS0
| SDVO_OUTPUT_TMDS1
))
1573 if (sdvo_priv
->caps
.output_flags
&
1574 (SDVO_OUTPUT_RGB0
| SDVO_OUTPUT_RGB1
))
1576 if (sdvo_priv
->caps
.output_flags
&
1577 (SDVO_OUTPUT_SVID0
| SDVO_OUTPUT_SVID1
))
1579 if (sdvo_priv
->caps
.output_flags
&
1580 (SDVO_OUTPUT_CVBS0
| SDVO_OUTPUT_CVBS1
))
1582 if (sdvo_priv
->caps
.output_flags
&
1583 (SDVO_OUTPUT_YPRPB0
| SDVO_OUTPUT_YPRPB1
))
1586 if (sdvo_priv
->caps
.output_flags
&
1587 (SDVO_OUTPUT_SCART0
| SDVO_OUTPUT_SCART1
))
1590 if (sdvo_priv
->caps
.output_flags
&
1591 (SDVO_OUTPUT_LVDS0
| SDVO_OUTPUT_LVDS1
))
1597 static struct drm_connector
*
1598 intel_find_analog_connector(struct drm_device
*dev
)
1600 struct drm_connector
*connector
;
1601 struct intel_encoder
*intel_encoder
;
1603 list_for_each_entry(connector
, &dev
->mode_config
.connector_list
, head
) {
1604 intel_encoder
= to_intel_encoder(connector
);
1605 if (intel_encoder
->type
== INTEL_OUTPUT_ANALOG
)
1612 intel_analog_is_connected(struct drm_device
*dev
)
1614 struct drm_connector
*analog_connector
;
1615 analog_connector
= intel_find_analog_connector(dev
);
1617 if (!analog_connector
)
1620 if (analog_connector
->funcs
->detect(analog_connector
) ==
1621 connector_status_disconnected
)
1627 enum drm_connector_status
1628 intel_sdvo_hdmi_sink_detect(struct drm_connector
*connector
, u16 response
)
1630 struct intel_encoder
*intel_encoder
= to_intel_encoder(connector
);
1631 struct intel_sdvo_priv
*sdvo_priv
= intel_encoder
->dev_priv
;
1632 enum drm_connector_status status
= connector_status_connected
;
1633 struct edid
*edid
= NULL
;
1635 edid
= drm_get_edid(&intel_encoder
->base
,
1636 intel_encoder
->ddc_bus
);
1638 /* This is only applied to SDVO cards with multiple outputs */
1639 if (edid
== NULL
&& intel_sdvo_multifunc_encoder(intel_encoder
)) {
1640 uint8_t saved_ddc
, temp_ddc
;
1641 saved_ddc
= sdvo_priv
->ddc_bus
;
1642 temp_ddc
= sdvo_priv
->ddc_bus
>> 1;
1644 * Don't use the 1 as the argument of DDC bus switch to get
1645 * the EDID. It is used for SDVO SPD ROM.
1647 while(temp_ddc
> 1) {
1648 sdvo_priv
->ddc_bus
= temp_ddc
;
1649 edid
= drm_get_edid(&intel_encoder
->base
,
1650 intel_encoder
->ddc_bus
);
1653 * When we can get the EDID, maybe it is the
1654 * correct DDC bus. Update it.
1656 sdvo_priv
->ddc_bus
= temp_ddc
;
1662 sdvo_priv
->ddc_bus
= saved_ddc
;
1664 /* when there is no edid and no monitor is connected with VGA
1665 * port, try to use the CRT ddc to read the EDID for DVI-connector
1668 sdvo_priv
->analog_ddc_bus
&&
1669 !intel_analog_is_connected(intel_encoder
->base
.dev
))
1670 edid
= drm_get_edid(&intel_encoder
->base
,
1671 sdvo_priv
->analog_ddc_bus
);
1673 /* Don't report the output as connected if it's a DVI-I
1674 * connector with a non-digital EDID coming out.
1676 if (response
& (SDVO_OUTPUT_TMDS0
| SDVO_OUTPUT_TMDS1
)) {
1677 if (edid
->input
& DRM_EDID_INPUT_DIGITAL
)
1678 sdvo_priv
->is_hdmi
=
1679 drm_detect_hdmi_monitor(edid
);
1681 status
= connector_status_disconnected
;
1685 intel_encoder
->base
.display_info
.raw_edid
= NULL
;
1687 } else if (response
& (SDVO_OUTPUT_TMDS0
| SDVO_OUTPUT_TMDS1
))
1688 status
= connector_status_disconnected
;
1693 static enum drm_connector_status
intel_sdvo_detect(struct drm_connector
*connector
)
1697 struct intel_encoder
*intel_encoder
= to_intel_encoder(connector
);
1698 struct intel_sdvo_priv
*sdvo_priv
= intel_encoder
->dev_priv
;
1700 intel_sdvo_write_cmd(intel_encoder
,
1701 SDVO_CMD_GET_ATTACHED_DISPLAYS
, NULL
, 0);
1702 if (sdvo_priv
->is_tv
) {
1703 /* add 30ms delay when the output type is SDVO-TV */
1706 status
= intel_sdvo_read_response(intel_encoder
, &response
, 2);
1708 DRM_DEBUG_KMS("SDVO response %d %d\n", response
& 0xff, response
>> 8);
1710 if (status
!= SDVO_CMD_STATUS_SUCCESS
)
1711 return connector_status_unknown
;
1714 return connector_status_disconnected
;
1716 if (intel_sdvo_multifunc_encoder(intel_encoder
) &&
1717 sdvo_priv
->attached_output
!= response
) {
1718 if (sdvo_priv
->controlled_output
!= response
&&
1719 intel_sdvo_output_setup(intel_encoder
, response
) != true)
1720 return connector_status_unknown
;
1721 sdvo_priv
->attached_output
= response
;
1723 return intel_sdvo_hdmi_sink_detect(connector
, response
);
1726 static void intel_sdvo_get_ddc_modes(struct drm_connector
*connector
)
1728 struct intel_encoder
*intel_encoder
= to_intel_encoder(connector
);
1729 struct intel_sdvo_priv
*sdvo_priv
= intel_encoder
->dev_priv
;
1732 /* set the bus switch and get the modes */
1733 num_modes
= intel_ddc_get_modes(intel_encoder
);
1736 * Mac mini hack. On this device, the DVI-I connector shares one DDC
1737 * link between analog and digital outputs. So, if the regular SDVO
1738 * DDC fails, check to see if the analog output is disconnected, in
1739 * which case we'll look there for the digital DDC data.
1741 if (num_modes
== 0 &&
1742 sdvo_priv
->analog_ddc_bus
&&
1743 !intel_analog_is_connected(intel_encoder
->base
.dev
)) {
1744 struct i2c_adapter
*digital_ddc_bus
;
1746 /* Switch to the analog ddc bus and try that
1748 digital_ddc_bus
= intel_encoder
->ddc_bus
;
1749 intel_encoder
->ddc_bus
= sdvo_priv
->analog_ddc_bus
;
1751 (void) intel_ddc_get_modes(intel_encoder
);
1753 intel_encoder
->ddc_bus
= digital_ddc_bus
;
1758 * Set of SDVO TV modes.
1759 * Note! This is in reply order (see loop in get_tv_modes).
1760 * XXX: all 60Hz refresh?
1762 struct drm_display_mode sdvo_tv_modes
[] = {
1763 { DRM_MODE("320x200", DRM_MODE_TYPE_DRIVER
, 5815, 320, 321, 384,
1764 416, 0, 200, 201, 232, 233, 0,
1765 DRM_MODE_FLAG_PHSYNC
| DRM_MODE_FLAG_PVSYNC
) },
1766 { DRM_MODE("320x240", DRM_MODE_TYPE_DRIVER
, 6814, 320, 321, 384,
1767 416, 0, 240, 241, 272, 273, 0,
1768 DRM_MODE_FLAG_PHSYNC
| DRM_MODE_FLAG_PVSYNC
) },
1769 { DRM_MODE("400x300", DRM_MODE_TYPE_DRIVER
, 9910, 400, 401, 464,
1770 496, 0, 300, 301, 332, 333, 0,
1771 DRM_MODE_FLAG_PHSYNC
| DRM_MODE_FLAG_PVSYNC
) },
1772 { DRM_MODE("640x350", DRM_MODE_TYPE_DRIVER
, 16913, 640, 641, 704,
1773 736, 0, 350, 351, 382, 383, 0,
1774 DRM_MODE_FLAG_PHSYNC
| DRM_MODE_FLAG_PVSYNC
) },
1775 { DRM_MODE("640x400", DRM_MODE_TYPE_DRIVER
, 19121, 640, 641, 704,
1776 736, 0, 400, 401, 432, 433, 0,
1777 DRM_MODE_FLAG_PHSYNC
| DRM_MODE_FLAG_PVSYNC
) },
1778 { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER
, 22654, 640, 641, 704,
1779 736, 0, 480, 481, 512, 513, 0,
1780 DRM_MODE_FLAG_PHSYNC
| DRM_MODE_FLAG_PVSYNC
) },
1781 { DRM_MODE("704x480", DRM_MODE_TYPE_DRIVER
, 24624, 704, 705, 768,
1782 800, 0, 480, 481, 512, 513, 0,
1783 DRM_MODE_FLAG_PHSYNC
| DRM_MODE_FLAG_PVSYNC
) },
1784 { DRM_MODE("704x576", DRM_MODE_TYPE_DRIVER
, 29232, 704, 705, 768,
1785 800, 0, 576, 577, 608, 609, 0,
1786 DRM_MODE_FLAG_PHSYNC
| DRM_MODE_FLAG_PVSYNC
) },
1787 { DRM_MODE("720x350", DRM_MODE_TYPE_DRIVER
, 18751, 720, 721, 784,
1788 816, 0, 350, 351, 382, 383, 0,
1789 DRM_MODE_FLAG_PHSYNC
| DRM_MODE_FLAG_PVSYNC
) },
1790 { DRM_MODE("720x400", DRM_MODE_TYPE_DRIVER
, 21199, 720, 721, 784,
1791 816, 0, 400, 401, 432, 433, 0,
1792 DRM_MODE_FLAG_PHSYNC
| DRM_MODE_FLAG_PVSYNC
) },
1793 { DRM_MODE("720x480", DRM_MODE_TYPE_DRIVER
, 25116, 720, 721, 784,
1794 816, 0, 480, 481, 512, 513, 0,
1795 DRM_MODE_FLAG_PHSYNC
| DRM_MODE_FLAG_PVSYNC
) },
1796 { DRM_MODE("720x540", DRM_MODE_TYPE_DRIVER
, 28054, 720, 721, 784,
1797 816, 0, 540, 541, 572, 573, 0,
1798 DRM_MODE_FLAG_PHSYNC
| DRM_MODE_FLAG_PVSYNC
) },
1799 { DRM_MODE("720x576", DRM_MODE_TYPE_DRIVER
, 29816, 720, 721, 784,
1800 816, 0, 576, 577, 608, 609, 0,
1801 DRM_MODE_FLAG_PHSYNC
| DRM_MODE_FLAG_PVSYNC
) },
1802 { DRM_MODE("768x576", DRM_MODE_TYPE_DRIVER
, 31570, 768, 769, 832,
1803 864, 0, 576, 577, 608, 609, 0,
1804 DRM_MODE_FLAG_PHSYNC
| DRM_MODE_FLAG_PVSYNC
) },
1805 { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER
, 34030, 800, 801, 864,
1806 896, 0, 600, 601, 632, 633, 0,
1807 DRM_MODE_FLAG_PHSYNC
| DRM_MODE_FLAG_PVSYNC
) },
1808 { DRM_MODE("832x624", DRM_MODE_TYPE_DRIVER
, 36581, 832, 833, 896,
1809 928, 0, 624, 625, 656, 657, 0,
1810 DRM_MODE_FLAG_PHSYNC
| DRM_MODE_FLAG_PVSYNC
) },
1811 { DRM_MODE("920x766", DRM_MODE_TYPE_DRIVER
, 48707, 920, 921, 984,
1812 1016, 0, 766, 767, 798, 799, 0,
1813 DRM_MODE_FLAG_PHSYNC
| DRM_MODE_FLAG_PVSYNC
) },
1814 { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER
, 53827, 1024, 1025, 1088,
1815 1120, 0, 768, 769, 800, 801, 0,
1816 DRM_MODE_FLAG_PHSYNC
| DRM_MODE_FLAG_PVSYNC
) },
1817 { DRM_MODE("1280x1024", DRM_MODE_TYPE_DRIVER
, 87265, 1280, 1281, 1344,
1818 1376, 0, 1024, 1025, 1056, 1057, 0,
1819 DRM_MODE_FLAG_PHSYNC
| DRM_MODE_FLAG_PVSYNC
) },
1822 static void intel_sdvo_get_tv_modes(struct drm_connector
*connector
)
1824 struct intel_encoder
*output
= to_intel_encoder(connector
);
1825 struct intel_sdvo_priv
*sdvo_priv
= output
->dev_priv
;
1826 struct intel_sdvo_sdtv_resolution_request tv_res
;
1827 uint32_t reply
= 0, format_map
= 0;
1832 /* Read the list of supported input resolutions for the selected TV
1835 for (i
= 0; i
< TV_FORMAT_NUM
; i
++)
1836 if (tv_format_names
[i
] == sdvo_priv
->tv_format_name
)
1839 format_map
= (1 << i
);
1840 memcpy(&tv_res
, &format_map
,
1841 sizeof(struct intel_sdvo_sdtv_resolution_request
) >
1842 sizeof(format_map
) ? sizeof(format_map
) :
1843 sizeof(struct intel_sdvo_sdtv_resolution_request
));
1845 intel_sdvo_set_target_output(output
, sdvo_priv
->controlled_output
);
1847 intel_sdvo_write_cmd(output
, SDVO_CMD_GET_SDTV_RESOLUTION_SUPPORT
,
1848 &tv_res
, sizeof(tv_res
));
1849 status
= intel_sdvo_read_response(output
, &reply
, 3);
1850 if (status
!= SDVO_CMD_STATUS_SUCCESS
)
1853 for (i
= 0; i
< ARRAY_SIZE(sdvo_tv_modes
); i
++)
1854 if (reply
& (1 << i
)) {
1855 struct drm_display_mode
*nmode
;
1856 nmode
= drm_mode_duplicate(connector
->dev
,
1859 drm_mode_probed_add(connector
, nmode
);
1864 static void intel_sdvo_get_lvds_modes(struct drm_connector
*connector
)
1866 struct intel_encoder
*intel_encoder
= to_intel_encoder(connector
);
1867 struct drm_i915_private
*dev_priv
= connector
->dev
->dev_private
;
1868 struct intel_sdvo_priv
*sdvo_priv
= intel_encoder
->dev_priv
;
1869 struct drm_display_mode
*newmode
;
1872 * Attempt to get the mode list from DDC.
1873 * Assume that the preferred modes are
1874 * arranged in priority order.
1876 intel_ddc_get_modes(intel_encoder
);
1877 if (list_empty(&connector
->probed_modes
) == false)
1880 /* Fetch modes from VBT */
1881 if (dev_priv
->sdvo_lvds_vbt_mode
!= NULL
) {
1882 newmode
= drm_mode_duplicate(connector
->dev
,
1883 dev_priv
->sdvo_lvds_vbt_mode
);
1884 if (newmode
!= NULL
) {
1885 /* Guarantee the mode is preferred */
1886 newmode
->type
= (DRM_MODE_TYPE_PREFERRED
|
1887 DRM_MODE_TYPE_DRIVER
);
1888 drm_mode_probed_add(connector
, newmode
);
1893 list_for_each_entry(newmode
, &connector
->probed_modes
, head
) {
1894 if (newmode
->type
& DRM_MODE_TYPE_PREFERRED
) {
1895 sdvo_priv
->sdvo_lvds_fixed_mode
=
1896 drm_mode_duplicate(connector
->dev
, newmode
);
1903 static int intel_sdvo_get_modes(struct drm_connector
*connector
)
1905 struct intel_encoder
*output
= to_intel_encoder(connector
);
1906 struct intel_sdvo_priv
*sdvo_priv
= output
->dev_priv
;
1908 if (sdvo_priv
->is_tv
)
1909 intel_sdvo_get_tv_modes(connector
);
1910 else if (sdvo_priv
->is_lvds
== true)
1911 intel_sdvo_get_lvds_modes(connector
);
1913 intel_sdvo_get_ddc_modes(connector
);
1915 if (list_empty(&connector
->probed_modes
))
1921 void intel_sdvo_destroy_enhance_property(struct drm_connector
*connector
)
1923 struct intel_encoder
*intel_encoder
= to_intel_encoder(connector
);
1924 struct intel_sdvo_priv
*sdvo_priv
= intel_encoder
->dev_priv
;
1925 struct drm_device
*dev
= connector
->dev
;
1927 if (sdvo_priv
->is_tv
) {
1928 if (sdvo_priv
->left_property
)
1929 drm_property_destroy(dev
, sdvo_priv
->left_property
);
1930 if (sdvo_priv
->right_property
)
1931 drm_property_destroy(dev
, sdvo_priv
->right_property
);
1932 if (sdvo_priv
->top_property
)
1933 drm_property_destroy(dev
, sdvo_priv
->top_property
);
1934 if (sdvo_priv
->bottom_property
)
1935 drm_property_destroy(dev
, sdvo_priv
->bottom_property
);
1936 if (sdvo_priv
->hpos_property
)
1937 drm_property_destroy(dev
, sdvo_priv
->hpos_property
);
1938 if (sdvo_priv
->vpos_property
)
1939 drm_property_destroy(dev
, sdvo_priv
->vpos_property
);
1941 if (sdvo_priv
->is_tv
) {
1942 if (sdvo_priv
->saturation_property
)
1943 drm_property_destroy(dev
,
1944 sdvo_priv
->saturation_property
);
1945 if (sdvo_priv
->contrast_property
)
1946 drm_property_destroy(dev
,
1947 sdvo_priv
->contrast_property
);
1948 if (sdvo_priv
->hue_property
)
1949 drm_property_destroy(dev
, sdvo_priv
->hue_property
);
1951 if (sdvo_priv
->is_tv
|| sdvo_priv
->is_lvds
) {
1952 if (sdvo_priv
->brightness_property
)
1953 drm_property_destroy(dev
,
1954 sdvo_priv
->brightness_property
);
1959 static void intel_sdvo_destroy(struct drm_connector
*connector
)
1961 struct intel_encoder
*intel_encoder
= to_intel_encoder(connector
);
1962 struct intel_sdvo_priv
*sdvo_priv
= intel_encoder
->dev_priv
;
1964 if (intel_encoder
->i2c_bus
)
1965 intel_i2c_destroy(intel_encoder
->i2c_bus
);
1966 if (intel_encoder
->ddc_bus
)
1967 intel_i2c_destroy(intel_encoder
->ddc_bus
);
1968 if (sdvo_priv
->analog_ddc_bus
)
1969 intel_i2c_destroy(sdvo_priv
->analog_ddc_bus
);
1971 if (sdvo_priv
->sdvo_lvds_fixed_mode
!= NULL
)
1972 drm_mode_destroy(connector
->dev
,
1973 sdvo_priv
->sdvo_lvds_fixed_mode
);
1975 if (sdvo_priv
->tv_format_property
)
1976 drm_property_destroy(connector
->dev
,
1977 sdvo_priv
->tv_format_property
);
1979 if (sdvo_priv
->is_tv
|| sdvo_priv
->is_lvds
)
1980 intel_sdvo_destroy_enhance_property(connector
);
1982 drm_sysfs_connector_remove(connector
);
1983 drm_connector_cleanup(connector
);
1985 kfree(intel_encoder
);
1989 intel_sdvo_set_property(struct drm_connector
*connector
,
1990 struct drm_property
*property
,
1993 struct intel_encoder
*intel_encoder
= to_intel_encoder(connector
);
1994 struct intel_sdvo_priv
*sdvo_priv
= intel_encoder
->dev_priv
;
1995 struct drm_encoder
*encoder
= &intel_encoder
->enc
;
1996 struct drm_crtc
*crtc
= encoder
->crtc
;
1998 bool changed
= false;
1999 uint8_t cmd
, status
;
2000 uint16_t temp_value
;
2002 ret
= drm_connector_property_set_value(connector
, property
, val
);
2006 if (property
== sdvo_priv
->tv_format_property
) {
2007 if (val
>= TV_FORMAT_NUM
) {
2011 if (sdvo_priv
->tv_format_name
==
2012 sdvo_priv
->tv_format_supported
[val
])
2015 sdvo_priv
->tv_format_name
= sdvo_priv
->tv_format_supported
[val
];
2019 if (sdvo_priv
->is_tv
|| sdvo_priv
->is_lvds
) {
2022 if (sdvo_priv
->left_property
== property
) {
2023 drm_connector_property_set_value(connector
,
2024 sdvo_priv
->right_property
, val
);
2025 if (sdvo_priv
->left_margin
== temp_value
)
2028 sdvo_priv
->left_margin
= temp_value
;
2029 sdvo_priv
->right_margin
= temp_value
;
2030 temp_value
= sdvo_priv
->max_hscan
-
2031 sdvo_priv
->left_margin
;
2032 cmd
= SDVO_CMD_SET_OVERSCAN_H
;
2033 } else if (sdvo_priv
->right_property
== property
) {
2034 drm_connector_property_set_value(connector
,
2035 sdvo_priv
->left_property
, val
);
2036 if (sdvo_priv
->right_margin
== temp_value
)
2039 sdvo_priv
->left_margin
= temp_value
;
2040 sdvo_priv
->right_margin
= temp_value
;
2041 temp_value
= sdvo_priv
->max_hscan
-
2042 sdvo_priv
->left_margin
;
2043 cmd
= SDVO_CMD_SET_OVERSCAN_H
;
2044 } else if (sdvo_priv
->top_property
== property
) {
2045 drm_connector_property_set_value(connector
,
2046 sdvo_priv
->bottom_property
, val
);
2047 if (sdvo_priv
->top_margin
== temp_value
)
2050 sdvo_priv
->top_margin
= temp_value
;
2051 sdvo_priv
->bottom_margin
= temp_value
;
2052 temp_value
= sdvo_priv
->max_vscan
-
2053 sdvo_priv
->top_margin
;
2054 cmd
= SDVO_CMD_SET_OVERSCAN_V
;
2055 } else if (sdvo_priv
->bottom_property
== property
) {
2056 drm_connector_property_set_value(connector
,
2057 sdvo_priv
->top_property
, val
);
2058 if (sdvo_priv
->bottom_margin
== temp_value
)
2060 sdvo_priv
->top_margin
= temp_value
;
2061 sdvo_priv
->bottom_margin
= temp_value
;
2062 temp_value
= sdvo_priv
->max_vscan
-
2063 sdvo_priv
->top_margin
;
2064 cmd
= SDVO_CMD_SET_OVERSCAN_V
;
2065 } else if (sdvo_priv
->hpos_property
== property
) {
2066 if (sdvo_priv
->cur_hpos
== temp_value
)
2069 cmd
= SDVO_CMD_SET_POSITION_H
;
2070 sdvo_priv
->cur_hpos
= temp_value
;
2071 } else if (sdvo_priv
->vpos_property
== property
) {
2072 if (sdvo_priv
->cur_vpos
== temp_value
)
2075 cmd
= SDVO_CMD_SET_POSITION_V
;
2076 sdvo_priv
->cur_vpos
= temp_value
;
2077 } else if (sdvo_priv
->saturation_property
== property
) {
2078 if (sdvo_priv
->cur_saturation
== temp_value
)
2081 cmd
= SDVO_CMD_SET_SATURATION
;
2082 sdvo_priv
->cur_saturation
= temp_value
;
2083 } else if (sdvo_priv
->contrast_property
== property
) {
2084 if (sdvo_priv
->cur_contrast
== temp_value
)
2087 cmd
= SDVO_CMD_SET_CONTRAST
;
2088 sdvo_priv
->cur_contrast
= temp_value
;
2089 } else if (sdvo_priv
->hue_property
== property
) {
2090 if (sdvo_priv
->cur_hue
== temp_value
)
2093 cmd
= SDVO_CMD_SET_HUE
;
2094 sdvo_priv
->cur_hue
= temp_value
;
2095 } else if (sdvo_priv
->brightness_property
== property
) {
2096 if (sdvo_priv
->cur_brightness
== temp_value
)
2099 cmd
= SDVO_CMD_SET_BRIGHTNESS
;
2100 sdvo_priv
->cur_brightness
= temp_value
;
2103 intel_sdvo_write_cmd(intel_encoder
, cmd
, &temp_value
, 2);
2104 status
= intel_sdvo_read_response(intel_encoder
,
2106 if (status
!= SDVO_CMD_STATUS_SUCCESS
) {
2107 DRM_DEBUG_KMS("Incorrect SDVO command \n");
2113 if (changed
&& crtc
)
2114 drm_crtc_helper_set_mode(crtc
, &crtc
->mode
, crtc
->x
,
2120 static const struct drm_encoder_helper_funcs intel_sdvo_helper_funcs
= {
2121 .dpms
= intel_sdvo_dpms
,
2122 .mode_fixup
= intel_sdvo_mode_fixup
,
2123 .prepare
= intel_encoder_prepare
,
2124 .mode_set
= intel_sdvo_mode_set
,
2125 .commit
= intel_encoder_commit
,
2128 static const struct drm_connector_funcs intel_sdvo_connector_funcs
= {
2129 .dpms
= drm_helper_connector_dpms
,
2130 .save
= intel_sdvo_save
,
2131 .restore
= intel_sdvo_restore
,
2132 .detect
= intel_sdvo_detect
,
2133 .fill_modes
= drm_helper_probe_single_connector_modes
,
2134 .set_property
= intel_sdvo_set_property
,
2135 .destroy
= intel_sdvo_destroy
,
2138 static const struct drm_connector_helper_funcs intel_sdvo_connector_helper_funcs
= {
2139 .get_modes
= intel_sdvo_get_modes
,
2140 .mode_valid
= intel_sdvo_mode_valid
,
2141 .best_encoder
= intel_best_encoder
,
2144 static void intel_sdvo_enc_destroy(struct drm_encoder
*encoder
)
2146 drm_encoder_cleanup(encoder
);
2149 static const struct drm_encoder_funcs intel_sdvo_enc_funcs
= {
2150 .destroy
= intel_sdvo_enc_destroy
,
2155 * Choose the appropriate DDC bus for control bus switch command for this
2156 * SDVO output based on the controlled output.
2158 * DDC bus number assignment is in a priority order of RGB outputs, then TMDS
2159 * outputs, then LVDS outputs.
2162 intel_sdvo_select_ddc_bus(struct intel_sdvo_priv
*dev_priv
)
2165 unsigned int num_bits
;
2167 /* Make a mask of outputs less than or equal to our own priority in the
2170 switch (dev_priv
->controlled_output
) {
2171 case SDVO_OUTPUT_LVDS1
:
2172 mask
|= SDVO_OUTPUT_LVDS1
;
2173 case SDVO_OUTPUT_LVDS0
:
2174 mask
|= SDVO_OUTPUT_LVDS0
;
2175 case SDVO_OUTPUT_TMDS1
:
2176 mask
|= SDVO_OUTPUT_TMDS1
;
2177 case SDVO_OUTPUT_TMDS0
:
2178 mask
|= SDVO_OUTPUT_TMDS0
;
2179 case SDVO_OUTPUT_RGB1
:
2180 mask
|= SDVO_OUTPUT_RGB1
;
2181 case SDVO_OUTPUT_RGB0
:
2182 mask
|= SDVO_OUTPUT_RGB0
;
2186 /* Count bits to find what number we are in the priority list. */
2187 mask
&= dev_priv
->caps
.output_flags
;
2188 num_bits
= hweight16(mask
);
2190 /* if more than 3 outputs, default to DDC bus 3 for now */
2194 /* Corresponds to SDVO_CONTROL_BUS_DDCx */
2195 dev_priv
->ddc_bus
= 1 << num_bits
;
2199 intel_sdvo_get_digital_encoding_mode(struct intel_encoder
*output
)
2201 struct intel_sdvo_priv
*sdvo_priv
= output
->dev_priv
;
2204 intel_sdvo_set_target_output(output
, sdvo_priv
->controlled_output
);
2206 intel_sdvo_write_cmd(output
, SDVO_CMD_GET_ENCODE
, NULL
, 0);
2207 status
= intel_sdvo_read_response(output
, &sdvo_priv
->is_hdmi
, 1);
2208 if (status
!= SDVO_CMD_STATUS_SUCCESS
)
2213 static struct intel_encoder
*
2214 intel_sdvo_chan_to_intel_encoder(struct intel_i2c_chan
*chan
)
2216 struct drm_device
*dev
= chan
->drm_dev
;
2217 struct drm_connector
*connector
;
2218 struct intel_encoder
*intel_encoder
= NULL
;
2220 list_for_each_entry(connector
,
2221 &dev
->mode_config
.connector_list
, head
) {
2222 if (to_intel_encoder(connector
)->ddc_bus
== &chan
->adapter
) {
2223 intel_encoder
= to_intel_encoder(connector
);
2227 return intel_encoder
;
2230 static int intel_sdvo_master_xfer(struct i2c_adapter
*i2c_adap
,
2231 struct i2c_msg msgs
[], int num
)
2233 struct intel_encoder
*intel_encoder
;
2234 struct intel_sdvo_priv
*sdvo_priv
;
2235 struct i2c_algo_bit_data
*algo_data
;
2236 const struct i2c_algorithm
*algo
;
2238 algo_data
= (struct i2c_algo_bit_data
*)i2c_adap
->algo_data
;
2240 intel_sdvo_chan_to_intel_encoder(
2241 (struct intel_i2c_chan
*)(algo_data
->data
));
2242 if (intel_encoder
== NULL
)
2245 sdvo_priv
= intel_encoder
->dev_priv
;
2246 algo
= intel_encoder
->i2c_bus
->algo
;
2248 intel_sdvo_set_control_bus_switch(intel_encoder
, sdvo_priv
->ddc_bus
);
2249 return algo
->master_xfer(i2c_adap
, msgs
, num
);
2252 static struct i2c_algorithm intel_sdvo_i2c_bit_algo
= {
2253 .master_xfer
= intel_sdvo_master_xfer
,
2257 intel_sdvo_get_slave_addr(struct drm_device
*dev
, int sdvo_reg
)
2259 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
2260 struct sdvo_device_mapping
*my_mapping
, *other_mapping
;
2262 if (sdvo_reg
== SDVOB
) {
2263 my_mapping
= &dev_priv
->sdvo_mappings
[0];
2264 other_mapping
= &dev_priv
->sdvo_mappings
[1];
2266 my_mapping
= &dev_priv
->sdvo_mappings
[1];
2267 other_mapping
= &dev_priv
->sdvo_mappings
[0];
2270 /* If the BIOS described our SDVO device, take advantage of it. */
2271 if (my_mapping
->slave_addr
)
2272 return my_mapping
->slave_addr
;
2274 /* If the BIOS only described a different SDVO device, use the
2275 * address that it isn't using.
2277 if (other_mapping
->slave_addr
) {
2278 if (other_mapping
->slave_addr
== 0x70)
2284 /* No SDVO device info is found for another DVO port,
2285 * so use mapping assumption we had before BIOS parsing.
2287 if (sdvo_reg
== SDVOB
)
2293 static int intel_sdvo_bad_tv_callback(const struct dmi_system_id
*id
)
2295 DRM_DEBUG_KMS("Ignoring bad SDVO TV connector for %s\n", id
->ident
);
2299 static struct dmi_system_id intel_sdvo_bad_tv
[] = {
2301 .callback
= intel_sdvo_bad_tv_callback
,
2302 .ident
= "IntelG45/ICH10R/DME1737",
2304 DMI_MATCH(DMI_SYS_VENDOR
, "IBM CORPORATION"),
2305 DMI_MATCH(DMI_PRODUCT_NAME
, "4800784"),
2309 { } /* terminating entry */
2313 intel_sdvo_output_setup(struct intel_encoder
*intel_encoder
, uint16_t flags
)
2315 struct drm_connector
*connector
= &intel_encoder
->base
;
2316 struct drm_encoder
*encoder
= &intel_encoder
->enc
;
2317 struct intel_sdvo_priv
*sdvo_priv
= intel_encoder
->dev_priv
;
2318 bool ret
= true, registered
= false;
2320 sdvo_priv
->is_tv
= false;
2321 intel_encoder
->needs_tv_clock
= false;
2322 sdvo_priv
->is_lvds
= false;
2324 if (device_is_registered(&connector
->kdev
)) {
2325 drm_sysfs_connector_remove(connector
);
2330 (SDVO_OUTPUT_TMDS0
| SDVO_OUTPUT_TMDS1
)) {
2331 if (sdvo_priv
->caps
.output_flags
& SDVO_OUTPUT_TMDS0
)
2332 sdvo_priv
->controlled_output
= SDVO_OUTPUT_TMDS0
;
2334 sdvo_priv
->controlled_output
= SDVO_OUTPUT_TMDS1
;
2336 encoder
->encoder_type
= DRM_MODE_ENCODER_TMDS
;
2337 connector
->connector_type
= DRM_MODE_CONNECTOR_DVID
;
2339 if (intel_sdvo_get_supp_encode(intel_encoder
,
2340 &sdvo_priv
->encode
) &&
2341 intel_sdvo_get_digital_encoding_mode(intel_encoder
) &&
2342 sdvo_priv
->is_hdmi
) {
2343 /* enable hdmi encoding mode if supported */
2344 intel_sdvo_set_encode(intel_encoder
, SDVO_ENCODE_HDMI
);
2345 intel_sdvo_set_colorimetry(intel_encoder
,
2346 SDVO_COLORIMETRY_RGB256
);
2347 connector
->connector_type
= DRM_MODE_CONNECTOR_HDMIA
;
2348 intel_encoder
->clone_mask
=
2349 (1 << INTEL_SDVO_NON_TV_CLONE_BIT
) |
2350 (1 << INTEL_ANALOG_CLONE_BIT
);
2352 } else if ((flags
& SDVO_OUTPUT_SVID0
) &&
2353 !dmi_check_system(intel_sdvo_bad_tv
)) {
2355 sdvo_priv
->controlled_output
= SDVO_OUTPUT_SVID0
;
2356 encoder
->encoder_type
= DRM_MODE_ENCODER_TVDAC
;
2357 connector
->connector_type
= DRM_MODE_CONNECTOR_SVIDEO
;
2358 sdvo_priv
->is_tv
= true;
2359 intel_encoder
->needs_tv_clock
= true;
2360 intel_encoder
->clone_mask
= 1 << INTEL_SDVO_TV_CLONE_BIT
;
2361 } else if (flags
& SDVO_OUTPUT_RGB0
) {
2363 sdvo_priv
->controlled_output
= SDVO_OUTPUT_RGB0
;
2364 encoder
->encoder_type
= DRM_MODE_ENCODER_DAC
;
2365 connector
->connector_type
= DRM_MODE_CONNECTOR_VGA
;
2366 intel_encoder
->clone_mask
= (1 << INTEL_SDVO_NON_TV_CLONE_BIT
) |
2367 (1 << INTEL_ANALOG_CLONE_BIT
);
2368 } else if (flags
& SDVO_OUTPUT_RGB1
) {
2370 sdvo_priv
->controlled_output
= SDVO_OUTPUT_RGB1
;
2371 encoder
->encoder_type
= DRM_MODE_ENCODER_DAC
;
2372 connector
->connector_type
= DRM_MODE_CONNECTOR_VGA
;
2373 intel_encoder
->clone_mask
= (1 << INTEL_SDVO_NON_TV_CLONE_BIT
) |
2374 (1 << INTEL_ANALOG_CLONE_BIT
);
2375 } else if (flags
& SDVO_OUTPUT_CVBS0
) {
2377 sdvo_priv
->controlled_output
= SDVO_OUTPUT_CVBS0
;
2378 encoder
->encoder_type
= DRM_MODE_ENCODER_TVDAC
;
2379 connector
->connector_type
= DRM_MODE_CONNECTOR_SVIDEO
;
2380 sdvo_priv
->is_tv
= true;
2381 intel_encoder
->needs_tv_clock
= true;
2382 intel_encoder
->clone_mask
= 1 << INTEL_SDVO_TV_CLONE_BIT
;
2383 } else if (flags
& SDVO_OUTPUT_LVDS0
) {
2385 sdvo_priv
->controlled_output
= SDVO_OUTPUT_LVDS0
;
2386 encoder
->encoder_type
= DRM_MODE_ENCODER_LVDS
;
2387 connector
->connector_type
= DRM_MODE_CONNECTOR_LVDS
;
2388 sdvo_priv
->is_lvds
= true;
2389 intel_encoder
->clone_mask
= (1 << INTEL_ANALOG_CLONE_BIT
) |
2390 (1 << INTEL_SDVO_LVDS_CLONE_BIT
);
2391 } else if (flags
& SDVO_OUTPUT_LVDS1
) {
2393 sdvo_priv
->controlled_output
= SDVO_OUTPUT_LVDS1
;
2394 encoder
->encoder_type
= DRM_MODE_ENCODER_LVDS
;
2395 connector
->connector_type
= DRM_MODE_CONNECTOR_LVDS
;
2396 sdvo_priv
->is_lvds
= true;
2397 intel_encoder
->clone_mask
= (1 << INTEL_ANALOG_CLONE_BIT
) |
2398 (1 << INTEL_SDVO_LVDS_CLONE_BIT
);
2401 unsigned char bytes
[2];
2403 sdvo_priv
->controlled_output
= 0;
2404 memcpy(bytes
, &sdvo_priv
->caps
.output_flags
, 2);
2405 DRM_DEBUG_KMS("%s: Unknown SDVO output type (0x%02x%02x)\n",
2406 SDVO_NAME(sdvo_priv
),
2407 bytes
[0], bytes
[1]);
2410 intel_encoder
->crtc_mask
= (1 << 0) | (1 << 1);
2412 if (ret
&& registered
)
2413 ret
= drm_sysfs_connector_add(connector
) == 0 ? true : false;
2420 static void intel_sdvo_tv_create_property(struct drm_connector
*connector
)
2422 struct intel_encoder
*intel_encoder
= to_intel_encoder(connector
);
2423 struct intel_sdvo_priv
*sdvo_priv
= intel_encoder
->dev_priv
;
2424 struct intel_sdvo_tv_format format
;
2425 uint32_t format_map
, i
;
2428 intel_sdvo_set_target_output(intel_encoder
,
2429 sdvo_priv
->controlled_output
);
2431 intel_sdvo_write_cmd(intel_encoder
,
2432 SDVO_CMD_GET_SUPPORTED_TV_FORMATS
, NULL
, 0);
2433 status
= intel_sdvo_read_response(intel_encoder
,
2434 &format
, sizeof(format
));
2435 if (status
!= SDVO_CMD_STATUS_SUCCESS
)
2438 memcpy(&format_map
, &format
, sizeof(format
) > sizeof(format_map
) ?
2439 sizeof(format_map
) : sizeof(format
));
2441 if (format_map
== 0)
2444 sdvo_priv
->format_supported_num
= 0;
2445 for (i
= 0 ; i
< TV_FORMAT_NUM
; i
++)
2446 if (format_map
& (1 << i
)) {
2447 sdvo_priv
->tv_format_supported
2448 [sdvo_priv
->format_supported_num
++] =
2453 sdvo_priv
->tv_format_property
=
2454 drm_property_create(
2455 connector
->dev
, DRM_MODE_PROP_ENUM
,
2456 "mode", sdvo_priv
->format_supported_num
);
2458 for (i
= 0; i
< sdvo_priv
->format_supported_num
; i
++)
2459 drm_property_add_enum(
2460 sdvo_priv
->tv_format_property
, i
,
2461 i
, sdvo_priv
->tv_format_supported
[i
]);
2463 sdvo_priv
->tv_format_name
= sdvo_priv
->tv_format_supported
[0];
2464 drm_connector_attach_property(
2465 connector
, sdvo_priv
->tv_format_property
, 0);
2469 static void intel_sdvo_create_enhance_property(struct drm_connector
*connector
)
2471 struct intel_encoder
*intel_encoder
= to_intel_encoder(connector
);
2472 struct intel_sdvo_priv
*sdvo_priv
= intel_encoder
->dev_priv
;
2473 struct intel_sdvo_enhancements_reply sdvo_data
;
2474 struct drm_device
*dev
= connector
->dev
;
2476 uint16_t response
, data_value
[2];
2478 intel_sdvo_write_cmd(intel_encoder
, SDVO_CMD_GET_SUPPORTED_ENHANCEMENTS
,
2480 status
= intel_sdvo_read_response(intel_encoder
, &sdvo_data
,
2482 if (status
!= SDVO_CMD_STATUS_SUCCESS
) {
2483 DRM_DEBUG_KMS(" incorrect response is returned\n");
2486 response
= *((uint16_t *)&sdvo_data
);
2488 DRM_DEBUG_KMS("No enhancement is supported\n");
2491 if (sdvo_priv
->is_tv
) {
2492 /* when horizontal overscan is supported, Add the left/right
2495 if (sdvo_data
.overscan_h
) {
2496 intel_sdvo_write_cmd(intel_encoder
,
2497 SDVO_CMD_GET_MAX_OVERSCAN_H
, NULL
, 0);
2498 status
= intel_sdvo_read_response(intel_encoder
,
2500 if (status
!= SDVO_CMD_STATUS_SUCCESS
) {
2501 DRM_DEBUG_KMS("Incorrect SDVO max "
2505 intel_sdvo_write_cmd(intel_encoder
,
2506 SDVO_CMD_GET_OVERSCAN_H
, NULL
, 0);
2507 status
= intel_sdvo_read_response(intel_encoder
,
2509 if (status
!= SDVO_CMD_STATUS_SUCCESS
) {
2510 DRM_DEBUG_KMS("Incorrect SDVO h_overscan\n");
2513 sdvo_priv
->max_hscan
= data_value
[0];
2514 sdvo_priv
->left_margin
= data_value
[0] - response
;
2515 sdvo_priv
->right_margin
= sdvo_priv
->left_margin
;
2516 sdvo_priv
->left_property
=
2517 drm_property_create(dev
, DRM_MODE_PROP_RANGE
,
2519 sdvo_priv
->left_property
->values
[0] = 0;
2520 sdvo_priv
->left_property
->values
[1] = data_value
[0];
2521 drm_connector_attach_property(connector
,
2522 sdvo_priv
->left_property
,
2523 sdvo_priv
->left_margin
);
2524 sdvo_priv
->right_property
=
2525 drm_property_create(dev
, DRM_MODE_PROP_RANGE
,
2527 sdvo_priv
->right_property
->values
[0] = 0;
2528 sdvo_priv
->right_property
->values
[1] = data_value
[0];
2529 drm_connector_attach_property(connector
,
2530 sdvo_priv
->right_property
,
2531 sdvo_priv
->right_margin
);
2532 DRM_DEBUG_KMS("h_overscan: max %d, "
2533 "default %d, current %d\n",
2534 data_value
[0], data_value
[1], response
);
2536 if (sdvo_data
.overscan_v
) {
2537 intel_sdvo_write_cmd(intel_encoder
,
2538 SDVO_CMD_GET_MAX_OVERSCAN_V
, NULL
, 0);
2539 status
= intel_sdvo_read_response(intel_encoder
,
2541 if (status
!= SDVO_CMD_STATUS_SUCCESS
) {
2542 DRM_DEBUG_KMS("Incorrect SDVO max "
2546 intel_sdvo_write_cmd(intel_encoder
,
2547 SDVO_CMD_GET_OVERSCAN_V
, NULL
, 0);
2548 status
= intel_sdvo_read_response(intel_encoder
,
2550 if (status
!= SDVO_CMD_STATUS_SUCCESS
) {
2551 DRM_DEBUG_KMS("Incorrect SDVO v_overscan\n");
2554 sdvo_priv
->max_vscan
= data_value
[0];
2555 sdvo_priv
->top_margin
= data_value
[0] - response
;
2556 sdvo_priv
->bottom_margin
= sdvo_priv
->top_margin
;
2557 sdvo_priv
->top_property
=
2558 drm_property_create(dev
, DRM_MODE_PROP_RANGE
,
2560 sdvo_priv
->top_property
->values
[0] = 0;
2561 sdvo_priv
->top_property
->values
[1] = data_value
[0];
2562 drm_connector_attach_property(connector
,
2563 sdvo_priv
->top_property
,
2564 sdvo_priv
->top_margin
);
2565 sdvo_priv
->bottom_property
=
2566 drm_property_create(dev
, DRM_MODE_PROP_RANGE
,
2567 "bottom_margin", 2);
2568 sdvo_priv
->bottom_property
->values
[0] = 0;
2569 sdvo_priv
->bottom_property
->values
[1] = data_value
[0];
2570 drm_connector_attach_property(connector
,
2571 sdvo_priv
->bottom_property
,
2572 sdvo_priv
->bottom_margin
);
2573 DRM_DEBUG_KMS("v_overscan: max %d, "
2574 "default %d, current %d\n",
2575 data_value
[0], data_value
[1], response
);
2577 if (sdvo_data
.position_h
) {
2578 intel_sdvo_write_cmd(intel_encoder
,
2579 SDVO_CMD_GET_MAX_POSITION_H
, NULL
, 0);
2580 status
= intel_sdvo_read_response(intel_encoder
,
2582 if (status
!= SDVO_CMD_STATUS_SUCCESS
) {
2583 DRM_DEBUG_KMS("Incorrect SDVO Max h_pos\n");
2586 intel_sdvo_write_cmd(intel_encoder
,
2587 SDVO_CMD_GET_POSITION_H
, NULL
, 0);
2588 status
= intel_sdvo_read_response(intel_encoder
,
2590 if (status
!= SDVO_CMD_STATUS_SUCCESS
) {
2591 DRM_DEBUG_KMS("Incorrect SDVO get h_postion\n");
2594 sdvo_priv
->max_hpos
= data_value
[0];
2595 sdvo_priv
->cur_hpos
= response
;
2596 sdvo_priv
->hpos_property
=
2597 drm_property_create(dev
, DRM_MODE_PROP_RANGE
,
2599 sdvo_priv
->hpos_property
->values
[0] = 0;
2600 sdvo_priv
->hpos_property
->values
[1] = data_value
[0];
2601 drm_connector_attach_property(connector
,
2602 sdvo_priv
->hpos_property
,
2603 sdvo_priv
->cur_hpos
);
2604 DRM_DEBUG_KMS("h_position: max %d, "
2605 "default %d, current %d\n",
2606 data_value
[0], data_value
[1], response
);
2608 if (sdvo_data
.position_v
) {
2609 intel_sdvo_write_cmd(intel_encoder
,
2610 SDVO_CMD_GET_MAX_POSITION_V
, NULL
, 0);
2611 status
= intel_sdvo_read_response(intel_encoder
,
2613 if (status
!= SDVO_CMD_STATUS_SUCCESS
) {
2614 DRM_DEBUG_KMS("Incorrect SDVO Max v_pos\n");
2617 intel_sdvo_write_cmd(intel_encoder
,
2618 SDVO_CMD_GET_POSITION_V
, NULL
, 0);
2619 status
= intel_sdvo_read_response(intel_encoder
,
2621 if (status
!= SDVO_CMD_STATUS_SUCCESS
) {
2622 DRM_DEBUG_KMS("Incorrect SDVO get v_postion\n");
2625 sdvo_priv
->max_vpos
= data_value
[0];
2626 sdvo_priv
->cur_vpos
= response
;
2627 sdvo_priv
->vpos_property
=
2628 drm_property_create(dev
, DRM_MODE_PROP_RANGE
,
2630 sdvo_priv
->vpos_property
->values
[0] = 0;
2631 sdvo_priv
->vpos_property
->values
[1] = data_value
[0];
2632 drm_connector_attach_property(connector
,
2633 sdvo_priv
->vpos_property
,
2634 sdvo_priv
->cur_vpos
);
2635 DRM_DEBUG_KMS("v_position: max %d, "
2636 "default %d, current %d\n",
2637 data_value
[0], data_value
[1], response
);
2640 if (sdvo_priv
->is_tv
) {
2641 if (sdvo_data
.saturation
) {
2642 intel_sdvo_write_cmd(intel_encoder
,
2643 SDVO_CMD_GET_MAX_SATURATION
, NULL
, 0);
2644 status
= intel_sdvo_read_response(intel_encoder
,
2646 if (status
!= SDVO_CMD_STATUS_SUCCESS
) {
2647 DRM_DEBUG_KMS("Incorrect SDVO Max sat\n");
2650 intel_sdvo_write_cmd(intel_encoder
,
2651 SDVO_CMD_GET_SATURATION
, NULL
, 0);
2652 status
= intel_sdvo_read_response(intel_encoder
,
2654 if (status
!= SDVO_CMD_STATUS_SUCCESS
) {
2655 DRM_DEBUG_KMS("Incorrect SDVO get sat\n");
2658 sdvo_priv
->max_saturation
= data_value
[0];
2659 sdvo_priv
->cur_saturation
= response
;
2660 sdvo_priv
->saturation_property
=
2661 drm_property_create(dev
, DRM_MODE_PROP_RANGE
,
2663 sdvo_priv
->saturation_property
->values
[0] = 0;
2664 sdvo_priv
->saturation_property
->values
[1] =
2666 drm_connector_attach_property(connector
,
2667 sdvo_priv
->saturation_property
,
2668 sdvo_priv
->cur_saturation
);
2669 DRM_DEBUG_KMS("saturation: max %d, "
2670 "default %d, current %d\n",
2671 data_value
[0], data_value
[1], response
);
2673 if (sdvo_data
.contrast
) {
2674 intel_sdvo_write_cmd(intel_encoder
,
2675 SDVO_CMD_GET_MAX_CONTRAST
, NULL
, 0);
2676 status
= intel_sdvo_read_response(intel_encoder
,
2678 if (status
!= SDVO_CMD_STATUS_SUCCESS
) {
2679 DRM_DEBUG_KMS("Incorrect SDVO Max contrast\n");
2682 intel_sdvo_write_cmd(intel_encoder
,
2683 SDVO_CMD_GET_CONTRAST
, NULL
, 0);
2684 status
= intel_sdvo_read_response(intel_encoder
,
2686 if (status
!= SDVO_CMD_STATUS_SUCCESS
) {
2687 DRM_DEBUG_KMS("Incorrect SDVO get contrast\n");
2690 sdvo_priv
->max_contrast
= data_value
[0];
2691 sdvo_priv
->cur_contrast
= response
;
2692 sdvo_priv
->contrast_property
=
2693 drm_property_create(dev
, DRM_MODE_PROP_RANGE
,
2695 sdvo_priv
->contrast_property
->values
[0] = 0;
2696 sdvo_priv
->contrast_property
->values
[1] = data_value
[0];
2697 drm_connector_attach_property(connector
,
2698 sdvo_priv
->contrast_property
,
2699 sdvo_priv
->cur_contrast
);
2700 DRM_DEBUG_KMS("contrast: max %d, "
2701 "default %d, current %d\n",
2702 data_value
[0], data_value
[1], response
);
2704 if (sdvo_data
.hue
) {
2705 intel_sdvo_write_cmd(intel_encoder
,
2706 SDVO_CMD_GET_MAX_HUE
, NULL
, 0);
2707 status
= intel_sdvo_read_response(intel_encoder
,
2709 if (status
!= SDVO_CMD_STATUS_SUCCESS
) {
2710 DRM_DEBUG_KMS("Incorrect SDVO Max hue\n");
2713 intel_sdvo_write_cmd(intel_encoder
,
2714 SDVO_CMD_GET_HUE
, NULL
, 0);
2715 status
= intel_sdvo_read_response(intel_encoder
,
2717 if (status
!= SDVO_CMD_STATUS_SUCCESS
) {
2718 DRM_DEBUG_KMS("Incorrect SDVO get hue\n");
2721 sdvo_priv
->max_hue
= data_value
[0];
2722 sdvo_priv
->cur_hue
= response
;
2723 sdvo_priv
->hue_property
=
2724 drm_property_create(dev
, DRM_MODE_PROP_RANGE
,
2726 sdvo_priv
->hue_property
->values
[0] = 0;
2727 sdvo_priv
->hue_property
->values
[1] =
2729 drm_connector_attach_property(connector
,
2730 sdvo_priv
->hue_property
,
2731 sdvo_priv
->cur_hue
);
2732 DRM_DEBUG_KMS("hue: max %d, default %d, current %d\n",
2733 data_value
[0], data_value
[1], response
);
2736 if (sdvo_priv
->is_tv
|| sdvo_priv
->is_lvds
) {
2737 if (sdvo_data
.brightness
) {
2738 intel_sdvo_write_cmd(intel_encoder
,
2739 SDVO_CMD_GET_MAX_BRIGHTNESS
, NULL
, 0);
2740 status
= intel_sdvo_read_response(intel_encoder
,
2742 if (status
!= SDVO_CMD_STATUS_SUCCESS
) {
2743 DRM_DEBUG_KMS("Incorrect SDVO Max bright\n");
2746 intel_sdvo_write_cmd(intel_encoder
,
2747 SDVO_CMD_GET_BRIGHTNESS
, NULL
, 0);
2748 status
= intel_sdvo_read_response(intel_encoder
,
2750 if (status
!= SDVO_CMD_STATUS_SUCCESS
) {
2751 DRM_DEBUG_KMS("Incorrect SDVO get brigh\n");
2754 sdvo_priv
->max_brightness
= data_value
[0];
2755 sdvo_priv
->cur_brightness
= response
;
2756 sdvo_priv
->brightness_property
=
2757 drm_property_create(dev
, DRM_MODE_PROP_RANGE
,
2759 sdvo_priv
->brightness_property
->values
[0] = 0;
2760 sdvo_priv
->brightness_property
->values
[1] =
2762 drm_connector_attach_property(connector
,
2763 sdvo_priv
->brightness_property
,
2764 sdvo_priv
->cur_brightness
);
2765 DRM_DEBUG_KMS("brightness: max %d, "
2766 "default %d, current %d\n",
2767 data_value
[0], data_value
[1], response
);
2773 bool intel_sdvo_init(struct drm_device
*dev
, int sdvo_reg
)
2775 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
2776 struct drm_connector
*connector
;
2777 struct intel_encoder
*intel_encoder
;
2778 struct intel_sdvo_priv
*sdvo_priv
;
2783 intel_encoder
= kcalloc(sizeof(struct intel_encoder
)+sizeof(struct intel_sdvo_priv
), 1, GFP_KERNEL
);
2784 if (!intel_encoder
) {
2788 sdvo_priv
= (struct intel_sdvo_priv
*)(intel_encoder
+ 1);
2789 sdvo_priv
->sdvo_reg
= sdvo_reg
;
2791 intel_encoder
->dev_priv
= sdvo_priv
;
2792 intel_encoder
->type
= INTEL_OUTPUT_SDVO
;
2794 /* setup the DDC bus. */
2795 if (sdvo_reg
== SDVOB
)
2796 intel_encoder
->i2c_bus
= intel_i2c_create(dev
, GPIOE
, "SDVOCTRL_E for SDVOB");
2798 intel_encoder
->i2c_bus
= intel_i2c_create(dev
, GPIOE
, "SDVOCTRL_E for SDVOC");
2800 if (!intel_encoder
->i2c_bus
)
2801 goto err_inteloutput
;
2803 sdvo_priv
->slave_addr
= intel_sdvo_get_slave_addr(dev
, sdvo_reg
);
2805 /* Save the bit-banging i2c functionality for use by the DDC wrapper */
2806 intel_sdvo_i2c_bit_algo
.functionality
= intel_encoder
->i2c_bus
->algo
->functionality
;
2808 /* Read the regs to test if we can talk to the device */
2809 for (i
= 0; i
< 0x40; i
++) {
2810 if (!intel_sdvo_read_byte(intel_encoder
, i
, &ch
[i
])) {
2811 DRM_DEBUG_KMS("No SDVO device found on SDVO%c\n",
2812 sdvo_reg
== SDVOB
? 'B' : 'C');
2817 /* setup the DDC bus. */
2818 if (sdvo_reg
== SDVOB
) {
2819 intel_encoder
->ddc_bus
= intel_i2c_create(dev
, GPIOE
, "SDVOB DDC BUS");
2820 sdvo_priv
->analog_ddc_bus
= intel_i2c_create(dev
, GPIOA
,
2821 "SDVOB/VGA DDC BUS");
2822 dev_priv
->hotplug_supported_mask
|= SDVOB_HOTPLUG_INT_STATUS
;
2824 intel_encoder
->ddc_bus
= intel_i2c_create(dev
, GPIOE
, "SDVOC DDC BUS");
2825 sdvo_priv
->analog_ddc_bus
= intel_i2c_create(dev
, GPIOA
,
2826 "SDVOC/VGA DDC BUS");
2827 dev_priv
->hotplug_supported_mask
|= SDVOC_HOTPLUG_INT_STATUS
;
2830 if (intel_encoder
->ddc_bus
== NULL
)
2833 /* Wrap with our custom algo which switches to DDC mode */
2834 intel_encoder
->ddc_bus
->algo
= &intel_sdvo_i2c_bit_algo
;
2836 /* In default case sdvo lvds is false */
2837 intel_sdvo_get_capabilities(intel_encoder
, &sdvo_priv
->caps
);
2839 if (intel_sdvo_output_setup(intel_encoder
,
2840 sdvo_priv
->caps
.output_flags
) != true) {
2841 DRM_DEBUG_KMS("SDVO output failed to setup on SDVO%c\n",
2842 sdvo_reg
== SDVOB
? 'B' : 'C');
2847 connector
= &intel_encoder
->base
;
2848 drm_connector_init(dev
, connector
, &intel_sdvo_connector_funcs
,
2849 connector
->connector_type
);
2851 drm_connector_helper_add(connector
, &intel_sdvo_connector_helper_funcs
);
2852 connector
->interlace_allowed
= 0;
2853 connector
->doublescan_allowed
= 0;
2854 connector
->display_info
.subpixel_order
= SubPixelHorizontalRGB
;
2856 drm_encoder_init(dev
, &intel_encoder
->enc
,
2857 &intel_sdvo_enc_funcs
, intel_encoder
->enc
.encoder_type
);
2859 drm_encoder_helper_add(&intel_encoder
->enc
, &intel_sdvo_helper_funcs
);
2861 drm_mode_connector_attach_encoder(&intel_encoder
->base
, &intel_encoder
->enc
);
2862 if (sdvo_priv
->is_tv
)
2863 intel_sdvo_tv_create_property(connector
);
2865 if (sdvo_priv
->is_tv
|| sdvo_priv
->is_lvds
)
2866 intel_sdvo_create_enhance_property(connector
);
2868 drm_sysfs_connector_add(connector
);
2870 intel_sdvo_select_ddc_bus(sdvo_priv
);
2872 /* Set the input timing to the screen. Assume always input 0. */
2873 intel_sdvo_set_target_input(intel_encoder
, true, false);
2875 intel_sdvo_get_input_pixel_clock_range(intel_encoder
,
2876 &sdvo_priv
->pixel_clock_min
,
2877 &sdvo_priv
->pixel_clock_max
);
2880 DRM_DEBUG_KMS("%s device VID/DID: %02X:%02X.%02X, "
2881 "clock range %dMHz - %dMHz, "
2882 "input 1: %c, input 2: %c, "
2883 "output 1: %c, output 2: %c\n",
2884 SDVO_NAME(sdvo_priv
),
2885 sdvo_priv
->caps
.vendor_id
, sdvo_priv
->caps
.device_id
,
2886 sdvo_priv
->caps
.device_rev_id
,
2887 sdvo_priv
->pixel_clock_min
/ 1000,
2888 sdvo_priv
->pixel_clock_max
/ 1000,
2889 (sdvo_priv
->caps
.sdvo_inputs_mask
& 0x1) ? 'Y' : 'N',
2890 (sdvo_priv
->caps
.sdvo_inputs_mask
& 0x2) ? 'Y' : 'N',
2891 /* check currently supported outputs */
2892 sdvo_priv
->caps
.output_flags
&
2893 (SDVO_OUTPUT_TMDS0
| SDVO_OUTPUT_RGB0
) ? 'Y' : 'N',
2894 sdvo_priv
->caps
.output_flags
&
2895 (SDVO_OUTPUT_TMDS1
| SDVO_OUTPUT_RGB1
) ? 'Y' : 'N');
2900 if (sdvo_priv
->analog_ddc_bus
!= NULL
)
2901 intel_i2c_destroy(sdvo_priv
->analog_ddc_bus
);
2902 if (intel_encoder
->ddc_bus
!= NULL
)
2903 intel_i2c_destroy(intel_encoder
->ddc_bus
);
2904 if (intel_encoder
->i2c_bus
!= NULL
)
2905 intel_i2c_destroy(intel_encoder
->i2c_bus
);
2907 kfree(intel_encoder
);