Commit 1b68283b64a7a1847410eff20886bd7bbfd8f9a6
1 parent
7981394e55
Exists in
v2017.01-smarct4x
and in
25 other branches
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>
Showing 2 changed files with 27 additions and 1 deletions Side-by-side Diff
drivers/video/display-uclass.c
... | ... | @@ -23,10 +23,19 @@ |
23 | 23 | const struct display_timing *timing) |
24 | 24 | { |
25 | 25 | struct dm_display_ops *ops = display_get_ops(dev); |
26 | + struct display_plat *disp_uc_plat; | |
27 | + int ret; | |
26 | 28 | |
27 | 29 | if (!ops || !ops->enable) |
28 | 30 | return -ENOSYS; |
29 | - return ops->enable(dev, panel_bpp, timing); | |
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; | |
30 | 39 | } |
31 | 40 | |
32 | 41 | int display_read_timing(struct udevice *dev, struct display_timing *timing) |
... | ... | @@ -46,6 +55,13 @@ |
46 | 55 | return ret; |
47 | 56 | |
48 | 57 | return edid_get_timing(buf, ret, timing, &panel_bits_per_colour); |
58 | +} | |
59 | + | |
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; | |
49 | 65 | } |
50 | 66 | |
51 | 67 | UCLASS_DRIVER(display) = { |
include/display.h
... | ... | @@ -16,10 +16,12 @@ |
16 | 16 | * @source_id: ID for the source of the display data, typically a video |
17 | 17 | * controller |
18 | 18 | * @src_dev: Source device providing the video |
19 | + * @in_use: Display is being used | |
19 | 20 | */ |
20 | 21 | struct display_plat { |
21 | 22 | int source_id; |
22 | 23 | struct udevice *src_dev; |
24 | + bool in_use; | |
23 | 25 | }; |
24 | 26 | |
25 | 27 | /** |
... | ... | @@ -40,6 +42,14 @@ |
40 | 42 | */ |
41 | 43 | int display_enable(struct udevice *dev, int panel_bpp, |
42 | 44 | const struct display_timing *timing); |
45 | + | |
46 | +/** | |
47 | + * display_in_use() - Check if a display is in use by any device | |
48 | + * | |
49 | + * @return true if the device is in use (display_enable() has been called | |
50 | + * successfully), else false | |
51 | + */ | |
52 | +bool display_in_use(struct udevice *dev); | |
43 | 53 | |
44 | 54 | struct dm_display_ops { |
45 | 55 | /** |