display_timing.h 3.1 KB

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