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 #ifdef HAVE_DRI
31 #include "xf86drmMode.h"
32 #endif
33 #ifdef HAVE_UDEV
34 #include "libudev.h"
35 #endif
36 
37 typedef struct {
38     int fd;
39     uint32_t fb_id;
40 #ifdef HAVE_DRI
41     drmModeResPtr mode_res;
42     drmModeFBPtr mode_fb;
43     drmEventContext event_context;
44 #endif
45     ScrnInfoPtr scrn;
46 #ifdef HAVE_UDEV
47     struct udev_monitor *uevent_monitor;
48     InputHandlerProc uevent_handler;
49 #endif
50     struct buffer_object *front_bo;
51 
52     Bool hwcursor;
53 } drmmode_rec, *drmmode_ptr;
54 
55 typedef struct {
56     drmmode_ptr drmmode;
57 #ifdef HAVE_DRI
58     drmModeCrtcPtr mode_crtc;
59 #endif
60     struct buffer_object *cursor_bo;
61     unsigned rotate_fb_id;
62     int index;
63 } drmmode_crtc_private_rec, *drmmode_crtc_private_ptr;
64 
65 #ifdef HAVE_DRI
66 typedef struct {
67     drmModePropertyPtr mode_prop;
68     uint64_t value;
69     int num_atoms; /* if range prop, num_atoms == 1; if enum prop, num_atoms == num_enums + 1 */
70     Atom *atoms;
71 } drmmode_prop_rec, *drmmode_prop_ptr;
72 
73 typedef struct {
74     drmmode_ptr drmmode;
75     int output_id;
76     drmModeConnectorPtr mode_output;
77     drmModeEncoderPtr *mode_encoders;
78     drmModePropertyBlobPtr edid_blob;
79     int dpms_enum_id;
80     int num_props;
81     drmmode_prop_ptr props;
82     int enc_mask;
83     int enc_clone_mask;
84 } drmmode_output_private_rec, *drmmode_output_private_ptr;
85 #endif
86 
87 extern xf86CrtcPtr window_belongs_to_crtc(ScrnInfoPtr pScrn, int x, int y, int w, int h);
88 extern Bool KMSCrtcInit(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
89 extern void drmmode_uevent_init(ScrnInfoPtr scrn, drmmode_ptr drmmode);
90 extern void drmmode_uevent_fini(ScrnInfoPtr scrn, drmmode_ptr drmmode);
91 #endif
92