Tizen 2.1 base
[sdk/emulator/qemu.git] / gl / mesa / src / gallium / include / state_tracker / drm_driver.h
1
2 #ifndef _DRM_DRIVER_H_
3 #define _DRM_DRIVER_H_
4
5 #include "pipe/p_compiler.h"
6
7 struct pipe_screen;
8 struct pipe_winsys;
9 struct pipe_context;
10 struct pipe_resource;
11
12 #define DRM_API_HANDLE_TYPE_SHARED 0
13 #define DRM_API_HANDLE_TYPE_KMS    1
14
15 /**
16  * For use with pipe_screen::{texture_from_handle|texture_get_handle}.
17  */
18 struct winsys_handle
19 {
20    /**
21     * Unused for texture_from_handle, always
22     * DRM_API_HANDLE_TYPE_SHARED.  Input to texture_get_handle,
23     * use TEXTURE_USAGE to select handle for kms or ipc.
24     */
25    unsigned type;
26    /**
27     * Input to texture_from_handle.
28     * Output for texture_get_handle.
29     */
30    unsigned handle;
31    /**
32     * Input to texture_from_handle.
33     * Output for texture_get_handle.
34     */
35    unsigned stride;
36 };
37
38
39
40 /**
41  * Configuration queries.
42  */
43 enum drm_conf {
44    /* How many frames to allow before throttling. Or -1 to indicate any number */
45    DRM_CONF_THROTTLE, /* DRM_CONF_INT. */
46    DRM_CONF_MAX
47 };
48
49 /**
50  * Type of configuration answer
51  */
52 enum drm_conf_type {
53    DRM_CONF_INT,
54    DRM_CONF_BOOL,
55    DRM_CONF_FLOAT,
56    DRM_CONF_POINTER
57 };
58
59 /**
60  * Return value from the configuration function.
61  */
62 struct drm_conf_ret {
63    enum drm_conf_type type;
64    union {
65       int val_int;
66       bool val_bool;
67       float val_float;
68       void *val_pointer;
69    } val;
70 };
71
72 struct drm_driver_descriptor
73 {
74    /**
75     * Identifying sufix/prefix of the binary, used by egl.
76     */
77    const char *name;
78
79    /**
80     * Kernel driver name, as accepted by drmOpenByName.
81     */
82    const char *driver_name;
83
84    /**
85     * Create a pipe srcreen.
86     *
87     * This function does any wrapping of the screen.
88     * For example wrapping trace or rbug debugging drivers around it.
89     */
90    struct pipe_screen* (*create_screen)(int drm_fd);
91
92
93    /**
94     * Return a configuration value.
95     *
96     * If this function is NULL, or if it returns NULL
97     * the state tracker- or state
98     * tracker manager should provide a reasonable default value.
99     */
100    const struct drm_conf_ret *(*configuration) (enum drm_conf conf);
101 };
102
103 extern struct drm_driver_descriptor driver_descriptor;
104
105 /**
106  * Instantiate a drm_driver_descriptor struct.
107  */
108 #define DRM_DRIVER_DESCRIPTOR(name_str, driver_name_str, func, conf) \
109 struct drm_driver_descriptor driver_descriptor = {             \
110    .name = name_str,                                           \
111    .driver_name = driver_name_str,                             \
112    .create_screen = func,                                      \
113    .configuration = (conf),                                    \
114 };
115
116 #endif