dss_features.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  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 dss_feat_id *features;
  33. const int num_features;
  34. const enum omap_dss_output_id *supported_outputs;
  35. const struct dss_param_range *dss_params;
  36. };
  37. /* This struct is assigned to one of the below during initialization */
  38. static const struct omap_dss_features *omap_current_dss_features;
  39. static const enum omap_dss_output_id omap2_dss_supported_outputs[] = {
  40. /* OMAP_DSS_CHANNEL_LCD */
  41. OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI,
  42. /* OMAP_DSS_CHANNEL_DIGIT */
  43. OMAP_DSS_OUTPUT_VENC,
  44. };
  45. static const enum omap_dss_output_id omap3430_dss_supported_outputs[] = {
  46. /* OMAP_DSS_CHANNEL_LCD */
  47. OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI |
  48. OMAP_DSS_OUTPUT_SDI | OMAP_DSS_OUTPUT_DSI1,
  49. /* OMAP_DSS_CHANNEL_DIGIT */
  50. OMAP_DSS_OUTPUT_VENC,
  51. };
  52. static const enum omap_dss_output_id omap3630_dss_supported_outputs[] = {
  53. /* OMAP_DSS_CHANNEL_LCD */
  54. OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI |
  55. OMAP_DSS_OUTPUT_DSI1,
  56. /* OMAP_DSS_CHANNEL_DIGIT */
  57. OMAP_DSS_OUTPUT_VENC,
  58. };
  59. static const enum omap_dss_output_id am43xx_dss_supported_outputs[] = {
  60. /* OMAP_DSS_CHANNEL_LCD */
  61. OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI,
  62. };
  63. static const enum omap_dss_output_id omap4_dss_supported_outputs[] = {
  64. /* OMAP_DSS_CHANNEL_LCD */
  65. OMAP_DSS_OUTPUT_DBI | OMAP_DSS_OUTPUT_DSI1,
  66. /* OMAP_DSS_CHANNEL_DIGIT */
  67. OMAP_DSS_OUTPUT_VENC | OMAP_DSS_OUTPUT_HDMI,
  68. /* OMAP_DSS_CHANNEL_LCD2 */
  69. OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI |
  70. OMAP_DSS_OUTPUT_DSI2,
  71. };
  72. static const enum omap_dss_output_id omap5_dss_supported_outputs[] = {
  73. /* OMAP_DSS_CHANNEL_LCD */
  74. OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI |
  75. OMAP_DSS_OUTPUT_DSI1 | OMAP_DSS_OUTPUT_DSI2,
  76. /* OMAP_DSS_CHANNEL_DIGIT */
  77. OMAP_DSS_OUTPUT_HDMI,
  78. /* OMAP_DSS_CHANNEL_LCD2 */
  79. OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI |
  80. OMAP_DSS_OUTPUT_DSI1,
  81. /* OMAP_DSS_CHANNEL_LCD3 */
  82. OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI |
  83. OMAP_DSS_OUTPUT_DSI2,
  84. };
  85. static const struct dss_param_range omap2_dss_param_range[] = {
  86. [FEAT_PARAM_DSS_FCK] = { 0, 133000000 },
  87. [FEAT_PARAM_DSS_PCD] = { 2, 255 },
  88. [FEAT_PARAM_DOWNSCALE] = { 1, 2 },
  89. /*
  90. * Assuming the line width buffer to be 768 pixels as OMAP2 DISPC
  91. * scaler cannot scale a image with width more than 768.
  92. */
  93. [FEAT_PARAM_LINEWIDTH] = { 1, 768 },
  94. };
  95. static const struct dss_param_range omap3_dss_param_range[] = {
  96. [FEAT_PARAM_DSS_FCK] = { 0, 173000000 },
  97. [FEAT_PARAM_DSS_PCD] = { 1, 255 },
  98. [FEAT_PARAM_DSIPLL_LPDIV] = { 1, (1 << 13) - 1},
  99. [FEAT_PARAM_DSI_FCK] = { 0, 173000000 },
  100. [FEAT_PARAM_DOWNSCALE] = { 1, 4 },
  101. [FEAT_PARAM_LINEWIDTH] = { 1, 1024 },
  102. };
  103. static const struct dss_param_range am43xx_dss_param_range[] = {
  104. [FEAT_PARAM_DSS_FCK] = { 0, 200000000 },
  105. [FEAT_PARAM_DSS_PCD] = { 1, 255 },
  106. [FEAT_PARAM_DOWNSCALE] = { 1, 4 },
  107. [FEAT_PARAM_LINEWIDTH] = { 1, 1024 },
  108. };
  109. static const struct dss_param_range omap4_dss_param_range[] = {
  110. [FEAT_PARAM_DSS_FCK] = { 0, 186000000 },
  111. [FEAT_PARAM_DSS_PCD] = { 1, 255 },
  112. [FEAT_PARAM_DSIPLL_LPDIV] = { 0, (1 << 13) - 1 },
  113. [FEAT_PARAM_DSI_FCK] = { 0, 170000000 },
  114. [FEAT_PARAM_DOWNSCALE] = { 1, 4 },
  115. [FEAT_PARAM_LINEWIDTH] = { 1, 2048 },
  116. };
  117. static const struct dss_param_range omap5_dss_param_range[] = {
  118. [FEAT_PARAM_DSS_FCK] = { 0, 209250000 },
  119. [FEAT_PARAM_DSS_PCD] = { 1, 255 },
  120. [FEAT_PARAM_DSIPLL_LPDIV] = { 0, (1 << 13) - 1 },
  121. [FEAT_PARAM_DSI_FCK] = { 0, 209250000 },
  122. [FEAT_PARAM_DOWNSCALE] = { 1, 4 },
  123. [FEAT_PARAM_LINEWIDTH] = { 1, 2048 },
  124. };
  125. static const enum dss_feat_id omap2_dss_feat_list[] = {
  126. FEAT_LCDENABLEPOL,
  127. FEAT_LCDENABLESIGNAL,
  128. FEAT_PCKFREEENABLE,
  129. FEAT_FUNCGATED,
  130. FEAT_ROWREPEATENABLE,
  131. FEAT_RESIZECONF,
  132. };
  133. static const enum dss_feat_id omap3430_dss_feat_list[] = {
  134. FEAT_LCDENABLEPOL,
  135. FEAT_LCDENABLESIGNAL,
  136. FEAT_PCKFREEENABLE,
  137. FEAT_FUNCGATED,
  138. FEAT_LINEBUFFERSPLIT,
  139. FEAT_ROWREPEATENABLE,
  140. FEAT_RESIZECONF,
  141. FEAT_CPR,
  142. FEAT_PRELOAD,
  143. FEAT_FIR_COEF_V,
  144. FEAT_ALPHA_FIXED_ZORDER,
  145. FEAT_FIFO_MERGE,
  146. FEAT_OMAP3_DSI_FIFO_BUG,
  147. };
  148. static const enum dss_feat_id am35xx_dss_feat_list[] = {
  149. FEAT_LCDENABLEPOL,
  150. FEAT_LCDENABLESIGNAL,
  151. FEAT_PCKFREEENABLE,
  152. FEAT_FUNCGATED,
  153. FEAT_LINEBUFFERSPLIT,
  154. FEAT_ROWREPEATENABLE,
  155. FEAT_RESIZECONF,
  156. FEAT_CPR,
  157. FEAT_PRELOAD,
  158. FEAT_FIR_COEF_V,
  159. FEAT_ALPHA_FIXED_ZORDER,
  160. FEAT_FIFO_MERGE,
  161. FEAT_OMAP3_DSI_FIFO_BUG,
  162. };
  163. static const enum dss_feat_id am43xx_dss_feat_list[] = {
  164. FEAT_LCDENABLEPOL,
  165. FEAT_LCDENABLESIGNAL,
  166. FEAT_PCKFREEENABLE,
  167. FEAT_FUNCGATED,
  168. FEAT_LINEBUFFERSPLIT,
  169. FEAT_ROWREPEATENABLE,
  170. FEAT_RESIZECONF,
  171. FEAT_CPR,
  172. FEAT_PRELOAD,
  173. FEAT_FIR_COEF_V,
  174. FEAT_ALPHA_FIXED_ZORDER,
  175. FEAT_FIFO_MERGE,
  176. };
  177. static const enum dss_feat_id omap3630_dss_feat_list[] = {
  178. FEAT_LCDENABLEPOL,
  179. FEAT_LCDENABLESIGNAL,
  180. FEAT_PCKFREEENABLE,
  181. FEAT_FUNCGATED,
  182. FEAT_LINEBUFFERSPLIT,
  183. FEAT_ROWREPEATENABLE,
  184. FEAT_RESIZECONF,
  185. FEAT_CPR,
  186. FEAT_PRELOAD,
  187. FEAT_FIR_COEF_V,
  188. FEAT_ALPHA_FIXED_ZORDER,
  189. FEAT_FIFO_MERGE,
  190. FEAT_OMAP3_DSI_FIFO_BUG,
  191. };
  192. static const enum dss_feat_id omap4430_es1_0_dss_feat_list[] = {
  193. FEAT_MGR_LCD2,
  194. FEAT_CORE_CLK_DIV,
  195. FEAT_LCD_CLK_SRC,
  196. FEAT_HANDLE_UV_SEPARATE,
  197. FEAT_ATTR2,
  198. FEAT_CPR,
  199. FEAT_PRELOAD,
  200. FEAT_FIR_COEF_V,
  201. FEAT_ALPHA_FREE_ZORDER,
  202. FEAT_FIFO_MERGE,
  203. FEAT_BURST_2D,
  204. };
  205. static const enum dss_feat_id omap4430_es2_0_1_2_dss_feat_list[] = {
  206. FEAT_MGR_LCD2,
  207. FEAT_CORE_CLK_DIV,
  208. FEAT_LCD_CLK_SRC,
  209. FEAT_HANDLE_UV_SEPARATE,
  210. FEAT_ATTR2,
  211. FEAT_CPR,
  212. FEAT_PRELOAD,
  213. FEAT_FIR_COEF_V,
  214. FEAT_ALPHA_FREE_ZORDER,
  215. FEAT_FIFO_MERGE,
  216. FEAT_BURST_2D,
  217. };
  218. static const enum dss_feat_id omap4_dss_feat_list[] = {
  219. FEAT_MGR_LCD2,
  220. FEAT_CORE_CLK_DIV,
  221. FEAT_LCD_CLK_SRC,
  222. FEAT_HANDLE_UV_SEPARATE,
  223. FEAT_ATTR2,
  224. FEAT_CPR,
  225. FEAT_PRELOAD,
  226. FEAT_FIR_COEF_V,
  227. FEAT_ALPHA_FREE_ZORDER,
  228. FEAT_FIFO_MERGE,
  229. FEAT_BURST_2D,
  230. };
  231. static const enum dss_feat_id omap5_dss_feat_list[] = {
  232. FEAT_MGR_LCD2,
  233. FEAT_MGR_LCD3,
  234. FEAT_CORE_CLK_DIV,
  235. FEAT_LCD_CLK_SRC,
  236. FEAT_HANDLE_UV_SEPARATE,
  237. FEAT_ATTR2,
  238. FEAT_CPR,
  239. FEAT_PRELOAD,
  240. FEAT_FIR_COEF_V,
  241. FEAT_ALPHA_FREE_ZORDER,
  242. FEAT_FIFO_MERGE,
  243. FEAT_BURST_2D,
  244. FEAT_MFLAG,
  245. };
  246. /* OMAP2 DSS Features */
  247. static const struct omap_dss_features omap2_dss_features = {
  248. .features = omap2_dss_feat_list,
  249. .num_features = ARRAY_SIZE(omap2_dss_feat_list),
  250. .supported_outputs = omap2_dss_supported_outputs,
  251. .dss_params = omap2_dss_param_range,
  252. };
  253. /* OMAP3 DSS Features */
  254. static const struct omap_dss_features omap3430_dss_features = {
  255. .features = omap3430_dss_feat_list,
  256. .num_features = ARRAY_SIZE(omap3430_dss_feat_list),
  257. .supported_outputs = omap3430_dss_supported_outputs,
  258. .dss_params = omap3_dss_param_range,
  259. };
  260. /*
  261. * AM35xx DSS Features. This is basically OMAP3 DSS Features without the
  262. * vdds_dsi regulator.
  263. */
  264. static const struct omap_dss_features am35xx_dss_features = {
  265. .features = am35xx_dss_feat_list,
  266. .num_features = ARRAY_SIZE(am35xx_dss_feat_list),
  267. .supported_outputs = omap3430_dss_supported_outputs,
  268. .dss_params = omap3_dss_param_range,
  269. };
  270. static const struct omap_dss_features am43xx_dss_features = {
  271. .features = am43xx_dss_feat_list,
  272. .num_features = ARRAY_SIZE(am43xx_dss_feat_list),
  273. .supported_outputs = am43xx_dss_supported_outputs,
  274. .dss_params = am43xx_dss_param_range,
  275. };
  276. static const struct omap_dss_features omap3630_dss_features = {
  277. .features = omap3630_dss_feat_list,
  278. .num_features = ARRAY_SIZE(omap3630_dss_feat_list),
  279. .supported_outputs = omap3630_dss_supported_outputs,
  280. .dss_params = omap3_dss_param_range,
  281. };
  282. /* OMAP4 DSS Features */
  283. /* For OMAP4430 ES 1.0 revision */
  284. static const struct omap_dss_features omap4430_es1_0_dss_features = {
  285. .features = omap4430_es1_0_dss_feat_list,
  286. .num_features = ARRAY_SIZE(omap4430_es1_0_dss_feat_list),
  287. .supported_outputs = omap4_dss_supported_outputs,
  288. .dss_params = omap4_dss_param_range,
  289. };
  290. /* For OMAP4430 ES 2.0, 2.1 and 2.2 revisions */
  291. static const struct omap_dss_features omap4430_es2_0_1_2_dss_features = {
  292. .features = omap4430_es2_0_1_2_dss_feat_list,
  293. .num_features = ARRAY_SIZE(omap4430_es2_0_1_2_dss_feat_list),
  294. .supported_outputs = omap4_dss_supported_outputs,
  295. .dss_params = omap4_dss_param_range,
  296. };
  297. /* For all the other OMAP4 versions */
  298. static const struct omap_dss_features omap4_dss_features = {
  299. .features = omap4_dss_feat_list,
  300. .num_features = ARRAY_SIZE(omap4_dss_feat_list),
  301. .supported_outputs = omap4_dss_supported_outputs,
  302. .dss_params = omap4_dss_param_range,
  303. };
  304. /* OMAP5 DSS Features */
  305. static const struct omap_dss_features omap5_dss_features = {
  306. .features = omap5_dss_feat_list,
  307. .num_features = ARRAY_SIZE(omap5_dss_feat_list),
  308. .supported_outputs = omap5_dss_supported_outputs,
  309. .dss_params = omap5_dss_param_range,
  310. };
  311. /* Functions returning values related to a DSS feature */
  312. unsigned long dss_feat_get_param_min(enum dss_range_param param)
  313. {
  314. return omap_current_dss_features->dss_params[param].min;
  315. }
  316. unsigned long dss_feat_get_param_max(enum dss_range_param param)
  317. {
  318. return omap_current_dss_features->dss_params[param].max;
  319. }
  320. enum omap_dss_output_id dss_feat_get_supported_outputs(enum omap_channel channel)
  321. {
  322. return omap_current_dss_features->supported_outputs[channel];
  323. }
  324. /* DSS has_feature check */
  325. bool dss_has_feature(enum dss_feat_id id)
  326. {
  327. int i;
  328. const enum dss_feat_id *features = omap_current_dss_features->features;
  329. const int num_features = omap_current_dss_features->num_features;
  330. for (i = 0; i < num_features; i++) {
  331. if (features[i] == id)
  332. return true;
  333. }
  334. return false;
  335. }
  336. void dss_features_init(enum omapdss_version version)
  337. {
  338. switch (version) {
  339. case OMAPDSS_VER_OMAP24xx:
  340. omap_current_dss_features = &omap2_dss_features;
  341. break;
  342. case OMAPDSS_VER_OMAP34xx_ES1:
  343. case OMAPDSS_VER_OMAP34xx_ES3:
  344. omap_current_dss_features = &omap3430_dss_features;
  345. break;
  346. case OMAPDSS_VER_OMAP3630:
  347. omap_current_dss_features = &omap3630_dss_features;
  348. break;
  349. case OMAPDSS_VER_OMAP4430_ES1:
  350. omap_current_dss_features = &omap4430_es1_0_dss_features;
  351. break;
  352. case OMAPDSS_VER_OMAP4430_ES2:
  353. omap_current_dss_features = &omap4430_es2_0_1_2_dss_features;
  354. break;
  355. case OMAPDSS_VER_OMAP4:
  356. omap_current_dss_features = &omap4_dss_features;
  357. break;
  358. case OMAPDSS_VER_OMAP5:
  359. case OMAPDSS_VER_DRA7xx:
  360. omap_current_dss_features = &omap5_dss_features;
  361. break;
  362. case OMAPDSS_VER_AM35xx:
  363. omap_current_dss_features = &am35xx_dss_features;
  364. break;
  365. case OMAPDSS_VER_AM43xx:
  366. omap_current_dss_features = &am43xx_dss_features;
  367. break;
  368. default:
  369. DSSWARN("Unsupported OMAP version");
  370. break;
  371. }
  372. }