brintos

brintos / linux-shallow public Read only

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