• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0+
2 
3 #include <common.h>
4 #include <env.h>
5 #include <linux/errno.h>
6 #include <asm/mach-imx/video.h>
7 
8 #ifdef CONFIG_IMX_HDMI
9 #include <asm/arch/mxc_hdmi.h>
10 #include <asm/io.h>
11 
detect_hdmi(struct display_info_t const * dev)12 int detect_hdmi(struct display_info_t const *dev)
13 {
14 	struct hdmi_regs *hdmi	= (struct hdmi_regs *)HDMI_ARB_BASE_ADDR;
15 	return readb(&hdmi->phy_stat0) & HDMI_DVI_STAT;
16 }
17 #endif
18 
board_video_skip(void)19 int board_video_skip(void)
20 {
21 	int i;
22 	int ret = 0;
23 	char const *panel = env_get("panel");
24 
25 	if (!panel) {
26 		for (i = 0; i < display_count; i++) {
27 			struct display_info_t const *dev = displays+i;
28 			if (dev->detect && dev->detect(dev)) {
29 				panel = dev->mode.name;
30 				printf("auto-detected panel %s\n", panel);
31 				break;
32 			}
33 		}
34 		if (!panel) {
35 			panel = displays[0].mode.name;
36 			printf("No panel detected: default to %s\n", panel);
37 			i = 0;
38 		}
39 	} else {
40 		for (i = 0; i < display_count; i++) {
41 			if (!strcmp(panel, displays[i].mode.name))
42 				break;
43 		}
44 	}
45 
46 	if (i < display_count) {
47 		ret = ipuv3_fb_init(&displays[i].mode, displays[i].di ? 1 : 0,
48 				    displays[i].pixfmt);
49 		if (!ret) {
50 			if (displays[i].enable)
51 				displays[i].enable(displays + i);
52 
53 			printf("Display: %s (%ux%u)\n",
54 			       displays[i].mode.name,
55 			       displays[i].mode.xres,
56 			       displays[i].mode.yres);
57 
58 #ifdef CONFIG_IMX_HDMI
59 			if (!strcmp(displays[i].mode.name, "HDMI"))
60 				imx_enable_hdmi_phy();
61 #endif
62 		} else
63 			printf("LCD %s cannot be configured: %d\n",
64 			       displays[i].mode.name, ret);
65 	} else {
66 		printf("unsupported panel %s\n", panel);
67 		return -EINVAL;
68 	}
69 
70 	return ret;
71 }
72 
ipu_displays_init(void)73 int ipu_displays_init(void)
74 {
75 	return board_video_skip();
76 }
77