Android hdmi out display error

Hello
I test hdmi out change resolution… -> 3840x2160
I modify code HwcConfig.cpp and some hwcomposer code…
HWC_PRIMARY_FRAMEBUFFER_WIDTH 3840
HWC_PRIMARY_FRAMEBUFFER_HEIGHT 2160

so adb capture image is good… but real monitor screen has broken.

monitor… broken

adb capture screen … normal…

Did you want to get 4K resolution UI? You also need to modify the kernel source code. Have a try!

diff --git a/arch/arm/boot/dts/amlogic/kvim3.dts b/arch/arm/boot/dts/amlogic/kvim3.dts
index dde53f5..53502e5 100755
--- a/arch/arm/boot/dts/amlogic/kvim3.dts
+++ b/arch/arm/boot/dts/amlogic/kvim3.dts
@@ -826,9 +826,10 @@
 
 &meson_fb {
 	status = "okay";
-	display_size_default = <1920 1080 1920 2160 32>;
-	mem_size = <0x00800000 0x1980000 0x100000 0x100000 0x800000>;
+	display_size_default = <3840 2160 3840 4320 32>;
+	mem_size = <0x00800000 0x2000000 0x100000 0x100000 0x800000>;	
 	logo_addr = "0x7f800000";
+	4k2k_fb = <1>;
 	mem_alloc = <0>;
 	pxp_mode = <0>; /** 0:normal mode 1:pxp mode */
 };



diff --git a/drivers/amlogic/media/osd/osd_hw.c b/drivers/amlogic/media/osd/osd_hw.c
index 13ddc6f..165d78a 100644
--- a/drivers/amlogic/media/osd/osd_hw.c
+++ b/drivers/amlogic/media/osd/osd_hw.c
@@ -2266,6 +2266,10 @@ int osd_set_scan_mode(u32 index)
 			osd_h_filter_mode = 1;
 			osd_v_filter_mode = 1;
 		}
+		if ((osd_hw.fb_for_4k2k) &&
+		    (osd_hw.free_scale_enable[index]))
+			osd_hw.scale_workaround = 1;
+
 		if (is_interlaced(vinfo)) {
 			osd_hw.scan_mode[index] = SCAN_MODE_INTERLACE;
 			if (osd_hw.osd_meson_dev.osd_ver == OSD_NORMAL)
@@ -2334,9 +2338,6 @@ int osd_set_scan_mode(u32 index)
 				&& (vinfo->height == 2160))
 				|| ((vinfo->width == 4096)
 				&& (vinfo->height == 2160))) {
-				if ((osd_hw.fb_for_4k2k)
-					&& (osd_hw.free_scale_enable[index]))
-						osd_hw.scale_workaround = 1;
 				osd_hw.field_out_en[output_index] = 0;
 			} else if (((vinfo->width == 720)
 				&& (vinfo->height == 480))





diff --git a/drivers/amlogic/media/osd/osd_hw.c b/drivers/amlogic/media/osd/osd_hw.c
index dd9c968..13ddc6f 100644
--- a/drivers/amlogic/media/osd/osd_hw.c
+++ b/drivers/amlogic/media/osd/osd_hw.c
@@ -33,6 +33,7 @@
 #include <linux/fs.h>
 #include <linux/sysfs.h>
 #include <linux/uaccess.h>
+#include <asm/div64.h>
 #include <linux/amlogic/cpu_version.h>
 /* Android Headers */
 
@@ -2335,7 +2336,6 @@ int osd_set_scan_mode(u32 index)
 				&& (vinfo->height == 2160))) {
 				if ((osd_hw.fb_for_4k2k)
 					&& (osd_hw.free_scale_enable[index]))
-					if (!(osd_hw.osd_meson_dev.afbc_type))
 						osd_hw.scale_workaround = 1;
 				osd_hw.field_out_en[output_index] = 0;
 			} else if (((vinfo->width == 720)
@@ -4923,7 +4923,7 @@ static void osd_set_dummy_data(u32 index, u32 alpha)
 
 static void osd_update_disp_freescale_enable(u32 index)
 {
-	int hf_phase_step, vf_phase_step;
+	u64 hf_phase_step, vf_phase_step;
 	int src_w, src_h, dst_w, dst_h;
 	int bot_ini_phase, top_ini_phase;
 	int vsc_ini_rcv_num, vsc_ini_rpt_p0_num;
@@ -4995,12 +4995,15 @@ static void osd_update_disp_freescale_enable(u32 index)
 		VSYNCOSD_WR_MPEG_REG(osd_reg->osd_sc_ctrl0, 0);
 	}
 
-	hf_phase_step = (src_w << 18) / dst_w;
-	hf_phase_step = (hf_phase_step << 6);
-	if (shift_workaround)
-		vf_phase_step = ((src_h - 1) << 20) / dst_h;
-	else
-		vf_phase_step = (src_h << 20) / dst_h;
+	hf_phase_step = (u64)src_w << 24;
+	do_div(hf_phase_step, dst_w);
+	if (shift_workaround) {
+		vf_phase_step = (u64)(src_h - 1) << 20;
+		do_div(vf_phase_step, dst_h);
+	} else {
+		vf_phase_step = (u64)src_h << 20;
+		do_div(vf_phase_step, dst_h);
+	}
 
 #ifdef NEW_PPS_PHASE
 	if (osd_hw.field_out_en[output_index]) {
-- 
2 Likes

Thank you. I success 4k.
I have one more question for your answer

mem_size = <0x00800000 0x1980000 0x100000 0x100000 0x800000>
display_size_default = <3840 2160 3840 4320 32>;|
mem_size = <0x00800000 0x2000000 0x100000 0x100000 0x800000>;|

how to calculate memsize? and how to decide display_size_default 4320 <-- this value?

display_size_default = <3840 2160 3840 4320 32>;
4320 = 2160×2

1 Like

You can fire up python and convert hex to a composite number (and vise versa)