xref: /openbmc/u-boot/include/display.h (revision ebce73f0)
1 /*
2  * Copyright 2014 Google Inc.
3  *
4  * SPDX-License-Identifier:     GPL-2.0+
5  */
6 
7 #ifndef _DISPLAY_H
8 #define _DISPLAY_H
9 
10 struct udevice;
11 struct display_timing;
12 
13 /**
14  * Display uclass platform data for each device
15  *
16  * @source_id:	ID for the source of the display data, typically a video
17  * controller
18  * @src_dev:	Source device providing the video
19  * @in_use:	Display is being used
20  */
21 struct display_plat {
22 	int source_id;
23 	struct udevice *src_dev;
24 	bool in_use;
25 };
26 
27 /**
28  * display_read_timing() - Read timing information
29  *
30  * @dev:	Device to read from
31  * @return 0 if OK, -ve on error
32  */
33 int display_read_timing(struct udevice *dev, struct display_timing *timing);
34 
35 /**
36  * display_port_enable() - Enable a display port device
37  *
38  * @dev:	Device to enable
39  * @panel_bpp:	Number of bits per pixel for panel
40  * @timing:	Display timings
41  * @return 0 if OK, -ve on error
42  */
43 int display_enable(struct udevice *dev, int panel_bpp,
44 		   const struct display_timing *timing);
45 
46 /**
47  * display_in_use() - Check if a display is in use by any device
48  *
49  * @return true if the device is in use (display_enable() has been called
50  * successfully), else false
51  */
52 bool display_in_use(struct udevice *dev);
53 
54 struct dm_display_ops {
55 	/**
56 	 * read_timing() - Read information directly
57 	 *
58 	 * @dev:	Device to read from
59 	 * @timing:	Display timings
60 	 * @return 0 if OK, -ve on error
61 	 */
62 	int (*read_timing)(struct udevice *dev, struct display_timing *timing);
63 
64 	/**
65 	 * read_edid() - Read information from EDID
66 	 *
67 	 * @dev:	Device to read from
68 	 * @buf:	Buffer to read into (should be EDID_SIZE bytes)
69 	 * @buf_size:	Buffer size (should be EDID_SIZE)
70 	 * @return number of bytes read, <=0 for error
71 	 */
72 	int (*read_edid)(struct udevice *dev, u8 *buf, int buf_size);
73 
74 	/**
75 	 * enable() - Enable the display port device
76 	 *
77 	 * @dev:	Device to enable
78 	 * @panel_bpp:	Number of bits per pixel for panel
79 	 * @timing:	Display timings
80 	 * @return 0 if OK, -ve on error
81 	 */
82 	int (*enable)(struct udevice *dev, int panel_bpp,
83 		      const struct display_timing *timing);
84 };
85 
86 #define display_get_ops(dev)	((struct dm_display_ops *)(dev)->driver->ops)
87 
88 #endif
89