1ad43ddacSmrg/*
2ad43ddacSmrg * Copyright © 2007 Red Hat, Inc.
3ad43ddacSmrg *
4ad43ddacSmrg * Permission is hereby granted, free of charge, to any person obtaining a
5ad43ddacSmrg * copy of this software and associated documentation files (the "Software"),
6ad43ddacSmrg * to deal in the Software without restriction, including without limitation
7ad43ddacSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8ad43ddacSmrg * and/or sell copies of the Software, and to permit persons to whom the
9ad43ddacSmrg * Software is furnished to do so, subject to the following conditions:
10ad43ddacSmrg *
11ad43ddacSmrg * The above copyright notice and this permission notice (including the next
12ad43ddacSmrg * paragraph) shall be included in all copies or substantial portions of the
13ad43ddacSmrg * Software.
14ad43ddacSmrg *
15ad43ddacSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16ad43ddacSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17ad43ddacSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18ad43ddacSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19ad43ddacSmrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20ad43ddacSmrg * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21ad43ddacSmrg * SOFTWARE.
22ad43ddacSmrg *
23ad43ddacSmrg * Authors:
24ad43ddacSmrg *     Dave Airlie <airlied@redhat.com>
25ad43ddacSmrg *
26ad43ddacSmrg */
27ad43ddacSmrg#ifndef DRMMODE_DISPLAY_H
28ad43ddacSmrg#define DRMMODE_DISPLAY_H
29ad43ddacSmrg
3043df4709Smrg#ifdef XF86DRM_MODE
3143df4709Smrg
32ad43ddacSmrg#include "xf86drmMode.h"
332f39173dSmrg#ifdef HAVE_LIBUDEV
342f39173dSmrg#include "libudev.h"
352f39173dSmrg#endif
36ad43ddacSmrg
37ad43ddacSmrg#include "radeon_probe.h"
38ad43ddacSmrg
39ad43ddacSmrgtypedef struct {
40ad43ddacSmrg  int fd;
41ad43ddacSmrg  unsigned fb_id;
4243df4709Smrg  drmModeResPtr mode_res;
43ad43ddacSmrg  drmModeFBPtr mode_fb;
44ad43ddacSmrg  int cpp;
45ad43ddacSmrg  struct radeon_bo_manager *bufmgr;
462f39173dSmrg  ScrnInfoPtr scrn;
472f39173dSmrg#ifdef HAVE_LIBUDEV
482f39173dSmrg  struct udev_monitor *uevent_monitor;
492f39173dSmrg  InputHandlerProc uevent_handler;
502f39173dSmrg#endif
512f39173dSmrg  drmEventContext event_context;
5240732134Srjs} drmmode_rec, *drmmode_ptr;
5340732134Srjs
5440732134Srjstypedef struct {
5543df4709Smrg  drmmode_ptr drmmode;
5640732134Srjs  unsigned old_fb_id;
572f39173dSmrg  int flip_count;
58921a55d8Smrg  void *event_data;
59921a55d8Smrg  unsigned int fe_frame;
6043df4709Smrg  unsigned int fe_tv_sec;
6143df4709Smrg  unsigned int fe_tv_usec;
6240732134Srjs} drmmode_flipdata_rec, *drmmode_flipdata_ptr;
63ad43ddacSmrg
6443df4709Smrgtypedef struct {
6543df4709Smrg  drmmode_flipdata_ptr flipdata;
6643df4709Smrg  Bool dispatch_me;
6743df4709Smrg} drmmode_flipevtcarrier_rec, *drmmode_flipevtcarrier_ptr;
68921a55d8Smrg
69ad43ddacSmrgtypedef struct {
70ad43ddacSmrg    drmmode_ptr drmmode;
71ad43ddacSmrg    drmModeCrtcPtr mode_crtc;
722f39173dSmrg    int hw_id;
73ad43ddacSmrg    struct radeon_bo *cursor_bo;
7443df4709Smrg    struct radeon_bo *rotate_bo;
7543df4709Smrg    unsigned rotate_fb_id;
7668105dcbSveego    int dpms_mode;
77ad43ddacSmrg    uint16_t lut_r[256], lut_g[256], lut_b[256];
78ad43ddacSmrg} drmmode_crtc_private_rec, *drmmode_crtc_private_ptr;
79ad43ddacSmrg
80ad43ddacSmrgtypedef struct {
81ad43ddacSmrg    drmModePropertyPtr mode_prop;
82ad43ddacSmrg    uint64_t value;
83ad43ddacSmrg    int num_atoms; /* if range prop, num_atoms == 1; if enum prop, num_atoms == num_enums + 1 */
84ad43ddacSmrg    Atom *atoms;
85ad43ddacSmrg} drmmode_prop_rec, *drmmode_prop_ptr;
86ad43ddacSmrg
87ad43ddacSmrg
88ad43ddacSmrgtypedef struct {
89ad43ddacSmrg    drmmode_ptr drmmode;
90ad43ddacSmrg    int output_id;
91ad43ddacSmrg    drmModeConnectorPtr mode_output;
92ad43ddacSmrg    drmModeEncoderPtr *mode_encoders;
93ad43ddacSmrg    drmModePropertyBlobPtr edid_blob;
94ad43ddacSmrg    int dpms_enum_id;
95ad43ddacSmrg    int num_props;
96ad43ddacSmrg    drmmode_prop_ptr props;
97ad43ddacSmrg    int enc_mask;
98ad43ddacSmrg    int enc_clone_mask;
99ad43ddacSmrg} drmmode_output_private_rec, *drmmode_output_private_ptr;
100ad43ddacSmrg
101ad43ddacSmrg
102ad43ddacSmrgextern Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp);
10340732134Srjsextern void drmmode_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
104ad43ddacSmrgextern Bool drmmode_set_bufmgr(ScrnInfoPtr pScrn, drmmode_ptr drmmode, struct radeon_bo_manager *bufmgr);
105ad43ddacSmrgextern void drmmode_set_cursor(ScrnInfoPtr scrn, drmmode_ptr drmmode, int id, struct radeon_bo *bo);
10668105dcbSveegovoid drmmode_adjust_frame(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int x, int y);
10743df4709Smrgextern Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
108ad43ddacSmrgextern void drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
109ad43ddacSmrgextern Bool drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn);
1102f39173dSmrg
1112f39173dSmrgextern void drmmode_uevent_init(ScrnInfoPtr scrn, drmmode_ptr drmmode);
1122f39173dSmrgextern void drmmode_uevent_fini(ScrnInfoPtr scrn, drmmode_ptr drmmode);
1132f39173dSmrg
114921a55d8Smrgextern int drmmode_get_height_align(ScrnInfoPtr scrn, uint32_t tiling);
115921a55d8Smrgextern int drmmode_get_pitch_align(ScrnInfoPtr scrn, int bpe, uint32_t tiling);
116921a55d8Smrgextern int drmmode_get_base_align(ScrnInfoPtr scrn, int bpe, uint32_t tiling);
117921a55d8Smrg
11843df4709SmrgBool radeon_do_pageflip(ScrnInfoPtr scrn, struct radeon_bo *new_front, void *data, int ref_crtc_hw_id);
119921a55d8Smrg
120ad43ddacSmrg#endif
121ad43ddacSmrg
12243df4709Smrg#endif
123