Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 33254105 authored by Shraddha Basantwani's avatar Shraddha Basantwani
Browse files

CEC: Add implementation of getPortInfo method to default HdmiCec

Bug: 185434120
Test: manual
Change-Id: Icb12d161304559b12723900192482173c6280052
parent 0dacc5cd
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ cc_library_shared {
        "libhidlbase",
        "liblog",
        "libbase",
        "libcutils",
        "libutils",
        "libhardware",
        "android.hardware.tv.cec@1.0",
+16 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#define LOG_TAG "android.hardware.tv.cec@1.0-impl"
#include <android-base/logging.h>

#include <cutils/properties.h>
#include <errno.h>
#include <fcntl.h>
#include <linux/cec.h>
@@ -119,7 +120,21 @@ Return<uint32_t> HdmiCecDefault::getVendorId() {
    return 0;
}

Return<void> HdmiCecDefault::getPortInfo(getPortInfo_cb /*_hidl_cb*/) {
Return<void> HdmiCecDefault::getPortInfo(getPortInfo_cb callback) {
    uint16_t addr;
    int ret = ioctl(mCecFd, CEC_ADAP_G_PHYS_ADDR, &addr);
    if (ret) {
        LOG(ERROR) << "Get port info failed, Error = " << strerror(errno);
    }

    unsigned int type = property_get_int32("ro.hdmi.device_type", CEC_DEVICE_PLAYBACK);
    hidl_vec<HdmiPortInfo> portInfos(1);
    portInfos[0] = {.type = (type == CEC_DEVICE_TV ? HdmiPortType::INPUT : HdmiPortType::OUTPUT),
                    .portId = 1,
                    .cecSupported = true,
                    .arcSupported = false,
                    .physicalAddress = addr};
    callback(portInfos);
    return Void();
}