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); 26 27 if (!ops || !ops->enable) 28 return -ENOSYS; 29 return ops->enable(dev, panel_bpp, timing); 30 } 31 32 int 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 39 if (ops && ops->read_timing) 40 return ops->read_timing(dev, timing); 41 42 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 51 UCLASS_DRIVER(display) = { 52 .id = UCLASS_DISPLAY, 53 .name = "display", 54 .per_device_platdata_auto_alloc_size = sizeof(struct display_plat), 55 }; 56