1 // Copyright (c) 2018-2019 Intel Corporation 2 // 3 // Permission is hereby granted, free of charge, to any person obtaining a copy 4 // of this software and associated documentation files (the "Software"), to deal 5 // in the Software without restriction, including without limitation the rights 6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 // copies of the Software, and to permit persons to whom the Software is 8 // furnished to do so, subject to the following conditions: 9 // 10 // The above copyright notice and this permission notice shall be included in all 11 // copies or substantial portions of the Software. 12 // 13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 // SOFTWARE. 20 21 #ifndef __MFX_INTERFACE_SCHEDULER_H 22 #define __MFX_INTERFACE_SCHEDULER_H 23 24 #include <mfxvideo.h> 25 #include <mfx_interface.h> 26 #include <mfxvideo++int.h> 27 28 #include <memory.h> 29 30 // {BE080281-4C93-4D26-B763-ED2AAB5D4BA1} 31 static const 32 MFX_GUID MFXIScheduler_GUID = 33 { 0xbe080281, 0x4c93, 0x4d26, { 0xb7, 0x63, 0xed, 0x2a, 0xab, 0x5d, 0x4b, 0xa1 } }; 34 35 // {DC775B1C-951D-421F-BFD8-CA562D95A418} 36 static const 37 MFX_GUID MFXIScheduler2_GUID = 38 { 0xdc775b1c, 0x951d, 0x421f, { 0xbf, 0xd8, 0xca, 0x56, 0x2d, 0x95, 0xa4, 0x18 } }; 39 40 enum mfxSchedulerFlags 41 { 42 // default behaviour policy 43 MFX_SCHEDULER_DEFAULT = 0, 44 MFX_SINGLE_THREAD = 1 45 }; 46 47 enum mfxSchedulerMessage 48 { 49 // Drop any performance adjustments 50 MFX_SCHEDULER_RESET_TO_DEFAULTS = 0, 51 // Start listening to the HW event from the driver 52 MFX_SCHEDULER_START_HW_LISTENING = 1, 53 // Stop listening to the HW event from the driver 54 MFX_SCHEDULER_STOP_HW_LISTENING = 2 55 }; 56 57 #pragma pack(1) 58 59 struct MFX_SCHEDULER_PARAM 60 { 61 // Working flags for the scheduler being initialized 62 mfxSchedulerFlags flags; 63 // Number of working threads 64 mfxU32 numberOfThreads; 65 // core interface to get access to event handle in case of Metro mode 66 VideoCORE *pCore; 67 }; 68 69 #pragma pack() 70 71 // Forward declaration of used classes 72 struct MFX_TASK; 73 //class VideoCORE; 74 75 // MFXIScheduler interface. 76 // The interface provides task management and execution functionality. 77 78 class MFXIScheduler : public MFXIUnknown 79 { 80 public: 81 ~MFXIScheduler(void)82 virtual ~MFXIScheduler(void){} 83 // Initialize the scheduler. Initialize the dependency tables and run threads. 84 virtual 85 mfxStatus Initialize(const MFX_SCHEDULER_PARAM *pParam = 0) = 0; 86 87 // Add a new task to the scheduler. Threads start processing task immediately. 88 virtual 89 mfxStatus AddTask(const MFX_TASK &task, mfxSyncPoint *pSyncPoint) = 0; 90 91 // Make synchronization, wait until task is done. 92 virtual 93 mfxStatus Synchronize(mfxSyncPoint syncPoint, mfxU32 timeToWait) = 0; 94 95 // Wait until specified dependency become resolved 96 virtual 97 mfxStatus WaitForDependencyResolved(const void *pDependency) = 0; 98 99 // Wait until all tasks of specified owner become complete or unattended 100 virtual 101 mfxStatus WaitForAllTasksCompletion(const void *pOwner) = 0; 102 103 // Reset 'waiting' status for tasks of specified owner 104 virtual 105 mfxStatus ResetWaitingStatus(const void *pOwner) = 0; 106 107 // Check the current status of the scheduler. 108 virtual 109 mfxStatus GetState(void) = 0; 110 111 // Get the initialization parameters of the scheduler 112 virtual 113 mfxStatus GetParam(MFX_SCHEDULER_PARAM *pParam) = 0; 114 115 // Recover from the failure. 116 virtual 117 mfxStatus Reset(void) = 0; 118 119 // Send a performance message to the scheduler 120 virtual 121 mfxStatus AdjustPerformance(const mfxSchedulerMessage message) = 0; 122 123 124 }; 125 126 struct MFX_SCHEDULER_PARAM2: public MFX_SCHEDULER_PARAM 127 { 128 // user-adjustable extended parameters 129 mfxExtThreadsParam params; 130 }; 131 132 class MFXIScheduler2 : public MFXIScheduler 133 { 134 public: 135 virtual 136 mfxStatus Initialize2(const MFX_SCHEDULER_PARAM2 *pParam = 0) = 0; 137 138 virtual 139 mfxStatus DoWork() = 0; 140 141 virtual 142 mfxStatus GetTimeout(mfxU32 & maxTimeToRun) = 0; 143 }; 144 145 #endif // __MFX_INTERFACE_SCHEDULER_H 146