Home | History | Annotate | Line # | Download | only in dispnv50
      1 /*	$NetBSD: disp.h,v 1.3 2021/12/19 10:49:47 riastradh Exp $	*/
      2 
      3 #ifndef __NV50_KMS_H__
      4 #define __NV50_KMS_H__
      5 #include <nvif/mem.h>
      6 
      7 #include "nouveau_display.h"
      8 
      9 struct nv50_msto;
     10 
     11 struct nv50_disp {
     12 	struct nvif_disp *disp;
     13 	struct nv50_core *core;
     14 
     15 #define NV50_DISP_SYNC(c, o)                                ((c) * 0x040 + (o))
     16 #define NV50_DISP_CORE_NTFY                       NV50_DISP_SYNC(0      , 0x00)
     17 #define NV50_DISP_WNDW_SEM0(c)                    NV50_DISP_SYNC(1 + (c), 0x00)
     18 #define NV50_DISP_WNDW_SEM1(c)                    NV50_DISP_SYNC(1 + (c), 0x10)
     19 #define NV50_DISP_WNDW_NTFY(c)                    NV50_DISP_SYNC(1 + (c), 0x20)
     20 #define NV50_DISP_BASE_SEM0(c)                    NV50_DISP_WNDW_SEM0(0 + (c))
     21 #define NV50_DISP_BASE_SEM1(c)                    NV50_DISP_WNDW_SEM1(0 + (c))
     22 #define NV50_DISP_BASE_NTFY(c)                    NV50_DISP_WNDW_NTFY(0 + (c))
     23 #define NV50_DISP_OVLY_SEM0(c)                    NV50_DISP_WNDW_SEM0(4 + (c))
     24 #define NV50_DISP_OVLY_SEM1(c)                    NV50_DISP_WNDW_SEM1(4 + (c))
     25 #define NV50_DISP_OVLY_NTFY(c)                    NV50_DISP_WNDW_NTFY(4 + (c))
     26 	struct nouveau_bo *sync;
     27 
     28 	struct mutex mutex;
     29 };
     30 
     31 static inline struct nv50_disp *
     32 nv50_disp(struct drm_device *dev)
     33 {
     34 	return nouveau_display(dev)->priv;
     35 }
     36 
     37 struct nv50_disp_interlock {
     38 	enum nv50_disp_interlock_type {
     39 		NV50_DISP_INTERLOCK_CORE = 0,
     40 		NV50_DISP_INTERLOCK_CURS,
     41 		NV50_DISP_INTERLOCK_BASE,
     42 		NV50_DISP_INTERLOCK_OVLY,
     43 		NV50_DISP_INTERLOCK_WNDW,
     44 		NV50_DISP_INTERLOCK_WIMM,
     45 		NV50_DISP_INTERLOCK__SIZE
     46 	} type;
     47 	u32 data;
     48 	u32 wimm;
     49 };
     50 
     51 void corec37d_ntfy_init(struct nouveau_bo *, u32);
     52 
     53 #ifdef __NetBSD__
     54 #  define	__lut_iomem	volatile
     55 #  define	__iomem		__lut_iomem
     56 #endif
     57 
     58 void head907d_olut_load(struct drm_color_lut *, int size, void __iomem *);
     59 
     60 #ifdef __NetBSD__
     61 #  undef	__iomem
     62 #endif
     63 
     64 struct nv50_chan {
     65 	struct nvif_object user;
     66 	struct nvif_device *device;
     67 };
     68 
     69 struct nv50_dmac {
     70 	struct nv50_chan base;
     71 
     72 	struct nvif_mem push;
     73 	u32 *ptr;
     74 
     75 	struct nvif_object sync;
     76 	struct nvif_object vram;
     77 
     78 	/* Protects against concurrent pushbuf access to this channel, lock is
     79 	 * grabbed by evo_wait (if the pushbuf reservation is successful) and
     80 	 * dropped again by evo_kick. */
     81 	struct spinlock lock;
     82 };
     83 
     84 int nv50_dmac_create(struct nvif_device *device, struct nvif_object *disp,
     85 		     const s32 *oclass, u8 head, void *data, u32 size,
     86 		     u64 syncbuf, struct nv50_dmac *dmac);
     87 void nv50_dmac_destroy(struct nv50_dmac *);
     88 
     89 u32 *evo_wait(struct nv50_dmac *, int nr);
     90 void evo_kick(u32 *, struct nv50_dmac *);
     91 
     92 #define evo_mthd(p, m, s) do {						\
     93 	const u32 _m = (m), _s = (s);					\
     94 	if (drm_debug_enabled(DRM_UT_KMS))				\
     95 		pr_err("%04x %d %s\n", _m, _s, __func__);		\
     96 	*((p)++) = ((_s << 18) | _m);					\
     97 } while(0)
     98 
     99 #define evo_data(p, d) do {						\
    100 	const u32 _d = (d);						\
    101 	if (drm_debug_enabled(DRM_UT_KMS))				\
    102 		pr_err("\t%08x\n", _d);					\
    103 	*((p)++) = _d;							\
    104 } while(0)
    105 #endif
    106