drmmode_display.h revision 0d16fef4
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    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 radeon_bo *cursor_bo;
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 or after a page flip crossing with a
99     * modeset)
100     */
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
113
114typedef struct {
115    drmmode_ptr drmmode;
116    int output_id;
117    drmModeConnectorPtr mode_output;
118    drmModeEncoderPtr *mode_encoders;
119    drmModePropertyBlobPtr edid_blob;
120    int dpms_enum_id;
121    int num_props;
122    drmmode_prop_ptr props;
123    int enc_mask;
124    int enc_clone_mask;
125} drmmode_output_private_rec, *drmmode_output_private_ptr;
126
127
128extern Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp);
129extern void drmmode_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
130extern void drmmode_fini(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
131extern Bool drmmode_set_bufmgr(ScrnInfoPtr pScrn, drmmode_ptr drmmode, struct radeon_bo_manager *bufmgr);
132extern void drmmode_set_cursor(ScrnInfoPtr scrn, drmmode_ptr drmmode, int id, struct radeon_bo *bo);
133void drmmode_adjust_frame(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int x, int y);
134extern Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode,
135				      Bool set_hw);
136#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) >= 10
137extern void drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
138#endif
139extern Bool drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn);
140
141extern void drmmode_scanout_free(ScrnInfoPtr scrn);
142
143extern void drmmode_uevent_init(ScrnInfoPtr scrn, drmmode_ptr drmmode);
144extern void drmmode_uevent_fini(ScrnInfoPtr scrn, drmmode_ptr drmmode);
145
146extern int drmmode_get_crtc_id(xf86CrtcPtr crtc);
147extern int drmmode_get_height_align(ScrnInfoPtr scrn, uint32_t tiling);
148extern int drmmode_get_pitch_align(ScrnInfoPtr scrn, int bpe, uint32_t tiling);
149extern int drmmode_get_base_align(ScrnInfoPtr scrn, int bpe, uint32_t tiling);
150
151Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,
152			uint32_t new_front_handle, uint64_t id, void *data,
153			int ref_crtc_hw_id, radeon_drm_handler_proc handler,
154			radeon_drm_abort_proc abort);
155int drmmode_crtc_get_ust_msc(xf86CrtcPtr crtc, CARD64 *ust, CARD64 *msc);
156int drmmode_get_current_ust(int drm_fd, CARD64 *ust);
157
158#endif
159
160