nouveau_bios.h revision 1.2.32.1 1 /* $NetBSD: nouveau_bios.h,v 1.2.32.1 2019/06/10 22:08:06 christos Exp $ */
2
3 /*
4 * Copyright 2007-2008 Nouveau Project
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice (including the next
14 * paragraph) shall be included in all copies or substantial portions of the
15 * Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 * DEALINGS IN THE SOFTWARE.
24 */
25
26 #ifndef __NOUVEAU_DISPBIOS_H__
27 #define __NOUVEAU_DISPBIOS_H__
28
29 #include <asm/byteorder.h>
30
31 #define DCB_MAX_NUM_ENTRIES 16
32 #define DCB_MAX_NUM_I2C_ENTRIES 16
33 #define DCB_MAX_NUM_GPIO_ENTRIES 32
34 #define DCB_MAX_NUM_CONNECTOR_ENTRIES 16
35
36 #define DCB_LOC_ON_CHIP 0
37
38 #define ROM16(x) le16_to_cpu(*(u16 *)&(x))
39 #define ROM32(x) le32_to_cpu(*(u32 *)&(x))
40 #define ROM48(x) ({ u8 *p = &(x); (u64)ROM16(p[4]) << 32 | ROM32(p[0]); })
41 #define ROM64(x) le64_to_cpu(*(u64 *)&(x))
42 #define ROMPTR(d,x) ({ \
43 struct nouveau_drm *drm = nouveau_drm((d)); \
44 ROM16(x) ? &drm->vbios.data[ROM16(x)] : NULL; \
45 })
46
47 struct bit_entry {
48 uint8_t id;
49 uint8_t version;
50 uint16_t length;
51 uint16_t offset;
52 uint8_t *data;
53 };
54
55 int bit_table(struct drm_device *, u8 id, struct bit_entry *);
56
57 #include <subdev/bios/dcb.h>
58 #include <subdev/bios/conn.h>
59
60 struct dcb_table {
61 uint8_t version;
62 int entries;
63 struct dcb_output entry[DCB_MAX_NUM_ENTRIES];
64 };
65
66 enum nouveau_or {
67 DCB_OUTPUT_A = (1 << 0),
68 DCB_OUTPUT_B = (1 << 1),
69 DCB_OUTPUT_C = (1 << 2)
70 };
71
72 enum LVDS_script {
73 /* Order *does* matter here */
74 LVDS_INIT = 1,
75 LVDS_RESET,
76 LVDS_BACKLIGHT_ON,
77 LVDS_BACKLIGHT_OFF,
78 LVDS_PANEL_ON,
79 LVDS_PANEL_OFF
80 };
81
82 struct nvbios {
83 struct drm_device *dev;
84 enum {
85 NVBIOS_BMP,
86 NVBIOS_BIT
87 } type;
88 uint16_t offset;
89 uint32_t length;
90 uint8_t *data;
91
92 uint8_t chip_version;
93
94 uint32_t dactestval;
95 uint32_t tvdactestval;
96 uint8_t digital_min_front_porch;
97 bool fp_no_ddc;
98
99 spinlock_t lock;
100
101 bool execute;
102
103 uint8_t major_version;
104 uint8_t feature_byte;
105 bool is_mobile;
106
107 uint32_t fmaxvco, fminvco;
108
109 bool old_style_init;
110 uint16_t init_script_tbls_ptr;
111 uint16_t extra_init_script_tbl_ptr;
112
113 uint16_t ram_restrict_tbl_ptr;
114 uint8_t ram_restrict_group_count;
115
116 struct dcb_table dcb;
117
118 struct {
119 int crtchead;
120 } state;
121
122 struct {
123 uint16_t fptablepointer; /* also used by tmds */
124 uint16_t fpxlatetableptr;
125 int xlatwidth;
126 uint16_t lvdsmanufacturerpointer;
127 uint16_t fpxlatemanufacturertableptr;
128 uint16_t mode_ptr;
129 uint16_t xlated_entry;
130 bool power_off_for_reset;
131 bool reset_after_pclk_change;
132 bool dual_link;
133 bool link_c_increment;
134 bool if_is_24bit;
135 int duallink_transition_clk;
136 uint8_t strapless_is_24bit;
137 uint8_t *edid;
138
139 /* will need resetting after suspend */
140 int last_script_invoc;
141 bool lvds_init_run;
142 } fp;
143
144 struct {
145 uint16_t output0_script_ptr;
146 uint16_t output1_script_ptr;
147 } tmds;
148
149 struct {
150 uint16_t mem_init_tbl_ptr;
151 uint16_t sdr_seq_tbl_ptr;
152 uint16_t ddr_seq_tbl_ptr;
153
154 struct {
155 uint8_t crt, tv, panel;
156 } i2c_indices;
157
158 uint16_t lvds_single_a_script_ptr;
159 } legacy;
160 };
161
162 void *olddcb_table(struct drm_device *);
163 void *olddcb_outp(struct drm_device *, u8 idx);
164 int olddcb_outp_foreach(struct drm_device *, void *data,
165 int (*)(struct drm_device *, void *, int idx, u8 *outp));
166 u8 *olddcb_conntab(struct drm_device *);
167 u8 *olddcb_conn(struct drm_device *, u8 idx);
168
169 int nouveau_bios_init(struct drm_device *);
170 void nouveau_bios_takedown(struct drm_device *dev);
171 int nouveau_run_vbios_init(struct drm_device *);
172 struct dcb_connector_table_entry *
173 nouveau_bios_connector_entry(struct drm_device *, int index);
174 bool nouveau_bios_fp_mode(struct drm_device *, struct drm_display_mode *);
175 uint8_t *nouveau_bios_embedded_edid(struct drm_device *);
176 int nouveau_bios_parse_lvds_table(struct drm_device *, int pxclk,
177 bool *dl, bool *if_is_24bit);
178 int run_tmds_table(struct drm_device *, struct dcb_output *,
179 int head, int pxclk);
180 int call_lvds_script(struct drm_device *, struct dcb_output *, int head,
181 enum LVDS_script, int pxclk);
182
183 #endif
184