blob: e8d8aaa15fbcbf0b2bcaeec0d612ad66346d28c3 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Simon Glass2dcf1432016-01-21 19:45:00 -07002/*
3 * Copyright 2014 Google Inc.
Simon Glass2dcf1432016-01-21 19:45:00 -07004 */
5
6#ifndef _DISPLAY_H
7#define _DISPLAY_H
8
Tom Rini03de3052024-05-20 13:35:03 -06009#include <linux/types.h>
10
Simon Glass2dcf1432016-01-21 19:45:00 -070011struct udevice;
12struct display_timing;
13
14/**
15 * Display uclass platform data for each device
16 *
17 * @source_id: ID for the source of the display data, typically a video
18 * controller
19 * @src_dev: Source device providing the video
Simon Glass1b682832016-11-13 14:22:07 -070020 * @in_use: Display is being used
Simon Glass2dcf1432016-01-21 19:45:00 -070021 */
22struct display_plat {
23 int source_id;
24 struct udevice *src_dev;
Simon Glass1b682832016-11-13 14:22:07 -070025 bool in_use;
Simon Glass2dcf1432016-01-21 19:45:00 -070026};
27
28/**
Jacob Cheneab314f2016-03-14 11:20:14 +080029 * display_read_timing() - Read timing information
Simon Glass2dcf1432016-01-21 19:45:00 -070030 *
31 * @dev: Device to read from
Heinrich Schuchardt185f8122022-01-19 18:05:50 +010032 * Return: 0 if OK, -ve on error
Simon Glass2dcf1432016-01-21 19:45:00 -070033 */
34int display_read_timing(struct udevice *dev, struct display_timing *timing);
35
36/**
37 * display_port_enable() - Enable a display port device
38 *
39 * @dev: Device to enable
40 * @panel_bpp: Number of bits per pixel for panel
41 * @timing: Display timings
Heinrich Schuchardt185f8122022-01-19 18:05:50 +010042 * Return: 0 if OK, -ve on error
Simon Glass2dcf1432016-01-21 19:45:00 -070043 */
44int display_enable(struct udevice *dev, int panel_bpp,
45 const struct display_timing *timing);
46
Simon Glass1b682832016-11-13 14:22:07 -070047/**
48 * display_in_use() - Check if a display is in use by any device
49 *
Heinrich Schuchardt185f8122022-01-19 18:05:50 +010050 * Return: true if the device is in use (display_enable() has been called
Simon Glass1b682832016-11-13 14:22:07 -070051 * successfully), else false
52 */
53bool display_in_use(struct udevice *dev);
54
Simon Glass2dcf1432016-01-21 19:45:00 -070055struct dm_display_ops {
56 /**
Jacob Cheneab314f2016-03-14 11:20:14 +080057 * read_timing() - Read information directly
58 *
59 * @dev: Device to read from
60 * @timing: Display timings
61 * @return 0 if OK, -ve on error
62 */
63 int (*read_timing)(struct udevice *dev, struct display_timing *timing);
64
65 /**
Simon Glass2dcf1432016-01-21 19:45:00 -070066 * read_edid() - Read information from EDID
67 *
68 * @dev: Device to read from
69 * @buf: Buffer to read into (should be EDID_SIZE bytes)
70 * @buf_size: Buffer size (should be EDID_SIZE)
71 * @return number of bytes read, <=0 for error
72 */
73 int (*read_edid)(struct udevice *dev, u8 *buf, int buf_size);
74
75 /**
76 * enable() - Enable the display port device
77 *
78 * @dev: Device to enable
79 * @panel_bpp: Number of bits per pixel for panel
80 * @timing: Display timings
81 * @return 0 if OK, -ve on error
82 */
83 int (*enable)(struct udevice *dev, int panel_bpp,
84 const struct display_timing *timing);
Neil Armstrongeb4ee4e2019-07-04 15:52:07 +020085
86 /**
87 * mode_valid() - Check if mode is supported
88 *
89 * @dev: Device to enable
90 * @timing: Display timings
91 * @return true if supported, false if not
92 */
93 bool (*mode_valid)(struct udevice *dev,
94 const struct display_timing *timing);
Simon Glass2dcf1432016-01-21 19:45:00 -070095};
96
97#define display_get_ops(dev) ((struct dm_display_ops *)(dev)->driver->ops)
98
99#endif