2 * Copyright (C) 2015 Google, Inc
3 * Written by Simon Glass <sjg@chromium.org>
5 * SPDX-License-Identifier: GPL-2.0+
12 #include <video_bridge.h>
14 int video_bridge_set_backlight(struct udevice *dev, int percent)
16 struct video_bridge_ops *ops = video_bridge_get_ops(dev);
18 if (!ops->set_backlight)
21 return ops->set_backlight(dev, percent);
24 int video_bridge_attach(struct udevice *dev)
26 struct video_bridge_ops *ops = video_bridge_get_ops(dev);
31 return ops->attach(dev);
34 int video_bridge_check_attached(struct udevice *dev)
36 struct video_bridge_priv *uc_priv = dev_get_uclass_priv(dev);
37 struct video_bridge_ops *ops = video_bridge_get_ops(dev);
40 if (!ops->check_attached) {
41 ret = dm_gpio_get_value(&uc_priv->hotplug);
43 return ret > 0 ? 0 : ret == 0 ? -ENOTCONN : ret;
46 return ops->check_attached(dev);
49 int video_bridge_read_edid(struct udevice *dev, u8 *buf, int buf_size)
51 struct video_bridge_ops *ops = video_bridge_get_ops(dev);
53 if (!ops || !ops->read_edid)
55 return ops->read_edid(dev, buf, buf_size);
58 static int video_bridge_pre_probe(struct udevice *dev)
60 struct video_bridge_priv *uc_priv = dev_get_uclass_priv(dev);
63 debug("%s\n", __func__);
64 ret = gpio_request_by_name(dev, "sleep-gpios", 0,
65 &uc_priv->sleep, GPIOD_IS_OUT);
67 debug("%s: Could not decode sleep-gpios (%d)\n", __func__, ret);
72 * Drop this for now as we do not have driver model pinctrl support
74 * ret = dm_gpio_set_pull(&uc_priv->sleep, GPIO_PULL_NONE);
76 * debug("%s: Could not set sleep pull value\n", __func__);
80 ret = gpio_request_by_name(dev, "reset-gpios", 0, &uc_priv->reset,
83 debug("%s: Could not decode reset-gpios (%d)\n", __func__, ret);
88 * Drop this for now as we do not have driver model pinctrl support
90 * ret = dm_gpio_set_pull(&uc_priv->reset, GPIO_PULL_NONE);
92 * debug("%s: Could not set reset pull value\n", __func__);
96 ret = gpio_request_by_name(dev, "hotplug-gpios", 0, &uc_priv->hotplug,
99 debug("%s: Could not decode hotplug (%d)\n", __func__, ret);
107 int video_bridge_set_active(struct udevice *dev, bool active)
109 struct video_bridge_priv *uc_priv = dev_get_uclass_priv(dev);
112 debug("%s: %d\n", __func__, active);
113 ret = dm_gpio_set_value(&uc_priv->sleep, !active);
117 ret = dm_gpio_set_value(&uc_priv->reset, true);
121 ret = dm_gpio_set_value(&uc_priv->reset, false);
127 UCLASS_DRIVER(video_bridge) = {
128 .id = UCLASS_VIDEO_BRIDGE,
129 .name = "video_bridge",
130 .per_device_auto_alloc_size = sizeof(struct video_bridge_priv),
131 .pre_probe = video_bridge_pre_probe,