Search in sources :

Example 6 with HdmiDeviceInfo

use of android.hardware.hdmi.HdmiDeviceInfo in project platform_frameworks_base by android.

the class HdmiControlService method initPortInfo.

// Initialize HDMI port information. Combine the information from CEC and MHL HAL and
// keep them in one place.
@ServiceThreadOnly
private void initPortInfo() {
    assertRunOnServiceThread();
    HdmiPortInfo[] cecPortInfo = null;
    // each port. Return empty array if CEC HAL didn't provide the info.
    if (mCecController != null) {
        cecPortInfo = mCecController.getPortInfos();
    }
    if (cecPortInfo == null) {
        return;
    }
    SparseArray<HdmiPortInfo> portInfoMap = new SparseArray<>();
    SparseIntArray portIdMap = new SparseIntArray();
    SparseArray<HdmiDeviceInfo> portDeviceMap = new SparseArray<>();
    for (HdmiPortInfo info : cecPortInfo) {
        portIdMap.put(info.getAddress(), info.getId());
        portInfoMap.put(info.getId(), info);
        portDeviceMap.put(info.getId(), new HdmiDeviceInfo(info.getAddress(), info.getId()));
    }
    mPortIdMap = new UnmodifiableSparseIntArray(portIdMap);
    mPortInfoMap = new UnmodifiableSparseArray<>(portInfoMap);
    mPortDeviceMap = new UnmodifiableSparseArray<>(portDeviceMap);
    HdmiPortInfo[] mhlPortInfo = mMhlController.getPortInfos();
    ArraySet<Integer> mhlSupportedPorts = new ArraySet<Integer>(mhlPortInfo.length);
    for (HdmiPortInfo info : mhlPortInfo) {
        if (info.isMhlSupported()) {
            mhlSupportedPorts.add(info.getId());
        }
    }
    // cec port info if we do not have have port that supports MHL.
    if (mhlSupportedPorts.isEmpty()) {
        mPortInfo = Collections.unmodifiableList(Arrays.asList(cecPortInfo));
        return;
    }
    ArrayList<HdmiPortInfo> result = new ArrayList<>(cecPortInfo.length);
    for (HdmiPortInfo info : cecPortInfo) {
        if (mhlSupportedPorts.contains(info.getId())) {
            result.add(new HdmiPortInfo(info.getId(), info.getType(), info.getAddress(), info.isCecSupported(), true, info.isArcSupported()));
        } else {
            result.add(info);
        }
    }
    mPortInfo = Collections.unmodifiableList(result);
}
Also used : HdmiDeviceInfo(android.hardware.hdmi.HdmiDeviceInfo) ArraySet(android.util.ArraySet) HdmiPortInfo(android.hardware.hdmi.HdmiPortInfo) ArrayList(java.util.ArrayList) SparseArray(android.util.SparseArray) SparseIntArray(android.util.SparseIntArray) ServiceThreadOnly(com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly)

Example 7 with HdmiDeviceInfo

use of android.hardware.hdmi.HdmiDeviceInfo in project platform_frameworks_base by android.

the class RoutingControlAction method handleTimerEvent.

@Override
public void handleTimerEvent(int timeoutState) {
    if (mState != timeoutState || mState == STATE_NONE) {
        Slog.w("CEC", "Timer in a wrong state. Ignored.");
        return;
    }
    switch(timeoutState) {
        case STATE_WAIT_FOR_ROUTING_INFORMATION:
            HdmiDeviceInfo device = tv().getDeviceInfoByPath(mCurrentRoutingPath);
            if (device != null && mQueryDevicePowerStatus) {
                int deviceLogicalAddress = device.getLogicalAddress();
                queryDevicePowerStatus(deviceLogicalAddress, new SendMessageCallback() {

                    @Override
                    public void onSendCompleted(int error) {
                        handlDevicePowerStatusAckResult(error == HdmiControlManager.RESULT_SUCCESS);
                    }
                });
            } else {
                updateActiveInput();
                finishWithCallback(HdmiControlManager.RESULT_SUCCESS);
            }
            return;
        case STATE_WAIT_FOR_REPORT_POWER_STATUS:
            if (isPowerOnOrTransient(getTvPowerStatus())) {
                updateActiveInput();
                sendSetStreamPath();
            }
            finishWithCallback(HdmiControlManager.RESULT_SUCCESS);
            return;
    }
}
Also used : HdmiDeviceInfo(android.hardware.hdmi.HdmiDeviceInfo) SendMessageCallback(com.android.server.hdmi.HdmiControlService.SendMessageCallback)

Example 8 with HdmiDeviceInfo

use of android.hardware.hdmi.HdmiDeviceInfo in project platform_frameworks_base by android.

the class HdmiControlService method updateSafeMhlInput.

@ServiceThreadOnly
private void updateSafeMhlInput() {
    assertRunOnServiceThread();
    List<HdmiDeviceInfo> inputs = Collections.emptyList();
    SparseArray<HdmiMhlLocalDeviceStub> devices = mMhlController.getAllLocalDevices();
    for (int i = 0; i < devices.size(); ++i) {
        HdmiMhlLocalDeviceStub device = devices.valueAt(i);
        HdmiDeviceInfo info = device.getInfo();
        if (info != null) {
            if (inputs.isEmpty()) {
                inputs = new ArrayList<>();
            }
            inputs.add(device.getInfo());
        }
    }
    synchronized (mLock) {
        mMhlDevices = inputs;
    }
}
Also used : HdmiDeviceInfo(android.hardware.hdmi.HdmiDeviceInfo) ServiceThreadOnly(com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly)

Example 9 with HdmiDeviceInfo

use of android.hardware.hdmi.HdmiDeviceInfo in project platform_frameworks_base by android.

the class HotplugDetectionAction method checkHotplug.

private void checkHotplug(List<Integer> ackedAddress, boolean audioOnly) {
    BitSet currentInfos = infoListToBitSet(tv().getDeviceInfoList(false), audioOnly);
    BitSet polledResult = addressListToBitSet(ackedAddress);
    // At first, check removed devices.
    BitSet removed = complement(currentInfos, polledResult);
    int index = -1;
    while ((index = removed.nextSetBit(index + 1)) != -1) {
        if (index == Constants.ADDR_AUDIO_SYSTEM) {
            HdmiDeviceInfo avr = tv().getAvrDeviceInfo();
            if (avr != null && tv().isConnected(avr.getPortId())) {
                ++mAvrStatusCount;
                Slog.w(TAG, "Ack not returned from AVR. count: " + mAvrStatusCount);
                if (mAvrStatusCount < AVR_COUNT_MAX) {
                    continue;
                }
            }
        }
        Slog.v(TAG, "Remove device by hot-plug detection:" + index);
        removeDevice(index);
    }
    // Reset the counter if the ack is returned from AVR.
    if (!removed.get(Constants.ADDR_AUDIO_SYSTEM)) {
        mAvrStatusCount = 0;
    }
    // Next, check added devices.
    BitSet added = complement(polledResult, currentInfos);
    index = -1;
    while ((index = added.nextSetBit(index + 1)) != -1) {
        Slog.v(TAG, "Add device by hot-plug detection:" + index);
        addDevice(index);
    }
}
Also used : HdmiDeviceInfo(android.hardware.hdmi.HdmiDeviceInfo) BitSet(java.util.BitSet)

Example 10 with HdmiDeviceInfo

use of android.hardware.hdmi.HdmiDeviceInfo in project platform_frameworks_base by android.

the class PowerStatusMonitorAction method queryPowerStatus.

private void queryPowerStatus() {
    List<HdmiDeviceInfo> deviceInfos = tv().getDeviceInfoList(false);
    resetPowerStatus(deviceInfos);
    for (HdmiDeviceInfo info : deviceInfos) {
        final int logicalAddress = info.getLogicalAddress();
        sendCommand(HdmiCecMessageBuilder.buildGiveDevicePowerStatus(getSourceAddress(), logicalAddress), new SendMessageCallback() {

            @Override
            public void onSendCompleted(int error) {
                // update power status into UNKNOWN.
                if (error != Constants.SEND_RESULT_SUCCESS) {
                    updatePowerStatus(logicalAddress, POWER_STATUS_UNKNOWN, true);
                }
            }
        });
    }
    mState = STATE_WAIT_FOR_REPORT_POWER_STATUS;
    // Add both timers, monitoring and timeout.
    addTimer(STATE_WAIT_FOR_NEXT_MONITORING, MONITIROING_INTERNAL_MS);
    addTimer(STATE_WAIT_FOR_REPORT_POWER_STATUS, REPORT_POWER_STATUS_TIMEOUT_MS);
}
Also used : HdmiDeviceInfo(android.hardware.hdmi.HdmiDeviceInfo) SendMessageCallback(com.android.server.hdmi.HdmiControlService.SendMessageCallback)

Aggregations

HdmiDeviceInfo (android.hardware.hdmi.HdmiDeviceInfo)172 ServiceThreadOnly (com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly)110 ArrayList (java.util.ArrayList)15 TvInputHardwareInfo (android.media.tv.TvInputHardwareInfo)12 HdmiPortInfo (android.hardware.hdmi.HdmiPortInfo)10 SendMessageCallback (com.android.server.hdmi.HdmiControlService.SendMessageCallback)10 IHdmiControlCallback (android.hardware.hdmi.IHdmiControlCallback)5 RemoteException (android.os.RemoteException)5 ArraySet (android.util.ArraySet)5 SparseArray (android.util.SparseArray)5 SparseIntArray (android.util.SparseIntArray)5 InputChannel (android.view.InputChannel)5 SomeArgs (com.android.internal.os.SomeArgs)5 DeviceDiscoveryCallback (com.android.server.hdmi.DeviceDiscoveryAction.DeviceDiscoveryCallback)5 AllocateAddressCallback (com.android.server.hdmi.HdmiCecController.AllocateAddressCallback)5 ActiveSource (com.android.server.hdmi.HdmiCecLocalDevice.ActiveSource)5 UnsupportedEncodingException (java.io.UnsupportedEncodingException)5 BitSet (java.util.BitSet)5 TvInputInfo (android.media.tv.TvInputInfo)4 Message (android.os.Message)4