]>
Commit | Line | Data |
---|---|---|
2dcf1433 SG |
1 | /* |
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 | ||
13 | int 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 | ||
22 | int 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); | |
1b68283b SG |
26 | struct display_plat *disp_uc_plat; |
27 | int ret; | |
2dcf1433 SG |
28 | |
29 | if (!ops || !ops->enable) | |
30 | return -ENOSYS; | |
1b68283b SG |
31 | ret = ops->enable(dev, panel_bpp, timing); |
32 | if (ret) | |
33 | return ret; | |
34 | ||
35 | disp_uc_plat = dev_get_uclass_platdata(dev); | |
36 | disp_uc_plat->in_use = true; | |
37 | ||
38 | return 0; | |
2dcf1433 SG |
39 | } |
40 | ||
41 | int display_read_timing(struct udevice *dev, struct display_timing *timing) | |
42 | { | |
43 | struct dm_display_ops *ops = display_get_ops(dev); | |
44 | int panel_bits_per_colour; | |
45 | u8 buf[EDID_EXT_SIZE]; | |
46 | int ret; | |
47 | ||
eab314f5 JC |
48 | if (ops && ops->read_timing) |
49 | return ops->read_timing(dev, timing); | |
50 | ||
2dcf1433 SG |
51 | if (!ops || !ops->read_edid) |
52 | return -ENOSYS; | |
53 | ret = ops->read_edid(dev, buf, sizeof(buf)); | |
54 | if (ret < 0) | |
55 | return ret; | |
56 | ||
57 | return edid_get_timing(buf, ret, timing, &panel_bits_per_colour); | |
58 | } | |
59 | ||
1b68283b SG |
60 | bool display_in_use(struct udevice *dev) |
61 | { | |
62 | struct display_plat *disp_uc_plat = dev_get_uclass_platdata(dev); | |
63 | ||
64 | return disp_uc_plat->in_use; | |
65 | } | |
66 | ||
2dcf1433 SG |
67 | UCLASS_DRIVER(display) = { |
68 | .id = UCLASS_DISPLAY, | |
69 | .name = "display", | |
70 | .per_device_platdata_auto_alloc_size = sizeof(struct display_plat), | |
71 | }; |