| 1 |
/* |
| 2 |
* Copyright © 2022 Intel Corporation |
| 3 |
* |
| 4 |
* Permission is hereby granted, free of charge, to any person obtaining a |
| 5 |
* copy of this software and associated documentation files (the "Software"), |
| 6 |
* to deal in the Software without restriction, including without limitation |
| 7 |
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 |
* and/or sell copies of the Software, and to permit persons to whom the |
| 9 |
* Software is furnished to do so, subject to the following conditions: |
| 10 |
* |
| 11 |
* The above copyright notice and this permission notice (including the next |
| 12 |
* paragraph) shall be included in all copies or substantial portions of the |
| 13 |
* Software. |
| 14 |
* |
| 15 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 18 |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 20 |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
| 21 |
* IN THE SOFTWARE. |
| 22 |
* |
| 23 |
* Authors: |
| 24 |
* Xiaogang Li <[email protected]> |
| 25 |
* |
| 26 |
*/ |
| 27 |
|
| 28 |
/** |
| 29 |
* @file mos_bufmgr_prelim.h |
| 30 |
* |
| 31 |
* The implementation for Prelim version functions. |
| 32 |
*/ |
| 33 |
|
| 34 |
#ifndef MOS_BUFMGR_PRELIM_H |
| 35 |
#define MOS_BUFMGR_PRELIM_H |
| 36 |
|
| 37 |
#ifdef __I915_PMU_OTHER |
| 38 |
#undef __I915_PMU_OTHER |
| 39 |
#endif |
| 40 |
|
| 41 |
#include "i915_drm.h" |
| 42 |
#include "i915_drm_prelim.h" |
| 43 |
#include "media_class_trace.h" |
| 44 |
class BufmgrPrelim |
| 45 |
{ |
| 46 |
public: |
| 47 |
static BufmgrPrelim *CreatePrelim(int fd); |
| 48 |
static void DestroyPrelim(BufmgrPrelim *prelim); |
| 49 |
static bool IsPrelimSupported(); |
| 50 |
static int QueryDeviceBlob(int fd, MEDIA_SYSTEM_INFO* gfxInfo); |
| 51 |
static int SetContextParamParallel(struct mos_linux_context *ctx, |
| 52 |
struct i915_engine_class_instance *ci, |
| 53 |
uint32_t count); |
| 54 |
|
| 55 |
int Init(struct mos_bufmgr &bufmgr, bool hasLmem); |
| 56 |
uint8_t GetLmemRegionCount(); |
| 57 |
|
| 58 |
void InitVmaHeap(mos_vma_heap *heap); |
| 59 |
void UninitVmaHeap(mos_vma_heap *heap); |
| 60 |
|
| 61 |
int QueryEngines(bool hasLmem, |
| 62 |
uint16_t engine_class, |
| 63 |
uint64_t caps, |
| 64 |
uint32_t *nengine, |
| 65 |
struct i915_engine_class_instance *ci); |
| 66 |
|
| 67 |
int CheckMemRegion(int memRegion, int mem_type); |
| 68 |
|
| 69 |
void SetMmapOffset(int memRegion, struct drm_i915_gem_mmap_offset &mmap_arg); |
| 70 |
|
| 71 |
int CreateGem(uint64_t inSize, |
| 72 |
uint32_t &outHandle, |
| 73 |
uint64_t &outSize, |
| 74 |
uint32_t &outRegion); |
| 75 |
|
| 76 |
int QueryEnginesCount(uint32_t *nengine); |
| 77 |
|
| 78 |
mos_memory_zone GetMemzoneForAddress(uint64_t address); |
| 79 |
|
| 80 |
int GetSystemMemRegionId() const { return PRELIM_I915_MEMORY_CLASS_SYSTEM; } |
| 81 |
|
| 82 |
void WaDisableSingleTimeline(bool hasLmem, uint32_t &flags); |
| 83 |
|
| 84 |
int GetMemoryInfo(bool hasLmem, char *info, uint32_t length); |
| 85 |
|
| 86 |
private: |
| 87 |
BufmgrPrelim(int fd); |
| 88 |
virtual ~BufmgrPrelim(); |
| 89 |
|
| 90 |
struct prelim_drm_i915_query_memory_regions *QueryMemRegions(); |
| 91 |
uint32_t GetTileId(); |
| 92 |
bool IsEngineSatisfyCaps(struct prelim_drm_i915_engine_info *engine, uint64_t caps); |
| 93 |
int QueryEnginesInternal(uint16_t engine_class, |
| 94 |
uint64_t caps, |
| 95 |
uint32_t *nengine, |
| 96 |
struct i915_engine_class_instance *ci, |
| 97 |
std::map<uint16_t, uint16_t> &logical_map); |
| 98 |
int QueryEnginesDistance(uint32_t nengine, |
| 99 |
struct prelim_drm_i915_query_distance_info *distances); |
| 100 |
bool IsQueryEnginesDistanceSupported(struct prelim_drm_i915_query_distance_info *distances); |
| 101 |
|
| 102 |
static int QueryItems(int fd, struct drm_i915_query_item *items, uint32_t n_items); |
| 103 |
|
| 104 |
private: |
| 105 |
uint32_t m_tileId = 0; |
| 106 |
int m_fd = -1; |
| 107 |
static bool m_prelimEnabled; |
| 108 |
|
| 109 |
static constexpr uint32_t TYPE_DECIMAL = 10; |
| 110 |
|
| 111 |
MEDIA_CLASS_DEFINE_END(BufmgrPrelim) |
| 112 |
}; |
| 113 |
|
| 114 |
#endif //! MOS_BUFMGR_PRELIM_H |