1295 lines · 39.2 KB · C
RawDownload
/* SPDX-License-Identifier: (GPL-2.0-only WITH Linux-syscall-note) OR MIT *//* Copyright (c) 2023 Imagination Technologies Ltd. */ #ifndef PVR_DRM_UAPI_H#define PVR_DRM_UAPI_H #include "drm.h" #include <linux/const.h>#include <linux/types.h> #if defined(__cplusplus)extern "C" {#endif /** * DOC: PowerVR UAPI * * The PowerVR IOCTL argument structs have a few limitations in place, in * addition to the standard kernel restrictions: * *  - All members must be type-aligned. *  - The overall struct must be padded to 64-bit alignment. *  - Explicit padding is almost always required. This takes the form of *    ``_padding_[x]`` members of sufficient size to pad to the next power-of-two *    alignment, where [x] is the offset into the struct in hexadecimal. Arrays *    are never used for alignment. Padding fields must be zeroed; this is *    always checked. *  - Unions may only appear as the last member of a struct. *  - Individual union members may grow in the future. The space between the *    end of a union member and the end of its containing union is considered *    "implicit padding" and must be zeroed. This is always checked. * * In addition to the IOCTL argument structs, the PowerVR UAPI makes use of * DEV_QUERY argument structs. These are used to fetch information about the * device and runtime. These structs are subject to the same rules set out * above. */ /** * struct drm_pvr_obj_array - Container used to pass arrays of objects * * It is not unusual to have to extend objects to pass new parameters, and the DRM * ioctl infrastructure is supporting that by padding ioctl arguments with zeros * when the data passed by userspace is smaller than the struct defined in the * drm_ioctl_desc, thus keeping things backward compatible. This type is just * applying the same concepts to indirect objects passed through arrays referenced * from the main ioctl arguments structure: the stride basically defines the size * of the object passed by userspace, which allows the kernel driver to pad with * zeros when it's smaller than the size of the object it expects. * * Use ``DRM_PVR_OBJ_ARRAY()`` to fill object array fields, unless you * have a very good reason not to. */struct drm_pvr_obj_array {	/** @stride: Stride of object struct. Used for versioning. */	__u32 stride; 	/** @count: Number of objects in the array. */	__u32 count; 	/** @array: User pointer to an array of objects. */	__u64 array;}; /** * DRM_PVR_OBJ_ARRAY() - Helper macro for filling &struct drm_pvr_obj_array. * @cnt: Number of elements pointed to py @ptr. * @ptr: Pointer to start of a C array. * * Return: Literal of type &struct drm_pvr_obj_array. */#define DRM_PVR_OBJ_ARRAY(cnt, ptr) \	{ .stride = sizeof((ptr)[0]), .count = (cnt), .array = (__u64)(uintptr_t)(ptr) } /** * DOC: PowerVR IOCTL interface */ /** * PVR_IOCTL() - Build a PowerVR IOCTL number * @_ioctl: An incrementing id for this IOCTL. Added to %DRM_COMMAND_BASE. * @_mode: Must be one of %DRM_IOR, %DRM_IOW or %DRM_IOWR. * @_data: The type of the args struct passed by this IOCTL. * * The struct referred to by @_data must have a ``drm_pvr_ioctl_`` prefix and an * ``_args suffix``. They are therefore omitted from @_data. * * This should only be used to build the constants described below; it should * never be used to call an IOCTL directly. * * Return: An IOCTL number to be passed to ioctl() from userspace. */#define PVR_IOCTL(_ioctl, _mode, _data) \	_mode(DRM_COMMAND_BASE + (_ioctl), struct drm_pvr_ioctl_##_data##_args) #define DRM_IOCTL_PVR_DEV_QUERY PVR_IOCTL(0x00, DRM_IOWR, dev_query)#define DRM_IOCTL_PVR_CREATE_BO PVR_IOCTL(0x01, DRM_IOWR, create_bo)#define DRM_IOCTL_PVR_GET_BO_MMAP_OFFSET PVR_IOCTL(0x02, DRM_IOWR, get_bo_mmap_offset)#define DRM_IOCTL_PVR_CREATE_VM_CONTEXT PVR_IOCTL(0x03, DRM_IOWR, create_vm_context)#define DRM_IOCTL_PVR_DESTROY_VM_CONTEXT PVR_IOCTL(0x04, DRM_IOW, destroy_vm_context)#define DRM_IOCTL_PVR_VM_MAP PVR_IOCTL(0x05, DRM_IOW, vm_map)#define DRM_IOCTL_PVR_VM_UNMAP PVR_IOCTL(0x06, DRM_IOW, vm_unmap)#define DRM_IOCTL_PVR_CREATE_CONTEXT PVR_IOCTL(0x07, DRM_IOWR, create_context)#define DRM_IOCTL_PVR_DESTROY_CONTEXT PVR_IOCTL(0x08, DRM_IOW, destroy_context)#define DRM_IOCTL_PVR_CREATE_FREE_LIST PVR_IOCTL(0x09, DRM_IOWR, create_free_list)#define DRM_IOCTL_PVR_DESTROY_FREE_LIST PVR_IOCTL(0x0a, DRM_IOW, destroy_free_list)#define DRM_IOCTL_PVR_CREATE_HWRT_DATASET PVR_IOCTL(0x0b, DRM_IOWR, create_hwrt_dataset)#define DRM_IOCTL_PVR_DESTROY_HWRT_DATASET PVR_IOCTL(0x0c, DRM_IOW, destroy_hwrt_dataset)#define DRM_IOCTL_PVR_SUBMIT_JOBS PVR_IOCTL(0x0d, DRM_IOW, submit_jobs) /** * DOC: PowerVR IOCTL DEV_QUERY interface */ /** * struct drm_pvr_dev_query_gpu_info - Container used to fetch information about * the graphics processor. * * When fetching this type &struct drm_pvr_ioctl_dev_query_args.type must be set * to %DRM_PVR_DEV_QUERY_GPU_INFO_GET. */struct drm_pvr_dev_query_gpu_info {	/**	 * @gpu_id: GPU identifier.	 *	 * For all currently supported GPUs this is the BVNC encoded as a 64-bit	 * value as follows:	 *	 *    +--------+--------+--------+-------+	 *    | 63..48 | 47..32 | 31..16 | 15..0 |	 *    +========+========+========+=======+	 *    | B      | V      | N      | C     |	 *    +--------+--------+--------+-------+	 */	__u64 gpu_id; 	/**	 * @num_phantoms: Number of Phantoms present.	 */	__u32 num_phantoms; 	/** @_padding_c: Reserved. This field must be zeroed. */	__u32 _padding_c;}; /** * struct drm_pvr_dev_query_runtime_info - Container used to fetch information * about the graphics runtime. * * When fetching this type &struct drm_pvr_ioctl_dev_query_args.type must be set * to %DRM_PVR_DEV_QUERY_RUNTIME_INFO_GET. */struct drm_pvr_dev_query_runtime_info {	/**	 * @free_list_min_pages: Minimum allowed free list size,	 * in PM physical pages.	 */	__u64 free_list_min_pages; 	/**	 * @free_list_max_pages: Maximum allowed free list size,	 * in PM physical pages.	 */	__u64 free_list_max_pages; 	/**	 * @common_store_alloc_region_size: Size of the Allocation	 * Region within the Common Store used for coefficient and shared	 * registers, in dwords.	 */	__u32 common_store_alloc_region_size; 	/**	 * @common_store_partition_space_size: Size of the	 * Partition Space within the Common Store for output buffers, in	 * dwords.	 */	__u32 common_store_partition_space_size; 	/**	 * @max_coeffs: Maximum coefficients, in dwords.	 */	__u32 max_coeffs; 	/**	 * @cdm_max_local_mem_size_regs: Maximum amount of local	 * memory available to a compute kernel, in dwords.	 */	__u32 cdm_max_local_mem_size_regs;}; /** * struct drm_pvr_dev_query_quirks - Container used to fetch information about * hardware fixes for which the device may require support in the user mode * driver. * * When fetching this type &struct drm_pvr_ioctl_dev_query_args.type must be set * to %DRM_PVR_DEV_QUERY_QUIRKS_GET. */struct drm_pvr_dev_query_quirks {	/**	 * @quirks: A userspace address for the hardware quirks __u32 array.	 *	 * The first @musthave_count items in the list are quirks that the	 * client must support for this device. If userspace does not support	 * all these quirks then functionality is not guaranteed and client	 * initialisation must fail.	 * The remaining quirks in the list affect userspace and the kernel or	 * firmware. They are disabled by default and require userspace to	 * opt-in. The opt-in mechanism depends on the quirk.	 */	__u64 quirks; 	/** @count: Length of @quirks (number of __u32). */	__u16 count; 	/**	 * @musthave_count: The number of entries in @quirks that are	 * mandatory, starting at index 0.	 */	__u16 musthave_count; 	/** @_padding_c: Reserved. This field must be zeroed. */	__u32 _padding_c;}; /** * struct drm_pvr_dev_query_enhancements - Container used to fetch information * about optional enhancements supported by the device that require support in * the user mode driver. * * When fetching this type &struct drm_pvr_ioctl_dev_query_args.type must be set * to %DRM_PVR_DEV_ENHANCEMENTS_GET. */struct drm_pvr_dev_query_enhancements {	/**	 * @enhancements: A userspace address for the hardware enhancements	 * __u32 array.	 *	 * These enhancements affect userspace and the kernel or firmware. They	 * are disabled by default and require userspace to opt-in. The opt-in	 * mechanism depends on the enhancement.	 */	__u64 enhancements; 	/** @count: Length of @enhancements (number of __u32). */	__u16 count; 	/** @_padding_a: Reserved. This field must be zeroed. */	__u16 _padding_a; 	/** @_padding_c: Reserved. This field must be zeroed. */	__u32 _padding_c;}; /** * enum drm_pvr_heap_id - Array index for heap info data returned by * %DRM_PVR_DEV_QUERY_HEAP_INFO_GET. * * For compatibility reasons all indices will be present in the returned array, * however some heaps may not be present. These are indicated where * &struct drm_pvr_heap.size is set to zero. */enum drm_pvr_heap_id {	/** @DRM_PVR_HEAP_GENERAL: General purpose heap. */	DRM_PVR_HEAP_GENERAL = 0,	/** @DRM_PVR_HEAP_PDS_CODE_DATA: PDS code and data heap. */	DRM_PVR_HEAP_PDS_CODE_DATA,	/** @DRM_PVR_HEAP_USC_CODE: USC code heap. */	DRM_PVR_HEAP_USC_CODE,	/** @DRM_PVR_HEAP_RGNHDR: Region header heap. Only used if GPU has BRN63142. */	DRM_PVR_HEAP_RGNHDR,	/** @DRM_PVR_HEAP_VIS_TEST: Visibility test heap. */	DRM_PVR_HEAP_VIS_TEST,	/** @DRM_PVR_HEAP_TRANSFER_FRAG: Transfer fragment heap. */	DRM_PVR_HEAP_TRANSFER_FRAG, 	/**	 * @DRM_PVR_HEAP_COUNT: The number of heaps returned by	 * %DRM_PVR_DEV_QUERY_HEAP_INFO_GET.	 *	 * More heaps may be added, so this also serves as the copy limit when	 * sent by the caller.	 */	DRM_PVR_HEAP_COUNT	/* Please only add additional heaps above DRM_PVR_HEAP_COUNT! */}; /** * struct drm_pvr_heap - Container holding information about a single heap. * * This will always be fetched as an array. */struct drm_pvr_heap {	/** @base: Base address of heap. */	__u64 base; 	/** @size: Size of heap, in bytes. Will be 0 if the heap is not present. */	__u64 size; 	/** @flags: Flags for this heap. Currently always 0. */	__u32 flags; 	/** @page_size_log2: Log2 of page size. */	__u32 page_size_log2;}; /** * struct drm_pvr_dev_query_heap_info - Container used to fetch information * about heaps supported by the device driver. * * Please note all driver-supported heaps will be returned up to &heaps.count. * Some heaps will not be present in all devices, which will be indicated by * &struct drm_pvr_heap.size being set to zero. * * When fetching this type &struct drm_pvr_ioctl_dev_query_args.type must be set * to %DRM_PVR_DEV_QUERY_HEAP_INFO_GET. */struct drm_pvr_dev_query_heap_info {	/**	 * @heaps: Array of &struct drm_pvr_heap. If pointer is NULL, the count	 * and stride will be updated with those known to the driver version, to	 * facilitate allocation by the caller.	 */	struct drm_pvr_obj_array heaps;}; /** * enum drm_pvr_static_data_area_usage - Array index for static data area info * returned by %DRM_PVR_DEV_QUERY_STATIC_DATA_AREAS_GET. * * For compatibility reasons all indices will be present in the returned array, * however some areas may not be present. These are indicated where * &struct drm_pvr_static_data_area.size is set to zero. */enum drm_pvr_static_data_area_usage {	/**	 * @DRM_PVR_STATIC_DATA_AREA_EOT: End of Tile PDS program code segment.	 *	 * The End of Tile PDS task runs at completion of a tile during a fragment job, and is	 * responsible for emitting the tile to the Pixel Back End.	 */	DRM_PVR_STATIC_DATA_AREA_EOT = 0, 	/**	 * @DRM_PVR_STATIC_DATA_AREA_FENCE: MCU fence area, used during cache flush and	 * invalidation.	 *	 * This must point to valid physical memory but the contents otherwise are not used.	 */	DRM_PVR_STATIC_DATA_AREA_FENCE, 	/**	 * @DRM_PVR_STATIC_DATA_AREA_VDM_SYNC: VDM sync program.	 *	 * The VDM sync program is used to synchronise multiple areas of the GPU hardware.	 */	DRM_PVR_STATIC_DATA_AREA_VDM_SYNC, 	/**	 * @DRM_PVR_STATIC_DATA_AREA_YUV_CSC: YUV coefficients.	 *	 * Area contains up to 16 slots with stride of 64 bytes. Each is a 3x4 matrix of u16 fixed	 * point numbers, with 1 sign bit, 2 integer bits and 13 fractional bits.	 *	 * The slots are :	 * 0 = VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY_KHR	 * 1 = VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_IDENTITY_KHR (full range)	 * 2 = VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_IDENTITY_KHR (conformant range)	 * 3 = VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_709_KHR (full range)	 * 4 = VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_709_KHR (conformant range)	 * 5 = VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_601_KHR (full range)	 * 6 = VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_601_KHR (conformant range)	 * 7 = VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_2020_KHR (full range)	 * 8 = VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_2020_KHR (conformant range)	 * 9 = VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_601_KHR (conformant range, 10 bit)	 * 10 = VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_709_KHR (conformant range, 10 bit)	 * 11 = VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_2020_KHR (conformant range, 10 bit)	 * 14 = Identity (biased)	 * 15 = Identity	 */	DRM_PVR_STATIC_DATA_AREA_YUV_CSC,}; /** * struct drm_pvr_static_data_area - Container holding information about a * single static data area. * * This will always be fetched as an array. */struct drm_pvr_static_data_area {	/**	 * @area_usage: Usage of static data area.	 * See &enum drm_pvr_static_data_area_usage.	 */	__u16 area_usage; 	/**	 * @location_heap_id: Array index of heap where this of static data	 * area is located. This array is fetched using	 * %DRM_PVR_DEV_QUERY_HEAP_INFO_GET.	 */	__u16 location_heap_id; 	/** @size: Size of static data area. Not present if set to zero. */	__u32 size; 	/** @offset: Offset of static data area from start of heap. */	__u64 offset;}; /** * struct drm_pvr_dev_query_static_data_areas - Container used to fetch * information about the static data areas in heaps supported by the device * driver. * * Please note all driver-supported static data areas will be returned up to * &static_data_areas.count. Some will not be present for all devices which, * will be indicated by &struct drm_pvr_static_data_area.size being set to zero. * * Further, some heaps will not be present either. See &struct * drm_pvr_dev_query_heap_info. * * When fetching this type &struct drm_pvr_ioctl_dev_query_args.type must be set * to %DRM_PVR_DEV_QUERY_STATIC_DATA_AREAS_GET. */struct drm_pvr_dev_query_static_data_areas {	/**	 * @static_data_areas: Array of &struct drm_pvr_static_data_area. If	 * pointer is NULL, the count and stride will be updated with those	 * known to the driver version, to facilitate allocation by the caller.	 */	struct drm_pvr_obj_array static_data_areas;}; /** * enum drm_pvr_dev_query - For use with &drm_pvr_ioctl_dev_query_args.type to * indicate the type of the receiving container. * * Append only. Do not reorder. */enum drm_pvr_dev_query {	/**	 * @DRM_PVR_DEV_QUERY_GPU_INFO_GET: The dev query args contain a pointer	 * to &struct drm_pvr_dev_query_gpu_info.	 */	DRM_PVR_DEV_QUERY_GPU_INFO_GET = 0, 	/**	 * @DRM_PVR_DEV_QUERY_RUNTIME_INFO_GET: The dev query args contain a	 * pointer to &struct drm_pvr_dev_query_runtime_info.	 */	DRM_PVR_DEV_QUERY_RUNTIME_INFO_GET, 	/**	 * @DRM_PVR_DEV_QUERY_QUIRKS_GET: The dev query args contain a pointer	 * to &struct drm_pvr_dev_query_quirks.	 */	DRM_PVR_DEV_QUERY_QUIRKS_GET, 	/**	 * @DRM_PVR_DEV_QUERY_ENHANCEMENTS_GET: The dev query args contain a	 * pointer to &struct drm_pvr_dev_query_enhancements.	 */	DRM_PVR_DEV_QUERY_ENHANCEMENTS_GET, 	/**	 * @DRM_PVR_DEV_QUERY_HEAP_INFO_GET: The dev query args contain a	 * pointer to &struct drm_pvr_dev_query_heap_info.	 */	DRM_PVR_DEV_QUERY_HEAP_INFO_GET, 	/**	 * @DRM_PVR_DEV_QUERY_STATIC_DATA_AREAS_GET: The dev query args contain	 * a pointer to &struct drm_pvr_dev_query_static_data_areas.	 */	DRM_PVR_DEV_QUERY_STATIC_DATA_AREAS_GET,}; /** * struct drm_pvr_ioctl_dev_query_args - Arguments for %DRM_IOCTL_PVR_DEV_QUERY. */struct drm_pvr_ioctl_dev_query_args {	/**	 * @type: Type of query and output struct. See &enum drm_pvr_dev_query.	 */	__u32 type; 	/**	 * @size: Size of the receiving struct, see @type.	 *	 * After a successful call this will be updated to the written byte	 * length.	 * Can also be used to get the minimum byte length (see @pointer).	 * This allows additional fields to be appended to the structs in	 * future.	 */	__u32 size; 

Lines 1–500 of 1295.