drmmode_display.h revision 18781e08
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    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 or after a page flip crossing with a
101     * modeset)
102     */
103    Bool need_modeset;
104    /* A flip is pending for this CRTC */
105    Bool flip_pending;
106} drmmode_crtc_private_rec, *drmmode_crtc_private_ptr;
107
108typedef struct {
109    drmModePropertyPtr mode_prop;
110    uint64_t value;
111    int num_atoms; /* if range prop, num_atoms == 1; if enum prop, num_atoms == num_enums + 1 */
112    Atom *atoms;
113} drmmode_prop_rec, *drmmode_prop_ptr;
114
115
116typedef struct {
117    drmmode_ptr drmmode;
118    int output_id;
119    drmModeConnectorPtr mode_output;
120    drmModeEncoderPtr *mode_encoders;
121    drmModePropertyBlobPtr edid_blob;
122    int dpms_enum_id;
123    int num_props;
124    drmmode_prop_ptr props;
125    int enc_mask;
126    int enc_clone_mask;
127} drmmode_output_private_rec, *drmmode_output_private_ptr;
128
129
130enum drmmode_flip_sync {
131    FLIP_VSYNC,
132    FLIP_ASYNC,
133};
134
135
136extern Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp);
137extern void drmmode_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
138extern void drmmode_fini(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
139extern Bool drmmode_set_bufmgr(ScrnInfoPtr pScrn, drmmode_ptr drmmode, struct radeon_bo_manager *bufmgr);
140extern void drmmode_set_cursor(ScrnInfoPtr scrn, drmmode_ptr drmmode, int id, struct radeon_bo *bo);
141void drmmode_adjust_frame(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int x, int y);
142extern Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode,
143				      Bool set_hw);
144extern void drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
145extern Bool drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn);
146
147extern void drmmode_scanout_free(ScrnInfoPtr scrn);
148
149extern void drmmode_uevent_init(ScrnInfoPtr scrn, drmmode_ptr drmmode);
150extern void drmmode_uevent_fini(ScrnInfoPtr scrn, drmmode_ptr drmmode);
151
152extern int drmmode_get_crtc_id(xf86CrtcPtr crtc);
153extern int drmmode_get_height_align(ScrnInfoPtr scrn, uint32_t tiling);
154extern int drmmode_get_pitch_align(ScrnInfoPtr scrn, int bpe, uint32_t tiling);
155extern int drmmode_get_base_align(ScrnInfoPtr scrn, int bpe, uint32_t tiling);
156extern void drmmode_clear_pending_flip(xf86CrtcPtr crtc);
157
158Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,
159			uint32_t new_front_handle, uint64_t id, void *data,
160			int ref_crtc_hw_id, radeon_drm_handler_proc handler,
161			radeon_drm_abort_proc abort,
162			enum drmmode_flip_sync flip_sync);
163int drmmode_crtc_get_ust_msc(xf86CrtcPtr crtc, CARD64 *ust, CARD64 *msc);
164int drmmode_get_current_ust(int drm_fd, CARD64 *ust);
165
166#endif
167
168