该系列文章总目录链接与各部分简介: Android Qcom Display学习(零)
XBL中背光驱动很简单,仅仅时方便不同项目的移植,AW99703/LM36922 I2C型的都可
boot_images/boot/QcomPkg/Library/I2CApiLib/AW99703Lib.c
/** @file AW99073Lib.c
AW99073 Backlight UEFI Driver code
Copyright (c) 2023 xxx, Inc. All rights reserved.
This file is released under license. Contact your HSM representative to setup
a license agreement in order to obtain rights to use this file.
*/
/*=============================================================================
EDIT HISTORY
when who what, where, why
-------- --- -----------------------------------------------------------
02/05/23 jerry Created
=============================================================================*/
#include "AW99073Lib.h"
static i2c_slave_config cfg = {
.bus_frequency_khz = 400,
.slave_address = 0x36,
.mode = I2C,
.slave_max_clock_stretch_us = 500,
.core_configuration1 = 0,
.core_configuration2 = 0
};
static void *pI2cHandle = NULL;
i2c_status aw99073_i2c_open(void){
i2c_status istatus = I2C_SUCCESS;
istatus = i2c_open((i2c_instance)(I2C_INSTANCE_002), &pI2cHandle);
if(istatus != I2C_SUCCESS){
DEBUG((EFI_D_ERROR, "failed to open i2c status = %d\n",(uint32)istatus));
}
return istatus;
}
i2c_status aw99073_i2c_close(void){
return i2c_close(pI2cHandle);
}
static unsigned int aw99073_i2c_write(unsigned char addr, unsigned int reg_data){
UINT32 bytes_written = 0;
i2c_status istatus = I2C_SUCCESS;
unsigned char buf[1] = {
0};
buf[0] = (unsigned char)reg_data;
istatus = i2c_write (pI2cHandle, &cfg, addr, 1, buf, 1, &bytes_written, 2500);
if(I2C_SUCCESS != istatus)
{
DEBUG((EFI_D_ERROR, " failed to write i2c status %d\n", (uint32) istatus));
}
return bytes_written;
}
unsigned int aw99073_config(void){
unsigned int ret = 0;
DEBUG((EFI_D_ERROR, " aw99073_config++++++++++++\r\n"));
aw99073_i2c_open();
ret = aw99073_i2c_write(0x03, 0x9b);
ret = aw99073_i2c_write(0x02, 0x01);
aw99073_i2c_close();
DEBUG((EFI_D_ERROR, " aw99073_config------------\r\n"));
return ret;
}
boot_images/boot/QcomPkg/Include/AW99073Lib.h
#ifndef __AW9903Lib_H__
#define __AW9903Lib_H__
#include <Uefi.h>
#include <Library/UefiLib.h>
#include <Library/QcomLib.h>
#include <Library/DebugLib.h>
#include "i2c_api.h"
unsigned int aw99073_config();
#endif
boot_images/boot/QcomPkg/Library/I2CApiLib/I2CApiLib.inf
[Sources.common]
I2cApi.c
AW99703Lib.c
boot/QcomPkg/SocPkg/Kodiak/Library/MDPPlatformLib/MDPPlatformLibPanelCommon.c
Panel_Default_Peripheral_Power/Panel_Default_Brightness_Enable -> aw99073_config()