coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
hdmi.c File Reference
#include <device/mmio.h>
#include <console/console.h>
#include <delay.h>
#include <edid.h>
#include <gpio.h>
#include <stdint.h>
#include <soc/addressmap.h>
#include <soc/hdmi.h>
#include <soc/grf.h>
#include <soc/vop.h>
#include <timer.h>
#include "chip.h"
Include dependency graph for hdmi.c:

Go to the source code of this file.

Data Structures

struct  tmds_n_cts
 
struct  hdmi_mpll_config
 
struct  hdmi_phy_config
 

Macros

#define AUDIO_SAMPLERATE_DEFAULT   (48*KHz)
 
#define hdmi_debug(x...)   do { if (0) printk(BIOS_DEBUG, x); } while (0)
 

Functions

static void hdmi_set_clock_regenerator (u32 n, u32 cts)
 
static int hdmi_lookup_n_cts (u32 pixel_clk)
 
static void hdmi_audio_set_samplerate (u32 pixel_clk)
 
static void hdmi_video_sample (void)
 
static void hdmi_update_csc_coeffs (void)
 
static void hdmi_video_csc (void)
 
static void hdmi_video_packetize (void)
 
static void hdmi_phy_test_clear (u8 bit)
 
static int hdmi_phy_wait_i2c_done (u32 msec)
 
static void hdmi_phy_i2c_write (u16 data, u8 addr)
 
static void hdmi_phy_enable_power (u8 enable)
 
static void hdmi_phy_enable_tmds (u8 enable)
 
static void hdmi_phy_enable_spare (u8 enable)
 
static void hdmi_phy_gen2_pddq (u8 enable)
 
static void hdmi_phy_gen2_txpwron (u8 enable)
 
static void hdmi_phy_sel_data_en_pol (u8 enable)
 
static void hdmi_phy_sel_interface_control (u8 enable)
 
static int hdmi_phy_configure (u32 mpixelclock)
 
static int hdmi_phy_init (u32 mpixelclock)
 
static void hdmi_av_composer (const struct edid *edid)
 
static void hdmi_enable_video_path (void)
 
static void hdmi_clear_overflow (void)
 
static void hdmi_audio_set_format (void)
 
static void hdmi_audio_fifo_reset (void)
 
static int hdmi_setup (const struct edid *edid)
 
static void hdmi_init_interrupt (void)
 
static u8 hdmi_get_plug_in_status (void)
 
static int hdmi_wait_for_hpd (void)
 
static int hdmi_ddc_wait_i2c_done (int msec)
 
static void hdmi_ddc_reset (void)
 
static int hdmi_read_edid (int block, u8 *buff)
 
int rk_hdmi_get_edid (struct edid *edid)
 
int rk_hdmi_enable (const struct edid *edid)
 
int rk_hdmi_init (u32 vop_id)
 

Variables

struct rk3288_hdmi_regs *const hdmi_regs = (void *)HDMI_TX_BASE
 
static const struct tmds_n_cts n_cts_table []
 
static const struct hdmi_phy_config rockchip_phy_config []
 
static const struct hdmi_mpll_config rockchip_mpll_cfg []
 
static const u32 csc_coeff_default [3][4]
 

Macro Definition Documentation

◆ AUDIO_SAMPLERATE_DEFAULT

#define AUDIO_SAMPLERATE_DEFAULT   (48*KHz)

Definition at line 21 of file hdmi.c.

◆ hdmi_debug

#define hdmi_debug (   x...)    do { if (0) printk(BIOS_DEBUG, x); } while (0)

Definition at line 23 of file hdmi.c.

Function Documentation

◆ hdmi_audio_fifo_reset()

static void hdmi_audio_fifo_reset ( void  )
static

Definition at line 593 of file hdmi.c.

References rk3288_hdmi_regs::aud_conf0, rk3288_hdmi_regs::aud_int, rk3288_hdmi_regs::aud_int1, HDMI_AUD_CONF0_SW_AUDIO_FIFO_RST, HDMI_MC_SWRSTZ_II2SSWRST_REQ, hdmi_regs, rk3288_hdmi_regs::mc_swrstz, and write32().

Referenced by hdmi_setup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hdmi_audio_set_format()

static void hdmi_audio_set_format ( void  )
static

Definition at line 581 of file hdmi.c.

References rk3288_hdmi_regs::aud_conf0, rk3288_hdmi_regs::aud_conf1, rk3288_hdmi_regs::aud_conf2, HDMI_AUD_CONF0_I2S_IN_EN_0, HDMI_AUD_CONF0_I2S_SELECT, HDMI_AUD_CONF1_I2S_MODE_STANDARD_MODE, HDMI_AUD_CONF1_I2S_WIDTH_16BIT, hdmi_regs, and write32().

Referenced by hdmi_setup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hdmi_audio_set_samplerate()

static void hdmi_audio_set_samplerate ( u32  pixel_clk)
static

Definition at line 176 of file hdmi.c.

References tmds_n_cts::cts, hdmi_debug, hdmi_lookup_n_cts(), hdmi_set_clock_regenerator(), tmds_n_cts::n, and n_cts_table.

Referenced by hdmi_setup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hdmi_av_composer()

◆ hdmi_clear_overflow()

static void hdmi_clear_overflow ( void  )
static

Definition at line 568 of file hdmi.c.

References count, rk3288_hdmi_regs::fc_invidconf, HDMI_MC_SWRSTZ_TMDSSWRST_REQ, hdmi_regs, rk3288_hdmi_regs::mc_swrstz, read32(), val, and write32().

Referenced by hdmi_setup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hdmi_ddc_reset()

static void hdmi_ddc_reset ( void  )
static

Definition at line 708 of file hdmi.c.

References clrsetbits32, HDMI_I2CM_SOFTRSTZ, hdmi_regs, and rk3288_hdmi_regs::i2cm_softrstz.

Referenced by hdmi_read_edid().

Here is the caller graph for this function:

◆ hdmi_ddc_wait_i2c_done()

static int hdmi_ddc_wait_i2c_done ( int  msec)
static

Definition at line 689 of file hdmi.c.

References hdmi_regs, rk3288_hdmi_regs::ih_i2cm_stat0, read32(), stopwatch_expired(), stopwatch_init_msecs_expire(), udelay(), val, and write32().

Referenced by hdmi_read_edid().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hdmi_enable_video_path()

◆ hdmi_get_plug_in_status()

static u8 hdmi_get_plug_in_status ( void  )
static

Definition at line 668 of file hdmi.c.

References HDMI_PHY_HPD, hdmi_regs, rk3288_hdmi_regs::phy_stat0, read32(), and val.

Referenced by hdmi_wait_for_hpd().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hdmi_init_interrupt()

◆ hdmi_lookup_n_cts()

static int hdmi_lookup_n_cts ( u32  pixel_clk)
static

Definition at line 162 of file hdmi.c.

References ARRAY_SIZE, and n_cts_table.

Referenced by hdmi_audio_set_samplerate().

Here is the caller graph for this function:

◆ hdmi_phy_configure()

◆ hdmi_phy_enable_power()

static void hdmi_phy_enable_power ( u8  enable)
static

Definition at line 337 of file hdmi.c.

References clrsetbits32, HDMI_PHY_CONF0_PDZ_MASK, HDMI_PHY_CONF0_PDZ_OFFSET, hdmi_regs, and rk3288_hdmi_regs::phy_conf0.

Referenced by hdmi_phy_configure(), and hdmi_phy_init().

Here is the caller graph for this function:

◆ hdmi_phy_enable_spare()

static void hdmi_phy_enable_spare ( u8  enable)
static

Definition at line 349 of file hdmi.c.

References clrsetbits32, HDMI_PHY_CONF0_SPARECTRL_MASK, HDMI_PHY_CONF0_SPARECTRL_OFFSET, hdmi_regs, and rk3288_hdmi_regs::phy_conf0.

Referenced by hdmi_phy_configure().

Here is the caller graph for this function:

◆ hdmi_phy_enable_tmds()

static void hdmi_phy_enable_tmds ( u8  enable)
static

Definition at line 343 of file hdmi.c.

References clrsetbits32, HDMI_PHY_CONF0_ENTMDS_MASK, HDMI_PHY_CONF0_ENTMDS_OFFSET, hdmi_regs, and rk3288_hdmi_regs::phy_conf0.

Referenced by hdmi_phy_configure(), and hdmi_phy_init().

Here is the caller graph for this function:

◆ hdmi_phy_gen2_pddq()

static void hdmi_phy_gen2_pddq ( u8  enable)
static

Definition at line 355 of file hdmi.c.

References clrsetbits32, HDMI_PHY_CONF0_GEN2_PDDQ_MASK, HDMI_PHY_CONF0_GEN2_PDDQ_OFFSET, hdmi_regs, and rk3288_hdmi_regs::phy_conf0.

Referenced by hdmi_phy_configure().

Here is the caller graph for this function:

◆ hdmi_phy_gen2_txpwron()

static void hdmi_phy_gen2_txpwron ( u8  enable)
static

Definition at line 361 of file hdmi.c.

References clrsetbits32, HDMI_PHY_CONF0_GEN2_TXPWRON_MASK, HDMI_PHY_CONF0_GEN2_TXPWRON_OFFSET, hdmi_regs, and rk3288_hdmi_regs::phy_conf0.

Referenced by hdmi_phy_configure().

Here is the caller graph for this function:

◆ hdmi_phy_i2c_write()

static void hdmi_phy_i2c_write ( u16  data,
u8  addr 
)
static

◆ hdmi_phy_init()

static int hdmi_phy_init ( u32  mpixelclock)
static

Definition at line 458 of file hdmi.c.

References hdmi_debug, hdmi_phy_configure(), hdmi_phy_enable_power(), hdmi_phy_enable_tmds(), hdmi_phy_sel_data_en_pol(), and hdmi_phy_sel_interface_control().

Referenced by hdmi_setup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hdmi_phy_sel_data_en_pol()

static void hdmi_phy_sel_data_en_pol ( u8  enable)
static

Definition at line 368 of file hdmi.c.

References clrsetbits32, HDMI_PHY_CONF0_SELDATAENPOL_MASK, HDMI_PHY_CONF0_SELDATAENPOL_OFFSET, hdmi_regs, and rk3288_hdmi_regs::phy_conf0.

Referenced by hdmi_phy_init().

Here is the caller graph for this function:

◆ hdmi_phy_sel_interface_control()

static void hdmi_phy_sel_interface_control ( u8  enable)
static

Definition at line 375 of file hdmi.c.

References clrsetbits32, HDMI_PHY_CONF0_SELDIPIF_MASK, HDMI_PHY_CONF0_SELDIPIF_OFFSET, hdmi_regs, and rk3288_hdmi_regs::phy_conf0.

Referenced by hdmi_phy_init().

Here is the caller graph for this function:

◆ hdmi_phy_test_clear()

static void hdmi_phy_test_clear ( u8  bit)
inlinestatic

Definition at line 300 of file hdmi.c.

References clrsetbits32, HDMI_PHY_TST0_TSTCLR_MASK, HDMI_PHY_TST0_TSTCLR_OFFSET, hdmi_regs, and rk3288_hdmi_regs::phy_tst0.

Referenced by hdmi_phy_configure().

Here is the caller graph for this function:

◆ hdmi_phy_wait_i2c_done()

static int hdmi_phy_wait_i2c_done ( u32  msec)
static

Definition at line 306 of file hdmi.c.

References hdmi_regs, rk3288_hdmi_regs::ih_i2cmphy_stat0, read32(), stopwatch_expired(), stopwatch_init_msecs_expire(), udelay(), val, and write32().

Referenced by hdmi_phy_i2c_write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hdmi_read_edid()

◆ hdmi_set_clock_regenerator()

◆ hdmi_setup()

static int hdmi_setup ( const struct edid edid)
static

◆ hdmi_update_csc_coeffs()

static void hdmi_update_csc_coeffs ( void  )
static

Definition at line 223 of file hdmi.c.

References ARRAY_SIZE, clrsetbits32, rk3288_hdmi_regs::csc_coef, csc_coeff_default, rk3288_hdmi_regs::csc_scale, HDMI_CSC_SCALE_CSCSCALE_MASK, hdmi_regs, rk3288_hdmi_regs::lsb, rk3288_hdmi_regs::msb, and write32().

Referenced by hdmi_video_csc().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hdmi_video_csc()

static void hdmi_video_csc ( void  )
static

Definition at line 241 of file hdmi.c.

References clrsetbits32, rk3288_hdmi_regs::csc_cfg, rk3288_hdmi_regs::csc_scale, HDMI_CSC_CFG_INTMODE_DISABLE, HDMI_CSC_SCALE_CSC_COLORDE_PTH_24BPP, HDMI_CSC_SCALE_CSC_COLORDE_PTH_MASK, hdmi_regs, hdmi_update_csc_coeffs(), and write32().

Referenced by hdmi_setup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hdmi_video_packetize()

◆ hdmi_video_sample()

◆ hdmi_wait_for_hpd()

static int hdmi_wait_for_hpd ( void  )
static

Definition at line 675 of file hdmi.c.

References hdmi_get_plug_in_status(), stopwatch_expired(), stopwatch_init_msecs_expire(), and udelay().

Referenced by rk_hdmi_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rk_hdmi_enable()

int rk_hdmi_enable ( const struct edid edid)

Definition at line 809 of file hdmi.c.

References hdmi_setup().

Referenced by rk_display_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rk_hdmi_get_edid()

int rk_hdmi_get_edid ( struct edid edid)

◆ rk_hdmi_init()

int rk_hdmi_init ( u32  vop_id)

Definition at line 816 of file hdmi.c.

References hdmi_debug, hdmi_init_interrupt(), hdmi_wait_for_hpd(), rk3288_grf, RK_CLRBITS, RK_SETBITS, rk3288_grf_regs::soc_con6, val, and write32().

Referenced by rk_display_init().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ csc_coeff_default

const u32 csc_coeff_default[3][4]
static
Initial value:
= {
{ 0x2000, 0x0000, 0x0000, 0x0000 },
{ 0x0000, 0x2000, 0x0000, 0x0000 },
{ 0x0000, 0x0000, 0x2000, 0x0000 }
}

Definition at line 127 of file hdmi.c.

Referenced by hdmi_update_csc_coeffs().

◆ hdmi_regs

◆ n_cts_table

const struct tmds_n_cts n_cts_table[]
static

Definition at line 25 of file hdmi.c.

Referenced by hdmi_audio_set_samplerate(), and hdmi_lookup_n_cts().

◆ rockchip_mpll_cfg

const struct hdmi_mpll_config rockchip_mpll_cfg[]
static
Initial value:
= {
{
.mpixelclock = 40000,
.cpce = 0x00b3, .gmp = 0x0000, .curr = 0x0018,
}, {
.mpixelclock = 65000,
.cpce = 0x0072, .gmp = 0x0001, .curr = 0x0028,
}, {
.mpixelclock = 66000,
.cpce = 0x013e, .gmp = 0x0003, .curr = 0x0038,
}, {
.mpixelclock = 83500,
.cpce = 0x0072, .gmp = 0x0001, .curr = 0x0028,
}, {
.mpixelclock = 146250,
.cpce = 0x0051, .gmp = 0x0002, .curr = 0x0038,
}, {
.mpixelclock = 148500,
.cpce = 0x0051, .gmp = 0x0003, .curr = 0x0000,
}, {
.mpixelclock = ~0ul,
.cpce = 0x0051, .gmp = 0x0003, .curr = 0x0000,
}
}

Definition at line 25 of file hdmi.c.

Referenced by hdmi_phy_configure().

◆ rockchip_phy_config

const struct hdmi_phy_config rockchip_phy_config[]
static
Initial value:
= {
{
.mpixelclock = 74250,
.sym_ctr = 0x8009, .term = 0x0004, .vlev_ctr = 0x0272,
}, {
.mpixelclock = 148500,
.sym_ctr = 0x802b, .term = 0x0004, .vlev_ctr = 0x028d,
}, {
.mpixelclock = 297000,
.sym_ctr = 0x8039, .term = 0x0005, .vlev_ctr = 0x028d,
}, {
.mpixelclock = ~0ul,
.sym_ctr = 0x0000, .term = 0x0000, .vlev_ctr = 0x0000,
}
}

Definition at line 25 of file hdmi.c.

Referenced by hdmi_phy_configure().