native_drm.h revision c9febff31f1032065f96ad76fd31f31ac330fef9
1/* 2 * Mesa 3-D graphics library 3 * Version: 7.8 4 * 5 * Copyright (C) 2010 Chia-I Wu <olv@0xlab.org> 6 * 7 * Permission is hereby granted, free of charge, to any person obtaining a 8 * copy of this software and associated documentation files (the "Software"), 9 * to deal in the Software without restriction, including without limitation 10 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 * and/or sell copies of the Software, and to permit persons to whom the 12 * Software is furnished to do so, subject to the following conditions: 13 * 14 * The above copyright notice and this permission notice shall be included 15 * in all copies or substantial portions of the Software. 16 * 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 * DEALINGS IN THE SOFTWARE. 24 */ 25 26#ifndef _NATIVE_DRM_H_ 27#define _NATIVE_DRM_H_ 28 29#include <xf86drm.h> 30#include <xf86drmMode.h> 31 32#include "pipe/p_compiler.h" 33#include "util/u_format.h" 34#include "pipe/p_state.h" 35#include "state_tracker/drm_driver.h" 36 37#include "common/native.h" 38#include "common/native_helper.h" 39 40struct drm_config; 41struct drm_crtc; 42struct drm_connector; 43struct drm_mode; 44struct drm_surface; 45 46struct drm_display { 47 struct native_display base; 48 49 struct native_event_handler *event_handler; 50 51 int fd; 52 struct drm_config *config; 53 54 /* for modesetting */ 55 drmModeResPtr resources; 56 struct drm_connector *connectors; 57 int num_connectors; 58 59 struct drm_surface **shown_surfaces; 60 /* save the original settings of the CRTCs */ 61 struct drm_crtc *saved_crtcs; 62}; 63 64struct drm_config { 65 struct native_config base; 66}; 67 68struct drm_crtc { 69 drmModeCrtcPtr crtc; 70 uint32_t connectors[32]; 71 int num_connectors; 72}; 73 74struct drm_framebuffer { 75 struct pipe_resource *texture; 76 boolean is_passive; 77 78 uint32_t buffer_id; 79}; 80 81struct drm_surface { 82 struct native_surface base; 83 struct drm_display *drmdpy; 84 85 struct resource_surface *rsurf; 86 enum pipe_format color_format; 87 int width, height; 88 89 unsigned int sequence_number; 90 struct drm_framebuffer front_fb, back_fb; 91 92 boolean is_shown; 93 struct drm_crtc current_crtc; 94 95 boolean have_pageflip; 96}; 97 98struct drm_connector { 99 struct native_connector base; 100 101 uint32_t connector_id; 102 drmModeConnectorPtr connector; 103 struct drm_mode *drm_modes; 104 int num_modes; 105}; 106 107struct drm_mode { 108 struct native_mode base; 109 drmModeModeInfo mode; 110}; 111 112static INLINE struct drm_display * 113drm_display(const struct native_display *ndpy) 114{ 115 return (struct drm_display *) ndpy; 116} 117 118static INLINE struct drm_config * 119drm_config(const struct native_config *nconf) 120{ 121 return (struct drm_config *) nconf; 122} 123 124static INLINE struct drm_surface * 125drm_surface(const struct native_surface *nsurf) 126{ 127 return (struct drm_surface *) nsurf; 128} 129 130static INLINE struct drm_connector * 131drm_connector(const struct native_connector *nconn) 132{ 133 return (struct drm_connector *) nconn; 134} 135 136static INLINE struct drm_mode * 137drm_mode(const struct native_mode *nmode) 138{ 139 return (struct drm_mode *) nmode; 140} 141 142boolean 143drm_display_init_modeset(struct native_display *ndpy); 144 145void 146drm_display_fini_modeset(struct native_display *ndpy); 147 148#endif /* _NATIVE_DRM_H_ */ 149