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