Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. /*
  2.  * Copyright © 2014-2015 Broadcom
  3.  *
  4.  * Permission is hereby granted, free of charge, to any person obtaining a
  5.  * copy of this software and associated documentation files (the "Software"),
  6.  * to deal in the Software without restriction, including without limitation
  7.  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8.  * and/or sell copies of the Software, and to permit persons to whom the
  9.  * Software is furnished to do so, subject to the following conditions:
  10.  *
  11.  * The above copyright notice and this permission notice (including the next
  12.  * paragraph) shall be included in all copies or substantial portions of the
  13.  * Software.
  14.  *
  15.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16.  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17.  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
  18.  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19.  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20.  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  21.  * IN THE SOFTWARE.
  22.  */
  23.  
  24. #ifndef _UAPI_VC4_DRM_H_
  25. #define _UAPI_VC4_DRM_H_
  26.  
  27. #include <drm.h>
  28.  
  29. #define DRM_VC4_SUBMIT_CL                         0x00
  30. #define DRM_VC4_WAIT_SEQNO                        0x01
  31. #define DRM_VC4_WAIT_BO                           0x02
  32. #define DRM_VC4_CREATE_BO                         0x03
  33. #define DRM_VC4_MMAP_BO                           0x04
  34.  
  35. #define DRM_IOCTL_VC4_SUBMIT_CL           DRM_IOWR( DRM_COMMAND_BASE + DRM_VC4_SUBMIT_CL, struct drm_vc4_submit_cl)
  36. #define DRM_IOCTL_VC4_WAIT_SEQNO          DRM_IOWR( DRM_COMMAND_BASE + DRM_VC4_WAIT_SEQNO, struct drm_vc4_wait_seqno)
  37. #define DRM_IOCTL_VC4_WAIT_BO             DRM_IOWR( DRM_COMMAND_BASE + DRM_VC4_WAIT_BO, struct drm_vc4_wait_bo)
  38. #define DRM_IOCTL_VC4_CREATE_BO           DRM_IOWR( DRM_COMMAND_BASE + DRM_VC4_CREATE_BO, struct drm_vc4_create_bo)
  39. #define DRM_IOCTL_VC4_MMAP_BO             DRM_IOWR( DRM_COMMAND_BASE + DRM_VC4_MMAP_BO, struct drm_vc4_mmap_bo)
  40.  
  41.  
  42. /**
  43.  * struct drm_vc4_submit_cl - ioctl argument for submitting commands to the 3D
  44.  * engine.
  45.  *
  46.  * Drivers typically use GPU BOs to store batchbuffers / command lists and
  47.  * their associated state.  However, because the VC4 lacks an MMU, we have to
  48.  * do validation of memory accesses by the GPU commands.  If we were to store
  49.  * our commands in BOs, we'd need to do uncached readback from them to do the
  50.  * validation process, which is too expensive.  Instead, userspace accumulates
  51.  * commands and associated state in plain memory, then the kernel copies the
  52.  * data to its own address space, and then validates and stores it in a GPU
  53.  * BO.
  54.  */
  55. struct drm_vc4_submit_cl {
  56.         /* Pointer to the binner command list.
  57.          *
  58.          * This is the first set of commands executed, which runs the
  59.          * coordinate shader to determine where primitives land on the screen,
  60.          * then writes out the state updates and draw calls necessary per tile
  61.          * to the tile allocation BO.
  62.          */
  63.         uint64_t bin_cl;
  64.  
  65.         /* Pointer to the render command list.
  66.          *
  67.          * The render command list contains a set of packets to load the
  68.          * current tile's state (reading from memory, or just clearing it)
  69.          * into the GPU, then call into the tile allocation BO to run the
  70.          * stored rendering for that tile, then store the tile's state back to
  71.          * memory.
  72.          */
  73.         uint64_t render_cl;
  74.  
  75.         /* Pointer to the shader records.
  76.          *
  77.          * Shader records are the structures read by the hardware that contain
  78.          * pointers to uniforms, shaders, and vertex attributes.  The
  79.          * reference to the shader record has enough information to determine
  80.          * how many pointers are necessary (fixed number for shaders/uniforms,
  81.          * and an attribute count), so those BO indices into bo_handles are
  82.          * just stored as uint32_ts before each shader record passed in.
  83.          */
  84.         uint64_t shader_rec;
  85.  
  86.         /* Pointer to uniform data and texture handles for the textures
  87.          * referenced by the shader.
  88.          *
  89.          * For each shader state record, there is a set of uniform data in the
  90.          * order referenced by the record (FS, VS, then CS).  Each set of
  91.          * uniform data has a uint32_t index into bo_handles per texture
  92.          * sample operation, in the order the QPU_W_TMUn_S writes appear in
  93.          * the program.  Following the texture BO handle indices is the actual
  94.          * uniform data.
  95.          *
  96.          * The individual uniform state blocks don't have sizes passed in,
  97.          * because the kernel has to determine the sizes anyway during shader
  98.          * code validation.
  99.          */
  100.         uint64_t uniforms;
  101.         uint64_t bo_handles;
  102.  
  103.         /* Size in bytes of the binner command list. */
  104.         uint32_t bin_cl_size;
  105.         /* Size in bytes of the render command list */
  106.         uint32_t render_cl_size;
  107.         /* Size in bytes of the set of shader records. */
  108.         uint32_t shader_rec_size;
  109.         /* Number of shader records.
  110.          *
  111.          * This could just be computed from the contents of shader_records and
  112.          * the address bits of references to them from the bin CL, but it
  113.          * keeps the kernel from having to resize some allocations it makes.
  114.          */
  115.         uint32_t shader_rec_count;
  116.         /* Size in bytes of the uniform state. */
  117.         uint32_t uniforms_size;
  118.  
  119.         /* Number of BO handles passed in (size is that times 4). */
  120.         uint32_t bo_handle_count;
  121.  
  122.         uint32_t flags;
  123.         uint32_t pad;
  124.  
  125.         /* Returned value of the seqno of this render job (for the
  126.          * wait ioctl).
  127.          */
  128.         uint64_t seqno;
  129. };
  130.  
  131. /**
  132.  * struct drm_vc4_wait_seqno - ioctl argument for waiting for
  133.  * DRM_VC4_SUBMIT_CL completion using its returned seqno.
  134.  *
  135.  * timeout_ns is the timeout in nanoseconds, where "0" means "don't
  136.  * block, just return the status."
  137.  */
  138. struct drm_vc4_wait_seqno {
  139.         uint64_t seqno;
  140.         uint64_t timeout_ns;
  141. };
  142.  
  143. /**
  144.  * struct drm_vc4_wait_bo - ioctl argument for waiting for
  145.  * completion of the last DRM_VC4_SUBMIT_CL on a BO.
  146.  *
  147.  * This is useful for cases where multiple processes might be
  148.  * rendering to a BO and you want to wait for all rendering to be
  149.  * completed.
  150.  */
  151. struct drm_vc4_wait_bo {
  152.         uint32_t handle;
  153.         uint32_t pad;
  154.         uint64_t timeout_ns;
  155. };
  156.  
  157. /**
  158.  * struct drm_vc4_create_bo - ioctl argument for creating VC4 BOs.
  159.  *
  160.  * There are currently no values for the flags argument, but it may be
  161.  * used in a future extension.
  162.  */
  163. struct drm_vc4_create_bo {
  164.         uint32_t size;
  165.         uint32_t flags;
  166.         /** Returned GEM handle for the BO. */
  167.         uint32_t handle;
  168.         uint32_t pad;
  169. };
  170.  
  171. /**
  172.  * struct drm_vc4_mmap_bo - ioctl argument for mapping VC4 BOs.
  173.  *
  174.  * This doesn't actually perform an mmap.  Instead, it returns the
  175.  * offset you need to use in an mmap on the DRM device node.  This
  176.  * means that tools like valgrind end up knowing about the mapped
  177.  * memory.
  178.  *
  179.  * There are currently no values for the flags argument, but it may be
  180.  * used in a future extension.
  181.  */
  182. struct drm_vc4_mmap_bo {
  183.         /** Handle for the object being mapped. */
  184.         uint32_t handle;
  185.         uint32_t flags;
  186.         /** offset into the drm node to use for subsequent mmap call. */
  187.         uint64_t offset;
  188. };
  189.  
  190. #endif /* _UAPI_VC4_DRM_H_ */
  191.