Merge 4.14.73 into android-4.14-p
[GitHub/moto-9609/android_kernel_motorola_exynos9610.git] / drivers / gpu / drm / nouveau / nouveau_display.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
77145f1c
BS
2#ifndef __NOUVEAU_DISPLAY_H__
3#define __NOUVEAU_DISPLAY_H__
4
5ce3bf3c 5#include <subdev/mmu.h>
77145f1c 6
4dc28134 7#include "nouveau_drv.h"
77145f1c
BS
8
9struct nouveau_framebuffer {
10 struct drm_framebuffer base;
11 struct nouveau_bo *nvbo;
be83cd4e 12 struct nvkm_vma vma;
8a423647 13 u32 r_handle;
77145f1c
BS
14 u32 r_format;
15 u32 r_pitch;
0ad72863
BS
16 struct nvif_object h_base[4];
17 struct nvif_object h_core;
77145f1c
BS
18};
19
20static inline struct nouveau_framebuffer *
21nouveau_framebuffer(struct drm_framebuffer *fb)
22{
23 return container_of(fb, struct nouveau_framebuffer, base);
24}
25
1608a0fb
BS
26int nouveau_framebuffer_new(struct drm_device *,
27 const struct drm_mode_fb_cmd2 *,
28 struct nouveau_bo *, struct nouveau_framebuffer **);
77145f1c
BS
29
30struct nouveau_page_flip_state {
31 struct list_head head;
32 struct drm_pending_vblank_event *event;
dc4ff116
GP
33 struct drm_crtc *crtc;
34 int bpp, pitch;
77145f1c
BS
35 u64 offset;
36};
37
38struct nouveau_display {
39 void *priv;
40 void (*dtor)(struct drm_device *);
41 int (*init)(struct drm_device *);
42 void (*fini)(struct drm_device *);
43
0ad72863 44 struct nvif_object disp;
ab0af559 45
77145f1c
BS
46 struct drm_property *dithering_mode;
47 struct drm_property *dithering_depth;
48 struct drm_property *underscan_property;
49 struct drm_property *underscan_hborder_property;
50 struct drm_property *underscan_vborder_property;
51 /* not really hue and saturation: */
52 struct drm_property *vibrant_hue_property;
53 struct drm_property *color_vibrance_property;
b167db0e
BS
54
55 struct drm_atomic_state *suspend;
77145f1c
BS
56};
57
58static inline struct nouveau_display *
59nouveau_display(struct drm_device *dev)
60{
61 return nouveau_drm(dev)->display;
62}
63
64int nouveau_display_create(struct drm_device *dev);
65void nouveau_display_destroy(struct drm_device *dev);
66int nouveau_display_init(struct drm_device *dev);
9ac837e0 67void nouveau_display_fini(struct drm_device *dev, bool suspend, bool runtime);
6fbb702e
BS
68int nouveau_display_suspend(struct drm_device *dev, bool runtime);
69void nouveau_display_resume(struct drm_device *dev, bool runtime);
88e72717
TR
70int nouveau_display_vblank_enable(struct drm_device *, unsigned int);
71void nouveau_display_vblank_disable(struct drm_device *, unsigned int);
1bf6ad62
DV
72bool nouveau_display_scanoutpos(struct drm_device *, unsigned int,
73 bool, int *, int *, ktime_t *,
74 ktime_t *, const struct drm_display_mode *);
77145f1c 75
77145f1c 76int nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
ed8d1975 77 struct drm_pending_vblank_event *event,
41292b1f
DV
78 uint32_t page_flip_flags,
79 struct drm_modeset_acquire_ctx *ctx);
77145f1c
BS
80int nouveau_finish_page_flip(struct nouveau_channel *,
81 struct nouveau_page_flip_state *);
82
83int nouveau_display_dumb_create(struct drm_file *, struct drm_device *,
84 struct drm_mode_create_dumb *args);
85int nouveau_display_dumb_map_offset(struct drm_file *, struct drm_device *,
86 u32 handle, u64 *offset);
77145f1c
BS
87
88void nouveau_hdmi_mode_set(struct drm_encoder *, struct drm_display_mode *);
89
90#ifdef CONFIG_DRM_NOUVEAU_BACKLIGHT
91extern int nouveau_backlight_init(struct drm_device *);
92extern void nouveau_backlight_exit(struct drm_device *);
db1a0ae2
PM
93extern void nouveau_backlight_ctor(void);
94extern void nouveau_backlight_dtor(void);
77145f1c
BS
95#else
96static inline int
97nouveau_backlight_init(struct drm_device *dev)
98{
99 return 0;
100}
101
102static inline void
103nouveau_backlight_exit(struct drm_device *dev) {
104}
db1a0ae2
PM
105
106static inline void
107nouveau_backlight_ctor(void) {
108}
109
110static inline void
111nouveau_backlight_dtor(void) {
112}
77145f1c
BS
113#endif
114
839ca903
BS
115struct drm_framebuffer *
116nouveau_user_framebuffer_create(struct drm_device *, struct drm_file *,
117 const struct drm_mode_fb_cmd2 *);
77145f1c 118#endif