1*83d290c5STom Rini /* SPDX-License-Identifier: GPL-2.0+ */ 2801ab9e9SSimon Glass /* 3801ab9e9SSimon Glass * Copyright (C) 2015 Google, Inc 4801ab9e9SSimon Glass * Written by Simon Glass <sjg@chromium.org> 5801ab9e9SSimon Glass */ 6801ab9e9SSimon Glass 7801ab9e9SSimon Glass #ifndef __VIDEO_BRIDGE 8801ab9e9SSimon Glass #define __VIDEO_BRIDGE 9801ab9e9SSimon Glass 10801ab9e9SSimon Glass #include <asm/gpio.h> 11801ab9e9SSimon Glass 12801ab9e9SSimon Glass /** 13801ab9e9SSimon Glass * struct video_bridge_priv - uclass information for video bridges 14801ab9e9SSimon Glass * 15801ab9e9SSimon Glass * @sleep: GPIO to assert to power down the bridge 16801ab9e9SSimon Glass * @reset: GPIO to assert to reset the bridge 17801ab9e9SSimon Glass * @hotplug: Optional GPIO to check if bridge is connected 18801ab9e9SSimon Glass */ 19801ab9e9SSimon Glass struct video_bridge_priv { 20801ab9e9SSimon Glass struct gpio_desc sleep; 21801ab9e9SSimon Glass struct gpio_desc reset; 22801ab9e9SSimon Glass struct gpio_desc hotplug; 23801ab9e9SSimon Glass }; 24801ab9e9SSimon Glass 25801ab9e9SSimon Glass /** 26801ab9e9SSimon Glass * Operations for video bridges 27801ab9e9SSimon Glass */ 28801ab9e9SSimon Glass struct video_bridge_ops { 29801ab9e9SSimon Glass /** 30801ab9e9SSimon Glass * attach() - attach a video bridge 31801ab9e9SSimon Glass * 32801ab9e9SSimon Glass * @return 0 if OK, -ve on error 33801ab9e9SSimon Glass */ 34801ab9e9SSimon Glass int (*attach)(struct udevice *dev); 35801ab9e9SSimon Glass 36801ab9e9SSimon Glass /** 37801ab9e9SSimon Glass * check_attached() - check if a bridge is correctly attached 38801ab9e9SSimon Glass * 39801ab9e9SSimon Glass * This method is optional - if not provided then the hotplug GPIO 40801ab9e9SSimon Glass * will be checked instead. 41801ab9e9SSimon Glass * 42801ab9e9SSimon Glass * @dev: Device to check 43801ab9e9SSimon Glass * @return 0 if attached, -EENOTCONN if not, or other -ve error 44801ab9e9SSimon Glass */ 45801ab9e9SSimon Glass int (*check_attached)(struct udevice *dev); 46801ab9e9SSimon Glass 47801ab9e9SSimon Glass /** 48801ab9e9SSimon Glass * set_backlight() - Set the backlight brightness 49801ab9e9SSimon Glass * 50801ab9e9SSimon Glass * @dev: device to adjust 51801ab9e9SSimon Glass * @percent: brightness percentage (0=off, 100=full brightness) 52801ab9e9SSimon Glass * @return 0 if OK, -ve on error 53801ab9e9SSimon Glass */ 54801ab9e9SSimon Glass int (*set_backlight)(struct udevice *dev, int percent); 55fdb55255SVasily Khoruzhick 56fdb55255SVasily Khoruzhick /** 57fdb55255SVasily Khoruzhick * read_edid() - Read information from EDID 58fdb55255SVasily Khoruzhick * 59fdb55255SVasily Khoruzhick * @dev: Device to read from 60fdb55255SVasily Khoruzhick * @buf: Buffer to read into 61fdb55255SVasily Khoruzhick * @buf_size: Buffer size 62fdb55255SVasily Khoruzhick * @return number of bytes read, <=0 for error 63fdb55255SVasily Khoruzhick */ 64fdb55255SVasily Khoruzhick int (*read_edid)(struct udevice *dev, u8 *buf, int buf_size); 65801ab9e9SSimon Glass }; 66801ab9e9SSimon Glass 67801ab9e9SSimon Glass #define video_bridge_get_ops(dev) \ 68801ab9e9SSimon Glass ((struct video_bridge_ops *)(dev)->driver->ops) 69801ab9e9SSimon Glass 70801ab9e9SSimon Glass /** 71801ab9e9SSimon Glass * video_bridge_attach() - attach a video bridge 72801ab9e9SSimon Glass * 73801ab9e9SSimon Glass * @return 0 if OK, -ve on error 74801ab9e9SSimon Glass */ 75801ab9e9SSimon Glass int video_bridge_attach(struct udevice *dev); 76801ab9e9SSimon Glass 77801ab9e9SSimon Glass /** 78801ab9e9SSimon Glass * video_bridge_set_backlight() - Set the backlight brightness 79801ab9e9SSimon Glass * 80801ab9e9SSimon Glass * @percent: brightness percentage (0=off, 100=full brightness) 81801ab9e9SSimon Glass * @return 0 if OK, -ve on error 82801ab9e9SSimon Glass */ 83801ab9e9SSimon Glass int video_bridge_set_backlight(struct udevice *dev, int percent); 84801ab9e9SSimon Glass 85801ab9e9SSimon Glass /** 86801ab9e9SSimon Glass * video_bridge_set_active() - take the bridge in/out of reset/powerdown 87801ab9e9SSimon Glass * 88801ab9e9SSimon Glass * @dev: Device to adjust 89801ab9e9SSimon Glass * @active: true to power up and reset, false to power down 90801ab9e9SSimon Glass */ 91801ab9e9SSimon Glass int video_bridge_set_active(struct udevice *dev, bool active); 92801ab9e9SSimon Glass 93801ab9e9SSimon Glass /** 94801ab9e9SSimon Glass * check_attached() - check if a bridge is correctly attached 95801ab9e9SSimon Glass * 96801ab9e9SSimon Glass * @dev: Device to check 97801ab9e9SSimon Glass * @return 0 if attached, -EENOTCONN if not, or other -ve error 98801ab9e9SSimon Glass */ 99801ab9e9SSimon Glass int video_bridge_check_attached(struct udevice *dev); 100801ab9e9SSimon Glass 101fdb55255SVasily Khoruzhick /** 102fdb55255SVasily Khoruzhick * video_bridge_read_edid() - Read information from EDID 103fdb55255SVasily Khoruzhick * 104fdb55255SVasily Khoruzhick * @dev: Device to read from 105fdb55255SVasily Khoruzhick * @buf: Buffer to read into 106fdb55255SVasily Khoruzhick * @buf_size: Buffer size 107fdb55255SVasily Khoruzhick * @return number of bytes read, <=0 for error 108fdb55255SVasily Khoruzhick */ 109fdb55255SVasily Khoruzhick int video_bridge_read_edid(struct udevice *dev, u8 *buf, int buf_size); 110fdb55255SVasily Khoruzhick 111801ab9e9SSimon Glass #endif 112