1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __NOUVEAU_DISPLAY_H__
3 #define __NOUVEAU_DISPLAY_H__
4 #include "nouveau_drv.h"
5 #include <nvif/disp.h>
6
7 struct nouveau_framebuffer {
8 struct drm_framebuffer base;
9 struct nouveau_bo *nvbo;
10 struct nouveau_vma *vma;
11 u32 r_handle;
12 u32 r_format;
13 u32 r_pitch;
14 struct nvif_object h_base[4];
15 struct nvif_object h_core;
16 };
17
18 static inline struct nouveau_framebuffer *
nouveau_framebuffer(struct drm_framebuffer * fb)19 nouveau_framebuffer(struct drm_framebuffer *fb)
20 {
21 return container_of(fb, struct nouveau_framebuffer, base);
22 }
23
24 int nouveau_framebuffer_new(struct drm_device *,
25 const struct drm_mode_fb_cmd2 *,
26 struct nouveau_bo *, struct nouveau_framebuffer **);
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 struct nvif_disp disp;
43
44 struct drm_property *dithering_mode;
45 struct drm_property *dithering_depth;
46 struct drm_property *underscan_property;
47 struct drm_property *underscan_hborder_property;
48 struct drm_property *underscan_vborder_property;
49 /* not really hue and saturation: */
50 struct drm_property *vibrant_hue_property;
51 struct drm_property *color_vibrance_property;
52
53 struct drm_atomic_state *suspend;
54 };
55
56 static inline struct nouveau_display *
nouveau_display(struct drm_device * dev)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, bool suspend, bool runtime);
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 *, unsigned int);
69 void nouveau_display_vblank_disable(struct drm_device *, unsigned int);
70 bool nouveau_display_scanoutpos(struct drm_device *, unsigned int,
71 bool, int *, int *, ktime_t *,
72 ktime_t *, const struct drm_display_mode *);
73
74 int nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
75 struct drm_pending_vblank_event *event,
76 uint32_t page_flip_flags,
77 struct drm_modeset_acquire_ctx *ctx);
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 #ifdef CONFIG_DRM_NOUVEAU_BACKLIGHT
89 extern int nouveau_backlight_init(struct drm_device *);
90 extern void nouveau_backlight_exit(struct drm_device *);
91 extern void nouveau_backlight_ctor(void);
92 extern void nouveau_backlight_dtor(void);
93 #else
94 static inline int
nouveau_backlight_init(struct drm_device * dev)95 nouveau_backlight_init(struct drm_device *dev)
96 {
97 return 0;
98 }
99
100 static inline void
nouveau_backlight_exit(struct drm_device * dev)101 nouveau_backlight_exit(struct drm_device *dev) {
102 }
103
104 static inline void
nouveau_backlight_ctor(void)105 nouveau_backlight_ctor(void) {
106 }
107
108 static inline void
nouveau_backlight_dtor(void)109 nouveau_backlight_dtor(void) {
110 }
111 #endif
112
113 struct drm_framebuffer *
114 nouveau_user_framebuffer_create(struct drm_device *, struct drm_file *,
115 const struct drm_mode_fb_cmd2 *);
116 #endif
117