Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Simon Glass | 2dcf143 | 2016-01-21 19:45:00 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2014 Google Inc. |
Simon Glass | 2dcf143 | 2016-01-21 19:45:00 -0700 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #ifndef _DISPLAY_H |
| 7 | #define _DISPLAY_H |
| 8 | |
Tom Rini | 03de305 | 2024-05-20 13:35:03 -0600 | [diff] [blame] | 9 | #include <linux/types.h> |
| 10 | |
Simon Glass | 2dcf143 | 2016-01-21 19:45:00 -0700 | [diff] [blame] | 11 | struct udevice; |
| 12 | struct 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 Glass | 1b68283 | 2016-11-13 14:22:07 -0700 | [diff] [blame] | 20 | * @in_use: Display is being used |
Simon Glass | 2dcf143 | 2016-01-21 19:45:00 -0700 | [diff] [blame] | 21 | */ |
| 22 | struct display_plat { |
| 23 | int source_id; |
| 24 | struct udevice *src_dev; |
Simon Glass | 1b68283 | 2016-11-13 14:22:07 -0700 | [diff] [blame] | 25 | bool in_use; |
Simon Glass | 2dcf143 | 2016-01-21 19:45:00 -0700 | [diff] [blame] | 26 | }; |
| 27 | |
| 28 | /** |
Jacob Chen | eab314f | 2016-03-14 11:20:14 +0800 | [diff] [blame] | 29 | * display_read_timing() - Read timing information |
Simon Glass | 2dcf143 | 2016-01-21 19:45:00 -0700 | [diff] [blame] | 30 | * |
| 31 | * @dev: Device to read from |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 32 | * Return: 0 if OK, -ve on error |
Simon Glass | 2dcf143 | 2016-01-21 19:45:00 -0700 | [diff] [blame] | 33 | */ |
| 34 | int 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 Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 42 | * Return: 0 if OK, -ve on error |
Simon Glass | 2dcf143 | 2016-01-21 19:45:00 -0700 | [diff] [blame] | 43 | */ |
| 44 | int display_enable(struct udevice *dev, int panel_bpp, |
| 45 | const struct display_timing *timing); |
| 46 | |
Simon Glass | 1b68283 | 2016-11-13 14:22:07 -0700 | [diff] [blame] | 47 | /** |
| 48 | * display_in_use() - Check if a display is in use by any device |
| 49 | * |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 50 | * Return: true if the device is in use (display_enable() has been called |
Simon Glass | 1b68283 | 2016-11-13 14:22:07 -0700 | [diff] [blame] | 51 | * successfully), else false |
| 52 | */ |
| 53 | bool display_in_use(struct udevice *dev); |
| 54 | |
Simon Glass | 2dcf143 | 2016-01-21 19:45:00 -0700 | [diff] [blame] | 55 | struct dm_display_ops { |
| 56 | /** |
Jacob Chen | eab314f | 2016-03-14 11:20:14 +0800 | [diff] [blame] | 57 | * 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 Glass | 2dcf143 | 2016-01-21 19:45:00 -0700 | [diff] [blame] | 66 | * 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 Armstrong | eb4ee4e | 2019-07-04 15:52:07 +0200 | [diff] [blame] | 85 | |
| 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 Glass | 2dcf143 | 2016-01-21 19:45:00 -0700 | [diff] [blame] | 95 | }; |
| 96 | |
| 97 | #define display_get_ops(dev) ((struct dm_display_ops *)(dev)->driver->ops) |
| 98 | |
| 99 | #endif |