Android 上 i2c 设备寄存器修改

问题背景

公司的顶级娱乐设备初期设计考虑不周导致出现了HDMI黑屏等问题,经过排查和hdmi保护芯片有关,只能重新修改飞线到i2c上面,在不同分辨率下修改保护芯片寄存器的值改善使用体验。

前期准备

编译i2c-tool,在Android上面运行,下载地址:https://github.com/suapapa/i2c-tools
编译出来生成的:i2cdetect、i2cdump、i2cget、i2cset二进制工具 push到system/bin目录

调试过程

1. 列出I2C_5 Bus上面挂载的设备

# i2cdetect -y 5
    0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- 32 -- 34 -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- 5e --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

2. 确定哪个是TDP158有关的设备

# i2cdump -y -f 5 0x32  
# i2cdump -y -f 5 0x34  
# i2cdump -y -f 5 0x5e

可以看到前面的地址是和eDP转VGA的共用,后面的0x5e是hdmi保护芯片有关的。有TDP158的字样。

No size specified (using byte-data access)

    0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef

00: 54 44 50 31 35 38 20 20 01 12 03 50 00 00 00 00    TDP158  ???S....

10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................

20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................

30: 3c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    <...............

40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................

50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................

60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................

70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................

80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................

90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................

a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................

b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................

c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................

d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................

e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................

f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................

3.计算与hdmi芯片保护有关的位

硬件给的消息是i2c设备的0Bh[4:3]位(即0x5e开始,偏移0xb的高位的第3、4位), 低于等于1080P的时候设置00(0x40), 高于1080P设置为11(0x58)

另外一个计算方法:TDP158的I2C地址是0xBC/BD,通过i2cdump可以看出这里起始地址是0x5e,0xBC和0xBD分别和起始地址相差0x5e(94)和0x5f(95),这里看到的每一个ASCII码用8位2进制来表示。

那么起始地址0x5e + 0x5e(8*12-2)就是0xBC的地址,现在的值是0x50(0101 0000)当高于1080p的时候就是0x58(0101 1000)

直接修改:i2cset -y -f 5 0x5e 0xb 0x58

怎么确定位置偏移0xb?0开始数12-1.就是0x50对应的地方.

4. 查看修改后寄存器的值

#i2cdump  -y -f 5 0x5e

No size specified (using byte-data access)

    0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef

00: 54 44 50 31 35 38 20 20 01 12 03 58 00 00 00 00    TDP158  ???S....

10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................

20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................

30: 3c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    <...............

40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................

50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................

60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................

70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................

80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................

90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................

a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................

b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................

c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................

d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................

e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................

f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................

可以看到修改成功.

你可能感兴趣的:(Android 上 i2c 设备寄存器修改)