xref: /openbmc/u-boot/include/video_bridge.h (revision e8f80a5a)
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Copyright (C) 2015 Google, Inc
4  * Written by Simon Glass <sjg@chromium.org>
5  */
6 
7 #ifndef __VIDEO_BRIDGE
8 #define __VIDEO_BRIDGE
9 
10 #include <asm/gpio.h>
11 
12 /**
13  * struct video_bridge_priv - uclass information for video bridges
14  *
15  * @sleep:	GPIO to assert to power down the bridge
16  * @reset:	GPIO to assert to reset the bridge
17  * @hotplug:	Optional GPIO to check if bridge is connected
18  */
19 struct video_bridge_priv {
20 	struct gpio_desc sleep;
21 	struct gpio_desc reset;
22 	struct gpio_desc hotplug;
23 };
24 
25 /**
26  * Operations for video bridges
27  */
28 struct video_bridge_ops {
29 	/**
30 	 * attach() - attach a video bridge
31 	 *
32 	 * @return 0 if OK, -ve on error
33 	 */
34 	int (*attach)(struct udevice *dev);
35 
36 	/**
37 	 * check_attached() - check if a bridge is correctly attached
38 	 *
39 	 * This method is optional - if not provided then the hotplug GPIO
40 	 * will be checked instead.
41 	 *
42 	 * @dev:	Device to check
43 	 * @return 0 if attached, -EENOTCONN if not, or other -ve error
44 	 */
45 	int (*check_attached)(struct udevice *dev);
46 
47 	/**
48 	 * set_backlight() - Set the backlight brightness
49 	 *
50 	 * @dev:	device to adjust
51 	 * @percent:	brightness percentage (0=off, 100=full brightness)
52 	 * @return 0 if OK, -ve on error
53 	 */
54 	int (*set_backlight)(struct udevice *dev, int percent);
55 
56 	/**
57 	 * read_edid() - Read information from EDID
58 	 *
59 	 * @dev:	Device to read from
60 	 * @buf:	Buffer to read into
61 	 * @buf_size:	Buffer size
62 	 * @return number of bytes read, <=0 for error
63 	 */
64 	int (*read_edid)(struct udevice *dev, u8 *buf, int buf_size);
65 };
66 
67 #define video_bridge_get_ops(dev) \
68 		((struct video_bridge_ops *)(dev)->driver->ops)
69 
70 /**
71  * video_bridge_attach() - attach a video bridge
72  *
73  * @return 0 if OK, -ve on error
74  */
75 int video_bridge_attach(struct udevice *dev);
76 
77 /**
78  * video_bridge_set_backlight() - Set the backlight brightness
79  *
80  * @percent:	brightness percentage (0=off, 100=full brightness)
81  * @return 0 if OK, -ve on error
82  */
83 int video_bridge_set_backlight(struct udevice *dev, int percent);
84 
85 /**
86  * video_bridge_set_active() - take the bridge in/out of reset/powerdown
87  *
88  * @dev:	Device to adjust
89  * @active:	true to power up and reset, false to power down
90  */
91 int video_bridge_set_active(struct udevice *dev, bool active);
92 
93 /**
94  * check_attached() - check if a bridge is correctly attached
95  *
96  * @dev:	Device to check
97  * @return 0 if attached, -EENOTCONN if not, or other -ve error
98  */
99 int video_bridge_check_attached(struct udevice *dev);
100 
101 /**
102  * video_bridge_read_edid() - Read information from EDID
103  *
104  * @dev:	Device to read from
105  * @buf:	Buffer to read into
106  * @buf_size:	Buffer size
107  * @return number of bytes read, <=0 for error
108  */
109 int video_bridge_read_edid(struct udevice *dev, u8 *buf, int buf_size);
110 
111 #endif
112