Debian Codegraph @

media_driver/agnostic/common/cm/cm_tracker.h

raw
1 /*
2 * Copyright (c) 2018-2019, 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 shall be included
12 * in all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 */
22 //!
23 //! \file cm_tracker.h
24 //! \brief Contains Class CmTracker definitions
25 //!
26 #pragma once
27
28 #include "cm_hal.h"
29 #include "cm_csync.h"
30 #include "frame_tracker.h"
31
32 class CmEventEx;
33
34 class CmTracker
35 {
36 public:
37 CmTracker(MOS_INTERFACE *osInterface);
38 ~CmTracker();
39 MOS_STATUS Initialize(uint32_t taskNum = 64);
40
41 MOS_STATUS AssignFrameTracker(uint32_t trackerIndex, uint32_t *taskId, uint32_t *tracker, bool hasEvent = true);
42
43 void InvalidFrameTracker(uint32_t taskId);
44
45 CM_HAL_TASK_STATUS Query(uint32_t taskId);
46
47 MOS_STATUS Refresh();
48
49 CM_RETURN_CODE WaitForAllTasksFinished();
50
51 inline void AssociateEvent(CmEventEx *event) { CMRT_UMD::CLock Locker(m_eventListSection); m_associatedEvents.push_back(event); }
52 inline void DeAssociateEvent(CmEventEx *event) { CMRT_UMD::CLock Locker(m_eventListSection); m_associatedEvents.remove(event); }
53
54 inline volatile uint32_t* GetLatestTrackerAddr(uint32_t trackerIndex) {return m_trackerProducer.GetLatestTrackerAddress(trackerIndex); }
55 inline void GetLatestTrackerResource(uint32_t trackerIndex, MOS_RESOURCE **resource, uint32_t *offset)
56 {
57 m_trackerProducer.GetLatestTrackerResource(trackerIndex, resource, offset);
58 }
59 inline FrameTrackerProducer *GetTrackerProducer() {return &m_trackerProducer;}
60
61 inline MOS_RESOURCE* GetResource() {return &m_resource; }
62 inline uint32_t GetFrameTrackerOffset(uint32_t taskId) {return taskId * sizeof(_CmFrameTracker); }
63 inline uint32_t GetStartOffset(uint32_t taskId) {return GetFrameTrackerOffset(taskId) + offsetof(_CmFrameTracker, start); }
64 inline uint32_t GetEndOffset(uint32_t taskId) {return GetFrameTrackerOffset(taskId) + offsetof(_CmFrameTracker, end); }
65 inline uint64_t GetStart(uint32_t taskId) {return *((uint64_t *)(m_data + GetStartOffset(taskId))); }
66 inline uint64_t GetEnd(uint32_t taskId) {return *((uint64_t *)(m_data + GetEndOffset(taskId))); }
67
68 protected:
69 struct _CmFrameTracker
70 {
71 uint32_t valid;
72 uint32_t tracker;
73 uint64_t start;
74 uint64_t end;
75 uint32_t trackerIndex;
76 };
77 MOS_INTERFACE *m_osInterface;
78
79 MOS_RESOURCE m_resource;
80 uint8_t *m_data;
81 uint32_t m_maxTaskNum;
82
83 uint32_t m_nextTaskID;
84
85 FrameTrackerProducer m_trackerProducer;
86
87 std::list<CmEventEx *> m_associatedEvents;
88 CMRT_UMD::CSync m_eventListSection;
89
90 };