intel_sdvo_regs.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. /*
  2. * Copyright © 2006-2007 Intel Corporation
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice (including the next
  12. * paragraph) shall be included in all copies or substantial portions of the
  13. * Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  18. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  21. * DEALINGS IN THE SOFTWARE.
  22. *
  23. * Authors:
  24. * Eric Anholt <eric@anholt.net>
  25. */
  26. /**
  27. * @file SDVO command definitions and structures.
  28. */
  29. #define SDVO_OUTPUT_FIRST (0)
  30. #define SDVO_OUTPUT_TMDS0 (1 << 0)
  31. #define SDVO_OUTPUT_RGB0 (1 << 1)
  32. #define SDVO_OUTPUT_CVBS0 (1 << 2)
  33. #define SDVO_OUTPUT_SVID0 (1 << 3)
  34. #define SDVO_OUTPUT_YPRPB0 (1 << 4)
  35. #define SDVO_OUTPUT_SCART0 (1 << 5)
  36. #define SDVO_OUTPUT_LVDS0 (1 << 6)
  37. #define SDVO_OUTPUT_TMDS1 (1 << 8)
  38. #define SDVO_OUTPUT_RGB1 (1 << 9)
  39. #define SDVO_OUTPUT_CVBS1 (1 << 10)
  40. #define SDVO_OUTPUT_SVID1 (1 << 11)
  41. #define SDVO_OUTPUT_YPRPB1 (1 << 12)
  42. #define SDVO_OUTPUT_SCART1 (1 << 13)
  43. #define SDVO_OUTPUT_LVDS1 (1 << 14)
  44. #define SDVO_OUTPUT_LAST (14)
  45. struct intel_sdvo_caps {
  46. u8 vendor_id;
  47. u8 device_id;
  48. u8 device_rev_id;
  49. u8 sdvo_version_major;
  50. u8 sdvo_version_minor;
  51. unsigned int sdvo_inputs_mask:2;
  52. unsigned int smooth_scaling:1;
  53. unsigned int sharp_scaling:1;
  54. unsigned int up_scaling:1;
  55. unsigned int down_scaling:1;
  56. unsigned int stall_support:1;
  57. unsigned int pad:1;
  58. u16 output_flags;
  59. } __attribute__((packed));
  60. /** This matches the EDID DTD structure, more or less */
  61. struct intel_sdvo_dtd {
  62. struct {
  63. u16 clock; /**< pixel clock, in 10kHz units */
  64. u8 h_active; /**< lower 8 bits (pixels) */
  65. u8 h_blank; /**< lower 8 bits (pixels) */
  66. u8 h_high; /**< upper 4 bits each h_active, h_blank */
  67. u8 v_active; /**< lower 8 bits (lines) */
  68. u8 v_blank; /**< lower 8 bits (lines) */
  69. u8 v_high; /**< upper 4 bits each v_active, v_blank */
  70. } part1;
  71. struct {
  72. u8 h_sync_off; /**< lower 8 bits, from hblank start */
  73. u8 h_sync_width; /**< lower 8 bits (pixels) */
  74. /** lower 4 bits each vsync offset, vsync width */
  75. u8 v_sync_off_width;
  76. /**
  77. * 2 high bits of hsync offset, 2 high bits of hsync width,
  78. * bits 4-5 of vsync offset, and 2 high bits of vsync width.
  79. */
  80. u8 sync_off_width_high;
  81. u8 dtd_flags;
  82. u8 sdvo_flags;
  83. /** bits 6-7 of vsync offset at bits 6-7 */
  84. u8 v_sync_off_high;
  85. u8 reserved;
  86. } part2;
  87. } __attribute__((packed));
  88. struct intel_sdvo_pixel_clock_range {
  89. u16 min; /**< pixel clock, in 10kHz units */
  90. u16 max; /**< pixel clock, in 10kHz units */
  91. } __attribute__((packed));
  92. struct intel_sdvo_preferred_input_timing_args {
  93. u16 clock;
  94. u16 width;
  95. u16 height;
  96. } __attribute__((packed));
  97. /* I2C registers for SDVO */
  98. #define SDVO_I2C_ARG_0 0x07
  99. #define SDVO_I2C_ARG_1 0x06
  100. #define SDVO_I2C_ARG_2 0x05
  101. #define SDVO_I2C_ARG_3 0x04
  102. #define SDVO_I2C_ARG_4 0x03
  103. #define SDVO_I2C_ARG_5 0x02
  104. #define SDVO_I2C_ARG_6 0x01
  105. #define SDVO_I2C_ARG_7 0x00
  106. #define SDVO_I2C_OPCODE 0x08
  107. #define SDVO_I2C_CMD_STATUS 0x09
  108. #define SDVO_I2C_RETURN_0 0x0a
  109. #define SDVO_I2C_RETURN_1 0x0b
  110. #define SDVO_I2C_RETURN_2 0x0c
  111. #define SDVO_I2C_RETURN_3 0x0d
  112. #define SDVO_I2C_RETURN_4 0x0e
  113. #define SDVO_I2C_RETURN_5 0x0f
  114. #define SDVO_I2C_RETURN_6 0x10
  115. #define SDVO_I2C_RETURN_7 0x11
  116. #define SDVO_I2C_VENDOR_BEGIN 0x20
  117. /* Status results */
  118. #define SDVO_CMD_STATUS_POWER_ON 0x0
  119. #define SDVO_CMD_STATUS_SUCCESS 0x1
  120. #define SDVO_CMD_STATUS_NOTSUPP 0x2
  121. #define SDVO_CMD_STATUS_INVALID_ARG 0x3
  122. #define SDVO_CMD_STATUS_PENDING 0x4
  123. #define SDVO_CMD_STATUS_TARGET_NOT_SPECIFIED 0x5
  124. #define SDVO_CMD_STATUS_SCALING_NOT_SUPP 0x6
  125. /* SDVO commands, argument/result registers */
  126. #define SDVO_CMD_RESET 0x01
  127. /** Returns a struct intel_sdvo_caps */
  128. #define SDVO_CMD_GET_DEVICE_CAPS 0x02
  129. #define SDVO_CMD_GET_FIRMWARE_REV 0x86
  130. # define SDVO_DEVICE_FIRMWARE_MINOR SDVO_I2C_RETURN_0
  131. # define SDVO_DEVICE_FIRMWARE_MAJOR SDVO_I2C_RETURN_1
  132. # define SDVO_DEVICE_FIRMWARE_PATCH SDVO_I2C_RETURN_2
  133. /**
  134. * Reports which inputs are trained (managed to sync).
  135. *
  136. * Devices must have trained within 2 vsyncs of a mode change.
  137. */
  138. #define SDVO_CMD_GET_TRAINED_INPUTS 0x03
  139. struct intel_sdvo_get_trained_inputs_response {
  140. unsigned int input0_trained:1;
  141. unsigned int input1_trained:1;
  142. unsigned int pad:6;
  143. } __attribute__((packed));
  144. /** Returns a struct intel_sdvo_output_flags of active outputs. */
  145. #define SDVO_CMD_GET_ACTIVE_OUTPUTS 0x04
  146. /**
  147. * Sets the current set of active outputs.
  148. *
  149. * Takes a struct intel_sdvo_output_flags. Must be preceded by a SET_IN_OUT_MAP
  150. * on multi-output devices.
  151. */
  152. #define SDVO_CMD_SET_ACTIVE_OUTPUTS 0x05
  153. /**
  154. * Returns the current mapping of SDVO inputs to outputs on the device.
  155. *
  156. * Returns two struct intel_sdvo_output_flags structures.
  157. */
  158. #define SDVO_CMD_GET_IN_OUT_MAP 0x06
  159. /**
  160. * Sets the current mapping of SDVO inputs to outputs on the device.
  161. *
  162. * Takes two struct i380_sdvo_output_flags structures.
  163. */
  164. #define SDVO_CMD_SET_IN_OUT_MAP 0x07
  165. /**
  166. * Returns a struct intel_sdvo_output_flags of attached displays.
  167. */
  168. #define SDVO_CMD_GET_ATTACHED_DISPLAYS 0x0b
  169. /**
  170. * Returns a struct intel_sdvo_ouptut_flags of displays supporting hot plugging.
  171. */
  172. #define SDVO_CMD_GET_HOT_PLUG_SUPPORT 0x0c
  173. /**
  174. * Takes a struct intel_sdvo_output_flags.
  175. */
  176. #define SDVO_CMD_SET_ACTIVE_HOT_PLUG 0x0d
  177. /**
  178. * Returns a struct intel_sdvo_output_flags of displays with hot plug
  179. * interrupts enabled.
  180. */
  181. #define SDVO_CMD_GET_ACTIVE_HOT_PLUG 0x0e
  182. #define SDVO_CMD_GET_INTERRUPT_EVENT_SOURCE 0x0f
  183. struct intel_sdvo_get_interrupt_event_source_response {
  184. u16 interrupt_status;
  185. unsigned int ambient_light_interrupt:1;
  186. unsigned int pad:7;
  187. } __attribute__((packed));
  188. /**
  189. * Selects which input is affected by future input commands.
  190. *
  191. * Commands affected include SET_INPUT_TIMINGS_PART[12],
  192. * GET_INPUT_TIMINGS_PART[12], GET_PREFERRED_INPUT_TIMINGS_PART[12],
  193. * GET_INPUT_PIXEL_CLOCK_RANGE, and CREATE_PREFERRED_INPUT_TIMINGS.
  194. */
  195. #define SDVO_CMD_SET_TARGET_INPUT 0x10
  196. struct intel_sdvo_set_target_input_args {
  197. unsigned int target_1:1;
  198. unsigned int pad:7;
  199. } __attribute__((packed));
  200. /**
  201. * Takes a struct intel_sdvo_output_flags of which outputs are targetted by
  202. * future output commands.
  203. *
  204. * Affected commands inclue SET_OUTPUT_TIMINGS_PART[12],
  205. * GET_OUTPUT_TIMINGS_PART[12], and GET_OUTPUT_PIXEL_CLOCK_RANGE.
  206. */
  207. #define SDVO_CMD_SET_TARGET_OUTPUT 0x11
  208. #define SDVO_CMD_GET_INPUT_TIMINGS_PART1 0x12
  209. #define SDVO_CMD_GET_INPUT_TIMINGS_PART2 0x13
  210. #define SDVO_CMD_SET_INPUT_TIMINGS_PART1 0x14
  211. #define SDVO_CMD_SET_INPUT_TIMINGS_PART2 0x15
  212. #define SDVO_CMD_SET_OUTPUT_TIMINGS_PART1 0x16
  213. #define SDVO_CMD_SET_OUTPUT_TIMINGS_PART2 0x17
  214. #define SDVO_CMD_GET_OUTPUT_TIMINGS_PART1 0x18
  215. #define SDVO_CMD_GET_OUTPUT_TIMINGS_PART2 0x19
  216. /* Part 1 */
  217. # define SDVO_DTD_CLOCK_LOW SDVO_I2C_ARG_0
  218. # define SDVO_DTD_CLOCK_HIGH SDVO_I2C_ARG_1
  219. # define SDVO_DTD_H_ACTIVE SDVO_I2C_ARG_2
  220. # define SDVO_DTD_H_BLANK SDVO_I2C_ARG_3
  221. # define SDVO_DTD_H_HIGH SDVO_I2C_ARG_4
  222. # define SDVO_DTD_V_ACTIVE SDVO_I2C_ARG_5
  223. # define SDVO_DTD_V_BLANK SDVO_I2C_ARG_6
  224. # define SDVO_DTD_V_HIGH SDVO_I2C_ARG_7
  225. /* Part 2 */
  226. # define SDVO_DTD_HSYNC_OFF SDVO_I2C_ARG_0
  227. # define SDVO_DTD_HSYNC_WIDTH SDVO_I2C_ARG_1
  228. # define SDVO_DTD_VSYNC_OFF_WIDTH SDVO_I2C_ARG_2
  229. # define SDVO_DTD_SYNC_OFF_WIDTH_HIGH SDVO_I2C_ARG_3
  230. # define SDVO_DTD_DTD_FLAGS SDVO_I2C_ARG_4
  231. # define SDVO_DTD_DTD_FLAG_INTERLACED (1 << 7)
  232. # define SDVO_DTD_DTD_FLAG_STEREO_MASK (3 << 5)
  233. # define SDVO_DTD_DTD_FLAG_INPUT_MASK (3 << 3)
  234. # define SDVO_DTD_DTD_FLAG_SYNC_MASK (3 << 1)
  235. # define SDVO_DTD_SDVO_FLAS SDVO_I2C_ARG_5
  236. # define SDVO_DTD_SDVO_FLAG_STALL (1 << 7)
  237. # define SDVO_DTD_SDVO_FLAG_CENTERED (0 << 6)
  238. # define SDVO_DTD_SDVO_FLAG_UPPER_LEFT (1 << 6)
  239. # define SDVO_DTD_SDVO_FLAG_SCALING_MASK (3 << 4)
  240. # define SDVO_DTD_SDVO_FLAG_SCALING_NONE (0 << 4)
  241. # define SDVO_DTD_SDVO_FLAG_SCALING_SHARP (1 << 4)
  242. # define SDVO_DTD_SDVO_FLAG_SCALING_SMOOTH (2 << 4)
  243. # define SDVO_DTD_VSYNC_OFF_HIGH SDVO_I2C_ARG_6
  244. /**
  245. * Generates a DTD based on the given width, height, and flags.
  246. *
  247. * This will be supported by any device supporting scaling or interlaced
  248. * modes.
  249. */
  250. #define SDVO_CMD_CREATE_PREFERRED_INPUT_TIMING 0x1a
  251. # define SDVO_PREFERRED_INPUT_TIMING_CLOCK_LOW SDVO_I2C_ARG_0
  252. # define SDVO_PREFERRED_INPUT_TIMING_CLOCK_HIGH SDVO_I2C_ARG_1
  253. # define SDVO_PREFERRED_INPUT_TIMING_WIDTH_LOW SDVO_I2C_ARG_2
  254. # define SDVO_PREFERRED_INPUT_TIMING_WIDTH_HIGH SDVO_I2C_ARG_3
  255. # define SDVO_PREFERRED_INPUT_TIMING_HEIGHT_LOW SDVO_I2C_ARG_4
  256. # define SDVO_PREFERRED_INPUT_TIMING_HEIGHT_HIGH SDVO_I2C_ARG_5
  257. # define SDVO_PREFERRED_INPUT_TIMING_FLAGS SDVO_I2C_ARG_6
  258. # define SDVO_PREFERRED_INPUT_TIMING_FLAGS_INTERLACED (1 << 0)
  259. # define SDVO_PREFERRED_INPUT_TIMING_FLAGS_SCALED (1 << 1)
  260. #define SDVO_CMD_GET_PREFERRED_INPUT_TIMING_PART1 0x1b
  261. #define SDVO_CMD_GET_PREFERRED_INPUT_TIMING_PART2 0x1c
  262. /** Returns a struct intel_sdvo_pixel_clock_range */
  263. #define SDVO_CMD_GET_INPUT_PIXEL_CLOCK_RANGE 0x1d
  264. /** Returns a struct intel_sdvo_pixel_clock_range */
  265. #define SDVO_CMD_GET_OUTPUT_PIXEL_CLOCK_RANGE 0x1e
  266. /** Returns a byte bitfield containing SDVO_CLOCK_RATE_MULT_* flags */
  267. #define SDVO_CMD_GET_SUPPORTED_CLOCK_RATE_MULTS 0x1f
  268. /** Returns a byte containing a SDVO_CLOCK_RATE_MULT_* flag */
  269. #define SDVO_CMD_GET_CLOCK_RATE_MULT 0x20
  270. /** Takes a byte containing a SDVO_CLOCK_RATE_MULT_* flag */
  271. #define SDVO_CMD_SET_CLOCK_RATE_MULT 0x21
  272. # define SDVO_CLOCK_RATE_MULT_1X (1 << 0)
  273. # define SDVO_CLOCK_RATE_MULT_2X (1 << 1)
  274. # define SDVO_CLOCK_RATE_MULT_4X (1 << 3)
  275. #define SDVO_CMD_GET_SUPPORTED_TV_FORMATS 0x27
  276. #define SDVO_CMD_GET_TV_FORMAT 0x28
  277. #define SDVO_CMD_SET_TV_FORMAT 0x29
  278. #define SDVO_CMD_GET_SUPPORTED_POWER_STATES 0x2a
  279. #define SDVO_CMD_GET_ENCODER_POWER_STATE 0x2b
  280. #define SDVO_CMD_SET_ENCODER_POWER_STATE 0x2c
  281. # define SDVO_ENCODER_STATE_ON (1 << 0)
  282. # define SDVO_ENCODER_STATE_STANDBY (1 << 1)
  283. # define SDVO_ENCODER_STATE_SUSPEND (1 << 2)
  284. # define SDVO_ENCODER_STATE_OFF (1 << 3)
  285. #define SDVO_CMD_SET_TV_RESOLUTION_SUPPORT 0x93
  286. #define SDVO_CMD_SET_CONTROL_BUS_SWITCH 0x7a
  287. # define SDVO_CONTROL_BUS_PROM 0x0
  288. # define SDVO_CONTROL_BUS_DDC1 0x1
  289. # define SDVO_CONTROL_BUS_DDC2 0x2
  290. # define SDVO_CONTROL_BUS_DDC3 0x3