blob: 00e9804565c200bc448fa1dd739183f236d22e9c [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Simon Glass7cf17572015-07-02 18:16:08 -06002/*
3 * Copyright (C) 2015 Google, Inc
4 * Written by Simon Glass <sjg@chromium.org>
Simon Glass7cf17572015-07-02 18:16:08 -06005 */
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 */
19struct 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 */
28struct 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);
Vasily Khoruzhick82e9a5a2017-09-20 23:29:07 -070055
56 /**
Svyatoslav Ryhelff9d0922025-02-14 10:57:05 +020057 * get_display_timing() - Get display timings from bridge.
58 *
59 * @dev: Bridge device containing the linked display timings
60 * @tim: Place to put timings
61 * @return 0 if OK, -ve on error
62 *
63 * This call it totally optional and useful mainly for integrated
64 * bridges with fixed output device.
65 */
66 int (*get_display_timing)(struct udevice *dev,
67 struct display_timing *timing);
68
69 /**
Vasily Khoruzhick82e9a5a2017-09-20 23:29:07 -070070 * read_edid() - Read information from EDID
71 *
72 * @dev: Device to read from
73 * @buf: Buffer to read into
74 * @buf_size: Buffer size
75 * @return number of bytes read, <=0 for error
76 */
77 int (*read_edid)(struct udevice *dev, u8 *buf, int buf_size);
Simon Glass7cf17572015-07-02 18:16:08 -060078};
79
80#define video_bridge_get_ops(dev) \
81 ((struct video_bridge_ops *)(dev)->driver->ops)
82
Svyatoslav Ryhele2ccbf12025-02-21 13:09:30 +020083#if CONFIG_IS_ENABLED(VIDEO_BRIDGE)
Simon Glass7cf17572015-07-02 18:16:08 -060084/**
85 * video_bridge_attach() - attach a video bridge
86 *
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +010087 * Return: 0 if OK, -ve on error
Simon Glass7cf17572015-07-02 18:16:08 -060088 */
89int video_bridge_attach(struct udevice *dev);
90
91/**
92 * video_bridge_set_backlight() - Set the backlight brightness
93 *
94 * @percent: brightness percentage (0=off, 100=full brightness)
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +010095 * Return: 0 if OK, -ve on error
Simon Glass7cf17572015-07-02 18:16:08 -060096 */
97int video_bridge_set_backlight(struct udevice *dev, int percent);
98
99/**
100 * video_bridge_set_active() - take the bridge in/out of reset/powerdown
101 *
102 * @dev: Device to adjust
103 * @active: true to power up and reset, false to power down
104 */
105int video_bridge_set_active(struct udevice *dev, bool active);
106
107/**
108 * check_attached() - check if a bridge is correctly attached
109 *
110 * @dev: Device to check
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +0100111 * Return: 0 if attached, -EENOTCONN if not, or other -ve error
Simon Glass7cf17572015-07-02 18:16:08 -0600112 */
113int video_bridge_check_attached(struct udevice *dev);
114
Vasily Khoruzhick82e9a5a2017-09-20 23:29:07 -0700115/**
Svyatoslav Ryhelff9d0922025-02-14 10:57:05 +0200116 * video_bridge_get_display_timing() - Get display timings from bridge.
117 *
118 * @dev: Bridge device containing the linked display timings
119 * Return: 0 if OK, -ve on error
120 */
121int video_bridge_get_display_timing(struct udevice *dev,
122 struct display_timing *timing);
123/**
Vasily Khoruzhick82e9a5a2017-09-20 23:29:07 -0700124 * video_bridge_read_edid() - Read information from EDID
125 *
126 * @dev: Device to read from
127 * @buf: Buffer to read into
128 * @buf_size: Buffer size
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +0100129 * Return: number of bytes read, <=0 for error
Vasily Khoruzhick82e9a5a2017-09-20 23:29:07 -0700130 */
131int video_bridge_read_edid(struct udevice *dev, u8 *buf, int buf_size);
Svyatoslav Ryhele2ccbf12025-02-21 13:09:30 +0200132#else
133static inline int video_bridge_attach(struct udevice *dev)
134{
135 return -ENOSYS;
136}
137
138static inline int video_bridge_set_backlight(struct udevice *dev, int percent)
139{
140 return -ENOSYS;
141}
142
143static inline int video_bridge_set_active(struct udevice *dev, bool active)
144{
145 return -ENOSYS;
146}
147
148static inline int video_bridge_check_attached(struct udevice *dev)
149{
150 return -ENOSYS;
151}
152
153static inline int video_bridge_get_display_timing(struct udevice *dev,
154 struct display_timing *timing)
155{
156 return -ENOSYS;
157}
158
159static inline int video_bridge_read_edid(struct udevice *dev, u8 *buf, int buf_size)
160{
161 return -ENOSYS;
162}
163#endif /* CONFIG_VIDEO_BRIDGE */
Vasily Khoruzhick82e9a5a2017-09-20 23:29:07 -0700164
Simon Glass7cf17572015-07-02 18:16:08 -0600165#endif