mdppLib.c

该博客主要介绍了Linux环境下MDP库中涉及的电源管理和背光控制的详细实现,包括面板ID的动态检测、电源配置、GPIO控制以及背光亮度调节。针对CDP面板,提供了如PowerUp、PowerDown、Reset和BacklightLevel等关键操作的静态函数。同时,还涵盖了DSI接口的配置和IBBLAB模块的等待稳定机制。
摘要由CSDN通过智能技术生成

/*=============================================================================

File: mdppLib.c

=============================================================================*/

#ifdef __cplusplus
extern “C” {
#endif

#include <PlatformInfo.h>
#include <Library/PcdLib.h>
#include <api/pmic/pm/pm_lcdb.h>
#include <api/pmic/pm/pm_wled.h>
#include <api/pmic/pm/pm_ldo.h>
#include <api/pmic/pm/pm_smps.h>
#include <api/pmic/pm/pm_boot.h>
#include <api/pmic/pm/pm_version.h>
#include “MDPTypes.h”
#include “MDPPlatformLib.h”
#include “MDPSystem.h”
#include “DDITlmm.h”
#include “pmapp_npa.h”
#include “npa.h”
#include “boot_extern_platforminfo_interface.h”
#include “HALDSILib.h”

/* -----------------------------------------------------------------------
** Defines
** ----------------------------------------------------------------------- */
#define PCD_PANEL_TYPE_OEM 1

#define DSI_READ_ADDRESS_SIZE 2
#define DSI_READ_READBACK_SIZE 8

#define PLATFORM_PANEL_ID_MAX_COMMANDS 3 // maximum panel ID read commands

// PMIC Device Indices
#define PMIC_A 0 // PMIC device (Vreg, LDO, ect)
#define PMIC_A 0 // PMIC device (Vreg, LDO, ect)
#define PMIC_PMI_DEV_INDEX 1 // PMIC interface device (IBB/LAB, GPIO, WLED)

#define PMIC_IBBLAB_READYTIME 25 // Maximum of milliseconds to wait for IBB/LAB to stabilize (Can be up to 8.8ms +/-16%)

/* SM8250 Main Panel CDP specific defines
*/
#define CDP_DISP_RESET_GPIO 75 // GPIO number for LCD0_RESET
#define CDP_DISP_TE_GPIO 66 // GPIO number for TE
#define CDP_DISP_MODE_SEL 46 // GPIO for panel mode select 0 = Dual Port, 1 = Single Port (DSC)
#define CDP_DISP_LCD_REG_EN 61 // GPIO for LCD internal boost power
#define CDP_DISP_LCD_BKLT_EN 60 // GPIO for backlight enable
#define CDP_SEC_DISP_RESET_GPIO 128 // GPIO number for LCD0_RESET on secondary display
#define CDP_SEC_DISP_TE_GPIO 67 // GPIO number for TE on secondary display

#define DSI_WRITE_BACKLIGHT_SIZE 3

#define DISP_DIV_ROUND_UP(x, y) (((x) + (y/2)) / (y))
#define PANEL_LIST_LENGTH(LIST) (sizeof(LIST)/sizeof((LIST)[0]))

// Get reset gpio based on display id
#define GET_CDP_DISP_RESET_GPIO(displayId) (((displayId) == MDP_DISPLAY_SECONDARY) ? CDP_SEC_DISP_RESET_GPIO : CDP_DISP_RESET_GPIO)

// Get te gpio based on display id
#define GET_CDP_DISP_TE_GPIO(displayId) (((displayId) == MDP_DISPLAY_SECONDARY) ? CDP_SEC_DISP_TE_GPIO : CDP_DISP_TE_GPIO)
uint8 readback[DSI_READ_READBACK_SIZE];

/* -----------------------------------------------------------------------
** Types
** ----------------------------------------------------------------------- */

/* Panel command ID list for dynamic panel detection
*/

typedef struct {
uint8 address[DSI_READ_ADDRESS_SIZE]; // DCS command for panel ID
uint8 expectedReadback[DSI_READ_READBACK_SIZE]; // expected readback
} PlatformPanelIDCommandInfo;

/* Dynamic panel ID detection entry
*/
typedef struct {
uint8 uCmdType; // data type for panel ID DSI read
uint32 uTotalRetry; // number of retry if DSI read fails
PlatformPanelIDCommandInfo panelIdCommands[PLATFORM_PANEL_ID_MAX_COMMANDS]; // commands for panel ID and expected readback
uint32 uLaneRemapOrder; // Lane remap order
const int8 *psPanelCfg; // pointer to the panel configuration
uint32 uPanelCfgSize; // size of panel configuration data
MDPPlatformPanelType eSelectedPanel; // index of the selected panel
uint32 uFlags; // flags to set clock config for now, can set other config in future
} PlatformDSIDetectParams;

/* Power configuration
/
typedef struct
{
MDP_PmicModuleControlType ePMICSecondaryPower[MDP_DISPLAY_MAX]; // Configuration for PMIC based secondary power source
} Panel_PowerCtrlParams;
/
NPA Client info
/
typedef struct
{
char
cResourceName;
char* cClientName;
}NPAClientName;

/* Panel backlight DCS command
*/
typedef struct {
uint8 uCmdType; // DCS command type for backlight control
uint8 command[DSI_WRITE_BACKLIGHT_SIZE]; // DCS command for backlight control
} PlatformPanelBacklightControl;

/* -----------------------------------------------------------------------
** Local functions
** ----------------------------------------------------------------------- */

/* Platform detection
*/
static MDP_Status ReadPlatformIDAndChipID(EFI_PLATFORMINFO_PLATFORM_INFO_TYPE *pPlatformInfo, EFIChipInfoIdType *pChipSetId, EFIChipInfoFamilyType *pChiSetFamily);
static MDP_Status DynamicDSIPanelDetection(MDPPlatformPanelInfo *pPlatformPanel, uint32 *puPanelID, PlatformDSIDetectParams *pPanelList, uint32 uPanelCnt);

/* 8998 Main Panel CDP Functions
*/
static MDP_Status Panel_CDP_PowerUp(MDP_Display_IDType eDisplayId, Panel_PowerCtrlParams *pPowerParams);
static MDP_Status Panel_CDP_PowerDown(MDP_Display_IDType eDisplayId, Panel_PowerCtrlParams *pPowerParams);
static MDP_Status Panel_CDP_Reset(MDP_Display_IDType eDisplayId);
static MDP_Status Panel_CDP_BacklightLevel(MDP_Display_IDType eDisplayId, BacklightConfigType *pBacklightConfig);
static MDP_Status Panel_CDP_PeripheralPower(MDP_Display_IDType eDisplayId, Panel_PowerCtrlParams *pPowerParams, bool32 bPowerUp);
static void Panel_IBBLAB_WaitForReady();

/* Main Panel CDP/MTP Functions
*/

/* General helper functions */
MDP_Status SetDefaultGPIOState(GpioStateType *pGPIOList);

/===========================================================================
Local Configuration Definitions
===========================================================================
/
//wanghui add for lcd
/******************************************************************

  •           Primary rm692e0 1080p Cmd Panel                    *
    
  •                                                            *
    
  •               1080x2400                                    *
    
  •               Single-DSI(DSI0)                             *
    
  •               Command mode                                 *
    

/
const static int8 Primary_rm692e0_1080p_cmd_xmldata[] =
“<?xml version=\"1.0\" encoding=\"utf-8\"?>”
“rm692e0 DSI Command Mode Panel (1080x2400 24bpp)”
“<Group id=“Active Timing”>”
" 1080"
" 0"
" 0"
" 0"
" 0"
" 0"
" 0"
" 2400"
" 0"
" 0"
" 0"
" 0"
" 0"
" 0"
" False"
" False"
" False"
" 0x0"
“”
“<Group id=“Display Interface”>”
" 9"
" 3"
“”
“<Group id=“DSI Interface”>”
" 2"
" 0"
" 36"
" 1"
" 4"
" 0x3C0000"
" False"
" False"
" True"
" 2"
" True"
" True"
" 2400"
" 2400"
" "
" 00\n"
" "
“”
“”
" 15 FE 00\n"
" 15 C2 08\n"
" 15 35 00\n"
" 15 51 07 ff\n"
" 05 11 00\n"
" FF 78\n"
" 05 29 00\n"
“”
“”
" 05 28\n"
" 05 10\n"
“”
“0x2E 0x3D”
“”
" 3"
“12”
“\n”;
/

  •           Primary vtdr6130 1080p Cmd Panel                    *
    
  •                                                            *
    
  •               1080x2400                                    *
    
  •               Single-DSI(DSI0)                             *
    
  •               Command mode                                 *
    

******************************************************************/

const static int8 Primary_vtdr6130_1080p_cmd_xmldata[] =
“<?xml version=\"1.0\" encoding=\"utf-8\"?>”
“vtdr6130 DSI Command Mode Panel (1080x2400 24bpp)”
“<Group id=“Active Timing”>”
" 1080"
" 0"
" 0"
" 0"
" 0"
" 0"
" 0"
" 2400"
" 0"
" 0"
" 0"
" 0"
" 0"
" 0"
" False"
" False"
" False"
" 0x0"
“”
“<Group id=“Display Interface”>”
" 9"
" 3"
“”
“<Group id=“DSI Interface”>”
" 2"
" 0"
" 36"
" 1"
" 4"
" 19200000"
" 0x3C0000"
" False"
" False"
" True"
" 2"
" True"
" True"
" 2400"
" 2400"
“1”
" True"
" 1"
" 1"
" 0"
" 0x0B"
" 540"
" 12"
" 1"
" "
" 00\n"
" "
“”
“”
" 15 03 01\n"
" 15 59 09\n"
" 15 35 00\n"
" 15 53 20\n"
" 15 51 07 ff\n"
" 15 6c 00\n"
" 15 6d 01\n"
" 15 6f 02\n"
" 39 70 11 00 00 AC 30 80 09 60 04 38 00 C8 02 1C 02 1C 02 00 01 17 00 20 22 E5 00 07 00 01 00 0B 00 83 18 00 10 F0 07 10 20 00 06 0F 0F 33 0E 1C 2A 38 46 54 62 69 70 77 79 7B 7D 7E 02 02 22 00 2A 40 2A BE 3A FC 3A FA 3A F8 3B 38 3B 78 3B B6 4B B6 4B F4 4B F4 6C 34 84 74 00 00 00 00 00 00\n"
" 05 11 00\n"
" FF 78\n"
" 05 29 00\n"
“”
“”
" 05 28\n"
" 05 10\n"
“”
“0x2E 0x3D”
“”
" 3"
“12”
“\n”;

/******************************************************************

  •           Primary Sharp 1080p Cmd Panel                    *
    
  •                                                            *
    
  •              
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值