drmmode_display.h revision 3ed65abb
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 "radeon_drm_queue.h" 36#include "radeon_probe.h" 37 38#ifndef DRM_CAP_TIMESTAMP_MONOTONIC 39#define DRM_CAP_TIMESTAMP_MONOTONIC 0x6 40#endif 41 42typedef struct { 43 int fd; 44 unsigned fb_id; 45 drmModeFBPtr mode_fb; 46 int cpp; 47 struct radeon_bo_manager *bufmgr; 48 ScrnInfoPtr scrn; 49#ifdef HAVE_LIBUDEV 50 struct udev_monitor *uevent_monitor; 51 InputHandlerProc uevent_handler; 52#endif 53 drmEventContext event_context; 54 int count_crtcs; 55 56 Bool delete_dp_12_displays; 57 58 Bool dri2_flipping; 59 Bool present_flipping; 60} drmmode_rec, *drmmode_ptr; 61 62typedef struct { 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 radeon_drm_handler_proc handler; 70 radeon_drm_abort_proc abort; 71} drmmode_flipdata_rec, *drmmode_flipdata_ptr; 72 73struct drmmode_scanout { 74 struct radeon_bo *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 radeon_bo *cursor_bo; 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 Bool tear_free; 93 int dpms_mode; 94 /* For when a flip is pending when DPMS off requested */ 95 int pending_dpms_mode; 96 CARD64 dpms_last_ust; 97 uint32_t dpms_last_seq; 98 int dpms_last_fps; 99 uint32_t interpolated_vblanks; 100 101 /* Modeset needed (for DPMS on or after a page flip crossing with a 102 * modeset) 103 */ 104 Bool need_modeset; 105 /* A flip is pending for this CRTC */ 106 Bool flip_pending; 107} drmmode_crtc_private_rec, *drmmode_crtc_private_ptr; 108 109typedef struct { 110 drmModePropertyPtr mode_prop; 111 uint64_t value; 112 int num_atoms; /* if range prop, num_atoms == 1; if enum prop, num_atoms == num_enums + 1 */ 113 Atom *atoms; 114} drmmode_prop_rec, *drmmode_prop_ptr; 115 116 117typedef struct { 118 drmmode_ptr drmmode; 119 int output_id; 120 drmModeConnectorPtr mode_output; 121 drmModeEncoderPtr *mode_encoders; 122 drmModePropertyBlobPtr edid_blob; 123 int dpms_enum_id; 124 int num_props; 125 drmmode_prop_ptr props; 126 int enc_mask; 127 int enc_clone_mask; 128 int tear_free; 129} drmmode_output_private_rec, *drmmode_output_private_ptr; 130 131 132enum drmmode_flip_sync { 133 FLIP_VSYNC, 134 FLIP_ASYNC, 135}; 136 137 138extern int drmmode_page_flip_target_absolute(RADEONEntPtr pRADEONEnt, 139 drmmode_crtc_private_ptr drmmode_crtc, 140 int fb_id, uint32_t flags, 141 uintptr_t drm_queue_seq, 142 uint32_t target_msc); 143extern int drmmode_page_flip_target_relative(RADEONEntPtr pRADEONEnt, 144 drmmode_crtc_private_ptr drmmode_crtc, 145 int fb_id, uint32_t flags, 146 uintptr_t drm_queue_seq, 147 uint32_t target_msc); 148extern Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp); 149extern void drmmode_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode); 150extern void drmmode_fini(ScrnInfoPtr pScrn, drmmode_ptr drmmode); 151extern Bool drmmode_set_bufmgr(ScrnInfoPtr pScrn, drmmode_ptr drmmode, struct radeon_bo_manager *bufmgr); 152extern void drmmode_set_cursor(ScrnInfoPtr scrn, drmmode_ptr drmmode, int id, struct radeon_bo *bo); 153void drmmode_adjust_frame(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int x, int y); 154extern Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode, 155 Bool set_hw); 156extern void drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode); 157extern Bool drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn); 158 159extern void drmmode_scanout_free(ScrnInfoPtr scrn); 160 161extern void drmmode_uevent_init(ScrnInfoPtr scrn, drmmode_ptr drmmode); 162extern void drmmode_uevent_fini(ScrnInfoPtr scrn, drmmode_ptr drmmode); 163 164extern int drmmode_get_crtc_id(xf86CrtcPtr crtc); 165extern int drmmode_get_height_align(ScrnInfoPtr scrn, uint32_t tiling); 166extern int drmmode_get_pitch_align(ScrnInfoPtr scrn, int bpe, uint32_t tiling); 167extern int drmmode_get_base_align(ScrnInfoPtr scrn, int bpe, uint32_t tiling); 168extern void drmmode_clear_pending_flip(xf86CrtcPtr crtc); 169 170Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, 171 uint32_t new_front_handle, uint64_t id, void *data, 172 int ref_crtc_hw_id, radeon_drm_handler_proc handler, 173 radeon_drm_abort_proc abort, 174 enum drmmode_flip_sync flip_sync, 175 uint32_t target_msc); 176int drmmode_crtc_get_ust_msc(xf86CrtcPtr crtc, CARD64 *ust, CARD64 *msc); 177int drmmode_get_current_ust(int drm_fd, CARD64 *ust); 178 179#endif 180 181