display_timing.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright 2012 Steffen Trumtrar <s.trumtrar@pengutronix.de>
  4. *
  5. * description of display timings
  6. */
  7. #ifndef __LINUX_DISPLAY_TIMING_H
  8. #define __LINUX_DISPLAY_TIMING_H
  9. #include <linux/bitops.h>
  10. #include <linux/types.h>
  11. enum display_flags {
  12. DISPLAY_FLAGS_HSYNC_LOW = BIT(0),
  13. DISPLAY_FLAGS_HSYNC_HIGH = BIT(1),
  14. DISPLAY_FLAGS_VSYNC_LOW = BIT(2),
  15. DISPLAY_FLAGS_VSYNC_HIGH = BIT(3),
  16. /* data enable flag */
  17. DISPLAY_FLAGS_DE_LOW = BIT(4),
  18. DISPLAY_FLAGS_DE_HIGH = BIT(5),
  19. /* drive data on pos. edge */
  20. DISPLAY_FLAGS_PIXDATA_POSEDGE = BIT(6),
  21. /* drive data on neg. edge */
  22. DISPLAY_FLAGS_PIXDATA_NEGEDGE = BIT(7),
  23. DISPLAY_FLAGS_INTERLACED = BIT(8),
  24. DISPLAY_FLAGS_DOUBLESCAN = BIT(9),
  25. DISPLAY_FLAGS_DOUBLECLK = BIT(10),
  26. /* drive sync on pos. edge */
  27. DISPLAY_FLAGS_SYNC_POSEDGE = BIT(11),
  28. /* drive sync on neg. edge */
  29. DISPLAY_FLAGS_SYNC_NEGEDGE = BIT(12),
  30. };
  31. /*
  32. * A single signal can be specified via a range of minimal and maximal values
  33. * with a typical value, that lies somewhere inbetween.
  34. */
  35. struct timing_entry {
  36. u32 min;
  37. u32 typ;
  38. u32 max;
  39. };
  40. /*
  41. * Single "mode" entry. This describes one set of signal timings a display can
  42. * have in one setting. This struct can later be converted to struct videomode
  43. * (see include/video/videomode.h). As each timing_entry can be defined as a
  44. * range, one struct display_timing may become multiple struct videomodes.
  45. *
  46. * Example: hsync active high, vsync active low
  47. *
  48. * Active Video
  49. * Video ______________________XXXXXXXXXXXXXXXXXXXXXX_____________________
  50. * |<- sync ->|<- back ->|<----- active ----->|<- front ->|<- sync..
  51. * | | porch | | porch |
  52. *
  53. * HSync _|¯¯¯¯¯¯¯¯¯¯|___________________________________________|¯¯¯¯¯¯¯¯¯
  54. *
  55. * VSync ¯|__________|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|_________
  56. */
  57. struct display_timing {
  58. struct timing_entry pixelclock;
  59. struct timing_entry hactive; /* hor. active video */
  60. struct timing_entry hfront_porch; /* hor. front porch */
  61. struct timing_entry hback_porch; /* hor. back porch */
  62. struct timing_entry hsync_len; /* hor. sync len */
  63. struct timing_entry vactive; /* ver. active video */
  64. struct timing_entry vfront_porch; /* ver. front porch */
  65. struct timing_entry vback_porch; /* ver. back porch */
  66. struct timing_entry vsync_len; /* ver. sync len */
  67. enum display_flags flags; /* display flags */
  68. };
  69. /*
  70. * This describes all timing settings a display provides.
  71. * The native_mode is the default setting for this display.
  72. * Drivers that can handle multiple videomodes should work with this struct and
  73. * convert each entry to the desired end result.
  74. */
  75. struct display_timings {
  76. unsigned int num_timings;
  77. unsigned int native_mode;
  78. struct display_timing **timings;
  79. };
  80. /* get one entry from struct display_timings */
  81. static inline struct display_timing *display_timings_get(const struct
  82. display_timings *disp,
  83. unsigned int index)
  84. {
  85. if (disp->num_timings > index)
  86. return disp->timings[index];
  87. else
  88. return NULL;
  89. }
  90. void display_timings_release(struct display_timings *disp);
  91. #endif