Path: blob/21.2-virgl/include/drm-uapi/lima_drm.h
4545 views
/* SPDX-License-Identifier: (GPL-2.0 WITH Linux-syscall-note) OR MIT */1/* Copyright 2017-2018 Qiang Yu <[email protected]> */23#ifndef __LIMA_DRM_H__4#define __LIMA_DRM_H__56#include "drm.h"78#if defined(__cplusplus)9extern "C" {10#endif1112enum drm_lima_param_gpu_id {13DRM_LIMA_PARAM_GPU_ID_UNKNOWN,14DRM_LIMA_PARAM_GPU_ID_MALI400,15DRM_LIMA_PARAM_GPU_ID_MALI450,16};1718enum drm_lima_param {19DRM_LIMA_PARAM_GPU_ID,20DRM_LIMA_PARAM_NUM_PP,21DRM_LIMA_PARAM_GP_VERSION,22DRM_LIMA_PARAM_PP_VERSION,23};2425/**26* get various information of the GPU27*/28struct drm_lima_get_param {29__u32 param; /* in, value in enum drm_lima_param */30__u32 pad; /* pad, must be zero */31__u64 value; /* out, parameter value */32};3334/*35* heap buffer dynamically increase backup memory size when GP task fail36* due to lack of heap memory. size field of heap buffer is an up bound of37* the backup memory which can be set to a fairly large value.38*/39#define LIMA_BO_FLAG_HEAP (1 << 0)4041/**42* create a buffer for used by GPU43*/44struct drm_lima_gem_create {45__u32 size; /* in, buffer size */46__u32 flags; /* in, buffer flags */47__u32 handle; /* out, GEM buffer handle */48__u32 pad; /* pad, must be zero */49};5051/**52* get information of a buffer53*/54struct drm_lima_gem_info {55__u32 handle; /* in, GEM buffer handle */56__u32 va; /* out, virtual address mapped into GPU MMU */57__u64 offset; /* out, used to mmap this buffer to CPU */58};5960#define LIMA_SUBMIT_BO_READ 0x0161#define LIMA_SUBMIT_BO_WRITE 0x026263/* buffer information used by one task */64struct drm_lima_gem_submit_bo {65__u32 handle; /* in, GEM buffer handle */66__u32 flags; /* in, buffer read/write by GPU */67};6869#define LIMA_GP_FRAME_REG_NUM 67071/* frame used to setup GP for each task */72struct drm_lima_gp_frame {73__u32 frame[LIMA_GP_FRAME_REG_NUM];74};7576#define LIMA_PP_FRAME_REG_NUM 2377#define LIMA_PP_WB_REG_NUM 127879/* frame used to setup mali400 GPU PP for each task */80struct drm_lima_m400_pp_frame {81__u32 frame[LIMA_PP_FRAME_REG_NUM];82__u32 num_pp;83__u32 wb[3 * LIMA_PP_WB_REG_NUM];84__u32 plbu_array_address[4];85__u32 fragment_stack_address[4];86};8788/* frame used to setup mali450 GPU PP for each task */89struct drm_lima_m450_pp_frame {90__u32 frame[LIMA_PP_FRAME_REG_NUM];91__u32 num_pp;92__u32 wb[3 * LIMA_PP_WB_REG_NUM];93__u32 use_dlbu;94__u32 _pad;95union {96__u32 plbu_array_address[8];97__u32 dlbu_regs[4];98};99__u32 fragment_stack_address[8];100};101102#define LIMA_PIPE_GP 0x00103#define LIMA_PIPE_PP 0x01104105#define LIMA_SUBMIT_FLAG_EXPLICIT_FENCE (1 << 0)106107/**108* submit a task to GPU109*110* User can always merge multi sync_file and drm_syncobj111* into one drm_syncobj as in_sync[0], but we reserve112* in_sync[1] for another task's out_sync to avoid the113* export/import/merge pass when explicit sync.114*/115struct drm_lima_gem_submit {116__u32 ctx; /* in, context handle task is submitted to */117__u32 pipe; /* in, which pipe to use, GP/PP */118__u32 nr_bos; /* in, array length of bos field */119__u32 frame_size; /* in, size of frame field */120__u64 bos; /* in, array of drm_lima_gem_submit_bo */121__u64 frame; /* in, GP/PP frame */122__u32 flags; /* in, submit flags */123__u32 out_sync; /* in, drm_syncobj handle used to wait task finish after submission */124__u32 in_sync[2]; /* in, drm_syncobj handle used to wait before start this task */125};126127#define LIMA_GEM_WAIT_READ 0x01128#define LIMA_GEM_WAIT_WRITE 0x02129130/**131* wait pending GPU task finish of a buffer132*/133struct drm_lima_gem_wait {134__u32 handle; /* in, GEM buffer handle */135__u32 op; /* in, CPU want to read/write this buffer */136__s64 timeout_ns; /* in, wait timeout in absulute time */137};138139/**140* create a context141*/142struct drm_lima_ctx_create {143__u32 id; /* out, context handle */144__u32 _pad; /* pad, must be zero */145};146147/**148* free a context149*/150struct drm_lima_ctx_free {151__u32 id; /* in, context handle */152__u32 _pad; /* pad, must be zero */153};154155#define DRM_LIMA_GET_PARAM 0x00156#define DRM_LIMA_GEM_CREATE 0x01157#define DRM_LIMA_GEM_INFO 0x02158#define DRM_LIMA_GEM_SUBMIT 0x03159#define DRM_LIMA_GEM_WAIT 0x04160#define DRM_LIMA_CTX_CREATE 0x05161#define DRM_LIMA_CTX_FREE 0x06162163#define DRM_IOCTL_LIMA_GET_PARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_LIMA_GET_PARAM, struct drm_lima_get_param)164#define DRM_IOCTL_LIMA_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_LIMA_GEM_CREATE, struct drm_lima_gem_create)165#define DRM_IOCTL_LIMA_GEM_INFO DRM_IOWR(DRM_COMMAND_BASE + DRM_LIMA_GEM_INFO, struct drm_lima_gem_info)166#define DRM_IOCTL_LIMA_GEM_SUBMIT DRM_IOW(DRM_COMMAND_BASE + DRM_LIMA_GEM_SUBMIT, struct drm_lima_gem_submit)167#define DRM_IOCTL_LIMA_GEM_WAIT DRM_IOW(DRM_COMMAND_BASE + DRM_LIMA_GEM_WAIT, struct drm_lima_gem_wait)168#define DRM_IOCTL_LIMA_CTX_CREATE DRM_IOR(DRM_COMMAND_BASE + DRM_LIMA_CTX_CREATE, struct drm_lima_ctx_create)169#define DRM_IOCTL_LIMA_CTX_FREE DRM_IOW(DRM_COMMAND_BASE + DRM_LIMA_CTX_FREE, struct drm_lima_ctx_free)170171#if defined(__cplusplus)172}173#endif174175#endif /* __LIMA_DRM_H__ */176177178