dss_features.c 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905
  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. /* Defines a generic omap register field */
  29. struct dss_reg_field {
  30. u8 start, end;
  31. };
  32. struct dss_param_range {
  33. int min, max;
  34. };
  35. struct omap_dss_features {
  36. const struct dss_reg_field *reg_fields;
  37. const int num_reg_fields;
  38. const enum dss_feat_id *features;
  39. const int num_features;
  40. const int num_mgrs;
  41. const int num_ovls;
  42. const enum omap_display_type *supported_displays;
  43. const enum omap_dss_output_id *supported_outputs;
  44. const u32 **supported_color_modes;
  45. const enum omap_overlay_caps *overlay_caps;
  46. const struct dss_param_range *dss_params;
  47. const u32 buffer_size_unit;
  48. const u32 burst_size_unit;
  49. };
  50. /* This struct is assigned to one of the below during initialization */
  51. static const struct omap_dss_features *omap_current_dss_features;
  52. static const struct dss_reg_field omap2_dss_reg_fields[] = {
  53. [FEAT_REG_FIRHINC] = { 11, 0 },
  54. [FEAT_REG_FIRVINC] = { 27, 16 },
  55. [FEAT_REG_FIFOLOWTHRESHOLD] = { 8, 0 },
  56. [FEAT_REG_FIFOHIGHTHRESHOLD] = { 24, 16 },
  57. [FEAT_REG_FIFOSIZE] = { 8, 0 },
  58. [FEAT_REG_HORIZONTALACCU] = { 9, 0 },
  59. [FEAT_REG_VERTICALACCU] = { 25, 16 },
  60. [FEAT_REG_DISPC_CLK_SWITCH] = { 0, 0 },
  61. };
  62. static const struct dss_reg_field omap3_dss_reg_fields[] = {
  63. [FEAT_REG_FIRHINC] = { 12, 0 },
  64. [FEAT_REG_FIRVINC] = { 28, 16 },
  65. [FEAT_REG_FIFOLOWTHRESHOLD] = { 11, 0 },
  66. [FEAT_REG_FIFOHIGHTHRESHOLD] = { 27, 16 },
  67. [FEAT_REG_FIFOSIZE] = { 10, 0 },
  68. [FEAT_REG_HORIZONTALACCU] = { 9, 0 },
  69. [FEAT_REG_VERTICALACCU] = { 25, 16 },
  70. [FEAT_REG_DISPC_CLK_SWITCH] = { 0, 0 },
  71. };
  72. static const struct dss_reg_field am43xx_dss_reg_fields[] = {
  73. [FEAT_REG_FIRHINC] = { 12, 0 },
  74. [FEAT_REG_FIRVINC] = { 28, 16 },
  75. [FEAT_REG_FIFOLOWTHRESHOLD] = { 11, 0 },
  76. [FEAT_REG_FIFOHIGHTHRESHOLD] = { 27, 16 },
  77. [FEAT_REG_FIFOSIZE] = { 10, 0 },
  78. [FEAT_REG_HORIZONTALACCU] = { 9, 0 },
  79. [FEAT_REG_VERTICALACCU] = { 25, 16 },
  80. [FEAT_REG_DISPC_CLK_SWITCH] = { 0, 0 },
  81. };
  82. static const struct dss_reg_field omap4_dss_reg_fields[] = {
  83. [FEAT_REG_FIRHINC] = { 12, 0 },
  84. [FEAT_REG_FIRVINC] = { 28, 16 },
  85. [FEAT_REG_FIFOLOWTHRESHOLD] = { 15, 0 },
  86. [FEAT_REG_FIFOHIGHTHRESHOLD] = { 31, 16 },
  87. [FEAT_REG_FIFOSIZE] = { 15, 0 },
  88. [FEAT_REG_HORIZONTALACCU] = { 10, 0 },
  89. [FEAT_REG_VERTICALACCU] = { 26, 16 },
  90. [FEAT_REG_DISPC_CLK_SWITCH] = { 9, 8 },
  91. };
  92. static const struct dss_reg_field omap5_dss_reg_fields[] = {
  93. [FEAT_REG_FIRHINC] = { 12, 0 },
  94. [FEAT_REG_FIRVINC] = { 28, 16 },
  95. [FEAT_REG_FIFOLOWTHRESHOLD] = { 15, 0 },
  96. [FEAT_REG_FIFOHIGHTHRESHOLD] = { 31, 16 },
  97. [FEAT_REG_FIFOSIZE] = { 15, 0 },
  98. [FEAT_REG_HORIZONTALACCU] = { 10, 0 },
  99. [FEAT_REG_VERTICALACCU] = { 26, 16 },
  100. [FEAT_REG_DISPC_CLK_SWITCH] = { 9, 7 },
  101. };
  102. static const enum omap_display_type omap2_dss_supported_displays[] = {
  103. /* OMAP_DSS_CHANNEL_LCD */
  104. OMAP_DISPLAY_TYPE_DPI | OMAP_DISPLAY_TYPE_DBI,
  105. /* OMAP_DSS_CHANNEL_DIGIT */
  106. OMAP_DISPLAY_TYPE_VENC,
  107. };
  108. static const enum omap_display_type omap3430_dss_supported_displays[] = {
  109. /* OMAP_DSS_CHANNEL_LCD */
  110. OMAP_DISPLAY_TYPE_DPI | OMAP_DISPLAY_TYPE_DBI |
  111. OMAP_DISPLAY_TYPE_SDI | OMAP_DISPLAY_TYPE_DSI,
  112. /* OMAP_DSS_CHANNEL_DIGIT */
  113. OMAP_DISPLAY_TYPE_VENC,
  114. };
  115. static const enum omap_display_type omap3630_dss_supported_displays[] = {
  116. /* OMAP_DSS_CHANNEL_LCD */
  117. OMAP_DISPLAY_TYPE_DPI | OMAP_DISPLAY_TYPE_DBI |
  118. OMAP_DISPLAY_TYPE_DSI,
  119. /* OMAP_DSS_CHANNEL_DIGIT */
  120. OMAP_DISPLAY_TYPE_VENC,
  121. };
  122. static const enum omap_display_type am43xx_dss_supported_displays[] = {
  123. /* OMAP_DSS_CHANNEL_LCD */
  124. OMAP_DISPLAY_TYPE_DPI | OMAP_DISPLAY_TYPE_DBI,
  125. };
  126. static const enum omap_display_type omap4_dss_supported_displays[] = {
  127. /* OMAP_DSS_CHANNEL_LCD */
  128. OMAP_DISPLAY_TYPE_DBI | OMAP_DISPLAY_TYPE_DSI,
  129. /* OMAP_DSS_CHANNEL_DIGIT */
  130. OMAP_DISPLAY_TYPE_VENC | OMAP_DISPLAY_TYPE_HDMI,
  131. /* OMAP_DSS_CHANNEL_LCD2 */
  132. OMAP_DISPLAY_TYPE_DPI | OMAP_DISPLAY_TYPE_DBI |
  133. OMAP_DISPLAY_TYPE_DSI,
  134. };
  135. static const enum omap_display_type omap5_dss_supported_displays[] = {
  136. /* OMAP_DSS_CHANNEL_LCD */
  137. OMAP_DISPLAY_TYPE_DPI | OMAP_DISPLAY_TYPE_DBI |
  138. OMAP_DISPLAY_TYPE_DSI,
  139. /* OMAP_DSS_CHANNEL_DIGIT */
  140. OMAP_DISPLAY_TYPE_HDMI | OMAP_DISPLAY_TYPE_DPI,
  141. /* OMAP_DSS_CHANNEL_LCD2 */
  142. OMAP_DISPLAY_TYPE_DPI | OMAP_DISPLAY_TYPE_DBI |
  143. OMAP_DISPLAY_TYPE_DSI,
  144. };
  145. static const enum omap_dss_output_id omap2_dss_supported_outputs[] = {
  146. /* OMAP_DSS_CHANNEL_LCD */
  147. OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI,
  148. /* OMAP_DSS_CHANNEL_DIGIT */
  149. OMAP_DSS_OUTPUT_VENC,
  150. };
  151. static const enum omap_dss_output_id omap3430_dss_supported_outputs[] = {
  152. /* OMAP_DSS_CHANNEL_LCD */
  153. OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI |
  154. OMAP_DSS_OUTPUT_SDI | OMAP_DSS_OUTPUT_DSI1,
  155. /* OMAP_DSS_CHANNEL_DIGIT */
  156. OMAP_DSS_OUTPUT_VENC,
  157. };
  158. static const enum omap_dss_output_id omap3630_dss_supported_outputs[] = {
  159. /* OMAP_DSS_CHANNEL_LCD */
  160. OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI |
  161. OMAP_DSS_OUTPUT_DSI1,
  162. /* OMAP_DSS_CHANNEL_DIGIT */
  163. OMAP_DSS_OUTPUT_VENC,
  164. };
  165. static const enum omap_dss_output_id am43xx_dss_supported_outputs[] = {
  166. /* OMAP_DSS_CHANNEL_LCD */
  167. OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI,
  168. };
  169. static const enum omap_dss_output_id omap4_dss_supported_outputs[] = {
  170. /* OMAP_DSS_CHANNEL_LCD */
  171. OMAP_DSS_OUTPUT_DBI | OMAP_DSS_OUTPUT_DSI1,
  172. /* OMAP_DSS_CHANNEL_DIGIT */
  173. OMAP_DSS_OUTPUT_VENC | OMAP_DSS_OUTPUT_HDMI,
  174. /* OMAP_DSS_CHANNEL_LCD2 */
  175. OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI |
  176. OMAP_DSS_OUTPUT_DSI2,
  177. };
  178. static const enum omap_dss_output_id omap5_dss_supported_outputs[] = {
  179. /* OMAP_DSS_CHANNEL_LCD */
  180. OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI |
  181. OMAP_DSS_OUTPUT_DSI1 | OMAP_DSS_OUTPUT_DSI2,
  182. /* OMAP_DSS_CHANNEL_DIGIT */
  183. OMAP_DSS_OUTPUT_HDMI,
  184. /* OMAP_DSS_CHANNEL_LCD2 */
  185. OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI |
  186. OMAP_DSS_OUTPUT_DSI1,
  187. /* OMAP_DSS_CHANNEL_LCD3 */
  188. OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI |
  189. OMAP_DSS_OUTPUT_DSI2,
  190. };
  191. #define COLOR_ARRAY(arr...) (const u32[]) { arr, 0 }
  192. static const u32 *omap2_dss_supported_color_modes[] = {
  193. /* OMAP_DSS_GFX */
  194. COLOR_ARRAY(
  195. DRM_FORMAT_RGBX4444, DRM_FORMAT_RGB565,
  196. DRM_FORMAT_XRGB8888, DRM_FORMAT_RGB888),
  197. /* OMAP_DSS_VIDEO1 */
  198. COLOR_ARRAY(
  199. DRM_FORMAT_RGB565, DRM_FORMAT_XRGB8888,
  200. DRM_FORMAT_RGB888, DRM_FORMAT_YUYV,
  201. DRM_FORMAT_UYVY),
  202. /* OMAP_DSS_VIDEO2 */
  203. COLOR_ARRAY(
  204. DRM_FORMAT_RGB565, DRM_FORMAT_XRGB8888,
  205. DRM_FORMAT_RGB888, DRM_FORMAT_YUYV,
  206. DRM_FORMAT_UYVY),
  207. };
  208. static const u32 *omap3_dss_supported_color_modes[] = {
  209. /* OMAP_DSS_GFX */
  210. COLOR_ARRAY(
  211. DRM_FORMAT_RGBX4444, DRM_FORMAT_ARGB4444,
  212. DRM_FORMAT_RGB565, DRM_FORMAT_XRGB8888,
  213. DRM_FORMAT_RGB888, DRM_FORMAT_ARGB8888,
  214. DRM_FORMAT_RGBA8888, DRM_FORMAT_RGBX8888),
  215. /* OMAP_DSS_VIDEO1 */
  216. COLOR_ARRAY(
  217. DRM_FORMAT_XRGB8888, DRM_FORMAT_RGB888,
  218. DRM_FORMAT_RGBX4444, DRM_FORMAT_RGB565,
  219. DRM_FORMAT_YUYV, DRM_FORMAT_UYVY),
  220. /* OMAP_DSS_VIDEO2 */
  221. COLOR_ARRAY(
  222. DRM_FORMAT_RGBX4444, DRM_FORMAT_ARGB4444,
  223. DRM_FORMAT_RGB565, DRM_FORMAT_XRGB8888,
  224. DRM_FORMAT_RGB888, DRM_FORMAT_YUYV,
  225. DRM_FORMAT_UYVY, DRM_FORMAT_ARGB8888,
  226. DRM_FORMAT_RGBA8888, DRM_FORMAT_RGBX8888),
  227. };
  228. static const u32 *omap4_dss_supported_color_modes[] = {
  229. /* OMAP_DSS_GFX */
  230. COLOR_ARRAY(
  231. DRM_FORMAT_RGBX4444, DRM_FORMAT_ARGB4444,
  232. DRM_FORMAT_RGB565, DRM_FORMAT_XRGB8888,
  233. DRM_FORMAT_RGB888, DRM_FORMAT_ARGB8888,
  234. DRM_FORMAT_RGBA8888, DRM_FORMAT_RGBX8888,
  235. DRM_FORMAT_ARGB1555, DRM_FORMAT_XRGB4444,
  236. DRM_FORMAT_RGBA4444, DRM_FORMAT_XRGB1555),
  237. /* OMAP_DSS_VIDEO1 */
  238. COLOR_ARRAY(
  239. DRM_FORMAT_RGB565, DRM_FORMAT_RGBX4444,
  240. DRM_FORMAT_YUYV, DRM_FORMAT_ARGB1555,
  241. DRM_FORMAT_RGBA8888, DRM_FORMAT_NV12,
  242. DRM_FORMAT_RGBA4444, DRM_FORMAT_XRGB8888,
  243. DRM_FORMAT_RGB888, DRM_FORMAT_UYVY,
  244. DRM_FORMAT_ARGB4444, DRM_FORMAT_XRGB1555,
  245. DRM_FORMAT_ARGB8888, DRM_FORMAT_XRGB4444,
  246. DRM_FORMAT_RGBX8888),
  247. /* OMAP_DSS_VIDEO2 */
  248. COLOR_ARRAY(
  249. DRM_FORMAT_RGB565, DRM_FORMAT_RGBX4444,
  250. DRM_FORMAT_YUYV, DRM_FORMAT_ARGB1555,
  251. DRM_FORMAT_RGBA8888, DRM_FORMAT_NV12,
  252. DRM_FORMAT_RGBA4444, DRM_FORMAT_XRGB8888,
  253. DRM_FORMAT_RGB888, DRM_FORMAT_UYVY,
  254. DRM_FORMAT_ARGB4444, DRM_FORMAT_XRGB1555,
  255. DRM_FORMAT_ARGB8888, DRM_FORMAT_XRGB4444,
  256. DRM_FORMAT_RGBX8888),
  257. /* OMAP_DSS_VIDEO3 */
  258. COLOR_ARRAY(
  259. DRM_FORMAT_RGB565, DRM_FORMAT_RGBX4444,
  260. DRM_FORMAT_YUYV, DRM_FORMAT_ARGB1555,
  261. DRM_FORMAT_RGBA8888, DRM_FORMAT_NV12,
  262. DRM_FORMAT_RGBA4444, DRM_FORMAT_XRGB8888,
  263. DRM_FORMAT_RGB888, DRM_FORMAT_UYVY,
  264. DRM_FORMAT_ARGB4444, DRM_FORMAT_XRGB1555,
  265. DRM_FORMAT_ARGB8888, DRM_FORMAT_XRGB4444,
  266. DRM_FORMAT_RGBX8888),
  267. /* OMAP_DSS_WB */
  268. COLOR_ARRAY(
  269. DRM_FORMAT_RGB565, DRM_FORMAT_RGBX4444,
  270. DRM_FORMAT_YUYV, DRM_FORMAT_ARGB1555,
  271. DRM_FORMAT_RGBA8888, DRM_FORMAT_NV12,
  272. DRM_FORMAT_RGBA4444, DRM_FORMAT_XRGB8888,
  273. DRM_FORMAT_RGB888, DRM_FORMAT_UYVY,
  274. DRM_FORMAT_ARGB4444, DRM_FORMAT_XRGB1555,
  275. DRM_FORMAT_ARGB8888, DRM_FORMAT_XRGB4444,
  276. DRM_FORMAT_RGBX8888),
  277. };
  278. static const enum omap_overlay_caps omap2_dss_overlay_caps[] = {
  279. /* OMAP_DSS_GFX */
  280. OMAP_DSS_OVL_CAP_POS | OMAP_DSS_OVL_CAP_REPLICATION,
  281. /* OMAP_DSS_VIDEO1 */
  282. OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_POS |
  283. OMAP_DSS_OVL_CAP_REPLICATION,
  284. /* OMAP_DSS_VIDEO2 */
  285. OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_POS |
  286. OMAP_DSS_OVL_CAP_REPLICATION,
  287. };
  288. static const enum omap_overlay_caps omap3430_dss_overlay_caps[] = {
  289. /* OMAP_DSS_GFX */
  290. OMAP_DSS_OVL_CAP_GLOBAL_ALPHA | OMAP_DSS_OVL_CAP_POS |
  291. OMAP_DSS_OVL_CAP_REPLICATION,
  292. /* OMAP_DSS_VIDEO1 */
  293. OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_POS |
  294. OMAP_DSS_OVL_CAP_REPLICATION,
  295. /* OMAP_DSS_VIDEO2 */
  296. OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_GLOBAL_ALPHA |
  297. OMAP_DSS_OVL_CAP_POS | OMAP_DSS_OVL_CAP_REPLICATION,
  298. };
  299. static const enum omap_overlay_caps omap3630_dss_overlay_caps[] = {
  300. /* OMAP_DSS_GFX */
  301. OMAP_DSS_OVL_CAP_GLOBAL_ALPHA | OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA |
  302. OMAP_DSS_OVL_CAP_POS | OMAP_DSS_OVL_CAP_REPLICATION,
  303. /* OMAP_DSS_VIDEO1 */
  304. OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_POS |
  305. OMAP_DSS_OVL_CAP_REPLICATION,
  306. /* OMAP_DSS_VIDEO2 */
  307. OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_GLOBAL_ALPHA |
  308. OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA | OMAP_DSS_OVL_CAP_POS |
  309. OMAP_DSS_OVL_CAP_REPLICATION,
  310. };
  311. static const enum omap_overlay_caps omap4_dss_overlay_caps[] = {
  312. /* OMAP_DSS_GFX */
  313. OMAP_DSS_OVL_CAP_GLOBAL_ALPHA | OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA |
  314. OMAP_DSS_OVL_CAP_ZORDER | OMAP_DSS_OVL_CAP_POS |
  315. OMAP_DSS_OVL_CAP_REPLICATION,
  316. /* OMAP_DSS_VIDEO1 */
  317. OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_GLOBAL_ALPHA |
  318. OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA | OMAP_DSS_OVL_CAP_ZORDER |
  319. OMAP_DSS_OVL_CAP_POS | OMAP_DSS_OVL_CAP_REPLICATION,
  320. /* OMAP_DSS_VIDEO2 */
  321. OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_GLOBAL_ALPHA |
  322. OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA | OMAP_DSS_OVL_CAP_ZORDER |
  323. OMAP_DSS_OVL_CAP_POS | OMAP_DSS_OVL_CAP_REPLICATION,
  324. /* OMAP_DSS_VIDEO3 */
  325. OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_GLOBAL_ALPHA |
  326. OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA | OMAP_DSS_OVL_CAP_ZORDER |
  327. OMAP_DSS_OVL_CAP_POS | OMAP_DSS_OVL_CAP_REPLICATION,
  328. };
  329. static const struct dss_param_range omap2_dss_param_range[] = {
  330. [FEAT_PARAM_DSS_FCK] = { 0, 133000000 },
  331. [FEAT_PARAM_DSS_PCD] = { 2, 255 },
  332. [FEAT_PARAM_DOWNSCALE] = { 1, 2 },
  333. /*
  334. * Assuming the line width buffer to be 768 pixels as OMAP2 DISPC
  335. * scaler cannot scale a image with width more than 768.
  336. */
  337. [FEAT_PARAM_LINEWIDTH] = { 1, 768 },
  338. };
  339. static const struct dss_param_range omap3_dss_param_range[] = {
  340. [FEAT_PARAM_DSS_FCK] = { 0, 173000000 },
  341. [FEAT_PARAM_DSS_PCD] = { 1, 255 },
  342. [FEAT_PARAM_DSIPLL_LPDIV] = { 1, (1 << 13) - 1},
  343. [FEAT_PARAM_DSI_FCK] = { 0, 173000000 },
  344. [FEAT_PARAM_DOWNSCALE] = { 1, 4 },
  345. [FEAT_PARAM_LINEWIDTH] = { 1, 1024 },
  346. };
  347. static const struct dss_param_range am43xx_dss_param_range[] = {
  348. [FEAT_PARAM_DSS_FCK] = { 0, 200000000 },
  349. [FEAT_PARAM_DSS_PCD] = { 1, 255 },
  350. [FEAT_PARAM_DOWNSCALE] = { 1, 4 },
  351. [FEAT_PARAM_LINEWIDTH] = { 1, 1024 },
  352. };
  353. static const struct dss_param_range omap4_dss_param_range[] = {
  354. [FEAT_PARAM_DSS_FCK] = { 0, 186000000 },
  355. [FEAT_PARAM_DSS_PCD] = { 1, 255 },
  356. [FEAT_PARAM_DSIPLL_LPDIV] = { 0, (1 << 13) - 1 },
  357. [FEAT_PARAM_DSI_FCK] = { 0, 170000000 },
  358. [FEAT_PARAM_DOWNSCALE] = { 1, 4 },
  359. [FEAT_PARAM_LINEWIDTH] = { 1, 2048 },
  360. };
  361. static const struct dss_param_range omap5_dss_param_range[] = {
  362. [FEAT_PARAM_DSS_FCK] = { 0, 209250000 },
  363. [FEAT_PARAM_DSS_PCD] = { 1, 255 },
  364. [FEAT_PARAM_DSIPLL_LPDIV] = { 0, (1 << 13) - 1 },
  365. [FEAT_PARAM_DSI_FCK] = { 0, 209250000 },
  366. [FEAT_PARAM_DOWNSCALE] = { 1, 4 },
  367. [FEAT_PARAM_LINEWIDTH] = { 1, 2048 },
  368. };
  369. static const enum dss_feat_id omap2_dss_feat_list[] = {
  370. FEAT_LCDENABLEPOL,
  371. FEAT_LCDENABLESIGNAL,
  372. FEAT_PCKFREEENABLE,
  373. FEAT_FUNCGATED,
  374. FEAT_ROWREPEATENABLE,
  375. FEAT_RESIZECONF,
  376. };
  377. static const enum dss_feat_id omap3430_dss_feat_list[] = {
  378. FEAT_LCDENABLEPOL,
  379. FEAT_LCDENABLESIGNAL,
  380. FEAT_PCKFREEENABLE,
  381. FEAT_FUNCGATED,
  382. FEAT_LINEBUFFERSPLIT,
  383. FEAT_ROWREPEATENABLE,
  384. FEAT_RESIZECONF,
  385. FEAT_DSI_REVERSE_TXCLKESC,
  386. FEAT_VENC_REQUIRES_TV_DAC_CLK,
  387. FEAT_CPR,
  388. FEAT_PRELOAD,
  389. FEAT_FIR_COEF_V,
  390. FEAT_ALPHA_FIXED_ZORDER,
  391. FEAT_FIFO_MERGE,
  392. FEAT_OMAP3_DSI_FIFO_BUG,
  393. FEAT_DPI_USES_VDDS_DSI,
  394. };
  395. static const enum dss_feat_id am35xx_dss_feat_list[] = {
  396. FEAT_LCDENABLEPOL,
  397. FEAT_LCDENABLESIGNAL,
  398. FEAT_PCKFREEENABLE,
  399. FEAT_FUNCGATED,
  400. FEAT_LINEBUFFERSPLIT,
  401. FEAT_ROWREPEATENABLE,
  402. FEAT_RESIZECONF,
  403. FEAT_DSI_REVERSE_TXCLKESC,
  404. FEAT_VENC_REQUIRES_TV_DAC_CLK,
  405. FEAT_CPR,
  406. FEAT_PRELOAD,
  407. FEAT_FIR_COEF_V,
  408. FEAT_ALPHA_FIXED_ZORDER,
  409. FEAT_FIFO_MERGE,
  410. FEAT_OMAP3_DSI_FIFO_BUG,
  411. };
  412. static const enum dss_feat_id am43xx_dss_feat_list[] = {
  413. FEAT_LCDENABLEPOL,
  414. FEAT_LCDENABLESIGNAL,
  415. FEAT_PCKFREEENABLE,
  416. FEAT_FUNCGATED,
  417. FEAT_LINEBUFFERSPLIT,
  418. FEAT_ROWREPEATENABLE,
  419. FEAT_RESIZECONF,
  420. FEAT_CPR,
  421. FEAT_PRELOAD,
  422. FEAT_FIR_COEF_V,
  423. FEAT_ALPHA_FIXED_ZORDER,
  424. FEAT_FIFO_MERGE,
  425. };
  426. static const enum dss_feat_id omap3630_dss_feat_list[] = {
  427. FEAT_LCDENABLEPOL,
  428. FEAT_LCDENABLESIGNAL,
  429. FEAT_PCKFREEENABLE,
  430. FEAT_FUNCGATED,
  431. FEAT_LINEBUFFERSPLIT,
  432. FEAT_ROWREPEATENABLE,
  433. FEAT_RESIZECONF,
  434. FEAT_DSI_PLL_PWR_BUG,
  435. FEAT_CPR,
  436. FEAT_PRELOAD,
  437. FEAT_FIR_COEF_V,
  438. FEAT_ALPHA_FIXED_ZORDER,
  439. FEAT_FIFO_MERGE,
  440. FEAT_OMAP3_DSI_FIFO_BUG,
  441. FEAT_DPI_USES_VDDS_DSI,
  442. };
  443. static const enum dss_feat_id omap4430_es1_0_dss_feat_list[] = {
  444. FEAT_MGR_LCD2,
  445. FEAT_CORE_CLK_DIV,
  446. FEAT_LCD_CLK_SRC,
  447. FEAT_DSI_DCS_CMD_CONFIG_VC,
  448. FEAT_DSI_VC_OCP_WIDTH,
  449. FEAT_DSI_GNQ,
  450. FEAT_HANDLE_UV_SEPARATE,
  451. FEAT_ATTR2,
  452. FEAT_CPR,
  453. FEAT_PRELOAD,
  454. FEAT_FIR_COEF_V,
  455. FEAT_ALPHA_FREE_ZORDER,
  456. FEAT_FIFO_MERGE,
  457. FEAT_BURST_2D,
  458. };
  459. static const enum dss_feat_id omap4430_es2_0_1_2_dss_feat_list[] = {
  460. FEAT_MGR_LCD2,
  461. FEAT_CORE_CLK_DIV,
  462. FEAT_LCD_CLK_SRC,
  463. FEAT_DSI_DCS_CMD_CONFIG_VC,
  464. FEAT_DSI_VC_OCP_WIDTH,
  465. FEAT_DSI_GNQ,
  466. FEAT_HDMI_CTS_SWMODE,
  467. FEAT_HANDLE_UV_SEPARATE,
  468. FEAT_ATTR2,
  469. FEAT_CPR,
  470. FEAT_PRELOAD,
  471. FEAT_FIR_COEF_V,
  472. FEAT_ALPHA_FREE_ZORDER,
  473. FEAT_FIFO_MERGE,
  474. FEAT_BURST_2D,
  475. };
  476. static const enum dss_feat_id omap4_dss_feat_list[] = {
  477. FEAT_MGR_LCD2,
  478. FEAT_CORE_CLK_DIV,
  479. FEAT_LCD_CLK_SRC,
  480. FEAT_DSI_DCS_CMD_CONFIG_VC,
  481. FEAT_DSI_VC_OCP_WIDTH,
  482. FEAT_DSI_GNQ,
  483. FEAT_HDMI_CTS_SWMODE,
  484. FEAT_HDMI_AUDIO_USE_MCLK,
  485. FEAT_HANDLE_UV_SEPARATE,
  486. FEAT_ATTR2,
  487. FEAT_CPR,
  488. FEAT_PRELOAD,
  489. FEAT_FIR_COEF_V,
  490. FEAT_ALPHA_FREE_ZORDER,
  491. FEAT_FIFO_MERGE,
  492. FEAT_BURST_2D,
  493. };
  494. static const enum dss_feat_id omap5_dss_feat_list[] = {
  495. FEAT_MGR_LCD2,
  496. FEAT_MGR_LCD3,
  497. FEAT_CORE_CLK_DIV,
  498. FEAT_LCD_CLK_SRC,
  499. FEAT_DSI_DCS_CMD_CONFIG_VC,
  500. FEAT_DSI_VC_OCP_WIDTH,
  501. FEAT_DSI_GNQ,
  502. FEAT_HDMI_CTS_SWMODE,
  503. FEAT_HDMI_AUDIO_USE_MCLK,
  504. FEAT_HANDLE_UV_SEPARATE,
  505. FEAT_ATTR2,
  506. FEAT_CPR,
  507. FEAT_PRELOAD,
  508. FEAT_FIR_COEF_V,
  509. FEAT_ALPHA_FREE_ZORDER,
  510. FEAT_FIFO_MERGE,
  511. FEAT_BURST_2D,
  512. FEAT_DSI_PHY_DCC,
  513. FEAT_MFLAG,
  514. };
  515. /* OMAP2 DSS Features */
  516. static const struct omap_dss_features omap2_dss_features = {
  517. .reg_fields = omap2_dss_reg_fields,
  518. .num_reg_fields = ARRAY_SIZE(omap2_dss_reg_fields),
  519. .features = omap2_dss_feat_list,
  520. .num_features = ARRAY_SIZE(omap2_dss_feat_list),
  521. .num_mgrs = 2,
  522. .num_ovls = 3,
  523. .supported_displays = omap2_dss_supported_displays,
  524. .supported_outputs = omap2_dss_supported_outputs,
  525. .supported_color_modes = omap2_dss_supported_color_modes,
  526. .overlay_caps = omap2_dss_overlay_caps,
  527. .dss_params = omap2_dss_param_range,
  528. .buffer_size_unit = 1,
  529. .burst_size_unit = 8,
  530. };
  531. /* OMAP3 DSS Features */
  532. static const struct omap_dss_features omap3430_dss_features = {
  533. .reg_fields = omap3_dss_reg_fields,
  534. .num_reg_fields = ARRAY_SIZE(omap3_dss_reg_fields),
  535. .features = omap3430_dss_feat_list,
  536. .num_features = ARRAY_SIZE(omap3430_dss_feat_list),
  537. .num_mgrs = 2,
  538. .num_ovls = 3,
  539. .supported_displays = omap3430_dss_supported_displays,
  540. .supported_outputs = omap3430_dss_supported_outputs,
  541. .supported_color_modes = omap3_dss_supported_color_modes,
  542. .overlay_caps = omap3430_dss_overlay_caps,
  543. .dss_params = omap3_dss_param_range,
  544. .buffer_size_unit = 1,
  545. .burst_size_unit = 8,
  546. };
  547. /*
  548. * AM35xx DSS Features. This is basically OMAP3 DSS Features without the
  549. * vdds_dsi regulator.
  550. */
  551. static const struct omap_dss_features am35xx_dss_features = {
  552. .reg_fields = omap3_dss_reg_fields,
  553. .num_reg_fields = ARRAY_SIZE(omap3_dss_reg_fields),
  554. .features = am35xx_dss_feat_list,
  555. .num_features = ARRAY_SIZE(am35xx_dss_feat_list),
  556. .num_mgrs = 2,
  557. .num_ovls = 3,
  558. .supported_displays = omap3430_dss_supported_displays,
  559. .supported_outputs = omap3430_dss_supported_outputs,
  560. .supported_color_modes = omap3_dss_supported_color_modes,
  561. .overlay_caps = omap3430_dss_overlay_caps,
  562. .dss_params = omap3_dss_param_range,
  563. .buffer_size_unit = 1,
  564. .burst_size_unit = 8,
  565. };
  566. static const struct omap_dss_features am43xx_dss_features = {
  567. .reg_fields = am43xx_dss_reg_fields,
  568. .num_reg_fields = ARRAY_SIZE(am43xx_dss_reg_fields),
  569. .features = am43xx_dss_feat_list,
  570. .num_features = ARRAY_SIZE(am43xx_dss_feat_list),
  571. .num_mgrs = 1,
  572. .num_ovls = 3,
  573. .supported_displays = am43xx_dss_supported_displays,
  574. .supported_outputs = am43xx_dss_supported_outputs,
  575. .supported_color_modes = omap3_dss_supported_color_modes,
  576. .overlay_caps = omap3430_dss_overlay_caps,
  577. .dss_params = am43xx_dss_param_range,
  578. .buffer_size_unit = 1,
  579. .burst_size_unit = 8,
  580. };
  581. static const struct omap_dss_features omap3630_dss_features = {
  582. .reg_fields = omap3_dss_reg_fields,
  583. .num_reg_fields = ARRAY_SIZE(omap3_dss_reg_fields),
  584. .features = omap3630_dss_feat_list,
  585. .num_features = ARRAY_SIZE(omap3630_dss_feat_list),
  586. .num_mgrs = 2,
  587. .num_ovls = 3,
  588. .supported_displays = omap3630_dss_supported_displays,
  589. .supported_outputs = omap3630_dss_supported_outputs,
  590. .supported_color_modes = omap3_dss_supported_color_modes,
  591. .overlay_caps = omap3630_dss_overlay_caps,
  592. .dss_params = omap3_dss_param_range,
  593. .buffer_size_unit = 1,
  594. .burst_size_unit = 8,
  595. };
  596. /* OMAP4 DSS Features */
  597. /* For OMAP4430 ES 1.0 revision */
  598. static const struct omap_dss_features omap4430_es1_0_dss_features = {
  599. .reg_fields = omap4_dss_reg_fields,
  600. .num_reg_fields = ARRAY_SIZE(omap4_dss_reg_fields),
  601. .features = omap4430_es1_0_dss_feat_list,
  602. .num_features = ARRAY_SIZE(omap4430_es1_0_dss_feat_list),
  603. .num_mgrs = 3,
  604. .num_ovls = 4,
  605. .supported_displays = omap4_dss_supported_displays,
  606. .supported_outputs = omap4_dss_supported_outputs,
  607. .supported_color_modes = omap4_dss_supported_color_modes,
  608. .overlay_caps = omap4_dss_overlay_caps,
  609. .dss_params = omap4_dss_param_range,
  610. .buffer_size_unit = 16,
  611. .burst_size_unit = 16,
  612. };
  613. /* For OMAP4430 ES 2.0, 2.1 and 2.2 revisions */
  614. static const struct omap_dss_features omap4430_es2_0_1_2_dss_features = {
  615. .reg_fields = omap4_dss_reg_fields,
  616. .num_reg_fields = ARRAY_SIZE(omap4_dss_reg_fields),
  617. .features = omap4430_es2_0_1_2_dss_feat_list,
  618. .num_features = ARRAY_SIZE(omap4430_es2_0_1_2_dss_feat_list),
  619. .num_mgrs = 3,
  620. .num_ovls = 4,
  621. .supported_displays = omap4_dss_supported_displays,
  622. .supported_outputs = omap4_dss_supported_outputs,
  623. .supported_color_modes = omap4_dss_supported_color_modes,
  624. .overlay_caps = omap4_dss_overlay_caps,
  625. .dss_params = omap4_dss_param_range,
  626. .buffer_size_unit = 16,
  627. .burst_size_unit = 16,
  628. };
  629. /* For all the other OMAP4 versions */
  630. static const struct omap_dss_features omap4_dss_features = {
  631. .reg_fields = omap4_dss_reg_fields,
  632. .num_reg_fields = ARRAY_SIZE(omap4_dss_reg_fields),
  633. .features = omap4_dss_feat_list,
  634. .num_features = ARRAY_SIZE(omap4_dss_feat_list),
  635. .num_mgrs = 3,
  636. .num_ovls = 4,
  637. .supported_displays = omap4_dss_supported_displays,
  638. .supported_outputs = omap4_dss_supported_outputs,
  639. .supported_color_modes = omap4_dss_supported_color_modes,
  640. .overlay_caps = omap4_dss_overlay_caps,
  641. .dss_params = omap4_dss_param_range,
  642. .buffer_size_unit = 16,
  643. .burst_size_unit = 16,
  644. };
  645. /* OMAP5 DSS Features */
  646. static const struct omap_dss_features omap5_dss_features = {
  647. .reg_fields = omap5_dss_reg_fields,
  648. .num_reg_fields = ARRAY_SIZE(omap5_dss_reg_fields),
  649. .features = omap5_dss_feat_list,
  650. .num_features = ARRAY_SIZE(omap5_dss_feat_list),
  651. .num_mgrs = 4,
  652. .num_ovls = 4,
  653. .supported_displays = omap5_dss_supported_displays,
  654. .supported_outputs = omap5_dss_supported_outputs,
  655. .supported_color_modes = omap4_dss_supported_color_modes,
  656. .overlay_caps = omap4_dss_overlay_caps,
  657. .dss_params = omap5_dss_param_range,
  658. .buffer_size_unit = 16,
  659. .burst_size_unit = 16,
  660. };
  661. /* Functions returning values related to a DSS feature */
  662. int dss_feat_get_num_mgrs(void)
  663. {
  664. return omap_current_dss_features->num_mgrs;
  665. }
  666. int dss_feat_get_num_ovls(void)
  667. {
  668. return omap_current_dss_features->num_ovls;
  669. }
  670. unsigned long dss_feat_get_param_min(enum dss_range_param param)
  671. {
  672. return omap_current_dss_features->dss_params[param].min;
  673. }
  674. unsigned long dss_feat_get_param_max(enum dss_range_param param)
  675. {
  676. return omap_current_dss_features->dss_params[param].max;
  677. }
  678. enum omap_display_type dss_feat_get_supported_displays(enum omap_channel channel)
  679. {
  680. return omap_current_dss_features->supported_displays[channel];
  681. }
  682. enum omap_dss_output_id dss_feat_get_supported_outputs(enum omap_channel channel)
  683. {
  684. return omap_current_dss_features->supported_outputs[channel];
  685. }
  686. const u32 *dss_feat_get_supported_color_modes(enum omap_plane_id plane)
  687. {
  688. return omap_current_dss_features->supported_color_modes[plane];
  689. }
  690. enum omap_overlay_caps dss_feat_get_overlay_caps(enum omap_plane_id plane)
  691. {
  692. return omap_current_dss_features->overlay_caps[plane];
  693. }
  694. bool dss_feat_color_mode_supported(enum omap_plane_id plane, u32 fourcc)
  695. {
  696. const u32 *modes;
  697. unsigned int i;
  698. modes = omap_current_dss_features->supported_color_modes[plane];
  699. for (i = 0; modes[i]; ++i) {
  700. if (modes[i] == fourcc)
  701. return true;
  702. }
  703. return false;
  704. }
  705. u32 dss_feat_get_buffer_size_unit(void)
  706. {
  707. return omap_current_dss_features->buffer_size_unit;
  708. }
  709. u32 dss_feat_get_burst_size_unit(void)
  710. {
  711. return omap_current_dss_features->burst_size_unit;
  712. }
  713. /* DSS has_feature check */
  714. bool dss_has_feature(enum dss_feat_id id)
  715. {
  716. int i;
  717. const enum dss_feat_id *features = omap_current_dss_features->features;
  718. const int num_features = omap_current_dss_features->num_features;
  719. for (i = 0; i < num_features; i++) {
  720. if (features[i] == id)
  721. return true;
  722. }
  723. return false;
  724. }
  725. void dss_feat_get_reg_field(enum dss_feat_reg_field id, u8 *start, u8 *end)
  726. {
  727. if (id >= omap_current_dss_features->num_reg_fields)
  728. BUG();
  729. *start = omap_current_dss_features->reg_fields[id].start;
  730. *end = omap_current_dss_features->reg_fields[id].end;
  731. }
  732. void dss_features_init(enum omapdss_version version)
  733. {
  734. switch (version) {
  735. case OMAPDSS_VER_OMAP24xx:
  736. omap_current_dss_features = &omap2_dss_features;
  737. break;
  738. case OMAPDSS_VER_OMAP34xx_ES1:
  739. case OMAPDSS_VER_OMAP34xx_ES3:
  740. omap_current_dss_features = &omap3430_dss_features;
  741. break;
  742. case OMAPDSS_VER_OMAP3630:
  743. omap_current_dss_features = &omap3630_dss_features;
  744. break;
  745. case OMAPDSS_VER_OMAP4430_ES1:
  746. omap_current_dss_features = &omap4430_es1_0_dss_features;
  747. break;
  748. case OMAPDSS_VER_OMAP4430_ES2:
  749. omap_current_dss_features = &omap4430_es2_0_1_2_dss_features;
  750. break;
  751. case OMAPDSS_VER_OMAP4:
  752. omap_current_dss_features = &omap4_dss_features;
  753. break;
  754. case OMAPDSS_VER_OMAP5:
  755. case OMAPDSS_VER_DRA7xx:
  756. omap_current_dss_features = &omap5_dss_features;
  757. break;
  758. case OMAPDSS_VER_AM35xx:
  759. omap_current_dss_features = &am35xx_dss_features;
  760. break;
  761. case OMAPDSS_VER_AM43xx:
  762. omap_current_dss_features = &am43xx_dss_features;
  763. break;
  764. default:
  765. DSSWARN("Unsupported OMAP version");
  766. break;
  767. }
  768. }