mdp_ppp22.c 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092
  1. /* drivers/video/msm/mdp_ppp22.c
  2. *
  3. * Copyright (C) 2007 The Linux Foundation. All rights reserved.
  4. * Copyright (C) 2007 Google Incorporated
  5. *
  6. * This software is licensed under the terms of the GNU General Public
  7. * License version 2, as published by the Free Software Foundation, and
  8. * may be copied, distributed, and modified under those terms.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. */
  15. #include <linux/kernel.h>
  16. #include <asm/io.h>
  17. #include <linux/msm_mdp.h>
  18. #include "mdp_hw.h"
  19. #include "mdp_ppp.h"
  20. struct mdp_table_entry {
  21. uint32_t reg;
  22. uint32_t val;
  23. };
  24. enum {
  25. MDP_DOWNSCALE_PT2TOPT4,
  26. MDP_DOWNSCALE_PT4TOPT6,
  27. MDP_DOWNSCALE_PT6TOPT8,
  28. MDP_DOWNSCALE_PT8TO1,
  29. MDP_DOWNSCALE_MAX,
  30. /* not technically in the downscale table list */
  31. MDP_DOWNSCALE_BLUR,
  32. };
  33. static int downscale_x_table;
  34. static int downscale_y_table;
  35. static struct mdp_table_entry mdp_upscale_table[] = {
  36. { 0x5fffc, 0x0 },
  37. { 0x50200, 0x7fc00000 },
  38. { 0x5fffc, 0xff80000d },
  39. { 0x50204, 0x7ec003f9 },
  40. { 0x5fffc, 0xfec0001c },
  41. { 0x50208, 0x7d4003f3 },
  42. { 0x5fffc, 0xfe40002b },
  43. { 0x5020c, 0x7b8003ed },
  44. { 0x5fffc, 0xfd80003c },
  45. { 0x50210, 0x794003e8 },
  46. { 0x5fffc, 0xfcc0004d },
  47. { 0x50214, 0x76c003e4 },
  48. { 0x5fffc, 0xfc40005f },
  49. { 0x50218, 0x73c003e0 },
  50. { 0x5fffc, 0xfb800071 },
  51. { 0x5021c, 0x708003de },
  52. { 0x5fffc, 0xfac00085 },
  53. { 0x50220, 0x6d0003db },
  54. { 0x5fffc, 0xfa000098 },
  55. { 0x50224, 0x698003d9 },
  56. { 0x5fffc, 0xf98000ac },
  57. { 0x50228, 0x654003d8 },
  58. { 0x5fffc, 0xf8c000c1 },
  59. { 0x5022c, 0x610003d7 },
  60. { 0x5fffc, 0xf84000d5 },
  61. { 0x50230, 0x5c8003d7 },
  62. { 0x5fffc, 0xf7c000e9 },
  63. { 0x50234, 0x580003d7 },
  64. { 0x5fffc, 0xf74000fd },
  65. { 0x50238, 0x534003d8 },
  66. { 0x5fffc, 0xf6c00112 },
  67. { 0x5023c, 0x4e8003d8 },
  68. { 0x5fffc, 0xf6800126 },
  69. { 0x50240, 0x494003da },
  70. { 0x5fffc, 0xf600013a },
  71. { 0x50244, 0x448003db },
  72. { 0x5fffc, 0xf600014d },
  73. { 0x50248, 0x3f4003dd },
  74. { 0x5fffc, 0xf5c00160 },
  75. { 0x5024c, 0x3a4003df },
  76. { 0x5fffc, 0xf5c00172 },
  77. { 0x50250, 0x354003e1 },
  78. { 0x5fffc, 0xf5c00184 },
  79. { 0x50254, 0x304003e3 },
  80. { 0x5fffc, 0xf6000195 },
  81. { 0x50258, 0x2b0003e6 },
  82. { 0x5fffc, 0xf64001a6 },
  83. { 0x5025c, 0x260003e8 },
  84. { 0x5fffc, 0xf6c001b4 },
  85. { 0x50260, 0x214003eb },
  86. { 0x5fffc, 0xf78001c2 },
  87. { 0x50264, 0x1c4003ee },
  88. { 0x5fffc, 0xf80001cf },
  89. { 0x50268, 0x17c003f1 },
  90. { 0x5fffc, 0xf90001db },
  91. { 0x5026c, 0x134003f3 },
  92. { 0x5fffc, 0xfa0001e5 },
  93. { 0x50270, 0xf0003f6 },
  94. { 0x5fffc, 0xfb4001ee },
  95. { 0x50274, 0xac003f9 },
  96. { 0x5fffc, 0xfcc001f5 },
  97. { 0x50278, 0x70003fb },
  98. { 0x5fffc, 0xfe4001fb },
  99. { 0x5027c, 0x34003fe },
  100. };
  101. static struct mdp_table_entry mdp_downscale_x_table_PT2TOPT4[] = {
  102. { 0x5fffc, 0x740008c },
  103. { 0x50280, 0x33800088 },
  104. { 0x5fffc, 0x800008e },
  105. { 0x50284, 0x33400084 },
  106. { 0x5fffc, 0x8400092 },
  107. { 0x50288, 0x33000080 },
  108. { 0x5fffc, 0x9000094 },
  109. { 0x5028c, 0x3300007b },
  110. { 0x5fffc, 0x9c00098 },
  111. { 0x50290, 0x32400077 },
  112. { 0x5fffc, 0xa40009b },
  113. { 0x50294, 0x32000073 },
  114. { 0x5fffc, 0xb00009d },
  115. { 0x50298, 0x31c0006f },
  116. { 0x5fffc, 0xbc000a0 },
  117. { 0x5029c, 0x3140006b },
  118. { 0x5fffc, 0xc8000a2 },
  119. { 0x502a0, 0x31000067 },
  120. { 0x5fffc, 0xd8000a5 },
  121. { 0x502a4, 0x30800062 },
  122. { 0x5fffc, 0xe4000a8 },
  123. { 0x502a8, 0x2fc0005f },
  124. { 0x5fffc, 0xec000aa },
  125. { 0x502ac, 0x2fc0005b },
  126. { 0x5fffc, 0xf8000ad },
  127. { 0x502b0, 0x2f400057 },
  128. { 0x5fffc, 0x108000b0 },
  129. { 0x502b4, 0x2e400054 },
  130. { 0x5fffc, 0x114000b2 },
  131. { 0x502b8, 0x2e000050 },
  132. { 0x5fffc, 0x124000b4 },
  133. { 0x502bc, 0x2d80004c },
  134. { 0x5fffc, 0x130000b6 },
  135. { 0x502c0, 0x2d000049 },
  136. { 0x5fffc, 0x140000b8 },
  137. { 0x502c4, 0x2c800045 },
  138. { 0x5fffc, 0x150000b9 },
  139. { 0x502c8, 0x2c000042 },
  140. { 0x5fffc, 0x15c000bd },
  141. { 0x502cc, 0x2b40003e },
  142. { 0x5fffc, 0x16c000bf },
  143. { 0x502d0, 0x2a80003b },
  144. { 0x5fffc, 0x17c000bf },
  145. { 0x502d4, 0x2a000039 },
  146. { 0x5fffc, 0x188000c2 },
  147. { 0x502d8, 0x29400036 },
  148. { 0x5fffc, 0x19c000c4 },
  149. { 0x502dc, 0x28800032 },
  150. { 0x5fffc, 0x1ac000c5 },
  151. { 0x502e0, 0x2800002f },
  152. { 0x5fffc, 0x1bc000c7 },
  153. { 0x502e4, 0x2740002c },
  154. { 0x5fffc, 0x1cc000c8 },
  155. { 0x502e8, 0x26c00029 },
  156. { 0x5fffc, 0x1dc000c9 },
  157. { 0x502ec, 0x26000027 },
  158. { 0x5fffc, 0x1ec000cc },
  159. { 0x502f0, 0x25000024 },
  160. { 0x5fffc, 0x200000cc },
  161. { 0x502f4, 0x24800021 },
  162. { 0x5fffc, 0x210000cd },
  163. { 0x502f8, 0x23800020 },
  164. { 0x5fffc, 0x220000ce },
  165. { 0x502fc, 0x2300001d },
  166. };
  167. static struct mdp_table_entry mdp_downscale_x_table_PT4TOPT6[] = {
  168. { 0x5fffc, 0x740008c },
  169. { 0x50280, 0x33800088 },
  170. { 0x5fffc, 0x800008e },
  171. { 0x50284, 0x33400084 },
  172. { 0x5fffc, 0x8400092 },
  173. { 0x50288, 0x33000080 },
  174. { 0x5fffc, 0x9000094 },
  175. { 0x5028c, 0x3300007b },
  176. { 0x5fffc, 0x9c00098 },
  177. { 0x50290, 0x32400077 },
  178. { 0x5fffc, 0xa40009b },
  179. { 0x50294, 0x32000073 },
  180. { 0x5fffc, 0xb00009d },
  181. { 0x50298, 0x31c0006f },
  182. { 0x5fffc, 0xbc000a0 },
  183. { 0x5029c, 0x3140006b },
  184. { 0x5fffc, 0xc8000a2 },
  185. { 0x502a0, 0x31000067 },
  186. { 0x5fffc, 0xd8000a5 },
  187. { 0x502a4, 0x30800062 },
  188. { 0x5fffc, 0xe4000a8 },
  189. { 0x502a8, 0x2fc0005f },
  190. { 0x5fffc, 0xec000aa },
  191. { 0x502ac, 0x2fc0005b },
  192. { 0x5fffc, 0xf8000ad },
  193. { 0x502b0, 0x2f400057 },
  194. { 0x5fffc, 0x108000b0 },
  195. { 0x502b4, 0x2e400054 },
  196. { 0x5fffc, 0x114000b2 },
  197. { 0x502b8, 0x2e000050 },
  198. { 0x5fffc, 0x124000b4 },
  199. { 0x502bc, 0x2d80004c },
  200. { 0x5fffc, 0x130000b6 },
  201. { 0x502c0, 0x2d000049 },
  202. { 0x5fffc, 0x140000b8 },
  203. { 0x502c4, 0x2c800045 },
  204. { 0x5fffc, 0x150000b9 },
  205. { 0x502c8, 0x2c000042 },
  206. { 0x5fffc, 0x15c000bd },
  207. { 0x502cc, 0x2b40003e },
  208. { 0x5fffc, 0x16c000bf },
  209. { 0x502d0, 0x2a80003b },
  210. { 0x5fffc, 0x17c000bf },
  211. { 0x502d4, 0x2a000039 },
  212. { 0x5fffc, 0x188000c2 },
  213. { 0x502d8, 0x29400036 },
  214. { 0x5fffc, 0x19c000c4 },
  215. { 0x502dc, 0x28800032 },
  216. { 0x5fffc, 0x1ac000c5 },
  217. { 0x502e0, 0x2800002f },
  218. { 0x5fffc, 0x1bc000c7 },
  219. { 0x502e4, 0x2740002c },
  220. { 0x5fffc, 0x1cc000c8 },
  221. { 0x502e8, 0x26c00029 },
  222. { 0x5fffc, 0x1dc000c9 },
  223. { 0x502ec, 0x26000027 },
  224. { 0x5fffc, 0x1ec000cc },
  225. { 0x502f0, 0x25000024 },
  226. { 0x5fffc, 0x200000cc },
  227. { 0x502f4, 0x24800021 },
  228. { 0x5fffc, 0x210000cd },
  229. { 0x502f8, 0x23800020 },
  230. { 0x5fffc, 0x220000ce },
  231. { 0x502fc, 0x2300001d },
  232. };
  233. static struct mdp_table_entry mdp_downscale_x_table_PT6TOPT8[] = {
  234. { 0x5fffc, 0xfe000070 },
  235. { 0x50280, 0x4bc00068 },
  236. { 0x5fffc, 0xfe000078 },
  237. { 0x50284, 0x4bc00060 },
  238. { 0x5fffc, 0xfe000080 },
  239. { 0x50288, 0x4b800059 },
  240. { 0x5fffc, 0xfe000089 },
  241. { 0x5028c, 0x4b000052 },
  242. { 0x5fffc, 0xfe400091 },
  243. { 0x50290, 0x4a80004b },
  244. { 0x5fffc, 0xfe40009a },
  245. { 0x50294, 0x4a000044 },
  246. { 0x5fffc, 0xfe8000a3 },
  247. { 0x50298, 0x4940003d },
  248. { 0x5fffc, 0xfec000ac },
  249. { 0x5029c, 0x48400037 },
  250. { 0x5fffc, 0xff0000b4 },
  251. { 0x502a0, 0x47800031 },
  252. { 0x5fffc, 0xff8000bd },
  253. { 0x502a4, 0x4640002b },
  254. { 0x5fffc, 0xc5 },
  255. { 0x502a8, 0x45000026 },
  256. { 0x5fffc, 0x8000ce },
  257. { 0x502ac, 0x43800021 },
  258. { 0x5fffc, 0x10000d6 },
  259. { 0x502b0, 0x4240001c },
  260. { 0x5fffc, 0x18000df },
  261. { 0x502b4, 0x40800018 },
  262. { 0x5fffc, 0x24000e6 },
  263. { 0x502b8, 0x3f000014 },
  264. { 0x5fffc, 0x30000ee },
  265. { 0x502bc, 0x3d400010 },
  266. { 0x5fffc, 0x40000f5 },
  267. { 0x502c0, 0x3b80000c },
  268. { 0x5fffc, 0x50000fc },
  269. { 0x502c4, 0x39800009 },
  270. { 0x5fffc, 0x6000102 },
  271. { 0x502c8, 0x37c00006 },
  272. { 0x5fffc, 0x7000109 },
  273. { 0x502cc, 0x35800004 },
  274. { 0x5fffc, 0x840010e },
  275. { 0x502d0, 0x33800002 },
  276. { 0x5fffc, 0x9800114 },
  277. { 0x502d4, 0x31400000 },
  278. { 0x5fffc, 0xac00119 },
  279. { 0x502d8, 0x2f4003fe },
  280. { 0x5fffc, 0xc40011e },
  281. { 0x502dc, 0x2d0003fc },
  282. { 0x5fffc, 0xdc00121 },
  283. { 0x502e0, 0x2b0003fb },
  284. { 0x5fffc, 0xf400125 },
  285. { 0x502e4, 0x28c003fa },
  286. { 0x5fffc, 0x11000128 },
  287. { 0x502e8, 0x268003f9 },
  288. { 0x5fffc, 0x12c0012a },
  289. { 0x502ec, 0x244003f9 },
  290. { 0x5fffc, 0x1480012c },
  291. { 0x502f0, 0x224003f8 },
  292. { 0x5fffc, 0x1640012e },
  293. { 0x502f4, 0x200003f8 },
  294. { 0x5fffc, 0x1800012f },
  295. { 0x502f8, 0x1e0003f8 },
  296. { 0x5fffc, 0x1a00012f },
  297. { 0x502fc, 0x1c0003f8 },
  298. };
  299. static struct mdp_table_entry mdp_downscale_x_table_PT8TO1[] = {
  300. { 0x5fffc, 0x0 },
  301. { 0x50280, 0x7fc00000 },
  302. { 0x5fffc, 0xff80000d },
  303. { 0x50284, 0x7ec003f9 },
  304. { 0x5fffc, 0xfec0001c },
  305. { 0x50288, 0x7d4003f3 },
  306. { 0x5fffc, 0xfe40002b },
  307. { 0x5028c, 0x7b8003ed },
  308. { 0x5fffc, 0xfd80003c },
  309. { 0x50290, 0x794003e8 },
  310. { 0x5fffc, 0xfcc0004d },
  311. { 0x50294, 0x76c003e4 },
  312. { 0x5fffc, 0xfc40005f },
  313. { 0x50298, 0x73c003e0 },
  314. { 0x5fffc, 0xfb800071 },
  315. { 0x5029c, 0x708003de },
  316. { 0x5fffc, 0xfac00085 },
  317. { 0x502a0, 0x6d0003db },
  318. { 0x5fffc, 0xfa000098 },
  319. { 0x502a4, 0x698003d9 },
  320. { 0x5fffc, 0xf98000ac },
  321. { 0x502a8, 0x654003d8 },
  322. { 0x5fffc, 0xf8c000c1 },
  323. { 0x502ac, 0x610003d7 },
  324. { 0x5fffc, 0xf84000d5 },
  325. { 0x502b0, 0x5c8003d7 },
  326. { 0x5fffc, 0xf7c000e9 },
  327. { 0x502b4, 0x580003d7 },
  328. { 0x5fffc, 0xf74000fd },
  329. { 0x502b8, 0x534003d8 },
  330. { 0x5fffc, 0xf6c00112 },
  331. { 0x502bc, 0x4e8003d8 },
  332. { 0x5fffc, 0xf6800126 },
  333. { 0x502c0, 0x494003da },
  334. { 0x5fffc, 0xf600013a },
  335. { 0x502c4, 0x448003db },
  336. { 0x5fffc, 0xf600014d },
  337. { 0x502c8, 0x3f4003dd },
  338. { 0x5fffc, 0xf5c00160 },
  339. { 0x502cc, 0x3a4003df },
  340. { 0x5fffc, 0xf5c00172 },
  341. { 0x502d0, 0x354003e1 },
  342. { 0x5fffc, 0xf5c00184 },
  343. { 0x502d4, 0x304003e3 },
  344. { 0x5fffc, 0xf6000195 },
  345. { 0x502d8, 0x2b0003e6 },
  346. { 0x5fffc, 0xf64001a6 },
  347. { 0x502dc, 0x260003e8 },
  348. { 0x5fffc, 0xf6c001b4 },
  349. { 0x502e0, 0x214003eb },
  350. { 0x5fffc, 0xf78001c2 },
  351. { 0x502e4, 0x1c4003ee },
  352. { 0x5fffc, 0xf80001cf },
  353. { 0x502e8, 0x17c003f1 },
  354. { 0x5fffc, 0xf90001db },
  355. { 0x502ec, 0x134003f3 },
  356. { 0x5fffc, 0xfa0001e5 },
  357. { 0x502f0, 0xf0003f6 },
  358. { 0x5fffc, 0xfb4001ee },
  359. { 0x502f4, 0xac003f9 },
  360. { 0x5fffc, 0xfcc001f5 },
  361. { 0x502f8, 0x70003fb },
  362. { 0x5fffc, 0xfe4001fb },
  363. { 0x502fc, 0x34003fe },
  364. };
  365. struct mdp_table_entry *mdp_downscale_x_table[MDP_DOWNSCALE_MAX] = {
  366. [MDP_DOWNSCALE_PT2TOPT4] = mdp_downscale_x_table_PT2TOPT4,
  367. [MDP_DOWNSCALE_PT4TOPT6] = mdp_downscale_x_table_PT4TOPT6,
  368. [MDP_DOWNSCALE_PT6TOPT8] = mdp_downscale_x_table_PT6TOPT8,
  369. [MDP_DOWNSCALE_PT8TO1] = mdp_downscale_x_table_PT8TO1,
  370. };
  371. static struct mdp_table_entry mdp_downscale_y_table_PT2TOPT4[] = {
  372. { 0x5fffc, 0x740008c },
  373. { 0x50300, 0x33800088 },
  374. { 0x5fffc, 0x800008e },
  375. { 0x50304, 0x33400084 },
  376. { 0x5fffc, 0x8400092 },
  377. { 0x50308, 0x33000080 },
  378. { 0x5fffc, 0x9000094 },
  379. { 0x5030c, 0x3300007b },
  380. { 0x5fffc, 0x9c00098 },
  381. { 0x50310, 0x32400077 },
  382. { 0x5fffc, 0xa40009b },
  383. { 0x50314, 0x32000073 },
  384. { 0x5fffc, 0xb00009d },
  385. { 0x50318, 0x31c0006f },
  386. { 0x5fffc, 0xbc000a0 },
  387. { 0x5031c, 0x3140006b },
  388. { 0x5fffc, 0xc8000a2 },
  389. { 0x50320, 0x31000067 },
  390. { 0x5fffc, 0xd8000a5 },
  391. { 0x50324, 0x30800062 },
  392. { 0x5fffc, 0xe4000a8 },
  393. { 0x50328, 0x2fc0005f },
  394. { 0x5fffc, 0xec000aa },
  395. { 0x5032c, 0x2fc0005b },
  396. { 0x5fffc, 0xf8000ad },
  397. { 0x50330, 0x2f400057 },
  398. { 0x5fffc, 0x108000b0 },
  399. { 0x50334, 0x2e400054 },
  400. { 0x5fffc, 0x114000b2 },
  401. { 0x50338, 0x2e000050 },
  402. { 0x5fffc, 0x124000b4 },
  403. { 0x5033c, 0x2d80004c },
  404. { 0x5fffc, 0x130000b6 },
  405. { 0x50340, 0x2d000049 },
  406. { 0x5fffc, 0x140000b8 },
  407. { 0x50344, 0x2c800045 },
  408. { 0x5fffc, 0x150000b9 },
  409. { 0x50348, 0x2c000042 },
  410. { 0x5fffc, 0x15c000bd },
  411. { 0x5034c, 0x2b40003e },
  412. { 0x5fffc, 0x16c000bf },
  413. { 0x50350, 0x2a80003b },
  414. { 0x5fffc, 0x17c000bf },
  415. { 0x50354, 0x2a000039 },
  416. { 0x5fffc, 0x188000c2 },
  417. { 0x50358, 0x29400036 },
  418. { 0x5fffc, 0x19c000c4 },
  419. { 0x5035c, 0x28800032 },
  420. { 0x5fffc, 0x1ac000c5 },
  421. { 0x50360, 0x2800002f },
  422. { 0x5fffc, 0x1bc000c7 },
  423. { 0x50364, 0x2740002c },
  424. { 0x5fffc, 0x1cc000c8 },
  425. { 0x50368, 0x26c00029 },
  426. { 0x5fffc, 0x1dc000c9 },
  427. { 0x5036c, 0x26000027 },
  428. { 0x5fffc, 0x1ec000cc },
  429. { 0x50370, 0x25000024 },
  430. { 0x5fffc, 0x200000cc },
  431. { 0x50374, 0x24800021 },
  432. { 0x5fffc, 0x210000cd },
  433. { 0x50378, 0x23800020 },
  434. { 0x5fffc, 0x220000ce },
  435. { 0x5037c, 0x2300001d },
  436. };
  437. static struct mdp_table_entry mdp_downscale_y_table_PT4TOPT6[] = {
  438. { 0x5fffc, 0x740008c },
  439. { 0x50300, 0x33800088 },
  440. { 0x5fffc, 0x800008e },
  441. { 0x50304, 0x33400084 },
  442. { 0x5fffc, 0x8400092 },
  443. { 0x50308, 0x33000080 },
  444. { 0x5fffc, 0x9000094 },
  445. { 0x5030c, 0x3300007b },
  446. { 0x5fffc, 0x9c00098 },
  447. { 0x50310, 0x32400077 },
  448. { 0x5fffc, 0xa40009b },
  449. { 0x50314, 0x32000073 },
  450. { 0x5fffc, 0xb00009d },
  451. { 0x50318, 0x31c0006f },
  452. { 0x5fffc, 0xbc000a0 },
  453. { 0x5031c, 0x3140006b },
  454. { 0x5fffc, 0xc8000a2 },
  455. { 0x50320, 0x31000067 },
  456. { 0x5fffc, 0xd8000a5 },
  457. { 0x50324, 0x30800062 },
  458. { 0x5fffc, 0xe4000a8 },
  459. { 0x50328, 0x2fc0005f },
  460. { 0x5fffc, 0xec000aa },
  461. { 0x5032c, 0x2fc0005b },
  462. { 0x5fffc, 0xf8000ad },
  463. { 0x50330, 0x2f400057 },
  464. { 0x5fffc, 0x108000b0 },
  465. { 0x50334, 0x2e400054 },
  466. { 0x5fffc, 0x114000b2 },
  467. { 0x50338, 0x2e000050 },
  468. { 0x5fffc, 0x124000b4 },
  469. { 0x5033c, 0x2d80004c },
  470. { 0x5fffc, 0x130000b6 },
  471. { 0x50340, 0x2d000049 },
  472. { 0x5fffc, 0x140000b8 },
  473. { 0x50344, 0x2c800045 },
  474. { 0x5fffc, 0x150000b9 },
  475. { 0x50348, 0x2c000042 },
  476. { 0x5fffc, 0x15c000bd },
  477. { 0x5034c, 0x2b40003e },
  478. { 0x5fffc, 0x16c000bf },
  479. { 0x50350, 0x2a80003b },
  480. { 0x5fffc, 0x17c000bf },
  481. { 0x50354, 0x2a000039 },
  482. { 0x5fffc, 0x188000c2 },
  483. { 0x50358, 0x29400036 },
  484. { 0x5fffc, 0x19c000c4 },
  485. { 0x5035c, 0x28800032 },
  486. { 0x5fffc, 0x1ac000c5 },
  487. { 0x50360, 0x2800002f },
  488. { 0x5fffc, 0x1bc000c7 },
  489. { 0x50364, 0x2740002c },
  490. { 0x5fffc, 0x1cc000c8 },
  491. { 0x50368, 0x26c00029 },
  492. { 0x5fffc, 0x1dc000c9 },
  493. { 0x5036c, 0x26000027 },
  494. { 0x5fffc, 0x1ec000cc },
  495. { 0x50370, 0x25000024 },
  496. { 0x5fffc, 0x200000cc },
  497. { 0x50374, 0x24800021 },
  498. { 0x5fffc, 0x210000cd },
  499. { 0x50378, 0x23800020 },
  500. { 0x5fffc, 0x220000ce },
  501. { 0x5037c, 0x2300001d },
  502. };
  503. static struct mdp_table_entry mdp_downscale_y_table_PT6TOPT8[] = {
  504. { 0x5fffc, 0xfe000070 },
  505. { 0x50300, 0x4bc00068 },
  506. { 0x5fffc, 0xfe000078 },
  507. { 0x50304, 0x4bc00060 },
  508. { 0x5fffc, 0xfe000080 },
  509. { 0x50308, 0x4b800059 },
  510. { 0x5fffc, 0xfe000089 },
  511. { 0x5030c, 0x4b000052 },
  512. { 0x5fffc, 0xfe400091 },
  513. { 0x50310, 0x4a80004b },
  514. { 0x5fffc, 0xfe40009a },
  515. { 0x50314, 0x4a000044 },
  516. { 0x5fffc, 0xfe8000a3 },
  517. { 0x50318, 0x4940003d },
  518. { 0x5fffc, 0xfec000ac },
  519. { 0x5031c, 0x48400037 },
  520. { 0x5fffc, 0xff0000b4 },
  521. { 0x50320, 0x47800031 },
  522. { 0x5fffc, 0xff8000bd },
  523. { 0x50324, 0x4640002b },
  524. { 0x5fffc, 0xc5 },
  525. { 0x50328, 0x45000026 },
  526. { 0x5fffc, 0x8000ce },
  527. { 0x5032c, 0x43800021 },
  528. { 0x5fffc, 0x10000d6 },
  529. { 0x50330, 0x4240001c },
  530. { 0x5fffc, 0x18000df },
  531. { 0x50334, 0x40800018 },
  532. { 0x5fffc, 0x24000e6 },
  533. { 0x50338, 0x3f000014 },
  534. { 0x5fffc, 0x30000ee },
  535. { 0x5033c, 0x3d400010 },
  536. { 0x5fffc, 0x40000f5 },
  537. { 0x50340, 0x3b80000c },
  538. { 0x5fffc, 0x50000fc },
  539. { 0x50344, 0x39800009 },
  540. { 0x5fffc, 0x6000102 },
  541. { 0x50348, 0x37c00006 },
  542. { 0x5fffc, 0x7000109 },
  543. { 0x5034c, 0x35800004 },
  544. { 0x5fffc, 0x840010e },
  545. { 0x50350, 0x33800002 },
  546. { 0x5fffc, 0x9800114 },
  547. { 0x50354, 0x31400000 },
  548. { 0x5fffc, 0xac00119 },
  549. { 0x50358, 0x2f4003fe },
  550. { 0x5fffc, 0xc40011e },
  551. { 0x5035c, 0x2d0003fc },
  552. { 0x5fffc, 0xdc00121 },
  553. { 0x50360, 0x2b0003fb },
  554. { 0x5fffc, 0xf400125 },
  555. { 0x50364, 0x28c003fa },
  556. { 0x5fffc, 0x11000128 },
  557. { 0x50368, 0x268003f9 },
  558. { 0x5fffc, 0x12c0012a },
  559. { 0x5036c, 0x244003f9 },
  560. { 0x5fffc, 0x1480012c },
  561. { 0x50370, 0x224003f8 },
  562. { 0x5fffc, 0x1640012e },
  563. { 0x50374, 0x200003f8 },
  564. { 0x5fffc, 0x1800012f },
  565. { 0x50378, 0x1e0003f8 },
  566. { 0x5fffc, 0x1a00012f },
  567. { 0x5037c, 0x1c0003f8 },
  568. };
  569. static struct mdp_table_entry mdp_downscale_y_table_PT8TO1[] = {
  570. { 0x5fffc, 0x0 },
  571. { 0x50300, 0x7fc00000 },
  572. { 0x5fffc, 0xff80000d },
  573. { 0x50304, 0x7ec003f9 },
  574. { 0x5fffc, 0xfec0001c },
  575. { 0x50308, 0x7d4003f3 },
  576. { 0x5fffc, 0xfe40002b },
  577. { 0x5030c, 0x7b8003ed },
  578. { 0x5fffc, 0xfd80003c },
  579. { 0x50310, 0x794003e8 },
  580. { 0x5fffc, 0xfcc0004d },
  581. { 0x50314, 0x76c003e4 },
  582. { 0x5fffc, 0xfc40005f },
  583. { 0x50318, 0x73c003e0 },
  584. { 0x5fffc, 0xfb800071 },
  585. { 0x5031c, 0x708003de },
  586. { 0x5fffc, 0xfac00085 },
  587. { 0x50320, 0x6d0003db },
  588. { 0x5fffc, 0xfa000098 },
  589. { 0x50324, 0x698003d9 },
  590. { 0x5fffc, 0xf98000ac },
  591. { 0x50328, 0x654003d8 },
  592. { 0x5fffc, 0xf8c000c1 },
  593. { 0x5032c, 0x610003d7 },
  594. { 0x5fffc, 0xf84000d5 },
  595. { 0x50330, 0x5c8003d7 },
  596. { 0x5fffc, 0xf7c000e9 },
  597. { 0x50334, 0x580003d7 },
  598. { 0x5fffc, 0xf74000fd },
  599. { 0x50338, 0x534003d8 },
  600. { 0x5fffc, 0xf6c00112 },
  601. { 0x5033c, 0x4e8003d8 },
  602. { 0x5fffc, 0xf6800126 },
  603. { 0x50340, 0x494003da },
  604. { 0x5fffc, 0xf600013a },
  605. { 0x50344, 0x448003db },
  606. { 0x5fffc, 0xf600014d },
  607. { 0x50348, 0x3f4003dd },
  608. { 0x5fffc, 0xf5c00160 },
  609. { 0x5034c, 0x3a4003df },
  610. { 0x5fffc, 0xf5c00172 },
  611. { 0x50350, 0x354003e1 },
  612. { 0x5fffc, 0xf5c00184 },
  613. { 0x50354, 0x304003e3 },
  614. { 0x5fffc, 0xf6000195 },
  615. { 0x50358, 0x2b0003e6 },
  616. { 0x5fffc, 0xf64001a6 },
  617. { 0x5035c, 0x260003e8 },
  618. { 0x5fffc, 0xf6c001b4 },
  619. { 0x50360, 0x214003eb },
  620. { 0x5fffc, 0xf78001c2 },
  621. { 0x50364, 0x1c4003ee },
  622. { 0x5fffc, 0xf80001cf },
  623. { 0x50368, 0x17c003f1 },
  624. { 0x5fffc, 0xf90001db },
  625. { 0x5036c, 0x134003f3 },
  626. { 0x5fffc, 0xfa0001e5 },
  627. { 0x50370, 0xf0003f6 },
  628. { 0x5fffc, 0xfb4001ee },
  629. { 0x50374, 0xac003f9 },
  630. { 0x5fffc, 0xfcc001f5 },
  631. { 0x50378, 0x70003fb },
  632. { 0x5fffc, 0xfe4001fb },
  633. { 0x5037c, 0x34003fe },
  634. };
  635. struct mdp_table_entry *mdp_downscale_y_table[MDP_DOWNSCALE_MAX] = {
  636. [MDP_DOWNSCALE_PT2TOPT4] = mdp_downscale_y_table_PT2TOPT4,
  637. [MDP_DOWNSCALE_PT4TOPT6] = mdp_downscale_y_table_PT4TOPT6,
  638. [MDP_DOWNSCALE_PT6TOPT8] = mdp_downscale_y_table_PT6TOPT8,
  639. [MDP_DOWNSCALE_PT8TO1] = mdp_downscale_y_table_PT8TO1,
  640. };
  641. struct mdp_table_entry mdp_gaussian_blur_table[] = {
  642. /* max variance */
  643. { 0x5fffc, 0x20000080 },
  644. { 0x50280, 0x20000080 },
  645. { 0x5fffc, 0x20000080 },
  646. { 0x50284, 0x20000080 },
  647. { 0x5fffc, 0x20000080 },
  648. { 0x50288, 0x20000080 },
  649. { 0x5fffc, 0x20000080 },
  650. { 0x5028c, 0x20000080 },
  651. { 0x5fffc, 0x20000080 },
  652. { 0x50290, 0x20000080 },
  653. { 0x5fffc, 0x20000080 },
  654. { 0x50294, 0x20000080 },
  655. { 0x5fffc, 0x20000080 },
  656. { 0x50298, 0x20000080 },
  657. { 0x5fffc, 0x20000080 },
  658. { 0x5029c, 0x20000080 },
  659. { 0x5fffc, 0x20000080 },
  660. { 0x502a0, 0x20000080 },
  661. { 0x5fffc, 0x20000080 },
  662. { 0x502a4, 0x20000080 },
  663. { 0x5fffc, 0x20000080 },
  664. { 0x502a8, 0x20000080 },
  665. { 0x5fffc, 0x20000080 },
  666. { 0x502ac, 0x20000080 },
  667. { 0x5fffc, 0x20000080 },
  668. { 0x502b0, 0x20000080 },
  669. { 0x5fffc, 0x20000080 },
  670. { 0x502b4, 0x20000080 },
  671. { 0x5fffc, 0x20000080 },
  672. { 0x502b8, 0x20000080 },
  673. { 0x5fffc, 0x20000080 },
  674. { 0x502bc, 0x20000080 },
  675. { 0x5fffc, 0x20000080 },
  676. { 0x502c0, 0x20000080 },
  677. { 0x5fffc, 0x20000080 },
  678. { 0x502c4, 0x20000080 },
  679. { 0x5fffc, 0x20000080 },
  680. { 0x502c8, 0x20000080 },
  681. { 0x5fffc, 0x20000080 },
  682. { 0x502cc, 0x20000080 },
  683. { 0x5fffc, 0x20000080 },
  684. { 0x502d0, 0x20000080 },
  685. { 0x5fffc, 0x20000080 },
  686. { 0x502d4, 0x20000080 },
  687. { 0x5fffc, 0x20000080 },
  688. { 0x502d8, 0x20000080 },
  689. { 0x5fffc, 0x20000080 },
  690. { 0x502dc, 0x20000080 },
  691. { 0x5fffc, 0x20000080 },
  692. { 0x502e0, 0x20000080 },
  693. { 0x5fffc, 0x20000080 },
  694. { 0x502e4, 0x20000080 },
  695. { 0x5fffc, 0x20000080 },
  696. { 0x502e8, 0x20000080 },
  697. { 0x5fffc, 0x20000080 },
  698. { 0x502ec, 0x20000080 },
  699. { 0x5fffc, 0x20000080 },
  700. { 0x502f0, 0x20000080 },
  701. { 0x5fffc, 0x20000080 },
  702. { 0x502f4, 0x20000080 },
  703. { 0x5fffc, 0x20000080 },
  704. { 0x502f8, 0x20000080 },
  705. { 0x5fffc, 0x20000080 },
  706. { 0x502fc, 0x20000080 },
  707. { 0x5fffc, 0x20000080 },
  708. { 0x50300, 0x20000080 },
  709. { 0x5fffc, 0x20000080 },
  710. { 0x50304, 0x20000080 },
  711. { 0x5fffc, 0x20000080 },
  712. { 0x50308, 0x20000080 },
  713. { 0x5fffc, 0x20000080 },
  714. { 0x5030c, 0x20000080 },
  715. { 0x5fffc, 0x20000080 },
  716. { 0x50310, 0x20000080 },
  717. { 0x5fffc, 0x20000080 },
  718. { 0x50314, 0x20000080 },
  719. { 0x5fffc, 0x20000080 },
  720. { 0x50318, 0x20000080 },
  721. { 0x5fffc, 0x20000080 },
  722. { 0x5031c, 0x20000080 },
  723. { 0x5fffc, 0x20000080 },
  724. { 0x50320, 0x20000080 },
  725. { 0x5fffc, 0x20000080 },
  726. { 0x50324, 0x20000080 },
  727. { 0x5fffc, 0x20000080 },
  728. { 0x50328, 0x20000080 },
  729. { 0x5fffc, 0x20000080 },
  730. { 0x5032c, 0x20000080 },
  731. { 0x5fffc, 0x20000080 },
  732. { 0x50330, 0x20000080 },
  733. { 0x5fffc, 0x20000080 },
  734. { 0x50334, 0x20000080 },
  735. { 0x5fffc, 0x20000080 },
  736. { 0x50338, 0x20000080 },
  737. { 0x5fffc, 0x20000080 },
  738. { 0x5033c, 0x20000080 },
  739. { 0x5fffc, 0x20000080 },
  740. { 0x50340, 0x20000080 },
  741. { 0x5fffc, 0x20000080 },
  742. { 0x50344, 0x20000080 },
  743. { 0x5fffc, 0x20000080 },
  744. { 0x50348, 0x20000080 },
  745. { 0x5fffc, 0x20000080 },
  746. { 0x5034c, 0x20000080 },
  747. { 0x5fffc, 0x20000080 },
  748. { 0x50350, 0x20000080 },
  749. { 0x5fffc, 0x20000080 },
  750. { 0x50354, 0x20000080 },
  751. { 0x5fffc, 0x20000080 },
  752. { 0x50358, 0x20000080 },
  753. { 0x5fffc, 0x20000080 },
  754. { 0x5035c, 0x20000080 },
  755. { 0x5fffc, 0x20000080 },
  756. { 0x50360, 0x20000080 },
  757. { 0x5fffc, 0x20000080 },
  758. { 0x50364, 0x20000080 },
  759. { 0x5fffc, 0x20000080 },
  760. { 0x50368, 0x20000080 },
  761. { 0x5fffc, 0x20000080 },
  762. { 0x5036c, 0x20000080 },
  763. { 0x5fffc, 0x20000080 },
  764. { 0x50370, 0x20000080 },
  765. { 0x5fffc, 0x20000080 },
  766. { 0x50374, 0x20000080 },
  767. { 0x5fffc, 0x20000080 },
  768. { 0x50378, 0x20000080 },
  769. { 0x5fffc, 0x20000080 },
  770. { 0x5037c, 0x20000080 },
  771. };
  772. static void load_table(const struct mdp_info *mdp,
  773. struct mdp_table_entry *table, int len)
  774. {
  775. int i;
  776. for (i = 0; i < len; i++)
  777. mdp_writel(mdp, table[i].val, table[i].reg);
  778. }
  779. enum {
  780. IMG_LEFT,
  781. IMG_RIGHT,
  782. IMG_TOP,
  783. IMG_BOTTOM,
  784. };
  785. static void get_edge_info(uint32_t src, uint32_t src_coord, uint32_t dst,
  786. uint32_t *interp1, uint32_t *interp2,
  787. uint32_t *repeat1, uint32_t *repeat2) {
  788. if (src > 3 * dst) {
  789. *interp1 = 0;
  790. *interp2 = src - 1;
  791. *repeat1 = 0;
  792. *repeat2 = 0;
  793. } else if (src == 3 * dst) {
  794. *interp1 = 0;
  795. *interp2 = src;
  796. *repeat1 = 0;
  797. *repeat2 = 1;
  798. } else if (src > dst && src < 3 * dst) {
  799. *interp1 = -1;
  800. *interp2 = src;
  801. *repeat1 = 1;
  802. *repeat2 = 1;
  803. } else if (src == dst) {
  804. *interp1 = -1;
  805. *interp2 = src + 1;
  806. *repeat1 = 1;
  807. *repeat2 = 2;
  808. } else {
  809. *interp1 = -2;
  810. *interp2 = src + 1;
  811. *repeat1 = 2;
  812. *repeat2 = 2;
  813. }
  814. *interp1 += src_coord;
  815. *interp2 += src_coord;
  816. }
  817. int mdp_ppp_cfg_edge_cond(struct mdp_blit_req *req, struct ppp_regs *regs)
  818. {
  819. int32_t luma_interp[4];
  820. int32_t luma_repeat[4];
  821. int32_t chroma_interp[4];
  822. int32_t chroma_bound[4];
  823. int32_t chroma_repeat[4];
  824. uint32_t dst_w, dst_h;
  825. memset(&luma_interp, 0, sizeof(int32_t) * 4);
  826. memset(&luma_repeat, 0, sizeof(int32_t) * 4);
  827. memset(&chroma_interp, 0, sizeof(int32_t) * 4);
  828. memset(&chroma_bound, 0, sizeof(int32_t) * 4);
  829. memset(&chroma_repeat, 0, sizeof(int32_t) * 4);
  830. regs->edge = 0;
  831. if (req->flags & MDP_ROT_90) {
  832. dst_w = req->dst_rect.h;
  833. dst_h = req->dst_rect.w;
  834. } else {
  835. dst_w = req->dst_rect.w;
  836. dst_h = req->dst_rect.h;
  837. }
  838. if (regs->op & (PPP_OP_SCALE_Y_ON | PPP_OP_SCALE_X_ON)) {
  839. get_edge_info(req->src_rect.h, req->src_rect.y, dst_h,
  840. &luma_interp[IMG_TOP], &luma_interp[IMG_BOTTOM],
  841. &luma_repeat[IMG_TOP], &luma_repeat[IMG_BOTTOM]);
  842. get_edge_info(req->src_rect.w, req->src_rect.x, dst_w,
  843. &luma_interp[IMG_LEFT], &luma_interp[IMG_RIGHT],
  844. &luma_repeat[IMG_LEFT], &luma_repeat[IMG_RIGHT]);
  845. } else {
  846. luma_interp[IMG_LEFT] = req->src_rect.x;
  847. luma_interp[IMG_RIGHT] = req->src_rect.x + req->src_rect.w - 1;
  848. luma_interp[IMG_TOP] = req->src_rect.y;
  849. luma_interp[IMG_BOTTOM] = req->src_rect.y + req->src_rect.h - 1;
  850. luma_repeat[IMG_LEFT] = 0;
  851. luma_repeat[IMG_TOP] = 0;
  852. luma_repeat[IMG_RIGHT] = 0;
  853. luma_repeat[IMG_BOTTOM] = 0;
  854. }
  855. chroma_interp[IMG_LEFT] = luma_interp[IMG_LEFT];
  856. chroma_interp[IMG_RIGHT] = luma_interp[IMG_RIGHT];
  857. chroma_interp[IMG_TOP] = luma_interp[IMG_TOP];
  858. chroma_interp[IMG_BOTTOM] = luma_interp[IMG_BOTTOM];
  859. chroma_bound[IMG_LEFT] = req->src_rect.x;
  860. chroma_bound[IMG_RIGHT] = req->src_rect.x + req->src_rect.w - 1;
  861. chroma_bound[IMG_TOP] = req->src_rect.y;
  862. chroma_bound[IMG_BOTTOM] = req->src_rect.y + req->src_rect.h - 1;
  863. if (IS_YCRCB(req->src.format)) {
  864. chroma_interp[IMG_LEFT] = chroma_interp[IMG_LEFT] >> 1;
  865. chroma_interp[IMG_RIGHT] = (chroma_interp[IMG_RIGHT] + 1) >> 1;
  866. chroma_bound[IMG_LEFT] = chroma_bound[IMG_LEFT] >> 1;
  867. chroma_bound[IMG_RIGHT] = chroma_bound[IMG_RIGHT] >> 1;
  868. }
  869. if (req->src.format == MDP_Y_CBCR_H2V2 ||
  870. req->src.format == MDP_Y_CRCB_H2V2) {
  871. chroma_interp[IMG_TOP] = (chroma_interp[IMG_TOP] - 1) >> 1;
  872. chroma_interp[IMG_BOTTOM] = (chroma_interp[IMG_BOTTOM] + 1)
  873. >> 1;
  874. chroma_bound[IMG_TOP] = (chroma_bound[IMG_TOP] + 1) >> 1;
  875. chroma_bound[IMG_BOTTOM] = chroma_bound[IMG_BOTTOM] >> 1;
  876. }
  877. chroma_repeat[IMG_LEFT] = chroma_bound[IMG_LEFT] -
  878. chroma_interp[IMG_LEFT];
  879. chroma_repeat[IMG_RIGHT] = chroma_interp[IMG_RIGHT] -
  880. chroma_bound[IMG_RIGHT];
  881. chroma_repeat[IMG_TOP] = chroma_bound[IMG_TOP] -
  882. chroma_interp[IMG_TOP];
  883. chroma_repeat[IMG_BOTTOM] = chroma_interp[IMG_BOTTOM] -
  884. chroma_bound[IMG_BOTTOM];
  885. if (chroma_repeat[IMG_LEFT] < 0 || chroma_repeat[IMG_LEFT] > 3 ||
  886. chroma_repeat[IMG_RIGHT] < 0 || chroma_repeat[IMG_RIGHT] > 3 ||
  887. chroma_repeat[IMG_TOP] < 0 || chroma_repeat[IMG_TOP] > 3 ||
  888. chroma_repeat[IMG_BOTTOM] < 0 || chroma_repeat[IMG_BOTTOM] > 3 ||
  889. luma_repeat[IMG_LEFT] < 0 || luma_repeat[IMG_LEFT] > 3 ||
  890. luma_repeat[IMG_RIGHT] < 0 || luma_repeat[IMG_RIGHT] > 3 ||
  891. luma_repeat[IMG_TOP] < 0 || luma_repeat[IMG_TOP] > 3 ||
  892. luma_repeat[IMG_BOTTOM] < 0 || luma_repeat[IMG_BOTTOM] > 3)
  893. return -1;
  894. regs->edge |= (chroma_repeat[IMG_LEFT] & 3) << MDP_LEFT_CHROMA;
  895. regs->edge |= (chroma_repeat[IMG_RIGHT] & 3) << MDP_RIGHT_CHROMA;
  896. regs->edge |= (chroma_repeat[IMG_TOP] & 3) << MDP_TOP_CHROMA;
  897. regs->edge |= (chroma_repeat[IMG_BOTTOM] & 3) << MDP_BOTTOM_CHROMA;
  898. regs->edge |= (luma_repeat[IMG_LEFT] & 3) << MDP_LEFT_LUMA;
  899. regs->edge |= (luma_repeat[IMG_RIGHT] & 3) << MDP_RIGHT_LUMA;
  900. regs->edge |= (luma_repeat[IMG_TOP] & 3) << MDP_TOP_LUMA;
  901. regs->edge |= (luma_repeat[IMG_BOTTOM] & 3) << MDP_BOTTOM_LUMA;
  902. return 0;
  903. }
  904. #define ONE_HALF (1LL << 32)
  905. #define ONE (1LL << 33)
  906. #define TWO (2LL << 33)
  907. #define THREE (3LL << 33)
  908. #define FRAC_MASK (ONE - 1)
  909. #define INT_MASK (~FRAC_MASK)
  910. static int scale_params(uint32_t dim_in, uint32_t dim_out, uint32_t origin,
  911. uint32_t *phase_init, uint32_t *phase_step)
  912. {
  913. /* to improve precicsion calculations are done in U31.33 and converted
  914. * to U3.29 at the end */
  915. int64_t k1, k2, k3, k4, tmp;
  916. uint64_t n, d, os, os_p, od, od_p, oreq;
  917. unsigned rpa = 0;
  918. int64_t ip64, delta;
  919. if (dim_out % 3 == 0)
  920. rpa = !(dim_in % (dim_out / 3));
  921. n = ((uint64_t)dim_out) << 34;
  922. d = dim_in;
  923. if (!d)
  924. return -1;
  925. do_div(n, d);
  926. k3 = (n + 1) >> 1;
  927. if ((k3 >> 4) < (1LL << 27) || (k3 >> 4) > (1LL << 31))
  928. return -1;
  929. n = ((uint64_t)dim_in) << 34;
  930. d = (uint64_t)dim_out;
  931. if (!d)
  932. return -1;
  933. do_div(n, d);
  934. k1 = (n + 1) >> 1;
  935. k2 = (k1 - ONE) >> 1;
  936. *phase_init = (int)(k2 >> 4);
  937. k4 = (k3 - ONE) >> 1;
  938. if (rpa) {
  939. os = ((uint64_t)origin << 33) - ONE_HALF;
  940. tmp = (dim_out * os) + ONE_HALF;
  941. if (!dim_in)
  942. return -1;
  943. do_div(tmp, dim_in);
  944. od = tmp - ONE_HALF;
  945. } else {
  946. os = ((uint64_t)origin << 1) - 1;
  947. od = (((k3 * os) >> 1) + k4);
  948. }
  949. od_p = od & INT_MASK;
  950. if (od_p != od)
  951. od_p += ONE;
  952. if (rpa) {
  953. tmp = (dim_in * od_p) + ONE_HALF;
  954. if (!dim_in)
  955. return -1;
  956. do_div(tmp, dim_in);
  957. os_p = tmp - ONE_HALF;
  958. } else {
  959. os_p = ((k1 * (od_p >> 33)) + k2);
  960. }
  961. oreq = (os_p & INT_MASK) - ONE;
  962. ip64 = os_p - oreq;
  963. delta = ((int64_t)(origin) << 33) - oreq;
  964. ip64 -= delta;
  965. /* limit to valid range before the left shift */
  966. delta = (ip64 & (1LL << 63)) ? 4 : -4;
  967. delta <<= 33;
  968. while (abs((int)(ip64 >> 33)) > 4)
  969. ip64 += delta;
  970. *phase_init = (int)(ip64 >> 4);
  971. *phase_step = (uint32_t)(k1 >> 4);
  972. return 0;
  973. }
  974. int mdp_ppp_cfg_scale(const struct mdp_info *mdp, struct ppp_regs *regs,
  975. struct mdp_rect *src_rect, struct mdp_rect *dst_rect,
  976. uint32_t src_format, uint32_t dst_format)
  977. {
  978. int downscale;
  979. uint32_t phase_init_x, phase_init_y, phase_step_x, phase_step_y;
  980. uint32_t scale_factor_x, scale_factor_y;
  981. if (scale_params(src_rect->w, dst_rect->w, 1, &phase_init_x,
  982. &phase_step_x) ||
  983. scale_params(src_rect->h, dst_rect->h, 1, &phase_init_y,
  984. &phase_step_y))
  985. return -1;
  986. regs->phasex_init = phase_init_x;
  987. regs->phasey_init = phase_init_y;
  988. regs->phasex_step = phase_step_x;
  989. regs->phasey_step = phase_step_y;
  990. scale_factor_x = (dst_rect->w * 10) / src_rect->w;
  991. scale_factor_y = (dst_rect->h * 10) / src_rect->h;
  992. if (scale_factor_x > 8)
  993. downscale = MDP_DOWNSCALE_PT8TO1;
  994. else if (scale_factor_x > 6)
  995. downscale = MDP_DOWNSCALE_PT6TOPT8;
  996. else if (scale_factor_x > 4)
  997. downscale = MDP_DOWNSCALE_PT4TOPT6;
  998. else
  999. downscale = MDP_DOWNSCALE_PT2TOPT4;
  1000. if (downscale != downscale_x_table) {
  1001. load_table(mdp, mdp_downscale_x_table[downscale], 64);
  1002. downscale_x_table = downscale;
  1003. }
  1004. if (scale_factor_y > 8)
  1005. downscale = MDP_DOWNSCALE_PT8TO1;
  1006. else if (scale_factor_y > 6)
  1007. downscale = MDP_DOWNSCALE_PT6TOPT8;
  1008. else if (scale_factor_y > 4)
  1009. downscale = MDP_DOWNSCALE_PT4TOPT6;
  1010. else
  1011. downscale = MDP_DOWNSCALE_PT2TOPT4;
  1012. if (downscale != downscale_y_table) {
  1013. load_table(mdp, mdp_downscale_y_table[downscale], 64);
  1014. downscale_y_table = downscale;
  1015. }
  1016. return 0;
  1017. }
  1018. int mdp_ppp_load_blur(const struct mdp_info *mdp)
  1019. {
  1020. if (!(downscale_x_table == MDP_DOWNSCALE_BLUR &&
  1021. downscale_y_table == MDP_DOWNSCALE_BLUR)) {
  1022. load_table(mdp, mdp_gaussian_blur_table, 128);
  1023. downscale_x_table = MDP_DOWNSCALE_BLUR;
  1024. downscale_y_table = MDP_DOWNSCALE_BLUR;
  1025. }
  1026. return 0;
  1027. }
  1028. void mdp_ppp_init_scale(const struct mdp_info *mdp)
  1029. {
  1030. downscale_x_table = MDP_DOWNSCALE_MAX;
  1031. downscale_y_table = MDP_DOWNSCALE_MAX;
  1032. load_table(mdp, mdp_upscale_table, ARRAY_SIZE(mdp_upscale_table));
  1033. }