nouveau_bios.h 4.5 KB

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