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_context; 9 struct pipe_resource; 10 11 #define DRM_API_HANDLE_TYPE_SHARED 0 12 #define DRM_API_HANDLE_TYPE_KMS 1 13 #define DRM_API_HANDLE_TYPE_FD 2 14 15 16 /** 17 * For use with pipe_screen::{texture_from_handle|texture_get_handle}. 18 */ 19 struct winsys_handle 20 { 21 /** 22 * Input for texture_from_handle, valid values are 23 * DRM_API_HANDLE_TYPE_SHARED or DRM_API_HANDLE_TYPE_FD. 24 * Input to texture_get_handle, 25 * to select handle for kms, flink, or prime. 26 */ 27 unsigned type; 28 /** 29 * Input for texture_get_handle, allows to export the offset 30 * of a specific layer of an array texture. 31 */ 32 unsigned layer; 33 /** 34 * Input to texture_from_handle. 35 * Output for texture_get_handle. 36 */ 37 unsigned handle; 38 /** 39 * Input to texture_from_handle. 40 * Output for texture_get_handle. 41 */ 42 unsigned stride; 43 /** 44 * Input to texture_from_handle. 45 * Output for texture_get_handle. 46 */ 47 unsigned offset; 48 }; 49 50 51 52 /** 53 * Configuration queries. 54 */ 55 enum drm_conf { 56 /* How many frames to allow before throttling. Or -1 to indicate any number */ 57 DRM_CONF_THROTTLE, /* DRM_CONF_INT. */ 58 /* Can this driver, running on this kernel, import and export dma-buf fds? */ 59 DRM_CONF_SHARE_FD, /* DRM_CONF_BOOL. */ 60 DRM_CONF_MAX 61 }; 62 63 /** 64 * Type of configuration answer 65 */ 66 enum drm_conf_type { 67 DRM_CONF_INT, 68 DRM_CONF_BOOL, 69 DRM_CONF_FLOAT, 70 DRM_CONF_POINTER 71 }; 72 73 /** 74 * Return value from the configuration function. 75 */ 76 struct drm_conf_ret { 77 enum drm_conf_type type; 78 union { 79 int val_int; 80 bool val_bool; 81 float val_float; 82 void *val_pointer; 83 } val; 84 }; 85 86 struct drm_driver_descriptor 87 { 88 /** 89 * Identifying prefix/suffix of the binary, used by the pipe-loader. 90 */ 91 const char *driver_name; 92 93 /** 94 * Create a pipe srcreen. 95 * 96 * This function does any wrapping of the screen. 97 * For example wrapping trace or rbug debugging drivers around it. 98 */ 99 struct pipe_screen* (*create_screen)(int drm_fd); 100 101 /** 102 * Return a configuration value. 103 * 104 * If this function is NULL, or if it returns NULL 105 * the state tracker- or state 106 * tracker manager should provide a reasonable default value. 107 */ 108 const struct drm_conf_ret *(*configuration) (enum drm_conf conf); 109 }; 110 111 extern const struct drm_driver_descriptor driver_descriptor; 112 113 /** 114 * Instantiate a drm_driver_descriptor struct. 115 */ 116 #define DRM_DRIVER_DESCRIPTOR(driver_name_str, func, conf) \ 117 const struct drm_driver_descriptor driver_descriptor = { \ 118 .driver_name = driver_name_str, \ 119 .create_screen = func, \ 120 .configuration = (conf), \ 121 }; 122 123 #endif 124