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