Skip to content

Commit

Permalink
Display: add LCD detect support
Browse files Browse the repository at this point in the history
  • Loading branch information
Terry committed Jan 2, 2020
1 parent 67c3b9c commit cf11480
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 13 deletions.
16 changes: 14 additions & 2 deletions board/khadas/configs/kvim3.h
Expand Up @@ -158,7 +158,7 @@
"else fi;"\
"\0"\
"storeargs="\
"setenv bootargs ${initargs} otg_device=${otg_device} reboot_mode_android=${reboot_mode_android} logo=${display_layer},loaded,${fb_addr} fb_width=${fb_width} fb_height=${fb_height} vout2=${outputmode2},enable vout=${outputmode},enable panel_type=${panel_type} lcd_ctrl=${lcd_ctrl} hdmitx=${cecconfig},${colorattribute} hdmimode=${hdmimode} frac_rate_policy=${frac_rate_policy} hdmi_read_edid=${hdmi_read_edid} cvbsmode=${cvbsmode} osd_reverse=${osd_reverse} video_reverse=${video_reverse} irq_check_en=${Irq_check_en} androidboot.selinux=${EnableSelinux} androidboot.firstboot=${firstboot} jtag=${jtag} wol_enable=${wol_enable} spi_state=${spi_state} fusb302_state=${fusb302_state} hwver=${hwver} factory_mac=${factory_mac}; "\
"setenv bootargs ${initargs} otg_device=${otg_device} reboot_mode_android=${reboot_mode_android} logo=${display_layer},loaded,${fb_addr} fb_width=${fb_width} fb_height=${fb_height} vout2=${outputmode2},enable vout=${outputmode},enable panel_type=${panel_type} lcd_ctrl=${lcd_ctrl} hdmitx=${cecconfig},${colorattribute} hdmimode=${hdmimode} frac_rate_policy=${frac_rate_policy} hdmi_read_edid=${hdmi_read_edid} cvbsmode=${cvbsmode} osd_reverse=${osd_reverse} video_reverse=${video_reverse} irq_check_en=${Irq_check_en} androidboot.selinux=${EnableSelinux} androidboot.firstboot=${firstboot} jtag=${jtag} wol_enable=${wol_enable} spi_state=${spi_state} fusb302_state=${fusb302_state} hwver=${hwver} factory_mac=${factory_mac} lcd_exist=${lcd_exist}; "\
"setenv bootargs ${bootargs} androidboot.hardware=amlogic;"\
"run cmdline_keys;"\
"\0"\
Expand Down Expand Up @@ -295,7 +295,11 @@
"else "\
"setenv reboot_mode_android ""normal"";"\
"run storeargs;"\
"hdmitx hpd;hdmitx get_preferred_mode;osd dual_logo;vpp hdrpkt;"\
"if test ${lcd_exist} = 0; then "\
"hdmitx hpd;hdmitx get_preferred_mode;osd open;osd clear;imgread pic logo bootup $loadaddr;bmp display $bootup_offset;bmp scale;vout output ${outputmode};vpp hdrpkt;"\
"else "\
"hdmitx hpd;hdmitx get_preferred_mode;osd dual_logo;vpp hdrpkt;"\
"fi;"\
"fi;fi;"\
"\0"\
"hwver_check="\
Expand Down Expand Up @@ -323,6 +327,13 @@
"mmc dev 1;"\
"fi;"\
"\0"\
"display_config="\
"fdt addr ${dtb_mem_addr}; "\
"if test ${lcd_exist} = 0; then "\
"fdt set /lcd status disable;"\
"fdt set /backlight status disable;"\
"fi;"\
"\0"\
"port_mode_change="\
"fdt addr ${dtb_mem_addr}; "\
"kbi portmode r;"\
Expand Down Expand Up @@ -376,6 +387,7 @@
"run factory_reset_poweroff_protect;"\
"run upgrade_check;"\
"run init_display;"\
"run display_config;"\
"run wol_init;"\
"run hwver_check;"\
"run spi_check;"\
Expand Down
18 changes: 15 additions & 3 deletions board/khadas/configs/kvim3l.h
Expand Up @@ -106,8 +106,8 @@
"loadaddr=1080000\0"\
"panel_type=lcd_1\0" \
"lcd_ctrl=0x00000000\0"\
"outputmode=panel\0" \
"hdmimode=1080p60hz\0" \
"outputmode=panel\0" \
"colorattribute=444,8bit\0"\
"cvbsmode=576cvbs\0" \
"display_width=1920\0" \
Expand Down Expand Up @@ -158,7 +158,7 @@
"else fi;"\
"\0"\
"storeargs="\
"setenv bootargs ${initargs} ${fs_type} otg_device=${otg_device} reboot_mode_android=${reboot_mode_android} logo=${display_layer},loaded,${fb_addr} fb_width=${fb_width} fb_height=${fb_height} vout2=${outputmode2},enable vout=${outputmode},enable panel_type=${panel_type} lcd_ctrl=${lcd_ctrl} hdmitx=${cecconfig},${colorattribute} hdmimode=${hdmimode} frac_rate_policy=${frac_rate_policy} hdmi_read_edid=${hdmi_read_edid} cvbsmode=${cvbsmode} osd_reverse=${osd_reverse} video_reverse=${video_reverse} irq_check_en=${Irq_check_en} androidboot.selinux=${EnableSelinux} androidboot.firstboot=${firstboot} jtag=${jtag} wol_enable=${wol_enable} hwver=${hwver} spi_state=${spi_state} fusb302_state=${fusb302_state} factory_mac=${factory_mac}; "\
"setenv bootargs ${initargs} ${fs_type} otg_device=${otg_device} reboot_mode_android=${reboot_mode_android} logo=${display_layer},loaded,${fb_addr} fb_width=${fb_width} fb_height=${fb_height} vout2=${outputmode2},enable vout=${outputmode},enable panel_type=${panel_type} lcd_ctrl=${lcd_ctrl} hdmitx=${cecconfig},${colorattribute} hdmimode=${hdmimode} frac_rate_policy=${frac_rate_policy} hdmi_read_edid=${hdmi_read_edid} cvbsmode=${cvbsmode} osd_reverse=${osd_reverse} video_reverse=${video_reverse} irq_check_en=${Irq_check_en} androidboot.selinux=${EnableSelinux} androidboot.firstboot=${firstboot} jtag=${jtag} wol_enable=${wol_enable} hwver=${hwver} spi_state=${spi_state} fusb302_state=${fusb302_state} factory_mac=${factory_mac} lcd_exist=${lcd_exist}; "\
"setenv bootargs ${bootargs} androidboot.hardware=amlogic;"\
"run cmdline_keys;"\
"\0"\
Expand Down Expand Up @@ -292,7 +292,11 @@
"else "\
"setenv reboot_mode_android ""normal"";"\
"run storeargs;"\
"hdmitx hpd;hdmitx get_preferred_mode;osd dual_logo;vpp hdrpkt;"\
"if test ${lcd_exist} = 0; then "\
"hdmitx hpd;hdmitx get_preferred_mode;osd open;osd clear;imgread pic logo bootup $loadaddr;bmp display $bootup_offset;bmp scale;vout output ${outputmode};vpp hdrpkt;"\
"else "\
"hdmitx hpd;hdmitx get_preferred_mode;osd dual_logo;vpp hdrpkt;"\
"fi;"\
"fi;fi;"\
"\0"\
"hwver_check="\
Expand Down Expand Up @@ -320,6 +324,13 @@
"kbi poweroff;"\
"fi;"\
"\0"\
"display_config="\
"fdt addr ${dtb_mem_addr}; "\
"if test ${lcd_exist} = 0; then "\
"fdt set /lcd status disable;"\
"fdt set /backlight status disable;"\
"fi;"\
"\0"\
"port_mode_change="\
"fdt addr ${dtb_mem_addr}; "\
"kbi portmode r;"\
Expand Down Expand Up @@ -374,6 +385,7 @@
"run factory_reset_poweroff_protect;"\
"run upgrade_check;"\
"run init_display;"\
"run display_config;"\
"run wol_init;"\
"run spi_check;"\
"run hwver_check;"\
Expand Down
26 changes: 26 additions & 0 deletions board/khadas/kvim3/kvim3.c
Expand Up @@ -627,6 +627,29 @@ U_BOOT_DEVICES(meson_pwm) = {
};
#endif /*end CONFIG_PWM_MESON*/

#if (defined (CONFIG_AML_LCD) && defined(CONFIG_TCA6408))
// detect whether the LCD is exist
void board_lcd_detect(void)
{
u8 mask = 0, value = 0;
int ret = 0;

// detect RESET pin
// if the LCD is connected, the RESET pin will be plll high
// if the LCD is not connected, the RESET pin will be low
mask = TCA_LCD_RESET_MASK;

ret = tca6408_get_value(&value, mask);
if (ret) {
printf("%s: failed to read LCD_RESET status! error: %d\n", __func__, ret);
return;
}

printf("LCD_RESET PIN: %d\n", value);
setenv_ulong("lcd_exist", value);
}
#endif /* CONFIG_AML_LCD */

extern void aml_pwm_cal_init(int mode);

int board_init(void)
Expand Down Expand Up @@ -725,6 +748,9 @@ int board_late_init(void)
run_command("cvbs init", 0);
#endif
#ifdef CONFIG_AML_LCD
#ifdef CONFIG_TCA6408
board_lcd_detect();
#endif
lcd_probe();
#endif

Expand Down
25 changes: 25 additions & 0 deletions board/khadas/kvim3l/kvim3l.c
Expand Up @@ -594,6 +594,28 @@ U_BOOT_DEVICES(meson_pwm) = {
};
#endif /*end CONFIG_PWM_MESON*/

#if (defined (CONFIG_AML_LCD) && defined(CONFIG_TCA6408))
// detect whether the LCD is exist
void board_lcd_detect(void)
{
u8 mask = 0, value = 0;
int ret = 0;

// detect RESET pin
// if the LCD is connected, the RESET pin will be plll high
// if the LCD is not connected, the RESET pin will be low
mask = TCA_LCD_RESET_MASK;

ret = tca6408_get_value(&value, mask);
if (ret) {
printf("%s: failed to read LCD_RESET status! error: %d\n", __func__, ret);
return;
}

printf("LCD_RESET PIN: %d\n", value);
setenv_ulong("lcd_exist", value);
}
#endif /* CONFIG_AML_LCD */
int board_init(void)
{
sys_led_init();
Expand Down Expand Up @@ -742,6 +764,9 @@ int board_late_init(void)
run_command("cvbs init", 0);
#endif
#ifdef CONFIG_AML_LCD
#ifdef CONFIG_TCA6408
board_lcd_detect();
#endif
lcd_probe();
#endif

Expand Down
9 changes: 6 additions & 3 deletions common/cmd_hdmitx.c
Expand Up @@ -35,7 +35,7 @@ static int do_hpd_detect(cmd_tbl_t *cmdtp, int flag, int argc,
{
#ifdef CONFIG_AML_LCD
struct aml_lcd_drv_s *lcd_drv = NULL;
char *mode;
char *mode, *lcd_exist;
#endif
int st;

Expand All @@ -44,8 +44,11 @@ static int do_hpd_detect(cmd_tbl_t *cmdtp, int flag, int argc,
if (lcd_drv) {
if (lcd_drv->lcd_outputmode_check) {
mode = getenv("outputmode");
if (lcd_drv->lcd_outputmode_check(mode) == 0)
return 0;
if (lcd_drv->lcd_outputmode_check(mode) == 0) {
lcd_exist = getenv("lcd_exist");
if (0 == strcmp(lcd_exist, "1"))
return 0;
}
}
}
#endif
Expand Down
21 changes: 16 additions & 5 deletions common/cmd_osd.c
Expand Up @@ -253,6 +253,8 @@ static int do_osd_get(cmd_tbl_t *cmdtp, int flag, int argc,
static int do_osd_dual_logo(cmd_tbl_t *cmdtp, int flag, int argc,
char *const argv[])
{
char *lcd_exist;
lcd_exist = getenv("lcd_exist");
#ifdef CONFIG_AML_HDMITX20
int st = 0;

Expand All @@ -262,11 +264,20 @@ static int do_osd_dual_logo(cmd_tbl_t *cmdtp, int flag, int argc,

if (st) {
/* hdmi plugin, dual logo display */
#if defined(CONFIG_DUAL_LOGO)
run_command(CONFIG_DUAL_LOGO, 0);
#else
printf("osd: dual logo cmd macro is not defined\n");
#endif
if (0 == strcmp(lcd_exist, "1")) {
#if defined(CONFIG_DUAL_LOGO)
run_command(CONFIG_DUAL_LOGO, 0);
#else
printf("osd: dual logo cmd macro is not defined\n");
#endif
} else {

#if defined(CONFIG_SINGLE_LOGO)
run_command(CONFIG_SINGLE_LOGO, 0);
#else
printf("osd: single logo cmd macro is not defined\n");
#endif
}
} else {
/* hdmi plugout, single logo display */
#if defined(CONFIG_SINGLE_LOGO)
Expand Down

0 comments on commit cf11480

Please sign in to comment.