From cac6f45aaf522e0c4f4c8279ed2796a0b12fa7c6 Mon Sep 17 00:00:00 2001 From: Zheng Yang Date: Mon, 25 Jun 2012 19:52:31 +0800 Subject: [PATCH] rk30 hdmi: 1. Fix HDMI 480P video parameter setting error. 2. Print EDID data when debug is enabled. --- drivers/video/rockchip/hdmi/rk30_hdmi_edid.c | 2 +- drivers/video/rockchip/hdmi/rk30_hdmi_hw.c | 51 +++++++++++-------- drivers/video/rockchip/hdmi/rk30_hdmi_sysfs.c | 2 +- drivers/video/rockchip/hdmi/rk30_hdmi_task.c | 9 +++- 4 files changed, 39 insertions(+), 25 deletions(-) diff --git a/drivers/video/rockchip/hdmi/rk30_hdmi_edid.c b/drivers/video/rockchip/hdmi/rk30_hdmi_edid.c index 3154bc255134..9fec195fea3c 100755 --- a/drivers/video/rockchip/hdmi/rk30_hdmi_edid.c +++ b/drivers/video/rockchip/hdmi/rk30_hdmi_edid.c @@ -218,7 +218,7 @@ static int hdmi_edid_parse_extensions_cea(unsigned char *buf, struct hdmi_edid * pedid->ycbcr444 = (buf[3] >> 5) & 0x01; pedid->ycbcr422 = (buf[3] >> 4) & 0x01; native_dtd_num = buf[3] & 0x0F; - hdmi_edid_debug("[EDID-CEA] ddc_offset %d underscan_support %d baseaudio_support %d yuv_support %d native_dtd_num %d\n", ddc_offset, underscan_support, baseaudio_support, yuv_support, native_dtd_num); +// hdmi_edid_debug("[EDID-CEA] ddc_offset %d underscan_support %d baseaudio_support %d yuv_support %d native_dtd_num %d\n", ddc_offset, underscan_support, baseaudio_support, yuv_support, native_dtd_num); // Parse data block while(cur_offset < ddc_offset) { diff --git a/drivers/video/rockchip/hdmi/rk30_hdmi_hw.c b/drivers/video/rockchip/hdmi/rk30_hdmi_hw.c index 1e4aabcfefa2..656c36adce1a 100755 --- a/drivers/video/rockchip/hdmi/rk30_hdmi_hw.c +++ b/drivers/video/rockchip/hdmi/rk30_hdmi_hw.c @@ -114,10 +114,10 @@ int rk30_hdmi_read_edid(int block, unsigned char *buff) ret = 0; hdmi_dbg(hdmi->dev, "[%s] edid read sucess\n", __FUNCTION__); -#if 0 +#ifdef HDMI_DEBUG for(value = 0; value < 128; value++) { printk("%02x ,", buff[value]); - if( (value + 1) % 8 == 0) + if( (value + 1) % 16 == 0) printk("\n"); } #endif @@ -376,10 +376,15 @@ int rk30_hdmi_config_video(struct rk30_hdmi_video_para *vpara) return -ENOENT; } hdmi->tmdsclk = mode->pixclock; - value = v_EXT_VIDEO_ENABLE(1) | v_INTERLACE(mode->vmode); + + if( (vpara->vic == HDMI_720x480p_60Hz_4_3) || (vpara->vic == HDMI_720x480p_60Hz_16_9) ) + value = v_VSYNC_OFFSET(6); + else + value = v_VSYNC_OFFSET(0); + value |= v_EXT_VIDEO_ENABLE(1) | v_INTERLACE(mode->vmode); if(mode->sync & FB_SYNC_HOR_HIGH_ACT) value |= v_HSYNC_POLARITY(1); - if(mode->sync | FB_SYNC_VERT_HIGH_ACT) + if(mode->sync & FB_SYNC_VERT_HIGH_ACT) value |= v_VSYNC_POLARITY(1); HDMIWrReg(EXT_VIDEO_PARA, value); value = mode->left_margin + mode->xres + mode->right_margin + mode->hsync_len; @@ -405,7 +410,11 @@ int rk30_hdmi_config_video(struct rk30_hdmi_video_para *vpara) value = mode->upper_margin + mode->vsync_len + mode->lower_margin; HDMIWrReg(EXT_VIDEO_PARA_VBLANK_L, value & 0xFF); - value = mode->upper_margin + mode->vsync_len; + if(vpara->vic == HDMI_720x480p_60Hz_4_3 || vpara->vic == HDMI_720x480p_60Hz_16_9) + value = 42; + else + value = mode->upper_margin + mode->vsync_len; + HDMIWrReg(EXT_VIDEO_PARA_VDELAY, value & 0xFF); value = mode->vsync_len; @@ -494,28 +503,28 @@ int rk30_hdmi_config_audio(struct hdmi_audio *audio) hdmi_err(hdmi->dev, "[%s] not support such sample rate %d\n", __FUNCTION__, audio->rate); return -ENOENT; } - switch(audio->word_length) - { - case HDMI_AUDIO_WORD_LENGTH_16bit: - word_length = 0x02; - break; - case HDMI_AUDIO_WORD_LENGTH_20bit: - word_length = 0x0a; - break; - case HDMI_AUDIO_WORD_LENGTH_24bit: - word_length = 0x0b; - break; - default: - hdmi_err(hdmi->dev, "[%s] not support such word length %d\n", __FUNCTION__, audio->word_length); - return -ENOENT; - } +// switch(audio->word_length) +// { +// case HDMI_AUDIO_WORD_LENGTH_16bit: +// word_length = 0x02; +// break; +// case HDMI_AUDIO_WORD_LENGTH_20bit: +// word_length = 0x0a; +// break; +// case HDMI_AUDIO_WORD_LENGTH_24bit: +// word_length = 0x0b; +// break; +// default: +// hdmi_err(hdmi->dev, "[%s] not support such word length %d\n", __FUNCTION__, audio->word_length); +// return -ENOENT; +// } //set_audio_if I2S HDMIWrReg(AUDIO_CTRL1, 0x00); //internal CTS, disable down sample, i2s input, disable MCLK HDMIWrReg(AUDIO_CTRL2, 0x40); HDMIWrReg(I2S_AUDIO_CTRL, v_I2S_MODE(I2S_MODE_STANDARD) | v_I2S_CHANNEL(channel) ); HDMIWrReg(I2S_INPUT_SWAP, 0x00); //no swap HDMIMskReg(value, AV_CTRL1, m_AUDIO_SAMPLE_RATE, v_AUDIO_SAMPLE_RATE(rate)) - HDMIWrReg(SRC_NUM_AUDIO_LEN, word_length); +// HDMIWrReg(SRC_NUM_AUDIO_LEN, word_length); //Set N value 6144, fs=48kHz HDMIWrReg(N_1, N & 0xFF); diff --git a/drivers/video/rockchip/hdmi/rk30_hdmi_sysfs.c b/drivers/video/rockchip/hdmi/rk30_hdmi_sysfs.c index f811cbabfeb8..828b77120f2f 100755 --- a/drivers/video/rockchip/hdmi/rk30_hdmi_sysfs.c +++ b/drivers/video/rockchip/hdmi/rk30_hdmi_sysfs.c @@ -48,7 +48,7 @@ static int hdmi_set_enable(struct rk_display_device *device, int enable) static int hdmi_get_status(struct rk_display_device *device) { struct hdmi *hdmi = device->priv_data; - if(hdmi->hotplug > HDMI_HPD_REMOVED) + if(hdmi->hotplug == HDMI_HPD_ACTIVED) return 1; else return 0; diff --git a/drivers/video/rockchip/hdmi/rk30_hdmi_task.c b/drivers/video/rockchip/hdmi/rk30_hdmi_task.c index fbaf507d4453..cbee83a5d509 100755 --- a/drivers/video/rockchip/hdmi/rk30_hdmi_task.c +++ b/drivers/video/rockchip/hdmi/rk30_hdmi_task.c @@ -86,7 +86,7 @@ void hdmi_sys_remove(void) #ifdef CONFIG_SWITCH switch_set_state(&(hdmi->switch_hdmi), 0); #endif - #if CONFIG_HDMI_RK30_CTL_CODEC + #ifdef CONFIG_HDMI_RK30_CTL_CODEC codec_set_spk(1); #endif } @@ -184,7 +184,6 @@ void hdmi_work(struct work_struct *work) if(hotplug != hdmi->hotplug) { if(hotplug == HDMI_HPD_ACTIVED){ - hdmi->hotplug = hotplug; hdmi->state = READ_PARSE_EDID; } else if(hdmi->hotplug == HDMI_HPD_ACTIVED) { @@ -207,6 +206,7 @@ void hdmi_work(struct work_struct *work) hdmi->state = HDMI_SLEEP; rk30_hdmi_removed(); } + hdmi->hotplug = hotplug; } else if(hotplug == HDMI_HPD_REMOVED) hdmi_sys_sleep(); @@ -245,12 +245,17 @@ void hdmi_work(struct work_struct *work) video.input_mode = VIDEO_INPUT_RGB_YCBCR_444; video.input_color = VIDEO_INPUT_COLOR_RGB;//VIDEO_INPUT_COLOR_YCBCR video.output_mode = hdmi->edid.sink_hdmi; + if(hdmi->edid.ycbcr444) video.output_color = VIDEO_OUTPUT_YCBCR444; else if(hdmi->edid.ycbcr422) video.output_color = VIDEO_OUTPUT_YCBCR422; else video.output_color = VIDEO_OUTPUT_RGB444; + // For DVI, output RGB + if(hdmi->edid.sink_hdmi == 0) + video.output_color = VIDEO_OUTPUT_RGB444; + rc = rk30_hdmi_config_video(&video); if(rc == HDMI_ERROR_SUCESS) { -- 2.34.1