X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=drivers%2Fvideo%2Frockchip%2Fhdmi%2Frockchip-hdmi-sysfs.c;h=d5d965049db7168d01cf78d0b6b6ce8cda721526;hb=e597832a0cc99cb534b6be6c129f7fed90bd4a9f;hp=f994d96c80f50049d397753f3f0c176af52e662d;hpb=d6f81d11337829cf86fbad53e209ae2cb2f12d88;p=firefly-linux-kernel-4.4.55.git diff --git a/drivers/video/rockchip/hdmi/rockchip-hdmi-sysfs.c b/drivers/video/rockchip/hdmi/rockchip-hdmi-sysfs.c index f994d96c80f5..d5d965049db7 100644 --- a/drivers/video/rockchip/hdmi/rockchip-hdmi-sysfs.c +++ b/drivers/video/rockchip/hdmi/rockchip-hdmi-sysfs.c @@ -18,9 +18,9 @@ static int hdmi_set_enable(struct rk_display_device *device, int enable) struct hdmi *hdmi = device->priv_data; if (enable == 0) - hdmi_submit_work(hdmi, HDMI_DISABLE_CTL, 0, NULL); + hdmi_submit_work(hdmi, HDMI_DISABLE_CTL, 0, 0); else - hdmi_submit_work(hdmi, HDMI_ENABLE_CTL, 0, NULL); + hdmi_submit_work(hdmi, HDMI_ENABLE_CTL, 0, 0); return 0; } @@ -51,8 +51,7 @@ static int hdmi_set_mode(struct rk_display_device *device, container_of(mode, struct display_modelist, mode); int vic = 0; - mutex_lock(&hdmi->lock); - if (mode == NULL) { + if (!mode) { hdmi->autoset = 1; vic = hdmi_find_best_mode(hdmi, 0); } else { @@ -63,9 +62,8 @@ static int hdmi_set_mode(struct rk_display_device *device, if (vic && hdmi->vic != vic) { hdmi->vic = vic; if (hdmi->hotplug == HDMI_HPD_ACTIVED) - hdmi_submit_work(hdmi, HDMI_SET_VIDEO, 0, NULL); + hdmi_submit_work(hdmi, HDMI_SET_VIDEO, 0, 0); } - mutex_unlock(&hdmi->lock); return 0; } @@ -75,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) @@ -100,17 +98,16 @@ static int hdmi_set_3dmode(struct rk_display_device *device, int mode) if (!hdmi) return -1; - mutex_lock(&hdmi->lock); + modelist = &hdmi->edid.modelist; 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; } - mutex_unlock(&hdmi->lock); if (!display_modelist) return -1; @@ -121,7 +118,7 @@ static int hdmi_set_3dmode(struct rk_display_device *device, int mode) if (hdmi->mode_3d != mode) { hdmi->mode_3d = mode; if (hdmi->hotplug == HDMI_HPD_ACTIVED) - hdmi_submit_work(hdmi, HDMI_SET_3D, 0, NULL); + hdmi_submit_work(hdmi, HDMI_SET_3D, 0, 0); } return 0; } @@ -136,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,*/ @@ -168,10 +165,9 @@ static int hdmi_get_edidaudioinfo(struct rk_display_device *device, return -1; memset(audioinfo, 0x00, len); - mutex_lock(&hdmi->lock); /*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; @@ -179,9 +175,8 @@ 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); } - mutex_unlock(&hdmi->lock); return 0; } @@ -190,7 +185,6 @@ static int hdmi_get_color(struct rk_display_device *device, char *buf) struct hdmi *hdmi = device->priv_data; int i, mode; - mutex_lock(&hdmi->lock); mode = (1 << HDMI_COLOR_RGB_0_255); if (hdmi->edid.sink_hdmi) { mode |= (1 << HDMI_COLOR_RGB_16_235); @@ -202,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 && @@ -217,8 +211,12 @@ 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); - mutex_unlock(&hdmi->lock); + "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, + "Current Colorimetry: %d\n", hdmi->colorimetry); return i; } @@ -242,12 +240,18 @@ static int hdmi_set_color(struct rk_display_device *device, hdmi->colordepth, value); if (hdmi->colordepth != value) hdmi->colordepth = value; + } else if (!strncmp(buf, "colorimetry", 11)) { + if (sscanf(buf, "colorimetry=%d", &value) == -1) + return -1; + pr_debug("current colorimetry is %d input colorimetry is %d\n", + hdmi->colorimetry, value); + if (hdmi->colorimetry != value) + hdmi->colorimetry = value; } else { - pr_err("%s unkown event\n", __func__); return -1; } if (hdmi->hotplug == HDMI_HPD_ACTIVED) - hdmi_submit_work(hdmi, HDMI_SET_COLOR, 0, NULL); + hdmi_submit_work(hdmi, HDMI_SET_COLOR, 0, 0); return 0; } @@ -295,13 +299,219 @@ static int hdmi_get_monspecs(struct rk_display_device *device, if (!hdmi) return -1; - mutex_lock(&hdmi->lock); if (hdmi->edid.specs) - *monspecs = *(hdmi->edid.specs); - mutex_unlock(&hdmi->lock); + *monspecs = *hdmi->edid.specs; return 0; } +/** + * 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) +{ + struct list_head *pos, *head = &hdmi->edid.modelist; + struct display_modelist *modelist; + struct fb_videomode *m; + struct hdmi_audio *audio; + int i, lens = len; + + lens += snprintf(buf + lens, PAGE_SIZE - lens, + "******** Show Sink Info ********\n"); + lens += snprintf(buf + lens, PAGE_SIZE - lens, + "Max tmds clk is %u\n", + hdmi->edid.maxtmdsclock); + if (hdmi->edid.hf_vsdb_version) + lens += snprintf(buf + lens, PAGE_SIZE - lens, + "Support HFVSDB\n"); + if (hdmi->edid.scdc_present) + lens += snprintf(buf + lens, PAGE_SIZE - lens, + "Support SCDC\n"); + lens += snprintf(buf + lens, PAGE_SIZE - lens, + "Support video mode:\n"); + list_for_each(pos, head) { + modelist = list_entry(pos, struct display_modelist, list); + m = &modelist->mode; + if (m->flag) + lens += snprintf(buf + lens, PAGE_SIZE - lens, + "\t%s(YCbCr420)\n", m->name); + else + lens += snprintf(buf + lens, PAGE_SIZE - lens, + "\t%s\n", m->name); + } + lens += snprintf(buf + lens, PAGE_SIZE - lens, + "Support video color mode:"); + lens += snprintf(buf + lens, PAGE_SIZE - lens, " RGB"); + if (hdmi->edid.ycbcr420) + lens += snprintf(buf + lens, PAGE_SIZE - lens, + " YCbCr420"); + if (hdmi->edid.ycbcr422) + lens += snprintf(buf + lens, PAGE_SIZE - lens, + " YCbCr422"); + if (hdmi->edid.ycbcr444) + lens += snprintf(buf + lens, PAGE_SIZE - lens, + " YCbCr444"); + lens += snprintf(buf + lens, PAGE_SIZE - lens, + "\nSupport video color depth:"); + lens += snprintf(buf + lens, PAGE_SIZE - lens, " 24bit"); + if (hdmi->edid.deepcolor & HDMI_DEEP_COLOR_30BITS) + lens += snprintf(buf + lens, PAGE_SIZE - lens, " 30bit"); + if (hdmi->edid.deepcolor & HDMI_DEEP_COLOR_36BITS) + lens += snprintf(buf + lens, PAGE_SIZE - lens, " 36bit"); + if (hdmi->edid.deepcolor & HDMI_DEEP_COLOR_48BITS) + lens += snprintf(buf + lens, PAGE_SIZE - lens, " 48bit"); + if (hdmi->edid.ycbcr420) + lens += snprintf(buf + lens, PAGE_SIZE - lens, " 420_24bit"); + if (hdmi->edid.deepcolor_420 & HDMI_DEEP_COLOR_30BITS) + lens += snprintf(buf + lens, PAGE_SIZE - lens, " 420_30bit"); + if (hdmi->edid.deepcolor_420 & HDMI_DEEP_COLOR_36BITS) + lens += snprintf(buf + lens, PAGE_SIZE - lens, " 420_36bit"); + if (hdmi->edid.deepcolor_420 & HDMI_DEEP_COLOR_48BITS) + lens += snprintf(buf + lens, PAGE_SIZE - lens, " 420_48bit"); + if (hdmi->edid.colorimetry) { + lens += snprintf(buf + lens, PAGE_SIZE - lens, + "\nExtended Colorimetry:"); + if (hdmi->edid.colorimetry & + (1 << (HDMI_COLORIMETRY_EXTEND_XVYCC_601 - 3))) + lens += snprintf(buf + lens, PAGE_SIZE - lens, + " xvYCC601"); + if (hdmi->edid.colorimetry & + (1 << (HDMI_COLORIMETRY_EXTEND_XVYCC_709 - 3))) + lens += snprintf(buf + lens, PAGE_SIZE - lens, + " xvYCC709"); + if (hdmi->edid.colorimetry & + (1 << (HDMI_COLORIMETRY_EXTEND_SYCC_601 - 3))) + lens += snprintf(buf + lens, PAGE_SIZE - lens, + " sYCC601"); + if (hdmi->edid.colorimetry & + (1 << (HDMI_COLORIMETRY_EXTEND_ADOBE_YCC601 - 3))) + lens += snprintf(buf + lens, PAGE_SIZE - lens, + " AdobeYCC601"); + if (hdmi->edid.colorimetry & + (1 << (HDMI_COLORIMETRY_EXTEND_ADOBE_RGB - 3))) + lens += snprintf(buf + lens, PAGE_SIZE - lens, + " AdobeRGB"); + if (hdmi->edid.colorimetry & + (1 << (HDMI_COLORIMETRY_EXTEND_BT_2020_YCC_C - 3))) + lens += snprintf(buf + lens, PAGE_SIZE - lens, + " BT2020cYCC"); + if (hdmi->edid.colorimetry & + (1 << (HDMI_COLORIMETRY_EXTEND_BT_2020_YCC - 3))) + lens += snprintf(buf + lens, PAGE_SIZE - lens, + " BT2020YCC"); + if (hdmi->edid.colorimetry & + (1 << (HDMI_COLORIMETRY_EXTEND_BT_2020_RGB - 3))) + lens += snprintf(buf + lens, PAGE_SIZE - lens, + " BT2020RGB"); + } + lens += snprintf(buf + lens, PAGE_SIZE - lens, + "\nSupport audio type:"); + for (i = 0; i < hdmi->edid.audio_num; i++) { + audio = &hdmi->edid.audio[i]; + switch (audio->type) { + case HDMI_AUDIO_LPCM: + lens += snprintf(buf + lens, PAGE_SIZE - lens, + " LPCM\n"); + break; + case HDMI_AUDIO_AC3: + lens += snprintf(buf + lens, PAGE_SIZE - lens, + " AC3"); + break; + case HDMI_AUDIO_MPEG1: + lens += snprintf(buf + lens, PAGE_SIZE - lens, + " MPEG1"); + break; + case HDMI_AUDIO_MP3: + lens += snprintf(buf + lens, PAGE_SIZE - lens, + " MP3"); + break; + case HDMI_AUDIO_MPEG2: + lens += snprintf(buf + lens, PAGE_SIZE - lens, + " MPEG2"); + break; + case HDMI_AUDIO_AAC_LC: + lens += snprintf(buf + lens, PAGE_SIZE - lens, + " AAC"); + break; + case HDMI_AUDIO_DTS: + lens += snprintf(buf + lens, PAGE_SIZE - lens, + " DTS"); + break; + case HDMI_AUDIO_ATARC: + lens += snprintf(buf + lens, PAGE_SIZE - lens, + " ATARC"); + break; + case HDMI_AUDIO_DSD: + lens += snprintf(buf + lens, PAGE_SIZE - lens, + " DSD"); + break; + case HDMI_AUDIO_E_AC3: + lens += snprintf(buf + lens, PAGE_SIZE - lens, + " E-AC3"); + break; + case HDMI_AUDIO_DTS_HD: + lens += snprintf(buf + lens, PAGE_SIZE - lens, + " DTS-HD"); + break; + case HDMI_AUDIO_MLP: + lens += snprintf(buf + lens, PAGE_SIZE - lens, + " MLP"); + break; + case HDMI_AUDIO_DST: + lens += snprintf(buf + lens, PAGE_SIZE - lens, + " DST"); + break; + case HDMI_AUDIO_WMA_PRO: + lens += snprintf(buf + lens, PAGE_SIZE - lens, + " WMP-PRO"); + break; + default: + lens += snprintf(buf + lens, PAGE_SIZE - lens, + " Unknown"); + break; + } + lens += snprintf(buf + lens, PAGE_SIZE - lens, + "Support max audio channel is %d\n", + audio->channel); + lens += snprintf(buf + lens, PAGE_SIZE - lens, + "Support audio sample rate:"); + if (audio->rate & HDMI_AUDIO_FS_32000) + lens += snprintf(buf + lens, PAGE_SIZE - lens, + " 32000"); + if (audio->rate & HDMI_AUDIO_FS_44100) + lens += snprintf(buf + lens, PAGE_SIZE - lens, + " 44100"); + if (audio->rate & HDMI_AUDIO_FS_48000) + lens += snprintf(buf + lens, PAGE_SIZE - lens, + " 48000"); + if (audio->rate & HDMI_AUDIO_FS_88200) + lens += snprintf(buf + lens, PAGE_SIZE - lens, + " 88200"); + if (audio->rate & HDMI_AUDIO_FS_96000) + lens += snprintf(buf + lens, PAGE_SIZE - lens, + " 96000"); + if (audio->rate & HDMI_AUDIO_FS_176400) + lens += snprintf(buf + lens, PAGE_SIZE - lens, + " 176400"); + if (audio->rate & HDMI_AUDIO_FS_192000) + lens += snprintf(buf + lens, PAGE_SIZE - lens, + " 192000"); + lens += snprintf(buf + lens, PAGE_SIZE - lens, + "\nSupport audio word length:"); + if (audio->rate & HDMI_AUDIO_WORD_LENGTH_16bit) + lens += snprintf(buf + lens, PAGE_SIZE - lens, + " 16bit"); + if (audio->rate & HDMI_AUDIO_WORD_LENGTH_20bit) + lens += snprintf(buf + lens, PAGE_SIZE - lens, + " 20bit"); + if (audio->rate & HDMI_AUDIO_WORD_LENGTH_24bit) + lens += snprintf(buf + lens, PAGE_SIZE - lens, + " 24bit"); + lens += snprintf(buf + lens, PAGE_SIZE - lens, "\n"); + } + return lens; +} + static int hdmi_get_debug(struct rk_display_device *device, char *buf) { struct hdmi *hdmi = device->priv_data; @@ -310,22 +520,48 @@ static int hdmi_get_debug(struct rk_display_device *device, char *buf) if (!hdmi) return 0; - len += snprintf(buf+len, PAGE_SIZE, "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, "Raw Data:"); - mutex_lock(&hdmi->lock); + len += snprintf(buf + len, PAGE_SIZE - len, "Raw Data:"); for (i = 0; i < HDMI_MAX_EDID_BLOCK; i++) { if (!hdmi->edid.raw[i]) break; buff = hdmi->edid.raw[i]; for (j = 0; j < HDMI_EDID_BLOCK_SIZE; j++) { if (j % 16 == 0) - len += snprintf(buf+len, PAGE_SIZE, "\n"); - len += snprintf(buf+len, PAGE_SIZE, "0x%02x, ", + len += snprintf(buf + len, + PAGE_SIZE - len, "\n"); + len += snprintf(buf + len, PAGE_SIZE - len, "0x%02x, ", buff[j]); } } - mutex_unlock(&hdmi->lock); + 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; } @@ -345,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) @@ -353,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;