2 *-----------------------------------------------------------------------------
3 * Filename: sdvo_intf.h
5 *-----------------------------------------------------------------------------
6 * Copyright (c) 2002-2010, Intel Corporation.
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26 *-----------------------------------------------------------------------------
28 * Definitions for SDVO interface
29 *-----------------------------------------------------------------------------
35 /* ......................................................................... */
36 /* Opcode, Status Code, Register definitions */
41 GET_DEVICE_CAPABILITIES,
50 GET_ATTACHED_DISPLAYS = 0x0B,
53 GET_HOT_PLUG_SUPPORT = 0x0C,
56 GET_INTERRUPT_EVENT_SOURCE,
58 /* Input/Output Timings */
59 SET_TARGET_INPUT = 0x10,
61 GET_INPUT_TIMINGS_PART1,
62 GET_INPUT_TIMINGS_PART2,
63 SET_INPUT_TIMINGS_PART1,
64 SET_INPUT_TIMINGS_PART2,
65 SET_OUTPUT_TIMINGS_PART1,
66 SET_OUTPUT_TIMINGS_PART2,
67 GET_OUTPUT_TIMINGS_PART1,
68 GET_OUTPUT_TIMINGS_PART2,
69 CREATE_PREFERRED_INPUT_TIMINGS,
70 GET_PREFERRED_INPUT_TIMINGS_PART1,
71 GET_PREFERRED_INPUT_TIMINGS_PART2,
72 GET_INPUT_PIXEL_CLOCK_RANGE,
73 GET_OUTPUT_PIXEL_CLOCK_RANGE,
74 GET_SUPPORTED_SDVO_CLOCK_RATE_MULTIPLIERS,
75 GET_SDVO_CLOCK_RATE_MULTIPLIER,
76 SET_SDVO_CLOCK_RATE_MULTIPLIER,
78 GET_SUPPORTED_TV_OUTPUT_FORMATS = 0x27,
82 /* Power Management */
83 GET_SUPPORTED_POWER_STATES = 0x2A,
87 /* Panel Power Sequencing */
88 GET_MAX_PANEL_POWER_SEQUENCING_PARAMETER = 0x2D,
89 GET_PANEL_POWER_SEQUENCING_PARAMETER,
90 SET_PANEL_POWER_SEQUENCING_PARAMETER,
92 GET_MAX_BACKLIGHT_LEVEL,
99 SET_UPSCALAR_COEFFICIENTS = 0x36,
104 /* Content Protection */
105 GET_ANCILLARY_VIDEO_INFORMATION,
106 SET_ANCILLARY_VIDEO_INFORMATION,
108 /* Picture Enhancements */
109 GET_MAX_FLICKER_FILTER = 0x4D,
113 GET_ADAPTIVE_FLICKER_FILTER,
114 SET_ADAPTIVE_FLICKER_FILTER,
116 GET_MAX_2D_FLICKER_FILTER,
117 GET_2D_FLICKER_FILTER,
118 SET_2D_FLICKER_FILTER,
136 GET_MAX_HORIZONTAL_OVERSCAN,
137 GET_HORIZONTAL_OVERSCAN,
138 SET_HORIZONTAL_OVERSCAN,
140 GET_MAX_VERTICAL_OVERSCAN,
141 GET_VERTICAL_OVERSCAN,
142 SET_VERTICAL_OVERSCAN,
144 GET_MAX_HORIZONTAL_POSITION,
145 GET_HORIZONTAL_POSITION,
146 SET_HORIZONTAL_POSITION,
148 GET_MAX_VERTICAL_POSITION,
149 GET_VERTICAL_POSITION,
150 SET_VERTICAL_POSITION,
162 GET_MAX_TV_CHROMA_FILTER,
163 GET_TV_CHROMA_FILTER,
164 SET_TV_CHROMA_FILTER,
166 GET_MAX_TV_LUMA_FILTER,
170 /* Control Bus Switch */
171 SET_CONTROL_BUS_SWITCH = 0x7A,
173 /* Picture Enhancements */
174 GET_MAX_ADAPTIVE_FLICKER_FILTER = 0x7B,
176 /* Power Management */
177 SET_DISPLAY_POWER_STATE = 0x7D,
179 /* Panel Power Sequencing */
181 GET_LVDS_PANEL_INFORMATION,
182 SET_LVDS_PANEL_INFORMATION,
183 GET_LVDS_PANEL_PROTECTION,
184 SET_LVDS_PANEL_PROTECTION,
186 GET_SDTV_RESOLUTION_SUPPORT = 0x83,
187 GET_SUPPORTED_ENHANCEMENTS,
188 GET_SCALED_HDTV_RESOLUTION_SUPPORT,
191 GET_FIRMWARE_VERSION = 0x86,
192 DETECT_LEGACY_VGA = 0x87,
195 PREPARE_TO_GENERATE_HDCPAN = 0x8A,
196 SET_PIXEL_REPLICATION = 0x8B,
197 GET_PIXEL_REPLICATION,
198 GET_COLORIMETRY_CAPABILITIES,
199 SET_CURRENT_COLORIMETRY,
200 GET_CURRENT_COLORIMETRY,
201 GET_AUDIO_ENCRYPTION_PREFERENCE,
204 SET_HDMI_BUFFER_INDEX,
205 GET_HDMI_BUFFER_INDEX,
206 GET_HDMI_BUFFER_INFO,
207 SET_HDMI_BUFFER_AUDIO_VIDEO_SPLIT,
208 GET_HDMI_BUFFER_AUDIO_VIDEO_SPLIT,
209 SET_HDMI_BUFFER_DATA,
210 GET_HDMI_BUFFER_DATA,
211 SET_HDMI_BUFFER_TRANSMIT_RATE,
212 GET_HDMI_BUFFER_TRANSMIT_RATE,
213 GET_HDMI_AUDIO_TRANSMISSION_CHARACTERISTICS,
214 GET_SUPPORTED_DIGITAL_ENCODING_MODES, /* 0x9D, */
215 GET_DIGITAL_ENCODING_MODE,
216 SET_DIGITAL_ENCODING_MODE,
220 SS_POWER_ON_STATE, /* 00: */
221 SS_SUCCESS, /* 01: Command successfully completed */
222 SS_NOT_SUPPORTED, /* 02: Invalid Opcode */
223 SS_INVALID_ARGUMENT, /* 03: Opcode is valid but arguments are not */
224 SS_PENDING, /* 04: Opcode is not completed yet */
225 SS_TARGET_UNSPECIFIED, /* 05: SetTargetInput/Output not called */
226 SS_SCALING_UNSUPPORTED, /* 06: Device does not support scaling */
229 SS_UNSUCCESSFUL = 10, /* 10: General Failure */
230 SS_INVALID_RETURN, /* 11: Unexpected return value */
231 SS_WRITE_FAILED, /* 12: Write Operation failed */
232 SS_READ_FAILED, /* 13: Read Operation failed */
235 #define SDVO_MAX_ARGS 8
236 #define SDVO_MAX_RETURNS 8
238 #define SDVO_REG_ARG_START 0x07
239 #define SDVO_REG_ARG_END 0x00
240 #define SDVO_REG_OPCODE 0x08
241 #define SDVO_REG_STATUS 0x09
242 #define SDVO_REG_RETURN_START 0x0A
243 #define SDVO_REG_RETURN_END 0x11
245 #define SDVO_MAX_RETRIES 3
247 /* ........................................................................ */
248 /* Structure definitions for Commands */
250 typedef unsigned char i2c_reg_t;
252 /* SDVOOutputFlagStructure Byte 0 */
262 } sdvo_display_output_t;
265 #define FP_DISP_MASK (BIT(0)|BIT(6)|BIT(7)|BIT(8)|BIT(14)) /*TMDS/LVDS/DRGB*/
266 #define TV_DISP_MASK (BIT(2)|BIT(3)|BIT(4)|BIT(5)) /*CVBS0/SVID0/YPRPB0/SCART0*/
267 #define CRT_EXT_DISP_MASK (BIT(1)|BIT(9)) /* External CRT */
268 #define LVDS_DISP_MASK (BIT(6)|BIT(14)) /* LVDS */
269 #define TMDS_DISP_MASK (BIT(0)|BIT(8))
270 #define TV_SVIDEO_DISP_MASK (BIT(3)) /* S-VIDEO */
271 #define TV_YPBPR_DISP_MASK (BIT(4)) /* YPBPR/Yipper */
272 #define DRGB_DISP_MASK (BIT(7)) /* DRGB0 */
276 sdvo_display_output_t out0;
277 sdvo_display_output_t out1;
279 unsigned short flags;
281 } sdvo_output_flags_t;
284 i2c_reg_t vendor_id; /* 00: Vendor ID */
285 i2c_reg_t device_id; /* 01: Device ID */
286 i2c_reg_t revision_id; /* 02: Revision ID */
287 i2c_reg_t version_minor; /* 03 : sDVO Minor Version (00) */
288 i2c_reg_t version_major; /* 04 : sDVO Major Version (01) */
289 /* 05 : Device capabilities */
290 i2c_reg_t num_inputs :2; /* 10 : Number of sDVO inputs (1 or 2) */
291 i2c_reg_t smooth_scaling:1; /* 2 : Smooth (Graphics) Scaling */
292 i2c_reg_t sharp_scaling :1; /* 3 : Sharp (Text) scaling */
293 i2c_reg_t up_scaling :1; /* 4 : Up Scaling */
294 i2c_reg_t down_scaling :1; /* 5 : Down Scaling */
295 i2c_reg_t stall :1; /* 6 : Stall */
296 i2c_reg_t reserved :1; /* 7 : Reserved */
297 sdvo_output_flags_t output; /* 06&07: Ouput supported by sDVO device */
298 } sdvo_device_capabilities_t;
301 unsigned short pixel_clock; /* Pixel clock / 10,000 */
302 unsigned short active_horz_pixels; /* 12 bits of horizontal active */
303 unsigned short active_vert_pixels; /* 12 bits of vertical active */
304 unsigned char b_interlaced :1; /* 1:Interlaced, 0: Non-Interlaced */
305 unsigned char b_scaled :1; /* 1:Image to be scaled, 0:Otherwise*/
306 unsigned char resv_bits :6; /* Reserved bits */
307 unsigned char resv_byte;
308 } sdvo_create_preferred_timings_t;
314 } sdvo_clock_rate_mult_t;
316 /* Detailed Timing Descriptor */
318 unsigned short pixel_clock; /* Pixel Clock / 10,000 */
319 unsigned short horz_active; /* Horizontal Active */
320 unsigned short horz_blanking; /* Horizontal Blanking */
321 unsigned short vert_active; /* Vertical Active */
322 unsigned short vert_blanking; /* Vertical Blanking */
323 unsigned short horz_sync_offset; /* Pixels from blanking start */
324 unsigned short horz_sync_pulse_width;
325 unsigned char vert_sync_offset;
326 unsigned char vert_sync_pulse_width;
327 unsigned char dtd_flags;
328 unsigned char sdvo_flags;
334 } sdvo_target_input_t;
337 i2c_reg_t dev_D0 :1; /* SDVO On */
340 i2c_reg_t dev_D3 :1; /* SDVO Off */
341 i2c_reg_t disp_D0:1; /* Display On : Vsync/Hsync/Video Active */
342 i2c_reg_t disp_D1:1; /* Display Standby : Vsync Active, Hsync/Video Off */
343 i2c_reg_t disp_D2:1; /* Display Suspend : Hsync Active, Vsync/Video Off */
344 i2c_reg_t disp_D3:1; /* Display Off : All signals Off */
345 } sdvo_power_states_t;
349 i2c_reg_t minor_DVI_rev :4;
350 i2c_reg_t major_DVI_rev :4;
353 i2c_reg_t minor_HDMI_rev:4;
354 i2c_reg_t major_HDMI_rev:4;
357 i2c_reg_t reserved[6]; /* reserved for future use */
358 } sdvo_digital_encode_modes_t;
361 sdvo_digital_encode_modes_t version;
362 }sdvo_hdmi_context_t;
365 typedef struct _sdvo_device_context {
366 sdvo_target_input_t inp_dev;
367 sdvo_output_flags_t out_type;
368 sdvo_device_capabilities_t dev_cap;
369 pd_callback_t *p_callback;
370 pd_attr_t *p_attr_table;
371 unsigned long num_attrs;
372 pd_timing_t *p_mode_table;
373 pd_timing_t *native_dtd;
374 unsigned short fp_width;
375 unsigned short fp_height;
376 unsigned char supp_pwr_states;
377 unsigned char device_pwr_state, display_pwr_state;
378 unsigned char up_scaling;
379 unsigned short t1; /* power state delays */
380 unsigned short t2; /* power state delays */
381 unsigned short t3; /* power state delays */
384 unsigned short text_tune;
385 sdvo_hdmi_context_t hdmi;
386 unsigned short st_sdvo;
387 } sdvo_device_context_t;
389 typedef struct sdvo_state {
390 unsigned long power_state;
394 /* ......................................................................... */
395 sdvo_status_t sdvo_execute_command(sdvo_device_context_t *p_ctx,
396 sdvo_opcode_t opcode,
397 i2c_reg_t num_args, i2c_reg_t *p_arg,
398 i2c_reg_t num_returns, i2c_reg_t *p_ret_value);
400 sdvo_status_t sdvo_reset(sdvo_device_context_t *p_ctx);
401 sdvo_status_t sdvo_get_device_capabilities(sdvo_device_context_t *p_ctx,
402 sdvo_device_capabilities_t *p_Dev_Cap);
403 sdvo_status_t sdvo_get_trained_inputs(sdvo_device_context_t *p_ctx,
405 sdvo_status_t sdvo_get_active_outputs(sdvo_device_context_t *p_ctx,
406 sdvo_output_flags_t *p_Out_Flags);
407 sdvo_status_t sdvo_set_active_outputs(sdvo_device_context_t *p_ctx,
408 sdvo_output_flags_t out_flags);
410 sdvo_status_t sdvo_get_in_out_map(sdvo_device_context_t *p_ctx,
411 sdvo_output_flags_t out_flags[2]);
412 sdvo_status_t sdvo_set_in_out_map(sdvo_device_context_t *p_ctx,
413 sdvo_output_flags_t out_flags[2]);
414 sdvo_status_t sdvo_set_upscalar_coefficient(sdvo_device_context_t *p_ctx,
415 i2c_reg_t upscalar_coefficient);
417 sdvo_status_t sdvo_get_attached_displays(sdvo_device_context_t *p_ctx,
418 sdvo_output_flags_t *p_Out_Flags);
420 sdvo_status_t sdvo_set_target_input(sdvo_device_context_t *p_ctx,
421 sdvo_target_input_t input);
422 sdvo_status_t sdvo_set_target_output(sdvo_device_context_t *p_ctx,
423 sdvo_output_flags_t out_flags);
425 sdvo_status_t sdvo_get_input_timings(sdvo_device_context_t *p_ctx,
427 sdvo_status_t sdvo_set_input_timings(sdvo_device_context_t *p_ctx,
430 sdvo_status_t sdvo_get_output_timings(sdvo_device_context_t *p_ctx,
432 sdvo_status_t sdvo_set_output_timings(sdvo_device_context_t *p_ctx,
435 sdvo_status_t sdvo_get_input_pixel_clock_range(sdvo_device_context_t *p_ctx,
436 unsigned short p_Pixel[2]);
438 sdvo_status_t sdvo_get_preferred_input_timings(sdvo_device_context_t *p_ctx,
439 sdvo_create_preferred_timings_t *p_Timings,
441 sdvo_status_t sdvo_get_clock_rate_multiplier(sdvo_device_context_t *p_ctx,
442 sdvo_clock_rate_mult_t *p_mult);
443 sdvo_status_t sdvo_set_clock_rate_multiplier(sdvo_device_context_t *p_ctx,
444 sdvo_clock_rate_mult_t mult);
446 sdvo_status_t sdvo_get_supported_power_states(sdvo_device_context_t *p_ctx,
447 i2c_reg_t *p_pwr_state);
448 sdvo_status_t sdvo_get_power_state(sdvo_device_context_t *p_ctx,
449 i2c_reg_t *p_Power_State);
450 sdvo_status_t sdvo_set_power_state(sdvo_device_context_t *p_ctx,
451 i2c_reg_t pwr_state);
452 sdvo_status_t sdvo_set_display_power_state(sdvo_device_context_t *p_ctx,
453 i2c_reg_t display_state);
454 #if !defined(CONFIG_MICRO) /* These are not used in vBIOS */
455 sdvo_status_t sdvo_set_digital_encoding_mode(sdvo_device_context_t *p_ctx,
456 i2c_reg_t digital_encoding_mode);
457 sdvo_status_t sdvo_get_hdmi_audio_transmission_char(
458 sdvo_device_context_t *p_ctx, i2c_reg_t *hdmi_reg);
459 sdvo_status_t sdvo_get_supported_encoding_modes(sdvo_device_context_t *p_ctx,
460 sdvo_digital_encode_modes_t *digital_encoding_modes);
461 sdvo_status_t sdvo_get_digital_encoding_mode(sdvo_device_context_t *p_ctx,
462 i2c_reg_t *digital_encoding_mode);
463 /* ------------------------------------------------------------------------- */
465 sdvo_status_t sdvo_get_min_max_pixel_clock(sdvo_device_context_t *p_ctx,
466 unsigned long *p_min_clock, unsigned long *p_max_clock);
468 sdvo_status_t sdvo_get_tv_output_format(sdvo_device_context_t *p_ctx,
469 i2c_reg_t *p_TV_Output_Format_Flag);
471 sdvo_status_t sdvo_get_sdtv_resolution_support(sdvo_device_context_t *p_ctx,
472 i2c_reg_t *p_Requested_SDTV_Format_Flag, i2c_reg_t *p_Resolution_Support_Flags);
474 sdvo_status_t sdvo_get_scaled_hdtv_resolution_support(
475 sdvo_device_context_t *p_ctx, i2c_reg_t *p_Requested_HDTV_Format_Flag,
476 i2c_reg_t *p_Resolution_Support_Flags);
478 sdvo_status_t sdvo_execute_command_read(sdvo_device_context_t *p_ctx,
479 i2c_reg_t num_returns, i2c_reg_t *p_ret_value);
481 #endif /* _SDVO_INTF_H_ */