dispc.c 80 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465
  1. /*
  2. * linux/drivers/video/omap2/dss/dispc.c
  3. *
  4. * Copyright (C) 2009 Nokia Corporation
  5. * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com>
  6. *
  7. * Some code and ideas taken from drivers/video/omap/ driver
  8. * by Imre Deak.
  9. *
  10. * This program is free software; you can redistribute it and/or modify it
  11. * under the terms of the GNU General Public License version 2 as published by
  12. * the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful, but WITHOUT
  15. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  16. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  17. * more details.
  18. *
  19. * You should have received a copy of the GNU General Public License along with
  20. * this program. If not, see <http://www.gnu.org/licenses/>.
  21. */
  22. #define DSS_SUBSYS_NAME "DISPC"
  23. #include <linux/kernel.h>
  24. #include <linux/dma-mapping.h>
  25. #include <linux/vmalloc.h>
  26. #include <linux/export.h>
  27. #include <linux/clk.h>
  28. #include <linux/io.h>
  29. #include <linux/jiffies.h>
  30. #include <linux/seq_file.h>
  31. #include <linux/delay.h>
  32. #include <linux/workqueue.h>
  33. #include <linux/hardirq.h>
  34. #include <linux/interrupt.h>
  35. #include <linux/platform_device.h>
  36. #include <linux/pm_runtime.h>
  37. #include <plat/sram.h>
  38. #include <plat/clock.h>
  39. #include <video/omapdss.h>
  40. #include "dss.h"
  41. #include "dss_features.h"
  42. #include "dispc.h"
  43. /* DISPC */
  44. #define DISPC_SZ_REGS SZ_4K
  45. #define DISPC_IRQ_MASK_ERROR (DISPC_IRQ_GFX_FIFO_UNDERFLOW | \
  46. DISPC_IRQ_OCP_ERR | \
  47. DISPC_IRQ_VID1_FIFO_UNDERFLOW | \
  48. DISPC_IRQ_VID2_FIFO_UNDERFLOW | \
  49. DISPC_IRQ_SYNC_LOST | \
  50. DISPC_IRQ_SYNC_LOST_DIGIT)
  51. #define DISPC_MAX_NR_ISRS 8
  52. struct omap_dispc_isr_data {
  53. omap_dispc_isr_t isr;
  54. void *arg;
  55. u32 mask;
  56. };
  57. enum omap_burst_size {
  58. BURST_SIZE_X2 = 0,
  59. BURST_SIZE_X4 = 1,
  60. BURST_SIZE_X8 = 2,
  61. };
  62. #define REG_GET(idx, start, end) \
  63. FLD_GET(dispc_read_reg(idx), start, end)
  64. #define REG_FLD_MOD(idx, val, start, end) \
  65. dispc_write_reg(idx, FLD_MOD(dispc_read_reg(idx), val, start, end))
  66. struct dispc_irq_stats {
  67. unsigned long last_reset;
  68. unsigned irq_count;
  69. unsigned irqs[32];
  70. };
  71. static struct {
  72. struct platform_device *pdev;
  73. void __iomem *base;
  74. int ctx_loss_cnt;
  75. int irq;
  76. struct clk *dss_clk;
  77. u32 fifo_size[MAX_DSS_OVERLAYS];
  78. spinlock_t irq_lock;
  79. u32 irq_error_mask;
  80. struct omap_dispc_isr_data registered_isr[DISPC_MAX_NR_ISRS];
  81. u32 error_irqs;
  82. struct work_struct error_work;
  83. bool ctx_valid;
  84. u32 ctx[DISPC_SZ_REGS / sizeof(u32)];
  85. #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
  86. spinlock_t irq_stats_lock;
  87. struct dispc_irq_stats irq_stats;
  88. #endif
  89. } dispc;
  90. enum omap_color_component {
  91. /* used for all color formats for OMAP3 and earlier
  92. * and for RGB and Y color component on OMAP4
  93. */
  94. DISPC_COLOR_COMPONENT_RGB_Y = 1 << 0,
  95. /* used for UV component for
  96. * OMAP_DSS_COLOR_YUV2, OMAP_DSS_COLOR_UYVY, OMAP_DSS_COLOR_NV12
  97. * color formats on OMAP4
  98. */
  99. DISPC_COLOR_COMPONENT_UV = 1 << 1,
  100. };
  101. static void _omap_dispc_set_irqs(void);
  102. static inline void dispc_write_reg(const u16 idx, u32 val)
  103. {
  104. __raw_writel(val, dispc.base + idx);
  105. }
  106. static inline u32 dispc_read_reg(const u16 idx)
  107. {
  108. return __raw_readl(dispc.base + idx);
  109. }
  110. static int dispc_get_ctx_loss_count(void)
  111. {
  112. struct device *dev = &dispc.pdev->dev;
  113. struct omap_display_platform_data *pdata = dev->platform_data;
  114. struct omap_dss_board_info *board_data = pdata->board_data;
  115. int cnt;
  116. if (!board_data->get_context_loss_count)
  117. return -ENOENT;
  118. cnt = board_data->get_context_loss_count(dev);
  119. WARN_ONCE(cnt < 0, "get_context_loss_count failed: %d\n", cnt);
  120. return cnt;
  121. }
  122. #define SR(reg) \
  123. dispc.ctx[DISPC_##reg / sizeof(u32)] = dispc_read_reg(DISPC_##reg)
  124. #define RR(reg) \
  125. dispc_write_reg(DISPC_##reg, dispc.ctx[DISPC_##reg / sizeof(u32)])
  126. static void dispc_save_context(void)
  127. {
  128. int i, j;
  129. DSSDBG("dispc_save_context\n");
  130. SR(IRQENABLE);
  131. SR(CONTROL);
  132. SR(CONFIG);
  133. SR(LINE_NUMBER);
  134. if (dss_has_feature(FEAT_ALPHA_FIXED_ZORDER) ||
  135. dss_has_feature(FEAT_ALPHA_FREE_ZORDER))
  136. SR(GLOBAL_ALPHA);
  137. if (dss_has_feature(FEAT_MGR_LCD2)) {
  138. SR(CONTROL2);
  139. SR(CONFIG2);
  140. }
  141. for (i = 0; i < dss_feat_get_num_mgrs(); i++) {
  142. SR(DEFAULT_COLOR(i));
  143. SR(TRANS_COLOR(i));
  144. SR(SIZE_MGR(i));
  145. if (i == OMAP_DSS_CHANNEL_DIGIT)
  146. continue;
  147. SR(TIMING_H(i));
  148. SR(TIMING_V(i));
  149. SR(POL_FREQ(i));
  150. SR(DIVISORo(i));
  151. SR(DATA_CYCLE1(i));
  152. SR(DATA_CYCLE2(i));
  153. SR(DATA_CYCLE3(i));
  154. if (dss_has_feature(FEAT_CPR)) {
  155. SR(CPR_COEF_R(i));
  156. SR(CPR_COEF_G(i));
  157. SR(CPR_COEF_B(i));
  158. }
  159. }
  160. for (i = 0; i < dss_feat_get_num_ovls(); i++) {
  161. SR(OVL_BA0(i));
  162. SR(OVL_BA1(i));
  163. SR(OVL_POSITION(i));
  164. SR(OVL_SIZE(i));
  165. SR(OVL_ATTRIBUTES(i));
  166. SR(OVL_FIFO_THRESHOLD(i));
  167. SR(OVL_ROW_INC(i));
  168. SR(OVL_PIXEL_INC(i));
  169. if (dss_has_feature(FEAT_PRELOAD))
  170. SR(OVL_PRELOAD(i));
  171. if (i == OMAP_DSS_GFX) {
  172. SR(OVL_WINDOW_SKIP(i));
  173. SR(OVL_TABLE_BA(i));
  174. continue;
  175. }
  176. SR(OVL_FIR(i));
  177. SR(OVL_PICTURE_SIZE(i));
  178. SR(OVL_ACCU0(i));
  179. SR(OVL_ACCU1(i));
  180. for (j = 0; j < 8; j++)
  181. SR(OVL_FIR_COEF_H(i, j));
  182. for (j = 0; j < 8; j++)
  183. SR(OVL_FIR_COEF_HV(i, j));
  184. for (j = 0; j < 5; j++)
  185. SR(OVL_CONV_COEF(i, j));
  186. if (dss_has_feature(FEAT_FIR_COEF_V)) {
  187. for (j = 0; j < 8; j++)
  188. SR(OVL_FIR_COEF_V(i, j));
  189. }
  190. if (dss_has_feature(FEAT_HANDLE_UV_SEPARATE)) {
  191. SR(OVL_BA0_UV(i));
  192. SR(OVL_BA1_UV(i));
  193. SR(OVL_FIR2(i));
  194. SR(OVL_ACCU2_0(i));
  195. SR(OVL_ACCU2_1(i));
  196. for (j = 0; j < 8; j++)
  197. SR(OVL_FIR_COEF_H2(i, j));
  198. for (j = 0; j < 8; j++)
  199. SR(OVL_FIR_COEF_HV2(i, j));
  200. for (j = 0; j < 8; j++)
  201. SR(OVL_FIR_COEF_V2(i, j));
  202. }
  203. if (dss_has_feature(FEAT_ATTR2))
  204. SR(OVL_ATTRIBUTES2(i));
  205. }
  206. if (dss_has_feature(FEAT_CORE_CLK_DIV))
  207. SR(DIVISOR);
  208. dispc.ctx_loss_cnt = dispc_get_ctx_loss_count();
  209. dispc.ctx_valid = true;
  210. DSSDBG("context saved, ctx_loss_count %d\n", dispc.ctx_loss_cnt);
  211. }
  212. static void dispc_restore_context(void)
  213. {
  214. int i, j, ctx;
  215. DSSDBG("dispc_restore_context\n");
  216. if (!dispc.ctx_valid)
  217. return;
  218. ctx = dispc_get_ctx_loss_count();
  219. if (ctx >= 0 && ctx == dispc.ctx_loss_cnt)
  220. return;
  221. DSSDBG("ctx_loss_count: saved %d, current %d\n",
  222. dispc.ctx_loss_cnt, ctx);
  223. /*RR(IRQENABLE);*/
  224. /*RR(CONTROL);*/
  225. RR(CONFIG);
  226. RR(LINE_NUMBER);
  227. if (dss_has_feature(FEAT_ALPHA_FIXED_ZORDER) ||
  228. dss_has_feature(FEAT_ALPHA_FREE_ZORDER))
  229. RR(GLOBAL_ALPHA);
  230. if (dss_has_feature(FEAT_MGR_LCD2))
  231. RR(CONFIG2);
  232. for (i = 0; i < dss_feat_get_num_mgrs(); i++) {
  233. RR(DEFAULT_COLOR(i));
  234. RR(TRANS_COLOR(i));
  235. RR(SIZE_MGR(i));
  236. if (i == OMAP_DSS_CHANNEL_DIGIT)
  237. continue;
  238. RR(TIMING_H(i));
  239. RR(TIMING_V(i));
  240. RR(POL_FREQ(i));
  241. RR(DIVISORo(i));
  242. RR(DATA_CYCLE1(i));
  243. RR(DATA_CYCLE2(i));
  244. RR(DATA_CYCLE3(i));
  245. if (dss_has_feature(FEAT_CPR)) {
  246. RR(CPR_COEF_R(i));
  247. RR(CPR_COEF_G(i));
  248. RR(CPR_COEF_B(i));
  249. }
  250. }
  251. for (i = 0; i < dss_feat_get_num_ovls(); i++) {
  252. RR(OVL_BA0(i));
  253. RR(OVL_BA1(i));
  254. RR(OVL_POSITION(i));
  255. RR(OVL_SIZE(i));
  256. RR(OVL_ATTRIBUTES(i));
  257. RR(OVL_FIFO_THRESHOLD(i));
  258. RR(OVL_ROW_INC(i));
  259. RR(OVL_PIXEL_INC(i));
  260. if (dss_has_feature(FEAT_PRELOAD))
  261. RR(OVL_PRELOAD(i));
  262. if (i == OMAP_DSS_GFX) {
  263. RR(OVL_WINDOW_SKIP(i));
  264. RR(OVL_TABLE_BA(i));
  265. continue;
  266. }
  267. RR(OVL_FIR(i));
  268. RR(OVL_PICTURE_SIZE(i));
  269. RR(OVL_ACCU0(i));
  270. RR(OVL_ACCU1(i));
  271. for (j = 0; j < 8; j++)
  272. RR(OVL_FIR_COEF_H(i, j));
  273. for (j = 0; j < 8; j++)
  274. RR(OVL_FIR_COEF_HV(i, j));
  275. for (j = 0; j < 5; j++)
  276. RR(OVL_CONV_COEF(i, j));
  277. if (dss_has_feature(FEAT_FIR_COEF_V)) {
  278. for (j = 0; j < 8; j++)
  279. RR(OVL_FIR_COEF_V(i, j));
  280. }
  281. if (dss_has_feature(FEAT_HANDLE_UV_SEPARATE)) {
  282. RR(OVL_BA0_UV(i));
  283. RR(OVL_BA1_UV(i));
  284. RR(OVL_FIR2(i));
  285. RR(OVL_ACCU2_0(i));
  286. RR(OVL_ACCU2_1(i));
  287. for (j = 0; j < 8; j++)
  288. RR(OVL_FIR_COEF_H2(i, j));
  289. for (j = 0; j < 8; j++)
  290. RR(OVL_FIR_COEF_HV2(i, j));
  291. for (j = 0; j < 8; j++)
  292. RR(OVL_FIR_COEF_V2(i, j));
  293. }
  294. if (dss_has_feature(FEAT_ATTR2))
  295. RR(OVL_ATTRIBUTES2(i));
  296. }
  297. if (dss_has_feature(FEAT_CORE_CLK_DIV))
  298. RR(DIVISOR);
  299. /* enable last, because LCD & DIGIT enable are here */
  300. RR(CONTROL);
  301. if (dss_has_feature(FEAT_MGR_LCD2))
  302. RR(CONTROL2);
  303. /* clear spurious SYNC_LOST_DIGIT interrupts */
  304. dispc_write_reg(DISPC_IRQSTATUS, DISPC_IRQ_SYNC_LOST_DIGIT);
  305. /*
  306. * enable last so IRQs won't trigger before
  307. * the context is fully restored
  308. */
  309. RR(IRQENABLE);
  310. DSSDBG("context restored\n");
  311. }
  312. #undef SR
  313. #undef RR
  314. int dispc_runtime_get(void)
  315. {
  316. int r;
  317. DSSDBG("dispc_runtime_get\n");
  318. r = pm_runtime_get_sync(&dispc.pdev->dev);
  319. WARN_ON(r < 0);
  320. return r < 0 ? r : 0;
  321. }
  322. void dispc_runtime_put(void)
  323. {
  324. int r;
  325. DSSDBG("dispc_runtime_put\n");
  326. r = pm_runtime_put_sync(&dispc.pdev->dev);
  327. WARN_ON(r < 0);
  328. }
  329. static inline bool dispc_mgr_is_lcd(enum omap_channel channel)
  330. {
  331. if (channel == OMAP_DSS_CHANNEL_LCD ||
  332. channel == OMAP_DSS_CHANNEL_LCD2)
  333. return true;
  334. else
  335. return false;
  336. }
  337. static struct omap_dss_device *dispc_mgr_get_device(enum omap_channel channel)
  338. {
  339. struct omap_overlay_manager *mgr =
  340. omap_dss_get_overlay_manager(channel);
  341. return mgr ? mgr->device : NULL;
  342. }
  343. u32 dispc_mgr_get_vsync_irq(enum omap_channel channel)
  344. {
  345. switch (channel) {
  346. case OMAP_DSS_CHANNEL_LCD:
  347. return DISPC_IRQ_VSYNC;
  348. case OMAP_DSS_CHANNEL_LCD2:
  349. return DISPC_IRQ_VSYNC2;
  350. case OMAP_DSS_CHANNEL_DIGIT:
  351. return DISPC_IRQ_EVSYNC_ODD | DISPC_IRQ_EVSYNC_EVEN;
  352. default:
  353. BUG();
  354. }
  355. }
  356. u32 dispc_mgr_get_framedone_irq(enum omap_channel channel)
  357. {
  358. switch (channel) {
  359. case OMAP_DSS_CHANNEL_LCD:
  360. return DISPC_IRQ_FRAMEDONE;
  361. case OMAP_DSS_CHANNEL_LCD2:
  362. return DISPC_IRQ_FRAMEDONE2;
  363. case OMAP_DSS_CHANNEL_DIGIT:
  364. return 0;
  365. default:
  366. BUG();
  367. }
  368. }
  369. bool dispc_mgr_go_busy(enum omap_channel channel)
  370. {
  371. int bit;
  372. if (dispc_mgr_is_lcd(channel))
  373. bit = 5; /* GOLCD */
  374. else
  375. bit = 6; /* GODIGIT */
  376. if (channel == OMAP_DSS_CHANNEL_LCD2)
  377. return REG_GET(DISPC_CONTROL2, bit, bit) == 1;
  378. else
  379. return REG_GET(DISPC_CONTROL, bit, bit) == 1;
  380. }
  381. void dispc_mgr_go(enum omap_channel channel)
  382. {
  383. int bit;
  384. bool enable_bit, go_bit;
  385. if (dispc_mgr_is_lcd(channel))
  386. bit = 0; /* LCDENABLE */
  387. else
  388. bit = 1; /* DIGITALENABLE */
  389. /* if the channel is not enabled, we don't need GO */
  390. if (channel == OMAP_DSS_CHANNEL_LCD2)
  391. enable_bit = REG_GET(DISPC_CONTROL2, bit, bit) == 1;
  392. else
  393. enable_bit = REG_GET(DISPC_CONTROL, bit, bit) == 1;
  394. if (!enable_bit)
  395. return;
  396. if (dispc_mgr_is_lcd(channel))
  397. bit = 5; /* GOLCD */
  398. else
  399. bit = 6; /* GODIGIT */
  400. if (channel == OMAP_DSS_CHANNEL_LCD2)
  401. go_bit = REG_GET(DISPC_CONTROL2, bit, bit) == 1;
  402. else
  403. go_bit = REG_GET(DISPC_CONTROL, bit, bit) == 1;
  404. if (go_bit) {
  405. DSSERR("GO bit not down for channel %d\n", channel);
  406. return;
  407. }
  408. DSSDBG("GO %s\n", channel == OMAP_DSS_CHANNEL_LCD ? "LCD" :
  409. (channel == OMAP_DSS_CHANNEL_LCD2 ? "LCD2" : "DIGIT"));
  410. if (channel == OMAP_DSS_CHANNEL_LCD2)
  411. REG_FLD_MOD(DISPC_CONTROL2, 1, bit, bit);
  412. else
  413. REG_FLD_MOD(DISPC_CONTROL, 1, bit, bit);
  414. }
  415. static void dispc_ovl_write_firh_reg(enum omap_plane plane, int reg, u32 value)
  416. {
  417. dispc_write_reg(DISPC_OVL_FIR_COEF_H(plane, reg), value);
  418. }
  419. static void dispc_ovl_write_firhv_reg(enum omap_plane plane, int reg, u32 value)
  420. {
  421. dispc_write_reg(DISPC_OVL_FIR_COEF_HV(plane, reg), value);
  422. }
  423. static void dispc_ovl_write_firv_reg(enum omap_plane plane, int reg, u32 value)
  424. {
  425. dispc_write_reg(DISPC_OVL_FIR_COEF_V(plane, reg), value);
  426. }
  427. static void dispc_ovl_write_firh2_reg(enum omap_plane plane, int reg, u32 value)
  428. {
  429. BUG_ON(plane == OMAP_DSS_GFX);
  430. dispc_write_reg(DISPC_OVL_FIR_COEF_H2(plane, reg), value);
  431. }
  432. static void dispc_ovl_write_firhv2_reg(enum omap_plane plane, int reg,
  433. u32 value)
  434. {
  435. BUG_ON(plane == OMAP_DSS_GFX);
  436. dispc_write_reg(DISPC_OVL_FIR_COEF_HV2(plane, reg), value);
  437. }
  438. static void dispc_ovl_write_firv2_reg(enum omap_plane plane, int reg, u32 value)
  439. {
  440. BUG_ON(plane == OMAP_DSS_GFX);
  441. dispc_write_reg(DISPC_OVL_FIR_COEF_V2(plane, reg), value);
  442. }
  443. static void dispc_ovl_set_scale_coef(enum omap_plane plane, int fir_hinc,
  444. int fir_vinc, int five_taps,
  445. enum omap_color_component color_comp)
  446. {
  447. const struct dispc_coef *h_coef, *v_coef;
  448. int i;
  449. h_coef = dispc_ovl_get_scale_coef(fir_hinc, true);
  450. v_coef = dispc_ovl_get_scale_coef(fir_vinc, five_taps);
  451. for (i = 0; i < 8; i++) {
  452. u32 h, hv;
  453. h = FLD_VAL(h_coef[i].hc0_vc00, 7, 0)
  454. | FLD_VAL(h_coef[i].hc1_vc0, 15, 8)
  455. | FLD_VAL(h_coef[i].hc2_vc1, 23, 16)
  456. | FLD_VAL(h_coef[i].hc3_vc2, 31, 24);
  457. hv = FLD_VAL(h_coef[i].hc4_vc22, 7, 0)
  458. | FLD_VAL(v_coef[i].hc1_vc0, 15, 8)
  459. | FLD_VAL(v_coef[i].hc2_vc1, 23, 16)
  460. | FLD_VAL(v_coef[i].hc3_vc2, 31, 24);
  461. if (color_comp == DISPC_COLOR_COMPONENT_RGB_Y) {
  462. dispc_ovl_write_firh_reg(plane, i, h);
  463. dispc_ovl_write_firhv_reg(plane, i, hv);
  464. } else {
  465. dispc_ovl_write_firh2_reg(plane, i, h);
  466. dispc_ovl_write_firhv2_reg(plane, i, hv);
  467. }
  468. }
  469. if (five_taps) {
  470. for (i = 0; i < 8; i++) {
  471. u32 v;
  472. v = FLD_VAL(v_coef[i].hc0_vc00, 7, 0)
  473. | FLD_VAL(v_coef[i].hc4_vc22, 15, 8);
  474. if (color_comp == DISPC_COLOR_COMPONENT_RGB_Y)
  475. dispc_ovl_write_firv_reg(plane, i, v);
  476. else
  477. dispc_ovl_write_firv2_reg(plane, i, v);
  478. }
  479. }
  480. }
  481. static void _dispc_setup_color_conv_coef(void)
  482. {
  483. int i;
  484. const struct color_conv_coef {
  485. int ry, rcr, rcb, gy, gcr, gcb, by, bcr, bcb;
  486. int full_range;
  487. } ctbl_bt601_5 = {
  488. 298, 409, 0, 298, -208, -100, 298, 0, 517, 0,
  489. };
  490. const struct color_conv_coef *ct;
  491. #define CVAL(x, y) (FLD_VAL(x, 26, 16) | FLD_VAL(y, 10, 0))
  492. ct = &ctbl_bt601_5;
  493. for (i = 1; i < dss_feat_get_num_ovls(); i++) {
  494. dispc_write_reg(DISPC_OVL_CONV_COEF(i, 0),
  495. CVAL(ct->rcr, ct->ry));
  496. dispc_write_reg(DISPC_OVL_CONV_COEF(i, 1),
  497. CVAL(ct->gy, ct->rcb));
  498. dispc_write_reg(DISPC_OVL_CONV_COEF(i, 2),
  499. CVAL(ct->gcb, ct->gcr));
  500. dispc_write_reg(DISPC_OVL_CONV_COEF(i, 3),
  501. CVAL(ct->bcr, ct->by));
  502. dispc_write_reg(DISPC_OVL_CONV_COEF(i, 4),
  503. CVAL(0, ct->bcb));
  504. REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(i), ct->full_range,
  505. 11, 11);
  506. }
  507. #undef CVAL
  508. }
  509. static void dispc_ovl_set_ba0(enum omap_plane plane, u32 paddr)
  510. {
  511. dispc_write_reg(DISPC_OVL_BA0(plane), paddr);
  512. }
  513. static void dispc_ovl_set_ba1(enum omap_plane plane, u32 paddr)
  514. {
  515. dispc_write_reg(DISPC_OVL_BA1(plane), paddr);
  516. }
  517. static void dispc_ovl_set_ba0_uv(enum omap_plane plane, u32 paddr)
  518. {
  519. dispc_write_reg(DISPC_OVL_BA0_UV(plane), paddr);
  520. }
  521. static void dispc_ovl_set_ba1_uv(enum omap_plane plane, u32 paddr)
  522. {
  523. dispc_write_reg(DISPC_OVL_BA1_UV(plane), paddr);
  524. }
  525. static void dispc_ovl_set_pos(enum omap_plane plane, int x, int y)
  526. {
  527. u32 val = FLD_VAL(y, 26, 16) | FLD_VAL(x, 10, 0);
  528. dispc_write_reg(DISPC_OVL_POSITION(plane), val);
  529. }
  530. static void dispc_ovl_set_pic_size(enum omap_plane plane, int width, int height)
  531. {
  532. u32 val = FLD_VAL(height - 1, 26, 16) | FLD_VAL(width - 1, 10, 0);
  533. if (plane == OMAP_DSS_GFX)
  534. dispc_write_reg(DISPC_OVL_SIZE(plane), val);
  535. else
  536. dispc_write_reg(DISPC_OVL_PICTURE_SIZE(plane), val);
  537. }
  538. static void dispc_ovl_set_vid_size(enum omap_plane plane, int width, int height)
  539. {
  540. u32 val;
  541. BUG_ON(plane == OMAP_DSS_GFX);
  542. val = FLD_VAL(height - 1, 26, 16) | FLD_VAL(width - 1, 10, 0);
  543. dispc_write_reg(DISPC_OVL_SIZE(plane), val);
  544. }
  545. static void dispc_ovl_set_zorder(enum omap_plane plane, u8 zorder)
  546. {
  547. struct omap_overlay *ovl = omap_dss_get_overlay(plane);
  548. if ((ovl->caps & OMAP_DSS_OVL_CAP_ZORDER) == 0)
  549. return;
  550. REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), zorder, 27, 26);
  551. }
  552. static void dispc_ovl_enable_zorder_planes(void)
  553. {
  554. int i;
  555. if (!dss_has_feature(FEAT_ALPHA_FREE_ZORDER))
  556. return;
  557. for (i = 0; i < dss_feat_get_num_ovls(); i++)
  558. REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(i), 1, 25, 25);
  559. }
  560. static void dispc_ovl_set_pre_mult_alpha(enum omap_plane plane, bool enable)
  561. {
  562. struct omap_overlay *ovl = omap_dss_get_overlay(plane);
  563. if ((ovl->caps & OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA) == 0)
  564. return;
  565. REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), enable ? 1 : 0, 28, 28);
  566. }
  567. static void dispc_ovl_setup_global_alpha(enum omap_plane plane, u8 global_alpha)
  568. {
  569. static const unsigned shifts[] = { 0, 8, 16, 24, };
  570. int shift;
  571. struct omap_overlay *ovl = omap_dss_get_overlay(plane);
  572. if ((ovl->caps & OMAP_DSS_OVL_CAP_GLOBAL_ALPHA) == 0)
  573. return;
  574. shift = shifts[plane];
  575. REG_FLD_MOD(DISPC_GLOBAL_ALPHA, global_alpha, shift + 7, shift);
  576. }
  577. static void dispc_ovl_set_pix_inc(enum omap_plane plane, s32 inc)
  578. {
  579. dispc_write_reg(DISPC_OVL_PIXEL_INC(plane), inc);
  580. }
  581. static void dispc_ovl_set_row_inc(enum omap_plane plane, s32 inc)
  582. {
  583. dispc_write_reg(DISPC_OVL_ROW_INC(plane), inc);
  584. }
  585. static void dispc_ovl_set_color_mode(enum omap_plane plane,
  586. enum omap_color_mode color_mode)
  587. {
  588. u32 m = 0;
  589. if (plane != OMAP_DSS_GFX) {
  590. switch (color_mode) {
  591. case OMAP_DSS_COLOR_NV12:
  592. m = 0x0; break;
  593. case OMAP_DSS_COLOR_RGB12U:
  594. m = 0x1; break;
  595. case OMAP_DSS_COLOR_RGBA16:
  596. m = 0x2; break;
  597. case OMAP_DSS_COLOR_RGBX16:
  598. m = 0x4; break;
  599. case OMAP_DSS_COLOR_ARGB16:
  600. m = 0x5; break;
  601. case OMAP_DSS_COLOR_RGB16:
  602. m = 0x6; break;
  603. case OMAP_DSS_COLOR_ARGB16_1555:
  604. m = 0x7; break;
  605. case OMAP_DSS_COLOR_RGB24U:
  606. m = 0x8; break;
  607. case OMAP_DSS_COLOR_RGB24P:
  608. m = 0x9; break;
  609. case OMAP_DSS_COLOR_YUV2:
  610. m = 0xa; break;
  611. case OMAP_DSS_COLOR_UYVY:
  612. m = 0xb; break;
  613. case OMAP_DSS_COLOR_ARGB32:
  614. m = 0xc; break;
  615. case OMAP_DSS_COLOR_RGBA32:
  616. m = 0xd; break;
  617. case OMAP_DSS_COLOR_RGBX32:
  618. m = 0xe; break;
  619. case OMAP_DSS_COLOR_XRGB16_1555:
  620. m = 0xf; break;
  621. default:
  622. BUG(); break;
  623. }
  624. } else {
  625. switch (color_mode) {
  626. case OMAP_DSS_COLOR_CLUT1:
  627. m = 0x0; break;
  628. case OMAP_DSS_COLOR_CLUT2:
  629. m = 0x1; break;
  630. case OMAP_DSS_COLOR_CLUT4:
  631. m = 0x2; break;
  632. case OMAP_DSS_COLOR_CLUT8:
  633. m = 0x3; break;
  634. case OMAP_DSS_COLOR_RGB12U:
  635. m = 0x4; break;
  636. case OMAP_DSS_COLOR_ARGB16:
  637. m = 0x5; break;
  638. case OMAP_DSS_COLOR_RGB16:
  639. m = 0x6; break;
  640. case OMAP_DSS_COLOR_ARGB16_1555:
  641. m = 0x7; break;
  642. case OMAP_DSS_COLOR_RGB24U:
  643. m = 0x8; break;
  644. case OMAP_DSS_COLOR_RGB24P:
  645. m = 0x9; break;
  646. case OMAP_DSS_COLOR_YUV2:
  647. m = 0xa; break;
  648. case OMAP_DSS_COLOR_UYVY:
  649. m = 0xb; break;
  650. case OMAP_DSS_COLOR_ARGB32:
  651. m = 0xc; break;
  652. case OMAP_DSS_COLOR_RGBA32:
  653. m = 0xd; break;
  654. case OMAP_DSS_COLOR_RGBX32:
  655. m = 0xe; break;
  656. case OMAP_DSS_COLOR_XRGB16_1555:
  657. m = 0xf; break;
  658. default:
  659. BUG(); break;
  660. }
  661. }
  662. REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), m, 4, 1);
  663. }
  664. void dispc_ovl_set_channel_out(enum omap_plane plane, enum omap_channel channel)
  665. {
  666. int shift;
  667. u32 val;
  668. int chan = 0, chan2 = 0;
  669. switch (plane) {
  670. case OMAP_DSS_GFX:
  671. shift = 8;
  672. break;
  673. case OMAP_DSS_VIDEO1:
  674. case OMAP_DSS_VIDEO2:
  675. case OMAP_DSS_VIDEO3:
  676. shift = 16;
  677. break;
  678. default:
  679. BUG();
  680. return;
  681. }
  682. val = dispc_read_reg(DISPC_OVL_ATTRIBUTES(plane));
  683. if (dss_has_feature(FEAT_MGR_LCD2)) {
  684. switch (channel) {
  685. case OMAP_DSS_CHANNEL_LCD:
  686. chan = 0;
  687. chan2 = 0;
  688. break;
  689. case OMAP_DSS_CHANNEL_DIGIT:
  690. chan = 1;
  691. chan2 = 0;
  692. break;
  693. case OMAP_DSS_CHANNEL_LCD2:
  694. chan = 0;
  695. chan2 = 1;
  696. break;
  697. default:
  698. BUG();
  699. }
  700. val = FLD_MOD(val, chan, shift, shift);
  701. val = FLD_MOD(val, chan2, 31, 30);
  702. } else {
  703. val = FLD_MOD(val, channel, shift, shift);
  704. }
  705. dispc_write_reg(DISPC_OVL_ATTRIBUTES(plane), val);
  706. }
  707. static enum omap_channel dispc_ovl_get_channel_out(enum omap_plane plane)
  708. {
  709. int shift;
  710. u32 val;
  711. enum omap_channel channel;
  712. switch (plane) {
  713. case OMAP_DSS_GFX:
  714. shift = 8;
  715. break;
  716. case OMAP_DSS_VIDEO1:
  717. case OMAP_DSS_VIDEO2:
  718. case OMAP_DSS_VIDEO3:
  719. shift = 16;
  720. break;
  721. default:
  722. BUG();
  723. }
  724. val = dispc_read_reg(DISPC_OVL_ATTRIBUTES(plane));
  725. if (dss_has_feature(FEAT_MGR_LCD2)) {
  726. if (FLD_GET(val, 31, 30) == 0)
  727. channel = FLD_GET(val, shift, shift);
  728. else
  729. channel = OMAP_DSS_CHANNEL_LCD2;
  730. } else {
  731. channel = FLD_GET(val, shift, shift);
  732. }
  733. return channel;
  734. }
  735. static void dispc_ovl_set_burst_size(enum omap_plane plane,
  736. enum omap_burst_size burst_size)
  737. {
  738. static const unsigned shifts[] = { 6, 14, 14, 14, };
  739. int shift;
  740. shift = shifts[plane];
  741. REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), burst_size, shift + 1, shift);
  742. }
  743. static void dispc_configure_burst_sizes(void)
  744. {
  745. int i;
  746. const int burst_size = BURST_SIZE_X8;
  747. /* Configure burst size always to maximum size */
  748. for (i = 0; i < omap_dss_get_num_overlays(); ++i)
  749. dispc_ovl_set_burst_size(i, burst_size);
  750. }
  751. static u32 dispc_ovl_get_burst_size(enum omap_plane plane)
  752. {
  753. unsigned unit = dss_feat_get_burst_size_unit();
  754. /* burst multiplier is always x8 (see dispc_configure_burst_sizes()) */
  755. return unit * 8;
  756. }
  757. void dispc_enable_gamma_table(bool enable)
  758. {
  759. /*
  760. * This is partially implemented to support only disabling of
  761. * the gamma table.
  762. */
  763. if (enable) {
  764. DSSWARN("Gamma table enabling for TV not yet supported");
  765. return;
  766. }
  767. REG_FLD_MOD(DISPC_CONFIG, enable, 9, 9);
  768. }
  769. static void dispc_mgr_enable_cpr(enum omap_channel channel, bool enable)
  770. {
  771. u16 reg;
  772. if (channel == OMAP_DSS_CHANNEL_LCD)
  773. reg = DISPC_CONFIG;
  774. else if (channel == OMAP_DSS_CHANNEL_LCD2)
  775. reg = DISPC_CONFIG2;
  776. else
  777. return;
  778. REG_FLD_MOD(reg, enable, 15, 15);
  779. }
  780. static void dispc_mgr_set_cpr_coef(enum omap_channel channel,
  781. struct omap_dss_cpr_coefs *coefs)
  782. {
  783. u32 coef_r, coef_g, coef_b;
  784. if (!dispc_mgr_is_lcd(channel))
  785. return;
  786. coef_r = FLD_VAL(coefs->rr, 31, 22) | FLD_VAL(coefs->rg, 20, 11) |
  787. FLD_VAL(coefs->rb, 9, 0);
  788. coef_g = FLD_VAL(coefs->gr, 31, 22) | FLD_VAL(coefs->gg, 20, 11) |
  789. FLD_VAL(coefs->gb, 9, 0);
  790. coef_b = FLD_VAL(coefs->br, 31, 22) | FLD_VAL(coefs->bg, 20, 11) |
  791. FLD_VAL(coefs->bb, 9, 0);
  792. dispc_write_reg(DISPC_CPR_COEF_R(channel), coef_r);
  793. dispc_write_reg(DISPC_CPR_COEF_G(channel), coef_g);
  794. dispc_write_reg(DISPC_CPR_COEF_B(channel), coef_b);
  795. }
  796. static void dispc_ovl_set_vid_color_conv(enum omap_plane plane, bool enable)
  797. {
  798. u32 val;
  799. BUG_ON(plane == OMAP_DSS_GFX);
  800. val = dispc_read_reg(DISPC_OVL_ATTRIBUTES(plane));
  801. val = FLD_MOD(val, enable, 9, 9);
  802. dispc_write_reg(DISPC_OVL_ATTRIBUTES(plane), val);
  803. }
  804. static void dispc_ovl_enable_replication(enum omap_plane plane, bool enable)
  805. {
  806. static const unsigned shifts[] = { 5, 10, 10, 10 };
  807. int shift;
  808. shift = shifts[plane];
  809. REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), enable, shift, shift);
  810. }
  811. void dispc_mgr_set_lcd_size(enum omap_channel channel, u16 width, u16 height)
  812. {
  813. u32 val;
  814. BUG_ON((width > (1 << 11)) || (height > (1 << 11)));
  815. val = FLD_VAL(height - 1, 26, 16) | FLD_VAL(width - 1, 10, 0);
  816. dispc_write_reg(DISPC_SIZE_MGR(channel), val);
  817. }
  818. void dispc_set_digit_size(u16 width, u16 height)
  819. {
  820. u32 val;
  821. BUG_ON((width > (1 << 11)) || (height > (1 << 11)));
  822. val = FLD_VAL(height - 1, 26, 16) | FLD_VAL(width - 1, 10, 0);
  823. dispc_write_reg(DISPC_SIZE_MGR(OMAP_DSS_CHANNEL_DIGIT), val);
  824. }
  825. static void dispc_read_plane_fifo_sizes(void)
  826. {
  827. u32 size;
  828. int plane;
  829. u8 start, end;
  830. u32 unit;
  831. unit = dss_feat_get_buffer_size_unit();
  832. dss_feat_get_reg_field(FEAT_REG_FIFOSIZE, &start, &end);
  833. for (plane = 0; plane < dss_feat_get_num_ovls(); ++plane) {
  834. size = REG_GET(DISPC_OVL_FIFO_SIZE_STATUS(plane), start, end);
  835. size *= unit;
  836. dispc.fifo_size[plane] = size;
  837. }
  838. }
  839. static u32 dispc_ovl_get_fifo_size(enum omap_plane plane)
  840. {
  841. return dispc.fifo_size[plane];
  842. }
  843. void dispc_ovl_set_fifo_threshold(enum omap_plane plane, u32 low, u32 high)
  844. {
  845. u8 hi_start, hi_end, lo_start, lo_end;
  846. u32 unit;
  847. unit = dss_feat_get_buffer_size_unit();
  848. WARN_ON(low % unit != 0);
  849. WARN_ON(high % unit != 0);
  850. low /= unit;
  851. high /= unit;
  852. dss_feat_get_reg_field(FEAT_REG_FIFOHIGHTHRESHOLD, &hi_start, &hi_end);
  853. dss_feat_get_reg_field(FEAT_REG_FIFOLOWTHRESHOLD, &lo_start, &lo_end);
  854. DSSDBG("fifo(%d) threshold (bytes), old %u/%u, new %u/%u\n",
  855. plane,
  856. REG_GET(DISPC_OVL_FIFO_THRESHOLD(plane),
  857. lo_start, lo_end) * unit,
  858. REG_GET(DISPC_OVL_FIFO_THRESHOLD(plane),
  859. hi_start, hi_end) * unit,
  860. low * unit, high * unit);
  861. dispc_write_reg(DISPC_OVL_FIFO_THRESHOLD(plane),
  862. FLD_VAL(high, hi_start, hi_end) |
  863. FLD_VAL(low, lo_start, lo_end));
  864. }
  865. void dispc_enable_fifomerge(bool enable)
  866. {
  867. if (!dss_has_feature(FEAT_FIFO_MERGE)) {
  868. WARN_ON(enable);
  869. return;
  870. }
  871. DSSDBG("FIFO merge %s\n", enable ? "enabled" : "disabled");
  872. REG_FLD_MOD(DISPC_CONFIG, enable ? 1 : 0, 14, 14);
  873. }
  874. void dispc_ovl_compute_fifo_thresholds(enum omap_plane plane,
  875. u32 *fifo_low, u32 *fifo_high, bool use_fifomerge)
  876. {
  877. /*
  878. * All sizes are in bytes. Both the buffer and burst are made of
  879. * buffer_units, and the fifo thresholds must be buffer_unit aligned.
  880. */
  881. unsigned buf_unit = dss_feat_get_buffer_size_unit();
  882. unsigned ovl_fifo_size, total_fifo_size, burst_size;
  883. int i;
  884. burst_size = dispc_ovl_get_burst_size(plane);
  885. ovl_fifo_size = dispc_ovl_get_fifo_size(plane);
  886. if (use_fifomerge) {
  887. total_fifo_size = 0;
  888. for (i = 0; i < omap_dss_get_num_overlays(); ++i)
  889. total_fifo_size += dispc_ovl_get_fifo_size(i);
  890. } else {
  891. total_fifo_size = ovl_fifo_size;
  892. }
  893. /*
  894. * We use the same low threshold for both fifomerge and non-fifomerge
  895. * cases, but for fifomerge we calculate the high threshold using the
  896. * combined fifo size
  897. */
  898. if (dss_has_feature(FEAT_OMAP3_DSI_FIFO_BUG)) {
  899. *fifo_low = ovl_fifo_size - burst_size * 2;
  900. *fifo_high = total_fifo_size - burst_size;
  901. } else {
  902. *fifo_low = ovl_fifo_size - burst_size;
  903. *fifo_high = total_fifo_size - buf_unit;
  904. }
  905. }
  906. static void dispc_ovl_set_fir(enum omap_plane plane,
  907. int hinc, int vinc,
  908. enum omap_color_component color_comp)
  909. {
  910. u32 val;
  911. if (color_comp == DISPC_COLOR_COMPONENT_RGB_Y) {
  912. u8 hinc_start, hinc_end, vinc_start, vinc_end;
  913. dss_feat_get_reg_field(FEAT_REG_FIRHINC,
  914. &hinc_start, &hinc_end);
  915. dss_feat_get_reg_field(FEAT_REG_FIRVINC,
  916. &vinc_start, &vinc_end);
  917. val = FLD_VAL(vinc, vinc_start, vinc_end) |
  918. FLD_VAL(hinc, hinc_start, hinc_end);
  919. dispc_write_reg(DISPC_OVL_FIR(plane), val);
  920. } else {
  921. val = FLD_VAL(vinc, 28, 16) | FLD_VAL(hinc, 12, 0);
  922. dispc_write_reg(DISPC_OVL_FIR2(plane), val);
  923. }
  924. }
  925. static void dispc_ovl_set_vid_accu0(enum omap_plane plane, int haccu, int vaccu)
  926. {
  927. u32 val;
  928. u8 hor_start, hor_end, vert_start, vert_end;
  929. dss_feat_get_reg_field(FEAT_REG_HORIZONTALACCU, &hor_start, &hor_end);
  930. dss_feat_get_reg_field(FEAT_REG_VERTICALACCU, &vert_start, &vert_end);
  931. val = FLD_VAL(vaccu, vert_start, vert_end) |
  932. FLD_VAL(haccu, hor_start, hor_end);
  933. dispc_write_reg(DISPC_OVL_ACCU0(plane), val);
  934. }
  935. static void dispc_ovl_set_vid_accu1(enum omap_plane plane, int haccu, int vaccu)
  936. {
  937. u32 val;
  938. u8 hor_start, hor_end, vert_start, vert_end;
  939. dss_feat_get_reg_field(FEAT_REG_HORIZONTALACCU, &hor_start, &hor_end);
  940. dss_feat_get_reg_field(FEAT_REG_VERTICALACCU, &vert_start, &vert_end);
  941. val = FLD_VAL(vaccu, vert_start, vert_end) |
  942. FLD_VAL(haccu, hor_start, hor_end);
  943. dispc_write_reg(DISPC_OVL_ACCU1(plane), val);
  944. }
  945. static void dispc_ovl_set_vid_accu2_0(enum omap_plane plane, int haccu,
  946. int vaccu)
  947. {
  948. u32 val;
  949. val = FLD_VAL(vaccu, 26, 16) | FLD_VAL(haccu, 10, 0);
  950. dispc_write_reg(DISPC_OVL_ACCU2_0(plane), val);
  951. }
  952. static void dispc_ovl_set_vid_accu2_1(enum omap_plane plane, int haccu,
  953. int vaccu)
  954. {
  955. u32 val;
  956. val = FLD_VAL(vaccu, 26, 16) | FLD_VAL(haccu, 10, 0);
  957. dispc_write_reg(DISPC_OVL_ACCU2_1(plane), val);
  958. }
  959. static void dispc_ovl_set_scale_param(enum omap_plane plane,
  960. u16 orig_width, u16 orig_height,
  961. u16 out_width, u16 out_height,
  962. bool five_taps, u8 rotation,
  963. enum omap_color_component color_comp)
  964. {
  965. int fir_hinc, fir_vinc;
  966. fir_hinc = 1024 * orig_width / out_width;
  967. fir_vinc = 1024 * orig_height / out_height;
  968. dispc_ovl_set_scale_coef(plane, fir_hinc, fir_vinc, five_taps,
  969. color_comp);
  970. dispc_ovl_set_fir(plane, fir_hinc, fir_vinc, color_comp);
  971. }
  972. static void dispc_ovl_set_scaling_common(enum omap_plane plane,
  973. u16 orig_width, u16 orig_height,
  974. u16 out_width, u16 out_height,
  975. bool ilace, bool five_taps,
  976. bool fieldmode, enum omap_color_mode color_mode,
  977. u8 rotation)
  978. {
  979. int accu0 = 0;
  980. int accu1 = 0;
  981. u32 l;
  982. dispc_ovl_set_scale_param(plane, orig_width, orig_height,
  983. out_width, out_height, five_taps,
  984. rotation, DISPC_COLOR_COMPONENT_RGB_Y);
  985. l = dispc_read_reg(DISPC_OVL_ATTRIBUTES(plane));
  986. /* RESIZEENABLE and VERTICALTAPS */
  987. l &= ~((0x3 << 5) | (0x1 << 21));
  988. l |= (orig_width != out_width) ? (1 << 5) : 0;
  989. l |= (orig_height != out_height) ? (1 << 6) : 0;
  990. l |= five_taps ? (1 << 21) : 0;
  991. /* VRESIZECONF and HRESIZECONF */
  992. if (dss_has_feature(FEAT_RESIZECONF)) {
  993. l &= ~(0x3 << 7);
  994. l |= (orig_width <= out_width) ? 0 : (1 << 7);
  995. l |= (orig_height <= out_height) ? 0 : (1 << 8);
  996. }
  997. /* LINEBUFFERSPLIT */
  998. if (dss_has_feature(FEAT_LINEBUFFERSPLIT)) {
  999. l &= ~(0x1 << 22);
  1000. l |= five_taps ? (1 << 22) : 0;
  1001. }
  1002. dispc_write_reg(DISPC_OVL_ATTRIBUTES(plane), l);
  1003. /*
  1004. * field 0 = even field = bottom field
  1005. * field 1 = odd field = top field
  1006. */
  1007. if (ilace && !fieldmode) {
  1008. accu1 = 0;
  1009. accu0 = ((1024 * orig_height / out_height) / 2) & 0x3ff;
  1010. if (accu0 >= 1024/2) {
  1011. accu1 = 1024/2;
  1012. accu0 -= accu1;
  1013. }
  1014. }
  1015. dispc_ovl_set_vid_accu0(plane, 0, accu0);
  1016. dispc_ovl_set_vid_accu1(plane, 0, accu1);
  1017. }
  1018. static void dispc_ovl_set_scaling_uv(enum omap_plane plane,
  1019. u16 orig_width, u16 orig_height,
  1020. u16 out_width, u16 out_height,
  1021. bool ilace, bool five_taps,
  1022. bool fieldmode, enum omap_color_mode color_mode,
  1023. u8 rotation)
  1024. {
  1025. int scale_x = out_width != orig_width;
  1026. int scale_y = out_height != orig_height;
  1027. if (!dss_has_feature(FEAT_HANDLE_UV_SEPARATE))
  1028. return;
  1029. if ((color_mode != OMAP_DSS_COLOR_YUV2 &&
  1030. color_mode != OMAP_DSS_COLOR_UYVY &&
  1031. color_mode != OMAP_DSS_COLOR_NV12)) {
  1032. /* reset chroma resampling for RGB formats */
  1033. REG_FLD_MOD(DISPC_OVL_ATTRIBUTES2(plane), 0, 8, 8);
  1034. return;
  1035. }
  1036. switch (color_mode) {
  1037. case OMAP_DSS_COLOR_NV12:
  1038. /* UV is subsampled by 2 vertically*/
  1039. orig_height >>= 1;
  1040. /* UV is subsampled by 2 horz.*/
  1041. orig_width >>= 1;
  1042. break;
  1043. case OMAP_DSS_COLOR_YUV2:
  1044. case OMAP_DSS_COLOR_UYVY:
  1045. /*For YUV422 with 90/270 rotation,
  1046. *we don't upsample chroma
  1047. */
  1048. if (rotation == OMAP_DSS_ROT_0 ||
  1049. rotation == OMAP_DSS_ROT_180)
  1050. /* UV is subsampled by 2 hrz*/
  1051. orig_width >>= 1;
  1052. /* must use FIR for YUV422 if rotated */
  1053. if (rotation != OMAP_DSS_ROT_0)
  1054. scale_x = scale_y = true;
  1055. break;
  1056. default:
  1057. BUG();
  1058. }
  1059. if (out_width != orig_width)
  1060. scale_x = true;
  1061. if (out_height != orig_height)
  1062. scale_y = true;
  1063. dispc_ovl_set_scale_param(plane, orig_width, orig_height,
  1064. out_width, out_height, five_taps,
  1065. rotation, DISPC_COLOR_COMPONENT_UV);
  1066. REG_FLD_MOD(DISPC_OVL_ATTRIBUTES2(plane),
  1067. (scale_x || scale_y) ? 1 : 0, 8, 8);
  1068. /* set H scaling */
  1069. REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), scale_x ? 1 : 0, 5, 5);
  1070. /* set V scaling */
  1071. REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), scale_y ? 1 : 0, 6, 6);
  1072. dispc_ovl_set_vid_accu2_0(plane, 0x80, 0);
  1073. dispc_ovl_set_vid_accu2_1(plane, 0x80, 0);
  1074. }
  1075. static void dispc_ovl_set_scaling(enum omap_plane plane,
  1076. u16 orig_width, u16 orig_height,
  1077. u16 out_width, u16 out_height,
  1078. bool ilace, bool five_taps,
  1079. bool fieldmode, enum omap_color_mode color_mode,
  1080. u8 rotation)
  1081. {
  1082. BUG_ON(plane == OMAP_DSS_GFX);
  1083. dispc_ovl_set_scaling_common(plane,
  1084. orig_width, orig_height,
  1085. out_width, out_height,
  1086. ilace, five_taps,
  1087. fieldmode, color_mode,
  1088. rotation);
  1089. dispc_ovl_set_scaling_uv(plane,
  1090. orig_width, orig_height,
  1091. out_width, out_height,
  1092. ilace, five_taps,
  1093. fieldmode, color_mode,
  1094. rotation);
  1095. }
  1096. static void dispc_ovl_set_rotation_attrs(enum omap_plane plane, u8 rotation,
  1097. bool mirroring, enum omap_color_mode color_mode)
  1098. {
  1099. bool row_repeat = false;
  1100. int vidrot = 0;
  1101. if (color_mode == OMAP_DSS_COLOR_YUV2 ||
  1102. color_mode == OMAP_DSS_COLOR_UYVY) {
  1103. if (mirroring) {
  1104. switch (rotation) {
  1105. case OMAP_DSS_ROT_0:
  1106. vidrot = 2;
  1107. break;
  1108. case OMAP_DSS_ROT_90:
  1109. vidrot = 1;
  1110. break;
  1111. case OMAP_DSS_ROT_180:
  1112. vidrot = 0;
  1113. break;
  1114. case OMAP_DSS_ROT_270:
  1115. vidrot = 3;
  1116. break;
  1117. }
  1118. } else {
  1119. switch (rotation) {
  1120. case OMAP_DSS_ROT_0:
  1121. vidrot = 0;
  1122. break;
  1123. case OMAP_DSS_ROT_90:
  1124. vidrot = 1;
  1125. break;
  1126. case OMAP_DSS_ROT_180:
  1127. vidrot = 2;
  1128. break;
  1129. case OMAP_DSS_ROT_270:
  1130. vidrot = 3;
  1131. break;
  1132. }
  1133. }
  1134. if (rotation == OMAP_DSS_ROT_90 || rotation == OMAP_DSS_ROT_270)
  1135. row_repeat = true;
  1136. else
  1137. row_repeat = false;
  1138. }
  1139. REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), vidrot, 13, 12);
  1140. if (dss_has_feature(FEAT_ROWREPEATENABLE))
  1141. REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane),
  1142. row_repeat ? 1 : 0, 18, 18);
  1143. }
  1144. static int color_mode_to_bpp(enum omap_color_mode color_mode)
  1145. {
  1146. switch (color_mode) {
  1147. case OMAP_DSS_COLOR_CLUT1:
  1148. return 1;
  1149. case OMAP_DSS_COLOR_CLUT2:
  1150. return 2;
  1151. case OMAP_DSS_COLOR_CLUT4:
  1152. return 4;
  1153. case OMAP_DSS_COLOR_CLUT8:
  1154. case OMAP_DSS_COLOR_NV12:
  1155. return 8;
  1156. case OMAP_DSS_COLOR_RGB12U:
  1157. case OMAP_DSS_COLOR_RGB16:
  1158. case OMAP_DSS_COLOR_ARGB16:
  1159. case OMAP_DSS_COLOR_YUV2:
  1160. case OMAP_DSS_COLOR_UYVY:
  1161. case OMAP_DSS_COLOR_RGBA16:
  1162. case OMAP_DSS_COLOR_RGBX16:
  1163. case OMAP_DSS_COLOR_ARGB16_1555:
  1164. case OMAP_DSS_COLOR_XRGB16_1555:
  1165. return 16;
  1166. case OMAP_DSS_COLOR_RGB24P:
  1167. return 24;
  1168. case OMAP_DSS_COLOR_RGB24U:
  1169. case OMAP_DSS_COLOR_ARGB32:
  1170. case OMAP_DSS_COLOR_RGBA32:
  1171. case OMAP_DSS_COLOR_RGBX32:
  1172. return 32;
  1173. default:
  1174. BUG();
  1175. }
  1176. }
  1177. static s32 pixinc(int pixels, u8 ps)
  1178. {
  1179. if (pixels == 1)
  1180. return 1;
  1181. else if (pixels > 1)
  1182. return 1 + (pixels - 1) * ps;
  1183. else if (pixels < 0)
  1184. return 1 - (-pixels + 1) * ps;
  1185. else
  1186. BUG();
  1187. }
  1188. static void calc_vrfb_rotation_offset(u8 rotation, bool mirror,
  1189. u16 screen_width,
  1190. u16 width, u16 height,
  1191. enum omap_color_mode color_mode, bool fieldmode,
  1192. unsigned int field_offset,
  1193. unsigned *offset0, unsigned *offset1,
  1194. s32 *row_inc, s32 *pix_inc)
  1195. {
  1196. u8 ps;
  1197. /* FIXME CLUT formats */
  1198. switch (color_mode) {
  1199. case OMAP_DSS_COLOR_CLUT1:
  1200. case OMAP_DSS_COLOR_CLUT2:
  1201. case OMAP_DSS_COLOR_CLUT4:
  1202. case OMAP_DSS_COLOR_CLUT8:
  1203. BUG();
  1204. return;
  1205. case OMAP_DSS_COLOR_YUV2:
  1206. case OMAP_DSS_COLOR_UYVY:
  1207. ps = 4;
  1208. break;
  1209. default:
  1210. ps = color_mode_to_bpp(color_mode) / 8;
  1211. break;
  1212. }
  1213. DSSDBG("calc_rot(%d): scrw %d, %dx%d\n", rotation, screen_width,
  1214. width, height);
  1215. /*
  1216. * field 0 = even field = bottom field
  1217. * field 1 = odd field = top field
  1218. */
  1219. switch (rotation + mirror * 4) {
  1220. case OMAP_DSS_ROT_0:
  1221. case OMAP_DSS_ROT_180:
  1222. /*
  1223. * If the pixel format is YUV or UYVY divide the width
  1224. * of the image by 2 for 0 and 180 degree rotation.
  1225. */
  1226. if (color_mode == OMAP_DSS_COLOR_YUV2 ||
  1227. color_mode == OMAP_DSS_COLOR_UYVY)
  1228. width = width >> 1;
  1229. case OMAP_DSS_ROT_90:
  1230. case OMAP_DSS_ROT_270:
  1231. *offset1 = 0;
  1232. if (field_offset)
  1233. *offset0 = field_offset * screen_width * ps;
  1234. else
  1235. *offset0 = 0;
  1236. *row_inc = pixinc(1 + (screen_width - width) +
  1237. (fieldmode ? screen_width : 0),
  1238. ps);
  1239. *pix_inc = pixinc(1, ps);
  1240. break;
  1241. case OMAP_DSS_ROT_0 + 4:
  1242. case OMAP_DSS_ROT_180 + 4:
  1243. /* If the pixel format is YUV or UYVY divide the width
  1244. * of the image by 2 for 0 degree and 180 degree
  1245. */
  1246. if (color_mode == OMAP_DSS_COLOR_YUV2 ||
  1247. color_mode == OMAP_DSS_COLOR_UYVY)
  1248. width = width >> 1;
  1249. case OMAP_DSS_ROT_90 + 4:
  1250. case OMAP_DSS_ROT_270 + 4:
  1251. *offset1 = 0;
  1252. if (field_offset)
  1253. *offset0 = field_offset * screen_width * ps;
  1254. else
  1255. *offset0 = 0;
  1256. *row_inc = pixinc(1 - (screen_width + width) -
  1257. (fieldmode ? screen_width : 0),
  1258. ps);
  1259. *pix_inc = pixinc(1, ps);
  1260. break;
  1261. default:
  1262. BUG();
  1263. }
  1264. }
  1265. static void calc_dma_rotation_offset(u8 rotation, bool mirror,
  1266. u16 screen_width,
  1267. u16 width, u16 height,
  1268. enum omap_color_mode color_mode, bool fieldmode,
  1269. unsigned int field_offset,
  1270. unsigned *offset0, unsigned *offset1,
  1271. s32 *row_inc, s32 *pix_inc)
  1272. {
  1273. u8 ps;
  1274. u16 fbw, fbh;
  1275. /* FIXME CLUT formats */
  1276. switch (color_mode) {
  1277. case OMAP_DSS_COLOR_CLUT1:
  1278. case OMAP_DSS_COLOR_CLUT2:
  1279. case OMAP_DSS_COLOR_CLUT4:
  1280. case OMAP_DSS_COLOR_CLUT8:
  1281. BUG();
  1282. return;
  1283. default:
  1284. ps = color_mode_to_bpp(color_mode) / 8;
  1285. break;
  1286. }
  1287. DSSDBG("calc_rot(%d): scrw %d, %dx%d\n", rotation, screen_width,
  1288. width, height);
  1289. /* width & height are overlay sizes, convert to fb sizes */
  1290. if (rotation == OMAP_DSS_ROT_0 || rotation == OMAP_DSS_ROT_180) {
  1291. fbw = width;
  1292. fbh = height;
  1293. } else {
  1294. fbw = height;
  1295. fbh = width;
  1296. }
  1297. /*
  1298. * field 0 = even field = bottom field
  1299. * field 1 = odd field = top field
  1300. */
  1301. switch (rotation + mirror * 4) {
  1302. case OMAP_DSS_ROT_0:
  1303. *offset1 = 0;
  1304. if (field_offset)
  1305. *offset0 = *offset1 + field_offset * screen_width * ps;
  1306. else
  1307. *offset0 = *offset1;
  1308. *row_inc = pixinc(1 + (screen_width - fbw) +
  1309. (fieldmode ? screen_width : 0),
  1310. ps);
  1311. *pix_inc = pixinc(1, ps);
  1312. break;
  1313. case OMAP_DSS_ROT_90:
  1314. *offset1 = screen_width * (fbh - 1) * ps;
  1315. if (field_offset)
  1316. *offset0 = *offset1 + field_offset * ps;
  1317. else
  1318. *offset0 = *offset1;
  1319. *row_inc = pixinc(screen_width * (fbh - 1) + 1 +
  1320. (fieldmode ? 1 : 0), ps);
  1321. *pix_inc = pixinc(-screen_width, ps);
  1322. break;
  1323. case OMAP_DSS_ROT_180:
  1324. *offset1 = (screen_width * (fbh - 1) + fbw - 1) * ps;
  1325. if (field_offset)
  1326. *offset0 = *offset1 - field_offset * screen_width * ps;
  1327. else
  1328. *offset0 = *offset1;
  1329. *row_inc = pixinc(-1 -
  1330. (screen_width - fbw) -
  1331. (fieldmode ? screen_width : 0),
  1332. ps);
  1333. *pix_inc = pixinc(-1, ps);
  1334. break;
  1335. case OMAP_DSS_ROT_270:
  1336. *offset1 = (fbw - 1) * ps;
  1337. if (field_offset)
  1338. *offset0 = *offset1 - field_offset * ps;
  1339. else
  1340. *offset0 = *offset1;
  1341. *row_inc = pixinc(-screen_width * (fbh - 1) - 1 -
  1342. (fieldmode ? 1 : 0), ps);
  1343. *pix_inc = pixinc(screen_width, ps);
  1344. break;
  1345. /* mirroring */
  1346. case OMAP_DSS_ROT_0 + 4:
  1347. *offset1 = (fbw - 1) * ps;
  1348. if (field_offset)
  1349. *offset0 = *offset1 + field_offset * screen_width * ps;
  1350. else
  1351. *offset0 = *offset1;
  1352. *row_inc = pixinc(screen_width * 2 - 1 +
  1353. (fieldmode ? screen_width : 0),
  1354. ps);
  1355. *pix_inc = pixinc(-1, ps);
  1356. break;
  1357. case OMAP_DSS_ROT_90 + 4:
  1358. *offset1 = 0;
  1359. if (field_offset)
  1360. *offset0 = *offset1 + field_offset * ps;
  1361. else
  1362. *offset0 = *offset1;
  1363. *row_inc = pixinc(-screen_width * (fbh - 1) + 1 +
  1364. (fieldmode ? 1 : 0),
  1365. ps);
  1366. *pix_inc = pixinc(screen_width, ps);
  1367. break;
  1368. case OMAP_DSS_ROT_180 + 4:
  1369. *offset1 = screen_width * (fbh - 1) * ps;
  1370. if (field_offset)
  1371. *offset0 = *offset1 - field_offset * screen_width * ps;
  1372. else
  1373. *offset0 = *offset1;
  1374. *row_inc = pixinc(1 - screen_width * 2 -
  1375. (fieldmode ? screen_width : 0),
  1376. ps);
  1377. *pix_inc = pixinc(1, ps);
  1378. break;
  1379. case OMAP_DSS_ROT_270 + 4:
  1380. *offset1 = (screen_width * (fbh - 1) + fbw - 1) * ps;
  1381. if (field_offset)
  1382. *offset0 = *offset1 - field_offset * ps;
  1383. else
  1384. *offset0 = *offset1;
  1385. *row_inc = pixinc(screen_width * (fbh - 1) - 1 -
  1386. (fieldmode ? 1 : 0),
  1387. ps);
  1388. *pix_inc = pixinc(-screen_width, ps);
  1389. break;
  1390. default:
  1391. BUG();
  1392. }
  1393. }
  1394. static unsigned long calc_fclk_five_taps(enum omap_channel channel, u16 width,
  1395. u16 height, u16 out_width, u16 out_height,
  1396. enum omap_color_mode color_mode)
  1397. {
  1398. u32 fclk = 0;
  1399. u64 tmp, pclk = dispc_mgr_pclk_rate(channel);
  1400. if (height <= out_height && width <= out_width)
  1401. return (unsigned long) pclk;
  1402. if (height > out_height) {
  1403. struct omap_dss_device *dssdev = dispc_mgr_get_device(channel);
  1404. unsigned int ppl = dssdev->panel.timings.x_res;
  1405. tmp = pclk * height * out_width;
  1406. do_div(tmp, 2 * out_height * ppl);
  1407. fclk = tmp;
  1408. if (height > 2 * out_height) {
  1409. if (ppl == out_width)
  1410. return 0;
  1411. tmp = pclk * (height - 2 * out_height) * out_width;
  1412. do_div(tmp, 2 * out_height * (ppl - out_width));
  1413. fclk = max(fclk, (u32) tmp);
  1414. }
  1415. }
  1416. if (width > out_width) {
  1417. tmp = pclk * width;
  1418. do_div(tmp, out_width);
  1419. fclk = max(fclk, (u32) tmp);
  1420. if (color_mode == OMAP_DSS_COLOR_RGB24U)
  1421. fclk <<= 1;
  1422. }
  1423. return fclk;
  1424. }
  1425. static unsigned long calc_fclk(enum omap_channel channel, u16 width,
  1426. u16 height, u16 out_width, u16 out_height)
  1427. {
  1428. unsigned int hf, vf;
  1429. /*
  1430. * FIXME how to determine the 'A' factor
  1431. * for the no downscaling case ?
  1432. */
  1433. if (width > 3 * out_width)
  1434. hf = 4;
  1435. else if (width > 2 * out_width)
  1436. hf = 3;
  1437. else if (width > out_width)
  1438. hf = 2;
  1439. else
  1440. hf = 1;
  1441. if (height > out_height)
  1442. vf = 2;
  1443. else
  1444. vf = 1;
  1445. if (cpu_is_omap24xx()) {
  1446. if (vf > 1 && hf > 1)
  1447. return dispc_mgr_pclk_rate(channel) * 4;
  1448. else
  1449. return dispc_mgr_pclk_rate(channel) * 2;
  1450. } else if (cpu_is_omap34xx()) {
  1451. return dispc_mgr_pclk_rate(channel) * vf * hf;
  1452. } else {
  1453. return dispc_mgr_pclk_rate(channel) * hf;
  1454. }
  1455. }
  1456. static int dispc_ovl_calc_scaling(enum omap_plane plane,
  1457. enum omap_channel channel, u16 width, u16 height,
  1458. u16 out_width, u16 out_height,
  1459. enum omap_color_mode color_mode, bool *five_taps)
  1460. {
  1461. struct omap_overlay *ovl = omap_dss_get_overlay(plane);
  1462. const int maxdownscale = dss_feat_get_param_max(FEAT_PARAM_DOWNSCALE);
  1463. const int maxsinglelinewidth =
  1464. dss_feat_get_param_max(FEAT_PARAM_LINEWIDTH);
  1465. unsigned long fclk = 0;
  1466. if (width == out_width && height == out_height)
  1467. return 0;
  1468. if ((ovl->caps & OMAP_DSS_OVL_CAP_SCALE) == 0)
  1469. return -EINVAL;
  1470. if (out_width < width / maxdownscale ||
  1471. out_width > width * 8)
  1472. return -EINVAL;
  1473. if (out_height < height / maxdownscale ||
  1474. out_height > height * 8)
  1475. return -EINVAL;
  1476. if (cpu_is_omap24xx()) {
  1477. if (width > maxsinglelinewidth)
  1478. DSSERR("Cannot scale max input width exceeded");
  1479. *five_taps = false;
  1480. fclk = calc_fclk(channel, width, height, out_width,
  1481. out_height);
  1482. } else if (cpu_is_omap34xx()) {
  1483. if (width > (maxsinglelinewidth * 2)) {
  1484. DSSERR("Cannot setup scaling");
  1485. DSSERR("width exceeds maximum width possible");
  1486. return -EINVAL;
  1487. }
  1488. fclk = calc_fclk_five_taps(channel, width, height, out_width,
  1489. out_height, color_mode);
  1490. if (width > maxsinglelinewidth) {
  1491. if (height > out_height && height < out_height * 2)
  1492. *five_taps = false;
  1493. else {
  1494. DSSERR("cannot setup scaling with five taps");
  1495. return -EINVAL;
  1496. }
  1497. }
  1498. if (!*five_taps)
  1499. fclk = calc_fclk(channel, width, height, out_width,
  1500. out_height);
  1501. } else {
  1502. if (width > maxsinglelinewidth) {
  1503. DSSERR("Cannot scale width exceeds max line width");
  1504. return -EINVAL;
  1505. }
  1506. fclk = calc_fclk(channel, width, height, out_width,
  1507. out_height);
  1508. }
  1509. DSSDBG("required fclk rate = %lu Hz\n", fclk);
  1510. DSSDBG("current fclk rate = %lu Hz\n", dispc_fclk_rate());
  1511. if (!fclk || fclk > dispc_fclk_rate()) {
  1512. DSSERR("failed to set up scaling, "
  1513. "required fclk rate = %lu Hz, "
  1514. "current fclk rate = %lu Hz\n",
  1515. fclk, dispc_fclk_rate());
  1516. return -EINVAL;
  1517. }
  1518. return 0;
  1519. }
  1520. int dispc_ovl_setup(enum omap_plane plane, struct omap_overlay_info *oi,
  1521. bool ilace, bool replication)
  1522. {
  1523. struct omap_overlay *ovl = omap_dss_get_overlay(plane);
  1524. bool five_taps = true;
  1525. bool fieldmode = 0;
  1526. int r, cconv = 0;
  1527. unsigned offset0, offset1;
  1528. s32 row_inc;
  1529. s32 pix_inc;
  1530. u16 frame_height = oi->height;
  1531. unsigned int field_offset = 0;
  1532. u16 outw, outh;
  1533. enum omap_channel channel;
  1534. channel = dispc_ovl_get_channel_out(plane);
  1535. DSSDBG("dispc_ovl_setup %d, pa %x, pa_uv %x, sw %d, %d,%d, %dx%d -> "
  1536. "%dx%d, cmode %x, rot %d, mir %d, ilace %d chan %d repl %d\n",
  1537. plane, oi->paddr, oi->p_uv_addr,
  1538. oi->screen_width, oi->pos_x, oi->pos_y, oi->width, oi->height,
  1539. oi->out_width, oi->out_height, oi->color_mode, oi->rotation,
  1540. oi->mirror, ilace, channel, replication);
  1541. if (oi->paddr == 0)
  1542. return -EINVAL;
  1543. outw = oi->out_width == 0 ? oi->width : oi->out_width;
  1544. outh = oi->out_height == 0 ? oi->height : oi->out_height;
  1545. if (ilace && oi->height == outh)
  1546. fieldmode = 1;
  1547. if (ilace) {
  1548. if (fieldmode)
  1549. oi->height /= 2;
  1550. oi->pos_y /= 2;
  1551. outh /= 2;
  1552. DSSDBG("adjusting for ilace: height %d, pos_y %d, "
  1553. "out_height %d\n",
  1554. oi->height, oi->pos_y, outh);
  1555. }
  1556. if (!dss_feat_color_mode_supported(plane, oi->color_mode))
  1557. return -EINVAL;
  1558. r = dispc_ovl_calc_scaling(plane, channel, oi->width, oi->height,
  1559. outw, outh, oi->color_mode,
  1560. &five_taps);
  1561. if (r)
  1562. return r;
  1563. if (oi->color_mode == OMAP_DSS_COLOR_YUV2 ||
  1564. oi->color_mode == OMAP_DSS_COLOR_UYVY ||
  1565. oi->color_mode == OMAP_DSS_COLOR_NV12)
  1566. cconv = 1;
  1567. if (ilace && !fieldmode) {
  1568. /*
  1569. * when downscaling the bottom field may have to start several
  1570. * source lines below the top field. Unfortunately ACCUI
  1571. * registers will only hold the fractional part of the offset
  1572. * so the integer part must be added to the base address of the
  1573. * bottom field.
  1574. */
  1575. if (!oi->height || oi->height == outh)
  1576. field_offset = 0;
  1577. else
  1578. field_offset = oi->height / outh / 2;
  1579. }
  1580. /* Fields are independent but interleaved in memory. */
  1581. if (fieldmode)
  1582. field_offset = 1;
  1583. if (oi->rotation_type == OMAP_DSS_ROT_DMA)
  1584. calc_dma_rotation_offset(oi->rotation, oi->mirror,
  1585. oi->screen_width, oi->width, frame_height,
  1586. oi->color_mode, fieldmode, field_offset,
  1587. &offset0, &offset1, &row_inc, &pix_inc);
  1588. else
  1589. calc_vrfb_rotation_offset(oi->rotation, oi->mirror,
  1590. oi->screen_width, oi->width, frame_height,
  1591. oi->color_mode, fieldmode, field_offset,
  1592. &offset0, &offset1, &row_inc, &pix_inc);
  1593. DSSDBG("offset0 %u, offset1 %u, row_inc %d, pix_inc %d\n",
  1594. offset0, offset1, row_inc, pix_inc);
  1595. dispc_ovl_set_color_mode(plane, oi->color_mode);
  1596. dispc_ovl_set_ba0(plane, oi->paddr + offset0);
  1597. dispc_ovl_set_ba1(plane, oi->paddr + offset1);
  1598. if (OMAP_DSS_COLOR_NV12 == oi->color_mode) {
  1599. dispc_ovl_set_ba0_uv(plane, oi->p_uv_addr + offset0);
  1600. dispc_ovl_set_ba1_uv(plane, oi->p_uv_addr + offset1);
  1601. }
  1602. dispc_ovl_set_row_inc(plane, row_inc);
  1603. dispc_ovl_set_pix_inc(plane, pix_inc);
  1604. DSSDBG("%d,%d %dx%d -> %dx%d\n", oi->pos_x, oi->pos_y, oi->width,
  1605. oi->height, outw, outh);
  1606. dispc_ovl_set_pos(plane, oi->pos_x, oi->pos_y);
  1607. dispc_ovl_set_pic_size(plane, oi->width, oi->height);
  1608. if (ovl->caps & OMAP_DSS_OVL_CAP_SCALE) {
  1609. dispc_ovl_set_scaling(plane, oi->width, oi->height,
  1610. outw, outh,
  1611. ilace, five_taps, fieldmode,
  1612. oi->color_mode, oi->rotation);
  1613. dispc_ovl_set_vid_size(plane, outw, outh);
  1614. dispc_ovl_set_vid_color_conv(plane, cconv);
  1615. }
  1616. dispc_ovl_set_rotation_attrs(plane, oi->rotation, oi->mirror,
  1617. oi->color_mode);
  1618. dispc_ovl_set_zorder(plane, oi->zorder);
  1619. dispc_ovl_set_pre_mult_alpha(plane, oi->pre_mult_alpha);
  1620. dispc_ovl_setup_global_alpha(plane, oi->global_alpha);
  1621. dispc_ovl_enable_replication(plane, replication);
  1622. return 0;
  1623. }
  1624. int dispc_ovl_enable(enum omap_plane plane, bool enable)
  1625. {
  1626. DSSDBG("dispc_enable_plane %d, %d\n", plane, enable);
  1627. REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), enable ? 1 : 0, 0, 0);
  1628. return 0;
  1629. }
  1630. static void dispc_disable_isr(void *data, u32 mask)
  1631. {
  1632. struct completion *compl = data;
  1633. complete(compl);
  1634. }
  1635. static void _enable_lcd_out(enum omap_channel channel, bool enable)
  1636. {
  1637. if (channel == OMAP_DSS_CHANNEL_LCD2) {
  1638. REG_FLD_MOD(DISPC_CONTROL2, enable ? 1 : 0, 0, 0);
  1639. /* flush posted write */
  1640. dispc_read_reg(DISPC_CONTROL2);
  1641. } else {
  1642. REG_FLD_MOD(DISPC_CONTROL, enable ? 1 : 0, 0, 0);
  1643. dispc_read_reg(DISPC_CONTROL);
  1644. }
  1645. }
  1646. static void dispc_mgr_enable_lcd_out(enum omap_channel channel, bool enable)
  1647. {
  1648. struct completion frame_done_completion;
  1649. bool is_on;
  1650. int r;
  1651. u32 irq;
  1652. /* When we disable LCD output, we need to wait until frame is done.
  1653. * Otherwise the DSS is still working, and turning off the clocks
  1654. * prevents DSS from going to OFF mode */
  1655. is_on = channel == OMAP_DSS_CHANNEL_LCD2 ?
  1656. REG_GET(DISPC_CONTROL2, 0, 0) :
  1657. REG_GET(DISPC_CONTROL, 0, 0);
  1658. irq = channel == OMAP_DSS_CHANNEL_LCD2 ? DISPC_IRQ_FRAMEDONE2 :
  1659. DISPC_IRQ_FRAMEDONE;
  1660. if (!enable && is_on) {
  1661. init_completion(&frame_done_completion);
  1662. r = omap_dispc_register_isr(dispc_disable_isr,
  1663. &frame_done_completion, irq);
  1664. if (r)
  1665. DSSERR("failed to register FRAMEDONE isr\n");
  1666. }
  1667. _enable_lcd_out(channel, enable);
  1668. if (!enable && is_on) {
  1669. if (!wait_for_completion_timeout(&frame_done_completion,
  1670. msecs_to_jiffies(100)))
  1671. DSSERR("timeout waiting for FRAME DONE\n");
  1672. r = omap_dispc_unregister_isr(dispc_disable_isr,
  1673. &frame_done_completion, irq);
  1674. if (r)
  1675. DSSERR("failed to unregister FRAMEDONE isr\n");
  1676. }
  1677. }
  1678. static void _enable_digit_out(bool enable)
  1679. {
  1680. REG_FLD_MOD(DISPC_CONTROL, enable ? 1 : 0, 1, 1);
  1681. /* flush posted write */
  1682. dispc_read_reg(DISPC_CONTROL);
  1683. }
  1684. static void dispc_mgr_enable_digit_out(bool enable)
  1685. {
  1686. struct completion frame_done_completion;
  1687. enum dss_hdmi_venc_clk_source_select src;
  1688. int r, i;
  1689. u32 irq_mask;
  1690. int num_irqs;
  1691. if (REG_GET(DISPC_CONTROL, 1, 1) == enable)
  1692. return;
  1693. src = dss_get_hdmi_venc_clk_source();
  1694. if (enable) {
  1695. unsigned long flags;
  1696. /* When we enable digit output, we'll get an extra digit
  1697. * sync lost interrupt, that we need to ignore */
  1698. spin_lock_irqsave(&dispc.irq_lock, flags);
  1699. dispc.irq_error_mask &= ~DISPC_IRQ_SYNC_LOST_DIGIT;
  1700. _omap_dispc_set_irqs();
  1701. spin_unlock_irqrestore(&dispc.irq_lock, flags);
  1702. }
  1703. /* When we disable digit output, we need to wait until fields are done.
  1704. * Otherwise the DSS is still working, and turning off the clocks
  1705. * prevents DSS from going to OFF mode. And when enabling, we need to
  1706. * wait for the extra sync losts */
  1707. init_completion(&frame_done_completion);
  1708. if (src == DSS_HDMI_M_PCLK && enable == false) {
  1709. irq_mask = DISPC_IRQ_FRAMEDONETV;
  1710. num_irqs = 1;
  1711. } else {
  1712. irq_mask = DISPC_IRQ_EVSYNC_EVEN | DISPC_IRQ_EVSYNC_ODD;
  1713. /* XXX I understand from TRM that we should only wait for the
  1714. * current field to complete. But it seems we have to wait for
  1715. * both fields */
  1716. num_irqs = 2;
  1717. }
  1718. r = omap_dispc_register_isr(dispc_disable_isr, &frame_done_completion,
  1719. irq_mask);
  1720. if (r)
  1721. DSSERR("failed to register %x isr\n", irq_mask);
  1722. _enable_digit_out(enable);
  1723. for (i = 0; i < num_irqs; ++i) {
  1724. if (!wait_for_completion_timeout(&frame_done_completion,
  1725. msecs_to_jiffies(100)))
  1726. DSSERR("timeout waiting for digit out to %s\n",
  1727. enable ? "start" : "stop");
  1728. }
  1729. r = omap_dispc_unregister_isr(dispc_disable_isr, &frame_done_completion,
  1730. irq_mask);
  1731. if (r)
  1732. DSSERR("failed to unregister %x isr\n", irq_mask);
  1733. if (enable) {
  1734. unsigned long flags;
  1735. spin_lock_irqsave(&dispc.irq_lock, flags);
  1736. dispc.irq_error_mask |= DISPC_IRQ_SYNC_LOST_DIGIT;
  1737. dispc_write_reg(DISPC_IRQSTATUS, DISPC_IRQ_SYNC_LOST_DIGIT);
  1738. _omap_dispc_set_irqs();
  1739. spin_unlock_irqrestore(&dispc.irq_lock, flags);
  1740. }
  1741. }
  1742. bool dispc_mgr_is_enabled(enum omap_channel channel)
  1743. {
  1744. if (channel == OMAP_DSS_CHANNEL_LCD)
  1745. return !!REG_GET(DISPC_CONTROL, 0, 0);
  1746. else if (channel == OMAP_DSS_CHANNEL_DIGIT)
  1747. return !!REG_GET(DISPC_CONTROL, 1, 1);
  1748. else if (channel == OMAP_DSS_CHANNEL_LCD2)
  1749. return !!REG_GET(DISPC_CONTROL2, 0, 0);
  1750. else
  1751. BUG();
  1752. }
  1753. void dispc_mgr_enable(enum omap_channel channel, bool enable)
  1754. {
  1755. if (dispc_mgr_is_lcd(channel))
  1756. dispc_mgr_enable_lcd_out(channel, enable);
  1757. else if (channel == OMAP_DSS_CHANNEL_DIGIT)
  1758. dispc_mgr_enable_digit_out(enable);
  1759. else
  1760. BUG();
  1761. }
  1762. void dispc_lcd_enable_signal_polarity(bool act_high)
  1763. {
  1764. if (!dss_has_feature(FEAT_LCDENABLEPOL))
  1765. return;
  1766. REG_FLD_MOD(DISPC_CONTROL, act_high ? 1 : 0, 29, 29);
  1767. }
  1768. void dispc_lcd_enable_signal(bool enable)
  1769. {
  1770. if (!dss_has_feature(FEAT_LCDENABLESIGNAL))
  1771. return;
  1772. REG_FLD_MOD(DISPC_CONTROL, enable ? 1 : 0, 28, 28);
  1773. }
  1774. void dispc_pck_free_enable(bool enable)
  1775. {
  1776. if (!dss_has_feature(FEAT_PCKFREEENABLE))
  1777. return;
  1778. REG_FLD_MOD(DISPC_CONTROL, enable ? 1 : 0, 27, 27);
  1779. }
  1780. void dispc_mgr_enable_fifohandcheck(enum omap_channel channel, bool enable)
  1781. {
  1782. if (channel == OMAP_DSS_CHANNEL_LCD2)
  1783. REG_FLD_MOD(DISPC_CONFIG2, enable ? 1 : 0, 16, 16);
  1784. else
  1785. REG_FLD_MOD(DISPC_CONFIG, enable ? 1 : 0, 16, 16);
  1786. }
  1787. void dispc_mgr_set_lcd_display_type(enum omap_channel channel,
  1788. enum omap_lcd_display_type type)
  1789. {
  1790. int mode;
  1791. switch (type) {
  1792. case OMAP_DSS_LCD_DISPLAY_STN:
  1793. mode = 0;
  1794. break;
  1795. case OMAP_DSS_LCD_DISPLAY_TFT:
  1796. mode = 1;
  1797. break;
  1798. default:
  1799. BUG();
  1800. return;
  1801. }
  1802. if (channel == OMAP_DSS_CHANNEL_LCD2)
  1803. REG_FLD_MOD(DISPC_CONTROL2, mode, 3, 3);
  1804. else
  1805. REG_FLD_MOD(DISPC_CONTROL, mode, 3, 3);
  1806. }
  1807. void dispc_set_loadmode(enum omap_dss_load_mode mode)
  1808. {
  1809. REG_FLD_MOD(DISPC_CONFIG, mode, 2, 1);
  1810. }
  1811. static void dispc_mgr_set_default_color(enum omap_channel channel, u32 color)
  1812. {
  1813. dispc_write_reg(DISPC_DEFAULT_COLOR(channel), color);
  1814. }
  1815. static void dispc_mgr_set_trans_key(enum omap_channel ch,
  1816. enum omap_dss_trans_key_type type,
  1817. u32 trans_key)
  1818. {
  1819. if (ch == OMAP_DSS_CHANNEL_LCD)
  1820. REG_FLD_MOD(DISPC_CONFIG, type, 11, 11);
  1821. else if (ch == OMAP_DSS_CHANNEL_DIGIT)
  1822. REG_FLD_MOD(DISPC_CONFIG, type, 13, 13);
  1823. else /* OMAP_DSS_CHANNEL_LCD2 */
  1824. REG_FLD_MOD(DISPC_CONFIG2, type, 11, 11);
  1825. dispc_write_reg(DISPC_TRANS_COLOR(ch), trans_key);
  1826. }
  1827. static void dispc_mgr_enable_trans_key(enum omap_channel ch, bool enable)
  1828. {
  1829. if (ch == OMAP_DSS_CHANNEL_LCD)
  1830. REG_FLD_MOD(DISPC_CONFIG, enable, 10, 10);
  1831. else if (ch == OMAP_DSS_CHANNEL_DIGIT)
  1832. REG_FLD_MOD(DISPC_CONFIG, enable, 12, 12);
  1833. else /* OMAP_DSS_CHANNEL_LCD2 */
  1834. REG_FLD_MOD(DISPC_CONFIG2, enable, 10, 10);
  1835. }
  1836. static void dispc_mgr_enable_alpha_fixed_zorder(enum omap_channel ch,
  1837. bool enable)
  1838. {
  1839. if (!dss_has_feature(FEAT_ALPHA_FIXED_ZORDER))
  1840. return;
  1841. if (ch == OMAP_DSS_CHANNEL_LCD)
  1842. REG_FLD_MOD(DISPC_CONFIG, enable, 18, 18);
  1843. else if (ch == OMAP_DSS_CHANNEL_DIGIT)
  1844. REG_FLD_MOD(DISPC_CONFIG, enable, 19, 19);
  1845. }
  1846. void dispc_mgr_setup(enum omap_channel channel,
  1847. struct omap_overlay_manager_info *info)
  1848. {
  1849. dispc_mgr_set_default_color(channel, info->default_color);
  1850. dispc_mgr_set_trans_key(channel, info->trans_key_type, info->trans_key);
  1851. dispc_mgr_enable_trans_key(channel, info->trans_enabled);
  1852. dispc_mgr_enable_alpha_fixed_zorder(channel,
  1853. info->partial_alpha_enabled);
  1854. if (dss_has_feature(FEAT_CPR)) {
  1855. dispc_mgr_enable_cpr(channel, info->cpr_enable);
  1856. dispc_mgr_set_cpr_coef(channel, &info->cpr_coefs);
  1857. }
  1858. }
  1859. void dispc_mgr_set_tft_data_lines(enum omap_channel channel, u8 data_lines)
  1860. {
  1861. int code;
  1862. switch (data_lines) {
  1863. case 12:
  1864. code = 0;
  1865. break;
  1866. case 16:
  1867. code = 1;
  1868. break;
  1869. case 18:
  1870. code = 2;
  1871. break;
  1872. case 24:
  1873. code = 3;
  1874. break;
  1875. default:
  1876. BUG();
  1877. return;
  1878. }
  1879. if (channel == OMAP_DSS_CHANNEL_LCD2)
  1880. REG_FLD_MOD(DISPC_CONTROL2, code, 9, 8);
  1881. else
  1882. REG_FLD_MOD(DISPC_CONTROL, code, 9, 8);
  1883. }
  1884. void dispc_mgr_set_io_pad_mode(enum dss_io_pad_mode mode)
  1885. {
  1886. u32 l;
  1887. int gpout0, gpout1;
  1888. switch (mode) {
  1889. case DSS_IO_PAD_MODE_RESET:
  1890. gpout0 = 0;
  1891. gpout1 = 0;
  1892. break;
  1893. case DSS_IO_PAD_MODE_RFBI:
  1894. gpout0 = 1;
  1895. gpout1 = 0;
  1896. break;
  1897. case DSS_IO_PAD_MODE_BYPASS:
  1898. gpout0 = 1;
  1899. gpout1 = 1;
  1900. break;
  1901. default:
  1902. BUG();
  1903. return;
  1904. }
  1905. l = dispc_read_reg(DISPC_CONTROL);
  1906. l = FLD_MOD(l, gpout0, 15, 15);
  1907. l = FLD_MOD(l, gpout1, 16, 16);
  1908. dispc_write_reg(DISPC_CONTROL, l);
  1909. }
  1910. void dispc_mgr_enable_stallmode(enum omap_channel channel, bool enable)
  1911. {
  1912. if (channel == OMAP_DSS_CHANNEL_LCD2)
  1913. REG_FLD_MOD(DISPC_CONTROL2, enable, 11, 11);
  1914. else
  1915. REG_FLD_MOD(DISPC_CONTROL, enable, 11, 11);
  1916. }
  1917. static bool _dispc_lcd_timings_ok(int hsw, int hfp, int hbp,
  1918. int vsw, int vfp, int vbp)
  1919. {
  1920. if (cpu_is_omap24xx() || omap_rev() < OMAP3430_REV_ES3_0) {
  1921. if (hsw < 1 || hsw > 64 ||
  1922. hfp < 1 || hfp > 256 ||
  1923. hbp < 1 || hbp > 256 ||
  1924. vsw < 1 || vsw > 64 ||
  1925. vfp < 0 || vfp > 255 ||
  1926. vbp < 0 || vbp > 255)
  1927. return false;
  1928. } else {
  1929. if (hsw < 1 || hsw > 256 ||
  1930. hfp < 1 || hfp > 4096 ||
  1931. hbp < 1 || hbp > 4096 ||
  1932. vsw < 1 || vsw > 256 ||
  1933. vfp < 0 || vfp > 4095 ||
  1934. vbp < 0 || vbp > 4095)
  1935. return false;
  1936. }
  1937. return true;
  1938. }
  1939. bool dispc_lcd_timings_ok(struct omap_video_timings *timings)
  1940. {
  1941. return _dispc_lcd_timings_ok(timings->hsw, timings->hfp,
  1942. timings->hbp, timings->vsw,
  1943. timings->vfp, timings->vbp);
  1944. }
  1945. static void _dispc_mgr_set_lcd_timings(enum omap_channel channel, int hsw,
  1946. int hfp, int hbp, int vsw, int vfp, int vbp)
  1947. {
  1948. u32 timing_h, timing_v;
  1949. if (cpu_is_omap24xx() || omap_rev() < OMAP3430_REV_ES3_0) {
  1950. timing_h = FLD_VAL(hsw-1, 5, 0) | FLD_VAL(hfp-1, 15, 8) |
  1951. FLD_VAL(hbp-1, 27, 20);
  1952. timing_v = FLD_VAL(vsw-1, 5, 0) | FLD_VAL(vfp, 15, 8) |
  1953. FLD_VAL(vbp, 27, 20);
  1954. } else {
  1955. timing_h = FLD_VAL(hsw-1, 7, 0) | FLD_VAL(hfp-1, 19, 8) |
  1956. FLD_VAL(hbp-1, 31, 20);
  1957. timing_v = FLD_VAL(vsw-1, 7, 0) | FLD_VAL(vfp, 19, 8) |
  1958. FLD_VAL(vbp, 31, 20);
  1959. }
  1960. dispc_write_reg(DISPC_TIMING_H(channel), timing_h);
  1961. dispc_write_reg(DISPC_TIMING_V(channel), timing_v);
  1962. }
  1963. /* change name to mode? */
  1964. void dispc_mgr_set_lcd_timings(enum omap_channel channel,
  1965. struct omap_video_timings *timings)
  1966. {
  1967. unsigned xtot, ytot;
  1968. unsigned long ht, vt;
  1969. if (!_dispc_lcd_timings_ok(timings->hsw, timings->hfp,
  1970. timings->hbp, timings->vsw,
  1971. timings->vfp, timings->vbp))
  1972. BUG();
  1973. _dispc_mgr_set_lcd_timings(channel, timings->hsw, timings->hfp,
  1974. timings->hbp, timings->vsw, timings->vfp,
  1975. timings->vbp);
  1976. dispc_mgr_set_lcd_size(channel, timings->x_res, timings->y_res);
  1977. xtot = timings->x_res + timings->hfp + timings->hsw + timings->hbp;
  1978. ytot = timings->y_res + timings->vfp + timings->vsw + timings->vbp;
  1979. ht = (timings->pixel_clock * 1000) / xtot;
  1980. vt = (timings->pixel_clock * 1000) / xtot / ytot;
  1981. DSSDBG("channel %d xres %u yres %u\n", channel, timings->x_res,
  1982. timings->y_res);
  1983. DSSDBG("pck %u\n", timings->pixel_clock);
  1984. DSSDBG("hsw %d hfp %d hbp %d vsw %d vfp %d vbp %d\n",
  1985. timings->hsw, timings->hfp, timings->hbp,
  1986. timings->vsw, timings->vfp, timings->vbp);
  1987. DSSDBG("hsync %luHz, vsync %luHz\n", ht, vt);
  1988. }
  1989. static void dispc_mgr_set_lcd_divisor(enum omap_channel channel, u16 lck_div,
  1990. u16 pck_div)
  1991. {
  1992. BUG_ON(lck_div < 1);
  1993. BUG_ON(pck_div < 1);
  1994. dispc_write_reg(DISPC_DIVISORo(channel),
  1995. FLD_VAL(lck_div, 23, 16) | FLD_VAL(pck_div, 7, 0));
  1996. }
  1997. static void dispc_mgr_get_lcd_divisor(enum omap_channel channel, int *lck_div,
  1998. int *pck_div)
  1999. {
  2000. u32 l;
  2001. l = dispc_read_reg(DISPC_DIVISORo(channel));
  2002. *lck_div = FLD_GET(l, 23, 16);
  2003. *pck_div = FLD_GET(l, 7, 0);
  2004. }
  2005. unsigned long dispc_fclk_rate(void)
  2006. {
  2007. struct platform_device *dsidev;
  2008. unsigned long r = 0;
  2009. switch (dss_get_dispc_clk_source()) {
  2010. case OMAP_DSS_CLK_SRC_FCK:
  2011. r = clk_get_rate(dispc.dss_clk);
  2012. break;
  2013. case OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC:
  2014. dsidev = dsi_get_dsidev_from_id(0);
  2015. r = dsi_get_pll_hsdiv_dispc_rate(dsidev);
  2016. break;
  2017. case OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DISPC:
  2018. dsidev = dsi_get_dsidev_from_id(1);
  2019. r = dsi_get_pll_hsdiv_dispc_rate(dsidev);
  2020. break;
  2021. default:
  2022. BUG();
  2023. }
  2024. return r;
  2025. }
  2026. unsigned long dispc_mgr_lclk_rate(enum omap_channel channel)
  2027. {
  2028. struct platform_device *dsidev;
  2029. int lcd;
  2030. unsigned long r;
  2031. u32 l;
  2032. l = dispc_read_reg(DISPC_DIVISORo(channel));
  2033. lcd = FLD_GET(l, 23, 16);
  2034. switch (dss_get_lcd_clk_source(channel)) {
  2035. case OMAP_DSS_CLK_SRC_FCK:
  2036. r = clk_get_rate(dispc.dss_clk);
  2037. break;
  2038. case OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC:
  2039. dsidev = dsi_get_dsidev_from_id(0);
  2040. r = dsi_get_pll_hsdiv_dispc_rate(dsidev);
  2041. break;
  2042. case OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DISPC:
  2043. dsidev = dsi_get_dsidev_from_id(1);
  2044. r = dsi_get_pll_hsdiv_dispc_rate(dsidev);
  2045. break;
  2046. default:
  2047. BUG();
  2048. }
  2049. return r / lcd;
  2050. }
  2051. unsigned long dispc_mgr_pclk_rate(enum omap_channel channel)
  2052. {
  2053. unsigned long r;
  2054. if (dispc_mgr_is_lcd(channel)) {
  2055. int pcd;
  2056. u32 l;
  2057. l = dispc_read_reg(DISPC_DIVISORo(channel));
  2058. pcd = FLD_GET(l, 7, 0);
  2059. r = dispc_mgr_lclk_rate(channel);
  2060. return r / pcd;
  2061. } else {
  2062. struct omap_dss_device *dssdev =
  2063. dispc_mgr_get_device(channel);
  2064. switch (dssdev->type) {
  2065. case OMAP_DISPLAY_TYPE_VENC:
  2066. return venc_get_pixel_clock();
  2067. case OMAP_DISPLAY_TYPE_HDMI:
  2068. return hdmi_get_pixel_clock();
  2069. default:
  2070. BUG();
  2071. }
  2072. }
  2073. }
  2074. void dispc_dump_clocks(struct seq_file *s)
  2075. {
  2076. int lcd, pcd;
  2077. u32 l;
  2078. enum omap_dss_clk_source dispc_clk_src = dss_get_dispc_clk_source();
  2079. enum omap_dss_clk_source lcd_clk_src;
  2080. if (dispc_runtime_get())
  2081. return;
  2082. seq_printf(s, "- DISPC -\n");
  2083. seq_printf(s, "dispc fclk source = %s (%s)\n",
  2084. dss_get_generic_clk_source_name(dispc_clk_src),
  2085. dss_feat_get_clk_source_name(dispc_clk_src));
  2086. seq_printf(s, "fck\t\t%-16lu\n", dispc_fclk_rate());
  2087. if (dss_has_feature(FEAT_CORE_CLK_DIV)) {
  2088. seq_printf(s, "- DISPC-CORE-CLK -\n");
  2089. l = dispc_read_reg(DISPC_DIVISOR);
  2090. lcd = FLD_GET(l, 23, 16);
  2091. seq_printf(s, "lck\t\t%-16lulck div\t%u\n",
  2092. (dispc_fclk_rate()/lcd), lcd);
  2093. }
  2094. seq_printf(s, "- LCD1 -\n");
  2095. lcd_clk_src = dss_get_lcd_clk_source(OMAP_DSS_CHANNEL_LCD);
  2096. seq_printf(s, "lcd1_clk source = %s (%s)\n",
  2097. dss_get_generic_clk_source_name(lcd_clk_src),
  2098. dss_feat_get_clk_source_name(lcd_clk_src));
  2099. dispc_mgr_get_lcd_divisor(OMAP_DSS_CHANNEL_LCD, &lcd, &pcd);
  2100. seq_printf(s, "lck\t\t%-16lulck div\t%u\n",
  2101. dispc_mgr_lclk_rate(OMAP_DSS_CHANNEL_LCD), lcd);
  2102. seq_printf(s, "pck\t\t%-16lupck div\t%u\n",
  2103. dispc_mgr_pclk_rate(OMAP_DSS_CHANNEL_LCD), pcd);
  2104. if (dss_has_feature(FEAT_MGR_LCD2)) {
  2105. seq_printf(s, "- LCD2 -\n");
  2106. lcd_clk_src = dss_get_lcd_clk_source(OMAP_DSS_CHANNEL_LCD2);
  2107. seq_printf(s, "lcd2_clk source = %s (%s)\n",
  2108. dss_get_generic_clk_source_name(lcd_clk_src),
  2109. dss_feat_get_clk_source_name(lcd_clk_src));
  2110. dispc_mgr_get_lcd_divisor(OMAP_DSS_CHANNEL_LCD2, &lcd, &pcd);
  2111. seq_printf(s, "lck\t\t%-16lulck div\t%u\n",
  2112. dispc_mgr_lclk_rate(OMAP_DSS_CHANNEL_LCD2), lcd);
  2113. seq_printf(s, "pck\t\t%-16lupck div\t%u\n",
  2114. dispc_mgr_pclk_rate(OMAP_DSS_CHANNEL_LCD2), pcd);
  2115. }
  2116. dispc_runtime_put();
  2117. }
  2118. #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
  2119. void dispc_dump_irqs(struct seq_file *s)
  2120. {
  2121. unsigned long flags;
  2122. struct dispc_irq_stats stats;
  2123. spin_lock_irqsave(&dispc.irq_stats_lock, flags);
  2124. stats = dispc.irq_stats;
  2125. memset(&dispc.irq_stats, 0, sizeof(dispc.irq_stats));
  2126. dispc.irq_stats.last_reset = jiffies;
  2127. spin_unlock_irqrestore(&dispc.irq_stats_lock, flags);
  2128. seq_printf(s, "period %u ms\n",
  2129. jiffies_to_msecs(jiffies - stats.last_reset));
  2130. seq_printf(s, "irqs %d\n", stats.irq_count);
  2131. #define PIS(x) \
  2132. seq_printf(s, "%-20s %10d\n", #x, stats.irqs[ffs(DISPC_IRQ_##x)-1]);
  2133. PIS(FRAMEDONE);
  2134. PIS(VSYNC);
  2135. PIS(EVSYNC_EVEN);
  2136. PIS(EVSYNC_ODD);
  2137. PIS(ACBIAS_COUNT_STAT);
  2138. PIS(PROG_LINE_NUM);
  2139. PIS(GFX_FIFO_UNDERFLOW);
  2140. PIS(GFX_END_WIN);
  2141. PIS(PAL_GAMMA_MASK);
  2142. PIS(OCP_ERR);
  2143. PIS(VID1_FIFO_UNDERFLOW);
  2144. PIS(VID1_END_WIN);
  2145. PIS(VID2_FIFO_UNDERFLOW);
  2146. PIS(VID2_END_WIN);
  2147. if (dss_feat_get_num_ovls() > 3) {
  2148. PIS(VID3_FIFO_UNDERFLOW);
  2149. PIS(VID3_END_WIN);
  2150. }
  2151. PIS(SYNC_LOST);
  2152. PIS(SYNC_LOST_DIGIT);
  2153. PIS(WAKEUP);
  2154. if (dss_has_feature(FEAT_MGR_LCD2)) {
  2155. PIS(FRAMEDONE2);
  2156. PIS(VSYNC2);
  2157. PIS(ACBIAS_COUNT_STAT2);
  2158. PIS(SYNC_LOST2);
  2159. }
  2160. #undef PIS
  2161. }
  2162. #endif
  2163. void dispc_dump_regs(struct seq_file *s)
  2164. {
  2165. int i, j;
  2166. const char *mgr_names[] = {
  2167. [OMAP_DSS_CHANNEL_LCD] = "LCD",
  2168. [OMAP_DSS_CHANNEL_DIGIT] = "TV",
  2169. [OMAP_DSS_CHANNEL_LCD2] = "LCD2",
  2170. };
  2171. const char *ovl_names[] = {
  2172. [OMAP_DSS_GFX] = "GFX",
  2173. [OMAP_DSS_VIDEO1] = "VID1",
  2174. [OMAP_DSS_VIDEO2] = "VID2",
  2175. [OMAP_DSS_VIDEO3] = "VID3",
  2176. };
  2177. const char **p_names;
  2178. #define DUMPREG(r) seq_printf(s, "%-50s %08x\n", #r, dispc_read_reg(r))
  2179. if (dispc_runtime_get())
  2180. return;
  2181. /* DISPC common registers */
  2182. DUMPREG(DISPC_REVISION);
  2183. DUMPREG(DISPC_SYSCONFIG);
  2184. DUMPREG(DISPC_SYSSTATUS);
  2185. DUMPREG(DISPC_IRQSTATUS);
  2186. DUMPREG(DISPC_IRQENABLE);
  2187. DUMPREG(DISPC_CONTROL);
  2188. DUMPREG(DISPC_CONFIG);
  2189. DUMPREG(DISPC_CAPABLE);
  2190. DUMPREG(DISPC_LINE_STATUS);
  2191. DUMPREG(DISPC_LINE_NUMBER);
  2192. if (dss_has_feature(FEAT_ALPHA_FIXED_ZORDER) ||
  2193. dss_has_feature(FEAT_ALPHA_FREE_ZORDER))
  2194. DUMPREG(DISPC_GLOBAL_ALPHA);
  2195. if (dss_has_feature(FEAT_MGR_LCD2)) {
  2196. DUMPREG(DISPC_CONTROL2);
  2197. DUMPREG(DISPC_CONFIG2);
  2198. }
  2199. #undef DUMPREG
  2200. #define DISPC_REG(i, name) name(i)
  2201. #define DUMPREG(i, r) seq_printf(s, "%s(%s)%*s %08x\n", #r, p_names[i], \
  2202. 48 - strlen(#r) - strlen(p_names[i]), " ", \
  2203. dispc_read_reg(DISPC_REG(i, r)))
  2204. p_names = mgr_names;
  2205. /* DISPC channel specific registers */
  2206. for (i = 0; i < dss_feat_get_num_mgrs(); i++) {
  2207. DUMPREG(i, DISPC_DEFAULT_COLOR);
  2208. DUMPREG(i, DISPC_TRANS_COLOR);
  2209. DUMPREG(i, DISPC_SIZE_MGR);
  2210. if (i == OMAP_DSS_CHANNEL_DIGIT)
  2211. continue;
  2212. DUMPREG(i, DISPC_DEFAULT_COLOR);
  2213. DUMPREG(i, DISPC_TRANS_COLOR);
  2214. DUMPREG(i, DISPC_TIMING_H);
  2215. DUMPREG(i, DISPC_TIMING_V);
  2216. DUMPREG(i, DISPC_POL_FREQ);
  2217. DUMPREG(i, DISPC_DIVISORo);
  2218. DUMPREG(i, DISPC_SIZE_MGR);
  2219. DUMPREG(i, DISPC_DATA_CYCLE1);
  2220. DUMPREG(i, DISPC_DATA_CYCLE2);
  2221. DUMPREG(i, DISPC_DATA_CYCLE3);
  2222. if (dss_has_feature(FEAT_CPR)) {
  2223. DUMPREG(i, DISPC_CPR_COEF_R);
  2224. DUMPREG(i, DISPC_CPR_COEF_G);
  2225. DUMPREG(i, DISPC_CPR_COEF_B);
  2226. }
  2227. }
  2228. p_names = ovl_names;
  2229. for (i = 0; i < dss_feat_get_num_ovls(); i++) {
  2230. DUMPREG(i, DISPC_OVL_BA0);
  2231. DUMPREG(i, DISPC_OVL_BA1);
  2232. DUMPREG(i, DISPC_OVL_POSITION);
  2233. DUMPREG(i, DISPC_OVL_SIZE);
  2234. DUMPREG(i, DISPC_OVL_ATTRIBUTES);
  2235. DUMPREG(i, DISPC_OVL_FIFO_THRESHOLD);
  2236. DUMPREG(i, DISPC_OVL_FIFO_SIZE_STATUS);
  2237. DUMPREG(i, DISPC_OVL_ROW_INC);
  2238. DUMPREG(i, DISPC_OVL_PIXEL_INC);
  2239. if (dss_has_feature(FEAT_PRELOAD))
  2240. DUMPREG(i, DISPC_OVL_PRELOAD);
  2241. if (i == OMAP_DSS_GFX) {
  2242. DUMPREG(i, DISPC_OVL_WINDOW_SKIP);
  2243. DUMPREG(i, DISPC_OVL_TABLE_BA);
  2244. continue;
  2245. }
  2246. DUMPREG(i, DISPC_OVL_FIR);
  2247. DUMPREG(i, DISPC_OVL_PICTURE_SIZE);
  2248. DUMPREG(i, DISPC_OVL_ACCU0);
  2249. DUMPREG(i, DISPC_OVL_ACCU1);
  2250. if (dss_has_feature(FEAT_HANDLE_UV_SEPARATE)) {
  2251. DUMPREG(i, DISPC_OVL_BA0_UV);
  2252. DUMPREG(i, DISPC_OVL_BA1_UV);
  2253. DUMPREG(i, DISPC_OVL_FIR2);
  2254. DUMPREG(i, DISPC_OVL_ACCU2_0);
  2255. DUMPREG(i, DISPC_OVL_ACCU2_1);
  2256. }
  2257. if (dss_has_feature(FEAT_ATTR2))
  2258. DUMPREG(i, DISPC_OVL_ATTRIBUTES2);
  2259. if (dss_has_feature(FEAT_PRELOAD))
  2260. DUMPREG(i, DISPC_OVL_PRELOAD);
  2261. }
  2262. #undef DISPC_REG
  2263. #undef DUMPREG
  2264. #define DISPC_REG(plane, name, i) name(plane, i)
  2265. #define DUMPREG(plane, name, i) \
  2266. seq_printf(s, "%s_%d(%s)%*s %08x\n", #name, i, p_names[plane], \
  2267. 46 - strlen(#name) - strlen(p_names[plane]), " ", \
  2268. dispc_read_reg(DISPC_REG(plane, name, i)))
  2269. /* Video pipeline coefficient registers */
  2270. /* start from OMAP_DSS_VIDEO1 */
  2271. for (i = 1; i < dss_feat_get_num_ovls(); i++) {
  2272. for (j = 0; j < 8; j++)
  2273. DUMPREG(i, DISPC_OVL_FIR_COEF_H, j);
  2274. for (j = 0; j < 8; j++)
  2275. DUMPREG(i, DISPC_OVL_FIR_COEF_HV, j);
  2276. for (j = 0; j < 5; j++)
  2277. DUMPREG(i, DISPC_OVL_CONV_COEF, j);
  2278. if (dss_has_feature(FEAT_FIR_COEF_V)) {
  2279. for (j = 0; j < 8; j++)
  2280. DUMPREG(i, DISPC_OVL_FIR_COEF_V, j);
  2281. }
  2282. if (dss_has_feature(FEAT_HANDLE_UV_SEPARATE)) {
  2283. for (j = 0; j < 8; j++)
  2284. DUMPREG(i, DISPC_OVL_FIR_COEF_H2, j);
  2285. for (j = 0; j < 8; j++)
  2286. DUMPREG(i, DISPC_OVL_FIR_COEF_HV2, j);
  2287. for (j = 0; j < 8; j++)
  2288. DUMPREG(i, DISPC_OVL_FIR_COEF_V2, j);
  2289. }
  2290. }
  2291. dispc_runtime_put();
  2292. #undef DISPC_REG
  2293. #undef DUMPREG
  2294. }
  2295. static void _dispc_mgr_set_pol_freq(enum omap_channel channel, bool onoff,
  2296. bool rf, bool ieo, bool ipc, bool ihs, bool ivs, u8 acbi,
  2297. u8 acb)
  2298. {
  2299. u32 l = 0;
  2300. DSSDBG("onoff %d rf %d ieo %d ipc %d ihs %d ivs %d acbi %d acb %d\n",
  2301. onoff, rf, ieo, ipc, ihs, ivs, acbi, acb);
  2302. l |= FLD_VAL(onoff, 17, 17);
  2303. l |= FLD_VAL(rf, 16, 16);
  2304. l |= FLD_VAL(ieo, 15, 15);
  2305. l |= FLD_VAL(ipc, 14, 14);
  2306. l |= FLD_VAL(ihs, 13, 13);
  2307. l |= FLD_VAL(ivs, 12, 12);
  2308. l |= FLD_VAL(acbi, 11, 8);
  2309. l |= FLD_VAL(acb, 7, 0);
  2310. dispc_write_reg(DISPC_POL_FREQ(channel), l);
  2311. }
  2312. void dispc_mgr_set_pol_freq(enum omap_channel channel,
  2313. enum omap_panel_config config, u8 acbi, u8 acb)
  2314. {
  2315. _dispc_mgr_set_pol_freq(channel, (config & OMAP_DSS_LCD_ONOFF) != 0,
  2316. (config & OMAP_DSS_LCD_RF) != 0,
  2317. (config & OMAP_DSS_LCD_IEO) != 0,
  2318. (config & OMAP_DSS_LCD_IPC) != 0,
  2319. (config & OMAP_DSS_LCD_IHS) != 0,
  2320. (config & OMAP_DSS_LCD_IVS) != 0,
  2321. acbi, acb);
  2322. }
  2323. /* with fck as input clock rate, find dispc dividers that produce req_pck */
  2324. void dispc_find_clk_divs(bool is_tft, unsigned long req_pck, unsigned long fck,
  2325. struct dispc_clock_info *cinfo)
  2326. {
  2327. u16 pcd_min, pcd_max;
  2328. unsigned long best_pck;
  2329. u16 best_ld, cur_ld;
  2330. u16 best_pd, cur_pd;
  2331. pcd_min = dss_feat_get_param_min(FEAT_PARAM_DSS_PCD);
  2332. pcd_max = dss_feat_get_param_max(FEAT_PARAM_DSS_PCD);
  2333. if (!is_tft)
  2334. pcd_min = 3;
  2335. best_pck = 0;
  2336. best_ld = 0;
  2337. best_pd = 0;
  2338. for (cur_ld = 1; cur_ld <= 255; ++cur_ld) {
  2339. unsigned long lck = fck / cur_ld;
  2340. for (cur_pd = pcd_min; cur_pd <= pcd_max; ++cur_pd) {
  2341. unsigned long pck = lck / cur_pd;
  2342. long old_delta = abs(best_pck - req_pck);
  2343. long new_delta = abs(pck - req_pck);
  2344. if (best_pck == 0 || new_delta < old_delta) {
  2345. best_pck = pck;
  2346. best_ld = cur_ld;
  2347. best_pd = cur_pd;
  2348. if (pck == req_pck)
  2349. goto found;
  2350. }
  2351. if (pck < req_pck)
  2352. break;
  2353. }
  2354. if (lck / pcd_min < req_pck)
  2355. break;
  2356. }
  2357. found:
  2358. cinfo->lck_div = best_ld;
  2359. cinfo->pck_div = best_pd;
  2360. cinfo->lck = fck / cinfo->lck_div;
  2361. cinfo->pck = cinfo->lck / cinfo->pck_div;
  2362. }
  2363. /* calculate clock rates using dividers in cinfo */
  2364. int dispc_calc_clock_rates(unsigned long dispc_fclk_rate,
  2365. struct dispc_clock_info *cinfo)
  2366. {
  2367. if (cinfo->lck_div > 255 || cinfo->lck_div == 0)
  2368. return -EINVAL;
  2369. if (cinfo->pck_div < 1 || cinfo->pck_div > 255)
  2370. return -EINVAL;
  2371. cinfo->lck = dispc_fclk_rate / cinfo->lck_div;
  2372. cinfo->pck = cinfo->lck / cinfo->pck_div;
  2373. return 0;
  2374. }
  2375. int dispc_mgr_set_clock_div(enum omap_channel channel,
  2376. struct dispc_clock_info *cinfo)
  2377. {
  2378. DSSDBG("lck = %lu (%u)\n", cinfo->lck, cinfo->lck_div);
  2379. DSSDBG("pck = %lu (%u)\n", cinfo->pck, cinfo->pck_div);
  2380. dispc_mgr_set_lcd_divisor(channel, cinfo->lck_div, cinfo->pck_div);
  2381. return 0;
  2382. }
  2383. int dispc_mgr_get_clock_div(enum omap_channel channel,
  2384. struct dispc_clock_info *cinfo)
  2385. {
  2386. unsigned long fck;
  2387. fck = dispc_fclk_rate();
  2388. cinfo->lck_div = REG_GET(DISPC_DIVISORo(channel), 23, 16);
  2389. cinfo->pck_div = REG_GET(DISPC_DIVISORo(channel), 7, 0);
  2390. cinfo->lck = fck / cinfo->lck_div;
  2391. cinfo->pck = cinfo->lck / cinfo->pck_div;
  2392. return 0;
  2393. }
  2394. /* dispc.irq_lock has to be locked by the caller */
  2395. static void _omap_dispc_set_irqs(void)
  2396. {
  2397. u32 mask;
  2398. u32 old_mask;
  2399. int i;
  2400. struct omap_dispc_isr_data *isr_data;
  2401. mask = dispc.irq_error_mask;
  2402. for (i = 0; i < DISPC_MAX_NR_ISRS; i++) {
  2403. isr_data = &dispc.registered_isr[i];
  2404. if (isr_data->isr == NULL)
  2405. continue;
  2406. mask |= isr_data->mask;
  2407. }
  2408. old_mask = dispc_read_reg(DISPC_IRQENABLE);
  2409. /* clear the irqstatus for newly enabled irqs */
  2410. dispc_write_reg(DISPC_IRQSTATUS, (mask ^ old_mask) & mask);
  2411. dispc_write_reg(DISPC_IRQENABLE, mask);
  2412. }
  2413. int omap_dispc_register_isr(omap_dispc_isr_t isr, void *arg, u32 mask)
  2414. {
  2415. int i;
  2416. int ret;
  2417. unsigned long flags;
  2418. struct omap_dispc_isr_data *isr_data;
  2419. if (isr == NULL)
  2420. return -EINVAL;
  2421. spin_lock_irqsave(&dispc.irq_lock, flags);
  2422. /* check for duplicate entry */
  2423. for (i = 0; i < DISPC_MAX_NR_ISRS; i++) {
  2424. isr_data = &dispc.registered_isr[i];
  2425. if (isr_data->isr == isr && isr_data->arg == arg &&
  2426. isr_data->mask == mask) {
  2427. ret = -EINVAL;
  2428. goto err;
  2429. }
  2430. }
  2431. isr_data = NULL;
  2432. ret = -EBUSY;
  2433. for (i = 0; i < DISPC_MAX_NR_ISRS; i++) {
  2434. isr_data = &dispc.registered_isr[i];
  2435. if (isr_data->isr != NULL)
  2436. continue;
  2437. isr_data->isr = isr;
  2438. isr_data->arg = arg;
  2439. isr_data->mask = mask;
  2440. ret = 0;
  2441. break;
  2442. }
  2443. if (ret)
  2444. goto err;
  2445. _omap_dispc_set_irqs();
  2446. spin_unlock_irqrestore(&dispc.irq_lock, flags);
  2447. return 0;
  2448. err:
  2449. spin_unlock_irqrestore(&dispc.irq_lock, flags);
  2450. return ret;
  2451. }
  2452. EXPORT_SYMBOL(omap_dispc_register_isr);
  2453. int omap_dispc_unregister_isr(omap_dispc_isr_t isr, void *arg, u32 mask)
  2454. {
  2455. int i;
  2456. unsigned long flags;
  2457. int ret = -EINVAL;
  2458. struct omap_dispc_isr_data *isr_data;
  2459. spin_lock_irqsave(&dispc.irq_lock, flags);
  2460. for (i = 0; i < DISPC_MAX_NR_ISRS; i++) {
  2461. isr_data = &dispc.registered_isr[i];
  2462. if (isr_data->isr != isr || isr_data->arg != arg ||
  2463. isr_data->mask != mask)
  2464. continue;
  2465. /* found the correct isr */
  2466. isr_data->isr = NULL;
  2467. isr_data->arg = NULL;
  2468. isr_data->mask = 0;
  2469. ret = 0;
  2470. break;
  2471. }
  2472. if (ret == 0)
  2473. _omap_dispc_set_irqs();
  2474. spin_unlock_irqrestore(&dispc.irq_lock, flags);
  2475. return ret;
  2476. }
  2477. EXPORT_SYMBOL(omap_dispc_unregister_isr);
  2478. #ifdef DEBUG
  2479. static void print_irq_status(u32 status)
  2480. {
  2481. if ((status & dispc.irq_error_mask) == 0)
  2482. return;
  2483. printk(KERN_DEBUG "DISPC IRQ: 0x%x: ", status);
  2484. #define PIS(x) \
  2485. if (status & DISPC_IRQ_##x) \
  2486. printk(#x " ");
  2487. PIS(GFX_FIFO_UNDERFLOW);
  2488. PIS(OCP_ERR);
  2489. PIS(VID1_FIFO_UNDERFLOW);
  2490. PIS(VID2_FIFO_UNDERFLOW);
  2491. if (dss_feat_get_num_ovls() > 3)
  2492. PIS(VID3_FIFO_UNDERFLOW);
  2493. PIS(SYNC_LOST);
  2494. PIS(SYNC_LOST_DIGIT);
  2495. if (dss_has_feature(FEAT_MGR_LCD2))
  2496. PIS(SYNC_LOST2);
  2497. #undef PIS
  2498. printk("\n");
  2499. }
  2500. #endif
  2501. /* Called from dss.c. Note that we don't touch clocks here,
  2502. * but we presume they are on because we got an IRQ. However,
  2503. * an irq handler may turn the clocks off, so we may not have
  2504. * clock later in the function. */
  2505. static irqreturn_t omap_dispc_irq_handler(int irq, void *arg)
  2506. {
  2507. int i;
  2508. u32 irqstatus, irqenable;
  2509. u32 handledirqs = 0;
  2510. u32 unhandled_errors;
  2511. struct omap_dispc_isr_data *isr_data;
  2512. struct omap_dispc_isr_data registered_isr[DISPC_MAX_NR_ISRS];
  2513. spin_lock(&dispc.irq_lock);
  2514. irqstatus = dispc_read_reg(DISPC_IRQSTATUS);
  2515. irqenable = dispc_read_reg(DISPC_IRQENABLE);
  2516. /* IRQ is not for us */
  2517. if (!(irqstatus & irqenable)) {
  2518. spin_unlock(&dispc.irq_lock);
  2519. return IRQ_NONE;
  2520. }
  2521. #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
  2522. spin_lock(&dispc.irq_stats_lock);
  2523. dispc.irq_stats.irq_count++;
  2524. dss_collect_irq_stats(irqstatus, dispc.irq_stats.irqs);
  2525. spin_unlock(&dispc.irq_stats_lock);
  2526. #endif
  2527. #ifdef DEBUG
  2528. if (dss_debug)
  2529. print_irq_status(irqstatus);
  2530. #endif
  2531. /* Ack the interrupt. Do it here before clocks are possibly turned
  2532. * off */
  2533. dispc_write_reg(DISPC_IRQSTATUS, irqstatus);
  2534. /* flush posted write */
  2535. dispc_read_reg(DISPC_IRQSTATUS);
  2536. /* make a copy and unlock, so that isrs can unregister
  2537. * themselves */
  2538. memcpy(registered_isr, dispc.registered_isr,
  2539. sizeof(registered_isr));
  2540. spin_unlock(&dispc.irq_lock);
  2541. for (i = 0; i < DISPC_MAX_NR_ISRS; i++) {
  2542. isr_data = &registered_isr[i];
  2543. if (!isr_data->isr)
  2544. continue;
  2545. if (isr_data->mask & irqstatus) {
  2546. isr_data->isr(isr_data->arg, irqstatus);
  2547. handledirqs |= isr_data->mask;
  2548. }
  2549. }
  2550. spin_lock(&dispc.irq_lock);
  2551. unhandled_errors = irqstatus & ~handledirqs & dispc.irq_error_mask;
  2552. if (unhandled_errors) {
  2553. dispc.error_irqs |= unhandled_errors;
  2554. dispc.irq_error_mask &= ~unhandled_errors;
  2555. _omap_dispc_set_irqs();
  2556. schedule_work(&dispc.error_work);
  2557. }
  2558. spin_unlock(&dispc.irq_lock);
  2559. return IRQ_HANDLED;
  2560. }
  2561. static void dispc_error_worker(struct work_struct *work)
  2562. {
  2563. int i;
  2564. u32 errors;
  2565. unsigned long flags;
  2566. static const unsigned fifo_underflow_bits[] = {
  2567. DISPC_IRQ_GFX_FIFO_UNDERFLOW,
  2568. DISPC_IRQ_VID1_FIFO_UNDERFLOW,
  2569. DISPC_IRQ_VID2_FIFO_UNDERFLOW,
  2570. DISPC_IRQ_VID3_FIFO_UNDERFLOW,
  2571. };
  2572. static const unsigned sync_lost_bits[] = {
  2573. DISPC_IRQ_SYNC_LOST,
  2574. DISPC_IRQ_SYNC_LOST_DIGIT,
  2575. DISPC_IRQ_SYNC_LOST2,
  2576. };
  2577. spin_lock_irqsave(&dispc.irq_lock, flags);
  2578. errors = dispc.error_irqs;
  2579. dispc.error_irqs = 0;
  2580. spin_unlock_irqrestore(&dispc.irq_lock, flags);
  2581. dispc_runtime_get();
  2582. for (i = 0; i < omap_dss_get_num_overlays(); ++i) {
  2583. struct omap_overlay *ovl;
  2584. unsigned bit;
  2585. ovl = omap_dss_get_overlay(i);
  2586. bit = fifo_underflow_bits[i];
  2587. if (bit & errors) {
  2588. DSSERR("FIFO UNDERFLOW on %s, disabling the overlay\n",
  2589. ovl->name);
  2590. dispc_ovl_enable(ovl->id, false);
  2591. dispc_mgr_go(ovl->manager->id);
  2592. mdelay(50);
  2593. }
  2594. }
  2595. for (i = 0; i < omap_dss_get_num_overlay_managers(); ++i) {
  2596. struct omap_overlay_manager *mgr;
  2597. unsigned bit;
  2598. mgr = omap_dss_get_overlay_manager(i);
  2599. bit = sync_lost_bits[i];
  2600. if (bit & errors) {
  2601. struct omap_dss_device *dssdev = mgr->device;
  2602. bool enable;
  2603. DSSERR("SYNC_LOST on channel %s, restarting the output "
  2604. "with video overlays disabled\n",
  2605. mgr->name);
  2606. enable = dssdev->state == OMAP_DSS_DISPLAY_ACTIVE;
  2607. dssdev->driver->disable(dssdev);
  2608. for (i = 0; i < omap_dss_get_num_overlays(); ++i) {
  2609. struct omap_overlay *ovl;
  2610. ovl = omap_dss_get_overlay(i);
  2611. if (ovl->id != OMAP_DSS_GFX &&
  2612. ovl->manager == mgr)
  2613. dispc_ovl_enable(ovl->id, false);
  2614. }
  2615. dispc_mgr_go(mgr->id);
  2616. mdelay(50);
  2617. if (enable)
  2618. dssdev->driver->enable(dssdev);
  2619. }
  2620. }
  2621. if (errors & DISPC_IRQ_OCP_ERR) {
  2622. DSSERR("OCP_ERR\n");
  2623. for (i = 0; i < omap_dss_get_num_overlay_managers(); ++i) {
  2624. struct omap_overlay_manager *mgr;
  2625. mgr = omap_dss_get_overlay_manager(i);
  2626. if (mgr->device && mgr->device->driver)
  2627. mgr->device->driver->disable(mgr->device);
  2628. }
  2629. }
  2630. spin_lock_irqsave(&dispc.irq_lock, flags);
  2631. dispc.irq_error_mask |= errors;
  2632. _omap_dispc_set_irqs();
  2633. spin_unlock_irqrestore(&dispc.irq_lock, flags);
  2634. dispc_runtime_put();
  2635. }
  2636. int omap_dispc_wait_for_irq_timeout(u32 irqmask, unsigned long timeout)
  2637. {
  2638. void dispc_irq_wait_handler(void *data, u32 mask)
  2639. {
  2640. complete((struct completion *)data);
  2641. }
  2642. int r;
  2643. DECLARE_COMPLETION_ONSTACK(completion);
  2644. r = omap_dispc_register_isr(dispc_irq_wait_handler, &completion,
  2645. irqmask);
  2646. if (r)
  2647. return r;
  2648. timeout = wait_for_completion_timeout(&completion, timeout);
  2649. omap_dispc_unregister_isr(dispc_irq_wait_handler, &completion, irqmask);
  2650. if (timeout == 0)
  2651. return -ETIMEDOUT;
  2652. if (timeout == -ERESTARTSYS)
  2653. return -ERESTARTSYS;
  2654. return 0;
  2655. }
  2656. int omap_dispc_wait_for_irq_interruptible_timeout(u32 irqmask,
  2657. unsigned long timeout)
  2658. {
  2659. void dispc_irq_wait_handler(void *data, u32 mask)
  2660. {
  2661. complete((struct completion *)data);
  2662. }
  2663. int r;
  2664. DECLARE_COMPLETION_ONSTACK(completion);
  2665. r = omap_dispc_register_isr(dispc_irq_wait_handler, &completion,
  2666. irqmask);
  2667. if (r)
  2668. return r;
  2669. timeout = wait_for_completion_interruptible_timeout(&completion,
  2670. timeout);
  2671. omap_dispc_unregister_isr(dispc_irq_wait_handler, &completion, irqmask);
  2672. if (timeout == 0)
  2673. return -ETIMEDOUT;
  2674. if (timeout == -ERESTARTSYS)
  2675. return -ERESTARTSYS;
  2676. return 0;
  2677. }
  2678. #ifdef CONFIG_OMAP2_DSS_FAKE_VSYNC
  2679. void dispc_fake_vsync_irq(void)
  2680. {
  2681. u32 irqstatus = DISPC_IRQ_VSYNC;
  2682. int i;
  2683. WARN_ON(!in_interrupt());
  2684. for (i = 0; i < DISPC_MAX_NR_ISRS; i++) {
  2685. struct omap_dispc_isr_data *isr_data;
  2686. isr_data = &dispc.registered_isr[i];
  2687. if (!isr_data->isr)
  2688. continue;
  2689. if (isr_data->mask & irqstatus)
  2690. isr_data->isr(isr_data->arg, irqstatus);
  2691. }
  2692. }
  2693. #endif
  2694. static void _omap_dispc_initialize_irq(void)
  2695. {
  2696. unsigned long flags;
  2697. spin_lock_irqsave(&dispc.irq_lock, flags);
  2698. memset(dispc.registered_isr, 0, sizeof(dispc.registered_isr));
  2699. dispc.irq_error_mask = DISPC_IRQ_MASK_ERROR;
  2700. if (dss_has_feature(FEAT_MGR_LCD2))
  2701. dispc.irq_error_mask |= DISPC_IRQ_SYNC_LOST2;
  2702. if (dss_feat_get_num_ovls() > 3)
  2703. dispc.irq_error_mask |= DISPC_IRQ_VID3_FIFO_UNDERFLOW;
  2704. /* there's SYNC_LOST_DIGIT waiting after enabling the DSS,
  2705. * so clear it */
  2706. dispc_write_reg(DISPC_IRQSTATUS, dispc_read_reg(DISPC_IRQSTATUS));
  2707. _omap_dispc_set_irqs();
  2708. spin_unlock_irqrestore(&dispc.irq_lock, flags);
  2709. }
  2710. void dispc_enable_sidle(void)
  2711. {
  2712. REG_FLD_MOD(DISPC_SYSCONFIG, 2, 4, 3); /* SIDLEMODE: smart idle */
  2713. }
  2714. void dispc_disable_sidle(void)
  2715. {
  2716. REG_FLD_MOD(DISPC_SYSCONFIG, 1, 4, 3); /* SIDLEMODE: no idle */
  2717. }
  2718. static void _omap_dispc_initial_config(void)
  2719. {
  2720. u32 l;
  2721. /* Exclusively enable DISPC_CORE_CLK and set divider to 1 */
  2722. if (dss_has_feature(FEAT_CORE_CLK_DIV)) {
  2723. l = dispc_read_reg(DISPC_DIVISOR);
  2724. /* Use DISPC_DIVISOR.LCD, instead of DISPC_DIVISOR1.LCD */
  2725. l = FLD_MOD(l, 1, 0, 0);
  2726. l = FLD_MOD(l, 1, 23, 16);
  2727. dispc_write_reg(DISPC_DIVISOR, l);
  2728. }
  2729. /* FUNCGATED */
  2730. if (dss_has_feature(FEAT_FUNCGATED))
  2731. REG_FLD_MOD(DISPC_CONFIG, 1, 9, 9);
  2732. /* L3 firewall setting: enable access to OCM RAM */
  2733. /* XXX this should be somewhere in plat-omap */
  2734. if (cpu_is_omap24xx())
  2735. __raw_writel(0x402000b0, OMAP2_L3_IO_ADDRESS(0x680050a0));
  2736. _dispc_setup_color_conv_coef();
  2737. dispc_set_loadmode(OMAP_DSS_LOAD_FRAME_ONLY);
  2738. dispc_read_plane_fifo_sizes();
  2739. dispc_configure_burst_sizes();
  2740. dispc_ovl_enable_zorder_planes();
  2741. }
  2742. /* DISPC HW IP initialisation */
  2743. static int omap_dispchw_probe(struct platform_device *pdev)
  2744. {
  2745. u32 rev;
  2746. int r = 0;
  2747. struct resource *dispc_mem;
  2748. struct clk *clk;
  2749. dispc.pdev = pdev;
  2750. spin_lock_init(&dispc.irq_lock);
  2751. #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
  2752. spin_lock_init(&dispc.irq_stats_lock);
  2753. dispc.irq_stats.last_reset = jiffies;
  2754. #endif
  2755. INIT_WORK(&dispc.error_work, dispc_error_worker);
  2756. dispc_mem = platform_get_resource(dispc.pdev, IORESOURCE_MEM, 0);
  2757. if (!dispc_mem) {
  2758. DSSERR("can't get IORESOURCE_MEM DISPC\n");
  2759. return -EINVAL;
  2760. }
  2761. dispc.base = devm_ioremap(&pdev->dev, dispc_mem->start,
  2762. resource_size(dispc_mem));
  2763. if (!dispc.base) {
  2764. DSSERR("can't ioremap DISPC\n");
  2765. return -ENOMEM;
  2766. }
  2767. dispc.irq = platform_get_irq(dispc.pdev, 0);
  2768. if (dispc.irq < 0) {
  2769. DSSERR("platform_get_irq failed\n");
  2770. return -ENODEV;
  2771. }
  2772. r = devm_request_irq(&pdev->dev, dispc.irq, omap_dispc_irq_handler,
  2773. IRQF_SHARED, "OMAP DISPC", dispc.pdev);
  2774. if (r < 0) {
  2775. DSSERR("request_irq failed\n");
  2776. return r;
  2777. }
  2778. clk = clk_get(&pdev->dev, "fck");
  2779. if (IS_ERR(clk)) {
  2780. DSSERR("can't get fck\n");
  2781. r = PTR_ERR(clk);
  2782. return r;
  2783. }
  2784. dispc.dss_clk = clk;
  2785. pm_runtime_enable(&pdev->dev);
  2786. r = dispc_runtime_get();
  2787. if (r)
  2788. goto err_runtime_get;
  2789. _omap_dispc_initial_config();
  2790. _omap_dispc_initialize_irq();
  2791. rev = dispc_read_reg(DISPC_REVISION);
  2792. dev_dbg(&pdev->dev, "OMAP DISPC rev %d.%d\n",
  2793. FLD_GET(rev, 7, 4), FLD_GET(rev, 3, 0));
  2794. dispc_runtime_put();
  2795. return 0;
  2796. err_runtime_get:
  2797. pm_runtime_disable(&pdev->dev);
  2798. clk_put(dispc.dss_clk);
  2799. return r;
  2800. }
  2801. static int omap_dispchw_remove(struct platform_device *pdev)
  2802. {
  2803. pm_runtime_disable(&pdev->dev);
  2804. clk_put(dispc.dss_clk);
  2805. return 0;
  2806. }
  2807. static int dispc_runtime_suspend(struct device *dev)
  2808. {
  2809. dispc_save_context();
  2810. dss_runtime_put();
  2811. return 0;
  2812. }
  2813. static int dispc_runtime_resume(struct device *dev)
  2814. {
  2815. int r;
  2816. r = dss_runtime_get();
  2817. if (r < 0)
  2818. return r;
  2819. dispc_restore_context();
  2820. return 0;
  2821. }
  2822. static const struct dev_pm_ops dispc_pm_ops = {
  2823. .runtime_suspend = dispc_runtime_suspend,
  2824. .runtime_resume = dispc_runtime_resume,
  2825. };
  2826. static struct platform_driver omap_dispchw_driver = {
  2827. .probe = omap_dispchw_probe,
  2828. .remove = omap_dispchw_remove,
  2829. .driver = {
  2830. .name = "omapdss_dispc",
  2831. .owner = THIS_MODULE,
  2832. .pm = &dispc_pm_ops,
  2833. },
  2834. };
  2835. int dispc_init_platform_driver(void)
  2836. {
  2837. return platform_driver_register(&omap_dispchw_driver);
  2838. }
  2839. void dispc_uninit_platform_driver(void)
  2840. {
  2841. return platform_driver_unregister(&omap_dispchw_driver);
  2842. }