drivers/gpu/drm/imagination/pvr_drv.h

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/imagination/pvr_drv.h

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/imagination/pvr_drv.h
Extension
.h
Size
5192 bytes
Lines
129
Domain
Driver Families
Bucket
drivers/gpu
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

#ifndef PVR_DRV_H
#define PVR_DRV_H

#include "linux/compiler_attributes.h"
#include <uapi/drm/pvr_drm.h>

#define PVR_DRIVER_NAME "powervr"
#define PVR_DRIVER_DESC "Imagination PowerVR (Series 6 and later) & IMG Graphics"

/*
 * Driver interface version:
 *  - 1.0: Initial interface
 */
#define PVR_DRIVER_MAJOR 1
#define PVR_DRIVER_MINOR 0
#define PVR_DRIVER_PATCHLEVEL 0

int pvr_get_uobj(u64 usr_ptr, u32 usr_size, u32 min_size, u32 obj_size, void *out);
int pvr_set_uobj(u64 usr_ptr, u32 usr_size, u32 min_size, u32 obj_size, const void *in);
int pvr_get_uobj_array(const struct drm_pvr_obj_array *in, u32 min_stride, u32 obj_size,
		       void **out);
int pvr_set_uobj_array(const struct drm_pvr_obj_array *out, u32 min_stride, u32 obj_size,
		       const void *in);

#define PVR_UOBJ_MIN_SIZE_INTERNAL(_typename, _last_mandatory_field) \
	(offsetof(_typename, _last_mandatory_field) + \
	 sizeof(((_typename *)NULL)->_last_mandatory_field))

/* NOLINTBEGIN(bugprone-macro-parentheses) */
#define PVR_UOBJ_DECL(_typename, _last_mandatory_field) \
	, _typename : PVR_UOBJ_MIN_SIZE_INTERNAL(_typename, _last_mandatory_field)
/* NOLINTEND(bugprone-macro-parentheses) */

/**
 * DOC: PVR user objects.
 *
 * Macros used to aid copying structured and array data to and from
 * userspace. Objects can differ in size, provided the minimum size
 * allowed is specified (using the last mandatory field in the struct).
 * All types used with PVR_UOBJ_GET/SET macros must be listed here under
 * PVR_UOBJ_MIN_SIZE, with the last mandatory struct field specified.
 */

/**
 * PVR_UOBJ_MIN_SIZE() - Fetch the minimum copy size of a compatible type object.
 * @_obj_name: The name of the object. Cannot be a typename - this is deduced.
 *
 * This cannot fail. Using the macro with an incompatible type will result in a
 * compiler error.
 *
 * To add compatibility for a type, list it within the macro in an orderly
 * fashion. The second argument is the name of the last mandatory field of the
 * struct type, which is used to calculate the size. See also PVR_UOBJ_DECL().
 *
 * Return: The minimum copy size.
 */
#define PVR_UOBJ_MIN_SIZE(_obj_name) _Generic(_obj_name \
	PVR_UOBJ_DECL(struct drm_pvr_job, hwrt) \
	PVR_UOBJ_DECL(struct drm_pvr_sync_op, value) \
	PVR_UOBJ_DECL(struct drm_pvr_dev_query_gpu_info, num_phantoms) \
	PVR_UOBJ_DECL(struct drm_pvr_dev_query_runtime_info, cdm_max_local_mem_size_regs) \
	PVR_UOBJ_DECL(struct drm_pvr_dev_query_quirks, _padding_c) \
	PVR_UOBJ_DECL(struct drm_pvr_dev_query_enhancements, _padding_c) \
	PVR_UOBJ_DECL(struct drm_pvr_heap, page_size_log2) \
	PVR_UOBJ_DECL(struct drm_pvr_dev_query_heap_info, heaps) \
	PVR_UOBJ_DECL(struct drm_pvr_static_data_area, offset) \
	PVR_UOBJ_DECL(struct drm_pvr_dev_query_static_data_areas, static_data_areas) \
	)

/**
 * PVR_UOBJ_GET() - Copies from _src_usr_ptr to &_dest_obj.
 * @_dest_obj: The destination container object in kernel space.
 * @_usr_size: The size of the source container in user space.
 * @_src_usr_ptr: __u64 raw pointer to the source container in user space.
 *
 * Return: Error code. See pvr_get_uobj().
 */
#define PVR_UOBJ_GET(_dest_obj, _usr_size, _src_usr_ptr) \
	pvr_get_uobj(_src_usr_ptr, _usr_size, \
		     PVR_UOBJ_MIN_SIZE(_dest_obj), \
		     sizeof(_dest_obj), &(_dest_obj))

/**
 * PVR_UOBJ_SET() - Copies from &_src_obj to _dest_usr_ptr.
 * @_dest_usr_ptr: __u64 raw pointer to the destination container in user space.
 * @_usr_size: The size of the destination container in user space.
 * @_src_obj: The source container object in kernel space.
 *
 * Return: Error code. See pvr_set_uobj().
 */

Annotation

Implementation Notes