display.h 2.3 KB

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