1d514b0f3Smrg/*
2d514b0f3Smrg * Copyright © 2007 Red Hat, Inc.
3d514b0f3Smrg *
4d514b0f3Smrg * Permission is hereby granted, free of charge, to any person obtaining a
5d514b0f3Smrg * copy of this software and associated documentation files (the "Software"),
6d514b0f3Smrg * to deal in the Software without restriction, including without limitation
7d514b0f3Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8d514b0f3Smrg * and/or sell copies of the Software, and to permit persons to whom the
9d514b0f3Smrg * Software is furnished to do so, subject to the following conditions:
10d514b0f3Smrg *
11d514b0f3Smrg * The above copyright notice and this permission notice (including the next
12d514b0f3Smrg * paragraph) shall be included in all copies or substantial portions of the
13d514b0f3Smrg * Software.
14d514b0f3Smrg *
15d514b0f3Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16d514b0f3Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17d514b0f3Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18d514b0f3Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19d514b0f3Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20d514b0f3Smrg * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21d514b0f3Smrg * SOFTWARE.
22d514b0f3Smrg *
23d514b0f3Smrg * Authors:
24d514b0f3Smrg *     Dave Airlie <airlied@redhat.com>
25d514b0f3Smrg *
26d514b0f3Smrg */
27d514b0f3Smrg#ifndef DRMMODE_DISPLAY_H
28d514b0f3Smrg#define DRMMODE_DISPLAY_H
29d514b0f3Smrg
30d514b0f3Smrg#ifdef XF86DRM_MODE
31d514b0f3Smrg
32d514b0f3Smrg#include "xf86drm.h"
33d514b0f3Smrg#include "xf86drmMode.h"
34d514b0f3Smrg#include "xf86str.h"
35d514b0f3Smrg#include "randrstr.h"
36d514b0f3Smrg#include "xf86Crtc.h"
37d514b0f3Smrg#ifdef HAVE_LIBUDEV
38d514b0f3Smrg#include "libudev.h"
39d514b0f3Smrg#endif
40d514b0f3Smrg
41d514b0f3Smrgtypedef struct {
42d514b0f3Smrg  int fd;
43d514b0f3Smrg  unsigned fb_id;
44d514b0f3Smrg  drmModeResPtr mode_res;
45d514b0f3Smrg  drmModeFBPtr mode_fb;
46d514b0f3Smrg  int cpp;
47d514b0f3Smrg  ScrnInfoPtr scrn;
48d514b0f3Smrg#ifdef HAVE_LIBUDEV
49d514b0f3Smrg  struct udev_monitor *uevent_monitor;
50d514b0f3Smrg  InputHandlerProc uevent_handler;
51d514b0f3Smrg#endif
52d514b0f3Smrg} drmmode_rec, *drmmode_ptr;
53d514b0f3Smrg
54d514b0f3Smrgtypedef struct {
55d514b0f3Smrg    drmmode_ptr drmmode;
56d514b0f3Smrg    drmModeCrtcPtr mode_crtc;
57d514b0f3Smrg    int hw_id;
58d514b0f3Smrg    struct qxl_bo *cursor_bo;
59d514b0f3Smrg    void *cursor_ptr;
60d514b0f3Smrg  //    struct radeon_bo *rotate_bo;
61d514b0f3Smrg    unsigned rotate_fb_id;
62d514b0f3Smrg    int dpms_mode;
63d514b0f3Smrg    uint16_t lut_r[256], lut_g[256], lut_b[256];
64d514b0f3Smrg} drmmode_crtc_private_rec, *drmmode_crtc_private_ptr;
65d514b0f3Smrg
66d514b0f3Smrg
67d514b0f3Smrgtypedef struct {
68d514b0f3Smrg    drmModePropertyPtr mode_prop;
69d514b0f3Smrg    uint64_t value;
70d514b0f3Smrg    int num_atoms; /* if range prop, num_atoms == 1; if enum prop, num_atoms == num_enums + 1 */
71d514b0f3Smrg    Atom *atoms;
72d514b0f3Smrg    int index; /* index within the kernel-size property array */
73d514b0f3Smrg} drmmode_prop_rec, *drmmode_prop_ptr;
74d514b0f3Smrg
75d514b0f3Smrgtypedef struct {
76d514b0f3Smrg    drmmode_ptr drmmode;
77d514b0f3Smrg    int output_id;
78d514b0f3Smrg    drmModeConnectorPtr mode_output;
79d514b0f3Smrg    drmModeEncoderPtr *mode_encoders;
80d514b0f3Smrg    drmModePropertyBlobPtr edid_blob;
81d514b0f3Smrg    int dpms_enum_id;
82d514b0f3Smrg    int num_props;
83d514b0f3Smrg    drmmode_prop_ptr props;
84d514b0f3Smrg    int enc_mask;
85d514b0f3Smrg    int enc_clone_mask;
86d514b0f3Smrg} drmmode_output_private_rec, *drmmode_output_private_ptr;
87d514b0f3Smrg
88d514b0f3Smrgextern Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp);
89d514b0f3Smrg
90d514b0f3Smrgextern void qxl_drmmode_uevent_init(ScrnInfoPtr scrn, drmmode_ptr drmmode);
91d514b0f3Smrgextern void qxl_drmmode_uevent_fini(ScrnInfoPtr scrn, drmmode_ptr drmmode);
92d514b0f3Smrg#endif
93d514b0f3Smrg
94d514b0f3Smrg#endif
95