blob: e4763de73df5e312ee810eeda9edb8d066176bd9 [file] [log] [blame]
Simon Glass7d3d7762016-01-21 19:45:00 -07001/*
2 * Copyright 2014 Google Inc.
3 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6
7#include <common.h>
8#include <dm.h>
9#include <display.h>
10#include <edid.h>
11#include <errno.h>
12
13int display_read_edid(struct udevice *dev, u8 *buf, int buf_size)
14{
15 struct dm_display_ops *ops = display_get_ops(dev);
16
17 if (!ops || !ops->read_edid)
18 return -ENOSYS;
19 return ops->read_edid(dev, buf, buf_size);
20}
21
22int display_enable(struct udevice *dev, int panel_bpp,
23 const struct display_timing *timing)
24{
25 struct dm_display_ops *ops = display_get_ops(dev);
26
27 if (!ops || !ops->enable)
28 return -ENOSYS;
29 return ops->enable(dev, panel_bpp, timing);
30}
31
32int display_read_timing(struct udevice *dev, struct display_timing *timing)
33{
34 struct dm_display_ops *ops = display_get_ops(dev);
35 int panel_bits_per_colour;
36 u8 buf[EDID_EXT_SIZE];
37 int ret;
38
Jacob Chen4b28a902016-03-14 11:20:14 +080039 if (ops && ops->read_timing)
40 return ops->read_timing(dev, timing);
41
Simon Glass7d3d7762016-01-21 19:45:00 -070042 if (!ops || !ops->read_edid)
43 return -ENOSYS;
44 ret = ops->read_edid(dev, buf, sizeof(buf));
45 if (ret < 0)
46 return ret;
47
48 return edid_get_timing(buf, ret, timing, &panel_bits_per_colour);
49}
50
51UCLASS_DRIVER(display) = {
52 .id = UCLASS_DISPLAY,
53 .name = "display",
54 .per_device_platdata_auto_alloc_size = sizeof(struct display_plat),
55};