1 /* SPDX-License-Identifier: MIT */
2 #ifndef __NOUVEAU_DISPLAY_H__
3 #define __NOUVEAU_DISPLAY_H__
4
5 #include "nouveau_drv.h"
6
7 #include <nvif/disp.h>
8
9 #include <drm/drm_framebuffer.h>
10
11 struct nouveau_framebuffer {
12 struct drm_framebuffer base;
13 struct nouveau_bo *nvbo;
14 struct nouveau_vma *vma;
15 u32 r_handle;
16 u32 r_format;
17 u32 r_pitch;
18 struct nvif_object h_base[4];
19 struct nvif_object h_core;
20 };
21
22 static inline struct nouveau_framebuffer *
nouveau_framebuffer(struct drm_framebuffer * fb)23 nouveau_framebuffer(struct drm_framebuffer *fb)
24 {
25 return container_of(fb, struct nouveau_framebuffer, base);
26 }
27
28 int nouveau_framebuffer_new(struct drm_device *,
29 const struct drm_mode_fb_cmd2 *,
30 struct nouveau_bo *, struct nouveau_framebuffer **);
31
32 struct nouveau_display {
33 void *priv;
34 void (*dtor)(struct drm_device *);
35 int (*init)(struct drm_device *, bool resume, bool runtime);
36 void (*fini)(struct drm_device *, bool suspend);
37
38 struct nvif_disp disp;
39
40 struct drm_property *dithering_mode;
41 struct drm_property *dithering_depth;
42 struct drm_property *underscan_property;
43 struct drm_property *underscan_hborder_property;
44 struct drm_property *underscan_vborder_property;
45 /* not really hue and saturation: */
46 struct drm_property *vibrant_hue_property;
47 struct drm_property *color_vibrance_property;
48
49 struct drm_atomic_state *suspend;
50 };
51
52 static inline struct nouveau_display *
nouveau_display(struct drm_device * dev)53 nouveau_display(struct drm_device *dev)
54 {
55 return nouveau_drm(dev)->display;
56 }
57
58 int nouveau_display_create(struct drm_device *dev);
59 void nouveau_display_destroy(struct drm_device *dev);
60 int nouveau_display_init(struct drm_device *dev, bool resume, bool runtime);
61 void nouveau_display_fini(struct drm_device *dev, bool suspend, bool runtime);
62 int nouveau_display_suspend(struct drm_device *dev, bool runtime);
63 void nouveau_display_resume(struct drm_device *dev, bool runtime);
64 int nouveau_display_vblank_enable(struct drm_device *, unsigned int);
65 void nouveau_display_vblank_disable(struct drm_device *, unsigned int);
66 bool nouveau_display_scanoutpos(struct drm_device *, unsigned int,
67 bool, int *, int *, ktime_t *,
68 ktime_t *, const struct drm_display_mode *);
69
70 int nouveau_display_dumb_create(struct drm_file *, struct drm_device *,
71 struct drm_mode_create_dumb *args);
72 int nouveau_display_dumb_map_offset(struct drm_file *, struct drm_device *,
73 u32 handle, u64 *offset);
74
75 void nouveau_hdmi_mode_set(struct drm_encoder *, struct drm_display_mode *);
76
77 struct drm_framebuffer *
78 nouveau_user_framebuffer_create(struct drm_device *, struct drm_file *,
79 const struct drm_mode_fb_cmd2 *);
80 #endif
81