1 /* $NetBSD: ior.h,v 1.2 2021/12/18 23:45:35 riastradh Exp $ */ 2 3 /* SPDX-License-Identifier: MIT */ 4 #ifndef __NVKM_DISP_IOR_H__ 5 #define __NVKM_DISP_IOR_H__ 6 #include "priv.h" 7 struct nvkm_i2c_aux; 8 9 struct nvkm_ior { 10 const struct nvkm_ior_func *func; 11 struct nvkm_disp *disp; 12 enum nvkm_ior_type { 13 DAC, 14 SOR, 15 PIOR, 16 } type; 17 int id; 18 char name[8]; 19 20 struct list_head head; 21 bool identity; 22 23 struct nvkm_ior_state { 24 struct nvkm_outp *outp; 25 unsigned rgdiv; 26 unsigned proto_evo:4; 27 enum nvkm_ior_proto { 28 CRT, 29 TV, 30 TMDS, 31 LVDS, 32 DP, 33 UNKNOWN 34 } proto:3; 35 unsigned link:2; 36 unsigned head:8; 37 } arm, asy; 38 39 /* Armed DP state. */ 40 struct { 41 bool mst; 42 bool ef; 43 u8 nr; 44 u8 bw; 45 } dp; 46 47 /* Armed TMDS state. */ 48 struct { 49 bool high_speed; 50 } tmds; 51 }; 52 53 struct nvkm_ior_func { 54 struct { 55 int (*get)(struct nvkm_outp *, int *link); 56 void (*set)(struct nvkm_outp *, struct nvkm_ior *); 57 } route; 58 59 void (*state)(struct nvkm_ior *, struct nvkm_ior_state *); 60 void (*power)(struct nvkm_ior *, bool normal, bool pu, 61 bool data, bool vsync, bool hsync); 62 int (*sense)(struct nvkm_ior *, u32 loadval); 63 void (*clock)(struct nvkm_ior *); 64 void (*war_2)(struct nvkm_ior *); 65 void (*war_3)(struct nvkm_ior *); 66 67 struct { 68 void (*ctrl)(struct nvkm_ior *, int head, bool enable, 69 u8 max_ac_packet, u8 rekey, u8 *avi, u8 avi_size, 70 u8 *vendor, u8 vendor_size); 71 void (*scdc)(struct nvkm_ior *, int head, u8 scdc); 72 } hdmi; 73 74 struct { 75 u8 lanes[4]; 76 int (*links)(struct nvkm_ior *, struct nvkm_i2c_aux *); 77 void (*power)(struct nvkm_ior *, int nr); 78 void (*pattern)(struct nvkm_ior *, int pattern); 79 void (*drive)(struct nvkm_ior *, int ln, int pc, 80 int dc, int pe, int tx_pu); 81 void (*vcpi)(struct nvkm_ior *, int head, u8 slot, 82 u8 slot_nr, u16 pbn, u16 aligned); 83 void (*audio)(struct nvkm_ior *, int head, bool enable); 84 void (*audio_sym)(struct nvkm_ior *, int head, u16 h, u32 v); 85 void (*activesym)(struct nvkm_ior *, int head, 86 u8 TU, u8 VTUa, u8 VTUf, u8 VTUi); 87 void (*watermark)(struct nvkm_ior *, int head, u8 watermark); 88 } dp; 89 90 struct { 91 void (*hpd)(struct nvkm_ior *, int head, bool present); 92 void (*eld)(struct nvkm_ior *, u8 *data, u8 size); 93 } hda; 94 }; 95 96 int nvkm_ior_new_(const struct nvkm_ior_func *func, struct nvkm_disp *, 97 enum nvkm_ior_type type, int id); 98 void nvkm_ior_del(struct nvkm_ior **); 99 struct nvkm_ior *nvkm_ior_find(struct nvkm_disp *, enum nvkm_ior_type, int id); 100 101 static inline u32 102 nv50_ior_base(struct nvkm_ior *ior) 103 { 104 return ior->id * 0x800; 105 } 106 107 void nv50_dac_power(struct nvkm_ior *, bool, bool, bool, bool, bool); 108 int nv50_dac_sense(struct nvkm_ior *, u32); 109 110 void nv50_pior_depth(struct nvkm_ior *, struct nvkm_ior_state *, u32 ctrl); 111 112 static inline u32 113 nv50_sor_link(struct nvkm_ior *ior) 114 { 115 return nv50_ior_base(ior) + ((ior->asy.link == 2) * 0x80); 116 } 117 118 void nv50_sor_state(struct nvkm_ior *, struct nvkm_ior_state *); 119 void nv50_sor_power(struct nvkm_ior *, bool, bool, bool, bool, bool); 120 void nv50_sor_clock(struct nvkm_ior *); 121 122 void g94_sor_state(struct nvkm_ior *, struct nvkm_ior_state *); 123 int g94_sor_dp_links(struct nvkm_ior *, struct nvkm_i2c_aux *); 124 void g94_sor_dp_power(struct nvkm_ior *, int); 125 void g94_sor_dp_pattern(struct nvkm_ior *, int); 126 void g94_sor_dp_drive(struct nvkm_ior *, int, int, int, int, int); 127 void g94_sor_dp_audio_sym(struct nvkm_ior *, int, u16, u32); 128 void g94_sor_dp_activesym(struct nvkm_ior *, int, u8, u8, u8, u8); 129 void g94_sor_dp_watermark(struct nvkm_ior *, int, u8); 130 131 void gt215_sor_dp_audio(struct nvkm_ior *, int, bool); 132 133 void gf119_sor_state(struct nvkm_ior *, struct nvkm_ior_state *); 134 void gf119_sor_clock(struct nvkm_ior *); 135 int gf119_sor_dp_links(struct nvkm_ior *, struct nvkm_i2c_aux *); 136 void gf119_sor_dp_pattern(struct nvkm_ior *, int); 137 void gf119_sor_dp_drive(struct nvkm_ior *, int, int, int, int, int); 138 void gf119_sor_dp_vcpi(struct nvkm_ior *, int, u8, u8, u16, u16); 139 void gf119_sor_dp_audio(struct nvkm_ior *, int, bool); 140 void gf119_sor_dp_audio_sym(struct nvkm_ior *, int, u16, u32); 141 void gf119_sor_dp_watermark(struct nvkm_ior *, int, u8); 142 143 void gm107_sor_dp_pattern(struct nvkm_ior *, int); 144 145 void gm200_sor_route_set(struct nvkm_outp *, struct nvkm_ior *); 146 int gm200_sor_route_get(struct nvkm_outp *, int *); 147 void gm200_sor_dp_drive(struct nvkm_ior *, int, int, int, int, int); 148 149 void gv100_sor_state(struct nvkm_ior *, struct nvkm_ior_state *); 150 void gv100_sor_dp_audio(struct nvkm_ior *, int, bool); 151 void gv100_sor_dp_audio_sym(struct nvkm_ior *, int, u16, u32); 152 void gv100_sor_dp_watermark(struct nvkm_ior *, int, u8); 153 154 void g84_hdmi_ctrl(struct nvkm_ior *, int, bool, u8, u8, u8 *, u8 , u8 *, u8); 155 void gt215_hdmi_ctrl(struct nvkm_ior *, int, bool, u8, u8, u8 *, u8 , u8 *, u8); 156 void gf119_hdmi_ctrl(struct nvkm_ior *, int, bool, u8, u8, u8 *, u8 , u8 *, u8); 157 void gk104_hdmi_ctrl(struct nvkm_ior *, int, bool, u8, u8, u8 *, u8 , u8 *, u8); 158 void gv100_hdmi_ctrl(struct nvkm_ior *, int, bool, u8, u8, u8 *, u8 , u8 *, u8); 159 160 void gm200_hdmi_scdc(struct nvkm_ior *, int, u8); 161 162 void gt215_hda_hpd(struct nvkm_ior *, int, bool); 163 void gt215_hda_eld(struct nvkm_ior *, u8 *, u8); 164 165 void gf119_hda_hpd(struct nvkm_ior *, int, bool); 166 void gf119_hda_eld(struct nvkm_ior *, u8 *, u8); 167 168 #define IOR_MSG(i,l,f,a...) do { \ 169 struct nvkm_ior *_ior = (i); \ 170 nvkm_##l(&_ior->disp->engine.subdev, "%s: "f"\n", _ior->name, ##a); \ 171 } while(0) 172 #define IOR_WARN(i,f,a...) IOR_MSG((i), warn, f, ##a) 173 #define IOR_DBG(i,f,a...) IOR_MSG((i), debug, f, ##a) 174 175 int nv50_dac_cnt(struct nvkm_disp *, unsigned long *); 176 int nv50_dac_new(struct nvkm_disp *, int); 177 178 int gf119_dac_cnt(struct nvkm_disp *, unsigned long *); 179 int gf119_dac_new(struct nvkm_disp *, int); 180 181 int nv50_pior_cnt(struct nvkm_disp *, unsigned long *); 182 int nv50_pior_new(struct nvkm_disp *, int); 183 184 int nv50_sor_cnt(struct nvkm_disp *, unsigned long *); 185 int nv50_sor_new(struct nvkm_disp *, int); 186 187 int g84_sor_new(struct nvkm_disp *, int); 188 189 int g94_sor_cnt(struct nvkm_disp *, unsigned long *); 190 int g94_sor_new(struct nvkm_disp *, int); 191 192 int mcp77_sor_new(struct nvkm_disp *, int); 193 int gt215_sor_new(struct nvkm_disp *, int); 194 int mcp89_sor_new(struct nvkm_disp *, int); 195 196 int gf119_sor_cnt(struct nvkm_disp *, unsigned long *); 197 int gf119_sor_new(struct nvkm_disp *, int); 198 199 int gk104_sor_new(struct nvkm_disp *, int); 200 int gm107_sor_new(struct nvkm_disp *, int); 201 int gm200_sor_new(struct nvkm_disp *, int); 202 203 int gv100_sor_cnt(struct nvkm_disp *, unsigned long *); 204 int gv100_sor_new(struct nvkm_disp *, int); 205 206 int tu102_sor_new(struct nvkm_disp *, int); 207 #endif 208