native_drm.h revision e4513e7fb96c6336d8c7fcdadfaddb6b335a736e
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 96struct drm_connector { 97 struct native_connector base; 98 99 uint32_t connector_id; 100 drmModeConnectorPtr connector; 101 struct drm_mode *drm_modes; 102 int num_modes; 103}; 104 105struct drm_mode { 106 struct native_mode base; 107 drmModeModeInfo mode; 108}; 109 110static INLINE struct drm_display * 111drm_display(const struct native_display *ndpy) 112{ 113 return (struct drm_display *) ndpy; 114} 115 116static INLINE struct drm_config * 117drm_config(const struct native_config *nconf) 118{ 119 return (struct drm_config *) nconf; 120} 121 122static INLINE struct drm_surface * 123drm_surface(const struct native_surface *nsurf) 124{ 125 return (struct drm_surface *) nsurf; 126} 127 128static INLINE struct drm_connector * 129drm_connector(const struct native_connector *nconn) 130{ 131 return (struct drm_connector *) nconn; 132} 133 134static INLINE struct drm_mode * 135drm_mode(const struct native_mode *nmode) 136{ 137 return (struct drm_mode *) nmode; 138} 139 140boolean 141drm_display_init_modeset(struct native_display *ndpy); 142 143void 144drm_display_fini_modeset(struct native_display *ndpy); 145 146#endif /* _NATIVE_DRM_H_ */ 147