/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */1/*2* Copyright (C) 2020-2025 Intel Corporation3*/45#ifndef __UAPI_IVPU_DRM_H__6#define __UAPI_IVPU_DRM_H__78#include "drm.h"910#if defined(__cplusplus)11extern "C" {12#endif1314#define DRM_IVPU_GET_PARAM 0x0015#define DRM_IVPU_SET_PARAM 0x0116#define DRM_IVPU_BO_CREATE 0x0217#define DRM_IVPU_BO_INFO 0x0318#define DRM_IVPU_SUBMIT 0x0519#define DRM_IVPU_BO_WAIT 0x0620#define DRM_IVPU_METRIC_STREAMER_START 0x0721#define DRM_IVPU_METRIC_STREAMER_STOP 0x0822#define DRM_IVPU_METRIC_STREAMER_GET_DATA 0x0923#define DRM_IVPU_METRIC_STREAMER_GET_INFO 0x0a24#define DRM_IVPU_CMDQ_CREATE 0x0b25#define DRM_IVPU_CMDQ_DESTROY 0x0c26#define DRM_IVPU_CMDQ_SUBMIT 0x0d27#define DRM_IVPU_BO_CREATE_FROM_USERPTR 0x0e2829#define DRM_IOCTL_IVPU_GET_PARAM \30DRM_IOWR(DRM_COMMAND_BASE + DRM_IVPU_GET_PARAM, struct drm_ivpu_param)3132#define DRM_IOCTL_IVPU_SET_PARAM \33DRM_IOW(DRM_COMMAND_BASE + DRM_IVPU_SET_PARAM, struct drm_ivpu_param)3435#define DRM_IOCTL_IVPU_BO_CREATE \36DRM_IOWR(DRM_COMMAND_BASE + DRM_IVPU_BO_CREATE, struct drm_ivpu_bo_create)3738#define DRM_IOCTL_IVPU_BO_INFO \39DRM_IOWR(DRM_COMMAND_BASE + DRM_IVPU_BO_INFO, struct drm_ivpu_bo_info)4041#define DRM_IOCTL_IVPU_SUBMIT \42DRM_IOW(DRM_COMMAND_BASE + DRM_IVPU_SUBMIT, struct drm_ivpu_submit)4344#define DRM_IOCTL_IVPU_BO_WAIT \45DRM_IOWR(DRM_COMMAND_BASE + DRM_IVPU_BO_WAIT, struct drm_ivpu_bo_wait)4647#define DRM_IOCTL_IVPU_METRIC_STREAMER_START \48DRM_IOWR(DRM_COMMAND_BASE + DRM_IVPU_METRIC_STREAMER_START, \49struct drm_ivpu_metric_streamer_start)5051#define DRM_IOCTL_IVPU_METRIC_STREAMER_STOP \52DRM_IOW(DRM_COMMAND_BASE + DRM_IVPU_METRIC_STREAMER_STOP, \53struct drm_ivpu_metric_streamer_stop)5455#define DRM_IOCTL_IVPU_METRIC_STREAMER_GET_DATA \56DRM_IOWR(DRM_COMMAND_BASE + DRM_IVPU_METRIC_STREAMER_GET_DATA, \57struct drm_ivpu_metric_streamer_get_data)5859#define DRM_IOCTL_IVPU_METRIC_STREAMER_GET_INFO \60DRM_IOWR(DRM_COMMAND_BASE + DRM_IVPU_METRIC_STREAMER_GET_INFO, \61struct drm_ivpu_metric_streamer_get_data)6263#define DRM_IOCTL_IVPU_CMDQ_CREATE \64DRM_IOWR(DRM_COMMAND_BASE + DRM_IVPU_CMDQ_CREATE, struct drm_ivpu_cmdq_create)6566#define DRM_IOCTL_IVPU_CMDQ_DESTROY \67DRM_IOW(DRM_COMMAND_BASE + DRM_IVPU_CMDQ_DESTROY, struct drm_ivpu_cmdq_destroy)6869#define DRM_IOCTL_IVPU_CMDQ_SUBMIT \70DRM_IOW(DRM_COMMAND_BASE + DRM_IVPU_CMDQ_SUBMIT, struct drm_ivpu_cmdq_submit)7172#define DRM_IOCTL_IVPU_BO_CREATE_FROM_USERPTR \73DRM_IOWR(DRM_COMMAND_BASE + DRM_IVPU_BO_CREATE_FROM_USERPTR, \74struct drm_ivpu_bo_create_from_userptr)7576/**77* DOC: contexts78*79* VPU contexts have private virtual address space, job queues and priority.80* Each context is identified by an unique ID. Context is created on open().81*/8283#define DRM_IVPU_PARAM_DEVICE_ID 084#define DRM_IVPU_PARAM_DEVICE_REVISION 185#define DRM_IVPU_PARAM_PLATFORM_TYPE 286#define DRM_IVPU_PARAM_CORE_CLOCK_RATE 387#define DRM_IVPU_PARAM_NUM_CONTEXTS 488#define DRM_IVPU_PARAM_CONTEXT_BASE_ADDRESS 589#define DRM_IVPU_PARAM_CONTEXT_PRIORITY 6 /* Deprecated */90#define DRM_IVPU_PARAM_CONTEXT_ID 791#define DRM_IVPU_PARAM_FW_API_VERSION 892#define DRM_IVPU_PARAM_ENGINE_HEARTBEAT 993#define DRM_IVPU_PARAM_UNIQUE_INFERENCE_ID 1094#define DRM_IVPU_PARAM_TILE_CONFIG 1195#define DRM_IVPU_PARAM_SKU 1296#define DRM_IVPU_PARAM_CAPABILITIES 1397#define DRM_IVPU_PARAM_PREEMPT_BUFFER_SIZE 149899#define DRM_IVPU_PLATFORM_TYPE_SILICON 0100101/* Deprecated, use DRM_IVPU_JOB_PRIORITY */102#define DRM_IVPU_CONTEXT_PRIORITY_IDLE 0103#define DRM_IVPU_CONTEXT_PRIORITY_NORMAL 1104#define DRM_IVPU_CONTEXT_PRIORITY_FOCUS 2105#define DRM_IVPU_CONTEXT_PRIORITY_REALTIME 3106107#define DRM_IVPU_JOB_PRIORITY_DEFAULT 0108#define DRM_IVPU_JOB_PRIORITY_IDLE 1109#define DRM_IVPU_JOB_PRIORITY_NORMAL 2110#define DRM_IVPU_JOB_PRIORITY_FOCUS 3111#define DRM_IVPU_JOB_PRIORITY_REALTIME 4112113/**114* DRM_IVPU_CAP_METRIC_STREAMER115*116* Metric streamer support. Provides sampling of various hardware performance117* metrics like DMA bandwidth and cache miss/hits. Can be used for profiling.118*/119#define DRM_IVPU_CAP_METRIC_STREAMER 1120/**121* DRM_IVPU_CAP_DMA_MEMORY_RANGE122*123* Driver has capability to allocate separate memory range124* accessible by hardware DMA.125*/126#define DRM_IVPU_CAP_DMA_MEMORY_RANGE 2127/**128* DRM_IVPU_CAP_MANAGE_CMDQ129*130* Driver supports explicit command queue operations like command queue create,131* command queue destroy and submit job on specific command queue.132*/133#define DRM_IVPU_CAP_MANAGE_CMDQ 3134/**135* DRM_IVPU_CAP_BO_CREATE_FROM_USERPTR136*137* Driver supports creating buffer objects from user space memory pointers.138* This allows creating GEM buffers from existing user memory regions.139*/140#define DRM_IVPU_CAP_BO_CREATE_FROM_USERPTR 4141142/**143* struct drm_ivpu_param - Get/Set VPU parameters144*/145struct drm_ivpu_param {146/**147* @param:148*149* Supported params:150*151* %DRM_IVPU_PARAM_DEVICE_ID:152* PCI Device ID of the VPU device (read-only)153*154* %DRM_IVPU_PARAM_DEVICE_REVISION:155* VPU device revision (read-only)156*157* %DRM_IVPU_PARAM_PLATFORM_TYPE:158* Returns %DRM_IVPU_PLATFORM_TYPE_SILICON on real hardware or device specific159* platform type when executing on a simulator or emulator (read-only)160*161* %DRM_IVPU_PARAM_CORE_CLOCK_RATE:162* Maximum frequency of the NPU data processing unit clock (read-only)163*164* %DRM_IVPU_PARAM_NUM_CONTEXTS:165* Maximum number of simultaneously existing contexts (read-only)166*167* %DRM_IVPU_PARAM_CONTEXT_BASE_ADDRESS:168* Lowest VPU virtual address available in the current context (read-only)169*170* %DRM_IVPU_PARAM_CONTEXT_ID:171* Current context ID, always greater than 0 (read-only)172*173* %DRM_IVPU_PARAM_FW_API_VERSION:174* Firmware API version array (read-only)175*176* %DRM_IVPU_PARAM_ENGINE_HEARTBEAT:177* Heartbeat value from an engine (read-only).178* Engine ID (i.e. DRM_IVPU_ENGINE_COMPUTE) is given via index.179*180* %DRM_IVPU_PARAM_UNIQUE_INFERENCE_ID:181* Device-unique inference ID (read-only)182*183* %DRM_IVPU_PARAM_TILE_CONFIG:184* VPU tile configuration (read-only)185*186* %DRM_IVPU_PARAM_SKU:187* VPU SKU ID (read-only)188*189* %DRM_IVPU_PARAM_CAPABILITIES:190* Supported capabilities (read-only)191*192* %DRM_IVPU_PARAM_PREEMPT_BUFFER_SIZE:193* Size of the preemption buffer (read-only)194*/195__u32 param;196197/** @index: Index for params that have multiple instances */198__u32 index;199200/** @value: Param value */201__u64 value;202};203204#define DRM_IVPU_BO_SHAVE_MEM 0x00000001205#define DRM_IVPU_BO_HIGH_MEM DRM_IVPU_BO_SHAVE_MEM206#define DRM_IVPU_BO_MAPPABLE 0x00000002207#define DRM_IVPU_BO_DMA_MEM 0x00000004208#define DRM_IVPU_BO_READ_ONLY 0x00000008209210#define DRM_IVPU_BO_CACHED 0x00000000211#define DRM_IVPU_BO_UNCACHED 0x00010000212#define DRM_IVPU_BO_WC 0x00020000213#define DRM_IVPU_BO_CACHE_MASK 0x00030000214215#define DRM_IVPU_BO_FLAGS \216(DRM_IVPU_BO_HIGH_MEM | \217DRM_IVPU_BO_MAPPABLE | \218DRM_IVPU_BO_DMA_MEM | \219DRM_IVPU_BO_READ_ONLY | \220DRM_IVPU_BO_CACHE_MASK)221222/**223* struct drm_ivpu_bo_create - Create BO backed by SHMEM224*225* Create GEM buffer object allocated in SHMEM memory.226*/227struct drm_ivpu_bo_create {228/** @size: The size in bytes of the allocated memory */229__u64 size;230231/**232* @flags:233*234* Supported flags:235*236* %DRM_IVPU_BO_HIGH_MEM:237*238* Allocate VPU address from >4GB range.239* Buffer object with vpu address >4GB can be always accessed by the240* VPU DMA engine, but some HW generation may not be able to access241* this memory from then firmware running on the VPU management processor.242* Suitable for input, output and some scratch buffers.243*244* %DRM_IVPU_BO_MAPPABLE:245*246* Buffer object can be mapped using mmap().247*248* %DRM_IVPU_BO_CACHED:249*250* Allocated BO will be cached on host side (WB) and snooped on the VPU side.251* This is the default caching mode.252*253* %DRM_IVPU_BO_UNCACHED:254*255* Not supported. Use DRM_IVPU_BO_WC instead.256*257* %DRM_IVPU_BO_WC:258*259* Allocated BO will use write combining buffer for writes but reads will be260* uncached.261*/262__u32 flags;263264/** @handle: Returned GEM object handle */265__u32 handle;266267/** @vpu_addr: Returned VPU virtual address */268__u64 vpu_addr;269};270271/**272* struct drm_ivpu_bo_create_from_userptr - Create dma-buf from user pointer273*274* Create a GEM buffer object from a user pointer to a memory region.275*/276struct drm_ivpu_bo_create_from_userptr {277/** @user_ptr: User pointer to memory region (must be page aligned) */278__u64 user_ptr;279280/** @size: Size of the memory region in bytes (must be page aligned) */281__u64 size;282283/**284* @flags:285*286* Supported flags:287*288* %DRM_IVPU_BO_HIGH_MEM:289*290* Allocate VPU address from >4GB range.291*292* %DRM_IVPU_BO_DMA_MEM:293*294* Allocate from DMA memory range accessible by hardware DMA.295*296* %DRM_IVPU_BO_READ_ONLY:297*298* Allocate as a read-only buffer object.299*/300__u32 flags;301302/** @handle: Returned GEM object handle */303__u32 handle;304305/** @vpu_addr: Returned VPU virtual address */306__u64 vpu_addr;307};308309/**310* struct drm_ivpu_bo_info - Query buffer object info311*/312struct drm_ivpu_bo_info {313/** @handle: Handle of the queried BO */314__u32 handle;315316/** @flags: Returned flags used to create the BO */317__u32 flags;318319/** @vpu_addr: Returned VPU virtual address */320__u64 vpu_addr;321322/**323* @mmap_offset:324*325* Returned offset to be used in mmap(). 0 in case the BO is not mappable.326*/327__u64 mmap_offset;328329/** @size: Returned GEM object size, aligned to PAGE_SIZE */330__u64 size;331};332333/* drm_ivpu_submit engines */334#define DRM_IVPU_ENGINE_COMPUTE 0335#define DRM_IVPU_ENGINE_COPY 1 /* Deprecated */336337/**338* struct drm_ivpu_submit - Submit commands to the VPU339*340* Execute a single command buffer on a given VPU engine.341* Handles to all referenced buffer objects have to be provided in @buffers_ptr.342*343* User space may wait on job completion using %DRM_IVPU_BO_WAIT ioctl.344*/345struct drm_ivpu_submit {346/**347* @buffers_ptr:348*349* A pointer to an u32 array of GEM handles of the BOs required for this job.350* The number of elements in the array must be equal to the value given by @buffer_count.351*352* The first BO is the command buffer. The rest of array has to contain all353* BOs referenced from the command buffer.354*/355__u64 buffers_ptr;356357/** @buffer_count: Number of elements in the @buffers_ptr */358__u32 buffer_count;359360/**361* @engine: Select the engine this job should be executed on362*363* %DRM_IVPU_ENGINE_COMPUTE:364*365* Performs Deep Learning Neural Compute Inference Operations366*/367__u32 engine;368369/** @flags: Reserved for future use - must be zero */370__u32 flags;371372/**373* @commands_offset:374*375* Offset inside the first buffer in @buffers_ptr containing commands376* to be executed. The offset has to be 8-byte aligned.377*/378__u32 commands_offset;379380/**381* @priority:382*383* Priority to be set for related job command queue, can be one of the following:384* %DRM_IVPU_JOB_PRIORITY_DEFAULT385* %DRM_IVPU_JOB_PRIORITY_IDLE386* %DRM_IVPU_JOB_PRIORITY_NORMAL387* %DRM_IVPU_JOB_PRIORITY_FOCUS388* %DRM_IVPU_JOB_PRIORITY_REALTIME389*/390__u32 priority;391};392393/**394* struct drm_ivpu_cmdq_submit - Submit commands to the VPU using explicit command queue395*396* Execute a single command buffer on a given command queue.397* Handles to all referenced buffer objects have to be provided in @buffers_ptr.398*399* User space may wait on job completion using %DRM_IVPU_BO_WAIT ioctl.400*/401struct drm_ivpu_cmdq_submit {402/**403* @buffers_ptr:404*405* A pointer to an u32 array of GEM handles of the BOs required for this job.406* The number of elements in the array must be equal to the value given by @buffer_count.407*408* The first BO is the command buffer. The rest of array has to contain all409* BOs referenced from the command buffer.410*/411__u64 buffers_ptr;412413/** @buffer_count: Number of elements in the @buffers_ptr */414__u32 buffer_count;415416/** @cmdq_id: ID for the command queue where job will be submitted */417__u32 cmdq_id;418419/** @flags: Reserved for future use - must be zero */420__u32 flags;421422/**423* @commands_offset:424*425* Offset inside the first buffer in @buffers_ptr containing commands426* to be executed. The offset has to be 8-byte aligned.427*/428__u32 commands_offset;429/**430* @preempt_buffer_index:431*432* Index of the preemption buffer in the buffers_ptr array.433*/434__u32 preempt_buffer_index;435__u32 reserved;436};437438/* drm_ivpu_bo_wait job status codes */439#define DRM_IVPU_JOB_STATUS_SUCCESS 0440#define DRM_IVPU_JOB_STATUS_ABORTED 256441442/**443* struct drm_ivpu_bo_wait - Wait for BO to become inactive444*445* Blocks until a given buffer object becomes inactive.446* With @timeout_ms set to 0 returns immediately.447*/448struct drm_ivpu_bo_wait {449/** @handle: Handle to the buffer object to be waited on */450__u32 handle;451452/** @flags: Reserved for future use - must be zero */453__u32 flags;454455/** @timeout_ns: Absolute timeout in nanoseconds (may be zero) */456__s64 timeout_ns;457458/**459* @job_status:460*461* Job status code which is updated after the job is completed.462* &DRM_IVPU_JOB_STATUS_SUCCESS or device specific error otherwise.463* Valid only if @handle points to a command buffer.464*/465__u32 job_status;466467/** @pad: Padding - must be zero */468__u32 pad;469};470471/**472* struct drm_ivpu_metric_streamer_start - Start collecting metric data473*/474struct drm_ivpu_metric_streamer_start {475/** @metric_group_mask: Indicates metric streamer instance */476__u64 metric_group_mask;477/** @sampling_period_ns: Sampling period in nanoseconds */478__u64 sampling_period_ns;479/**480* @read_period_samples:481*482* Number of samples after which user space will try to read the data.483* Reading the data after significantly longer period may cause data loss.484*/485__u32 read_period_samples;486/** @sample_size: Returned size of a single sample in bytes */487__u32 sample_size;488/** @max_data_size: Returned max @data_size from %DRM_IOCTL_IVPU_METRIC_STREAMER_GET_DATA */489__u32 max_data_size;490};491492/**493* struct drm_ivpu_metric_streamer_get_data - Copy collected metric data494*/495struct drm_ivpu_metric_streamer_get_data {496/** @metric_group_mask: Indicates metric streamer instance */497__u64 metric_group_mask;498/** @buffer_ptr: A pointer to a destination for the copied data */499__u64 buffer_ptr;500/** @buffer_size: Size of the destination buffer */501__u64 buffer_size;502/**503* @data_size: Returned size of copied metric data504*505* If the @buffer_size is zero, returns the amount of data ready to be copied.506*/507__u64 data_size;508};509510/* Command queue flags */511#define DRM_IVPU_CMDQ_FLAG_TURBO 0x00000001512513/**514* struct drm_ivpu_cmdq_create - Create command queue for job submission515*/516struct drm_ivpu_cmdq_create {517/** @cmdq_id: Returned ID of created command queue */518__u32 cmdq_id;519/**520* @priority:521*522* Priority to be set for related job command queue, can be one of the following:523* %DRM_IVPU_JOB_PRIORITY_DEFAULT524* %DRM_IVPU_JOB_PRIORITY_IDLE525* %DRM_IVPU_JOB_PRIORITY_NORMAL526* %DRM_IVPU_JOB_PRIORITY_FOCUS527* %DRM_IVPU_JOB_PRIORITY_REALTIME528*/529__u32 priority;530/**531* @flags:532*533* Supported flags:534*535* %DRM_IVPU_CMDQ_FLAG_TURBO536*537* Enable low-latency mode for the command queue. The NPU will maximize performance538* when executing jobs from such queue at the cost of increased power usage.539*/540__u32 flags;541};542543/**544* struct drm_ivpu_cmdq_destroy - Destroy a command queue545*/546struct drm_ivpu_cmdq_destroy {547/** @cmdq_id: ID of command queue to destroy */548__u32 cmdq_id;549};550551/**552* struct drm_ivpu_metric_streamer_stop - Stop collecting metric data553*/554struct drm_ivpu_metric_streamer_stop {555/** @metric_group_mask: Indicates metric streamer instance */556__u64 metric_group_mask;557};558559#if defined(__cplusplus)560}561#endif562563#endif /* __UAPI_IVPU_DRM_H__ */564565566