dss_features.c 9.3 KB

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