dss_features.c 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /*
  2. * linux/drivers/video/omap2/dss/dss_features.c
  3. *
  4. * Copyright (C) 2010 Texas Instruments
  5. * Author: Archit Taneja <archit@ti.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License version 2 as published by
  9. * the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful, but WITHOUT
  12. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  14. * more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along with
  17. * this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #include <linux/kernel.h>
  20. #include <linux/types.h>
  21. #include <linux/err.h>
  22. #include <linux/slab.h>
  23. #include <plat/display.h>
  24. #include <plat/cpu.h>
  25. #include "dss_features.h"
  26. /* Defines a generic omap register field */
  27. struct dss_reg_field {
  28. enum dss_feat_reg_field id;
  29. u8 start, end;
  30. };
  31. struct omap_dss_features {
  32. const struct dss_reg_field *reg_fields;
  33. const int num_reg_fields;
  34. const u32 has_feature;
  35. const int num_mgrs;
  36. const int num_ovls;
  37. const enum omap_display_type *supported_displays;
  38. const enum omap_color_mode *supported_color_modes;
  39. };
  40. /* This struct is assigned to one of the below during initialization */
  41. static struct omap_dss_features *omap_current_dss_features;
  42. static const struct dss_reg_field omap2_dss_reg_fields[] = {
  43. { FEAT_REG_FIRHINC, 11, 0 },
  44. { FEAT_REG_FIRVINC, 27, 16 },
  45. { FEAT_REG_FIFOLOWTHRESHOLD, 8, 0 },
  46. { FEAT_REG_FIFOHIGHTHRESHOLD, 24, 16 },
  47. { FEAT_REG_FIFOSIZE, 8, 0 },
  48. };
  49. static const struct dss_reg_field omap3_dss_reg_fields[] = {
  50. { FEAT_REG_FIRHINC, 12, 0 },
  51. { FEAT_REG_FIRVINC, 28, 16 },
  52. { FEAT_REG_FIFOLOWTHRESHOLD, 11, 0 },
  53. { FEAT_REG_FIFOHIGHTHRESHOLD, 27, 16 },
  54. { FEAT_REG_FIFOSIZE, 10, 0 },
  55. };
  56. static const enum omap_display_type omap2_dss_supported_displays[] = {
  57. /* OMAP_DSS_CHANNEL_LCD */
  58. OMAP_DISPLAY_TYPE_DPI | OMAP_DISPLAY_TYPE_DBI |
  59. OMAP_DISPLAY_TYPE_SDI | OMAP_DISPLAY_TYPE_DSI,
  60. /* OMAP_DSS_CHANNEL_DIGIT */
  61. OMAP_DISPLAY_TYPE_VENC,
  62. };
  63. static const enum omap_display_type omap3_dss_supported_displays[] = {
  64. /* OMAP_DSS_CHANNEL_LCD */
  65. OMAP_DISPLAY_TYPE_DPI | OMAP_DISPLAY_TYPE_DBI |
  66. OMAP_DISPLAY_TYPE_SDI | OMAP_DISPLAY_TYPE_DSI,
  67. /* OMAP_DSS_CHANNEL_DIGIT */
  68. OMAP_DISPLAY_TYPE_VENC,
  69. };
  70. static const enum omap_color_mode omap2_dss_supported_color_modes[] = {
  71. /* OMAP_DSS_GFX */
  72. OMAP_DSS_COLOR_CLUT1 | OMAP_DSS_COLOR_CLUT2 |
  73. OMAP_DSS_COLOR_CLUT4 | OMAP_DSS_COLOR_CLUT8 |
  74. OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_RGB16 |
  75. OMAP_DSS_COLOR_RGB24U | OMAP_DSS_COLOR_RGB24P,
  76. /* OMAP_DSS_VIDEO1 */
  77. OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U |
  78. OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_YUV2 |
  79. OMAP_DSS_COLOR_UYVY,
  80. /* OMAP_DSS_VIDEO2 */
  81. OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U |
  82. OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_YUV2 |
  83. OMAP_DSS_COLOR_UYVY,
  84. };
  85. static const enum omap_color_mode omap3_dss_supported_color_modes[] = {
  86. /* OMAP_DSS_GFX */
  87. OMAP_DSS_COLOR_CLUT1 | OMAP_DSS_COLOR_CLUT2 |
  88. OMAP_DSS_COLOR_CLUT4 | OMAP_DSS_COLOR_CLUT8 |
  89. OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_ARGB16 |
  90. OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U |
  91. OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_ARGB32 |
  92. OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_RGBX32,
  93. /* OMAP_DSS_VIDEO1 */
  94. OMAP_DSS_COLOR_RGB24U | OMAP_DSS_COLOR_RGB24P |
  95. OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_RGB16 |
  96. OMAP_DSS_COLOR_YUV2 | OMAP_DSS_COLOR_UYVY,
  97. /* OMAP_DSS_VIDEO2 */
  98. OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_ARGB16 |
  99. OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U |
  100. OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_YUV2 |
  101. OMAP_DSS_COLOR_UYVY | OMAP_DSS_COLOR_ARGB32 |
  102. OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_RGBX32,
  103. };
  104. /* OMAP2 DSS Features */
  105. static struct omap_dss_features omap2_dss_features = {
  106. .reg_fields = omap2_dss_reg_fields,
  107. .num_reg_fields = ARRAY_SIZE(omap2_dss_reg_fields),
  108. .num_mgrs = 2,
  109. .num_ovls = 3,
  110. .supported_displays = omap2_dss_supported_displays,
  111. .supported_color_modes = omap2_dss_supported_color_modes,
  112. };
  113. /* OMAP3 DSS Features */
  114. static struct omap_dss_features omap3_dss_features = {
  115. .reg_fields = omap3_dss_reg_fields,
  116. .num_reg_fields = ARRAY_SIZE(omap3_dss_reg_fields),
  117. .has_feature = FEAT_GLOBAL_ALPHA,
  118. .num_mgrs = 2,
  119. .num_ovls = 3,
  120. .supported_displays = omap3_dss_supported_displays,
  121. .supported_color_modes = omap3_dss_supported_color_modes,
  122. };
  123. /* Functions returning values related to a DSS feature */
  124. int dss_feat_get_num_mgrs(void)
  125. {
  126. return omap_current_dss_features->num_mgrs;
  127. }
  128. int dss_feat_get_num_ovls(void)
  129. {
  130. return omap_current_dss_features->num_ovls;
  131. }
  132. enum omap_display_type dss_feat_get_supported_displays(enum omap_channel channel)
  133. {
  134. return omap_current_dss_features->supported_displays[channel];
  135. }
  136. enum omap_color_mode dss_feat_get_supported_color_modes(enum omap_plane plane)
  137. {
  138. return omap_current_dss_features->supported_color_modes[plane];
  139. }
  140. /* DSS has_feature check */
  141. bool dss_has_feature(enum dss_feat_id id)
  142. {
  143. return omap_current_dss_features->has_feature & id;
  144. }
  145. void dss_feat_get_reg_field(enum dss_feat_reg_field id, u8 *start, u8 *end)
  146. {
  147. if (id >= omap_current_dss_features->num_reg_fields)
  148. BUG();
  149. *start = omap_current_dss_features->reg_fields[id].start;
  150. *end = omap_current_dss_features->reg_fields[id].end;
  151. }
  152. void dss_features_init(void)
  153. {
  154. if (cpu_is_omap24xx())
  155. omap_current_dss_features = &omap2_dss_features;
  156. else
  157. omap_current_dss_features = &omap3_dss_features;
  158. }