Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Simon Glass | 7cf1757 | 2015-07-02 18:16:08 -0600 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2015 Google, Inc |
| 4 | * Written by Simon Glass <sjg@chromium.org> |
Simon Glass | 7cf1757 | 2015-07-02 18:16:08 -0600 | [diff] [blame] | 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); |
Vasily Khoruzhick | 82e9a5a | 2017-09-20 23:29:07 -0700 | [diff] [blame] | 55 | |
| 56 | /** |
Svyatoslav Ryhel | ff9d092 | 2025-02-14 10:57:05 +0200 | [diff] [blame] | 57 | * 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 Khoruzhick | 82e9a5a | 2017-09-20 23:29:07 -0700 | [diff] [blame] | 70 | * 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 Glass | 7cf1757 | 2015-07-02 18:16:08 -0600 | [diff] [blame] | 78 | }; |
| 79 | |
| 80 | #define video_bridge_get_ops(dev) \ |
| 81 | ((struct video_bridge_ops *)(dev)->driver->ops) |
| 82 | |
Svyatoslav Ryhel | e2ccbf1 | 2025-02-21 13:09:30 +0200 | [diff] [blame] | 83 | #if CONFIG_IS_ENABLED(VIDEO_BRIDGE) |
Simon Glass | 7cf1757 | 2015-07-02 18:16:08 -0600 | [diff] [blame] | 84 | /** |
| 85 | * video_bridge_attach() - attach a video bridge |
| 86 | * |
Heinrich Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 87 | * Return: 0 if OK, -ve on error |
Simon Glass | 7cf1757 | 2015-07-02 18:16:08 -0600 | [diff] [blame] | 88 | */ |
| 89 | int 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 Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 95 | * Return: 0 if OK, -ve on error |
Simon Glass | 7cf1757 | 2015-07-02 18:16:08 -0600 | [diff] [blame] | 96 | */ |
| 97 | int 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 | */ |
| 105 | int 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 Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 111 | * Return: 0 if attached, -EENOTCONN if not, or other -ve error |
Simon Glass | 7cf1757 | 2015-07-02 18:16:08 -0600 | [diff] [blame] | 112 | */ |
| 113 | int video_bridge_check_attached(struct udevice *dev); |
| 114 | |
Vasily Khoruzhick | 82e9a5a | 2017-09-20 23:29:07 -0700 | [diff] [blame] | 115 | /** |
Svyatoslav Ryhel | ff9d092 | 2025-02-14 10:57:05 +0200 | [diff] [blame] | 116 | * 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 | */ |
| 121 | int video_bridge_get_display_timing(struct udevice *dev, |
| 122 | struct display_timing *timing); |
| 123 | /** |
Vasily Khoruzhick | 82e9a5a | 2017-09-20 23:29:07 -0700 | [diff] [blame] | 124 | * 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 Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 129 | * Return: number of bytes read, <=0 for error |
Vasily Khoruzhick | 82e9a5a | 2017-09-20 23:29:07 -0700 | [diff] [blame] | 130 | */ |
| 131 | int video_bridge_read_edid(struct udevice *dev, u8 *buf, int buf_size); |
Svyatoslav Ryhel | e2ccbf1 | 2025-02-21 13:09:30 +0200 | [diff] [blame] | 132 | #else |
| 133 | static inline int video_bridge_attach(struct udevice *dev) |
| 134 | { |
| 135 | return -ENOSYS; |
| 136 | } |
| 137 | |
| 138 | static inline int video_bridge_set_backlight(struct udevice *dev, int percent) |
| 139 | { |
| 140 | return -ENOSYS; |
| 141 | } |
| 142 | |
| 143 | static inline int video_bridge_set_active(struct udevice *dev, bool active) |
| 144 | { |
| 145 | return -ENOSYS; |
| 146 | } |
| 147 | |
| 148 | static inline int video_bridge_check_attached(struct udevice *dev) |
| 149 | { |
| 150 | return -ENOSYS; |
| 151 | } |
| 152 | |
| 153 | static inline int video_bridge_get_display_timing(struct udevice *dev, |
| 154 | struct display_timing *timing) |
| 155 | { |
| 156 | return -ENOSYS; |
| 157 | } |
| 158 | |
| 159 | static 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 Khoruzhick | 82e9a5a | 2017-09-20 23:29:07 -0700 | [diff] [blame] | 164 | |
Simon Glass | 7cf1757 | 2015-07-02 18:16:08 -0600 | [diff] [blame] | 165 | #endif |