File: cm_global_api_os.cpp

package info (click to toggle)
intel-media-driver 25.4.2%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 152,228 kB
  • sloc: cpp: 1,615,750; ansic: 216,716; asm: 39,161; python: 555; sh: 177; makefile: 16
file content (109 lines) | stat: -rw-r--r-- 3,746 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*
* Copyright (c) 2017, Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
//!
//! \file  cm_global_api_os.cpp
//! \brief Contains implementations of gloabl CM APIs which are Linux-dependent.
//!

#include "cm_device_rt.h"

using CMRT_UMD::CmDevice;
using CMRT_UMD::CmDeviceRT;
//!
//! \brief    Creates a CmDevice from a MOS context.
//! \details  If an existing CmDevice has already associated to the MOS context,
//!           the existing CmDevice will be returned. Otherwise, a new CmDevice
//!           instance will be created and associatied with that MOS context.
//! \param    mosContext
//!           [in] pointer to MOS conetext.
//! \param    device
//!           [in,out] reference to the pointer to the CmDevice.
//! \param    devCreateOption
//!           [in] option to customize CmDevice.
//! \retval   CM_SUCCESS if the CmDevice is successfully created.
//! \retval   CM_NULL_POINTER if mosContext is null.
//! \retval   CM_FAILURE otherwise.
//!
CM_RT_API int32_t CreateCmDevice(MOS_CONTEXT *mosContext,
                                 CmDevice* &device,
                                 uint32_t devCreateOption,
                                 uint8_t  priority)
{
    UNUSED(priority);
    if (mosContext == nullptr)
    {
        return CM_NULL_POINTER;
    }
    CmDeviceRT* deviceRT = nullptr;

    int32_t ret = CmDeviceRT::Create(mosContext, deviceRT, devCreateOption);
    if(ret == CM_SUCCESS)
    {
        device = deviceRT;
    }

    return ret;
}

//!
//! \brief    Destroys the CmDevice.
//! \details  This function also destroys surfaces, kernels, programs, samplers,
//!           threadspaces, tasks and the queues that were created using this
//!           device instance but haven't explicitly been destroyed by calling
//!           respective destroy functions. 
//! \param    device
//!           [in] reference to the pointer to the CmDevice.
//! \retval   CM_SUCCESS if CmDevice is successfully destroyed.
//! \retval   CM_FAILURE otherwise.
//!
CM_RT_API int32_t DestroyCmDevice(CmDevice* & device)
{
    if (device == nullptr)
    {
        return CM_SUCCESS;
    }

    CmDeviceRT* deviceRT = static_cast<CmDeviceRT*>(device);
    int32_t ret = CmDeviceRT::Destroy(deviceRT);
    if (ret != CM_SUCCESS)
    {
        return ret;
    }

    device = nullptr;

    return CM_SUCCESS;
}

//!
//! \brief    Initialize cm hal ddi interfaces
//! \details  Initialize cm hal ddi interfaces
//! \param    cmState
//!           [in,out] the pointer to the cm state.
//! \return   MOS_STATUS
//!           MOS_STATUS_SUCCESS if succeeded, otherwise error code
//!
MOS_STATUS InitCmOsDDIInterface(PCM_HAL_STATE cmState)
{
    UNUSED(cmState);
    return MOS_STATUS_SUCCESS;
}