Ejemplo n.º 1
0
DisplayControlSet DomainDisplayControl_001::getDisplayControlSet(UIntN participantIndex, UIntN domainIndex)
{
    if (m_displayControlSet.isInvalid())
    {
        m_displayControlSet.set(createDisplayControlSet(domainIndex));
    }
    return m_displayControlSet.get();
}
Ejemplo n.º 2
0
void DomainDisplayControl_001::createDisplayControlDynamicCaps(UIntN domainIndex)
{
    UIntN upperLimitIndex;
    UIntN lowerLimitIndex;
    UInt32 uint32val;

    // Get dynamic caps
    //  The caps are stored in BIOS as brightness percentage.  They must be converted
    //  to indices before they can be used.

    // FIXME:  ESIF treats this as a UInt32 but we treat this as a percentage.  Need to get this in sync.
    uint32val = m_participantServicesInterface->primitiveExecuteGetAsUInt32(
        esif_primitive_type::GET_DISPLAY_DEPTH_LIMIT, domainIndex);
    Percentage lowerLimitBrightness = Percentage::fromWholeNumber(uint32val / 100);
    lowerLimitIndex = m_displayControlSet->getControlIndex(lowerLimitBrightness);

    try
    {
        // FIXME:  ESIF treats this as a UInt32 but we treat this as a percentage.  Need to get this in sync.
        uint32val = m_participantServicesInterface->primitiveExecuteGetAsUInt32(
            esif_primitive_type::GET_DISPLAY_CAPABILITY, domainIndex);
        Percentage upperLimitBrightness = static_cast<double>(uint32val) / 100.0;
        upperLimitIndex = m_displayControlSet->getControlIndex(upperLimitBrightness);
    }
    catch (...)
    {
        // DDPC is optional
        m_participantServicesInterface->writeMessageDebug(
            ParticipantMessage(FLF, "DDPC was not present.  Setting upper limit to 100."));
        upperLimitIndex = 0; // Max brightness
    }

    if (m_displayControlSet == nullptr)
    {
        createDisplayControlSet(domainIndex);
    }

    if (upperLimitIndex >= (m_displayControlSet->getCount()) ||
        lowerLimitIndex >= (m_displayControlSet->getCount()))
    {
        throw dptf_exception("Retrieved control index out of control set bounds.");
    }

    if (upperLimitIndex > lowerLimitIndex)
    {
        lowerLimitIndex = m_displayControlSet->getCount() - 1;
        m_participantServicesInterface->writeMessageWarning(
            ParticipantMessage(FLF, "Limit index mismatch, ignoring lower limit."));
    }

    m_displayControlDynamicCaps = new DisplayControlDynamicCaps(upperLimitIndex, lowerLimitIndex);
}