Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. /**************************************************************************
  2.  *
  3.  * Copyright 2012 Francisco Jerez
  4.  * All Rights Reserved.
  5.  *
  6.  * Permission is hereby granted, free of charge, to any person obtaining a
  7.  * copy of this software and associated documentation files (the
  8.  * "Software"), to deal in the Software without restriction, including
  9.  * without limitation the rights to use, copy, modify, merge, publish,
  10.  * distribute, sub license, and/or sell copies of the Software, and to
  11.  * permit persons to whom the Software is furnished to do so, subject to
  12.  * the following conditions:
  13.  *
  14.  * The above copyright notice and this permission notice (including the
  15.  * next paragraph) shall be included in all copies or substantial portions
  16.  * of the Software.
  17.  *
  18.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  19.  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  20.  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
  21.  * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
  22.  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  23.  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  24.  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  25.  *
  26.  **************************************************************************/
  27.  
  28. /**
  29.  * \file Library that provides device enumeration and creation of
  30.  * winsys/pipe_screen instances.
  31.  */
  32.  
  33. #ifndef PIPE_LOADER_H
  34. #define PIPE_LOADER_H
  35.  
  36. #include "pipe/p_compiler.h"
  37. #include "state_tracker/drm_driver.h"
  38.  
  39. #ifdef HAVE_PIPE_LOADER_XLIB
  40. #include <X11/Xlib.h>
  41. #endif
  42.  
  43. #ifdef __cplusplus
  44. extern "C" {
  45. #endif
  46.  
  47. struct pipe_screen;
  48. struct drisw_loader_funcs;
  49.  
  50. enum pipe_loader_device_type {
  51.    PIPE_LOADER_DEVICE_SOFTWARE,
  52.    PIPE_LOADER_DEVICE_PCI,
  53.    PIPE_LOADER_DEVICE_PLATFORM,
  54.    NUM_PIPE_LOADER_DEVICE_TYPES
  55. };
  56.  
  57. /**
  58.  * A device known to the pipe loader.
  59.  */
  60. struct pipe_loader_device {
  61.    enum pipe_loader_device_type type;
  62.  
  63.    union {
  64.       struct {
  65.          int vendor_id;
  66.          int chip_id;
  67.       } pci;
  68.    } u; /**< Discriminated by \a type */
  69.  
  70.    char *driver_name;
  71.    const struct pipe_loader_ops *ops;
  72. };
  73.  
  74. /**
  75.  * Get a list of known devices.
  76.  *
  77.  * \param devs Array that will be filled with pointers to the devices
  78.  *             available in the system.
  79.  * \param ndev Maximum number of devices to return.
  80.  * \return Number of devices available in the system.
  81.  */
  82. int
  83. pipe_loader_probe(struct pipe_loader_device **devs, int ndev);
  84.  
  85. /**
  86.  * Create a pipe_screen for the specified device.
  87.  *
  88.  * \param dev Device the screen will be created for.
  89.  * \param library_paths Colon-separated list of filesystem paths that
  90.  *                      will be used to look for the pipe driver
  91.  *                      module that handles this device.
  92.  */
  93. struct pipe_screen *
  94. pipe_loader_create_screen(struct pipe_loader_device *dev,
  95.                           const char *library_paths);
  96.  
  97. /**
  98.  * Query the configuration parameters for the specified device.
  99.  *
  100.  * \param dev Device that will be queried.
  101.  * \param conf The drm_conf id of the option to be queried.
  102.  */
  103. const struct drm_conf_ret *
  104. pipe_loader_configuration(struct pipe_loader_device *dev,
  105.                           enum drm_conf conf);
  106.  
  107. /**
  108.  * Release resources allocated for a list of devices.
  109.  *
  110.  * Should be called when the specified devices are no longer in use to
  111.  * release any resources allocated by pipe_loader_probe.
  112.  *
  113.  * \param devs Devices to release.
  114.  * \param ndev Number of devices to release.
  115.  */
  116. void
  117. pipe_loader_release(struct pipe_loader_device **devs, int ndev);
  118.  
  119. #ifdef HAVE_PIPE_LOADER_XLIB
  120.  
  121. /**
  122.  * Initialize Xlib for an associated display.
  123.  *
  124.  * This function is platform-specific.
  125.  *
  126.  * \sa pipe_loader_probe
  127.  */
  128. bool
  129. pipe_loader_sw_probe_xlib(struct pipe_loader_device **devs, Display *display);
  130.  
  131. #endif
  132.  
  133.  
  134. #ifdef HAVE_PIPE_LOADER_DRI
  135.  
  136. /**
  137.  * Initialize sw dri device give the drisw_loader_funcs.
  138.  *
  139.  * This function is platform-specific.
  140.  *
  141.  * \sa pipe_loader_probe
  142.  */
  143. bool
  144. pipe_loader_sw_probe_dri(struct pipe_loader_device **devs,
  145.                          struct drisw_loader_funcs *drisw_lf);
  146.  
  147. #endif
  148.  
  149. /**
  150.  * Initialize a null sw device.
  151.  *
  152.  * This function is platform-specific.
  153.  *
  154.  * \sa pipe_loader_probe
  155.  */
  156. bool
  157. pipe_loader_sw_probe_null(struct pipe_loader_device **devs);
  158.  
  159. /**
  160.  * Get a list of known software devices.
  161.  *
  162.  * This function is platform-specific.
  163.  *
  164.  * \sa pipe_loader_probe
  165.  */
  166. int
  167. pipe_loader_sw_probe(struct pipe_loader_device **devs, int ndev);
  168.  
  169. /**
  170.  * Get a software device wrapped atop another device.
  171.  *
  172.  * This function is platform-specific.
  173.  *
  174.  * \sa pipe_loader_probe
  175.  */
  176. boolean
  177. pipe_loader_sw_probe_wrapped(struct pipe_loader_device **dev,
  178.                              struct pipe_screen *screen);
  179.  
  180. #ifdef HAVE_PIPE_LOADER_DRM
  181.  
  182. /**
  183.  * Get a list of known DRM devices.
  184.  *
  185.  * This function is platform-specific.
  186.  *
  187.  * \sa pipe_loader_probe
  188.  */
  189. int
  190. pipe_loader_drm_probe(struct pipe_loader_device **devs, int ndev);
  191.  
  192. /**
  193.  * Initialize a DRM device in an already opened fd.
  194.  *
  195.  * This function is platform-specific.
  196.  *
  197.  * \sa pipe_loader_probe
  198.  *
  199.  * \param auth_x If true, the pipe-loader will attempt to
  200.  *               authenticate with the X server.
  201.  */
  202. bool
  203. pipe_loader_drm_probe_fd(struct pipe_loader_device **dev, int fd,
  204.                          boolean auth_x);
  205.  
  206. #endif
  207.  
  208. #ifdef __cplusplus
  209. }
  210. #endif
  211.  
  212. #endif /* PIPE_LOADER_H */
  213.