blob: 3befbb821a56bccec5d6af58ce1f5b24f5a5125d [file] [log] [blame]
Ben Skeggs6ee73862009-12-11 19:24:15 +10001/*
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
Ben Skeggs77145f12012-07-31 16:16:21 +100024#ifndef __NOUVEAU_DISPBIOS_H__
25#define __NOUVEAU_DISPBIOS_H__
Ben Skeggs6ee73862009-12-11 19:24:15 +100026
27#include "nvreg.h"
Ben Skeggs6ee73862009-12-11 19:24:15 +100028
29#define DCB_MAX_NUM_ENTRIES 16
30#define DCB_MAX_NUM_I2C_ENTRIES 16
31#define DCB_MAX_NUM_GPIO_ENTRIES 32
32#define DCB_MAX_NUM_CONNECTOR_ENTRIES 16
33
34#define DCB_LOC_ON_CHIP 0
35
Ben Skeggsf9f9f532011-10-12 16:48:48 +100036#define ROM16(x) le16_to_cpu(*(u16 *)&(x))
37#define ROM32(x) le32_to_cpu(*(u32 *)&(x))
38#define ROM48(x) ({ u8 *p = &(x); (u64)ROM16(p[4]) << 32 | ROM32(p[0]); })
39#define ROM64(x) le64_to_cpu(*(u64 *)&(x))
40#define ROMPTR(d,x) ({ \
Ben Skeggs77145f12012-07-31 16:16:21 +100041 struct nouveau_drm *drm = nouveau_drm((d)); \
42 ROM16(x) ? &drm->vbios.data[ROM16(x)] : NULL; \
Ben Skeggsf9f9f532011-10-12 16:48:48 +100043})
Ben Skeggs4709bff2010-09-13 15:18:40 +100044
45struct bit_entry {
46 uint8_t id;
47 uint8_t version;
48 uint16_t length;
49 uint16_t offset;
50 uint8_t *data;
51};
52
53int bit_table(struct drm_device *, u8 id, struct bit_entry *);
54
Ben Skeggscb75d972012-07-11 10:44:20 +100055#include <subdev/bios/dcb.h>
Ben Skeggsd38ac522012-07-22 16:41:26 +100056#include <subdev/bios/conn.h>
Ben Skeggs6ee73862009-12-11 19:24:15 +100057
Ben Skeggs7f245b22010-02-24 09:56:18 +100058struct dcb_table {
Ben Skeggs6ee73862009-12-11 19:24:15 +100059 uint8_t version;
Ben Skeggs7f245b22010-02-24 09:56:18 +100060 int entries;
Ben Skeggscb75d972012-07-11 10:44:20 +100061 struct dcb_output entry[DCB_MAX_NUM_ENTRIES];
Ben Skeggs6ee73862009-12-11 19:24:15 +100062};
63
Ben Skeggs6ee73862009-12-11 19:24:15 +100064enum nouveau_or {
Ben Skeggscb75d972012-07-11 10:44:20 +100065 DCB_OUTPUT_A = (1 << 0),
66 DCB_OUTPUT_B = (1 << 1),
67 DCB_OUTPUT_C = (1 << 2)
Ben Skeggs6ee73862009-12-11 19:24:15 +100068};
69
70enum LVDS_script {
71 /* Order *does* matter here */
72 LVDS_INIT = 1,
73 LVDS_RESET,
74 LVDS_BACKLIGHT_ON,
75 LVDS_BACKLIGHT_OFF,
76 LVDS_PANEL_ON,
77 LVDS_PANEL_OFF
78};
79
Ben Skeggs04a39c52010-02-24 10:03:05 +100080struct nvbios {
81 struct drm_device *dev;
Ben Skeggs4709bff2010-09-13 15:18:40 +100082 enum {
83 NVBIOS_BMP,
84 NVBIOS_BIT
85 } type;
86 uint16_t offset;
Ben Skeggs4489b982012-03-07 13:22:50 +100087 uint32_t length;
88 uint8_t *data;
Ben Skeggs04a39c52010-02-24 10:03:05 +100089
Ben Skeggs6ee73862009-12-11 19:24:15 +100090 uint8_t chip_version;
91
92 uint32_t dactestval;
93 uint32_t tvdactestval;
94 uint8_t digital_min_front_porch;
95 bool fp_no_ddc;
Ben Skeggs6ee73862009-12-11 19:24:15 +100096
Ben Skeggsc7ca4d12011-02-03 20:10:49 +100097 spinlock_t lock;
Ben Skeggs39c9bfb2010-02-09 10:22:29 +100098
Ben Skeggs6ee73862009-12-11 19:24:15 +100099 bool execute;
100
101 uint8_t major_version;
102 uint8_t feature_byte;
103 bool is_mobile;
104
105 uint32_t fmaxvco, fminvco;
106
107 bool old_style_init;
108 uint16_t init_script_tbls_ptr;
109 uint16_t extra_init_script_tbl_ptr;
110 uint16_t macro_index_tbl_ptr;
111 uint16_t macro_tbl_ptr;
112 uint16_t condition_tbl_ptr;
113 uint16_t io_condition_tbl_ptr;
114 uint16_t io_flag_condition_tbl_ptr;
115 uint16_t init_function_tbl_ptr;
116
117 uint16_t pll_limit_tbl_ptr;
118 uint16_t ram_restrict_tbl_ptr;
Marcin Koƛcielnicki37383652009-12-15 00:37:31 +0000119 uint8_t ram_restrict_group_count;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000120
121 uint16_t some_script_ptr; /* BIT I + 14 */
122 uint16_t init96_tbl_ptr; /* BIT I + 16 */
123
Ben Skeggs7f245b22010-02-24 09:56:18 +1000124 struct dcb_table dcb;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000125
126 struct {
127 int crtchead;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000128 } state;
129
130 struct {
Ben Skeggscb75d972012-07-11 10:44:20 +1000131 struct dcb_output *output;
Ben Skeggs02e4f582011-07-06 21:21:42 +1000132 int crtc;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000133 uint16_t script_table_ptr;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000134 } display;
135
136 struct {
137 uint16_t fptablepointer; /* also used by tmds */
138 uint16_t fpxlatetableptr;
139 int xlatwidth;
140 uint16_t lvdsmanufacturerpointer;
141 uint16_t fpxlatemanufacturertableptr;
142 uint16_t mode_ptr;
143 uint16_t xlated_entry;
144 bool power_off_for_reset;
145 bool reset_after_pclk_change;
146 bool dual_link;
147 bool link_c_increment;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000148 bool if_is_24bit;
149 int duallink_transition_clk;
150 uint8_t strapless_is_24bit;
151 uint8_t *edid;
152
153 /* will need resetting after suspend */
154 int last_script_invoc;
155 bool lvds_init_run;
156 } fp;
157
158 struct {
159 uint16_t output0_script_ptr;
160 uint16_t output1_script_ptr;
161 } tmds;
162
163 struct {
164 uint16_t mem_init_tbl_ptr;
165 uint16_t sdr_seq_tbl_ptr;
166 uint16_t ddr_seq_tbl_ptr;
167
168 struct {
169 uint8_t crt, tv, panel;
170 } i2c_indices;
171
172 uint16_t lvds_single_a_script_ptr;
173 } legacy;
174};
175
Ben Skeggse0996ae2012-07-10 12:20:17 +1000176void *olddcb_table(struct drm_device *);
177void *olddcb_outp(struct drm_device *, u8 idx);
178int olddcb_outp_foreach(struct drm_device *, void *data,
Ben Skeggs6b5a81a2011-11-10 15:42:55 +1000179 int (*)(struct drm_device *, void *, int idx, u8 *outp));
Ben Skeggscb75d972012-07-11 10:44:20 +1000180u8 *olddcb_conntab(struct drm_device *);
181u8 *olddcb_conn(struct drm_device *, u8 idx);
Ben Skeggs6b5a81a2011-11-10 15:42:55 +1000182
Ben Skeggs77145f12012-07-31 16:16:21 +1000183int nouveau_bios_init(struct drm_device *);
184void nouveau_bios_takedown(struct drm_device *dev);
185int nouveau_run_vbios_init(struct drm_device *);
186struct dcb_connector_table_entry *
187nouveau_bios_connector_entry(struct drm_device *, int index);
188int nouveau_bios_run_display_table(struct drm_device *, u16 id, int clk,
189 struct dcb_output *, int crtc);
190bool nouveau_bios_fp_mode(struct drm_device *, struct drm_display_mode *);
191uint8_t *nouveau_bios_embedded_edid(struct drm_device *);
192int nouveau_bios_parse_lvds_table(struct drm_device *, int pxclk,
193 bool *dl, bool *if_is_24bit);
194int run_tmds_table(struct drm_device *, struct dcb_output *,
195 int head, int pxclk);
196int call_lvds_script(struct drm_device *, struct dcb_output *, int head,
197 enum LVDS_script, int pxclk);
198bool bios_encoder_match(struct dcb_output *, u32 hash);
199
Ben Skeggs6ee73862009-12-11 19:24:15 +1000200#endif