hdmitx21: s6 need to support 1080p120hz [1/2]

PD#SWPL-176326

Problem:
s6 need to support 1080p120hz

Solution:
s6 need to support 1080p120hz

Verify:
S6

Change-Id: I2eff125097ca09d4e793c1d7df558b3ef585846e
Signed-off-by: ruofei.zhao <ruofei.zhao@amlogic.com>
diff --git a/arch/arm/dts/amlogic/meson-s6.dtsi b/arch/arm/dts/amlogic/meson-s6.dtsi
index ccc401c..70e3754 100644
--- a/arch/arm/dts/amlogic/meson-s6.dtsi
+++ b/arch/arm/dts/amlogic/meson-s6.dtsi
@@ -97,6 +97,11 @@
 		status = "disabled";
 	};
 
+	amhdmitx: amhdmitx {
+		compatible = "amlogic, amhdmitx-s6";
+		status = "okay";
+		max_refreshrate = <120>; /* the max freshrate of S6 is upto 120hz */
+	};
 };
 
 &ethmac {
diff --git a/drivers/amlogic/media/vout/hdmitx/hdmitx21/hdmitx_drv.c b/drivers/amlogic/media/vout/hdmitx/hdmitx21/hdmitx_drv.c
index 49bb1b1..081896a 100644
--- a/drivers/amlogic/media/vout/hdmitx/hdmitx21/hdmitx_drv.c
+++ b/drivers/amlogic/media/vout/hdmitx/hdmitx21/hdmitx_drv.c
@@ -270,6 +270,7 @@
 
 	hdev->tx_common.res_1080p = 0;
 	hdev->enc_idx = 0;
+	hdev->tx_common.max_refreshrate = 60; /* default */
 	dt_blob = gd->fdt_blob;
 	if (!dt_blob) {
 		printf("ERR: hdmitx: dt_blob is null\n");
@@ -328,7 +329,6 @@
 
 	printf("tx_max_frl_rate: %d\n", hdev->tx_max_frl_rate);
 
-	hdev->tx_common.max_refreshrate = 60; /* default */
 	propdata = (char *)fdt_getprop(dt_blob, node, "max_refreshrate", NULL);
 	if (propdata) {
 		max_refreshrate = be32_to_cpup((u32 *)propdata);
@@ -2905,7 +2905,7 @@
 }
 
 /* VIC is supported by SOC/IP level */
-int hdmitx_hw_validate_mode(struct hdmitx_hw_common *tx_hw, u32 vic)
+int hdmitx_hw_validate_mode(struct hdmitx_hw_common *tx_hw, u32 vic, u32 max_refreshrate)
 {
 	int ret = 0;
 	const struct hdmi_timing *timing;
@@ -2923,19 +2923,16 @@
 	case MESON_CPU_ID_S5:
 		/* for S5, the MAX capabilities are 8K60, and 4k120, and below */
 		ret = (soc_resolution_limited(timing, 4320) && soc_freshrate_limited(timing, 60)) ||
-		       (soc_resolution_limited(timing, 2160) && soc_freshrate_limited(timing, 120));
+		       (soc_resolution_limited(timing, 2160) &&
+				soc_freshrate_limited(timing, max_refreshrate));
 		break;
 	case MESON_CPU_ID_S1A:
 		ret = soc_resolution_limited(timing, 1080) && soc_freshrate_limited(timing, 60);
 		break;
-	case MESON_CPU_ID_S7D:
-		ret = (soc_resolution_limited(timing, 2160) && soc_freshrate_limited(timing, 60)) ||
-		       (soc_resolution_limited(timing, 1080) && soc_freshrate_limited(timing, 120));
-		break;
-	case MESON_CPU_ID_S7:
-	case MESON_CPU_ID_T7:
 	default:
-		ret = soc_resolution_limited(timing, 2160) && soc_freshrate_limited(timing, 60);
+		ret = (soc_resolution_limited(timing, 2160) && soc_freshrate_limited(timing, 60)) ||
+		       (soc_resolution_limited(timing, 1080) &&
+				soc_freshrate_limited(timing, max_refreshrate));
 		break;
 	}
 
diff --git a/drivers/amlogic/media/vout/hdmitx/hdmitx_common/hdmitx_check_valid.c b/drivers/amlogic/media/vout/hdmitx/hdmitx_common/hdmitx_check_valid.c
index 27b92c7..d17392f 100644
--- a/drivers/amlogic/media/vout/hdmitx/hdmitx_common/hdmitx_check_valid.c
+++ b/drivers/amlogic/media/vout/hdmitx/hdmitx_common/hdmitx_check_valid.c
@@ -83,7 +83,7 @@
 	}
 
 	/*ip level filter*/
-	if (hdmitx_hw_validate_mode(tx_comm->tx_hw, vic) != 0)
+	if (hdmitx_hw_validate_mode(tx_comm->tx_hw, vic, tx_comm->max_refreshrate) != 0)
 		return -EPERM;
 
 	return 0;
diff --git a/include/amlogic/media/vout/hdmitx21/hdmitx_module.h b/include/amlogic/media/vout/hdmitx21/hdmitx_module.h
index 92decf4..29a6826 100644
--- a/include/amlogic/media/vout/hdmitx21/hdmitx_module.h
+++ b/include/amlogic/media/vout/hdmitx21/hdmitx_module.h
@@ -227,7 +227,7 @@
 				    enum hdmi_vic vic, u32 frac_rate_policy,
 				    enum hdmi_colorspace cs, enum hdmi_color_depth cd,
 				    enum hdmi_quantization_range cr);
-int hdmitx_hw_validate_mode(struct hdmitx_hw_common *tx_hw, u32 vic);
+int hdmitx_hw_validate_mode(struct hdmitx_hw_common *tx_hw, u32 vic, u32 max_refreshrate);
 
 #ifdef CONFIG_AML_DSC_ENC
 bool edid_check_dsc_support(struct tx_cap *hdmi_tx_cap,