1 1.2 riastrad /* $NetBSD: disp.h,v 1.3 2021/12/18 23:45:32 riastradh Exp $ */ 2 1.2 riastrad 3 1.3 riastrad /* SPDX-License-Identifier: MIT */ 4 1.1 riastrad #ifndef __NV04_DISPLAY_H__ 5 1.1 riastrad #define __NV04_DISPLAY_H__ 6 1.3 riastrad #include <subdev/bios.h> 7 1.1 riastrad #include <subdev/bios/pll.h> 8 1.1 riastrad 9 1.1 riastrad #include "nouveau_display.h" 10 1.1 riastrad 11 1.1 riastrad enum nv04_fp_display_regs { 12 1.1 riastrad FP_DISPLAY_END, 13 1.1 riastrad FP_TOTAL, 14 1.1 riastrad FP_CRTC, 15 1.1 riastrad FP_SYNC_START, 16 1.1 riastrad FP_SYNC_END, 17 1.1 riastrad FP_VALID_START, 18 1.1 riastrad FP_VALID_END 19 1.1 riastrad }; 20 1.1 riastrad 21 1.1 riastrad struct nv04_crtc_reg { 22 1.1 riastrad unsigned char MiscOutReg; 23 1.1 riastrad uint8_t CRTC[0xa0]; 24 1.1 riastrad uint8_t CR58[0x10]; 25 1.1 riastrad uint8_t Sequencer[5]; 26 1.1 riastrad uint8_t Graphics[9]; 27 1.1 riastrad uint8_t Attribute[21]; 28 1.1 riastrad unsigned char DAC[768]; 29 1.1 riastrad 30 1.1 riastrad /* PCRTC regs */ 31 1.1 riastrad uint32_t fb_start; 32 1.1 riastrad uint32_t crtc_cfg; 33 1.1 riastrad uint32_t cursor_cfg; 34 1.1 riastrad uint32_t gpio_ext; 35 1.1 riastrad uint32_t crtc_830; 36 1.1 riastrad uint32_t crtc_834; 37 1.1 riastrad uint32_t crtc_850; 38 1.1 riastrad uint32_t crtc_eng_ctrl; 39 1.1 riastrad 40 1.1 riastrad /* PRAMDAC regs */ 41 1.1 riastrad uint32_t nv10_cursync; 42 1.2 riastrad struct nvkm_pll_vals pllvals; 43 1.1 riastrad uint32_t ramdac_gen_ctrl; 44 1.1 riastrad uint32_t ramdac_630; 45 1.1 riastrad uint32_t ramdac_634; 46 1.1 riastrad uint32_t tv_setup; 47 1.1 riastrad uint32_t tv_vtotal; 48 1.1 riastrad uint32_t tv_vskew; 49 1.1 riastrad uint32_t tv_vsync_delay; 50 1.1 riastrad uint32_t tv_htotal; 51 1.1 riastrad uint32_t tv_hskew; 52 1.1 riastrad uint32_t tv_hsync_delay; 53 1.1 riastrad uint32_t tv_hsync_delay2; 54 1.1 riastrad uint32_t fp_horiz_regs[7]; 55 1.1 riastrad uint32_t fp_vert_regs[7]; 56 1.1 riastrad uint32_t dither; 57 1.1 riastrad uint32_t fp_control; 58 1.1 riastrad uint32_t dither_regs[6]; 59 1.1 riastrad uint32_t fp_debug_0; 60 1.1 riastrad uint32_t fp_debug_1; 61 1.1 riastrad uint32_t fp_debug_2; 62 1.1 riastrad uint32_t fp_margin_color; 63 1.1 riastrad uint32_t ramdac_8c0; 64 1.1 riastrad uint32_t ramdac_a20; 65 1.1 riastrad uint32_t ramdac_a24; 66 1.1 riastrad uint32_t ramdac_a34; 67 1.1 riastrad uint32_t ctv_regs[38]; 68 1.1 riastrad }; 69 1.1 riastrad 70 1.1 riastrad struct nv04_output_reg { 71 1.1 riastrad uint32_t output; 72 1.1 riastrad int head; 73 1.1 riastrad }; 74 1.1 riastrad 75 1.1 riastrad struct nv04_mode_state { 76 1.1 riastrad struct nv04_crtc_reg crtc_reg[2]; 77 1.1 riastrad uint32_t pllsel; 78 1.1 riastrad uint32_t sel_clk; 79 1.1 riastrad }; 80 1.1 riastrad 81 1.1 riastrad struct nv04_display { 82 1.1 riastrad struct nv04_mode_state mode_reg; 83 1.1 riastrad struct nv04_mode_state saved_reg; 84 1.1 riastrad uint32_t saved_vga_font[4][16384]; 85 1.1 riastrad uint32_t dac_users[4]; 86 1.1 riastrad struct nouveau_bo *image[2]; 87 1.3 riastrad struct nvif_notify flip; 88 1.1 riastrad }; 89 1.1 riastrad 90 1.1 riastrad static inline struct nv04_display * 91 1.1 riastrad nv04_display(struct drm_device *dev) 92 1.1 riastrad { 93 1.1 riastrad return nouveau_display(dev)->priv; 94 1.1 riastrad } 95 1.1 riastrad 96 1.1 riastrad /* nv04_display.c */ 97 1.1 riastrad int nv04_display_create(struct drm_device *); 98 1.1 riastrad 99 1.1 riastrad /* nv04_crtc.c */ 100 1.1 riastrad int nv04_crtc_create(struct drm_device *, int index); 101 1.1 riastrad 102 1.1 riastrad /* nv04_dac.c */ 103 1.1 riastrad int nv04_dac_create(struct drm_connector *, struct dcb_output *); 104 1.1 riastrad uint32_t nv17_dac_sample_load(struct drm_encoder *encoder); 105 1.1 riastrad int nv04_dac_output_offset(struct drm_encoder *encoder); 106 1.1 riastrad void nv04_dac_update_dacclk(struct drm_encoder *encoder, bool enable); 107 1.1 riastrad bool nv04_dac_in_use(struct drm_encoder *encoder); 108 1.1 riastrad 109 1.1 riastrad /* nv04_dfp.c */ 110 1.1 riastrad int nv04_dfp_create(struct drm_connector *, struct dcb_output *); 111 1.1 riastrad int nv04_dfp_get_bound_head(struct drm_device *dev, struct dcb_output *dcbent); 112 1.1 riastrad void nv04_dfp_bind_head(struct drm_device *dev, struct dcb_output *dcbent, 113 1.1 riastrad int head, bool dl); 114 1.1 riastrad void nv04_dfp_disable(struct drm_device *dev, int head); 115 1.1 riastrad void nv04_dfp_update_fp_control(struct drm_encoder *encoder, int mode); 116 1.1 riastrad 117 1.1 riastrad /* nv04_tv.c */ 118 1.1 riastrad int nv04_tv_identify(struct drm_device *dev, int i2c_index); 119 1.1 riastrad int nv04_tv_create(struct drm_connector *, struct dcb_output *); 120 1.1 riastrad 121 1.1 riastrad /* nv17_tv.c */ 122 1.1 riastrad int nv17_tv_create(struct drm_connector *, struct dcb_output *); 123 1.1 riastrad 124 1.1 riastrad /* overlay.c */ 125 1.1 riastrad void nouveau_overlay_init(struct drm_device *dev); 126 1.1 riastrad 127 1.1 riastrad static inline bool 128 1.1 riastrad nv_two_heads(struct drm_device *dev) 129 1.1 riastrad { 130 1.1 riastrad struct nouveau_drm *drm = nouveau_drm(dev); 131 1.1 riastrad const int impl = dev->pdev->device & 0x0ff0; 132 1.1 riastrad 133 1.3 riastrad if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_CELSIUS && impl != 0x0100 && 134 1.1 riastrad impl != 0x0150 && impl != 0x01a0 && impl != 0x0200) 135 1.1 riastrad return true; 136 1.1 riastrad 137 1.1 riastrad return false; 138 1.1 riastrad } 139 1.1 riastrad 140 1.1 riastrad static inline bool 141 1.1 riastrad nv_gf4_disp_arch(struct drm_device *dev) 142 1.1 riastrad { 143 1.1 riastrad return nv_two_heads(dev) && (dev->pdev->device & 0x0ff0) != 0x0110; 144 1.1 riastrad } 145 1.1 riastrad 146 1.1 riastrad static inline bool 147 1.1 riastrad nv_two_reg_pll(struct drm_device *dev) 148 1.1 riastrad { 149 1.1 riastrad struct nouveau_drm *drm = nouveau_drm(dev); 150 1.1 riastrad const int impl = dev->pdev->device & 0x0ff0; 151 1.1 riastrad 152 1.3 riastrad if (impl == 0x0310 || impl == 0x0340 || drm->client.device.info.family >= NV_DEVICE_INFO_V0_CURIE) 153 1.1 riastrad return true; 154 1.1 riastrad return false; 155 1.1 riastrad } 156 1.1 riastrad 157 1.1 riastrad static inline bool 158 1.1 riastrad nv_match_device(struct drm_device *dev, unsigned device, 159 1.1 riastrad unsigned sub_vendor, unsigned sub_device) 160 1.1 riastrad { 161 1.1 riastrad return dev->pdev->device == device && 162 1.1 riastrad dev->pdev->subsystem_vendor == sub_vendor && 163 1.1 riastrad dev->pdev->subsystem_device == sub_device; 164 1.1 riastrad } 165 1.1 riastrad 166 1.1 riastrad #include <subdev/bios/init.h> 167 1.1 riastrad 168 1.1 riastrad static inline void 169 1.1 riastrad nouveau_bios_run_init_table(struct drm_device *dev, u16 table, 170 1.1 riastrad struct dcb_output *outp, int crtc) 171 1.1 riastrad { 172 1.3 riastrad nvbios_init(&nvxx_bios(&nouveau_drm(dev)->client.device)->subdev, table, 173 1.3 riastrad init.outp = outp; 174 1.3 riastrad init.head = crtc; 175 1.3 riastrad ); 176 1.1 riastrad } 177 1.1 riastrad 178 1.3 riastrad int nv04_flip_complete(struct nvif_notify *); 179 1.1 riastrad #endif 180