• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "codec_stub.h"
17 #include <hdf_device_object.h>
18 #include <hdf_log.h>
19 #include <osal_mem.h>
20 
CodecServiceDispatch(struct HdfDeviceIoClient * client,int cmdId,struct HdfSBuf * data,struct HdfSBuf * reply)21 static int32_t CodecServiceDispatch(struct HdfDeviceIoClient *client, int cmdId,
22     struct HdfSBuf *data, struct HdfSBuf *reply)
23 {
24     return CodecServiceOnRemoteRequest(client, cmdId, data, reply);
25 }
26 
HdfCodecDriverRelease(struct HdfDeviceObject * deviceObject)27 void HdfCodecDriverRelease(struct HdfDeviceObject *deviceObject)
28 {
29     struct IDeviceIoService *testService = deviceObject->service;
30     OsalMemFree(testService);
31 }
32 
HdfCodecDriverBind(struct HdfDeviceObject * deviceObject)33 int HdfCodecDriverBind(struct HdfDeviceObject *deviceObject)
34 {
35     HDF_LOGE("HdfCodecDriverBind enter!");
36 
37     struct IDeviceIoService *ioService = (struct IDeviceIoService *)OsalMemAlloc(sizeof(struct IDeviceIoService));
38     if (ioService == NULL) {
39         HDF_LOGE("HdfCodecDriverBind OsalMemAlloc IDeviceIoService failed!");
40         return HDF_FAILURE;
41     }
42 
43     ioService->Dispatch = CodecServiceDispatch;
44     ioService->Open = NULL;
45     ioService->Release = NULL;
46     int ret = HdfDeviceObjectSetInterfaceDesc(deviceObject, "ohos.hdi.codec_service");
47     if (ret != HDF_SUCCESS) {
48         HDF_LOGE("failed to set interface desc");
49         return ret;
50     }
51     deviceObject->service = ioService;
52     return HDF_SUCCESS;
53 }
54 
HdfCodecDriverInit(struct HdfDeviceObject * deviceObject)55 int HdfCodecDriverInit(struct HdfDeviceObject *deviceObject)
56 {
57     HDF_LOGE("HdfSampleDriverCInit enter, new hdi impl");
58     return HDF_SUCCESS;
59 }
60 
61 struct HdfDriverEntry g_codecHostDriverEntry = {
62     .moduleVersion = 1,
63     .moduleName = "libcodec_server.z.so",
64     .Bind = HdfCodecDriverBind,
65     .Init = HdfCodecDriverInit,
66     .Release = HdfCodecDriverRelease,
67 };
68 
69 HDF_INIT(g_codecHostDriverEntry);