Skip to content
Open
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
7 changes: 7 additions & 0 deletions Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ cc_defaults {
"libsync",
"libui",
"libutils",
"libbinder",
"libhwcservice",
],

include_dirs: ["vendor/intel/external/drm-hwcomposer"],
Expand All @@ -68,6 +70,10 @@ cc_defaults {
"-DHWC2_USE_CPP11",
"-std=c++17",
"-DUSE_IMAPPER4_METADATA_API",
"-Wno-unused-parameter",
"-Wno-unused-private-field",
"-Wno-unused-function",
"-frtti",
],

product_variables: {
Expand Down Expand Up @@ -111,6 +117,7 @@ filegroup {
"hwc2_device/HwcDisplayConfigs.cpp",
"hwc2_device/HwcLayer.cpp",
"hwc2_device/hwc2_device.cpp",
"hwc2_device/hwcservice.cpp",
],
}

Expand Down
69 changes: 69 additions & 0 deletions drm/DrmAtomicStateManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -675,4 +675,73 @@ auto DrmAtomicStateManager::SetColorBrightnessContrast(void) ->int{

return 0;
}

void DrmAtomicStateManager::SetHDCPState(HWCContentProtection state,
HWCContentType content_type) {
uint64_t value = 3;
uint64_t type = 3;
int ret =0;

auto *connector = pipe_->connector->Get();

if (!connector->IsConnected())
return;

desired_protection_support_ = state;

if (desired_protection_support_ == current_protection_support_)
return;

if (pipe_->connector->Get()->GetHdcpTypeProperty().id() <= 0) {
ALOGE("Cannot set HDCP state as Type property is not supported \n");
return;
}

std::tie(ret, type) = pipe_->connector->Get()->GetHdcpTypeProperty().value();

if ((content_type < 2) && (content_type_ != content_type)) {
content_type_ = content_type;

drmModeConnectorSetProperty(pipe_->device->GetFd(),
pipe_->connector->Get()->GetId(),
pipe_->connector->Get()->GetHdcpTypeProperty().id(),
content_type);

}

if (pipe_->connector->Get()->GetHdcpProperty().id() <= 0) {
ALOGE("Cannot set HDCP state as Connector property is not supported \n");
return;
}

std::tie(ret, value) = pipe_->connector->Get()->GetHdcpProperty().value();

if (value < 3) {
switch (value) {
case 0:
current_protection_support_ = hwcomposer::HWCContentProtection::kUnDesired;
break;
case 1:
current_protection_support_ = hwcomposer::HWCContentProtection::kDesired;
break;
default:
ALOGE("%s GetHDCPConnectorProperty default", __FUNCTION__);
break;
}
}

if (desired_protection_support_ == HWCContentProtection::kUnSupported) {
desired_protection_support_ = current_protection_support_;
}

current_protection_support_ = desired_protection_support_;
if (current_protection_support_ == kDesired) {
value = 1;
}

drmModeConnectorSetProperty(pipe_->device->GetFd(),
pipe_->connector->Get()->GetId(),
pipe_->connector->Get()->GetHdcpProperty().id(),
value);
}
} // namespace android
8 changes: 8 additions & 0 deletions drm/DrmAtomicStateManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ class DrmAtomicStateManager {
uint32_t brightness_c) ->int;
auto ApplyPendingLUT(struct drm_color_lut *lut, uint64_t lut_size) -> int;

void SetHDCPState(HWCContentProtection state,
HWCContentType content_type);
private:
auto CommitFrame(AtomicCommitArgs &args) -> int;

Expand Down Expand Up @@ -156,6 +158,12 @@ class DrmAtomicStateManager {
int frames_staged_{};
int frames_tracked_{};
bool hdr_mdata_set_ = false;

hwcomposer::HWCContentProtection current_protection_support_ =
hwcomposer::HWCContentProtection::kUnSupported;
hwcomposer::HWCContentProtection desired_protection_support_ =
hwcomposer::HWCContentProtection::kUnSupported;
hwcomposer::HWCContentType content_type_ = hwcomposer::kCONTENT_TYPE0;
};

} // namespace android
Expand Down
8 changes: 8 additions & 0 deletions drm/DrmConnector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ auto DrmConnector::CreateInstance(DrmDevice &dev, uint32_t connector_id,
auto c = std::unique_ptr<DrmConnector>(
new DrmConnector(std::move(conn), &dev, index));

if (!GetConnectorProperty(dev, *c, "Content Protection", &c->hdcp_id_property_)) {
ALOGE("%s GetHDCPConnectorProperty check failed!", __FUNCTION__);
}

if (!GetConnectorProperty(dev, *c, "HDCP Content Type", &c->hdcp_type_property_)) {
ALOGE("%s GetHDCPTypeProperty check failed!", __FUNCTION__);
}

if (!GetConnectorProperty(dev, *c, "DPMS", &c->dpms_property_) ||
!GetConnectorProperty(dev, *c, "CRTC_ID", &c->crtc_id_property_) ||
(dev.IsHdrSupportedDevice() && !GetConnectorProperty(dev, *c, "HDR_OUTPUT_METADATA", &c->hdr_op_metadata_prop_))) {
Expand Down
13 changes: 12 additions & 1 deletion drm/DrmConnector.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "DrmUnique.h"
#include "utils/hdr_metadata_defs.h"
#include "utils/cta_hdr_defs.h"
#include "utils/hwcdefs.h"

namespace android {

Expand Down Expand Up @@ -114,6 +115,13 @@ class DrmConnector : public PipelineBindable<DrmConnector> {
return hdr_metadata_;
}

auto &GetHdcpProperty() const {
return hdcp_id_property_;
}

auto &GetHdcpTypeProperty() const {
return hdcp_type_property_;
}

auto IsConnected() const {
return connector_->connection == DRM_MODE_CONNECTED;
Expand Down Expand Up @@ -144,7 +152,8 @@ class DrmConnector : public PipelineBindable<DrmConnector> {

void PrepareHdrMetadata(hdr_md *layer_hdr_metadata,
struct hdr_output_metadata *final_hdr_metadata);

void SetHDCPState(hwcomposer::HWCContentProtection state,
hwcomposer::HWCContentType content_type);
const DrmProperty &link_status_property() const;
private:
DrmConnector(DrmModeConnectorUnique connector, DrmDevice *drm, uint32_t index)
Expand All @@ -167,6 +176,8 @@ class DrmConnector : public PipelineBindable<DrmConnector> {
DrmProperty writeback_fb_id_;
DrmProperty writeback_out_fence_;
DrmProperty link_status_property_;
DrmProperty hdcp_id_property_;
DrmProperty hdcp_type_property_;

uint32_t preferred_mode_id_{};
//hdr_output_metadata property
Expand Down
1 change: 1 addition & 0 deletions drm/DrmDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "DrmEncoder.h"
#include "DrmFbImporter.h"
#include "utils/UniqueFd.h"
#include "utils/hwcdefs.h"

#define DRM_FORMAT_NV12_Y_TILED_INTEL fourcc_code('9', '9', '9', '6')
namespace android {
Expand Down
16 changes: 15 additions & 1 deletion drm/ResourceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

#include <ctime>
#include <sstream>
#include <binder/IPCThreadState.h>
#include <binder/ProcessState.h>

#include "bufferinfo/BufferInfoGetter.h"
#include "drm/DrmAtomicStateManager.h"
Expand Down Expand Up @@ -177,10 +179,22 @@ void ResourceManager::Init() {
});

UpdateFrontendDisplays();

pt_ = std::thread(&ResourceManager::HwcServiceThread, this);
initialized_ = true;
}

void ResourceManager::HwcServiceThread() {
this->hwcService_.Start((DrmHwcTwo*)frontend_interface_);
sp<ProcessState> proc(ProcessState::self());
if (!proc.get())
{
ALOGE("Error: Fail to new ProcessState.");
return;
}
proc->startThreadPool();
IPCThreadState::self()->joinThreadPool();
}

void ResourceManager::DeInit() {
if (!initialized_) {
ALOGE("Not initialized");
Expand Down
4 changes: 4 additions & 0 deletions drm/ResourceManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "DrmDisplayPipeline.h"
#include "DrmFbImporter.h"
#include "UEventListener.h"
#include "hwc2_device/hwcservice.h"

namespace android {
class HwcDisplay;
Expand Down Expand Up @@ -64,6 +65,7 @@ class ResourceManager {
void UpdateFrontendDisplays();
void DetachAllFrontendDisplays();
void ReloadNode();
void HwcServiceThread();

std::vector<std::unique_ptr<DrmDevice>> drms_;

Expand All @@ -81,6 +83,8 @@ class ResourceManager {
bool initialized_{};
int card_num_ = 0;
bool reloaded_{};
android::HwcService hwcService_;
std::thread pt_;
};
} // namespace android

Expand Down
47 changes: 47 additions & 0 deletions hwc2_device/DrmHwcTwo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,53 @@ void DrmHwcTwo::SendHotplugEventToClient(hwc2_display_t displayid,
}
}

void DrmHwcTwo::EnableHDCPSessionForDisplay(uint32_t connector,
EHwcsContentType content_type) {
HWCContentType type = kCONTENT_TYPE0;

if (content_type == HWCS_CP_CONTENT_TYPE1) {
type = kCONTENT_TYPE1;
}

size_t size = displays_.size();
for (size_t i = 0; i < size; i++) {
if (displays_[i]-> GetPipe().connector->Get()->GetId()== connector) {
displays_[i]->GetPipe().atomic_state_manager->SetHDCPState(HWCContentProtection::kDesired, type);
}
}
}

void DrmHwcTwo::EnableHDCPSessionForAllDisplays(EHwcsContentType content_type) {
HWCContentType type = kCONTENT_TYPE0;

if (content_type == HWCS_CP_CONTENT_TYPE1) {
type = kCONTENT_TYPE1;
}

size_t size = displays_.size();
for (size_t i = 0; i < size; i++) {
displays_[i]->GetPipe().atomic_state_manager->SetHDCPState(HWCContentProtection::kDesired, type);
}
}

void DrmHwcTwo::DisableHDCPSessionForDisplay(uint32_t connector) {
size_t size = displays_.size();
for (size_t i = 0; i < size; i++) {
if (displays_[i]->GetPipe().connector->Get()->GetId() == connector) {
displays_[i]->GetPipe().atomic_state_manager->SetHDCPState(HWCContentProtection::kUnDesired,
HWCContentType::kInvalid);
}
}
}

void DrmHwcTwo::DisableHDCPSessionForAllDisplays() {
size_t size = displays_.size();
for (size_t i = 0; i < size; i++) {
displays_[i]->GetPipe().atomic_state_manager->SetHDCPState(HWCContentProtection::kUnDesired,
HWCContentType::kInvalid);
}
}

void DrmHwcTwo::SendVsyncEventToClient(
hwc2_display_t displayid, int64_t timestamp,
[[maybe_unused]] uint32_t vsync_period) const {
Expand Down
8 changes: 8 additions & 0 deletions hwc2_device/DrmHwcTwo.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ class DrmHwcTwo : public PipelineToFrontendBindingInterface {
void SendVsyncPeriodTimingChangedEventToClient(hwc2_display_t displayid,
int64_t timestamp) const;

void EnableHDCPSessionForDisplay(uint32_t connector,
EHwcsContentType content_type);

void EnableHDCPSessionForAllDisplays(EHwcsContentType content_type);

void DisableHDCPSessionForDisplay(uint32_t connector);

void DisableHDCPSessionForAllDisplays();
private:
void SendHotplugEventToClient(hwc2_display_t displayid, bool connected);

Expand Down
Loading
Loading