Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  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 to texture_from_handle.
  30.     * Output for texture_get_handle.
  31.     */
  32.    unsigned handle;
  33.    /**
  34.     * Input to texture_from_handle.
  35.     * Output for texture_get_handle.
  36.     */
  37.    unsigned stride;
  38. };
  39.  
  40.  
  41.  
  42. /**
  43.  * Configuration queries.
  44.  */
  45. enum drm_conf {
  46.    /* How many frames to allow before throttling. Or -1 to indicate any number */
  47.    DRM_CONF_THROTTLE, /* DRM_CONF_INT. */
  48.    /* Can this driver, running on this kernel, import and export dma-buf fds? */
  49.    DRM_CONF_SHARE_FD, /* DRM_CONF_BOOL. */
  50.    DRM_CONF_MAX
  51. };
  52.  
  53. /**
  54.  * Type of configuration answer
  55.  */
  56. enum drm_conf_type {
  57.    DRM_CONF_INT,
  58.    DRM_CONF_BOOL,
  59.    DRM_CONF_FLOAT,
  60.    DRM_CONF_POINTER
  61. };
  62.  
  63. /**
  64.  * Return value from the configuration function.
  65.  */
  66. struct drm_conf_ret {
  67.    enum drm_conf_type type;
  68.    union {
  69.       int val_int;
  70.       bool val_bool;
  71.       float val_float;
  72.       void *val_pointer;
  73.    } val;
  74. };
  75.  
  76. struct drm_driver_descriptor
  77. {
  78.    /**
  79.     * Identifying sufix/prefix of the binary, used by egl.
  80.     */
  81.    const char *name;
  82.  
  83.    /**
  84.     * Kernel driver name, as accepted by drmOpenByName.
  85.     */
  86.    const char *driver_name;
  87.  
  88.    /**
  89.     * Create a pipe srcreen.
  90.     *
  91.     * This function does any wrapping of the screen.
  92.     * For example wrapping trace or rbug debugging drivers around it.
  93.     */
  94.    struct pipe_screen* (*create_screen)(int drm_fd);
  95.  
  96.  
  97.    /**
  98.     * Return a configuration value.
  99.     *
  100.     * If this function is NULL, or if it returns NULL
  101.     * the state tracker- or state
  102.     * tracker manager should provide a reasonable default value.
  103.     */
  104.    const struct drm_conf_ret *(*configuration) (enum drm_conf conf);
  105. };
  106.  
  107. extern struct drm_driver_descriptor driver_descriptor;
  108.  
  109. /**
  110.  * Instantiate a drm_driver_descriptor struct.
  111.  */
  112. #define DRM_DRIVER_DESCRIPTOR(name_str, driver_name_str, func, conf) \
  113. struct drm_driver_descriptor driver_descriptor = {             \
  114.    .name = name_str,                                           \
  115.    .driver_name = driver_name_str,                             \
  116.    .create_screen = func,                                      \
  117.    .configuration = (conf),                                    \
  118. };
  119.  
  120. extern struct pipe_screen *dd_create_screen(int fd);
  121.  
  122. extern const char *dd_driver_name(void);
  123.  
  124. extern const struct drm_conf_ret *dd_configuration(enum drm_conf conf);
  125.  
  126. #endif
  127.