xref: /aosp_15_r20/external/intel-media-driver/media_driver/linux/common/cm/hal/cm_queue_rt_os.cpp (revision ba62d9d3abf0e404f2022b4cd7a85e107f48596f)
1 /*
2 * Copyright (c) 2007-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_queue_rt_os.cpp
24 //! \brief     This file contains CmQueueRT implementations specific to Linux system.
25 //!
26 
27 #include "cm_queue_rt.h"
28 
29 #include "cm_mem.h"
30 
31 namespace CMRT_UMD
32 {
CreateSyncBuffer(CM_HAL_STATE * halState)33 MOS_STATUS CmQueueRT::CreateSyncBuffer(CM_HAL_STATE *halState)
34 {
35     if (INVALID_SYNC_BUFFER_HANDLE != m_syncBufferHandle)
36     {
37         return MOS_STATUS_SUCCESS;  // Buffer has been created.
38     }
39     CM_HAL_BUFFER_PARAM buffer_param;
40     CmSafeMemSet(&buffer_param, 0, sizeof(buffer_param));
41     buffer_param.size = halState->cmHalInterface->GetTimeStampResourceSize();
42     buffer_param.type = CM_BUFFER_N;
43     buffer_param.isAllocatedbyCmrtUmd = true;
44     MOS_STATUS result = halState->pfnAllocateBuffer(halState, &buffer_param);
45     if (MOS_STATUS_SUCCESS == result)
46     {
47         m_syncBufferHandle = buffer_param.handle;
48     }
49     return result;
50 }
51 
SelectSyncBuffer(CM_HAL_STATE * halState)52 MOS_STATUS CmQueueRT::SelectSyncBuffer(CM_HAL_STATE *halState)
53 {
54     return halState->pfnSelectSyncBuffer(halState, m_syncBufferHandle);
55 }
56 
ReleaseSyncBuffer(CM_HAL_STATE * halState)57 MOS_STATUS CmQueueRT::ReleaseSyncBuffer(CM_HAL_STATE *halState)
58 {
59     if (INVALID_SYNC_BUFFER_HANDLE == m_syncBufferHandle)
60     {
61         return MOS_STATUS_SUCCESS;
62     }
63     CM_CHK_MOSSTATUS_RETURN(halState->pfnFreeBuffer(halState, m_syncBufferHandle));
64     m_syncBufferHandle = INVALID_SYNC_BUFFER_HANDLE;
65     return halState->pfnSelectSyncBuffer(halState, INVALID_SYNC_BUFFER_HANDLE);
66 }
67 }// namespace
68