dss_features.c 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  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_DSS_CHANNEL_DIGIT */
  60. OMAP_DISPLAY_TYPE_VENC,
  61. };
  62. static const enum omap_display_type omap3430_dss_supported_displays[] = {
  63. /* OMAP_DSS_CHANNEL_LCD */
  64. OMAP_DISPLAY_TYPE_DPI | OMAP_DISPLAY_TYPE_DBI |
  65. OMAP_DISPLAY_TYPE_SDI | OMAP_DISPLAY_TYPE_DSI,
  66. /* OMAP_DSS_CHANNEL_DIGIT */
  67. OMAP_DISPLAY_TYPE_VENC,
  68. };
  69. static const enum omap_display_type omap3630_dss_supported_displays[] = {
  70. /* OMAP_DSS_CHANNEL_LCD */
  71. OMAP_DISPLAY_TYPE_DPI | OMAP_DISPLAY_TYPE_DBI |
  72. OMAP_DISPLAY_TYPE_DSI,
  73. /* OMAP_DSS_CHANNEL_DIGIT */
  74. OMAP_DISPLAY_TYPE_VENC,
  75. };
  76. static const enum omap_display_type omap4_dss_supported_displays[] = {
  77. /* OMAP_DSS_CHANNEL_LCD */
  78. OMAP_DISPLAY_TYPE_DBI | OMAP_DISPLAY_TYPE_DSI,
  79. /* OMAP_DSS_CHANNEL_DIGIT */
  80. OMAP_DISPLAY_TYPE_VENC,
  81. /* OMAP_DSS_CHANNEL_LCD2 */
  82. OMAP_DISPLAY_TYPE_DPI | OMAP_DISPLAY_TYPE_DBI |
  83. OMAP_DISPLAY_TYPE_DSI,
  84. };
  85. static const enum omap_color_mode omap2_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_RGB16 |
  90. OMAP_DSS_COLOR_RGB24U | OMAP_DSS_COLOR_RGB24P,
  91. /* OMAP_DSS_VIDEO1 */
  92. OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U |
  93. OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_YUV2 |
  94. OMAP_DSS_COLOR_UYVY,
  95. /* OMAP_DSS_VIDEO2 */
  96. OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U |
  97. OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_YUV2 |
  98. OMAP_DSS_COLOR_UYVY,
  99. };
  100. static const enum omap_color_mode omap3_dss_supported_color_modes[] = {
  101. /* OMAP_DSS_GFX */
  102. OMAP_DSS_COLOR_CLUT1 | OMAP_DSS_COLOR_CLUT2 |
  103. OMAP_DSS_COLOR_CLUT4 | OMAP_DSS_COLOR_CLUT8 |
  104. OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_ARGB16 |
  105. OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U |
  106. OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_ARGB32 |
  107. OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_RGBX32,
  108. /* OMAP_DSS_VIDEO1 */
  109. OMAP_DSS_COLOR_RGB24U | OMAP_DSS_COLOR_RGB24P |
  110. OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_RGB16 |
  111. OMAP_DSS_COLOR_YUV2 | OMAP_DSS_COLOR_UYVY,
  112. /* OMAP_DSS_VIDEO2 */
  113. OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_ARGB16 |
  114. OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U |
  115. OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_YUV2 |
  116. OMAP_DSS_COLOR_UYVY | OMAP_DSS_COLOR_ARGB32 |
  117. OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_RGBX32,
  118. };
  119. /* OMAP2 DSS Features */
  120. static struct omap_dss_features omap2_dss_features = {
  121. .reg_fields = omap2_dss_reg_fields,
  122. .num_reg_fields = ARRAY_SIZE(omap2_dss_reg_fields),
  123. .has_feature =
  124. FEAT_LCDENABLEPOL | FEAT_LCDENABLESIGNAL |
  125. FEAT_PCKFREEENABLE | FEAT_FUNCGATED,
  126. .num_mgrs = 2,
  127. .num_ovls = 3,
  128. .supported_displays = omap2_dss_supported_displays,
  129. .supported_color_modes = omap2_dss_supported_color_modes,
  130. };
  131. /* OMAP3 DSS Features */
  132. static struct omap_dss_features omap3430_dss_features = {
  133. .reg_fields = omap3_dss_reg_fields,
  134. .num_reg_fields = ARRAY_SIZE(omap3_dss_reg_fields),
  135. .has_feature =
  136. FEAT_GLOBAL_ALPHA | FEAT_LCDENABLEPOL |
  137. FEAT_LCDENABLESIGNAL | FEAT_PCKFREEENABLE |
  138. FEAT_FUNCGATED,
  139. .num_mgrs = 2,
  140. .num_ovls = 3,
  141. .supported_displays = omap3430_dss_supported_displays,
  142. .supported_color_modes = omap3_dss_supported_color_modes,
  143. };
  144. static struct omap_dss_features omap3630_dss_features = {
  145. .reg_fields = omap3_dss_reg_fields,
  146. .num_reg_fields = ARRAY_SIZE(omap3_dss_reg_fields),
  147. .has_feature =
  148. FEAT_GLOBAL_ALPHA | FEAT_LCDENABLEPOL |
  149. FEAT_LCDENABLESIGNAL | FEAT_PCKFREEENABLE |
  150. FEAT_PRE_MULT_ALPHA | FEAT_FUNCGATED,
  151. .num_mgrs = 2,
  152. .num_ovls = 3,
  153. .supported_displays = omap3630_dss_supported_displays,
  154. .supported_color_modes = omap3_dss_supported_color_modes,
  155. };
  156. /* OMAP4 DSS Features */
  157. static struct omap_dss_features omap4_dss_features = {
  158. .reg_fields = omap3_dss_reg_fields,
  159. .num_reg_fields = ARRAY_SIZE(omap3_dss_reg_fields),
  160. .has_feature =
  161. FEAT_GLOBAL_ALPHA | FEAT_PRE_MULT_ALPHA |
  162. FEAT_MGR_LCD2,
  163. .num_mgrs = 3,
  164. .num_ovls = 3,
  165. .supported_displays = omap4_dss_supported_displays,
  166. .supported_color_modes = omap3_dss_supported_color_modes,
  167. };
  168. /* Functions returning values related to a DSS feature */
  169. int dss_feat_get_num_mgrs(void)
  170. {
  171. return omap_current_dss_features->num_mgrs;
  172. }
  173. int dss_feat_get_num_ovls(void)
  174. {
  175. return omap_current_dss_features->num_ovls;
  176. }
  177. enum omap_display_type dss_feat_get_supported_displays(enum omap_channel channel)
  178. {
  179. return omap_current_dss_features->supported_displays[channel];
  180. }
  181. enum omap_color_mode dss_feat_get_supported_color_modes(enum omap_plane plane)
  182. {
  183. return omap_current_dss_features->supported_color_modes[plane];
  184. }
  185. bool dss_feat_color_mode_supported(enum omap_plane plane,
  186. enum omap_color_mode color_mode)
  187. {
  188. return omap_current_dss_features->supported_color_modes[plane] &
  189. color_mode;
  190. }
  191. /* DSS has_feature check */
  192. bool dss_has_feature(enum dss_feat_id id)
  193. {
  194. return omap_current_dss_features->has_feature & id;
  195. }
  196. void dss_feat_get_reg_field(enum dss_feat_reg_field id, u8 *start, u8 *end)
  197. {
  198. if (id >= omap_current_dss_features->num_reg_fields)
  199. BUG();
  200. *start = omap_current_dss_features->reg_fields[id].start;
  201. *end = omap_current_dss_features->reg_fields[id].end;
  202. }
  203. void dss_features_init(void)
  204. {
  205. if (cpu_is_omap24xx())
  206. omap_current_dss_features = &omap2_dss_features;
  207. else if (cpu_is_omap3630())
  208. omap_current_dss_features = &omap3630_dss_features;
  209. else if (cpu_is_omap34xx())
  210. omap_current_dss_features = &omap3430_dss_features;
  211. else
  212. omap_current_dss_features = &omap4_dss_features;
  213. }