video: rockchip: hdmi: contrast uboot and kernel resolution
[firefly-linux-kernel-4.4.55.git] / drivers / video / rockchip / hdmi / rockchip-hdmi-sysfs.c
index 73e6787135015e042710334345f49f45dd4d582d..d5d965049db7168d01cf78d0b6b6ce8cda721526 100644 (file)
@@ -51,7 +51,7 @@ static int hdmi_set_mode(struct rk_display_device *device,
                        container_of(mode, struct display_modelist, mode);
        int vic = 0;
 
-       if (mode == NULL) {
+       if (!mode) {
                hdmi->autoset = 1;
                vic = hdmi_find_best_mode(hdmi, 0);
        } else {
@@ -73,13 +73,13 @@ static int hdmi_get_mode(struct rk_display_device *device,
        struct hdmi *hdmi = device->priv_data;
        struct fb_videomode *vmode;
 
-       if (mode == NULL)
+       if (!mode)
                return -1;
 
        if (hdmi->vic) {
                vmode = (struct fb_videomode *)
                        hdmi_vic_to_videomode(hdmi->vic);
-               if (unlikely(vmode == NULL))
+               if (unlikely(!vmode))
                        return -1;
                *mode = *vmode;
                if (hdmi->vic & HDMI_VIDEO_YUV420)
@@ -103,10 +103,10 @@ static int hdmi_set_3dmode(struct rk_display_device *device, int mode)
        list_for_each(pos, modelist) {
                display_modelist =
                        list_entry(pos, struct display_modelist, list);
-               if (hdmi->vic == display_modelist->vic)
-                       break;
-               else
+               if (hdmi->vic != display_modelist->vic)
                        display_modelist = NULL;
+               else
+                       break;
        }
        if (!display_modelist)
                return -1;
@@ -133,9 +133,9 @@ static int hdmi_get_3dmode(struct rk_display_device *device)
                return hdmi->mode_3d;
 }
 
-/*CEA 861-E: Audio Coding Type
-  sync width enum hdmi_audio_type
-*/
+/* CEA 861-E: Audio Coding Type
* sync width enum hdmi_audio_type
+ */
 static const char * const audioformatstr[] = {
        "",
        "LPCM",         /*HDMI_AUDIO_LPCM = 1,*/
@@ -167,7 +167,7 @@ static int hdmi_get_edidaudioinfo(struct rk_display_device *device,
        memset(audioinfo, 0x00, len);
        /*printk("hdmi:edid: audio_num: %d\n", hdmi->edid.audio_num);*/
        for (i = 0; i < hdmi->edid.audio_num; i++) {
-               audio = &(hdmi->edid.audio[i]);
+               audio = &hdmi->edid.audio[i];
                if (audio->type < 1 || audio->type > HDMI_AUDIO_WMA_PRO) {
                        pr_info("audio type: unsupported.");
                        continue;
@@ -175,7 +175,7 @@ static int hdmi_get_edidaudioinfo(struct rk_display_device *device,
                size = strlen(audioformatstr[audio->type]);
                memcpy(audioinfo, audioformatstr[audio->type], size);
                audioinfo[size] = ',';
-               audioinfo += (size+1);
+               audioinfo += (size + 1);
        }
        return 0;
 }
@@ -196,7 +196,7 @@ static int hdmi_get_color(struct rk_display_device *device, char *buf)
        i = snprintf(buf, PAGE_SIZE,
                     "Supported Color Mode: %d\n", mode);
        i += snprintf(buf + i, PAGE_SIZE - i,
-                     "Current Color Mode: %d\n", hdmi->colormode);
+                     "Current Color Mode: %d\n", hdmi->video.color_output);
 
        mode = (1 << 1); /* 24 bit*/
        if (hdmi->edid.deepcolor & HDMI_DEEP_COLOR_30BITS &&
@@ -211,7 +211,8 @@ static int hdmi_get_color(struct rk_display_device *device, char *buf)
        i += snprintf(buf + i, PAGE_SIZE - i,
                      "Supported Color Depth: %d\n", mode);
        i += snprintf(buf + i, PAGE_SIZE - i,
-                     "Current Color Depth: %d\n", hdmi->colordepth);
+                     "Current Color Depth: %d\n",
+                     hdmi->video.color_output_depth);
        i += snprintf(buf + i, PAGE_SIZE - i,
                      "Supported Colorimetry: %d\n", hdmi->edid.colorimetry);
        i += snprintf(buf + i, PAGE_SIZE - i,
@@ -247,7 +248,6 @@ static int hdmi_set_color(struct rk_display_device *device,
                if (hdmi->colorimetry != value)
                        hdmi->colorimetry = value;
        } else {
-               pr_err("%s unkown event\n", __func__);
                return -1;
        }
        if (hdmi->hotplug == HDMI_HPD_ACTIVED)
@@ -300,12 +300,12 @@ static int hdmi_get_monspecs(struct rk_display_device *device,
                return -1;
 
        if (hdmi->edid.specs)
-               *monspecs = *(hdmi->edid.specs);
+               *monspecs = *hdmi->edid.specs;
        return 0;
 }
 
 /**
- * hdmi_show_sink_info: show hdmi sink device infomation
+ * hdmi_show_sink_info: show hdmi sink device information
  * @hdmi: handle of hdmi
  */
 static int hdmi_show_sink_info(struct hdmi *hdmi, char *buf, int len)
@@ -407,7 +407,7 @@ static int hdmi_show_sink_info(struct hdmi *hdmi, char *buf, int len)
        lens += snprintf(buf + lens, PAGE_SIZE - lens,
                         "\nSupport audio type:");
        for (i = 0; i < hdmi->edid.audio_num; i++) {
-               audio = &(hdmi->edid.audio[i]);
+               audio = &hdmi->edid.audio[i];
                switch (audio->type) {
                case HDMI_AUDIO_LPCM:
                        lens += snprintf(buf + lens, PAGE_SIZE - lens,
@@ -467,7 +467,7 @@ static int hdmi_show_sink_info(struct hdmi *hdmi, char *buf, int len)
                        break;
                default:
                        lens += snprintf(buf + lens, PAGE_SIZE - lens,
-                                        " Unkown");
+                                        " Unknown");
                        break;
                }
                lens += snprintf(buf + lens, PAGE_SIZE - lens,
@@ -497,7 +497,7 @@ static int hdmi_show_sink_info(struct hdmi *hdmi, char *buf, int len)
                        lens += snprintf(buf + lens, PAGE_SIZE - lens,
                                         " 192000");
                lens += snprintf(buf + lens, PAGE_SIZE - lens,
-                                "\nSupport audio word lenght:");
+                                "\nSupport audio word length:");
                if (audio->rate & HDMI_AUDIO_WORD_LENGTH_16bit)
                        lens += snprintf(buf + lens, PAGE_SIZE - lens,
                                         " 16bit");
@@ -520,9 +520,9 @@ static int hdmi_get_debug(struct rk_display_device *device, char *buf)
 
        if (!hdmi)
                return 0;
-       len += snprintf(buf+len, PAGE_SIZE - len, "EDID status:%s\n",
+       len += snprintf(buf + len, PAGE_SIZE - len, "EDID status:%s\n",
                        hdmi->edid.status ? "False" : "Okay");
-       len += snprintf(buf+len, PAGE_SIZE - len, "Raw Data:");
+       len += snprintf(buf + len, PAGE_SIZE - len, "Raw Data:");
        for (i = 0; i < HDMI_MAX_EDID_BLOCK; i++) {
                if (!hdmi->edid.raw[i])
                        break;
@@ -531,16 +531,40 @@ static int hdmi_get_debug(struct rk_display_device *device, char *buf)
                        if (j % 16 == 0)
                                len += snprintf(buf + len,
                                                PAGE_SIZE - len, "\n");
-                       len += snprintf(buf+len, PAGE_SIZE - len, "0x%02x, ",
+                       len += snprintf(buf + len, PAGE_SIZE - len, "0x%02x, ",
                                        buff[j]);
                }
        }
-       len += snprintf(buf+len, PAGE_SIZE, "\n");
+       len += snprintf(buf + len, PAGE_SIZE, "\n");
        if (!hdmi->edid.status)
                len += hdmi_show_sink_info(hdmi, buf, len);
        return len;
 }
 
+static int vr_get_info(struct rk_display_device *device, char *buf)
+{
+       struct hdmi *hdmi = device->priv_data;
+       int valid, width, height, x_w, x_h, hwr, einit, vsync, panel, scan;
+       int len = 0;
+
+       valid = hdmi->prop.valid;
+       width = hdmi->prop.value.width;
+       height = hdmi->prop.value.height;
+       x_w = hdmi->prop.value.x_w;
+       x_h = hdmi->prop.value.x_h;
+       hwr = hdmi->prop.value.hwrotation;
+       einit = hdmi->prop.value.einit;
+       vsync = hdmi->prop.value.vsync;
+       panel = hdmi->prop.value.panel;
+       scan = hdmi->prop.value.scan;
+
+       len = snprintf(buf, PAGE_SIZE,
+               "valid=%d,width=%d,height=%d,xres=%d,yres=%d,hwrotation=%d,orientation=%d,vsync=%d,panel=%d,scan=%d\n",
+               valid, width, height, x_w, x_h, hwr, einit, vsync, panel, scan);
+
+       return len;
+}
+
 static struct rk_display_ops hdmi_display_ops = {
        .setenable = hdmi_set_enable,
        .getenable = hdmi_get_enable,
@@ -557,6 +581,7 @@ static struct rk_display_ops hdmi_display_ops = {
        .setscale = hdmi_set_scale,
        .getscale = hdmi_get_scale,
        .getdebug = hdmi_get_debug,
+       .getvrinfo = vr_get_info,
 };
 
 static int hdmi_display_probe(struct rk_display_device *device, void *devdata)
@@ -565,6 +590,11 @@ static int hdmi_display_probe(struct rk_display_device *device, void *devdata)
 
        device->owner = THIS_MODULE;
        strcpy(device->type, "HDMI");
+       if (strstr(hdmi->property->name, "dp"))
+               strcpy(device->type, "DP");
+       else
+               strcpy(device->type, "HDMI");
+
        device->priority = DISPLAY_PRIORITY_HDMI;
        device->name = hdmi->property->name;
        device->property = hdmi->property->display;