video: Track whether a display is in use

Mark a display as in use when display_enable() is called. This can avoid
a display being used by multiple video-output devices.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass 2016-11-13 14:22:07 -07:00
parent 7981394e55
commit 1b68283b64
2 changed files with 27 additions and 1 deletions

View file

@ -23,10 +23,19 @@ 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;
return ops->enable(dev, panel_bpp, timing);
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;
}
int display_read_timing(struct udevice *dev, struct display_timing *timing)
@ -48,6 +57,13 @@ int display_read_timing(struct udevice *dev, struct display_timing *timing)
return edid_get_timing(buf, ret, timing, &panel_bits_per_colour);
}
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",

View file

@ -16,10 +16,12 @@ struct display_timing;
* @source_id: ID for the source of the display data, typically a video
* controller
* @src_dev: Source device providing the video
* @in_use: Display is being used
*/
struct display_plat {
int source_id;
struct udevice *src_dev;
bool in_use;
};
/**
@ -41,6 +43,14 @@ int display_read_timing(struct udevice *dev, struct display_timing *timing);
int display_enable(struct udevice *dev, int panel_bpp,
const struct display_timing *timing);
/**
* display_in_use() - Check if a display is in use by any device
*
* @return true if the device is in use (display_enable() has been called
* successfully), else false
*/
bool display_in_use(struct udevice *dev);
struct dm_display_ops {
/**
* read_timing() - Read information directly