dss_features.c 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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/module.h>
  21. #include <linux/types.h>
  22. #include <linux/err.h>
  23. #include <linux/slab.h>
  24. #include <drm/drm_fourcc.h>
  25. #include "omapdss.h"
  26. #include "dss.h"
  27. #include "dss_features.h"
  28. struct dss_param_range {
  29. int min, max;
  30. };
  31. struct omap_dss_features {
  32. const enum omap_dss_output_id *supported_outputs;
  33. const struct dss_param_range *dss_params;
  34. };
  35. /* This struct is assigned to one of the below during initialization */
  36. static const struct omap_dss_features *omap_current_dss_features;
  37. static const enum omap_dss_output_id omap2_dss_supported_outputs[] = {
  38. /* OMAP_DSS_CHANNEL_LCD */
  39. OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI,
  40. /* OMAP_DSS_CHANNEL_DIGIT */
  41. OMAP_DSS_OUTPUT_VENC,
  42. };
  43. static const enum omap_dss_output_id omap3430_dss_supported_outputs[] = {
  44. /* OMAP_DSS_CHANNEL_LCD */
  45. OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI |
  46. OMAP_DSS_OUTPUT_SDI | OMAP_DSS_OUTPUT_DSI1,
  47. /* OMAP_DSS_CHANNEL_DIGIT */
  48. OMAP_DSS_OUTPUT_VENC,
  49. };
  50. static const enum omap_dss_output_id omap3630_dss_supported_outputs[] = {
  51. /* OMAP_DSS_CHANNEL_LCD */
  52. OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI |
  53. OMAP_DSS_OUTPUT_DSI1,
  54. /* OMAP_DSS_CHANNEL_DIGIT */
  55. OMAP_DSS_OUTPUT_VENC,
  56. };
  57. static const enum omap_dss_output_id am43xx_dss_supported_outputs[] = {
  58. /* OMAP_DSS_CHANNEL_LCD */
  59. OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI,
  60. };
  61. static const enum omap_dss_output_id omap4_dss_supported_outputs[] = {
  62. /* OMAP_DSS_CHANNEL_LCD */
  63. OMAP_DSS_OUTPUT_DBI | OMAP_DSS_OUTPUT_DSI1,
  64. /* OMAP_DSS_CHANNEL_DIGIT */
  65. OMAP_DSS_OUTPUT_VENC | OMAP_DSS_OUTPUT_HDMI,
  66. /* OMAP_DSS_CHANNEL_LCD2 */
  67. OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI |
  68. OMAP_DSS_OUTPUT_DSI2,
  69. };
  70. static const enum omap_dss_output_id omap5_dss_supported_outputs[] = {
  71. /* OMAP_DSS_CHANNEL_LCD */
  72. OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI |
  73. OMAP_DSS_OUTPUT_DSI1 | OMAP_DSS_OUTPUT_DSI2,
  74. /* OMAP_DSS_CHANNEL_DIGIT */
  75. OMAP_DSS_OUTPUT_HDMI,
  76. /* OMAP_DSS_CHANNEL_LCD2 */
  77. OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI |
  78. OMAP_DSS_OUTPUT_DSI1,
  79. /* OMAP_DSS_CHANNEL_LCD3 */
  80. OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI |
  81. OMAP_DSS_OUTPUT_DSI2,
  82. };
  83. static const struct dss_param_range omap2_dss_param_range[] = {
  84. [FEAT_PARAM_DSS_FCK] = { 0, 133000000 },
  85. };
  86. static const struct dss_param_range omap3_dss_param_range[] = {
  87. [FEAT_PARAM_DSS_FCK] = { 0, 173000000 },
  88. };
  89. static const struct dss_param_range am43xx_dss_param_range[] = {
  90. [FEAT_PARAM_DSS_FCK] = { 0, 200000000 },
  91. };
  92. static const struct dss_param_range omap4_dss_param_range[] = {
  93. [FEAT_PARAM_DSS_FCK] = { 0, 186000000 },
  94. };
  95. static const struct dss_param_range omap5_dss_param_range[] = {
  96. [FEAT_PARAM_DSS_FCK] = { 0, 209250000 },
  97. };
  98. /* OMAP2 DSS Features */
  99. static const struct omap_dss_features omap2_dss_features = {
  100. .supported_outputs = omap2_dss_supported_outputs,
  101. .dss_params = omap2_dss_param_range,
  102. };
  103. /* OMAP3 DSS Features */
  104. static const struct omap_dss_features omap3430_dss_features = {
  105. .supported_outputs = omap3430_dss_supported_outputs,
  106. .dss_params = omap3_dss_param_range,
  107. };
  108. /*
  109. * AM35xx DSS Features. This is basically OMAP3 DSS Features without the
  110. * vdds_dsi regulator.
  111. */
  112. static const struct omap_dss_features am35xx_dss_features = {
  113. .supported_outputs = omap3430_dss_supported_outputs,
  114. .dss_params = omap3_dss_param_range,
  115. };
  116. static const struct omap_dss_features am43xx_dss_features = {
  117. .supported_outputs = am43xx_dss_supported_outputs,
  118. .dss_params = am43xx_dss_param_range,
  119. };
  120. static const struct omap_dss_features omap3630_dss_features = {
  121. .supported_outputs = omap3630_dss_supported_outputs,
  122. .dss_params = omap3_dss_param_range,
  123. };
  124. /* OMAP4 DSS Features */
  125. /* For OMAP4430 ES 1.0 revision */
  126. static const struct omap_dss_features omap4430_es1_0_dss_features = {
  127. .supported_outputs = omap4_dss_supported_outputs,
  128. .dss_params = omap4_dss_param_range,
  129. };
  130. /* For OMAP4430 ES 2.0, 2.1 and 2.2 revisions */
  131. static const struct omap_dss_features omap4430_es2_0_1_2_dss_features = {
  132. .supported_outputs = omap4_dss_supported_outputs,
  133. .dss_params = omap4_dss_param_range,
  134. };
  135. /* For all the other OMAP4 versions */
  136. static const struct omap_dss_features omap4_dss_features = {
  137. .supported_outputs = omap4_dss_supported_outputs,
  138. .dss_params = omap4_dss_param_range,
  139. };
  140. /* OMAP5 DSS Features */
  141. static const struct omap_dss_features omap5_dss_features = {
  142. .supported_outputs = omap5_dss_supported_outputs,
  143. .dss_params = omap5_dss_param_range,
  144. };
  145. /* Functions returning values related to a DSS feature */
  146. unsigned long dss_feat_get_param_min(enum dss_range_param param)
  147. {
  148. return omap_current_dss_features->dss_params[param].min;
  149. }
  150. unsigned long dss_feat_get_param_max(enum dss_range_param param)
  151. {
  152. return omap_current_dss_features->dss_params[param].max;
  153. }
  154. enum omap_dss_output_id dss_feat_get_supported_outputs(enum omap_channel channel)
  155. {
  156. return omap_current_dss_features->supported_outputs[channel];
  157. }
  158. void dss_features_init(enum omapdss_version version)
  159. {
  160. switch (version) {
  161. case OMAPDSS_VER_OMAP24xx:
  162. omap_current_dss_features = &omap2_dss_features;
  163. break;
  164. case OMAPDSS_VER_OMAP34xx_ES1:
  165. case OMAPDSS_VER_OMAP34xx_ES3:
  166. omap_current_dss_features = &omap3430_dss_features;
  167. break;
  168. case OMAPDSS_VER_OMAP3630:
  169. omap_current_dss_features = &omap3630_dss_features;
  170. break;
  171. case OMAPDSS_VER_OMAP4430_ES1:
  172. omap_current_dss_features = &omap4430_es1_0_dss_features;
  173. break;
  174. case OMAPDSS_VER_OMAP4430_ES2:
  175. omap_current_dss_features = &omap4430_es2_0_1_2_dss_features;
  176. break;
  177. case OMAPDSS_VER_OMAP4:
  178. omap_current_dss_features = &omap4_dss_features;
  179. break;
  180. case OMAPDSS_VER_OMAP5:
  181. case OMAPDSS_VER_DRA7xx:
  182. omap_current_dss_features = &omap5_dss_features;
  183. break;
  184. case OMAPDSS_VER_AM35xx:
  185. omap_current_dss_features = &am35xx_dss_features;
  186. break;
  187. case OMAPDSS_VER_AM43xx:
  188. omap_current_dss_features = &am43xx_dss_features;
  189. break;
  190. default:
  191. DSSWARN("Unsupported OMAP version");
  192. break;
  193. }
  194. }