Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Simon Glass | 7d3d776 | 2016-01-21 19:45:00 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2014 Google Inc. |
Simon Glass | 7d3d776 | 2016-01-21 19:45:00 -0700 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #ifndef _DISPLAY_H |
| 7 | #define _DISPLAY_H |
| 8 | |
| 9 | struct udevice; |
| 10 | struct display_timing; |
| 11 | |
| 12 | /** |
| 13 | * Display uclass platform data for each device |
| 14 | * |
| 15 | * @source_id: ID for the source of the display data, typically a video |
| 16 | * controller |
| 17 | * @src_dev: Source device providing the video |
Simon Glass | 365b7f7 | 2016-11-13 14:22:07 -0700 | [diff] [blame] | 18 | * @in_use: Display is being used |
Simon Glass | 7d3d776 | 2016-01-21 19:45:00 -0700 | [diff] [blame] | 19 | */ |
| 20 | struct display_plat { |
| 21 | int source_id; |
| 22 | struct udevice *src_dev; |
Simon Glass | 365b7f7 | 2016-11-13 14:22:07 -0700 | [diff] [blame] | 23 | bool in_use; |
Simon Glass | 7d3d776 | 2016-01-21 19:45:00 -0700 | [diff] [blame] | 24 | }; |
| 25 | |
| 26 | /** |
Jacob Chen | 4b28a90 | 2016-03-14 11:20:14 +0800 | [diff] [blame] | 27 | * display_read_timing() - Read timing information |
Simon Glass | 7d3d776 | 2016-01-21 19:45:00 -0700 | [diff] [blame] | 28 | * |
| 29 | * @dev: Device to read from |
Heinrich Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 30 | * Return: 0 if OK, -ve on error |
Simon Glass | 7d3d776 | 2016-01-21 19:45:00 -0700 | [diff] [blame] | 31 | */ |
| 32 | int display_read_timing(struct udevice *dev, struct display_timing *timing); |
| 33 | |
| 34 | /** |
| 35 | * display_port_enable() - Enable a display port device |
| 36 | * |
| 37 | * @dev: Device to enable |
| 38 | * @panel_bpp: Number of bits per pixel for panel |
| 39 | * @timing: Display timings |
Heinrich Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 40 | * Return: 0 if OK, -ve on error |
Simon Glass | 7d3d776 | 2016-01-21 19:45:00 -0700 | [diff] [blame] | 41 | */ |
| 42 | int display_enable(struct udevice *dev, int panel_bpp, |
| 43 | const struct display_timing *timing); |
| 44 | |
Simon Glass | 365b7f7 | 2016-11-13 14:22:07 -0700 | [diff] [blame] | 45 | /** |
| 46 | * display_in_use() - Check if a display is in use by any device |
| 47 | * |
Heinrich Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 48 | * Return: true if the device is in use (display_enable() has been called |
Simon Glass | 365b7f7 | 2016-11-13 14:22:07 -0700 | [diff] [blame] | 49 | * successfully), else false |
| 50 | */ |
| 51 | bool display_in_use(struct udevice *dev); |
| 52 | |
Simon Glass | 7d3d776 | 2016-01-21 19:45:00 -0700 | [diff] [blame] | 53 | struct dm_display_ops { |
| 54 | /** |
Jacob Chen | 4b28a90 | 2016-03-14 11:20:14 +0800 | [diff] [blame] | 55 | * read_timing() - Read information directly |
| 56 | * |
| 57 | * @dev: Device to read from |
| 58 | * @timing: Display timings |
| 59 | * @return 0 if OK, -ve on error |
| 60 | */ |
| 61 | int (*read_timing)(struct udevice *dev, struct display_timing *timing); |
| 62 | |
| 63 | /** |
Simon Glass | 7d3d776 | 2016-01-21 19:45:00 -0700 | [diff] [blame] | 64 | * read_edid() - Read information from EDID |
| 65 | * |
| 66 | * @dev: Device to read from |
| 67 | * @buf: Buffer to read into (should be EDID_SIZE bytes) |
| 68 | * @buf_size: Buffer size (should be EDID_SIZE) |
| 69 | * @return number of bytes read, <=0 for error |
| 70 | */ |
| 71 | int (*read_edid)(struct udevice *dev, u8 *buf, int buf_size); |
| 72 | |
| 73 | /** |
| 74 | * enable() - Enable the display port device |
| 75 | * |
| 76 | * @dev: Device to enable |
| 77 | * @panel_bpp: Number of bits per pixel for panel |
| 78 | * @timing: Display timings |
| 79 | * @return 0 if OK, -ve on error |
| 80 | */ |
| 81 | int (*enable)(struct udevice *dev, int panel_bpp, |
| 82 | const struct display_timing *timing); |
Neil Armstrong | faa419c | 2019-07-04 15:52:07 +0200 | [diff] [blame] | 83 | |
| 84 | /** |
| 85 | * mode_valid() - Check if mode is supported |
| 86 | * |
| 87 | * @dev: Device to enable |
| 88 | * @timing: Display timings |
| 89 | * @return true if supported, false if not |
| 90 | */ |
| 91 | bool (*mode_valid)(struct udevice *dev, |
| 92 | const struct display_timing *timing); |
Simon Glass | 7d3d776 | 2016-01-21 19:45:00 -0700 | [diff] [blame] | 93 | }; |
| 94 | |
| 95 | #define display_get_ops(dev) ((struct dm_display_ops *)(dev)->driver->ops) |
| 96 | |
| 97 | #endif |