1 /* SPDX-License-Identifier: MIT */
2 #ifndef __NOUVEAU_DISPLAY_H__
3 #define __NOUVEAU_DISPLAY_H__
4 #include "nouveau_drv.h"
5 #include <nvif/disp.h>
6 
7 struct nouveau_framebuffer {
8 	struct drm_framebuffer base;
9 	struct nouveau_bo *nvbo;
10 	struct nouveau_vma *vma;
11 	u32 r_handle;
12 	u32 r_format;
13 	u32 r_pitch;
14 	struct nvif_object h_base[4];
15 	struct nvif_object h_core;
16 };
17 
18 static inline struct nouveau_framebuffer *
19 nouveau_framebuffer(struct drm_framebuffer *fb)
20 {
21 	return container_of(fb, struct nouveau_framebuffer, base);
22 }
23 
24 int nouveau_framebuffer_new(struct drm_device *,
25 			    const struct drm_mode_fb_cmd2 *,
26 			    struct nouveau_bo *, struct nouveau_framebuffer **);
27 
28 struct nouveau_display {
29 	void *priv;
30 	void (*dtor)(struct drm_device *);
31 	int  (*init)(struct drm_device *, bool resume, bool runtime);
32 	void (*fini)(struct drm_device *, bool suspend);
33 
34 	struct nvif_disp disp;
35 
36 	struct drm_property *dithering_mode;
37 	struct drm_property *dithering_depth;
38 	struct drm_property *underscan_property;
39 	struct drm_property *underscan_hborder_property;
40 	struct drm_property *underscan_vborder_property;
41 	/* not really hue and saturation: */
42 	struct drm_property *vibrant_hue_property;
43 	struct drm_property *color_vibrance_property;
44 
45 	struct drm_atomic_state *suspend;
46 };
47 
48 static inline struct nouveau_display *
49 nouveau_display(struct drm_device *dev)
50 {
51 	return nouveau_drm(dev)->display;
52 }
53 
54 int  nouveau_display_create(struct drm_device *dev);
55 void nouveau_display_destroy(struct drm_device *dev);
56 int  nouveau_display_init(struct drm_device *dev, bool resume, bool runtime);
57 void nouveau_display_fini(struct drm_device *dev, bool suspend, bool runtime);
58 int  nouveau_display_suspend(struct drm_device *dev, bool runtime);
59 void nouveau_display_resume(struct drm_device *dev, bool runtime);
60 int  nouveau_display_vblank_enable(struct drm_device *, unsigned int);
61 void nouveau_display_vblank_disable(struct drm_device *, unsigned int);
62 bool  nouveau_display_scanoutpos(struct drm_device *, unsigned int,
63 				 bool, int *, int *, ktime_t *,
64 				 ktime_t *, const struct drm_display_mode *);
65 
66 int  nouveau_display_dumb_create(struct drm_file *, struct drm_device *,
67 				 struct drm_mode_create_dumb *args);
68 int  nouveau_display_dumb_map_offset(struct drm_file *, struct drm_device *,
69 				     u32 handle, u64 *offset);
70 
71 void nouveau_hdmi_mode_set(struct drm_encoder *, struct drm_display_mode *);
72 
73 struct drm_framebuffer *
74 nouveau_user_framebuffer_create(struct drm_device *, struct drm_file *,
75 				const struct drm_mode_fb_cmd2 *);
76 #endif
77