drmmode_display.h revision de2362d3
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_probe.h" 36 37#ifndef DRM_CAP_TIMESTAMP_MONOTONIC 38#define DRM_CAP_TIMESTAMP_MONOTONIC 0x6 39#endif 40 41typedef struct { 42 int fd; 43 unsigned fb_id; 44 drmModeResPtr mode_res; 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} drmmode_rec, *drmmode_ptr; 55 56typedef struct { 57 drmmode_ptr drmmode; 58 unsigned old_fb_id; 59 int flip_count; 60 void *event_data; 61 unsigned int fe_frame; 62 unsigned int fe_tv_sec; 63 unsigned int fe_tv_usec; 64} drmmode_flipdata_rec, *drmmode_flipdata_ptr; 65 66typedef struct { 67 drmmode_flipdata_ptr flipdata; 68 Bool dispatch_me; 69} drmmode_flipevtcarrier_rec, *drmmode_flipevtcarrier_ptr; 70 71typedef struct { 72 drmmode_ptr drmmode; 73 drmModeCrtcPtr mode_crtc; 74 int hw_id; 75 struct radeon_bo *cursor_bo; 76 struct radeon_bo *rotate_bo; 77 unsigned rotate_fb_id; 78 int dpms_mode; 79 CARD64 dpms_last_ust; 80 uint32_t dpms_last_seq; 81 int dpms_last_fps; 82 uint32_t interpolated_vblanks; 83 uint16_t lut_r[256], lut_g[256], lut_b[256]; 84 int scanout_pixmap_x; 85} drmmode_crtc_private_rec, *drmmode_crtc_private_ptr; 86 87typedef struct { 88 drmModePropertyPtr mode_prop; 89 uint64_t value; 90 int num_atoms; /* if range prop, num_atoms == 1; if enum prop, num_atoms == num_enums + 1 */ 91 Atom *atoms; 92} drmmode_prop_rec, *drmmode_prop_ptr; 93 94 95typedef struct { 96 drmmode_ptr drmmode; 97 int output_id; 98 drmModeConnectorPtr mode_output; 99 drmModeEncoderPtr *mode_encoders; 100 drmModePropertyBlobPtr edid_blob; 101 int dpms_enum_id; 102 int num_props; 103 drmmode_prop_ptr props; 104 int enc_mask; 105 int enc_clone_mask; 106} drmmode_output_private_rec, *drmmode_output_private_ptr; 107 108 109extern Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp); 110extern void drmmode_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode); 111extern void drmmode_fini(ScrnInfoPtr pScrn, drmmode_ptr drmmode); 112extern Bool drmmode_set_bufmgr(ScrnInfoPtr pScrn, drmmode_ptr drmmode, struct radeon_bo_manager *bufmgr); 113extern void drmmode_set_cursor(ScrnInfoPtr scrn, drmmode_ptr drmmode, int id, struct radeon_bo *bo); 114void drmmode_adjust_frame(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int x, int y); 115extern Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode); 116extern void drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode); 117extern Bool drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn); 118 119extern void drmmode_uevent_init(ScrnInfoPtr scrn, drmmode_ptr drmmode); 120extern void drmmode_uevent_fini(ScrnInfoPtr scrn, drmmode_ptr drmmode); 121 122extern int drmmode_get_height_align(ScrnInfoPtr scrn, uint32_t tiling); 123extern int drmmode_get_pitch_align(ScrnInfoPtr scrn, int bpe, uint32_t tiling); 124extern int drmmode_get_base_align(ScrnInfoPtr scrn, int bpe, uint32_t tiling); 125 126Bool radeon_do_pageflip(ScrnInfoPtr scrn, struct radeon_bo *new_front, void *data, int ref_crtc_hw_id); 127int drmmode_get_current_ust(int drm_fd, CARD64 *ust); 128 129#endif 130 131