display_timing.h 3.5 KB

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