2 * Mesa 3-D graphics library
5 * Copyright (C) 2010 Chia-I Wu <olv@0xlab.org>
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:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 #ifndef _NATIVE_KMS_H_
26 #define _NATIVE_KMS_H_
29 #include <xf86drmMode.h>
31 #include "pipe/p_compiler.h"
32 #include "util/u_format.h"
33 #include "pipe/p_state.h"
34 #include "state_tracker/drm_api.h"
36 #include "common/native.h"
38 enum kms_surface_type
{
39 KMS_SURFACE_TYPE_PBUFFER
,
40 KMS_SURFACE_TYPE_SCANOUT
49 uint32_t connectors
[32];
54 struct native_display base
;
58 drmModeResPtr resources
;
59 struct kms_config
*config
;
61 struct kms_connector
*connectors
;
64 struct kms_surface
**shown_surfaces
;
65 /* save the original settings of the CRTCs */
66 struct kms_crtc
*saved_crtcs
;
69 struct kms_framebuffer
{
70 struct pipe_texture
*texture
;
77 struct native_surface base
;
78 enum kms_surface_type type
;
79 enum pipe_format color_format
;
80 struct kms_display
*kdpy
;
83 struct pipe_texture
*textures
[NUM_NATIVE_ATTACHMENTS
];
84 unsigned int sequence_number
;
85 struct kms_framebuffer front_fb
, back_fb
;
88 struct kms_crtc current_crtc
;
92 struct native_config base
;
95 struct kms_connector
{
96 struct native_connector base
;
98 uint32_t connector_id
;
99 drmModeConnectorPtr connector
;
100 struct kms_mode
*kms_modes
;
105 struct native_mode base
;
106 drmModeModeInfo mode
;
109 static INLINE
struct kms_display
*
110 kms_display(const struct native_display
*ndpy
)
112 return (struct kms_display
*) ndpy
;
115 static INLINE
struct kms_surface
*
116 kms_surface(const struct native_surface
*nsurf
)
118 return (struct kms_surface
*) nsurf
;
121 static INLINE
struct kms_config
*
122 kms_config(const struct native_config
*nconf
)
124 return (struct kms_config
*) nconf
;
127 static INLINE
struct kms_connector
*
128 kms_connector(const struct native_connector
*nconn
)
130 return (struct kms_connector
*) nconn
;
133 static INLINE
struct kms_mode
*
134 kms_mode(const struct native_mode
*nmode
)
136 return (struct kms_mode
*) nmode
;
139 #endif /* _NATIVE_KMS_H_ */