std::shared_ptr<XmlNode> DisplayControlCapabilitiesArbitrator::getArbitrationXmlForPolicy(UIntN policyIndex) const
{
	auto requestRoot = XmlNode::createWrapperElement("display_control_capabilities_arbitrator_status");
	DisplayControlDynamicCaps caps = DisplayControlDynamicCaps(Constants::Invalid, Constants::Invalid);
	auto policyRequest = m_requestedMaxDisplayIndex.find(policyIndex);
	if (policyRequest != m_requestedMaxDisplayIndex.end())
	{
		caps.setCurrentUpperLimit(policyRequest->second);
	}

	policyRequest = m_requestedMinDisplayIndex.find(policyIndex);
	if (policyRequest != m_requestedMinDisplayIndex.end())
	{
		caps.setCurrentLowerLimit(policyRequest->second);
	}
	requestRoot->addChild(caps.getXml());

	auto policyLockRequest = m_requestedLocks.find(policyIndex);
	Bool lockRequested = false;
	if (policyLockRequest != m_requestedLocks.end())
	{
		lockRequested = policyLockRequest->second;
	}
	requestRoot->addChild(XmlNode::createDataElement("requested_lock", StatusFormat::friendlyValue(lockRequested)));

	return requestRoot;
}
示例#2
0
void DomainDisplayControl_001::setDisplayControlDynamicCaps(UIntN participantIndex, UIntN domainIndex, 
    DisplayControlDynamicCaps newCapabilities)
{
    auto displaySet = getDisplayControlSet(participantIndex, domainIndex);
    auto upperLimitIndex = newCapabilities.getCurrentUpperLimit();
    auto lowerLimitIndex = newCapabilities.getCurrentLowerLimit();

    if (upperLimitIndex != Constants::Invalid && lowerLimitIndex != Constants::Invalid)
    {
        auto size = displaySet.getCount();
        if (upperLimitIndex >= size)
        {
            throw dptf_exception("Upper Limit index is out of control set bounds.");
        }
        else if (upperLimitIndex > lowerLimitIndex || lowerLimitIndex >= size)
        {
            lowerLimitIndex = size - 1;
            getParticipantServices()->writeMessageWarning(
                ParticipantMessage(FLF, "Limit index mismatch, setting lower limit to lowest possible index."));
        }

        m_displayControlDynamicCaps.invalidate();

        Percentage upperLimitBrightness = displaySet[upperLimitIndex].getBrightness();
        UInt32 uint32UpperLimit = upperLimitBrightness.toWholeNumber();
        getParticipantServices()->primitiveExecuteSetAsUInt32(
            esif_primitive_type::SET_DISPLAY_CAPABILITY,
            uint32UpperLimit,
            domainIndex,
            Constants::Esif::NoPersistInstance);

        Percentage lowerLimitBrightness = displaySet[lowerLimitIndex].getBrightness();
        UInt32 uint32LowerLimit = lowerLimitBrightness.toWholeNumber();
        getParticipantServices()->primitiveExecuteSetAsUInt32(
            esif_primitive_type::SET_DISPLAY_DEPTH_LIMIT,
            uint32LowerLimit,
            domainIndex,
            Constants::Esif::NoPersistInstance);
    }
    else
    {
        m_displayControlDynamicCaps.invalidate();

        getParticipantServices()->primitiveExecuteSetAsUInt32(
            esif_primitive_type::SET_DISPLAY_CAPABILITY,
            upperLimitIndex,
            domainIndex,
            Constants::Esif::NoPersistInstance);

        getParticipantServices()->primitiveExecuteSetAsUInt32(
            esif_primitive_type::SET_DISPLAY_DEPTH_LIMIT,
            lowerLimitIndex,
            domainIndex,
            Constants::Esif::NoPersistInstance);
    }
}
void DisplayControlCapabilitiesArbitrator::updatePolicyRequest(
	const DisplayControlDynamicCaps& caps,
	UIntN policyIndex,
	std::map<UIntN, UIntN>& minRequests,
	std::map<UIntN, UIntN>& maxRequests)
{
	auto newMax = caps.getCurrentUpperLimit();
	auto newMin = caps.getCurrentLowerLimit();

	if (newMax == Constants::Invalid && newMin == Constants::Invalid)
	{
		maxRequests.erase(policyIndex);
		minRequests.erase(policyIndex);
	}
	else
	{
		maxRequests[policyIndex] = newMax;
		minRequests[policyIndex] = newMin;
	}
}