blob: 856abe0f070d0335b198d57b745c2fa247a5e7c6 [file] [log] [blame]
Ben Skeggs77145f12012-07-31 16:16:21 +10001#ifndef __NOUVEAU_DISPLAY_H__
2#define __NOUVEAU_DISPLAY_H__
3
Ben Skeggs5ce3bf32015-01-14 09:57:36 +10004#include <subdev/mmu.h>
Ben Skeggs77145f12012-07-31 16:16:21 +10005
6#include "nouveau_drm.h"
7
8struct nouveau_framebuffer {
9 struct drm_framebuffer base;
10 struct nouveau_bo *nvbo;
Ben Skeggsbe83cd42015-01-14 15:36:34 +100011 struct nvkm_vma vma;
Ben Skeggs8a423642014-08-10 04:10:19 +100012 u32 r_handle;
Ben Skeggs77145f12012-07-31 16:16:21 +100013 u32 r_format;
14 u32 r_pitch;
Ben Skeggs0ad72862014-08-10 04:10:22 +100015 struct nvif_object h_base[4];
16 struct nvif_object h_core;
Ben Skeggs77145f12012-07-31 16:16:21 +100017};
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_init(struct drm_device *, struct nouveau_framebuffer *,
26 struct drm_mode_fb_cmd2 *, struct nouveau_bo *);
27
28struct nouveau_page_flip_state {
29 struct list_head head;
30 struct drm_pending_vblank_event *event;
31 int crtc, bpp, pitch, x, y;
32 u64 offset;
33};
34
35struct nouveau_display {
36 void *priv;
37 void (*dtor)(struct drm_device *);
38 int (*init)(struct drm_device *);
39 void (*fini)(struct drm_device *);
40
Ben Skeggsab0af552014-08-10 04:10:19 +100041 int (*fb_ctor)(struct drm_framebuffer *);
42 void (*fb_dtor)(struct drm_framebuffer *);
43
Ben Skeggs0ad72862014-08-10 04:10:22 +100044 struct nvif_object disp;
Ben Skeggsab0af552014-08-10 04:10:19 +100045
Ben Skeggs77145f12012-07-31 16:16:21 +100046 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;
54};
55
56static inline struct nouveau_display *
57nouveau_display(struct drm_device *dev)
58{
59 return nouveau_drm(dev)->display;
60}
61
62int nouveau_display_create(struct drm_device *dev);
63void nouveau_display_destroy(struct drm_device *dev);
64int nouveau_display_init(struct drm_device *dev);
65void nouveau_display_fini(struct drm_device *dev);
Ben Skeggs6fbb7022014-10-02 13:22:27 +100066int nouveau_display_suspend(struct drm_device *dev, bool runtime);
67void nouveau_display_resume(struct drm_device *dev, bool runtime);
Thierry Reding88e72712015-09-24 18:35:31 +020068int nouveau_display_vblank_enable(struct drm_device *, unsigned int);
69void nouveau_display_vblank_disable(struct drm_device *, unsigned int);
70int nouveau_display_scanoutpos(struct drm_device *, unsigned int,
71 unsigned int, int *, int *, ktime_t *,
72 ktime_t *, const struct drm_display_mode *);
73int nouveau_display_vblstamp(struct drm_device *, unsigned int, int *,
Ben Skeggsd83ef852013-11-14 13:37:49 +100074 struct timeval *, unsigned);
Ben Skeggs77145f12012-07-31 16:16:21 +100075
Ben Skeggs77145f12012-07-31 16:16:21 +100076int nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
Keith Packarded8d1972013-07-22 18:49:58 -070077 struct drm_pending_vblank_event *event,
78 uint32_t page_flip_flags);
Ben Skeggs77145f12012-07-31 16:16:21 +100079int 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);
Ben Skeggs77145f12012-07-31 16:16:21 +100086
87void nouveau_hdmi_mode_set(struct drm_encoder *, struct drm_display_mode *);
88
Dave Airlie5addcf02012-09-10 14:20:51 +100089int nouveau_crtc_set_config(struct drm_mode_set *set);
Ben Skeggs77145f12012-07-31 16:16:21 +100090#ifdef CONFIG_DRM_NOUVEAU_BACKLIGHT
91extern int nouveau_backlight_init(struct drm_device *);
92extern void nouveau_backlight_exit(struct drm_device *);
93#else
94static inline int
95nouveau_backlight_init(struct drm_device *dev)
96{
97 return 0;
98}
99
100static inline void
101nouveau_backlight_exit(struct drm_device *dev) {
102}
103#endif
104
105#endif