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