nouveau_display.h revision 1.2 1 /* $NetBSD: nouveau_display.h,v 1.2 2018/08/27 04:58:24 riastradh Exp $ */
2
3 #ifndef __NOUVEAU_DISPLAY_H__
4 #define __NOUVEAU_DISPLAY_H__
5
6 #include <subdev/mmu.h>
7
8 #include "nouveau_drm.h"
9
10 struct nouveau_framebuffer {
11 struct drm_framebuffer base;
12 struct nouveau_bo *nvbo;
13 struct nvkm_vma vma;
14 u32 r_handle;
15 u32 r_format;
16 u32 r_pitch;
17 struct nvif_object h_base[4];
18 struct nvif_object h_core;
19 };
20
21 static inline struct nouveau_framebuffer *
22 nouveau_framebuffer(struct drm_framebuffer *fb)
23 {
24 return container_of(fb, struct nouveau_framebuffer, base);
25 }
26
27 int nouveau_framebuffer_init(struct drm_device *, struct nouveau_framebuffer *,
28 struct drm_mode_fb_cmd2 *, struct nouveau_bo *);
29
30 struct nouveau_page_flip_state {
31 struct list_head head;
32 struct drm_pending_vblank_event *event;
33 int crtc, bpp, pitch, x, y;
34 u64 offset;
35 };
36
37 struct nouveau_display {
38 void *priv;
39 void (*dtor)(struct drm_device *);
40 int (*init)(struct drm_device *);
41 void (*fini)(struct drm_device *);
42
43 int (*fb_ctor)(struct drm_framebuffer *);
44 void (*fb_dtor)(struct drm_framebuffer *);
45
46 struct nvif_object disp;
47
48 struct drm_property *dithering_mode;
49 struct drm_property *dithering_depth;
50 struct drm_property *underscan_property;
51 struct drm_property *underscan_hborder_property;
52 struct drm_property *underscan_vborder_property;
53 /* not really hue and saturation: */
54 struct drm_property *vibrant_hue_property;
55 struct drm_property *color_vibrance_property;
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);
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 int nouveau_display_scanoutpos(struct drm_device *, unsigned int,
73 unsigned int, int *, int *, ktime_t *,
74 ktime_t *, const struct drm_display_mode *);
75 int nouveau_display_vblstamp(struct drm_device *, unsigned int, int *,
76 struct timeval *, unsigned);
77
78 int nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
79 struct drm_pending_vblank_event *event,
80 uint32_t page_flip_flags);
81 int nouveau_finish_page_flip(struct nouveau_channel *,
82 struct nouveau_page_flip_state *);
83
84 int nouveau_display_dumb_create(struct drm_file *, struct drm_device *,
85 struct drm_mode_create_dumb *args);
86 int nouveau_display_dumb_map_offset(struct drm_file *, struct drm_device *,
87 u32 handle, u64 *offset);
88
89 void nouveau_hdmi_mode_set(struct drm_encoder *, struct drm_display_mode *);
90
91 int nouveau_crtc_set_config(struct drm_mode_set *set);
92 #ifdef CONFIG_DRM_NOUVEAU_BACKLIGHT
93 extern int nouveau_backlight_init(struct drm_device *);
94 extern void nouveau_backlight_exit(struct drm_device *);
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 #endif
106
107 #endif
108