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);
}
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;
}
}
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;
}
}
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);
}
}
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);
}
Aggregations