drmmode_display.h revision 504d986f
1/* 2 * Copyright © 2007 Red Hat, Inc. 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice (including the next 12 * paragraph) shall be included in all copies or substantial portions of the 13 * Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 * SOFTWARE. 22 * 23 * Authors: 24 * Dave Airlie <airlied@redhat.com> 25 * 26 */ 27#ifndef DRMMODE_DISPLAY_H 28#define DRMMODE_DISPLAY_H 29 30#include "xf86drmMode.h" 31#ifdef HAVE_LIBUDEV 32#include "libudev.h" 33#endif 34 35#include "amdgpu_drm_queue.h" 36#include "amdgpu_probe.h" 37#include "amdgpu.h" 38 39#ifndef DRM_CAP_TIMESTAMP_MONOTONIC 40#define DRM_CAP_TIMESTAMP_MONOTONIC 0x6 41#endif 42 43typedef struct { 44 unsigned fb_id; 45 drmModeFBPtr mode_fb; 46 int cpp; 47 ScrnInfoPtr scrn; 48#ifdef HAVE_LIBUDEV 49 struct udev_monitor *uevent_monitor; 50 InputHandlerProc uevent_handler; 51#endif 52 drmEventContext event_context; 53 int count_crtcs; 54 55 Bool delete_dp_12_displays; 56 57 Bool dri2_flipping; 58 Bool present_flipping; 59} drmmode_rec, *drmmode_ptr; 60 61typedef struct { 62 int fd; 63 unsigned old_fb_id; 64 int flip_count; 65 void *event_data; 66 unsigned int fe_frame; 67 uint64_t fe_usec; 68 xf86CrtcPtr fe_crtc; 69 amdgpu_drm_handler_proc handler; 70 amdgpu_drm_abort_proc abort; 71} drmmode_flipdata_rec, *drmmode_flipdata_ptr; 72 73struct drmmode_scanout { 74 struct amdgpu_buffer *bo; 75 PixmapPtr pixmap; 76 unsigned fb_id; 77 int width, height; 78}; 79 80typedef struct { 81 drmmode_ptr drmmode; 82 drmModeCrtcPtr mode_crtc; 83 int hw_id; 84 struct amdgpu_buffer *cursor_buffer; 85 struct drmmode_scanout rotate; 86 struct drmmode_scanout scanout[2]; 87 struct drmmode_scanout scanout_destroy[2]; 88 DamagePtr scanout_damage; 89 RegionRec scanout_last_region; 90 unsigned scanout_id; 91 Bool scanout_update_pending; 92 int dpms_mode; 93 /* For when a flip is pending when DPMS off requested */ 94 int pending_dpms_mode; 95 CARD64 dpms_last_ust; 96 uint32_t dpms_last_seq; 97 int dpms_last_fps; 98 uint32_t interpolated_vblanks; 99 100 /* Modeset needed for DPMS on */ 101 Bool need_modeset; 102 /* A flip is pending for this CRTC */ 103 Bool flip_pending; 104} drmmode_crtc_private_rec, *drmmode_crtc_private_ptr; 105 106typedef struct { 107 drmModePropertyPtr mode_prop; 108 uint64_t value; 109 int num_atoms; /* if range prop, num_atoms == 1; if enum prop, num_atoms == num_enums + 1 */ 110 Atom *atoms; 111} drmmode_prop_rec, *drmmode_prop_ptr; 112 113typedef struct { 114 drmmode_ptr drmmode; 115 int output_id; 116 drmModeConnectorPtr mode_output; 117 drmModeEncoderPtr *mode_encoders; 118 drmModePropertyBlobPtr edid_blob; 119 int dpms_enum_id; 120 int num_props; 121 drmmode_prop_ptr props; 122 int enc_mask; 123 int enc_clone_mask; 124} drmmode_output_private_rec, *drmmode_output_private_ptr; 125 126 127enum drmmode_flip_sync { 128 FLIP_VSYNC, 129 FLIP_ASYNC, 130}; 131 132 133extern Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp); 134extern void drmmode_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode); 135extern void drmmode_fini(ScrnInfoPtr pScrn, drmmode_ptr drmmode); 136extern void drmmode_set_cursor(ScrnInfoPtr scrn, drmmode_ptr drmmode, int id, 137 struct amdgpu_buffer *bo); 138void drmmode_adjust_frame(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int x, int y); 139extern Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode, 140 Bool set_hw); 141extern void drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode); 142extern Bool drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn); 143 144extern void drmmode_scanout_free(ScrnInfoPtr scrn); 145 146extern void drmmode_uevent_init(ScrnInfoPtr scrn, drmmode_ptr drmmode); 147extern void drmmode_uevent_fini(ScrnInfoPtr scrn, drmmode_ptr drmmode); 148 149extern int drmmode_get_crtc_id(xf86CrtcPtr crtc); 150extern int drmmode_get_pitch_align(ScrnInfoPtr scrn, int bpe); 151extern void drmmode_clear_pending_flip(xf86CrtcPtr crtc); 152Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, 153 PixmapPtr new_front, uint64_t id, void *data, 154 int ref_crtc_hw_id, amdgpu_drm_handler_proc handler, 155 amdgpu_drm_abort_proc abort, 156 enum drmmode_flip_sync flip_sync); 157int drmmode_crtc_get_ust_msc(xf86CrtcPtr crtc, CARD64 *ust, CARD64 *msc); 158int drmmode_get_current_ust(int drm_fd, CARD64 * ust); 159 160#endif 161