Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 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 | |
Ben Skeggs | 77145f1 | 2012-07-31 16:16:21 +1000 | [diff] [blame] | 24 | #ifndef __NOUVEAU_DISPBIOS_H__ |
| 25 | #define __NOUVEAU_DISPBIOS_H__ |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 26 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 27 | #define DCB_MAX_NUM_ENTRIES 16 |
| 28 | #define DCB_MAX_NUM_I2C_ENTRIES 16 |
| 29 | #define DCB_MAX_NUM_GPIO_ENTRIES 32 |
| 30 | #define DCB_MAX_NUM_CONNECTOR_ENTRIES 16 |
| 31 | |
| 32 | #define DCB_LOC_ON_CHIP 0 |
| 33 | |
Ben Skeggs | f9f9f53 | 2011-10-12 16:48:48 +1000 | [diff] [blame] | 34 | #define ROM16(x) le16_to_cpu(*(u16 *)&(x)) |
| 35 | #define ROM32(x) le32_to_cpu(*(u32 *)&(x)) |
| 36 | #define ROM48(x) ({ u8 *p = &(x); (u64)ROM16(p[4]) << 32 | ROM32(p[0]); }) |
| 37 | #define ROM64(x) le64_to_cpu(*(u64 *)&(x)) |
| 38 | #define ROMPTR(d,x) ({ \ |
Ben Skeggs | 77145f1 | 2012-07-31 16:16:21 +1000 | [diff] [blame] | 39 | struct nouveau_drm *drm = nouveau_drm((d)); \ |
| 40 | ROM16(x) ? &drm->vbios.data[ROM16(x)] : NULL; \ |
Ben Skeggs | f9f9f53 | 2011-10-12 16:48:48 +1000 | [diff] [blame] | 41 | }) |
Ben Skeggs | 4709bff | 2010-09-13 15:18:40 +1000 | [diff] [blame] | 42 | |
| 43 | struct bit_entry { |
| 44 | uint8_t id; |
| 45 | uint8_t version; |
| 46 | uint16_t length; |
| 47 | uint16_t offset; |
| 48 | uint8_t *data; |
| 49 | }; |
| 50 | |
| 51 | int bit_table(struct drm_device *, u8 id, struct bit_entry *); |
| 52 | |
Ben Skeggs | cb75d97 | 2012-07-11 10:44:20 +1000 | [diff] [blame] | 53 | #include <subdev/bios/dcb.h> |
Ben Skeggs | d38ac52 | 2012-07-22 16:41:26 +1000 | [diff] [blame] | 54 | #include <subdev/bios/conn.h> |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 55 | |
Ben Skeggs | 7f245b2 | 2010-02-24 09:56:18 +1000 | [diff] [blame] | 56 | struct dcb_table { |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 57 | uint8_t version; |
Ben Skeggs | 7f245b2 | 2010-02-24 09:56:18 +1000 | [diff] [blame] | 58 | int entries; |
Ben Skeggs | cb75d97 | 2012-07-11 10:44:20 +1000 | [diff] [blame] | 59 | struct dcb_output entry[DCB_MAX_NUM_ENTRIES]; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 60 | }; |
| 61 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 62 | enum nouveau_or { |
Ben Skeggs | cb75d97 | 2012-07-11 10:44:20 +1000 | [diff] [blame] | 63 | DCB_OUTPUT_A = (1 << 0), |
| 64 | DCB_OUTPUT_B = (1 << 1), |
| 65 | DCB_OUTPUT_C = (1 << 2) |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 66 | }; |
| 67 | |
| 68 | enum LVDS_script { |
| 69 | /* Order *does* matter here */ |
| 70 | LVDS_INIT = 1, |
| 71 | LVDS_RESET, |
| 72 | LVDS_BACKLIGHT_ON, |
| 73 | LVDS_BACKLIGHT_OFF, |
| 74 | LVDS_PANEL_ON, |
| 75 | LVDS_PANEL_OFF |
| 76 | }; |
| 77 | |
Ben Skeggs | 04a39c5 | 2010-02-24 10:03:05 +1000 | [diff] [blame] | 78 | struct nvbios { |
| 79 | struct drm_device *dev; |
Ben Skeggs | 4709bff | 2010-09-13 15:18:40 +1000 | [diff] [blame] | 80 | enum { |
| 81 | NVBIOS_BMP, |
| 82 | NVBIOS_BIT |
| 83 | } type; |
| 84 | uint16_t offset; |
Ben Skeggs | 4489b98 | 2012-03-07 13:22:50 +1000 | [diff] [blame] | 85 | uint32_t length; |
| 86 | uint8_t *data; |
Ben Skeggs | 04a39c5 | 2010-02-24 10:03:05 +1000 | [diff] [blame] | 87 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 88 | uint8_t chip_version; |
| 89 | |
| 90 | uint32_t dactestval; |
| 91 | uint32_t tvdactestval; |
| 92 | uint8_t digital_min_front_porch; |
| 93 | bool fp_no_ddc; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 94 | |
Ben Skeggs | c7ca4d1 | 2011-02-03 20:10:49 +1000 | [diff] [blame] | 95 | spinlock_t lock; |
Ben Skeggs | 39c9bfb | 2010-02-09 10:22:29 +1000 | [diff] [blame] | 96 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 97 | bool execute; |
| 98 | |
| 99 | uint8_t major_version; |
| 100 | uint8_t feature_byte; |
| 101 | bool is_mobile; |
| 102 | |
| 103 | uint32_t fmaxvco, fminvco; |
| 104 | |
| 105 | bool old_style_init; |
| 106 | uint16_t init_script_tbls_ptr; |
| 107 | uint16_t extra_init_script_tbl_ptr; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 108 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 109 | uint16_t ram_restrict_tbl_ptr; |
Marcin KoĆcielnicki | 3738365 | 2009-12-15 00:37:31 +0000 | [diff] [blame] | 110 | uint8_t ram_restrict_group_count; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 111 | |
Ben Skeggs | 7f245b2 | 2010-02-24 09:56:18 +1000 | [diff] [blame] | 112 | struct dcb_table dcb; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 113 | |
| 114 | struct { |
| 115 | int crtchead; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 116 | } state; |
| 117 | |
| 118 | struct { |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 119 | uint16_t fptablepointer; /* also used by tmds */ |
| 120 | uint16_t fpxlatetableptr; |
| 121 | int xlatwidth; |
| 122 | uint16_t lvdsmanufacturerpointer; |
| 123 | uint16_t fpxlatemanufacturertableptr; |
| 124 | uint16_t mode_ptr; |
| 125 | uint16_t xlated_entry; |
| 126 | bool power_off_for_reset; |
| 127 | bool reset_after_pclk_change; |
| 128 | bool dual_link; |
| 129 | bool link_c_increment; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 130 | bool if_is_24bit; |
| 131 | int duallink_transition_clk; |
| 132 | uint8_t strapless_is_24bit; |
| 133 | uint8_t *edid; |
| 134 | |
| 135 | /* will need resetting after suspend */ |
| 136 | int last_script_invoc; |
| 137 | bool lvds_init_run; |
| 138 | } fp; |
| 139 | |
| 140 | struct { |
| 141 | uint16_t output0_script_ptr; |
| 142 | uint16_t output1_script_ptr; |
| 143 | } tmds; |
| 144 | |
| 145 | struct { |
| 146 | uint16_t mem_init_tbl_ptr; |
| 147 | uint16_t sdr_seq_tbl_ptr; |
| 148 | uint16_t ddr_seq_tbl_ptr; |
| 149 | |
| 150 | struct { |
| 151 | uint8_t crt, tv, panel; |
| 152 | } i2c_indices; |
| 153 | |
| 154 | uint16_t lvds_single_a_script_ptr; |
| 155 | } legacy; |
| 156 | }; |
| 157 | |
Ben Skeggs | e0996ae | 2012-07-10 12:20:17 +1000 | [diff] [blame] | 158 | void *olddcb_table(struct drm_device *); |
| 159 | void *olddcb_outp(struct drm_device *, u8 idx); |
| 160 | int olddcb_outp_foreach(struct drm_device *, void *data, |
Ben Skeggs | 6b5a81a | 2011-11-10 15:42:55 +1000 | [diff] [blame] | 161 | int (*)(struct drm_device *, void *, int idx, u8 *outp)); |
Ben Skeggs | cb75d97 | 2012-07-11 10:44:20 +1000 | [diff] [blame] | 162 | u8 *olddcb_conntab(struct drm_device *); |
| 163 | u8 *olddcb_conn(struct drm_device *, u8 idx); |
Ben Skeggs | 6b5a81a | 2011-11-10 15:42:55 +1000 | [diff] [blame] | 164 | |
Ben Skeggs | 77145f1 | 2012-07-31 16:16:21 +1000 | [diff] [blame] | 165 | int nouveau_bios_init(struct drm_device *); |
| 166 | void nouveau_bios_takedown(struct drm_device *dev); |
| 167 | int nouveau_run_vbios_init(struct drm_device *); |
| 168 | struct dcb_connector_table_entry * |
| 169 | nouveau_bios_connector_entry(struct drm_device *, int index); |
Ben Skeggs | 77145f1 | 2012-07-31 16:16:21 +1000 | [diff] [blame] | 170 | bool nouveau_bios_fp_mode(struct drm_device *, struct drm_display_mode *); |
| 171 | uint8_t *nouveau_bios_embedded_edid(struct drm_device *); |
| 172 | int nouveau_bios_parse_lvds_table(struct drm_device *, int pxclk, |
| 173 | bool *dl, bool *if_is_24bit); |
| 174 | int run_tmds_table(struct drm_device *, struct dcb_output *, |
| 175 | int head, int pxclk); |
| 176 | int call_lvds_script(struct drm_device *, struct dcb_output *, int head, |
| 177 | enum LVDS_script, int pxclk); |
Ben Skeggs | 77145f1 | 2012-07-31 16:16:21 +1000 | [diff] [blame] | 178 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 179 | #endif |