nouveau_bios.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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. #define DCB_MAX_NUM_ENTRIES 16
  26. #define DCB_MAX_NUM_I2C_ENTRIES 16
  27. #define DCB_MAX_NUM_GPIO_ENTRIES 32
  28. #define DCB_MAX_NUM_CONNECTOR_ENTRIES 16
  29. #define DCB_LOC_ON_CHIP 0
  30. #define ROM16(x) le16_to_cpu(*(u16 *)&(x))
  31. #define ROM32(x) le32_to_cpu(*(u32 *)&(x))
  32. #define ROM48(x) ({ u8 *p = &(x); (u64)ROM16(p[4]) << 32 | ROM32(p[0]); })
  33. #define ROM64(x) le64_to_cpu(*(u64 *)&(x))
  34. #define ROMPTR(d,x) ({ \
  35. struct nouveau_drm *drm = nouveau_drm((d)); \
  36. ROM16(x) ? &drm->vbios.data[ROM16(x)] : NULL; \
  37. })
  38. struct bit_entry {
  39. uint8_t id;
  40. uint8_t version;
  41. uint16_t length;
  42. uint16_t offset;
  43. uint8_t *data;
  44. };
  45. int bit_table(struct drm_device *, u8 id, struct bit_entry *);
  46. #include <subdev/bios/dcb.h>
  47. #include <subdev/bios/conn.h>
  48. struct dcb_table {
  49. uint8_t version;
  50. int entries;
  51. struct dcb_output entry[DCB_MAX_NUM_ENTRIES];
  52. };
  53. enum nouveau_or {
  54. DCB_OUTPUT_A = (1 << 0),
  55. DCB_OUTPUT_B = (1 << 1),
  56. DCB_OUTPUT_C = (1 << 2)
  57. };
  58. enum LVDS_script {
  59. /* Order *does* matter here */
  60. LVDS_INIT = 1,
  61. LVDS_RESET,
  62. LVDS_BACKLIGHT_ON,
  63. LVDS_BACKLIGHT_OFF,
  64. LVDS_PANEL_ON,
  65. LVDS_PANEL_OFF
  66. };
  67. struct nvbios {
  68. struct drm_device *dev;
  69. enum {
  70. NVBIOS_BMP,
  71. NVBIOS_BIT
  72. } type;
  73. uint16_t offset;
  74. uint32_t length;
  75. uint8_t *data;
  76. uint8_t chip_version;
  77. uint32_t dactestval;
  78. uint32_t tvdactestval;
  79. uint8_t digital_min_front_porch;
  80. bool fp_no_ddc;
  81. spinlock_t lock;
  82. bool execute;
  83. uint8_t major_version;
  84. uint8_t feature_byte;
  85. bool is_mobile;
  86. uint32_t fmaxvco, fminvco;
  87. bool old_style_init;
  88. uint16_t init_script_tbls_ptr;
  89. uint16_t extra_init_script_tbl_ptr;
  90. uint16_t ram_restrict_tbl_ptr;
  91. uint8_t ram_restrict_group_count;
  92. struct dcb_table dcb;
  93. struct {
  94. int crtchead;
  95. } state;
  96. struct {
  97. uint16_t fptablepointer; /* also used by tmds */
  98. uint16_t fpxlatetableptr;
  99. int xlatwidth;
  100. uint16_t lvdsmanufacturerpointer;
  101. uint16_t fpxlatemanufacturertableptr;
  102. uint16_t mode_ptr;
  103. uint16_t xlated_entry;
  104. bool power_off_for_reset;
  105. bool reset_after_pclk_change;
  106. bool dual_link;
  107. bool link_c_increment;
  108. bool if_is_24bit;
  109. int duallink_transition_clk;
  110. uint8_t strapless_is_24bit;
  111. uint8_t *edid;
  112. /* will need resetting after suspend */
  113. int last_script_invoc;
  114. bool lvds_init_run;
  115. } fp;
  116. struct {
  117. uint16_t output0_script_ptr;
  118. uint16_t output1_script_ptr;
  119. } tmds;
  120. struct {
  121. uint16_t mem_init_tbl_ptr;
  122. uint16_t sdr_seq_tbl_ptr;
  123. uint16_t ddr_seq_tbl_ptr;
  124. struct {
  125. uint8_t crt, tv, panel;
  126. } i2c_indices;
  127. uint16_t lvds_single_a_script_ptr;
  128. } legacy;
  129. };
  130. void *olddcb_table(struct drm_device *);
  131. void *olddcb_outp(struct drm_device *, u8 idx);
  132. int olddcb_outp_foreach(struct drm_device *, void *data,
  133. int (*)(struct drm_device *, void *, int idx, u8 *outp));
  134. u8 *olddcb_conntab(struct drm_device *);
  135. u8 *olddcb_conn(struct drm_device *, u8 idx);
  136. int nouveau_bios_init(struct drm_device *);
  137. void nouveau_bios_takedown(struct drm_device *dev);
  138. int nouveau_run_vbios_init(struct drm_device *);
  139. struct dcb_connector_table_entry *
  140. nouveau_bios_connector_entry(struct drm_device *, int index);
  141. bool nouveau_bios_fp_mode(struct drm_device *, struct drm_display_mode *);
  142. uint8_t *nouveau_bios_embedded_edid(struct drm_device *);
  143. int nouveau_bios_parse_lvds_table(struct drm_device *, int pxclk,
  144. bool *dl, bool *if_is_24bit);
  145. int run_tmds_table(struct drm_device *, struct dcb_output *,
  146. int head, int pxclk);
  147. int call_lvds_script(struct drm_device *, struct dcb_output *, int head,
  148. enum LVDS_script, int pxclk);
  149. #endif