高通UEFI研究[五]

高通UEFI显示部分函数研究:

1、显示环境变量QcomPkg/QcomTestPkg/DisplayApp/DisplayApp.c

EnvVarEntry EnvVarList[] =
{
  {L"DISABLEDISPLAY", sizeof(UINT8)},     // DISPLAY_VAR_DISABLEDISPLAY
  {L"DISPLAYCONFIG",  sizeof(UINT32)},    // DISPLAY_VAR_DISPLAYFLAGS
  {L"DISPLAYID",      sizeof(UINT32)},    // DISPLAY_VAR_DISPLAYID  
};

2、DisplayDxeInitialize调用MDPInit获取当前屏的硬件配置和屏的信息

3、MDPDetect 用于检测显示器是否存在以及支持的模式,通过XML, I2C or EDID,具体看xml配置。

    MDPDetect->MDPDetectPanel(QcomPkg/Library/MDPLib/MDPEDID.c)->XML_UpdateTag->MDPPlatformConfigure

4、MDPDetectExtPlugin  用于检测外部显示器信息ExtDisp_Init

     MDPDetectExtPlugin->ExtDisp_Init(直接返回成功)->ExtDisp_IsDisplayPlugged(直接返回0)

5、CheckPanelOverride  帮助程序功能,检查是否设置了面板替代并解析替代
字符串(如果设置),这个是处理fastboot oem panel name手动设置新的面板的处理流程,一般我们不会设置,走默认设置就可以了!

6、MDPSetProperty 此函数将配置特定的显示属性

     MDP_DISPLAY_PROPERTY_BACKLIGHT  设置背光

     MDP_DISPLAY_PROPERTY_FIRMWAREENV

     MDP_DISPLAY_PROPERTY_MODE_INFO              // 

     MDP_DISPLAY_PROPERTY_POWER_STATE          //缓存当前显示电源状态信息

     MDP_DISPLAY_PROPERTY_ABL_INTERFACE_INIT //   初始化数据变量 和 初始化显示上下文,稍后将用于为ABL创建面板配置字符串

7、MDP_DataPartitionInit  读取显示数据分区并设置引导服务变量

8、Display_Utils_Initialize  初始化数据变量 和 初始化显示上下文,稍后将用于为ABL创建面板配置字符串,这个函数主要会调用CheckTargetPanelSupport 获取受支持面板的列表并构建DT信息数组

9 、CheckTargetPanelSupport 主要调用MDPPlatformConfigure 获取面板信息,然后把下面的面板信息传给abl

typedef enum {
  MDPPLATFORM_PANEL_NONE =0x0,                            /* No panel specified                     */
  MDPPLATFORM_PANEL_SIM_VIDEO_PANEL,                      /* Single DSI video mode simulation panel */
  MDPPLATFORM_PANEL_SIM_DUALDSI_VIDEO_PANEL,              /* Dual DSI video mode simulation panel   */
  MDPPLATFORM_PANEL_SIM_CMD_PANEL,                        /* Single DSI CMD mode simulation panel */
  MDPPLATFORM_PANEL_SIM_DUALDSI_CMD_PANEL,                /* Dual DSI CMD mode simulation panel   */
  MDPPLATFORM_PANEL_SIM_DSC_375_CMD_PANEL,                /* Single DSI CMD mode with DSC 3.75 compression simulation panel */
  MDPPLATFORM_PANEL_SIM_DUAL_DSC_375_CMD_PANEL,           /* Dual DSI CMD mode with DSC 3.75 compression simulation panel   */
  MDPPLATFORM_PANEL_SHARP_4K_DSC_CMD,                     /* NT35950 4k command panel DSC mode      */
  MDPPLATFORM_PANEL_SHARP_4K_DSC_VIDEO,                   /* NT35950 4k video panel DSC mode        */
  MDPPLATFORM_PANEL_TRULY_WQXGA_DSC_CMD,                  /* Truly 2k cmd panel DSC mode single dsi     */
  MDPPLATFORM_PANEL_TRULY_WQXGA_DSC_VIDEO,                /* Truly 2k video panel DSC mode single dsi     */
  MDPPLATFORM_PANEL_TRULY_WQXGA_DUALDSI_CMD,              /* Truly 2k cmd panel non-DSC mode      */
  MDPPLATFORM_PANEL_TRULY_WQXGA_DUALDSI_VIDEO,            /* Truly 2k video panel non-DSC mode      */
  MDPPLATFORM_PANEL_SHARP_1080P_CMD,                      /* Sharp 1080p cmd panel non-DSC mode      */
  MDPPLATFORM_PANEL_SHARP_120HZ_1080P_CMD,                /* Sharp 120hz 1080p cmd panel non-DSC mode      */
  MDPPLATFORM_PANEL_SAMSUNG_WQHD_AMOLED_DSC_CMD,          /* Samsung mg2 wqhd amoled cmd panel DSC mode      */
  MDPPLATFORM_PANEL_SAMSUNG_1080P_AMOLED_DSC_CMD,         /* Samsung mg2 1080p amoled cmd panel DSC mode      */
  MDPPLATFORM_PANEL_SAMSUNG_720P_AMOLED_CMD,              /* Samsung mg2 720p amoled cmd panel non-DSC mode      */
  MDPPLATFORM_PANEL_SAMSUNG_WQHD_AMOLED_DUAL_CMD,         /* Samsung mg1 wqhd amoled dual cmd panel non-DSC mode      */
  MDPPLATFORM_PANEL_TRULY_1080P_VIDEO,                    /* Truly 1080P single dsi video mode      */
  MDPPLATFORM_PANEL_TRULY_1080P_CMD,                      /* Truly 1080P single dsi command mode    */
  MDPPLATFORM_PANEL_SHARP_WQHD_DUALDSI_CMD,               /* sharp wqhd dual dsi command mode */
  MDPPLATFORM_PANEL_SHARP_WQHD_DUALDSI_VIDEO,             /* sharp wqhd dual dsi video mode */
  MDPPLATFORM_PANEL_NT36850_TRULY_WQHD_CMD,               /* NT36850 Truly wqhd dual dsi command mode */
  MDPPLATFORM_PANEL_MAX
} MDPPlatformPanelType;

10、FUNCTION: panel_ConfigGPIO() 
  Initialize LCD panel GPIOs and PMICs

11、MDPPlatformConfigure 这个函数完成大部分的功能,屏的配置和获取信息最终都通过这个函数执行的。

函数原型MDP_Status MDPPlatformConfigure(MDP_Display_IDType eDisplayId, MDPPlatformConfigType eConfig, MDPPlatformParams *pPlatformParams)

参数1:

typedef enum
{
  MDP_DISPLAY_PRIMARY,                 /* Primary display */
  MDP_DISPLAY_SECONDARY,               /* Secondary display */
  MDP_DISPLAY_EXTERNAL,                /* External display */
  MDP_DISPLAY_MAX,
  MDP_DISPLAY_FORCE_32BIT = 0x7FFFFFFF
} MDP_Display_IDType;

参数2:

typedef enum
{
  MDPPLATFORM_CONFIG_GETPANELCONFIG = 0x0,               /* Retrieve panel configuration */
  MDPPLATFORM_CONFIG_POWERUP,                            /* Power up power grid */
  MDPPLATFORM_CONFIG_POWERDOWN,                          /* Power down power grid */
  MDPPLATFORM_CONFIG_GETPANELID,                         /* Return the panel identifier */
  MDPPLATFORM_CONFIG_SETBACKLIGHT,                       /* Set a brightness or backlight level */
  MDPPLATFORM_CONFIG_GETPLATFORMINFO,                    /* Return platform configuration information */
  MDPPLATFORM_CONFIG_SW_RENDERER,                        /* Return SW render mode information */
  MDPPLATFORM_CONFIG_RESETPANEL,                         /* Physical reset of the panel */
  MDPPLATFORM_CONFIG_SETGPIOSTATE,                       /* Set the state of a GPIO */
  MDPPLATFORM_CONFIG_GETPANELLIST,                       /* Get list of supported panels */
  MDPPLATFORM_CONFIG_GETPANELDTINFO,                     /* Get list of panels DT Info*/
  MDPPLATFORM_CONFIG_GETPANELSUPPORTFLAGS,               /* Check if a supplied panel is supported in bootloader */
  MDPPLATFORM_CONFIG_BYPASS,                             /* Configuration bypass */
  MDPPLATFORM_CONFIG_MAX
} MDPPlatformConfigType;
 

参数3:/* Union of panel properties passed to MDPPlatformConfigure() function
*/
typedef union
{
    MDPPlatformPanelInfo       sPlatformPanel;      /* MDPPLATFORM_CONFIG_GETPANELCONFIG(Primary) */
    HDMI_PinInfo               sHDMIPinConfig;      /* MDPPLATFORM_CONFIG_GETPANELCONFIG(HDMI) */
    DP_InterfaceInfo           sDPConfig;           /* MDPPLATFORM_CONFIG_GETPANELCONFIG(DP) */
    BacklightConfigType        sBacklightConfig;    /* MDPPLATFORM_CONFIG_SETBACKLIGHT */
    MDPPlatformInfo            sPlatformInfo;       /* MDPPLATFORM_CONFIG_GETPLATFORMINFO */
    MDPPlatformPanelResetInfo  sPlatformPanelReset; /* MDPPLATFORM_CONFIG_RESETPANEL */
    PowerConfigType            sPowerConfig;        /* MDPPLATFORM_CONFIG_POWERUP/MDPPLATFORM_CONFIG_POWERDOWN */
    GpioStateType              sGPIOState;          /* MDPPLATFORM_CONFIG_SETGPIOSTATE */
    PanelListType              sPanelList;          /* MDPPLATFORM_CONFIG_GETPANELLIST */
    PanelInfoType             *psPanelDTInfo;       /* MDPPLATFORM_CONFIG_GETPANELDTINFO */
    PanelSupportType           sPanelSupport;       /* MDPPLATFORM_CONFIG_GETPANELSUPPORTFLAGS */
} MDPPlatformParams;

MDPPlatformConfigure分析

MDP_Status MDPPlatformConfigure(MDP_Display_IDType eDisplayId, MDPPlatformConfigType eConfig, MDPPlatformParams *pPlatformParams)
{
  MDP_Status               eStatus               = MDP_STATUS_OK;
  uint32                   uPanelID              = 0;
  uint32                   uPlatformSubtype      = 0;
  uint32                   uHardwareVersionMajor = 0;
  uint32                   uHardwareVersionMinor = 0;
  MDPPlatformConfigType    ePlatformConfig;
  PlatformDSIDetectParams  *pPanelList           = NULL;
  uint32                   uPanelCnt;

  /* Static information, initial once during the first call */
  static bool32                 bInitFlag        = FALSE;
  static MDPPlatformInfo        sPlatformInfo;
  static Panel_PowerCtrlParams  sPanelPowerCtrl;

  if (FALSE == bInitFlag)
  {
    MDP_OSAL_MEMZERO(&sPlatformInfo,    sizeof(MDPPlatformInfo));
    MDP_OSAL_MEMZERO(&sPanelPowerCtrl,  sizeof(Panel_PowerCtrlParams));
    bInitFlag = TRUE;
  }

  // Get remapped platform configuration enum
  ePlatformConfig = PlatformConfigRemap(&sPlatformInfo, eConfig); //在SW渲染模式下,绕过操纵硬件的所有配置,绕过gpio  背光等硬件配置
      
  // Read the platform ID once
  if (FALSE == sPlatformInfo.bPlatformDetected)
  {
    if (MDP_STATUS_OK == ReadPlatformIDAndChipID(&sPlatformInfo.sEFIPlatformType, &sPlatformInfo.sEFIChipSetId, &sPlatformInfo.sEFIChipSetFamily))//读取平台硬件信息
    {
      uint32 uTemp                    = 0;
      sPlatformInfo.bPlatformDetected = TRUE;

      // Read the display panel ID override
      if (MDP_STATUS_OK == MDP_GetEnvironmentVariable(L"DISPLAYID", &uTemp, sizeof(uTemp)))// 检测用户是否修改屏
      {
        if (uTemp > 0)
        {
          DEBUG((EFI_D_ERROR, "DisplayDxe: Panel override enabled (ID:0x%x)\n", uTemp));
          sPlatformInfo.uPanelIdOverride =  uTemp;
        }
      }
    }

    /*
     * Napali QRD device panels need 180 inverted
     */
    if ((sPlatformInfo.sEFIChipSetFamily == EFICHIPINFO_FAMILY_SDM845) &&
        (sPlatformInfo.sEFIPlatformType.platform == EFI_PLATFORMINFO_TYPE_QRD))
    {
          sPlatformInfo.uPanelOrientationOverride = MDP_ROTATE_180;
    }

    // Parse sub-revision specific info to determine the QRD platform type
    uPlatformSubtype      = sPlatformInfo.sEFIPlatformType.subtype         & 0xFF;
    uHardwareVersionMajor = (sPlatformInfo.sEFIPlatformType.version >> 16) & 0xFF;
    uHardwareVersionMinor = sPlatformInfo.sEFIPlatformType.version         & 0xFF;
  }
  
  switch (ePlatformConfig)
  {
  case MDPPLATFORM_CONFIG_SW_RENDERER:
  
    if (NULL == pPlatformParams)
    {
      eStatus = MDP_STATUS_BAD_PARAM;
    }
    else if (TRUE == sPlatformInfo.bSWRender)
    {
      // SW Render mode is enabled already, just return the status
      pPlatformParams->sPlatformInfo.bSWRender = TRUE;
    }
    else if ((EFI_PLATFORMINFO_TYPE_UNKNOWN == sPlatformInfo.sEFIPlatformType.platform) ||
             (EFI_PLATFORMINFO_TYPE_VIRTIO  == sPlatformInfo.sEFIPlatformType.platform) ||
             (EFI_PLATFORMINFO_TYPE_RUMI    == sPlatformInfo.sEFIPlatformType.platform) ||
             (TRUE == pPlatformParams->sPlatformInfo.bSWRenderOverrride) ||
             (TRUE == PcdGetBool(PcdDisplayForceSwRenderer)))
    {
      // Force SW render mode for emulation and unknown platforms
      pPlatformParams->sPlatformInfo.bSWRender = TRUE;
      // Store that an override has been requested by the caller
      sPlatformInfo.bSWRenderOverrride         = pPlatformParams->sPlatformInfo.bSWRenderOverrride;
      // Cache that SW Rendering is enabled
      sPlatformInfo.bSWRender                  = TRUE;
      DEBUG((EFI_D_ERROR, "DisplayDxe: SW renderer mode enabled!\n"));
    }
    else
    {
      // Force SW render mode off
      sPlatformInfo.bSWRender                  = FALSE;      
      // Report SW render mode is disabled
      pPlatformParams->sPlatformInfo.bSWRender = FALSE;
    }
    break;
  case MDPPLATFORM_CONFIG_GETPANELCONFIG:  //获取屏配置信息
    {
      if (NULL == pPlatformParams)
      {
        eStatus = MDP_STATUS_BAD_PARAM;
      }
      else
      {
        // Retrieve panel configuration (could be dependent on the interface)
        switch (eDisplayId)
        {
        case MDP_DISPLAY_PRIMARY:
          
          pPlatformParams->sPlatformPanel.uDefaultVendor   = 0;
          pPlatformParams->sPlatformPanel.uDefaultRevision = 0;
          pPlatformParams->sPlatformPanel.uPanelId         = 0;
          pPlatformParams->sPlatformPanel.uPowerGridId     = sPanelPowerCtrl.ePMICSecondaryPower[eDisplayId];
          pPlatformParams->sPlatformPanel.pPanelXMLConfig  = NULL;
  
          if (TRUE == Panel_CheckOverride(eDisplayId, pPlatformParams))
          {
            //Use configuration set by panel override
          }
          else if (TRUE == sPlatformInfo.bSWRender)
          {
            //use dummy panel for sw rendering
            pPlatformParams->sPlatformPanel.pPanelXMLConfig  = (int8 *)dummy_xmldata;
            pPlatformParams->sPlatformPanel.uConfigSize      = sizeof(dummy_xmldata);
            pPlatformParams->sPlatformPanel.eSelectedPanel   = MDPPLATFORM_PANEL_NONE;
          }
          else
          {
            // Report the proper information depending on the display.
            switch (sPlatformInfo.sEFIPlatformType.platform)
            {
            case EFI_PLATFORMINFO_TYPE_CDP:
            case EFI_PLATFORMINFO_TYPE_MTP:
            case EFI_PLATFORMINFO_TYPE_QRD:
              if (sPlatformInfo.sEFIPlatformType.subtype == 3)
              {
                 pPanelList = panelList_3;
                 uPanelCnt  = sizeof(panelList_3)/sizeof(PlatformDSIDetectParams);
                 sPlatformInfo.uPanelIdOverride =  0xffffff;    /* sim vid override id */
              }
              else if (sPlatformInfo.sEFIPlatformType.subtype == 1)
              {
                 pPanelList = panelList_1;
                 uPanelCnt  = sizeof(panelList_1)/sizeof(PlatformDSIDetectParams);
              }
              else
              {
                 pPanelList = panelList_0;
                 uPanelCnt  = sizeof(panelList_0)/sizeof(PlatformDSIDetectParams);
              }

              if (MDP_STATUS_OK != DynamicDSIPanelDetection(pPlatformParams, &uPanelID, sPlatformInfo.uPanelIdOverride, pPanelList, uPanelCnt))
              {
                  /* not detected, use defualt panel */
                  pPlatformParams->sPlatformPanel.pPanelXMLConfig = (int8 *)pPanelList->psPanelCfg;
                  pPlatformParams->sPlatformPanel.uConfigSize     = pPanelList->uPanelCfgSize;
                  pPlatformParams->sPlatformPanel.eSelectedPanel  = pPanelList->eSelectedPanel;
                  uPanelID = ((pPanelList->panelIdCommands[1].expectedReadback[0] << 8) |
                                             pPanelList->panelIdCommands[2].expectedReadback[0]);
                  pPlatformParams->sPlatformPanel.uPanelId        = uPanelID;
                  sPlatformInfo.uPrimaryPanelId                   = uPanelID;
              }
              else
              {
                  /* detected */
                  pPlatformParams->sPlatformPanel.uPanelId = uPanelID;
                  sPlatformInfo.uPrimaryPanelId            = uPanelID;
              }
              break;

            case EFI_PLATFORMINFO_TYPE_HDK:
              pPlatformParams->sPlatformPanel.pPanelXMLConfig   = (int8 *)NT36850_Truly_WQHD_cmd_xmldata;
              pPlatformParams->sPlatformPanel.uConfigSize       = sizeof(NT36850_Truly_WQHD_cmd_xmldata);
              pPlatformParams->sPlatformPanel.eSelectedPanel    = MDPPLATFORM_PANEL_NT36850_TRULY_WQHD_CMD;
              break;

            case EFI_PLATFORMINFO_TYPE_CLS:
                // Default panel    
                pPlatformParams->sPlatformPanel.pPanelXMLConfig = (int8 *)CLS_SN65DSIx6_WQHD_DSI_xmldata;
                pPlatformParams->sPlatformPanel.uConfigSize     = sizeof(CLS_SN65DSIx6_WQHD_DSI_xmldata);
                pPlatformParams->sPlatformPanel.uPanelId        = 0x000000C3;   
                sPlatformInfo.uPrimaryPanelId                   = pPlatformParams->sPlatformPanel.uPanelId;
                break;

            default:
              pPlatformParams->sPlatformPanel.pPanelXMLConfig    = (int8 *)dummy_xmldata;
              pPlatformParams->sPlatformPanel.uConfigSize        = sizeof(dummy_xmldata);
              pPlatformParams->sPlatformPanel.eSelectedPanel     = MDPPLATFORM_PANEL_NONE;
              break;
            }
          }
          break;
  
        case MDP_DISPLAY_EXTERNAL: 
          switch (PcdGet32(PcdExtDisplayType))
          {
            case PCD_EXTERNAL_DISPLAY_DP:
              pPlatformParams->sDPConfig.bInvertPlugPolarity       = DP_USBPlugInvertedOrientation();
              
              // For Nazgul, DP Phy lane to pad connection is the reverse of DP alt mode over usb type-c spec defined mapping
              pPlatformParams->sDPConfig.bReversePhyDataPath       = TRUE;
              break;
          
            default:
              break;
          }
          break;
  
        default:
          break;
        }
      }
    }
    break;
  case MDPPLATFORM_CONFIG_POWERUP:
    {
      switch (eDisplayId)
      {
      case MDP_DISPLAY_PRIMARY:
  
        // Config based on the platform
        switch (sPlatformInfo.sEFIPlatformType.platform)
        {
        case EFI_PLATFORMINFO_TYPE_CDP:
        case EFI_PLATFORMINFO_TYPE_MTP:
        case EFI_PLATFORMINFO_TYPE_QRD:
        case EFI_PLATFORMINFO_TYPE_HDK:

          // Primary Power Sequence
          if (MDP_STATUS_OK != (eStatus = Panel_CDP_PowerUp(eDisplayId, &sPanelPowerCtrl)))
          {
            DEBUG((EFI_D_WARN, "DisplayDxe: Primary Power Up Sequence Failed (%d)\n", eStatus));
          }
          else if (MDP_STATUS_OK != (eStatus = Panel_CDP_PeripheralPower(eDisplayId, &sPanelPowerCtrl, TRUE)))  // Secondary Power Sequence
          {
            DEBUG((EFI_D_WARN, "DisplayDxe: Secondary Power Up Sequence Failed (%d)\n", eStatus));
          }
          break;
        case EFI_PLATFORMINFO_TYPE_CLS:
          
          // Primary Power Sequence
          if (MDP_STATUS_OK != (eStatus = Panel_CLS_PowerUp(eDisplayId, &sPanelPowerCtrl)))
          {
            DEBUG((EFI_D_WARN, "DisplayDxe: Primary Power Up Sequence Failed (%d)\n", eStatus));
          }
          break;
  
        default:
          break;
        }
  
        break;
  
      case MDP_DISPLAY_EXTERNAL:
  
        // Config based on the platform
        switch (sPlatformInfo.sEFIPlatformType.platform)
        {
        case EFI_PLATFORMINFO_TYPE_CDP:
        case EFI_PLATFORMINFO_TYPE_MTP:
        case EFI_PLATFORMINFO_TYPE_QRD:
        case EFI_PLATFORMINFO_TYPE_HDK:
          eStatus = ExternalPanel_CDP_PowerUp(eDisplayId, &sPanelPowerCtrl);
          break;
        default:
          break;
        }
        break;
  
      default:
        break;
  
      }
  
    }
    break;
    case MDPPLATFORM_CONFIG_GETPANELDTINFO:
    {
      if (NULL == pPlatformParams)
      {
        eStatus = MDP_STATUS_BAD_PARAM;
      }
      else
      {
        pPlatformParams->psPanelDTInfo = (PanelInfoType*)&gPanelList;
      }
      break;
  
    }
    case MDPPLATFORM_CONFIG_GETPANELLIST:
      {
        if (NULL == pPlatformParams)
        {
          eStatus = MDP_STATUS_BAD_PARAM;
        }
        else
        {
          uint32 i = 0;
          
          while (MDPPLATFORM_PANEL_NONE != gPanelList[i].ePanel)
          {
            //Copy Panel ID
            pPlatformParams->sPanelList.ePanel[i] = gPanelList[i].ePanel;
            i++; 
          }
  
          pPlatformParams->sPanelList.uCount = i;
        }
      }
      break;
    
  case MDPPLATFORM_CONFIG_GETPANELSUPPORTFLAGS:
    {
      if (NULL == pPlatformParams)
      {
        eStatus = MDP_STATUS_BAD_PARAM;
      }
      else
      {
        //Lookup panel
        int32 i = PANEL_INFOLIST_LENGTH - 1;
        while (0 <= i)
        {
          if (pPlatformParams->sPanelSupport.ePanel == gPanelList[i].ePanel)
          {
            if ((DISP_TOPOLOGY_CONFIG_NONE == pPlatformParams->sPanelSupport.uModeIndex) ||
                (pPlatformParams->sPanelSupport.uModeIndex > DISPLAY_MODE_MAX))
            {
              pPlatformParams->sPanelSupport.uFlags = gPanelList[i].uModeFlags[0];
            }
            else
            {
              pPlatformParams->sPanelSupport.uFlags = gPanelList[i].uModeFlags[pPlatformParams->sPanelSupport.uModeIndex-1];
            }
            break;
          }
          i--;
        }
      }
    }
    break;
  case MDPPLATFORM_CONFIG_POWERDOWN:
    {
      // Handle power down
      switch (eDisplayId)
      {
      case MDP_DISPLAY_PRIMARY:
  
        // Config based on the platform
        switch (sPlatformInfo.sEFIPlatformType.platform)
        {
        case EFI_PLATFORMINFO_TYPE_CDP:
        case EFI_PLATFORMINFO_TYPE_MTP:
        case EFI_PLATFORMINFO_TYPE_QRD:
        case EFI_PLATFORMINFO_TYPE_HDK:
          if (MDP_STATUS_OK != (eStatus = Panel_CDP_PowerDown(eDisplayId, &sPanelPowerCtrl)))
          {
            DEBUG((EFI_D_WARN, "DisplayDxe: Primary Power Down Sequence Failed (%d)\n", eStatus));
          }
          else if (MDP_STATUS_OK != (eStatus = Panel_CDP_PeripheralPower(eDisplayId, &sPanelPowerCtrl, FALSE)))  // Secondary Power Sequence
          {
            DEBUG((EFI_D_WARN, "DisplayDxe: Secondary Power Down Sequence Failed (%d)\n", eStatus));
          }
          sPanelPowerCtrl.bBacklightEnabled = FALSE; /* wled is turned off */
          break;
        case EFI_PLATFORMINFO_TYPE_CLS:
          if (MDP_STATUS_OK != (eStatus = Panel_CLS_PowerDown(eDisplayId, &sPanelPowerCtrl)))
          {
            DEBUG((EFI_D_WARN, "DisplayDxe: Primary Power Down Sequence Failed (%d)\n", eStatus));
          }
          break;
        default:
          break;
        }
  
        break;
      case MDP_DISPLAY_EXTERNAL:
        // Config based on the platform
        switch (sPlatformInfo.sEFIPlatformType.platform)
        {
        case EFI_PLATFORMINFO_TYPE_CDP:
        case EFI_PLATFORMINFO_TYPE_MTP:
        case EFI_PLATFORMINFO_TYPE_QRD:
        case EFI_PLATFORMINFO_TYPE_HDK:
          eStatus = ExternalPanel_CDP_PowerDown(eDisplayId, &sPanelPowerCtrl);
          break;
        default:
          break;
        }
        break;
      default:
        break;
      }
    }
    break;
  case MDPPLATFORM_CONFIG_SETBACKLIGHT:
    {
      if (NULL == pPlatformParams)
      {
        eStatus = MDP_STATUS_BAD_PARAM;
      }
      else
      {
        // Handle backlight level
        switch (eDisplayId)
        {
        case MDP_DISPLAY_PRIMARY:
          switch (sPlatformInfo.sEFIPlatformType.platform)
          {
          case EFI_PLATFORMINFO_TYPE_CDP:
          case EFI_PLATFORMINFO_TYPE_MTP:
          case EFI_PLATFORMINFO_TYPE_QRD:
          case EFI_PLATFORMINFO_TYPE_HDK:
            if( sPanelPowerCtrl.bBacklightEnabled == FALSE)
            {
                eStatus = Panel_CDP_backlight_enable(eDisplayId, &sPanelPowerCtrl);
                if (eStatus != MDP_STATUS_OK)
                {
                  DEBUG((EFI_D_WARN, "MDPPlatformConfig: Backlight enabled Failed\n"));
                }
                sPanelPowerCtrl.bBacklightEnabled = TRUE;
            }
            eStatus = Panel_CDP_BacklightLevel(eDisplayId, &pPlatformParams->sBacklightConfig);
            break;
          case EFI_PLATFORMINFO_TYPE_CLS:
          default:
            break;
          }
          break;
        case MDP_DISPLAY_EXTERNAL:
          eStatus = MDP_STATUS_NOT_SUPPORTED;
          break;
        default:
          break;
        }
      }
    }
    break;
  case MDPPLATFORM_CONFIG_GETPANELID:
    {
    }
    break;
  case MDPPLATFORM_CONFIG_GETPLATFORMINFO:
    {
      if (NULL == pPlatformParams)
      {
        eStatus = MDP_STATUS_BAD_PARAM;
      }
      else
      {
        //
        // Return platform information
        //
        MDP_OSAL_MEMCPY(&pPlatformParams->sPlatformInfo, &sPlatformInfo, sizeof(MDPPlatformInfo));
      }
    }
    break;
  case MDPPLATFORM_CONFIG_RESETPANEL:
    {
      if (pPlatformParams->sPlatformPanelReset.uResetGpio == 0)
      {
           sPanelPowerCtrl.uResetGpio = CDP_DISP_RESET_GPIO;
           pPlatformParams->sPlatformPanelReset.uResetGpio = CDP_DISP_RESET_GPIO;
      }
      else 
      {
           sPanelPowerCtrl.uResetGpio = pPlatformParams->sPlatformPanelReset.uResetGpio;
      }
      switch (eDisplayId)
      {
      case MDP_DISPLAY_PRIMARY:
  
        // Config based on the platform
        switch (sPlatformInfo.sEFIPlatformType.platform)
        {
        case EFI_PLATFORMINFO_TYPE_CDP:
        case EFI_PLATFORMINFO_TYPE_MTP:
        case EFI_PLATFORMINFO_TYPE_QRD:
        case EFI_PLATFORMINFO_TYPE_HDK:
          eStatus = Panel_CDP_Reset(&pPlatformParams->sPlatformPanelReset);
          break;
        case EFI_PLATFORMINFO_TYPE_CLS:
          eStatus = Panel_CLS_Reset();
          break;
        default:
          break;
        }
  
        break;
      case MDP_DISPLAY_EXTERNAL:
        eStatus = MDP_STATUS_NOT_SUPPORTED;
        break;
      default:
        break;
      }
    }
    break;
  
  case MDPPLATFORM_CONFIG_SETGPIOSTATE:
    {
      if (NULL == pPlatformParams)
      {
        eStatus = MDP_STATUS_BAD_PARAM;
      }
      else
      {
        eStatus = SetDefaultGPIOState(&pPlatformParams->sGPIOState);
      }
    }
    break;
  case  MDPPLATFORM_CONFIG_BYPASS:
    {
        // SW Render Bypass mode
        eStatus = MDP_STATUS_OK;
    }
    break;   
  default:
    eStatus = MDP_STATUS_BAD_PARAM;
    break;
  }
  
  return eStatus;
}

发布了25 篇原创文章 · 获赞 0 · 访问量 996

猜你喜欢

转载自blog.csdn.net/jlgcumt/article/details/104836900