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