intel_bios.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. /*
  2. * Copyright © 2006 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 FROM,
  20. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  21. * SOFTWARE.
  22. *
  23. * Authors:
  24. * Eric Anholt <eric@anholt.net>
  25. *
  26. */
  27. #ifndef _I830_BIOS_H_
  28. #define _I830_BIOS_H_
  29. #include "drmP.h"
  30. struct vbt_header {
  31. u8 signature[20]; /**< Always starts with 'VBT$' */
  32. u16 version; /**< decimal */
  33. u16 header_size; /**< in bytes */
  34. u16 vbt_size; /**< in bytes */
  35. u8 vbt_checksum;
  36. u8 reserved0;
  37. u32 bdb_offset; /**< from beginning of VBT */
  38. u32 aim_offset[4]; /**< from beginning of VBT */
  39. } __attribute__((packed));
  40. struct bdb_header {
  41. u8 signature[16]; /**< Always 'BIOS_DATA_BLOCK' */
  42. u16 version; /**< decimal */
  43. u16 header_size; /**< in bytes */
  44. u16 bdb_size; /**< in bytes */
  45. };
  46. /* strictly speaking, this is a "skip" block, but it has interesting info */
  47. struct vbios_data {
  48. u8 type; /* 0 == desktop, 1 == mobile */
  49. u8 relstage;
  50. u8 chipset;
  51. u8 lvds_present:1;
  52. u8 tv_present:1;
  53. u8 rsvd2:6; /* finish byte */
  54. u8 rsvd3[4];
  55. u8 signon[155];
  56. u8 copyright[61];
  57. u16 code_segment;
  58. u8 dos_boot_mode;
  59. u8 bandwidth_percent;
  60. u8 rsvd4; /* popup memory size */
  61. u8 resize_pci_bios;
  62. u8 rsvd5; /* is crt already on ddc2 */
  63. } __attribute__((packed));
  64. /*
  65. * There are several types of BIOS data blocks (BDBs), each block has
  66. * an ID and size in the first 3 bytes (ID in first, size in next 2).
  67. * Known types are listed below.
  68. */
  69. #define BDB_GENERAL_FEATURES 1
  70. #define BDB_GENERAL_DEFINITIONS 2
  71. #define BDB_OLD_TOGGLE_LIST 3
  72. #define BDB_MODE_SUPPORT_LIST 4
  73. #define BDB_GENERIC_MODE_TABLE 5
  74. #define BDB_EXT_MMIO_REGS 6
  75. #define BDB_SWF_IO 7
  76. #define BDB_SWF_MMIO 8
  77. #define BDB_DOT_CLOCK_TABLE 9
  78. #define BDB_MODE_REMOVAL_TABLE 10
  79. #define BDB_CHILD_DEVICE_TABLE 11
  80. #define BDB_DRIVER_FEATURES 12
  81. #define BDB_DRIVER_PERSISTENCE 13
  82. #define BDB_EXT_TABLE_PTRS 14
  83. #define BDB_DOT_CLOCK_OVERRIDE 15
  84. #define BDB_DISPLAY_SELECT 16
  85. /* 17 rsvd */
  86. #define BDB_DRIVER_ROTATION 18
  87. #define BDB_DISPLAY_REMOVE 19
  88. #define BDB_OEM_CUSTOM 20
  89. #define BDB_EFP_LIST 21 /* workarounds for VGA hsync/vsync */
  90. #define BDB_SDVO_LVDS_OPTIONS 22
  91. #define BDB_SDVO_PANEL_DTDS 23
  92. #define BDB_SDVO_LVDS_PNP_IDS 24
  93. #define BDB_SDVO_LVDS_POWER_SEQ 25
  94. #define BDB_TV_OPTIONS 26
  95. #define BDB_LVDS_OPTIONS 40
  96. #define BDB_LVDS_LFP_DATA_PTRS 41
  97. #define BDB_LVDS_LFP_DATA 42
  98. #define BDB_LVDS_BACKLIGHT 43
  99. #define BDB_LVDS_POWER 44
  100. #define BDB_SKIP 254 /* VBIOS private block, ignore */
  101. struct bdb_general_features {
  102. /* bits 1 */
  103. u8 panel_fitting:2;
  104. u8 flexaim:1;
  105. u8 msg_enable:1;
  106. u8 clear_screen:3;
  107. u8 color_flip:1;
  108. /* bits 2 */
  109. u8 download_ext_vbt:1;
  110. u8 enable_ssc:1;
  111. u8 ssc_freq:1;
  112. u8 enable_lfp_on_override:1;
  113. u8 disable_ssc_ddt:1;
  114. u8 rsvd8:3; /* finish byte */
  115. /* bits 3 */
  116. u8 disable_smooth_vision:1;
  117. u8 single_dvi:1;
  118. u8 rsvd9:6; /* finish byte */
  119. /* bits 4 */
  120. u8 legacy_monitor_detect;
  121. /* bits 5 */
  122. u8 int_crt_support:1;
  123. u8 int_tv_support:1;
  124. u8 rsvd11:6; /* finish byte */
  125. } __attribute__((packed));
  126. struct bdb_general_definitions {
  127. /* DDC GPIO */
  128. u8 crt_ddc_gmbus_pin;
  129. /* DPMS bits */
  130. u8 dpms_acpi:1;
  131. u8 skip_boot_crt_detect:1;
  132. u8 dpms_aim:1;
  133. u8 rsvd1:5; /* finish byte */
  134. /* boot device bits */
  135. u8 boot_display[2];
  136. u8 child_dev_size;
  137. /* device info */
  138. u8 tv_or_lvds_info[33];
  139. u8 dev1[33];
  140. u8 dev2[33];
  141. u8 dev3[33];
  142. u8 dev4[33];
  143. /* may be another device block here on some platforms */
  144. };
  145. struct bdb_lvds_options {
  146. u8 panel_type;
  147. u8 rsvd1;
  148. /* LVDS capabilities, stored in a dword */
  149. u8 rsvd2:1;
  150. u8 lvds_edid:1;
  151. u8 pixel_dither:1;
  152. u8 pfit_ratio_auto:1;
  153. u8 pfit_gfx_mode_enhanced:1;
  154. u8 pfit_text_mode_enhanced:1;
  155. u8 pfit_mode:2;
  156. u8 rsvd4;
  157. } __attribute__((packed));
  158. /* LFP pointer table contains entries to the struct below */
  159. struct bdb_lvds_lfp_data_ptr {
  160. u16 fp_timing_offset; /* offsets are from start of bdb */
  161. u8 fp_table_size;
  162. u16 dvo_timing_offset;
  163. u8 dvo_table_size;
  164. u16 panel_pnp_id_offset;
  165. u8 pnp_table_size;
  166. } __attribute__((packed));
  167. struct bdb_lvds_lfp_data_ptrs {
  168. u8 lvds_entries; /* followed by one or more lvds_data_ptr structs */
  169. struct bdb_lvds_lfp_data_ptr ptr[16];
  170. } __attribute__((packed));
  171. /* LFP data has 3 blocks per entry */
  172. struct lvds_fp_timing {
  173. u16 x_res;
  174. u16 y_res;
  175. u32 lvds_reg;
  176. u32 lvds_reg_val;
  177. u32 pp_on_reg;
  178. u32 pp_on_reg_val;
  179. u32 pp_off_reg;
  180. u32 pp_off_reg_val;
  181. u32 pp_cycle_reg;
  182. u32 pp_cycle_reg_val;
  183. u32 pfit_reg;
  184. u32 pfit_reg_val;
  185. u16 terminator;
  186. } __attribute__((packed));
  187. struct lvds_dvo_timing {
  188. u16 clock; /**< In 10khz */
  189. u8 hactive_lo;
  190. u8 hblank_lo;
  191. u8 hblank_hi:4;
  192. u8 hactive_hi:4;
  193. u8 vactive_lo;
  194. u8 vblank_lo;
  195. u8 vblank_hi:4;
  196. u8 vactive_hi:4;
  197. u8 hsync_off_lo;
  198. u8 hsync_pulse_width;
  199. u8 vsync_pulse_width:4;
  200. u8 vsync_off:4;
  201. u8 rsvd0:6;
  202. u8 hsync_off_hi:2;
  203. u8 h_image;
  204. u8 v_image;
  205. u8 max_hv;
  206. u8 h_border;
  207. u8 v_border;
  208. u8 rsvd1:3;
  209. u8 digital:2;
  210. u8 vsync_positive:1;
  211. u8 hsync_positive:1;
  212. u8 rsvd2:1;
  213. } __attribute__((packed));
  214. struct lvds_pnp_id {
  215. u16 mfg_name;
  216. u16 product_code;
  217. u32 serial;
  218. u8 mfg_week;
  219. u8 mfg_year;
  220. } __attribute__((packed));
  221. struct bdb_lvds_lfp_data_entry {
  222. struct lvds_fp_timing fp_timing;
  223. struct lvds_dvo_timing dvo_timing;
  224. struct lvds_pnp_id pnp_id;
  225. } __attribute__((packed));
  226. struct bdb_lvds_lfp_data {
  227. struct bdb_lvds_lfp_data_entry data[16];
  228. } __attribute__((packed));
  229. struct aimdb_header {
  230. char signature[16];
  231. char oem_device[20];
  232. u16 aimdb_version;
  233. u16 aimdb_header_size;
  234. u16 aimdb_size;
  235. } __attribute__((packed));
  236. struct aimdb_block {
  237. u8 aimdb_id;
  238. u16 aimdb_size;
  239. } __attribute__((packed));
  240. struct vch_panel_data {
  241. u16 fp_timing_offset;
  242. u8 fp_timing_size;
  243. u16 dvo_timing_offset;
  244. u8 dvo_timing_size;
  245. u16 text_fitting_offset;
  246. u8 text_fitting_size;
  247. u16 graphics_fitting_offset;
  248. u8 graphics_fitting_size;
  249. } __attribute__((packed));
  250. struct vch_bdb_22 {
  251. struct aimdb_block aimdb_block;
  252. struct vch_panel_data panels[16];
  253. } __attribute__((packed));
  254. bool intel_init_bios(struct drm_device *dev);
  255. /*
  256. * Driver<->VBIOS interaction occurs through scratch bits in
  257. * GR18 & SWF*.
  258. */
  259. /* GR18 bits are set on display switch and hotkey events */
  260. #define GR18_DRIVER_SWITCH_EN (1<<7) /* 0: VBIOS control, 1: driver control */
  261. #define GR18_HOTKEY_MASK 0x78 /* See also SWF4 15:0 */
  262. #define GR18_HK_NONE (0x0<<3)
  263. #define GR18_HK_LFP_STRETCH (0x1<<3)
  264. #define GR18_HK_TOGGLE_DISP (0x2<<3)
  265. #define GR18_HK_DISP_SWITCH (0x4<<3) /* see SWF14 15:0 for what to enable */
  266. #define GR18_HK_POPUP_DISABLED (0x6<<3)
  267. #define GR18_HK_POPUP_ENABLED (0x7<<3)
  268. #define GR18_HK_PFIT (0x8<<3)
  269. #define GR18_HK_APM_CHANGE (0xa<<3)
  270. #define GR18_HK_MULTIPLE (0xc<<3)
  271. #define GR18_USER_INT_EN (1<<2)
  272. #define GR18_A0000_FLUSH_EN (1<<1)
  273. #define GR18_SMM_EN (1<<0)
  274. /* Set by driver, cleared by VBIOS */
  275. #define SWF00_YRES_SHIFT 16
  276. #define SWF00_XRES_SHIFT 0
  277. #define SWF00_RES_MASK 0xffff
  278. /* Set by VBIOS at boot time and driver at runtime */
  279. #define SWF01_TV2_FORMAT_SHIFT 8
  280. #define SWF01_TV1_FORMAT_SHIFT 0
  281. #define SWF01_TV_FORMAT_MASK 0xffff
  282. #define SWF10_VBIOS_BLC_I2C_EN (1<<29)
  283. #define SWF10_GTT_OVERRIDE_EN (1<<28)
  284. #define SWF10_LFP_DPMS_OVR (1<<27) /* override DPMS on display switch */
  285. #define SWF10_ACTIVE_TOGGLE_LIST_MASK (7<<24)
  286. #define SWF10_OLD_TOGGLE 0x0
  287. #define SWF10_TOGGLE_LIST_1 0x1
  288. #define SWF10_TOGGLE_LIST_2 0x2
  289. #define SWF10_TOGGLE_LIST_3 0x3
  290. #define SWF10_TOGGLE_LIST_4 0x4
  291. #define SWF10_PANNING_EN (1<<23)
  292. #define SWF10_DRIVER_LOADED (1<<22)
  293. #define SWF10_EXTENDED_DESKTOP (1<<21)
  294. #define SWF10_EXCLUSIVE_MODE (1<<20)
  295. #define SWF10_OVERLAY_EN (1<<19)
  296. #define SWF10_PLANEB_HOLDOFF (1<<18)
  297. #define SWF10_PLANEA_HOLDOFF (1<<17)
  298. #define SWF10_VGA_HOLDOFF (1<<16)
  299. #define SWF10_ACTIVE_DISP_MASK 0xffff
  300. #define SWF10_PIPEB_LFP2 (1<<15)
  301. #define SWF10_PIPEB_EFP2 (1<<14)
  302. #define SWF10_PIPEB_TV2 (1<<13)
  303. #define SWF10_PIPEB_CRT2 (1<<12)
  304. #define SWF10_PIPEB_LFP (1<<11)
  305. #define SWF10_PIPEB_EFP (1<<10)
  306. #define SWF10_PIPEB_TV (1<<9)
  307. #define SWF10_PIPEB_CRT (1<<8)
  308. #define SWF10_PIPEA_LFP2 (1<<7)
  309. #define SWF10_PIPEA_EFP2 (1<<6)
  310. #define SWF10_PIPEA_TV2 (1<<5)
  311. #define SWF10_PIPEA_CRT2 (1<<4)
  312. #define SWF10_PIPEA_LFP (1<<3)
  313. #define SWF10_PIPEA_EFP (1<<2)
  314. #define SWF10_PIPEA_TV (1<<1)
  315. #define SWF10_PIPEA_CRT (1<<0)
  316. #define SWF11_MEMORY_SIZE_SHIFT 16
  317. #define SWF11_SV_TEST_EN (1<<15)
  318. #define SWF11_IS_AGP (1<<14)
  319. #define SWF11_DISPLAY_HOLDOFF (1<<13)
  320. #define SWF11_DPMS_REDUCED (1<<12)
  321. #define SWF11_IS_VBE_MODE (1<<11)
  322. #define SWF11_PIPEB_ACCESS (1<<10) /* 0 here means pipe a */
  323. #define SWF11_DPMS_MASK 0x07
  324. #define SWF11_DPMS_OFF (1<<2)
  325. #define SWF11_DPMS_SUSPEND (1<<1)
  326. #define SWF11_DPMS_STANDBY (1<<0)
  327. #define SWF11_DPMS_ON 0
  328. #define SWF14_GFX_PFIT_EN (1<<31)
  329. #define SWF14_TEXT_PFIT_EN (1<<30)
  330. #define SWF14_LID_STATUS_CLOSED (1<<29) /* 0 here means open */
  331. #define SWF14_POPUP_EN (1<<28)
  332. #define SWF14_DISPLAY_HOLDOFF (1<<27)
  333. #define SWF14_DISP_DETECT_EN (1<<26)
  334. #define SWF14_DOCKING_STATUS_DOCKED (1<<25) /* 0 here means undocked */
  335. #define SWF14_DRIVER_STATUS (1<<24)
  336. #define SWF14_OS_TYPE_WIN9X (1<<23)
  337. #define SWF14_OS_TYPE_WINNT (1<<22)
  338. /* 21:19 rsvd */
  339. #define SWF14_PM_TYPE_MASK 0x00070000
  340. #define SWF14_PM_ACPI_VIDEO (0x4 << 16)
  341. #define SWF14_PM_ACPI (0x3 << 16)
  342. #define SWF14_PM_APM_12 (0x2 << 16)
  343. #define SWF14_PM_APM_11 (0x1 << 16)
  344. #define SWF14_HK_REQUEST_MASK 0x0000ffff /* see GR18 6:3 for event type */
  345. /* if GR18 indicates a display switch */
  346. #define SWF14_DS_PIPEB_LFP2_EN (1<<15)
  347. #define SWF14_DS_PIPEB_EFP2_EN (1<<14)
  348. #define SWF14_DS_PIPEB_TV2_EN (1<<13)
  349. #define SWF14_DS_PIPEB_CRT2_EN (1<<12)
  350. #define SWF14_DS_PIPEB_LFP_EN (1<<11)
  351. #define SWF14_DS_PIPEB_EFP_EN (1<<10)
  352. #define SWF14_DS_PIPEB_TV_EN (1<<9)
  353. #define SWF14_DS_PIPEB_CRT_EN (1<<8)
  354. #define SWF14_DS_PIPEA_LFP2_EN (1<<7)
  355. #define SWF14_DS_PIPEA_EFP2_EN (1<<6)
  356. #define SWF14_DS_PIPEA_TV2_EN (1<<5)
  357. #define SWF14_DS_PIPEA_CRT2_EN (1<<4)
  358. #define SWF14_DS_PIPEA_LFP_EN (1<<3)
  359. #define SWF14_DS_PIPEA_EFP_EN (1<<2)
  360. #define SWF14_DS_PIPEA_TV_EN (1<<1)
  361. #define SWF14_DS_PIPEA_CRT_EN (1<<0)
  362. /* if GR18 indicates a panel fitting request */
  363. #define SWF14_PFIT_EN (1<<0) /* 0 means disable */
  364. /* if GR18 indicates an APM change request */
  365. #define SWF14_APM_HIBERNATE 0x4
  366. #define SWF14_APM_SUSPEND 0x3
  367. #define SWF14_APM_STANDBY 0x1
  368. #define SWF14_APM_RESTORE 0x0
  369. #endif /* _I830_BIOS_H_ */