Merge tag 'docs-4.15-2' of git://git.lwn.net/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 #include "nouveau_drv.h"
5
6 struct nouveau_framebuffer {
7         struct drm_framebuffer base;
8         struct nouveau_bo *nvbo;
9         struct nouveau_vma *vma;
10         u32 r_handle;
11         u32 r_format;
12         u32 r_pitch;
13         struct nvif_object h_base[4];
14         struct nvif_object h_core;
15 };
16
17 static inline struct nouveau_framebuffer *
18 nouveau_framebuffer(struct drm_framebuffer *fb)
19 {
20         return container_of(fb, struct nouveau_framebuffer, base);
21 }
22
23 int nouveau_framebuffer_new(struct drm_device *,
24                             const struct drm_mode_fb_cmd2 *,
25                             struct nouveau_bo *, struct nouveau_framebuffer **);
26
27 struct nouveau_page_flip_state {
28         struct list_head head;
29         struct drm_pending_vblank_event *event;
30         struct drm_crtc *crtc;
31         int bpp, pitch;
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         struct nvif_object disp;
42
43         struct drm_property *dithering_mode;
44         struct drm_property *dithering_depth;
45         struct drm_property *underscan_property;
46         struct drm_property *underscan_hborder_property;
47         struct drm_property *underscan_vborder_property;
48         /* not really hue and saturation: */
49         struct drm_property *vibrant_hue_property;
50         struct drm_property *color_vibrance_property;
51
52         struct drm_atomic_state *suspend;
53 };
54
55 static inline struct nouveau_display *
56 nouveau_display(struct drm_device *dev)
57 {
58         return nouveau_drm(dev)->display;
59 }
60
61 int  nouveau_display_create(struct drm_device *dev);
62 void nouveau_display_destroy(struct drm_device *dev);
63 int  nouveau_display_init(struct drm_device *dev);
64 void nouveau_display_fini(struct drm_device *dev, bool suspend);
65 int  nouveau_display_suspend(struct drm_device *dev, bool runtime);
66 void nouveau_display_resume(struct drm_device *dev, bool runtime);
67 int  nouveau_display_vblank_enable(struct drm_device *, unsigned int);
68 void nouveau_display_vblank_disable(struct drm_device *, unsigned int);
69 bool  nouveau_display_scanoutpos(struct drm_device *, unsigned int,
70                                  bool, int *, int *, ktime_t *,
71                                  ktime_t *, const struct drm_display_mode *);
72
73 int  nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
74                             struct drm_pending_vblank_event *event,
75                             uint32_t page_flip_flags,
76                             struct drm_modeset_acquire_ctx *ctx);
77 int  nouveau_finish_page_flip(struct nouveau_channel *,
78                               struct nouveau_page_flip_state *);
79
80 int  nouveau_display_dumb_create(struct drm_file *, struct drm_device *,
81                                  struct drm_mode_create_dumb *args);
82 int  nouveau_display_dumb_map_offset(struct drm_file *, struct drm_device *,
83                                      u32 handle, u64 *offset);
84
85 void nouveau_hdmi_mode_set(struct drm_encoder *, struct drm_display_mode *);
86
87 #ifdef CONFIG_DRM_NOUVEAU_BACKLIGHT
88 extern int nouveau_backlight_init(struct drm_device *);
89 extern void nouveau_backlight_exit(struct drm_device *);
90 extern void nouveau_backlight_ctor(void);
91 extern void nouveau_backlight_dtor(void);
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
103 static inline void
104 nouveau_backlight_ctor(void) {
105 }
106
107 static inline void
108 nouveau_backlight_dtor(void) {
109 }
110 #endif
111
112 struct drm_framebuffer *
113 nouveau_user_framebuffer_create(struct drm_device *, struct drm_file *,
114                                 const struct drm_mode_fb_cmd2 *);
115 #endif