hdmi_tx: improve display of current hdmi config
authorcdu13a <cdu13a@gmail.com>
Sun, 7 Apr 2019 01:04:11 +0000 (21:04 -0400)
committerNick Xie <nick@khadas.com>
Fri, 12 Jul 2019 05:36:09 +0000 (13:36 +0800)
Use register info to get info about current config and display it in a more human
readable format.

drivers/amlogic/media/vout/hdmitx/hdmi_tx_20/hdmi_tx_main.c

index 0fca9b7..40fc184 100644 (file)
@@ -58,6 +58,8 @@
 #include <linux/amlogic/media/vout/hdmi_tx/hdmi_tx_module.h>
 #include <linux/amlogic/media/vout/hdmi_tx/hdmi_config.h>
 #include "hw/tvenc_conf.h"
+#include "hw/hdmi_tx_reg.h"
+#include "hw/mach_reg.h"
 #include "hw/common.h"
 #include "hw/hw_clk.h"
 #include "hdmi_tx_hdcp.h"
@@ -440,6 +442,10 @@ static int set_disp_mode_auto(void)
        struct hdmi_format_para *para = NULL;
        unsigned char mode[32];
        enum hdmi_vic vic = HDMI_Unknown;
+//     char* pix_fmt[] = {"RGB","YUV422","YUV444","YUV420"};
+//     char* eotf[] = {"SDR","HDR","HDR10","HLG"};
+//     char* range[] = {"default","limited","full"};
+
        /* vic_ready got from IP */
        enum hdmi_vic vic_ready = hdev->HWOp.GetState(
                hdev, STAT_VIDEO_VIC, 0);
@@ -1791,6 +1797,11 @@ static ssize_t show_config(struct device *dev,
        int pos = 0;
        unsigned char *conf;
        struct hdmitx_dev *hdev = &hdmitx_device;
+       char* pix_fmt[] = {"RGB","YUV422","YUV444","YUV420"};
+       char* eotf[] = {"SDR","HDR","HDR10","HLG"};
+       char* range[] = {"default","limited","full"};
+       char* colourimetry[] = {"default", "BT.601", "BT.709", "xvYCC601","xvYCC709",
+       "sYCC601","Adobe_YCC601","Adobe_RGB","BT.2020c","BT.2020nc","P3 D65","P3 DCI"};
 
        pos += snprintf(buf+pos, PAGE_SIZE, "cur_VIC: %d\n", hdev->cur_VIC);
        if (hdev->cur_video_param)
@@ -1798,10 +1809,26 @@ static ssize_t show_config(struct device *dev,
                        "cur_video_param->VIC=%d\n",
                        hdev->cur_video_param->VIC);
        if (hdev->para) {
-               pos += snprintf(buf+pos, PAGE_SIZE, "cd = %d\n",
-                       hdev->para->cd);
-               pos += snprintf(buf+pos, PAGE_SIZE, "cs = %d\n",
-                       hdev->para->cs);
+               struct hdmi_format_para *para;
+               para = hdev->para;
+
+               pos += snprintf(buf+pos, PAGE_SIZE, "VIC: %d %s\n",
+                               hdmitx_device.cur_VIC, para->name);
+               pos += snprintf(buf + pos, PAGE_SIZE, "Colour depth: %d-bit\nColourspace: %s\nColour range: %s\nEOTF: %s\nYCC colour range: %s\n",
+                               (((hdmitx_rd_reg(HDMITX_DWC_TX_INVID0) & 0x6) >> 1) + 4 ) * 2,
+                               pix_fmt[(hdmitx_rd_reg(HDMITX_DWC_FC_AVICONF0) & 0x3)],
+                               range[(hdmitx_rd_reg(HDMITX_DWC_FC_AVICONF2) & 0xc) >> 2],
+                               eotf[(hdmitx_rd_reg(HDMITX_DWC_FC_DRM_PB00) & 7)],
+                               range[((hdmitx_rd_reg(HDMITX_DWC_FC_AVICONF3) & 0xc) >> 2) + 1]);
+        if (((hdmitx_rd_reg(HDMITX_DWC_FC_AVICONF1) & 0xc0) >> 6) < 0x3)
+                       pos += snprintf(buf + pos, PAGE_SIZE, "Colourimetry: %s\n",
+                                       colourimetry[(hdmitx_rd_reg(HDMITX_DWC_FC_AVICONF1) & 0xc0) >> 6]);
+        else
+                       pos += snprintf(buf + pos, PAGE_SIZE, "Colourimetry: %s\n",
+                                       colourimetry[((hdmitx_rd_reg(HDMITX_DWC_FC_AVICONF2) & 0x70) >> 4) + 3]);
+               pos += snprintf(buf + pos, PAGE_SIZE, "PLL clock: 0x%08x, Vid clock div 0x%08x\n",
+                               hd_read_reg(P_HHI_HDMI_PLL_CNTL),
+                               hd_read_reg(P_HHI_VID_PLL_CLK_DIV));
        }
 
        switch (hdev->tx_aud_cfg) {