Merge tag 'please-pull-gettime_vsyscall_update' of git://git.kernel.org/pub/scm/linux...
[sfrench/cifs-2.6.git] / drivers / gpu / drm / nouveau / nouveau_display.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __NOUVEAU_DISPLAY_H__
3 #define __NOUVEAU_DISPLAY_H__
4
5 #include <subdev/mmu.h>
6
7 #include "nouveau_drv.h"
8
9 struct nouveau_framebuffer {
10         struct drm_framebuffer base;
11         struct nouveau_bo *nvbo;
12         struct nvkm_vma vma;
13         u32 r_handle;
14         u32 r_format;
15         u32 r_pitch;
16         struct nvif_object h_base[4];
17         struct nvif_object h_core;
18 };
19
20 static inline struct nouveau_framebuffer *
21 nouveau_framebuffer(struct drm_framebuffer *fb)
22 {
23         return container_of(fb, struct nouveau_framebuffer, base);
24 }
25
26 int nouveau_framebuffer_new(struct drm_device *,
27                             const struct drm_mode_fb_cmd2 *,
28                             struct nouveau_bo *, struct nouveau_framebuffer **);
29
30 struct nouveau_page_flip_state {
31         struct list_head head;
32         struct drm_pending_vblank_event *event;
33         struct drm_crtc *crtc;
34         int bpp, pitch;
35         u64 offset;
36 };
37
38 struct nouveau_display {
39         void *priv;
40         void (*dtor)(struct drm_device *);
41         int  (*init)(struct drm_device *);
42         void (*fini)(struct drm_device *);
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         struct drm_atomic_state *suspend;
56 };
57
58 static inline struct nouveau_display *
59 nouveau_display(struct drm_device *dev)
60 {
61         return nouveau_drm(dev)->display;
62 }
63
64 int  nouveau_display_create(struct drm_device *dev);
65 void nouveau_display_destroy(struct drm_device *dev);
66 int  nouveau_display_init(struct drm_device *dev);
67 void nouveau_display_fini(struct drm_device *dev, bool suspend);
68 int  nouveau_display_suspend(struct drm_device *dev, bool runtime);
69 void nouveau_display_resume(struct drm_device *dev, bool runtime);
70 int  nouveau_display_vblank_enable(struct drm_device *, unsigned int);
71 void nouveau_display_vblank_disable(struct drm_device *, unsigned int);
72 bool  nouveau_display_scanoutpos(struct drm_device *, unsigned int,
73                                  bool, int *, int *, ktime_t *,
74                                  ktime_t *, const struct drm_display_mode *);
75
76 int  nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
77                             struct drm_pending_vblank_event *event,
78                             uint32_t page_flip_flags,
79                             struct drm_modeset_acquire_ctx *ctx);
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 #ifdef CONFIG_DRM_NOUVEAU_BACKLIGHT
91 extern int nouveau_backlight_init(struct drm_device *);
92 extern void nouveau_backlight_exit(struct drm_device *);
93 extern void nouveau_backlight_ctor(void);
94 extern void nouveau_backlight_dtor(void);
95 #else
96 static inline int
97 nouveau_backlight_init(struct drm_device *dev)
98 {
99         return 0;
100 }
101
102 static inline void
103 nouveau_backlight_exit(struct drm_device *dev) {
104 }
105
106 static inline void
107 nouveau_backlight_ctor(void) {
108 }
109
110 static inline void
111 nouveau_backlight_dtor(void) {
112 }
113 #endif
114
115 struct drm_framebuffer *
116 nouveau_user_framebuffer_create(struct drm_device *, struct drm_file *,
117                                 const struct drm_mode_fb_cmd2 *);
118 #endif