1 #ifndef __NOUVEAU_DISPLAY_H__
2 #define __NOUVEAU_DISPLAY_H__
3 
4 #include <subdev/mmu.h>
5 
6 #include "nouveau_drv.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 			     const 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 	struct drm_crtc *crtc;
32 	int bpp, pitch;
33 	u64 offset;
34 };
35 
36 struct nouveau_display {
37 	void *priv;
38 	void (*dtor)(struct drm_device *);
39 	int  (*init)(struct drm_device *);
40 	void (*fini)(struct drm_device *);
41 
42 	int  (*fb_ctor)(struct drm_framebuffer *);
43 	void (*fb_dtor)(struct drm_framebuffer *);
44 
45 	struct nvif_object disp;
46 
47 	struct drm_property *dithering_mode;
48 	struct drm_property *dithering_depth;
49 	struct drm_property *underscan_property;
50 	struct drm_property *underscan_hborder_property;
51 	struct drm_property *underscan_vborder_property;
52 	/* not really hue and saturation: */
53 	struct drm_property *vibrant_hue_property;
54 	struct drm_property *color_vibrance_property;
55 };
56 
57 static inline struct nouveau_display *
58 nouveau_display(struct drm_device *dev)
59 {
60 	return nouveau_drm(dev)->display;
61 }
62 
63 int  nouveau_display_create(struct drm_device *dev);
64 void nouveau_display_destroy(struct drm_device *dev);
65 int  nouveau_display_init(struct drm_device *dev);
66 void nouveau_display_fini(struct drm_device *dev);
67 int  nouveau_display_suspend(struct drm_device *dev, bool runtime);
68 void nouveau_display_resume(struct drm_device *dev, bool runtime);
69 int  nouveau_display_vblank_enable(struct drm_device *, unsigned int);
70 void nouveau_display_vblank_disable(struct drm_device *, unsigned int);
71 int  nouveau_display_scanoutpos(struct drm_device *, unsigned int,
72 				unsigned int, int *, int *, ktime_t *,
73 				ktime_t *, const struct drm_display_mode *);
74 int  nouveau_display_vblstamp(struct drm_device *, unsigned int, int *,
75 			      struct timeval *, unsigned);
76 
77 int  nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
78 			    struct drm_pending_vblank_event *event,
79 			    uint32_t page_flip_flags);
80 int  nouveau_finish_page_flip(struct nouveau_channel *,
81 			      struct nouveau_page_flip_state *);
82 
83 int  nouveau_display_dumb_create(struct drm_file *, struct drm_device *,
84 				 struct drm_mode_create_dumb *args);
85 int  nouveau_display_dumb_map_offset(struct drm_file *, struct drm_device *,
86 				     u32 handle, u64 *offset);
87 
88 void nouveau_hdmi_mode_set(struct drm_encoder *, struct drm_display_mode *);
89 
90 int nouveau_crtc_set_config(struct drm_mode_set *set);
91 #ifdef CONFIG_DRM_NOUVEAU_BACKLIGHT
92 extern int nouveau_backlight_init(struct drm_device *);
93 extern void nouveau_backlight_exit(struct drm_device *);
94 #else
95 static inline int
96 nouveau_backlight_init(struct drm_device *dev)
97 {
98 	return 0;
99 }
100 
101 static inline void
102 nouveau_backlight_exit(struct drm_device *dev) {
103 }
104 #endif
105 
106 #endif
107