xref: /linux/drivers/gpu/drm/nouveau/nouveau_display.h (revision ca55b2fef3a9373fcfc30f82fd26bc7fccbda732)
1 #ifndef __NOUVEAU_DISPLAY_H__
2 #define __NOUVEAU_DISPLAY_H__
3 
4 #include <subdev/mmu.h>
5 
6 #include "nouveau_drm.h"
7 
8 struct nouveau_framebuffer {
9 	struct drm_framebuffer base;
10 	struct nouveau_bo *nvbo;
11 	struct nvkm_vma vma;
12 	u32 r_handle;
13 	u32 r_format;
14 	u32 r_pitch;
15 	struct nvif_object h_base[4];
16 	struct nvif_object h_core;
17 };
18 
19 static inline struct nouveau_framebuffer *
20 nouveau_framebuffer(struct drm_framebuffer *fb)
21 {
22 	return container_of(fb, struct nouveau_framebuffer, base);
23 }
24 
25 int nouveau_framebuffer_init(struct drm_device *, struct nouveau_framebuffer *,
26 			     struct drm_mode_fb_cmd2 *, struct nouveau_bo *);
27 
28 struct nouveau_page_flip_state {
29 	struct list_head head;
30 	struct drm_pending_vblank_event *event;
31 	int crtc, bpp, pitch, x, y;
32 	u64 offset;
33 };
34 
35 struct nouveau_display {
36 	void *priv;
37 	void (*dtor)(struct drm_device *);
38 	int  (*init)(struct drm_device *);
39 	void (*fini)(struct drm_device *);
40 
41 	int  (*fb_ctor)(struct drm_framebuffer *);
42 	void (*fb_dtor)(struct drm_framebuffer *);
43 
44 	struct nvif_object disp;
45 
46 	struct drm_property *dithering_mode;
47 	struct drm_property *dithering_depth;
48 	struct drm_property *underscan_property;
49 	struct drm_property *underscan_hborder_property;
50 	struct drm_property *underscan_vborder_property;
51 	/* not really hue and saturation: */
52 	struct drm_property *vibrant_hue_property;
53 	struct drm_property *color_vibrance_property;
54 };
55 
56 static inline struct nouveau_display *
57 nouveau_display(struct drm_device *dev)
58 {
59 	return nouveau_drm(dev)->display;
60 }
61 
62 int  nouveau_display_create(struct drm_device *dev);
63 void nouveau_display_destroy(struct drm_device *dev);
64 int  nouveau_display_init(struct drm_device *dev);
65 void nouveau_display_fini(struct drm_device *dev);
66 int  nouveau_display_suspend(struct drm_device *dev, bool runtime);
67 void nouveau_display_resume(struct drm_device *dev, bool runtime);
68 int  nouveau_display_vblank_enable(struct drm_device *, int);
69 void nouveau_display_vblank_disable(struct drm_device *, int);
70 int  nouveau_display_scanoutpos(struct drm_device *, int, unsigned int,
71 				int *, int *, ktime_t *, ktime_t *);
72 int  nouveau_display_vblstamp(struct drm_device *, int, int *,
73 			      struct timeval *, unsigned);
74 
75 int  nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
76 			    struct drm_pending_vblank_event *event,
77 			    uint32_t page_flip_flags);
78 int  nouveau_finish_page_flip(struct nouveau_channel *,
79 			      struct nouveau_page_flip_state *);
80 
81 int  nouveau_display_dumb_create(struct drm_file *, struct drm_device *,
82 				 struct drm_mode_create_dumb *args);
83 int  nouveau_display_dumb_map_offset(struct drm_file *, struct drm_device *,
84 				     u32 handle, u64 *offset);
85 
86 void nouveau_hdmi_mode_set(struct drm_encoder *, struct drm_display_mode *);
87 
88 int nouveau_crtc_set_config(struct drm_mode_set *set);
89 #ifdef CONFIG_DRM_NOUVEAU_BACKLIGHT
90 extern int nouveau_backlight_init(struct drm_device *);
91 extern void nouveau_backlight_exit(struct drm_device *);
92 #else
93 static inline int
94 nouveau_backlight_init(struct drm_device *dev)
95 {
96 	return 0;
97 }
98 
99 static inline void
100 nouveau_backlight_exit(struct drm_device *dev) {
101 }
102 #endif
103 
104 #endif
105