nouveau_bios.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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_DISPBIOS_H__
  24. #define __NOUVEAU_DISPBIOS_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 nouveau_drm *drm = nouveau_drm((d)); \
  37. ROM16(x) ? &drm->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. #include <subdev/bios/dcb.h>
  48. #include <subdev/bios/conn.h>
  49. struct dcb_table {
  50. uint8_t version;
  51. int entries;
  52. struct dcb_output entry[DCB_MAX_NUM_ENTRIES];
  53. };
  54. enum nouveau_or {
  55. DCB_OUTPUT_A = (1 << 0),
  56. DCB_OUTPUT_B = (1 << 1),
  57. DCB_OUTPUT_C = (1 << 2)
  58. };
  59. enum LVDS_script {
  60. /* Order *does* matter here */
  61. LVDS_INIT = 1,
  62. LVDS_RESET,
  63. LVDS_BACKLIGHT_ON,
  64. LVDS_BACKLIGHT_OFF,
  65. LVDS_PANEL_ON,
  66. LVDS_PANEL_OFF
  67. };
  68. struct nvbios {
  69. struct drm_device *dev;
  70. enum {
  71. NVBIOS_BMP,
  72. NVBIOS_BIT
  73. } type;
  74. uint16_t offset;
  75. uint32_t length;
  76. uint8_t *data;
  77. uint8_t chip_version;
  78. uint32_t dactestval;
  79. uint32_t tvdactestval;
  80. uint8_t digital_min_front_porch;
  81. bool fp_no_ddc;
  82. spinlock_t lock;
  83. bool execute;
  84. uint8_t major_version;
  85. uint8_t feature_byte;
  86. bool is_mobile;
  87. uint32_t fmaxvco, fminvco;
  88. bool old_style_init;
  89. uint16_t init_script_tbls_ptr;
  90. uint16_t extra_init_script_tbl_ptr;
  91. uint16_t macro_index_tbl_ptr;
  92. uint16_t macro_tbl_ptr;
  93. uint16_t condition_tbl_ptr;
  94. uint16_t io_condition_tbl_ptr;
  95. uint16_t io_flag_condition_tbl_ptr;
  96. uint16_t init_function_tbl_ptr;
  97. uint16_t pll_limit_tbl_ptr;
  98. uint16_t ram_restrict_tbl_ptr;
  99. uint8_t ram_restrict_group_count;
  100. uint16_t some_script_ptr; /* BIT I + 14 */
  101. uint16_t init96_tbl_ptr; /* BIT I + 16 */
  102. struct dcb_table dcb;
  103. struct {
  104. int crtchead;
  105. } state;
  106. struct {
  107. uint16_t fptablepointer; /* also used by tmds */
  108. uint16_t fpxlatetableptr;
  109. int xlatwidth;
  110. uint16_t lvdsmanufacturerpointer;
  111. uint16_t fpxlatemanufacturertableptr;
  112. uint16_t mode_ptr;
  113. uint16_t xlated_entry;
  114. bool power_off_for_reset;
  115. bool reset_after_pclk_change;
  116. bool dual_link;
  117. bool link_c_increment;
  118. bool if_is_24bit;
  119. int duallink_transition_clk;
  120. uint8_t strapless_is_24bit;
  121. uint8_t *edid;
  122. /* will need resetting after suspend */
  123. int last_script_invoc;
  124. bool lvds_init_run;
  125. } fp;
  126. struct {
  127. uint16_t output0_script_ptr;
  128. uint16_t output1_script_ptr;
  129. } tmds;
  130. struct {
  131. uint16_t mem_init_tbl_ptr;
  132. uint16_t sdr_seq_tbl_ptr;
  133. uint16_t ddr_seq_tbl_ptr;
  134. struct {
  135. uint8_t crt, tv, panel;
  136. } i2c_indices;
  137. uint16_t lvds_single_a_script_ptr;
  138. } legacy;
  139. };
  140. void *olddcb_table(struct drm_device *);
  141. void *olddcb_outp(struct drm_device *, u8 idx);
  142. int olddcb_outp_foreach(struct drm_device *, void *data,
  143. int (*)(struct drm_device *, void *, int idx, u8 *outp));
  144. u8 *olddcb_conntab(struct drm_device *);
  145. u8 *olddcb_conn(struct drm_device *, u8 idx);
  146. int nouveau_bios_init(struct drm_device *);
  147. void nouveau_bios_takedown(struct drm_device *dev);
  148. int nouveau_run_vbios_init(struct drm_device *);
  149. struct dcb_connector_table_entry *
  150. nouveau_bios_connector_entry(struct drm_device *, int index);
  151. bool nouveau_bios_fp_mode(struct drm_device *, struct drm_display_mode *);
  152. uint8_t *nouveau_bios_embedded_edid(struct drm_device *);
  153. int nouveau_bios_parse_lvds_table(struct drm_device *, int pxclk,
  154. bool *dl, bool *if_is_24bit);
  155. int run_tmds_table(struct drm_device *, struct dcb_output *,
  156. int head, int pxclk);
  157. int call_lvds_script(struct drm_device *, struct dcb_output *, int head,
  158. enum LVDS_script, int pxclk);
  159. #endif