d841f4884ea4fb63558f94384fa9a2769882e000
[profile/ivi/mesa.git] / src / gallium / state_trackers / egl / kms / native_kms.h
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_KMS_H_
27 #define _NATIVE_KMS_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_api.h"
36
37 #include "common/native.h"
38
39 struct kms_config;
40 struct kms_connector;
41 struct kms_mode;
42
43 struct kms_crtc {
44    drmModeCrtcPtr crtc;
45    uint32_t connectors[32];
46    int num_connectors;
47 };
48
49 struct kms_display {
50    struct native_display base;
51
52    struct native_event_handler *event_handler;
53
54    int fd;
55    struct drm_api *api;
56    drmModeResPtr resources;
57    struct kms_config *config;
58
59    struct kms_connector *connectors;
60    int num_connectors;
61
62    struct kms_surface **shown_surfaces;
63    /* save the original settings of the CRTCs */
64    struct kms_crtc *saved_crtcs;
65 };
66
67 struct kms_framebuffer {
68    struct pipe_texture *texture;
69    boolean is_passive;
70
71    uint32_t buffer_id;
72 };
73
74 struct kms_surface {
75    struct native_surface base;
76    enum pipe_format color_format;
77    struct kms_display *kdpy;
78    int width, height;
79
80    struct pipe_texture *textures[NUM_NATIVE_ATTACHMENTS];
81    unsigned int sequence_number;
82    struct kms_framebuffer front_fb, back_fb;
83
84    boolean is_shown;
85    struct kms_crtc current_crtc;
86 };
87
88 struct kms_config {
89    struct native_config base;
90 };
91
92 struct kms_connector {
93    struct native_connector base;
94
95    uint32_t connector_id;
96    drmModeConnectorPtr connector;
97    struct kms_mode *kms_modes;
98    int num_modes;
99 };
100
101 struct kms_mode {
102    struct native_mode base;
103    drmModeModeInfo mode;
104 };
105
106 static INLINE struct kms_display *
107 kms_display(const struct native_display *ndpy)
108 {
109    return (struct kms_display *) ndpy;
110 }
111
112 static INLINE struct kms_surface *
113 kms_surface(const struct native_surface *nsurf)
114 {
115    return (struct kms_surface *) nsurf;
116 }
117
118 static INLINE struct kms_config *
119 kms_config(const struct native_config *nconf)
120 {
121    return (struct kms_config *) nconf;
122 }
123
124 static INLINE struct kms_connector *
125 kms_connector(const struct native_connector *nconn)
126 {
127    return (struct kms_connector *) nconn;
128 }
129
130 static INLINE struct kms_mode *
131 kms_mode(const struct native_mode *nmode)
132 {
133    return (struct kms_mode *) nmode;
134 }
135
136 #endif /* _NATIVE_KMS_H_ */