diff --git a/bluetooth/bluetooth.gni b/bluetooth/bluetooth.gni new file mode 100755 index 0000000000000000000000000000000000000000..29b3358b984b6a28a90a08ad633a1a216d4ae87e --- /dev/null +++ b/bluetooth/bluetooth.gni @@ -0,0 +1,4 @@ +declare_args() { + drivers_peripheral_bluetooth_bt_device_is_zt9612 = false +} + diff --git a/bluetooth/bundle.json b/bluetooth/bundle.json index 9773bc06e81bfc98ae6634024b02a5c8554d9025..4e277f2fe2e1de6c4e12c08ddfc1c0c1edab0df4 100644 --- a/bluetooth/bundle.json +++ b/bluetooth/bundle.json @@ -14,6 +14,7 @@ "subsystem": "hdf", "features": [ "drivers_peripheral_bluetooth_a2dp_hdi", + "drivers_peripheral_bluetooth_bt_device_is_zt9612", "drivers_peripheral_bluetooth_mac_update" ], "adapted_system_type": ["standard"], diff --git a/bluetooth/hci/hdi_service/BUILD.gn b/bluetooth/hci/hdi_service/BUILD.gn index fc58a610853690a45f2948807fe7ab12547c8ad4..baa72c298261b2992e7a5117f25c6ece86193493 100644 --- a/bluetooth/hci/hdi_service/BUILD.gn +++ b/bluetooth/hci/hdi_service/BUILD.gn @@ -12,7 +12,7 @@ # limitations under the License. import("//build/ohos.gni") import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni") - +import("//drivers/peripheral/bluetooth/bluetooth.gni") declare_args() { drivers_peripheral_bluetooth_mac_update = false } @@ -26,10 +26,15 @@ ohos_shared_library("libhci_interface_service_1.0") { "$root_path/implement", ] + defines = [] if (drivers_peripheral_bluetooth_mac_update) { - defines = [ "BT_MAC_UPDATE" ] + defines += [ "BT_MAC_UPDATE" ] } + + if (drivers_peripheral_bluetooth_bt_device_is_zt9612) { + defines += [ "SUPPORT_ZT9612_BT_VENDOR" ] + } sources = [ "$root_path/hci_interface_impl.cpp", "$root_path/implement/bluetooth_address.cpp", diff --git a/bluetooth/hci/hdi_service/implement/bt_hal_constant.h b/bluetooth/hci/hdi_service/implement/bt_hal_constant.h index d0e29b4ef3a7641c070b140aea8772298c9c3afe..38d4acc4354c951ab3105b4196aae100bf5a6dbf 100644 --- a/bluetooth/hci/hdi_service/implement/bt_hal_constant.h +++ b/bluetooth/hci/hdi_service/implement/bt_hal_constant.h @@ -25,6 +25,7 @@ namespace HDI { namespace Bluetooth { namespace Hci { constexpr const char *BT_VENDOR_NAME = "libbt_vendor.z.so"; +constexpr const char *BT_FIRMWARE_NAME = "/vendor/lib/libbt_vendor.z.so"; constexpr const char *BT_VENDOR_INTERFACE_SYMBOL_NAME = "BLUETOOTH_VENDOR_LIB_INTERFACE"; constexpr const char *BT_DEVICE_ADDRESS_PATH = "/data/vendor/bluetooth/btmac.txt"; constexpr int BT_THREAD_POLICY = SCHED_RR; diff --git a/bluetooth/hci/hdi_service/implement/mct_protocol.cpp b/bluetooth/hci/hdi_service/implement/mct_protocol.cpp index 908ffe253772e60cd97591cc4df1f2cfffdc1708..9194ccbf5e95898365381ce541db6e3277e23d89 100644 --- a/bluetooth/hci/hdi_service/implement/mct_protocol.cpp +++ b/bluetooth/hci/hdi_service/implement/mct_protocol.cpp @@ -29,10 +29,19 @@ namespace OHOS { namespace HDI { namespace Bluetooth { namespace Hci { +#ifdef SUPPORT_ZT9612_BT_VENDOR +MctProtocol::MctProtocol(const int fds[CH_MAX], HciDataCallback onAclReceive, HciDataCallback onScoReceive, + HciDataCallback onEventReceive) +#else MctProtocol::MctProtocol(const int fds[HCI_MAX_CHANNEL], HciDataCallback onAclReceive, HciDataCallback onScoReceive, HciDataCallback onEventReceive) +#endif { +#ifdef SUPPORT_ZT9612_BT_VENDOR + for (int ii = 0; ii < CH_MAX; ii++) { +#else for (int ii = 0; ii < HCI_MAX_CHANNEL; ii++) { +#endif hciFds_[ii] = fds[ii]; } onAclReceive_ = onAclReceive; @@ -43,13 +52,19 @@ MctProtocol::MctProtocol(const int fds[HCI_MAX_CHANNEL], HciDataCallback onAclRe ssize_t MctProtocol::SendPacket(HciPacketType packetType, const std::vector &packetData) { uint8_t type = packetType; - +#ifdef SUPPORT_ZT9612_BT_VENDOR + if (packetType == HciPacketType::HCI_PACKET_TYPE_COMMAND) { + return Write(hciFds_[bt_vendor_hci_channels_t::CH_CMD], &type, sizeof(type)); + } else if (packetType == HciPacketType::HCI_PACKET_TYPE_ACL_DATA) { + return Write(hciFds_[bt_vendor_hci_channels_t::CH_ACL_OUT], &type, sizeof(type)); + } +#else if (packetType == HciPacketType::HCI_PACKET_TYPE_COMMAND) { return Write(hciFds_[hci_channels_t::HCI_CMD], &type, sizeof(type)); } else if (packetType == HciPacketType::HCI_PACKET_TYPE_ACL_DATA) { return Write(hciFds_[hci_channels_t::HCI_ACL_OUT], &type, sizeof(type)); } - +#endif return 0; } diff --git a/bluetooth/hci/hdi_service/implement/mct_protocol.h b/bluetooth/hci/hdi_service/implement/mct_protocol.h index 0632c73e46142c54687d8a5dcfc1d63ef7ae6f86..8af0cdb70e4c5d20d1448df77f4d965bd6f79b67 100644 --- a/bluetooth/hci/hdi_service/implement/mct_protocol.h +++ b/bluetooth/hci/hdi_service/implement/mct_protocol.h @@ -26,15 +26,24 @@ namespace Bluetooth { namespace Hci { class MctProtocol : public HciProtocol { public: +#ifdef SUPPORT_ZT9612_BT_VENDOR + MctProtocol(const int fds[CH_MAX], HciDataCallback onAclReceive, HciDataCallback onScoReceive, + HciDataCallback onEventReceive); +#else MctProtocol(const int fds[HCI_MAX_CHANNEL], HciDataCallback onAclReceive, HciDataCallback onScoReceive, HciDataCallback onEventReceive); +#endif ssize_t SendPacket(HciPacketType packetType, const std::vector &packetData) override; void ReadEventData(int fd); void ReadAclData(int fd); ~MctProtocol() override; private: +#ifdef SUPPORT_ZT9612_BT_VENDOR + int hciFds_[CH_MAX] = {0}; +#else int hciFds_[HCI_MAX_CHANNEL] = {0}; +#endif HciDataCallback onAclReceive_; HciDataCallback onScoReceive_; HciDataCallback onEventReceive_; diff --git a/bluetooth/hci/hdi_service/implement/ohos_bt_vendor_lib.h b/bluetooth/hci/hdi_service/implement/ohos_bt_vendor_lib.h index 090c01bddc0a0e905a540a257188f2b6e987fc7e..478e13fa1d54be0c73c58dfb71ec4b7e9f3f80bc 100644 --- a/bluetooth/hci/hdi_service/implement/ohos_bt_vendor_lib.h +++ b/bluetooth/hci/hdi_service/implement/ohos_bt_vendor_lib.h @@ -1,3 +1,342 @@ +/****************************************************************************** + * + * Copyright (C) 2009-2012 Shandong ZTop Microelectronics 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. + * + ******************************************************************************/ +#ifdef SUPPORT_ZT9612_BT_VENDOR +#ifndef OHOS_BT_VENDOR_LIB_H +#define OHOS_BT_VENDOR_LIB_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** Struct types */ + +/** Typedefs and defines */ + +/** Vendor specific operations OPCODE */ +typedef enum { +/* [operation] + * Power on or off the BT Controller. + * [input param] + * A pointer to int type with content of bt_vendor_power_state_t. + * Typecasting conversion: (int *) param. + * [return] + * 0 - default, don't care. + * [callback] + * None. + */ + BT_VND_OP_POWER_CTRL, + +/* [operation] + * Perform any vendor specific initialization or configuration + * on the BT Controller. This is called before stack initialization. + * [input param] + * None. + * [return] + * 0 - default, don't care. + * [callback] + * Must call fwcfg_cb to notify the stack of the completion of vendor + * specific initialization once it has been done. + */ + BT_VND_OP_FW_CFG, + +/* [operation] + * Perform any vendor specific SCO/PCM configuration on the BT Controller. + * This is called after stack initialization. + * [input param] + * None. + * [return] + * 0 - default, don't care. + * [callback] + * Must call scocfg_cb to notify the stack of the completion of vendor + * specific SCO configuration once it has been done. + */ + BT_VND_OP_SCO_CFG, + +/* [operation] + * Open UART port on where the BT Controller is attached. + * This is called before stack initialization. + * [input param] + * A pointer to int array type for open file descriptors. + * The mapping of HCI channel to fd slot in the int array is given in + * bt_vendor_hci_channels_t. + * And, it requires the vendor lib to fill up the content before returning + * the call. + * Typecasting conversion: (int (*)[]) param. + * [return] + * Numbers of opened file descriptors. + * Valid number: + * 1 - CMD/EVT/ACL-In/ACL-Out via the same fd (e.g. UART) + * 2 - CMD/EVT on one fd, and ACL-In/ACL-Out on the other fd + * 4 - CMD, EVT, ACL-In, ACL-Out are on their individual fd + * [callback] + * None. + */ + BT_VND_OP_USERIAL_OPEN, + +/* [operation] + * Close the previously opened UART port. + * [input param] + * None. + * [return] + * 0 - default, don't care. + * [callback] + * None. + */ + BT_VND_OP_USERIAL_CLOSE, + +/* [operation] + * Get the LPM idle timeout in milliseconds. + * The stack uses this information to launch a timer delay before it + * attempts to de-assert LPM WAKE signal once downstream HCI packet + * has been delivered. + * [input param] + * A pointer to uint32_t type which is passed in by the stack. And, it + * requires the vendor lib to fill up the content before returning + * the call. + * Typecasting conversion: (uint32_t *) param. + * [return] + * 0 - default, don't care. + * [callback] + * None. + */ + BT_VND_OP_GET_LPM_IDLE_TIMEOUT, + +/* [operation] + * Enable or disable LPM mode on BT Controller. + * [input param] + * A pointer to uint8_t type with content of bt_vendor_lpm_mode_t. + * Typecasting conversion: (uint8_t *) param. + * [return] + * 0 - default, don't care. + * [callback] + * Must call lpm_cb to notify the stack of the completion of LPM + * disable/enable process once it has been done. + */ + BT_VND_OP_LPM_SET_MODE, + +/* [operation] + * Assert or Deassert LPM WAKE on BT Controller. + * [input param] + * A pointer to uint8_t type with content of bt_vendor_lpm_wake_state_t. + * Typecasting conversion: (uint8_t *) param. + * [return] + * 0 - default, don't care. + * [callback] + * None. + */ + BT_VND_OP_LPM_WAKE_SET_STATE, + + BT_OP_EVENT_CALLBACK, +} bt_vendor_opcode_t; + +/** Power on/off control states */ +typedef enum { + BT_VND_PWR_OFF, + BT_VND_PWR_ON, +} bt_vendor_power_state_t; + +/** Define HCI channel identifier in the file descriptors array + used in BT_VND_OP_USERIAL_OPEN operation. + */ +typedef enum { + CH_CMD, // HCI Command channel + CH_EVT, // HCI Event channel + CH_ACL_OUT, // HCI ACL downstream channel + CH_ACL_IN, // HCI ACL upstream channel + + CH_MAX // Total channels +} bt_vendor_hci_channels_t; + +/** LPM disable/enable request */ +typedef enum { + BT_VND_LPM_DISABLE, + BT_VND_LPM_ENABLE, +} bt_vendor_lpm_mode_t; + +/** LPM WAKE set state request */ +typedef enum { + BT_VND_LPM_WAKE_ASSERT, + BT_VND_LPM_WAKE_DEASSERT, +} bt_vendor_lpm_wake_state_t; + +/** Callback result values */ +typedef enum { + BT_VND_OP_RESULT_SUCCESS, + BT_VND_OP_RESULT_FAIL, +} bt_vendor_op_result_t; + +/* + * Bluetooth Host/Controller Vendor callback structure. + */ + +/* vendor initialization/configuration callback */ +typedef void (*cfg_result_cb)(bt_vendor_op_result_t result); + +/* datapath buffer allocation callback (callout) + * + * Vendor lib needs to request a buffer through the alloc callout function + * from HCI lib if the buffer is for constructing a HCI Command packet which + * will be sent through xmit_cb to BT Controller. + * + * For each buffer allocation, the requested size needs to be big enough to + * accommodate the below header plus a complete HCI packet -- + * typedef struct + * { + * uint16_t event; + * uint16_t len; + * uint16_t offset; + * uint16_t layer_specific; + * } HC_BT_HDR; + * + * HCI lib returns a pointer to the buffer where Vendor lib should use to + * construct a HCI command packet as below format: + * + * -------------------------------------------- + * | HC_BT_HDR | HCI command | + * -------------------------------------------- + * where + * HC_BT_HDR.event = 0x2000; + * HC_BT_HDR.len = Length of HCI command; + * HC_BT_HDR.offset = 0; + * HC_BT_HDR.layer_specific = 0; + * + * For example, a HCI_RESET Command will be formed as + * ------------------------ + * | HC_BT_HDR |03|0c|00| + * ------------------------ + * with + * HC_BT_HDR.event = 0x2000; + * HC_BT_HDR.len = 3; + * HC_BT_HDR.offset = 0; + * HC_BT_HDR.layer_specific = 0; + */ +typedef void *(*malloc_cb)(int size); + +/* datapath buffer deallocation callback (callout) */ +typedef void (*mdealloc_cb)(void *p_buf); + +/* define callback of the cmd_xmit_cb + * + * The callback function which HCI lib will call with the return of command + * complete packet. Vendor lib is responsible for releasing the buffer passed + * in at the p_mem parameter by calling dealloc callout function. + */ + /* included from hci.h */ + /* typedef void (*tINT_CMD_CBACK)(void *p_mem); */ + +/* hci command packet transmit callback (callout) + * + * Vendor lib calls xmit_cb callout function in order to send a HCI Command + * packet to BT Controller. The buffer carrying HCI Command packet content + * needs to be first allocated through the alloc callout function. + * HCI lib will release the buffer for Vendor lib once it has delivered the + * packet content to BT Controller. + * + * Vendor lib needs also provide a callback function (p_cback) which HCI lib + * will call with the return of command complete packet. + * + * The opcode parameter gives the HCI OpCode (combination of OGF and OCF) of + * HCI Command packet. For example, opcode = 0x0c03 for the HCI_RESET command + * packet. + */ + +typedef uint8_t(*cmd_xmit_cb) (uint16_t opcode, void *p_buf); + +typedef struct { + /** set to sizeof(bt_vendor_callbacks_t) */ + size_t size; + + /* + * Callback and callout functions have implemented in HCI libray + * (libbt-hci.so). + */ + + /* notifies caller result of firmware configuration request */ + cfg_result_cb fwcfg_cb; + + /* notifies caller result of sco configuration request */ + cfg_result_cb scocfg_cb; + + /* notifies caller result of lpm enable/disable */ + cfg_result_cb lpm_cb; + + /* buffer allocation request */ + malloc_cb alloc; + + /* buffer deallocation request */ + mdealloc_cb dealloc; + + /* hci command packet transmit request */ + cmd_xmit_cb xmit_cb; +} bt_vendor_callbacks_t; + +/* + * Bluetooth Host/Controller VENDOR Interface + */ +typedef struct { + /** Set to sizeof(bt_vndor_interface_t) */ + size_t size; + + /* + * Functions need to be implemented in Vendor libray (libbt-vendor.so). + */ + + /** + * Caller will open the interface and pass in the callback routines + * to the implemenation of this interface. + */ + int (*init)(const bt_vendor_callbacks_t * p_cb, unsigned char *local_bdaddr); + + /** Vendor specific operations */ + int (*op)(bt_vendor_opcode_t opcode, void *param); + + /** Closes the interface */ + void (*cleanup)(void); +} bt_vendor_interface_t; + +/* + * External shared lib functions/data + */ + +/* Entry point of DLib -- + * Vendor library needs to implement the body of bt_vendor_interface_t + * structure and uses the below name as the variable name. HCI library + * will use this symbol name to get address of the object through the + * dlsym call. + */ +typedef struct { + uint16_t event; + uint16_t len; + uint16_t offset; + uint16_t layer_specific; + uint8_t data[]; +} HC_BT_HDR; + +#ifdef __cplusplus +} +#endif + +#endif /* BT_VENDOR_LIB_H */ +#else /* * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -190,3 +529,5 @@ typedef struct { #endif #endif /* BT_VENDOR_LIB_H */ + +#endif \ No newline at end of file diff --git a/bluetooth/hci/hdi_service/implement/vendor_interface.cpp b/bluetooth/hci/hdi_service/implement/vendor_interface.cpp index 14282f0b426296cd5a8f640355ebc457a4c2e2d7..44f0df8137f71fc449733922477d06d99f4935b3 100644 --- a/bluetooth/hci/hdi_service/implement/vendor_interface.cpp +++ b/bluetooth/hci/hdi_service/implement/vendor_interface.cpp @@ -42,12 +42,24 @@ namespace Hci { namespace V1_0 { constexpr size_t BT_VENDOR_INVALID_DATA_LEN = 0; constexpr int32_t RT_PRIORITY = 1; +#ifdef SUPPORT_ZT9612_BT_VENDOR +bt_vendor_callbacks_t VendorInterface::vendorCallbacks_ = { + .size = sizeof(bt_vendor_callbacks_t), + .fwcfg_cb = VendorInterface::OnInitCallback, + .scocfg_cb = nullptr, // 未使用SCO + .lpm_cb = VendorInterface::OnLpmCallback, +#else BtVendorCallbacksT VendorInterface::vendorCallbacks_ = { .size = sizeof(BtVendorCallbacksT), .initCb = VendorInterface::OnInitCallback, +#endif .alloc = VendorInterface::OnMallocCallback, .dealloc = VendorInterface::OnFreeCallback, +#ifdef SUPPORT_ZT9612_BT_VENDOR + .xmit_cb = VendorInterface::OnCmdXmitCallback, +#else .xmitCb = VendorInterface::OnCmdXmitCallback, +#endif }; VendorInterface::VendorInterface() @@ -67,9 +79,15 @@ bool VendorInterface::WatchHciChannel(const ReceiveCallback &receiveCallback) HDF_LOGI("vendorInterface setscheduler failed rc:%{public}d.", rc); } HDF_LOGI("VendorInterface BT_OP_HCI_CHANNEL_OPEN begin"); +#ifdef SUPPORT_ZT9612_BT_VENDOR + int channel[CH_MAX] = {0}; + int channelCount = vendorInterface_->op(BT_VND_OP_USERIAL_OPEN, channel); + if (channelCount < 1 || channelCount > CH_MAX) { +#else int channel[HCI_MAX_CHANNEL] = {0}; int channelCount = vendorInterface_->op(BtOpcodeT::BT_OP_HCI_CHANNEL_OPEN, channel); if (channelCount < 1 || channelCount > HCI_MAX_CHANNEL) { +#endif HDF_LOGE("vendorInterface_->op BT_OP_HCI_CHANNEL_OPEN failed ret:%{public}d.", channelCount); return false; } @@ -88,10 +106,17 @@ bool VendorInterface::WatchHciChannel(const ReceiveCallback &receiveCallback) receiveCallback.onAclReceive, receiveCallback.onScoReceive, std::bind(&VendorInterface::OnEventReceived, this, std::placeholders::_1)); +#ifdef SUPPORT_ZT9612_BT_VENDOR + watcher_->AddFdToWatcher( + channel[CH_ACL_IN], std::bind(&Hci::MctProtocol::ReadAclData, mct, std::placeholders::_1)); + watcher_->AddFdToWatcher( + channel[CH_EVT], std::bind(&Hci::MctProtocol::ReadEventData, mct, std::placeholders::_1)); +#else watcher_->AddFdToWatcher( channel[hci_channels_t::HCI_ACL_IN], std::bind(&Hci::MctProtocol::ReadAclData, mct, std::placeholders::_1)); watcher_->AddFdToWatcher( channel[hci_channels_t::HCI_EVT], std::bind(&Hci::MctProtocol::ReadEventData, mct, std::placeholders::_1)); +#endif hci_ = mct; } @@ -107,15 +132,23 @@ bool VendorInterface::Initialize( eventDataCallback_ = receiveCallback.onEventReceive; HDF_LOGI("VendorInterface dlopen"); - vendorHandle_ = dlopen(BT_VENDOR_NAME, RTLD_NOW); + vendorHandle_ = dlopen(BT_FIRMWARE_NAME, RTLD_NOW); if (vendorHandle_ == nullptr) { - HDF_LOGE("VendorInterface dlopen %{public}s failed, error code: %{public}s", BT_VENDOR_NAME, dlerror()); - return false; + HDF_LOGE("VendorInterface dlopen %{public}s failed, error code: %{public}s", BT_FIRMWARE_NAME, dlerror()); + vendorHandle_ = dlopen(BT_VENDOR_NAME, RTLD_NOW); + if (vendorHandle_ == nullptr) { + HDF_LOGE("VendorInterface dlopen %{public}s failed, error code: %{public}s", BT_VENDOR_NAME, dlerror()); + return false; + } } +#ifdef SUPPORT_ZT9612_BT_VENDOR + vendorInterface_ = + reinterpret_cast(dlsym(vendorHandle_, BT_VENDOR_INTERFACE_SYMBOL_NAME)); +#else vendorInterface_ = reinterpret_cast(dlsym(vendorHandle_, BT_VENDOR_INTERFACE_SYMBOL_NAME)); - +#endif auto bluetoothAddress = BluetoothAddress::GetDeviceAddress(); std::vector address = { 0, 0, 0, 0, 0, 0 }; if (bluetoothAddress != nullptr) { @@ -133,8 +166,12 @@ bool VendorInterface::Initialize( HDF_LOGE("vendorInterface_->init failed."); return false; } - +#ifdef SUPPORT_ZT9612_BT_VENDOR + int powerOn = BT_VND_PWR_ON; + result = vendorInterface_->op(BT_VND_OP_POWER_CTRL, &powerOn); +#else result = vendorInterface_->op(BtOpcodeT::BT_OP_POWER_ON, nullptr); +#endif if (result != 0) { HDF_LOGE("vendorInterface_->op BT_OP_POWER_ON failed."); return false; @@ -157,8 +194,12 @@ bool VendorInterface::Initialize( } HDF_LOGI("VendorInterface BT_OP_INIT"); +#ifdef SUPPORT_ZT9612_BT_VENDOR + int fwConfig = 1; // 任意非空值 + vendorInterface_->op(BT_VND_OP_FW_CFG, &fwConfig); +#else vendorInterface_->op(BtOpcodeT::BT_OP_INIT, nullptr); - +#endif HDF_LOGI("VendorInterface Initialize end"); return true; } @@ -174,11 +215,19 @@ void VendorInterface::CleanUp() if (watcher_ != nullptr) { watcher_->Stop(); } +#ifdef SUPPORT_ZT9612_BT_VENDOR + int lpmDisable = BT_VND_LPM_DISABLE; + vendorInterface_->op(BT_VND_OP_LPM_SET_MODE, &lpmDisable); + vendorInterface_->op(BT_VND_OP_USERIAL_CLOSE, nullptr); + int powerOff = BT_VND_PWR_OFF; + vendorInterface_->op(BT_VND_OP_POWER_CTRL, &powerOff); + vendorInterface_->cleanup(); +#else vendorInterface_->op(BtOpcodeT::BT_OP_LPM_DISABLE, nullptr); vendorInterface_->op(BtOpcodeT::BT_OP_HCI_CHANNEL_CLOSE, nullptr); vendorInterface_->op(BtOpcodeT::BT_OP_POWER_OFF, nullptr); vendorInterface_->close(); - +#endif hci_ = nullptr; vendorInterface_ = nullptr; initializeCompleteCallback_ = nullptr; @@ -206,8 +255,14 @@ size_t VendorInterface::SendPacket(Hci::HciPacketType type, const std::vectorSetTimeout( std::chrono::milliseconds(lpmTimer_), std::bind(&VendorInterface::WatcherTimeout, this)); } + if (!wakeupLock_) { +#ifdef SUPPORT_ZT9612_BT_VENDOR + int wakeAssert = BT_VND_LPM_WAKE_ASSERT; + vendorInterface_->op(BT_VND_OP_LPM_WAKE_SET_STATE, &wakeAssert); +#else vendorInterface_->op(BtOpcodeT::BT_OP_WAKEUP_LOCK, nullptr); +#endif wakeupLock_ = true; } } @@ -219,27 +274,48 @@ size_t VendorInterface::SendPacket(Hci::HciPacketType type, const std::vectorSendPacket(type, packet); } +#ifdef SUPPORT_ZT9612_BT_VENDOR +void VendorInterface::OnInitCallback(bt_vendor_op_result_t result) +#else void VendorInterface::OnInitCallback(BtOpResultT result) +#endif { HDF_LOGI("%{public}s, ", __func__); if (VendorInterface::GetInstance()->initializeCompleteCallback_) { +#ifdef SUPPORT_ZT9612_BT_VENDOR + VendorInterface::GetInstance()->initializeCompleteCallback_(result == BT_VND_OP_RESULT_SUCCESS); +#else VendorInterface::GetInstance()->initializeCompleteCallback_(result == BTC_OP_RESULT_SUCCESS); +#endif VendorInterface::GetInstance()->initializeCompleteCallback_ = nullptr; } uint32_t lpmTimer = 0; +#ifdef SUPPORT_ZT9612_BT_VENDOR + if (VendorInterface::GetInstance()->vendorInterface_->op(BT_VND_OP_GET_LPM_IDLE_TIMEOUT, &lpmTimer) != 0) { +#else if (VendorInterface::GetInstance()->vendorInterface_->op(BtOpcodeT::BT_OP_GET_LPM_TIMER, &lpmTimer) != 0) { +#endif HDF_LOGE("Vector interface BT_OP_GET_LPM_TIMER failed"); } VendorInterface::GetInstance()->lpmTimer_ = lpmTimer; - +#ifdef SUPPORT_ZT9612_BT_VENDOR + uint8_t lpmEnable = BT_VND_LPM_ENABLE; + VendorInterface::GetInstance()->vendorInterface_->op(BT_VND_OP_LPM_SET_MODE, &lpmEnable); +#else VendorInterface::GetInstance()->vendorInterface_->op(BtOpcodeT::BT_OP_LPM_ENABLE, nullptr); +#endif if (VendorInterface::GetInstance()->watcher_ != nullptr) { VendorInterface::GetInstance()->watcher_->SetTimeout(std::chrono::milliseconds(lpmTimer), std::bind(&VendorInterface::WatcherTimeout, VendorInterface::GetInstance())); } } +#ifdef SUPPORT_ZT9612_BT_VENDOR +void VendorInterface::OnLpmCallback(bt_vendor_op_result_t result) { + HDF_LOGI("LPM operation result: %d", result); +} +#endif void *VendorInterface::OnMallocCallback(int size) { static int MAX_BUFFER_SIZE = 1024; @@ -256,9 +332,13 @@ void VendorInterface::OnFreeCallback(void *buf) free(buf); } } - +#ifdef SUPPORT_ZT9612_BT_VENDOR +uint8_t VendorInterface::OnCmdXmitCallback(uint16_t opcode, void *buf) +#else size_t VendorInterface::OnCmdXmitCallback(uint16_t opcode, void *buf) +#endif { + HDF_LOGI("%{public}s, ", __func__); HC_BT_HDR *hdr = reinterpret_cast(buf); VendorInterface::GetInstance()->vendorSentOpcode_ = opcode; @@ -269,6 +349,7 @@ size_t VendorInterface::OnCmdXmitCallback(uint16_t opcode, void *buf) void VendorInterface::OnEventReceived(const std::vector &data) { + HDF_LOGI("%{public}s, ", __func__); if (data[0] == Hci::HCI_EVENT_CODE_VENDOR_SPECIFIC) { size_t buffSize = sizeof(HC_BT_HDR) + data.size(); HC_BT_HDR *buff = reinterpret_cast(new uint8_t[buffSize]); @@ -278,7 +359,7 @@ void VendorInterface::OnEventReceived(const std::vector &data) buff->layer_specific = 0; (void)memcpy_s(buff->data, buffSize - sizeof(HC_BT_HDR), data.data(), data.size()); if (vendorInterface_ && vendorInterface_->op) { - vendorInterface_->op(BtOpcodeT::BT_OP_EVENT_CALLBACK, buff); + vendorInterface_->op(BT_OP_EVENT_CALLBACK, buff); } delete[] buff; } else if (vendorSentOpcode_ != 0 && data[0] == Hci::HCI_EVENT_CODE_COMMAND_COMPLETE) { @@ -294,7 +375,7 @@ void VendorInterface::OnEventReceived(const std::vector &data) (void)memcpy_s(buff->data, buffSize - sizeof(HC_BT_HDR), data.data(), data.size()); vendorSentOpcode_ = 0; if (vendorInterface_ && vendorInterface_->op) { - vendorInterface_->op(BtOpcodeT::BT_OP_EVENT_CALLBACK, buff); + vendorInterface_->op(BT_OP_EVENT_CALLBACK, buff); } delete[] buff; } @@ -307,7 +388,12 @@ void VendorInterface::WatcherTimeout() { std::lock_guard lock(wakeupMutex_); if (!activity_ && wakeupLock_ && vendorInterface_ && vendorInterface_->op) { +#ifdef SUPPORT_ZT9612_BT_VENDOR + int wakeDeassert = BT_VND_LPM_WAKE_DEASSERT; + vendorInterface_->op(BT_VND_OP_LPM_WAKE_SET_STATE, &wakeDeassert); +#else vendorInterface_->op(BtOpcodeT::BT_OP_WAKEUP_UNLOCK, nullptr); +#endif wakeupLock_ = false; } activity_ = false; diff --git a/bluetooth/hci/hdi_service/implement/vendor_interface.h b/bluetooth/hci/hdi_service/implement/vendor_interface.h index 6ea0bc7407e6e9d0e26bf7df9b29e4f7075d05c9..48994b4c12924a54726810382f47971a26061a73 100644 --- a/bluetooth/hci/hdi_service/implement/vendor_interface.h +++ b/bluetooth/hci/hdi_service/implement/vendor_interface.h @@ -47,11 +47,19 @@ public: size_t SendPacket(Hci::HciPacketType type, const std::vector &packet); private: - static void OnInitCallback(BtOpResultT result); +#ifdef SUPPORT_ZT9612_BT_VENDOR + static void OnInitCallback(bt_vendor_op_result_t result); +#else + static void OnInitCallback(BtOpResultT result); +#endif static void* OnMallocCallback(int size); static void OnFreeCallback(void* buf); +#ifdef SUPPORT_ZT9612_BT_VENDOR + static uint8_t OnCmdXmitCallback(uint16_t opcode, void* buf); + static void OnLpmCallback(bt_vendor_op_result_t result); +#else static size_t OnCmdXmitCallback(uint16_t opcode, void* buf); - +#endif void OnEventReceived(const std::vector &data); bool WatchHciChannel(const ReceiveCallback &receiveCallback); void WatcherTimeout(); @@ -60,8 +68,13 @@ private: InitializeCompleteCallback initializeCompleteCallback_; ReceiveDataCallback eventDataCallback_; void* vendorHandle_ = nullptr; +#ifdef SUPPORT_ZT9612_BT_VENDOR + bt_vendor_interface_t *vendorInterface_ = nullptr; + static bt_vendor_callbacks_t vendorCallbacks_; +#else BtVendorInterfaceT *vendorInterface_ = nullptr; static BtVendorCallbacksT vendorCallbacks_; +#endif std::shared_ptr watcher_; std::shared_ptr hci_ = nullptr; uint16_t vendorSentOpcode_ = 0; diff --git a/camera/hdi_service/v1_0/BUILD.gn b/camera/hdi_service/v1_0/BUILD.gn index d08c46f781fefaf5dbb359039a879f237b6e4d8a..8fd0479bf88f72dd2dd7c3c421244639de297ac1 100644 --- a/camera/hdi_service/v1_0/BUILD.gn +++ b/camera/hdi_service/v1_0/BUILD.gn @@ -124,6 +124,12 @@ if (defined(ohos_lite)) { if (drivers_peripheral_camera_feature_usb) { defines += [ "CHIP_PROD_CAMERA_HOST_CONFIG" ] } + if (product_name == "gk6780v100") { + defines += [ "OHOS_GK6780V100" ] + } + if (product_name == "gk6323") { + defines += [ "OHOS_GK6323" ] + } if (is_standard_system) { external_deps = [ @@ -169,6 +175,12 @@ if (defined(ohos_lite)) { if (use_hitrace) { defines += [ "HITRACE_LOG_ENABLED" ] } + if (product_name == "gk6780v100") { + defines += [ "OHOS_GK6780V100" ] + } + if (product_name == "gk6323") { + defines += [ "OHOS_GK6323" ] + } if (is_standard_system) { external_deps = [ diff --git a/camera/vdi_base/common/adapter/platform/v4l2/src/device_manager/include/v4l2_device_manager.h b/camera/vdi_base/common/adapter/platform/v4l2/src/device_manager/include/v4l2_device_manager.h index c9cc463e2968ed125fc4b450d77f0f3e986219fc..7a0e89fee879df579ef31a2050e9bceb39dc9813 100644 --- a/camera/vdi_base/common/adapter/platform/v4l2/src/device_manager/include/v4l2_device_manager.h +++ b/camera/vdi_base/common/adapter/platform/v4l2/src/device_manager/include/v4l2_device_manager.h @@ -143,7 +143,12 @@ private: void AddDefaultFlashAvailable(std::shared_ptr metadata); void AddDefaultJpegOrientation(std::shared_ptr metadata); void AddDefaultJpegQuality(std::shared_ptr metadata); +#if defined(OHOS_GK6323) + void AddDefaultAbilityStreamAvailableBasicConfigurations(std::shared_ptr metadata, + const std::vector& deviceFormat); +#else void AddDefaultAbilityStreamAvailableBasicConfigurations(std::shared_ptr metadata); +#endif void AddDefaultSensorOrientation(std::shared_ptr metadata); void AddDefaultFocalLength(std::shared_ptr metadata); diff --git a/camera/vdi_base/common/adapter/platform/v4l2/src/device_manager/v4l2_device_manager.cpp b/camera/vdi_base/common/adapter/platform/v4l2/src/device_manager/v4l2_device_manager.cpp index 8f91f46911a938245df0a607afbe7fecd6ec80ad..3a7008e356c549688e5d5d792dcdc17c48de8f69 100644 --- a/camera/vdi_base/common/adapter/platform/v4l2/src/device_manager/v4l2_device_manager.cpp +++ b/camera/vdi_base/common/adapter/platform/v4l2/src/device_manager/v4l2_device_manager.cpp @@ -337,10 +337,19 @@ void V4L2DeviceManager::UvcCallBack(const std::string hardwareName, std::vector< CAMERA_LOGI("uvc plug in %{public}s begin", hardwareName.c_str()); CameraId id = ReturnEnableCameraId(""); CHECK_IF_EQUAL_RETURN_VOID(id, CAMERA_MAX); +#if !defined(OHOS_GK6323) RetCode rc = GetManager(DM_M_SENSOR)->CreateController(DM_C_SENSOR, hardwareName); CHECK_IF_EQUAL_RETURN_VOID(rc, RC_ERROR); - +#endif AddHardware(id, hardwareName); +#if defined(OHOS_GK6323) + if (CheckManagerList(DM_M_SENSOR) == false) { + CreateManager(); + } else { + RetCode rc = GetManager(DM_M_SENSOR)->CreateController(DM_C_SENSOR, hardwareName); + CHECK_IF_EQUAL_RETURN_VOID(rc, RC_ERROR); + } +#endif std::shared_ptr meta = std::make_shared(ITEM_CAPACITY_SIZE, DATA_CAPACITY_SIZE); CHECK_IF_PTR_NULL_RETURN_VOID(meta); @@ -458,7 +467,11 @@ void V4L2DeviceManager::AddDefaultOhosTag(std::shared_ptr camera AddDefaultFlashAvailable(cameraMetadata); AddDefaultJpegOrientation(cameraMetadata); AddDefaultJpegQuality(cameraMetadata); +#if defined(OHOS_GK6323) + AddDefaultAbilityStreamAvailableBasicConfigurations(cameraMetadata, deviceFormat); +#else AddDefaultAbilityStreamAvailableBasicConfigurations(cameraMetadata); +#endif AddDefaultSensorOrientation(cameraMetadata); AddDefaultFocalLength(cameraMetadata); } @@ -573,6 +586,20 @@ void V4L2DeviceManager::ConvertAbilityExposureModesToOhos(std::shared_ptr abilityExposureModesVector; +#if defined(OHOS_GK6323) + for (int i = 0; i < deviceControl.menu.size(); i++) { + if (deviceControl.menu[i].id != V4L2_CID_EXPOSURE_AUTO) { + continue; + } + if (deviceControl.menu[i].index == V4L2_EXPOSURE_MANUAL || + deviceControl.menu[i].index == V4L2_EXPOSURE_SHUTTER_PRIORITY) { + abilityExposureModesVector.push_back(OHOS_CAMERA_EXPOSURE_MODE_MANUAL); + } else if (deviceControl.menu[i].index == V4L2_EXPOSURE_AUTO || + deviceControl.menu[i].index == V4L2_EXPOSURE_APERTURE_PRIORITY) { + abilityExposureModesVector.push_back(OHOS_CAMERA_EXPOSURE_MODE_CONTINUOUS_AUTO); + } + } +#else for (int i = 0; i < deviceControl.menu.size(); i++) { if (deviceControl.menu[i].id != V4L2_CID_EXPOSURE_AUTO) { continue; @@ -583,6 +610,7 @@ void V4L2DeviceManager::ConvertAbilityExposureModesToOhos(std::shared_ptr me AddOrUpdateOhosTag(metadata, OHOS_JPEG_QUALITY, jpegQualityVector); } +#if defined(OHOS_GK6323) +void V4L2DeviceManager::AddDefaultAbilityStreamAvailableBasicConfigurations( + std::shared_ptr metadata, const std::vector& deviceFormat) +{ + int maxMumFps = 30; +#if defined(OHOS_GK6323) + std::string name = "Motion-JPEG"; +#else + std::string name = "YUYV 4:2:2"; +#endif + int32_t fpsValue = 0; + std::vector formatVector; + std::vector> formatVectorExist = {{0, 0}}; + std::vector abilityStreamAvailableBasicConfigurationsVector; + +RETRY: + for (auto& it : deviceFormat) { + if (it.fmtdesc.description != name || it.fmtdesc.fps.numerator == 0) { + continue; + } + fpsValue = it.fmtdesc.fps.denominator / it.fmtdesc.fps.numerator; + if (fpsValue >= maxMumFps) { + if (formatVector.size() != 0) { + formatVector.clear(); + } + auto duplicate = std::find_if(formatVectorExist.begin(), formatVectorExist.end(), + [&](const std::pair& dim) { + return dim.first == it.fmtdesc.width && dim.second == it.fmtdesc.height; + }); + if (duplicate == formatVectorExist.end()) { + if (it.fmtdesc.width >= 640) { + formatVector.push_back(OHOS_CAMERA_FORMAT_RGBA_8888); + formatVector.push_back(it.fmtdesc.width); + formatVector.push_back(it.fmtdesc.height); + formatVector.push_back(OHOS_CAMERA_FORMAT_YCRCB_420_SP); + formatVector.push_back(it.fmtdesc.width); + formatVector.push_back(it.fmtdesc.height); + formatVector.push_back(OHOS_CAMERA_FORMAT_JPEG); + formatVector.push_back(it.fmtdesc.width); + formatVector.push_back(it.fmtdesc.height); + abilityStreamAvailableBasicConfigurationsVector.insert( + abilityStreamAvailableBasicConfigurationsVector.begin(), + formatVector.begin(), formatVector.end()); + } + formatVectorExist.push_back(std::make_pair(it.fmtdesc.width, it.fmtdesc.height)); + } + } + } + + if (abilityStreamAvailableBasicConfigurationsVector.size() == 0) { + if (maxMumFps > 0) { + maxMumFps = maxMumFps - 5; + goto RETRY; + } else { + CAMERA_LOGE("abilityStreamAvailableBasicConfigurations is not data."); + } + } + + AddOrUpdateOhosTag(metadata, OHOS_ABILITY_STREAM_AVAILABLE_BASIC_CONFIGURATIONS, + abilityStreamAvailableBasicConfigurationsVector); + + std::vector videoStabilizationAvailableModes; + videoStabilizationAvailableModes.push_back(OHOS_CAMERA_VIDEO_STABILIZATION_OFF); + AddOrUpdateOhosTag(metadata, OHOS_ABILITY_VIDEO_STABILIZATION_MODES, + videoStabilizationAvailableModes); +} + +#else void V4L2DeviceManager::AddDefaultAbilityStreamAvailableBasicConfigurations(std::shared_ptr metadata) { std::vector abilityStreamAvailableBasicConfigurationsVector; @@ -845,6 +941,7 @@ void V4L2DeviceManager::AddDefaultAbilityStreamAvailableBasicConfigurations(std: AddOrUpdateOhosTag(metadata, OHOS_ABILITY_STREAM_AVAILABLE_BASIC_CONFIGURATIONS, abilityStreamAvailableBasicConfigurationsVector); } +#endif void V4L2DeviceManager::AddDefaultSensorOrientation(std::shared_ptr metadata) { diff --git a/camera/vdi_base/common/adapter/platform/v4l2/src/driver_adapter/src/v4l2_buffer.cpp b/camera/vdi_base/common/adapter/platform/v4l2/src/driver_adapter/src/v4l2_buffer.cpp index cdd12da33dbe5d6f163f80cb2b411e0377778df5..ef5bb6ab57ef2dcd10a573aea7e96307b08d98c7 100644 --- a/camera/vdi_base/common/adapter/platform/v4l2/src/driver_adapter/src/v4l2_buffer.cpp +++ b/camera/vdi_base/common/adapter/platform/v4l2/src/driver_adapter/src/v4l2_buffer.cpp @@ -321,6 +321,18 @@ RetCode HosV4L2Buffers::V4L2DequeueBuffer(int fd) return RC_ERROR; } #endif +#if defined(OHOS_GK6780V100) || defined(OHOS_GK6323) + if (memoryType_ == V4L2_MEMORY_MMAP || memoryType_ == V4L2_MEMORY_DMABUF) { + if (adapterBufferMap_[buf.index].userBufPtr && adapterBufferMap_[buf.index].start) { + if (adapterBufferMap_[buf.index].length < buf.bytesused) { + CAMERA_LOGE("ERROR: BufferMap length error"); + return RC_ERROR; + } + (void)memcpy_s(adapterBufferMap_[buf.index].userBufPtr, adapterBufferMap_[buf.index].length, + adapterBufferMap_[buf.index].start, buf.bytesused); + } + } +#else if (memoryType_ == V4L2_MEMORY_MMAP || memoryType_ == V4L2_MEMORY_DMABUF) { if (adapterBufferMap_[buf.index].userBufPtr && adapterBufferMap_[buf.index].start) { if (adapterBufferMap_[buf.index].length > buffLong_) { @@ -331,6 +343,7 @@ RetCode HosV4L2Buffers::V4L2DequeueBuffer(int fd) adapterBufferMap_[buf.index].start, adapterBufferMap_[buf.index].length); } } +#endif std::lock_guard l(bufferLock_); auto IterMap = queueBuffers_.find(fd); if (IterMap == queueBuffers_.end()) { @@ -350,6 +363,9 @@ RetCode HosV4L2Buffers::V4L2DequeueBuffer(int fd) } CameraDumper& dumper = CameraDumper::GetInstance(); dumper.DumpBuffer("DQBuffer", ENABLE_DQ_BUFFER_DUMP, Iter->second->buffer_); +#if defined(OHOS_GK6780V100) || defined(OHOS_GK6323) + Iter->second->buffer_->SetBytesUsed(buf.bytesused); +#endif dequeueBuffer_(Iter->second); bufferMap.erase(Iter); return RC_OK; @@ -383,7 +399,9 @@ RetCode HosV4L2Buffers::V4L2AllocBuffer(int fd, const std::shared_ptr buf.length, frameSpec->buffer_->GetSize(), buf.index); if (buf.length > frameSpec->buffer_->GetSize()) { CAMERA_LOGE("RROR:user buff < V4L2 buf.length\n"); +#if !defined(OHOS_GK6780V100) && !defined(OHOS_GK6323) return RC_ERROR; +#endif } buffLong_ = frameSpec->buffer_->GetSize(); if (memoryType_ == V4L2_MEMORY_MMAP || memoryType_ == V4L2_MEMORY_DMABUF) { diff --git a/camera/vdi_base/common/adapter/platform/v4l2/src/driver_adapter/src/v4l2_control.cpp b/camera/vdi_base/common/adapter/platform/v4l2/src/driver_adapter/src/v4l2_control.cpp index 1a49091a89fa65ea72754758d636e47bf1a65273..daf346dea57bcdee8319e8b7a156e12ca875ce8f 100644 --- a/camera/vdi_base/common/adapter/platform/v4l2/src/driver_adapter/src/v4l2_control.cpp +++ b/camera/vdi_base/common/adapter/platform/v4l2/src/driver_adapter/src/v4l2_control.cpp @@ -218,6 +218,14 @@ void HosV4L2Control::V4L2SetValue(int fd, std::vector& control, qCtrl.name, qCtrl.id, qCtrl.type, qCtrl.minimum, qCtrl.maximum, value, qCtrl.step, qCtrl.default_value); } +#if defined(OHOS_GK6780V100) + if (qCtrl.id == V4L2_CID_EXPOSURE_AUTO_PRIORITY) { + rc = V4L2SetCtrl(fd, qCtrl.id, 0); + if (rc != RC_ERROR) { + CAMERA_LOGD("V4L2_CID_EXPOSURE_AUTO_PRIORITY set 0"); + } + } +#endif CAMERA_LOGD("V4L2SetValue out fd = %{public}d\n", fd); } diff --git a/camera/vdi_base/common/adapter/platform/v4l2/src/driver_adapter/src/v4l2_uvc.cpp b/camera/vdi_base/common/adapter/platform/v4l2/src/driver_adapter/src/v4l2_uvc.cpp index 9df851a8f7c3c0e5550cc58d8cb5fa8a7276f407..9c1106b9b58e967c280ea26a21e6961c5c2ed138 100644 --- a/camera/vdi_base/common/adapter/platform/v4l2/src/driver_adapter/src/v4l2_uvc.cpp +++ b/camera/vdi_base/common/adapter/platform/v4l2/src/driver_adapter/src/v4l2_uvc.cpp @@ -134,6 +134,12 @@ void HosV4L2UVC::V4L2UvcMatchDev(const std::string name, const std::string v4l2D V4L2UvcSearchCapability(std::string(devName), v4l2Device, inOut); uvcCallbackFun_(std::string(devName), control_, format_, inOut); +#if defined(OHOS_GK6323) + for (auto it = HosV4L2Dev::deviceMatch.begin(); it != HosV4L2Dev::deviceMatch.end(); it++) { + CAMERA_LOGI("UVC: HosV4L2Dev::deviceMatch: devName=%{public}s v4l2Device=%{public}s.\n", + it->first.c_str(), it->second.c_str()); + } +#endif } RetCode HosV4L2UVC::V4L2UvcGetCap(const std::string v4l2Device, struct v4l2_capability& cap) diff --git a/camera/vdi_base/common/adapter/platform/v4l2/src/pipeline_core/nodes/uvc_node/uvc_node.cpp b/camera/vdi_base/common/adapter/platform/v4l2/src/pipeline_core/nodes/uvc_node/uvc_node.cpp index cf2021d0fee9bf629cca6a2380cace19a2c6040d..33fbe93c2e3d0b720f4ed8516489c58c375bbad4 100644 --- a/camera/vdi_base/common/adapter/platform/v4l2/src/pipeline_core/nodes/uvc_node/uvc_node.cpp +++ b/camera/vdi_base/common/adapter/platform/v4l2/src/pipeline_core/nodes/uvc_node/uvc_node.cpp @@ -21,6 +21,14 @@ UvcNode::UvcNode(const std::string& name, const std::string& type, const std::st : SourceNode(name, type, cameraId), NodeBase(name, type, cameraId) { CAMERA_LOGI("%s enter, type(%s), cameraid(%{public}s)\n", name_.c_str(), type_.c_str(), cameraId_.c_str()); +#if defined(OHOS_GK6323) + std::string formatH264 = "h264"; + if (type_ == formatH264) { + v4l2Format_ = V4L2_PIX_FMT_H264; + } else { + v4l2Format_ = V4L2_PIX_FMT_MJPEG; + } +#endif RetCode rc = RC_OK; constexpr int ITEM_CAPACITY_SIZE = 30; constexpr int DATA_CAPACITY_SIZE = 1000; @@ -47,17 +55,28 @@ struct MetadataTag { CameraId cameraId2 = CAMERA_FIRST; }; -const MetadataTag OHOS_MAP_CAMERA_ID[] = { +#if defined(OHOS_GK6323) +const MetadataTag g_ohosMapCameraId[] = { + { "lcam001", CAMERA_FIRST }, + { "lcam002", CAMERA_SECOND }, + { "lcam003", CAMERA_THIRD }, + { "lcam004", CAMERA_FOURTH }, + { "lcam005", CAMERA_FIFTH }, + { "lcam006", CAMERA_SIXTH }, +}; +#else +const MetadataTag g_ohosMapCameraId[] = { { "lcam001", CAMERA_THIRD }, { "lcam002", CAMERA_THIRD }, { "lcam003", CAMERA_FOURTH }, { "lcam004", CAMERA_FIFTH }, { "lcam005", CAMERA_SIXTH }, }; +#endif CameraId UvcNode::ConvertCameraId(const std::string &cameraId) { - for (auto cameraID : OHOS_MAP_CAMERA_ID) { + for (auto cameraID : g_ohosMapCameraId) { if (cameraID.cameraId1 == cameraId) { return cameraID.cameraId2; } @@ -101,7 +120,11 @@ RetCode UvcNode::Start(const int32_t streamId) std::vector> outPorts = GetOutPorts(); for (const auto& it : outPorts) { DeviceFormat format; +#if defined(OHOS_GK6323) + format.fmtdesc.pixelformat = v4l2Format_; +#else format.fmtdesc.pixelformat = V4L2_PIX_FMT_YUYV; +#endif format.fmtdesc.width = wide_; format.fmtdesc.height = high_; int bufCnt = it->format_.bufferCount_; @@ -230,6 +253,7 @@ void UvcNode::DeliverBuffer(std::shared_ptr& buffer) return; } +#if !defined(OHOS_GK6323) CameraDumper& dumper = CameraDumper::GetInstance(); dumper.DumpBuffer("YUV422", ENABLE_UVC_NODE, buffer, wide_, high_); @@ -249,6 +273,7 @@ void UvcNode::DeliverBuffer(std::shared_ptr& buffer) buffer->SetCurHeight(high_); buffer->SetIsValidDataInSurfaceBuffer(false); dumper.DumpBuffer("YUV420", ENABLE_UVC_NODE_CONVERTED, buffer, wide_, high_); +#endif SourceNode::DeliverBuffer(buffer); return; } diff --git a/camera/vdi_base/common/adapter/platform/v4l2/src/pipeline_core/nodes/uvc_node/uvc_node.h b/camera/vdi_base/common/adapter/platform/v4l2/src/pipeline_core/nodes/uvc_node/uvc_node.h index 2d6eef8fe6b3cb2d2f09e0cdd502d63cd53a02bf..5a4e9b9c0746c2f14daea8f10213b44d2b667214 100644 --- a/camera/vdi_base/common/adapter/platform/v4l2/src/pipeline_core/nodes/uvc_node/uvc_node.h +++ b/camera/vdi_base/common/adapter/platform/v4l2/src/pipeline_core/nodes/uvc_node/uvc_node.h @@ -44,6 +44,9 @@ private: void YUV422To420(uint8_t yuv422[], uint8_t yuv420[], int width, int height); private: +#if defined(OHOS_GK6323) + int32_t v4l2Format_; +#endif std::mutex requestLock_; std::map> captureRequests_ = {}; std::shared_ptr sensorController_ = nullptr; diff --git a/camera/vdi_base/common/adapter/platform/v4l2/src/pipeline_core/nodes/v4l2_source_node/v4l2_source_node.cpp b/camera/vdi_base/common/adapter/platform/v4l2/src/pipeline_core/nodes/v4l2_source_node/v4l2_source_node.cpp index 00ee36808c366dd5443ff3ed7e018dcf516a71d8..4d7a95fa346db425a7be6eb6021fe69889579230 100644 --- a/camera/vdi_base/common/adapter/platform/v4l2/src/pipeline_core/nodes/v4l2_source_node/v4l2_source_node.cpp +++ b/camera/vdi_base/common/adapter/platform/v4l2/src/pipeline_core/nodes/v4l2_source_node/v4l2_source_node.cpp @@ -95,8 +95,12 @@ RetCode V4L2SourceNode::Start(const int32_t streamId) format.fmtdesc.pixelformat = V4L2_PIX_FMT_YUV420; } else { #endif +#if defined(OHOS_GK6323) + format.fmtdesc.pixelformat = V4L2_PIX_FMT_MJPEG; +#else format.fmtdesc.pixelformat = V4L2Utils::ConvertPixfmtHal2V4l2( static_cast(it->format_.format_)); +#endif #ifdef V4L2_EMULATOR } #endif diff --git a/camera/vdi_base/common/buffer_manager/src/image_buffer.cpp b/camera/vdi_base/common/buffer_manager/src/image_buffer.cpp index 87fc68522e5646f8cccd25fcaad43e3b437bcb45..43613e3e995f276780391bde5971a86626cfbe7b 100644 --- a/camera/vdi_base/common/buffer_manager/src/image_buffer.cpp +++ b/camera/vdi_base/common/buffer_manager/src/image_buffer.cpp @@ -368,6 +368,20 @@ void ImageBuffer::SetStreamId(const int32_t streamId) return; } +#if defined(OHOS_GK6780V100) || defined(OHOS_GK6323) +uint32_t ImageBuffer::GetBytesUsed() const +{ + return bytesUsed_; +} + +void ImageBuffer::SetBytesUsed(const uint32_t size) +{ + std::lock_guard l(l_); + bytesUsed_ = size; + return; +} +#endif + void ImageBuffer::SetIsValidDataInSurfaceBuffer(const bool isValid) { std::lock_guard l(l_); diff --git a/camera/vdi_base/common/include/camera.h b/camera/vdi_base/common/include/camera.h index da087cd35b409e7768a4992afb719e2a87a8a1eb..9bbb25fba63b9cb595ee7c2a2b59cfca77c8e23c 100644 --- a/camera/vdi_base/common/include/camera.h +++ b/camera/vdi_base/common/include/camera.h @@ -105,6 +105,9 @@ enum CameraBufferUsage : uint64_t { CAMERA_USAGE_MEM_MMZ = (1 << 4), CAMERA_USAGE_MEM_MMZ_CACHE = (1 << 5), CAMERA_USAGE_MEM_FB = (1 << 6), +#if defined(OHOS_GK6780V100) + CAMERA_USAGE_VENDOR_PRI2 = (1 << 7), +#endif }; enum CameraBufferFormat : uint32_t { diff --git a/camera/vdi_base/common/include/ibuffer.h b/camera/vdi_base/common/include/ibuffer.h index 8b6aa8c3cd1bbd8a42352a98c17f9683d54c6d35..d8b72ee662f5267174ab3e7c801d541e9942a764 100644 --- a/camera/vdi_base/common/include/ibuffer.h +++ b/camera/vdi_base/common/include/ibuffer.h @@ -87,7 +87,10 @@ public: virtual void SetEsFrameNum(const int32_t frameNum) = 0; virtual void SetStreamId(const int32_t streamId) = 0; virtual void SetIsValidDataInSurfaceBuffer(const bool isValid) = 0; - +#if defined(OHOS_GK6780V100) || defined(OHOS_GK6323) + virtual uint32_t GetBytesUsed() const = 0; + virtual void SetBytesUsed(const uint32_t size) = 0; +#endif virtual void Free() = 0; virtual bool operator==(const IBuffer& u) = 0; diff --git a/camera/vdi_base/common/include/image_buffer.h b/camera/vdi_base/common/include/image_buffer.h index 93e08713c26c008ebca591668e26e1ba585dcf00..f291859d11a4b40d3fa60c0981a45773b74b7655 100644 --- a/camera/vdi_base/common/include/image_buffer.h +++ b/camera/vdi_base/common/include/image_buffer.h @@ -89,11 +89,18 @@ public: void SetEsFrameNum(const int32_t frameNum) override; void SetStreamId(const int32_t streamId) override; void SetIsValidDataInSurfaceBuffer(const bool isValid) override; +#if defined(OHOS_GK6780V100) || defined(OHOS_GK6323) + uint32_t GetBytesUsed() const override; + void SetBytesUsed(const uint32_t size) override; +#endif void Free() override; bool operator==(const IBuffer& u) override; private: +#if defined(OHOS_GK6780V100) || defined(OHOS_GK6323) + uint32_t bytesUsed_ = 0; +#endif bool isDataValidInSurfaceBuffer_ = false; int32_t index_ = -1; uint32_t width_ = 0; diff --git a/camera/vdi_base/common/pipeline_core/nodes/src/source_node/source_node.cpp b/camera/vdi_base/common/pipeline_core/nodes/src/source_node/source_node.cpp index 6e5604c864a8a6342b93cb6d2efbd78fb44cbab4..f68fb82ce5c326e0ef377a17a3fa477053ff5a91 100644 --- a/camera/vdi_base/common/pipeline_core/nodes/src/source_node/source_node.cpp +++ b/camera/vdi_base/common/pipeline_core/nodes/src/source_node/source_node.cpp @@ -270,6 +270,7 @@ void SourceNode::PortHandler::CollectBuffers() CAMERA_LOGI("streamId[%{public}d], bufferIndex[%{public}d], Size %{public}d => %{public}d", buffer->GetStreamId(), buffer->GetIndex(), buffer->GetSize(), bufferSize); +#if (!defined(OHOS_GK6780V100) && !defined(OHOS_GK6323)) if (buffer->GetVirAddress() == buffer->GetSuffaceBufferAddr()) { CAMERA_LOGI("CollectBuffers begin malloc buffer"); auto bufferAddr = malloc(bufferSize); @@ -286,6 +287,7 @@ void SourceNode::PortHandler::CollectBuffers() CAMERA_LOGE("CollectBuffers malloc buffer fail"); } } +#endif frameSpec->buffer_ = buffer; auto node = port->GetNode(); CHECK_IF_PTR_NULL_RETURN_VOID(node); diff --git a/camera/vdi_base/usb_camera/adapter/platform/v4l2/src/device_manager/v4l2_device_manager.cpp b/camera/vdi_base/usb_camera/adapter/platform/v4l2/src/device_manager/v4l2_device_manager.cpp index 6f34f6301f3708af5621cb190a29907527cf7dd5..1e3f364c06f38ee175bd90e49b9e23d5e8be51f7 100644 --- a/camera/vdi_base/usb_camera/adapter/platform/v4l2/src/device_manager/v4l2_device_manager.cpp +++ b/camera/vdi_base/usb_camera/adapter/platform/v4l2/src/device_manager/v4l2_device_manager.cpp @@ -446,7 +446,11 @@ void V4L2DeviceManager::AddDefaultOhosTag(std::shared_ptr camera AddDefaultFlashAvailable(cameraMetadata); AddDefaultJpegOrientation(cameraMetadata); AddDefaultJpegQuality(cameraMetadata); +#if defined(OHOS_GK6323) + AddDefaultAbilityStreamAvailableBasicConfigurations(cameraMetadata, deviceFormat); +#else AddDefaultAbilityStreamAvailableBasicConfigurations(cameraMetadata); +#endif AddDefaultSensorOrientation(cameraMetadata); AddDefaultFocalLength(cameraMetadata); } @@ -755,6 +759,66 @@ void V4L2DeviceManager::AddDefaultJpegQuality(std::shared_ptr me AddOrUpdateOhosTag(metadata, OHOS_JPEG_QUALITY, jpegQualityVector); } +#if defined(OHOS_GK6323) +void V4L2DeviceManager::AddDefaultAbilityStreamAvailableBasicConfigurations( + std::shared_ptr metadata, const std::vector& deviceFormat) +{ + int maxMumFps = 30; +#if defined(OHOS_GK6323) + std::string name = "Motion-JPEG"; +#else + std::string name = "YUYV 4:2:2"; +#endif + int32_t fpsValue = 0; + std::vector formatVector; + std::vector abilityStreamAvailableBasicConfigurationsVector; + +RETRY: + for (auto& it : deviceFormat) { + if (it.fmtdesc.description != name || it.fmtdesc.fps.numerator == 0) { + continue; + } + fpsValue = it.fmtdesc.fps.denominator / it.fmtdesc.fps.numerator; + if (fpsValue >= maxMumFps) { + if (formatVector.size() != 0) { + formatVector.clear(); + } + if (it.fmtdesc.width >= 640) { + formatVector.push_back(OHOS_CAMERA_FORMAT_RGBA_8888); + formatVector.push_back(it.fmtdesc.width); + formatVector.push_back(it.fmtdesc.height); + formatVector.push_back(OHOS_CAMERA_FORMAT_YCRCB_420_SP); + formatVector.push_back(it.fmtdesc.width); + formatVector.push_back(it.fmtdesc.height); + formatVector.push_back(OHOS_CAMERA_FORMAT_JPEG); + formatVector.push_back(it.fmtdesc.width); + formatVector.push_back(it.fmtdesc.height); + abilityStreamAvailableBasicConfigurationsVector.insert( + abilityStreamAvailableBasicConfigurationsVector.begin(), + formatVector.begin(), formatVector.end()); + } + } + } + + if (abilityStreamAvailableBasicConfigurationsVector.size() == 0) { + if (maxMumFps > 0) { + maxMumFps = maxMumFps - 5; + goto RETRY; + } else { + CAMERA_LOGE("abilityStreamAvailableBasicConfigurations is not data."); + } + } + + AddOrUpdateOhosTag(metadata, OHOS_ABILITY_STREAM_AVAILABLE_BASIC_CONFIGURATIONS, + abilityStreamAvailableBasicConfigurationsVector); + + std::vector videoStabilizationAvailableModes; + videoStabilizationAvailableModes.push_back(OHOS_CAMERA_VIDEO_STABILIZATION_OFF); + AddOrUpdateOhosTag(metadata, OHOS_ABILITY_VIDEO_STABILIZATION_MODES, + videoStabilizationAvailableModes); +} + +#else void V4L2DeviceManager::AddDefaultAbilityStreamAvailableBasicConfigurations(std::shared_ptr metadata) { std::vector abilityStreamAvailableBasicConfigurationsVector; @@ -762,6 +826,7 @@ void V4L2DeviceManager::AddDefaultAbilityStreamAvailableBasicConfigurations(std: AddOrUpdateOhosTag(metadata, OHOS_ABILITY_STREAM_AVAILABLE_BASIC_CONFIGURATIONS, abilityStreamAvailableBasicConfigurationsVector); } +#endif void V4L2DeviceManager::AddDefaultSensorOrientation(std::shared_ptr metadata) { diff --git a/camera/vdi_base/v4l2/src/camera_host/camera_host_vdi_impl.cpp b/camera/vdi_base/v4l2/src/camera_host/camera_host_vdi_impl.cpp index 900495957a05026cf4a8efcd902f72d177656a41..46218dda24886fe56975ccbe10f8ec0819017dd7 100644 --- a/camera/vdi_base/v4l2/src/camera_host/camera_host_vdi_impl.cpp +++ b/camera/vdi_base/v4l2/src/camera_host/camera_host_vdi_impl.cpp @@ -346,8 +346,55 @@ int32_t CameraHostVdiImpl::SetFlashlight(const std::string &cameraId, bool isEn DFX_LOCAL_HITRACE_END; } + +#if defined(OHOS_GK6323) RetCode CameraHostVdiImpl::SetFlashlight(const std::vector &phyCameraIds, bool isEnable, VdiFlashlightStatus &flashlightStatus) +{ + RetCode rc = RC_OK; + std::map enumCameraIdMap_ = { + { "CAMERA_FIRST", CAMERA_FIRST }, + { "CAMERA_SECOND", CAMERA_SECOND }, + { "CAMERA_THIRD", CAMERA_THIRD }, + { "CAMERA_FOURTH", CAMERA_FOURTH }, + { "CAMERA_FIFTH", CAMERA_FIFTH }, + { "CAMERA_SIXTH", CAMERA_SIXTH }, + }; + std::shared_ptr deviceManager = IDeviceManager::GetInstance(); + if (deviceManager == nullptr) { + CAMERA_LOGW("device manager is null [dm name MpiDeviceManager]."); + return RC_ERROR; + } + + for (auto& phyCameraId : phyCameraIds) { + CameraId curCameraId = CAMERA_MAX; + for (auto iter = enumCameraIdMap_.begin(); iter != enumCameraIdMap_.end(); iter++) { + if (iter->first == phyCameraId) { + curCameraId = iter->second; + break; + } + } + + if (curCameraId == CAMERA_MAX) { + flashlightStatus = FLASHLIGHT_OFF; + return RC_OK; + } + + rc = deviceManager->SetFlashlight(FLASH_TORCH, isEnable, curCameraId); + if (rc == RC_OK) { + if (isEnable) { + flashlightStatus = FLASHLIGHT_OFF; + } else { + flashlightStatus = FLASHLIGHT_ON; + } + } + } + + return rc; +} +#else +RetCode CameraHostVdiImpl::SetFlashlight(const std::vector &phyCameraIds, + bool isEnable, VdiFlashlightStatus &flashlightStatus) { std::shared_ptr deviceManager = IDeviceManager::GetInstance(); (void)phyCameraIds; @@ -367,6 +414,7 @@ RetCode CameraHostVdiImpl::SetFlashlight(const std::vector &phyCame return rc; } +#endif void CameraHostVdiImpl::OnCameraStatus(CameraId cameraId, VdiCameraStatus status, const std::shared_ptr ability) diff --git a/camera/vdi_base/v4l2/src/stream_operator/stream_base.cpp b/camera/vdi_base/v4l2/src/stream_operator/stream_base.cpp index 340bd94573a4f2aa25eff4c4f215fbef33ddde82..979b1848aef02b64d4267e3edb44b413c5841ed0 100644 --- a/camera/vdi_base/v4l2/src/stream_operator/stream_base.cpp +++ b/camera/vdi_base/v4l2/src/stream_operator/stream_base.cpp @@ -551,12 +551,24 @@ RetCode StreamBase::ChangeToOfflineStream(std::shared_ptr offline uint64_t StreamBase::GetUsage() { +#if defined(OHOS_GK6780V100) + if (streamType_ == PREVIEW && streamConfig_.format == CAMERA_FORMAT_YCRCB_420_SP) { + return CAMERA_USAGE_SW_WRITE_OFTEN | CAMERA_USAGE_SW_READ_OFTEN | CAMERA_USAGE_MEM_DMA | CAMERA_USAGE_VENDOR_PRI2; + } else { + return CAMERA_USAGE_SW_WRITE_OFTEN | CAMERA_USAGE_SW_READ_OFTEN | CAMERA_USAGE_MEM_DMA; + } +#else return CAMERA_USAGE_SW_WRITE_OFTEN | CAMERA_USAGE_SW_READ_OFTEN | CAMERA_USAGE_MEM_DMA; +#endif } uint32_t StreamBase::GetBufferCount() { - return 3; // 3: buffer count +#if defined(OHOS_GK6780V100) + return 6; // 3: buffer count +#else + return 3; +#endif } StreamConfiguration StreamBase::GetStreamAttribute() const diff --git a/camera/vdi_base/v4l2/src/stream_operator/stream_operator_vdi_impl.cpp b/camera/vdi_base/v4l2/src/stream_operator/stream_operator_vdi_impl.cpp index f64f3483b171d2fecff628722f00983d489eeb55..ea2c8c6a77a26ada1748d78654a017e66fc928a8 100644 --- a/camera/vdi_base/v4l2/src/stream_operator/stream_operator_vdi_impl.cpp +++ b/camera/vdi_base/v4l2/src/stream_operator/stream_operator_vdi_impl.cpp @@ -330,7 +330,11 @@ int32_t StreamOperatorVdiImpl::CommitStreams(VdiOperationMode mode, const std::v std::shared_ptr setting; MetadataUtils::ConvertVecToMetadata(modeSetting, setting); +#if defined(OHOS_GK6780V100) + DynamicStreamSwitchMode method = streamPipeline_->CheckStreamsSupported((VdiOperationMode)2, setting, configs); +#else DynamicStreamSwitchMode method = streamPipeline_->CheckStreamsSupported(mode, setting, configs); +#endif CameraHalTimeSysevent::WriteCameraParameterEvent(CameraHalTimeSysevent::GetEventName(PARAMS_OFCAPTURE_OR_VEDIO), setting->get()); CHECK_IF_EQUAL_RETURN_VALUE(method, DYNAMIC_STREAM_SWITCH_NOT_SUPPORT, INVALID_ARGUMENT); diff --git a/codec/image/vdi/codec_jpeg_vdi.h b/codec/image/vdi/codec_jpeg_vdi.h index 0b3a23a6b1547b9ad0a73dcbd9d3a971d0277d11..0d43576424f835787b832edcb5cab90df01de514 100644 --- a/codec/image/vdi/codec_jpeg_vdi.h +++ b/codec/image/vdi/codec_jpeg_vdi.h @@ -24,6 +24,10 @@ extern "C" { #define CODEC_JPEG_VDI_LIB_NAME "libjpeg_vdi_impl.z.so" +struct CodecJpegCallbackHwi { + int32_t (*OnEvent)(int32_t error); +}; + struct ICodecJpegHwi { int32_t (*JpegInit)(); diff --git a/codec/interfaces/include/codec_component_type.h b/codec/interfaces/include/codec_component_type.h index 7562f3797f9f9a8cd5e68975904428722a5c7013..30d63554d94e3f43d224ef30a4485d28a95e2021 100644 --- a/codec/interfaces/include/codec_component_type.h +++ b/codec/interfaces/include/codec_component_type.h @@ -69,6 +69,24 @@ typedef enum { MEDIA_ROLETYPE_VIDEO_MPEG4, /** VP9 video */ MEDIA_ROLETYPE_VIDEO_VP9, +#ifdef GOKE_PRODUCT + /** MPEG2 video */ + MEDIA_ROLETYPE_VIDEO_MPEG2, + /** MJPEG video */ + MEDIA_ROLETYPE_VIDEO_MJPEG, + /** H.263 video */ + MEDIA_ROLETYPE_VIDEO_H263, + /** AVS video */ + MEDIA_ROLETYPE_VIDEO_AVS, + /** AVS+ video */ + MEDIA_ROLETYPE_VIDEO_CAVS, + /** AVS2 video */ + MEDIA_ROLETYPE_VIDEO_AVS2, + /** Windows Media Video */ + MEDIA_ROLETYPE_VIDEO_WMV, + /** Real video */ + MEDIA_ROLETYPE_VIDEO_RV, +#endif /** Audio codec */ MEDIA_ROLETYPE_AUDIO_FIRST = 0x10000, /** Advanced Audio Coding (AAC) */ diff --git a/display/composer/hdi_service/BUILD.gn b/display/composer/hdi_service/BUILD.gn index 013e232806563a46a7e2258e507b97244b17e5e5..81b7921a4501b8341973ded2b83cc93c9292e278 100644 --- a/display/composer/hdi_service/BUILD.gn +++ b/display/composer/hdi_service/BUILD.gn @@ -24,6 +24,11 @@ group("display_composer_hdi_service") { ohos_shared_library("libdisplay_composer_service_1.2") { defines = [] defines += display_defines + + if (product_name == "gk6780v100") { + defines += [ "OHOS_GK6780V100" ] + } + include_dirs = [ "../../utils/include", "include", diff --git a/display/composer/hdi_service/include/idisplay_composer_vdi.h b/display/composer/hdi_service/include/idisplay_composer_vdi.h index 15240c24305efbfdbd59800f9a53b3715c8c4981..eef7f832276d2bdc371aecc2a163f661072a51ca 100644 --- a/display/composer/hdi_service/include/idisplay_composer_vdi.h +++ b/display/composer/hdi_service/include/idisplay_composer_vdi.h @@ -20,7 +20,11 @@ #include #include "buffer_handle.h" #include "v1_2/include/idisplay_composer_interface.h" +#ifdef OHOS_GK6780V100 +#include "v1_2/display_composer_type.h" +#else #include "v1_0/display_composer_type.h" +#endif namespace OHOS { namespace HDI { diff --git a/tvservice/BUILD.gn b/tvservice/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..96cb6e5b25fca6bd7b9a84ff5245840306a7b5c0 --- /dev/null +++ b/tvservice/BUILD.gn @@ -0,0 +1,25 @@ +# Copyright (c) 2025 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. +import("//build/ohos.gni") + +print("=============tvservice_entry============") +group("tvservice_entry") { + deps = [ + "video:tvservice_video_host_entry", + "audio:tvservice_audio_host_entry", + "hdmi/hdmirx:tvservice_hdmi_host_entry", + "hdmi/hdmitx:tvservice_hdmitx_host_entry", + "dtv/demux:tvservice_dtv_demux_host_entry", + "dtv/frontend:tvservice_dtv_frontend_host_entry" + ] +} \ No newline at end of file diff --git a/tvservice/audio/BUILD.gn b/tvservice/audio/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..3bb2f086cdf475c55377a24d245a6979cfde72fd --- /dev/null +++ b/tvservice/audio/BUILD.gn @@ -0,0 +1,19 @@ +# Copyright (c) 2025 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. +import("//build/ohos.gni") + +print("=============tvservice_audio_host_entry============") +group("tvservice_audio_host_entry") { + deps = [ "interfaces/hdi_service:hdf_tvservice_audio_host"] + #deps += [ "interfaces/vdi_base:tvservice_audio_vdi_impl_default" ] +} \ No newline at end of file diff --git a/tvservice/audio/interfaces/hdi_service/BUILD.gn b/tvservice/audio/interfaces/hdi_service/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..b668c337c208ad0eb99f7f04471f096fb9f0b475 --- /dev/null +++ b/tvservice/audio/interfaces/hdi_service/BUILD.gn @@ -0,0 +1,82 @@ +# Copyright (c) 2025 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. +import("//build/ohos.gni") +import("../../../tvservice.gni") + +ohos_shared_library("libtvservice_audio_service_1.0") { + defines = [] + include_dirs = [ + "../../utils/include", + "include" + ] + sources = [ + "src/tvservice_audio_service.cpp" + ] + + external_deps = [ + "c_utils:utils", + "hdf_core:libhdf_ipc_adapter", + "hdf_core:libhdi", + "hdf_core:libhdf_host", + "hdf_core:libhdf_utils", + "hilog:libhilog", + "ipc:ipc_single", + "libxml2:libxml2", + "drivers_interface_tvservice:libtvservice_audio_stub_1.0", + "drivers_interface_tvservice:libtvservice_audio_proxy_1.0", + ] + + if (has_tvservice_hisysevent_part) { + external_deps += [ "hisysevent:libhisysevent" ] + } + + install_images = [ chipset_base_dir ] + subsystem_name = "hdf" + part_name = "drivers_peripheral_tvservice" +} + + +ohos_shared_library("libtvservice_audio_driver") { + sources = [ + "src/tvservice_audio_driver.cpp" + ] + + external_deps = [ + "c_utils:utils", + "hdf_core:libhdf_ipc_adapter", + "hdf_core:libhdi", + "hdf_core:libhdf_host", + "hdf_core:libhdf_utils", + "hilog:libhilog", + "ipc:ipc_single", + "drivers_interface_tvservice:libtvservice_audio_stub_1.0", + "drivers_interface_tvservice:libtvservice_audio_proxy_1.0", + ] + if (has_tvservice_c_utils_part) { + external_deps += [ "c_utils:utils" ] + } + + shlib_type = "hdi" + install_images = [ chipset_base_dir ] + subsystem_name = "hdf" + part_name = "drivers_peripheral_tvservice" +} + +group("hdf_tvservice_audio_host") { + deps = [ + ":libtvservice_audio_driver", + ":libtvservice_audio_service_1.0", + ] + +print("=============hdf_tvservice_audio_host============") +} \ No newline at end of file diff --git a/tvservice/audio/interfaces/hdi_service/include/tvservice_audio_service.h b/tvservice/audio/interfaces/hdi_service/include/tvservice_audio_service.h new file mode 100644 index 0000000000000000000000000000000000000000..44f11a47ae6090c127f2b6ba5e76580f28e0e0ea --- /dev/null +++ b/tvservice/audio/interfaces/hdi_service/include/tvservice_audio_service.h @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2025 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. + */ + + #ifndef OHOS_HDI_TVSERVICE_AUDIO_H + #define OHOS_HDI_TVSERVICE_AUDIO_H + + #include "tvservice_audio_vdi.h" + #include "v1_0/itvservice_audio.h" + #include "v1_0/tvservice_audio_types.h" + #include + + #include + #include + #include + #include "hdf_sbuf.h" + + + namespace OHOS { + namespace HDI { + namespace Tvservice { + namespace Audio { + namespace V1_0 { + class TvserviceAudioService : public ITvserviceAudio { + public: + TvserviceAudioService(); + virtual ~TvserviceAudioService(); + + int32_t AmpInit() override; + int32_t AmpControllerSetMute(bool isMute) override; + int32_t SetInternalMining(bool isInit) override; + int32_t AmpControllerGetMute(bool& isMute) override; + int32_t AmpControllerCheckAllValid(uint32_t num) override; + int32_t AmpControllerCheckValid(bool &status) override; + int32_t SetManagerHalType(AudioControllerType type) override; + int32_t ResetManagerHalType() override; + int32_t AudioControllerCreate(AoutAudioInputType source) override; + int32_t AudioControllerStart(AudioTrackType m_trackType) override; + int32_t AudioControllerStop() override; + int32_t AudioControllerDestroy() override; + int32_t SetSource(AoutAudioInputType source) override; + int32_t SetAiEnable(bool enable) override; + int32_t GetDelay(uint32_t& delayMs) override; + int32_t SetAiDelay(uint32_t aiDelay) override; + int32_t GetSinkDelay(uint32_t& sinkDelay) override; + int32_t GetAoutAudioInputType(AoutAudioInputType& m_source) override; + int32_t GetTrackWeight(uint32_t handle, TrackGainAttr& gainAttr) override; + int32_t SetTrackWeight(uint32_t handle, const TrackGainAttr& gainAttr) override; + int32_t SetSourceMute(TrackSourceType trackSource, bool sourceMute) override; + int32_t GetStreamInfo(AcodecStreamInfo& acodecStreamInfo) override; + int32_t SetTrackAttr(uint32_t trackHandle, const AudioTrackAttr& trackAttr) override; + int32_t GetTrackAttr(uint32_t trackHandle, AudioTrackAttr& trackAttr) override; + int32_t SetTrackChannelMode(TrackChannelModeType mode) override; + int32_t GetTrackInfo(OutDeviceTrackInfo& trackInfo) override; + int32_t GetTrackHandle(uint32_t& handle) override; + int32_t SetSourceVolumeByPid(const AudioSourceInfo& info) override; + int32_t GetSourceVolumeByPid(AudioSourceInfo& info) override; + int32_t SetSourceMuteByPid(const AudioSourceInfo& info) override; + int32_t GetSourceMuteByPid(AudioSourceInfo& info) override; + int32_t GetDefAttr(AudioOutDeviceAttr& attr) override; + int32_t AudioPortControllerOpen(const AudioOutDeviceAttr& attr, const std::vector& prescaler) override; + int32_t AudioPortControllerSetMute(AoutDeviceType type, bool isMute) override; + int32_t SetArcCap(const ArcCap& arcCap) override; + int32_t SetArcMode(SoundArcModeType arcMode) override; + int32_t SetArcEnable(bool isArcEnable) override; + int32_t SetSpdifEnable(bool isSpdifEnable) override; + int32_t SetSpdifMode(SoundSpdifModeType spdifMode) override; + int32_t GetSpdifMode(SoundSpdifModeType& spdifMode) override; + int32_t SetSinkDelay(uint32_t delay) override; + int32_t SetAllCastMute(bool isMute) override; + int32_t SetPrecisionVol(AoutDeviceType deviceType, const SoundPreciGainAttr& gainAttr) override; + int32_t SetLowlatencyVolume(AoutDeviceType deviceType, uint32_t volumeIndex) override; + int32_t SetAvDecTypeSupport(AvDecType type, bool enable) override; + int32_t GetChipDecoderCap(ChipDecoderCap &chipCap)override; + int32_t SetOutPortDelay(AoutDeviceType type, uint32_t delayMs) override; + int32_t GetOutPortDelay(AoutDeviceType type, uint32_t& delayMs) override; + int32_t SetUserMute(bool userMute) override; + int32_t HdmiAudioControllerRun() override; + int32_t GetDolbyStreamType(AudioStreamType& audioStreamType, uint32_t& value) override; + int32_t GetDtsStreamType(AudioStreamType& audioStreamType, uint32_t& value) override; + int32_t GetAudioInfo(HdmiAudioAttr& hdmiAudioInfo) override; + int32_t GetAudioStatus(SignalStatus& signalState) override; + int32_t IsOnlySupportPassthrough(int32_t adecType, bool& onlySupport) override; + int32_t MicInit() override; + int32_t MicControllerCheckAllValid(uint32_t num) override; + int32_t MicControllerCheckValid(bool &status) override; + int32_t CreateAefObj(int32_t id) override; + int32_t DeleteAefObj(int32_t id) override; + int32_t SetAefEnable(bool enable) override; + int32_t GetAefEnable(bool &enable) override; + int32_t SetAefVolume(const AefBufferType& buf) override; + int32_t SetAefTuning(const AefBufferType& buf) override; + int32_t SetAefConfig(const AefBufferType& buf) override; + int32_t SetAefCustom(const AefBufferType& buf) override; + int32_t GetAefParamsSum(std::vector& checkSumList) override; + int32_t SetSubwooferAef(bool isSubwooferAef) override; + int32_t SetAVCThreshold(const int32_t avcThreshold) override; + int32_t GetAVCThreshold(int32_t &avcThreshold) override; + int32_t SetOverModulation(const int32_t overModulation) override; + int32_t GetOverModulation(int32_t &overModulation) override; + + private: + int32_t LoadVdiSo(); + int32_t LoadVdiV1_0(); + + private: + /* Common */ + void* libHandle_; + std::mutex mutex_; + + /* V1_0, which is the version of vdi */ + TvserviceAudioVdi* vdiImpl_; + DestroyAudioVdiFunc destroyVdiFunc_; + }; + } // V1_0 + } // Audio + } // Tvservice + } // HDI + } // OHOS + #endif // OHOS_HDI_TVSERVICE_AUDIO_H \ No newline at end of file diff --git a/tvservice/audio/interfaces/hdi_service/include/tvservice_audio_vdi.h b/tvservice/audio/interfaces/hdi_service/include/tvservice_audio_vdi.h new file mode 100644 index 0000000000000000000000000000000000000000..aab564b205721a7e925c0225aa8b2abe39caf6e0 --- /dev/null +++ b/tvservice/audio/interfaces/hdi_service/include/tvservice_audio_vdi.h @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2025 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. + */ + + #ifndef OHOS_HDI_TVSERVICE_AUDIO_VDI_H + #define OHOS_HDI_TVSERVICE_AUDIO_VDI_H + + #include + #include + #include "v1_0/itvservice_audio.h" + #include "v1_0/tvservice_audio_types.h" + + namespace OHOS { + namespace HDI { + namespace Tvservice { + namespace Audio { + namespace V1_0 { + using namespace OHOS::HDI::Tvservice::Audio::V1_0; + + #define TVSERVICE_AUDIO_VDI_LIBRARY "libtvservice_audio_vdi_impl_default.z.so" + + class TvserviceAudioVdi { + public: + virtual ~TvserviceAudioVdi() = default; + + virtual int32_t AmpInit() = 0; + virtual int32_t AmpControllerSetMute(bool isMute) = 0; + virtual int32_t SetInternalMining(bool isInit) = 0; + virtual int32_t AmpControllerGetMute(bool& isMute) = 0; + virtual int32_t AmpControllerCheckAllValid(uint32_t num) = 0; + virtual int32_t AmpControllerCheckValid(bool &status) = 0; + virtual int32_t SetManagerHalType(AudioControllerType type) = 0; + virtual int32_t ResetManagerHalType() = 0; + virtual int32_t AudioControllerCreate(AoutAudioInputType source) = 0; + virtual int32_t AudioControllerStart(AudioTrackType m_trackType) = 0; + virtual int32_t AudioControllerStop() = 0; + virtual int32_t AudioControllerDestroy() = 0; + virtual int32_t SetSource(AoutAudioInputType source) = 0; + virtual int32_t SetAiEnable(bool enable) = 0; + virtual int32_t GetDelay(uint32_t& delayMs) = 0; + virtual int32_t SetAiDelay(uint32_t aiDelay) = 0; + virtual int32_t GetSinkDelay(uint32_t& sinkDelay) = 0; + virtual int32_t GetAoutAudioInputType(AoutAudioInputType& m_source) = 0; + virtual int32_t GetTrackWeight(uint32_t handle, TrackGainAttr& gainAttr) = 0; + virtual int32_t SetTrackWeight(uint32_t handle, const TrackGainAttr& gainAttr) = 0; + virtual int32_t SetSourceMute(TrackSourceType trackSource, bool sourceMute) = 0; + virtual int32_t GetStreamInfo(AcodecStreamInfo& acodecStreamInfo) = 0; + virtual int32_t SetTrackAttr(uint32_t trackHandle, const AudioTrackAttr& trackAttr) = 0; + virtual int32_t GetTrackAttr(uint32_t trackHandle, AudioTrackAttr& trackAttr) = 0; + virtual int32_t SetTrackChannelMode(TrackChannelModeType mode) = 0; + virtual int32_t GetTrackInfo(OutDeviceTrackInfo& trackInfo) = 0; + virtual int32_t GetTrackHandle(uint32_t& handle) = 0; + virtual int32_t SetSourceVolumeByPid(const AudioSourceInfo& info) = 0; + virtual int32_t GetSourceVolumeByPid(AudioSourceInfo& info) = 0; + virtual int32_t SetSourceMuteByPid(const AudioSourceInfo& info) = 0; + virtual int32_t GetSourceMuteByPid(AudioSourceInfo& info) = 0; + virtual int32_t GetDefAttr(AudioOutDeviceAttr& attr) = 0; + virtual int32_t AudioPortControllerOpen(const AudioOutDeviceAttr& attr, const std::vector prescaler) = 0; + virtual int32_t AudioPortControllerSetMute(AoutDeviceType type, bool isMute) = 0; + virtual int32_t SetArcCap(const ArcCap& arcCap) = 0; + virtual int32_t SetArcMode(SoundArcModeType arcMode) = 0; + virtual int32_t SetArcEnable(bool isArcEnable) = 0; + virtual int32_t SetSpdifEnable(bool isSpdifEnable) = 0; + virtual int32_t SetSpdifMode(SoundSpdifModeType spdifMode) = 0; + virtual int32_t GetSpdifMode(SoundSpdifModeType& spdifMode) = 0; + virtual int32_t SetSinkDelay(uint32_t delay) = 0; + virtual int32_t SetAllCastMute(bool isMute) = 0; + virtual int32_t SetPrecisionVol(AoutDeviceType deviceType, const SoundPreciGainAttr& gainAttr) = 0; + virtual int32_t SetLowlatencyVolume(AoutDeviceType deviceType, uint32_t volumeIndex) = 0; + virtual int32_t SetAvDecTypeSupport(AvDecType type, bool enable) = 0; + virtual int32_t GetChipDecoderCap(ChipDecoderCap &chipCap) = 0; + virtual int32_t SetOutPortDelay(AoutDeviceType type, uint32_t delayMs) = 0; + virtual int32_t GetOutPortDelay(AoutDeviceType type, uint32_t& delayMs) = 0; + virtual int32_t SetUserMute(bool userMute) = 0; + virtual int32_t HdmiAudioControllerRun() = 0; + virtual int32_t GetDolbyStreamType(AudioStreamType& audioStreamType, uint32_t& value) = 0; + virtual int32_t GetDtsStreamType(AudioStreamType& audioStreamType, uint32_t& value) = 0; + virtual int32_t GetAudioInfo(HdmiAudioAttr& hdmiAudioInfo) = 0; + virtual int32_t GetAudioStatus(SignalStatus& signalState) = 0; + virtual int32_t IsOnlySupportPassthrough(int32_t adecType, bool& onlySupport) = 0; + virtual int32_t MicInit() = 0; + virtual int32_t MicControllerCheckAllValid(uint32_t num) = 0; + virtual int32_t MicControllerCheckValid(bool &status) = 0; + virtual int32_t CreateAefObj(int32_t id) = 0; + virtual int32_t DeleteAefObj(int32_t id) = 0; + virtual int32_t SetAefEnable(bool enable) = 0; + virtual int32_t GetAefEnable(bool &enable) = 0; + virtual int32_t SetAefVolume(const AefBufferType& buf) = 0; + virtual int32_t SetAefTuning(const AefBufferType& buf) = 0; + virtual int32_t SetAefConfig(const AefBufferType& buf) = 0; + virtual int32_t SetAefCustom(const AefBufferType& buf) = 0; + virtual int32_t GetAefParamsSum(std::vector& checkSumList) = 0; + virtual int32_t SetSubwooferAef(bool isSubwooferAef) = 0; + virtual int32_t SetAVCThreshold(const int32_t avcThreshold) = 0; + virtual int32_t GetAVCThreshold(int32_t &avcThreshold) = 0; + virtual int32_t SetOverModulation(const int32_t overModulation) = 0; + virtual int32_t GetOverModulation(int32_t &overModulation) = 0; + + }; + + using CreateAudioVdiFunc = TvserviceAudioVdi* (*)(); + using DestroyAudioVdiFunc = void (*)(TvserviceAudioVdi* vdi); + extern "C" TvserviceAudioVdi* CreateAudioVdi(); + extern "C" void DestroyAudioVdi(TvserviceAudioVdi* vdi); + } // namespace V1_0 + } // namespace Audio + } // namespace Tvservice + } // namespace HDI + } // namespace OHOS + #endif // OHOS_HDI_TVSERVICE_AUDIO_VDI_H \ No newline at end of file diff --git a/tvservice/audio/interfaces/hdi_service/src/tvservice_audio_driver.cpp b/tvservice/audio/interfaces/hdi_service/src/tvservice_audio_driver.cpp new file mode 100644 index 0000000000000000000000000000000000000000..be9229719c78d8c1767c6bdd2adced153f976860 --- /dev/null +++ b/tvservice/audio/interfaces/hdi_service/src/tvservice_audio_driver.cpp @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2025 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 + #include "v1_0/tvservice_audio_stub.h" + + #define HDF_LOG_TAG TvserviceAudioDriver + + struct HdfTvserviceAudioHost { + struct IDeviceIoService ioService; + OHOS::sptr stub; + }; + + static pthread_rwlock_t g_rwLock = PTHREAD_RWLOCK_INITIALIZER; + static bool g_stop = true; + + static int32_t TvserviceAudioDriverDispatch(struct HdfDeviceIoClient *client, int cmdId, struct HdfSBuf *data, + struct HdfSBuf *reply) + { + HDF_LOGI("TvserviceAudioDriverDispatch enter"); + + if ((client == nullptr) || (client->device == nullptr)) { + HDF_LOGE("%{public}s: param is nullptr", __func__); + return HDF_ERR_INVALID_PARAM; + } + + OHOS::MessageParcel* dataParcel = nullptr; + OHOS::MessageParcel* replyParcel = nullptr; + OHOS::MessageOption option; + + if (SbufToParcel(data, &dataParcel) != HDF_SUCCESS) { + HDF_LOGE("%{public}s:invalid data sbuf object to dispatch", __func__); + return HDF_ERR_INVALID_PARAM; + } + if (SbufToParcel(reply, &replyParcel) != HDF_SUCCESS) { + HDF_LOGE("%{public}s:invalid reply sbuf object to dispatch", __func__); + return HDF_ERR_INVALID_PARAM; + } + + pthread_rwlock_rdlock(&g_rwLock); + auto* hdfTvserviceAudioHost = CONTAINER_OF(client->device->service, struct HdfTvserviceAudioHost, ioService); + if (hdfTvserviceAudioHost == nullptr || g_stop) { + pthread_rwlock_unlock(&g_rwLock); + HDF_LOGE("%{public}s:hdfTvserviceAudioHost nullptr, stop: %{public}d", __func__, g_stop); + return HDF_FAILURE; + } + + HDF_LOGI("TvserviceAudioDriverDispatch cmdId:%{public}d", cmdId); + int32_t ret = hdfTvserviceAudioHost->stub->SendRequest(cmdId, *dataParcel, *replyParcel, option); + pthread_rwlock_unlock(&g_rwLock); + HDF_LOGI("TvserviceAudioDriverDispatch ret:%{public}d", ret); + return ret; + } + + static int HdfTvserviceAudioDriverInit([[maybe_unused]] struct HdfDeviceObject *deviceObject) + { + HDF_LOGI("HdfTvserviceAudioDriverInit enter"); + return HDF_SUCCESS; + } + + static int HdfTvserviceAudioDriverBind(struct HdfDeviceObject *deviceObject) + { + HDF_LOGI("HdfTvserviceAudioDriverBind enter"); + static auto* hdfTvserviceAudioHost = new (std::nothrow) HdfTvserviceAudioHost; + if (hdfTvserviceAudioHost == nullptr) { + HDF_LOGE("%{public}s: failed to create hdfTvserviceAudioHost object", __func__); + return HDF_FAILURE; + } + + hdfTvserviceAudioHost->ioService.Dispatch = TvserviceAudioDriverDispatch; + hdfTvserviceAudioHost->ioService.Open = NULL; + hdfTvserviceAudioHost->ioService.Release = NULL; + + auto serviceImpl = OHOS::HDI::Tvservice::Audio::V1_0::ITvserviceAudio::Get(true); + if (serviceImpl == nullptr) { + HDF_LOGE("%{public}s: failed to get the implement of service", __func__); + delete hdfTvserviceAudioHost; + return HDF_FAILURE; + } + + hdfTvserviceAudioHost->stub = OHOS::HDI::ObjectCollector::GetInstance().GetOrNewObject(serviceImpl, + OHOS::HDI::Tvservice::Audio::V1_0::ITvserviceAudio::GetDescriptor()); + if (hdfTvserviceAudioHost->stub == nullptr) { + HDF_LOGE("%{public}s: failed to get stub object", __func__); + delete hdfTvserviceAudioHost; + return HDF_FAILURE; + } + deviceObject->service = &hdfTvserviceAudioHost->ioService; + g_stop = false; + HDF_LOGI("HdfTvserviceAudioDriverBind HDF_SUCCESS"); + return HDF_SUCCESS; + } + + static void HdfTvserviceAudioDriverRelease(struct HdfDeviceObject *deviceObject) + { + HDF_LOGI("HdfTvserviceAudioDriverRelease enter"); + } + + static struct HdfDriverEntry g_tvserviceaudioDriverEntry = { + .moduleVersion = 1, + .moduleName = "tvservice_audio_service", + .Bind = HdfTvserviceAudioDriverBind, + .Init = HdfTvserviceAudioDriverInit, + .Release = HdfTvserviceAudioDriverRelease, + }; + + #ifdef __cplusplus + extern "C" { + #endif /* __cplusplus */ + HDF_INIT(g_tvserviceaudioDriverEntry); + #ifdef __cplusplus + } + #endif /* __cplusplus */ \ No newline at end of file diff --git a/tvservice/audio/interfaces/hdi_service/src/tvservice_audio_service.cpp b/tvservice/audio/interfaces/hdi_service/src/tvservice_audio_service.cpp new file mode 100644 index 0000000000000000000000000000000000000000..22b1497a4c6cfcd2f67aa8c38dc2870376be5aa2 --- /dev/null +++ b/tvservice/audio/interfaces/hdi_service/src/tvservice_audio_service.cpp @@ -0,0 +1,829 @@ +/* + * Copyright (c) 2025 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 "tvservice_audio_service.h" + #include "tvservice_audio_vdi.h" + #include + #include + #include + #include + #include + #include + #include "osal_mem.h" + #define HDF_LOG_TAG TvserviceAudioImpl + + namespace OHOS { + namespace HDI { + namespace Tvservice { + namespace Audio { + namespace V1_0 { + extern "C" ITvserviceAudio* TvserviceAudioImplGetInstance(void) + { + return new (std::nothrow) TvserviceAudioService(); + } + + TvserviceAudioService::TvserviceAudioService() + : libHandle_(nullptr), + vdiImpl_(nullptr) + { + int32_t ret = LoadVdiSo(); + if (ret != HDF_SUCCESS) { + HDF_LOGE("Load tvservice audio VDI failed, lib: %{public}s", TVSERVICE_AUDIO_VDI_LIBRARY); + return; + } + + ret = LoadVdiV1_0(); + + if (ret != HDF_SUCCESS) { + dlclose(libHandle_); + libHandle_ = nullptr; + HDF_LOGE("Load tvservice audio VDI function failed"); + } + } + + TvserviceAudioService::~TvserviceAudioService() + { + } + + int32_t TvserviceAudioService::LoadVdiSo() + { + const char* errStr = dlerror(); + if (errStr != nullptr) { + HDF_LOGE("audio load vdi, clear earlier dlerror: %{public}s", errStr); + } + libHandle_ = dlopen(TVSERVICE_AUDIO_VDI_LIBRARY, RTLD_LAZY); + if (libHandle_ == nullptr) { + HDF_LOGE("audio load vendor vdi default library failed: %{public}s", + TVSERVICE_AUDIO_VDI_LIBRARY); + + } else { + HDF_LOGI("audio load vendor vdi default library: %{public}s", TVSERVICE_AUDIO_VDI_LIBRARY); + } + + return HDF_SUCCESS; + } + + int32_t TvserviceAudioService::LoadVdiV1_0() + { + CreateAudioVdiFunc createVdiFunc = nullptr; + const char* errStr = nullptr; + + createVdiFunc = reinterpret_cast(dlsym(libHandle_, "CreateAudioVdi")); + if (createVdiFunc == nullptr) { + errStr = dlerror(); + if (errStr != nullptr) { + HDF_LOGE("CreateAudioVdiFunc dlsym error: %{public}s", errStr); + } + return HDF_FAILURE; + } + + destroyVdiFunc_ = reinterpret_cast(dlsym(libHandle_, "DestroyAudioVdi")); + if (destroyVdiFunc_ == nullptr) { + errStr = dlerror(); + if (errStr != nullptr) { + HDF_LOGE("DestroyAudioVdiFunc dlsym error: %{public}s", errStr); + } + return HDF_FAILURE; + } + + vdiImpl_ = createVdiFunc(); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioService::AmpInit() + { + HDF_LOGE("enter %s", __func__); + if(vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->AmpInit(); + } + + int32_t TvserviceAudioService::AmpControllerSetMute(bool isMute) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->AmpControllerSetMute(isMute); + } + + int32_t TvserviceAudioService::SetInternalMining(bool isInit) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->SetInternalMining(isInit); + } + + int32_t TvserviceAudioService::AmpControllerGetMute(bool& isMute) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->AmpControllerGetMute(isMute); + } + + int32_t TvserviceAudioService::AmpControllerCheckAllValid(uint32_t num) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->AmpControllerCheckAllValid(num); + } + + int32_t TvserviceAudioService::AmpControllerCheckValid(bool &status) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->AmpControllerCheckValid(status); + } + + int32_t TvserviceAudioService::SetManagerHalType(AudioControllerType type) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->SetManagerHalType(type); + } + + int32_t TvserviceAudioService::ResetManagerHalType() + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->ResetManagerHalType(); + } + + int32_t TvserviceAudioService::AudioControllerCreate(AoutAudioInputType source) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->AudioControllerCreate(source); + } + + int32_t TvserviceAudioService::AudioControllerStart(AudioTrackType m_trackType) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->AudioControllerStart(m_trackType); + } + + int32_t TvserviceAudioService::AudioControllerStop() + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->AudioControllerStop(); + } + + int32_t TvserviceAudioService::AudioControllerDestroy() + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->AudioControllerDestroy(); + } + + int32_t TvserviceAudioService::SetSource(AoutAudioInputType source) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->SetSource(source); + } + + int32_t TvserviceAudioService::SetAiEnable(bool enable) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->SetAiEnable(enable); + } + + int32_t TvserviceAudioService::GetDelay(uint32_t& delayMs) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->GetDelay(delayMs); + } + + int32_t TvserviceAudioService::SetAiDelay(uint32_t aiDelay) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->SetAiDelay(aiDelay); + } + + int32_t TvserviceAudioService::GetSinkDelay(uint32_t& sinkDelay) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->GetSinkDelay(sinkDelay); + } + + int32_t TvserviceAudioService::GetAoutAudioInputType(AoutAudioInputType& m_source) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->GetAoutAudioInputType(m_source); + } + + int32_t TvserviceAudioService::GetTrackWeight(uint32_t handle, TrackGainAttr& gainAttr) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->GetTrackWeight(handle, gainAttr); + } + + int32_t TvserviceAudioService::SetTrackWeight(uint32_t handle, const TrackGainAttr& gainAttr) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->SetTrackWeight(handle, gainAttr); + } + + int32_t TvserviceAudioService::SetSourceMute(TrackSourceType trackSource, bool sourceMute) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->SetSourceMute(trackSource, sourceMute); + } + + int32_t TvserviceAudioService::GetStreamInfo(AcodecStreamInfo& acodecStreamInfo) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->GetStreamInfo(acodecStreamInfo); + } + + int32_t TvserviceAudioService::SetTrackAttr(uint32_t trackHandle, const AudioTrackAttr& trackAttr) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->SetTrackAttr(trackHandle, trackAttr); + } + + int32_t TvserviceAudioService::GetTrackAttr(uint32_t trackHandle, AudioTrackAttr& trackAttr) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->GetTrackAttr(trackHandle, trackAttr); + } + + int32_t TvserviceAudioService::SetTrackChannelMode(TrackChannelModeType mode) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->SetTrackChannelMode(mode); + } + + int32_t TvserviceAudioService::GetTrackInfo(OutDeviceTrackInfo& trackInfo) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->GetTrackInfo(trackInfo); + } + + int32_t TvserviceAudioService::GetTrackHandle(uint32_t& handle) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->GetTrackHandle(handle); + } + + int32_t TvserviceAudioService::SetSourceVolumeByPid(const AudioSourceInfo& info) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->SetSourceVolumeByPid(info); + } + + int32_t TvserviceAudioService::GetSourceVolumeByPid(AudioSourceInfo& info) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->GetSourceVolumeByPid(info); + } + + int32_t TvserviceAudioService::SetSourceMuteByPid(const AudioSourceInfo& info) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->SetSourceMuteByPid(info); + } + + int32_t TvserviceAudioService::GetSourceMuteByPid(AudioSourceInfo& info) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->GetSourceMuteByPid(info); + } + + int32_t TvserviceAudioService::GetDefAttr(AudioOutDeviceAttr& attr) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->GetDefAttr(attr); + } + + int32_t TvserviceAudioService::AudioPortControllerOpen(const AudioOutDeviceAttr& attr, const std::vector& prescaler) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->AudioPortControllerOpen(attr, prescaler); + } + + int32_t TvserviceAudioService::AudioPortControllerSetMute(AoutDeviceType type, bool isMute) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->AudioPortControllerSetMute(type, isMute); + } + + int32_t TvserviceAudioService::SetArcCap(const ArcCap& arcCap) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->SetArcCap(arcCap); + } + + int32_t TvserviceAudioService::SetArcMode(SoundArcModeType arcMode) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->SetArcMode(arcMode); + } + + int32_t TvserviceAudioService::SetArcEnable(bool isArcEnable) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->SetArcEnable(isArcEnable); + } + + int32_t TvserviceAudioService::SetSpdifEnable(bool isSpdifEnable) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->SetSpdifEnable(isSpdifEnable); + } + + int32_t TvserviceAudioService::SetSpdifMode(SoundSpdifModeType spdifMode) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->SetSpdifMode(spdifMode); + } + + int32_t TvserviceAudioService::GetSpdifMode(SoundSpdifModeType& spdifMode) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->GetSpdifMode(spdifMode); + } + + int32_t TvserviceAudioService::SetSinkDelay(uint32_t delay) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->SetSinkDelay(delay); + } + + int32_t TvserviceAudioService::SetAllCastMute(bool isMute) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->SetAllCastMute(isMute); + } + + int32_t TvserviceAudioService::SetPrecisionVol(AoutDeviceType deviceType, const SoundPreciGainAttr& gainAttr) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->SetPrecisionVol(deviceType, gainAttr); + } + + int32_t TvserviceAudioService::SetLowlatencyVolume(AoutDeviceType deviceType, uint32_t volumeIndex) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->SetLowlatencyVolume(deviceType, volumeIndex); + } + + int32_t TvserviceAudioService::SetAvDecTypeSupport(AvDecType type, bool enable) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->SetAvDecTypeSupport(type, enable); + } + + int32_t TvserviceAudioService::GetChipDecoderCap(ChipDecoderCap &chipCap) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->GetChipDecoderCap(chipCap); + } + + int32_t TvserviceAudioService::SetOutPortDelay(AoutDeviceType type, uint32_t delayMs) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->SetOutPortDelay(type, delayMs); + } + + int32_t TvserviceAudioService::GetOutPortDelay(AoutDeviceType type, uint32_t& delayMs) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->GetOutPortDelay(type, delayMs); + } + + int32_t TvserviceAudioService::SetUserMute(bool userMute) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->SetUserMute(userMute); + } + + int32_t TvserviceAudioService::HdmiAudioControllerRun() + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->HdmiAudioControllerRun(); + } + + int32_t TvserviceAudioService::GetDolbyStreamType(AudioStreamType& audioStreamType, uint32_t& value) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->GetDolbyStreamType(audioStreamType, value); + } + + int32_t TvserviceAudioService::GetDtsStreamType(AudioStreamType& audioStreamType, uint32_t& value) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->GetDtsStreamType(audioStreamType, value); + } + + int32_t TvserviceAudioService::GetAudioInfo(HdmiAudioAttr& hdmiAudioInfo) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->GetAudioInfo(hdmiAudioInfo); + } + + int32_t TvserviceAudioService::GetAudioStatus(SignalStatus& signalState) + { + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->GetAudioStatus(signalState); + } + +int32_t TvserviceAudioService::IsOnlySupportPassthrough(int32_t adecType, bool& onlySupport) +{ + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->IsOnlySupportPassthrough(adecType, onlySupport); +} + +int32_t TvserviceAudioService::MicInit() +{ + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->MicInit(); +} + +int32_t TvserviceAudioService::MicControllerCheckAllValid(uint32_t num) +{ + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->MicControllerCheckAllValid(num); +} + +int32_t TvserviceAudioService::MicControllerCheckValid(bool &status) +{ + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGI("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->MicControllerCheckValid(status); +} + +int32_t TvserviceAudioService::CreateAefObj(int32_t id) +{ + HDF_LOGI("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->CreateAefObj(id); +} + +int32_t TvserviceAudioService::DeleteAefObj(int32_t id) +{ + HDF_LOGI("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->DeleteAefObj(id); +} + +int32_t TvserviceAudioService::SetAefEnable(bool enable) +{ + HDF_LOGI("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->SetAefEnable(enable); +} + +int32_t TvserviceAudioService::GetAefEnable(bool& enable) +{ + HDF_LOGI("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->GetAefEnable(enable); +} + +int32_t TvserviceAudioService::SetAefVolume(const AefBufferType& buf) +{ + HDF_LOGI("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->SetAefVolume(buf); +} + +int32_t TvserviceAudioService::SetAefTuning(const AefBufferType& buf) +{ + HDF_LOGI("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->SetAefTuning(buf); +} + +int32_t TvserviceAudioService::SetAefConfig(const AefBufferType& buf) +{ + HDF_LOGI("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->SetAefConfig(buf); +} + +int32_t TvserviceAudioService::SetAefCustom(const AefBufferType& buf) +{ + HDF_LOGI("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->SetAefCustom(buf); +} + +int32_t TvserviceAudioService::GetAefParamsSum(std::vector& checkSumList) +{ + HDF_LOGI("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->GetAefParamsSum(checkSumList); +} + +int32_t TvserviceAudioService::SetSubwooferAef(bool isSubwooferAef) +{ + HDF_LOGI("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->SetSubwooferAef(isSubwooferAef); +} + +int32_t TvserviceAudioService::SetAVCThreshold(const int32_t avcThreshold) +{ + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->SetAVCThreshold(avcThreshold); +} + +int32_t TvserviceAudioService::GetAVCThreshold(int32_t &avcThreshold) +{ + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->GetAVCThreshold(avcThreshold); +} + +int32_t TvserviceAudioService::SetOverModulation(const int32_t overModulation) +{ + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->SetOverModulation(overModulation); +} + +int32_t TvserviceAudioService::GetOverModulation(int32_t &overModulation) +{ + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->GetOverModulation(overModulation); +} + + } // v1_0 + } // Audio + } // Tvservice + } // HDI + } // OHOS \ No newline at end of file diff --git a/tvservice/audio/interfaces/vdi_base/BUILD.gn b/tvservice/audio/interfaces/vdi_base/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..dc64c2665a1af04b21ec5a421035caa9d003f502 --- /dev/null +++ b/tvservice/audio/interfaces/vdi_base/BUILD.gn @@ -0,0 +1,49 @@ +# Copyright (C) 2025 HiHope Open Source Organization . +# 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. + +import("//build/ohos.gni") +import("../../../tvservice.gni") +import("//vendor/${product_company}/${product_name}/product.gni") + +ohos_shared_library("tvservice_audio_vdi_impl_default") { + defines = [] + sources = [ + "src/tvservice_audio_vdi_impl.cpp", + ] + output_name = "tvservice_audio_vdi_impl_default" + include_dirs = [ + "include", + "../hdi_service/include", + "../../utils/include", + ] + cflags_cc = [ + "-fPIC", + "-Wall", + "-Wno-error=unused-function", + "-Wno-error=missing-braces", + "-Wno-error=#warnings", + ] + external_deps = [ + "c_utils:utils", + "drivers_interface_tvservice:libtvservice_audio_stub_1.0", + "drivers_interface_tvservice:libtvservice_audio_proxy_1.0", + "hdf_core:libhdf_utils", + "hilog:libhilog", + "hitrace:hitrace_meter", + "ipc:ipc_single", + ] + install_enable = true + install_images = [ chipset_base_dir ] + subsystem_name = "hdf" + part_name = "drivers_peripheral_tvservice" +} \ No newline at end of file diff --git a/tvservice/audio/interfaces/vdi_base/include/tvservice_audio_vdi_impl.h b/tvservice/audio/interfaces/vdi_base/include/tvservice_audio_vdi_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..f6c1748cf5035cfe524df5b6782ef81f8aa36820 --- /dev/null +++ b/tvservice/audio/interfaces/vdi_base/include/tvservice_audio_vdi_impl.h @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2025 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. + */ + + #ifndef TVSERVICE_AUDIO_VDI_IMPL_H + #define TVSERVICE_AUDIO_VDI_IMPL_H + + #include "tvservice_audio_vdi.h" + #include "v1_0/tvservice_audio_types.h" + + namespace OHOS { + namespace HDI { + namespace Tvservice { + namespace Audio { + using namespace OHOS::HDI::Tvservice::Audio; + + class TvserviceAudioVdiImpl : public V1_0::TvserviceAudioVdi { + public: + TvserviceAudioVdiImpl(); + virtual ~TvserviceAudioVdiImpl(); + + int32_t AmpInit() override; + int32_t AmpControllerSetMute(bool isMute) override; + int32_t SetInternalMining(bool isInit) override; + int32_t AmpControllerGetMute(bool& isMute) override; + int32_t AmpControllerCheckAllValid(uint32_t num) override; + int32_t AmpControllerCheckValid(bool &status) override; + int32_t SetManagerHalType(V1_0::AudioControllerType type) override; + int32_t ResetManagerHalType() override; + int32_t AudioControllerCreate(V1_0::AoutAudioInputType source) override; + int32_t AudioControllerStart(V1_0::AudioTrackType m_trackType) override; + int32_t AudioControllerStop() override; + int32_t AudioControllerDestroy() override; + int32_t SetSource(V1_0::AoutAudioInputType source) override; + int32_t SetAiEnable(bool enable) override; + int32_t GetDelay(uint32_t& delayMs) override; + int32_t SetAiDelay(uint32_t aiDelay) override; + int32_t GetSinkDelay(uint32_t& sinkDelay) override; + int32_t GetAoutAudioInputType(V1_0::AoutAudioInputType& m_source) override; + int32_t GetTrackWeight(uint32_t handle, V1_0::TrackGainAttr& gainAttr) override; + int32_t SetTrackWeight(uint32_t handle, const V1_0::TrackGainAttr& gainAttr) override; + int32_t SetSourceMute(V1_0::TrackSourceType trackSource, bool sourceMute) override; + int32_t GetStreamInfo(V1_0::AcodecStreamInfo& acodecStreamInfo) override; + int32_t SetTrackAttr(uint32_t trackHandle, const V1_0::AudioTrackAttr& trackAttr) override; + int32_t GetTrackAttr(uint32_t trackHandle, V1_0::AudioTrackAttr& trackAttr) override; + int32_t SetTrackChannelMode(V1_0::TrackChannelModeType mode) override; + int32_t GetTrackInfo(V1_0::OutDeviceTrackInfo& trackInfo) override; + int32_t GetTrackHandle(uint32_t& handle) override; + int32_t SetSourceVolumeByPid(const V1_0::AudioSourceInfo& info) override; + int32_t GetSourceVolumeByPid(V1_0::AudioSourceInfo& info) override; + int32_t SetSourceMuteByPid(const V1_0::AudioSourceInfo& info) override; + int32_t GetSourceMuteByPid(V1_0::AudioSourceInfo& info) override; + int32_t GetDefAttr(V1_0::AudioOutDeviceAttr& attr) override; + int32_t AudioPortControllerOpen(const V1_0::AudioOutDeviceAttr& attr, const std::vector prescaler) override; + int32_t AudioPortControllerSetMute(V1_0::AoutDeviceType type, bool isMute) override; + int32_t SetArcCap(const V1_0::ArcCap& arcCap) override; + int32_t SetArcMode(V1_0::SoundArcModeType arcMode) override; + int32_t SetArcEnable(bool isArcEnable) override; + int32_t SetSpdifEnable(bool isSpdifEnable) override; + int32_t SetSpdifMode(V1_0::SoundSpdifModeType spdifMode) override; + int32_t GetSpdifMode(V1_0::SoundSpdifModeType& spdifMode) override; + int32_t SetSinkDelay(uint32_t delay) override; + int32_t SetAllCastMute(bool isMute) override; + int32_t SetPrecisionVol(V1_0::AoutDeviceType deviceType, const V1_0::SoundPreciGainAttr& gainAttr) override; + int32_t SetLowlatencyVolume(V1_0::AoutDeviceType deviceType, uint32_t volumeIndex) override; + int32_t SetAvDecTypeSupport(V1_0::AvDecType type, bool enable) override; + int32_t GetChipDecoderCap(V1_0::ChipDecoderCap &chipCap) override; + int32_t SetOutPortDelay(V1_0::AoutDeviceType type, uint32_t delayMs) override; + int32_t GetOutPortDelay(V1_0::AoutDeviceType type, uint32_t& delayMs) override; + int32_t SetUserMute(bool userMute) override; + int32_t HdmiAudioControllerRun() override; + int32_t GetDolbyStreamType(V1_0::AudioStreamType& audioStreamType, uint32_t& value) override; + int32_t GetDtsStreamType(V1_0::AudioStreamType& audioStreamType, uint32_t& value) override; + int32_t GetAudioInfo(V1_0::HdmiAudioAttr& hdmiAudioInfo) override; + int32_t GetAudioStatus(V1_0::SignalStatus& signalState) override; + int32_t MicInit() override; + int32_t IsOnlySupportPassthrough(int32_t adecType, bool& onlySupport) override; + int32_t MicControllerCheckAllValid(uint32_t num) override; + int32_t MicControllerCheckValid(bool &status) override; + int32_t CreateAefObj(int32_t id) override; + int32_t DeleteAefObj(int32_t id) override; + int32_t SetAefEnable(bool enable) override; + int32_t GetAefEnable(bool &enable) override; + int32_t SetAefVolume(const V1_0::AefBufferType& buf) override; + int32_t SetAefTuning(const V1_0::AefBufferType& buf) override; + int32_t SetAefConfig(const V1_0::AefBufferType& buf) override; + int32_t SetAefCustom(const V1_0::AefBufferType& buf) override; + int32_t GetAefParamsSum(std::vector& checkSumList) override; + int32_t SetSubwooferAef(bool isSubwooferAef) override; + int32_t SetAVCThreshold(const int32_t avcThreshold) override; + int32_t GetAVCThreshold(int32_t &avcThreshold) override; + int32_t SetOverModulation(const int32_t overModulation) override; + int32_t GetOverModulation(int32_t &overModulation) override; + + }; + } // Audio + } // Tvservice + } // HDI + } // OHOS + #endif // TVSERVICE_AUDIO_VDI_IMPL_H diff --git a/tvservice/audio/interfaces/vdi_base/src/tvservice_audio_vdi_impl.cpp b/tvservice/audio/interfaces/vdi_base/src/tvservice_audio_vdi_impl.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e0f00ea52bde2ba8d78d9ada5786aa12e636cb42 --- /dev/null +++ b/tvservice/audio/interfaces/vdi_base/src/tvservice_audio_vdi_impl.cpp @@ -0,0 +1,484 @@ +/* + * Copyright (c) 2025 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 "tvservice_audio_vdi_impl.h" + #include + #include "tvservice_audio_hdf_log.h" + #include "hdf_log.h" + + #include + #include + #include + #include "securec.h" + + namespace OHOS { + namespace HDI { + namespace Tvservice { + namespace Audio { + + TvserviceAudioVdiImpl::TvserviceAudioVdiImpl() + { + } + + TvserviceAudioVdiImpl::~TvserviceAudioVdiImpl() + { + } + + + int32_t TvserviceAudioVdiImpl::AmpInit() + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::AmpControllerSetMute(bool isMute) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::SetInternalMining(bool isInit) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::AmpControllerGetMute(bool& isMute) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::AmpControllerCheckAllValid(uint32_t num) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::AmpControllerCheckValid(bool &status) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::SetManagerHalType(V1_0::AudioControllerType type) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::ResetManagerHalType() + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::AudioControllerCreate(V1_0::AoutAudioInputType source) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::AudioControllerStart(V1_0::AudioTrackType m_trackType) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::AudioControllerStop() + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::AudioControllerDestroy() + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::SetSource(V1_0::AoutAudioInputType source) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::SetAiEnable(bool enable) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::GetDelay(uint32_t& delayMs) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::SetAiDelay(uint32_t aiDelay) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::GetSinkDelay(uint32_t& sinkDelay) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::GetAoutAudioInputType(V1_0::AoutAudioInputType& m_source) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::GetTrackWeight(uint32_t handle, V1_0::TrackGainAttr& gainAttr) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::SetTrackWeight(uint32_t handle, const V1_0::TrackGainAttr& gainAttr) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::SetSourceMute(V1_0::TrackSourceType trackSource, bool sourceMute) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::GetStreamInfo(V1_0::AcodecStreamInfo& acodecStreamInfo) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::SetTrackAttr(uint32_t trackHandle, const V1_0::AudioTrackAttr& trackAttr) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::GetTrackAttr(uint32_t trackHandle, V1_0::AudioTrackAttr& trackAttr) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::SetTrackChannelMode(V1_0::TrackChannelModeType mode) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS;; + } + + int32_t TvserviceAudioVdiImpl::GetTrackInfo(V1_0::OutDeviceTrackInfo& trackInfo) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::GetTrackHandle(uint32_t& handle) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::SetSourceVolumeByPid(const V1_0::AudioSourceInfo& info) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::GetSourceVolumeByPid(V1_0::AudioSourceInfo& info) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::SetSourceMuteByPid(const V1_0::AudioSourceInfo& info) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::GetSourceMuteByPid(V1_0::AudioSourceInfo& info) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::GetDefAttr(V1_0::AudioOutDeviceAttr& attr) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::AudioPortControllerOpen(const V1_0::AudioOutDeviceAttr& attr, const std::vector prescaler) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::AudioPortControllerSetMute(V1_0::AoutDeviceType type, bool isMute) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::SetArcCap(const V1_0::ArcCap& arcCap) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::SetArcMode(V1_0::SoundArcModeType arcMode) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::SetArcEnable(bool isArcEnable) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::SetSpdifEnable(bool isSpdifEnable) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::SetSpdifMode(V1_0::SoundSpdifModeType spdifMode) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::GetSpdifMode(V1_0::SoundSpdifModeType& spdifMode) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::SetSinkDelay(uint32_t delay) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::SetAllCastMute(bool isMute) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::SetPrecisionVol(V1_0::AoutDeviceType deviceType, const V1_0::SoundPreciGainAttr& gainAttr) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::SetLowlatencyVolume(V1_0::AoutDeviceType deviceType, uint32_t volumeIndex) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::SetAvDecTypeSupport(V1_0::AvDecType type, bool enable) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::GetChipDecoderCap(V1_0::ChipDecoderCap &chipCap) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::SetOutPortDelay(V1_0::AoutDeviceType type, uint32_t delayMs) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::GetOutPortDelay(V1_0::AoutDeviceType type, uint32_t& delayMs) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::SetUserMute(bool userMute) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::HdmiAudioControllerRun() + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::GetDolbyStreamType(V1_0::AudioStreamType& audioStreamType, uint32_t& value) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::GetDtsStreamType(V1_0::AudioStreamType& audioStreamType, uint32_t& value) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::GetAudioInfo(V1_0::HdmiAudioAttr& hdmiAudioInfo) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::GetAudioStatus(V1_0::SignalStatus& signalState) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::IsOnlySupportPassthrough(int32_t adecType, bool& onlySupport) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::MicInit() + { + + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::MicControllerCheckAllValid(uint32_t num) + { + + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::MicControllerCheckValid(bool &status) + { + + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::CreateAefObj(int32_t id) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::DeleteAefObj(int32_t id) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::SetAefEnable(bool enable) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::GetAefEnable(bool& enable) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::SetAefVolume(const V1_0::AefBufferType& buf) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::SetAefTuning(const V1_0::AefBufferType& buf) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::SetAefConfig(const V1_0::AefBufferType& buf) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::SetAefCustom(const V1_0::AefBufferType& buf) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::GetAefParamsSum(std::vector& checkSumList) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + + int32_t TvserviceAudioVdiImpl::SetSubwooferAef(bool isSubwooferAef) + { + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; + } + +int32_t TvserviceAudioVdiImpl::SetAVCThreshold(const int32_t avcThreshold) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceAudioVdiImpl::GetAVCThreshold(int32_t &avcThreshold) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceAudioVdiImpl::SetOverModulation(const int32_t overModulation) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceAudioVdiImpl::GetOverModulation(int32_t &overModulation) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + + extern "C" V1_0::TvserviceAudioVdi *CreateAudioVdi() + { + return new TvserviceAudioVdiImpl(); + } + + extern "C" void DestroyAudioVdi(V1_0::TvserviceAudioVdi* vdi) + { + delete vdi; + } + } // Audio + } // Tvservice + } // HDI + } // OHOS \ No newline at end of file diff --git a/tvservice/audio/utils/include/tvservice_audio_hdf_log.h b/tvservice/audio/utils/include/tvservice_audio_hdf_log.h new file mode 100644 index 0000000000000000000000000000000000000000..ac5ebbc0292b6b53ddd793d7e1f81fd1680ab26c --- /dev/null +++ b/tvservice/audio/utils/include/tvservice_audio_hdf_log.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2025 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. + */ + +#ifndef tvservice_video_host_LOG_H +#define tvservice_video_host_LOG_H + +#include "hdf_log.h" + +// #ifdef LOG_DOMAIN +// #undef LOG_DOMAIN +// #endif +// #define LOG_DOMAIN 0xD002511 + +#endif //tvservice_video_host_LOG_H \ No newline at end of file diff --git a/tvservice/bundle.json b/tvservice/bundle.json new file mode 100644 index 0000000000000000000000000000000000000000..e8819ad5d0577e47635ff5be4f3935484a99b37c --- /dev/null +++ b/tvservice/bundle.json @@ -0,0 +1,47 @@ +{ + "name": "@ohos/drivers_peripheral_tvservice", + "description": "tvservice_hdf", + "version": "3.1", + "license": "Apache License 2.0", + "publishAs": "code-segment", + "segment": { + "destPath": "drivers/peripheral/tvservice" + }, + "dirs": {}, + "scripts": {}, + "component": { + "name": "drivers_peripheral_tvservice", + "subsystem": "hdf", + "features": [ + ], + "adapted_system_type": ["standard"], + "rom": "", + "ram": "", + "deps": { + "components": [ + "c_utils", + "config_policy", + "drivers_peripheral_tvservice", + "drivers_interface_tvservice", + "hdf_core", + "hilog", + "hisysevent", + "libxml2", + "ipc", + "hitrace" + ], + "third_party": [ + "jsoncpp" + ] + }, + "build": { + "sub_component": [ + "//drivers/peripheral/tvservice:tvservice_entry" + ], + "test": [ + "//drivers/peripheral/tvservice/test/:hdf_test_dtv" + ], + "inner_kits": [] + } + } +} \ No newline at end of file diff --git a/tvservice/dtv/demux/BUILD.gn b/tvservice/dtv/demux/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..78528eaabd387f2cbbcb85f2a4db1e2c9f0b1bd2 --- /dev/null +++ b/tvservice/dtv/demux/BUILD.gn @@ -0,0 +1,20 @@ +# Copyright (c) 2025 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. +import("//build/ohos.gni") + +print("=============tvservice_dtv_demux_host_entry============") +group("tvservice_dtv_demux_host_entry") { + deps = [ "interfaces/hdi_service:hdf_tvservice_dtv_demux_host"] + # deps += [ "interfaces/vdi_base:tvservice_dtv_demux_vdi_impl_default" ] + # deps += [ "interfaces/vdi_base:tvservice_dtv_demux_vdi_impl_default" ] +} \ No newline at end of file diff --git a/tvservice/dtv/demux/interfaces/hdi_service/BUILD.gn b/tvservice/dtv/demux/interfaces/hdi_service/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..f5cd62e3a90fa3906b536bddae46d426d004c15f --- /dev/null +++ b/tvservice/dtv/demux/interfaces/hdi_service/BUILD.gn @@ -0,0 +1,81 @@ +# Copyright (c) 2025 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. +import("//build/ohos.gni") +import("../../../../tvservice.gni") + +ohos_shared_library("libtvservice_dtv_demux_service_1.0") { + defines = [] + include_dirs = [ + "../../utils/include", + "include" + ] + sources = [ + "src/tvservice_dtv_demux_service.c" + ] + + external_deps = [ + "c_utils:utils", + "hdf_core:libhdf_ipc_adapter", + "hdf_core:libhdi", + "hdf_core:libhdf_host", + "hdf_core:libhdf_utils", + "hilog:libhilog", + "ipc:ipc_single", + "libxml2:libxml2", + "drivers_interface_tvservice:libtvservice_dtv_demux_stub_1.0", + "drivers_interface_tvservice:libtvservice_dtv_demux_proxy_1.0", + ] + + if (has_tvservice_hisysevent_part) { + external_deps += [ "hisysevent:libhisysevent" ] + } + + install_images = [ chipset_base_dir ] + subsystem_name = "hdf" + part_name = "drivers_peripheral_tvservice" +} + +ohos_shared_library("libtvservice_dtv_demux_driver") { + sources = [ + "src/tvservice_dtv_demux_driver.c" + ] + + external_deps = [ + "c_utils:utils", + "hdf_core:libhdf_ipc_adapter", + "hdf_core:libhdi", + "hdf_core:libhdf_host", + "hdf_core:libhdf_utils", + "hilog:libhilog", + "ipc:ipc_single", + "drivers_interface_tvservice:libtvservice_dtv_demux_stub_1.0", + "drivers_interface_tvservice:libtvservice_dtv_demux_proxy_1.0", + ] + if (has_tvservice_c_utils_part) { + external_deps += [ "c_utils:utils" ] + } + + shlib_type = "hdi" + install_images = [ chipset_base_dir ] + subsystem_name = "hdf" + part_name = "drivers_peripheral_tvservice" +} + +group("hdf_tvservice_dtv_demux_host") { + deps = [ + ":libtvservice_dtv_demux_driver", + ":libtvservice_dtv_demux_service_1.0", + ] + +print("=============hdf_tvservice_dtv_demux_host============") +} \ No newline at end of file diff --git a/tvservice/dtv/demux/interfaces/hdi_service/include/tvservice_dtv_demux_vdi.h b/tvservice/dtv/demux/interfaces/hdi_service/include/tvservice_dtv_demux_vdi.h new file mode 100644 index 0000000000000000000000000000000000000000..e8a25626a942062a2b4b1bd9f40154065666efba --- /dev/null +++ b/tvservice/dtv/demux/interfaces/hdi_service/include/tvservice_dtv_demux_vdi.h @@ -0,0 +1,127 @@ +/* +* Copyright (c) 2025 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. +*/ + +#ifndef TVSERVICE_DTV_DEMUX_VDI_H +#define TVSERVICE_DTV_DEMUX_VDI_H + +#include "v1_0/itvservice_dtv_demux.h" +#include "v1_0/tvservice_dtv_demux_types.h" + +#define TVSERVICE_DTV_DEMUX_VDI_LIBRARY "libtvservice_dtv_demux_vdi_impl_default.z.so" + +typedef unsigned char UCHAR; +typedef uint8_t U8; +typedef uint16_t U16; +typedef uint32_t U32; +typedef uint64_t U64; +typedef int32_t S32; +typedef struct DMX_INIT_PARAMS_S DMX_INIT_PARAMS_S; +typedef struct DMX_TERM_PARAM_S DMX_TERM_PARAM_S; +typedef struct DMX_STATUS_S DMX_STATUS_S; +typedef struct DMX_SOURCE_PARAMS_S DMX_SOURCE_PARAMS_S; +typedef struct DMX_CAPABILITY_S DMX_CAPABILITY_S; +typedef struct DMX_CHANNEL_OPEN_PARAM_S DMX_CHANNEL_OPEN_PARAM_S; +typedef struct DMX_CHANNEL_CLOSE_PARAMS_S DMX_CHANNEL_CLOSE_PARAMS_S; +typedef struct DMX_CHANNEL_INFO_S DMX_CHANNEL_INFO_S; +typedef struct DMX_CHANNEL_SETTING_S DMX_CHANNEL_SETTING_S; +typedef struct DMX_FILTER_DATA_S DMX_FILTER_DATA_S; +typedef struct DMX_CHANNEL_DATA_S DMX_CHANNEL_DATA_S; +typedef struct DMX_DESCRAMBLER_ATTR_S DMX_DESCRAMBLER_ATTR_S; +typedef struct DMX_DESC_ASSOCIATE_PARAMS_S DMX_DESC_ASSOCIATE_PARAMS_S; +typedef struct DMX_DCAS_KEYLADDER_SETTING_S DMX_DCAS_KEYLADDER_SETTING_S; +typedef struct DMX_DCAS_NONCE_SETTING_S DMX_DCAS_NONCE_SETTING_S; +typedef struct DMX_PARSER_FILTER_OPEN_PARAM_S DMX_PARSER_FILTER_OPEN_PARAM_S; +typedef struct DMX_ESFRAME_INFO_S DMX_ESFRAME_INFO_S; +typedef struct DMX_TSBUF_ATTR_S DMX_TSBUF_ATTR_S; +typedef struct DMX_STREAM_DATA_S DMX_STREAM_DATA_S; +typedef struct DMX_TSO_PORT_ATTR_S DMX_TSO_PORT_ATTR_S; +typedef enum DMX_ID_E DMX_ID_E; +typedef enum DMX_DESC_ASSOCIATE_MODE_E DMX_DESC_ASSOCIATE_MODE_E; + +struct TvserviceDtvDemuxVdi { + S32 (*dmx_init)(const DMX_INIT_PARAMS_S* const pstInitParams); + S32 (*dmx_term)(const DMX_TERM_PARAM_S* const pstTermParams); + S32 (*dmx_set_source_params)(const DMX_ID_E enDemuxId, const DMX_SOURCE_PARAMS_S* pstSourceParams); + S32 (*dmx_get_source_params)(const DMX_ID_E enDemuxId, DMX_SOURCE_PARAMS_S* const pstSourceParams); + S32 (*dmx_disconnect)(const DMX_ID_E enDemuxId); + S32 (*dmx_reconnect)(const DMX_ID_E enDemuxId); + S32 (*dmx_get_capability)(DMX_CAPABILITY_S* const pstCapability); + S32 (*dmx_get_status)(const DMX_ID_E enDemuxId, DMX_STATUS_S* const pstStatus); + S32 (*dmx_channel_open)(const DMX_ID_E enDemuxId, U32* const pu32ChannelId, const DMX_CHANNEL_OPEN_PARAM_S* const pstOpenParams); + S32 (*dmx_channel_close)(const U32 u32ChannelId, const DMX_CHANNEL_CLOSE_PARAMS_S* pstCloseParams); + S32 (*dmx_channel_set_pid)(const U32 u32ChannelId, const U16 u16Pid); + S32 (*dmx_channel_query)(const DMX_ID_E enDemuxId, U32* const pu32ChannelId, const U16 u16Pid); + S32 (*dmx_channel_enable)(const U32 u32ChannelId); + S32 (*dmx_channel_disable)(const U32 u32ChannelId); + S32 (*dmx_channel_reset)(const U32 u32ChannelId); + S32 (*dmx_channel_get_info)(const U32 u32ChannelId, DMX_CHANNEL_INFO_S* const pstInfo); + S32 (*dmx_channel_set)(const U32 u32ChannelId, const DMX_CHANNEL_SETTING_S* const pstSettings); + S32 (*dmx_channel_get)(const U32 u32ChannelId, DMX_CHANNEL_SETTING_S* const pstSettings); + S32 (*dmx_channel_get_buf)(const U32 u32ChannelId, U32 u32AcquirePackageNum, U32* pu32AcquiredNum, DMX_CHANNEL_DATA_S* pstChannelData, const U32 u32TimeoutMs); + S32 (*dmx_channel_release_buf)(const U32 u32ChannelId, const U32 u32ReleaseNum, DMX_CHANNEL_DATA_S* pstChannelData); + S32 (*dmx_channel_add_filter)(const U32 u32ChannelId, U32* const pu32FilterId, const DMX_FILTER_DATA_S* const pstFilterData); + S32 (*dmx_channel_set_filter)(const U32 u32ChannelId, const U32 u32FilterId, const DMX_FILTER_DATA_S* const pstFilterData); + S32 (*dmx_channel_get_filter)(const U32 u32ChannelId, const U32 u32FilterId, DMX_FILTER_DATA_S* const pstFilterData); + S32 (*dmx_channel_destroy_filter)(const U32 u32ChannelId, const U32 u32FilterId); + S32 (*dmx_channel_destroy_all_filter)(const U32 u32ChannelId); + S32 (*dmx_channel_enable_filter)(const U32 u32ChannelId, const U32 u32FilterId); + S32 (*dmx_channel_disable_filter)(const U32 u32ChannelId, const U32 u32FilterId); + S32 (*dmx_channel_query_filter_by_table_id)(const U32 u32ChannelId, U32* const pu32FilterId, const U8 u8TableId, const U16 u16ExtId); + S32 (*dmx_channel_query_filter_by_filter_data)(const U32 u32ChannelId, U32* const pu32FilterId, const DMX_FILTER_DATA_S* const pstFilterData); + S32 (*dmx_descrambler_open)(const DMX_ID_E enDemuxId, U32* const pu32DescId, const DMX_DESC_ASSOCIATE_MODE_E enMode); + S32 (*dmx_descrambler_open_ex)(const DMX_ID_E enDemuxId, U32* const pu32DescId, const DMX_DESCRAMBLER_ATTR_S* pstDesramblerAttr); + S32 (*dmx_descrambler_enable)(const U32 u32DescId); + S32 (*dmx_descrambler_disable)(const U32 u32DescId); + S32 (*dmx_descrambler_close)(const U32 u32DescId); + S32 (*dmx_descrambler_associate)(const U32 u32DescId, const DMX_DESC_ASSOCIATE_PARAMS_S* const pstParams); + S32 (*dmx_descrambler_get_associate_info)(const U32 u32DescId, DMX_DESC_ASSOCIATE_PARAMS_S* const pstParams); + S32 (*dmx_descrambler_set_even_key)(const U32 u32DescId, const U8* const pu8Key, const U32 u32Len, const U32 u32Option); + S32 (*dmx_descrambler_set_even_iv)(const U32 u32DescId, const U8* const pu8IV, const U32 u32Len); + S32 (*dmx_descrambler_set_odd_key)(const U32 u32DescId, const U8* const pu8Key, const U32 u32Len, const U32 u32Option); + S32 (*dmx_descrambler_set_odd_iv)(const U32 u32DescId, const U8* const pu8IV, const U32 u32Len); + S32 (*dmx_set_descrambler_attribute)(const U32 u32DescId, const DMX_DESCRAMBLER_ATTR_S* pstAttr); + S32 (*dmx_get_descrambler_attribute)(const U32 u32DescId, DMX_DESCRAMBLER_ATTR_S* pstAttr); + S32 (*dmx_dcas_keyladder_config)(const U32 u32DescId, const DMX_DCAS_KEYLADDER_SETTING_S* pstDcasKLConfig); + S32 (*dmx_dcas_get_nonce)(const U32 u32DescId, const DMX_DCAS_NONCE_SETTING_S* pstDcasNonceConfig, U8* pu8DANonce); + S32 (*dmx_avfilter_open)(const DMX_ID_E enDemuxId, U32* const pu32AVFilterId, const DMX_PARSER_FILTER_OPEN_PARAM_S* const pstFilterOpenPara); + S32 (*dmx_avfilter_enable)(const U32 u32AVFilterId); + S32 (*dmx_avfilter_get_esframe)(const U32 u32AVFilterId, DMX_ESFRAME_INFO_S* pstFrameInfo); + S32 (*dmx_avfilter_release_esframe)(const U32 u32AVFilterId, const DMX_ESFRAME_INFO_S* pstFrameInfo); + S32 (*dmx_avfilter_disable)(const U32 u32AVFilterId); + S32 (*dmx_avfilter_close)(const U32 u32AVFilterId); + S32 (*dmx_pcr_open)(const DMX_ID_E enDemuxId, U32* const pu32PcrId, const U32 u32Pid); + S32 (*dmx_pcr_close)(const U32 u32PcrId); + S32 (*dmx_pcr_get)(const U32 u32PcrId, U64* pu64StcTime); + S32 (*dmx_tsbuffer_create)(const DMX_ID_E enDemuxId, U32* const pu32TsBufferId); + S32 (*dmx_tsbuffer_get)(U32 u32TsBufferId, U32 u32Size, U32 u32TimeoutMs, DMX_STREAM_DATA_S* pstStreamData); + S32 (*dmx_tsbuffer_put)(U32 u32TsBufferId, U32 u32ValidDataLen); + S32 (*dmx_tsbuffer_destroy)(U32 u32TsBufferId); + S32 (*dmx_get_streampath_param)(DMX_ID_E enDemuxId, UCHAR* pStreamPath, S32* pStreamPathLength); + + /* 以下接口为非国标接口 */ + S32 (*dmx_channel_get_data_handle)(U32* pu32ChannelId, U32* pu32ChNum, const U32 u32TimeoutMs); + S32 (*dmx_tsbuffer_create_ex)(const DMX_ID_E enDemuxId, const DMX_TSBUF_ATTR_S* pstBufAttr, U32* const pu32TsBufferId); + S32 (*dmx_tsbuffer_get_ex)(U32 u32TsBufferId, U32 u32Size, U32 u32TimeoutMs, DMX_STREAM_DATA_S* pstStreamData, U32* pu32PhyAddr); + S32 (*dmx_get_tso_port_attr)(U32 tsoPortId, DMX_TSO_PORT_ATTR_S* tvAttr); + S32 (*dmx_set_tso_port_attr)(U32 tsoPortId, const DMX_TSO_PORT_ATTR_S* tvAttr); +}; + +typedef struct TvserviceDtvDemuxVdi* (*CreateDtvDemuxVdiFunc)(); +typedef void (*DestroyDtvDemuxVdiFunc)(struct TvserviceDtvDemuxVdi* vdi); + +struct TvserviceDtvDemuxVdi* CreateDtvDemuxVdi(); +void DestroyDtvDemuxVdi(struct TvserviceDtvDemuxVdi* vdi); + +#endif // TVSERVICE_DTV_DEMUX_VDI_H \ No newline at end of file diff --git a/tvservice/dtv/demux/interfaces/hdi_service/src/tvservice_dtv_demux_driver.c b/tvservice/dtv/demux/interfaces/hdi_service/src/tvservice_dtv_demux_driver.c new file mode 100644 index 0000000000000000000000000000000000000000..2a82a313211531f193eb0d36ef35bb1a409d8172 --- /dev/null +++ b/tvservice/dtv/demux/interfaces/hdi_service/src/tvservice_dtv_demux_driver.c @@ -0,0 +1,119 @@ +/* +* Copyright (c) 2025 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 +#include +#include +#include +#include "v1_0/itvservice_dtv_demux.h" + +#define HDF_LOG_TAG tvservice_dtv_demux_driver + +struct HdfTvserviceDtvDemuxHost { + struct IDeviceIoService ioService; + struct ITvserviceDtvDemux *service; + struct HdfRemoteService **stubObject; +}; + +static int32_t TvserviceDtvDemuxDriverDispatch(struct HdfDeviceIoClient *client, int cmdId, + struct HdfSBuf *data, struct HdfSBuf *reply) +{ + struct HdfTvserviceDtvDemuxHost *host = CONTAINER_OF(client->device->service, struct HdfTvserviceDtvDemuxHost, ioService); + if (host->service == NULL || host->stubObject == NULL) { + HDF_LOGE("%{public}s: invalid service obj", __func__); + return HDF_ERR_INVALID_OBJECT; + } + + struct HdfRemoteService *stubObj = *host->stubObject; + if (stubObj == NULL || stubObj->dispatcher == NULL || stubObj->dispatcher->Dispatch == NULL) { + return HDF_ERR_INVALID_OBJECT; + } + + return stubObj->dispatcher->Dispatch((struct HdfRemoteService *)stubObj->target, cmdId, data, reply); +} + +static int HdfTvserviceDtvDemuxDriverInit(struct HdfDeviceObject *deviceObject) +{ + HDF_LOGI("%{public}s: driver init start", __func__); + return HDF_SUCCESS; +} + +static int HdfTvserviceDtvDemuxDriverBind(struct HdfDeviceObject *deviceObject) +{ + HDF_LOGI("%{public}s: driver bind start", __func__); + int32_t ret = HdfDeviceObjectSetInterfaceDesc(deviceObject, ITVSERVICEDTVDEMUX_INTERFACE_DESC); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%{public}s: failed to set interface descriptor of device object", __func__); + return ret; + } + + struct HdfTvserviceDtvDemuxHost *host = (struct HdfTvserviceDtvDemuxHost *)OsalMemCalloc(sizeof(struct HdfTvserviceDtvDemuxHost)); + if (host == NULL) { + HDF_LOGE("%{public}s: create HdfTvserviceDtvDemuxHost object failed!", __func__); + return HDF_FAILURE; + } + + struct ITvserviceDtvDemux *serviceImpl = ITvserviceDtvDemuxGet(true); + if (serviceImpl == NULL) { + HDF_LOGE("%{public}s: create serviceImpl failed!", __func__); + OsalMemFree(host); + return HDF_FAILURE; + } + + struct HdfRemoteService **stubObj = StubCollectorGetOrNewObject(ITVSERVICEDTVDEMUX_INTERFACE_DESC, serviceImpl); + if (stubObj == NULL) { + HDF_LOGE("%{public}s: failed to get stub object", __func__); + OsalMemFree(host); + ITvserviceDtvDemuxRelease(serviceImpl, true); + return HDF_FAILURE; + } + + host->ioService.Dispatch = TvserviceDtvDemuxDriverDispatch; + host->ioService.Open = NULL; + host->ioService.Release = NULL; + host->service = serviceImpl; + host->stubObject = stubObj; + deviceObject->service = &host->ioService; + HDF_LOGI("%{public}s: driver bind end", __func__); + return HDF_SUCCESS; +} + +static void HdfTvserviceDtvDemuxDriverRelease(struct HdfDeviceObject *deviceObject) +{ + HDF_LOGI("%{public}s: driver release start", __func__); + if (deviceObject->service == NULL) { + return; + } + + struct HdfTvserviceDtvDemuxHost *host = CONTAINER_OF(deviceObject->service, struct HdfTvserviceDtvDemuxHost, ioService); + if (host != NULL) { + StubCollectorRemoveObject(ITVSERVICEDTVDEMUX_INTERFACE_DESC, host->service); + ITvserviceDtvDemuxRelease(host->service, true); + OsalMemFree(host); + } +} + +struct HdfDriverEntry g_tvservicedtvdemuxDriverEntry = { + .moduleVersion = 1, + .moduleName = "tvservice_dtv_demux_service", + .Bind = HdfTvserviceDtvDemuxDriverBind, + .Init = HdfTvserviceDtvDemuxDriverInit, + .Release = HdfTvserviceDtvDemuxDriverRelease, +}; + +HDF_INIT(g_tvservicedtvdemuxDriverEntry); \ No newline at end of file diff --git a/tvservice/dtv/demux/interfaces/hdi_service/src/tvservice_dtv_demux_service.c b/tvservice/dtv/demux/interfaces/hdi_service/src/tvservice_dtv_demux_service.c new file mode 100644 index 0000000000000000000000000000000000000000..6bcfea5aacd3ce355d191bd7ae2b6e0f2d8a1838 --- /dev/null +++ b/tvservice/dtv/demux/interfaces/hdi_service/src/tvservice_dtv_demux_service.c @@ -0,0 +1,612 @@ +/* +* Copyright (c) 2025 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 +#include + +#include "osal_mem.h" +#include "tvservice_dtv_demux_vdi.h" +#include "v1_0/itvservice_dtv_demux.h" + +#define HDF_LOG_TAG tvservice_dtv_demux_service + +struct TvserviceDtvDemuxService { + struct ITvserviceDtvDemux interface; +}; + +static void *g_libHandle = NULL; +static struct TvserviceDtvDemuxVdi *g_vdiImpl = NULL; +static DestroyDtvDemuxVdiFunc g_destroyVdiFunc = NULL; + + /* 动态加载vdi库 */ +static int32_t TvserviceDtvDemuxLoadVdiSo() +{ + HDF_LOGI("demux load vendor vdi library: %{public}s start", TVSERVICE_DTV_DEMUX_VDI_LIBRARY); + const char* errStr = dlerror(); + if (errStr != NULL) { + HDF_LOGE("demux load vdi, clear earlier dlerror: %{public}s", errStr); + return HDF_FAILURE; + } + + g_libHandle = dlopen(TVSERVICE_DTV_DEMUX_VDI_LIBRARY, RTLD_LAZY); + if (g_libHandle == NULL) { + HDF_LOGE("demux load vendor vdi default library failed: %{public}s", TVSERVICE_DTV_DEMUX_VDI_LIBRARY); + return HDF_FAILURE; + } else { + HDF_LOGI("demux load vendor vdi default library: %{public}s", TVSERVICE_DTV_DEMUX_VDI_LIBRARY); + return HDF_SUCCESS; + } +} + +/* 动态加载vdi库中的接口函数 */ +static int32_t TvserviceDtvDemuxLoadVdiV1_0() +{ + HDF_LOGI("demux load vendor vdi impl start"); + CreateDtvDemuxVdiFunc createVdiFunc = NULL; + const char* errStr = NULL; + + createVdiFunc = dlsym(g_libHandle, "CreateDtvDemuxVdi"); + if (createVdiFunc == NULL) { + errStr = dlerror(); + if (errStr != NULL) { + HDF_LOGE("CreateDtvDemuxVdi dlsym error: %{public}s", errStr); + } + return HDF_FAILURE; + } + + g_destroyVdiFunc = dlsym(g_libHandle, "DestroyDtvDemuxVdi"); + if (g_destroyVdiFunc == NULL) { + errStr = dlerror(); + if (errStr != NULL) { + HDF_LOGE("DestroyDtvDemuxVdi dlsym error: %{public}s", errStr); + } + return HDF_FAILURE; + } + + g_vdiImpl = createVdiFunc(); + + HDF_LOGI("demux load vendor vdi impl end"); + return HDF_SUCCESS; +} + +static int32_t TvserviceDtvDemuxdmx_init(struct ITvserviceDtvDemux *self, const struct DMX_INIT_PARAMS_S* pstInitParams) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_init(pstInitParams); +} + +static int32_t TvserviceDtvDemuxdmx_term(struct ITvserviceDtvDemux *self, const struct DMX_TERM_PARAM_S* pstTermParams) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_term(pstTermParams); +} + +static int32_t TvserviceDtvDemuxdmx_set_source_params(struct ITvserviceDtvDemux *self, enum DMX_ID_E enDemuxId, const struct DMX_SOURCE_PARAMS_S* pstSourceParams) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_set_source_params(enDemuxId, pstSourceParams); +} + +static int32_t TvserviceDtvDemuxdmx_get_source_params(struct ITvserviceDtvDemux *self, enum DMX_ID_E enDemuxId, struct DMX_SOURCE_PARAMS_S* pstSourceParams) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_get_source_params(enDemuxId, pstSourceParams); +} + +static int32_t TvserviceDtvDemuxdmx_disconnect(struct ITvserviceDtvDemux *self, enum DMX_ID_E enDemuxId) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_disconnect(enDemuxId); +} + +static int32_t TvserviceDtvDemuxdmx_reconnect(struct ITvserviceDtvDemux *self, enum DMX_ID_E enDemuxId) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_reconnect(enDemuxId); +} + +static int32_t TvserviceDtvDemuxdmx_get_capability(struct ITvserviceDtvDemux *self, struct DMX_CAPABILITY_S* pstCapability) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_get_capability(pstCapability); +} + +static int32_t TvserviceDtvDemuxdmx_get_status(struct ITvserviceDtvDemux *self, enum DMX_ID_E enDemuxId, struct DMX_STATUS_S* pstStatus) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_get_status(enDemuxId, pstStatus); +} + +static int32_t TvserviceDtvDemuxdmx_channel_open(struct ITvserviceDtvDemux *self, enum DMX_ID_E enDemuxId, uint32_t* pu32ChannelId, const struct DMX_CHANNEL_OPEN_PARAM_S* pstOpenParams) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_channel_open(enDemuxId, pu32ChannelId, pstOpenParams); +} + +static int32_t TvserviceDtvDemuxdmx_channel_close(struct ITvserviceDtvDemux *self, uint32_t u32ChannelId, + const struct DMX_CHANNEL_CLOSE_PARAMS_S* pstCloseParams) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_channel_close(u32ChannelId, pstCloseParams); +} + +static int32_t TvserviceDtvDemuxdmx_channel_set_pid(struct ITvserviceDtvDemux *self, uint32_t u32ChannelId, + uint16_t u16Pid) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_channel_set_pid(u32ChannelId, u16Pid); +} + +static int32_t TvserviceDtvDemuxdmx_channel_query(struct ITvserviceDtvDemux *self, enum DMX_ID_E enDemuxId, + uint32_t* pu32ChannelId, uint16_t u16Pid) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_channel_query(enDemuxId, pu32ChannelId, u16Pid); +} + +static int32_t TvserviceDtvDemuxdmx_channel_enable(struct ITvserviceDtvDemux *self, uint32_t u32ChannelId) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_channel_enable(u32ChannelId); +} + +static int32_t TvserviceDtvDemuxdmx_channel_disable(struct ITvserviceDtvDemux *self, uint32_t u32ChannelId) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_channel_disable(u32ChannelId); +} + +static int32_t TvserviceDtvDemuxdmx_channel_reset(struct ITvserviceDtvDemux *self, uint32_t u32ChannelId) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_channel_reset(u32ChannelId); +} + +static int32_t TvserviceDtvDemuxdmx_channel_get_info(struct ITvserviceDtvDemux *self, uint32_t u32ChannelId, + struct DMX_CHANNEL_INFO_S* pstInfo) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_channel_get_info(u32ChannelId, pstInfo); +} + +static int32_t TvserviceDtvDemuxdmx_channel_set(struct ITvserviceDtvDemux *self, uint32_t u32ChannelId, + const struct DMX_CHANNEL_SETTING_S* pstSettings) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_channel_set(u32ChannelId, pstSettings); +} + +static int32_t TvserviceDtvDemuxdmx_channel_get(struct ITvserviceDtvDemux *self, uint32_t u32ChannelId, + struct DMX_CHANNEL_SETTING_S* pstSettings) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_channel_get(u32ChannelId, pstSettings); +} + +static int32_t TvserviceDtvDemuxdmx_channel_get_buf(struct ITvserviceDtvDemux *self, uint32_t u32ChannelId, + uint32_t u32AcquirePackageNum, uint32_t* pu32AcquiredNum, struct DMX_CHANNEL_DATA_S* pstChannelData, uint32_t u32TimeoutMs) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_channel_get_buf(u32ChannelId, u32AcquirePackageNum, pu32AcquiredNum, pstChannelData, u32TimeoutMs); +} + +static int32_t TvserviceDtvDemuxdmx_channel_release_buf(struct ITvserviceDtvDemux *self, uint32_t u32ChannelId, + uint32_t u32ReleaseNum, struct DMX_CHANNEL_DATA_S* pstChannelData) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_channel_release_buf(u32ChannelId, u32ReleaseNum, pstChannelData); +} + +static int32_t TvserviceDtvDemuxdmx_channel_add_filter(struct ITvserviceDtvDemux *self, uint32_t u32ChannelId, + uint32_t* pu32FilterId, const struct DMX_FILTER_DATA_S* pstFilterData) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_channel_add_filter(u32ChannelId, pu32FilterId, pstFilterData); +} + +static int32_t TvserviceDtvDemuxdmx_channel_set_filter(struct ITvserviceDtvDemux *self, uint32_t u32ChannelId, + uint32_t u32FilterId, const struct DMX_FILTER_DATA_S* pstFilterData) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_channel_set_filter(u32ChannelId, u32FilterId, pstFilterData); +} + +static int32_t TvserviceDtvDemuxdmx_channel_get_filter(struct ITvserviceDtvDemux *self, uint32_t u32ChannelId, + uint32_t u32FilterId, struct DMX_FILTER_DATA_S* pstFilterData) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_channel_get_filter(u32ChannelId, u32FilterId, pstFilterData); +} + +static int32_t TvserviceDtvDemuxdmx_channel_destroy_filter(struct ITvserviceDtvDemux *self, uint32_t u32ChannelId, + uint32_t u32FilterId) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_channel_destroy_filter(u32ChannelId, u32FilterId); +} + +static int32_t TvserviceDtvDemuxdmx_channel_destroy_all_filter(struct ITvserviceDtvDemux *self, uint32_t u32ChannelId) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_channel_destroy_all_filter(u32ChannelId); +} + +static int32_t TvserviceDtvDemuxdmx_channel_enable_filter(struct ITvserviceDtvDemux *self, uint32_t u32ChannelId, + uint32_t u32FilterId) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_channel_enable_filter(u32ChannelId, u32FilterId); +} + +static int32_t TvserviceDtvDemuxdmx_channel_disable_filter(struct ITvserviceDtvDemux *self, uint32_t u32ChannelId, + uint32_t u32FilterId) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_channel_disable_filter(u32ChannelId, u32FilterId); +} + +static int32_t TvserviceDtvDemuxdmx_channel_query_filter_by_table_id(struct ITvserviceDtvDemux *self, + uint32_t u32ChannelId, uint32_t* pu32FilterId, uint8_t u8TableId, uint16_t u16ExtId) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_channel_query_filter_by_table_id(u32ChannelId, pu32FilterId, u8TableId, u16ExtId); +} + +static int32_t TvserviceDtvDemuxdmx_channel_query_filter_by_filter_data(struct ITvserviceDtvDemux *self, + uint32_t u32ChannelId, uint32_t* pu32FilterId, const struct DMX_FILTER_DATA_S* pstFilterData) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_channel_query_filter_by_filter_data(u32ChannelId, pu32FilterId, pstFilterData); +} + +static int32_t TvserviceDtvDemuxdmx_descrambler_open(struct ITvserviceDtvDemux *self, enum DMX_ID_E enDemuxId, + uint32_t* pu32DescId, enum DMX_DESC_ASSOCIATE_MODE_E enMode) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_descrambler_open(enDemuxId, pu32DescId, enMode); +} + +static int32_t TvserviceDtvDemuxdmx_descrambler_open_ex(struct ITvserviceDtvDemux *self, enum DMX_ID_E enDemuxId, + uint32_t* pu32DescId, const struct DMX_DESCRAMBLER_ATTR_S* pstDesramblerAttr) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_descrambler_open_ex(enDemuxId, pu32DescId, pstDesramblerAttr); +} + +static int32_t TvserviceDtvDemuxdmx_descrambler_enable(struct ITvserviceDtvDemux *self, uint32_t u32DescId) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_descrambler_enable(u32DescId); +} + +static int32_t TvserviceDtvDemuxdmx_descrambler_disable(struct ITvserviceDtvDemux *self, uint32_t u32DescId) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_descrambler_disable(u32DescId); +} + +static int32_t TvserviceDtvDemuxdmx_descrambler_close(struct ITvserviceDtvDemux *self, uint32_t u32DescId) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_descrambler_close(u32DescId); +} + +static int32_t TvserviceDtvDemuxdmx_descrambler_associate(struct ITvserviceDtvDemux *self, uint32_t u32DescId, + const struct DMX_DESC_ASSOCIATE_PARAMS_S* pstParams) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_descrambler_associate(u32DescId, pstParams); +} + +static int32_t TvserviceDtvDemuxdmx_descrambler_get_associate_info(struct ITvserviceDtvDemux *self, uint32_t u32DescId, + struct DMX_DESC_ASSOCIATE_PARAMS_S* pstParams) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_descrambler_get_associate_info(u32DescId, pstParams); +} + +static int32_t TvserviceDtvDemuxdmx_descrambler_set_even_key(struct ITvserviceDtvDemux *self, uint32_t u32DescId, + uint8_t* pu8Key, uint32_t u32Len, uint32_t u32Option) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_descrambler_set_even_key(u32DescId, pu8Key, u32Len, u32Option); +} + +static int32_t TvserviceDtvDemuxdmx_descrambler_set_even_iv(struct ITvserviceDtvDemux *self, uint32_t u32DescId, + uint8_t* pu8IV, uint32_t u32Len) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_descrambler_set_even_iv(u32DescId, pu8IV, u32Len); +} + +static int32_t TvserviceDtvDemuxdmx_descrambler_set_odd_key(struct ITvserviceDtvDemux *self, uint32_t u32DescId, + uint8_t* pu8Key, uint32_t u32Len, uint32_t u32Option) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_descrambler_set_odd_key(u32DescId, pu8Key, u32Len, u32Option); +} + +static int32_t TvserviceDtvDemuxdmx_descrambler_set_odd_iv(struct ITvserviceDtvDemux *self, uint32_t u32DescId, + uint8_t* pu8IV, uint32_t u32Len) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_descrambler_set_odd_iv(u32DescId, pu8IV, u32Len); +} + +static int32_t TvserviceDtvDemuxdmx_set_descrambler_attribute(struct ITvserviceDtvDemux *self, uint32_t u32DescId, + const struct DMX_DESCRAMBLER_ATTR_S* pstAttr) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_set_descrambler_attribute(u32DescId, pstAttr); +} + +static int32_t TvserviceDtvDemuxdmx_get_descrambler_attribute(struct ITvserviceDtvDemux *self, uint32_t u32DescId, + struct DMX_DESCRAMBLER_ATTR_S* pstAttr) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_get_descrambler_attribute(u32DescId, pstAttr); +} + +static int32_t TvserviceDtvDemuxdmx_dcas_keyladder_config(struct ITvserviceDtvDemux *self, uint32_t u32DescId, + const struct DMX_DCAS_KEYLADDER_SETTING_S* pstDcasKLConfig) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_dcas_keyladder_config(u32DescId, pstDcasKLConfig); +} + +static int32_t TvserviceDtvDemuxdmx_dcas_get_nonce(struct ITvserviceDtvDemux *self, uint32_t u32DescId, + const struct DMX_DCAS_NONCE_SETTING_S* pstDcasNonceConfig, uint8_t* pu8DANonce) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_dcas_get_nonce(u32DescId, pstDcasNonceConfig, pu8DANonce); +} + +static int32_t TvserviceDtvDemuxdmx_avfilter_open(struct ITvserviceDtvDemux *self, enum DMX_ID_E enDemuxId, + uint32_t* pu32AVFilterId, struct DMX_PARSER_FILTER_OPEN_PARAM_S* pstFilterOpenPara) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_avfilter_open(enDemuxId, pu32AVFilterId, pstFilterOpenPara); +} + +static int32_t TvserviceDtvDemuxdmx_avfilter_enable(struct ITvserviceDtvDemux *self, uint32_t u32AVFilterId) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_avfilter_enable(u32AVFilterId); +} + +static int32_t TvserviceDtvDemuxdmx_avfilter_get_esframe(struct ITvserviceDtvDemux *self, uint32_t u32AVFilterId, + struct DMX_ESFRAME_INFO_S* pstFrameInfo) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_avfilter_get_esframe(u32AVFilterId, pstFrameInfo); +} + +static int32_t TvserviceDtvDemuxdmx_avfilter_release_esframe(struct ITvserviceDtvDemux *self, uint32_t u32AVFilterId, + const struct DMX_ESFRAME_INFO_S* pstFrameInfo) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_avfilter_release_esframe(u32AVFilterId, pstFrameInfo); +} + +static int32_t TvserviceDtvDemuxdmx_avfilter_disable(struct ITvserviceDtvDemux *self, uint32_t u32AVFilterId) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_avfilter_disable(u32AVFilterId); +} + +static int32_t TvserviceDtvDemuxdmx_avfilter_close(struct ITvserviceDtvDemux *self, uint32_t u32AVFilterId) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_avfilter_close(u32AVFilterId); +} + +static int32_t TvserviceDtvDemuxdmx_pcr_open(struct ITvserviceDtvDemux *self, enum DMX_ID_E enDemuxId, + uint32_t* pu32PcrId, uint32_t u32Pid) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_pcr_open(enDemuxId, pu32PcrId, u32Pid); +} + +static int32_t TvserviceDtvDemuxdmx_pcr_close(struct ITvserviceDtvDemux *self, uint32_t u32PcrId) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_pcr_close(u32PcrId); +} + +static int32_t TvserviceDtvDemuxdmx_pcr_get(struct ITvserviceDtvDemux *self, uint32_t u32PcrId, uint64_t* pu64StcTime) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_pcr_get(u32PcrId, pu64StcTime); +} + +static int32_t TvserviceDtvDemuxdmx_tsbuffer_create(struct ITvserviceDtvDemux *self, enum DMX_ID_E enDemuxId, + uint32_t* pu32TsBufferId) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_tsbuffer_create(enDemuxId, pu32TsBufferId); +} + +static int32_t TvserviceDtvDemuxdmx_tsbuffer_get(struct ITvserviceDtvDemux *self, uint32_t u32TsBufferId, + uint32_t u32Size, uint32_t u32TimeoutMs, struct DMX_STREAM_DATA_S* pstStreamData) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_tsbuffer_get(u32TsBufferId, u32Size, u32TimeoutMs, pstStreamData); +} + +static int32_t TvserviceDtvDemuxdmx_tsbuffer_put(struct ITvserviceDtvDemux *self, uint32_t u32TsBufferId, + uint32_t u32ValidDataLen) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_tsbuffer_put(u32TsBufferId, u32ValidDataLen); +} + +static int32_t TvserviceDtvDemuxdmx_tsbuffer_destroy(struct ITvserviceDtvDemux *self, uint32_t u32TsBufferId) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_tsbuffer_destroy(u32TsBufferId); +} + +static int32_t TvserviceDtvDemuxdmx_get_streampath_param(struct ITvserviceDtvDemux *self, enum DMX_ID_E enDemuxId, + uint8_t* pStreamPath, int32_t* pStreamPathLength) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_get_streampath_param(enDemuxId, pStreamPath, pStreamPathLength); +} + +static int32_t TvserviceDtvDemuxdmx_channel_get_data_handle(struct ITvserviceDtvDemux *self, uint32_t* pu32ChannelId, + uint32_t* pu32ChNum, uint32_t u32TimeoutMs) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_channel_get_data_handle(pu32ChannelId, pu32ChNum, u32TimeoutMs); +} + +static int32_t TvserviceDtvDemuxdmx_tsbuffer_create_ex(struct ITvserviceDtvDemux *self, enum DMX_ID_E enDemuxId, + const struct DMX_TSBUF_ATTR_S* pstBufAttr, uint32_t* pu32TsBufferId) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_tsbuffer_create_ex(enDemuxId, pstBufAttr, pu32TsBufferId); +} + +static int32_t TvserviceDtvDemuxdmx_tsbuffer_get_ex(struct ITvserviceDtvDemux *self, uint32_t u32TsBufferId, + uint32_t u32Size, uint32_t u32TimeoutMs, struct DMX_STREAM_DATA_S* pstStreamData, uint32_t* pu32PhyAddr) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_tsbuffer_get_ex(u32TsBufferId, u32Size, u32TimeoutMs, pstStreamData, pu32PhyAddr); +} + +static int32_t TvserviceDtvDemuxdmx_get_tso_port_attr(struct ITvserviceDtvDemux *self, uint32_t tsoPortId, + struct DMX_TSO_PORT_ATTR_S* tvAttr) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_get_tso_port_attr(tsoPortId, tvAttr); +} + +static int32_t TvserviceDtvDemuxdmx_set_tso_port_attr(struct ITvserviceDtvDemux *self, uint32_t tsoPortId, + struct DMX_TSO_PORT_ATTR_S* tvAttr) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->dmx_set_tso_port_attr(tsoPortId, tvAttr); +} + +static int32_t TvserviceDtvDemuxGetVersion(struct ITvserviceDtvDemux *self, uint32_t* majorVer, uint32_t* minorVer) +{ + *majorVer = ITVSERVICE_DTV_DEMUX_MAJOR_VERSION; + *minorVer = ITVSERVICE_DTV_DEMUX_MINOR_VERSION; + return HDF_SUCCESS; +} + +struct ITvserviceDtvDemux *TvserviceDtvDemuxImplGetInstance(void) +{ + HDF_LOGI("malloc TvserviceDtvDemuxService obj start"); + if (g_libHandle == NULL && TvserviceDtvDemuxLoadVdiSo() == HDF_FAILURE) { + return NULL; + } + if (g_vdiImpl == NULL && TvserviceDtvDemuxLoadVdiV1_0() == HDF_FAILURE) { + return NULL; + } + + struct TvserviceDtvDemuxService *service = (struct TvserviceDtvDemuxService *)OsalMemCalloc(sizeof(struct TvserviceDtvDemuxService)); + if (service == NULL) { + HDF_LOGI("%{public}s: malloc TvserviceDtvDemuxService obj failed!", __func__); + return NULL; + } + + service->interface.dmx_init = TvserviceDtvDemuxdmx_init; + service->interface.dmx_term = TvserviceDtvDemuxdmx_term; + service->interface.dmx_set_source_params = TvserviceDtvDemuxdmx_set_source_params; + service->interface.dmx_get_source_params = TvserviceDtvDemuxdmx_get_source_params; + service->interface.dmx_disconnect = TvserviceDtvDemuxdmx_disconnect; + service->interface.dmx_reconnect = TvserviceDtvDemuxdmx_reconnect; + service->interface.dmx_get_capability = TvserviceDtvDemuxdmx_get_capability; + service->interface.dmx_get_status = TvserviceDtvDemuxdmx_get_status; + service->interface.dmx_channel_open = TvserviceDtvDemuxdmx_channel_open; + service->interface.dmx_channel_close = TvserviceDtvDemuxdmx_channel_close; + service->interface.dmx_channel_set_pid = TvserviceDtvDemuxdmx_channel_set_pid; + service->interface.dmx_channel_query = TvserviceDtvDemuxdmx_channel_query; + service->interface.dmx_channel_enable = TvserviceDtvDemuxdmx_channel_enable; + service->interface.dmx_channel_disable = TvserviceDtvDemuxdmx_channel_disable; + service->interface.dmx_channel_reset = TvserviceDtvDemuxdmx_channel_reset; + service->interface.dmx_channel_get_info = TvserviceDtvDemuxdmx_channel_get_info; + service->interface.dmx_channel_set = TvserviceDtvDemuxdmx_channel_set; + service->interface.dmx_channel_get = TvserviceDtvDemuxdmx_channel_get; + service->interface.dmx_channel_get_buf = TvserviceDtvDemuxdmx_channel_get_buf; + service->interface.dmx_channel_release_buf = TvserviceDtvDemuxdmx_channel_release_buf; + service->interface.dmx_channel_add_filter = TvserviceDtvDemuxdmx_channel_add_filter; + service->interface.dmx_channel_set_filter = TvserviceDtvDemuxdmx_channel_set_filter; + service->interface.dmx_channel_get_filter = TvserviceDtvDemuxdmx_channel_get_filter; + service->interface.dmx_channel_destroy_filter = TvserviceDtvDemuxdmx_channel_destroy_filter; + service->interface.dmx_channel_destroy_all_filter = TvserviceDtvDemuxdmx_channel_destroy_all_filter; + service->interface.dmx_channel_enable_filter = TvserviceDtvDemuxdmx_channel_enable_filter; + service->interface.dmx_channel_disable_filter = TvserviceDtvDemuxdmx_channel_disable_filter; + service->interface.dmx_channel_query_filter_by_table_id = TvserviceDtvDemuxdmx_channel_query_filter_by_table_id; + service->interface.dmx_channel_query_filter_by_filter_data = TvserviceDtvDemuxdmx_channel_query_filter_by_filter_data; + service->interface.dmx_descrambler_open = TvserviceDtvDemuxdmx_descrambler_open; + service->interface.dmx_descrambler_open_ex = TvserviceDtvDemuxdmx_descrambler_open_ex; + service->interface.dmx_descrambler_enable = TvserviceDtvDemuxdmx_descrambler_enable; + service->interface.dmx_descrambler_disable = TvserviceDtvDemuxdmx_descrambler_disable; + service->interface.dmx_descrambler_close = TvserviceDtvDemuxdmx_descrambler_close; + service->interface.dmx_descrambler_associate = TvserviceDtvDemuxdmx_descrambler_associate; + service->interface.dmx_descrambler_get_associate_info = TvserviceDtvDemuxdmx_descrambler_get_associate_info; + service->interface.dmx_descrambler_set_even_key = TvserviceDtvDemuxdmx_descrambler_set_even_key; + service->interface.dmx_descrambler_set_even_iv = TvserviceDtvDemuxdmx_descrambler_set_even_iv; + service->interface.dmx_descrambler_set_odd_key = TvserviceDtvDemuxdmx_descrambler_set_odd_key; + service->interface.dmx_descrambler_set_odd_iv = TvserviceDtvDemuxdmx_descrambler_set_odd_iv; + service->interface.dmx_set_descrambler_attribute = TvserviceDtvDemuxdmx_set_descrambler_attribute; + service->interface.dmx_get_descrambler_attribute = TvserviceDtvDemuxdmx_get_descrambler_attribute; + service->interface.dmx_dcas_keyladder_config = TvserviceDtvDemuxdmx_dcas_keyladder_config; + service->interface.dmx_dcas_get_nonce = TvserviceDtvDemuxdmx_dcas_get_nonce; + service->interface.dmx_avfilter_open = TvserviceDtvDemuxdmx_avfilter_open; + service->interface.dmx_avfilter_enable = TvserviceDtvDemuxdmx_avfilter_enable; + service->interface.dmx_avfilter_get_esframe = TvserviceDtvDemuxdmx_avfilter_get_esframe; + service->interface.dmx_avfilter_release_esframe = TvserviceDtvDemuxdmx_avfilter_release_esframe; + service->interface.dmx_avfilter_disable = TvserviceDtvDemuxdmx_avfilter_disable; + service->interface.dmx_avfilter_close = TvserviceDtvDemuxdmx_avfilter_close; + service->interface.dmx_pcr_open = TvserviceDtvDemuxdmx_pcr_open; + service->interface.dmx_pcr_close = TvserviceDtvDemuxdmx_pcr_close; + service->interface.dmx_pcr_get = TvserviceDtvDemuxdmx_pcr_get; + service->interface.dmx_tsbuffer_create = TvserviceDtvDemuxdmx_tsbuffer_create; + service->interface.dmx_tsbuffer_get = TvserviceDtvDemuxdmx_tsbuffer_get; + service->interface.dmx_tsbuffer_put = TvserviceDtvDemuxdmx_tsbuffer_put; + service->interface.dmx_tsbuffer_destroy = TvserviceDtvDemuxdmx_tsbuffer_destroy; + service->interface.dmx_get_streampath_param = TvserviceDtvDemuxdmx_get_streampath_param; + service->interface.dmx_channel_get_data_handle = TvserviceDtvDemuxdmx_channel_get_data_handle; + service->interface.dmx_tsbuffer_create_ex = TvserviceDtvDemuxdmx_tsbuffer_create_ex; + service->interface.dmx_tsbuffer_get_ex = TvserviceDtvDemuxdmx_tsbuffer_get_ex; + service->interface.dmx_get_tso_port_attr = TvserviceDtvDemuxdmx_get_tso_port_attr; + service->interface.dmx_set_tso_port_attr = TvserviceDtvDemuxdmx_set_tso_port_attr; + service->interface.GetVersion = TvserviceDtvDemuxGetVersion; + HDF_LOGI("malloc TvserviceDtvDemuxService obj end"); + return &service->interface; +} + +void TvserviceDtvDemuxImplRelease(struct ITvserviceDtvDemux *instance) +{ + if (instance == NULL) { + return; + } + OsalMemFree(instance); + + if (g_vdiImpl != NULL && g_destroyVdiFunc != NULL) { + g_destroyVdiFunc(g_vdiImpl); + g_vdiImpl = NULL; + g_destroyVdiFunc = NULL; + + dlclose(g_libHandle); + g_libHandle= NULL; + } +} \ No newline at end of file diff --git a/tvservice/dtv/demux/interfaces/vdi_base/BUILD.gn b/tvservice/dtv/demux/interfaces/vdi_base/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..338b8fc89af7992cb433dc22c670e87a3561f06f --- /dev/null +++ b/tvservice/dtv/demux/interfaces/vdi_base/BUILD.gn @@ -0,0 +1,49 @@ +# Copyright (C) 2025 HiHope Open Source Organization . +# 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. + +import("//build/ohos.gni") +import("../../../../tvservice.gni") +import("//vendor/${product_company}/${product_name}/product.gni") + +ohos_shared_library("tvservice_dtv_demux_vdi_impl_default") { + defines = [] + sources = [ + "src/tvservice_dtv_demux_vdi_impl.c", + ] + output_name = "tvservice_dtv_demux_vdi_impl_default" + include_dirs = [ + "include", + "../hdi_service/include", + "../../utils/include", + ] + cflags_cc = [ + "-fPIC", + "-Wall", + "-Wno-error=unused-function", + "-Wno-error=missing-braces", + "-Wno-error=#warnings", + ] + external_deps = [ + "c_utils:utils", + "drivers_interface_tvservice:libtvservice_dtv_demux_stub_1.0", + "drivers_interface_tvservice:libtvservice_dtv_demux_proxy_1.0", + "hdf_core:libhdf_utils", + "hilog:libhilog", + "hitrace:hitrace_meter", + "ipc:ipc_single" + ] + install_enable = true + install_images = [ chipset_base_dir ] + subsystem_name = "hdf" + part_name = "drivers_peripheral_tvservice" +} \ No newline at end of file diff --git a/tvservice/dtv/demux/interfaces/vdi_base/include/tvservice_dtv_demux_vdi_impl.h b/tvservice/dtv/demux/interfaces/vdi_base/include/tvservice_dtv_demux_vdi_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..14ddc1fc243469439d123650b38c9b6c8b903efe --- /dev/null +++ b/tvservice/dtv/demux/interfaces/vdi_base/include/tvservice_dtv_demux_vdi_impl.h @@ -0,0 +1,98 @@ +/* +* Copyright (c) 2025 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. +*/ + +#ifndef TVSERVICE_DTV_DEMUX_VDI_IMPL_H +#define TVSERVICE_DTV_DEMUX_VDI_IMPL_H + +#include "dtv_demux_hal.h" + +#define TVSERVICE_DTV_DEMUX_VDI_LIBRARY "libtvservice_dtv_demux_vdi_impl_default.z.so" + +struct TvserviceDtvDemuxVdi +{ + S32 (*dmx_init)(const DMX_INIT_PARAMS_S* const pstInitParams); + S32 (*dmx_term)(const DMX_TERM_PARAM_S* const pstTermParams); + S32 (*dmx_set_source_params)(const DMX_ID_E enDemuxId, const DMX_SOURCE_PARAMS_S* pstSourceParams); + S32 (*dmx_get_source_params)(const DMX_ID_E enDemuxId, DMX_SOURCE_PARAMS_S* const pstSourceParams); + S32 (*dmx_disconnect)(const DMX_ID_E enDemuxId); + S32 (*dmx_reconnect)(const DMX_ID_E enDemuxId); + S32 (*dmx_get_capability)(DMX_CAPABILITY_S* const pstCapability); + S32 (*dmx_get_status)(const DMX_ID_E enDemuxId, DMX_STATUS_S* const pstStatus); + S32 (*dmx_channel_open)(const DMX_ID_E enDemuxId, U32* const pu32ChannelId, const DMX_CHANNEL_OPEN_PARAM_S* const pstOpenParams); + S32 (*dmx_channel_close)(const U32 u32ChannelId, const DMX_CHANNEL_CLOSE_PARAMS_S* pstCloseParams); + S32 (*dmx_channel_set_pid)(const U32 u32ChannelId, const U16 u16Pid); + S32 (*dmx_channel_query)(const DMX_ID_E enDemuxId, U32* const pu32ChannelId, const U16 u16Pid); + S32 (*dmx_channel_enable)(const U32 u32ChannelId); + S32 (*dmx_channel_disable)(const U32 u32ChannelId); + S32 (*dmx_channel_reset)(const U32 u32ChannelId); + S32 (*dmx_channel_get_info)(const U32 u32ChannelId, DMX_CHANNEL_INFO_S* const pstInfo); + S32 (*dmx_channel_set)(const U32 u32ChannelId, const DMX_CHANNEL_SETTING_S* const pstSettings); + S32 (*dmx_channel_get)(const U32 u32ChannelId, DMX_CHANNEL_SETTING_S* const pstSettings); + S32 (*dmx_channel_get_buf)(const U32 u32ChannelId, U32 u32AcquirePackageNum, U32* pu32AcquiredNum, DMX_CHANNEL_DATA_S* pstChannelData, const U32 u32TimeoutMs); + S32 (*dmx_channel_release_buf)(const U32 u32ChannelId, const U32 u32ReleaseNum, DMX_CHANNEL_DATA_S* pstChannelData); + S32 (*dmx_channel_add_filter)(const U32 u32ChannelId, U32* const pu32FilterId, const DMX_FILTER_DATA_S* const pstFilterData); + S32 (*dmx_channel_set_filter)(const U32 u32ChannelId, const U32 u32FilterId, const DMX_FILTER_DATA_S* const pstFilterData); + S32 (*dmx_channel_get_filter)(const U32 u32ChannelId, const U32 u32FilterId, DMX_FILTER_DATA_S* const pstFilterData); + S32 (*dmx_channel_destroy_filter)(const U32 u32ChannelId, const U32 u32FilterId); + S32 (*dmx_channel_destroy_all_filter)(const U32 u32ChannelId); + S32 (*dmx_channel_enable_filter)(const U32 u32ChannelId, const U32 u32FilterId); + S32 (*dmx_channel_disable_filter)(const U32 u32ChannelId, const U32 u32FilterId); + S32 (*dmx_channel_query_filter_by_table_id)(const U32 u32ChannelId, U32* const pu32FilterId, const U8 u8TableId, const U16 u16ExtId); + S32 (*dmx_channel_query_filter_by_filter_data)(const U32 u32ChannelId, U32* const pu32FilterId, const DMX_FILTER_DATA_S* const pstFilterData); + S32 (*dmx_descrambler_open)(const DMX_ID_E enDemuxId, U32* const pu32DescId, const DMX_DESC_ASSOCIATE_MODE_E enMode); + S32 (*dmx_descrambler_open_ex)(const DMX_ID_E enDemuxId, U32* const pu32DescId, const DMX_DESCRAMBLER_ATTR_S* pstDesramblerAttr); + S32 (*dmx_descrambler_enable)(const U32 u32DescId); + S32 (*dmx_descrambler_disable)(const U32 u32DescId); + S32 (*dmx_descrambler_close)(const U32 u32DescId); + S32 (*dmx_descrambler_associate)(const U32 u32DescId, const DMX_DESC_ASSOCIATE_PARAMS_S* const pstParams); + S32 (*dmx_descrambler_get_associate_info)(const U32 u32DescId, DMX_DESC_ASSOCIATE_PARAMS_S* const pstParams); + S32 (*dmx_descrambler_set_even_key)(const U32 u32DescId, const U8* const pu8Key, const U32 u32Len, const U32 u32Option); + S32 (*dmx_descrambler_set_even_iv)(const U32 u32DescId, const U8* const pu8IV, const U32 u32Len); + S32 (*dmx_descrambler_set_odd_key)(const U32 u32DescId, const U8* const pu8Key, const U32 u32Len, const U32 u32Option); + S32 (*dmx_descrambler_set_odd_iv)(const U32 u32DescId, const U8* const pu8IV, const U32 u32Len); + S32 (*dmx_set_descrambler_attribute)(const U32 u32DescId, const DMX_DESCRAMBLER_ATTR_S* pstAttr); + S32 (*dmx_get_descrambler_attribute)(const U32 u32DescId, DMX_DESCRAMBLER_ATTR_S* pstAttr); + S32 (*dmx_dcas_keyladder_config)(const U32 u32DescId, const DMX_DCAS_KEYLADDER_SETTING_S* pstDcasKLConfig); + S32 (*dmx_dcas_get_nonce)(const U32 u32DescId, const DMX_DCAS_NONCE_SETTING_S* pstDcasNonceConfig, U8* pu8DANonce); + S32 (*dmx_avfilter_open)(const DMX_ID_E enDemuxId, U32* const pu32AVFilterId, const DMX_PARSER_FILTER_OPEN_PARAM_S* const pstFilterOpenPara); + S32 (*dmx_avfilter_enable)(const U32 u32AVFilterId); + S32 (*dmx_avfilter_get_esframe)(const U32 u32AVFilterId, DMX_ESFRAME_INFO_S* pstFrameInfo); + S32 (*dmx_avfilter_release_esframe)(const U32 u32AVFilterId, DMX_ESFRAME_INFO_S* pstFrameInfo); + S32 (*dmx_avfilter_disable)(const U32 u32AVFilterId); + S32 (*dmx_avfilter_close)(const U32 u32AVFilterId); + S32 (*dmx_pcr_open)(const DMX_ID_E enDemuxId, U32* const pu32PcrId, const U32 u32Pid); + S32 (*dmx_pcr_close)(const U32 u32PcrId); + S32 (*dmx_pcr_get)(const U32 u32PcrId, U64* pu64StcTime); + S32 (*dmx_tsbuffer_create)(const DMX_ID_E enDemuxId, U32* const pu32TsBufferId); + S32 (*dmx_tsbuffer_get)(U32 u32TsBufferId, U32 u32Size, U32 u32TimeoutMs, DMX_STREAM_DATA_S* pstStreamData); + S32 (*dmx_tsbuffer_put)(U32 u32TsBufferId, U32 u32ValidDataLen); + S32 (*dmx_tsbuffer_destroy)(U32 u32TsBufferId); + S32 (*dmx_get_streampath_param)(DMX_ID_E enDemuxId, UCHAR* pStreamPath, S32* pStreamPathLength); + + /* 以下接口为非国标接口 */ + S32 (*dmx_channel_get_data_handle)(U32* pu32ChannelId, U32* pu32ChNum, const U32 u32TimeoutMs); + S32 (*dmx_tsbuffer_create_ex)(const DMX_ID_E enDemuxId, DMX_TSBUF_ATTR_S* pstBufAttr, U32* const pu32TsBufferId); + S32 (*dmx_tsbuffer_get_ex)(U32 u32TsBufferId, U32 u32Size, U32 u32TimeoutMs, DMX_STREAM_DATA_S* pstStreamData, U32* pu32PhyAddr); + S32 (*dmx_get_tso_port_attr)(U32 tsoPortId, DMX_TSO_PORT_ATTR_S* tvAttr); + S32 (*dmx_set_tso_port_attr)(U32 tsoPortId, const DMX_TSO_PORT_ATTR_S* tvAttr); +}; + +typedef struct TvserviceDtvDemuxVdi* (*CreateDtvDemuxVdiFunc)(); +typedef void (*DestroyDtvDemuxVdiFunc)(struct TvserviceDtvDemuxVdi* vdi); + +struct TvserviceDtvDemuxVdi* CreateDtvDemuxVdi(); +void DestroyDtvDemuxVdi(struct TvserviceDtvDemuxVdi* vdi); + +#endif // TVSERVICE_DTV_DEMUX_VDI_IMPL_H \ No newline at end of file diff --git a/tvservice/dtv/demux/interfaces/vdi_base/src/tvservice_dtv_demux_vdi_impl.c b/tvservice/dtv/demux/interfaces/vdi_base/src/tvservice_dtv_demux_vdi_impl.c new file mode 100644 index 0000000000000000000000000000000000000000..710f250e81fdde963410076572e456411521a010 --- /dev/null +++ b/tvservice/dtv/demux/interfaces/vdi_base/src/tvservice_dtv_demux_vdi_impl.c @@ -0,0 +1,476 @@ +/* +* Copyright (c) 2025 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 "tvservice_dtv_demux_vdi_impl.h" + +#include +#include "osal_mem.h" + +static S32 dmx_init(const DMX_INIT_PARAMS_S* const pstInitParams) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_term(const DMX_TERM_PARAM_S* const pstTermParams) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_set_source_params(const DMX_ID_E enDemuxId, const DMX_SOURCE_PARAMS_S* pstSourceParams) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_get_source_params(const DMX_ID_E enDemuxId, DMX_SOURCE_PARAMS_S* const pstSourceParams) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_disconnect(const DMX_ID_E enDemuxId) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_reconnect(const DMX_ID_E enDemuxId) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_get_capability(DMX_CAPABILITY_S* const pstCapability) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_get_status(const DMX_ID_E enDemuxId, DMX_STATUS_S* const pstStatus) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; + +static S32 dmx_channel_open(const DMX_ID_E enDemuxId, U32* const pu32ChannelId, const DMX_CHANNEL_OPEN_PARAM_S* const pstOpenParams) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_channel_close(const U32 u32ChannelId, const DMX_CHANNEL_CLOSE_PARAMS_S* pstCloseParams) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_channel_set_pid(const U32 u32ChannelId, const U16 u16Pid) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_channel_query(const DMX_ID_E enDemuxId, U32* const pu32ChannelId, const U16 u16Pid) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_channel_enable(const U32 u32ChannelId) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_channel_disable(const U32 u32ChannelId) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + rreturn HDF_SUCCESS; + +static S32 dmx_channel_reset(const U32 u32ChannelId) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_channel_get_info(const U32 u32ChannelId, DMX_CHANNEL_INFO_S* const pstInfo) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_channel_set(const U32 u32ChannelId, const DMX_CHANNEL_SETTING_S* const pstSettings) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_channel_get(const U32 u32ChannelId, DMX_CHANNEL_SETTING_S* const pstSettings) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_channel_get_buf(const U32 u32ChannelId, U32 u32AcquirePackageNum, U32* pu32AcquiredNum, DMX_CHANNEL_DATA_S* pstChannelData, const U32 u32TimeoutMs) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_channel_release_buf(const U32 u32ChannelId, const U32 u32ReleaseNum, DMX_CHANNEL_DATA_S* pstChannelData) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_channel_add_filter(const U32 u32ChannelId, U32* const pu32FilterId, const DMX_FILTER_DATA_S* const pstFilterData) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_channel_set_filter(const U32 u32ChannelId, const U32 u32FilterId, const DMX_FILTER_DATA_S* const pstFilterData) +{ + return HDF_SUCCESS; +} + +static S32 dmx_channel_get_filter(const U32 u32ChannelId, const U32 u32FilterId, DMX_FILTER_DATA_S* const pstFilterData) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; + +static S32 dmx_channel_destroy_filter(const U32 u32ChannelId, const U32 u32FilterId) +{ + return HDF_SUCCESS; +} + +static S32 dmx_channel_destroy_all_filter(const U32 u32ChannelId) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_channel_enable_filter(const U32 u32ChannelId, const U32 u32FilterId) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_channel_disable_filter(const U32 u32ChannelId, const U32 u32FilterId) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_channel_query_filter_by_table_id(const U32 u32ChannelId, U32* const pu32FilterId, const U8 u8TableId, const U16 u16ExtId) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_channel_query_filter_by_filter_data(const U32 u32ChannelId, U32* const pu32FilterId, const DMX_FILTER_DATA_S* const pstFilterData) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_descrambler_open(const DMX_ID_E enDemuxId, U32* const pu32DescId, const DMX_DESC_ASSOCIATE_MODE_E enMode) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_descrambler_open_ex(const DMX_ID_E enDemuxId, U32* const pu32DescId, const DMX_DESCRAMBLER_ATTR_S* pstDesramblerAttr) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_descrambler_enable(const U32 u32DescId) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; + +static S32 dmx_descrambler_disable(const U32 u32DescId) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_descrambler_close(const U32 u32DescId) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_descrambler_associate(const U32 u32DescId, const DMX_DESC_ASSOCIATE_PARAMS_S* const pstParams) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_descrambler_get_associate_info(const U32 u32DescId, DMX_DESC_ASSOCIATE_PARAMS_S* const pstParams) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_descrambler_set_even_key(const U32 u32DescId, const U8* const pu8Key, const U32 u32Len, const U32 u32Option) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_descrambler_set_even_iv(const U32 u32DescId, const U8* const pu8IV, const U32 u32Len) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_descrambler_set_odd_key(const U32 u32DescId, const U8* const pu8Key, const U32 u32Len, const U32 u32Option) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_descrambler_set_odd_iv(const U32 u32DescId, const U8* const pu8IV, const U32 u32Len) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_set_descrambler_attribute(const U32 u32DescId, DMX_DESCRAMBLER_ATTR_S* pstAttr) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_get_descrambler_attribute(const U32 u32DescId, DMX_DESCRAMBLER_ATTR_S* pstAttr) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_dcas_keyladder_config(const U32 u32DescId, const DMX_DCAS_KEYLADDER_SETTING_S* pstDcasKLConfig) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_dcas_get_nonce(const U32 u32DescId, const DMX_DCAS_NONCE_SETTING_S* pstDcasNonceConfig, U8* pu8DANonce) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_avfilter_open(const DMX_ID_E enDemuxId, U32* const pu32AVFilterId, const DMX_PARSER_FILTER_OPEN_PARAM_S* const pstFilterOpenPara) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_avfilter_enable(const U32 u32AVFilterId) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_avfilter_get_esframe(const U32 u32AVFilterId, DMX_ESFRAME_INFO_S* pstFrameInfo) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_avfilter_release_esframe(const U32 u32AVFilterId, DMX_ESFRAME_INFO_S* pstFrameInfo) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_avfilter_disable(const U32 u32AVFilterId) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_avfilter_close(const U32 u32AVFilterId) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_pcr_open(const DMX_ID_E enDemuxId, U32* const pu32PcrId, const U32 u32Pid) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_pcr_close(const U32 u32PcrId) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_pcr_get(const U32 u32PcrId, U64* pu64StcTime) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_tsbuffer_create(const DMX_ID_E enDemuxId, U32* const pu32TsBufferId) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_tsbuffer_get(U32 u32TsBufferId, U32 u32Size, U32 u32TimeoutMs, DMX_STREAM_DATA_S* pstStreamData) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_tsbuffer_put(U32 u32TsBufferId, U32 u32ValidDataLen) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_tsbuffer_destroy(U32 u32TsBufferId) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_get_streampath_param(DMX_ID_E enDemuxId, UCHAR* pStreamPath, S32* pStreamPathLength) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +/* 以下接口为非国标接口 */ +static S32 dmx_channel_get_data_handle(U32* pu32ChannelId, U32* pu32ChNum, const U32 u32TimeoutMs) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_tsbuffer_create_ex(const DMX_ID_E enDemuxId, DMX_TSBUF_ATTR_S* pstBufAttr, U32* const pu32TsBufferId) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_tsbuffer_get_ex(U32 u32TsBufferId, U32 u32Size, U32 u32TimeoutMs, DMX_STREAM_DATA_S* pstStreamData, U32* pu32PhyAddr) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_get_tso_port_attr(U32 tsoPortId, DMX_TSO_PORT_ATTR_S* tvAttr) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static S32 dmx_set_tso_port_attr(U32 tsoPortId, const DMX_TSO_PORT_ATTR_S* tvAttr) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +struct TvserviceDtvDemuxVdi* CreateDtvDemuxVdi() +{ + HDF_LOGI("malloc TvserviceDtvDemuxVdi obj start."); + struct TvserviceDtvDemuxVdi *vdiImpl = (struct TvserviceDtvDemuxVdi *)OsalMemCalloc(sizeof(struct TvserviceDtvDemuxVdi)); + if (vdiImpl == NULL) { + HDF_LOGI("%{public}s: malloc TvserviceDtvDemuxVdi obj failed!", __func__); + return NULL; + } + // vdiImpl->dmx_init = dmx_init; + // vdiImpl->dmx_term = dmx_term; + // vdiImpl->dmx_set_source_params = dmx_set_source_params; + // vdiImpl->dmx_get_source_params = dmx_get_source_params; + // vdiImpl->dmx_disconnect = dmx_disconnect; + // vdiImpl->dmx_reconnect = dmx_reconnect; + // vdiImpl->dmx_get_capability = dmx_get_capability; + // vdiImpl->dmx_get_status = dmx_get_status; + // vdiImpl->dmx_channel_open = dmx_channel_open; + // vdiImpl->dmx_channel_close = dmx_channel_close; + // vdiImpl->dmx_channel_set_pid = dmx_channel_set_pid; + // vdiImpl->dmx_channel_query = dmx_channel_query; + // vdiImpl->dmx_channel_enable = dmx_channel_enable; + // vdiImpl->dmx_channel_disable = dmx_channel_disable; + // vdiImpl->dmx_channel_reset = dmx_channel_reset; + // vdiImpl->dmx_channel_get_info = dmx_channel_get_info; + // vdiImpl->dmx_channel_set = dmx_channel_set; + // vdiImpl->dmx_channel_get = dmx_channel_get; + // vdiImpl->dmx_channel_get_buf = dmx_channel_get_buf; + // vdiImpl->dmx_channel_release_buf = dmx_channel_release_buf; + // vdiImpl->dmx_channel_add_filter = dmx_channel_add_filter; + // vdiImpl->dmx_channel_set_filter = dmx_channel_set_filter; + // vdiImpl->dmx_channel_get_filter = dmx_channel_get_filter; + // vdiImpl->dmx_channel_destroy_filter = dmx_channel_destroy_filter; + // vdiImpl->dmx_channel_destroy_all_filter = dmx_channel_destroy_all_filter; + // vdiImpl->dmx_channel_enable_filter = dmx_channel_enable_filter; + // vdiImpl->dmx_channel_disable_filter = dmx_channel_disable_filter; + // vdiImpl->dmx_channel_query_filter_by_table_id = dmx_channel_query_filter_by_table_id; + // vdiImpl->dmx_channel_query_filter_by_filter_data = dmx_channel_query_filter_by_filter_data; + // vdiImpl->dmx_descrambler_open = dmx_descrambler_open; + // vdiImpl->dmx_descrambler_open_ex = dmx_descrambler_open_ex; + // vdiImpl->dmx_descrambler_enable = dmx_descrambler_enable; + // vdiImpl->dmx_descrambler_disable = dmx_descrambler_disable; + // vdiImpl->dmx_descrambler_close = dmx_descrambler_close; + // vdiImpl->dmx_descrambler_associate = dmx_descrambler_associate; + // vdiImpl->dmx_descrambler_get_associate_info = dmx_descrambler_get_associate_info; + // vdiImpl->dmx_descrambler_set_even_key = dmx_descrambler_set_even_key; + // vdiImpl->dmx_descrambler_set_even_iv = dmx_descrambler_set_even_iv; + // vdiImpl->dmx_descrambler_set_odd_key = dmx_descrambler_set_odd_key; + // vdiImpl->dmx_descrambler_set_odd_iv = dmx_descrambler_set_odd_iv; + // vdiImpl->dmx_set_descrambler_attribute = dmx_set_descrambler_attribute; + // vdiImpl->dmx_get_descrambler_attribute = dmx_get_descrambler_attribute; + // vdiImpl->dmx_dcas_keyladder_config = dmx_dcas_keyladder_config; + // vdiImpl->dmx_dcas_get_nonce = dmx_dcas_get_nonce; + // vdiImpl->dmx_avfilter_open = dmx_avfilter_open; + // vdiImpl->dmx_avfilter_enable = dmx_avfilter_enable; + // vdiImpl->dmx_avfilter_get_esframe = dmx_avfilter_get_esframe; + // vdiImpl->dmx_avfilter_release_esframe = dmx_avfilter_release_esframe; + // vdiImpl->dmx_avfilter_disable = dmx_avfilter_disable; + // vdiImpl->dmx_avfilter_close = dmx_avfilter_close; + // vdiImpl->dmx_pcr_open = dmx_pcr_open; + // vdiImpl->dmx_pcr_close = dmx_pcr_close; + // vdiImpl->dmx_pcr_get = dmx_pcr_get; + // vdiImpl->dmx_tsbuffer_create = dmx_tsbuffer_create; + // vdiImpl->dmx_tsbuffer_get = dmx_tsbuffer_get; + // vdiImpl->dmx_tsbuffer_put = dmx_tsbuffer_put; + // vdiImpl->dmx_tsbuffer_destroy = dmx_tsbuffer_destroy; + // vdiImpl->dmx_get_streampath_param = dmx_get_streampath_param; + // /* 以下是非国标的接口 */ + // vdiImpl->dmx_channel_get_data_handle = dmx_channel_get_data_handle; + // vdiImpl->dmx_tsbuffer_create_ex = dmx_tsbuffer_create_ex; + // vdiImpl->dmx_tsbuffer_get_ex = dmx_tsbuffer_get_ex; + // vdiImpl->dmx_get_tso_port_attr = dmx_get_tso_port_attr; + // vdiImpl->dmx_set_tso_port_attr = dmx_set_tso_port_attr; + HDF_LOGI("malloc TvserviceDtvDemuxVdi obj end."); + return vdiImpl; +} + +void DestroyDtvDemuxVdi(struct TvserviceDtvDemuxVdi* vdi) +{ + if (vdi == NULL) { + return; + } + OsalMemFree(vdi); +} \ No newline at end of file diff --git a/tvservice/dtv/frontend/BUILD.gn b/tvservice/dtv/frontend/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..527c77e44dd1b8ae34f2df50c2f2848515372fd6 --- /dev/null +++ b/tvservice/dtv/frontend/BUILD.gn @@ -0,0 +1,19 @@ +# Copyright (c) 2025 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. +import("//build/ohos.gni") + +print("=============tvservice_dtv_frontend_host_entry============") +group("tvservice_dtv_frontend_host_entry") { + deps = [ "interfaces/hdi_service:hdf_tvservice_dtv_frontend_host"] + # deps += [ "interfaces/vdi_base:tvservice_dtv_frontend_vdi_impl_default" ] +} \ No newline at end of file diff --git a/tvservice/dtv/frontend/interfaces/hdi_service/BUILD.gn b/tvservice/dtv/frontend/interfaces/hdi_service/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..a659240cc3c47c1993173b05ef12e0d4fe527c01 --- /dev/null +++ b/tvservice/dtv/frontend/interfaces/hdi_service/BUILD.gn @@ -0,0 +1,82 @@ +# Copyright (c) 2025 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. +import("//build/ohos.gni") +import("../../../../tvservice.gni") + +ohos_shared_library("libtvservice_dtv_frontend_service_1.0") { + defines = [] + include_dirs = [ + "../../utils/include", + "include" + ] + sources = [ + "src/tvservice_dtv_frontend_service.c" + ] + + external_deps = [ + "c_utils:utils", + "hdf_core:libhdf_ipc_adapter", + "hdf_core:libhdi", + "hdf_core:libhdf_host", + "hdf_core:libhdf_utils", + "hilog:libhilog", + "ipc:ipc_single", + "libxml2:libxml2", + "drivers_interface_tvservice:libtvservice_dtv_frontend_stub_1.0", + "drivers_interface_tvservice:libtvservice_dtv_frontend_proxy_1.0", + ] + + if (has_tvservice_hisysevent_part) { + external_deps += [ "hisysevent:libhisysevent" ] + } + + install_images = [ chipset_base_dir ] + subsystem_name = "hdf" + part_name = "drivers_peripheral_tvservice" +} + + +ohos_shared_library("libtvservice_dtv_frontend_driver") { + sources = [ + "src/tvservice_dtv_frontend_driver.c" + ] + + external_deps = [ + "c_utils:utils", + "hdf_core:libhdf_ipc_adapter", + "hdf_core:libhdi", + "hdf_core:libhdf_host", + "hdf_core:libhdf_utils", + "hilog:libhilog", + "ipc:ipc_single", + "drivers_interface_tvservice:libtvservice_dtv_frontend_stub_1.0", + "drivers_interface_tvservice:libtvservice_dtv_frontend_proxy_1.0", + ] + if (has_tvservice_c_utils_part) { + external_deps += [ "c_utils:utils" ] + } + + shlib_type = "hdi" + install_images = [ chipset_base_dir ] + subsystem_name = "hdf" + part_name = "drivers_peripheral_tvservice" +} + +group("hdf_tvservice_dtv_frontend_host") { + deps = [ + ":libtvservice_dtv_frontend_driver", + ":libtvservice_dtv_frontend_service_1.0", + ] + +print("=============hdf_tvservice_dtv_frontend_host============") +} \ No newline at end of file diff --git a/tvservice/dtv/frontend/interfaces/hdi_service/include/tvservice_dtv_frontend_vdi.h b/tvservice/dtv/frontend/interfaces/hdi_service/include/tvservice_dtv_frontend_vdi.h new file mode 100644 index 0000000000000000000000000000000000000000..721038f699bdb8c279b607ac08aa4e1fa5a87104 --- /dev/null +++ b/tvservice/dtv/frontend/interfaces/hdi_service/include/tvservice_dtv_frontend_vdi.h @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2025 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. +*/ + +#ifndef TVSERVICE_DTV_FRONTEND_VDI_H +#define TVSERVICE_DTV_FRONTEND_VDI_H + +#include "v1_0/itvservice_dtv_frontend.h" +#include "v1_0/tvservice_dtv_frontend_types.h" + +#define TVSERVICE_DTV_FRONTEND_VDI_LIBRARY "libtvservice_dtv_frontend_vdi_impl_default.z.so" + +typedef struct FRONTEND_INIT_PARAMS_S FRONTEND_INIT_PARAMS_S; +typedef struct FRONTEND_OPEN_PARAMS_S FRONTEND_OPEN_PARAMS_S; +typedef struct FRONTEND_TERM_PARAMS_S FRONTEND_TERM_PARAMS_S; +typedef struct FRONTEND_SCAN_INFO_S FRONTEND_SCAN_INFO_S; +typedef struct FRONTEND_REG_CALLBACK_PARAMS_S FRONTEND_REG_CALLBACK_PARAMS_S; +typedef struct FRONTEND_ATV_SIGNALINFO_S FRONTEND_ATV_SIGNALINFO_S; +typedef struct FRONTEND_INFO_S FRONTEND_INFO_S; +typedef struct FRONTEND_CAPABILITY_S FRONTEND_CAPABILITY_S; +typedef struct FRONTEND_SAT_LNB_INFO_S FRONTEND_SAT_LNB_INFO_S; +typedef struct FRONTEND_G2_CHANNEL_INFO_S FRONTEND_G2_CHANNEL_INFO_S; +typedef struct FRONTEND_G2_REQ_PARAMS_S FRONTEND_G2_REQ_PARAMS_S; +typedef struct FRONTEND_G2_RPN_PARAMS_S FRONTEND_G2_RPN_PARAMS_S; +typedef enum FRONTEND_LNB_PWR_STATUS_E FRONTEND_LNB_PWR_STATUS_E; +typedef enum FRONTEND_ATV_LOCK_STATUS_E FRONTEND_ATV_LOCK_STATUS_E; +typedef enum FRONTEND_FE_STATUS_E FRONTEND_FE_STATUS_E; +struct TvserviceDtvFrontendVdi { + int32_t (*frontend_init)(FRONTEND_INIT_PARAMS_S* pstInitParams); + int32_t (*frontend_open)(unsigned int* phFrontend,FRONTEND_OPEN_PARAMS_S* pOpenParams); + int32_t (*frontend_close)(unsigned int frontend_handle); + int32_t (*frontend_term)(FRONTEND_TERM_PARAMS_S* pstTermParams); + int32_t (*frontend_get_scan_info)(unsigned int hFrontend,FRONTEND_SCAN_INFO_S * pstScanInfo); + int32_t (*frontend_sat_config_lnb)(unsigned int hFrontend,FRONTEND_SAT_LNB_INFO_S* pstLnbInfo); + int32_t (*frontend_get_lnb_pwr_status)(unsigned int hFrontend,FRONTEND_LNB_PWR_STATUS_E* penLnbPwrStatu); + int32_t (*frontend_start_scan)(unsigned int hFrontend,FRONTEND_SCAN_INFO_S* pstScanParams, bool bSynch,unsigned int u32Timeout); + int32_t (*frontend_abort)(unsigned int hFrontend); + int32_t (*frontend_register_callback)(unsigned int hFrontend,FRONTEND_REG_CALLBACK_PARAMS_S* pstRegParams); + int32_t (*frontend_lock)(unsigned int hFrontend); + int32_t (*frontend_get_bert)(unsigned int hFrontend,float* pfBert); + int32_t (*frontend_get_signal_quality)(unsigned int hFrontend,unsigned int* pu32Quality); + int32_t (*frontend_get_signal_strength)(unsigned int hFrontend, unsigned int* pu32Strength); + int32_t (*frontend_get_atvsignalinfo)(unsigned int hFrontend,FRONTEND_ATV_SIGNALINFO_S* pstSignalInfo); + int32_t (*frontend_get_connect_status)(unsigned int hFrontend,FRONTEND_FE_STATUS_E * penStatus); + int32_t (*frontend_get_info)(unsigned int hFrontend,FRONTEND_INFO_S* pstInfo); + int32_t (*frontend_get_capability)(FRONTEND_CAPABILITY_S* pstCapability); + int32_t (*frontend_get_channel_num)(unsigned int hFrontend,unsigned char* pu8ChannelNum); + int32_t (*frontend_get_channel_info)(unsigned int hFrontend,unsigned char u8ChannelIndex,FRONTEND_G2_CHANNEL_INFO_S* pstChannelInfo,unsigned int u32Timeout); + int32_t (*frontend_config_channel)(unsigned int hFrontend,unsigned char u8ChannelIndex,FRONTEND_G2_REQ_PARAMS_S* pstReqParams, FRONTEND_G2_RPN_PARAMS_S* pstRpnParams,unsigned int u32Timeout); + int32_t (*frontend_atv_get_lock_status)(unsigned int hFrontend,FRONTEND_ATV_LOCK_STATUS_E* penLockStatus); + int32_t (*frontend_atv_fineTune)(unsigned int hFrontend, unsigned int us32Steps); +}; + +typedef struct TvserviceDtvFrontendVdi* (*CreateDtvFrontendVdiFunc)(); +typedef void (*DestroyDtvFrontendVdiFunc)(struct TvserviceDtvFrontendVdi* vdi); + +struct TvserviceDtvFrontendVdi* CreateDtvFrontendVdi(); +typedef void (*DestroyDtvFrontendVdi)(struct TvserviceDtvFrontendVdi* vdi); + +#endif // TVSERVICE_DTV_FRONTEND_VDI_H \ No newline at end of file diff --git a/tvservice/dtv/frontend/interfaces/hdi_service/src/tvservice_dtv_frontend_driver.c b/tvservice/dtv/frontend/interfaces/hdi_service/src/tvservice_dtv_frontend_driver.c new file mode 100644 index 0000000000000000000000000000000000000000..2370b7f07fe6564c72c9328e6f851fce62047ef3 --- /dev/null +++ b/tvservice/dtv/frontend/interfaces/hdi_service/src/tvservice_dtv_frontend_driver.c @@ -0,0 +1,118 @@ +/* +* Copyright (c) 2025 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 +#include +#include +#include +#include "v1_0/itvservice_dtv_frontend.h" + +#define HDF_LOG_TAG tvservice_dtv_frontend_driver + +struct HdfTvserviceDtvFrontendHost { + struct IDeviceIoService ioService; + struct ITvserviceDtvFrontend *service; + struct HdfRemoteService **stubObject; +}; + +static int32_t TvserviceDtvFrontendDriverDispatch(struct HdfDeviceIoClient *client, int cmdId, + struct HdfSBuf *data, struct HdfSBuf *reply) +{ + struct HdfTvserviceDtvFrontendHost *host = CONTAINER_OF(client->device->service, struct HdfTvserviceDtvFrontendHost, ioService); + if (host->service == NULL || host->stubObject == NULL) { + HDF_LOGE("%{public}s: invalid service obj", __func__); + return HDF_ERR_INVALID_OBJECT; + } + + struct HdfRemoteService *stubObj = *host->stubObject; + if (stubObj == NULL || stubObj->dispatcher == NULL || stubObj->dispatcher->Dispatch == NULL) { + return HDF_ERR_INVALID_OBJECT; + } + + return stubObj->dispatcher->Dispatch((struct HdfRemoteService *)stubObj->target, cmdId, data, reply); +} + +static int HdfTvserviceDtvFrontendDriverInit(struct HdfDeviceObject *deviceObject) +{ + HDF_LOGI("%{public}s: driver init start", __func__); + return HDF_SUCCESS; +} + +static int HdfTvserviceDtvFrontendDriverBind(struct HdfDeviceObject *deviceObject) +{ + HDF_LOGI("%{public}s: driver bind start", __func__); + int32_t ret = HdfDeviceObjectSetInterfaceDesc(deviceObject, ITVSERVICEDTVFRONTEND_INTERFACE_DESC); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%{public}s: failed to set interface descriptor of device object", __func__); + return ret; + } + + struct HdfTvserviceDtvFrontendHost *host = (struct HdfTvserviceDtvFrontendHost *)OsalMemCalloc(sizeof(struct HdfTvserviceDtvFrontendHost)); + if (host == NULL) { + HDF_LOGE("%{public}s: create HdfTvserviceDtvFrontendHost object failed!", __func__); + return HDF_FAILURE; + } + + struct ITvserviceDtvFrontend *serviceImpl = ITvserviceDtvFrontendGet(true); + if (serviceImpl == NULL) { + HDF_LOGE("%{public}s: create serviceImpl failed!", __func__); + OsalMemFree(host); + return HDF_FAILURE; + } + + struct HdfRemoteService **stubObj = StubCollectorGetOrNewObject(ITVSERVICEDTVFRONTEND_INTERFACE_DESC, serviceImpl); + if (stubObj == NULL) { + HDF_LOGE("%{public}s: failed to get stub object", __func__); + OsalMemFree(host); + ITvserviceDtvFrontendRelease(serviceImpl, true); + return HDF_FAILURE; + } + + host->ioService.Dispatch = TvserviceDtvFrontendDriverDispatch; + host->ioService.Open = NULL; + host->ioService.Release = NULL; + host->service = serviceImpl; + host->stubObject = stubObj; + deviceObject->service = &host->ioService; + return HDF_SUCCESS; +} + +static void HdfTvserviceDtvFrontendDriverRelease(struct HdfDeviceObject *deviceObject) +{ + HDF_LOGI("%{public}s: driver release start", __func__); + if (deviceObject->service == NULL) { + return; + } + + struct HdfTvserviceDtvFrontendHost *host = CONTAINER_OF(deviceObject->service, struct HdfTvserviceDtvFrontendHost, ioService); + if (host != NULL) { + StubCollectorRemoveObject(ITVSERVICEDTVFRONTEND_INTERFACE_DESC, host->service); + ITvserviceDtvFrontendRelease(host->service, true); + OsalMemFree(host); + } +} + +struct HdfDriverEntry g_tvservicedtvfrontendDriverEntry = { + .moduleVersion = 1, + .moduleName = "tvservice_dtv_frontend_service", + .Bind = HdfTvserviceDtvFrontendDriverBind, + .Init = HdfTvserviceDtvFrontendDriverInit, + .Release = HdfTvserviceDtvFrontendDriverRelease, +}; + +HDF_INIT(g_tvservicedtvfrontendDriverEntry); \ No newline at end of file diff --git a/tvservice/dtv/frontend/interfaces/hdi_service/src/tvservice_dtv_frontend_service.c b/tvservice/dtv/frontend/interfaces/hdi_service/src/tvservice_dtv_frontend_service.c new file mode 100644 index 0000000000000000000000000000000000000000..0c446957f3febc0b8bdba400192cf222b943a0b7 --- /dev/null +++ b/tvservice/dtv/frontend/interfaces/hdi_service/src/tvservice_dtv_frontend_service.c @@ -0,0 +1,308 @@ +/* +* Copyright (c) 2025 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 +#include "v1_0/itvservice_dtv_frontend.h" +#include "tvservice_dtv_frontend_vdi.h" +#include + +#define HDF_LOG_TAG tvservice_dtv_frontend_service + +void* g_libHandle = NULL; +DestroyDtvFrontendVdiFunc g_destroyVdiFunc = NULL; +static struct TvserviceDtvFrontendVdi* g_vdiImpl =NULL; + +static int32_t TvserviceDtvFrontendLoadVdiSO() +{ + const char* errStr = dlerror(); + if (errStr != NULL) { + HDF_LOGE("frontend load vdi, clear earlier dlerror: %{public}s", errStr); + } + g_libHandle = dlopen(TVSERVICE_DTV_FRONTEND_VDI_LIBRARY, RTLD_LAZY); + if (g_libHandle == NULL) { + HDF_LOGE("frontend load vendor vdi default library failed: %{public}s", TVSERVICE_DTV_FRONTEND_VDI_LIBRARY); + return HDF_FAILURE; + } + + HDF_LOGI("DTV frontend load vendor vdi default library: %{public}s", TVSERVICE_DTV_FRONTEND_VDI_LIBRARY); + return HDF_SUCCESS; +} + +static int32_t TvserviceDtvFrontendLoadVdiV1_0() +{ + CreateDtvFrontendVdiFunc createVdiFunc = NULL; + const char* errStr = NULL; + + createVdiFunc = dlsym(g_libHandle, "CreateDtvFrontendVdi"); + if (createVdiFunc == NULL) { + errStr = dlerror(); + if (errStr != NULL) { + HDF_LOGE("CreateDtvFrontendVdiFunc dlsym error: %{public}s", errStr); + } + else { + HDF_LOGE("CreateDtvFrontendVdiFunc dlsym error: createVdiFunc NULL"); + } + return HDF_FAILURE; + } + + g_destroyVdiFunc = dlsym(g_libHandle, "DestroyDtvFrontendVdi"); + if (g_destroyVdiFunc == NULL) { + errStr = dlerror(); + if (errStr != NULL) { + HDF_LOGE("DestroyFrontendVdiFunc dlsym error: %{public}s", errStr); + } + return HDF_FAILURE; + } + + g_vdiImpl = createVdiFunc(); + HDF_LOGI("DTV frontend load vendor func: %{public}s", TVSERVICE_DTV_FRONTEND_VDI_LIBRARY); + return HDF_SUCCESS; +} + +struct TvserviceDtvFrontendService { + struct ITvserviceDtvFrontend interface; +}; + +static int32_t TvserviceDtvFrontendfrontend_init(struct ITvserviceDtvFrontend *self, + const struct FRONTEND_INIT_PARAMS_S* pstInitParams) +{ + HDF_LOGI("%s %s %d", __FILE__,__func__,__LINE__); + return g_vdiImpl->frontend_init((FRONTEND_INIT_PARAMS_S*)pstInitParams); +} + +static int32_t TvserviceDtvFrontendfrontend_open(struct ITvserviceDtvFrontend *self, uint32_t* phFrontend, + const struct FRONTEND_OPEN_PARAMS_S* pOpenParams) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->frontend_open((uint32_t*)phFrontend,(FRONTEND_OPEN_PARAMS_S*)pOpenParams); +} + +static int32_t TvserviceDtvFrontendfrontend_close(struct ITvserviceDtvFrontend *self, uint32_t frontend_handle) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->frontend_close(frontend_handle); +} + +static int32_t TvserviceDtvFrontendfrontend_term(struct ITvserviceDtvFrontend *self, + const struct FRONTEND_TERM_PARAMS_S* pstTermParams) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->frontend_term((FRONTEND_TERM_PARAMS_S*)pstTermParams); +} + +static int32_t TvserviceDtvFrontendfrontend_get_scan_info(struct ITvserviceDtvFrontend *self, uint32_t hFrontend, + struct FRONTEND_SCAN_INFO_S* pstScanInfo) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->frontend_get_scan_info(hFrontend,(FRONTEND_SCAN_INFO_S*)pstScanInfo); +} + +static int32_t TvserviceDtvFrontendfrontend_sat_config_lnb(struct ITvserviceDtvFrontend *self, uint32_t hFrontend, + const struct FRONTEND_SAT_LNB_INFO_S* pstLnbInfo) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->frontend_sat_config_lnb(hFrontend,(FRONTEND_SAT_LNB_INFO_S*)pstLnbInfo); +} + +static int32_t TvserviceDtvFrontendfrontend_get_lnb_pwr_status(struct ITvserviceDtvFrontend *self, uint32_t hFrontend, + enum FRONTEND_LNB_PWR_STATUS_E* penLnbPwrStatu) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->frontend_get_lnb_pwr_status(hFrontend,(FRONTEND_LNB_PWR_STATUS_E*)penLnbPwrStatu); +} + +static int32_t TvserviceDtvFrontendfrontend_start_scan(struct ITvserviceDtvFrontend *self, uint32_t hFrontend, + const struct FRONTEND_SCAN_INFO_S* pstScanParams, bool bSynch, uint32_t u32Timeout) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->frontend_start_scan(hFrontend,(FRONTEND_SCAN_INFO_S*)pstScanParams,bSynch,u32Timeout); +} + +static int32_t TvserviceDtvFrontendfrontend_abort(struct ITvserviceDtvFrontend *self, uint32_t hFrontend) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->frontend_abort(hFrontend); +} + +static int32_t TvserviceDtvFrontendfrontend_register_callback(struct ITvserviceDtvFrontend *self, uint32_t hFrontend, + const struct FRONTEND_REG_CALLBACK_PARAMS_S* pstRegParams) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->frontend_register_callback(hFrontend,(FRONTEND_REG_CALLBACK_PARAMS_S*)pstRegParams); + +} + +static int32_t TvserviceDtvFrontendfrontend_lock(struct ITvserviceDtvFrontend *self, uint32_t hFrontend) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->frontend_lock(hFrontend); +} + +static int32_t TvserviceDtvFrontendfrontend_get_bert(struct ITvserviceDtvFrontend *self, uint32_t hFrontend, + float* pfBert) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->frontend_get_bert(hFrontend,(float*)pfBert); +} + +static int32_t TvserviceDtvFrontendfrontend_get_signal_quality(struct ITvserviceDtvFrontend *self, uint32_t hFrontend, + uint32_t* pu32Quality) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->frontend_get_signal_quality(hFrontend,(uint32_t*)pu32Quality); +} + +static int32_t TvserviceDtvFrontendfrontend_get_signal_strength(struct ITvserviceDtvFrontend *self, uint32_t hFrontend, + uint32_t* pu32Strength) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->frontend_get_signal_strength(hFrontend,(uint32_t*)pu32Strength); +} + +static int32_t TvserviceDtvFrontendfrontend_get_atvsignalinfo(struct ITvserviceDtvFrontend *self, uint32_t hFrontend, + struct FRONTEND_ATV_SIGNALINFO_S* pstSignalInfo) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->frontend_get_atvsignalinfo(hFrontend,(FRONTEND_ATV_SIGNALINFO_S*)pstSignalInfo); +} + +static int32_t TvserviceDtvFrontendfrontend_get_connect_status(struct ITvserviceDtvFrontend *self, uint32_t hFrontend, + enum FRONTEND_FE_STATUS_E* penStatus) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->frontend_get_connect_status(hFrontend,penStatus); +} + +static int32_t TvserviceDtvFrontendfrontend_get_info(struct ITvserviceDtvFrontend *self, uint32_t hFrontend, + struct FRONTEND_INFO_S* pstInfo) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->frontend_get_info(hFrontend,pstInfo); +} + +static int32_t TvserviceDtvFrontendfrontend_get_capability(struct ITvserviceDtvFrontend *self, + struct FRONTEND_CAPABILITY_S* pstCapability) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->frontend_get_capability((FRONTEND_CAPABILITY_S*)pstCapability); +} + +static int32_t TvserviceDtvFrontendfrontend_get_channel_num(struct ITvserviceDtvFrontend *self, uint32_t hFrontend, + uint8_t* pu8ChannelNum) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->frontend_get_channel_num(hFrontend,pu8ChannelNum); +} + +static int32_t TvserviceDtvFrontendfrontend_get_channel_info(struct ITvserviceDtvFrontend *self, uint32_t hFrontend, + uint8_t u8ChannelIndex, struct FRONTEND_G2_CHANNEL_INFO_S* pstChannelInfo, uint32_t u32Timeout) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->frontend_get_channel_info(hFrontend,u8ChannelIndex,pstChannelInfo,u32Timeout); +} + +static int32_t TvserviceDtvFrontendfrontend_config_channel(struct ITvserviceDtvFrontend *self, uint32_t hFrontend, + uint8_t u8ChannelIndex, const struct FRONTEND_G2_REQ_PARAMS_S* pstReqParams, struct FRONTEND_G2_RPN_PARAMS_S* pstRpnParams, uint32_t u32Timeout) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->frontend_config_channel(hFrontend,u8ChannelIndex,(FRONTEND_G2_REQ_PARAMS_S*)pstReqParams,pstRpnParams,u32Timeout); +} + +static int32_t TvserviceDtvFrontendfrontend_atv_get_lock_status(struct ITvserviceDtvFrontend *self, uint32_t hFrontend, + enum FRONTEND_ATV_LOCK_STATUS_E* penLockStatus) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->frontend_atv_get_lock_status(hFrontend,penLockStatus); +} + +static int32_t TvserviceDtvFrontendfrontend_atv_fineTune(struct ITvserviceDtvFrontend *self, uint32_t hFrontend, + uint32_t us32Steps) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return g_vdiImpl->frontend_atv_fineTune(hFrontend,us32Steps); +} + +static int32_t TvserviceDtvFrontendGetVersion(struct ITvserviceDtvFrontend *self, uint32_t* majorVer, uint32_t* minorVer) +{ + *majorVer = ITVSERVICE_DTV_FRONTEND_MAJOR_VERSION; + *minorVer = ITVSERVICE_DTV_FRONTEND_MINOR_VERSION; + return HDF_SUCCESS; +} + +struct ITvserviceDtvFrontend *TvserviceDtvFrontendImplGetInstance(void) +{ + struct TvserviceDtvFrontendService *service = (struct TvserviceDtvFrontendService *)OsalMemCalloc(sizeof(struct TvserviceDtvFrontendService)); + if (service == NULL) { + HDF_LOGE("%{public}s: malloc TvserviceDtvFrontendService obj failed!", __func__); + return NULL; + } + + if (g_libHandle == NULL && TvserviceDtvFrontendLoadVdiSO() == HDF_FAILURE) { + HDF_LOGE("%{public}s: TvserviceDtvFrontendLoadVdiSO load failed!", __func__); + return NULL; + } + + if (g_libHandle != NULL && TvserviceDtvFrontendLoadVdiV1_0() == HDF_FAILURE) { + HDF_LOGE("%{public}s: TvserviceDtvFrontendLoadVdiV1_0 load impl failed!", __func__); + return NULL; + } + + service->interface.frontend_init = TvserviceDtvFrontendfrontend_init; + service->interface.frontend_open = TvserviceDtvFrontendfrontend_open; + service->interface.frontend_close = TvserviceDtvFrontendfrontend_close; + service->interface.frontend_term = TvserviceDtvFrontendfrontend_term; + service->interface.frontend_get_scan_info = TvserviceDtvFrontendfrontend_get_scan_info; + service->interface.frontend_sat_config_lnb = TvserviceDtvFrontendfrontend_sat_config_lnb; + service->interface.frontend_get_lnb_pwr_status = TvserviceDtvFrontendfrontend_get_lnb_pwr_status; + service->interface.frontend_start_scan = TvserviceDtvFrontendfrontend_start_scan; + service->interface.frontend_abort = TvserviceDtvFrontendfrontend_abort; + service->interface.frontend_register_callback = TvserviceDtvFrontendfrontend_register_callback; + service->interface.frontend_lock = TvserviceDtvFrontendfrontend_lock; + service->interface.frontend_get_bert = TvserviceDtvFrontendfrontend_get_bert; + service->interface.frontend_get_signal_quality = TvserviceDtvFrontendfrontend_get_signal_quality; + service->interface.frontend_get_signal_strength = TvserviceDtvFrontendfrontend_get_signal_strength; + service->interface.frontend_get_atvsignalinfo = TvserviceDtvFrontendfrontend_get_atvsignalinfo; + service->interface.frontend_get_connect_status = TvserviceDtvFrontendfrontend_get_connect_status; + service->interface.frontend_get_info = TvserviceDtvFrontendfrontend_get_info; + service->interface.frontend_get_capability = TvserviceDtvFrontendfrontend_get_capability; + service->interface.frontend_get_channel_num = TvserviceDtvFrontendfrontend_get_channel_num; + service->interface.frontend_get_channel_info = TvserviceDtvFrontendfrontend_get_channel_info; + service->interface.frontend_config_channel = TvserviceDtvFrontendfrontend_config_channel; + service->interface.frontend_atv_get_lock_status = TvserviceDtvFrontendfrontend_atv_get_lock_status; + service->interface.frontend_atv_fineTune = TvserviceDtvFrontendfrontend_atv_fineTune; + service->interface.GetVersion = TvserviceDtvFrontendGetVersion; + return &service->interface; +} + +void TvserviceDtvFrontendImplRelease(struct ITvserviceDtvFrontend *instance) +{ + if (instance == NULL) { + return; + } + OsalMemFree(instance); + + if (g_vdiImpl != NULL && g_destroyVdiFunc != NULL) { + g_destroyVdiFunc(g_vdiImpl); + + g_vdiImpl = NULL; + g_destroyVdiFunc = NULL; + + dlclose(g_libHandle); + g_libHandle = NULL; + } +} diff --git a/tvservice/dtv/frontend/interfaces/vdi_base/BUILD.gn b/tvservice/dtv/frontend/interfaces/vdi_base/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..be9456438ef10e3f64d41c07c4820ab9074566fd --- /dev/null +++ b/tvservice/dtv/frontend/interfaces/vdi_base/BUILD.gn @@ -0,0 +1,49 @@ +# Copyright (C) 2025 HiHope Open Source Organization . +# 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. + +import("//build/ohos.gni") +import("../../../../tvservice.gni") +import("//vendor/${product_company}/${product_name}/product.gni") + +ohos_shared_library("tvservice_dtv_frontend_vdi_impl_default") { + defines = [] + sources = [ + "src/tvservice_dtv_frontend_vdi_impl.c", + ] + output_name = "tvservice_dtv_frontend_vdi_impl_default" + include_dirs = [ + "include", + "../hdi_service/include", + "../../utils/include", + ] + cflags_cc = [ + "-fPIC", + "-Wall", + "-Wno-error=unused-function", + "-Wno-error=missing-braces", + "-Wno-error=#warnings", + ] + external_deps = [ + "c_utils:utils", + "drivers_interface_tvservice:libtvservice_dtv_frontend_stub_1.0", + "drivers_interface_tvservice:libtvservice_dtv_frontend_proxy_1.0", + "hdf_core:libhdf_utils", + "hilog:libhilog", + "hitrace:hitrace_meter", + "ipc:ipc_single", + ] + install_enable = true + install_images = [ chipset_base_dir ] + subsystem_name = "hdf" + part_name = "drivers_peripheral_tvservice" +} \ No newline at end of file diff --git a/tvservice/dtv/frontend/interfaces/vdi_base/include/tvservice_dtv_frontend_vdi_impl.h b/tvservice/dtv/frontend/interfaces/vdi_base/include/tvservice_dtv_frontend_vdi_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..ec3e044e989bda8c4fca7238cc75bf23f5e537ed --- /dev/null +++ b/tvservice/dtv/frontend/interfaces/vdi_base/include/tvservice_dtv_frontend_vdi_impl.h @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2025 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. +*/ + +#ifndef TVSERVICE_DTV_FRONTEND_VDI_IMPL_H +#define TVSERVICE_DTV_FRONTEND_VDI_IMPL_H +#include + +struct TvserviceDtvFrontendVdi +{ + int32_t (*frontend_init)(FRONTEND_INIT_PARAMS_S* pstInitParams); + int32_t (*frontend_open)(unsigned int* phFrontend, FRONTEND_OPEN_PARAMS_S* pOpenParams); + int32_t (*frontend_close)(unsigned int frontend_handle); + int32_t (*frontend_term)(FRONTEND_TERM_PARAMS_S* pstTermParams); + int32_t (*frontend_get_scan_info)(unsigned int hFrontend, FRONTEND_SCAN_INFO_S * pstScanInfo); + int32_t (*frontend_sat_config_lnb)(unsigned int hFrontend,FRONTEND_SAT_LNB_INFO_S* pstLnbInfo); + int32_t (*frontend_get_lnb_pwr_status)(unsigned int hFrontend,FRONTEND_LNB_PWR_STATUS_E * penLnbPwrStatu); + int32_t (*frontend_start_scan)(unsigned int hFrontend,FRONTEND_SCAN_INFO_S* pstScanParams, bool bSynch,unsigned int u32Timeout); + int32_t (*frontend_abort)(unsigned int hFrontend); + int32_t (*frontend_register_callback)(unsigned int hFrontend,FRONTEND_REG_CALLBACK_PARAMS_S* pstRegParams); + int32_t (*frontend_lock)(unsigned int hFrontend); + int32_t (*frontend_get_bert)(unsigned int hFrontend,float* pfBert); + int32_t (*frontend_get_signal_quality)(unsigned int hFrontend,unsigned int* pu32Quality); + int32_t (*frontend_get_signal_strength)(unsigned int hFrontend, unsigned int* pu32Strength); + int32_t (*frontend_get_atvsignalinfo)(unsigned int hFrontend,FRONTEND_ATV_SIGNALINFO_S* pstSignalInfo); + int32_t (*frontend_get_connect_status)(HANDLE hFrontend,FRONTEND_FE_STATUS_E * penStatus); + int32_t (*frontend_get_info)(unsigned int hFrontend,FRONTEND_INFO_S* pstInfo); + int32_t (*frontend_get_capability)(FRONTEND_CAPABILITY_S* pstCapability); + int32_t (*frontend_get_channel_num)(unsigned int hFrontend,unsigned char* pu8ChannelNum); + int32_t (*frontend_get_channel_info)(unsigned int hFrontend,unsigned char u8ChannelIndex,FRONTEND_G2_CHANNEL_INFO_S* pstChannelInfo,unsigned int u32Timeout); + int32_t (*frontend_config_channel)(unsigned int hFrontend,unsigned char u8ChannelIndex,FRONTEND_G2_REQ_PARAMS_S* pstReqParams,FRONTEND_G2_RPN_PARAMS_S* pstRpnParams,unsigned int u32Timeout); + int32_t (*frontend_atv_get_lock_status)(unsigned int hFrontend, FRONTEND_ATV_LOCK_STATUS_E* penLockStatus); + int32_t (*frontend_atv_fineTune)(unsigned int hFrontend, unsigned int us32Steps); +}; + +struct TvserviceDtvFrontendVdi* CreateDtvFrontendVdi(); +typedef void (*DestroyDtvFrontendVdiFunc)(struct TvserviceDtvFrontendVdi* vdi); +#endif \ No newline at end of file diff --git a/tvservice/dtv/frontend/interfaces/vdi_base/src/tvservice_dtv_frontend_vdi_impl.c b/tvservice/dtv/frontend/interfaces/vdi_base/src/tvservice_dtv_frontend_vdi_impl.c new file mode 100644 index 0000000000000000000000000000000000000000..fb92706fd3f813efd0799f23572cb6053d3c5bc8 --- /dev/null +++ b/tvservice/dtv/frontend/interfaces/vdi_base/src/tvservice_dtv_frontend_vdi_impl.c @@ -0,0 +1,200 @@ +/* +* Copyright (c) 2025 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 "tvservice_dtv_frontend_vdi_impl.h" +#include +#include +static int32_t frontend_init(FRONTEND_INIT_PARAMS_S* pstInitParams) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static int32_t frontend_open_EX(unsigned int* phFrontend, FRONTEND_OPEN_PARAMS_S* pOpenParams) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static int32_t frontend_close_EX(unsigned int frontend_handle) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static int32_t frontend_term(FRONTEND_TERM_PARAMS_S* pstTermParams) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static int32_t frontend_get_scan_info(unsigned int hFrontend, FRONTEND_SCAN_INFO_S * pstScanInfo) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static int32_t frontend_sat_config_lnb(unsigned int hFrontend,FRONTEND_SAT_LNB_INFO_S* pstLnbInfo) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static int32_t frontend_get_lnb_pwr_status(unsigned int hFrontend,FRONTEND_LNB_PWR_STATUS_E * penLnbPwrStatu) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static int32_t frontend_start_scan(unsigned int hFrontend,FRONTEND_SCAN_INFO_S* pstScanParams, bool bSynch,unsigned int u32Timeout) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static int32_t frontend_abort(unsigned int hFrontend) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static int32_t frontend_register_callback(unsigned int hFrontend,FRONTEND_REG_CALLBACK_PARAMS_S* pstRegParams) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static int32_t frontend_lock(unsigned int hFrontend) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static int32_t frontend_get_bert(unsigned int hFrontend,float* pfBert) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static int32_t frontend_get_signal_quality(unsigned int hFrontend,unsigned int* pu32Quality) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static int32_t frontend_get_signal_strength(unsigned int hFrontend, unsigned int* pu32Strength) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static int32_t frontend_get_atvsignalinfo(unsigned int hFrontend,FRONTEND_ATV_SIGNALINFO_S* pstSignalInfo) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static int32_t frontend_get_connect_status(unsigned int hFrontend,FRONTEND_FE_STATUS_E * penStatus) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static int32_t frontend_get_info(unsigned int hFrontend,FRONTEND_INFO_S* pstInfo) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static int32_t frontend_get_capability(FRONTEND_CAPABILITY_S* pstCapability) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static int32_t frontend_get_channel_num(unsigned int hFrontend,unsigned char* pu8ChannelNum) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static int32_t frontend_get_channel_info(unsigned int hFrontend,unsigned char u8ChannelIndex,FRONTEND_G2_CHANNEL_INFO_S* pstChannelInfo,unsigned int u32Timeout) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static int32_t frontend_config_channel(unsigned int hFrontend,unsigned char u8ChannelIndex,FRONTEND_G2_REQ_PARAMS_S* pstReqParams,FRONTEND_G2_RPN_PARAMS_S* pstRpnParams,unsigned int u32Timeout) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static int32_t frontend_atv_get_lock_status(unsigned int hFrontend, FRONTEND_ATV_LOCK_STATUS_E* penLockStatus) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + +static int32_t frontend_atv_fineTune(unsigned int hFrontend, unsigned int us32Steps) +{ + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + return HDF_SUCCESS; +} + + +struct TvserviceDtvFrontendVdi* CreateDtvFrontendVdi() +{ + struct TvserviceDtvFrontendVdi *vdiImpl = (struct TvserviceDtvFrontendVdi *)OsalMemCalloc(sizeof(struct TvserviceDtvFrontendVdi)); + if (vdiImpl == NULL) { + HDF_LOGE("%{public}s: malloc TvserviceDtvFrontendVdi obj failed!", __func__); + return NULL; + } + // vdiImpl->frontend_init = frontend_init; + // vdiImpl->frontend_open = frontend_open_EX;// Use frontend_open_EX to avoid conflict with the function in tvos_hal_frontend.h + // vdiImpl->frontend_close = frontend_close_EX; // Use frontend_close_EX to avoid conflict with the function in tvos_hal_frontend.h + // vdiImpl->frontend_term = frontend_term; + // vdiImpl->frontend_get_scan_info = frontend_get_scan_info; + // vdiImpl->frontend_sat_config_lnb = frontend_sat_config_lnb; + // vdiImpl->frontend_get_lnb_pwr_status = frontend_get_lnb_pwr_status; + // vdiImpl->frontend_start_scan = frontend_start_scan; + // vdiImpl->frontend_abort = frontend_abort; + // vdiImpl->frontend_register_callback = frontend_register_callback; + // vdiImpl->frontend_lock = frontend_lock; + // vdiImpl->frontend_get_bert = frontend_get_bert; + // vdiImpl->frontend_get_signal_quality = frontend_get_signal_quality; + // vdiImpl->frontend_get_signal_strength = frontend_get_signal_strength; + // vdiImpl->frontend_get_atvsignalinfo = frontend_get_atvsignalinfo; + // vdiImpl->frontend_get_connect_status=frontend_get_connect_status; + // vdiImpl->frontend_get_info = frontend_get_info; + // vdiImpl->frontend_get_capability = frontend_get_capability; + // vdiImpl->frontend_get_channel_num = frontend_get_channel_num; + // vdiImpl->frontend_get_channel_info = frontend_get_channel_info; + // vdiImpl->frontend_config_channel = frontend_config_channel; + // vdiImpl->frontend_atv_get_lock_status = frontend_atv_get_lock_status; + // vdiImpl->frontend_atv_fineTune = frontend_atv_fineTune; + + HDF_LOGI("%s %s %d in", __FILE__,__func__,__LINE__); + + return vdiImpl; +} + +void DestroyDtvFrontendVdi(struct TvserviceDtvFrontendVdi* vdi) +{ + if (vdi == NULL) { + return; + } + OsalMemFree(vdi); +} \ No newline at end of file diff --git a/tvservice/dtv/frontend/utils/include/tvservice_dtv_demux_hdf_log.h b/tvservice/dtv/frontend/utils/include/tvservice_dtv_demux_hdf_log.h new file mode 100644 index 0000000000000000000000000000000000000000..caaa7694c57064aa6be1ae58a6ad039058c1db90 --- /dev/null +++ b/tvservice/dtv/frontend/utils/include/tvservice_dtv_demux_hdf_log.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 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. + */ + + #ifndef TVSERVICE_DTV_DEMUX_HOST_LOG_H + #define TVSERVICE_DTV_DEMUX_HOST_LOG_H + + #include "hdf_log.h" + + #endif //TVSERVICE_DTV_DEMUX_HOST_LOG_H \ No newline at end of file diff --git a/tvservice/hdmi/hdmirx/BUILD.gn b/tvservice/hdmi/hdmirx/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..33f709271e1af22a8df9718f1802a714dbadc770 --- /dev/null +++ b/tvservice/hdmi/hdmirx/BUILD.gn @@ -0,0 +1,19 @@ +# Copyright (c) 2025 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. +import("//build/ohos.gni") + +print("=============tvservice_hdmi_host_entry============") +group("tvservice_hdmi_host_entry") { + deps = [ "interfaces/hdi_service:hdf_tvservice_hdmi_host"] + #deps += [ "interfaces/vdi_base:tvservice_hdmi_vdi_impl_default" ] +} \ No newline at end of file diff --git a/tvservice/hdmi/hdmirx/interfaces/hdi_service/BUILD.gn b/tvservice/hdmi/hdmirx/interfaces/hdi_service/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..e45140b5922966a3f136613517b9bb389b7f7f35 --- /dev/null +++ b/tvservice/hdmi/hdmirx/interfaces/hdi_service/BUILD.gn @@ -0,0 +1,82 @@ +# Copyright (c) 2025 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. +import("//build/ohos.gni") +import("../../../../tvservice.gni") + +ohos_shared_library("libtvservice_hdmi_service_1.0") { + defines = [] + include_dirs = [ + "../../utils/include", + "include" + ] + sources = [ + "src/tvservice_hdmi_service.cpp" + ] + + external_deps = [ + "c_utils:utils", + "hdf_core:libhdf_ipc_adapter", + "hdf_core:libhdi", + "hdf_core:libhdf_host", + "hdf_core:libhdf_utils", + "hilog:libhilog", + "ipc:ipc_single", + "libxml2:libxml2", + "drivers_interface_tvservice:libtvservice_hdmi_stub_1.0", + "drivers_interface_tvservice:libtvservice_hdmi_proxy_1.0", + ] + + if (has_tvservice_hisysevent_part) { + external_deps += [ "hisysevent:libhisysevent" ] + } + + install_images = [ chipset_base_dir ] + subsystem_name = "hdf" + part_name = "drivers_peripheral_tvservice" +} + + +ohos_shared_library("libtvservice_hdmi_driver") { + sources = [ + "src/tvservice_hdmi_driver.cpp" + ] + + external_deps = [ + "c_utils:utils", + "hdf_core:libhdf_ipc_adapter", + "hdf_core:libhdi", + "hdf_core:libhdf_host", + "hdf_core:libhdf_utils", + "hilog:libhilog", + "ipc:ipc_single", + "drivers_interface_tvservice:libtvservice_hdmi_stub_1.0", + "drivers_interface_tvservice:libtvservice_hdmi_proxy_1.0", + ] + if (has_tvservice_c_utils_part) { + external_deps += [ "c_utils:utils" ] + } + + shlib_type = "hdi" + install_images = [ chipset_base_dir ] + subsystem_name = "hdf" + part_name = "drivers_peripheral_tvservice" +} + +group("hdf_tvservice_hdmi_host") { + deps = [ + ":libtvservice_hdmi_driver", + ":libtvservice_hdmi_service_1.0", + ] + +print("=============hdf_tvservice_hdmi_host============") +} \ No newline at end of file diff --git a/tvservice/hdmi/hdmirx/interfaces/hdi_service/include/tvservice_hdmi_service.h b/tvservice/hdmi/hdmirx/interfaces/hdi_service/include/tvservice_hdmi_service.h new file mode 100644 index 0000000000000000000000000000000000000000..1f93cf657cc6557d400bcdba4e02e1c28341baff --- /dev/null +++ b/tvservice/hdmi/hdmirx/interfaces/hdi_service/include/tvservice_hdmi_service.h @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2025 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. + */ + +#ifndef OHOS_HDI_TVSERVICE_HDMI_H +#define OHOS_HDI_TVSERVICE_HDMI_H + +#include "tvservice_hdmi_vdi.h" +#include "v1_0/itvservice_hdmi.h" +#include "v1_0/tvservice_hdmi_types.h" +#include + +#include +#include +#include +#include "hdf_sbuf.h" + +namespace OHOS { +namespace HDI { +namespace Tvservice { +namespace Hdmi { +namespace Hdmirx { +namespace V1_0 { + +class TvserviceHdmiService : public ITvserviceHdmi { +public: + TvserviceHdmiService(); + virtual ~TvserviceHdmiService(); + int32_t RxCecCtrlSetCommand(const CecCmd& cmd) override; + int32_t RxCecCtrlGetCommand(CecCmd& cmd) override; + int32_t RxCecCtrlGetCurCmdState(HdmiRxCecCmdState& state) override; + int32_t RxCecCtrlSetOneTouchPlayEnable(bool oneTouchPlay) override; + + int32_t SetEnhancedArcEnable(bool enhancedArc) override; + int32_t GetEnhancedArcState(EnhancedArcStateType& state) override; + int32_t GetEnhancedArcSadInfo(ShortAudioDescriptorInfo& sadInfo) override; + int32_t RxCecEnable(bool enable) override; + +private: + int32_t LoadVdiSo(); + int32_t LoadVdiV1_0(); + +private: + /* Common */ + void* libHandle_; + std::mutex mutex_; + + /* V1_0, which is the version of vdi */ + TvserviceHdmiVdi* vdiImpl_; + DestroyHdmiVdiFunc destroyVdiFunc_; +}; + +} // V1_0 +} // Hdmirx +} // Hdmi +} // Tvservice +} // HDI +} // OHOS +#endif // OHOS_HDI_TVSERVICE_HDMI_H \ No newline at end of file diff --git a/tvservice/hdmi/hdmirx/interfaces/hdi_service/include/tvservice_hdmi_vdi.h b/tvservice/hdmi/hdmirx/interfaces/hdi_service/include/tvservice_hdmi_vdi.h new file mode 100644 index 0000000000000000000000000000000000000000..6ddf9c47ac9283737636418b70261d7514ced38e --- /dev/null +++ b/tvservice/hdmi/hdmirx/interfaces/hdi_service/include/tvservice_hdmi_vdi.h @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2025 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. + */ + +#ifndef OHOS_HDI_TVSERVICE_HDMI_VDI_H +#define OHOS_HDI_TVSERVICE_HDMI_VDI_H + +#include +#include +#include "v1_0/itvservice_hdmi.h" +#include "v1_0/tvservice_hdmi_types.h" + +namespace OHOS { +namespace HDI { +namespace Tvservice { +namespace Hdmi { +namespace Hdmirx { +namespace V1_0 { +using namespace OHOS::HDI::Tvservice::Hdmi::Hdmirx::V1_0; + +#define TVSERVICE_HDMI_VDI_LIBRARY "libtvservice_hdmi_vdi_impl_default.z.so" + +class TvserviceHdmiVdi { +public: + virtual ~TvserviceHdmiVdi() = default; + virtual int32_t RxCecCtrlSetCommand(const CecCmd& cmd) = 0; + virtual int32_t RxCecCtrlGetCommand(CecCmd& cmd) = 0; + virtual int32_t RxCecCtrlGetCurCmdState(HdmiRxCecCmdState& state) = 0; + virtual int32_t RxCecCtrlSetOneTouchPlayEnable(bool oneTouchPlay) = 0; + + virtual int32_t SetEnhancedArcEnable(bool EnhancedArc) = 0; + virtual int32_t GetEnhancedArcState(EnhancedArcStateType& state) = 0; + virtual int32_t GetEnhancedArcSadInfo(ShortAudioDescriptorInfo& state) = 0; + virtual int32_t RxCecEnable(bool enable) = 0; +}; + +using CreateHdmiVdiFunc = TvserviceHdmiVdi* (*)(); +using DestroyHdmiVdiFunc = void (*)(TvserviceHdmiVdi* vdi); +extern "C" TvserviceHdmiVdi* CreateHdmiVdi(); +extern "C" void DestroyHdmiVdi(TvserviceHdmiVdi* vdi); +} // namespace V1_0 +} // namespace Hdmirx +} // namespace Hdmi +} // namespace Tvservice +} // namespace HDI +} // namespace OHOS +#endif // OHOS_HDI_TVSERVICE_HDMI_VDI_H \ No newline at end of file diff --git a/tvservice/hdmi/hdmirx/interfaces/hdi_service/src/tvservice_hdmi_driver.cpp b/tvservice/hdmi/hdmirx/interfaces/hdi_service/src/tvservice_hdmi_driver.cpp new file mode 100644 index 0000000000000000000000000000000000000000..54977a12915cf1420dc06f35e28ddea378a62fec --- /dev/null +++ b/tvservice/hdmi/hdmirx/interfaces/hdi_service/src/tvservice_hdmi_driver.cpp @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2025 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 +#include "v1_0/tvservice_hdmi_stub.h" + +#define HDF_LOG_TAG tvservice_hdmi_driver + +using namespace OHOS::HDI::Tvservice::Hdmi::Hdmirx::V1_0; + +struct HdfTvserviceHdmiHost { + struct IDeviceIoService ioService; + OHOS::sptr stub; +}; + +static int32_t TvserviceHdmiDriverDispatch(struct HdfDeviceIoClient *client, int cmdId, struct HdfSBuf *data, + struct HdfSBuf *reply) +{ + auto *hdfTvserviceHdmiHost = CONTAINER_OF(client->device->service, struct HdfTvserviceHdmiHost, ioService); + + OHOS::MessageParcel *dataParcel = nullptr; + OHOS::MessageParcel *replyParcel = nullptr; + OHOS::MessageOption option; + + if (SbufToParcel(data, &dataParcel) != HDF_SUCCESS) { + HDF_LOGE("%{public}s: invalid data sbuf object to dispatch", __func__); + return HDF_ERR_INVALID_PARAM; + } + if (SbufToParcel(reply, &replyParcel) != HDF_SUCCESS) { + HDF_LOGE("%{public}s: invalid reply sbuf object to dispatch", __func__); + return HDF_ERR_INVALID_PARAM; + } + + return hdfTvserviceHdmiHost->stub->SendRequest(cmdId, *dataParcel, *replyParcel, option); +} + +static int HdfTvserviceHdmiDriverInit(struct HdfDeviceObject *deviceObject) +{ + HDF_LOGI("%{public}s: driver init start", __func__); + return HDF_SUCCESS; +} + +static int HdfTvserviceHdmiDriverBind(struct HdfDeviceObject *deviceObject) +{ + HDF_LOGI("%{public}s: driver bind start", __func__); + auto *hdfTvserviceHdmiHost = new (std::nothrow) HdfTvserviceHdmiHost; + if (hdfTvserviceHdmiHost == nullptr) { + HDF_LOGE("%{public}s: failed to create create HdfTvserviceHdmiHost object", __func__); + return HDF_FAILURE; + } + + hdfTvserviceHdmiHost->ioService.Dispatch = TvserviceHdmiDriverDispatch; + hdfTvserviceHdmiHost->ioService.Open = NULL; + hdfTvserviceHdmiHost->ioService.Release = NULL; + + auto serviceImpl = OHOS::HDI::Tvservice::Hdmi::Hdmirx::V1_0::ITvserviceHdmi::Get(true); + if (serviceImpl == nullptr) { + HDF_LOGE("%{public}s: failed to get of implement service", __func__); + delete hdfTvserviceHdmiHost; + return HDF_FAILURE; + } + + hdfTvserviceHdmiHost->stub = OHOS::HDI::ObjectCollector::GetInstance().GetOrNewObject(serviceImpl, + OHOS::HDI::Tvservice::Hdmi::Hdmirx::V1_0::ITvserviceHdmi::GetDescriptor()); + if (hdfTvserviceHdmiHost->stub == nullptr) { + HDF_LOGE("%{public}s: failed to get stub object", __func__); + delete hdfTvserviceHdmiHost; + return HDF_FAILURE; + } + + deviceObject->service = &hdfTvserviceHdmiHost->ioService; + return HDF_SUCCESS; +} + +static void HdfTvserviceHdmiDriverRelease(struct HdfDeviceObject *deviceObject) +{ + HDF_LOGI("%{public}s: driver release start", __func__); + if (deviceObject->service == nullptr) { + return; + } + + auto *hdfTvserviceHdmiHost = CONTAINER_OF(deviceObject->service, struct HdfTvserviceHdmiHost, ioService); + if (hdfTvserviceHdmiHost != nullptr) { + delete hdfTvserviceHdmiHost; + } +} + +struct HdfDriverEntry g_tvservicehdmiDriverEntry = { + .moduleVersion = 1, + .moduleName = "tvservice_hdmirx_service", + .Bind = HdfTvserviceHdmiDriverBind, + .Init = HdfTvserviceHdmiDriverInit, + .Release = HdfTvserviceHdmiDriverRelease, +}; + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ +HDF_INIT(g_tvservicehdmiDriverEntry); +#ifdef __cplusplus +} +#endif /* __cplusplus */ diff --git a/tvservice/hdmi/hdmirx/interfaces/hdi_service/src/tvservice_hdmi_service.cpp b/tvservice/hdmi/hdmirx/interfaces/hdi_service/src/tvservice_hdmi_service.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8cab3b7dfaa800ce6821aedeb7f7917b1768087c --- /dev/null +++ b/tvservice/hdmi/hdmirx/interfaces/hdi_service/src/tvservice_hdmi_service.cpp @@ -0,0 +1,191 @@ +/* + * Copyright (c) 2025 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 "tvservice_hdmi_service.h" +#include "tvservice_hdmi_vdi.h" +#include +#include +#include +#include +#include +#include +#include "osal_mem.h" +#define HDF_LOG_TAG TvserviceHdmiImpl + +namespace OHOS { +namespace HDI { +namespace Tvservice { +namespace Hdmi { +namespace Hdmirx { +namespace V1_0 { +extern "C" ITvserviceHdmi* TvserviceHdmiImplGetInstance(void) +{ + return new (std::nothrow) TvserviceHdmiService(); +} + +TvserviceHdmiService::TvserviceHdmiService(): libHandle_(nullptr), vdiImpl_(nullptr) +{ + HDF_LOGI("enter %s", __func__); + int32_t ret = LoadVdiSo(); + if (ret != HDF_SUCCESS) { + HDF_LOGE("Load tvservice hdmi VDI failed, lib: %{public}s", TVSERVICE_HDMI_VDI_LIBRARY); + return; + } + + ret = LoadVdiV1_0(); + + if (ret != HDF_SUCCESS) { + dlclose(libHandle_); + libHandle_ = nullptr; + HDF_LOGE("Load tvservice hdmi VDI function failed"); + } + HDF_LOGI("end %s", __func__); + +} + + +TvserviceHdmiService::~TvserviceHdmiService() +{ + +} + +int32_t TvserviceHdmiService::LoadVdiSo() +{ + const char* errStr = dlerror(); + HDF_LOGI("enter %s", __func__); + if (errStr != nullptr) { + HDF_LOGE("hdmi load vdi, clear earlier dlerror: %{public}s", errStr); + } + libHandle_ = dlopen(TVSERVICE_HDMI_VDI_LIBRARY, RTLD_LAZY); + if (libHandle_ == nullptr) { + HDF_LOGE("hdmi load vendor vdi default library failed: %{public}s", + TVSERVICE_HDMI_VDI_LIBRARY); + + } else { + HDF_LOGI("hdmi load vendor vdi default library: %{public}s", TVSERVICE_HDMI_VDI_LIBRARY); + } + HDF_LOGI("end %s", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceHdmiService::LoadVdiV1_0() +{ + CreateHdmiVdiFunc createVdiFunc = nullptr; + const char* errStr = nullptr; + HDF_LOGI("enter %s", __func__); + createVdiFunc = reinterpret_cast(dlsym(libHandle_, "CreateHdmiVdi")); + if (createVdiFunc == nullptr) { + errStr = dlerror(); + if (errStr != nullptr) { + HDF_LOGE("CreateHdmiVdiFunc dlsym error: %{public}s", errStr); + } + return HDF_FAILURE; + } + + destroyVdiFunc_ = reinterpret_cast(dlsym(libHandle_, "DestroyHdmiVdi")); + if (destroyVdiFunc_ == nullptr) { + errStr = dlerror(); + if (errStr != nullptr) { + HDF_LOGE("DestroyHdmiVdiFunc dlsym error: %{public}s", errStr); + } + return HDF_FAILURE; + } + HDF_LOGI("end %s", __func__); + vdiImpl_ = createVdiFunc(); + return HDF_SUCCESS; +} + +int32_t TvserviceHdmiService::RxCecCtrlSetCommand(const CecCmd& cmd) +{ + HDF_LOGI("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->RxCecCtrlSetCommand(cmd); +} + +int32_t TvserviceHdmiService::RxCecCtrlGetCommand(CecCmd& cmd) +{ + HDF_LOGI("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->RxCecCtrlGetCommand(cmd); +} +int32_t TvserviceHdmiService::RxCecCtrlGetCurCmdState(HdmiRxCecCmdState& state) +{ + HDF_LOGI("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->RxCecCtrlGetCurCmdState(state); +} +int32_t TvserviceHdmiService::RxCecCtrlSetOneTouchPlayEnable(bool oneTouchPlay) +{ + HDF_LOGI("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->RxCecCtrlSetOneTouchPlayEnable(oneTouchPlay); +} + +int32_t TvserviceHdmiService::SetEnhancedArcEnable(bool EnhancedArc) +{ + HDF_LOGI("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->SetEnhancedArcEnable(EnhancedArc); +} + +int32_t TvserviceHdmiService::GetEnhancedArcState(EnhancedArcStateType& state) +{ + HDF_LOGI("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->GetEnhancedArcState(state); +} + +int32_t TvserviceHdmiService::GetEnhancedArcSadInfo(ShortAudioDescriptorInfo& sadInfo) +{ + HDF_LOGI("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->GetEnhancedArcSadInfo(sadInfo); +} + +int32_t TvserviceHdmiService::RxCecEnable(bool enable) +{ + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->RxCecEnable(enable); +} +} // V1_0 +} // Hdmirx +} // Hdmi +} // Tvservice +} // HDI +} // OHOS diff --git a/tvservice/hdmi/hdmirx/interfaces/vdi_base/BUILD.gn b/tvservice/hdmi/hdmirx/interfaces/vdi_base/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..c2a0cf48e869ca26fe9b9c016f5db1f40c500373 --- /dev/null +++ b/tvservice/hdmi/hdmirx/interfaces/vdi_base/BUILD.gn @@ -0,0 +1,49 @@ +# Copyright (C) 2025 HiHope Open Source Organization . +# 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. + +import("//build/ohos.gni") +import("../../../tvservice.gni") +import("//vendor/${product_company}/${product_name}/product.gni") + +ohos_shared_library("tvservice_hdmi_vdi_impl_default") { + defines = [] + sources = [ + "src/tvservice_hdmi_vdi_impl.cpp", + ] + output_name = "tvservice_hdmi_vdi_impl_default" + include_dirs = [ + "include", + "../hdi_service/include", + "../../utils/include", + ] + cflags_cc = [ + "-fPIC", + "-Wall", + "-Wno-error=unused-function", + "-Wno-error=missing-braces", + "-Wno-error=#warnings", + ] + external_deps = [ + "c_utils:utils", + "drivers_interface_tvservice:libtvservice_hdmi_stub_1.0", + "drivers_interface_tvservice:libtvservice_hdmi_proxy_1.0", + "hdf_core:libhdf_utils", + "hilog:libhilog", + "hitrace:hitrace_meter", + "ipc:ipc_single", + ] + install_enable = true + install_images = [ chipset_base_dir ] + subsystem_name = "hdf" + part_name = "drivers_peripheral_tvservice" +} \ No newline at end of file diff --git a/tvservice/hdmi/hdmirx/interfaces/vdi_base/include/tvservice_hdmi_vdi_impl.h b/tvservice/hdmi/hdmirx/interfaces/vdi_base/include/tvservice_hdmi_vdi_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..b22b8468aca9583daf6e12dd391c000f637aa929 --- /dev/null +++ b/tvservice/hdmi/hdmirx/interfaces/vdi_base/include/tvservice_hdmi_vdi_impl.h @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2025 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. + */ + +#ifndef TVSERVICE_HDMI_VDI_IMPL_H +#define TVSERVICE_HDMI_VDI_IMPL_H + +#include "tvservice_hdmi_vdi.h" +#include "v1_0/tvservice_hdmi_types.h" + +namespace OHOS { +namespace HDI { +namespace Tvservice { +namespace Hdmi { +namespace Hdmirx { +using namespace OHOS::HDI::Tvservice::Hdmi; + +class TvserviceHdmiVdiImpl : public V1_0::TvserviceHdmiVdi { +public: + TvserviceHdmiVdiImpl(); + virtual ~TvserviceHdmiVdiImpl(); + int32_t RxCecCtrlSetCommand(const V1_0::CecCmd& cmd) override; + int32_t RxCecCtrlGetCommand(V1_0::CecCmd& cmd) override; + int32_t RxCecCtrlGetCurCmdState(V1_0::HdmiRxCecCmdState& state) override; + int32_t RxCecCtrlSetOneTouchPlayEnable(bool oneTouchPlay) override; + int32_t SetEnhancedArcEnable(bool EnhancedArc) override; + int32_t GetEnhancedArcState(V1_0::EnhancedArcStateType& state) override; + int32_t GetEnhancedArcSadInfo(V1_0::ShortAudioDescriptorInfo& sadInfo) override; + int32_t RxCecEnable(bool enable) override; +private: +}; +} // Hdmirx +} // Hdmi +} // Tvservice +} // HDI +} // OHOS +#endif // TVSERVICE_HDMI_VDI_IMPL_H diff --git a/tvservice/hdmi/hdmirx/interfaces/vdi_base/src/tvservice_hdmi_vdi_impl.cpp b/tvservice/hdmi/hdmirx/interfaces/vdi_base/src/tvservice_hdmi_vdi_impl.cpp new file mode 100644 index 0000000000000000000000000000000000000000..02983d58a2ef3b074f5e98aed57d0985133a4656 --- /dev/null +++ b/tvservice/hdmi/hdmirx/interfaces/vdi_base/src/tvservice_hdmi_vdi_impl.cpp @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2025 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 "tvservice_hdmi_vdi_impl.h" +#include +#include "tvservice_hdmi_hdf_log.h" +#include "hdf_log.h" + +#include +#include +#include +#include "securec.h" + +using namespace std; + +namespace OHOS { +namespace HDI { +namespace Tvservice { +namespace Hdmi { +namespace Hdmirx { + +TvserviceHdmiVdiImpl::TvserviceHdmiVdiImpl() +{ +} + +TvserviceHdmiVdiImpl::~TvserviceHdmiVdiImpl() +{ +} + +int32_t TvserviceHdmiVdiImpl::RxCecCtrlSetCommand(const V1_0::CecCmd& cmd) +{ + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; +} +int32_t TvserviceHdmiVdiImpl::RxCecCtrlGetCommand(V1_0::CecCmd& cmd) +{ + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceHdmiVdiImpl::RxCecCtrlGetCurCmdState(V1_0::HdmiRxCecCmdState& state) +{ + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceHdmiVdiImpl::RxCecCtrlSetOneTouchPlayEnable(bool oneTouchPlay) +{ + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceHdmiVdiImpl::SetEnhancedArcEnable(bool EnhancedArc) +{ + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceHdmiVdiImpl::GetEnhancedArcState(V1_0::EnhancedArcStateType& state) +{ + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; +} +int32_t TvserviceHdmiVdiImpl::GetEnhancedArcSadInfo(V1_0::ShortAudioDescriptorInfo& sadInfo) +{ + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceHdmiVdiImpl::RxCecEnable(bool enable) +{ + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; +} + +extern "C" V1_0::TvserviceHdmiVdi *CreateHdmiVdi() +{ + return new TvserviceHdmiVdiImpl(); +} + +extern "C" void DestroyHdmiVdi(V1_0::TvserviceHdmiVdi* vdi) +{ + delete vdi; +} +} // Hdmirx +} // Hdmi +} // Tvservice +} // HDI +} // OHOS \ No newline at end of file diff --git a/tvservice/hdmi/hdmirx/utils/include/tvservice_hdmi_hdf_log.h b/tvservice/hdmi/hdmirx/utils/include/tvservice_hdmi_hdf_log.h new file mode 100644 index 0000000000000000000000000000000000000000..62ece8f1ea9520c99aa96c960dbcdcc783b99222 --- /dev/null +++ b/tvservice/hdmi/hdmirx/utils/include/tvservice_hdmi_hdf_log.h @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2025 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. + */ + +#ifndef TVSERVICE_LOG_H +#define TVSERVICE_LOG_H +#include +#include +#include "hilog/log.h" + +#ifdef HDF_LOG_TAG +#undef HDF_LOG_TAG +#endif + +#if defined(__cplusplus) +extern "C" { +#endif + +#undef LOG_TAG +#define LOG_TAG "TVS-V" +#undef LOG_DOMAIN +#define LOG_DOMAIN 0xD002515 + +#ifndef TVSERVICE_UNUSED +#define TVSERVICE_UNUSED(x) (void)(x) +#endif + +#ifndef TVSERVICE_DEBUG_ENABLE +#define TVSERVICE_DEBUG_ENABLE 1 +#endif + +#ifndef TVSERVICE_LOGD +#define TVSERVICE_LOGD(format, ...) \ + do { \ + if (TVSERVICE_DEBUG_ENABLE) { \ + HILOG_DEBUG(LOG_CORE, "[%{public}s:%{public}d] " format "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__); \ + } \ + } while (0) +#endif + +#ifndef TVSERVICE_LOGI +#define TVSERVICE_LOGI(format, ...) \ + do { \ + HILOG_INFO(LOG_CORE, "[%{public}s:%{public}d] " format "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__); \ + } while (0) +#endif + +#ifndef TVSERVICE_LOGW +#define TVSERVICE_LOGW(format, ...) \ + do { \ + HILOG_WARN(LOG_CORE, "[%{public}s:%{public}d] " format "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__); \ + } while (0) +#endif + +#ifndef TVSERVICE_LOGE +#define TVSERVICE_LOGE(format, ...) \ + do { \ + HILOG_ERROR(LOG_CORE, \ + "\033[0;32;31m" \ + "[%{public}s:%{public}d] " format "\033[m" \ + "\n", \ + __FUNCTION__, __LINE__, ##__VA_ARGS__); \ + } while (0) +#endif + +#ifndef CHECK_NULLPOINTER_RETURN_VALUE +#define CHECK_NULLPOINTER_RETURN_VALUE(pointer, ret) \ + do { \ + if ((pointer) == NULL) { \ + TVSERVICE_LOGE("pointer is null and return ret\n"); \ + return (ret); \ + } \ + } while (0) +#endif + +#ifndef CHECK_NULLPOINTER_RETURN +#define CHECK_NULLPOINTER_RETURN(pointer) \ + do { \ + if ((pointer) == NULL) { \ + TVSERVICE_LOGE("pointer is null and return\n"); \ + return; \ + } \ + } while (0) +#endif + +#ifndef TVSERVICE_CHK_RETURN +#define TVSERVICE_CHK_RETURN(val, ret, ...) \ + do { \ + if (val) { \ + __VA_ARGS__; \ + return (ret); \ + } \ + } while (0) +#endif + +#ifndef TVSERVICE_CHK_RETURN_NOT_VALUE +#define TVSERVICE_CHK_RETURN_NOT_VALUE(val, ...) \ + do { \ + if (val) { \ + __VA_ARGS__; \ + return; \ + } \ + } while (0) +#endif + +#ifdef __cplusplus +} +#endif + +#endif // TVSERVICE_LOG_H \ No newline at end of file diff --git a/tvservice/hdmi/hdmitx/BUILD.gn b/tvservice/hdmi/hdmitx/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..237d6f7633004dfda8f7ff65bef2d892f626d062 --- /dev/null +++ b/tvservice/hdmi/hdmitx/BUILD.gn @@ -0,0 +1,19 @@ +# Copyright (c) 2025 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. +import("//build/ohos.gni") + +print("=============tvservice_hdmi_host_entry============") +group("tvservice_hdmitx_host_entry") { + deps = [ "interfaces/hdi_service:hdf_tvservice_hdmi_host"] + deps += [ "interfaces/vdi_base:tvservice_hdmitx_vdi_impl_default" ] +} \ No newline at end of file diff --git a/tvservice/hdmi/hdmitx/interfaces/hdi_service/BUILD.gn b/tvservice/hdmi/hdmitx/interfaces/hdi_service/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..b4a3e8dfae07f14063d40701390ee4cd10828f3a --- /dev/null +++ b/tvservice/hdmi/hdmitx/interfaces/hdi_service/BUILD.gn @@ -0,0 +1,80 @@ +# Copyright (c) 2025 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. +import("//build/ohos.gni") +import("../../../../tvservice.gni") + +ohos_shared_library("libtvservice_hdmitx_service_1.0") { + defines = [] + include_dirs = [ + "../../utils/include", + "include" + ] + sources = [ + "src/tvservice_hdmitx_service.cpp" + ] + + external_deps = [ + "c_utils:utils", + "hdf_core:libhdf_ipc_adapter", + "hdf_core:libhdi", + "hdf_core:libhdf_host", + "hdf_core:libhdf_utils", + "hilog:libhilog", + "ipc:ipc_single", + "libxml2:libxml2", + "drivers_interface_tvservice:libtvservice_hdmitx_stub_1.0", + "drivers_interface_tvservice:libtvservice_hdmitx_proxy_1.0", + ] + + if (has_tvservice_hisysevent_part) { + external_deps += [ "hisysevent:libhisysevent" ] + } + + install_images = [ chipset_base_dir ] + subsystem_name = "hdf" + part_name = "drivers_peripheral_tvservice" +} + +ohos_shared_library("libtvservice_hdmitx_driver") { + sources = [ + "src/tvservice_hdmitx_driver.cpp" + ] + + external_deps = [ + "c_utils:utils", + "hdf_core:libhdf_ipc_adapter", + "hdf_core:libhdi", + "hdf_core:libhdf_host", + "hdf_core:libhdf_utils", + "hilog:libhilog", + "ipc:ipc_single", + "drivers_interface_tvservice:libtvservice_hdmitx_stub_1.0", + "drivers_interface_tvservice:libtvservice_hdmitx_proxy_1.0", + ] + if (has_tvservice_c_utils_part) { + external_deps += [ "c_utils:utils" ] + } + + shlib_type = "hdi" + install_images = [ chipset_base_dir ] + subsystem_name = "hdf" + part_name = "drivers_peripheral_tvservice" +} + +group("hdf_tvservice_hdmi_host") { + deps = [ + ":libtvservice_hdmitx_driver", + ":libtvservice_hdmitx_service_1.0", + ] + +} \ No newline at end of file diff --git a/tvservice/hdmi/hdmitx/interfaces/hdi_service/include/tvservice_hdmitx_service.h b/tvservice/hdmi/hdmitx/interfaces/hdi_service/include/tvservice_hdmitx_service.h new file mode 100644 index 0000000000000000000000000000000000000000..b3c8bd880e5efde08159ae40836b5660566d0c14 --- /dev/null +++ b/tvservice/hdmi/hdmitx/interfaces/hdi_service/include/tvservice_hdmitx_service.h @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2025 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. + */ + +#ifndef TVSERVICE_HDMI_HDMITX_H +#define TVSERVICE_HDMI_HDMITX_H + +#include "tvservice_hdmitx_vdi.h" +#include "v1_0/itvservice_hdmitx.h" +#include +#include +#include +#include +#include +#include +#include + +namespace OHOS { +namespace HDI { +namespace Tvservice { +namespace Hdmi { +namespace Hdmitx { +namespace V1_0 { +class TvserviceHdmitxService : public ITvserviceHdmitx { +public: + TvserviceHdmitxService() ; + virtual ~TvserviceHdmitxService() = default; + int32_t HDMITXEnable(HdmitxPortType port, bool enable) override; + int32_t LoadVdiV1_0(); + int32_t LoadVdiSo(); + int32_t GetDisplayMode(int32_t dispid, MwDisplayMode& mode) override; + int32_t GetDisplaySupportedModeList(int32_t dispid,MwDisplayAvailableMode& mode) override; + int32_t SetDisplayMode(int32_t dispid,const MwDisplayMode& mode) override; +private: + void* libHandle_ = nullptr; + DestroyHdmitxVdiFunc destroyVdiFunc_ = nullptr; + TvserviceHdmitxVdi* vdiImpl_ = nullptr; +}; +} // V1_0 +} // Hdmitx +} // Hdmi +} // Tvservice +} // HDI +} // OHOS + +#endif // OHOS_HDI_TVSERVICE_HDMI_HDMITX_V1_0_TVSERVICEHDMITXSERVICE_H + diff --git a/tvservice/hdmi/hdmitx/interfaces/hdi_service/include/tvservice_hdmitx_vdi.h b/tvservice/hdmi/hdmitx/interfaces/hdi_service/include/tvservice_hdmitx_vdi.h new file mode 100644 index 0000000000000000000000000000000000000000..45a8b3d83c9a329ae5e618f96a7d093ce28cd3c7 --- /dev/null +++ b/tvservice/hdmi/hdmitx/interfaces/hdi_service/include/tvservice_hdmitx_vdi.h @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2025 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. + */ + +#ifndef OHOS_HDI_TVSERVICE_HDMITX_VDI_H +#define OHOS_HDI_TVSERVICE_HDMITX_VDI_H + +#include +#include +#include "v1_0/itvservice_hdmitx.h" +#include "v1_0/tvservice_hdmitx_types.h" + +namespace OHOS { +namespace HDI { +namespace Tvservice { +namespace Hdmi { +namespace Hdmitx { +namespace V1_0 { +using namespace OHOS::HDI::Tvservice::Hdmi::Hdmitx::V1_0; + +#define TVSERVICE_HDMITX_VDI_LIBRARY "libtvservice_hdmitx_vdi_impl_default.z.so" + +class TvserviceHdmitxVdi { +public: + virtual ~TvserviceHdmitxVdi() = default; + virtual int32_t HDMITXEnable(HdmitxPortType port, bool enable) = 0; + virtual int32_t GetDisplayMode(int32_t dispid, MwDisplayMode& mode) = 0; + virtual int32_t GetDisplaySupportedModeList(int32_t dispid,MwDisplayAvailableMode& mode) = 0; + virtual int32_t SetDisplayMode(int32_t dispid,const MwDisplayMode& mode) = 0; +}; + +using CreateHdmitxVdiFunc = TvserviceHdmitxVdi* (*)(); +using DestroyHdmitxVdiFunc = void (*)(TvserviceHdmitxVdi* vdi); +extern "C" TvserviceHdmitxVdi* CreateHdmiVdi(); +extern "C" void DestroyHdmitxVdi(TvserviceHdmitxVdi* vdi); +} // V1_0 +} // Hdmitx +} // Hdmi +} // Tvservice +} // HDI +} // OHOS +#endif // OHOS_HDI_TVSERVICE_HDMI_VDI_H \ No newline at end of file diff --git a/tvservice/hdmi/hdmitx/interfaces/hdi_service/src/tvservice_hdmitx_driver.cpp b/tvservice/hdmi/hdmitx/interfaces/hdi_service/src/tvservice_hdmitx_driver.cpp new file mode 100644 index 0000000000000000000000000000000000000000..658f149546d8b9e98455e8fb45181ad31946a525 --- /dev/null +++ b/tvservice/hdmi/hdmitx/interfaces/hdi_service/src/tvservice_hdmitx_driver.cpp @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2025 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 +#include "v1_0/tvservice_hdmitx_stub.h" + +#define HDF_LOG_TAG tvservice_hdmitx_driver + +using namespace OHOS::HDI::Tvservice::Hdmi::Hdmitx::V1_0; + +struct HdfTvserviceHdmitxHost { + struct IDeviceIoService ioService; + OHOS::sptr stub; +}; + +static int32_t TvserviceHdmitxDriverDispatch(struct HdfDeviceIoClient *client, int cmdId, struct HdfSBuf *data, struct HdfSBuf *reply) +{ + auto *hdfTvserviceHdmitxHost = CONTAINER_OF(client->device->service, struct HdfTvserviceHdmitxHost, ioService); + if (hdfTvserviceHdmitxHost == nullptr) { + HDF_LOGE("%{public}s:hdfTvserviceHdmitxHost nullptr", __func__); + return HDF_FAILURE; + } + + OHOS::MessageParcel *dataParcel = nullptr; + OHOS::MessageParcel *replyParcel = nullptr; + OHOS::MessageOption option; + + if (SbufToParcel(data, &dataParcel) != HDF_SUCCESS) { + HDF_LOGE("%{public}s: invalid data sbuf object to dispatch", __func__); + return HDF_ERR_INVALID_PARAM; + } + if (SbufToParcel(reply, &replyParcel) != HDF_SUCCESS) { + HDF_LOGE("%{public}s: invalid reply sbuf object to dispatch", __func__); + return HDF_ERR_INVALID_PARAM; + } + + return hdfTvserviceHdmitxHost->stub->SendRequest(cmdId, *dataParcel, *replyParcel, option); +} + +static int HdfTvserviceHdmitxDriverInit(struct HdfDeviceObject *deviceObject) +{ + HDF_LOGI("%{public}s: driver init start", __func__); + return HDF_SUCCESS; +} + +static int HdfTvserviceHdmitxDriverBind(struct HdfDeviceObject *deviceObject) +{ + HDF_LOGI("%{public}s: driver bind start", __func__); + auto *hdfTvserviceHdmitxHost = new (std::nothrow) HdfTvserviceHdmitxHost; + if (hdfTvserviceHdmitxHost == nullptr) { + HDF_LOGE("%{public}s: failed to create create HdfTvserviceHdmitxHost object", __func__); + return HDF_FAILURE; + } + + hdfTvserviceHdmitxHost->ioService.Dispatch = TvserviceHdmitxDriverDispatch; + hdfTvserviceHdmitxHost->ioService.Open = NULL; + hdfTvserviceHdmitxHost->ioService.Release = NULL; + + auto serviceImpl = OHOS::HDI::Tvservice::Hdmi::Hdmitx::V1_0::ITvserviceHdmitx::Get(true); + if (serviceImpl == nullptr) { + HDF_LOGE("%{public}s: failed to get of implement service", __func__); + delete hdfTvserviceHdmitxHost; + return HDF_FAILURE; + } + + hdfTvserviceHdmitxHost->stub = OHOS::HDI::ObjectCollector::GetInstance().GetOrNewObject(serviceImpl, + OHOS::HDI::Tvservice::Hdmi::Hdmitx::V1_0::ITvserviceHdmitx::GetDescriptor()); + if (hdfTvserviceHdmitxHost->stub == nullptr) { + HDF_LOGE("%{public}s: failed to get stub object", __func__); + delete hdfTvserviceHdmitxHost; + return HDF_FAILURE; + } + + deviceObject->service = &hdfTvserviceHdmitxHost->ioService; + return HDF_SUCCESS; +} + +static void HdfTvserviceHdmitxDriverRelease(struct HdfDeviceObject *deviceObject) +{ + HDF_LOGI("%{public}s: driver release start", __func__); + if (deviceObject->service == nullptr) { + return; + } + + auto *hdfTvserviceHdmitxHost = CONTAINER_OF(deviceObject->service, struct HdfTvserviceHdmitxHost, ioService); + if (hdfTvserviceHdmitxHost != nullptr) { + delete hdfTvserviceHdmitxHost; + } +} + +struct HdfDriverEntry g_tvservicehdmitxDriverEntry = { + .moduleVersion = 1, + .moduleName = "tvservice_hdmitx_service", + .Bind = HdfTvserviceHdmitxDriverBind, + .Init = HdfTvserviceHdmitxDriverInit, + .Release = HdfTvserviceHdmitxDriverRelease, +}; + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ +HDF_INIT(g_tvservicehdmitxDriverEntry); +#ifdef __cplusplus +} +#endif /* __cplusplus */ diff --git a/tvservice/hdmi/hdmitx/interfaces/hdi_service/src/tvservice_hdmitx_service.cpp b/tvservice/hdmi/hdmitx/interfaces/hdi_service/src/tvservice_hdmitx_service.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c63c54a02cd81a7065b406bc38c75f18761b42f6 --- /dev/null +++ b/tvservice/hdmi/hdmitx/interfaces/hdi_service/src/tvservice_hdmitx_service.cpp @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2025 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 "tvservice_hdmitx_service.h" +#include +#include + +#define HDF_LOG_TAG tvservice_hdmitx_service + +namespace OHOS { +namespace HDI { +namespace Tvservice { +namespace Hdmi { +namespace Hdmitx { +namespace V1_0 { +extern "C" ITvserviceHdmitx *TvserviceHdmitxImplGetInstance(void) +{ + return new (std::nothrow) TvserviceHdmitxService(); +} + +TvserviceHdmitxService::TvserviceHdmitxService(): libHandle_(nullptr), vdiImpl_(nullptr) +{ + HDF_LOGI("enter %s", __func__); + int32_t ret = LoadVdiSo(); + if (ret != HDF_SUCCESS) { + HDF_LOGE("Load tvservice hdmi VDI failed, lib: %{public}s", TVSERVICE_HDMITX_VDI_LIBRARY); + return; + } + + ret = LoadVdiV1_0(); + + if (ret != HDF_SUCCESS) { + dlclose(libHandle_); + libHandle_ = nullptr; + HDF_LOGE("Load tvservice hdmi VDI function failed"); + } + HDF_LOGI("end %s", __func__); +} + +int32_t TvserviceHdmitxService::LoadVdiSo() +{ + const char* errStr = dlerror(); + HDF_LOGI("enter %s", __func__); + if (errStr != nullptr) { + HDF_LOGE("hdmi load vdi, clear earlier dlerror: %{public}s", errStr); + } + libHandle_ = dlopen(TVSERVICE_HDMITX_VDI_LIBRARY, RTLD_LAZY); + if (libHandle_ == nullptr) { + HDF_LOGE("hdmi load vendor vdi default library failed: %{public}s", TVSERVICE_HDMITX_VDI_LIBRARY); + + } else { + HDF_LOGI("hdmi load vendor vdi default library: %{public}s", TVSERVICE_HDMITX_VDI_LIBRARY); + } + HDF_LOGI("end %s", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceHdmitxService::LoadVdiV1_0() +{ + const char* errStr = nullptr; + HDF_LOGI("enter %s", __func__); + CreateHdmitxVdiFunc createVdiFunc = reinterpret_cast(dlsym(libHandle_, "CreateHdmitxVdi")); + if (createVdiFunc == nullptr) { + errStr = dlerror(); + if (errStr != nullptr) { + HDF_LOGE("CreateHdmitxVdiFunc dlsym error: %{public}s", errStr); + } + return HDF_FAILURE; + } + + destroyVdiFunc_ = reinterpret_cast(dlsym(libHandle_, "DestroyHdmitxVdi")); + if (destroyVdiFunc_ == nullptr) { + errStr = dlerror(); + if (errStr != nullptr) { + HDF_LOGE("DestroyHdmitxVdiFunc dlsym error: %{public}s", errStr); + } + return HDF_FAILURE; + } + HDF_LOGI("end %s", __func__); + vdiImpl_ = createVdiFunc(); + return HDF_SUCCESS; +} + +int32_t TvserviceHdmitxService::HDMITXEnable(HdmitxPortType port, bool enable) +{ + HDF_LOGI("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->HDMITXEnable(port, enable); +} + +int32_t TvserviceHdmitxService::GetDisplayMode(int32_t dispid,MwDisplayMode& mode) +{ + HDF_LOGI("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->GetDisplayMode(dispid, mode); +} + +int32_t TvserviceHdmitxService::GetDisplaySupportedModeList(int32_t dispid,MwDisplayAvailableMode& mode) +{ + HDF_LOGI("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->GetDisplaySupportedModeList(dispid, mode); +} + +int32_t TvserviceHdmitxService::SetDisplayMode(int32_t dispid,const MwDisplayMode& mode) +{ + HDF_LOGI("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ failed", __func__); + return HDF_FAILURE; + } + return vdiImpl_->SetDisplayMode(dispid, mode); +} + +} // V1_0 +} // Hdmitx +} // Hdmi +} // Tvservice +} // HDI +} // OHOS diff --git a/tvservice/hdmi/hdmitx/interfaces/vdi_base/BUILD.gn b/tvservice/hdmi/hdmitx/interfaces/vdi_base/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..02b65af598bed65541d3630d0484e8e47e8c8275 --- /dev/null +++ b/tvservice/hdmi/hdmitx/interfaces/vdi_base/BUILD.gn @@ -0,0 +1,49 @@ +# Copyright (C) 2025 HiHope Open Source Organization . +# 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. + +import("//build/ohos.gni") +import("../../../../tvservice.gni") +import("//vendor/${product_company}/${product_name}/product.gni") + +ohos_shared_library("tvservice_hdmitx_vdi_impl_default") { + defines = [] + sources = [ + "src/tvservice_hdmitx_vdi_impl.cpp", + ] + output_name = "tvservice_hdmitx_vdi_impl_default" + include_dirs = [ + "include", + "../hdi_service/include", + "../../utils/include", + ] + cflags_cc = [ + "-fPIC", + "-Wall", + "-Wno-error=unused-function", + "-Wno-error=missing-braces", + "-Wno-error=#warnings", + ] + external_deps = [ + "c_utils:utils", + "drivers_interface_tvservice:libtvservice_hdmitx_stub_1.0", + "drivers_interface_tvservice:libtvservice_hdmitx_proxy_1.0", + "hdf_core:libhdf_utils", + "hilog:libhilog", + "hitrace:hitrace_meter", + "ipc:ipc_single", + ] + install_enable = true + install_images = [ chipset_base_dir ] + subsystem_name = "hdf" + part_name = "drivers_peripheral_tvservice" +} \ No newline at end of file diff --git a/tvservice/hdmi/hdmitx/interfaces/vdi_base/include/tvservice_hdmitx_vdi_impl.h b/tvservice/hdmi/hdmitx/interfaces/vdi_base/include/tvservice_hdmitx_vdi_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..31b4f10e0eac3c7e9137575eedbb536d87a370c0 --- /dev/null +++ b/tvservice/hdmi/hdmitx/interfaces/vdi_base/include/tvservice_hdmitx_vdi_impl.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2025 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. + */ + +#ifndef TVSERVICE_HDMITX_VDI_IMPL_H +#define TVSERVICE_HDMITX_VDI_IMPL_H + +#include "tvservice_hdmitx_vdi.h" +#include "v1_0/tvservice_hdmitx_types.h" + +namespace OHOS { +namespace HDI { +namespace Tvservice { +namespace Hdmi { +namespace Hdmitx { +namespace V1_0 { +using namespace OHOS::HDI::Tvservice::Hdmi::Hdmitx; + +class TvserviceHdmitxVdiImpl : public V1_0::TvserviceHdmitxVdi { +public: + TvserviceHdmitxVdiImpl() =default; + ~TvserviceHdmitxVdiImpl()=default; + virtual int32_t HDMITXEnable(HdmitxPortType port, bool enable) override; + virtual int32_t GetDisplayMode(int32_t dispid, MwDisplayMode& mode) override; + virtual int32_t GetDisplaySupportedModeList(int32_t dispid,MwDisplayAvailableMode& mode) override; + virtual int32_t SetDisplayMode(int32_t dispid,const MwDisplayMode& mode) override; +private: +}; +} // V1_0 +} // Hdmitx +} // Hdmi +} // Tvservice +} // HDI +} // OHOS +#endif // TVSERVICE_HDMI_VDI_IMPL_H diff --git a/tvservice/hdmi/hdmitx/interfaces/vdi_base/src/tvservice_hdmitx_vdi_impl.cpp b/tvservice/hdmi/hdmitx/interfaces/vdi_base/src/tvservice_hdmitx_vdi_impl.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fa7c56689f8730762583b4085e98992dd36a786c --- /dev/null +++ b/tvservice/hdmi/hdmitx/interfaces/vdi_base/src/tvservice_hdmitx_vdi_impl.cpp @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2025 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 "tvservice_hdmitx_vdi_impl.h" +#include +#include "tvservice_hdmitx_hdf_log.h" +#include "hdf_log.h" + +#include +#include +#include +#include "securec.h" + +using namespace std; + +namespace OHOS { +namespace HDI { +namespace Tvservice { +namespace Hdmi { +namespace Hdmitx { +namespace V1_0 { + +int32_t TvserviceHdmitxVdiImpl:: HDMITXEnable(V1_0::HdmitxPortType port, bool enable) +{ + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceHdmitxVdiImpl:: GetDisplayMode(int32_t dispid, MwDisplayMode& mode) +{ + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceHdmitxVdiImpl:: GetDisplaySupportedModeList(int32_t dispid,MwDisplayAvailableMode& mode) +{ + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceHdmitxVdiImpl:: SetDisplayMode(int32_t dispid,const MwDisplayMode& mode) +{ + HDF_LOGI("%s in", __func__); + return HDF_SUCCESS; +} + +extern "C" V1_0::TvserviceHdmitxVdi *CreateHdmitxVdi() +{ + return new TvserviceHdmitxVdiImpl(); +} + +extern "C" void DestroyHdmitxVdi(V1_0::TvserviceHdmitxVdi* vdi) +{ + delete vdi; +} +} // V1_0 +} // Hdmitx +} // Hdmi +} // Tvservice +} // HDI +} // OHOS diff --git a/tvservice/hdmi/hdmitx/utils/include/tvservice_hdmitx_hdf_log.h b/tvservice/hdmi/hdmitx/utils/include/tvservice_hdmitx_hdf_log.h new file mode 100644 index 0000000000000000000000000000000000000000..62ece8f1ea9520c99aa96c960dbcdcc783b99222 --- /dev/null +++ b/tvservice/hdmi/hdmitx/utils/include/tvservice_hdmitx_hdf_log.h @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2025 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. + */ + +#ifndef TVSERVICE_LOG_H +#define TVSERVICE_LOG_H +#include +#include +#include "hilog/log.h" + +#ifdef HDF_LOG_TAG +#undef HDF_LOG_TAG +#endif + +#if defined(__cplusplus) +extern "C" { +#endif + +#undef LOG_TAG +#define LOG_TAG "TVS-V" +#undef LOG_DOMAIN +#define LOG_DOMAIN 0xD002515 + +#ifndef TVSERVICE_UNUSED +#define TVSERVICE_UNUSED(x) (void)(x) +#endif + +#ifndef TVSERVICE_DEBUG_ENABLE +#define TVSERVICE_DEBUG_ENABLE 1 +#endif + +#ifndef TVSERVICE_LOGD +#define TVSERVICE_LOGD(format, ...) \ + do { \ + if (TVSERVICE_DEBUG_ENABLE) { \ + HILOG_DEBUG(LOG_CORE, "[%{public}s:%{public}d] " format "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__); \ + } \ + } while (0) +#endif + +#ifndef TVSERVICE_LOGI +#define TVSERVICE_LOGI(format, ...) \ + do { \ + HILOG_INFO(LOG_CORE, "[%{public}s:%{public}d] " format "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__); \ + } while (0) +#endif + +#ifndef TVSERVICE_LOGW +#define TVSERVICE_LOGW(format, ...) \ + do { \ + HILOG_WARN(LOG_CORE, "[%{public}s:%{public}d] " format "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__); \ + } while (0) +#endif + +#ifndef TVSERVICE_LOGE +#define TVSERVICE_LOGE(format, ...) \ + do { \ + HILOG_ERROR(LOG_CORE, \ + "\033[0;32;31m" \ + "[%{public}s:%{public}d] " format "\033[m" \ + "\n", \ + __FUNCTION__, __LINE__, ##__VA_ARGS__); \ + } while (0) +#endif + +#ifndef CHECK_NULLPOINTER_RETURN_VALUE +#define CHECK_NULLPOINTER_RETURN_VALUE(pointer, ret) \ + do { \ + if ((pointer) == NULL) { \ + TVSERVICE_LOGE("pointer is null and return ret\n"); \ + return (ret); \ + } \ + } while (0) +#endif + +#ifndef CHECK_NULLPOINTER_RETURN +#define CHECK_NULLPOINTER_RETURN(pointer) \ + do { \ + if ((pointer) == NULL) { \ + TVSERVICE_LOGE("pointer is null and return\n"); \ + return; \ + } \ + } while (0) +#endif + +#ifndef TVSERVICE_CHK_RETURN +#define TVSERVICE_CHK_RETURN(val, ret, ...) \ + do { \ + if (val) { \ + __VA_ARGS__; \ + return (ret); \ + } \ + } while (0) +#endif + +#ifndef TVSERVICE_CHK_RETURN_NOT_VALUE +#define TVSERVICE_CHK_RETURN_NOT_VALUE(val, ...) \ + do { \ + if (val) { \ + __VA_ARGS__; \ + return; \ + } \ + } while (0) +#endif + +#ifdef __cplusplus +} +#endif + +#endif // TVSERVICE_LOG_H \ No newline at end of file diff --git a/tvservice/test/BUILD.gn b/tvservice/test/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..755ee47c2acf31ec718bb7f039352da7eff1d9b0 --- /dev/null +++ b/tvservice/test/BUILD.gn @@ -0,0 +1,22 @@ +# Copyright (c) 2025 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. + +import("//build/ohos.gni") +import("//build/test.gni") + +group("hdf_test_dtv") { + testonly = true + deps = [ + "unittest:hdi_unittest_dtv_demux", + ] +} diff --git a/tvservice/test/unittest/BUILD.gn b/tvservice/test/unittest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..4654666a93f92d6030242163a8c1d75f3c2c0c29 --- /dev/null +++ b/tvservice/test/unittest/BUILD.gn @@ -0,0 +1,100 @@ +# Copyright (c) 2025 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. + +import("//build/ohos.gni") +import("//build/test.gni") +import("../../tvservice.gni") + +ohos_unittest("hdi_unittest_dtv_demux") { + module_out_path= "drivers_peripheral_tvservice/dtv/demux/hdi_unittest_dtv_demux" + include_dirs = [ + "../../interfaces/hdi_service/include", + "../../utils/include", + ] + + sources = [ "dtv/hdf_dtv_demux_hdi_test.cpp" ] + + cflags = [ + "-Wall", + "-Wextra", + "-Werror", + "-fsigned-char", + "-fno-common", + "-fno-strict-aliasing", + ] + + external_deps = [ + "hdf_core:libhdf_utils", + "hilog:libhilog", + "ipc:ipc_single", + "drivers_interface_tvservice:libtvservice_dtv_demux_stub_1.0", + "drivers_interface_tvservice:libtvservice_dtv_demux_proxy_1.0", + ] + +} + +ohos_unittest("hdi_unittest_dtv_frontend") { + module_out_path= "drivers_peripheral_tvservice/dtv/frontend/hdi_unittest_dtv_frontend" + include_dirs = [ + "../../interfaces/hdi_service/include", + "../../utils/include", + ] + + sources = [ "dtv/hdf_dtv_frontend_hdi_test.cpp" ] + + cflags = [ + "-Wall", + "-Wextra", + "-Werror", + "-fsigned-char", + "-fno-common", + "-fno-strict-aliasing", + ] + + external_deps = [ + "hdf_core:libhdf_utils", + "hilog:libhilog", + "ipc:ipc_single", + "drivers_interface_tvservice:libtvservice_dtv_frontend_stub_1.0", + "drivers_interface_tvservice:libtvservice_dtv_frontend_proxy_1.0", + ] + +} + +ohos_unittest("audio_hdi_test") { + module_out_path = "drivers_peripheral_tvservice/audio/audio_hdi_test" + + sources = ["audio/audio_hdi_test.cpp" ] + + cflags = [ + "-Wall", + "-Wextra", + "-Werror", + "-fsigned-char", + "-fno-common", + "-fno-strict-aliasing", + ] + include_dirs = [ + "../../interfaces/hdi_service/include", + "../../utils/include", + ] + + external_deps = [ + "hilog:libhilog", + "c_utils:utils", + "drivers_interface_tvservice:libtvservice_hdmi_stub_1.0", + "drivers_interface_tvservice:libtvservice_audio_stub_1.0", + "drivers_interface_tvservice:libtvservice_hdmi_proxy_1.0", + "drivers_interface_tvservice:libtvservice_audio_proxy_1.0", + ] +} \ No newline at end of file diff --git a/tvservice/test/unittest/audio/audio_hdi_test.cpp b/tvservice/test/unittest/audio/audio_hdi_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..dd9713bb9594796aef20d217366f17eff3e19fdc --- /dev/null +++ b/tvservice/test/unittest/audio/audio_hdi_test.cpp @@ -0,0 +1,206 @@ +/* Copyright (C) 2025 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 "audio_hdi_test.h" + #include "v1_0/itvservice_audio.h" + #include "v1_0/itvservice_hdmi.h" + #include "v1_0/tvservice_audio_types.h" + using namespace OHOS::HDI::Tvservice::Audio::V1_0; + using namespace OHOS::HDI::Tvservice::Hdmi::V1_0; + + static ITvserviceAudio* g_AudioImpl = nullptr; + static ITvserviceHdmi* g_HdmiImpl = nullptr; + + void HDIAudioServiceTest::SetUpTestCase() { + g_AudioImpl = ITvserviceAudio::Get(true); + g_HdmiImpl = ITvserviceHdmi::Get(true); + } + +void HDIAudioServiceTest::TearDownTestCase(void) {} +void HDIAudioServiceTest::SetUp(void) {} +void HDIAudioServiceTest::TearDown(void) {} + + HWTEST_F(HDIAudioServiceTest, Audio_HDI_SetArcEnable_001, testing::ext::TestSize.Level1) + { + int32_t ret = g_AudioImpl->SetArcEnable(true); + EXPECT_EQ(ret, HDF_SUCCESS); + } + + HWTEST_F(HDIAudioServiceTest, Audio_HDI_SetArcEnable_002, testing::ext::TestSize.Level1) + { + int32_t ret = g_AudioImpl->SetArcEnable(false); + EXPECT_EQ(ret, HDF_SUCCESS); + } + + HWTEST_F(HDIAudioServiceTest, Audio_HDI_SetArcCap_001, testing::ext::TestSize.Level1) + { + ArcCap arcCap; + arcCap.isAudioFmtSupported = {true, false, true}; + int32_t ret = g_AudioImpl->SetArcCap(arcCap); + EXPECT_EQ(ret, HDF_SUCCESS); + } + + HWTEST_F(HDIAudioServiceTest, Audio_HDI_SetArcMode_001, testing::ext::TestSize.Level1) + { + int32_t ret = g_AudioImpl->SetArcMode(SoundArcModeType::SOUND_ARC_AUDIO_MODE_AUTO); + EXPECT_EQ(ret, HDF_SUCCESS); + } + + HWTEST_F(HDIAudioServiceTest, Audio_HDI_SetArcMode_002, testing::ext::TestSize.Level1) + { + int32_t ret = g_AudioImpl->SetArcMode(SoundArcModeType::SOUND_ARC_AUDIO_MODE_RAW); + EXPECT_EQ(ret, HDF_SUCCESS); + } + + + HWTEST_F(HDIAudioServiceTest, Audio_HDI_SetSpdifEnable_001, testing::ext::TestSize.Level1) + { + int32_t ret = g_AudioImpl->SetSpdifEnable(true); + EXPECT_EQ(ret, HDF_SUCCESS); + } + + HWTEST_F(HDIAudioServiceTest, Audio_HDI_SetSpdifEnable_002, testing::ext::TestSize.Level1) + { + int32_t ret = g_AudioImpl->SetSpdifEnable(false); + EXPECT_EQ(ret, HDF_SUCCESS); + } + + HWTEST_F(HDIAudioServiceTest, Audio_HDI_SetSpdifMode_001, testing::ext::TestSize.Level1) + { + SoundSpdifModeType spdifMode = SoundSpdifModeType::SOUND_SPDIF_MODE_AUTO;//(2) + int32_t ret = g_AudioImpl->SetSpdifMode(spdifMode); + EXPECT_EQ(ret, HDF_SUCCESS); + + SoundSpdifModeType mode = SOUND_SPDIF_MODE_BUTT;//(3) + int32_t ret_ = g_AudioImpl->GetSpdifMode(mode); + EXPECT_EQ(ret_, HDF_SUCCESS); + EXPECT_TRUE(mode == SOUND_SPDIF_MODE_AUTO); + } + + HWTEST_F(HDIAudioServiceTest, Audio_HDI_SetSpdifMode_002, testing::ext::TestSize.Level1) + { + SoundSpdifModeType spdifMode = SoundSpdifModeType::SOUND_SPDIF_MODE_RAW;//(2) + int32_t ret = g_AudioImpl->SetSpdifMode(spdifMode); + EXPECT_EQ(ret, HDF_SUCCESS); + + SoundSpdifModeType mode = SOUND_SPDIF_MODE_BUTT;//(3) + int32_t ret_ = g_AudioImpl->GetSpdifMode(mode); + EXPECT_EQ(ret_, HDF_SUCCESS); + EXPECT_TRUE(mode == SOUND_SPDIF_MODE_RAW); + } + + HWTEST_F(HDIAudioServiceTest, Audio_HDI_SetOutPortDelay_001, testing::ext::TestSize.Level1) + { + AoutDeviceType deviceType = AOUT_DEVICE_HDMI;//(4) + uint32_t delayMs = 50; // 典型延迟值 + int32_t ret = g_AudioImpl->SetOutPortDelay(deviceType, delayMs); + EXPECT_EQ(ret, HDF_SUCCESS); + + uint32_t delayMs_ = 0; + int32_t ret_ = g_AudioImpl->GetOutPortDelay(deviceType, delayMs_); + EXPECT_EQ(ret_, HDF_SUCCESS); + EXPECT_GT(delayMs_, 50); + } + + HWTEST_F(HDIAudioServiceTest, Audio_HDI_SetOutPortDelay_002, testing::ext::TestSize.Level1) + { + AoutDeviceType deviceType = AOUT_DEVICE_HDMI;//(4) + uint32_t delayMs = 100; // 典型延迟值 + int32_t ret = g_AudioImpl->SetOutPortDelay(deviceType, delayMs); + EXPECT_EQ(ret, HDF_SUCCESS); + + uint32_t delayMs_ = 0; + int32_t ret_ = g_AudioImpl->GetOutPortDelay(deviceType, delayMs_); + EXPECT_EQ(ret_, HDF_SUCCESS); + EXPECT_GT(delayMs_, 100); + } + + HWTEST_F(HDIAudioServiceTest, Audio_HDI_AudioPortControllerSetMute_001, testing::ext::TestSize.Level1) + { + AoutDeviceType deviceType = AoutDeviceType::AOUT_DEVICE_SPEAKER;//(8) + bool isMute = true; + int32_t ret = g_AudioImpl->AudioPortControllerSetMute(deviceType, isMute); + EXPECT_EQ(ret, HDF_SUCCESS); + } + + HWTEST_F(HDIAudioServiceTest, Audio_HDI_AudioPortControllerSetMute_002, testing::ext::TestSize.Level1) + { + AoutDeviceType deviceType = AoutDeviceType::AOUT_DEVICE_SPEAKER; + bool isMute = false; + int32_t ret = g_AudioImpl->AudioPortControllerSetMute(deviceType, isMute); + EXPECT_EQ(ret, HDF_SUCCESS); + } + + HWTEST_F(HDIAudioServiceTest, Audio_HDI_SetPrecisionVol_001, testing::ext::TestSize.Level1) + { + AoutDeviceType deviceType = AoutDeviceType::AOUT_DEVICE_SPEAKER;//(8) + SoundPreciGainAttr gainAttr = { + .integerGain = 50, // 整数值音量 (0-100) + .decimalGain = 50 // 小数值音量 (0-99),表示0.5 + }; + int32_t ret = g_AudioImpl->SetPrecisionVol(deviceType, gainAttr); + EXPECT_EQ(ret, HDF_SUCCESS); + } + + HWTEST_F(HDIAudioServiceTest, Audio_HDI_SetPrecisionVol_002, testing::ext::TestSize.Level1) + { + AoutDeviceType deviceType = AoutDeviceType::AOUT_DEVICE_SPDIF;//(2) + SoundPreciGainAttr gainAttr = { + .integerGain = 50, // 整数值音量 (0-100) + .decimalGain = 50 // 小数值音量 (0-99),表示0.5 + }; + int32_t ret = g_AudioImpl->SetPrecisionVol(deviceType, gainAttr); + EXPECT_EQ(ret, HDF_SUCCESS); + } + + HWTEST_F(HDIAudioServiceTest, Audio_HDI_SetPrecisionVol_003, testing::ext::TestSize.Level1) + { + AoutDeviceType deviceType = AoutDeviceType::AOUT_DEVICE_ARC;//(16) + SoundPreciGainAttr gainAttr = { + .integerGain = 50, // 整数值音量 (0-100) + .decimalGain = 50 // 小数值音量 (0-99),表示0.5 + }; + int32_t ret = g_AudioImpl->SetPrecisionVol(deviceType, gainAttr); + EXPECT_EQ(ret, HDF_SUCCESS); + } + + HWTEST_F(HDIAudioServiceTest, HDMI_CEC_ARC_VolumeUp_001, testing::ext::TestSize.Level1) + { + CecCmd cmd = { + .srcAddr = CecLogicalAddr::CEC_LOGADDR_TV, // 源地址:电视(0x00) + .dstAddr = CecLogicalAddr::CEC_LOGADDR_AUDSYS, // 目标地址:音频系统(0x05,通常为Soundbar) + .opcode = CecOpcode::CEC_OPCODE_USER_CONTROL_PRESSED, // 操作码:用户控制按下(0x44) + .operand = { + .args = {0x03}, // 操作数:音量增加按钮(CEC标准中Volume Up的按钮代码为0x03) + .argCount = 1 + } + }; + int32_t ret = g_HdmiImpl->RxCecCtrlSetCommand(cmd); + EXPECT_EQ(ret, HDF_SUCCESS); + } + + HWTEST_F(HDIAudioServiceTest, HDMI_CEC_ARC_VolumeDown_002, testing::ext::TestSize.Level1) + { + CecCmd cmd = { + .srcAddr = CecLogicalAddr::CEC_LOGADDR_TV, // 源地址:电视 + .dstAddr = CecLogicalAddr::CEC_LOGADDR_AUDSYS, // 目标地址:音频系统 + .opcode = CecOpcode::CEC_OPCODE_USER_CONTROL_PRESSED, // 操作码:用户控制按下 + .operand = { + .args = {0x04}, // 操作数:音量减少按钮(CEC标准中Volume Down的按钮代码为0x04) + .argCount = 1 + } + }; + int32_t ret = g_HdmiImpl->RxCecCtrlSetCommand(cmd); + EXPECT_EQ(ret, HDF_SUCCESS); + } \ No newline at end of file diff --git a/tvservice/test/unittest/audio/audio_hdi_test.h b/tvservice/test/unittest/audio/audio_hdi_test.h new file mode 100644 index 0000000000000000000000000000000000000000..47817bcee4e116466f2feacc2a2229a3a162b754 --- /dev/null +++ b/tvservice/test/unittest/audio/audio_hdi_test.h @@ -0,0 +1,29 @@ + /* Copyright (C) 2025 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. + */ +#ifndef AUDIO_HDI_TEST_H +#define AUDIO_HDI_TEST_H + +#include + +class HDIAudioServiceTest : public testing::Test { + public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + + void SetUp(void); + void TearDown(void); + }; + + +#endif \ No newline at end of file diff --git a/tvservice/test/unittest/dtv/hdf_dtv_demux_hdi_test.cpp b/tvservice/test/unittest/dtv/hdf_dtv_demux_hdi_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..caa8de8236455a0de74735750592dc31be04564f --- /dev/null +++ b/tvservice/test/unittest/dtv/hdf_dtv_demux_hdi_test.cpp @@ -0,0 +1,519 @@ +/* +* Copyright (c) 2025 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 "v1_0/itvservice_dtv_demux.h" + +static struct ITvserviceDtvDemux * g_serviceImpl =NULL; +class HdfDtvDemuxHdiTest : public testing::Test { + public: + static void SetUpTestCase(); +}; + +void HdfDtvDemuxHdiTest::SetUpTestCase() +{ + g_serviceImpl = ITvserviceDtvDemuxGet(true); +} + + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest001, testing::ext::TestSize.Level1) +{ + struct DMX_INIT_PARAMS_S stInitParams; + int32_t ret = g_serviceImpl->dmx_init(g_serviceImpl, &stInitParams); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest002, testing::ext::TestSize.Level1) +{ + unsigned int u32DescId =0; + DMX_DESC_ASSOCIATE_PARAMS_S stParams; + int32_t ret = g_serviceImpl->dmx_descrambler_associate(g_serviceImpl,u32DescId,&stParams); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest003, testing::ext::TestSize.Level1) +{ + unsigned int u32DescId =0; + int32_t ret = g_serviceImpl->dmx_descrambler_enable(g_serviceImpl,u32DescId); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest004, testing::ext::TestSize.Level1) +{ + unsigned int u32DescId =0; + int32_t ret = g_serviceImpl->dmx_descrambler_disable(g_serviceImpl,u32DescId); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest005, testing::ext::TestSize.Level1) +{ + DMX_ID_E enDemuxId = DMX_ID_E::DMX_ID_0; + unsigned int u32DescId; + DMX_DESCRAMBLER_ATTR_S stDesramblerAttr; + + int32_t ret = g_serviceImpl->dmx_descrambler_open_ex(g_serviceImpl,enDemuxId,&u32DescId,&stDesramblerAttr); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest006, testing::ext::TestSize.Level1) +{ + unsigned int u32DescId =0; + + int32_t ret = g_serviceImpl->dmx_descrambler_close(g_serviceImpl,u32DescId); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest007, testing::ext::TestSize.Level1) +{ + struct DMX_TERM_PARAM_S stTermParams; + int32_t ret = g_serviceImpl->dmx_term(g_serviceImpl, &stTermParams); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest008, testing::ext::TestSize.Level1) +{ + enum DMX_ID_E enDemuxId = DMX_ID_E::DMX_ID_0; + struct DMX_SOURCE_PARAMS_S stSourceParams; + int32_t ret = g_serviceImpl->dmx_set_source_params(g_serviceImpl, enDemuxId, &stSourceParams); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest009, testing::ext::TestSize.Level1) +{ + enum DMX_ID_E enDemuxId = DMX_ID_E::DMX_ID_0; + struct DMX_SOURCE_PARAMS_S stSourceParams; + int32_t ret = g_serviceImpl->dmx_get_source_params(g_serviceImpl, enDemuxId, &stSourceParams); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest010, testing::ext::TestSize.Level1) +{ + enum DMX_ID_E enDemuxId = DMX_ID_E::DMX_ID_0; + int32_t ret = g_serviceImpl->dmx_disconnect(g_serviceImpl, enDemuxId); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest011, testing::ext::TestSize.Level1) +{ + enum DMX_ID_E enDemuxId = DMX_ID_E::DMX_ID_0; + struct DMX_STATUS_S stStatus; + int32_t ret = g_serviceImpl->dmx_get_status(g_serviceImpl, enDemuxId, &stStatus); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest012, testing::ext::TestSize.Level1) +{ + enum DMX_ID_E enDemuxId = DMX_ID_E::DMX_ID_0; + uint32_t u32ChannelId; + struct DMX_CHANNEL_OPEN_PARAM_S stOpenParams; + int32_t ret = g_serviceImpl->dmx_channel_open(g_serviceImpl, enDemuxId, &u32ChannelId, &stOpenParams); + EXPECT_EQ(0, ret); +} +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest013, testing::ext::TestSize.Level1) +{ + uint32_t u32ChannelId = 0; + struct DMX_CHANNEL_CLOSE_PARAMS_S stCloseParams; + int32_t ret = g_serviceImpl->dmx_channel_close(g_serviceImpl, u32ChannelId, &stCloseParams); + EXPECT_EQ(0, ret); +} +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest014, testing::ext::TestSize.Level1) +{ + uint32_t u32ChannelId = 0; + uint16_t u16Pid = 0; + int32_t ret = g_serviceImpl->dmx_channel_set_pid(g_serviceImpl, u32ChannelId, u16Pid); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest015, testing::ext::TestSize.Level1) +{ + enum DMX_ID_E enDemuxId = DMX_ID_E::DMX_ID_0; + uint32_t u32ChannelId; + uint16_t u16Pid = 0; + int32_t ret = g_serviceImpl->dmx_channel_query(g_serviceImpl, enDemuxId, &u32ChannelId, u16Pid); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest016, testing::ext::TestSize.Level1) +{ + uint32_t u32ChannelId = 0; + int32_t ret = g_serviceImpl->dmx_channel_enable(g_serviceImpl, u32ChannelId); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest017, testing::ext::TestSize.Level1) +{ + uint32_t u32ChannelId = 0; + int32_t ret = g_serviceImpl->dmx_channel_disable(g_serviceImpl, u32ChannelId); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest018, testing::ext::TestSize.Level1) +{ + uint32_t u32ChannelId = 0; + int32_t ret = g_serviceImpl->dmx_channel_reset(g_serviceImpl, u32ChannelId); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest019, testing::ext::TestSize.Level1) +{ + uint32_t u32ChannelId = 0; + struct DMX_CHANNEL_INFO_S stInfo; + int32_t ret = g_serviceImpl->dmx_channel_get_info(g_serviceImpl, u32ChannelId, &stInfo); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest020, testing::ext::TestSize.Level1) +{ + uint32_t u32ChannelId = 0; + struct DMX_CHANNEL_SETTING_S stSettings; + int32_t ret = g_serviceImpl->dmx_channel_set(g_serviceImpl, u32ChannelId, &stSettings); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest021, testing::ext::TestSize.Level1) +{ + uint32_t u32ChannelId = 0; + struct DMX_CHANNEL_SETTING_S stSettings; + int32_t ret = g_serviceImpl->dmx_channel_get(g_serviceImpl, u32ChannelId, &stSettings); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest022, testing::ext::TestSize.Level1) +{ + uint32_t u32ChannelId = 0; + uint32_t u32AcquirePackageNum = 0; + uint32_t u32AcquiredNum; + struct DMX_CHANNEL_DATA_S stChannelData; + uint32_t u32TimeoutMs = 0; + int32_t ret = g_serviceImpl->dmx_channel_get_buf(g_serviceImpl, u32ChannelId, u32AcquirePackageNum, + &u32AcquiredNum, &stChannelData, u32TimeoutMs); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest023, testing::ext::TestSize.Level1) +{ + uint32_t u32ChannelId = 0; + uint32_t u32ReleaseNum = 0; + struct DMX_CHANNEL_DATA_S stChannelData; + int32_t ret = g_serviceImpl->dmx_channel_release_buf(g_serviceImpl, u32ChannelId, u32ReleaseNum, &stChannelData); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest024, testing::ext::TestSize.Level1) +{ + uint32_t u32ChannelId = 0; + uint32_t u32FilterId; + struct DMX_FILTER_DATA_S stFilterData; + int32_t ret = g_serviceImpl->dmx_channel_add_filter(g_serviceImpl, u32ChannelId, &u32FilterId, &stFilterData); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest025, testing::ext::TestSize.Level1) +{ + uint32_t u32ChannelId = 0; + uint32_t u32FilterId = 0; + struct DMX_FILTER_DATA_S stFilterData; + int32_t ret = g_serviceImpl->dmx_channel_set_filter(g_serviceImpl, u32ChannelId, u32FilterId, &stFilterData); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest026, testing::ext::TestSize.Level1) +{ + uint32_t u32ChannelId = 0; + uint32_t u32FilterId = 0; + struct DMX_FILTER_DATA_S stFilterData; + int32_t ret = g_serviceImpl->dmx_channel_get_filter(g_serviceImpl, u32ChannelId, u32FilterId, &stFilterData); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest027, testing::ext::TestSize.Level1) +{ + uint32_t u32ChannelId = 0; + uint32_t u32FilterId = 0; + int32_t ret = g_serviceImpl->dmx_channel_destroy_filter(g_serviceImpl, u32ChannelId, u32FilterId); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest028, testing::ext::TestSize.Level1) +{ + uint32_t u32ChannelId = 0; + int32_t ret = g_serviceImpl->dmx_channel_destroy_all_filter(g_serviceImpl, u32ChannelId); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest029, testing::ext::TestSize.Level1) +{ + uint32_t u32ChannelId = 0; + uint32_t u32FilterId = 0; + int32_t ret = g_serviceImpl->dmx_channel_enable_filter(g_serviceImpl, u32ChannelId, u32FilterId); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest030, testing::ext::TestSize.Level1) +{ + uint32_t u32ChannelId = 0; + uint32_t u32FilterId = 0; + int32_t ret = g_serviceImpl->dmx_channel_disable_filter(g_serviceImpl, u32ChannelId, u32FilterId); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest031, testing::ext::TestSize.Level1) +{ + uint32_t u32ChannelId = 0; + uint32_t u32FilterId = 0; + uint8_t u8TableId = 0; + uint16_t u16ExtId = 0; + int32_t ret = g_serviceImpl->dmx_channel_query_filter_by_table_id(g_serviceImpl, u32ChannelId, &u32FilterId, u8TableId, u16ExtId); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest032, testing::ext::TestSize.Level1) +{ + uint32_t u32ChannelId = 0; + uint32_t u32FilterId = 0; + struct DMX_FILTER_DATA_S stFilterData; + int32_t ret = g_serviceImpl->dmx_channel_query_filter_by_filter_data(g_serviceImpl, u32ChannelId, &u32FilterId, &stFilterData); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest033, testing::ext::TestSize.Level1) +{ + uint32_t u32DescId; + enum DMX_DESC_ASSOCIATE_MODE_E enMode = DMX_DESC_ASSOCIATE_MODE_E::DMX_DESCRAMBLER_ASSOCIATE_WITH_PIDS; + int32_t ret = g_serviceImpl->dmx_descrambler_open(g_serviceImpl, DMX_ID_E::DMX_ID_0, &u32DescId, enMode); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest036, testing::ext::TestSize.Level1) +{ + uint32_t u32DescId = 0; + struct DMX_DESC_ASSOCIATE_PARAMS_S stParams; + int32_t ret = g_serviceImpl->dmx_descrambler_get_associate_info(g_serviceImpl, u32DescId,&stParams); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest038, testing::ext::TestSize.Level1) +{ + enum DMX_ID_E enDemuxId = DMX_ID_E::DMX_ID_0; + int32_t ret = g_serviceImpl->dmx_reconnect(g_serviceImpl, enDemuxId); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest039, testing::ext::TestSize.Level1) +{ + struct DMX_CAPABILITY_S stCapability; + int32_t ret = g_serviceImpl->dmx_get_capability(g_serviceImpl, &stCapability); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest040, testing::ext::TestSize.Level1) +{ + uint32_t u32DescId = 0; + uint8_t u8Key; + uint32_t u32Len = 0; // Assuming length is set to 0 for this test case + uint32_t u32Option =0; + int32_t ret = g_serviceImpl->dmx_descrambler_set_even_key(g_serviceImpl, u32DescId, &u8Key, u32Len, u32Option); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest041, testing::ext::TestSize.Level1) +{ + uint32_t u32DescId = 0; + uint8_t u8Key; + uint32_t u32Len = 0; + uint32_t u32Option = 0; + int32_t ret = g_serviceImpl->dmx_descrambler_set_odd_key(g_serviceImpl, u32DescId, &u8Key, u32Len, u32Option); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest042, testing::ext::TestSize.Level1) +{ + uint32_t u32DescId = 0; + uint8_t u8IV; + uint32_t u32Len = 0; + int32_t ret = g_serviceImpl->dmx_descrambler_set_even_iv(g_serviceImpl,u32DescId,&u8IV,u32Len); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest043, testing::ext::TestSize.Level1) +{ + uint32_t u32DescId=0; + uint8_t u8IV; + uint32_t u32Len=0; + int32_t ret = g_serviceImpl->dmx_descrambler_set_odd_iv(g_serviceImpl,u32DescId,&u8IV,u32Len); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest044, testing::ext::TestSize.Level1) +{ + uint32_t u32DescId =0; + struct DMX_DESCRAMBLER_ATTR_S stAttr; + int32_t ret = g_serviceImpl->dmx_set_descrambler_attribute(g_serviceImpl,u32DescId,&stAttr); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest045, testing::ext::TestSize.Level1) +{ + uint32_t u32DescId = 0; + struct DMX_DESCRAMBLER_ATTR_S stAttr; + int32_t ret = g_serviceImpl->dmx_get_descrambler_attribute(g_serviceImpl,u32DescId,&stAttr); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest046, testing::ext::TestSize.Level1) +{ + uint32_t u32DescId = 0; + struct DMX_DESC_ASSOCIATE_PARAMS_S stParams; + int32_t ret = g_serviceImpl->dmx_descrambler_associate(g_serviceImpl, u32DescId, &stParams); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest047, testing::ext::TestSize.Level1) +{ + uint32_t u32DescId= 0; + struct DMX_DCAS_NONCE_SETTING_S stDcasNonceConfig; + uint8_t u8DANonce; + int32_t ret = g_serviceImpl->dmx_dcas_get_nonce(g_serviceImpl, u32DescId, &stDcasNonceConfig, &u8DANonce); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest048, testing::ext::TestSize.Level1) +{ + enum DMX_ID_E enDemuxId= DMX_ID_E::DMX_ID_0; + uint32_t u32AVFilterId; + struct DMX_PARSER_FILTER_OPEN_PARAM_S stFilterOpenPara; + int32_t ret = g_serviceImpl->dmx_avfilter_open(g_serviceImpl, enDemuxId, &u32AVFilterId, &stFilterOpenPara); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest049, testing::ext::TestSize.Level1) +{ + uint32_t u32AVFilterId = 0; + int32_t ret = g_serviceImpl->dmx_avfilter_enable(g_serviceImpl, u32AVFilterId); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest050, testing::ext::TestSize.Level1) +{ + uint32_t u32AVFilterId = 0; + struct DMX_ESFRAME_INFO_S stFrameInfo; + int32_t ret = g_serviceImpl->dmx_avfilter_get_esframe(g_serviceImpl, u32AVFilterId, &stFrameInfo); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest051, testing::ext::TestSize.Level1) +{ + uint32_t u32AVFilterId = 0; + struct DMX_ESFRAME_INFO_S stFrameInfo; + int32_t ret = g_serviceImpl->dmx_avfilter_release_esframe(g_serviceImpl, u32AVFilterId, &stFrameInfo); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest052, testing::ext::TestSize.Level1) +{ + uint32_t u32AVFilterId = 0; + int32_t ret = g_serviceImpl->dmx_avfilter_disable(g_serviceImpl, u32AVFilterId); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest053, testing::ext::TestSize.Level1) +{ + uint32_t u32AVFilterId = 0; + int32_t ret = g_serviceImpl->dmx_avfilter_close(g_serviceImpl, u32AVFilterId); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest054, testing::ext::TestSize.Level1) +{ + enum DMX_ID_E enDemuxId= DMX_ID_E::DMX_ID_0; + uint32_t u32PcrId = 0; + uint32_t u32Pid = 0; + int32_t ret = g_serviceImpl->dmx_pcr_open(g_serviceImpl, enDemuxId,&u32PcrId, u32Pid); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest055, testing::ext::TestSize.Level1) +{ + uint32_t u32PcrId = 0; + int32_t ret = g_serviceImpl->dmx_pcr_close(g_serviceImpl, u32PcrId); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest056, testing::ext::TestSize.Level1) +{ + uint32_t u32PcrId = 0; + // Assuming the PCR time is in milliseconds, adjust as necessary for your implementation + uint64_t u64StcTime; + int32_t ret = g_serviceImpl->dmx_pcr_get(g_serviceImpl, u32PcrId, &u64StcTime); + EXPECT_EQ(0, ret); +} +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest057, testing::ext::TestSize.Level1) +{ + enum DMX_ID_E enDemuxId = DMX_ID_E::DMX_ID_0; + uint32_t u32TsBufferId = 0; + int32_t ret = g_serviceImpl->dmx_tsbuffer_create(g_serviceImpl, enDemuxId, &u32TsBufferId); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest058, testing::ext::TestSize.Level1) +{ + uint32_t u32TsBufferId= 0; + uint32_t u32Size= 1024; // Example size, adjust as necessary + uint32_t u32TimeoutMs= 1000; + struct DMX_STREAM_DATA_S stStreamData; + int32_t ret = g_serviceImpl->dmx_tsbuffer_get(g_serviceImpl, u32TsBufferId, u32Size, u32TimeoutMs, &stStreamData); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest059, testing::ext::TestSize.Level1) +{ + uint32_t u32TsBufferId= 0; + uint32_t u32ValidDataLen = 512; // Example length, adjust as necessary + int32_t ret = g_serviceImpl->dmx_tsbuffer_put(g_serviceImpl, u32TsBufferId, u32ValidDataLen); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest060, testing::ext::TestSize.Level1) +{ + uint32_t u32TsBufferId = 0; + int32_t ret = g_serviceImpl->dmx_tsbuffer_destroy(g_serviceImpl, u32TsBufferId); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest061, testing::ext::TestSize.Level1) +{ + enum DMX_ID_E enDemuxId= DMX_ID_E::DMX_ID_0; + uint8_t StreamPath; + int32_t StreamPathLength; + int32_t ret = g_serviceImpl->dmx_get_streampath_param(g_serviceImpl, enDemuxId, &StreamPath, &StreamPathLength); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest062, testing::ext::TestSize.Level1) +{ + uint32_t u32ChannelId; + uint32_t u32ChNum; + uint32_t u32TimeoutMs= 1000; // Example timeout, adjust as necessary + int32_t ret = g_serviceImpl->dmx_channel_get_data_handle(g_serviceImpl, &u32ChannelId, &u32ChNum, u32TimeoutMs); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvDemuxHdiTest, HdfDtvDemuxHdiTest063, testing::ext::TestSize.Level1) +{ + enum DMX_ID_E enDemuxId= DMX_ID_E::DMX_ID_0; + struct DMX_TSBUF_ATTR_S stBufAttr; + uint32_t u32TsBufferId; + int32_t ret = g_serviceImpl->dmx_tsbuffer_create_ex(g_serviceImpl,enDemuxId, &stBufAttr, &u32TsBufferId); + EXPECT_EQ(0, ret); +} \ No newline at end of file diff --git a/tvservice/test/unittest/dtv/hdf_dtv_frontend_hdi_test.cpp b/tvservice/test/unittest/dtv/hdf_dtv_frontend_hdi_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..17bdfe71d86dd0813dbb7701d828136295fb2474 --- /dev/null +++ b/tvservice/test/unittest/dtv/hdf_dtv_frontend_hdi_test.cpp @@ -0,0 +1,258 @@ +/* +* Copyright (c) 2025 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 "v1_0/itvservice_dtv_frontend.h" + +static struct ITvserviceDtvFrontend * g_serviceImpl =NULL; +class HdfDtvFrontendHdiTest : public testing::Test { + public: + static void SetUpTestCase(); +}; + +void HdfDtvFrontendHdiTest::SetUpTestCase() +{ + g_serviceImpl = ITvserviceDtvFrontendGet(true); +} + + +HWTEST_F(HdfDtvFrontendHdiTest, HdfDtvFrontendHdiTest000, testing::ext::TestSize.Level1) +{ + ASSERT_NE(nullptr, g_serviceImpl); +} + +HWTEST_F(HdfDtvFrontendHdiTest, HdfDtvFrontendHdiTest001, testing::ext::TestSize.Level1) +{ + FRONTEND_INIT_PARAMS_S stInitParams; + int32_t ret = g_serviceImpl->frontend_init(g_serviceImpl, &stInitParams); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvFrontendHdiTest, HdfDtvFrontendHdiTest002, testing::ext::TestSize.Level1) +{ + unsigned int hFrontend =0; + unsigned int us32Steps =0; + int32_t ret = g_serviceImpl->frontend_atv_fineTune(g_serviceImpl, hFrontend, us32Steps); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvFrontendHdiTest, HdfDtvFrontendHdiTest003, testing::ext::TestSize.Level1) +{ + unsigned int hFrontend =0; + FRONTEND_OPEN_PARAMS_S OpenParams; + int32_t ret = g_serviceImpl->frontend_open(g_serviceImpl, &hFrontend, &OpenParams); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvFrontendHdiTest, HdfDtvFrontendHdiTest004, testing::ext::TestSize.Level1) +{ + unsigned int hFrontend =0; + int32_t ret = g_serviceImpl->frontend_close(g_serviceImpl, hFrontend); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvFrontendHdiTest, HdfDtvFrontendHdiTest005, testing::ext::TestSize.Level1) +{ + FRONTEND_TERM_PARAMS_S stTermParams; + int32_t ret = g_serviceImpl->frontend_term(g_serviceImpl, &stTermParams); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvFrontendHdiTest, HdfDtvFrontendHdiTest006, testing::ext::TestSize.Level1) +{ + unsigned int hFrontend =0; + FRONTEND_SCAN_INFO_S stScanInfo; + int32_t ret = g_serviceImpl->frontend_get_scan_info(g_serviceImpl, hFrontend, &stScanInfo); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvFrontendHdiTest, HdfDtvFrontendHdiTest007, testing::ext::TestSize.Level1) +{ + unsigned int hFrontend =0; + FRONTEND_SAT_LNB_INFO_S stLnbInfo; + int32_t ret = g_serviceImpl->frontend_sat_config_lnb(g_serviceImpl, hFrontend, &stLnbInfo); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvFrontendHdiTest, HdfDtvFrontendHdiTest008, testing::ext::TestSize.Level1) +{ + unsigned int hFrontend =0; + FRONTEND_LNB_PWR_STATUS_E enLnbPwrStatus; + int32_t ret = g_serviceImpl->frontend_get_lnb_pwr_status(g_serviceImpl, hFrontend, &enLnbPwrStatus); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvFrontendHdiTest, HdfDtvFrontendHdiTest009, testing::ext::TestSize.Level1) +{ + unsigned int hFrontend =0; + FRONTEND_G2_CHANNEL_INFO_S stChannelInfo; + uint8_t u8ChannelIndex = 0; + uint32_t u32Timeout = 0; + int32_t ret = g_serviceImpl->frontend_get_channel_info(g_serviceImpl, hFrontend, u8ChannelIndex, &stChannelInfo, u32Timeout); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvFrontendHdiTest, HdfDtvFrontendHdiTest010, testing::ext::TestSize.Level1) +{ + unsigned int hFrontend =0; + FRONTEND_G2_REQ_PARAMS_S stReqParams; + FRONTEND_G2_RPN_PARAMS_S stRpnParams; + uint8_t u8ChannelIndex = 0; + uint32_t u32Timeout = 0; + int32_t ret = g_serviceImpl->frontend_config_channel(g_serviceImpl, hFrontend, u8ChannelIndex, &stReqParams, &stRpnParams, u32Timeout); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvFrontendHdiTest, HdfDtvFrontendHdiTest011, testing::ext::TestSize.Level1) +{ + unsigned int hFrontend =0; + enum FRONTEND_ATV_LOCK_STATUS_E enLockStatus; + int32_t ret = g_serviceImpl->frontend_atv_get_lock_status(g_serviceImpl, hFrontend, &enLockStatus); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvFrontendHdiTest, HdfDtvFrontendHdiTest012, testing::ext::TestSize.Level1) +{ + uint32_t majorVer = 0; + uint32_t minorVer = 0; + int32_t ret = g_serviceImpl->GetVersion(g_serviceImpl, &majorVer, &minorVer); + EXPECT_EQ(0, ret); + EXPECT_GT(majorVer, 0); + EXPECT_GE(minorVer, 0); +} + +HWTEST_F(HdfDtvFrontendHdiTest, HdfDtvFrontendHdiTest013, testing::ext::TestSize.Level1) +{ + uint32_t hFrontend=0; + int32_t ret = g_serviceImpl->frontend_abort(g_serviceImpl, hFrontend); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvFrontendHdiTest, HdfDtvFrontendHdiTest014, testing::ext::TestSize.Level1) +{ + uint32_t hFrontend=0; + struct FRONTEND_REG_CALLBACK_PARAMS_S stRegParams; + int32_t ret = g_serviceImpl->frontend_register_callback(g_serviceImpl, hFrontend, &stRegParams); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvFrontendHdiTest, HdfDtvFrontendHdiTest015, testing::ext::TestSize.Level1) +{ + uint32_t hFrontend=0; + int32_t ret = g_serviceImpl->frontend_lock(g_serviceImpl, hFrontend); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvFrontendHdiTest, HdfDtvFrontendHdiTest016, testing::ext::TestSize.Level1) +{ + uint32_t hFrontend=0; + float fBert = 0.0f; + int32_t ret = g_serviceImpl->frontend_get_bert(g_serviceImpl, hFrontend, &fBert); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvFrontendHdiTest, HdfDtvFrontendHdiTest017, testing::ext::TestSize.Level1) +{ + uint32_t hFrontend=0; + uint32_t u32Quality = 0; + int32_t ret = g_serviceImpl->frontend_get_signal_quality(g_serviceImpl, hFrontend, &u32Quality); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvFrontendHdiTest, HdfDtvFrontendHdiTest018, testing::ext::TestSize.Level1) +{ + uint32_t hFrontend=0; + uint32_t u32Strength = 0; + int32_t ret = g_serviceImpl->frontend_get_signal_strength(g_serviceImpl, hFrontend, &u32Strength); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvFrontendHdiTest, HdfDtvFrontendHdiTest019, testing::ext::TestSize.Level1) +{ + uint32_t hFrontend=0; + struct FRONTEND_ATV_SIGNALINFO_S stSignalInfo; + int32_t ret = g_serviceImpl->frontend_get_atvsignalinfo(g_serviceImpl, hFrontend, &stSignalInfo); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvFrontendHdiTest, HdfDtvFrontendHdiTest020, testing::ext::TestSize.Level1) +{ + uint32_t hFrontend=0; + enum FRONTEND_FE_STATUS_E enStatus; + int32_t ret = g_serviceImpl->frontend_get_connect_status(g_serviceImpl, hFrontend, &enStatus); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvFrontendHdiTest, HdfDtvFrontendHdiTest021, testing::ext::TestSize.Level1) +{ + uint32_t hFrontend=0; + struct FRONTEND_INFO_S stInfo; + int32_t ret = g_serviceImpl->frontend_get_info(g_serviceImpl, hFrontend, &stInfo); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvFrontendHdiTest, HdfDtvFrontendHdiTest023, testing::ext::TestSize.Level1) +{ + uint32_t hFrontend=0; + uint8_t u8ChannelNum = 0; + int32_t ret = g_serviceImpl->frontend_get_channel_num(g_serviceImpl, hFrontend, &u8ChannelNum); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvFrontendHdiTest, HdfDtvFrontendHdiTest024, testing::ext::TestSize.Level1) +{ + uint32_t hFrontend=0; + uint8_t u8ChannelIndex = 0; + struct FRONTEND_G2_CHANNEL_INFO_S stChannelInfo; + uint32_t u32Timeout = 0; + int32_t ret = g_serviceImpl->frontend_get_channel_info(g_serviceImpl, hFrontend, u8ChannelIndex, &stChannelInfo, u32Timeout); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvFrontendHdiTest, HdfDtvFrontendHdiTest025, testing::ext::TestSize.Level1) +{ + uint32_t hFrontend=0; + uint8_t u8ChannelIndex = 0; + struct FRONTEND_G2_REQ_PARAMS_S stReqParams; + struct FRONTEND_G2_RPN_PARAMS_S stRpnParams; + uint32_t u32Timeout = 0; + int32_t ret = g_serviceImpl->frontend_config_channel(g_serviceImpl, hFrontend, u8ChannelIndex, &stReqParams, &stRpnParams, u32Timeout); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvFrontendHdiTest, HdfDtvFrontendHdiTest026, testing::ext::TestSize.Level1) +{ + uint32_t hFrontend=0; + enum FRONTEND_ATV_LOCK_STATUS_E enLockStatus; + int32_t ret = g_serviceImpl->frontend_atv_get_lock_status(g_serviceImpl, hFrontend, &enLockStatus); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvFrontendHdiTest, HdfDtvFrontendHdiTest027, testing::ext::TestSize.Level1) +{ + uint32_t hFrontend=0; + uint32_t us32Steps = 0; + int32_t ret = g_serviceImpl->frontend_atv_fineTune(g_serviceImpl, hFrontend, us32Steps); + EXPECT_EQ(0, ret); +} + +HWTEST_F(HdfDtvFrontendHdiTest, HdfDtvFrontendHdiTest028, testing::ext::TestSize.Level1) +{ + uint32_t hFrontend=0; + struct FRONTEND_SCAN_INFO_S stScanParams; + bool bSynch= true; + uint32_t u32Timeout= 0; + int32_t ret = g_serviceImpl->frontend_start_scan(g_serviceImpl, hFrontend, &stScanParams, bSynch, u32Timeout); + EXPECT_EQ(0, ret); +} \ No newline at end of file diff --git a/tvservice/tvservice.gni b/tvservice/tvservice.gni new file mode 100644 index 0000000000000000000000000000000000000000..24b9a3619de959bc8b440e4e335f287905c92b32 --- /dev/null +++ b/tvservice/tvservice.gni @@ -0,0 +1,31 @@ +# Copyright (c) 2025 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. + +declare_args() { +} + + +if (!defined(global_parts_info) || + defined(global_parts_info.commonlibrary_c_utils)) { + has_tvservice_c_utils_part = true +} else { + has_tvservice_c_utils_part = false +} + +if (!defined(global_parts_info) || + defined(global_parts_info.hiviewdfx_hisysevent)) { + has_tvservice_hisysevent_part = true + # cflags_cc += [ "-DHAS_POWER_HISYSEVENT_PART" ] +} else { + has_tvservice_hisysevent_part = false +} \ No newline at end of file diff --git a/tvservice/video/BUILD.gn b/tvservice/video/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..0730c7f4bf3be1a7d046424ab9d191f409d4acec --- /dev/null +++ b/tvservice/video/BUILD.gn @@ -0,0 +1,19 @@ +# Copyright (c) 2025 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. +import("//build/ohos.gni") + +print("=============tvservice_video_host_entry============") +group("tvservice_video_host_entry") { + deps = [ "interfaces/hdi_service:hdf_tvservice_video_host"] + #deps += [ "interfaces/vdi_base:tvservice_video_vdi_impl_default" ] +} \ No newline at end of file diff --git a/tvservice/video/interfaces/hdi_service/BUILD.gn b/tvservice/video/interfaces/hdi_service/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..e53c791d9041c8ae567c701c87c37090f006893b --- /dev/null +++ b/tvservice/video/interfaces/hdi_service/BUILD.gn @@ -0,0 +1,82 @@ +# Copyright (c) 2025 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. +import("//build/ohos.gni") +import("../../../tvservice.gni") + +ohos_shared_library("libtvservice_video_service_1.0") { + defines = [] + include_dirs = [ + "../../utils/include", + "include" + ] + sources = [ + "src/tvservice_video_service.cpp" + ] + + external_deps = [ + "c_utils:utils", + "hdf_core:libhdf_ipc_adapter", + "hdf_core:libhdi", + "hdf_core:libhdf_host", + "hdf_core:libhdf_utils", + "hilog:libhilog", + "ipc:ipc_single", + "libxml2:libxml2", + "drivers_interface_tvservice:libtvservice_video_stub_1.0", + "drivers_interface_tvservice:libtvservice_video_proxy_1.0", + ] + + if (has_tvservice_hisysevent_part) { + external_deps += [ "hisysevent:libhisysevent" ] + } + + install_images = [ chipset_base_dir ] + subsystem_name = "hdf" + part_name = "drivers_peripheral_tvservice" +} + + +ohos_shared_library("libtvservice_video_driver") { + sources = [ + "src/tvservice_video_driver.cpp" + ] + + external_deps = [ + "c_utils:utils", + "hdf_core:libhdf_ipc_adapter", + "hdf_core:libhdi", + "hdf_core:libhdf_host", + "hdf_core:libhdf_utils", + "hilog:libhilog", + "ipc:ipc_single", + "drivers_interface_tvservice:libtvservice_video_stub_1.0", + "drivers_interface_tvservice:libtvservice_video_proxy_1.0", + ] + if (has_tvservice_c_utils_part) { + external_deps += [ "c_utils:utils" ] + } + + shlib_type = "hdi" + install_images = [ chipset_base_dir ] + subsystem_name = "hdf" + part_name = "drivers_peripheral_tvservice" +} + +group("hdf_tvservice_video_host") { + deps = [ + ":libtvservice_video_driver", + ":libtvservice_video_service_1.0", + ] + +print("=============hdf_tvservice_video_host============") +} \ No newline at end of file diff --git a/tvservice/video/interfaces/hdi_service/include/tvservice_video_service.h b/tvservice/video/interfaces/hdi_service/include/tvservice_video_service.h new file mode 100644 index 0000000000000000000000000000000000000000..fe5caad96902e2d60f68923fbf1bbcbbe282f61d --- /dev/null +++ b/tvservice/video/interfaces/hdi_service/include/tvservice_video_service.h @@ -0,0 +1,180 @@ +/* + * Copyright (c) 2025 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. + */ + +#ifndef OHOS_HDI_TVSERVICE_VIDEO_H +#define OHOS_HDI_TVSERVICE_VIDEO_H + +#include "tvservice_video_vdi.h" +#include "v1_0/itvservice_video.h" +#include "v1_0/tvservice_video_types.h" +#include + +#include +#include +#include +#include "hdf_sbuf.h" + +namespace OHOS { +namespace HDI { +namespace Tvservice { +namespace Video { +namespace V1_0 { + + +class TvserviceVideoService : public ITvserviceVideo { +public: + TvserviceVideoService(); + virtual ~TvserviceVideoService(); + int32_t Connect() override; + int32_t Disconnect() override; + + int32_t CastInit(const CastVencChnAttr &chnAttr, CastMode castMode)override; + int32_t CastDeInit()override; + // int32_t CastAcquireStream(CastVencStream &vencStream) override; + // int32_t CastReleaseStream(const CastVencStream &vencStream) override; + int32_t CastClose(bool isBackground) override; + int32_t CastRequestIDRFrame() override; + int32_t CastSetAttr(const CastVencChnAttr &chnAttr, CastType castType) override; + int32_t CastGetAttr(CastVencChnAttr &chnAttr) override; + int32_t CastPause() override; + int32_t CastResume() override; + int32_t CastCreateVideo(SourceType source, bool needOpenDevice) override; + int32_t CastDestroyVideo(bool needCloseDevice) override; + int32_t CastStartVideo() override; + int32_t CastStopVideo() override; + int32_t CastGetVideoSignal(SignalStatus &status) override; + int32_t CastGetVideoInfo(VideoInfo &videoInfo) override; + int32_t CastAcquireInputFrame(bool frameRateCtrl,uint32_t &handle) override; + int32_t CastReleaseInputFrame(uint32_t handle) override; + int32_t CastProcessFrame(uint32_t inputHandle, uint32_t &decoderHandle) override; + int32_t CastQueueFrameToDecoder(uint32_t handle) override; + int32_t CastDequeueFrameFromDecoder(uint32_t &handle) override; + int32_t CastReleaseFrameBuffQueue() override; + int32_t CastObtainManually(CastMode mode) override; + int32_t CastFreezeScreen(bool isFreeze) override; + + int32_t HdcpEdidResumeHdcp() override; + int32_t HdcpEdidUpdateHdcp(HdmiRxHdcpType type) override; + int32_t HdcpEdidInitEdid(const HdmiRxEdidData& Data) override; + int32_t HdcpEdidUpdateEdid(const HdmiRxEdid& edid) override; + int32_t HdcpEdidSetEdidMode(HdmiRxPort port, HdmiRxEdidType edidType) override; + + int32_t PanelSetBacklightLevel(const uint32_t level) override; + int32_t PanelSetBoostLevel(BoostType boostType, CommonLevel level) override; + int32_t PanelSetBacklightMode(BacklightMode mode) override; + int32_t PanelSetDynamicBlEnable(bool isEnable) override; + int32_t PanelIsDynamicBlEnable(bool &isEnable) override; + int32_t PanelGetPanelAttr(PanelAttr &panelAttr) override; + int32_t PanelGetPowerStatus(bool& enable) override; + int32_t PanelSetBacklightParam(const BacklightParam& backlightParam) override; + int32_t PanelSetPanelPower(bool enable) override; + int32_t PanelSetBlGradualChangeMode(uint32_t mode) override; + int32_t PanelNotifySourceFramerate(const CustomVideoInfo& info) override; + int32_t PanelGetBinVersionInfo(std::string &version) override; + + int32_t PqGetPqPath(std::string &path) override; + int32_t PqInit(const std::string& path) override; + int32_t PqSetSaturation(uint32_t saturation) override; + int32_t PqSetGamma(GammaType gammaType) override; + int32_t PqIsHdrType(HdrType hdrType) override; + int32_t PqSetBrightness(uint32_t brightness) override; + int32_t PqSetContrast(uint32_t contrast) override; + int32_t PqSetSharpness(uint32_t sharpness) override; + int32_t PqSetHue(uint32_t hue) override; + int32_t PqSetNr(uint32_t nrLevel) override; + int32_t PqSetDciGainLevel(CommonLevel dciGainLevel) override; + int32_t PqGetDciGainLevel(CommonLevel& dciGainLevel) override; + int32_t PqSetPqModuleEnable(PqModuleType type, bool isEnable) override; + int32_t PqSetColorManageParam(const ColorManageParam& colorManageParam) override; + int32_t PqSetDeBlocking(uint32_t nrValue) override; + int32_t PqSetDeMosquito(uint32_t nrValue) override; + int32_t PqSetMemcLevel(CommonLevel level) override; + int32_t PqSetDciDbdrDemo(DemoMode demoMode, bool isEnable) override; + int32_t PqSetHdrType(HdrType type) override; + int32_t PqGetHdrType(HdrType &type) override; + int32_t PqSetColorTempParam(const ColorTempParam& colorTempParam) override; + int32_t PqSetColorGain(const uint32_t acmIndex) override; + int32_t PqSetGammaTable(const GammaTable& gammaTable) override; + int32_t PqGetGammaTable(GammaTable& gammaTable) override; + int32_t PqSetHdrCurveIndex(uint32_t hdrCurveIndex) override; + int32_t PqSetDciType(uint32_t typeIndex) override; + int32_t PqSetDciGain(const DciGain& dciGain) override; + int32_t PqGetMemcLevel(CommonLevel& level) override; + int32_t PqSetPanelColorPoint(const PanelColorParam& panelColorParam) override; + + int32_t VideoInputSetHdmiRange(HdmiRange hdmiRange) override; + int32_t VideoInputGetOfflineSignalStatus(SourceType src,InputConnectStatus& status) override; + int32_t VideoInputGetSignalStatus(SignalStatus& status) override; + int32_t VideoGetSource(SourceType &source) override; + int32_t VideoCreate(SourceType source) override; + int32_t VideoStop(const VideoParam& param) override; + int32_t VideoDestroy() override; + int32_t VideoStart(const VideoParam& param) override; + int32_t VideoInputGetHdmiRxSignalEvent(std::vector& event) override; + int32_t VideoInputGetVideoInfo(VideoInfo& info) override; + int32_t VideoInputFreezeWindow(bool isFreeze) override; + int32_t VideoInputSetSourcePortMap(const std::vector& sourceVector, const std::vector& portVector) override; + int32_t VideoInputGetDisplayCapabilities(uint32_t& minFrameRate,uint32_t& maxFrameRate) override; + int32_t VideoOutputSetVideoOutputRect(const VideoRect& rect) override; + int32_t VideoOutputGetVideoOutputRect(VideoRect& rect) override; + + int32_t GetColorSys(ColorSysType &colorSysType) override; + int32_t SetVideoRatio(const VideoRatio &videoRatio) override; + int32_t SetVideoOutputCrop(const VideoCrop &videoCrop) override; + int32_t GetAvStreamInfo(AvStreamInfo &avStreamInfo) override; + int32_t VideoOperation(VideoOperationType videoOperationType) override; + int32_t GetVideoDelay(uint32_t &delayMs) override; + int32_t GetHdmirxProductInfo(SourceType source, HdmirxProductInfo &info) override; + int32_t SetVrrEnable(bool isEnable) override; + int32_t SetAllmEnable(bool isEnable) override; + int32_t HandleNonStdTiming() override; + int32_t SetColorSys(const ColorSysType colorSys) override; + int32_t GetHdmiRxInfo(HdmiRxInfo &hdmiRxInfo)override; + int32_t AdaptViCapLatency()override; + int32_t GetWinAspectMode(WinAspectMode &aspectMode)override; + int32_t SetWinAspectMode(const WinAspectMode aspectMode)override; + int32_t SetDisplayVrrEnable(bool isEnable)override; + int32_t SetAutoLowLatencyMode(const DispAllmMode allMode)override; + int32_t SetMultiWindowStatus(bool isMultiWindow)override; + int32_t SetDispColorSpace(const DispColorSpaceType dispColorSpaceType)override; + int32_t SetQuickOutputEnable(bool isEnable) override; + int32_t GetWindowHandle(WindowType windowType, uint32_t& handle) override; + + int32_t SetMAC(const std::string &macStr) override; + int32_t GetMAC(std::string &macStr) override; + int32_t SetSN(const std::string &snStr) override; + int32_t GetSN(std::string &snStr) override; + int32_t GetCpuTemperature(int32_t &temp) override; + int32_t GetCpuId(std::string &chipidStr) override; +private: + int32_t LoadVdiSo(); + int32_t LoadVdiV1_0(); + +private: + /* Common */ + void* libHandle_; + std::mutex mutex_; + + /* V1_0, which is the version of vdi */ + TvserviceVideoVdi* vdiImpl_; + DestroyVideoVdiFunc destroyVdiFunc_; +}; + +} // V1_0 +} // Video +} // Tvservice +} // HDI +} // OHOS +#endif // OHOS_HDI_TVSERVICE_VIDEO_H diff --git a/tvservice/video/interfaces/hdi_service/include/tvservice_video_vdi.h b/tvservice/video/interfaces/hdi_service/include/tvservice_video_vdi.h new file mode 100644 index 0000000000000000000000000000000000000000..40b5226a8d6acb55baca810c7e96424e996b58e5 --- /dev/null +++ b/tvservice/video/interfaces/hdi_service/include/tvservice_video_vdi.h @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2025 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. + */ + +#ifndef OHOS_HDI_TVSERVICE_VIDEO_VDI_H +#define OHOS_HDI_TVSERVICE_VIDEO_VDI_H + +#include +#include +#include +#include "v1_0/itvservice_video.h" +#include "v1_0/tvservice_video_types.h" + +namespace OHOS { +namespace HDI { +namespace Tvservice { +namespace Video { +namespace V1_0 { +using namespace OHOS::HDI::Tvservice::Video::V1_0; + +#define TVSERVICE_VIDEO_VDI_LIBRARY "libtvservice_video_vdi_impl_default.z.so" + +class TvserviceVideoVdi { +public: + virtual ~TvserviceVideoVdi() = default; + virtual int32_t Connect() = 0; + virtual int32_t Disconnect() = 0; + + virtual int32_t CastInit(const CastVencChnAttr &chnAttr, CastMode castMode) = 0; + virtual int32_t CastDeInit() = 0; + virtual int32_t CastClose(bool isBackground) = 0; + virtual int32_t CastRequestIDRFrame() = 0; + virtual int32_t CastSetAttr(const CastVencChnAttr &chnAttr, CastType castType) = 0; + virtual int32_t CastGetAttr(CastVencChnAttr &chnAttr) = 0; + virtual int32_t CastPause() = 0; + virtual int32_t CastResume() = 0; + virtual int32_t CastCreateVideo(SourceType source, bool needOpenDevice) = 0; + virtual int32_t CastDestroyVideo(bool needCloseDevice) = 0; + virtual int32_t CastStartVideo() = 0; + virtual int32_t CastStopVideo() = 0; + virtual int32_t CastGetVideoSignal(SignalStatus &status) = 0; + virtual int32_t CastGetVideoInfo(VideoInfo &videoInfo) = 0; + virtual int32_t CastAcquireInputFrame(bool frameRateCtrl,uint32_t &handle) = 0; + virtual int32_t CastReleaseInputFrame(uint32_t handle) = 0; + virtual int32_t CastProcessFrame(uint32_t inputHandle, uint32_t &decoderHandle) = 0; + virtual int32_t CastQueueFrameToDecoder(uint32_t handle) = 0; + virtual int32_t CastDequeueFrameFromDecoder(uint32_t &handle) = 0; + virtual int32_t CastReleaseFrameBuffQueue() = 0; + virtual int32_t CastObtainManually(CastMode mode) = 0; + virtual int32_t CastFreezeScreen(bool isFreeze) = 0; + + virtual int32_t HdcpEdidResumeHdcp() = 0; + virtual int32_t HdcpEdidUpdateHdcp(HdmiRxHdcpType type) = 0; + virtual int32_t HdcpEdidInitEdid(const HdmiRxEdidData& Data) = 0; + virtual int32_t HdcpEdidUpdateEdid(const HdmiRxEdid& edid) = 0; + virtual int32_t HdcpEdidSetEdidMode(HdmiRxPort port, HdmiRxEdidType edidType) = 0; + + virtual int32_t PanelSetBacklightLevel(const uint32_t level) = 0; + virtual int32_t PanelSetBoostLevel(BoostType boostType, CommonLevel level) = 0; + virtual int32_t PanelSetBacklightMode(BacklightMode mode) = 0; + virtual int32_t PanelSetDynamicBlEnable(bool isEnable) = 0; + virtual int32_t PanelIsDynamicBlEnable(bool &isEnable) = 0; + virtual int32_t PanelGetPanelAttr(PanelAttr &panelAttr) = 0; + virtual int32_t PanelGetPowerStatus(bool& enable) = 0; + virtual int32_t PanelSetBacklightParam(const BacklightParam& backlightParam) = 0; + virtual int32_t PanelSetPanelPower(bool enable) = 0; + virtual int32_t PanelSetBlGradualChangeMode(uint32_t mode) = 0; + virtual int32_t PanelNotifySourceFramerate(const CustomVideoInfo& info) = 0; + virtual int32_t PanelGetBinVersionInfo(std::string &version) = 0; + + virtual int32_t PqGetPqPath(std::string &path) = 0; + virtual int32_t PqInit(const std::string& path) = 0; + virtual int32_t PqSetSaturation(uint32_t saturation) = 0; + virtual int32_t PqSetGamma(GammaType gammaType) = 0; + virtual int32_t PqIsHdrType(HdrType hdrType) = 0; + virtual int32_t PqSetBrightness(uint32_t brightness) = 0; + virtual int32_t PqSetContrast(uint32_t contrast) = 0; + virtual int32_t PqSetSharpness(uint32_t sharpness) = 0; + virtual int32_t PqSetHue(uint32_t hue) = 0; + virtual int32_t PqSetNr(uint32_t nrLevel) = 0; + virtual int32_t PqSetDciGainLevel(CommonLevel dciGainLevel) = 0; + virtual int32_t PqGetDciGainLevel(CommonLevel& dciGainLevel) = 0; + virtual int32_t PqSetPqModuleEnable(PqModuleType type, bool isEnable) = 0; + virtual int32_t PqSetColorManageParam(const ColorManageParam& colorManageParam) = 0; + virtual int32_t PqSetDeBlocking(uint32_t nrValue) = 0; + virtual int32_t PqSetDeMosquito(uint32_t nrValue) = 0; + virtual int32_t PqSetMemcLevel(CommonLevel level) = 0; + virtual int32_t PqSetDciDbdrDemo(DemoMode demoMode, bool isEnable) = 0; + virtual int32_t PqSetHdrType(HdrType type) = 0; + virtual int32_t PqGetHdrType(HdrType &type) = 0; + virtual int32_t PqSetColorTempParam(const ColorTempParam& colorTempParam) = 0; + virtual int32_t PqSetColorGain(const uint32_t acmIndex) = 0; + virtual int32_t PqSetGammaTable(const GammaTable& gammaTable) = 0; + virtual int32_t PqGetGammaTable(GammaTable& gammaTable) = 0; + virtual int32_t PqSetHdrCurveIndex(uint32_t hdrCurveIndex) = 0; + virtual int32_t PqSetDciType(uint32_t typeIndex) = 0; + virtual int32_t PqSetDciGain(const DciGain& dciGain) = 0; + virtual int32_t PqGetMemcLevel(CommonLevel& level) = 0; + virtual int32_t PqSetPanelColorPoint(const PanelColorParam& panelColorParam) = 0; + + virtual int32_t VideoInputSetHdmiRange(HdmiRange hdmiRange) = 0; + virtual int32_t VideoInputGetOfflineSignalStatus(SourceType src,InputConnectStatus& status) = 0; + virtual int32_t VideoInputGetSignalStatus(SignalStatus& status) = 0; + virtual int32_t VideoGetSource(SourceType &source) = 0; + virtual int32_t VideoCreate(SourceType source) = 0; + virtual int32_t VideoStop(const VideoParam& param) = 0; + virtual int32_t VideoDestroy() = 0; + virtual int32_t VideoStart(const VideoParam& param) = 0; + virtual int32_t VideoInputGetHdmiRxSignalEvent(std::vector& event) = 0; + virtual int32_t VideoInputGetVideoInfo(VideoInfo& info) = 0; + virtual int32_t VideoInputFreezeWindow(bool isFreeze) = 0; + virtual int32_t VideoInputSetSourcePortMap(std::map portMap) = 0; + virtual int32_t VideoInputGetDisplayCapabilities(uint32_t& minFrameRate,uint32_t& maxFrameRate) = 0; + virtual int32_t VideoOutputSetVideoOutputRect(const VideoRect& rect) = 0; + virtual int32_t VideoOutputGetVideoOutputRect(VideoRect& rect) = 0; + + virtual int32_t GetColorSys(ColorSysType &colorSysType) = 0; + virtual int32_t SetVideoRatio(const VideoRatio &videoRatio) = 0; + virtual int32_t SetVideoOutputCrop(const VideoCrop &videoCrop) = 0; + virtual int32_t GetAvStreamInfo(AvStreamInfo &avStreamInfo) = 0; + virtual int32_t VideoOperation(VideoOperationType videoOperationType) = 0; + virtual int32_t GetVideoDelay(uint32_t &delayMs) = 0; + virtual int32_t GetHdmirxProductInfo(SourceType source, HdmirxProductInfo &info) = 0; + virtual int32_t SetVrrEnable(bool isEnable) = 0 ; + virtual int32_t SetAllmEnable(bool isEnable) = 0 ; + virtual int32_t HandleNonStdTiming() = 0; + virtual int32_t SetColorSys(const ColorSysType colorSys) = 0; + virtual int32_t GetHdmiRxInfo(HdmiRxInfo &hdmiRxInfo) = 0; + virtual int32_t AdaptViCapLatency() = 0; + virtual int32_t GetWinAspectMode(WinAspectMode &aspectMode) = 0; + virtual int32_t SetWinAspectMode(const WinAspectMode aspectMode) = 0; + virtual int32_t SetDisplayVrrEnable(bool isEnable) = 0; + virtual int32_t SetAutoLowLatencyMode(const DispAllmMode allMode) = 0; + virtual int32_t SetMultiWindowStatus(bool isMultiWindow) = 0; + virtual int32_t SetDispColorSpace(const DispColorSpaceType dispColorSpaceType) = 0; + virtual int32_t SetQuickOutputEnable(bool isEnable) = 0; + virtual int32_t GetWindowHandle(WindowType windowType, uint32_t& handle) = 0; + + virtual int32_t SetMAC(const std::string &macStr) = 0; + virtual int32_t GetMAC(std::string &macStr) = 0; + virtual int32_t SetSN(const std::string &snStr) = 0; + virtual int32_t GetSN(std::string &snStr) = 0; + virtual int32_t GetCpuTemperature(int32_t &temp) = 0; + virtual int32_t GetCpuId(std::string &chipidStr) = 0; +}; + +using CreateVideoVdiFunc = TvserviceVideoVdi* (*)(); +using DestroyVideoVdiFunc = void (*)(TvserviceVideoVdi* vdi); +extern "C" TvserviceVideoVdi* CreateVideoVdi(); +extern "C" void DestroyVideoVdi(TvserviceVideoVdi* vdi); +} // namespace V1_0 +} // namespace Video +} // namespace Tvservice +} // namespace HDI +} // namespace OHOS +#endif // OHOS_HDI_TVSERVICE_VIDEO_VDI_H diff --git a/tvservice/video/interfaces/hdi_service/src/tvservice_video_driver.cpp b/tvservice/video/interfaces/hdi_service/src/tvservice_video_driver.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a21fb2b5fdc4ff3fe59a126201ab1b5d32f65cae --- /dev/null +++ b/tvservice/video/interfaces/hdi_service/src/tvservice_video_driver.cpp @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2025 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 +#include "v1_0/tvservice_video_stub.h" + +#define HDF_LOG_TAG TvserviceVideoDriver + + +struct HdfTvserviceVideoHost { + struct IDeviceIoService ioService; + OHOS::sptr stub; +}; + +static pthread_rwlock_t g_rwLock = PTHREAD_RWLOCK_INITIALIZER; +static bool g_stop = true; + +static int32_t TvserviceVideoDriverDispatch(struct HdfDeviceIoClient *client, int cmdId, struct HdfSBuf *data, + struct HdfSBuf *reply) +{ + HDF_LOGI("TvserviceVideoDriverDispatch enter"); + + if ((client == nullptr) || (client->device == nullptr)) { + HDF_LOGE("%{public}s: param is nullptr", __func__); + return HDF_ERR_INVALID_PARAM; + } + + OHOS::MessageParcel* dataParcel = nullptr; + OHOS::MessageParcel* replyParcel = nullptr; + OHOS::MessageOption option; + + if (SbufToParcel(data, &dataParcel) != HDF_SUCCESS) { + HDF_LOGE("%{public}s:invalid data sbuf object to dispatch", __func__); + return HDF_ERR_INVALID_PARAM; + } + if (SbufToParcel(reply, &replyParcel) != HDF_SUCCESS) { + HDF_LOGE("%{public}s:invalid reply sbuf object to dispatch", __func__); + return HDF_ERR_INVALID_PARAM; + } + + pthread_rwlock_rdlock(&g_rwLock); + auto* hdfTvserviceVideoHost = CONTAINER_OF(client->device->service, struct HdfTvserviceVideoHost, ioService); + if (hdfTvserviceVideoHost == nullptr || g_stop) { + pthread_rwlock_unlock(&g_rwLock); + HDF_LOGE("%{public}s:hdfTvserviceVideoHost nullptr, stop: %{public}d", __func__, g_stop); + return HDF_FAILURE; + } + + HDF_LOGI("TvserviceVideoDriverDispatch cmdId:%{public}d", cmdId); + int32_t ret = hdfTvserviceVideoHost->stub->SendRequest(cmdId, *dataParcel, *replyParcel, option); + pthread_rwlock_unlock(&g_rwLock); + HDF_LOGI("TvserviceVideoDriverDispatch ret:%{public}d", ret); + return ret; +} + +static int HdfTvserviceVideoDriverInit([[maybe_unused]] struct HdfDeviceObject *deviceObject) +{ + HDF_LOGI("HdfTvserviceVideoDriverInit enter"); + return HDF_SUCCESS; +} + +static int HdfTvserviceVideoDriverBind(struct HdfDeviceObject *deviceObject) +{ + HDF_LOGI("HdfTvserviceVideoDriverBind enter"); + static auto* hdfTvserviceVideoHost = new (std::nothrow) HdfTvserviceVideoHost; + if (hdfTvserviceVideoHost == nullptr) { + HDF_LOGE("%{public}s: failed to create hdfTvserviceVideoHost object", __func__); + return HDF_FAILURE; + } + + hdfTvserviceVideoHost->ioService.Dispatch = TvserviceVideoDriverDispatch; + hdfTvserviceVideoHost->ioService.Open = NULL; + hdfTvserviceVideoHost->ioService.Release = NULL; + + auto serviceImpl = OHOS::HDI::Tvservice::Video::V1_0::ITvserviceVideo::Get(true); + if (serviceImpl == nullptr) { + HDF_LOGE("%{public}s: failed to get the implement of service", __func__); + delete hdfTvserviceVideoHost; + return HDF_FAILURE; + } + + hdfTvserviceVideoHost->stub = OHOS::HDI::ObjectCollector::GetInstance().GetOrNewObject(serviceImpl, + OHOS::HDI::Tvservice::Video::V1_0::ITvserviceVideo::GetDescriptor()); + if (hdfTvserviceVideoHost->stub == nullptr) { + HDF_LOGE("%{public}s: failed to get stub object", __func__); + delete hdfTvserviceVideoHost; + return HDF_FAILURE; + } + deviceObject->service = &hdfTvserviceVideoHost->ioService; + g_stop = false; + HDF_LOGI("HdfTvserviceVideoDriverBind HDF_SUCCESS"); + return HDF_SUCCESS; +} + +static void HdfTvserviceVideoDriverRelease(struct HdfDeviceObject *deviceObject) +{ + HDF_LOGI("HdfTvserviceVideoDriverRelease enter"); +} + +static struct HdfDriverEntry g_tvservicevideoDriverEntry = { + .moduleVersion = 1, + .moduleName = "tvservice_video_service", + .Bind = HdfTvserviceVideoDriverBind, + .Init = HdfTvserviceVideoDriverInit, + .Release = HdfTvserviceVideoDriverRelease, +}; + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ +HDF_INIT(g_tvservicevideoDriverEntry); +#ifdef __cplusplus +} + #endif /* __cplusplus */ \ No newline at end of file diff --git a/tvservice/video/interfaces/hdi_service/src/tvservice_video_service.cpp b/tvservice/video/interfaces/hdi_service/src/tvservice_video_service.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ff52d1a2fe779171615ff99565d5fc975010e22c --- /dev/null +++ b/tvservice/video/interfaces/hdi_service/src/tvservice_video_service.cpp @@ -0,0 +1,1238 @@ +/* + * Copyright (c) 2025 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 "tvservice_video_service.h" +#include "tvservice_video_vdi.h" +#include +#include +#include +#include +#include +#include +#include "osal_mem.h" +#include +#define HDF_LOG_TAG TvserviceVideoImpl + +namespace OHOS { +namespace HDI { +namespace Tvservice { +namespace Video { +namespace V1_0 { +extern "C" ITvserviceVideo* TvserviceVideoImplGetInstance(void) +{ + HDF_LOGI("enter %{public}s", __func__); + return new (std::nothrow) TvserviceVideoService(); +} + +TvserviceVideoService::TvserviceVideoService(): libHandle_(nullptr),vdiImpl_(nullptr) +{ + HDF_LOGI("enter %{public}s", __func__); + + int32_t ret = LoadVdiSo(); + if (ret != HDF_SUCCESS) { + HDF_LOGE("Load tvservice video VDI failed, lib: %{public}s", TVSERVICE_VIDEO_VDI_LIBRARY); + return; + } + + ret = LoadVdiV1_0(); + + if (ret != HDF_SUCCESS) { + dlclose(libHandle_); + libHandle_ = nullptr; + HDF_LOGE("Load tvservice video VDI function failed"); + } +} + + +TvserviceVideoService::~TvserviceVideoService(){} + +int32_t TvserviceVideoService::LoadVdiSo() +{ + HDF_LOGI("enter %{public}s", __func__); + + const char* errStr = dlerror(); + if (errStr != nullptr) { + HDF_LOGE("video load vdi, clear earlier dlerror: %{public}s", errStr); + } + + libHandle_ = dlopen(TVSERVICE_VIDEO_VDI_LIBRARY, RTLD_LAZY); + + if (libHandle_ == nullptr) { + HDF_LOGE("video load vendor vdi default library failed: %{public}s",TVSERVICE_VIDEO_VDI_LIBRARY); + } else { + HDF_LOGI("video load vendor vdi default library: %{public}s", TVSERVICE_VIDEO_VDI_LIBRARY); + } + + return HDF_SUCCESS; +} + +int32_t TvserviceVideoService::LoadVdiV1_0() +{ + HDF_LOGI("enter %{public}s", __func__); + + CreateVideoVdiFunc createVdiFunc = nullptr; + const char* errStr = nullptr; + + createVdiFunc = reinterpret_cast(dlsym(libHandle_, "CreateVideoVdi")); + if (createVdiFunc == nullptr) { + errStr = dlerror(); + if (errStr != nullptr) { + HDF_LOGE("CreateVideoVdiFunc dlsym error: %{public}s", errStr); + } + return HDF_FAILURE; + } + + destroyVdiFunc_ = reinterpret_cast(dlsym(libHandle_, "DestroyVideoVdi")); + if (destroyVdiFunc_ == nullptr) { + errStr = dlerror(); + if (errStr != nullptr) { + HDF_LOGE("DestroyVideoVdiFunc dlsym error: %{public}s", errStr); + } + return HDF_FAILURE; + } + + vdiImpl_ = createVdiFunc(); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoService::Connect() +{ + HDF_LOGI("enter %{public}s", __func__); + vdiImpl_->Connect(); + HDF_LOGI("leave %{public}s", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoService::Disconnect() +{ + HDF_LOGI("enter %{public}s", __func__); + vdiImpl_->Disconnect(); + HDF_LOGI("leave %{public}s", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoService::CastInit(const CastVencChnAttr &chnAttr, CastMode castMode) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->CastInit(chnAttr, castMode); +} + +int32_t TvserviceVideoService::CastDeInit() +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->CastDeInit(); +} + +int32_t TvserviceVideoService::CastClose(bool isBackground) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->CastClose(isBackground); +} + +int32_t TvserviceVideoService::CastRequestIDRFrame() +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->CastRequestIDRFrame(); +} + +int32_t TvserviceVideoService::CastSetAttr(const CastVencChnAttr &chnAttr, CastType castType) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->CastSetAttr(chnAttr, castType); +} + +int32_t TvserviceVideoService::CastGetAttr(CastVencChnAttr &chnAttr) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->CastGetAttr(chnAttr); +} + +int32_t TvserviceVideoService::CastPause() +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->CastPause(); +} + +int32_t TvserviceVideoService::CastResume() +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->CastResume(); +} + +int32_t TvserviceVideoService::CastCreateVideo(SourceType source, bool needOpenDevice) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->CastCreateVideo(source, needOpenDevice); +} + +int32_t TvserviceVideoService::CastDestroyVideo(bool needCloseDevice) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->CastDestroyVideo(needCloseDevice); +} + +int32_t TvserviceVideoService::CastStartVideo() +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->CastStartVideo(); +} + +int32_t TvserviceVideoService::CastStopVideo() +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->CastStopVideo(); +} + +int32_t TvserviceVideoService::CastGetVideoSignal(SignalStatus &status) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->CastGetVideoSignal(status); +} + +int32_t TvserviceVideoService::CastGetVideoInfo(VideoInfo &videoInfo) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->CastGetVideoInfo(videoInfo); +} + +int32_t TvserviceVideoService::CastAcquireInputFrame(bool frameRateCtrl, uint32_t &handle) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->CastAcquireInputFrame(frameRateCtrl, handle); +} + +int32_t TvserviceVideoService::CastReleaseInputFrame(uint32_t handle) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->CastReleaseInputFrame(handle); +} + +int32_t TvserviceVideoService::CastProcessFrame(uint32_t inputHandle, uint32_t &decoderHandle) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->CastProcessFrame(inputHandle, decoderHandle); +} + +int32_t TvserviceVideoService::CastQueueFrameToDecoder(uint32_t handle) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->CastQueueFrameToDecoder(handle); +} + +int32_t TvserviceVideoService::CastDequeueFrameFromDecoder(uint32_t &handle) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->CastDequeueFrameFromDecoder(handle); +} + +int32_t TvserviceVideoService::CastReleaseFrameBuffQueue() +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->CastReleaseFrameBuffQueue(); +} + +int32_t TvserviceVideoService::CastObtainManually(CastMode mode) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->CastObtainManually(mode); +} + +int32_t TvserviceVideoService::CastFreezeScreen(bool isFreeze) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->CastFreezeScreen(isFreeze); +} + +int32_t TvserviceVideoService::HdcpEdidResumeHdcp() +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->HdcpEdidResumeHdcp(); +} + +int32_t TvserviceVideoService::HdcpEdidUpdateHdcp(HdmiRxHdcpType type) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->HdcpEdidUpdateHdcp(type); +} + +int32_t TvserviceVideoService::HdcpEdidInitEdid(const HdmiRxEdidData& Data) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->HdcpEdidInitEdid(Data); +} + +int32_t TvserviceVideoService::HdcpEdidUpdateEdid(const HdmiRxEdid& edid) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->HdcpEdidUpdateEdid(edid); +} + +int32_t TvserviceVideoService::HdcpEdidSetEdidMode(HdmiRxPort port, HdmiRxEdidType edidType) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->HdcpEdidSetEdidMode(port, edidType); +} + +int32_t TvserviceVideoService::PanelSetBacklightLevel(const uint32_t level) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->PanelSetBacklightLevel(level); +} + +int32_t TvserviceVideoService::PanelSetBoostLevel(BoostType boostType, CommonLevel level) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->PanelSetBoostLevel(boostType, level); +} + +int32_t TvserviceVideoService::PanelSetBacklightMode(BacklightMode mode) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->PanelSetBacklightMode(mode); +} + +int32_t TvserviceVideoService::PanelSetDynamicBlEnable(bool isEnable) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->PanelSetDynamicBlEnable(isEnable); +} + +int32_t TvserviceVideoService::PanelIsDynamicBlEnable(bool &isEnable) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->PanelIsDynamicBlEnable(isEnable); +} + +int32_t TvserviceVideoService::PanelGetPanelAttr(PanelAttr &panelAttr) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->PanelGetPanelAttr(panelAttr); +} + +int32_t TvserviceVideoService::PanelGetPowerStatus(bool& enable) +{ + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->PanelGetPowerStatus(enable); +} + +int32_t TvserviceVideoService::PanelSetBacklightParam(const BacklightParam& backlightParam) +{ + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->PanelSetBacklightParam(backlightParam); +} + +int32_t TvserviceVideoService::PanelSetPanelPower(bool enable) +{ + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->PanelSetPanelPower(enable); +} + +int32_t TvserviceVideoService::PanelSetBlGradualChangeMode(uint32_t mode) +{ + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->PanelSetBlGradualChangeMode(mode); +} + +int32_t TvserviceVideoService::PanelNotifySourceFramerate(const CustomVideoInfo& info) +{ + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->PanelNotifySourceFramerate(info); +} + +int32_t TvserviceVideoService::PanelGetBinVersionInfo(std::string &version) +{ + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->PanelGetBinVersionInfo(version); +} + +int32_t TvserviceVideoService::PqGetPqPath(std::string& path) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->PqGetPqPath(path); +} + +int32_t TvserviceVideoService::PqInit(const std::string& path) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->PqInit(path); +} + +int32_t TvserviceVideoService::PqSetSaturation(uint32_t saturation) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->PqSetSaturation(saturation); +} + +int32_t TvserviceVideoService::PqSetGamma(GammaType gammaType) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->PqSetGamma(gammaType); +} + +int32_t TvserviceVideoService::PqIsHdrType(HdrType hdrType) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->PqIsHdrType(hdrType); +} + +int32_t TvserviceVideoService::PqSetBrightness(uint32_t brightness) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->PqSetBrightness(brightness); +} + +int32_t TvserviceVideoService::PqSetContrast(uint32_t contrast) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->PqSetContrast(contrast); +} + +int32_t TvserviceVideoService::PqSetSharpness(uint32_t sharpness) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->PqSetSharpness(sharpness); +} + +int32_t TvserviceVideoService::PqSetHue(uint32_t hue) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->PqSetHue(hue); +} + +int32_t TvserviceVideoService::PqSetNr(uint32_t nrLevel) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->PqSetNr(nrLevel); +} + +int32_t TvserviceVideoService::PqSetDciGainLevel(CommonLevel dciGainLevel) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->PqSetDciGainLevel(dciGainLevel); +} + +int32_t TvserviceVideoService::PqGetDciGainLevel(CommonLevel& dciGainLevel) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->PqGetDciGainLevel(dciGainLevel); +} + +int32_t TvserviceVideoService::PqSetPqModuleEnable(PqModuleType type, bool isEnable) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->PqSetPqModuleEnable(type, isEnable); +} + +int32_t TvserviceVideoService::PqSetColorManageParam(const ColorManageParam& colorManageParam) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->PqSetColorManageParam(colorManageParam); +} + +int32_t TvserviceVideoService::PqSetDeBlocking(uint32_t nrValue) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->PqSetDeBlocking(nrValue); +} + +int32_t TvserviceVideoService::PqSetDeMosquito(uint32_t nrValue) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->PqSetDeMosquito(nrValue); +} + +int32_t TvserviceVideoService::PqSetMemcLevel(CommonLevel level) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->PqSetMemcLevel(level); +} + +int32_t TvserviceVideoService::PqSetDciDbdrDemo(DemoMode demoMode, bool isEnable) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->PqSetDciDbdrDemo(demoMode, isEnable); +} + +int32_t TvserviceVideoService::PqSetHdrType(HdrType type) +{ + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->PqSetHdrType(type); +} + +int32_t TvserviceVideoService::PqGetHdrType(HdrType &type) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->PqGetHdrType(type); +} + +int32_t TvserviceVideoService::PqSetColorTempParam(const ColorTempParam& colorTempParam) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->PqSetColorTempParam(colorTempParam); +} + +int32_t TvserviceVideoService::PqSetColorGain(const uint32_t acmIndex) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->PqSetColorGain(acmIndex); +} + +int32_t TvserviceVideoService::PqSetGammaTable(const GammaTable& gammaTable) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->PqSetGammaTable(gammaTable); +} + +int32_t TvserviceVideoService::PqGetGammaTable(GammaTable& gammaTable) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->PqGetGammaTable(gammaTable); +} + +int32_t TvserviceVideoService::PqSetHdrCurveIndex(uint32_t hdrCurveIndex) +{ + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->PqSetHdrCurveIndex(hdrCurveIndex); +} + +int32_t TvserviceVideoService::PqSetDciType(uint32_t typeIndex) +{ + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->PqSetDciType(typeIndex); +} + +int32_t TvserviceVideoService::PqSetDciGain(const DciGain& dciGain) +{ + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->PqSetDciGain(dciGain); +} + +int32_t TvserviceVideoService::PqGetMemcLevel(CommonLevel& level) +{ + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->PqGetMemcLevel(level); +} + +int32_t TvserviceVideoService::PqSetPanelColorPoint(const PanelColorParam& panelColorParam) +{ + HDF_LOGE("enter %s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->PqSetPanelColorPoint(panelColorParam); +} + +int32_t TvserviceVideoService::VideoInputSetHdmiRange(HdmiRange hdmiRange) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->VideoInputSetHdmiRange(hdmiRange); +} + +int32_t TvserviceVideoService::VideoInputGetOfflineSignalStatus(SourceType src, InputConnectStatus& status) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->VideoInputGetOfflineSignalStatus(src, status); +} + +int32_t TvserviceVideoService::VideoInputGetSignalStatus(SignalStatus& status) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->VideoInputGetSignalStatus(status); +} + +int32_t TvserviceVideoService::VideoGetSource(SourceType &source) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->VideoGetSource(source); +} + +int32_t TvserviceVideoService::VideoCreate(SourceType source) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->VideoCreate(source); +} + +int32_t TvserviceVideoService::VideoStop(const VideoParam& param) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->VideoStop(param); +} + +int32_t TvserviceVideoService::VideoDestroy() +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->VideoDestroy(); +} + +int32_t TvserviceVideoService::VideoStart(const VideoParam& param) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->VideoStart(param); +} + +int32_t TvserviceVideoService::VideoInputGetHdmiRxSignalEvent(std::vector& event) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->VideoInputGetHdmiRxSignalEvent(event); +} + +int32_t TvserviceVideoService::VideoInputGetVideoInfo(VideoInfo& info) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->VideoInputGetVideoInfo(info); +} + +int32_t TvserviceVideoService::VideoInputFreezeWindow(bool isFreeze) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->VideoInputFreezeWindow(isFreeze); +} + +int32_t TvserviceVideoService::VideoInputGetDisplayCapabilities(uint32_t& minFrameRate, uint32_t& maxFrameRate) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->VideoInputGetDisplayCapabilities(minFrameRate, maxFrameRate); +} + +int32_t TvserviceVideoService::VideoOutputSetVideoOutputRect(const VideoRect& rect) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->VideoOutputSetVideoOutputRect(rect); +} + +int32_t TvserviceVideoService::VideoOutputGetVideoOutputRect(VideoRect& rect) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->VideoOutputGetVideoOutputRect(rect); +} + +int32_t TvserviceVideoService::GetColorSys(ColorSysType &colorSysType) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->GetColorSys(colorSysType); +} + +int32_t TvserviceVideoService::SetVideoRatio(const VideoRatio &videoRatio) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->SetVideoRatio(videoRatio); +} + +int32_t TvserviceVideoService::SetVideoOutputCrop(const VideoCrop &videoCrop) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->SetVideoOutputCrop(videoCrop); +} + +int32_t TvserviceVideoService::GetAvStreamInfo(AvStreamInfo &avStreamInfo) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->GetAvStreamInfo(avStreamInfo); +} + +int32_t TvserviceVideoService::VideoOperation(VideoOperationType videoOperationType) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->VideoOperation(videoOperationType); +} + +int32_t TvserviceVideoService::GetVideoDelay(uint32_t &delayMs) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->GetVideoDelay(delayMs); +} + +int32_t TvserviceVideoService::GetHdmirxProductInfo(SourceType source, HdmirxProductInfo &info) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->GetHdmirxProductInfo(source, info); +} + +int32_t TvserviceVideoService::VideoInputSetSourcePortMap(const std::vector& sourceVector, const std::vector& portVector) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + std::map portMap; + if(sourceVector.size() != portVector.size()){ + HDF_LOGE("%{public}s sourceVector.size() != portVector.size()", __func__); + return HDF_FAILURE; + } + for (size_t i = 0; i < sourceVector.size(); i++) { + portMap[sourceVector[i]] = portVector[i]; + } + return vdiImpl_->VideoInputSetSourcePortMap(portMap); +} +int32_t TvserviceVideoService::SetVrrEnable(bool isEnable) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->SetVrrEnable(isEnable); +} + +int32_t TvserviceVideoService::SetAllmEnable(bool isEnable) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->SetAllmEnable(isEnable); +} + +int32_t TvserviceVideoService::HandleNonStdTiming() +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->HandleNonStdTiming(); +} + +int32_t TvserviceVideoService::SetColorSys(const ColorSysType colorSys) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->SetColorSys(colorSys); +} + +int32_t TvserviceVideoService::GetHdmiRxInfo(HdmiRxInfo &hdmiRxInfo) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->GetHdmiRxInfo(hdmiRxInfo); +} + +int32_t TvserviceVideoService::AdaptViCapLatency() +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->AdaptViCapLatency(); +} + +int32_t TvserviceVideoService::GetWinAspectMode(WinAspectMode &aspectMode) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->GetWinAspectMode(aspectMode); +} + +int32_t TvserviceVideoService::SetWinAspectMode(const WinAspectMode aspectMode) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->SetWinAspectMode(aspectMode); + +} + +int32_t TvserviceVideoService::SetDisplayVrrEnable(bool isEnable) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->SetDisplayVrrEnable(isEnable); +} + +int32_t TvserviceVideoService::SetAutoLowLatencyMode(const DispAllmMode allMode) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->SetAutoLowLatencyMode(allMode); +} + +int32_t TvserviceVideoService::SetMultiWindowStatus(bool isMultiWindow) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->SetMultiWindowStatus(isMultiWindow); +} + +int32_t TvserviceVideoService::SetDispColorSpace(const DispColorSpaceType dispColorSpaceType) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->SetDispColorSpace(dispColorSpaceType); +} + +int32_t TvserviceVideoService::SetQuickOutputEnable(bool isEnable) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->SetQuickOutputEnable(isEnable); +} + +int32_t TvserviceVideoService::GetWindowHandle(WindowType windowType,uint32_t &handle) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->GetWindowHandle(windowType,handle); +} + +int32_t TvserviceVideoService::SetMAC(const std::string &macStr) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->SetMAC(macStr); +} + +int32_t TvserviceVideoService::GetMAC(std::string &macStr) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->GetMAC(macStr); +} + +int32_t TvserviceVideoService::SetSN(const std::string &snStr) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->SetSN(snStr); +} + +int32_t TvserviceVideoService::GetSN(std::string &snStr) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->GetSN(snStr); +} + +int32_t TvserviceVideoService::GetCpuTemperature(int32_t &temp) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->GetCpuTemperature(temp); +} + +int32_t TvserviceVideoService::GetCpuId(std::string &chipidStr) +{ + HDF_LOGI("enter %{public}s", __func__); + if (vdiImpl_ == nullptr) { + HDF_LOGE("%{public}s vdiImpl_ is nullptr", __func__); + return HDF_FAILURE; + } + return vdiImpl_->GetCpuId(chipidStr); +} + +} // V1_0 +} // Video +} // Tvservice +} // HDI +} // OHOS diff --git a/tvservice/video/interfaces/vdi_base/BUILD.gn b/tvservice/video/interfaces/vdi_base/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..38e958b3a9ccb364b620d5458e6b3f189e57cec9 --- /dev/null +++ b/tvservice/video/interfaces/vdi_base/BUILD.gn @@ -0,0 +1,50 @@ +# Copyright (C) 2025 HiHope Open Source Organization . +# 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. + +import("//build/ohos.gni") +import("../../../tvservice.gni") +import("//vendor/${product_company}/${product_name}/product.gni") + +ohos_shared_library("tvservice_video_vdi_impl_default") { + defines = [] + sources = [ + "src/tvservice_video_vdi_impl.cpp", + "src/tvservice_deviceinfo.c" + ] + output_name = "tvservice_video_vdi_impl_default" + include_dirs = [ + "include", + "../hdi_service/include", + "../../utils/include", + ] + cflags_cc = [ + "-fPIC", + "-Wall", + "-Wno-error=unused-function", + "-Wno-error=missing-braces", + "-Wno-error=#warnings", + ] + external_deps = [ + "c_utils:utils", + "drivers_interface_tvservice:libtvservice_video_stub_1.0", + "drivers_interface_tvservice:libtvservice_video_proxy_1.0", + "hdf_core:libhdf_utils", + "hilog:libhilog", + "hitrace:hitrace_meter", + "ipc:ipc_single", + ] + install_enable = true + install_images = [ chipset_base_dir ] + subsystem_name = "hdf" + part_name = "drivers_peripheral_tvservice" +} \ No newline at end of file diff --git a/tvservice/video/interfaces/vdi_base/include/tvservice_deviceinfo.h b/tvservice/video/interfaces/vdi_base/include/tvservice_deviceinfo.h new file mode 100644 index 0000000000000000000000000000000000000000..26d4747b089a81a0cffe969e507936f7f820a872 --- /dev/null +++ b/tvservice/video/interfaces/vdi_base/include/tvservice_deviceinfo.h @@ -0,0 +1,32 @@ +#ifndef TVSERVICE_DEVICEINFO_H +#define TVSERVICE_DEVICEINFO_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef int (*mPGetCpuTemperature)( int *temp ); +typedef int (*mPGetCpuId)(char *chipid, unsigned int len); +typedef int (*mPGetMAC)(char *chipmac, unsigned int len); +typedef int (*mPSetMAC)(char *chipmac, unsigned int len); +typedef int (*mPGetSN)(char *chipsn, unsigned int len); +typedef int (*mPSetSN)(char *chipsn, unsigned int len); + +typedef struct { + mPGetCpuTemperature MPGetCpuTemperature; + mPGetCpuId MPGetCpuId; + mPGetMAC MPGetMAC; + mPSetMAC MPSetMAC; + mPGetSN MPGetSN; + mPSetSN MPSetSN; +}GKMpiApi; + +extern GKMpiApi *g_gkApi; +int32_t GetGkApi(GKMpiApi **mppApi); +void ReleaseGkApi(GKMpiApi *mppApi); + +#ifdef __cplusplus +} +#endif + +#endif // HDI_MPP_MPI_H \ No newline at end of file diff --git a/tvservice/video/interfaces/vdi_base/include/tvservice_video_vdi_impl.h b/tvservice/video/interfaces/vdi_base/include/tvservice_video_vdi_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..c71a35d914367caf37abeaaa2a7b62de64fec973 --- /dev/null +++ b/tvservice/video/interfaces/vdi_base/include/tvservice_video_vdi_impl.h @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2025 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. + */ + +#ifndef TVSERVICE_VIDEO_VDI_IMPL_H +#define TVSERVICE_VIDEO_VDI_IMPL_H + +#include "tvservice_video_vdi.h" +#include "v1_0/tvservice_video_types.h" +#include "tvservice_deviceinfo.h" + +namespace OHOS { +namespace HDI { +namespace Tvservice { +namespace Video { +using namespace OHOS::HDI::Tvservice::Video; + +class TvserviceVideoVdiImpl : public V1_0::TvserviceVideoVdi { +public: + TvserviceVideoVdiImpl(); + virtual ~TvserviceVideoVdiImpl(); + int32_t Connect() override; + int32_t Disconnect() override; + + int32_t CastInit(const V1_0::CastVencChnAttr &chnAttr, V1_0::CastMode castMode) override; + int32_t CastDeInit() override; + int32_t CastClose(bool isBackground) override; + int32_t CastRequestIDRFrame() override; + int32_t CastSetAttr(const V1_0::CastVencChnAttr &chnAttr, V1_0::CastType castType) override; + int32_t CastGetAttr(V1_0::CastVencChnAttr &chnAttr) override; + int32_t CastPause() override; + int32_t CastResume() override; + int32_t CastCreateVideo(V1_0::SourceType source, bool needOpenDevice) override; + int32_t CastDestroyVideo(bool needCloseDevice) override; + int32_t CastStartVideo() override; + int32_t CastStopVideo() override; + int32_t CastGetVideoSignal(V1_0::SignalStatus &status) override; + int32_t CastGetVideoInfo(V1_0::VideoInfo &videoInfo) override; + int32_t CastAcquireInputFrame(bool frameRateCtrl, uint32_t &handle) override; + int32_t CastReleaseInputFrame(uint32_t handle) override; + int32_t CastProcessFrame(uint32_t inputHandle, uint32_t &decoderHandle) override; + int32_t CastQueueFrameToDecoder(uint32_t handle) override; + int32_t CastDequeueFrameFromDecoder(uint32_t &handle) override; + int32_t CastReleaseFrameBuffQueue() override; + int32_t CastObtainManually(V1_0::CastMode mode) override; + int32_t CastFreezeScreen(bool isFreeze) override; + + int32_t HdcpEdidResumeHdcp() override; + int32_t HdcpEdidUpdateHdcp(V1_0::HdmiRxHdcpType type) override; + int32_t HdcpEdidInitEdid(const V1_0::HdmiRxEdidData &Data) override; + int32_t HdcpEdidUpdateEdid(const V1_0::HdmiRxEdid &edid) override; + int32_t HdcpEdidSetEdidMode(V1_0::HdmiRxPort port, V1_0::HdmiRxEdidType edidType) override; + + int32_t PanelSetBacklightLevel(const uint32_t level) override; + int32_t PanelSetBoostLevel(V1_0::BoostType boostType, V1_0::CommonLevel level) override; + int32_t PanelSetBacklightMode(V1_0::BacklightMode mode) override; + int32_t PanelSetDynamicBlEnable(bool isEnable) override; + int32_t PanelIsDynamicBlEnable(bool &isEnable) override; + int32_t PanelGetPanelAttr(V1_0::PanelAttr &panelAttr) override; + int32_t PanelGetPowerStatus(bool &enable) override; + int32_t PanelSetBacklightParam(const V1_0::BacklightParam &backlightParam) override; + int32_t PanelSetPanelPower(bool enable) override; + int32_t PanelSetBlGradualChangeMode(uint32_t mode) override; + int32_t PanelNotifySourceFramerate(const V1_0::CustomVideoInfo &info) override; + int32_t PanelGetBinVersionInfo(std::string &version) override; + + int32_t PqGetPqPath(std::string &path) override; + int32_t PqInit(const std::string &path) override; + int32_t PqSetSaturation(uint32_t saturation) override; + int32_t PqSetGamma(V1_0::GammaType gammaType) override; + int32_t PqIsHdrType(V1_0::HdrType hdrType) override; + int32_t PqSetBrightness(uint32_t brightness) override; + int32_t PqSetContrast(uint32_t contrast) override; + int32_t PqSetSharpness(uint32_t sharpness) override; + int32_t PqSetHue(uint32_t hue) override; + int32_t PqSetNr(uint32_t nrLevel) override; + int32_t PqSetDciGainLevel(V1_0::CommonLevel dciGainLevel) override; + int32_t PqGetDciGainLevel(V1_0::CommonLevel &dciGainLevel) override; + int32_t PqSetPqModuleEnable(V1_0::PqModuleType type, bool isEnable) override; + int32_t PqSetColorManageParam(const V1_0::ColorManageParam &colorManageParam) override; + int32_t PqSetDeBlocking(uint32_t nrValue) override; + int32_t PqSetDeMosquito(uint32_t nrValue) override; + int32_t PqSetMemcLevel(V1_0::CommonLevel level) override; + int32_t PqSetDciDbdrDemo(V1_0::DemoMode demoMode, bool isEnable) override; + int32_t PqSetHdrType(V1_0::HdrType type) override; + int32_t PqGetHdrType(V1_0::HdrType &type) override; + int32_t PqSetColorTempParam(const V1_0::ColorTempParam &colorTempParam) override; + int32_t PqSetColorGain(const uint32_t acmIndex) override; + int32_t PqSetGammaTable(const V1_0::GammaTable &gammaTable) override; + int32_t PqGetGammaTable(V1_0::GammaTable &gammaTable) override; + int32_t PqSetHdrCurveIndex(uint32_t hdrCurveIndex) override; + int32_t PqSetDciType(uint32_t typeIndex) override; + int32_t PqSetDciGain(const V1_0::DciGain &dciGain) override; + int32_t PqGetMemcLevel(V1_0::CommonLevel& level) override; + int32_t PqSetPanelColorPoint(const V1_0::PanelColorParam &panelColorParam) override; + + int32_t VideoInputSetHdmiRange(V1_0::HdmiRange hdmiRange) override; + int32_t VideoInputGetOfflineSignalStatus(V1_0::SourceType src, V1_0::InputConnectStatus &status) override; + int32_t VideoInputGetSignalStatus(V1_0::SignalStatus &status) override; + int32_t VideoGetSource(V1_0::SourceType &source) override; + int32_t VideoCreate(V1_0::SourceType source) override; + int32_t VideoStop(const V1_0::VideoParam ¶m) override; + int32_t VideoDestroy() override; + int32_t VideoStart(const V1_0::VideoParam ¶m) override; + int32_t VideoInputGetHdmiRxSignalEvent(std::vector &event) override; + int32_t VideoInputGetVideoInfo(V1_0::VideoInfo &info) override; + int32_t VideoInputFreezeWindow(bool isFreeze) override; + int32_t VideoInputSetSourcePortMap(std::map portMap) override; + int32_t VideoInputGetDisplayCapabilities(uint32_t &minFrameRate, uint32_t &maxFrameRate) override; + int32_t VideoOutputSetVideoOutputRect(const V1_0::VideoRect &rect) override; + int32_t VideoOutputGetVideoOutputRect(V1_0::VideoRect &rect) override; + + int32_t GetColorSys(V1_0::ColorSysType &colorSysType) override; + int32_t SetVideoRatio(const V1_0::VideoRatio &videoRatio) override; + int32_t SetVideoOutputCrop(const V1_0::VideoCrop &videoCrop) override; + int32_t GetAvStreamInfo(V1_0::AvStreamInfo &avStreamInfo) override; + int32_t VideoOperation(V1_0::VideoOperationType videoOperationType) override; + int32_t GetVideoDelay(uint32_t &delayMs) override; + int32_t GetHdmirxProductInfo(V1_0::SourceType source, V1_0::HdmirxProductInfo &info) override; + int32_t SetVrrEnable(bool isEnable) override; + int32_t SetAllmEnable(bool isEnable) override; + int32_t HandleNonStdTiming() override; + int32_t SetColorSys(const V1_0::ColorSysType colorSysType) override; + int32_t GetHdmiRxInfo(V1_0::HdmiRxInfo &hdmiRxInfo)override; + int32_t AdaptViCapLatency()override; + int32_t GetWinAspectMode(V1_0::WinAspectMode &aspectMode)override; + int32_t SetWinAspectMode(const V1_0::WinAspectMode aspectMode)override; + int32_t SetDisplayVrrEnable(bool isEnable)override; + int32_t SetAutoLowLatencyMode(const V1_0::DispAllmMode allMode)override; + int32_t SetMultiWindowStatus(bool isMultiWindow)override; + int32_t SetDispColorSpace(const V1_0::DispColorSpaceType dispColorSpaceType)override; + int32_t SetQuickOutputEnable(bool isEnable)override; + int32_t GetWindowHandle(V1_0::WindowType windowType, uint32_t& handle) override; + + int32_t SetMAC(const std::string &macStr) override; + int32_t GetMAC(std::string &macStr) override; + int32_t SetSN(const std::string &snStr) override; + int32_t GetSN(std::string &snStr) override; + int32_t GetCpuTemperature(int32_t &temp) override; + int32_t GetCpuId(std::string &chipidStr) override; +private: +}; +} // Video +} // Tvservice +} // HDI +} // OHOS +#endif // TVSERVICE_VIDEO_VDI_IMPL_H diff --git a/tvservice/video/interfaces/vdi_base/src/tvservice_deviceinfo.c b/tvservice/video/interfaces/vdi_base/src/tvservice_deviceinfo.c new file mode 100644 index 0000000000000000000000000000000000000000..a93d248316f39c2ab5e03b9341fa057d2b9852e5 --- /dev/null +++ b/tvservice/video/interfaces/vdi_base/src/tvservice_deviceinfo.c @@ -0,0 +1,60 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "securec.h" + +#include "tvservice_deviceinfo.h" + +void *mLibHandle = NULL; +GKMpiApi *g_gkApi = NULL; + +#if defined(__arm64__) || defined(__aarch64__) +char *mLibName = "/vendor/lib64/libmp_deviceinfo.z.so"; +#else +char *mLibName = "/vendor/lib/libmp_deviceinfo.z.so"; +#endif + +int32_t GetGkApi(GKMpiApi **gkApi) +{ + *gkApi = (GKMpiApi *)malloc(sizeof(GKMpiApi)); + if (*gkApi == NULL) { + printf("%s: malloc failed!", __func__); + return -1; + } + + GKMpiApi *pGkApi = *gkApi; + memset(pGkApi, 0, sizeof(GKMpiApi)); + + mLibHandle = dlopen(mLibName, RTLD_NOW); + if (mLibHandle == NULL) { + printf("%s: lib %s dlopen failed, error code[%s]", __func__, mLibName, dlerror()); + free(*gkApi); + *gkApi = NULL; + return -1; + } + + pGkApi->MPGetCpuTemperature = (mPGetCpuTemperature)dlsym(mLibHandle, "MPGetCpuTemperature"); + pGkApi->MPGetCpuId = (mPGetCpuId)dlsym(mLibHandle, "MPGetCpuId"); + pGkApi->MPGetMAC = (mPGetMAC)dlsym(mLibHandle, "MPGetMAC"); + pGkApi->MPSetMAC = (mPSetMAC)dlsym(mLibHandle, "MPSetMAC"); + pGkApi->MPGetSN = (mPGetSN)dlsym(mLibHandle, "MPGetSN"); + pGkApi->MPSetSN = (mPSetSN)dlsym(mLibHandle, "MPSetSN"); + + printf("get api ok"); + + return 0; +} + +void ReleaseGkApi(GKMpiApi *gkApi) +{ + if (gkApi != NULL) { + memset(gkApi, 0, sizeof(GKMpiApi)); + free(gkApi); + } +} diff --git a/tvservice/video/interfaces/vdi_base/src/tvservice_video_vdi_impl.cpp b/tvservice/video/interfaces/vdi_base/src/tvservice_video_vdi_impl.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f3070882da987a34653405b304816cf60a10639d --- /dev/null +++ b/tvservice/video/interfaces/vdi_base/src/tvservice_video_vdi_impl.cpp @@ -0,0 +1,821 @@ +/* + * Copyright (c) 2025 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 "tvservice_video_vdi_impl.h" +#include +#include "tvservice_video_hdf_log.h" +#include "hdf_log.h" + +#include +#include +#include +#include "securec.h" + +using namespace std; + +namespace OHOS { +namespace HDI { +namespace Tvservice { +namespace Video { + +TvserviceVideoVdiImpl::TvserviceVideoVdiImpl() {} + +TvserviceVideoVdiImpl::~TvserviceVideoVdiImpl() {} + +int32_t TvserviceVideoVdiImpl::Connect() +{ + TVSERVICE_LOGI("enter %s start", __func__); + + TVSERVICE_LOGI("enter %s end", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::Disconnect() +{ + TVSERVICE_LOGI("enter %s start", __func__); + + TVSERVICE_LOGI("enter %s end", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::CastInit(const V1_0::CastVencChnAttr &chnAttr, V1_0::CastMode castMode) +{ + HDF_LOGE("%s not impl", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::CastDeInit() +{ + HDF_LOGE("%s not impl", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::CastClose(bool isBackground) +{ + HDF_LOGE("%s not impl", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::CastRequestIDRFrame() +{ + HDF_LOGE("%s not impl", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::CastSetAttr(const V1_0::CastVencChnAttr &chnAttr, V1_0::CastType castType) +{ + HDF_LOGE("%s not impl", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::CastGetAttr(V1_0::CastVencChnAttr &chnAttr) +{ + HDF_LOGE("%s not impl", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::CastPause() +{ + HDF_LOGE("%s not impl", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::CastResume() +{ + HDF_LOGE("%s not impl", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::CastCreateVideo(V1_0::SourceType source, bool needOpenDevice) +{ + HDF_LOGE("%s not impl", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::CastDestroyVideo(bool needCloseDevice) +{ + HDF_LOGE("%s not impl", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::CastStartVideo() +{ + HDF_LOGE("%s not impl", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::CastStopVideo() +{ + HDF_LOGE("%s not impl", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::CastGetVideoSignal(V1_0::SignalStatus &status) +{ + HDF_LOGE("%s not impl", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::CastGetVideoInfo(V1_0::VideoInfo &videoInfo) +{ + HDF_LOGE("%s not impl", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::CastAcquireInputFrame(bool frameRateCtrl, uint32_t &handle) +{ + HDF_LOGE("%s not impl", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::CastReleaseInputFrame(uint32_t handle) +{ + HDF_LOGE("%s not impl", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::CastProcessFrame(uint32_t inputHandle, uint32_t &decoderHandle) +{ + HDF_LOGE("%s not impl", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::CastQueueFrameToDecoder(uint32_t handle) +{ + HDF_LOGE("%s not impl", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::CastDequeueFrameFromDecoder(uint32_t &handle) +{ + HDF_LOGE("%s not impl", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::CastReleaseFrameBuffQueue() +{ + HDF_LOGE("%s not impl", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::CastObtainManually(V1_0::CastMode mode) +{ + HDF_LOGE("%s not impl", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::CastFreezeScreen(bool isFreeze) +{ + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::PqSetColorManageParam(const V1_0::ColorManageParam &colorManageParam) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::HdcpEdidResumeHdcp() +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::HdcpEdidUpdateHdcp(V1_0::HdmiRxHdcpType type) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::HdcpEdidInitEdid(const V1_0::HdmiRxEdidData &Data) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::HdcpEdidUpdateEdid(const V1_0::HdmiRxEdid &edid) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::HdcpEdidSetEdidMode(V1_0::HdmiRxPort port, V1_0::HdmiRxEdidType edidType) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::PanelSetBacklightLevel(const uint32_t level) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::PanelSetBoostLevel(V1_0::BoostType boostType, V1_0::CommonLevel level) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::PanelSetBacklightMode(V1_0::BacklightMode mode) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::PanelSetDynamicBlEnable(bool isEnable) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::PanelIsDynamicBlEnable(bool &isEnable) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::PanelGetPanelAttr(V1_0::PanelAttr &panelAttr) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::PanelGetPowerStatus(bool &enable) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::PanelSetBacklightParam(const V1_0::BacklightParam &backlightParam) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::PanelSetPanelPower(bool enable) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::PanelSetBlGradualChangeMode(uint32_t mode) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::PanelNotifySourceFramerate(const V1_0::CustomVideoInfo &info) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::PanelGetBinVersionInfo(std::string &version) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::PqGetPqPath(std::string &path) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::PqInit(const std::string &path) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::PqSetSaturation(uint32_t saturation) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::PqSetGamma(V1_0::GammaType gammaType) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::PqIsHdrType(V1_0::HdrType hdrType) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::PqSetBrightness(uint32_t brightness) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::PqSetContrast(uint32_t contrast) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::PqSetSharpness(uint32_t sharpness) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::PqSetHue(uint32_t hue) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::PqSetNr(uint32_t nrLevel) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::PqSetDciGainLevel(V1_0::CommonLevel dciGainLevel) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::PqGetDciGainLevel(V1_0::CommonLevel &dciGainLevel) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::PqSetPqModuleEnable(V1_0::PqModuleType type, bool isEnable) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::PqSetDeBlocking(uint32_t nrValue) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::PqSetDeMosquito(uint32_t nrValue) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::PqSetMemcLevel(V1_0::CommonLevel level) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::PqSetDciDbdrDemo(V1_0::DemoMode demoMode, bool isEnable) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::PqSetHdrType(V1_0::HdrType type) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::PqGetHdrType(V1_0::HdrType &type) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::PqSetColorTempParam(const V1_0::ColorTempParam &colorTempParam) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::PqSetColorGain(const uint32_t acmIndex) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::PqSetGammaTable(const V1_0::GammaTable &gammaTable) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::PqGetGammaTable(V1_0::GammaTable &gammaTable) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::PqSetHdrCurveIndex(uint32_t hdrCurveIndex) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::PqSetDciType(uint32_t typeIndex) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::PqSetDciGain(const V1_0::DciGain &dciGain) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::PqGetMemcLevel(V1_0::CommonLevel& level) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::PqSetPanelColorPoint(const V1_0::PanelColorParam &panelColorParam) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::VideoInputSetHdmiRange(V1_0::HdmiRange hdmiRange) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::VideoInputGetOfflineSignalStatus(V1_0::SourceType src, V1_0::InputConnectStatus &status) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::VideoInputGetSignalStatus(V1_0::SignalStatus &status) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::VideoGetSource(V1_0::SourceType &source) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::VideoCreate(V1_0::SourceType source) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::VideoStop(const V1_0::VideoParam ¶m) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::VideoDestroy() +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::VideoStart(const V1_0::VideoParam ¶m) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::VideoInputGetHdmiRxSignalEvent(std::vector &event) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::VideoInputGetVideoInfo(V1_0::VideoInfo &info) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::VideoInputFreezeWindow(bool isFreeze) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::VideoInputSetSourcePortMap(std::map portMap) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::VideoInputGetDisplayCapabilities(uint32_t &minFrameRate, uint32_t &maxFrameRate) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::VideoOutputSetVideoOutputRect(const V1_0::VideoRect &rect) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::VideoOutputGetVideoOutputRect(V1_0::VideoRect &rect) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::GetColorSys(V1_0::ColorSysType &colorSysType) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::SetVideoRatio(const V1_0::VideoRatio &videoRatio) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::SetVideoOutputCrop(const V1_0::VideoCrop &videoCrop) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::GetAvStreamInfo(V1_0::AvStreamInfo &avStreamInfo) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::VideoOperation(V1_0::VideoOperationType videoOperationType) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::GetVideoDelay(uint32_t &delayMs) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::GetHdmirxProductInfo(V1_0::SourceType source, V1_0::HdmirxProductInfo &info) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::SetVrrEnable(bool isEnable) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::SetAllmEnable(bool isEnable) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::HandleNonStdTiming() +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::SetColorSys(const V1_0::ColorSysType colorSysType) +{ + HDF_LOGE("%s colorSysType:%d in ", __func__,colorSysType); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::GetHdmiRxInfo(V1_0::HdmiRxInfo &hdmiRxInfo) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::AdaptViCapLatency() +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::GetWinAspectMode(V1_0::WinAspectMode &aspectMode) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::SetWinAspectMode(const V1_0::WinAspectMode aspectMode) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::SetDisplayVrrEnable(bool isEnable) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::SetAutoLowLatencyMode(const V1_0::DispAllmMode allMode) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::SetMultiWindowStatus(bool isMultiWindow) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::SetDispColorSpace(const V1_0::DispColorSpaceType dispColorSpaceType) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::SetQuickOutputEnable(bool isEnable) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::GetWindowHandle(V1_0::WindowType windowType, uint32_t& handle) +{ + HDF_LOGE("%s in", __func__); + return HDF_SUCCESS; +} + +int32_t TvserviceVideoVdiImpl::SetMAC(const std::string &macStr) +{ + HDF_LOGE("%s in", __func__); + + if (g_gkApi == nullptr || g_gkApi->MPSetMAC == nullptr) { + HDF_LOGE("g_gkApi or MPSetMAC is null"); + return HDF_ERR_INVALID_OBJECT; + } + + if (macStr.empty() || macStr.length() >= 64) { + HDF_LOGE("Invalid MAC address length"); + return HDF_ERR_INVALID_PARAM; + } + + int ret = g_gkApi->MPSetMAC(const_cast(macStr.c_str()), macStr.length()); + if (ret == 0) { + HDF_LOGI("MAC set successfully: %s", macStr.c_str()); + return HDF_SUCCESS; + } else { + HDF_LOGE("Failed to set MAC"); + return HDF_FAILURE; + } +} + +int32_t TvserviceVideoVdiImpl::GetMAC(std::string &macStr) +{ + HDF_LOGE("%s in", __func__); + + if (g_gkApi == nullptr || g_gkApi->MPGetMAC == nullptr) { + HDF_LOGE("g_gkApi or MPGetMAC is null"); + return HDF_ERR_INVALID_OBJECT; + } + + char chipmac_str[64] = {0}; + int ret = g_gkApi->MPGetMAC(chipmac_str, sizeof(chipmac_str)); + if (ret == 0) { + macStr = chipmac_str; + HDF_LOGI("MAC retrieved: %s", macStr.c_str()); + return HDF_SUCCESS; + } else { + HDF_LOGE("Failed to get MAC"); + return HDF_FAILURE; + } +} + +int32_t TvserviceVideoVdiImpl::SetSN(const std::string &snStr) +{ + HDF_LOGE("%s in", __func__); + + if (g_gkApi == nullptr || g_gkApi->MPSetSN == nullptr) { + HDF_LOGE("g_gkApi or MPSetSN is null"); + return HDF_ERR_INVALID_OBJECT; + } + + if (snStr.empty() || snStr.length() >= 64) { + HDF_LOGE("Invalid SN length"); + return HDF_ERR_INVALID_PARAM; + } + + int ret = g_gkApi->MPSetSN(const_cast(snStr.c_str()), snStr.length()); + if (ret == 0) { + HDF_LOGI("SN set successfully: %s", snStr.c_str()); + return HDF_SUCCESS; + } else { + HDF_LOGE("Failed to set SN"); + return HDF_FAILURE; + } +} + +int32_t TvserviceVideoVdiImpl::GetSN(std::string &snStr) +{ + HDF_LOGE("%s in", __func__); + + if (g_gkApi == nullptr || g_gkApi->MPGetSN == nullptr) { + HDF_LOGE("g_gkApi or MPGetSN is null"); + return HDF_ERR_INVALID_OBJECT; + } + + char chipsn_str[64] = {0}; + int ret = g_gkApi->MPGetSN(chipsn_str, sizeof(chipsn_str)); + if (ret == 0) { + snStr = chipsn_str; + HDF_LOGI("SN retrieved: %s", snStr.c_str()); + return HDF_SUCCESS; + } else { + HDF_LOGE("Failed to get SN"); + return HDF_FAILURE; + } +} + +int32_t TvserviceVideoVdiImpl::GetCpuTemperature(int32_t &temp) +{ + HDF_LOGE("%s in", __func__); + + if (g_gkApi == nullptr || g_gkApi->MPGetCpuTemperature == nullptr) { + HDF_LOGE("g_gkApi or MPGetCpuTemperature is null"); + return HDF_ERR_INVALID_OBJECT; + } + + int ret = g_gkApi->MPGetCpuTemperature(&temp); + if (ret == 0) { + HDF_LOGI("CPU Temperature: %d", temp); + return HDF_SUCCESS; + } else { + HDF_LOGE("Failed to get CPU temperature"); + return HDF_FAILURE; + } +} + +int32_t TvserviceVideoVdiImpl::GetCpuId(std::string &chipidStr) +{ + HDF_LOGE("%s in", __func__); + + if (g_gkApi == nullptr || g_gkApi->MPGetCpuId == nullptr) { + HDF_LOGE("g_gkApi or MPGetCpuId is null"); + return HDF_ERR_INVALID_OBJECT; + } + + char chipid_str[17] = {0}; + int ret = g_gkApi->MPGetCpuId(chipid_str, sizeof(chipid_str)); + if (ret == 0) { + chipidStr = chipid_str; + HDF_LOGI("Chip ID: %s", chipidStr.c_str()); + return HDF_SUCCESS; + } else { + HDF_LOGE("Failed to get Chip ID"); + return HDF_FAILURE; + } +} + +extern "C" V1_0::TvserviceVideoVdi *CreateVideoVdi() +{ + GetGkApi(&g_gkApi); + return new TvserviceVideoVdiImpl(); +} + +extern "C" void DestroyVideoVdi(V1_0::TvserviceVideoVdi *vdi) +{ + ReleaseGkApi(g_gkApi); + delete vdi; +} + +} // Video +} // Tvservice +} // HDI +} // OHOS diff --git a/tvservice/video/utils/include/tvservice_video_hdf_log.h b/tvservice/video/utils/include/tvservice_video_hdf_log.h new file mode 100644 index 0000000000000000000000000000000000000000..62ece8f1ea9520c99aa96c960dbcdcc783b99222 --- /dev/null +++ b/tvservice/video/utils/include/tvservice_video_hdf_log.h @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2025 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. + */ + +#ifndef TVSERVICE_LOG_H +#define TVSERVICE_LOG_H +#include +#include +#include "hilog/log.h" + +#ifdef HDF_LOG_TAG +#undef HDF_LOG_TAG +#endif + +#if defined(__cplusplus) +extern "C" { +#endif + +#undef LOG_TAG +#define LOG_TAG "TVS-V" +#undef LOG_DOMAIN +#define LOG_DOMAIN 0xD002515 + +#ifndef TVSERVICE_UNUSED +#define TVSERVICE_UNUSED(x) (void)(x) +#endif + +#ifndef TVSERVICE_DEBUG_ENABLE +#define TVSERVICE_DEBUG_ENABLE 1 +#endif + +#ifndef TVSERVICE_LOGD +#define TVSERVICE_LOGD(format, ...) \ + do { \ + if (TVSERVICE_DEBUG_ENABLE) { \ + HILOG_DEBUG(LOG_CORE, "[%{public}s:%{public}d] " format "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__); \ + } \ + } while (0) +#endif + +#ifndef TVSERVICE_LOGI +#define TVSERVICE_LOGI(format, ...) \ + do { \ + HILOG_INFO(LOG_CORE, "[%{public}s:%{public}d] " format "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__); \ + } while (0) +#endif + +#ifndef TVSERVICE_LOGW +#define TVSERVICE_LOGW(format, ...) \ + do { \ + HILOG_WARN(LOG_CORE, "[%{public}s:%{public}d] " format "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__); \ + } while (0) +#endif + +#ifndef TVSERVICE_LOGE +#define TVSERVICE_LOGE(format, ...) \ + do { \ + HILOG_ERROR(LOG_CORE, \ + "\033[0;32;31m" \ + "[%{public}s:%{public}d] " format "\033[m" \ + "\n", \ + __FUNCTION__, __LINE__, ##__VA_ARGS__); \ + } while (0) +#endif + +#ifndef CHECK_NULLPOINTER_RETURN_VALUE +#define CHECK_NULLPOINTER_RETURN_VALUE(pointer, ret) \ + do { \ + if ((pointer) == NULL) { \ + TVSERVICE_LOGE("pointer is null and return ret\n"); \ + return (ret); \ + } \ + } while (0) +#endif + +#ifndef CHECK_NULLPOINTER_RETURN +#define CHECK_NULLPOINTER_RETURN(pointer) \ + do { \ + if ((pointer) == NULL) { \ + TVSERVICE_LOGE("pointer is null and return\n"); \ + return; \ + } \ + } while (0) +#endif + +#ifndef TVSERVICE_CHK_RETURN +#define TVSERVICE_CHK_RETURN(val, ret, ...) \ + do { \ + if (val) { \ + __VA_ARGS__; \ + return (ret); \ + } \ + } while (0) +#endif + +#ifndef TVSERVICE_CHK_RETURN_NOT_VALUE +#define TVSERVICE_CHK_RETURN_NOT_VALUE(val, ...) \ + do { \ + if (val) { \ + __VA_ARGS__; \ + return; \ + } \ + } while (0) +#endif + +#ifdef __cplusplus +} +#endif + +#endif // TVSERVICE_LOG_H \ No newline at end of file diff --git a/usb/ddk/host/src/usb_pnp_manager.c b/usb/ddk/host/src/usb_pnp_manager.c index 7b8a240c1e27b0c299bef3fc239f2eecfb57569d..80cb2656674df7aa4d421fc2cc60f87e5ffc4b06 100644 --- a/usb/ddk/host/src/usb_pnp_manager.c +++ b/usb/ddk/host/src/usb_pnp_manager.c @@ -167,15 +167,15 @@ static int32_t UsbPnpManagerInit(struct HdfDeviceObject *device) }; usbPnpListener.priv = (void *)(device); - int32_t ret = DdkDevMgrInit(UsbPnpMgrGetGadgetPath(device, "gadget_state_path")); + int32_t ret = DdkListenerMgrInit(); if (ret != HDF_SUCCESS) { - HDF_LOGE("%{public}s: DdkDevMgrInit error", __func__); + HDF_LOGE("%{public}s: DdkListenerMgrInit error", __func__); return HDF_FAILURE; } - ret = DdkListenerMgrInit(); + ret = DdkDevMgrInit(UsbPnpMgrGetGadgetPath(device, "gadget_state_path")); if (ret != HDF_SUCCESS) { - HDF_LOGE("%{public}s: DdkListenerMgrInit error", __func__); + HDF_LOGE("%{public}s: DdkDevMgrInit error", __func__); return HDF_FAILURE; }