/* * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include #include #include #include "codec_config_parser.h" #include "codec_stub.h" static int32_t CodecServiceDispatch(struct HdfDeviceIoClient *client, int cmdId, struct HdfSBuf *data, struct HdfSBuf *reply) { return CodecServiceOnRemoteRequest(client, cmdId, data, reply); } static void HdfCodecDriverRelease(struct HdfDeviceObject *deviceObject) { struct IDeviceIoService *testService = deviceObject->service; OsalMemFree(testService); ClearCapabilityGroup(); } static int HdfCodecDriverBind(struct HdfDeviceObject *deviceObject) { HDF_LOGI("HdfCodecDriverBind enter!"); struct IDeviceIoService *ioService = (struct IDeviceIoService *)OsalMemAlloc(sizeof(struct IDeviceIoService)); if (ioService == NULL) { HDF_LOGE("HdfCodecDriverBind OsalMemAlloc IDeviceIoService failed!"); return HDF_FAILURE; } ioService->Dispatch = CodecServiceDispatch; ioService->Open = NULL; ioService->Release = NULL; int ret = HdfDeviceObjectSetInterfaceDesc(deviceObject, "ohos.hdi.codec_service"); if (ret != HDF_SUCCESS) { HDF_LOGE("failed to set interface desc"); return ret; } deviceObject->service = ioService; return HDF_SUCCESS; } static int HdfCodecDriverInit(struct HdfDeviceObject *deviceObject) { HDF_LOGI("HdfSampleDriverCInit enter, new hdi impl"); if (LoadCodecCapabilityFromHcs(deviceObject->property) != HDF_SUCCESS) { HDF_LOGE("LoadCodecCapabilityFromHcs failed"); ClearCapabilityGroup(); } return HDF_SUCCESS; } struct HdfDriverEntry g_codecHostDriverEntry = { .moduleVersion = 1, .moduleName = "libcodec_server.z.so", .Bind = HdfCodecDriverBind, .Init = HdfCodecDriverInit, .Release = HdfCodecDriverRelease, }; HDF_INIT(g_codecHostDriverEntry);