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