[HALACR-50] Add HAL interface for HDCP 55/324955/6 accepted/tizen_unified accepted/tizen_unified_x tizen accepted/tizen/unified/20250610.081744 accepted/tizen/unified/x/20250610.082512
authorHaesu Gwon <haesu.gwon@samsung.com>
Thu, 29 May 2025 08:16:13 +0000 (17:16 +0900)
committerHaesu Gwon <haesu.gwon@samsung.com>
Wed, 4 Jun 2025 03:00:13 +0000 (12:00 +0900)
- Add "doc" directory for documentation.
- Add new HDCP HAL interface.

[Version] 1.0.0
[Issue Type] New feature

Change-Id: Iada815ba26854b03d25eddea89912958f4406c5b

15 files changed:
CMakeLists.txt [new file with mode: 0644]
LICENSE [new file with mode: 0644]
doc/hal_hdcp_doc.h [new file with mode: 0644]
doc/images/hal_drm_state_diagram.png [new file with mode: 0644]
hal-api-hdcp-haltests.manifest [new file with mode: 0644]
hal-api-hdcp.manifest [new file with mode: 0644]
hal-api-hdcp.pc.in [new file with mode: 0644]
include/hal-hdcp-interface-1.h [new file with mode: 0644]
include/hal-hdcp-interface.h [new file with mode: 0644]
include/hal-hdcp.h [new file with mode: 0644]
packaging/hal-api-hdcp-manifest.xml [new file with mode: 0644]
packaging/hal-api-hdcp.spec [new file with mode: 0644]
src/hal-api-hdcp.c [new file with mode: 0644]
tests/CMakeLists.txt [new file with mode: 0644]
tests/hdcp_hal_test.cpp [new file with mode: 0644]

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..5e5937a
--- /dev/null
@@ -0,0 +1,51 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)
+PROJECT(hal-api-hdcp)
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(EXEC_PREFIX "${CMAKE_INSTALL_PREFIX}/bin")
+SET(INCLUDEDIR "${CMAKE_INSTALL_PREFIX}/include")
+SET(LIBDIR ${CMAKE_LIBDIR_PREFIX})
+SET(VERSION_MAJOR 0)
+SET(VERSION "${VERSION_MAJOR}.1.0")
+
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+
+SET(PKG_MODULES
+    dlog
+    glib-2.0
+    hal-api-common
+)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED ${PKG_MODULES})
+
+FOREACH(flag ${pkgs_CFLAGS})
+    SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g -fno-omit-frame-pointer -finstrument-functions")
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIC -Wall -Wextra -Wno-array-bounds -Wno-empty-body -Wno-ignored-qualifiers -Wno-unused-parameter -Wshadow -Wwrite-strings -Wswitch-default -Wno-unused-but-set-parameter -Wno-unused-but-set-variable")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -lrt")
+
+SET(SRCS src/hal-api-hdcp.c)
+
+ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})
+
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} -Wl,--as-needed -Wl,--rpath=${LIBDIR}/hal)
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${VERSION_MAJOR})
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${VERSION})
+
+CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY)
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIBDIR}/hal)
+
+INSTALL(DIRECTORY include/ DESTINATION include/hal
+        FILES_MATCHING
+        PATTERN "*_private.h" EXCLUDE
+        PATTERN "include/*.h")
+
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIBDIR}/pkgconfig)
+
+ADD_SUBDIRECTORY(tests)
diff --git a/LICENSE b/LICENSE
new file mode 100644 (file)
index 0000000..36123b0
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,203 @@
+Copyright (c) 2000 - 2025 Samsung Electronics Co., Ltd. All rights reserved.
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   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.
diff --git a/doc/hal_hdcp_doc.h b/doc/hal_hdcp_doc.h
new file mode 100644 (file)
index 0000000..af50bd2
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2025 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 __TIZEN_HAL_HDCP_DOC_H__
+#define __TIZEN_HAL_HDCP_DOC_H__
+
+
+/**
+ * @file hal_hdcp_doc.h
+ * @brief This file contains high level documentation of the HAL HDCP.
+ */
+
+/**
+ * @defgroup HALAPI_HAL_HDCP_MODULE HDCP
+ * @brief The @ref HALAPI_HAL_HDCP_MODULE provides functions for hdcp devices.
+ *
+ * @section HALAPI_HAL_HDCP_MODULE_HEADER Required Header
+ *   \#include <hal-hdcp.h>
+ *
+ * @section HALAPI_HAL_HDCP_MODULE_OVERVIEW Overview
+ * The hdcp devices have various specifications, so it's hard to control them using single code.
+ * The hdcp HAL provides common abstraction interfaces to control hdcp devices which are different.
+ *
+ * The HDCP HAL allows creation of components required in secure playback including:
+ * - managing hdcp sessions.
+ * - decrypt hdcp content.
+ * - encrypt content.
+ *
+ * @subsection HALAPI_HAL_HDCP_MODULE_STATE_DIAGRAM State Diagram
+ * @image html hal_hdcp_state_diagram.png
+ *
+ * @subsection HALAPI_HAL_HDCP_MODULE_STATE_TRANSITIONS State Transitions
+ * <div><table class="doxtable" >
+ * <tr>
+ *    <th><b>FUNCTION</b></th>
+ *    <th><b>PRE-STATE</b></th>
+ *    <th><b>POST-STATE</b></th>
+ *    <th><b>SYNC TYPE</b></th>
+ * </tr>
+ * <tr>
+ *    <td> hal_hdcp_init() </td>
+ *    <td> NONE </td>
+ *    <td> INITIALIZED </td>
+ *    <td> SYNC </td>
+ * </tr>
+ * <tr>
+ *    <td> hal_hdcp_deinit() </td>
+ *    <td> INITIALIZED </td>
+ *    <td> NONE </td>
+ *    <td> SYNC </td>
+ * </tr>
+ * <tr>
+ *    <td> hal_hdcp_open() </td>
+ *    <td> INITIALIZED </td>
+ *    <td> OPENED </td>
+ *    <td> SYNC </td>
+ * </tr>
+ * <tr>
+ *    <td> hal_hdcp_close() </td>
+ *    <td> OPENED </td>
+ *    <td> INITIALIZED </td>
+ *    <td> SYNC </td>
+ * </tr>
+ * </table></div>
+ *
+ * For more information on the HDCP features and the macros, see HAL HDCP programming guides and tutorials.
+ */
+
+#endif /* __TIZEN_HAL_HDCP_DOC_H__ */
diff --git a/doc/images/hal_drm_state_diagram.png b/doc/images/hal_drm_state_diagram.png
new file mode 100644 (file)
index 0000000..cc8647f
Binary files /dev/null and b/doc/images/hal_drm_state_diagram.png differ
diff --git a/hal-api-hdcp-haltests.manifest b/hal-api-hdcp-haltests.manifest
new file mode 100644 (file)
index 0000000..41a9320
--- /dev/null
@@ -0,0 +1,6 @@
+<manifest>
+    <request>
+        <domain name="_"/>
+    </request>
+</manifest>
+
diff --git a/hal-api-hdcp.manifest b/hal-api-hdcp.manifest
new file mode 100644 (file)
index 0000000..41a9320
--- /dev/null
@@ -0,0 +1,6 @@
+<manifest>
+    <request>
+        <domain name="_"/>
+    </request>
+</manifest>
+
diff --git a/hal-api-hdcp.pc.in b/hal-api-hdcp.pc.in
new file mode 100644 (file)
index 0000000..484072c
--- /dev/null
@@ -0,0 +1,13 @@
+# Package Information for pkg-config
+prefix=@PREFIX@
+exec_prefix=@EXEC_PREFIX@/hal
+libdir=@LIBDIR@/hal
+includedir=@INCLUDEDIR@/hal
+
+Name: @PROJECT_NAME@
+Description: @PROJECT_NAME@ interface
+Version: @VERSION@
+Requires:
+Libs: -L${libdir} -l@PROJECT_NAME@
+Cflags: -I${includedir}
+CXXflags: -I${includedir}
diff --git a/include/hal-hdcp-interface-1.h b/include/hal-hdcp-interface-1.h
new file mode 100644 (file)
index 0000000..1bc1d80
--- /dev/null
@@ -0,0 +1,202 @@
+/*
+ * HAL (Hardware Abstract Layer) interface API for HDCP
+ *
+ * Copyright (c) 2025 Samsung Electronics 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 __HAL_HDCP_INTERFACE_1__
+#define __HAL_HDCP_INTERFACE_1__
+
+#include <stdbool.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file hal-hdcp-interface-1.h
+ * @brief This file contains the Tizen HDCP HAL interface API, related structures and enumerations.
+ * @since HAL_MODULE_HDCP 1.0
+ */
+
+/**
+ * @addtogroup HALAPI_HAL_HDCP_MODULE
+ * @{
+ */
+
+/**
+ * @brief Enumeration for the HDCP error.
+ * @since HAL_MODULE_HDCP 1.0
+ */
+typedef enum hal_hdcp_error {
+    HAL_HDCP_ERROR_NONE                 = 0,                    /**< Error none */
+    HAL_HDCP_ERROR_NOT_SUPPORTED        = (int32_t)0x80004001,  /**< Not supported */
+    HAL_HDCP_ERROR_INVALID_PARAMETER    = (int32_t)0x80004002,  /**< Invalid parameter */
+    HAL_HDCP_ERROR_INVALID_STATE        = (int32_t)0x80004003,  /**< Invalid state */
+    HAL_HDCP_ERROR_OUT_OF_MEMORY        = (int32_t)0x80004004,  /**< Out of memory */
+
+    HAL_HDCP_ERROR_INTERNAL             = (int32_t)0x80004ffd,  /**< Internal */
+    HAL_HDCP_ERROR_NOT_IMPLEMENTED      = (int32_t)0x80004ffe,  /**< Not implemented */
+    HAL_HDCP_ERROR_UNKNOWN              = (int32_t)0x80004fff   /**< Unknown */
+} hal_hdcp_error_e;
+
+/**
+ * @brief Enumeration for the HDCP state.
+ * @since HAL_MODULE_HDCP 1.0
+ */
+typedef enum hal_hdcp_state {
+    HAL_HDCP_STATE_NONE,         /**< None state */
+    HAL_HDCP_STATE_INITIALIZED,  /**< Initialized state for HDCP device */
+    HAL_HDCP_STATE_OPENED,       /**< Opened state for HDCP device */
+} hal_hdcp_state_e;
+
+/**
+ * @brief The structure type of HDCP buffer.
+ * @since HAL_MODULE_HDCP 1.0
+ */
+typedef struct {
+    bool is_secure;       /**< The flag which indicates the real data is managed in secure world or not */
+
+    uint32_t size;        /**< The size of data buffer */
+    unsigned char *data;  /**< The pointer of data buffer */
+    int fd;               /**< The fd(file descriptor) of data buffer */
+} hal_hdcp_buffer_s;
+
+/**
+ * @brief Enumeration for the HDCP command.
+ * @since HAL_MODULE_HDCP 1.0
+ */
+typedef enum hal_hdcp_command {
+    HAL_HDCP_COMMAND_BASE    = (uint64_t)0x0000000000000001,  /**< Base of command */
+    HAL_HDCP_COMMAND_CUSTOM  = (uint64_t)0xf000000000000000   /**< Custom */
+} hal_hdcp_command_e;
+
+/**
+ * @brief The structure type of the HDCP HAL custom command.
+ * @since HAL_MODULE_HDCP 1.0
+ */
+typedef struct {
+       const char *name;  /**< The name of custom command */
+       void *value;       /**< The value of custom command */
+} hal_hdcp_custom_command_s;
+
+/**
+ * @brief The structure type of batch command.
+ * @since HAL_MODULE_HDCP 1.0
+ */
+typedef struct hal_hdcp_batch_command_control {
+    uint64_t command_set_flag;         /**< flag for updating commands */
+
+    hal_hdcp_custom_command_s custom;  /**< The value for custom command */
+} hal_hdcp_batch_command_control_s;
+
+/**
+ * @brief Enumeration for the HDCP message type.
+ * @since HAL_MODULE_HDCP 1.0
+ */
+typedef enum hal_hdcp_message_type {
+       HAL_HDCP_MESSAGE_TYPE_ERROR,  /**< The error */
+} hal_hdcp_message_type_e;
+
+/**
+ * @brief The structure type of the HDCP message.
+ * @since HAL_MODULE_HDCP 1.0
+ */
+typedef struct hal_hdcp_message {
+    hal_hdcp_message_type_e type;     /**< The type of message */
+    union {
+        hal_hdcp_error_e error_code;  /**< The error code */
+    };
+} hal_hdcp_message_s;
+
+/**
+ * @brief Callback function for notification from HDCP HAL.
+ * @since HAL_MODULE_HDCP 1.0
+ * @param[in] message The message from HDCP HAL
+ * @param[in] user_data The user data for callback
+ * @see hal_hdcp_add_message_callback()
+ * @see hal_hdcp_remove_message_callback()
+ */
+typedef hal_hdcp_error_e (*hal_hdcp_message_cb)(hal_hdcp_message_s *message, void *user_data);
+
+/* HDCP */
+
+/**
+ * @brief HDCP device type
+ * @since HAL_MODULE_HDCP 1.0
+ */
+typedef enum
+{
+    HAL_HDCP_DEVICE_RECEIVER,           /**< Receiver */
+    HAL_HDCP_DEVICE_TRANSMIT,           /**< Transmitter */
+    HAL_HDCP_DEVICE_TRANSMIT_MULTISINK, /**< Transmitter with multi sink */
+ } hal_hdcp_device_type_e;
+
+/**
+ * @brief HDCP protocol version
+ * @since HAL_MODULE_HDCP 1.0
+ */
+typedef enum
+{
+    HAL_HDCP_VERSION_2_0 = 20,  /**< HDCP version 2.0 */
+    HAL_HDCP_VERSION_2_1 = 21,  /**< HDCP version 2.1 */
+    HAL_HDCP_VERSION_2_2 = 22,  /**< HDCP version 2.2 */
+} hal_hdcp_protocol_version_e;
+
+/**
+ * @brief The structure type of the HDCP HAL functions.
+ * @since HAL_MODULE_HDCP 1.0
+ */
+typedef struct _hal_backend_hdcp_funcs {
+    /** Initializes HDCP HAL backend handle */
+    int (*init)(void **hdcp_handle);
+    /** Deinitializes HDCP HAL backend handle */
+    int (*deinit)(void *hdcp_handle);
+    /** Opens HDCP */
+    int (*hdcp_open)(void *hdcp_handle, hal_hdcp_device_type_e type, hal_hdcp_protocol_version_e version);
+    /** Closes HDCP */
+    int (*hdcp_close)(void *hdcp_handle);
+    /** Starts HDCP receiver */
+    int (*hdcp_start_receiver)(void *hdcp_handle, uint32_t socket_port, uint32_t *hdcp_id);
+    /** Stops HDCP receiver */
+    int (*hdcp_stop_receiver)(void *hdcp_handle, uint32_t hdcp_id);
+    /** Starts HDCP transmitter */
+    int (*hdcp_start_transmitter)(void *hdcp_handle, const char *socket_ip, uint32_t socket_port, uint32_t *hdcp_id);
+    /** Stops HDCP transmitter */
+    int (*hdcp_stop_transmitter)(void *hdcp_handle, uint32_t hdcp_id);
+    /** Allocates hdcp output buffer */
+    int (*hdcp_allocate_output_buffer)(void *hdcp_handle, uint32_t size, bool is_secure, hal_hdcp_buffer_s *buffer);
+    /** Releases hdcp output buffer */
+    int (*hdcp_release_output_buffer)(void *hdcp_handle, hal_hdcp_buffer_s *buffer);
+    /** Decrypts HDCP data */
+    int (*hdcp_decrypt)(void *hdcp_handle, hal_hdcp_buffer_s *input, void *decrypt_info, hal_hdcp_buffer_s *output);
+    /** Encrypts HDCP data */
+    int (*hdcp_encrypt)(void *hdcp_handle, hal_hdcp_buffer_s *input, uint32_t hdcp_id, void *encrypt_info, hal_hdcp_buffer_s *output);
+    /** Sets the various command and value */
+    int (*set_command)(void *hdcp_handle, hal_hdcp_command_e command, void *value);
+    /** Gets the current value of command */
+    int (*get_command)(void *hdcp_handle, hal_hdcp_command_e command, void **value);
+    /** Sets a set of commands */
+    int (*set_batch_command)(void *hdcp_handle, hal_hdcp_batch_command_control_s *batch_command, hal_hdcp_command_e *error_command);
+} hal_backend_hdcp_funcs;
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __HAL_HDCP_INTERFACE_1__ */
diff --git a/include/hal-hdcp-interface.h b/include/hal-hdcp-interface.h
new file mode 100644 (file)
index 0000000..8f7e1d1
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * HAL (Hardware Abstract Layer) interface API for HDCP
+ *
+ * Copyright (c) 2025 Samsung Electronics 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 __HAL_HDCP_INTERFACE__
+#define __HAL_HDCP_INTERFACE__
+
+#include <hal-hdcp-interface-1.h>
+
+#endif /* __HAL_HDCP_INTERFACE__ */
diff --git a/include/hal-hdcp.h b/include/hal-hdcp.h
new file mode 100644 (file)
index 0000000..5a6fc77
--- /dev/null
@@ -0,0 +1,300 @@
+/*
+ * HAL(Hardware Abstract Layer) API for HDCP(High-bandwidth Digital Content Protection)
+ *
+ * Copyright (c) 2025 Samsung Electronics 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 __HAL_HDCP__
+#define __HAL_HDCP__
+
+#include <hal-hdcp-interface.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file hal-hdcp.h
+ * @brief This file contains the Tizen HDCP HAL API, related structures and enumerations.
+ * @since HAL_MODULE_HDCP 1.0
+ */
+
+/**
+ * @addtogroup HAL_HDCP_MODULE
+ * @{
+ */
+
+/**
+ * @brief Initializes new handle of HDCP HAL.
+ * @since HAL_MODULE_HDCP 1.0
+ * @param[out] hdcp_handle A newly returned handle to the HDCP HAL
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #HAL_HDCP_ERROR_NONE Successful
+ * @retval #HAL_HDCP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HAL_HDCP_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #HAL_HDCP_ERROR_INTERNAL Internal error
+ * @post If it succeeds, the HDCP state will be #HAL_HDCP_STATE_INITIALIZED.
+ * @see hal_hdcp_deinit()
+ */
+int hal_hdcp_init(void **hdcp_handle);
+
+/**
+ * @brief Deinitializes handle of HDCP HAL.
+ * @since HAL_MODULE_HDCP 1.0
+ * @param[in] hdcp_handle The handle to the HDCP HAL
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #HAL_HDCP_ERROR_NONE Successful
+ * @retval #HAL_HDCP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HAL_HDCP_ERROR_NOT_IMPLEMENTED The feature is not implemented
+ * @post If it succeeds, the HDCP state will be #HAL_HDCP_STATE_NONE.
+ * @see hal_hdcp_init()
+ */
+int hal_hdcp_deinit(void *hdcp_handle);
+
+/**
+ * @brief Opens HDCP.
+ * @since HAL_MODULE_HDCP 1.0
+ * @param[in] hdcp_handle The handle to the HDCP HAL
+ * @param[in] type The type of HDCP
+ * @param[in] version The version of HDCP
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #HAL_HDCP_ERROR_NONE Successful
+ * @retval #HAL_HDCP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HAL_HDCP_ERROR_NOT_IMPLEMENTED The feature is not implemented
+ * @pre  The HDCP state must be set to #HAL_HDCP_STATE_INITIALIZED.
+ * @post If it succeeds, the HDCP state will be #HAL_HDCP_STATE_OPENED.
+ * @see hal_hdcp_close()
+ */
+int hal_hdcp_open(void *hdcp_handle, hal_hdcp_device_type_e type, hal_hdcp_protocol_version_e version);
+
+/**
+ * @brief Closes HDCP.
+ * @since HAL_MODULE_HDCP 1.0
+ * @param[in] hdcp_handle The handle to the HDCP HAL
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #HAL_HDCP_ERROR_NONE Successful
+ * @retval #HAL_HDCP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HAL_HDCP_ERROR_NOT_IMPLEMENTED The feature is not implemented
+ * @pre  The HDCP state must be set to #HAL_HDCP_STATE_OPENED.
+ * @post If it succeeds, the HDCP state will be #HAL_HDCP_STATE_INITIALIZED.
+ * @see hal_hdcp_open()
+ */
+int hal_hdcp_close(void *hdcp_handle);
+
+/**
+ * @brief Starts HDCP receiver.
+ * @since HAL_MODULE_HDCP 1.0
+ * @param[in] hdcp_handle The handle to the HDCP HAL
+ * @param[in] socket_port The socket port number
+ * @param[out] hdcp_id The hdcp id
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #HAL_HDCP_ERROR_NONE Successful
+ * @retval #HAL_HDCP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HAL_HDCP_ERROR_NOT_IMPLEMENTED The feature is not implemented
+ * @pre The HDCP state must be set to #HAL_HDCP_STATE_OPENED.
+ * @see hal_hdcp_stop_receiver()
+ */
+int hal_hdcp_start_receiver(void *hdcp_handle, uint32_t socket_port, uint32_t *hdcp_id);
+
+/**
+ * @brief Stops HDCP receiver.
+ * @since HAL_MODULE_HDCP 1.0
+ * @param[in] hdcp_handle The handle to the HDCP HAL
+ * @param[in] hdcp_id The hdcp id
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #HAL_HDCP_ERROR_NONE Successful
+ * @retval #HAL_HDCP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HAL_HDCP_ERROR_NOT_IMPLEMENTED The feature is not implemented
+ * @pre The HDCP state must be set to #HAL_HDCP_STATE_OPENED.
+ * @see hal_hdcp_start_receiver()
+ */
+int hal_hdcp_stop_receiver(void *hdcp_handle, uint32_t hdcp_id);
+
+/**
+ * @brief Starts HDCP transmitter.
+ * @since HAL_MODULE_HDCP 1.0
+ * @param[in] hdcp_handle The handle to the HDCP HAL
+ * @param[in] socket_ip The socket ip address
+ * @param[in] socket_port The socket port number
+ * @param[out] hdcp_id The hdcp id
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #HAL_HDCP_ERROR_NONE Successful
+ * @retval #HAL_HDCP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HAL_HDCP_ERROR_NOT_IMPLEMENTED The feature is not implemented
+ * @pre The HDCP state must be set to #HAL_HDCP_STATE_OPENED.
+ * @see hal_hdcp_stop_transmitter()
+ */
+int hal_hdcp_start_transmitter(void *hdcp_handle, const char *socket_ip, uint32_t socket_port, uint32_t *hdcp_id);
+
+/**
+ * @brief Stops HDCP transmitter.
+ * @since HAL_MODULE_HDCP 1.0
+ * @param[in] hdcp_handle The handle to the HDCP HAL
+ * @param[in] hdcp_id The hdcp id
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #HAL_HDCP_ERROR_NONE Successful
+ * @retval #HAL_HDCP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HAL_HDCP_ERROR_NOT_IMPLEMENTED The feature is not implemented
+ * @pre The HDCP state must be set to #HAL_HDCP_STATE_OPENED.
+ * @see hal_hdcp_start_transmitter()
+ */
+int hal_hdcp_stop_transmitter(void *hdcp_handle, uint32_t hdcp_id);
+
+/**
+ * @brief Allocates HDCP output buffer.
+ * @since HAL_MODULE_HDCP 1.0
+ * @param[in] hdcp_handle The handle to the HDCP HAL
+ * @param[in] size The size of output buffer
+ * @param[in] is_secure The flag which indicates the real data is managed in secure world or not
+ * @param[out] output The HDCP output buffer
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #HAL_HDCP_ERROR_NONE Successful
+ * @retval #HAL_HDCP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HAL_HDCP_ERROR_INTERNAL Internal error
+ * @retval #HAL_HDCP_ERROR_NOT_IMPLEMENTED The feature is not implemented
+ * @pre The HDCP state must be set to #HAL_HDCP_STATE_OPENED.
+ * @see hal_hdcp_release_output_buffer()
+ * @see hal_hdcp_decrypt()
+ */
+int hal_hdcp_allocate_output_buffer(void *hdcp_handle, uint32_t size, bool is_secure, hal_hdcp_buffer_s *buffer);
+
+/**
+ * @brief Releases HDCP output buffer.
+ * @since HAL_MODULE_HDCP 1.0
+ * @remarks The output buffer should be released with this function after use it.
+ * @param[in] hdcp_handle The handle to the HDCP HAL
+ * @param[in] output The HDCP output buffer to release
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #HAL_HDCP_ERROR_NONE Successful
+ * @retval #HAL_HDCP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HAL_HDCP_ERROR_NOT_IMPLEMENTED The feature is not implemented
+ * @pre The HDCP state must be set to #HAL_HDCP_STATE_OPENED.
+ * @see hal_hdcp_allocate_output_buffer()
+ * @see hal_hdcp_decrypt()
+ */
+int hal_hdcp_release_output_buffer(void *hdcp_handle, hal_hdcp_buffer_s *buffer);
+
+/**
+ * @brief Decrypts HDCP data.
+ * @since HAL_MODULE_HDCP 1.0
+ * @param[in] hdcp_handle The handle to the HDCP HAL
+ * @param[in] input The input buffer to decrypt
+ * @param[in] decrypt_info The decryption information
+ * @param[out] output The decrypted output buffer
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #HAL_HDCP_ERROR_NONE Successful
+ * @retval #HAL_HDCP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HAL_HDCP_ERROR_INTERNAL Internal error
+ * @retval #HAL_HDCP_ERROR_NOT_IMPLEMENTED The feature is not implemented
+ * @pre The HDCP state must be set to #HAL_HDCP_STATE_OPENED.
+ * @see hal_hdcp_allocate_output_buffer()
+ * @see hal_hdcp_release_output_buffer()
+ */
+int hal_hdcp_decrypt(void *hdcp_handle, hal_hdcp_buffer_s *input, void *decrypt_info, hal_hdcp_buffer_s *output);
+
+/**
+ * @brief Encrypts HDCP data to send.
+ * @since HAL_MODULE_HDCP 1.0
+ * @param[in] hdcp_handle The handle to the HDCP HAL
+ * @param[in] input The input buffer to encrypt
+ * @param[in] hdcp_id The hdcp id
+ * @param[in] encrypt_info The encryption information
+ * @param[out] output The encrypted output buffer
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #HAL_HDCP_ERROR_NONE Successful
+ * @retval #HAL_HDCP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HAL_HDCP_ERROR_INTERNAL Internal error
+ * @retval #HAL_HDCP_ERROR_NOT_IMPLEMENTED The feature is not implemented
+ * @pre The HDCP state must be set to #HAL_HDCP_STATE_OPENED.
+ * @see hal_hdcp_allocate_output_buffer()
+ * @see hal_hdcp_release_output_buffer()
+ */
+int hal_hdcp_encrypt(void *hdcp_handle, hal_hdcp_buffer_s *input, uint32_t hdcp_id, void *encrypt_info, hal_hdcp_buffer_s *output);
+
+/**
+ * @brief Gets the state of HDCP.
+ * @since HAL_MODULE_HDCP 1.0
+ * @param[in]  hdcp_handle The handle to the HDCP HAL
+ * @param[out] state The current state of the HDCP
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #HAL_HDCP_ERROR_NONE Successful
+ * @retval #HAL_HDCP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HAL_HDCP_ERROR_NOT_IMPLEMENTED The feature is not implemented
+ * @pre The HDCP state must be set to #HAL_HDCP_STATE_INITIALIZED.
+ */
+int hal_hdcp_get_state(void *hdcp_handle, hal_hdcp_state_e *state);
+
+/**
+ * @brief Sets the various command and value to control HDCP.
+ * @since HAL_MODULE_HDCP 1.0
+ * @param[in] hdcp_handle The handle to the HDCP HAL
+ * @param[in] command The command to control the HDCP device
+ * @param[in] value The value to set
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #HAL_HDCP_ERROR_NONE Successful
+ * @retval #HAL_HDCP_ERROR_NOT_SUPPORTED The command is not supported
+ * @retval #HAL_HDCP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HAL_HDCP_ERROR_INVALID_STATE Invalid state
+ * @retval #HAL_HDCP_ERROR_NOT_IMPLEMENTED The feature is not implemented
+ * @pre The HDCP state must be set to #HAL_HDCP_STATE_INITIALIZED.
+ * @see hal_hdcp_get_command()
+ */
+int hal_hdcp_set_command(void *hdcp_handle, hal_hdcp_command_e command, void *value);
+
+/**
+ * @brief Gets the current value of command.
+ * @since HAL_MODULE_HDCP 1.0
+ * @param[in] hdcp_handle The handle to the HDCP HAL
+ * @param[in] command The command to control the HDCP device
+ * @param[out] value The value to get
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #HAL_HDCP_ERROR_NONE Successful
+ * @retval #HAL_HDCP_ERROR_NOT_SUPPORTED The command is not supported
+ * @retval #HAL_HDCP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HAL_HDCP_ERROR_INVALID_STATE Invalid state
+ * @retval #HAL_HDCP_ERROR_INTERNAL Internal error
+ * @retval #HAL_HDCP_ERROR_NOT_IMPLEMENTED The feature is not implemented
+ * @pre The HDCP state must be set to #HAL_HDCP_STATE_INITIALIZED.
+ * @see hal_hdcp_set_command()
+ */
+int hal_hdcp_get_command(void *hdcp_handle, hal_hdcp_command_e command, void **value);
+
+/**
+ * @brief Sets a set of commands.
+ * @since HAL_MODULE_HDCP 1.0
+ * @remarks error_command will be set if error is returned from the function.
+ * @param[in] hdcp_handle The handle to the HDCP HAL
+ * @param[in] batch_command The batch command to set
+ * @param[out] error_command The error command
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #HAL_HDCP_ERROR_NONE Successful
+ * @retval #HAL_HDCP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HAL_HDCP_ERROR_INVALID_STATE Invalid state
+ * @retval #HAL_HDCP_ERROR_NOT_IMPLEMENTED The feature is not implemented
+ * @pre The HDCP state must be set to #HAL_HDCP_STATE_INITIALIZED.
+ * @see hal_hdcp_set_command()
+ * @see hal_hdcp_get_command()
+ */
+int hal_hdcp_set_batch_command(void *hdcp_handle, hal_hdcp_batch_command_control_s *batch_command, hal_hdcp_command_e *error_command);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __HAL_HDCP__ */
diff --git a/packaging/hal-api-hdcp-manifest.xml b/packaging/hal-api-hdcp-manifest.xml
new file mode 100644 (file)
index 0000000..550f1a5
--- /dev/null
@@ -0,0 +1,8 @@
+<hal-api>
+    <manifest platform-version="10.0">
+        <hal-module>
+            <name>HAL_MODULE_HDCP</name>
+            <version transport="passthrough">1.0</version>
+        </hal-module>
+    </manifest>
+</hal-api>
diff --git a/packaging/hal-api-hdcp.spec b/packaging/hal-api-hdcp.spec
new file mode 100644 (file)
index 0000000..a246805
--- /dev/null
@@ -0,0 +1,84 @@
+%define name           hal-api-hdcp
+
+### main package #########
+Name:       %{name}
+Summary:    %{name} interface
+Version:    1.0.1
+Release:    0
+Group:      Development/Libraries
+License:    Apache-2.0
+Source0:    %{name}-%{version}.tar.gz
+Source1:    %{name}-manifest.xml
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+BuildRequires: cmake
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(hal-api-common)
+BuildRequires: pkgconfig(gmock)
+BuildRequires: pkgconfig(capi-system-info)
+
+%description
+%{name} interface package for product vendor developer
+
+
+### devel package #########
+%package    devel
+Summary:    %{name} interface
+Group:      Development/Libraries
+Requires:   %{name} = %{version}-%{release}
+
+%description devel
+%{name} interface development package for product vendor developer
+
+### test package #########
+%package haltests
+Summary: tests for %{name}
+Requires: %{name} = %{version}
+
+%description haltests
+Haltests for %{name}
+
+
+### build and install #########
+%prep
+%setup -q
+
+%cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DCMAKE_LIBDIR_PREFIX=%{_libdir}
+
+%build
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+mkdir -p %{buildroot}%{_sysconfdir}/hal
+cp %{SOURCE1} %{buildroot}%{_sysconfdir}/hal/
+%make_install
+
+%clean
+rm -rf %{buildroot}
+
+%post
+/sbin/ldconfig
+/usr/bin/hal-compatibility-checker --reset
+
+%postun
+/sbin/ldconfig
+/usr/bin/hal-compatibility-checker --reset
+
+%files
+%manifest %{name}.manifest
+%license LICENSE
+%defattr(-,root,root,-)
+%{_libdir}/hal/*.so.*
+%{_sysconfdir}/hal/%{name}-manifest.xml
+
+%files devel
+%defattr(-,root,root,-)
+%{_includedir}/hal/*.h
+%{_libdir}/hal/*.so
+%{_libdir}/pkgconfig/*.pc
+
+%files haltests
+%manifest %{name}-haltests.manifest
+%{_bindir}/hal/hdcp-haltests
diff --git a/src/hal-api-hdcp.c b/src/hal-api-hdcp.c
new file mode 100644 (file)
index 0000000..b5c0252
--- /dev/null
@@ -0,0 +1,431 @@
+/*
+ * HAL (Hardware Abstract Layer) API HDCP
+ *
+ * Copyright (c) 2025 Samsung Electronics 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 <stdio.h>
+#include <stdint.h>
+#include <dlfcn.h>
+#include <dlog.h>
+#include <glib.h>
+
+#include <hal/hal-common.h>
+
+#include "hal-hdcp-interface.h"
+#include "hal-hdcp.h"
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "HALAPI_HDCP"
+
+#define HAL_HDCP_RETURN_IF_NULL(arg, ret) \
+do { \
+    if (!(arg)) { \
+        SLOGE("[%s]failed, return[%s]", #arg, #ret); \
+        return (ret); \
+    } \
+} while (0)
+
+#define HAL_HDCP_CHECK_STATE(state, target_state) \
+do { \
+    if ((state < target_state)) { \
+        SLOGE("should be [%d]state", target_state); \
+        return HAL_HDCP_ERROR_INVALID_STATE; \
+    } \
+} while (0)
+
+#define AUTOCLEAN_LOCKER(x) g_autoptr(GMutexLocker) locker = g_mutex_locker_new(x);
+#define AUTOCLEAN_UNLOCKER() g_clear_pointer(&locker, g_mutex_locker_free);
+
+typedef struct _hal_hdcp_s {
+    void *backend;
+    hal_backend_hdcp_funcs *funcs;
+    hal_hdcp_state_e state;
+    GMutex lock;
+} hal_hdcp_s;
+
+static void __hal_hdcp_set_state(hal_hdcp_s *handle, hal_hdcp_state_e state)
+{
+    LOGI("Current state : %d, Target state : %d", handle->state, state);
+    handle->state = state;
+}
+
+static int hal_hdcp_init_backend(void **data, void *user_data)
+{
+    if (!data) {
+        SLOGE("NULL data");
+        return -EINVAL;
+    }
+
+    *data = g_new0(hal_backend_hdcp_funcs, 1);
+
+    SLOGI("new - hdcp HAL funcs[%p], size[%zu]",
+        *data, sizeof(hal_backend_hdcp_funcs));
+
+    return 0;
+}
+
+static int hal_hdcp_exit_backend(void *data, void *user_data)
+{
+    if (!data) {
+        SLOGE("NULL data");
+        return -EINVAL;
+    }
+
+    SLOGI("release - hdcp HAL funcs[%p], size[%zu]",
+        data, sizeof(hal_backend_hdcp_funcs));
+
+    g_free(data);
+
+    return 0;
+}
+
+int hal_hdcp_init(void **hdcp_handle)
+{
+    HAL_HDCP_RETURN_IF_NULL(hdcp_handle, HAL_HDCP_ERROR_INVALID_PARAMETER);
+
+    SLOGI("start");
+
+    hal_hdcp_s *new_handle = g_new0(hal_hdcp_s, 1);
+
+    g_mutex_init(&new_handle->lock);
+    AUTOCLEAN_LOCKER(&new_handle->lock);
+
+    int ret = hal_common_get_backend_v2(HAL_MODULE_HDCP,
+        (void **)&new_handle->funcs,
+        NULL,
+    hal_hdcp_init_backend);
+    if (ret != 0) {
+        SLOGE("Failed to get backend");
+        goto __HAL_INIT_FAILED;
+    }
+
+    if (!new_handle->funcs || !new_handle->funcs->init) {
+        SLOGE("invalid ptr[%p]", new_handle->funcs);
+        goto __HAL_INIT_FAILED;
+    }
+
+    ret = new_handle->funcs->init(&new_handle->backend);
+    if (ret != HAL_HDCP_ERROR_NONE) {
+        SLOGE("backend init failed[0x%x]", ret);
+        goto __HAL_INIT_FAILED;
+    }
+
+    __hal_hdcp_set_state(new_handle, HAL_HDCP_STATE_INITIALIZED);
+
+    *hdcp_handle = (void *)new_handle;
+
+    SLOGI("done");
+
+    return HAL_HDCP_ERROR_NONE;
+
+__HAL_INIT_FAILED:
+    if (new_handle->funcs) {
+        hal_common_put_backend_v2(HAL_MODULE_HDCP,
+            (void *)new_handle->funcs,
+            NULL,
+            hal_hdcp_exit_backend);
+    }
+
+    g_free(new_handle);
+
+    return HAL_HDCP_ERROR_INTERNAL;
+}
+
+int hal_hdcp_deinit(void *hdcp_handle)
+{
+    int ret = 0;
+    hal_hdcp_s *handle = (hal_hdcp_s *)hdcp_handle;
+
+    HAL_HDCP_RETURN_IF_NULL(handle, HAL_HDCP_ERROR_INVALID_PARAMETER);
+    HAL_HDCP_RETURN_IF_NULL(handle->funcs, HAL_HDCP_ERROR_INVALID_PARAMETER);
+    HAL_HDCP_RETURN_IF_NULL(handle->funcs->deinit, HAL_HDCP_ERROR_NOT_IMPLEMENTED);
+
+    SLOGI("start handle=%p", hdcp_handle);
+
+    AUTOCLEAN_LOCKER(&handle->lock);
+
+    ret = handle->funcs->deinit(handle->backend);
+    if (ret != HAL_HDCP_ERROR_NONE) {
+        SLOGE("deinit failed[0x%x]", ret);
+        return ret;
+    }
+
+    hal_common_put_backend_v2(HAL_MODULE_HDCP,
+        (void *)handle->funcs,
+        NULL,
+        hal_hdcp_exit_backend);
+
+    AUTOCLEAN_UNLOCKER();
+    g_mutex_clear(&handle->lock);
+
+    g_free(handle);
+    handle = NULL;
+
+    SLOGI("done");
+
+    return HAL_HDCP_ERROR_NONE;
+}
+
+int hal_hdcp_open(void *hdcp_handle, hal_hdcp_device_type_e type, hal_hdcp_protocol_version_e version)
+{
+    int ret = 0;
+    hal_hdcp_s *handle = (hal_hdcp_s *)hdcp_handle;
+
+    HAL_HDCP_RETURN_IF_NULL(handle, HAL_HDCP_ERROR_INVALID_PARAMETER);
+    HAL_HDCP_RETURN_IF_NULL(handle->funcs, HAL_HDCP_ERROR_INVALID_PARAMETER);
+    HAL_HDCP_RETURN_IF_NULL(handle->funcs->hdcp_open, HAL_HDCP_ERROR_NOT_IMPLEMENTED);
+
+    if (type < HAL_HDCP_DEVICE_RECEIVER || type > HAL_HDCP_DEVICE_TRANSMIT_MULTISINK)
+        return HAL_HDCP_ERROR_INVALID_PARAMETER;
+
+    if (version < HAL_HDCP_VERSION_2_0 || version > HAL_HDCP_VERSION_2_2)
+        return HAL_HDCP_ERROR_INVALID_PARAMETER;
+
+    AUTOCLEAN_LOCKER(&handle->lock);
+
+    HAL_HDCP_CHECK_STATE(handle->state, HAL_HDCP_STATE_INITIALIZED);
+
+    ret = handle->funcs->hdcp_open(handle->backend, type, version);
+    if (ret == HAL_HDCP_ERROR_NONE)
+        __hal_hdcp_set_state(handle, HAL_HDCP_STATE_OPENED);
+
+    return ret;
+}
+
+int hal_hdcp_close(void *hdcp_handle)
+{
+    int ret = 0;
+    hal_hdcp_s *handle = (hal_hdcp_s *)hdcp_handle;
+
+    HAL_HDCP_RETURN_IF_NULL(handle, HAL_HDCP_ERROR_INVALID_PARAMETER);
+    HAL_HDCP_RETURN_IF_NULL(handle->funcs, HAL_HDCP_ERROR_INVALID_PARAMETER);
+    HAL_HDCP_RETURN_IF_NULL(handle->funcs->hdcp_close, HAL_HDCP_ERROR_NOT_IMPLEMENTED);
+
+    AUTOCLEAN_LOCKER(&handle->lock);
+
+    HAL_HDCP_CHECK_STATE(handle->state, HAL_HDCP_STATE_OPENED);
+
+    ret = handle->funcs->hdcp_close(handle->backend);
+    if (ret == HAL_HDCP_ERROR_NONE)
+        __hal_hdcp_set_state(handle, HAL_HDCP_STATE_INITIALIZED);
+
+    return ret;
+}
+
+int hal_hdcp_start_receiver(void *hdcp_handle, uint32_t socket_port, uint32_t *hdcp_id)
+{
+    hal_hdcp_s *handle = (hal_hdcp_s *)hdcp_handle;
+
+    HAL_HDCP_RETURN_IF_NULL(handle, HAL_HDCP_ERROR_INVALID_PARAMETER);
+    HAL_HDCP_RETURN_IF_NULL(handle->funcs, HAL_HDCP_ERROR_INVALID_PARAMETER);
+    HAL_HDCP_RETURN_IF_NULL(handle->funcs->hdcp_start_receiver, HAL_HDCP_ERROR_NOT_IMPLEMENTED);
+    HAL_HDCP_RETURN_IF_NULL(hdcp_id, HAL_HDCP_ERROR_INVALID_PARAMETER);
+
+    AUTOCLEAN_LOCKER(&handle->lock);
+
+    HAL_HDCP_CHECK_STATE(handle->state, HAL_HDCP_STATE_OPENED);
+
+    return handle->funcs->hdcp_start_receiver(handle->backend, socket_port, hdcp_id);
+}
+
+int hal_hdcp_stop_receiver(void *hdcp_handle, uint32_t hdcp_id)
+{
+    hal_hdcp_s *handle = (hal_hdcp_s *)hdcp_handle;
+
+    HAL_HDCP_RETURN_IF_NULL(handle, HAL_HDCP_ERROR_INVALID_PARAMETER);
+    HAL_HDCP_RETURN_IF_NULL(handle->funcs, HAL_HDCP_ERROR_INVALID_PARAMETER);
+    HAL_HDCP_RETURN_IF_NULL(handle->funcs->hdcp_stop_receiver, HAL_HDCP_ERROR_NOT_IMPLEMENTED);
+
+    AUTOCLEAN_LOCKER(&handle->lock);
+
+    HAL_HDCP_CHECK_STATE(handle->state, HAL_HDCP_STATE_OPENED);
+
+    return handle->funcs->hdcp_stop_receiver(handle->backend, hdcp_id);
+}
+
+int hal_hdcp_start_transmitter(void *hdcp_handle, const char *socket_ip, uint32_t socket_port, uint32_t *hdcp_id)
+{
+    hal_hdcp_s *handle = (hal_hdcp_s *)hdcp_handle;
+
+    HAL_HDCP_RETURN_IF_NULL(handle, HAL_HDCP_ERROR_INVALID_PARAMETER);
+    HAL_HDCP_RETURN_IF_NULL(handle->funcs, HAL_HDCP_ERROR_INVALID_PARAMETER);
+    HAL_HDCP_RETURN_IF_NULL(handle->funcs->hdcp_start_transmitter, HAL_HDCP_ERROR_NOT_IMPLEMENTED);
+    HAL_HDCP_RETURN_IF_NULL(socket_ip, HAL_HDCP_ERROR_INVALID_PARAMETER);
+    HAL_HDCP_RETURN_IF_NULL(hdcp_id, HAL_HDCP_ERROR_INVALID_PARAMETER);
+
+    AUTOCLEAN_LOCKER(&handle->lock);
+
+    HAL_HDCP_CHECK_STATE(handle->state, HAL_HDCP_STATE_OPENED);
+
+    return handle->funcs->hdcp_start_transmitter(handle->backend, socket_ip, socket_port, hdcp_id);
+}
+
+int hal_hdcp_stop_transmitter(void *hdcp_handle, uint32_t hdcp_id)
+{
+    hal_hdcp_s *handle = (hal_hdcp_s *)hdcp_handle;
+
+    HAL_HDCP_RETURN_IF_NULL(handle, HAL_HDCP_ERROR_INVALID_PARAMETER);
+    HAL_HDCP_RETURN_IF_NULL(handle->funcs, HAL_HDCP_ERROR_INVALID_PARAMETER);
+    HAL_HDCP_RETURN_IF_NULL(handle->funcs->hdcp_stop_transmitter, HAL_HDCP_ERROR_NOT_IMPLEMENTED);
+
+    AUTOCLEAN_LOCKER(&handle->lock);
+
+    HAL_HDCP_CHECK_STATE(handle->state, HAL_HDCP_STATE_OPENED);
+
+    return handle->funcs->hdcp_stop_transmitter(handle->backend, hdcp_id);
+}
+
+int hal_hdcp_allocate_output_buffer(void *hdcp_handle, uint32_t size, bool is_secure, hal_hdcp_buffer_s *buffer)
+{
+    hal_hdcp_s *handle = (hal_hdcp_s *)hdcp_handle;
+
+    HAL_HDCP_RETURN_IF_NULL(handle, HAL_HDCP_ERROR_INVALID_PARAMETER);
+    HAL_HDCP_RETURN_IF_NULL(handle->funcs, HAL_HDCP_ERROR_INVALID_PARAMETER);
+    HAL_HDCP_RETURN_IF_NULL(handle->funcs->hdcp_stop_transmitter, HAL_HDCP_ERROR_NOT_IMPLEMENTED);
+    HAL_HDCP_RETURN_IF_NULL(buffer, HAL_HDCP_ERROR_INVALID_PARAMETER);
+
+    AUTOCLEAN_LOCKER(&handle->lock);
+
+    HAL_HDCP_CHECK_STATE(handle->state, HAL_HDCP_STATE_OPENED);
+
+    return handle->funcs->hdcp_allocate_output_buffer(handle->backend, size, is_secure, buffer);
+}
+
+int hal_hdcp_release_output_buffer(void *hdcp_handle, hal_hdcp_buffer_s *buffer)
+{
+    hal_hdcp_s *handle = (hal_hdcp_s *)hdcp_handle;
+
+    HAL_HDCP_RETURN_IF_NULL(handle, HAL_HDCP_ERROR_INVALID_PARAMETER);
+    HAL_HDCP_RETURN_IF_NULL(handle->funcs, HAL_HDCP_ERROR_INVALID_PARAMETER);
+    HAL_HDCP_RETURN_IF_NULL(handle->funcs->hdcp_stop_transmitter, HAL_HDCP_ERROR_NOT_IMPLEMENTED);
+    HAL_HDCP_RETURN_IF_NULL(buffer, HAL_HDCP_ERROR_INVALID_PARAMETER);
+
+    AUTOCLEAN_LOCKER(&handle->lock);
+
+    HAL_HDCP_CHECK_STATE(handle->state, HAL_HDCP_STATE_OPENED);
+
+    return handle->funcs->hdcp_release_output_buffer(handle->backend, buffer);
+}
+
+int hal_hdcp_decrypt(void *hdcp_handle, hal_hdcp_buffer_s *input, void *decrypt_info, hal_hdcp_buffer_s *output)
+{
+    hal_hdcp_s *handle = (hal_hdcp_s *)hdcp_handle;
+
+    HAL_HDCP_RETURN_IF_NULL(handle, HAL_HDCP_ERROR_INVALID_PARAMETER);
+    HAL_HDCP_RETURN_IF_NULL(handle->funcs, HAL_HDCP_ERROR_INVALID_PARAMETER);
+    HAL_HDCP_RETURN_IF_NULL(handle->funcs->hdcp_decrypt, HAL_HDCP_ERROR_NOT_IMPLEMENTED);
+    HAL_HDCP_RETURN_IF_NULL(input, HAL_HDCP_ERROR_INVALID_PARAMETER);
+    HAL_HDCP_RETURN_IF_NULL(output, HAL_HDCP_ERROR_INVALID_PARAMETER);
+
+    AUTOCLEAN_LOCKER(&handle->lock);
+
+    HAL_HDCP_CHECK_STATE(handle->state, HAL_HDCP_STATE_OPENED);
+
+    return handle->funcs->hdcp_decrypt(handle->backend, input, decrypt_info, output);
+}
+
+int hal_hdcp_encrypt(void *hdcp_handle, hal_hdcp_buffer_s *input, uint32_t hdcp_id, void *encrypt_info, hal_hdcp_buffer_s *output)
+{
+    hal_hdcp_s *handle = (hal_hdcp_s *)hdcp_handle;
+
+    HAL_HDCP_RETURN_IF_NULL(handle, HAL_HDCP_ERROR_INVALID_PARAMETER);
+    HAL_HDCP_RETURN_IF_NULL(handle->funcs, HAL_HDCP_ERROR_INVALID_PARAMETER);
+    HAL_HDCP_RETURN_IF_NULL(handle->funcs->hdcp_encrypt, HAL_HDCP_ERROR_NOT_IMPLEMENTED);
+    HAL_HDCP_RETURN_IF_NULL(input, HAL_HDCP_ERROR_INVALID_PARAMETER);
+    HAL_HDCP_RETURN_IF_NULL(encrypt_info, HAL_HDCP_ERROR_INVALID_PARAMETER);
+    HAL_HDCP_RETURN_IF_NULL(output, HAL_HDCP_ERROR_INVALID_PARAMETER);
+
+    AUTOCLEAN_LOCKER(&handle->lock);
+
+    HAL_HDCP_CHECK_STATE(handle->state, HAL_HDCP_STATE_OPENED);
+
+    return handle->funcs->hdcp_encrypt(handle->backend, input, hdcp_id, encrypt_info, output);
+}
+
+int hal_hdcp_get_state(void *hdcp_handle, hal_hdcp_state_e *state)
+{
+    hal_hdcp_s *handle = (hal_hdcp_s *)hdcp_handle;
+
+    HAL_HDCP_RETURN_IF_NULL(handle, HAL_HDCP_ERROR_INVALID_PARAMETER);
+    HAL_HDCP_RETURN_IF_NULL(state, HAL_HDCP_ERROR_INVALID_PARAMETER);
+
+    AUTOCLEAN_LOCKER(&handle->lock);
+
+    HAL_HDCP_CHECK_STATE(handle->state, HAL_HDCP_STATE_INITIALIZED);
+
+    *state = handle->state;
+
+    return HAL_HDCP_ERROR_NONE;
+}
+
+int hal_hdcp_set_command(void *hdcp_handle, hal_hdcp_command_e command, void *value)
+{
+    hal_hdcp_s *handle = (hal_hdcp_s *)hdcp_handle;
+
+    HAL_HDCP_RETURN_IF_NULL(handle, HAL_HDCP_ERROR_INVALID_PARAMETER);
+    HAL_HDCP_RETURN_IF_NULL(handle->funcs, HAL_HDCP_ERROR_INVALID_PARAMETER);
+    HAL_HDCP_RETURN_IF_NULL(handle->funcs->set_command, HAL_HDCP_ERROR_NOT_IMPLEMENTED);
+    HAL_HDCP_RETURN_IF_NULL(value, HAL_HDCP_ERROR_INVALID_PARAMETER);
+
+    if (command < HAL_HDCP_COMMAND_BASE || command > HAL_HDCP_COMMAND_CUSTOM)
+        return HAL_HDCP_ERROR_INVALID_PARAMETER;
+
+    AUTOCLEAN_LOCKER(&handle->lock);
+
+    HAL_HDCP_CHECK_STATE(handle->state, HAL_HDCP_STATE_INITIALIZED);
+
+    return handle->funcs->set_command(handle->backend, command, value);
+}
+
+int hal_hdcp_get_command(void *hdcp_handle, hal_hdcp_command_e command, void **value)
+{
+    hal_hdcp_s *handle = (hal_hdcp_s *)hdcp_handle;
+
+    HAL_HDCP_RETURN_IF_NULL(handle, HAL_HDCP_ERROR_INVALID_PARAMETER);
+    HAL_HDCP_RETURN_IF_NULL(handle->funcs, HAL_HDCP_ERROR_INVALID_PARAMETER);
+    HAL_HDCP_RETURN_IF_NULL(handle->funcs->get_command, HAL_HDCP_ERROR_NOT_IMPLEMENTED);
+    HAL_HDCP_RETURN_IF_NULL(value, HAL_HDCP_ERROR_INVALID_PARAMETER);
+
+    if (command < HAL_HDCP_COMMAND_BASE || command > HAL_HDCP_COMMAND_CUSTOM)
+        return HAL_HDCP_ERROR_INVALID_PARAMETER;
+
+    AUTOCLEAN_LOCKER(&handle->lock);
+
+    HAL_HDCP_CHECK_STATE(handle->state, HAL_HDCP_STATE_INITIALIZED);
+
+    return handle->funcs->get_command(handle->backend, command, value);
+}
+
+int hal_hdcp_set_batch_command(void *hdcp_handle, hal_hdcp_batch_command_control_s *batch_command, hal_hdcp_command_e *error_command)
+{
+    hal_hdcp_s *handle = (hal_hdcp_s *)hdcp_handle;
+
+    HAL_HDCP_RETURN_IF_NULL(handle, HAL_HDCP_ERROR_INVALID_PARAMETER);
+    HAL_HDCP_RETURN_IF_NULL(handle->funcs, HAL_HDCP_ERROR_INVALID_PARAMETER);
+    HAL_HDCP_RETURN_IF_NULL(handle->funcs->set_batch_command, HAL_HDCP_ERROR_NOT_IMPLEMENTED);
+    HAL_HDCP_RETURN_IF_NULL(batch_command, HAL_HDCP_ERROR_INVALID_PARAMETER);
+    HAL_HDCP_RETURN_IF_NULL(batch_command->custom.name, HAL_HDCP_ERROR_INVALID_PARAMETER);
+    HAL_HDCP_RETURN_IF_NULL(batch_command->custom.value, HAL_HDCP_ERROR_INVALID_PARAMETER);
+    /* error_command could be NULL. */
+
+    AUTOCLEAN_LOCKER(&handle->lock);
+
+    HAL_HDCP_CHECK_STATE(handle->state, HAL_HDCP_STATE_INITIALIZED);
+
+    return handle->funcs->set_batch_command(handle->backend, batch_command, error_command);
+}
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
new file mode 100644 (file)
index 0000000..a7ed9f9
--- /dev/null
@@ -0,0 +1,21 @@
+SET(HAL_HDCP_TEST "hdcp-haltests")
+
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -Werror")
+
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/ HALTEST_SRCS)
+ADD_EXECUTABLE(${HAL_HDCP_TEST} ${HALTEST_SRCS})
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${HAL_HDCP_TEST} REQUIRED glib-2.0 gmock capi-system-info)
+
+FOREACH(flag ${${HAL_HDCP_TEST}_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -fPIC -pie -Wall")
+
+TARGET_LINK_LIBRARIES(${HAL_HDCP_TEST} ${PROJECT_NAME} ${${HAL_HDCP_TEST}_LDFLAGS})
+SET_TARGET_PROPERTIES(${HAL_HDCP_TEST} PROPERTIES COMPILE_FLAGS "-fPIE")
+SET_TARGET_PROPERTIES(${HAL_HDCP_TEST} PROPERTIES LINK_FLAGS "-pie")
+
+INSTALL(TARGETS ${HAL_HDCP_TEST} DESTINATION ${EXEC_PREFIX}/hal/)
diff --git a/tests/hdcp_hal_test.cpp b/tests/hdcp_hal_test.cpp
new file mode 100644 (file)
index 0000000..fb5ab44
--- /dev/null
@@ -0,0 +1,912 @@
+/*
+ * Copyright (c) 2025 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Haesu Gwon <haesu.gwon@samsung.com>
+ *
+ * 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 <glib.h>
+#include <string.h>
+#include <gtest/gtest.h>
+#include <unistd.h>
+#include <iostream>
+#include <system_info.h>
+#include <hal-hdcp.h>
+
+static int gRet;
+static void *gHalHandle;
+static const char *gSocketIp = "192.168.0.1";
+static int gPortIp = 100;
+
+/*
+ * main class
+ */
+class HdcpHalTest : public testing::Test
+{
+    public:
+        virtual void SetUp()
+        {
+            gRet = hal_hdcp_init(&gHalHandle);
+            if (gRet == HAL_HDCP_ERROR_NONE) {
+                std::cout << "HDCP HAL init - handle: " << gHalHandle << std::endl;
+                return;
+            }
+
+            std::cout << "HDCP HAL init failed " << gRet << std::endl;
+        }
+
+        virtual void TearDown()
+        {
+            if (gHalHandle) {
+                std::cout << "HDCP HAL deinit - handle: " << gHalHandle << std::endl;
+                gRet = hal_hdcp_deinit(gHalHandle);
+                gHalHandle = nullptr;
+            }
+        }
+};
+
+/**
+ * @testcase        InitP
+ * @since           HAL_MODULE_HDCP 1.0
+ * @author          SR(haesu.gwon)
+ * @reviewer        SR(gilbok)
+ * @type            auto
+ * @description     Positive, Initialize HDCP HAL handle
+ * @apicovered      hal_hdcp_init
+ * @passcase        when hal_hdcp_init returns HAL_HDCP_ERROR_NONE and the handle "gHalHandle" is not a null pointer
+ * @failcase        when handle "gHalHandle" is a null pointer
+ * @precondition    None
+ * @postcondition   None
+ */
+TEST_F(HdcpHalTest, InitP)
+{
+    ASSERT_NE(gHalHandle, nullptr);
+}
+
+/**
+ * @testcase        InitN
+ * @since           HAL_MODULE_HDCP 1.0
+ * @author          SR(haesu.gwon)
+ * @reviewer        SR(gilbok)
+ * @type            auto
+ * @description     Negative, Initialize HDCP HAL handle
+ * @apicovered      hal_hdcp_init
+ * @passcase        when input handle of hal_hdcp_init is a null pointer and hal_hdcp_init returns HAL_HDCP_ERROR_INVALID_PARAMETER
+ * @failcase        when hal_hdcp_init does not returns HAL_HDCP_ERROR_INVALID_PARAMETER
+ * @precondition    None
+ * @postcondition   None
+ */
+TEST_F(HdcpHalTest, InitN)
+{
+    gRet = hal_hdcp_init(nullptr);
+    EXPECT_EQ(gRet, HAL_HDCP_ERROR_INVALID_PARAMETER);
+}
+
+/**
+ * @testcase        DeinitP
+ * @since           HAL_MODULE_HDCP 1.0
+ * @author          SR(haesu.gwon)
+ * @reviewer        SR(gilbok)
+ * @type            auto
+ * @description     Positive, Deinitialize HDCP HAL handle
+ * @apicovered      hal_hdcp_init, hal_hdcp_deinit
+ * @passcase        when hal_hdcp_deinit returns HAL_HDCP_ERROR_NONE
+ * @failcase        when hal_hdcp_deinit does not return HAL_HDCP_ERROR_NONE
+ * @precondition    None
+ * @postcondition   None
+ */
+TEST_F(HdcpHalTest, DeinitP)
+{
+    void *hal_handle = nullptr;
+
+    gRet = hal_hdcp_init(&hal_handle);
+
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+    ASSERT_NE(hal_handle, nullptr);
+
+    if (hal_handle) {
+        gRet = hal_hdcp_deinit(hal_handle);
+        EXPECT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+        hal_handle = nullptr;
+    }
+}
+
+/**
+ * @testcase        DeinitN
+ * @since           HAL_MODULE_HDCP 1.0
+ * @author          SR(haesu.gwon)
+ * @reviewer        SR(gilbok)
+ * @type            auto
+ * @description     Negative, Deinitialize HDCP HAL handle
+ * @apicovered      hal_hdcp_init, hal_hdcp_deinit
+ * @passcase        when hal_hdcp_deinit returns HAL_HDCP_ERROR_INVALID_PARAMETER
+ * @failcase        when hal_hdcp_deinit does not return HAL_HDCP_ERROR_INVALID_PARAMETER
+ * @precondition    None
+ * @postcondition   None
+ */
+TEST_F(HdcpHalTest, DeinitN)
+{
+    gRet = hal_hdcp_deinit(nullptr);
+    EXPECT_EQ(gRet, HAL_HDCP_ERROR_INVALID_PARAMETER);
+}
+
+/**
+ * @testcase        HdcpSetCommandP
+ * @since           HAL_MODULE_HDCP 1.0
+ * @author          SR(haesu.gwon)
+ * @reviewer        SR(gilbok)
+ * @type            auto
+ * @description     Positive, Set command
+ * @apicovered      hal_hdcp_set_batch_command
+ * @passcase        when hal_hdcp_set_batch_command returns HAL_HDCP_ERROR_NONE
+ * @failcase        when hal_hdcp_set_batch_command does not return HAL_HDCP_ERROR_NONE
+ * @precondition    None
+ * @postcondition   None
+ */
+TEST_F(HdcpHalTest, HdcpSetBatchCommandP)
+{
+    hal_hdcp_batch_command_control_s batch_command;
+    batch_command.command_set_flag |= HAL_HDCP_COMMAND_CUSTOM;
+    batch_command.custom.name = "custom_command_name";
+    batch_command.custom.value = (void*)10;
+
+    gRet = hal_hdcp_open(gHalHandle, HAL_HDCP_DEVICE_RECEIVER, HAL_HDCP_VERSION_2_0);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_set_batch_command(gHalHandle, &batch_command, nullptr);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_close(gHalHandle);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+}
+
+/**
+ * @testcase        HdcpSetBatchCommandN
+ * @since           HAL_MODULE_HDCP 1.0
+ * @author          SR(haesu.gwon)
+ * @reviewer        SR(gilbok)
+ * @type            auto
+ * @description     Negative, Set command
+ * @apicovered      hal_hdcp_set_batch_command
+ * @passcase        when hal_hdcp_set_batch_command returns HAL_HDCP_ERROR_INVALID_PARAMETER
+ * @failcase        when hal_hdcp_set_batch_command does not return HAL_HDCP_ERROR_INVALID_PARAMETER
+ * @precondition    None
+ * @postcondition   None
+ */
+TEST_F(HdcpHalTest, HdcpSetBatchCommandN)
+{
+    hal_hdcp_batch_command_control_s batch_command;
+    batch_command.command_set_flag |= HAL_HDCP_COMMAND_CUSTOM;
+    batch_command.custom.name = "custom_command_name";
+    batch_command.custom.value = (void*)10;
+
+    gRet = hal_hdcp_open(gHalHandle, HAL_HDCP_DEVICE_RECEIVER, HAL_HDCP_VERSION_2_0);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_set_batch_command(nullptr, &batch_command, nullptr);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_INVALID_PARAMETER);
+
+    gRet = hal_hdcp_set_batch_command(gHalHandle, nullptr, nullptr);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_INVALID_PARAMETER);
+
+    gRet = hal_hdcp_close(gHalHandle);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+}
+
+/**
+ * @testcase        HdcpOpenP
+ * @since           HAL_MODULE_HDCP 1.0
+ * @author          SR(haesu.gwon)
+ * @reviewer        SR(gilbok)
+ * @type            auto
+ * @description     Positive, Open HDCP
+ * @apicovered      hal_hdcp_open
+ * @passcase        when hal_hdcp_open returns HAL_HDCP_ERROR_NONE
+ * @failcase        when hal_hdcp_open does not return HAL_HDCP_ERROR_NONE
+ * @precondition    None
+ * @postcondition   None
+ */
+TEST_F(HdcpHalTest, HdcpOpenP)
+{
+    gRet = hal_hdcp_open(gHalHandle, HAL_HDCP_DEVICE_RECEIVER, HAL_HDCP_VERSION_2_0);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+}
+
+/**
+ * @testcase        HdcpCloseP
+ * @since           HAL_MODULE_HDCP 1.0
+ * @author          SR(haesu.gwon)
+ * @reviewer        SR(gilbok)
+ * @type            auto
+ * @description     Positive, Close HDCP
+ * @apicovered      hal_hdcp_close
+ * @passcase        when hal_hdcp_close returns HAL_HDCP_ERROR_NONE
+ * @failcase        when hal_hdcp_close does not return HAL_HDCP_ERROR_NONE
+ * @precondition    None
+ * @postcondition   None
+ */
+TEST_F(HdcpHalTest, HdcpCloseP)
+{
+    gRet = hal_hdcp_open(gHalHandle, HAL_HDCP_DEVICE_RECEIVER, HAL_HDCP_VERSION_2_0);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_close(gHalHandle);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+}
+
+/**
+ * @testcase        HdcpCloseN
+ * @since           HAL_MODULE_HDCP 1.0
+ * @author          SR(haesu.gwon)
+ * @reviewer        SR(gilbok)
+ * @type            auto
+ * @description     Negative, Close HDCP
+ * @apicovered      hal_hdcp_close
+ * @passcase        when hal_hdcp_open is not called and hal_hdcp_close returns HAL_HDCP_ERROR_INVALID_STATE
+ * @failcase        when hal_hdcp_close does not return HAL_HDCP_ERROR_INVALID_STATE
+ * @precondition    None
+ * @postcondition   None
+ */
+TEST_F(HdcpHalTest, HdcpCloseN1)
+{
+    gRet = hal_hdcp_close(gHalHandle);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_INVALID_STATE);
+}
+
+/**
+ * @testcase        HdcpCloseN
+ * @since           HAL_MODULE_HDCP 1.0
+ * @author          SR(haesu.gwon)
+ * @reviewer        SR(gilbok)
+ * @type            auto
+ * @description     Negative, Close HDCP
+ * @apicovered      hal_hdcp_close
+ * @passcase        when hal_hdcp_close returns HAL_HDCP_ERROR_INVALID_PARAMETER
+ * @failcase        when hal_hdcp_close does not return HAL_HDCP_ERROR_INVALID_PARAMETER
+ * @precondition    None
+ * @postcondition   None
+ */
+TEST_F(HdcpHalTest, HdcpCloseN2)
+{
+    gRet = hal_hdcp_open(gHalHandle, HAL_HDCP_DEVICE_RECEIVER, HAL_HDCP_VERSION_2_0);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_close(nullptr);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_INVALID_PARAMETER);
+}
+
+/**
+ * @testcase        HdcpStartReceiverP
+ * @since           HAL_MODULE_HDCP 1.0
+ * @author          SR(haesu.gwon)
+ * @reviewer        SR(gilbok)
+ * @type            auto
+ * @description     Positive, Start HDCP receiver
+ * @apicovered      hal_hdcp_start_receiver
+ * @passcase        when hal_hdcp_start_receiver returns HAL_HDCP_ERROR_NONE
+ * @failcase        when hal_hdcp_start_receiver does not return HAL_HDCP_ERROR_NONE
+ * @precondition    None
+ * @postcondition   None
+ */
+TEST_F(HdcpHalTest, HdcpStartReceiverP)
+{
+    uint32_t hdcp_id = 0;
+
+    gRet = hal_hdcp_open(gHalHandle, HAL_HDCP_DEVICE_RECEIVER, HAL_HDCP_VERSION_2_0);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_start_receiver(gHalHandle, 100, &hdcp_id);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_close(gHalHandle);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+}
+
+/**
+ * @testcase        HdcpStartReceiverN
+ * @since           HAL_MODULE_HDCP 1.0
+ * @author          SR(haesu.gwon)
+ * @reviewer        SR(gilbok)
+ * @type            auto
+ * @description     Negative, Start HDCP receiver
+ * @apicovered      hal_hdcp_start_receiver
+ * @passcase        when hal_hdcp_start_receiver returns HAL_HDCP_ERROR_INVALID_STATE
+ * @failcase        when hal_hdcp_start_receiver does not return HAL_HDCP_ERROR_INVALID_STATE
+ * @precondition    None
+ * @postcondition   None
+ */
+TEST_F(HdcpHalTest, HdcpStartReceiverN1)
+{
+    uint32_t hdcp_id = 0;
+
+    gRet = hal_hdcp_start_receiver(gHalHandle, 100, &hdcp_id);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_INVALID_STATE);
+}
+
+/**
+ * @testcase        HdcpStartReceiverN2
+ * @since           HAL_MODULE_HDCP 1.0
+ * @author          SR(haesu.gwon)
+ * @reviewer        SR(gilbok)
+ * @type            auto
+ * @description     Negative, Start HDCP receiver
+ * @apicovered      hal_hdcp_start_receiver
+ * @passcase        when hal_hdcp_start_receiver returns HAL_HDCP_ERROR_INVALID_PARAMETER
+ * @failcase        when hal_hdcp_start_receiver does not return HAL_HDCP_ERROR_INVALID_PARAMETER
+ * @precondition    None
+ * @postcondition   None
+ */
+TEST_F(HdcpHalTest, HdcpStartReceiverN2)
+{
+    uint32_t hdcp_id = 0;
+
+    gRet = hal_hdcp_open(gHalHandle, HAL_HDCP_DEVICE_RECEIVER, HAL_HDCP_VERSION_2_0);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_start_receiver(nullptr, 100, &hdcp_id);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_INVALID_PARAMETER);
+
+    gRet = hal_hdcp_start_receiver(gHalHandle, 100, nullptr);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_INVALID_PARAMETER);
+
+    gRet = hal_hdcp_close(gHalHandle);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+}
+
+/**
+ * @testcase        HdcpStopReceiverP
+ * @since           HAL_MODULE_HDCP 1.0
+ * @author          SR(haesu.gwon)
+ * @reviewer        SR(gilbok)
+ * @type            auto
+ * @description     Positive, Stop HDCP receiver
+ * @apicovered      hal_hdcp_stop_receiver
+ * @passcase        when hal_hdcp_stop_receiver returns HAL_HDCP_ERROR_NONE
+ * @failcase        when hal_hdcp_stop_receiver does not return HAL_HDCP_ERROR_NONE
+ * @precondition    None
+ * @postcondition   None
+ */
+TEST_F(HdcpHalTest, HdcpStopReceiverP)
+{
+    uint32_t hdcp_id = 0;
+
+    gRet = hal_hdcp_open(gHalHandle, HAL_HDCP_DEVICE_RECEIVER, HAL_HDCP_VERSION_2_0);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_start_receiver(gHalHandle, 100, &hdcp_id);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_stop_receiver(gHalHandle, hdcp_id);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_close(gHalHandle);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+}
+
+/**
+ * @testcase        HdcpStopReceiverN1
+ * @since           HAL_MODULE_HDCP 1.0
+ * @author          SR(haesu.gwon)
+ * @reviewer        SR(gilbok)
+ * @type            auto
+ * @description     Negative, Stop HDCP receiver
+ * @apicovered      hal_hdcp_stop_receiver
+ * @passcase        when hal_hdcp_stop_receiver returns HAL_HDCP_ERROR_INVALID_STATE
+ * @failcase        when hal_hdcp_stop_receiver does not return HAL_HDCP_ERROR_INVALID_STATE
+ * @precondition    None
+ * @postcondition   None
+ */
+TEST_F(HdcpHalTest, HdcpStopReceiverN1)
+{
+    uint32_t hdcp_id = 0;
+
+    gRet = hal_hdcp_stop_receiver(gHalHandle, hdcp_id);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_INVALID_STATE);
+}
+
+/**
+ * @testcase        HdcpStopReceiverN2
+ * @since           HAL_MODULE_HDCP 1.0
+ * @author          SR(haesu.gwon)
+ * @reviewer        SR(gilbok)
+ * @type            auto
+ * @description     Negative, Stop HDCP receiver
+ * @apicovered      hal_hdcp_stop_receiver
+ * @passcase        when hal_hdcp_stop_receiver returns HAL_HDCP_ERROR_INVALID_PARAMETER
+ * @failcase        when hal_hdcp_stop_receiver does not return HAL_HDCP_ERROR_INVALID_PARAMETER
+ * @precondition    None
+ * @postcondition   None
+ */
+TEST_F(HdcpHalTest, HdcpStopReceiverN2)
+{
+    uint32_t hdcp_id = 0;
+
+    gRet = hal_hdcp_open(gHalHandle, HAL_HDCP_DEVICE_RECEIVER, HAL_HDCP_VERSION_2_0);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_start_receiver(gHalHandle, 100, &hdcp_id);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_stop_receiver(nullptr, hdcp_id);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_INVALID_PARAMETER);
+
+    gRet = hal_hdcp_close(gHalHandle);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+}
+
+/**
+ * @testcase        HdcpStartTransmitterP
+ * @since           HAL_MODULE_HDCP 1.0
+ * @author          SR(haesu.gwon)
+ * @reviewer        SR(gilbok)
+ * @type            auto
+ * @description     Positive, Start HDCP transmitter
+ * @apicovered      hal_hdcp_start_transmitter
+ * @passcase        when hal_hdcp_start_transmitter returns HAL_HDCP_ERROR_NONE
+ * @failcase        when hal_hdcp_start_transmitter does not return HAL_HDCP_ERROR_NONE
+ * @precondition    None
+ * @postcondition   None
+ */
+TEST_F(HdcpHalTest, HdcpStartTransmitterP)
+{
+    uint32_t hdcp_id = 0;
+
+    gRet = hal_hdcp_open(gHalHandle, HAL_HDCP_DEVICE_RECEIVER, HAL_HDCP_VERSION_2_0);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_start_transmitter(gHalHandle, gSocketIp, gPortIp, &hdcp_id);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_close(gHalHandle);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+}
+
+/**
+ * @testcase        HdcpStartTransmitterN1
+ * @since           HAL_MODULE_HDCP 1.0
+ * @author          SR(haesu.gwon)
+ * @reviewer        SR(gilbok)
+ * @type            auto
+ * @description     Negative, Start HDCP transmitter
+ * @apicovered      hal_hdcp_start_transmitter
+ * @passcase        when hal_hdcp_start_transmitter returns HAL_HDCP_ERROR_INVALID_STATE
+ * @failcase        when hal_hdcp_start_transmitter does not return HAL_HDCP_ERROR_INVALID_STATE
+ * @precondition    None
+ * @postcondition   None
+ */
+TEST_F(HdcpHalTest, HdcpStartTransmitterN1)
+{
+    uint32_t hdcp_id = 0;
+
+    gRet = hal_hdcp_start_transmitter(gHalHandle, gSocketIp, gPortIp, &hdcp_id);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_INVALID_STATE);
+}
+
+/**
+ * @testcase        HdcpStartTransmitterN2
+ * @since           HAL_MODULE_HDCP 1.0
+ * @author          SR(haesu.gwon)
+ * @reviewer        SR(gilbok)
+ * @type            auto
+ * @description     Negative, Start HDCP transmitter
+ * @apicovered      hal_hdcp_start_transmitter
+ * @passcase        when hal_hdcp_start_transmitter returns HAL_HDCP_ERROR_INVALID_PARAMETER
+ * @failcase        when hal_hdcp_start_transmitter does not return HAL_HDCP_ERROR_INVALID_PARAMETER
+ * @precondition    None
+ * @postcondition   None
+ */
+TEST_F(HdcpHalTest, HdcpStartTransmitterN2)
+{
+    uint32_t hdcp_id = 0;
+
+    gRet = hal_hdcp_open(gHalHandle, HAL_HDCP_DEVICE_RECEIVER, HAL_HDCP_VERSION_2_0);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_start_transmitter(nullptr, gSocketIp, gPortIp, &hdcp_id);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_INVALID_PARAMETER);
+
+    gRet = hal_hdcp_close(gHalHandle);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+}
+
+/**
+ * @testcase        HdcpStopTransmitterP
+ * @since           HAL_MODULE_HDCP 1.0
+ * @author          SR(haesu.gwon)
+ * @reviewer        SR(gilbok)
+ * @type            auto
+ * @description     Positive, Stop HDCP transmitter
+ * @apicovered      hal_hdcp_stop_transmitter
+ * @passcase        when hal_hdcp_stop_transmitter returns HAL_HDCP_ERROR_NONE
+ * @failcase        when hal_hdcp_stop_transmitter does not return HAL_HDCP_ERROR_NONE
+ * @precondition    None
+ * @postcondition   None
+ */
+TEST_F(HdcpHalTest, HdcpStopTransmitterP)
+{
+    uint32_t hdcp_id = 0;
+
+    gRet = hal_hdcp_open(gHalHandle, HAL_HDCP_DEVICE_RECEIVER, HAL_HDCP_VERSION_2_0);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_start_transmitter(gHalHandle, gSocketIp, gPortIp, &hdcp_id);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_stop_transmitter(gHalHandle, hdcp_id);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_close(gHalHandle);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+}
+
+/**
+ * @testcase        HdcpStopTransmitterN1
+ * @since           HAL_MODULE_HDCP 1.0
+ * @author          SR(haesu.gwon)
+ * @reviewer        SR(gilbok)
+ * @type            auto
+ * @description     Negative, Stop HDCP transmitter
+ * @apicovered      hal_hdcp_stop_transmitter
+ * @passcase        when hal_hdcp_stop_transmitter returns HAL_HDCP_ERROR_INVALID_STATE
+ * @failcase        when hal_hdcp_stop_transmitter does not return HAL_HDCP_ERROR_INVALID_STATE
+ * @precondition    None
+ * @postcondition   None
+ */
+TEST_F(HdcpHalTest, HdcpStopTransmitterN1)
+{
+    uint32_t hdcp_id = 0;
+
+    gRet = hal_hdcp_stop_transmitter(gHalHandle, hdcp_id);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_INVALID_STATE);
+}
+
+/**
+ * @testcase        HdcpStopTransmitterN2
+ * @since           HAL_MODULE_HDCP 1.0
+ * @author          SR(haesu.gwon)
+ * @reviewer        SR(gilbok)
+ * @type            auto
+ * @description     Negative, Stop HDCP transmitter
+ * @apicovered      hal_hdcp_stop_transmitter
+ * @passcase        when hal_hdcp_stop_transmitter returns HAL_HDCP_ERROR_INVALID_PARAMETER
+ * @failcase        when hal_hdcp_stop_transmitter does not return HAL_HDCP_ERROR_INVALID_PARAMETER
+ * @precondition    None
+ * @postcondition   None
+ */
+TEST_F(HdcpHalTest, HdcpStopTransmitterN2)
+{
+    uint32_t hdcp_id = 0;
+
+    gRet = hal_hdcp_open(gHalHandle, HAL_HDCP_DEVICE_RECEIVER, HAL_HDCP_VERSION_2_0);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_start_transmitter(gHalHandle, gSocketIp, gPortIp, &hdcp_id);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_stop_transmitter(nullptr, hdcp_id);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_INVALID_PARAMETER);
+
+    gRet = hal_hdcp_close(gHalHandle);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+}
+
+/**
+ * @testcase        HdcpAllocateBufferP
+ * @since           HAL_MODULE_HDCP 1.0
+ * @author          SR(haesu.gwon)
+ * @reviewer        SR(gilbok)
+ * @type            auto
+ * @description     Positive, Allocate output buffer
+ * @apicovered      hal_hdcp_allocate_output_buffer
+ * @passcase        when hal_hdcp_allocate_output_buffer returns HAL_HDCP_ERROR_NONE
+ * @failcase        when hal_hdcp_allocate_output_buffer does not return HAL_HDCP_ERROR_NONE
+ * @precondition    None
+ * @postcondition   None
+ */
+TEST_F(HdcpHalTest, HdcpAllocateBufferP)
+{
+    uint32_t hdcp_id = 0;
+    hal_hdcp_buffer_s output;
+
+    gRet = hal_hdcp_open(gHalHandle, HAL_HDCP_DEVICE_RECEIVER, HAL_HDCP_VERSION_2_0);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_start_transmitter(gHalHandle, gSocketIp, gPortIp, &hdcp_id);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_allocate_output_buffer(gHalHandle, 1000, false, &output);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_stop_transmitter(gHalHandle, hdcp_id);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_close(gHalHandle);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+}
+
+/**
+ * @testcase        HdcpAllocateBufferN
+ * @since           HAL_MODULE_HDCP 1.0
+ * @author          SR(haesu.gwon)
+ * @reviewer        SR(gilbok)
+ * @type            auto
+ * @description     Negative, Allocate output buffer
+ * @apicovered      hal_hdcp_allocate_output_buffer
+ * @passcase        when hal_hdcp_allocate_output_buffer returns HAL_HDCP_ERROR_NONE
+ * @failcase        when hal_hdcp_allocate_output_buffer does not return HAL_HDCP_ERROR_NONE
+ * @precondition    None
+ * @postcondition   None
+ */
+TEST_F(HdcpHalTest, HdcpAllocateBufferN)
+{
+    uint32_t hdcp_id = 0;
+    hal_hdcp_buffer_s output;
+
+    gRet = hal_hdcp_open(gHalHandle, HAL_HDCP_DEVICE_RECEIVER, HAL_HDCP_VERSION_2_0);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_start_transmitter(gHalHandle, gSocketIp, gPortIp, &hdcp_id);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_allocate_output_buffer(nullptr, 1000, false, &output);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_INVALID_PARAMETER);
+
+    gRet = hal_hdcp_allocate_output_buffer(gHalHandle, 1000, false, nullptr);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_INVALID_PARAMETER);
+
+    gRet = hal_hdcp_stop_transmitter(gHalHandle, hdcp_id);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_close(gHalHandle);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+}
+
+/**
+ * @testcase        HdcpReleaseBufferP
+ * @since           HAL_MODULE_HDCP 1.0
+ * @author          SR(haesu.gwon)
+ * @reviewer        SR(gilbok)
+ * @type            auto
+ * @description     Positive, Release output buffer
+ * @apicovered      hal_hdcp_release_output_buffer
+ * @passcase        when hal_hdcp_release_output_buffer returns HAL_HDCP_ERROR_NONE
+ * @failcase        when hal_hdcp_release_output_buffer does not return HAL_HDCP_ERROR_NONE
+ * @precondition    None
+ * @postcondition   None
+ */
+TEST_F(HdcpHalTest, HdcpReleaseBufferP)
+{
+    uint32_t hdcp_id = 0;
+    hal_hdcp_buffer_s output;
+
+    gRet = hal_hdcp_open(gHalHandle, HAL_HDCP_DEVICE_RECEIVER, HAL_HDCP_VERSION_2_0);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_start_transmitter(gHalHandle, gSocketIp, gPortIp, &hdcp_id);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_allocate_output_buffer(gHalHandle, 1000, false, &output);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_release_output_buffer(gHalHandle, &output);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_stop_transmitter(gHalHandle, hdcp_id);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_close(gHalHandle);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+}
+
+/**
+ * @testcase        HdcpReleaseBufferN
+ * @since           HAL_MODULE_HDCP 1.0
+ * @author          SR(haesu.gwon)
+ * @reviewer        SR(gilbok)
+ * @type            auto
+ * @description     Negative, Release output buffer
+ * @apicovered      hal_hdcp_release_output_buffer
+ * @passcase        when hal_hdcp_release_output_buffer returns HAL_HDCP_ERROR_NONE
+ * @failcase        when hal_hdcp_release_output_buffer does not return HAL_HDCP_ERROR_NONE
+ * @precondition    None
+ * @postcondition   None
+ */
+TEST_F(HdcpHalTest, HdcpReleaseBufferN)
+{
+    uint32_t hdcp_id = 0;
+    hal_hdcp_buffer_s output;
+
+    gRet = hal_hdcp_open(gHalHandle, HAL_HDCP_DEVICE_RECEIVER, HAL_HDCP_VERSION_2_0);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_start_transmitter(gHalHandle, gSocketIp, gPortIp, &hdcp_id);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_allocate_output_buffer(gHalHandle, 1000, false, &output);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_release_output_buffer(nullptr, &output);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_INVALID_PARAMETER);
+
+    gRet = hal_hdcp_release_output_buffer(gHalHandle, nullptr);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_INVALID_PARAMETER);
+
+    gRet = hal_hdcp_stop_transmitter(gHalHandle, hdcp_id);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_close(gHalHandle);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+}
+
+/**
+ * @testcase        HdcpDecryptP
+ * @since           HAL_MODULE_HDCP 1.0
+ * @author          SR(haesu.gwon)
+ * @reviewer        SR(gilbok)
+ * @type            auto
+ * @description     Positive, Decrypt HDCP data
+ * @apicovered      hal_hdcp_decrypt
+ * @passcase        when hal_hdcp_decrypt returns HAL_HDCP_ERROR_NONE
+ * @failcase        when hal_hdcp_decrypt does not return HAL_HDCP_ERROR_NONE
+ * @precondition    None
+ * @postcondition   None
+ */
+TEST_F(HdcpHalTest, HdcpDecryptP)
+{
+    uint32_t hdcp_id = 0;
+    hal_hdcp_buffer_s input, output;
+    uint32_t decrypt_info;
+
+    gRet = hal_hdcp_open(gHalHandle, HAL_HDCP_DEVICE_RECEIVER, HAL_HDCP_VERSION_2_0);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_start_transmitter(gHalHandle, gSocketIp, gPortIp, &hdcp_id);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_allocate_output_buffer(gHalHandle, 1000, false, &output);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    input.size = 100;
+    gRet = hal_hdcp_decrypt(gHalHandle, &input, (void *)&decrypt_info, &output);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_stop_transmitter(gHalHandle, hdcp_id);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_close(gHalHandle);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+}
+
+/**
+ * @testcase        HdcpDecryptN1
+ * @since           HAL_MODULE_HDCP 1.0
+ * @author          SR(haesu.gwon)
+ * @reviewer        SR(gilbok)
+ * @type            auto
+ * @description     Negative, Decrypt HDCP data
+ * @apicovered      hal_hdcp_decrypt
+ * @passcase        when hal_hdcp_decrypt returns HAL_HDCP_ERROR_INVALID_PARAMETER
+ * @failcase        when hal_hdcp_decrypt does not return HAL_HDCP_ERROR_INVALID_PARAMETER
+ * @precondition    None
+ * @postcondition   None
+ */
+TEST_F(HdcpHalTest, HdcpDecryptN1)
+{
+    uint32_t hdcp_id = 0;
+    hal_hdcp_buffer_s output;
+    int decrypt_info;
+
+    gRet = hal_hdcp_open(gHalHandle, HAL_HDCP_DEVICE_RECEIVER, HAL_HDCP_VERSION_2_0);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_start_transmitter(gHalHandle, gSocketIp, gPortIp, &hdcp_id);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_decrypt(gHalHandle, nullptr, (void *)&decrypt_info, &output);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_INVALID_PARAMETER);
+
+    gRet = hal_hdcp_stop_transmitter(gHalHandle, hdcp_id);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_close(gHalHandle);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+}
+
+/**
+ * @testcase        HdcpEncryptP
+ * @since           HAL_MODULE_HDCP 1.0
+ * @author          SR(haesu.gwon)
+ * @reviewer        SR(gilbok)
+ * @type            auto
+ * @description     Positive, Encrypt HDCP data
+ * @apicovered      hal_hdcp_encrypt
+ * @passcase        when hal_hdcp_encrypt returns HAL_HDCP_ERROR_NONE
+ * @failcase        when hal_hdcp_encrypt does not return HAL_HDCP_ERROR_NONE
+ * @precondition    None
+ * @postcondition   None
+ */
+TEST_F(HdcpHalTest, HdcpEncryptP)
+{
+    uint32_t hdcp_id = 0;
+    hal_hdcp_buffer_s input, output;
+    uint32_t encrypt_info;
+
+    gRet = hal_hdcp_open(gHalHandle, HAL_HDCP_DEVICE_RECEIVER, HAL_HDCP_VERSION_2_0);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_start_transmitter(gHalHandle, gSocketIp, gPortIp, &hdcp_id);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_allocate_output_buffer(gHalHandle, 1000, false, &output);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    input.size = 100;
+    gRet = hal_hdcp_encrypt(gHalHandle, &input, hdcp_id, (void *)&encrypt_info, &output);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_stop_transmitter(gHalHandle, hdcp_id);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_close(gHalHandle);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+}
+
+/**
+ * @testcase        HdcpEncryptN1
+ * @since           HAL_MODULE_HDCP 1.0
+ * @author          SR(haesu.gwon)
+ * @reviewer        SR(gilbok)
+ * @type            auto
+ * @description     Negative, Encrypt HDCP data
+ * @apicovered      hal_hdcp_encrypt
+ * @passcase        when hal_hdcp_encrypt returns HAL_HDCP_ERROR_INVALID_PARAMETER
+ * @failcase        when hal_hdcp_encrypt does not return HAL_HDCP_ERROR_INVALID_PARAMETER
+ * @precondition    None
+ * @postcondition   None
+ */
+TEST_F(HdcpHalTest, HdcpEncryptN1)
+{
+    uint32_t hdcp_id = 0;
+    hal_hdcp_buffer_s input, output;
+    uint32_t encrypt_info;
+    input.size = 100;
+
+    gRet = hal_hdcp_open(gHalHandle, HAL_HDCP_DEVICE_RECEIVER, HAL_HDCP_VERSION_2_0);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_start_transmitter(gHalHandle, gSocketIp, gPortIp, &hdcp_id);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_encrypt(gHalHandle, nullptr, hdcp_id, (void *)&encrypt_info, &output);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_INVALID_PARAMETER);
+
+    gRet = hal_hdcp_encrypt(gHalHandle, &input, hdcp_id, nullptr, &output);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_INVALID_PARAMETER);
+
+    gRet = hal_hdcp_encrypt(gHalHandle, &input, hdcp_id, (void *)&encrypt_info, nullptr);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_INVALID_PARAMETER);
+
+    gRet = hal_hdcp_stop_transmitter(gHalHandle, hdcp_id);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+    gRet = hal_hdcp_close(gHalHandle);
+    ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+}
+
+int main(int argc, char **argv)
+{
+    testing::InitGoogleTest(&argc, argv);
+
+    return RUN_ALL_TESTS();
+}