int rk610_hdmi_sys_init(struct hdmi *hdmi) { // System power power off HDMIWrReg(SYS_CTRL, v_REG_CLK_SOURCE_IIS | v_PWR_OFF | v_INT_POL_HIGH); //Synchronize analog module. // HDMIWrReg(PHY_SYNC, 0x00); // HDMIWrReg(PHY_SYNC, 0x01); // set hdmi phy parameters // driver mode HDMIWrReg(PHY_DRIVER, v_MAIN_DRIVER(8)| v_PRE_DRIVER(0) | v_TX_ENABLE(0)); // HDMIWrReg(PHY_PRE_EMPHASIS, 0x04); HDMIWrReg(PHY_PRE_EMPHASIS, v_PRE_EMPHASIS(0) | v_TMDS_PWRDOWN(1)); //Driver power down // pll mode HDMIWrReg(0xe8, 0x10); HDMIWrReg(0xe6, 0x2c); #if 0 HDMIWrReg(PHY_PLL_CTRL, 0); #else HDMIWrReg(PHY_PLL_CTRL, v_PLL_DISABLE(1) | v_PLL_RESET(1) | v_TMDS_RESET(1)); HDMIWrReg(PHY_PLL_LDO_PWR, v_LDO_PWR_DOWN(1)); HDMIWrReg(PHY_BANDGAP_PWR, v_BANDGAP_PWR_DOWN); #endif // Enable Hotplug interrupt HDMIWrReg(INTERRUPT_MASK1, m_INT_HOTPLUG); return HDMI_ERROR_SUCESS; }
int rk610_hdmi_sys_remove(struct hdmi *hdmi) { if(rk610_hdmi->hdcp_power_off_cb) rk610_hdmi->hdcp_power_off_cb(); HDMIWrReg(PHY_DRIVER, v_MAIN_DRIVER(8)| v_PRE_DRIVER(0) | v_TX_ENABLE(0)); HDMIWrReg(PHY_PRE_EMPHASIS, v_PRE_EMPHASIS(0) | v_TMDS_PWRDOWN(1)); //Driver power down HDMIWrReg(PHY_PLL_CTRL, v_PLL_DISABLE(1) | v_PLL_RESET(1) | v_TMDS_RESET(1)); HDMIWrReg(PHY_PLL_LDO_PWR, v_LDO_PWR_DOWN(1)); HDMIWrReg(PHY_BANDGAP_PWR, v_BANDGAP_PWR_DOWN); return 0; }
int rk610_hdmi_sys_remove(void) { hdmi_dbg(hdmi->dev, "%s \n", __FUNCTION__); if(hdmi->hdcp_power_off_cb) hdmi->hdcp_power_off_cb(); HDMIWrReg(PHY_DRIVER, v_MAIN_DRIVER(8)| v_PRE_DRIVER(0) | v_TX_ENABLE(0)); HDMIWrReg(PHY_PRE_EMPHASIS, v_PRE_EMPHASIS(0) | v_TMDS_PWRDOWN(1)); //Driver power down HDMIWrReg(PHY_PLL_CTRL, v_PLL_DISABLE(1) | v_PLL_RESET(1) | v_TMDS_RESET(1)); HDMIWrReg(PHY_PLL_LDO_PWR, v_LDO_PWR_DOWN(1)); HDMIWrReg(PHY_BANDGAP_PWR, v_BANDGAP_PWR_DOWN); return 0; }
int rk610_hdmi_sys_config_video(struct hdmi *hdmi, int vic, int input_color, int output_color) { char value; struct fb_videomode *mode; // Diable HDCP if(rk610_hdmi->hdcp_power_off_cb) rk610_hdmi->hdcp_power_off_cb(); // Diable video and audio output HDMIWrReg(AV_MUTE, v_AUDIO_MUTE(1) | v_VIDEO_MUTE(1)); // Input video mode is SDR RGB24bit, Data enable signal from external HDMIWrReg(VIDEO_CONTRL1, v_VIDEO_INPUT_FORMAT(VIDEO_INPUT_SDR_RGB444) | v_DE_EXTERNAL); HDMIWrReg(VIDEO_CONTRL2, v_VIDEO_INPUT_BITS(VIDEO_INPUT_8BITS) | (output_color & 0xFF)); // Set HDMI Mode HDMIWrReg(HDCP_CTRL, v_HDMI_DVI(hdmi->edid.is_hdmi)); // Enable or disalbe color space convert if(input_color != output_color) { value = v_SOF_DISABLE | v_CSC_ENABLE; } else value = v_SOF_DISABLE; HDMIWrReg(VIDEO_CONTRL3, value); #if 1 HDMIWrReg(VIDEO_TIMING_CTL, 0); mode = (struct fb_videomode *)ext_hdmi_vic_to_videomode(vic); if(mode == NULL) { hdmi_dbg(hdmi->dev, "[%s] not found vic %d\n", __FUNCTION__, vic); return -ENOENT; } rk610_hdmi->frequency = mode->pixclock; #else // Set ext video value = v_EXTERANL_VIDEO(1) | v_INETLACE(mode->vmode); if(mode->sync & FB_SYNC_HOR_HIGH_ACT) value |= v_HSYNC_POLARITY(1); if(mode->sync & FB_SYNC_VERT_HIGH_ACT) value |= v_VSYNC_POLARITY(1); HDMIWrReg(VIDEO_TIMING_CTL, value); value = mode->left_margin + mode->xres + mode->right_margin + mode->hsync_len; HDMIWrReg(VIDEO_EXT_HTOTAL_L, value & 0xFF); HDMIWrReg(VIDEO_EXT_HTOTAL_H, (value >> 8) & 0xFF); value = mode->left_margin + mode->right_margin + mode->hsync_len; HDMIWrReg(VIDEO_EXT_HBLANK_L, value & 0xFF); HDMIWrReg(VIDEO_EXT_HBLANK_H, (value >> 8) & 0xFF); value = mode->left_margin + mode->hsync_len; HDMIWrReg(VIDEO_EXT_HDELAY_L, value & 0xFF); HDMIWrReg(VIDEO_EXT_HDELAY_H, (value >> 8) & 0xFF); value = mode->hsync_len; HDMIWrReg(VIDEO_EXT_HDURATION_L, value & 0xFF); HDMIWrReg(VIDEO_EXT_HDURATION_H, (value >> 8) & 0xFF); value = mode->upper_margin + mode->yres + mode->lower_margin + mode->vsync_len; HDMIWrReg(VIDEO_EXT_VTOTAL_L, value & 0xFF); HDMIWrReg(VIDEO_EXT_VTOTAL_H, (value >> 8) & 0xFF); value = mode->upper_margin + mode->vsync_len + mode->lower_margin; HDMIWrReg(VIDEO_EXT_VBLANK, value & 0xFF); value = mode->upper_margin + mode->vsync_len; HDMIWrReg(VIDEO_EXT_VDELAY, value & 0xFF); value = mode->vsync_len; HDMIWrReg(VIDEO_EXT_VDURATION, value & 0xFF); #endif if(hdmi->edid.is_hdmi) { rk610_hdmi_config_avi(vic, output_color); hdmi_dbg(hdmi->dev, "[%s] sucess output HDMI.\n", __FUNCTION__); } else { hdmi_dbg(hdmi->dev, "[%s] sucess output DVI.\n", __FUNCTION__); } // Power on TMDS HDMIWrReg(PHY_PRE_EMPHASIS, v_PRE_EMPHASIS(0) | v_TMDS_PWRDOWN(0)); // TMDS power on // Enable TMDS value = 0; rk610_hdmi_i2c_read_reg(PHY_DRIVER, &value); value |= v_TX_ENABLE(1); HDMIWrReg(PHY_DRIVER, value); return 0; }