| 1 | /* SPDX-License-Identifier: GPL-2.0 or MIT */ |
| 2 | /* Copyright 2025 Arm, Ltd. */ |
| 3 | |
| 4 | #ifndef __ETHOSU_GEM_H__ |
| 5 | #define __ETHOSU_GEM_H__ |
| 6 | |
| 7 | #include "ethosu_device.h" |
| 8 | #include <drm/drm_gem_dma_helper.h> |
| 9 | |
| 10 | struct ethosu_validated_cmdstream_info { |
| 11 | u32 cmd_size; |
| 12 | u64 region_size[NPU_BASEP_REGION_MAX]; |
| 13 | bool output_region[NPU_BASEP_REGION_MAX]; |
| 14 | }; |
| 15 | |
| 16 | /** |
| 17 | * struct ethosu_gem_object - Driver specific GEM object. |
| 18 | */ |
| 19 | struct ethosu_gem_object { |
| 20 | /** @base: Inherit from drm_gem_shmem_object. */ |
| 21 | struct drm_gem_dma_object base; |
| 22 | |
| 23 | struct ethosu_validated_cmdstream_info *info; |
| 24 | |
| 25 | /** @flags: Combination of drm_ethosu_bo_flags flags. */ |
| 26 | u32 flags; |
| 27 | }; |
| 28 | |
| 29 | static inline |
| 30 | struct ethosu_gem_object *to_ethosu_bo(struct drm_gem_object *obj) |
| 31 | { |
| 32 | return container_of(to_drm_gem_dma_obj(obj), struct ethosu_gem_object, base); |
| 33 | } |
| 34 | |
| 35 | struct drm_gem_object *ethosu_gem_create_object(struct drm_device *ddev, |
| 36 | size_t size); |
| 37 | |
| 38 | int ethosu_gem_create_with_handle(struct drm_file *file, |
| 39 | struct drm_device *ddev, |
| 40 | u64 *size, u32 flags, uint32_t *handle); |
| 41 | |
| 42 | int ethosu_gem_cmdstream_create(struct drm_file *file, |
| 43 | struct drm_device *ddev, |
| 44 | u32 size, u64 data, u32 flags, u32 *handle); |
| 45 | |
| 46 | #endif /* __ETHOSU_GEM_H__ */ |
| 47 | |