blob: 3b429eac578a4339490386c06915798044c92285 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Simon Glass801ab9e2015-07-02 18:16:08 -06002/*
3 * Copyright (C) 2015 Google, Inc
4 * Written by Simon Glass <sjg@chromium.org>
Simon Glass801ab9e2015-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 Khoruzhickfdb55252017-09-20 23:29:07 -070055
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);
Simon Glass801ab9e2015-07-02 18:16:08 -060065};
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 *
Heinrich Schuchardt185f8122022-01-19 18:05:50 +010073 * Return: 0 if OK, -ve on error
Simon Glass801ab9e2015-07-02 18:16:08 -060074 */
75int 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)
Heinrich Schuchardt185f8122022-01-19 18:05:50 +010081 * Return: 0 if OK, -ve on error
Simon Glass801ab9e2015-07-02 18:16:08 -060082 */
83int 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 */
91int 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
Heinrich Schuchardt185f8122022-01-19 18:05:50 +010097 * Return: 0 if attached, -EENOTCONN if not, or other -ve error
Simon Glass801ab9e2015-07-02 18:16:08 -060098 */
99int video_bridge_check_attached(struct udevice *dev);
100
Vasily Khoruzhickfdb55252017-09-20 23:29:07 -0700101/**
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
Heinrich Schuchardt185f8122022-01-19 18:05:50 +0100107 * Return: number of bytes read, <=0 for error
Vasily Khoruzhickfdb55252017-09-20 23:29:07 -0700108 */
109int video_bridge_read_edid(struct udevice *dev, u8 *buf, int buf_size);
110
Simon Glass801ab9e2015-07-02 18:16:08 -0600111#endif