nouveau_bios.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. /*
  2. * Copyright 2007-2008 Nouveau Project
  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. #ifndef __NOUVEAU_BIOS_H__
  24. #define __NOUVEAU_BIOS_H__
  25. #include "nvreg.h"
  26. #define DCB_MAX_NUM_ENTRIES 16
  27. #define DCB_MAX_NUM_I2C_ENTRIES 16
  28. #define DCB_MAX_NUM_GPIO_ENTRIES 32
  29. #define DCB_MAX_NUM_CONNECTOR_ENTRIES 16
  30. #define DCB_LOC_ON_CHIP 0
  31. #define ROM16(x) le16_to_cpu(*(u16 *)&(x))
  32. #define ROM32(x) le32_to_cpu(*(u32 *)&(x))
  33. #define ROM48(x) ({ u8 *p = &(x); (u64)ROM16(p[4]) << 32 | ROM32(p[0]); })
  34. #define ROM64(x) le64_to_cpu(*(u64 *)&(x))
  35. #define ROMPTR(d,x) ({ \
  36. struct drm_nouveau_private *dev_priv = (d)->dev_private; \
  37. ROM16(x) ? &dev_priv->vbios.data[ROM16(x)] : NULL; \
  38. })
  39. struct bit_entry {
  40. uint8_t id;
  41. uint8_t version;
  42. uint16_t length;
  43. uint16_t offset;
  44. uint8_t *data;
  45. };
  46. int bit_table(struct drm_device *, u8 id, struct bit_entry *);
  47. enum dcb_connector_type {
  48. DCB_CONNECTOR_VGA = 0x00,
  49. DCB_CONNECTOR_TV_0 = 0x10,
  50. DCB_CONNECTOR_TV_1 = 0x11,
  51. DCB_CONNECTOR_TV_3 = 0x13,
  52. DCB_CONNECTOR_DVI_I = 0x30,
  53. DCB_CONNECTOR_DVI_D = 0x31,
  54. DCB_CONNECTOR_DMS59_0 = 0x38,
  55. DCB_CONNECTOR_DMS59_1 = 0x39,
  56. DCB_CONNECTOR_LVDS = 0x40,
  57. DCB_CONNECTOR_LVDS_SPWG = 0x41,
  58. DCB_CONNECTOR_DP = 0x46,
  59. DCB_CONNECTOR_eDP = 0x47,
  60. DCB_CONNECTOR_HDMI_0 = 0x60,
  61. DCB_CONNECTOR_HDMI_1 = 0x61,
  62. DCB_CONNECTOR_DMS59_DP0 = 0x64,
  63. DCB_CONNECTOR_DMS59_DP1 = 0x65,
  64. DCB_CONNECTOR_NONE = 0xff
  65. };
  66. enum dcb_type {
  67. OUTPUT_ANALOG = 0,
  68. OUTPUT_TV = 1,
  69. OUTPUT_TMDS = 2,
  70. OUTPUT_LVDS = 3,
  71. OUTPUT_DP = 6,
  72. OUTPUT_EOL = 14, /* DCB 4.0+, appears to be end-of-list */
  73. OUTPUT_UNUSED = 15,
  74. OUTPUT_ANY = -1
  75. };
  76. struct dcb_entry {
  77. int index; /* may not be raw dcb index if merging has happened */
  78. enum dcb_type type;
  79. uint8_t i2c_index;
  80. uint8_t heads;
  81. uint8_t connector;
  82. uint8_t bus;
  83. uint8_t location;
  84. uint8_t or;
  85. bool duallink_possible;
  86. union {
  87. struct sor_conf {
  88. int link;
  89. } sorconf;
  90. struct {
  91. int maxfreq;
  92. } crtconf;
  93. struct {
  94. struct sor_conf sor;
  95. bool use_straps_for_mode;
  96. bool use_acpi_for_edid;
  97. bool use_power_scripts;
  98. } lvdsconf;
  99. struct {
  100. bool has_component_output;
  101. } tvconf;
  102. struct {
  103. struct sor_conf sor;
  104. int link_nr;
  105. int link_bw;
  106. } dpconf;
  107. struct {
  108. struct sor_conf sor;
  109. int slave_addr;
  110. } tmdsconf;
  111. };
  112. bool i2c_upper_default;
  113. };
  114. struct dcb_table {
  115. uint8_t version;
  116. int entries;
  117. struct dcb_entry entry[DCB_MAX_NUM_ENTRIES];
  118. };
  119. enum nouveau_or {
  120. OUTPUT_A = (1 << 0),
  121. OUTPUT_B = (1 << 1),
  122. OUTPUT_C = (1 << 2)
  123. };
  124. enum LVDS_script {
  125. /* Order *does* matter here */
  126. LVDS_INIT = 1,
  127. LVDS_RESET,
  128. LVDS_BACKLIGHT_ON,
  129. LVDS_BACKLIGHT_OFF,
  130. LVDS_PANEL_ON,
  131. LVDS_PANEL_OFF
  132. };
  133. struct nvbios {
  134. struct drm_device *dev;
  135. enum {
  136. NVBIOS_BMP,
  137. NVBIOS_BIT
  138. } type;
  139. uint16_t offset;
  140. uint32_t length;
  141. uint8_t *data;
  142. uint8_t chip_version;
  143. uint32_t dactestval;
  144. uint32_t tvdactestval;
  145. uint8_t digital_min_front_porch;
  146. bool fp_no_ddc;
  147. spinlock_t lock;
  148. bool execute;
  149. uint8_t major_version;
  150. uint8_t feature_byte;
  151. bool is_mobile;
  152. uint32_t fmaxvco, fminvco;
  153. bool old_style_init;
  154. uint16_t init_script_tbls_ptr;
  155. uint16_t extra_init_script_tbl_ptr;
  156. uint16_t macro_index_tbl_ptr;
  157. uint16_t macro_tbl_ptr;
  158. uint16_t condition_tbl_ptr;
  159. uint16_t io_condition_tbl_ptr;
  160. uint16_t io_flag_condition_tbl_ptr;
  161. uint16_t init_function_tbl_ptr;
  162. uint16_t pll_limit_tbl_ptr;
  163. uint16_t ram_restrict_tbl_ptr;
  164. uint8_t ram_restrict_group_count;
  165. uint16_t some_script_ptr; /* BIT I + 14 */
  166. uint16_t init96_tbl_ptr; /* BIT I + 16 */
  167. struct dcb_table dcb;
  168. struct {
  169. int crtchead;
  170. } state;
  171. struct {
  172. struct dcb_entry *output;
  173. int crtc;
  174. uint16_t script_table_ptr;
  175. } display;
  176. struct {
  177. uint16_t fptablepointer; /* also used by tmds */
  178. uint16_t fpxlatetableptr;
  179. int xlatwidth;
  180. uint16_t lvdsmanufacturerpointer;
  181. uint16_t fpxlatemanufacturertableptr;
  182. uint16_t mode_ptr;
  183. uint16_t xlated_entry;
  184. bool power_off_for_reset;
  185. bool reset_after_pclk_change;
  186. bool dual_link;
  187. bool link_c_increment;
  188. bool if_is_24bit;
  189. int duallink_transition_clk;
  190. uint8_t strapless_is_24bit;
  191. uint8_t *edid;
  192. /* will need resetting after suspend */
  193. int last_script_invoc;
  194. bool lvds_init_run;
  195. } fp;
  196. struct {
  197. uint16_t output0_script_ptr;
  198. uint16_t output1_script_ptr;
  199. } tmds;
  200. struct {
  201. uint16_t mem_init_tbl_ptr;
  202. uint16_t sdr_seq_tbl_ptr;
  203. uint16_t ddr_seq_tbl_ptr;
  204. struct {
  205. uint8_t crt, tv, panel;
  206. } i2c_indices;
  207. uint16_t lvds_single_a_script_ptr;
  208. } legacy;
  209. };
  210. void *olddcb_table(struct drm_device *);
  211. void *olddcb_outp(struct drm_device *, u8 idx);
  212. int olddcb_outp_foreach(struct drm_device *, void *data,
  213. int (*)(struct drm_device *, void *, int idx, u8 *outp));
  214. u8 *dcb_conntab(struct drm_device *);
  215. u8 *dcb_conn(struct drm_device *, u8 idx);
  216. #endif