drmmode_display.h revision d6c0b56e
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 DamagePtr damage; 77 unsigned fb_id; 78 int width, height; 79}; 80 81typedef struct { 82 drmmode_ptr drmmode; 83 drmModeCrtcPtr mode_crtc; 84 int hw_id; 85 struct amdgpu_buffer *cursor_buffer; 86 struct drmmode_scanout rotate; 87 struct drmmode_scanout scanout[2]; 88 unsigned scanout_id; 89 Bool scanout_update_pending; 90 int dpms_mode; 91 CARD64 dpms_last_ust; 92 uint32_t dpms_last_seq; 93 int dpms_last_fps; 94 uint32_t interpolated_vblanks; 95 uint16_t lut_r[256], lut_g[256], lut_b[256]; 96 int prime_pixmap_x; 97 98 /* Modeset needed for DPMS on */ 99 Bool need_modeset; 100 /* A flip is pending for this CRTC */ 101 Bool flip_pending; 102} drmmode_crtc_private_rec, *drmmode_crtc_private_ptr; 103 104typedef struct { 105 drmModePropertyPtr mode_prop; 106 uint64_t value; 107 int num_atoms; /* if range prop, num_atoms == 1; if enum prop, num_atoms == num_enums + 1 */ 108 Atom *atoms; 109} drmmode_prop_rec, *drmmode_prop_ptr; 110 111typedef struct { 112 drmmode_ptr drmmode; 113 int output_id; 114 drmModeConnectorPtr mode_output; 115 drmModeEncoderPtr *mode_encoders; 116 drmModePropertyBlobPtr edid_blob; 117 int dpms_enum_id; 118 int num_props; 119 drmmode_prop_ptr props; 120 int enc_mask; 121 int enc_clone_mask; 122} drmmode_output_private_rec, *drmmode_output_private_ptr; 123 124extern Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp); 125extern void drmmode_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode); 126extern void drmmode_fini(ScrnInfoPtr pScrn, drmmode_ptr drmmode); 127extern void drmmode_set_cursor(ScrnInfoPtr scrn, drmmode_ptr drmmode, int id, 128 struct amdgpu_buffer *bo); 129void drmmode_adjust_frame(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int x, int y); 130extern Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode, 131 Bool set_hw); 132#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) >= 10 133extern void drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode); 134#endif 135extern Bool drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn); 136 137extern void drmmode_scanout_free(ScrnInfoPtr scrn); 138 139extern void drmmode_uevent_init(ScrnInfoPtr scrn, drmmode_ptr drmmode); 140extern void drmmode_uevent_fini(ScrnInfoPtr scrn, drmmode_ptr drmmode); 141 142extern int drmmode_get_crtc_id(xf86CrtcPtr crtc); 143extern int drmmode_get_pitch_align(ScrnInfoPtr scrn, int bpe); 144Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, 145 PixmapPtr new_front, uint64_t id, void *data, 146 int ref_crtc_hw_id, amdgpu_drm_handler_proc handler, 147 amdgpu_drm_abort_proc abort); 148int drmmode_crtc_get_ust_msc(xf86CrtcPtr crtc, CARD64 *ust, CARD64 *msc); 149int drmmode_get_current_ust(int drm_fd, CARD64 * ust); 150 151#endif 152