display_timing.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. };
  28. /*
  29. * A single signal can be specified via a range of minimal and maximal values
  30. * with a typical value, that lies somewhere inbetween.
  31. */
  32. struct timing_entry {
  33. u32 min;
  34. u32 typ;
  35. u32 max;
  36. };
  37. /*
  38. * Single "mode" entry. This describes one set of signal timings a display can
  39. * have in one setting. This struct can later be converted to struct videomode
  40. * (see include/video/videomode.h). As each timing_entry can be defined as a
  41. * range, one struct display_timing may become multiple struct videomodes.
  42. *
  43. * Example: hsync active high, vsync active low
  44. *
  45. * Active Video
  46. * Video ______________________XXXXXXXXXXXXXXXXXXXXXX_____________________
  47. * |<- sync ->|<- back ->|<----- active ----->|<- front ->|<- sync..
  48. * | | porch | | porch |
  49. *
  50. * HSync _|¯¯¯¯¯¯¯¯¯¯|___________________________________________|¯¯¯¯¯¯¯¯¯
  51. *
  52. * VSync ¯|__________|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|_________
  53. */
  54. struct display_timing {
  55. struct timing_entry pixelclock;
  56. struct timing_entry hactive; /* hor. active video */
  57. struct timing_entry hfront_porch; /* hor. front porch */
  58. struct timing_entry hback_porch; /* hor. back porch */
  59. struct timing_entry hsync_len; /* hor. sync len */
  60. struct timing_entry vactive; /* ver. active video */
  61. struct timing_entry vfront_porch; /* ver. front porch */
  62. struct timing_entry vback_porch; /* ver. back porch */
  63. struct timing_entry vsync_len; /* ver. sync len */
  64. enum display_flags flags; /* display flags */
  65. };
  66. /*
  67. * This describes all timing settings a display provides.
  68. * The native_mode is the default setting for this display.
  69. * Drivers that can handle multiple videomodes should work with this struct and
  70. * convert each entry to the desired end result.
  71. */
  72. struct display_timings {
  73. unsigned int num_timings;
  74. unsigned int native_mode;
  75. struct display_timing **timings;
  76. };
  77. /* get one entry from struct display_timings */
  78. static inline struct display_timing *display_timings_get(const struct
  79. display_timings *disp,
  80. unsigned int index)
  81. {
  82. if (disp->num_timings > index)
  83. return disp->timings[index];
  84. else
  85. return NULL;
  86. }
  87. void display_timings_release(struct display_timings *disp);
  88. #endif