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