• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  *
4  * HDF is dual licensed: you can use it either under the terms of
5  * the GPL, or the BSD license, at your option.
6  * See the LICENSE file in the root of this repository for complete details.
7  */
8 
9 #include "hdf_base.h"
10 #include "hdf_load_vdi.h"
11 #include "hdf_log.h"
12 #include "vdi_sample2_driver.h"
13 
14 #define HDF_LOG_TAG vdi_sample2
15 
16 namespace OHOS {
17 namespace VDI {
18 namespace Sample {
19 namespace V1_0 {
VdiSample(int para)20 VdiSample::VdiSample(int para)
21 {
22     priData = para;
23 }
24 
ServiceA(void)25 int VdiSample::ServiceA(void)
26 {
27     HDF_LOGI("%{public}s", __func__);
28     return HDF_SUCCESS;
29 }
30 
ServiceB(IVdiSample * vdi)31 int VdiSample::ServiceB(IVdiSample *vdi)
32 {
33     VdiSample *sample = reinterpret_cast<VdiSample *>(vdi);
34     HDF_LOGI("%{public}s %{public}d", __func__, sample->priData);
35     return HDF_SUCCESS;
36 }
37 
SampleAOpen(struct HdfVdiBase * vdiBase)38 static int SampleAOpen(struct HdfVdiBase *vdiBase)
39 {
40     HDF_LOGI("%{public}s", __func__);
41     struct VdiWrapperB *sampleB = reinterpret_cast<struct VdiWrapperB *>(vdiBase);
42     sampleB->module = new VdiSample(1);
43     return HDF_SUCCESS;
44 }
45 
SampleAClose(struct HdfVdiBase * vdiBase)46 static int SampleAClose(struct HdfVdiBase *vdiBase)
47 {
48     HDF_LOGI("%{public}s", __func__);
49     struct VdiWrapperB *sampleB = reinterpret_cast<struct VdiWrapperB *>(vdiBase);
50     VdiSample *sample = reinterpret_cast<VdiSample *>(sampleB->module);
51     delete sample;
52     sampleB->module = nullptr;
53     return HDF_SUCCESS;
54 }
55 
56 static struct VdiWrapperB g_vdiB = {
57     .base = {
58         .moduleVersion = 1,
59         .moduleName = "SampleServiceB",
60         .CreateVdiInstance = SampleAOpen,
61         .DestoryVdiInstance = SampleAClose,
62     },
63     .module = nullptr,
64 };
65 } // namespace V1_0
66 } // namespace Sample
67 } // namespace VDI
68 } // namespace OHOS
69 
70 HDF_VDI_INIT(OHOS::VDI::Sample::V1_0::g_vdiB);
71