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