dss_features.c 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  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 unsigned long max_dss_fck;
  38. const enum omap_display_type *supported_displays;
  39. const enum omap_color_mode *supported_color_modes;
  40. };
  41. /* This struct is assigned to one of the below during initialization */
  42. static struct omap_dss_features *omap_current_dss_features;
  43. static const struct dss_reg_field omap2_dss_reg_fields[] = {
  44. { FEAT_REG_FIRHINC, 11, 0 },
  45. { FEAT_REG_FIRVINC, 27, 16 },
  46. { FEAT_REG_FIFOLOWTHRESHOLD, 8, 0 },
  47. { FEAT_REG_FIFOHIGHTHRESHOLD, 24, 16 },
  48. { FEAT_REG_FIFOSIZE, 8, 0 },
  49. { FEAT_REG_HORIZONTALACCU, 9, 0 },
  50. { FEAT_REG_VERTICALACCU, 25, 16 },
  51. };
  52. static const struct dss_reg_field omap3_dss_reg_fields[] = {
  53. { FEAT_REG_FIRHINC, 12, 0 },
  54. { FEAT_REG_FIRVINC, 28, 16 },
  55. { FEAT_REG_FIFOLOWTHRESHOLD, 11, 0 },
  56. { FEAT_REG_FIFOHIGHTHRESHOLD, 27, 16 },
  57. { FEAT_REG_FIFOSIZE, 10, 0 },
  58. { FEAT_REG_HORIZONTALACCU, 9, 0 },
  59. { FEAT_REG_VERTICALACCU, 25, 16 },
  60. };
  61. static const struct dss_reg_field omap4_dss_reg_fields[] = {
  62. { FEAT_REG_FIRHINC, 12, 0 },
  63. { FEAT_REG_FIRVINC, 28, 16 },
  64. { FEAT_REG_FIFOLOWTHRESHOLD, 15, 0 },
  65. { FEAT_REG_FIFOHIGHTHRESHOLD, 31, 16 },
  66. { FEAT_REG_FIFOSIZE, 15, 0 },
  67. { FEAT_REG_HORIZONTALACCU, 10, 0 },
  68. { FEAT_REG_VERTICALACCU, 26, 16 },
  69. };
  70. static const enum omap_display_type omap2_dss_supported_displays[] = {
  71. /* OMAP_DSS_CHANNEL_LCD */
  72. OMAP_DISPLAY_TYPE_DPI | OMAP_DISPLAY_TYPE_DBI,
  73. /* OMAP_DSS_CHANNEL_DIGIT */
  74. OMAP_DISPLAY_TYPE_VENC,
  75. };
  76. static const enum omap_display_type omap3430_dss_supported_displays[] = {
  77. /* OMAP_DSS_CHANNEL_LCD */
  78. OMAP_DISPLAY_TYPE_DPI | OMAP_DISPLAY_TYPE_DBI |
  79. OMAP_DISPLAY_TYPE_SDI | OMAP_DISPLAY_TYPE_DSI,
  80. /* OMAP_DSS_CHANNEL_DIGIT */
  81. OMAP_DISPLAY_TYPE_VENC,
  82. };
  83. static const enum omap_display_type omap3630_dss_supported_displays[] = {
  84. /* OMAP_DSS_CHANNEL_LCD */
  85. OMAP_DISPLAY_TYPE_DPI | OMAP_DISPLAY_TYPE_DBI |
  86. OMAP_DISPLAY_TYPE_DSI,
  87. /* OMAP_DSS_CHANNEL_DIGIT */
  88. OMAP_DISPLAY_TYPE_VENC,
  89. };
  90. static const enum omap_display_type omap4_dss_supported_displays[] = {
  91. /* OMAP_DSS_CHANNEL_LCD */
  92. OMAP_DISPLAY_TYPE_DBI | OMAP_DISPLAY_TYPE_DSI,
  93. /* OMAP_DSS_CHANNEL_DIGIT */
  94. OMAP_DISPLAY_TYPE_VENC,
  95. /* OMAP_DSS_CHANNEL_LCD2 */
  96. OMAP_DISPLAY_TYPE_DPI | OMAP_DISPLAY_TYPE_DBI |
  97. OMAP_DISPLAY_TYPE_DSI,
  98. };
  99. static const enum omap_color_mode omap2_dss_supported_color_modes[] = {
  100. /* OMAP_DSS_GFX */
  101. OMAP_DSS_COLOR_CLUT1 | OMAP_DSS_COLOR_CLUT2 |
  102. OMAP_DSS_COLOR_CLUT4 | OMAP_DSS_COLOR_CLUT8 |
  103. OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_RGB16 |
  104. OMAP_DSS_COLOR_RGB24U | OMAP_DSS_COLOR_RGB24P,
  105. /* OMAP_DSS_VIDEO1 */
  106. OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U |
  107. OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_YUV2 |
  108. OMAP_DSS_COLOR_UYVY,
  109. /* OMAP_DSS_VIDEO2 */
  110. OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U |
  111. OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_YUV2 |
  112. OMAP_DSS_COLOR_UYVY,
  113. };
  114. static const enum omap_color_mode omap3_dss_supported_color_modes[] = {
  115. /* OMAP_DSS_GFX */
  116. OMAP_DSS_COLOR_CLUT1 | OMAP_DSS_COLOR_CLUT2 |
  117. OMAP_DSS_COLOR_CLUT4 | OMAP_DSS_COLOR_CLUT8 |
  118. OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_ARGB16 |
  119. OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U |
  120. OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_ARGB32 |
  121. OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_RGBX32,
  122. /* OMAP_DSS_VIDEO1 */
  123. OMAP_DSS_COLOR_RGB24U | OMAP_DSS_COLOR_RGB24P |
  124. OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_RGB16 |
  125. OMAP_DSS_COLOR_YUV2 | OMAP_DSS_COLOR_UYVY,
  126. /* OMAP_DSS_VIDEO2 */
  127. OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_ARGB16 |
  128. OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U |
  129. OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_YUV2 |
  130. OMAP_DSS_COLOR_UYVY | OMAP_DSS_COLOR_ARGB32 |
  131. OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_RGBX32,
  132. };
  133. /* OMAP2 DSS Features */
  134. static struct omap_dss_features omap2_dss_features = {
  135. .reg_fields = omap2_dss_reg_fields,
  136. .num_reg_fields = ARRAY_SIZE(omap2_dss_reg_fields),
  137. .has_feature =
  138. FEAT_LCDENABLEPOL | FEAT_LCDENABLESIGNAL |
  139. FEAT_PCKFREEENABLE | FEAT_FUNCGATED |
  140. FEAT_ROWREPEATENABLE | FEAT_RESIZECONF,
  141. .num_mgrs = 2,
  142. .num_ovls = 3,
  143. .max_dss_fck = 173000000,
  144. .supported_displays = omap2_dss_supported_displays,
  145. .supported_color_modes = omap2_dss_supported_color_modes,
  146. };
  147. /* OMAP3 DSS Features */
  148. static struct omap_dss_features omap3430_dss_features = {
  149. .reg_fields = omap3_dss_reg_fields,
  150. .num_reg_fields = ARRAY_SIZE(omap3_dss_reg_fields),
  151. .has_feature =
  152. FEAT_GLOBAL_ALPHA | FEAT_LCDENABLEPOL |
  153. FEAT_LCDENABLESIGNAL | FEAT_PCKFREEENABLE |
  154. FEAT_FUNCGATED | FEAT_ROWREPEATENABLE |
  155. FEAT_LINEBUFFERSPLIT | FEAT_RESIZECONF,
  156. .num_mgrs = 2,
  157. .num_ovls = 3,
  158. .max_dss_fck = 173000000,
  159. .supported_displays = omap3430_dss_supported_displays,
  160. .supported_color_modes = omap3_dss_supported_color_modes,
  161. };
  162. static struct omap_dss_features omap3630_dss_features = {
  163. .reg_fields = omap3_dss_reg_fields,
  164. .num_reg_fields = ARRAY_SIZE(omap3_dss_reg_fields),
  165. .has_feature =
  166. FEAT_GLOBAL_ALPHA | FEAT_LCDENABLEPOL |
  167. FEAT_LCDENABLESIGNAL | FEAT_PCKFREEENABLE |
  168. FEAT_PRE_MULT_ALPHA | FEAT_FUNCGATED |
  169. FEAT_ROWREPEATENABLE | FEAT_LINEBUFFERSPLIT |
  170. FEAT_RESIZECONF,
  171. .num_mgrs = 2,
  172. .num_ovls = 3,
  173. .max_dss_fck = 173000000,
  174. .supported_displays = omap3630_dss_supported_displays,
  175. .supported_color_modes = omap3_dss_supported_color_modes,
  176. };
  177. /* OMAP4 DSS Features */
  178. static struct omap_dss_features omap4_dss_features = {
  179. .reg_fields = omap4_dss_reg_fields,
  180. .num_reg_fields = ARRAY_SIZE(omap4_dss_reg_fields),
  181. .has_feature =
  182. FEAT_GLOBAL_ALPHA | FEAT_PRE_MULT_ALPHA |
  183. FEAT_MGR_LCD2 | FEAT_GLOBAL_ALPHA_VID1,
  184. .num_mgrs = 3,
  185. .num_ovls = 3,
  186. .max_dss_fck = 186000000,
  187. .supported_displays = omap4_dss_supported_displays,
  188. .supported_color_modes = omap3_dss_supported_color_modes,
  189. };
  190. /* Functions returning values related to a DSS feature */
  191. int dss_feat_get_num_mgrs(void)
  192. {
  193. return omap_current_dss_features->num_mgrs;
  194. }
  195. int dss_feat_get_num_ovls(void)
  196. {
  197. return omap_current_dss_features->num_ovls;
  198. }
  199. /* Max supported DSS FCK in Hz */
  200. unsigned long dss_feat_get_max_dss_fck(void)
  201. {
  202. return omap_current_dss_features->max_dss_fck;
  203. }
  204. enum omap_display_type dss_feat_get_supported_displays(enum omap_channel channel)
  205. {
  206. return omap_current_dss_features->supported_displays[channel];
  207. }
  208. enum omap_color_mode dss_feat_get_supported_color_modes(enum omap_plane plane)
  209. {
  210. return omap_current_dss_features->supported_color_modes[plane];
  211. }
  212. bool dss_feat_color_mode_supported(enum omap_plane plane,
  213. enum omap_color_mode color_mode)
  214. {
  215. return omap_current_dss_features->supported_color_modes[plane] &
  216. color_mode;
  217. }
  218. /* DSS has_feature check */
  219. bool dss_has_feature(enum dss_feat_id id)
  220. {
  221. return omap_current_dss_features->has_feature & id;
  222. }
  223. void dss_feat_get_reg_field(enum dss_feat_reg_field id, u8 *start, u8 *end)
  224. {
  225. if (id >= omap_current_dss_features->num_reg_fields)
  226. BUG();
  227. *start = omap_current_dss_features->reg_fields[id].start;
  228. *end = omap_current_dss_features->reg_fields[id].end;
  229. }
  230. void dss_features_init(void)
  231. {
  232. if (cpu_is_omap24xx())
  233. omap_current_dss_features = &omap2_dss_features;
  234. else if (cpu_is_omap3630())
  235. omap_current_dss_features = &omap3630_dss_features;
  236. else if (cpu_is_omap34xx())
  237. omap_current_dss_features = &omap3430_dss_features;
  238. else
  239. omap_current_dss_features = &omap4_dss_features;
  240. }