display_timing.h 3.4 KB

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