dss_features.c 7.0 KB

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