| 1 |
/* |
| 2 |
* Copyright (c) 2018-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 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 |
//! |
| 24 |
//! \file media_packet.cpp |
| 25 |
//! \brief Defines the common interface for media media_packet |
| 26 |
//! \details The media media_packet interface is further sub-divided by component, |
| 27 |
//! this file is for the base interface which is shared by all components. |
| 28 |
//! |
| 29 |
|
| 30 |
#include "media_packet.h" |
| 31 |
#include "media_utils.h" |
| 32 |
#include "codec_def_common.h" |
| 33 |
#include "media_status_report.h" |
| 34 |
#include "mhw_mi.h" |
| 35 |
#include "null_hardware.h" |
| 36 |
|
| 37 |
MOS_STATUS MediaPacket::StartStatusReport( |
| 38 |
uint32_t srType, |
| 39 |
MOS_COMMAND_BUFFER *cmdBuffer) |
| 40 |
{ |
| 41 |
MOS_STATUS result = MOS_STATUS_SUCCESS; |
| 42 |
|
| 43 |
if (m_statusReport == nullptr) |
| 44 |
{ |
| 45 |
return MOS_STATUS_NULL_POINTER; |
| 46 |
} |
| 47 |
|
| 48 |
PMOS_RESOURCE osResource = nullptr; |
| 49 |
uint32_t offset = 0; |
| 50 |
|
| 51 |
result = m_statusReport->GetAddress(srType, osResource, offset); |
| 52 |
|
| 53 |
result = SetStartTag(osResource, offset, srType, cmdBuffer); |
| 54 |
|
| 55 |
MEDIA_CHK_STATUS_RETURN(NullHW::StartPredicate(m_osInterface, m_miInterface, cmdBuffer)); |
| 56 |
|
| 57 |
return result; |
| 58 |
} |
| 59 |
|
| 60 |
MOS_STATUS MediaPacket::UpdateStatusReport( |
| 61 |
uint32_t srType, |
| 62 |
MOS_COMMAND_BUFFER *cmdBuffer) |
| 63 |
{ |
| 64 |
MOS_STATUS result = MOS_STATUS_SUCCESS; |
| 65 |
|
| 66 |
if (m_statusReport == nullptr) |
| 67 |
{ |
| 68 |
return MOS_STATUS_NULL_POINTER; |
| 69 |
} |
| 70 |
|
| 71 |
PMOS_RESOURCE osResource = nullptr; |
| 72 |
uint32_t offset = 0; |
| 73 |
|
| 74 |
result = m_statusReport->GetAddress(srType, osResource, offset); |
| 75 |
|
| 76 |
auto count = m_statusReport->GetSubmittedCount(); |
| 77 |
|
| 78 |
MHW_MI_STORE_DATA_PARAMS storeDataParams; |
| 79 |
storeDataParams.pOsResource = osResource; |
| 80 |
storeDataParams.dwResourceOffset = offset; |
| 81 |
storeDataParams.dwValue = count + 1; |
| 82 |
|
| 83 |
MEDIA_CHK_STATUS_RETURN(m_miInterface->AddMiStoreDataImmCmd( |
| 84 |
cmdBuffer, |
| 85 |
&storeDataParams)); |
| 86 |
|
| 87 |
return result; |
| 88 |
} |
| 89 |
|
| 90 |
MOS_STATUS MediaPacket::EndStatusReport( |
| 91 |
uint32_t srType, |
| 92 |
MOS_COMMAND_BUFFER *cmdBuffer) |
| 93 |
{ |
| 94 |
MOS_STATUS result = MOS_STATUS_SUCCESS; |
| 95 |
|
| 96 |
if (m_statusReport == nullptr) |
| 97 |
{ |
| 98 |
return MOS_STATUS_NULL_POINTER; |
| 99 |
} |
| 100 |
|
| 101 |
PMOS_RESOURCE osResource = nullptr; |
| 102 |
uint32_t offset = 0; |
| 103 |
|
| 104 |
MEDIA_CHK_STATUS_RETURN(NullHW::StopPredicate(m_osInterface, m_miInterface, cmdBuffer)); |
| 105 |
|
| 106 |
result = m_statusReport->GetAddress(srType, osResource, offset); |
| 107 |
|
| 108 |
result = SetEndTag(osResource, offset, srType, cmdBuffer); |
| 109 |
|
| 110 |
return result; |
| 111 |
} |
| 112 |
|
| 113 |
MOS_STATUS MediaPacket::SetStartTag( |
| 114 |
MOS_RESOURCE *osResource, |
| 115 |
uint32_t offset, |
| 116 |
uint32_t srType, |
| 117 |
MOS_COMMAND_BUFFER *cmdBuffer) |
| 118 |
{ |
| 119 |
MHW_MI_STORE_DATA_PARAMS storeDataParams; |
| 120 |
storeDataParams.pOsResource = osResource; |
| 121 |
storeDataParams.dwResourceOffset = offset; |
| 122 |
storeDataParams.dwValue = CODECHAL_STATUS_QUERY_START_FLAG; |
| 123 |
|
| 124 |
MEDIA_CHK_STATUS_RETURN(m_miInterface->AddMiStoreDataImmCmd( |
| 125 |
cmdBuffer, |
| 126 |
&storeDataParams)); |
| 127 |
|
| 128 |
return MOS_STATUS_SUCCESS; |
| 129 |
} |
| 130 |
|
| 131 |
MOS_STATUS MediaPacket::SetEndTag( |
| 132 |
MOS_RESOURCE *osResource, |
| 133 |
uint32_t offset, |
| 134 |
uint32_t srType, |
| 135 |
MOS_COMMAND_BUFFER *cmdBuffer) |
| 136 |
{ |
| 137 |
MHW_MI_STORE_DATA_PARAMS storeDataParams; |
| 138 |
storeDataParams.pOsResource = osResource; |
| 139 |
storeDataParams.dwResourceOffset = offset; |
| 140 |
storeDataParams.dwValue = CODECHAL_STATUS_QUERY_END_FLAG; |
| 141 |
|
| 142 |
MEDIA_CHK_STATUS_RETURN(m_miInterface->AddMiStoreDataImmCmd( |
| 143 |
cmdBuffer, |
| 144 |
&storeDataParams)); |
| 145 |
|
| 146 |
return MOS_STATUS_SUCCESS; |
| 147 |
} |