一、需求:
一个固件兼容3款屏幕模组(mipi显示,触摸驱动,背光亮度都不一样)。硬件设计上:通过mipi读取id,或者adc读取id。
二、网上找了下:
找到个最火的博客是基于rk提供的方法,太复杂了。(第一眼就是,繁琐,又长又臭)
三、自己实现吧:
1. 修改dts,增加mipi初始化参数(在rk原有的增加-xx后缀):
panel-init-sequence-aa = [
39 01 04 B9 83 11 2A
.......
];
panel-init-sequence-bb = [
39 01 04 B9 83 22 2A
.......
]
panel-init-sequence-cc = [
39 01 04 B9 83 33 2A
.......
]
2. 同理修改dts增加屏幕显示参数:
disp_timings0: display-timings {
native-mode = <&dsi0_timing0>;
dsi0_timing0: timing0 {
aa_clock-frequency = <135000000>; // 135000000
aa_hactive = <1080>;
aa_vactive = <1920>;
aa_hfront-porch = <48>; // 48
aa_hsync-len = <12>;
aa_hback-porch = <16>;
aa_vfront-porch = <44>;
aa_vsync-len = <5>; // 5
aa_vback-porch = <5>;
aa_hsync-active = <0>;
aa_vsync-active = <0>;
aa_de-active = <0>;
aa_pixelclk-active = <1>;
bb_clock-frequency = <125000000>; // 135000000
bb_hactive = <1080>;
bb_vactive = <1920>;
bb_hfront-porch = <60>; // 48
bb_hsync-len = <6>;
bb_hback-porch = <60>;
bb_vfront-porch = <24>;
bb_vsync-len = <1>; // 5
bb_vback-porch = <6>;
bb_hsync-active = <0>;
bb_vsync-active = <0>;
bb_de-active = <0>;
bb_pixelclk-active = <1>;
cc_clock-frequency = <125000000>; // 135000000
cc_hactive = <1080>;
cc_vactive = <1920>;
cc_hfront-porch = <60>; // 48
cc_hsync-len = <6>;
cc_hback-porch = <60>;
cc_vfront-porch = <24>;
cc_vsync-len = <1>; // 5
cc_vback-porch = <6>;
cc_hsync-active = <0>;
cc_vsync-active = <0>;
cc_de-active = <0>;
cc_pixelclk-active = <1>;
};
};
3. reset-delay-ms = <200>;上电,复位时间等有需要也可以同理增加。
4. 修改代码(以uboot为例, kernel就是依样画葫芦)
修改rockchip_display.c文件rockchip_ofnode_get_display_mode函数。把 FDT_GET_INT(hactive, "hactive"); 改为 FDT_GET_INT(hactive, "aa_hactive"); 部分代码:
switch (g_panel_id) // 通过 adc采集硬件id进行赋值
{
case AA_PANEL_ID:
printf("windra using aa display-timings dts\n");
FDT_GET_INT(hactive, "aa_hactive");
...................................
同理修改rockchip_panel.c文件的static int rockchip_panel_ofdata_to_platdata(struct udevice *dev)函数。 部分代码:
switch (g_panel_id)
{
case AAS_PANEL_ID:
printf("windra using panel-init-sequence-cw\n");
data = dev_read_prop(dev, "panel-init-sequence-cw", &len);
break;
..........................
5. 读取屏幕id可以通过mipi(该方法rk提供,自己百度吧),也可以通过adc读取id(rk3568 Android12 sdk默认uboot有bug,需要自己修改)