Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable media hdcp #27

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion daemon/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ include $(CLEAR_VARS)

LOCAL_CPPFLAGS := \
-DANDROID \
-DUSES_IA_HWCOMPOSER \
-DANDROID_VERSION=800 \
-DLOG_TAG=\"HDCPD\"

Expand Down Expand Up @@ -60,7 +61,8 @@ LOCAL_SHARED_LIBRARIES := \
liblog \
libcrypto \
libdrm \
libssl
libssl \
libhwcservice

LOCAL_STATIC_LIBRARIES := \
libhdcpcommon \
Expand Down
16 changes: 14 additions & 2 deletions daemon/portmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,7 @@ int32_t PortManager::EnablePort(
{
HDCP_FUNCTION_ENTER;

HDCP_NORMALMESSAGE("level %d", level);
DrmObject *drmObject = GetDrmObjectByPortId(portId);
if (nullptr == drmObject ||
DRM_MODE_DISCONNECTED == drmObject->GetConnection())
Expand All @@ -731,6 +732,7 @@ int32_t PortManager::EnablePort(

bool type1Capable =
(UINT32_MAX != drmObject->GetPropertyId(CP_CONTENT_TYPE));
HDCP_NORMALMESSAGE("type1Capable %d", type1Capable);

if (!type1Capable)
{
Expand All @@ -749,6 +751,7 @@ int32_t PortManager::EnablePort(
// if level == 2, then content type == 1 means enabled,
// content type == 0 means upgrade to type 1.
uint8_t currCpType = drmObject->GetCpType();
HDCP_NORMALMESSAGE("currCpType %d", currCpType);
if (CP_TYPE_INVALID != currCpType && (uint32_t)(level - 1) <= currCpType)
{
drmObject->AddRefAppId(appId);
Expand All @@ -767,6 +770,7 @@ int32_t PortManager::EnablePort(
default : break;
}

HDCP_NORMALMESSAGE("cpType %d", cpType);
// Set CP_Content_Type property, try at most AUTH_NUM_RETRY times
ret = SetPortProperty(
drmObject->GetDrmId(),
Expand All @@ -787,6 +791,7 @@ int32_t PortManager::EnablePort(
// The port hasn't been enabled so far
// Set Content Protection property, try at most AUTH_NUM_RETRY times
uint8_t cpValue = CP_DESIRED;
HDCP_NORMALMESSAGE("cpValue %d", cpValue);
ret = SetPortProperty(
drmObject->GetDrmId(),
drmObject->GetPropertyId(CONTENT_PROTECTION),
Expand Down Expand Up @@ -1417,7 +1422,10 @@ int32_t PortManagerHWComposer::SetPortProperty(
{
HDCP_FUNCTION_ENTER;

HDCP_NORMALMESSAGE("PortManagerHWComposer::SetPortProperty");
int32_t ret = EINVAL;
uint8_t propValue = 0;
static uint8_t typeValue = 0;

DrmObject *drmObject = GetDrmObjectByDrmId(drmId);
if (nullptr == drmObject)
Expand All @@ -1432,11 +1440,14 @@ int32_t PortManagerHWComposer::SetPortProperty(
return ENOENT;
}

uint8_t propValue = *value;
propValue = *value;
if (propId == drmObject->GetPropertyId(CP_CONTENT_TYPE))
typeValue = *value;

android::ProcessState::initWithDriver(BINDER_IPC);

#ifdef USES_IA_HWCOMPOSER
HDCP_NORMALMESSAGE("PortManagerHWComposer::SetPortProperty hwcService_Connect");
// Connect to HWC service
HWCSHANDLE hwcs = HwcService_Connect();
if (nullptr == hwcs)
Expand All @@ -1457,12 +1468,13 @@ int32_t PortManagerHWComposer::SetPortProperty(
{
HDCP_NORMALMESSAGE("Set content protection property (on) via HWC");
ret = HwcService_Video_EnableHDCPSession_ForDisplay(hwcs, drmId,
(EHwcsContentType)propValue);
(EHwcsContentType)typeValue);
}
else if (propId == drmObject->GetPropertyId(CP_CONTENT_TYPE))
{
// This is only for HDCP2.2
HDCP_NORMALMESSAGE("Set content type property via HWC");
HDCP_NORMALMESSAGE("Set content type property via HWC, propVlue = %d", propValue);
ret = HwcService_Video_EnableHDCPSession_ForDisplay(hwcs, drmId,
(EHwcsContentType)propValue);
}
Expand Down
10 changes: 8 additions & 2 deletions daemon/portmanager_android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,13 @@
drmObject->GetPropertyId(CONTENT_PROTECTION))
{
*cpValue = properties->prop_values[i];
HDCP_ASSERTMESSAGE("Get properties cpvalue ", *cpValue);
}
else if (properties->props[i] ==
drmObject->GetPropertyId(CP_CONTENT_TYPE))
{
*cpType = properties->prop_values[i];
HDCP_ASSERTMESSAGE("Get properties cpType ", *cpType);
}
}

Expand Down Expand Up @@ -110,6 +112,7 @@ int32_t setPortProperty_hwcservice(int32_t m_DrmFd,
// If the size isn't sizeof(uint8_t), it means SRM data, need create blob
// then set the blob id by drmModeConnectorSetProperty

HDCP_ASSERTMESSAGE("setPortProperty_hwcservice");
int ret = EINVAL;
uint32_t propValue;
if (sizeof(uint8_t) != size)
Expand Down Expand Up @@ -156,13 +159,15 @@ int32_t setPortProperty_hwcservice(int32_t m_DrmFd,
#ifdef USES_IA_HWCOMPOSER
if(propId == drmObject->GetPropertyId(CONTENT_PROTECTION))
{
HDCP_ASSERTMESSAGE("Attempting HDCP Enable");
HDCP_ASSERTMESSAGE("Attempting HDCP Enable, value =%d", value);
HDCP_ASSERTMESSAGE("Attempting HDCP Enable, propValue =%d", propValue);
ret = HwcService_Video_EnableHDCPSession_ForDisplay(
hwcs, drmId, (EHwcsContentType)propValue);
} else if(propId == drmObject->GetPropertyId(CP_CONTENT_TYPE))
{
//This is only for HDCP2.2
HDCP_ASSERTMESSAGE("Attempting HDCP Enable Type 1");
HDCP_ASSERTMESSAGE("Attempting HDCP Enable Type, value =%d", value);
HDCP_ASSERTMESSAGE("Attempting HDCP Enable Type, propValue =%d", propValue);
ret = HwcService_Video_EnableHDCPSession_ForDisplay(
hwcs, drmId, (EHwcsContentType)propValue);
} else if(propId == drmObject->GetPropertyId(CP_SRM))
Expand All @@ -172,6 +177,7 @@ int32_t setPortProperty_hwcservice(int32_t m_DrmFd,
(const int8_t *)&value, size);
} else
{
HDCP_ASSERTMESSAGE("Hwc disconnect");
HwcService_Disconnect(hwcs);
hwcs = NULL;
ret = EINVAL;
Expand Down
23 changes: 23 additions & 0 deletions test/Android.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#
# Copyright (c) 2009-2018, Intel Corporation
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.

# Recursively call sub-folder Android.mk
include $(call all-subdir-makefiles)
22 changes: 22 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright (c) 2020, Intel Corporation
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.


add_subdirectory(hdcpTestUtility)
75 changes: 75 additions & 0 deletions test/hdcpTestUtility/Android.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#
# Copyright (c) 2009-2018, Intel Corporation
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

# For ALOGV and enter/exit log, set ENABLE_DEBUG=1 during compilation e.g. mm ENABLE_DEBUG=1 -j32
LOCAL_CPPFLAGS += \
-DANDROID \
-DANDROID_VERSION=800 \
-DLOG_TAG=\"HDCPTESTUTILITY\"

# LOG_CONSOLE will print ALOGI, ALOGE, ALOGW in Android. Enable on debug build
ifeq ($(TARGET_BUILD_VARIANT),userdebug)
LOCAL_CPPFLAGS += -DLOG_CONSOLE
endif

# For ALOGV and function enter/exit log, set ENABLE_DEBUG=1 during compilation e.g. mm ENABLE_DEBUG=1 -j32
ifeq ($(ENABLE_DEBUG),1)
LOCAL_CPPFLAGS += \
-DHDCP_USE_VERBOSE_LOGGING \
-DHDCP_USE_FUNCTION_LOGGING \
-DHDCP_USE_LINK_FUNCTION_LOGGING
endif

ifeq ($(ENABLE_DEBUG),1)
LOCAL_CPPFLAG += \
-DLOG_CONSOLE \
-DHDCP_USE_VERBOSE_LOGGING \
-DHDCP_USE_FUNCTION_LOGGING \
-DHDCP_USE_LINK_FUNCTION_LOGGING
endif

#WA
LOCAL_CPPFLAGS += \
-Wno-unused-parameter \
-Wno-error

LOCAL_C_INCLUDES += \
$(LOCAL_PATH)/../../sdk \
$(LOCAL_PATH)/../../test/hdcpTestUtility \

LOCAL_SRC_FILES := \
hdcpTestUtility.cpp \

LOCAL_SHARED_LIBRARIES := \
libutils \
liblog \
libhdcpsdk \

LOCAL_EXPORT_C_INCLUDE_DIRS = \
$(LOCAL_PATH)/

LOCAL_MODULE := hdcpTestUtility
LOCAL_PROPRIETARY_MODULE := true

include $(BUILD_EXECUTABLE)
30 changes: 30 additions & 0 deletions test/hdcpTestUtility/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright (c) 2020, Intel Corporation
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.

project(hdcpTestUtility CXX)

get_filename_component(HDCP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../.." REALPATH)
include_directories(${HDCP_DIR}/sdk)

add_executable(${PROJECT_NAME} hdcpTestUtility.cpp)

target_compile_options(${PROJECT_NAME} PRIVATE ${HDCP_CXX_FLAGS})

target_link_libraries(${PROJECT_NAME} hdcpsdk)
Loading