RK3588添加分辨率
一、添加正常分辨率
添加正常分辨率,开机edid自动识别到合适的分辨率显示到屏幕;
代码路径:kernel/drivers/gpu/drm/drm_edid.c
HDMI屏一般是为自动获取屏幕的分辨率,获取屏幕信息之后进行对算(*cea_mode_for_vic),之后从edid_cea_modes_1[]分辨率数组中对比出一个符合当前屏幕的最优分辨率显示出来,如果需要添加当前屏幕所属正常分辨率,只需要在edid_cea_modes_1[]中添加一个分辨率;因为数组规定只大小为127,所以当你添加一个分辨率之后需要当场当前的一个分辨率。
下面展示一些 内联代码片
。
static const struct drm_display_mode edid_cea_modes_1[] = {
/* 1 - 640x480@60Hz 4:3 */
{ DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 25175, 640, 656,
752, 800, 0, 480, 490, 492, 525, 0,
DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC),
.picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, },
/* 2 - 720x480@60Hz 4:3 */
{ DRM_MODE("720x480", DRM_MODE_TYPE_DRIVER, 27000, 720, 736,
798, 858, 0, 480, 489, 495, 525, 0,
DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC),
.picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, },
/* 3 - 720x480@60Hz 16:9 */
{ DRM_MODE("720x480", DRM_MODE_TYPE_DRIVER, 27000, 720, 736,
798, 858, 0, 480, 489, 495, 525, 0,
DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC),
.picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
......
/* 125 - 5120x2160@50Hz 64:27 */
{ DRM_MODE("5120x2160", DRM_MODE_TYPE_DRIVER, 742500, 5120, 6216,
6304, 6600, 0, 2160, 2168, 2178, 2250, 0,
DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
.picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
/* 126 - 5120x2160@60Hz 64:27 */
{ DRM_MODE("5120x2160", DRM_MODE_TYPE_DRIVER, 742500, 5120, 5284,
5372, 5500, 0, 2160, 2168, 2178, 2250, 0,
DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
.picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
/* 127 - 5120x2160@100Hz 64:27 */
{ DRM_MODE("5120x2160", DRM_MODE_TYPE_DRIVER, 1485000, 5120, 6216,
6304, 6600, 0, 2160, 2168, 2178, 2250, 0,
DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
.picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
二、添加特殊分辨率
添加特殊分辨率,如果单个特殊分辨率,开机会去读取单个分辨率显示;如果多个分辨率需要在开机的时候手动设置合适的分辨率,不然默认使用的是第一个分辨率。
代码路径:
kernel/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
kernel/drivers/gpu/drm/drm_edid.c
当前使用dw-hdmi.c 中关闭edid识别,强制去读取dw_hdmi_default_modes[]中的分辨率,然后再于dw_hdmi_default_modes[]中的分辨率去与drm_edid.c中的drm_dmt_modes[]对比,如果有一样的分辨率既显示。
下面展示一些 内联代码片
添加drm_edid.c中的库分辨率
--- a/kernel/drivers/gpu/drm/drm_edid.c
+++ b/kernel/drivers/gpu/drm/drm_edid.c
@@ -221,6 +221,7 @@ static const struct edid_quirk {
* Autogenerated from the DMT spec.
* This table is copied from xfree86/modes/xf86EdidModes.c.
*/
static const struct drm_display_mode drm_dmt_modes[] = {
/* 0x01 - 640x350@85Hz */
{ DRM_MODE("640x350", DRM_MODE_TYPE_DRIVER, 31500, 640, 672,
@@ -238,6 +239,14 @@ static const struct drm_display_mode drm_dmt_modes[] = {
{ DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 25175, 640, 656,
752, 800, 0, 480, 490, 492, 525, 0,
DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) },
+
+ /* 0x04 - 640x480@60Hz */
+ { DRM_MODE("480x640", DRM_MODE_TYPE_DRIVER, 25175, 480, 526,
+ 530, 570, 0, 640, 656, 658, 692, 0,
+ DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
+
/* 0x05 - 640x480@72Hz */
{ DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 31500, 640, 664,
704, 832, 0, 480, 489, 492, 520, 0,
添加dw-hdmi.c中的特殊分辨率
--- a/kernel/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
+++ b/kernel/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
static const struct drm_display_mode dw_hdmi_default_modes[] = {
+#if 0
/* 16 - 1920x1080@60Hz 16:9 */
{ DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 148500, 1920, 2008,
2052, 2200, 0, 1080, 1084, 1089, 1125, 0,
@@ -135,6 +137,15 @@ static const struct drm_display_mode dw_hdmi_default_modes[] = {
798, 858, 0, 480, 489, 495, 525, 0,
DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC),
.picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, },
+
+#endif
+ /* 127 - 480x640@60Hz 4:3 */
+ { DRM_MODE("480x640", DRM_MODE_TYPE_DRIVER, 25175, 480, 526,
+ 530, 570, 0, 640, 656, 658, 692, 0,
+ DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
+ .picture_aspect_ratio = HDMI_PICTURE_ASPECT_NONE, },
+
+#if 0
/* 4 - 1280x720@60Hz 16:9 */
{ DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 74250, 1280, 1390,
1430, 1650, 0, 720, 725, 730, 750, 0,
@@ -160,6 +171,7 @@ static const struct drm_display_mode dw_hdmi_default_modes[] = {
798, 858, 0, 480, 489, 495, 525, 0,
DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC),
.picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, },
+#endif
};
enum frl_mask {
@@ -2114,7 +2126,8 @@ static int dw_hdmi_connector_get_modes(struct drm_connector *connector)
return 0;
memset(metedata, 0, sizeof(*metedata));
- edid = drm_get_edid(connector, hdmi->ddc);
+ edid = NULL;
+ //edid = drm_get_edid(connector, hdmi->ddc);
if (edid) {
dev_dbg(hdmi->dev, "got edid: width[%d] x height[%d]\n",
edid->width_cm, edid->height_cm);
@@ -2288,7 +2301,8 @@ static void dw_hdmi_attach_properties(struct dw_hdmi_qp *hdmi)
if (hdmi->plat_data->get_grf_color_fmt)
color = hdmi->plat_data->get_grf_color_fmt(data);
- val = (hdmi_readl(hdmi, PKT_VSI_CONTENTS1) >> 8) & 0xffffff;
+ val = HDMI_FORUM_OUI;
+ //val = (hdmi_readl(hdmi, PKT_VSI_CONTENTS1) >> 8) & 0xffffff;
if (val == HDMI_FORUM_OUI)
hdmi->allm_enable = true;
else
添加dts中的配置
--- a/kernel/arch/arm64/boot/dts/rockchip/rk3588/rk3588.dts
+++ b/kernel/arch/arm64/boot/dts/rockchip/rk3588/rk3588.dts
@@ -257,6 +257,21 @@
//vmmc-supply = <&vccio_sd_s0>;
};
+&display_subsystem {
+clocks = <&hdptxphy_hdmi_clk0>, <&hdptxphy_hdmi_clk1>;
+clock-names = "hdmi0_phy_pll", "hdmi1_phy_pll";
+};
+
+&hdptxphy_hdmi_clk0 {
+ status = "okay";
+};
+
+&hdptxphy_hdmi_clk1 {
+ status = "okay";
+};
+
&fiq_debugger {
rockchip,baudrate = <115200>;
};