mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-06-09 23:36:03 +09:00
![Simon Glass](/assets/img/avatar_default.png)
This construct is quite long-winded. In earlier days it made some sense since auto-allocation was a strange concept. But with driver model now used pretty universally, we can shorten this to 'auto'. This reduces verbosity and makes it easier to read. Coincidentally it also ensures that every declaration is on one line, thus making dtoc's job easier. Signed-off-by: Simon Glass <sjg@chromium.org>
84 lines
1.8 KiB
C
84 lines
1.8 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* Copyright 2014 Google Inc.
|
|
*/
|
|
|
|
#include <common.h>
|
|
#include <dm.h>
|
|
#include <display.h>
|
|
#include <edid.h>
|
|
#include <errno.h>
|
|
|
|
int display_read_edid(struct udevice *dev, u8 *buf, int buf_size)
|
|
{
|
|
struct dm_display_ops *ops = display_get_ops(dev);
|
|
|
|
if (!ops || !ops->read_edid)
|
|
return -ENOSYS;
|
|
return ops->read_edid(dev, buf, buf_size);
|
|
}
|
|
|
|
int display_enable(struct udevice *dev, int panel_bpp,
|
|
const struct display_timing *timing)
|
|
{
|
|
struct dm_display_ops *ops = display_get_ops(dev);
|
|
struct display_plat *disp_uc_plat;
|
|
int ret;
|
|
|
|
if (!ops || !ops->enable)
|
|
return -ENOSYS;
|
|
ret = ops->enable(dev, panel_bpp, timing);
|
|
if (ret)
|
|
return ret;
|
|
|
|
disp_uc_plat = dev_get_uclass_platdata(dev);
|
|
disp_uc_plat->in_use = true;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static bool display_mode_valid(void *priv, const struct display_timing *timing)
|
|
{
|
|
struct udevice *dev = priv;
|
|
struct dm_display_ops *ops = display_get_ops(dev);
|
|
|
|
if (ops && ops->mode_valid)
|
|
return ops->mode_valid(dev, timing);
|
|
|
|
return true;
|
|
}
|
|
|
|
int display_read_timing(struct udevice *dev, struct display_timing *timing)
|
|
{
|
|
struct dm_display_ops *ops = display_get_ops(dev);
|
|
int panel_bits_per_colour;
|
|
u8 buf[EDID_EXT_SIZE];
|
|
int ret;
|
|
|
|
if (ops && ops->read_timing)
|
|
return ops->read_timing(dev, timing);
|
|
|
|
if (!ops || !ops->read_edid)
|
|
return -ENOSYS;
|
|
ret = ops->read_edid(dev, buf, sizeof(buf));
|
|
if (ret < 0)
|
|
return ret;
|
|
|
|
return edid_get_timing_validate(buf, ret, timing,
|
|
&panel_bits_per_colour,
|
|
display_mode_valid, dev);
|
|
}
|
|
|
|
bool display_in_use(struct udevice *dev)
|
|
{
|
|
struct display_plat *disp_uc_plat = dev_get_uclass_platdata(dev);
|
|
|
|
return disp_uc_plat->in_use;
|
|
}
|
|
|
|
UCLASS_DRIVER(display) = {
|
|
.id = UCLASS_DISPLAY,
|
|
.name = "display",
|
|
.per_device_platdata_auto = sizeof(struct display_plat),
|
|
};
|