Android Qcom Display学习(十六)

该系列文章总目录链接与各部分简介: 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()
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值