Home | History | Annotate | Line # | Download | only in drm
      1  1.1  riastrad /*	$NetBSD: virtgpu_drm.h,v 1.2 2021/12/18 23:45:46 riastradh Exp $	*/
      2  1.1  riastrad 
      3  1.1  riastrad /*
      4  1.1  riastrad  * Copyright 2013 Red Hat
      5  1.1  riastrad  * All Rights Reserved.
      6  1.1  riastrad  *
      7  1.1  riastrad  * Permission is hereby granted, free of charge, to any person obtaining a
      8  1.1  riastrad  * copy of this software and associated documentation files (the "Software"),
      9  1.1  riastrad  * to deal in the Software without restriction, including without limitation
     10  1.1  riastrad  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
     11  1.1  riastrad  * and/or sell copies of the Software, and to permit persons to whom the
     12  1.1  riastrad  * Software is furnished to do so, subject to the following conditions:
     13  1.1  riastrad  *
     14  1.1  riastrad  * The above copyright notice and this permission notice (including the next
     15  1.1  riastrad  * paragraph) shall be included in all copies or substantial portions of the
     16  1.1  riastrad  * Software.
     17  1.1  riastrad  *
     18  1.1  riastrad  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     19  1.1  riastrad  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     20  1.1  riastrad  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     21  1.1  riastrad  * THE AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
     22  1.1  riastrad  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
     23  1.1  riastrad  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
     24  1.1  riastrad  * OTHER DEALINGS IN THE SOFTWARE.
     25  1.1  riastrad  */
     26  1.1  riastrad #ifndef VIRTGPU_DRM_H
     27  1.1  riastrad #define VIRTGPU_DRM_H
     28  1.1  riastrad 
     29  1.1  riastrad #include "drm.h"
     30  1.1  riastrad 
     31  1.1  riastrad #if defined(__cplusplus)
     32  1.1  riastrad extern "C" {
     33  1.1  riastrad #endif
     34  1.1  riastrad 
     35  1.1  riastrad /* Please note that modifications to all structs defined here are
     36  1.1  riastrad  * subject to backwards-compatibility constraints.
     37  1.1  riastrad  *
     38  1.1  riastrad  * Do not use pointers, use __u64 instead for 32 bit / 64 bit user/kernel
     39  1.1  riastrad  * compatibility Keep fields aligned to their size
     40  1.1  riastrad  */
     41  1.1  riastrad 
     42  1.1  riastrad #define DRM_VIRTGPU_MAP         0x01
     43  1.1  riastrad #define DRM_VIRTGPU_EXECBUFFER  0x02
     44  1.1  riastrad #define DRM_VIRTGPU_GETPARAM    0x03
     45  1.1  riastrad #define DRM_VIRTGPU_RESOURCE_CREATE 0x04
     46  1.1  riastrad #define DRM_VIRTGPU_RESOURCE_INFO     0x05
     47  1.1  riastrad #define DRM_VIRTGPU_TRANSFER_FROM_HOST 0x06
     48  1.1  riastrad #define DRM_VIRTGPU_TRANSFER_TO_HOST 0x07
     49  1.1  riastrad #define DRM_VIRTGPU_WAIT     0x08
     50  1.1  riastrad #define DRM_VIRTGPU_GET_CAPS  0x09
     51  1.1  riastrad 
     52  1.1  riastrad #define VIRTGPU_EXECBUF_FENCE_FD_IN	0x01
     53  1.1  riastrad #define VIRTGPU_EXECBUF_FENCE_FD_OUT	0x02
     54  1.1  riastrad #define VIRTGPU_EXECBUF_FLAGS  (\
     55  1.1  riastrad 		VIRTGPU_EXECBUF_FENCE_FD_IN |\
     56  1.1  riastrad 		VIRTGPU_EXECBUF_FENCE_FD_OUT |\
     57  1.1  riastrad 		0)
     58  1.1  riastrad 
     59  1.1  riastrad struct drm_virtgpu_map {
     60  1.1  riastrad 	__u64 offset; /* use for mmap system call */
     61  1.1  riastrad 	__u32 handle;
     62  1.1  riastrad 	__u32 pad;
     63  1.1  riastrad };
     64  1.1  riastrad 
     65  1.1  riastrad struct drm_virtgpu_execbuffer {
     66  1.1  riastrad 	__u32 flags;
     67  1.1  riastrad 	__u32 size;
     68  1.1  riastrad 	__u64 command; /* void* */
     69  1.1  riastrad 	__u64 bo_handles;
     70  1.1  riastrad 	__u32 num_bo_handles;
     71  1.1  riastrad 	__s32 fence_fd; /* in/out fence fd (see VIRTGPU_EXECBUF_FENCE_FD_IN/OUT) */
     72  1.1  riastrad };
     73  1.1  riastrad 
     74  1.1  riastrad #define VIRTGPU_PARAM_3D_FEATURES 1 /* do we have 3D features in the hw */
     75  1.1  riastrad #define VIRTGPU_PARAM_CAPSET_QUERY_FIX 2 /* do we have the capset fix */
     76  1.1  riastrad 
     77  1.1  riastrad struct drm_virtgpu_getparam {
     78  1.1  riastrad 	__u64 param;
     79  1.1  riastrad 	__u64 value;
     80  1.1  riastrad };
     81  1.1  riastrad 
     82  1.1  riastrad /* NO_BO flags? NO resource flag? */
     83  1.1  riastrad /* resource flag for y_0_top */
     84  1.1  riastrad struct drm_virtgpu_resource_create {
     85  1.1  riastrad 	__u32 target;
     86  1.1  riastrad 	__u32 format;
     87  1.1  riastrad 	__u32 bind;
     88  1.1  riastrad 	__u32 width;
     89  1.1  riastrad 	__u32 height;
     90  1.1  riastrad 	__u32 depth;
     91  1.1  riastrad 	__u32 array_size;
     92  1.1  riastrad 	__u32 last_level;
     93  1.1  riastrad 	__u32 nr_samples;
     94  1.1  riastrad 	__u32 flags;
     95  1.1  riastrad 	__u32 bo_handle; /* if this is set - recreate a new resource attached to this bo ? */
     96  1.1  riastrad 	__u32 res_handle;  /* returned by kernel */
     97  1.1  riastrad 	__u32 size;        /* validate transfer in the host */
     98  1.1  riastrad 	__u32 stride;      /* validate transfer in the host */
     99  1.1  riastrad };
    100  1.1  riastrad 
    101  1.1  riastrad struct drm_virtgpu_resource_info {
    102  1.1  riastrad 	__u32 bo_handle;
    103  1.1  riastrad 	__u32 res_handle;
    104  1.1  riastrad 	__u32 size;
    105  1.1  riastrad 	__u32 stride;
    106  1.1  riastrad };
    107  1.1  riastrad 
    108  1.1  riastrad struct drm_virtgpu_3d_box {
    109  1.1  riastrad 	__u32 x;
    110  1.1  riastrad 	__u32 y;
    111  1.1  riastrad 	__u32 z;
    112  1.1  riastrad 	__u32 w;
    113  1.1  riastrad 	__u32 h;
    114  1.1  riastrad 	__u32 d;
    115  1.1  riastrad };
    116  1.1  riastrad 
    117  1.1  riastrad struct drm_virtgpu_3d_transfer_to_host {
    118  1.1  riastrad 	__u32 bo_handle;
    119  1.1  riastrad 	struct drm_virtgpu_3d_box box;
    120  1.1  riastrad 	__u32 level;
    121  1.1  riastrad 	__u32 offset;
    122  1.1  riastrad };
    123  1.1  riastrad 
    124  1.1  riastrad struct drm_virtgpu_3d_transfer_from_host {
    125  1.1  riastrad 	__u32 bo_handle;
    126  1.1  riastrad 	struct drm_virtgpu_3d_box box;
    127  1.1  riastrad 	__u32 level;
    128  1.1  riastrad 	__u32 offset;
    129  1.1  riastrad };
    130  1.1  riastrad 
    131  1.1  riastrad #define VIRTGPU_WAIT_NOWAIT 1 /* like it */
    132  1.1  riastrad struct drm_virtgpu_3d_wait {
    133  1.1  riastrad 	__u32 handle; /* 0 is an invalid handle */
    134  1.1  riastrad 	__u32 flags;
    135  1.1  riastrad };
    136  1.1  riastrad 
    137  1.1  riastrad struct drm_virtgpu_get_caps {
    138  1.1  riastrad 	__u32 cap_set_id;
    139  1.1  riastrad 	__u32 cap_set_ver;
    140  1.1  riastrad 	__u64 addr;
    141  1.1  riastrad 	__u32 size;
    142  1.1  riastrad 	__u32 pad;
    143  1.1  riastrad };
    144  1.1  riastrad 
    145  1.1  riastrad #define DRM_IOCTL_VIRTGPU_MAP \
    146  1.1  riastrad 	DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_MAP, struct drm_virtgpu_map)
    147  1.1  riastrad 
    148  1.1  riastrad #define DRM_IOCTL_VIRTGPU_EXECBUFFER \
    149  1.1  riastrad 	DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_EXECBUFFER,\
    150  1.1  riastrad 		struct drm_virtgpu_execbuffer)
    151  1.1  riastrad 
    152  1.1  riastrad #define DRM_IOCTL_VIRTGPU_GETPARAM \
    153  1.1  riastrad 	DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_GETPARAM,\
    154  1.1  riastrad 		struct drm_virtgpu_getparam)
    155  1.1  riastrad 
    156  1.1  riastrad #define DRM_IOCTL_VIRTGPU_RESOURCE_CREATE			\
    157  1.1  riastrad 	DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_RESOURCE_CREATE,	\
    158  1.1  riastrad 		struct drm_virtgpu_resource_create)
    159  1.1  riastrad 
    160  1.1  riastrad #define DRM_IOCTL_VIRTGPU_RESOURCE_INFO \
    161  1.1  riastrad 	DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_RESOURCE_INFO, \
    162  1.1  riastrad 		 struct drm_virtgpu_resource_info)
    163  1.1  riastrad 
    164  1.1  riastrad #define DRM_IOCTL_VIRTGPU_TRANSFER_FROM_HOST \
    165  1.1  riastrad 	DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_TRANSFER_FROM_HOST,	\
    166  1.1  riastrad 		struct drm_virtgpu_3d_transfer_from_host)
    167  1.1  riastrad 
    168  1.1  riastrad #define DRM_IOCTL_VIRTGPU_TRANSFER_TO_HOST \
    169  1.1  riastrad 	DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_TRANSFER_TO_HOST,	\
    170  1.1  riastrad 		struct drm_virtgpu_3d_transfer_to_host)
    171  1.1  riastrad 
    172  1.1  riastrad #define DRM_IOCTL_VIRTGPU_WAIT				\
    173  1.1  riastrad 	DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_WAIT,	\
    174  1.1  riastrad 		struct drm_virtgpu_3d_wait)
    175  1.1  riastrad 
    176  1.1  riastrad #define DRM_IOCTL_VIRTGPU_GET_CAPS \
    177  1.1  riastrad 	DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_GET_CAPS, \
    178  1.1  riastrad 	struct drm_virtgpu_get_caps)
    179  1.1  riastrad 
    180  1.1  riastrad #if defined(__cplusplus)
    181  1.1  riastrad }
    182  1.1  riastrad #endif
    183  1.1  riastrad 
    184  1.1  riastrad #endif
    185