From 1b596398a88aadc44c09ef6fa06bc781f9fbc4cf Mon Sep 17 00:00:00 2001 From: Luan Yuan Date: Mon, 5 Feb 2018 10:59:50 +0800 Subject: [PATCH] hdmitx: 2160p50zh contains 2160p50hz420 etc.[1/2] PD#158454: hdmitx: uniform the sysfs node 'disp_cap' Previous handling of node 'disp_cap' may contains both '2160p50hz' and '2160p50hz420', which may confuse the application. Now start to uniform the 'disp_cap', which will only contains valid mode, without colorspace information. Not each combination of 'disp_cap' and 'dc_cap' is valid, please use 'valid_mode' to test combination. Change-Id: I2d1c97b33272ddd439acf8cadef9e35dfc2dbe82 Signed-off-by: Luan Yuan --- .../vout/hdmitx/hdmi_tx_20/hdmi_tx_main.c | 46 ++++++++++++++++--- 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/drivers/amlogic/media/vout/hdmitx/hdmi_tx_20/hdmi_tx_main.c b/drivers/amlogic/media/vout/hdmitx/hdmi_tx_20/hdmi_tx_main.c index f8d1bce431d2..9d76d208bb3e 100644 --- a/drivers/amlogic/media/vout/hdmitx/hdmi_tx_20/hdmi_tx_main.c +++ b/drivers/amlogic/media/vout/hdmitx/hdmi_tx_20/hdmi_tx_main.c @@ -1383,15 +1383,29 @@ const char *disp_mode_t[] = { "smpte30hz", "smpte50hz", "smpte60hz", - "smpte50hz420", - "smpte60hz420", "2160p50hz", "2160p60hz", - "2160p50hz420", - "2160p60hz420", NULL }; +static int is_4k50_fmt(char *mode) +{ + int i; + static char const *hdmi4k50[] = { + "2160p50hz", + "2160p60hz", + "smpte50hz", + "smpte50hz", + NULL + }; + + for (i = 0; hdmi4k50[i]; i++) { + if (strcmp(hdmi4k50[i], mode) == 0) + return 1; + } + return 0; +} + /**/ static ssize_t show_disp_cap(struct device *dev, struct device_attribute *attr, char *buf) @@ -1400,13 +1414,23 @@ static ssize_t show_disp_cap(struct device *dev, const char *native_disp_mode = hdmitx_edid_get_native_VIC(&hdmitx_device); enum hdmi_vic vic; + char mode_tmp[32]; if (hdmitx_device.tv_no_edid) { pos += snprintf(buf+pos, PAGE_SIZE, "null edid\n"); } else { for (i = 0; disp_mode_t[i]; i++) { - vic = hdmitx_edid_get_VIC(&hdmitx_device, - disp_mode_t[i], 0); + memset(mode_tmp, 0, sizeof(mode_tmp)); + strncpy(mode_tmp, disp_mode_t[i], sizeof(mode_tmp)); + vic = hdmitx_edid_get_VIC(&hdmitx_device, mode_tmp, 0); + /* Handling only 4k420 mode */ + if (vic == HDMI_Unknown) { + if (is_4k50_fmt(mode_tmp)) { + strcat(mode_tmp, "420"); + vic = hdmitx_edid_get_VIC(&hdmitx_device, + mode_tmp, 0); + } + } if (vic != HDMI_Unknown) { pos += snprintf(buf+pos, PAGE_SIZE, "%s", disp_mode_t[i]); @@ -1564,6 +1588,16 @@ static ssize_t show_dc_cap(struct device *dev, pos += snprintf(buf + pos, PAGE_SIZE, "420,8bit\n"); goto next444; } + vic = hdmitx_edid_get_VIC(&hdmitx_device, "smpte60hz420", 0); + if (vic != HDMI_Unknown) { + pos += snprintf(buf + pos, PAGE_SIZE, "420,8bit\n"); + goto next444; + } + vic = hdmitx_edid_get_VIC(&hdmitx_device, "smpte50hz420", 0); + if (vic != HDMI_Unknown) { + pos += snprintf(buf + pos, PAGE_SIZE, "420,8bit\n"); + goto next444; + } } next444: if (pRXCap->dc_y444) {