RK3288 HDMI增加特殊分辨率

转载请注明出处:https://www.cnblogs.com/lialong1st/p/9174475.html

 

CPU:RK3288

系统:Android 5.1 

 

本帖以 HDMI 800x600p-60 为例,添加新的分辨率。

 

1、修改文件,打开调试模式,得到 EDID 信息后,记得关闭

diff --git a/kernel/drivers/video/fbmon.c b/kernel/drivers/video/fbmon.c
index 6103fa6..ce9b11e 100755
--- a/kernel/drivers/video/fbmon.c
+++ b/kernel/drivers/video/fbmon.c
@@ -43,7 +43,8 @@
  * EDID parser
  */
 
-#undef DEBUG  /* define this for verbose EDID parsing output */
+//#undef DEBUG  /* define this for verbose EDID parsing output */
+#define DEBUG
 
 #ifdef DEBUG
 #define DPRINTK(fmt, args...) printk(fmt,## args)

 

2、打印出 EDID 信息

[    0.805638] ========================================
[    0.805652] Display Information (EDID)
[    0.805662] ========================================
[    0.805672]    EDID Version 1.3
[    0.805682]    Manufacturer: ROW
[    0.805691]    Model: 0
[    0.805699]    Serial#: 0
[    0.805708]    Year: 2014 Week 12
[    0.805719]    Monitor Name: AAA
[    0.805728]    Display Characteristics:
[    0.805738]       Monitor Operating Limits: From EDID
[    0.805754]            H: 30-80KHz V: 50-76Hz DCLK: 160MHz
[    0.805764]       Digital Display Input
      Sync: 
[    0.805780]       Max H-size in cm: variable
[    0.805791]       Max V-size in cm: variable
[    0.805801]       Gamma: 1.0
[    0.805813]       DPMS: Active yes, Suspend no, Standby yes
[    0.805823]       Unknown
[    0.805832]       Chroma
[    0.805840]          RedX:     0.636 RedY:     0.349
[    0.805852]          GreenX:   0.290 GreenY:   0.589
[    0.805863]          BlueX:    0.143 BlueY:    0.080
[    0.805875]          WhiteX:   0.313 WhiteY:   0.329
[    0.805886]       First DETAILED Timing is preferred
[    0.805899]    Detailed Timings
[    0.805910]       40 MHz 800 840 968 1056 600 601 605 628 +HSync +VSync

[    0.805932]    Supported VESA Modes
[    0.805945]       720x400@70Hz
[    0.805955]       640x480@60Hz
[    0.805964]       640x480@72Hz
[    0.805972]       640x480@75Hz
[    0.805980]       800x600@56Hz
[    0.805988]       800x600@60Hz
[    0.805997]       800x600@72Hz
[    0.806005]       800x600@75Hz
[    0.806014]       Manufacturer's mask: 0
[    0.806023]    Standard Timings
[    0.806034] ========================================

Detailed Timings 是主要的 LCD 参数,Supported VESA Modes 是 LCD 支持的分辨率。

通过源码查看各参数的含义:

路径:kernel/drivers/video/fbmon.c

DPRINTK("      %d MHz ",  PIXEL_CLOCK/1000000);
DPRINTK("%d %d %d %d ", H_ACTIVE, H_ACTIVE + H_SYNC_OFFSET, H_ACTIVE + H_SYNC_OFFSET + H_SYNC_WIDTH, H_ACTIVE + H_BLANKING);
DPRINTK("%d %d %d %d ", V_ACTIVE, V_ACTIVE + V_SYNC_OFFSET, V_ACTIVE + V_SYNC_OFFSET + V_SYNC_WIDTH, V_ACTIVE + V_BLANKING);
DPRINTK("%sHSync %sVSync\n\n", (HSYNC_POSITIVE) ? "+" : "-", (VSYNC_POSITIVE) ? "+" : "-");

由此可以得到 LCD 的各参数:

40M = PIXEL_CLOCK = pixclock
800 = H_ACTIVE = xres
840 = H_ACTIVE + H_SYNC_OFFSET = xres + h_fp = 800 + 40
968 = H_ACTIVE + H_SYNC_OFFSET + H_SYNC_WIDTH = xres + h_fp + h_pw = 800 + 40 + 128
1056 = H_ACTIVE + H_BLANKING = xres + h_bp + h_fp + h_pw = 800 + 88 + 40 + 128
600 = V_ACTIVE = yres
601 = V_ACTIVE + V_SYNC_OFFSET = yres + v_fp = 600 + 1
605 = V_ACTIVE + V_SYNC_OFFSET + V_SYNC_WIDTH = yres + v_fp + v_pw = 600 + 1 + 4
628 = V_ACTIVE + V_BLANKING = yres + v_bp + v_fp + v_pw = 600 + 23 + 1 + 4
+HSync = HSYNC_POSITIVE
+VSync = VSYNC_POSITIVE

 

3、在枚举中增加此分辨率,枚举值为 108,并修改默认分辨率

diff --git a/kernel/drivers/video/rockchip/hdmi/rockchip-hdmi.h b/kernel/drivers/video/rockchip/hdmi/rockchip-hdmi.h
index b5475e4..f31f5b9 100755
--- a/kernel/drivers/video/rockchip/hdmi/rockchip-hdmi.h
+++ b/kernel/drivers/video/rockchip/hdmi/rockchip-hdmi.h
@@ -129,6 +129,7 @@ enum hdmi_video_infomation_code {
HDMI_3840X2160P_30HZ_4_3, /*105*/
HDMI_3840X2160P_50HZ_4_3,
HDMI_3840X2160P_60HZ_4_3,
+ HDMI_800X600P_60HZ, /*108*/
};

/* HDMI Extended Resolution */
@@ -474,7 +475,7 @@ struct hdmi {
#define HDMI_AUTO_CONFIG false

/* HDMI default vide mode */
-#define HDMI_VIDEO_DEFAULT_MODE HDMI_1920X1080P_60HZ//HDMI_1280X720P_60HZ
+#define HDMI_VIDEO_DEFAULT_MODE HDMI_800X600P_60HZ//HDMI_1920X1080P_60HZ//HDMI_1280X720P_60HZ
/*HDMI_1920X1080P_60HZ*/
#define HDMI_VIDEO_DEFAULT_COLORMODE HDMI_COLOR_AUTO
#define HDMI_VIDEO_DEFAULT_COLORDEPTH 8

 

4、将屏参数据添加到数组 static const struct hdmi_video_timing hdmi_mode[] 中

 /* name refresh xres yres pixclock h_bp h_fp v_bp v_fp h_pw v_pw polariry PorI flag vic 2ndvic pixelrepeat interface */
/* 名称 刷新频率 行像素 列像素 像素时钟 水平后沿 水平前沿 垂直后沿 垂直前沿 行同步脉宽 列同步脉宽 极性 扫描方式 标志 枚举值 第二枚举值  像素重复 接口*/
diff --git a/kernel/drivers/video/rockchip/hdmi/rockchip-hdmi-lcdc.c b/kernel/drivers/video/rockchip/hdmi/rockchip-hdmi-lcdc.c
index 63a5cfb..0f920c2 100755
--- a/kernel/drivers/video/rockchip/hdmi/rockchip-hdmi-lcdc.c
+++ b/kernel/drivers/video/rockchip/hdmi/rockchip-hdmi-lcdc.c
@@ -7,6 +7,7 @@ static const struct hdmi_video_timing hdmi_mode[] = {
    { {    "720x576i@50Hz",    50,    720,    576,    27000000,    69,    12,    19,    2,    63,    3,            0,                1,    0    },    21,    HDMI_720X576I_50HZ_16_9,    2,    OUT_P888},
    { {    "720x480p@60Hz",    60,    720,    480,    27000000,    60,    16,    30,    9,    62,    6,            0,                0,    0    },    2,     HDMI_720X480P_60HZ_16_9,    1,    OUT_P888},
    { {    "720x576p@50Hz",    50,    720,    576,    27000000,    68,    12,    39,    5,    64,    5,            0,                0,    0    },    17,    HDMI_720X576P_50HZ_16_9,    1,    OUT_P888},
+   { {    "800x600p@60Hz",    60,    800,    600,    40000000,    88,    40,    23,    1,    128,   4,    FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,    0,    0}, 108, HDMI_800X600P_60HZ,      1,  OUT_P888},
    { {    "1280x720p@24Hz",   24,    1280,   720,    59400000,    220,   1760,  20,    5,    40,    5,    FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,    0,    0}, 60,  HDMI_1280X720P_24HZ_4_3, 1,  OUT_P888},
    { {    "1280x720p@25Hz",   25,    1280,   720,    74250000,    220,   2420,  20,    5,    40,    5,    FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,    0,    0}, 61,  HDMI_1280X720P_25HZ_4_3, 1,  OUT_P888},
    { {    "1280x720p@30Hz",   30,    1280,   720,    74250000,    220,   1760,  20,    5,    40,    5,    FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,    0,    0}, 62,  HDMI_1280X720P_30HZ_4_3, 1,  OUT_P888},

polariry:水平同步高电平有效和垂直同步高电平有效

PorI:0 为不是隔行扫描。定义文件路径:/kernel/include/uapi/linux/fb.h

flag:不知道什么意思

vic:在分辨率枚举中的编号,本次添加的为 108

 

5、此时 HDMI 可以正常输入 800x600 的分辨率,但是实际显示可能有问题。

根据显示器的 EDID 修改 dts 中加载的屏参文件,修改值与添加到 HDMI 数组中的相同。

diff --git a/kernel/arch/arm/boot/dts/lcd-800x600.dtsi b/kernel/arch/arm/boot/dts/lcd-800x600.dtsi
index c0baf15..733a157 100755
--- a/kernel/arch/arm/boot/dts/lcd-800x600.dtsi
+++ b/kernel/arch/arm/boot/dts/lcd-800x600.dtsi
@@ -15,12 +15,12 @@
                                clock-frequency = <40000000>;
-                               hactive = <1920>;
-                               vactive = <1080>; 
-                               hback-porch = <126>;
-                               hfront-porch = <120>;
-                               vback-porch = <10>;
-                               vfront-porch = <10>;
-                               hsync-len = <10>;
-                               vsync-len = <8>;
+                               hactive = <800>;
+                               vactive = <600>; 
+                               hback-porch = <88>;
+                               hfront-porch = <40>;
+                               vback-porch = <23>;
+                               vfront-porch = <1>;
+                               hsync-len = <128>;
+                               vsync-len = <4>;
                                hsync-active = <0>;  
                                vsync-active = <0>;
                                de-active = <0>;

 

6、编译烧录,HDMI 显示正常,确认当前分辨率可以在设置 -> HDMI ->分辨率设置中查看,也可以通过指令查看。

$ cat /sys/class/display/HDMI/mode

 

posted @ 2018-07-06 18:19  LeeAaron  阅读(6551)  评论(2编辑  收藏  举报