1 /* SPDX-License-Identifier: GPL-2.0+ */ 2 /* 3 * Copyright 2014 Google Inc. 4 */ 5 6 #ifndef _DISPLAY_H 7 #define _DISPLAY_H 8 9 #include <linux/types.h> 10 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 20 * @in_use: Display is being used 21 */ 22 struct display_plat { 23 int source_id; 24 struct udevice *src_dev; 25 bool in_use; 26 }; 27 28 /** 29 * display_read_timing() - Read timing information 30 * 31 * @dev: Device to read from 32 * Return: 0 if OK, -ve on error 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 42 * Return: 0 if OK, -ve on error 43 */ 44 int display_enable(struct udevice *dev, int panel_bpp, 45 const struct display_timing *timing); 46 47 /** 48 * display_in_use() - Check if a display is in use by any device 49 * 50 * Return: true if the device is in use (display_enable() has been called 51 * successfully), else false 52 */ 53 bool display_in_use(struct udevice *dev); 54 55 struct dm_display_ops { 56 /** 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 /** 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); 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); 95 }; 96 97 #define display_get_ops(dev) ((struct dm_display_ops *)(dev)->driver->ops) 98 99 #endif 100