auofb.c 100 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777
  1. /*
  2. * linux/drivers/video/auofb.c -- for AUO epaper frame buffer device
  3. *
  4. * Modified by Ivan.Ruan
  5. *
  6. * Created 2009/04/01 by Ivan.Ruan
  7. *
  8. *
  9. *
  10. */
  11. #include <linux/module.h>
  12. #include <linux/kernel.h>
  13. #include <linux/errno.h>
  14. #include <linux/string.h>
  15. #include <linux/mm.h>
  16. #include <linux/tty.h>
  17. #include <linux/slab.h>
  18. #include <linux/delay.h>
  19. #include <linux/fb.h>
  20. #include <linux/init.h>
  21. #include <linux/dma-mapping.h>
  22. #include <linux/string.h>
  23. #include <linux/ioctl.h>
  24. #include <linux/platform_device.h>
  25. #include <linux/clk.h>
  26. #include <linux/freezer.h>
  27. #include <asm/io.h>
  28. #include <asm/uaccess.h>
  29. #include <asm/div64.h>
  30. #include <linux/auofb_ioctl.h>
  31. //#include <asm/mach/map.h>
  32. #include <asm/arch/regs-lcd.h>
  33. #include <asm/arch/regs-gpio.h>
  34. #include <asm/arch/regs-timer.h>
  35. #include <asm/arch/regs-watchdog.h>
  36. #include <asm/arch/idle.h>
  37. #include <asm/arch/regs-s3c2450-clock.h>
  38. #include "epaper.h"
  39. #include "auofb.h"
  40. #ifdef CONFIG_PM
  41. #include <linux/pm.h>
  42. #include <asm/plat-s3c24xx/pm.h>
  43. #endif
  44. #include <asm/io.h>
  45. #include <linux/platform_device.h>
  46. //#define FRAMEBUFFER_DMA
  47. #define EPD_HW_ROTATE
  48. //#define EPD_HW_ROTATE_NO_MODE4
  49. //#define AUOFB_ROTATE
  50. #if defined(CONFIG_QISDA_QD060B00) || defined(CONFIG_QISDA_QD060N00_DVT1_1) || defined(CONFIG_QISDA_QD090B00) || defined(CONFIG_QISDA_QD090B00_EVT1)||defined(CONFIG_QISDA_SH060B00)
  51. #define EPD_ENABLE_PRE_DISPLAY
  52. #endif
  53. #define AUO_LUT_LENGTH 983040 //in bytes
  54. #define DPRINTK(x...) printk("AUOFB: " x)
  55. //#define DPRINTK(x...)
  56. #define DEF_DISPLAY_BRIGHTNESS 4
  57. #define PIXEL_BPP4 4
  58. #define PIXEL_BPP8 8
  59. #define PIXEL_BPP16 16 /* RGB 5-6-5 format for SMDK EVAL BOARD */
  60. #define PIXEL_BPP24 24 /* RGB 8-8-8 format for SMDK EVAL BOARD */
  61. #ifdef FRAMEBUFFER_DMA
  62. #define UPDATE_WIDTH_MIN 12
  63. #define UPDATE_WIDTH_MULTIPLES 4
  64. #define UPDATE_HEIGHT_MIN 8
  65. #define UPDATE_HEIGHT_MULTIPLES 4
  66. #else
  67. #define UPDATE_WIDTH_MIN 12
  68. #define UPDATE_WIDTH_MULTIPLES 4
  69. #define UPDATE_HEIGHT_MIN 8
  70. #define UPDATE_HEIGHT_MULTIPLES 4
  71. #endif
  72. #ifdef EPD_HW_ROTATE
  73. #define H_RESOLUTION AUO_EPAPER_PHYSICAL_V_RESOLUTION
  74. #define V_RESOLUTION AUO_EPAPER_PHYSICAL_H_RESOLUTION
  75. #define H_RESOLUTION_OSD AUO_EPAPER_PHYSICAL_V_RESOLUTION
  76. #define V_RESOLUTION_OSD AUO_EPAPER_PHYSICAL_H_RESOLUTION
  77. #else //SW rotate
  78. #ifdef AUOFB_ROTATE
  79. #define H_RESOLUTION AUO_EPAPER_PHYSICAL_V_RESOLUTION
  80. #define V_RESOLUTION AUO_EPAPER_PHYSICAL_H_RESOLUTION
  81. #define H_RESOLUTION_OSD AUO_EPAPER_PHYSICAL_V_RESOLUTION
  82. #define V_RESOLUTION_OSD AUO_EPAPER_PHYSICAL_H_RESOLUTION
  83. #else //not rotate
  84. #define H_RESOLUTION AUO_EPAPER_PHYSICAL_H_RESOLUTION
  85. #define V_RESOLUTION AUO_EPAPER_PHYSICAL_V_RESOLUTION
  86. #define H_RESOLUTION_OSD AUO_EPAPER_PHYSICAL_H_RESOLUTION
  87. #define V_RESOLUTION_OSD AUO_EPAPER_PHYSICAL_V_RESOLUTION
  88. #endif
  89. #endif //#ifdef EPD_HW_ROTATE
  90. #define MAX_ALPHA_LEVEL 0x0f
  91. #define H_FP 1 /* front porch */
  92. #define H_SW 1 /* Hsync width */
  93. #define H_BP 1 /* Back porch */
  94. #define V_FP 1 /* front porch */
  95. #define V_SW 1 /* Vsync width */
  96. #define V_BP 1 /* Back porch */
  97. #define VFRAME_FREQ 1
  98. #define LCD_PIXEL_CLOCK (VFRAME_FREQ *(H_FP+H_SW+H_BP+H_RESOLUTION) * (V_FP+V_SW+V_BP+V_RESOLUTION))
  99. #define PIXEL_CLOCK VFRAME_FREQ * LCD_PIXEL_CLOCK /* vclk = frame * pixel_count */
  100. #define WINCONx_BIT_SWAP_ON (1<<2) //shift on basis of half-word swap
  101. #define WINCONx_BYTE_SWAP_ON (1<<1) //shift on basis of half-word swap
  102. #define WINCONx_HALFW_SWAP_ON (1<<0) //shift on basis of half-word swap
  103. #define WINCONx_4WORD_BURST (2)
  104. #define WINCONx_8WORD_BURST (1)
  105. #define WINCONx_16WORD_BURST (0)
  106. #define WINCONx_PLANE_BLENDING (0)
  107. #define WINCONx_PIXEL_BLENDING (1)
  108. #define WINCONx_1BPP_PALLET (0)
  109. #define WINCONx_2BPP_PALLET (1)
  110. #define WINCONx_4BPP_PALLET (2)
  111. #define WINCONx_8BPP_PALLET (3)
  112. #define WINCONx_8BPP_NO_PALLET (4)
  113. #define WINCONx_16BPP_565 (5)
  114. #define WINCONx_16BPP_A555 (6)
  115. #define WINCONx_16BPP_1555 (7)
  116. #define WINCONx_18BPP_666 (8)
  117. #define WINCONx_18BPP_A665 (9)
  118. #define WINCONx_19BPP_A666 (10)
  119. #define WINCONx_24BPP_888 (11)
  120. #define WINCONx_24BPP_A887 (12)
  121. #define WINCONx_25BPP_A888 (13)
  122. #define WINCONx_ALPHA_MODE_0 (0)
  123. #define WINCONx_ALPHA_MODE_1 (1)
  124. //bit shift
  125. #define WINCON_BUFSEL (23)
  126. #define WINCON_BUFAUTOEN (22)
  127. #define WINCON_BIT_SWAP_S (18)
  128. #define WINCON_BYTE_SWAP_S (17)
  129. #define WINCON_SWAP_S (16)
  130. #define WINCON_BURSTLEN_S (9)
  131. #define WINCON_BLENDING_S (6)
  132. #define WINCON_BPP_S (2)
  133. #define WINCON_ALPHA_S (1)
  134. //* VIDWxADD2
  135. //bit shift
  136. #define VIDWxADD2_OFFSET_SIZE_S (13)
  137. #define VIDWxADD2_PAGE_WIDTH_S (0)
  138. //* VIDOSDxA,B,C
  139. //bit shift
  140. #define VIDOSDxAB_HORIZON_X_S (11)
  141. #define VIDOSDxAB_VERTICAL_Y_S (0)
  142. #define VIDOSDxC_ALPHA0_S (12)
  143. #define LCD_OFF 0
  144. #define LCD_ON 1
  145. #define LCD_WIN_0 0
  146. #define LCD_WIN_1 1
  147. #define LCD_WIN_ALL 2
  148. #define LCD_BUF_0 0
  149. #define LCD_BUF_1 1
  150. #if defined(AUO_EPAPER_6_INCH)
  151. #if defined(EPD_HW_ROTATE)
  152. #define BOOT_PROGRESS_BAR_X 32
  153. #define BOOT_PROGRESS_BAR_Y 767
  154. #define BOOT_PROGRESS_BAR_W (567-32)
  155. #define BOOT_PROGRESS_BAR_H (784-767)
  156. #else
  157. #define BOOT_PROGRESS_BAR_X 203
  158. #define BOOT_PROGRESS_BAR_Y 95
  159. #define BOOT_PROGRESS_BAR_W 8
  160. #define BOOT_PROGRESS_BAR_H 413
  161. #endif
  162. #ifdef CONFIG_RESCUEOS_BUILD
  163. #define BOOT_PROGRESS_BAR_DELAY_TIME 100 //2 sec = 420
  164. #else
  165. #define BOOT_PROGRESS_BAR_DELAY_TIME 250 //2 sec = 420
  166. #endif
  167. #else
  168. #if defined(EPD_HW_ROTATE)
  169. #define BOOT_PROGRESS_BAR_X 121
  170. #define BOOT_PROGRESS_BAR_Y 259
  171. #define BOOT_PROGRESS_BAR_W 528
  172. #define BOOT_PROGRESS_BAR_H 8
  173. #else
  174. #define BOOT_PROGRESS_BAR_X 259
  175. #define BOOT_PROGRESS_BAR_Y 119
  176. #define BOOT_PROGRESS_BAR_W 8
  177. #define BOOT_PROGRESS_BAR_H 531
  178. #endif
  179. #define BOOT_PROGRESS_BAR_DELAY_TIME 250
  180. #endif
  181. //test time
  182. struct timeval now;
  183. suseconds_t diff;
  184. //var
  185. int pre_mode=0;
  186. static int delayLoopCount;
  187. int display_brightness = DEF_DISPLAY_BRIGHTNESS;
  188. static int picnum=0;;
  189. static int Initialize = 0;
  190. static unsigned long update_display_timeout = (1600*2); //1600 about 1s
  191. static pid_t update_display_pid = 0;
  192. static wait_queue_head_t update_display_wq;
  193. static DECLARE_COMPLETION(update_display_thread_exited);
  194. static pid_t boot_progress_bar_pid = 0;
  195. static wait_queue_head_t boot_progress_bar_wq;
  196. static DECLARE_COMPLETION(boot_progress_bar_thread_exited);
  197. static unsigned short u16Temperature = 0;
  198. static unsigned short u16EPDType = 0;
  199. static unsigned short u16PanelType = 0;
  200. static unsigned short u16LUTVersion = 0;
  201. static unsigned short u16PrevMode = 0;
  202. static unsigned long u32PowerState = EN_EPD_DEVICE_POWER_STATE_D0;
  203. /*
  204. u32FullUpdateThreshold:
  205. 0 ~ (AUO_EPAPER_PHYSICAL_V_RESOLUTION*AUO_EPAPER_PHYSICAL_H_RESOLUTION)
  206. 0: Always full screen update
  207. AUO_EPAPER_PHYSICAL_V_RESOLUTION*AUO_EPAPER_PHYSICAL_H_RESOLUTION: update region is depand on partial_info
  208. */
  209. static unsigned long u32FullUpdateThreshold = (AUO_EPAPER_PHYSICAL_V_RESOLUTION*AUO_EPAPER_PHYSICAL_H_RESOLUTION);
  210. DECLARE_MUTEX(auofb_lock);
  211. struct auo_fb_info info;
  212. static unsigned char* pu8Framebuffer = NULL;
  213. static unsigned short* pu16Translatebuffer = NULL;
  214. static unsigned char* pu8RotateBuffer = NULL;
  215. u_char * cpu_VideoPhysicalTemp_f1;
  216. dma_addr_t map_VideoPhysicalTemp_f1;
  217. typedef struct partial_update_info
  218. {
  219. int mode;
  220. int x;
  221. int y;
  222. int w;
  223. int h;
  224. unsigned short u16EpaperCommand;
  225. }_partial_update_info;
  226. //_partial_update_info partial_info;
  227. _partial_update_info w_partial_info;
  228. _partial_update_info r_partial_info;
  229. #define PARTIAL_INFO_QUEUE_SIZE 50
  230. _partial_update_info partial_info_queue[PARTIAL_INFO_QUEUE_SIZE];
  231. static int pr=0;
  232. static int pw=0;
  233. #if defined(EPD_ENABLE_PRE_DISPLAY)
  234. atomic_t gPowerOnFirstDisplay = ATOMIC_INIT(0); // to identify if a screen update is the first update after power on
  235. #endif
  236. struct auo_fb_mach_info auo_mach_info = {
  237. //Video control 0 register,
  238. .vidcon0= S3C_VIDCON0_VIDOUT_RGB_IF | S3C_VIDCON0_PNRMODE_RGB_P | S3C_VIDCON0_CLKDIR_DIVIDED | S3C_VIDCON0_VCLKEN_ENABLE |S3C_VIDCON0_CLKSEL_F_HCLK,
  239. .vidcon1= S3C_VIDCON1_IHSYNC_INVERT | S3C_VIDCON1_IVSYNC_INVERT,
  240. //Video time control 0 register
  241. .vidtcon0= S3C_VIDTCON0_VBPD(V_BP-1) | S3C_VIDTCON0_VFPD(V_FP-1) | S3C_VIDTCON0_VSPW(V_SW-1),
  242. .vidtcon1= S3C_VIDTCON1_HBPD(H_BP-1) | S3C_VIDTCON1_HFPD(H_FP-1 ) | S3C_VIDTCON1_HSPW(H_SW-1),
  243. .vidtcon2= S3C_VIDTCON2_LINEVAL(V_RESOLUTION-1) | S3C_VIDTCON2_HOZVAL(H_RESOLUTION-1),
  244. // Window control 0 register, 4 bpp
  245. .wincon0= S3C_WINCONx_HAWSWP_ENABLE | S3C_WINCONx_BURSTLEN_4WORD | (2<<2),
  246. .wincon1= S3C_WINCONx_HAWSWP_ENABLE | S3C_WINCONx_BURSTLEN_4WORD | S3C_WINCONx_BPPMODE_F_16BPP_565 | S3C_WINCONx_BLD_PIX_PLANE | S3C_WINCONx_ALPHA_SEL_1, // 4word burst, 16bpp for OSD
  247. //Video Window 0, 1��s position control register
  248. .vidosd0a= S3C_VIDOSDxA_OSD_LTX_F(0) | S3C_VIDOSDxA_OSD_LTY_F(0),
  249. .vidosd0b= S3C_VIDOSDxB_OSD_RBX_F(H_RESOLUTION-1) | S3C_VIDOSDxB_OSD_RBY_F(V_RESOLUTION-1),
  250. .vidosd1a= S3C_VIDOSDxA_OSD_LTX_F(0) | S3C_VIDOSDxA_OSD_LTY_F(0),
  251. .vidosd1b= S3C_VIDOSDxB_OSD_RBX_F(H_RESOLUTION_OSD-1) | S3C_VIDOSDxB_OSD_RBY_F(V_RESOLUTION_OSD-1),
  252. .vidosd1c= S3C_VIDOSDxC_ALPHA1_B(MAX_ALPHA_LEVEL) | S3C_VIDOSDxC_ALPHA1_G(MAX_ALPHA_LEVEL) |S3C_VIDOSDxC_ALPHA1_R(MAX_ALPHA_LEVEL),
  253. //Indicate the Video interrupt control register
  254. .vidintcon= S3C_VIDINTCON0_FRAMESEL0_VSYNC | S3C_VIDINTCON0_FRAMESEL1_NONE | S3C_VIDINTCON0_INTFRMEN_ENABLE | S3C_VIDINTCON0_INTEN_ENABLE,
  255. .width= H_RESOLUTION,
  256. .height= V_RESOLUTION,
  257. .xres= H_RESOLUTION,
  258. .yres= V_RESOLUTION,
  259. .xoffset= 0,
  260. .yoffset= 0,
  261. .xres_virtual = H_RESOLUTION,
  262. .yres_virtual = V_RESOLUTION,
  263. .osd_width= H_RESOLUTION_OSD,
  264. .osd_height= V_RESOLUTION_OSD,
  265. .osd_xres= H_RESOLUTION_OSD,
  266. .osd_yres= V_RESOLUTION_OSD,
  267. .osd_xres_virtual= H_RESOLUTION_OSD,
  268. .osd_yres_virtual= V_RESOLUTION_OSD,
  269. //Ivan
  270. .bpp= PIXEL_BPP16,
  271. .bytes_per_pixel= 2,
  272. /*
  273. #if defined (CONFIG_FB_BPP_8)
  274. .bpp= PIXEL_BPP8,
  275. .bytes_per_pixel= 1,
  276. #if defined(CONFIG_CPU_S3C2443) || defined(CONFIG_CPU_S3C2450) || defined(CONFIG_CPU_S3C2416)
  277. .wpalcon= W0PAL_24BIT,
  278. #elif defined(CONFIG_CPU_S3C6400) || defined(CONFIG_CPU_S3C6410)
  279. .wpalcon= W0PAL_16BIT,
  280. #endif
  281. #elif defined (CONFIG_FB_BPP_16)
  282. .bpp= PIXEL_BPP16,
  283. .bytes_per_pixel= 2,
  284. #elif defined (CONFIG_FB_BPP_24)
  285. .bpp= PIXEL_BPP24,
  286. .bytes_per_pixel= 4,
  287. #endif
  288. */
  289. .pixclock= PIXEL_CLOCK,
  290. //Color key control register
  291. .w1keycon0= S3C_WxKEYCON0_KEYBLEN_DISABLE | S3C_WxKEYCON0_KEYEN_F_DISABLE | S3C_WxKEYCON0_DIRCON_MATCH_FG_IMAGE |
  292. S3C_WxKEYCON0_COMPKEY(0x0),
  293. .w1keycon1= S3C_WxKEYCON1_COLVAL(0xffffff),
  294. .w2keycon0= S3C_WxKEYCON0_KEYBLEN_DISABLE | S3C_WxKEYCON0_KEYEN_F_DISABLE | S3C_WxKEYCON0_DIRCON_MATCH_FG_IMAGE |
  295. S3C_WxKEYCON0_COMPKEY(0x0),
  296. .w2keycon1= S3C_WxKEYCON1_COLVAL(0xffffff),
  297. .w3keycon0= S3C_WxKEYCON0_KEYBLEN_DISABLE | S3C_WxKEYCON0_KEYEN_F_DISABLE | S3C_WxKEYCON0_DIRCON_MATCH_FG_IMAGE |
  298. S3C_WxKEYCON0_COMPKEY(0x0),
  299. .w3keycon1= S3C_WxKEYCON1_COLVAL(0xffffff),
  300. .w4keycon0= S3C_WxKEYCON0_KEYBLEN_DISABLE | S3C_WxKEYCON0_KEYEN_F_DISABLE | S3C_WxKEYCON0_DIRCON_MATCH_FG_IMAGE |
  301. S3C_WxKEYCON0_COMPKEY(0x0),
  302. .w4keycon1= S3C_WxKEYCON1_COLVAL(0xffffff),
  303. .hsync_len= H_SW,
  304. .vsync_len= V_SW,
  305. .left_margin= H_FP,
  306. .upper_margin= V_FP,
  307. .right_margin= H_BP,
  308. .lower_margin= V_BP,
  309. .sync= 0,
  310. .cmap_static= 1,
  311. };
  312. struct semaphore vma_list_semaphore;
  313. struct fb_vma_list_entry {
  314. struct list_head list;
  315. struct vm_area_struct *vma;
  316. };
  317. static unsigned long videomemorysize;
  318. struct page **videopages;
  319. static int numpages;
  320. LIST_HEAD(vma_list);
  321. static bool isInitial = false;
  322. static bool isReady = true;
  323. static bool update_ready = false;
  324. T_DISPLAY_FRAME gStDisFrame;
  325. //timer
  326. static struct work_struct workq_panel_update;
  327. static struct timer_list panel_timer_qisda;
  328. static void panel_timer_handler_qisda(unsigned long data) { schedule_work(&workq_panel_update); }
  329. static int lock_auofb_entry(char *function_name);
  330. static void lock_auofb_exit(char *function_name);
  331. static bool auofb_update_queue_put(_partial_update_info put_region);
  332. static bool auofb_update_queue_get(_partial_update_info* get_region);
  333. static bool auofb_update_queue_is_empty(void);
  334. static bool auofb_update_queue_is_full(void);
  335. static void auofb_rotate_RGB565(unsigned short w, unsigned short h, unsigned short* src_data, unsigned short* dst_data);
  336. static void auofb_convert_RGB565(unsigned short w, unsigned short h, unsigned short* src_data, unsigned short* dst_data);
  337. static int update_display_thread(void *unused);
  338. static void start_update_display_thread(void);
  339. static void stop_update_display_thread(void);
  340. static panel_update_workqueue(struct work_struct *work);
  341. static void wake_update_display_thread(void);
  342. static int auo_fb_is_update_region_legal(void);
  343. #define LOCK_AUOFB_ENTRY() lock_auofb_entry((char *)__FUNCTION__)
  344. #define LOCK_AUOFB_EXIT() lock_auofb_exit((char *)__FUNCTION__)
  345. static int lock_auofb_entry(char *function_name)
  346. {
  347. int result = 0;
  348. //DPRINTK("%s(pid=%d) getting lock...\n", function_name, (int)sys_getpid());
  349. // Did we get the lock?
  350. //
  351. if ( down_interruptible(&auofb_lock) )
  352. //if ( down(&auofb_lock) )
  353. {
  354. DPRINTK("%s(pid=%d) COULD NOT get lock...\n", function_name, (int)sys_getpid());
  355. result = -ERESTARTSYS;
  356. }
  357. else
  358. {
  359. ;
  360. DPRINTK("%s(pid=%d) got lock...\n", function_name, (int)sys_getpid());
  361. }
  362. // No, release it.
  363. //
  364. if ( result )
  365. up(&auofb_lock);
  366. return ( result );
  367. }
  368. static void lock_auofb_exit(char *function_name)
  369. {
  370. up(&auofb_lock);
  371. //DPRINTK("%s(pid=%d) released lock...\n", function_name, (int)sys_getpid());
  372. }
  373. static bool auofb_update_queue_put(_partial_update_info put_region)
  374. {
  375. #if defined(EPD_ENABLE_PRE_DISPLAY)
  376. // { workaround for MMI first update not using mode 0 after T-Con power on + pre display cmd
  377. if ((atomic_read(&gPowerOnFirstDisplay ) == 1))
  378. {
  379. if(put_region.mode == 0)
  380. {
  381. put_region.mode = 1;
  382. }
  383. atomic_set(&gPowerOnFirstDisplay, 0);
  384. }
  385. // } workaround for MMI first update not using mode 0 after T-Con power on + pre display cmd
  386. #endif
  387. partial_info_queue[pw] = put_region;
  388. pw++;
  389. pw%=PARTIAL_INFO_QUEUE_SIZE;
  390. return true;
  391. }
  392. static bool auofb_update_queue_get(_partial_update_info* get_region)
  393. {
  394. *get_region = partial_info_queue[pr];
  395. pr++;
  396. pr%=PARTIAL_INFO_QUEUE_SIZE;
  397. return true;
  398. }
  399. static bool auofb_update_queue_is_empty(void)
  400. {
  401. if(pr == pw)
  402. return true;
  403. return false;
  404. }
  405. static bool auofb_update_queue_is_full(void)
  406. {
  407. if(((pw+1)%PARTIAL_INFO_QUEUE_SIZE) == pr)
  408. return true;
  409. return false;
  410. }
  411. static void auofb_rotate_RGB565(unsigned short w, unsigned short h, unsigned short* src_data, unsigned short* dst_data)
  412. {
  413. int i,j;
  414. for(i=0; i< w; i++)
  415. {
  416. for(j=0; j< h; j++)
  417. {
  418. //printf("%d -%d\n", i * h + j, j * w + (w - i - 1));
  419. dst_data[i * h + j] = src_data[j * w + (w - i - 1)];
  420. }
  421. }
  422. }
  423. #if defined(EPD_ENABLE_PRE_DISPLAY)
  424. /* RGB table for RGB 565 */
  425. unsigned short u16TableR[] =
  426. {
  427. 0,
  428. 77,
  429. 154,
  430. 231,
  431. 308,
  432. 385,
  433. 462,
  434. 539,
  435. 616,
  436. 693,
  437. 770,
  438. 847,
  439. 924,
  440. 1001,
  441. 1078,
  442. 1155,
  443. 1232,
  444. 1309,
  445. 1386,
  446. 1463,
  447. 1540,
  448. 1617,
  449. 1694,
  450. 1771,
  451. 1848,
  452. 1925,
  453. 2002,
  454. 2079,
  455. 2156,
  456. 2233,
  457. 2310,
  458. 2387
  459. };
  460. unsigned short u16TableG[] =
  461. {
  462. 0,
  463. 151,
  464. 302,
  465. 453,
  466. 604,
  467. 755,
  468. 906,
  469. 1057,
  470. 1208,
  471. 1359,
  472. 1510,
  473. 1661,
  474. 1812,
  475. 1963,
  476. 2114,
  477. 2265,
  478. 2416,
  479. 2567,
  480. 2718,
  481. 2869,
  482. 3020,
  483. 3171,
  484. 3322,
  485. 3473,
  486. 3624,
  487. 3775,
  488. 3926,
  489. 4077,
  490. 4228,
  491. 4379,
  492. 4530,
  493. 4681,
  494. 4832,
  495. 4983,
  496. 5134,
  497. 5285,
  498. 5436,
  499. 5587,
  500. 5738,
  501. 5889,
  502. 6040,
  503. 6191,
  504. 6342,
  505. 6493,
  506. 6644,
  507. 6795,
  508. 6946,
  509. 7097,
  510. 7248,
  511. 7399,
  512. 7550,
  513. 7701,
  514. 7852,
  515. 8003,
  516. 8154,
  517. 8305,
  518. 8456,
  519. 8607,
  520. 8758,
  521. 8909,
  522. 9060,
  523. 9211,
  524. 9362,
  525. 9513
  526. };
  527. unsigned short u16TableB[] =
  528. {
  529. 0,
  530. 28,
  531. 56,
  532. 84,
  533. 112,
  534. 140,
  535. 168,
  536. 196,
  537. 224,
  538. 252,
  539. 280,
  540. 308,
  541. 336,
  542. 364,
  543. 392,
  544. 420,
  545. 448,
  546. 476,
  547. 504,
  548. 532,
  549. 560,
  550. 588,
  551. 616,
  552. 644,
  553. 672,
  554. 700,
  555. 728,
  556. 756,
  557. 784,
  558. 812,
  559. 840,
  560. 868
  561. };
  562. static void auofb_convert_RGB565(unsigned short w, unsigned short h, unsigned short* src_data, unsigned short* dst_data)
  563. {
  564. int i;
  565. int length = w*h*auo_mach_info.bytes_per_pixel/8;
  566. unsigned short u16val1, u16val2, u16val3, u16val4;
  567. unsigned short u8R, u8G, u8B;
  568. unsigned short* pu16TranslatePtr = dst_data;
  569. unsigned short* pu16ProcessPtr = src_data;
  570. unsigned short u16Pixel;
  571. // printk("*** +%s\n", __func__);
  572. for(i=0;i<length;i++)
  573. {
  574. // 1st pixel
  575. u16Pixel = *(pu16ProcessPtr + 0);
  576. u8R = ((u16Pixel & 0xF800) >> auo_fb_rgb_16.red.offset);
  577. u8G = ((u16Pixel & 0x07E0) >> (auo_fb_rgb_16.green.offset+1));
  578. u8B = ((u16Pixel & 0x001F) >> auo_fb_rgb_16.blue.offset);
  579. u16val1 = (u16TableR[u8R] + u16TableG[u8G] + u16TableB[u8B]) >> 9;
  580. // 2nd pixel
  581. u16Pixel = *(pu16ProcessPtr + 1);
  582. u8R = ((u16Pixel & 0xF800) >> auo_fb_rgb_16.red.offset);
  583. u8G = ((u16Pixel & 0x07E0) >> (auo_fb_rgb_16.green.offset+1));
  584. u8B = ((u16Pixel & 0x001F) >> auo_fb_rgb_16.blue.offset);
  585. u16val2 = (u16TableR[u8R] + u16TableG[u8G] + u16TableB[u8B]) >> 5;
  586. // 3rd pixel
  587. u16Pixel = *(pu16ProcessPtr + 2);
  588. u8R = ((u16Pixel & 0xF800) >> auo_fb_rgb_16.red.offset);
  589. u8G = ((u16Pixel & 0x07E0) >> (auo_fb_rgb_16.green.offset+1));
  590. u8B = ((u16Pixel & 0x001F) >> auo_fb_rgb_16.blue.offset);
  591. u16val3 = (u16TableR[u8R] + u16TableG[u8G] + u16TableB[u8B]) >> 1;
  592. // 4th pixel
  593. u16Pixel = *(pu16ProcessPtr + 3);
  594. u8R = ((u16Pixel & 0xF800) >> auo_fb_rgb_16.red.offset);
  595. u8G = ((u16Pixel & 0x07E0) >> (auo_fb_rgb_16.green.offset+1));
  596. u8B = ((u16Pixel & 0x001F) >> auo_fb_rgb_16.blue.offset);
  597. u16val4 = (u16TableR[u8R] + u16TableG[u8G] + u16TableB[u8B]) << 3;
  598. *pu16TranslatePtr = ( ( (u16val4) & 0xF000)
  599. | ( (u16val3) & 0x0F00)
  600. | ( (u16val2) & 0x00F0)
  601. | ( (u16val1) & 0x000F) );
  602. pu16TranslatePtr++;
  603. pu16ProcessPtr = pu16ProcessPtr + 4;
  604. }
  605. // printk("*** -%s\n", __func__);
  606. }
  607. #else
  608. static void auofb_convert_RGB565(unsigned short w, unsigned short h, unsigned short* src_data, unsigned short* dst_data)
  609. {
  610. int i;
  611. unsigned short u16val;
  612. unsigned short* pu16TranslatePtr = dst_data;
  613. unsigned short* pu16ProcessPtr = src_data;
  614. for(i=0;i<(w*h*auo_mach_info.bytes_per_pixel/8);i++)
  615. {
  616. *pu16TranslatePtr = 0;
  617. // 1st pixel
  618. u16val = ((((*pu16ProcessPtr & 0xF800) >> auo_fb_rgb_16.red.offset)*77 +
  619. ((*pu16ProcessPtr & 0x07E0) >> (auo_fb_rgb_16.green.offset+1))*151 +
  620. ((*pu16ProcessPtr & 0x1F) >> auo_fb_rgb_16.blue.offset)*28)>>8 >>1);
  621. *pu16TranslatePtr = (*pu16TranslatePtr) | (u16val & 0x000F);
  622. // 2nd pixel
  623. u16val = ((((*(pu16ProcessPtr+1) & 0xF800) >> auo_fb_rgb_16.red.offset)*77 +
  624. ((*(pu16ProcessPtr+1) & 0x07E0) >> (auo_fb_rgb_16.green.offset+1))*151 +
  625. ((*(pu16ProcessPtr+1) & 0x1F) >> auo_fb_rgb_16.blue.offset)*28)>>8 >>1);
  626. *pu16TranslatePtr = (*pu16TranslatePtr) | ((u16val<<4) & 0x00F0);
  627. // 3rd pixel
  628. u16val = ((((*(pu16ProcessPtr+2) & 0xF800) >> auo_fb_rgb_16.red.offset)*77 +
  629. ((*(pu16ProcessPtr+2) & 0x07E0) >>(auo_fb_rgb_16.green.offset+1))*151 +
  630. ((*(pu16ProcessPtr+2) & 0x1F) >> auo_fb_rgb_16.blue.offset)*28)>>8>>1);
  631. *pu16TranslatePtr = (*pu16TranslatePtr) | ((u16val<<8) & 0x0F00);
  632. // 4th pixel
  633. u16val = ((((*(pu16ProcessPtr+3) & 0xF800) >> auo_fb_rgb_16.red.offset)*77 +
  634. ((*(pu16ProcessPtr+3) & 0x07E0) >> (auo_fb_rgb_16.green.offset+1))*151 +
  635. ((*(pu16ProcessPtr+3) & 0x1F) >> auo_fb_rgb_16.blue.offset)*28)>>8>>1);
  636. *pu16TranslatePtr = (*pu16TranslatePtr) | ((u16val<<12) & 0xF000);
  637. pu16TranslatePtr++;
  638. pu16ProcessPtr = pu16ProcessPtr+4;
  639. }
  640. }
  641. #endif
  642. static void auofb_basic_display_setting( unsigned long win_num,unsigned long buf_num)
  643. {
  644. unsigned long screenwidth_in_byte=0,offsize_in_byte=0;
  645. unsigned long offsize;
  646. unsigned long tmp=0;
  647. screenwidth_in_byte = H_RESOLUTION*4/8;
  648. if((screenwidth_in_byte%64)!=0) //64 is depanded on WINCONx_16WORD_BURST
  649. {
  650. screenwidth_in_byte += 64 - (screenwidth_in_byte%64);
  651. }
  652. offsize =0;
  653. offsize_in_byte = offsize*8/8;
  654. // WINCON0/1
  655. tmp = (0<<WINCON_BUFSEL)|(0<<WINCON_BUFAUTOEN)|(1<<WINCON_SWAP_S)|(0<<WINCON_BURSTLEN_S)|(5<<WINCON_BPP_S);
  656. __raw_writel(tmp, S3C_WINCON0);
  657. // WIN0/1 OSD(top)
  658. tmp = (0<<VIDOSDxAB_HORIZON_X_S)|(0);
  659. __raw_writel(tmp, S3C_VIDOSD0A);
  660. // WIN0/1 OSD(bottom)
  661. tmp = (((H_RESOLUTION)-1)<<VIDOSDxAB_HORIZON_X_S)|((V_RESOLUTION/4)-1);
  662. __raw_writel(tmp, S3C_VIDOSD0B);
  663. //=================
  664. cpu_VideoPhysicalTemp_f1 = dma_alloc_writecombine(info.dev, H_RESOLUTION*V_RESOLUTION/2,
  665. &map_VideoPhysicalTemp_f1, GFP_KERNEL);
  666. memset(cpu_VideoPhysicalTemp_f1, 0xFF, H_RESOLUTION*V_RESOLUTION/2);
  667. //=================
  668. // WIN0/1 buffer start address
  669. __raw_writel((unsigned long)map_VideoPhysicalTemp_f1, S3C_VIDW00ADD0B0);
  670. // WIN0/1 buffer end address
  671. __raw_writel((unsigned long)map_VideoPhysicalTemp_f1 + (screenwidth_in_byte+offsize_in_byte)*(V_RESOLUTION), S3C_VIDW00ADD1B0);
  672. // WIN0/1 buffer size
  673. __raw_writel((offsize_in_byte<<VIDWxADD2_OFFSET_SIZE_S)|screenwidth_in_byte, S3C_VIDW00ADD2B0);
  674. __raw_writel(0, S3C_WIN0MAP);
  675. //if (win_num>0)
  676. {
  677. __raw_writel(0, S3C_VIDOSD1C);
  678. __raw_writel(0, S3C_W1KEYCON0);
  679. __raw_writel(0, S3C_W1KEYCON1);
  680. }
  681. }
  682. static void auofb_display_setting( unsigned long win_num,unsigned long buf_num, unsigned short x, unsigned short y, unsigned short w, unsigned short h)
  683. {
  684. unsigned long screenwidth_in_byte=0,offsize_in_byte=0;
  685. unsigned long offsize;
  686. unsigned long tmp=0;
  687. printk("\n(%d, %d, %d, %d)\n", x,y,w,h);
  688. screenwidth_in_byte = w*4/8;
  689. if((screenwidth_in_byte%16)!=0) //16 is depanded on WINCONx_16WORD_BURST
  690. {
  691. screenwidth_in_byte += 16 - (screenwidth_in_byte%16);
  692. }
  693. offsize =0;
  694. offsize_in_byte = offsize*8/8;
  695. // WINCON0/1
  696. tmp = (0<<WINCON_BUFSEL)|(0<<WINCON_BUFAUTOEN)|(0<<WINCON_BIT_SWAP_S)|(0<<WINCON_BYTE_SWAP_S)|(1<<WINCON_SWAP_S)|(WINCONx_4WORD_BURST<<WINCON_BURSTLEN_S)|(5<<WINCON_BPP_S);
  697. __raw_writel(tmp, S3C_WINCON0);
  698. // WIN0/1 OSD(top)
  699. tmp = ((0)<<VIDOSDxAB_HORIZON_X_S)|(0);
  700. __raw_writel(tmp, S3C_VIDOSD0A);
  701. // WIN0/1 OSD(bottom)
  702. tmp = (((w-1))<<VIDOSDxAB_HORIZON_X_S)|((h-1));
  703. __raw_writel(tmp, S3C_VIDOSD0B);
  704. // WIN0/1 buffer start address
  705. __raw_writel((unsigned long)map_VideoPhysicalTemp_f1, S3C_VIDW00ADD0B0);
  706. // WIN0/1 buffer end address
  707. __raw_writel((unsigned long)map_VideoPhysicalTemp_f1 + (screenwidth_in_byte+offsize_in_byte)*(h), S3C_VIDW00ADD1B0);
  708. // WIN0/1 buffer size
  709. __raw_writel((offsize_in_byte<<VIDWxADD2_OFFSET_SIZE_S)|screenwidth_in_byte, S3C_VIDW00ADD2B0);
  710. }
  711. static void auofb_LcdEnvidOnOff(unsigned char onoff)
  712. {
  713. unsigned long tmp = 0;
  714. if(onoff==LCD_ON)
  715. {
  716. tmp = __raw_readl(S3C_VIDCON0);
  717. tmp |= (3);
  718. __raw_writel(tmp, S3C_VIDCON0);
  719. }
  720. else
  721. {
  722. tmp = __raw_readl(S3C_VIDCON0);
  723. tmp &= (~1);
  724. __raw_writel(tmp, S3C_VIDCON0);
  725. __raw_writel((1<<0), S3C_CPUTRIGCON2);
  726. while( 1) // Check end of frame
  727. {
  728. tmp = __raw_readl(S3C_VIDCON0);
  729. if(!(tmp&1))
  730. break;
  731. msleep(20);
  732. }
  733. }
  734. }
  735. static void auofb_LcdWindowOnOff(unsigned char num, unsigned char onoff)
  736. {
  737. unsigned long tmp = 0;
  738. switch(num)
  739. {
  740. case LCD_WIN_0:
  741. if(onoff==LCD_ON)
  742. {
  743. tmp = __raw_readl(S3C_WINCON0);
  744. tmp |= 0x01;
  745. __raw_writel(tmp, S3C_WINCON0);
  746. }
  747. else
  748. {
  749. tmp = __raw_readl(S3C_WINCON0);
  750. tmp &= ~0x01;
  751. __raw_writel(tmp, S3C_WINCON0);
  752. }
  753. break;
  754. case LCD_WIN_1:
  755. if(onoff==LCD_ON)
  756. {
  757. tmp = __raw_readl(S3C_WINCON1);
  758. tmp |= 0x01;
  759. __raw_writel(tmp, S3C_WINCON1);
  760. }
  761. else
  762. {
  763. tmp = __raw_readl(S3C_WINCON1);
  764. tmp &= ~0x01;
  765. __raw_writel(tmp, S3C_WINCON1);
  766. }
  767. break;
  768. case LCD_WIN_ALL:
  769. if(onoff==LCD_ON)
  770. {
  771. tmp = __raw_readl(S3C_WINCON0);
  772. tmp |= 0x01;
  773. __raw_writel(tmp, S3C_WINCON0);
  774. tmp = __raw_readl(S3C_WINCON1);
  775. tmp |= 0x01;
  776. __raw_writel(tmp, S3C_WINCON1);
  777. }
  778. else
  779. {
  780. tmp = __raw_readl(S3C_WINCON0);
  781. tmp &= ~0x01;
  782. __raw_writel(tmp, S3C_WINCON0);
  783. tmp = __raw_readl(S3C_WINCON1);
  784. tmp &= ~0x01;
  785. __raw_writel(tmp, S3C_WINCON1);
  786. }
  787. default:
  788. break;
  789. }
  790. return;
  791. }
  792. static void auofb_Display_Start(char win_num) // 0: LCD_WIN_0, 1: LCD_WIN_1, 2: LCD_WIN_ALL
  793. {
  794. auofb_LcdWindowOnOff(win_num,LCD_ON);
  795. auofb_LcdEnvidOnOff(LCD_ON);
  796. #if defined(EPD_ENABLE_PRE_DISPLAY)
  797. mdelay(1);
  798. #else
  799. msleep(1);
  800. #endif
  801. __raw_writel((1<<0), S3C_CPUTRIGCON2);
  802. return;
  803. }
  804. static void auofb_Display_End(unsigned char win_num)
  805. {
  806. auofb_LcdWindowOnOff(win_num,LCD_OFF);
  807. auofb_LcdEnvidOnOff(LCD_OFF);
  808. return;
  809. }
  810. static void auofb_Disp(T_DISPLAY_FRAME tmpDispFrame)
  811. {
  812. #ifdef FRAMEBUFFER_DMA
  813. int get_mode = Epaper_Get_Partial_Update_Mode();
  814. if((get_mode == PARTIAL_DSP_MODE_4) || (get_mode == PARTIAL_DSP_MODE_4_W))
  815. {
  816. Epaper_Disp(tmpDispFrame);
  817. }
  818. else
  819. {
  820. printk("\nDMA out, (x,y,w,h)=(%d,%d,%d,%d)\n",tmpDispFrame.tFrameRange.X, tmpDispFrame.tFrameRange.Y, tmpDispFrame.tFrameRange.W, tmpDispFrame.tFrameRange.H);
  821. auofb_display_setting(0,0, tmpDispFrame.tFrameRange.X, tmpDispFrame.tFrameRange.Y, tmpDispFrame.tFrameRange.W, tmpDispFrame.tFrameRange.H);
  822. Epaper_Pre_DMA_Disp_Start(tmpDispFrame);
  823. if(is_Epaper_Write_Ready())
  824. {
  825. auofb_Display_Start(0);
  826. auofb_Display_End(0);
  827. }
  828. Epaper_Pre_DMA_Disp_Stop(tmpDispFrame);
  829. }
  830. #else
  831. Epaper_Disp(tmpDispFrame);
  832. #endif
  833. }
  834. /*
  835. static void boot_progress_bar_draw_bar(void)
  836. {
  837. //u16boot_progress_bar_Data
  838. T_DISPLAY_FRAME stDisFrame;
  839. stDisFrame.u16EpaperCommand = AUO_EPAPER_CMD_PARTIALDISP;
  840. stDisFrame.tFrameRange.X = 199;
  841. stDisFrame.tFrameRange.Y = 92;
  842. stDisFrame.tFrameRange.W = 12;
  843. stDisFrame.tFrameRange.H = 420;
  844. Epaper_Set_Partial_Update_Mode(1);
  845. stDisFrame.pFrameData = u16boot_progress_bar_Data;
  846. if(is_Epaper_Write_Ready())
  847. Epaper_Disp(stDisFrame);
  848. }
  849. */
  850. static void boot_progress_bar_draw_percent(int percent)
  851. {
  852. T_DISPLAY_FRAME stDisFrame;
  853. int i;
  854. //unsigned short progress_bar[BOOT_PROGRESS_BAR_W*BOOT_PROGRESS_BAR_H/4];
  855. int line_bytes = BOOT_PROGRESS_BAR_W/4*2;
  856. int draw_len = 0;
  857. if(percent == 0)
  858. return;
  859. memset((unsigned char*)pu16Translatebuffer, 0xff, BOOT_PROGRESS_BAR_W*BOOT_PROGRESS_BAR_H/4*2);
  860. #if defined(EPD_HW_ROTATE)
  861. if((BOOT_PROGRESS_BAR_W*percent/100)%4 != 0)
  862. {
  863. draw_len = (BOOT_PROGRESS_BAR_W*percent/100) + (4)-((BOOT_PROGRESS_BAR_W*percent/100)%4);
  864. }
  865. else
  866. draw_len = (BOOT_PROGRESS_BAR_W*percent/100);
  867. for(i=0; i< BOOT_PROGRESS_BAR_H; i++)
  868. {
  869. memset((unsigned char*)pu16Translatebuffer + (BOOT_PROGRESS_BAR_W/2)*i, 0x0, (draw_len/2));
  870. }
  871. #else
  872. memset((unsigned char*)pu16Translatebuffer+(BOOT_PROGRESS_BAR_H-(BOOT_PROGRESS_BAR_H*percent/100))*line_bytes, 0x0, (BOOT_PROGRESS_BAR_H*percent/100)*line_bytes);
  873. #endif
  874. Epaper_Set_Partial_Update_Mode(1);
  875. stDisFrame.u16EpaperCommand = AUO_EPAPER_CMD_PARTIALDISP;
  876. stDisFrame.tFrameRange.X = BOOT_PROGRESS_BAR_X;
  877. stDisFrame.tFrameRange.Y = BOOT_PROGRESS_BAR_Y;
  878. stDisFrame.tFrameRange.W = BOOT_PROGRESS_BAR_W;
  879. stDisFrame.tFrameRange.H = BOOT_PROGRESS_BAR_H;
  880. stDisFrame.pFrameData = pu16Translatebuffer;
  881. if(is_Epaper_Write_Ready())
  882. {
  883. DPRINTK("\nEpaper Progress %d",percent);
  884. //Epaper_Disp(stDisFrame);
  885. auofb_Disp(stDisFrame);
  886. }
  887. }
  888. static int boot_progress_bar_thread(void *unused)
  889. {
  890. int thread_active = 1;
  891. int draw_count =0;
  892. msleep(500);
  893. //boot_progress_bar_draw_bar();
  894. daemonize("Boot_progress_bar_udt");
  895. allow_signal(SIGKILL);
  896. thread_active = 0;
  897. while ( thread_active )
  898. {
  899. try_to_freeze(); //for freeze kernel_thread
  900. if ( !signal_pending(current) )
  901. {
  902. printk("\nboot_progress_bar_thread");
  903. boot_progress_bar_draw_percent(10+(draw_count*10));
  904. draw_count++;
  905. if(draw_count ==10)
  906. {
  907. thread_active = 0;
  908. }
  909. interruptible_sleep_on_timeout(&boot_progress_bar_wq, BOOT_PROGRESS_BAR_DELAY_TIME);
  910. }
  911. else
  912. thread_active = 0;
  913. }
  914. complete_and_exit(&boot_progress_bar_thread_exited, 0);
  915. }
  916. static int update_display_thread(void *unused)
  917. {
  918. int thread_active = 1;
  919. int i=0;
  920. unsigned short* pu16ProcessPtr=NULL;
  921. unsigned short* pu16TranslatePtr=pu16Translatebuffer;
  922. unsigned short u16val;
  923. T_DISPLAY_FRAME stDisFrame;
  924. unsigned long count;
  925. unsigned long timeout_time = update_display_timeout;
  926. unsigned char* pu8Tmp_region = NULL;
  927. unsigned char* pu8Tmp_copy_ptr = NULL;
  928. int test_len=0;
  929. unsigned long tmp_clock;
  930. unsigned long total_clock;
  931. daemonize("AUOEINK_udt");
  932. allow_signal(SIGKILL);
  933. while ( thread_active )
  934. {
  935. try_to_freeze(); //for freeze kernel_thread
  936. if ( !signal_pending(current) )
  937. {
  938. if ( 0 == LOCK_AUOFB_ENTRY() )
  939. {
  940. pu16ProcessPtr = NULL;
  941. pu16TranslatePtr = pu16Translatebuffer;
  942. //if(update_ready)
  943. while(!auofb_update_queue_is_empty())
  944. {
  945. DPRINTK("AUO EINK time start, jiffies: %lu, HZ: %lu\n", jiffies, HZ);
  946. total_clock = tmp_clock = jiffies;
  947. auofb_update_queue_get(&r_partial_info);
  948. #if defined(EPD_ENABLE_PRE_DISPLAY)
  949. /*********************************************************/
  950. if( AUO_EPAPER_CMD_INIT == r_partial_info.u16EpaperCommand )
  951. {
  952. #ifdef EPD_HW_ROTATE
  953. Epaper_Init(AUO_EPAPER_PHYSICAL_H_RESOLUTION, AUO_EPAPER_PHYSICAL_V_RESOLUTION, 0, 0, 90, 0, 0, 0, 0, 0);
  954. #else
  955. Epaper_Init(AUO_EPAPER_PHYSICAL_H_RESOLUTION, AUO_EPAPER_PHYSICAL_V_RESOLUTION, 0, 0, 0, 0, 0, 0, 0, 0);
  956. #endif
  957. continue;
  958. }
  959. /*********************************************************/
  960. #endif
  961. Epaper_Set_Partial_Update_Mode(r_partial_info.mode);
  962. #ifdef EPD_HW_ROTATE
  963. #ifdef EPD_HW_ROTATE_NO_MODE4
  964. if((r_partial_info.mode == PARTIAL_DSP_MODE_4) || (r_partial_info.mode == PARTIAL_DSP_MODE_4_W))
  965. {
  966. if( (u16PrevMode != PARTIAL_DSP_MODE_4) && (u16PrevMode != PARTIAL_DSP_MODE_4_W) )
  967. {
  968. if(is_Epaper_Write_Ready())
  969. Epaper_Init(AUO_EPAPER_PHYSICAL_H_RESOLUTION, AUO_EPAPER_PHYSICAL_V_RESOLUTION, 0, 0, 0, 0, 0, 0, 0, 0);
  970. }
  971. //check if the updated region is valid
  972. if( (r_partial_info.w == auo_mach_info.xres_virtual) && (r_partial_info.h == auo_mach_info.yres_virtual))
  973. {
  974. //rotate
  975. auofb_rotate_RGB565(auo_mach_info.xres_virtual, auo_mach_info.yres_virtual, (unsigned short*)
  976. pu8Framebuffer, (unsigned short*)pu8RotateBuffer);
  977. }
  978. else
  979. {
  980. pu8Tmp_region = vmalloc(r_partial_info.w * 2 * r_partial_info.h); // *2 --> unsigned short
  981. DPRINTK("\nAlloc tmp region len 1 =%d\n",r_partial_info.w * 2 * r_partial_info.h);
  982. pu8Tmp_copy_ptr = pu8Framebuffer + (H_RESOLUTION * 2 * (r_partial_info.y) + ((r_partial_info.x) * 2));
  983. test_len=0;
  984. for(i=0;i<r_partial_info.h;i++)
  985. {
  986. memcpy(pu8Tmp_region+(i * r_partial_info.w * 2), pu8Tmp_copy_ptr, r_partial_info.w * 2);
  987. pu8Tmp_copy_ptr = pu8Tmp_copy_ptr + H_RESOLUTION*2;
  988. test_len = test_len + r_partial_info.w * 2;
  989. }
  990. DPRINTK("\nCopy Len 1 =%d\n",test_len);
  991. //rotate
  992. auofb_rotate_RGB565(r_partial_info.w, r_partial_info.h, (unsigned short*)
  993. pu8Tmp_region, (unsigned short*)pu8RotateBuffer);
  994. vfree(pu8Tmp_region);
  995. }
  996. DPRINTK("AUO EINK time rotate, jiffies: %lu, Elapsed time: %lu\n", jiffies, jiffies-tmp_clock);
  997. tmp_clock = jiffies;
  998. pu16ProcessPtr = (unsigned short*)pu8RotateBuffer;
  999. auofb_convert_RGB565(r_partial_info.w, r_partial_info.h, (unsigned short*)pu8RotateBuffer, pu16Translatebuffer);
  1000. if(isInitial)
  1001. {
  1002. stDisFrame.u16EpaperCommand = r_partial_info.u16EpaperCommand;
  1003. stDisFrame.tFrameRange.X = r_partial_info.y + 1;
  1004. stDisFrame.tFrameRange.Y = (H_RESOLUTION - (r_partial_info.x) - r_partial_info.w) +1;
  1005. stDisFrame.tFrameRange.W = r_partial_info.h;
  1006. stDisFrame.tFrameRange.H = r_partial_info.w;
  1007. stDisFrame.pFrameData = pu16Translatebuffer;
  1008. if(is_Epaper_Write_Ready())
  1009. auofb_Disp(stDisFrame);
  1010. if( (u16PrevMode != PARTIAL_DSP_MODE_4) && (u16PrevMode != PARTIAL_DSP_MODE_4_W) )
  1011. {
  1012. if((r_partial_info.mode == PARTIAL_DSP_MODE_4) || (r_partial_info.mode == PARTIAL_DSP_MODE_4_W))
  1013. {
  1014. if(is_Epaper_Write_Ready())
  1015. auofb_Disp(stDisFrame);
  1016. }
  1017. }
  1018. u16PrevMode = r_partial_info.mode;
  1019. update_ready = false;
  1020. }
  1021. }
  1022. else
  1023. {
  1024. if( (u16PrevMode == PARTIAL_DSP_MODE_4) || (u16PrevMode == PARTIAL_DSP_MODE_4_W) )
  1025. {
  1026. if(is_Epaper_Write_Ready())
  1027. Epaper_Init(AUO_EPAPER_PHYSICAL_H_RESOLUTION, AUO_EPAPER_PHYSICAL_V_RESOLUTION, 0, 0, 90, 0, 0, 0, 0, 0);
  1028. }
  1029. #endif //#ifdef EPD_HW_ROTATE_NO_MODE4
  1030. if( (r_partial_info.w == auo_mach_info.xres_virtual) && (r_partial_info.h == auo_mach_info.yres_virtual))
  1031. {
  1032. auofb_convert_RGB565(r_partial_info.w, r_partial_info.h, (unsigned short*)pu8Framebuffer, pu16Translatebuffer);
  1033. }
  1034. else
  1035. {
  1036. //pu8Tmp_region = vmalloc(r_partial_info.w * 2 * r_partial_info.h); // *2 --> unsigned short
  1037. DPRINTK("\nAlloc tmp region len 1 =%d\n",r_partial_info.w * 2 * r_partial_info.h);
  1038. pu8Tmp_copy_ptr = pu8Framebuffer + (H_RESOLUTION * 2 * (r_partial_info.y) + ((r_partial_info.x) * 2));
  1039. test_len=0;
  1040. for(i=0;i<r_partial_info.h;i++)
  1041. {
  1042. //memcpy(pu8Tmp_region+(i * r_partial_info.w * 2), pu8Tmp_copy_ptr, r_partial_info.w * 2);
  1043. memcpy(pu8RotateBuffer+(i * r_partial_info.w * 2), pu8Tmp_copy_ptr, r_partial_info.w * 2);
  1044. pu8Tmp_copy_ptr = pu8Tmp_copy_ptr + H_RESOLUTION*2;
  1045. test_len = test_len + r_partial_info.w * 2;
  1046. }
  1047. DPRINTK("\nCopy Len 1 =%d\n",test_len);
  1048. //rotate
  1049. /*auofb_rotate_RGB565(r_partial_info.w, r_partial_info.h, (unsigned short*)
  1050. pu8Tmp_region, (unsigned short*)pu8RotateBuffer);*/
  1051. //vfree(pu8Tmp_region);
  1052. pu16ProcessPtr = (unsigned short*)pu8RotateBuffer;
  1053. auofb_convert_RGB565(r_partial_info.w, r_partial_info.h, (unsigned short*)pu8RotateBuffer, pu16Translatebuffer);
  1054. }
  1055. if(isInitial)
  1056. {
  1057. stDisFrame.u16EpaperCommand = r_partial_info.u16EpaperCommand;
  1058. {
  1059. stDisFrame.tFrameRange.X = r_partial_info.x+1;
  1060. stDisFrame.tFrameRange.Y = r_partial_info.y+1;
  1061. stDisFrame.tFrameRange.W = r_partial_info.w;
  1062. stDisFrame.tFrameRange.H = r_partial_info.h;
  1063. }
  1064. stDisFrame.pFrameData = pu16Translatebuffer;
  1065. //stDisFrame.pFrameData = (unsigned short*)pu8Framebuffer; //do not need to convert
  1066. gStDisFrame = stDisFrame;
  1067. if(is_Epaper_Write_Ready())
  1068. auofb_Disp(stDisFrame);
  1069. if( (u16PrevMode != PARTIAL_DSP_MODE_4) && (u16PrevMode != PARTIAL_DSP_MODE_4_W) )
  1070. {
  1071. if((r_partial_info.mode == PARTIAL_DSP_MODE_4) || (r_partial_info.mode == PARTIAL_DSP_MODE_4_W))
  1072. {
  1073. if(is_Epaper_Write_Ready())
  1074. auofb_Disp(stDisFrame);
  1075. }
  1076. }
  1077. u16PrevMode = r_partial_info.mode;
  1078. update_ready = false;
  1079. DPRINTK("AUO EINK time display, jiffies: %lu, Elapsed time: %lu\n", jiffies, jiffies-tmp_clock);
  1080. tmp_clock = jiffies;
  1081. }
  1082. #ifdef EPD_HW_ROTATE_NO_MODE4
  1083. }
  1084. #endif
  1085. #else //sw rotate
  1086. #ifdef AUOFB_ROTATE
  1087. //check if the updated region is valid
  1088. if( (r_partial_info.w == auo_mach_info.xres_virtual) && (r_partial_info.h == auo_mach_info.yres_virtual))
  1089. {
  1090. //rotate
  1091. auofb_rotate_RGB565(auo_mach_info.xres_virtual, auo_mach_info.yres_virtual, (unsigned short*)
  1092. pu8Framebuffer, (unsigned short*)pu8RotateBuffer);
  1093. }
  1094. else
  1095. {
  1096. pu8Tmp_region = vmalloc(r_partial_info.w * 2 * r_partial_info.h); // *2 --> unsigned short
  1097. DPRINTK("\nAlloc tmp region len 1 =%d\n",r_partial_info.w * 2 * r_partial_info.h);
  1098. pu8Tmp_copy_ptr = pu8Framebuffer + (H_RESOLUTION * 2 * (r_partial_info.y) + ((r_partial_info.x) * 2));
  1099. test_len=0;
  1100. for(i=0;i<r_partial_info.h;i++)
  1101. {
  1102. memcpy(pu8Tmp_region+(i * r_partial_info.w * 2), pu8Tmp_copy_ptr, r_partial_info.w * 2);
  1103. pu8Tmp_copy_ptr = pu8Tmp_copy_ptr + H_RESOLUTION*2;
  1104. test_len = test_len + r_partial_info.w * 2;
  1105. }
  1106. DPRINTK("\nCopy Len 1 =%d\n",test_len);
  1107. //rotate
  1108. auofb_rotate_RGB565(r_partial_info.w, r_partial_info.h, (unsigned short*)
  1109. pu8Tmp_region, (unsigned short*)pu8RotateBuffer);
  1110. vfree(pu8Tmp_region);
  1111. }
  1112. DPRINTK("AUO EINK time rotate, jiffies: %lu, Elapsed time: %lu\n", jiffies, jiffies-tmp_clock);
  1113. tmp_clock = jiffies;
  1114. #endif
  1115. #ifdef AUOFB_ROTATE
  1116. pu16ProcessPtr = (unsigned short*)pu8RotateBuffer;
  1117. #else
  1118. pu16ProcessPtr = (unsigned short*)pu8Framebuffer;
  1119. #endif
  1120. #ifdef AUOFB_ROTATE
  1121. auofb_convert_RGB565(r_partial_info.w, r_partial_info.h, (unsigned short*)pu8RotateBuffer, pu16Translatebuffer);
  1122. #else
  1123. auofb_convert_RGB565(r_partial_info.w, r_partial_info.h, (unsigned short*)pu8Framebuffer, pu16Translatebuffer);
  1124. #endif
  1125. DPRINTK("AUO EINK time convert grey, jiffies: %lu, Elapsed time: %lu\n", jiffies, jiffies-tmp_clock);
  1126. tmp_clock = jiffies;
  1127. if(isInitial)
  1128. {
  1129. //DPRINTK("\n@@@@@@@@@@@@send i80...");
  1130. //stDisFrame.u16EpaperCommand = AUO_EPAPER_CMD_FULLDISP;
  1131. stDisFrame.u16EpaperCommand = r_partial_info.u16EpaperCommand;
  1132. /*
  1133. if(r_partial_info.mode == 0)
  1134. {
  1135. stDisFrame.tFrameRange.X = 1;
  1136. stDisFrame.tFrameRange.Y = 1;
  1137. //stDisFrame.tFrameRange.W = H_RESOLUTION;
  1138. //stDisFrame.tFrameRange.H = V_RESOLUTION;
  1139. //rotation test: still send 800x600
  1140. stDisFrame.tFrameRange.W = 800;
  1141. stDisFrame.tFrameRange.H = 600;
  1142. }
  1143. else*/
  1144. {
  1145. #ifdef AUOFB_ROTATE
  1146. stDisFrame.tFrameRange.X = r_partial_info.y + 1;
  1147. stDisFrame.tFrameRange.Y = (H_RESOLUTION - (r_partial_info.x) - r_partial_info.w) +1;
  1148. stDisFrame.tFrameRange.W = r_partial_info.h;
  1149. stDisFrame.tFrameRange.H = r_partial_info.w;
  1150. #else
  1151. stDisFrame.tFrameRange.X = r_partial_info.x;
  1152. stDisFrame.tFrameRange.Y = r_partial_info.y;
  1153. stDisFrame.tFrameRange.W = r_partial_info.w;
  1154. stDisFrame.tFrameRange.H = r_partial_info.h;
  1155. #endif
  1156. }
  1157. stDisFrame.pFrameData = pu16Translatebuffer;
  1158. //stDisFrame.pFrameData = (unsigned short*)pu8Framebuffer; //do not need to convert
  1159. gStDisFrame = stDisFrame;
  1160. if(is_Epaper_Write_Ready())
  1161. auofb_Disp(stDisFrame);
  1162. if( (u16PrevMode != PARTIAL_DSP_MODE_4) && (u16PrevMode != PARTIAL_DSP_MODE_4_W) )
  1163. {
  1164. if((r_partial_info.mode == PARTIAL_DSP_MODE_4) || (r_partial_info.mode == PARTIAL_DSP_MODE_4_W))
  1165. {
  1166. if(is_Epaper_Write_Ready())
  1167. auofb_Disp(stDisFrame);
  1168. }
  1169. }
  1170. u16PrevMode = r_partial_info.mode;
  1171. update_ready = false;
  1172. DPRINTK("AUO EINK time display, jiffies: %lu, Elapsed time: %lu\n", jiffies, jiffies-tmp_clock);
  1173. tmp_clock = jiffies;
  1174. }
  1175. #endif //#ifdef EPD_HW_ROTATE
  1176. if(stDisFrame.u16EpaperCommand != AUO_EPAPER_CMD_PRE_DISPLAY_START)
  1177. {
  1178. if((r_partial_info.mode == PARTIAL_DSP_MODE_4) || (r_partial_info.mode == PARTIAL_DSP_MODE_4_W))
  1179. msleep(20);
  1180. else
  1181. msleep(500);
  1182. }
  1183. //printk("pw=%d, pr=%d\n",pw,pr);
  1184. }
  1185. DPRINTK("AUO EINK time end: %lu, Total Elapsed time: %lu\n", jiffies, jiffies-total_clock);
  1186. LOCK_AUOFB_EXIT();
  1187. }
  1188. //interruptible_sleep_on_timeout(&update_display_wq, 1500);
  1189. interruptible_sleep_on(&update_display_wq);
  1190. }
  1191. else
  1192. thread_active = 0;
  1193. }
  1194. complete_and_exit(&update_display_thread_exited, 0);
  1195. }
  1196. static void start_boot_progress_bar_thread(void)
  1197. {
  1198. return;
  1199. init_waitqueue_head(&boot_progress_bar_wq);
  1200. if ( 0 > (boot_progress_bar_pid = kernel_thread(boot_progress_bar_thread, NULL, CLONE_KERNEL)) )
  1201. boot_progress_bar_pid = 0;
  1202. }
  1203. static void start_update_display_thread(void)
  1204. {
  1205. return;
  1206. init_waitqueue_head(&update_display_wq);
  1207. if ( 0 > (update_display_pid = kernel_thread(update_display_thread, NULL, CLONE_KERNEL)) )
  1208. update_display_pid = 0;
  1209. isInitial = true;
  1210. }
  1211. static void stop_boot_progress_bar_thread(void)
  1212. {
  1213. return;
  1214. if ( 0 < boot_progress_bar_pid )
  1215. if ( 0 == kill_proc(boot_progress_bar_pid, SIGKILL, 1) )
  1216. wait_for_completion(&boot_progress_bar_thread_exited);
  1217. }
  1218. static void stop_update_display_thread(void)
  1219. {
  1220. return;
  1221. if ( 0 < update_display_pid )
  1222. if ( 0 == kill_proc(update_display_pid, SIGKILL, 1) )
  1223. wait_for_completion(&update_display_thread_exited);
  1224. }
  1225. static panel_update_workqueue(struct work_struct *work)
  1226. {
  1227. return;
  1228. if ( 0 == LOCK_AUOFB_ENTRY() )
  1229. {
  1230. if(is_Epaper_Write_Ready())
  1231. {
  1232. DPRINTK("\n!!! Time's up!\n");
  1233. panel_timer_qisda.expires = jiffies + (10*HZ)/10;
  1234. //update_ready = true;
  1235. wake_up(&update_display_wq);
  1236. }
  1237. LOCK_AUOFB_EXIT();
  1238. }
  1239. //mod_timer(&panel_timer_qisda,panel_timer_qisda.expires);
  1240. //del_timer(&touch_iic_timer_qisda);
  1241. }
  1242. static void wake_update_display_thread(void)
  1243. {
  1244. return;
  1245. if ( 0 == LOCK_AUOFB_ENTRY() )
  1246. {
  1247. if(is_Epaper_Write_Ready())
  1248. {
  1249. update_ready = true;
  1250. wake_up(&update_display_wq);
  1251. }
  1252. LOCK_AUOFB_EXIT();
  1253. }
  1254. }
  1255. /**
  1256. * auofb_open - Optional function. Called when the framebuffer is
  1257. * first accessed.
  1258. * @info: frame buffer structure that represents a single frame buffer
  1259. * @user: tell us if the userland (value=1) or the console is accessing
  1260. * the framebuffer.
  1261. *
  1262. * This function is the first function called in the framebuffer api.
  1263. * Usually you don't need to provide this function. The case where it
  1264. * is used is to change from a text mode hardware state to a graphics
  1265. * mode state.
  1266. *
  1267. * Returns negative errno on error, or zero on success.
  1268. */
  1269. static int auofb_open(const struct fb_info *info, int user)
  1270. {
  1271. return 0;
  1272. }
  1273. /**
  1274. * auofb_release - Optional function. Called when the framebuffer
  1275. * device is closed.
  1276. * @info: frame buffer structure that represents a single frame buffer
  1277. * @user: tell us if the userland (value=1) or the console is accessing
  1278. * the framebuffer.
  1279. *
  1280. * Thus function is called when we close /dev/fb or the framebuffer
  1281. * console system is released. Usually you don't need this function.
  1282. * The case where it is usually used is to go from a graphics state
  1283. * to a text mode state.
  1284. *
  1285. * Returns negative errno on error, or zero on success.
  1286. */
  1287. static int auofb_release(const struct fb_info *info, int user)
  1288. {
  1289. return 0;
  1290. }
  1291. /**
  1292. * auofb_check_var - Optional function. Validates a var passed in.
  1293. * @var: frame buffer variable screen structure
  1294. * @info: frame buffer structure that represents a single frame buffer
  1295. *
  1296. * Checks to see if the hardware supports the state requested by
  1297. * var passed in. This function does not alter the hardware state!!!
  1298. * This means the data stored in struct fb_info and struct auo_par do
  1299. * not change. This includes the var inside of struct fb_info.
  1300. * Do NOT change these. This function can be called on its own if we
  1301. * intent to only test a mode and not actually set it. The stuff in
  1302. * modedb.c is a example of this. If the var passed in is slightly
  1303. * off by what the hardware can support then we alter the var PASSED in
  1304. * to what we can do.
  1305. *
  1306. * For values that are off, this function must round them _up_ to the
  1307. * next value that is supported by the hardware. If the value is
  1308. * greater than the highest value supported by the hardware, then this
  1309. * function must return -EINVAL.
  1310. *
  1311. * Exception to the above rule: Some drivers have a fixed mode, ie,
  1312. * the hardware is already set at boot up, and cannot be changed. In
  1313. * this case, it is more acceptable that this function just return
  1314. * a copy of the currently working var (info->var). Better is to not
  1315. * implement this function, as the upper layer will do the copying
  1316. * of the current var for you.
  1317. *
  1318. * Note: This is the only function where the contents of var can be
  1319. * freely adjusted after the driver has been registered. If you find
  1320. * that you have code outside of this function that alters the content
  1321. * of var, then you are doing something wrong. Note also that the
  1322. * contents of info->var must be left untouched at all times after
  1323. * driver registration.
  1324. *
  1325. * Returns negative errno on error, or zero on success.
  1326. */
  1327. static int auofb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
  1328. {
  1329. DPRINTK("check_var(var=%p, info=%p)\n", var, info);
  1330. switch (var->bits_per_pixel) {
  1331. case 4:
  1332. var->red = auo_fb_rgb_4.red;
  1333. var->green = auo_fb_rgb_4.green;
  1334. var->blue = auo_fb_rgb_4.blue;
  1335. var->transp = auo_fb_rgb_4.transp;
  1336. break;
  1337. case 8:
  1338. var->red = auo_fb_rgb_8.red;
  1339. var->green = auo_fb_rgb_8.green;
  1340. var->blue = auo_fb_rgb_8.blue;
  1341. var->transp = auo_fb_rgb_8.transp;
  1342. break;
  1343. case 16:
  1344. var->red = auo_fb_rgb_16.red;
  1345. var->green = auo_fb_rgb_16.green;
  1346. var->blue = auo_fb_rgb_16.blue;
  1347. var->transp = auo_fb_rgb_16.transp;
  1348. break;
  1349. case 24:
  1350. var->red = auo_fb_rgb_24.red;
  1351. var->green = auo_fb_rgb_24.green;
  1352. var->blue = auo_fb_rgb_24.blue;
  1353. var->transp = auo_fb_rgb_24.transp;
  1354. break;
  1355. case 32:
  1356. var->red = auo_fb_rgb_32.red;
  1357. var->green = auo_fb_rgb_32.green;
  1358. var->blue = auo_fb_rgb_32.blue;
  1359. var->transp = auo_fb_rgb_32.transp;
  1360. break;
  1361. }
  1362. return 0;
  1363. }
  1364. void auo_fb_activate_var(struct auo_fb_info *fbi,
  1365. struct fb_var_screeninfo *var)
  1366. {
  1367. DPRINTK("%s: var->bpp = %d\n", __FUNCTION__, var->bits_per_pixel);
  1368. switch (var->bits_per_pixel) {
  1369. case 4:
  1370. auo_mach_info.wincon0= S3C_WINCONx_HAWSWP_ENABLE | S3C_WINCONx_BURSTLEN_4WORD | S3C_WINCONx_BPPMODE_F_16BPP_565; // 4word burst, 16bpp,
  1371. auo_mach_info.wincon1= S3C_WINCONx_HAWSWP_ENABLE | S3C_WINCONx_BURSTLEN_4WORD | S3C_WINCONx_BPPMODE_F_16BPP_565 | S3C_WINCONx_BLD_PIX_PLANE | S3C_WINCONx_ALPHA_SEL_1; //
  1372. auo_mach_info.bpp= PIXEL_BPP4;
  1373. auo_mach_info.bytes_per_pixel= 1;
  1374. break;
  1375. case 8:
  1376. auo_mach_info.wincon0= S3C_WINCONx_BYTSWP_ENABLE | S3C_WINCONx_BURSTLEN_4WORD | S3C_WINCONx_BPPMODE_F_8BPP_PAL; // 4word burst, 8bpp-palletized,
  1377. auo_mach_info.wincon1= S3C_WINCONx_HAWSWP_ENABLE | S3C_WINCONx_BURSTLEN_4WORD | S3C_WINCONx_BPPMODE_F_16BPP_565 | S3C_WINCONx_BLD_PIX_PLANE | S3C_WINCONx_ALPHA_SEL_1; // 4word burst, 16bpp for OSD
  1378. auo_mach_info.bpp= PIXEL_BPP8;
  1379. auo_mach_info.bytes_per_pixel= 1;
  1380. auo_mach_info.wpalcon= S3C_WPALCON_W0PAL_24BIT;
  1381. break;
  1382. case 16:
  1383. auo_mach_info.wincon0= S3C_WINCONx_HAWSWP_ENABLE | S3C_WINCONx_BURSTLEN_4WORD | S3C_WINCONx_BPPMODE_F_16BPP_565; // 4word burst, 16bpp,
  1384. auo_mach_info.wincon1= S3C_WINCONx_HAWSWP_ENABLE | S3C_WINCONx_BURSTLEN_4WORD | S3C_WINCONx_BPPMODE_F_16BPP_565 | S3C_WINCONx_BLD_PIX_PLANE | S3C_WINCONx_ALPHA_SEL_1; //
  1385. auo_mach_info.bpp= PIXEL_BPP16;
  1386. auo_mach_info.bytes_per_pixel= 2;
  1387. break;
  1388. case 24:
  1389. auo_mach_info.wincon0= S3C_WINCONx_HAWSWP_DISABLE | S3C_WINCONx_BURSTLEN_16WORD | S3C_WINCONx_BPPMODE_F_24BPP_888; // 4word burst, 24bpp,,
  1390. auo_mach_info.wincon1= S3C_WINCONx_HAWSWP_DISABLE | S3C_WINCONx_BURSTLEN_16WORD | S3C_WINCONx_BPPMODE_F_24BPP_888 | S3C_WINCONx_BLD_PIX_PLANE | S3C_WINCONx_ALPHA_SEL_1; // 4word burst, 24bpp for OSD
  1391. auo_mach_info.bpp= PIXEL_BPP24;
  1392. auo_mach_info.bytes_per_pixel= 4;
  1393. break;
  1394. case 32:
  1395. auo_mach_info.bytes_per_pixel= 4;
  1396. break;
  1397. }
  1398. #if 0
  1399. /* write new registers */
  1400. __raw_writel(auo_mach_info.wincon0, S3C_WINCON0);
  1401. __raw_writel(auo_mach_info.wincon1, S3C_WINCON1);
  1402. __raw_writel(auo_mach_info.wpalcon, S3C_WPALCON);
  1403. //__raw_writel(mach_info.wincon0|S3C_WINCONx_ENWIN_F_ENABLE|S3C_WINCONx_BUFAUTOEN_ENABLE, S3C_WINCON0); /* Double buffer auto enable bit */
  1404. __raw_writel(auo_mach_info.wincon0|S3C_WINCONx_ENWIN_F_ENABLE, S3C_WINCON0);
  1405. __raw_writel(auo_mach_info.vidcon0|S3C_VIDCON0_ENVID_ENABLE|S3C_VIDCON0_ENVID_F_ENABLE, S3C_VIDCON0);
  1406. #endif
  1407. }
  1408. /**
  1409. * auofb_set_par - Optional function. Alters the hardware state.
  1410. * @info: frame buffer structure that represents a single frame buffer
  1411. *
  1412. * Using the fb_var_screeninfo in fb_info we set the resolution of the
  1413. * this particular framebuffer. This function alters the par AND the
  1414. * fb_fix_screeninfo stored in fb_info. It doesn't not alter var in
  1415. * fb_info since we are using that data. This means we depend on the
  1416. * data in var inside fb_info to be supported by the hardware.
  1417. *
  1418. * This function is also used to recover/restore the hardware to a
  1419. * known working state.
  1420. *
  1421. * auofb_check_var is always called before auofb_set_par to ensure that
  1422. * the contents of var is always valid.
  1423. *
  1424. * Again if you can't change the resolution you don't need this function.
  1425. *
  1426. * However, even if your hardware does not support mode changing,
  1427. * a set_par might be needed to at least initialize the hardware to
  1428. * a known working state, especially if it came back from another
  1429. * process that also modifies the same hardware, such as X.
  1430. *
  1431. * If this is the case, a combination such as the following should work:
  1432. *
  1433. * static int auofb_check_var(struct fb_var_screeninfo *var,
  1434. * struct fb_info *info)
  1435. * {
  1436. * *var = info->var;
  1437. * return 0;
  1438. * }
  1439. *
  1440. * static int auofb_set_par(struct fb_info *info)
  1441. * {
  1442. * init your hardware here
  1443. * }
  1444. *
  1445. * Returns negative errno on error, or zero on success.
  1446. */
  1447. static int auofb_set_par(struct fb_info *info)
  1448. {
  1449. struct auo_fb_info *fbi = (struct auo_fb_info *)info;
  1450. struct fb_var_screeninfo *var = &info->var;
  1451. if (var->bits_per_pixel == 16)
  1452. fbi->fb.fix.visual = FB_VISUAL_TRUECOLOR;
  1453. else if (var->bits_per_pixel == 32)
  1454. fbi->fb.fix.visual = FB_VISUAL_TRUECOLOR;
  1455. else
  1456. fbi->fb.fix.visual = FB_VISUAL_PSEUDOCOLOR;
  1457. fbi->fb.fix.line_length = var->width * auo_mach_info.bytes_per_pixel;
  1458. /* activate this new configuration */
  1459. auo_fb_activate_var(fbi, var);
  1460. return 0;
  1461. }
  1462. /**
  1463. * auofb_setcolreg - Optional function. Sets a color register.
  1464. * @regno: Which register in the CLUT we are programming
  1465. * @red: The red value which can be up to 16 bits wide
  1466. * @green: The green value which can be up to 16 bits wide
  1467. * @blue: The blue value which can be up to 16 bits wide.
  1468. * @transp: If supported, the alpha value which can be up to 16 bits wide.
  1469. * @info: frame buffer info structure
  1470. *
  1471. * Set a single color register. The values supplied have a 16 bit
  1472. * magnitude which needs to be scaled in this function for the hardware.
  1473. * Things to take into consideration are how many color registers, if
  1474. * any, are supported with the current color visual. With truecolor mode
  1475. * no color palettes are supported. Here a pseudo palette is created
  1476. * which we store the value in pseudo_palette in struct fb_info. For
  1477. * pseudocolor mode we have a limited color palette. To deal with this
  1478. * we can program what color is displayed for a particular pixel value.
  1479. * DirectColor is similar in that we can program each color field. If
  1480. * we have a static colormap we don't need to implement this function.
  1481. *
  1482. * Returns negative errno on error, or zero on success.
  1483. */
  1484. static int auofb_setcolreg(unsigned regno, unsigned red, unsigned green,
  1485. unsigned blue, unsigned transp,
  1486. const struct fb_info *info)
  1487. {
  1488. struct auo_fb_info *fbi = (struct auo_fb_info *)info;
  1489. unsigned int val;
  1490. switch (fbi->fb.fix.visual) {
  1491. case FB_VISUAL_TRUECOLOR:
  1492. /* true-colour, use pseuo-palette */
  1493. if (regno < 16) {
  1494. u32 *pal = fbi->fb.pseudo_palette;
  1495. /*
  1496. val = chan_to_field(red, fbi->fb.var.red);
  1497. val |= chan_to_field(green, fbi->fb.var.green);
  1498. val |= chan_to_field(blue, fbi->fb.var.blue);
  1499. */
  1500. pal[regno] = val;
  1501. }
  1502. break;
  1503. case FB_VISUAL_PSEUDOCOLOR:
  1504. if (regno < 256) {
  1505. /* currently assume RGB 8-8-8 mode -- for SONY */
  1506. val = ((red << 8) & 0xff0000);
  1507. val |= ((green >> 0) & 0xff00);
  1508. val |= ((blue >> 8) & 0xff);
  1509. DPRINTK("index = %d, val = 0x%8X\n", regno, val);
  1510. //schedule_palette_update(fbi, regno, val);
  1511. }
  1512. break;
  1513. default:
  1514. return 1; /* unknown type */
  1515. }
  1516. return 0;
  1517. }
  1518. /**
  1519. * auofb_pan_display - NOT a required function. Pans the display.
  1520. * @var: frame buffer variable screen structure
  1521. * @info: frame buffer structure that represents a single frame buffer
  1522. *
  1523. * Pan (or wrap, depending on the `vmode' field) the display using the
  1524. * `xoffset' and `yoffset' fields of the `var' structure.
  1525. * If the values don't fit, return -EINVAL.
  1526. *
  1527. * Returns negative errno on error, or zero on success.
  1528. */
  1529. static int auofb_pan_display(struct fb_var_screeninfo *var,
  1530. const struct fb_info *info)
  1531. {
  1532. /*
  1533. * If your hardware does not support panning, _do_ _not_ implement this
  1534. * function. Creating a dummy function will just confuse user apps.
  1535. */
  1536. /*
  1537. * Note that even if this function is fully functional, a setting of
  1538. * 0 in both xpanstep and ypanstep means that this function will never
  1539. * get called.
  1540. */
  1541. /* ... */
  1542. return 0;
  1543. }
  1544. /**
  1545. * auofb_blank - NOT a required function. Blanks the display.
  1546. * @blank_mode: the blank mode we want.
  1547. * @info: frame buffer structure that represents a single frame buffer
  1548. *
  1549. * Blank the screen if blank_mode != FB_BLANK_UNBLANK, else unblank.
  1550. * Return 0 if blanking succeeded, != 0 if un-/blanking failed due to
  1551. * e.g. a video mode which doesn't support it.
  1552. *
  1553. * Implements VESA suspend and powerdown modes on hardware that supports
  1554. * disabling hsync/vsync:
  1555. *
  1556. * FB_BLANK_NORMAL = display is blanked, syncs are on.
  1557. * FB_BLANK_HSYNC_SUSPEND = hsync off
  1558. * FB_BLANK_VSYNC_SUSPEND = vsync off
  1559. * FB_BLANK_POWERDOWN = hsync and vsync off
  1560. *
  1561. * If implementing this function, at least support FB_BLANK_UNBLANK.
  1562. * Return !0 for any modes that are unimplemented.
  1563. *
  1564. */
  1565. static int auofb_blank(int blank_mode, const struct fb_info *info)
  1566. {
  1567. /* ... */
  1568. return 0;
  1569. }
  1570. /* ------------ Accelerated Functions --------------------- */
  1571. /*
  1572. * We provide our own functions if we have hardware acceleration
  1573. * or non packed pixel format layouts. If we have no hardware
  1574. * acceleration, we can use a generic unaccelerated function. If using
  1575. * a pack pixel format just use the functions in cfb_*.c. Each file
  1576. * has one of the three different accel functions we support.
  1577. */
  1578. /**
  1579. * auofb_fillrect - REQUIRED function. Can use generic routines if
  1580. * non acclerated hardware and packed pixel based.
  1581. * Draws a rectangle on the screen.
  1582. *
  1583. * @info: frame buffer structure that represents a single frame buffer
  1584. * @region: The structure representing the rectangular region we
  1585. * wish to draw to.
  1586. *
  1587. * This drawing operation places/removes a retangle on the screen
  1588. * depending on the rastering operation with the value of color which
  1589. * is in the current color depth format.
  1590. */
  1591. void auofb_fillrect(struct fb_info *p, const struct fb_fillrect *region)
  1592. {
  1593. /* Meaning of struct fb_fillrect
  1594. *
  1595. * @dx: The x and y corrdinates of the upper left hand corner of the
  1596. * @dy: area we want to draw to.
  1597. * @width: How wide the rectangle is we want to draw.
  1598. * @height: How tall the rectangle is we want to draw.
  1599. * @color: The color to fill in the rectangle with.
  1600. * @rop: The raster operation. We can draw the rectangle with a COPY
  1601. * of XOR which provides erasing effect.
  1602. */
  1603. }
  1604. /**
  1605. * auofb_copyarea - REQUIRED function. Can use generic routines if
  1606. * non acclerated hardware and packed pixel based.
  1607. * Copies one area of the screen to another area.
  1608. *
  1609. * @info: frame buffer structure that represents a single frame buffer
  1610. * @area: Structure providing the data to copy the framebuffer contents
  1611. * from one region to another.
  1612. *
  1613. * This drawing operation copies a rectangular area from one area of the
  1614. * screen to another area.
  1615. */
  1616. void auofb_copyarea(struct fb_info *p, const struct fb_copyarea *area)
  1617. {
  1618. /*
  1619. * @dx: The x and y coordinates of the upper left hand corner of the
  1620. * @dy: destination area on the screen.
  1621. * @width: How wide the rectangle is we want to copy.
  1622. * @height: How tall the rectangle is we want to copy.
  1623. * @sx: The x and y coordinates of the upper left hand corner of the
  1624. * @sy: source area on the screen.
  1625. */
  1626. }
  1627. /**
  1628. * auofb_imageblit - REQUIRED function. Can use generic routines if
  1629. * non acclerated hardware and packed pixel based.
  1630. * Copies a image from system memory to the screen.
  1631. *
  1632. * @info: frame buffer structure that represents a single frame buffer
  1633. * @image: structure defining the image.
  1634. *
  1635. * This drawing operation draws a image on the screen. It can be a
  1636. * mono image (needed for font handling) or a color image (needed for
  1637. * tux).
  1638. */
  1639. void auofb_imageblit(struct fb_info *p, const struct fb_image *image)
  1640. {
  1641. /*
  1642. * @dx: The x and y coordinates of the upper left hand corner of the
  1643. * @dy: destination area to place the image on the screen.
  1644. * @width: How wide the image is we want to copy.
  1645. * @height: How tall the image is we want to copy.
  1646. * @fg_color: For mono bitmap images this is color data for
  1647. * @bg_color: the foreground and background of the image to
  1648. * write directly to the frmaebuffer.
  1649. * @depth: How many bits represent a single pixel for this image.
  1650. * @data: The actual data used to construct the image on the display.
  1651. * @cmap: The colormap used for color images.
  1652. */
  1653. /*
  1654. * The generic function, cfb_imageblit, expects that the bitmap scanlines are
  1655. * padded to the next byte. Most hardware accelerators may require padding to
  1656. * the next u16 or the next u32. If that is the case, the driver can specify
  1657. * this by setting info->pixmap.scan_align = 2 or 4. See a more
  1658. * comprehensive description of the pixmap below.
  1659. */
  1660. }
  1661. /**
  1662. * auofb_cursor - OPTIONAL. If your hardware lacks support
  1663. * for a cursor, leave this field NULL.
  1664. *
  1665. * @info: frame buffer structure that represents a single frame buffer
  1666. * @cursor: structure defining the cursor to draw.
  1667. *
  1668. * This operation is used to set or alter the properities of the
  1669. * cursor.
  1670. *
  1671. * Returns negative errno on error, or zero on success.
  1672. */
  1673. #if 0
  1674. int auofb_cursor(struct fb_info *info, struct fb_cursor *cursor)
  1675. {
  1676. /*
  1677. * @set: Which fields we are altering in struct fb_cursor
  1678. * @enable: Disable or enable the cursor
  1679. * @rop: The bit operation we want to do.
  1680. * @mask: This is the cursor mask bitmap.
  1681. * @dest: A image of the area we are going to display the cursor.
  1682. * Used internally by the driver.
  1683. * @hot: The hot spot.
  1684. * @image: The actual data for the cursor image.
  1685. *
  1686. * NOTES ON FLAGS (cursor->set):
  1687. *
  1688. * FB_CUR_SETIMAGE - the cursor image has changed (cursor->image.data)
  1689. * FB_CUR_SETPOS - the cursor position has changed (cursor->image.dx|dy)
  1690. * FB_CUR_SETHOT - the cursor hot spot has changed (cursor->hot.dx|dy)
  1691. * FB_CUR_SETCMAP - the cursor colors has changed (cursor->fg_color|bg_color)
  1692. * FB_CUR_SETSHAPE - the cursor bitmask has changed (cursor->mask)
  1693. * FB_CUR_SETSIZE - the cursor size has changed (cursor->width|height)
  1694. * FB_CUR_SETALL - everything has changed
  1695. *
  1696. * NOTES ON ROPs (cursor->rop, Raster Operation)
  1697. *
  1698. * ROP_XOR - cursor->image.data XOR cursor->mask
  1699. * ROP_COPY - curosr->image.data AND cursor->mask
  1700. *
  1701. * OTHER NOTES:
  1702. *
  1703. * - fbcon only supports a 2-color cursor (cursor->image.depth = 1)
  1704. * - The fb_cursor structure, @cursor, _will_ always contain valid
  1705. * fields, whether any particular bitfields in cursor->set is set
  1706. * or not.
  1707. */
  1708. }
  1709. /**
  1710. * auofb_rotate - NOT a required function. If your hardware
  1711. * supports rotation the whole screen then
  1712. * you would provide a hook for this.
  1713. *
  1714. * @info: frame buffer structure that represents a single frame buffer
  1715. * @angle: The angle we rotate the screen.
  1716. *
  1717. * This operation is used to set or alter the properities of the
  1718. * cursor.
  1719. */
  1720. void auofb_rotate(struct fb_info *info, int angle)
  1721. {
  1722. /* Will be deprecated */
  1723. }
  1724. /**
  1725. * auofb_poll - NOT a required function. The purpose of this
  1726. * function is to provide a way for some process
  1727. * to wait until a specific hardware event occurs
  1728. * for the framebuffer device.
  1729. *
  1730. * @info: frame buffer structure that represents a single frame buffer
  1731. * @wait: poll table where we store process that await a event.
  1732. */
  1733. void auofb_poll(struct fb_info *info, poll_table *wait)
  1734. {
  1735. }
  1736. /**
  1737. * auofb_sync - NOT a required function. Normally the accel engine
  1738. * for a graphics card take a specific amount of time.
  1739. * Often we have to wait for the accelerator to finish
  1740. * its operation before we can write to the framebuffer
  1741. * so we can have consistent display output.
  1742. *
  1743. * @info: frame buffer structure that represents a single frame buffer
  1744. *
  1745. * If the driver has implemented its own hardware-based drawing function,
  1746. * implementing this function is highly recommended.
  1747. */
  1748. void auofb_sync(struct fb_info *info)
  1749. {
  1750. }
  1751. #endif
  1752. /*
  1753. * Initialization
  1754. */
  1755. static int add_vma(struct vm_area_struct *vma)
  1756. {
  1757. struct fb_vma_list_entry *list_entry;
  1758. DPRINTK("\n@@@@@@@@@add_vma");
  1759. list_entry = kmalloc(sizeof(struct fb_vma_list_entry), GFP_KERNEL);
  1760. list_entry->vma = vma;
  1761. down_interruptible(&vma_list_semaphore);
  1762. list_add_tail((struct list_head *)list_entry, &vma_list);
  1763. up(&vma_list_semaphore);
  1764. return 0;
  1765. }
  1766. static struct fb_vma_list_entry *find_fb_vma_entry(struct vm_area_struct *vma)
  1767. {
  1768. struct list_head *ptr;
  1769. struct fb_vma_list_entry *entry;
  1770. DPRINTK("\n@@@@@@@@@find_fb_vma_entry");
  1771. for (ptr = vma_list.next; ptr != &vma_list; ptr = ptr->next) {
  1772. entry = list_entry(ptr, struct fb_vma_list_entry, list);
  1773. if (entry->vma == vma) {
  1774. return entry;
  1775. }
  1776. }
  1777. return NULL;
  1778. }
  1779. static int remove_vma(struct vm_area_struct *vma)
  1780. {
  1781. struct fb_vma_list_entry *entry;
  1782. DPRINTK("\n@@@@@@@@@remove_vma");
  1783. down_interruptible(&vma_list_semaphore);
  1784. entry = find_fb_vma_entry(vma);
  1785. if (entry != NULL) {
  1786. list_del((struct list_head *) entry);
  1787. kfree(entry);
  1788. }
  1789. up(&vma_list_semaphore);
  1790. return 0;
  1791. }
  1792. void auo_fb_vma_open(struct vm_area_struct *vma)
  1793. {
  1794. DPRINTK("\n@@@@@@@@@auo_fb_vma_open");
  1795. add_vma(vma);
  1796. }
  1797. void auo_fb_vma_close(struct vm_area_struct *vma)
  1798. {
  1799. DPRINTK("\n@@@@@@@@@auo_fb_vma_close");
  1800. remove_vma(vma);
  1801. }
  1802. struct page *auo_fb_vma_nopage( struct vm_area_struct *vma, unsigned long address, int *type)
  1803. {
  1804. unsigned long offset;
  1805. struct page *page = NOPAGE_SIGBUS;
  1806. //DPRINTK("\n@@@@@@@@@auo_fb_vma_nopage");
  1807. offset = address - vma->vm_start + (vma->vm_pgoff << PAGE_SHIFT);
  1808. if (offset > videomemorysize) {
  1809. return page;
  1810. }
  1811. page = videopages[offset >> PAGE_SHIFT];
  1812. get_page(page);
  1813. return page;
  1814. }
  1815. static struct vm_operations_struct auo_fb_vma_ops = {
  1816. open: auo_fb_vma_open,
  1817. close: auo_fb_vma_close,
  1818. nopage: auo_fb_vma_nopage,
  1819. };
  1820. int auo_fb_mmap(
  1821. //struct fb_info *info,
  1822. struct file *file,
  1823. struct vm_area_struct *vma)
  1824. {
  1825. DPRINTK("\n@@@@@@@@@auo_fb_mmap");
  1826. DPRINTK("\n@@@@@@@@@@mmap size=%d\n", vma->vm_end - vma->vm_start);
  1827. vma->vm_ops = &auo_fb_vma_ops;
  1828. vma->vm_flags |= VM_RESERVED;
  1829. auo_fb_vma_open(vma);
  1830. /* unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
  1831. if(offset >= __pa(high_memory) || (file->f_flags & O_SYNC))
  1832. vma->vm_flags |= VM_IO;
  1833. vma->vm_flags |= VM_RESERVED;
  1834. DPRINTK("\noffset=%d",offset);
  1835. offset += S3C24XX_PA_LCD;
  1836. if(remap_pfn_range(vma, vma->vm_start, offset >> PAGE_SHIFT, vma->vm_end - vma->vm_start, vma->vm_page_prot))
  1837. return -EAGAIN;
  1838. */
  1839. return 0;
  1840. }
  1841. static int auo_fb_is_update_region_legal(void)
  1842. {
  1843. #ifdef EPD_HW_ROTATE
  1844. #ifdef EPD_HW_ROTATE_NO_MODE4
  1845. if((w_partial_info.mode == PARTIAL_DSP_MODE_4) || (w_partial_info.mode == PARTIAL_DSP_MODE_4_W))
  1846. {
  1847. if( (w_partial_info.x > (H_RESOLUTION-1)) ||
  1848. (w_partial_info.y > (V_RESOLUTION-1)) ||
  1849. (w_partial_info.w == 0) ||
  1850. (w_partial_info.h == 0) ||
  1851. (w_partial_info.w > H_RESOLUTION) ||
  1852. (w_partial_info.h > V_RESOLUTION))
  1853. return -EINVAL;
  1854. //fill data to legal region
  1855. if((w_partial_info.x + w_partial_info.w) > H_RESOLUTION)
  1856. w_partial_info.w = H_RESOLUTION - w_partial_info.x;
  1857. if((w_partial_info.y + w_partial_info.h) > V_RESOLUTION)
  1858. w_partial_info.h = V_RESOLUTION - w_partial_info.y;
  1859. if(((w_partial_info.y+1) % 2)==0) //In EPD view, X is not odd
  1860. {
  1861. DPRINTK("\nw_partial_info.y=%d\n",w_partial_info.y);
  1862. w_partial_info.y--;
  1863. w_partial_info.h++; //because w_partial_info.y--
  1864. }
  1865. if(w_partial_info.h < UPDATE_WIDTH_MIN)
  1866. w_partial_info.h = UPDATE_WIDTH_MIN;
  1867. if((w_partial_info.h % UPDATE_WIDTH_MULTIPLES) != 0) //In EPD view, w is not times of UPDATE_WIDTH_MULTIPLES
  1868. {
  1869. DPRINTK("\nw_partial_info.h=%d\n",w_partial_info.h);
  1870. int tmp_offset = UPDATE_WIDTH_MULTIPLES - w_partial_info.h%UPDATE_WIDTH_MULTIPLES;
  1871. w_partial_info.h = w_partial_info.h + tmp_offset;
  1872. }
  1873. if(((w_partial_info.y + 1) + w_partial_info.h)> (V_RESOLUTION+1))
  1874. {
  1875. w_partial_info.y = V_RESOLUTION - w_partial_info.h ;
  1876. //w_partial_info.h = V_RESOLUTION;
  1877. //w_partial_info.y = 0;
  1878. }
  1879. if(w_partial_info.w < UPDATE_HEIGHT_MIN)
  1880. w_partial_info.w = UPDATE_HEIGHT_MIN;
  1881. if((((H_RESOLUTION - (w_partial_info.x) - w_partial_info.w) +1) % 2)==0) //In EPD view, Y is not odd
  1882. {
  1883. //w_partial_info.x--;
  1884. w_partial_info.w = w_partial_info.w+1;
  1885. }
  1886. if((w_partial_info.w % UPDATE_HEIGHT_MULTIPLES) != 0) //In EPD view, h is not times of UPDATE_HEIGHT_MULTIPLES
  1887. {
  1888. DPRINTK("\nw_partial_info.w=%d\n",w_partial_info.w);
  1889. int tmp_offset = UPDATE_HEIGHT_MULTIPLES - w_partial_info.w%UPDATE_HEIGHT_MULTIPLES;
  1890. w_partial_info.w = w_partial_info.w + tmp_offset;
  1891. w_partial_info.x = w_partial_info.x - tmp_offset;
  1892. }
  1893. if((((H_RESOLUTION - (w_partial_info.x) - w_partial_info.w) +1) + w_partial_info.w)> (H_RESOLUTION+1))
  1894. {
  1895. w_partial_info.x = H_RESOLUTION - w_partial_info.w ;
  1896. }
  1897. //check (x,y,w,h) again
  1898. if(((w_partial_info.y + 1) < 1) ||
  1899. (((H_RESOLUTION - (w_partial_info.x) - w_partial_info.w) +1) < 1) ||
  1900. (w_partial_info.h < UPDATE_HEIGHT_MIN) ||
  1901. (w_partial_info.w < UPDATE_WIDTH_MIN) ||
  1902. ((w_partial_info.y + 1 + w_partial_info.h)>(V_RESOLUTION+1)) ||
  1903. (((H_RESOLUTION - (w_partial_info.x) - w_partial_info.w) +1 + w_partial_info.w)>(H_RESOLUTION+1)) ||
  1904. (((w_partial_info.y+1) % 2)==0) ||
  1905. ((((H_RESOLUTION - (w_partial_info.x) - w_partial_info.w) +1) % 2)==0) ||
  1906. ((w_partial_info.h % UPDATE_WIDTH_MULTIPLES) != 0) ||
  1907. ((w_partial_info.w % UPDATE_HEIGHT_MULTIPLES) != 0)
  1908. )
  1909. {
  1910. printk("\nAUOFB ERROR: (X,Y,W,L)=(%d,%d,%d,%d)",w_partial_info.y + 1, (H_RESOLUTION - (w_partial_info.x) - w_partial_info.w) +1, w_partial_info.h, w_partial_info.w);
  1911. return -EFAULT;
  1912. }
  1913. return 0;
  1914. }
  1915. #endif
  1916. printk("\nAUOFB: Check coordinator"); //do not remove this printk
  1917. //check (X,Y,W,H) first time
  1918. if( (w_partial_info.x > (H_RESOLUTION-1)) ||
  1919. (w_partial_info.y > (V_RESOLUTION-1)) ||
  1920. (w_partial_info.w == 0) ||
  1921. (w_partial_info.h == 0) ||
  1922. (w_partial_info.w > H_RESOLUTION) ||
  1923. (w_partial_info.h > V_RESOLUTION))
  1924. return -EINVAL;
  1925. //fill data to legal region
  1926. if((w_partial_info.x + w_partial_info.w) > H_RESOLUTION)
  1927. w_partial_info.w = H_RESOLUTION - w_partial_info.x;
  1928. if((w_partial_info.y + w_partial_info.h) > V_RESOLUTION)
  1929. w_partial_info.h = V_RESOLUTION - w_partial_info.y;
  1930. if(((w_partial_info.x+1) % 2)==0) //X is not odd
  1931. {
  1932. DPRINTK("\nw_partial_info.x=%d\n",w_partial_info.x);
  1933. w_partial_info.x--;
  1934. w_partial_info.w++; //because w_partial_info.x--
  1935. }
  1936. /*
  1937. if(w_partial_info.w < 12)
  1938. w_partial_info.w = 12;
  1939. if((w_partial_info.w % 4) != 0) //w is not times of 4
  1940. {
  1941. DPRINTK("\nw_partial_info.w=%d\n",w_partial_info.w);
  1942. int tmp_offset = 4 - w_partial_info.w%4;
  1943. w_partial_info.w = w_partial_info.w + tmp_offset;
  1944. }
  1945. */
  1946. if(w_partial_info.w < UPDATE_WIDTH_MIN)
  1947. w_partial_info.w = UPDATE_WIDTH_MIN;
  1948. if((w_partial_info.w % UPDATE_WIDTH_MULTIPLES) != 0) //w is not times of UPDATE_WIDTH_MULTIPLES
  1949. {
  1950. DPRINTK("\nw_partial_info.w=%d\n",w_partial_info.w);
  1951. int tmp_offset = UPDATE_WIDTH_MULTIPLES - w_partial_info.w%UPDATE_WIDTH_MULTIPLES;
  1952. w_partial_info.w = w_partial_info.w + tmp_offset;
  1953. }
  1954. //test end
  1955. if(((w_partial_info.x + 1) + w_partial_info.w)> (H_RESOLUTION+1))
  1956. {
  1957. w_partial_info.x = H_RESOLUTION - w_partial_info.w ;
  1958. }
  1959. if(w_partial_info.h < UPDATE_HEIGHT_MIN)
  1960. w_partial_info.h = UPDATE_HEIGHT_MIN;
  1961. if(((w_partial_info.y+1) % 2)==0) //Y is not odd
  1962. {
  1963. if(w_partial_info.y > 3)
  1964. {
  1965. w_partial_info.y = w_partial_info.y -3;
  1966. w_partial_info.h = w_partial_info.h+3;
  1967. }
  1968. else
  1969. {
  1970. w_partial_info.y--;
  1971. w_partial_info.h = w_partial_info.h+1;
  1972. }
  1973. }
  1974. /*
  1975. if((w_partial_info.h % 2) != 0) //h is not times of 2
  1976. {
  1977. DPRINTK("\nw_partial_info.h=%d\n",w_partial_info.h);
  1978. int tmp_offset = 2 - w_partial_info.h%2;
  1979. w_partial_info.h = w_partial_info.h + tmp_offset;
  1980. }
  1981. */
  1982. if((w_partial_info.h % UPDATE_HEIGHT_MULTIPLES) != 0) //h is not times of UPDATE_HEIGHT_MULTIPLES
  1983. {
  1984. DPRINTK("\nw_partial_info.h=%d\n",w_partial_info.h);
  1985. int tmp_offset = UPDATE_HEIGHT_MULTIPLES - w_partial_info.h%UPDATE_HEIGHT_MULTIPLES;
  1986. w_partial_info.h = w_partial_info.h + tmp_offset;
  1987. }
  1988. if(((w_partial_info.y + 1) + w_partial_info.h)> (V_RESOLUTION+1))
  1989. {
  1990. w_partial_info.y = V_RESOLUTION - w_partial_info.h ;
  1991. }
  1992. //check (x,y,w,h) again
  1993. if(((w_partial_info.x + 1) < 1) ||
  1994. ((w_partial_info.y +1) < 1) ||
  1995. (w_partial_info.w < UPDATE_WIDTH_MIN) ||
  1996. (w_partial_info.h < UPDATE_HEIGHT_MIN) ||
  1997. ((w_partial_info.x + 1 + w_partial_info.w)>(H_RESOLUTION+1)) ||
  1998. ((w_partial_info.y +1 + w_partial_info.h)>(V_RESOLUTION+1)) ||
  1999. (((w_partial_info.x+1) % 2)==0) ||
  2000. (((w_partial_info.y +1) % 2)==0) ||
  2001. ((w_partial_info.w %UPDATE_WIDTH_MULTIPLES) != 0) ||
  2002. // ((w_partial_info.h % 2) != 0)
  2003. ((w_partial_info.h % UPDATE_HEIGHT_MULTIPLES) != 0)
  2004. )
  2005. {
  2006. printk("\nAUOFB ERROR 111: (X,Y,W,L)=(%d,%d,%d,%d)",w_partial_info.x + 1, w_partial_info.y + 1, w_partial_info.w, w_partial_info.h);
  2007. return -EFAULT;
  2008. }
  2009. #else
  2010. #ifdef AUOFB_ROTATE
  2011. //check (X,Y,W,H) first time
  2012. if( (w_partial_info.x > (H_RESOLUTION-1)) ||
  2013. (w_partial_info.y > (V_RESOLUTION-1)) ||
  2014. (w_partial_info.w == 0) ||
  2015. (w_partial_info.h == 0) ||
  2016. (w_partial_info.w > H_RESOLUTION) ||
  2017. (w_partial_info.h > V_RESOLUTION))
  2018. return -EINVAL;
  2019. //fill data to legal region
  2020. if((w_partial_info.x + w_partial_info.w) > H_RESOLUTION)
  2021. w_partial_info.w = H_RESOLUTION - w_partial_info.x;
  2022. if((w_partial_info.y + w_partial_info.h) > V_RESOLUTION)
  2023. w_partial_info.h = V_RESOLUTION - w_partial_info.y;
  2024. if(((w_partial_info.y+1) % 2)==0) //In EPD view, X is not odd
  2025. {
  2026. DPRINTK("\nw_partial_info.y=%d\n",w_partial_info.y);
  2027. w_partial_info.y--;
  2028. w_partial_info.h++; //because w_partial_info.y--
  2029. }
  2030. if(w_partial_info.h < UPDATE_WIDTH_MIN)
  2031. w_partial_info.h = UPDATE_WIDTH_MIN;
  2032. if((w_partial_info.h % UPDATE_WIDTH_MULTIPLES) != 0) //In EPD view, w is not times of UPDATE_WIDTH_MULTIPLES
  2033. {
  2034. DPRINTK("\nw_partial_info.h=%d\n",w_partial_info.h);
  2035. int tmp_offset = UPDATE_WIDTH_MULTIPLES - w_partial_info.h%UPDATE_WIDTH_MULTIPLES;
  2036. w_partial_info.h = w_partial_info.h + tmp_offset;
  2037. }
  2038. if(((w_partial_info.y + 1) + w_partial_info.h)> (V_RESOLUTION+1))
  2039. {
  2040. w_partial_info.y = V_RESOLUTION - w_partial_info.h ;
  2041. //w_partial_info.h = V_RESOLUTION;
  2042. //w_partial_info.y = 0;
  2043. }
  2044. if(w_partial_info.w < UPDATE_HEIGHT_MIN)
  2045. w_partial_info.w = UPDATE_HEIGHT_MIN;
  2046. if((((H_RESOLUTION - (w_partial_info.x) - w_partial_info.w) +1) % 2)==0) //In EPD view, Y is not odd
  2047. {
  2048. //w_partial_info.x--;
  2049. w_partial_info.w = w_partial_info.w+1;
  2050. }
  2051. if((w_partial_info.w % UPDATE_HEIGHT_MULTIPLES) != 0) //In EPD view, h is not times of 2
  2052. {
  2053. DPRINTK("\nw_partial_info.w=%d\n",w_partial_info.w);
  2054. int tmp_offset = UPDATE_HEIGHT_MULTIPLES - w_partial_info.w%UPDATE_HEIGHT_MULTIPLES;
  2055. w_partial_info.w = w_partial_info.w + tmp_offset;
  2056. w_partial_info.x = w_partial_info.x - tmp_offset;
  2057. }
  2058. if((((H_RESOLUTION - (w_partial_info.x) - w_partial_info.w) +1) + w_partial_info.w)> (H_RESOLUTION+1))
  2059. {
  2060. w_partial_info.x = H_RESOLUTION - w_partial_info.w ;
  2061. }
  2062. //check (x,y,w,h) again
  2063. if(((w_partial_info.y + 1) < 1) ||
  2064. (((H_RESOLUTION - (w_partial_info.x) - w_partial_info.w) +1) < 1) ||
  2065. (w_partial_info.h < UPDATE_WIDTH_MIN) ||
  2066. (w_partial_info.w < UPDATE_HEIGHT_MIN) ||
  2067. ((w_partial_info.y + 1 + w_partial_info.h)>(V_RESOLUTION+1)) ||
  2068. (((H_RESOLUTION - (w_partial_info.x) - w_partial_info.w) +1 + w_partial_info.w)>(H_RESOLUTION+1)) ||
  2069. (((w_partial_info.y+1) % 2)==0) ||
  2070. ((((H_RESOLUTION - (w_partial_info.x) - w_partial_info.w) +1) % 2)==0) ||
  2071. ((w_partial_info.h % UPDATE_WIDTH_MULTIPLES) != 0) ||
  2072. ((w_partial_info.w % UPDATE_HEIGHT_MULTIPLES) != 0)
  2073. )
  2074. {
  2075. printk("\nAUOFB ERROR: (X,Y,W,L)=(%d,%d,%d,%d)",w_partial_info.y + 1, (H_RESOLUTION - (w_partial_info.x) - w_partial_info.w) +1, w_partial_info.h, w_partial_info.w);
  2076. return -EFAULT;
  2077. }
  2078. #endif //#ifdef AUOFB_ROTATE
  2079. #endif //#ifdef EPD_HW_ROTATE
  2080. return 0;
  2081. }
  2082. #ifdef EPD_ENABLE_PRE_DISPLAY
  2083. int auo_fb_pre_display(void)
  2084. {
  2085. if ( 0 == LOCK_AUOFB_ENTRY() )
  2086. {
  2087. _partial_update_info tmp_partial_info;
  2088. tmp_partial_info.x = 0;
  2089. tmp_partial_info.y = 0;
  2090. tmp_partial_info.w = H_RESOLUTION;
  2091. tmp_partial_info.h = V_RESOLUTION;
  2092. tmp_partial_info.mode = 0;
  2093. tmp_partial_info.u16EpaperCommand = AUO_EPAPER_CMD_PRE_DISPLAY_START;
  2094. Epaper_Set_Partial_Update_Mode(tmp_partial_info.mode);
  2095. if(!auofb_update_queue_is_full())
  2096. auofb_update_queue_put(tmp_partial_info);
  2097. LOCK_AUOFB_EXIT();
  2098. }
  2099. // don't wakeup display thread.
  2100. //wake_update_display_thread(); w
  2101. //printk("\nauo_fb_pre_display\n");
  2102. }
  2103. #endif
  2104. #if defined(EPD_ENABLE_PRE_DISPLAY)
  2105. /*****************************************************************************/
  2106. void auo_fb_put_epd_init_command(void)
  2107. {
  2108. // printk("*** +%s\n", __func__);
  2109. if ( 0 == LOCK_AUOFB_ENTRY() )
  2110. {
  2111. _partial_update_info tmp_partial_info;
  2112. tmp_partial_info.x = 0;
  2113. tmp_partial_info.y = 0;
  2114. tmp_partial_info.w = 0;
  2115. tmp_partial_info.h = 0;
  2116. tmp_partial_info.mode = 0;
  2117. tmp_partial_info.u16EpaperCommand = AUO_EPAPER_CMD_INIT;
  2118. if(!auofb_update_queue_is_full())
  2119. {
  2120. // printk("*** %s: put init command\n", __func__);
  2121. auofb_update_queue_put(tmp_partial_info);
  2122. }
  2123. LOCK_AUOFB_EXIT();
  2124. }
  2125. // printk("*** -%s\n", __func__);
  2126. }
  2127. /*****************************************************************************/
  2128. #endif
  2129. int auo_fb_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg)
  2130. {
  2131. struct auo_fb_info *fbi = container_of(info, struct auo_fb_info, fb);
  2132. struct fb_var_screeninfo *var= &fbi->fb.var;
  2133. void __user *argp = (void __user *)arg;
  2134. struct vm_area_struct *tvma;
  2135. struct page *tpage;
  2136. u_int virt_addr, phys_addr, offset;
  2137. struct mm_struct *mm = current->mm;
  2138. int brightness;
  2139. auo_win_info_t win_info_from_app;
  2140. auo_color_key_info_t colkey_info;
  2141. auo_color_val_info_t colval_info;
  2142. bool panel_status;
  2143. /*
  2144. 0xFF00 ~ 0xFF7F : Control TCON
  2145. 0xFF80 ~ 0xFF9F : Customer
  2146. 0xFFA0 ~ 0xFFDF : Read info from TCON
  2147. 0xFFE0 ~ 0xFFFF : Utility or test
  2148. */
  2149. switch(cmd){
  2150. /* [MTR] */
  2151. case IOCTL_AUO_SENDCOMMAND:
  2152. {
  2153. sAUOCommand cmd;
  2154. unsigned char buffer[2048];
  2155. unsigned char *user_buffer;
  2156. unsigned long user_buflen, copysize, copysize16;
  2157. unsigned short *ptr16;
  2158. if (copy_from_user (&cmd, argp, sizeof(cmd)))
  2159. return -EFAULT;
  2160. /* Now execute the command */
  2161. Epaper_sendCommandStart(&cmd);
  2162. ///INFOL(INFO_VERBOSE, ("/* Seventh: Send data if needed */"));
  2163. if (GET_COMMAND_HAVE_DATA(cmd.cmd) != 0)
  2164. {
  2165. //INFOL(INFO_VERBOSE, ("Yes, we have data to send!"));
  2166. user_buflen = cmd.datalen;
  2167. user_buffer = (unsigned char *)cmd.data;
  2168. while (user_buflen != 0)
  2169. {
  2170. copysize = user_buflen;
  2171. if (user_buflen > sizeof(buffer))
  2172. copysize = sizeof(buffer);
  2173. if ( copy_from_user(buffer, user_buffer, copysize) )
  2174. return -EFAULT;
  2175. copysize16 = (copysize + 1) / 2;
  2176. //printk(KERN_ERR "cp16=%ld cp=%ld\n", copysize16, copysize);
  2177. ptr16 = (unsigned short *) buffer;
  2178. Epaper_sendData(buffer, copysize16);
  2179. user_buflen -= copysize;
  2180. user_buffer += copysize;
  2181. }
  2182. }
  2183. Epaper_sendCommandEnd(&cmd);
  2184. }
  2185. break;
  2186. /* [/MTR] */
  2187. //*********************************************************************************
  2188. case AUOFB_IOCTL_TCON_GET_BUSY_STATUS: //busy pin
  2189. panel_status = is_Epaper_Write_Ready_No_Wait();
  2190. if(copy_to_user((void *)arg, (const void *) &panel_status, sizeof(bool)))
  2191. return -EFAULT;
  2192. break;
  2193. case AUOFB_IOCTL_SW_REFRESH:
  2194. //DPRINTK("\nAUOFB full update!!!");
  2195. if ( 0 == LOCK_AUOFB_ENTRY() )
  2196. {
  2197. w_partial_info.x = 0;
  2198. w_partial_info.y = 0;
  2199. w_partial_info.w = H_RESOLUTION;
  2200. w_partial_info.h = V_RESOLUTION;
  2201. w_partial_info.mode = 0;
  2202. Epaper_Set_Partial_Update_Mode(w_partial_info.mode);
  2203. w_partial_info.u16EpaperCommand = AUO_EPAPER_CMD_PARTIALDISP;
  2204. if(!auofb_update_queue_is_full())
  2205. auofb_update_queue_put(w_partial_info);
  2206. LOCK_AUOFB_EXIT();
  2207. }
  2208. wake_update_display_thread();
  2209. break;
  2210. case AUOFB_IOCTL_TCON_PARTIAL_UPDATE:
  2211. DPRINTK("\nAUOFB partial update!!!");
  2212. if ( 0 == LOCK_AUOFB_ENTRY() )
  2213. {
  2214. //if(is_Epaper_Write_Ready())
  2215. {
  2216. if(copy_from_user(&w_partial_info, (_partial_update_info *) arg, sizeof(_partial_update_info)))
  2217. return -EFAULT;
  2218. DPRINTK("\nAUOFB partial update, (%d,%d,%d,%d,%d)!!!",
  2219. w_partial_info.mode, w_partial_info.x, w_partial_info.y, w_partial_info.w, w_partial_info.h);
  2220. if(auo_fb_is_update_region_legal() != 0)
  2221. {
  2222. LOCK_AUOFB_EXIT();
  2223. return -EFAULT;
  2224. }
  2225. if( (w_partial_info.w*w_partial_info.h) >= u32FullUpdateThreshold )
  2226. {
  2227. w_partial_info.x = 0;
  2228. w_partial_info.y = 0;
  2229. w_partial_info.w = H_RESOLUTION;
  2230. w_partial_info.h = V_RESOLUTION;
  2231. }
  2232. Epaper_Set_Partial_Update_Mode(w_partial_info.mode);
  2233. w_partial_info.u16EpaperCommand = AUO_EPAPER_CMD_PARTIALDISP;
  2234. if(!auofb_update_queue_is_full())
  2235. auofb_update_queue_put(w_partial_info);
  2236. }
  2237. LOCK_AUOFB_EXIT();
  2238. }
  2239. wake_update_display_thread();
  2240. break;
  2241. case AUOFB_IOCTL_TCON_SHUTDOWN: //shutdown TCON
  2242. if(is_Epaper_Write_Ready())
  2243. {
  2244. //AUO T-CON Standby
  2245. msleep(100);
  2246. Epaper_Enter_Standby_Mode(1);
  2247. msleep(100);
  2248. //AUO T-CON Sleep
  2249. Epaper_Enter_Sleep_Mode(1);
  2250. msleep(5);
  2251. //Shutdown T-CON Power
  2252. Epaper_Power(0);
  2253. //Shutdown i80 of s3c
  2254. EPaper_CloseLcdPort();
  2255. //msleep(1000);
  2256. u32PowerState = EN_EPD_DEVICE_POWER_STATE_D3;
  2257. }
  2258. else
  2259. return -EFAULT;
  2260. break;
  2261. case AUOFB_IOCTL_TCON_STANDBY: //TCON Standby
  2262. if(u32PowerState == EN_EPD_DEVICE_POWER_STATE_D0)
  2263. {
  2264. if(is_Epaper_Write_Ready())
  2265. {
  2266. msleep(100);
  2267. Epaper_Enter_Standby_Mode(1);
  2268. msleep(100); //TCON need at least 64ms to enter standby mode
  2269. u32PowerState = EN_EPD_DEVICE_POWER_STATE_D1;
  2270. }
  2271. else
  2272. return -EFAULT;
  2273. }
  2274. break;
  2275. case AUOFB_IOCTL_TCON_WAKEUP: //TCON Wakeup (leave standby)
  2276. if(u32PowerState == EN_EPD_DEVICE_POWER_STATE_D1)
  2277. {
  2278. Epaper_Enter_Standby_Mode(0);
  2279. msleep(100);
  2280. u32PowerState = EN_EPD_DEVICE_POWER_STATE_D0;
  2281. }
  2282. break;
  2283. case AUOFB_IOCTL_TCON_SLEEP: //TCON Sleep
  2284. if(u32PowerState == EN_EPD_DEVICE_POWER_STATE_D1)
  2285. {
  2286. Epaper_Enter_Sleep_Mode(1);
  2287. msleep(5);
  2288. u32PowerState = EN_EPD_DEVICE_POWER_STATE_D2;
  2289. }
  2290. break;
  2291. case AUOFB_IOCTL_TCON_NO_SLEEP: //TCON no Sleep
  2292. if(u32PowerState == EN_EPD_DEVICE_POWER_STATE_D2)
  2293. {
  2294. Epaper_Enter_Sleep_Mode(0);
  2295. msleep(5);
  2296. u32PowerState = EN_EPD_DEVICE_POWER_STATE_D1;
  2297. }
  2298. break;
  2299. case AUOFB_IOCTL_TCON_REFRESH: //Display refresh
  2300. if(is_Epaper_Write_Ready())
  2301. Epaper_Display_Refresh();
  2302. else
  2303. return -EFAULT;
  2304. break;
  2305. case AUOFB_IOCTL_SET_UPDATE_THRESHOLD: //Set u32FullUpdateThreshold
  2306. if(copy_from_user(&u32FullUpdateThreshold, (unsigned long*) arg, sizeof(unsigned long)))
  2307. return -EFAULT;
  2308. break;
  2309. case AUOFB_IOCTL_TCON_RESET: //TCON RESET command
  2310. if(is_Epaper_Write_Ready())
  2311. Epaper_Reset();
  2312. else
  2313. return -EFAULT;
  2314. break;
  2315. case AUOFB_IOCTL_TCON_INIT:
  2316. break;
  2317. case AUOFB_IOCTL_TCON_UPDATE_LUT:
  2318. {
  2319. unsigned char* lut_data = NULL;
  2320. lut_data = __get_free_pages(GFP_KERNEL, get_order(AUO_LUT_LENGTH));
  2321. if(lut_data == NULL)
  2322. {
  2323. return -EFAULT;
  2324. }
  2325. if(copy_from_user(lut_data, (unsigned char*) arg, AUO_LUT_LENGTH))
  2326. {
  2327. free_pages((unsigned long)lut_data, get_order(AUO_LUT_LENGTH));
  2328. return -EFAULT;
  2329. }
  2330. Epaper_Update_LUT((unsigned short*)lut_data,AUO_LUT_LENGTH/2 );
  2331. free_pages((unsigned long)lut_data, get_order(AUO_LUT_LENGTH));
  2332. break;
  2333. }
  2334. case AUOFB_IOCTL_TCON_POWER_STATE:
  2335. {
  2336. unsigned long UserPowerState = 0;
  2337. if(copy_from_user(&UserPowerState, (unsigned long*) arg, sizeof(unsigned long)))
  2338. return -EFAULT;
  2339. switch(u32PowerState)
  2340. {
  2341. case EN_EPD_DEVICE_POWER_STATE_D0:
  2342. switch(UserPowerState)
  2343. {
  2344. case EN_EPD_DEVICE_POWER_STATE_D0:
  2345. //do nothing
  2346. break;
  2347. case EN_EPD_DEVICE_POWER_STATE_D1:
  2348. if(is_Epaper_Write_Ready())
  2349. {
  2350. msleep(100);
  2351. Epaper_Enter_Standby_Mode(1);
  2352. msleep(100); //TCON need at least 64ms to enter standby mode
  2353. }
  2354. else
  2355. return -EFAULT;
  2356. break;
  2357. case EN_EPD_DEVICE_POWER_STATE_D2:
  2358. if(is_Epaper_Write_Ready())
  2359. {
  2360. //AUO T-CON Standby
  2361. msleep(100);
  2362. Epaper_Enter_Standby_Mode(1);
  2363. msleep(100);
  2364. //AUO T-CON Sleep
  2365. Epaper_Enter_Sleep_Mode(1);
  2366. msleep(5);
  2367. }
  2368. else
  2369. return -EFAULT;
  2370. break;
  2371. case EN_EPD_DEVICE_POWER_STATE_D3:
  2372. if(is_Epaper_Write_Ready())
  2373. {
  2374. //AUO T-CON Standby
  2375. msleep(100);
  2376. Epaper_Enter_Standby_Mode(1);
  2377. msleep(100);
  2378. //AUO T-CON Sleep
  2379. Epaper_Enter_Sleep_Mode(1);
  2380. msleep(5);
  2381. //Shutdown T-CON Power
  2382. Epaper_Power(0);
  2383. //Shutdown i80 of s3c
  2384. EPaper_CloseLcdPort();
  2385. //msleep(1000);
  2386. }
  2387. else
  2388. return -EFAULT;
  2389. break;
  2390. default:
  2391. return -EFAULT;
  2392. }
  2393. break;
  2394. case EN_EPD_DEVICE_POWER_STATE_D1:
  2395. switch(UserPowerState)
  2396. {
  2397. case EN_EPD_DEVICE_POWER_STATE_D0:
  2398. Epaper_Enter_Standby_Mode(0);
  2399. msleep(100);
  2400. break;
  2401. case EN_EPD_DEVICE_POWER_STATE_D1:
  2402. //do nothing
  2403. break;
  2404. case EN_EPD_DEVICE_POWER_STATE_D2:
  2405. Epaper_Enter_Sleep_Mode(1);
  2406. msleep(5);
  2407. break;
  2408. case EN_EPD_DEVICE_POWER_STATE_D3:
  2409. Epaper_Enter_Sleep_Mode(1);
  2410. msleep(5);
  2411. //Shutdown T-CON Power
  2412. Epaper_Power(0);
  2413. //Shutdown i80 of s3c
  2414. EPaper_CloseLcdPort();
  2415. //msleep(1000);
  2416. break;
  2417. default:
  2418. return -EFAULT;
  2419. }
  2420. break;
  2421. case EN_EPD_DEVICE_POWER_STATE_D2:
  2422. switch(UserPowerState)
  2423. {
  2424. case EN_EPD_DEVICE_POWER_STATE_D0:
  2425. Epaper_Enter_Sleep_Mode(0);
  2426. msleep(5);
  2427. Epaper_Enter_Standby_Mode(0);
  2428. msleep(100);
  2429. break;
  2430. case EN_EPD_DEVICE_POWER_STATE_D1:
  2431. Epaper_Enter_Sleep_Mode(0);
  2432. msleep(5);
  2433. break;
  2434. case EN_EPD_DEVICE_POWER_STATE_D2:
  2435. //do nothing
  2436. break;
  2437. case EN_EPD_DEVICE_POWER_STATE_D3:
  2438. //Shutdown T-CON Power
  2439. Epaper_Power(0);
  2440. //Shutdown i80 of s3c
  2441. EPaper_CloseLcdPort();
  2442. //msleep(1000);
  2443. break;
  2444. default:
  2445. return -EFAULT;
  2446. }
  2447. break;
  2448. case EN_EPD_DEVICE_POWER_STATE_D3:
  2449. switch(UserPowerState)
  2450. {
  2451. case EN_EPD_DEVICE_POWER_STATE_D0:
  2452. msleep(100);
  2453. #ifdef EPD_HW_ROTATE
  2454. Epaper_Init(AUO_EPAPER_PHYSICAL_H_RESOLUTION, AUO_EPAPER_PHYSICAL_V_RESOLUTION, 0, 0, 90, 0, 0, 0, 0, 0);
  2455. #else
  2456. Epaper_Init(AUO_EPAPER_PHYSICAL_H_RESOLUTION, AUO_EPAPER_PHYSICAL_V_RESOLUTION, 0, 0, 0, 0, 0, 0, 0, 0);
  2457. #endif
  2458. #ifdef EPD_ENABLE_PRE_DISPLAY
  2459. atomic_set(&gPowerOnFirstDisplay, 1);
  2460. auo_fb_pre_display();
  2461. #endif
  2462. break;
  2463. case EN_EPD_DEVICE_POWER_STATE_D1:
  2464. //not allowed
  2465. return -EFAULT;
  2466. case EN_EPD_DEVICE_POWER_STATE_D2:
  2467. //not allowed
  2468. return -EFAULT;
  2469. case EN_EPD_DEVICE_POWER_STATE_D3:
  2470. //do nothing
  2471. break;
  2472. default:
  2473. return -EFAULT;
  2474. }
  2475. break;
  2476. default:
  2477. return -EFAULT;
  2478. }
  2479. u32PowerState = UserPowerState;
  2480. break;
  2481. }
  2482. //*********************************************************************************
  2483. case AUOFB_IOCTL_TCON_GET_TEMPERATURE: //Get Tempterature
  2484. if(is_Epaper_Write_Ready())
  2485. Epaper_Read_R_TEMP(&u16Temperature,&u16EPDType,&u16PanelType,&u16LUTVersion);
  2486. if(copy_to_user((void *)arg, (const void *) &u16Temperature, sizeof(unsigned short)))
  2487. return -EFAULT;
  2488. break;
  2489. case AUOFB_IOCTL_TCON_GET_EPD_TYPE: //Get EPD type
  2490. if(is_Epaper_Write_Ready())
  2491. Epaper_Read_R_TEMP(&u16Temperature,&u16EPDType,&u16PanelType,&u16LUTVersion);
  2492. if(copy_to_user((void *)arg, (const void *) &u16EPDType, sizeof(unsigned short)))
  2493. return -EFAULT;
  2494. break;
  2495. case AUOFB_IOCTL_TCON_GET_PANEL_TYPE: //Get Panel type
  2496. if(is_Epaper_Write_Ready())
  2497. Epaper_Read_R_TEMP(&u16Temperature,&u16EPDType,&u16PanelType,&u16LUTVersion);
  2498. if(copy_to_user((void *)arg, (const void *) &u16PanelType, sizeof(unsigned short)))
  2499. return -EFAULT;
  2500. break;
  2501. case AUOFB_IOCTL_TCON_GET_LUT_INFO: //Get LUT version
  2502. if(is_Epaper_Write_Ready())
  2503. Epaper_Read_R_TEMP(&u16Temperature,&u16EPDType,&u16PanelType,&u16LUTVersion);
  2504. if(copy_to_user((void *)arg, (const void *) &u16LUTVersion, sizeof(unsigned short)))
  2505. return -EFAULT;
  2506. break;
  2507. //*********************************************************************************
  2508. case AUOFB_IOCTL_SHOW_PROGRESS_BAR:
  2509. {
  2510. int percent = 0;
  2511. if(copy_from_user(&percent, (int *) arg, sizeof(int)))
  2512. return -EFAULT;
  2513. //Epaper_Show_Progress(percent);
  2514. break;
  2515. }
  2516. case AUOFB_IOCTL_CLEAN_EPD:
  2517. {
  2518. Epaper_Clean_Panel();
  2519. break;
  2520. }
  2521. /* Qisda, Howard Hsu, 2010/01/11, Add show image ioctrl { */
  2522. case AUOFB_IOCTL_SHOW_IMAGE:
  2523. {
  2524. T_DISPLAY_FRAME stDisFrame;
  2525. _partial_update_info partial_info;
  2526. unsigned long pic_array_size = 0;
  2527. unsigned long pic_array_max = AUO_EPAPER_PHYSICAL_H_RESOLUTION*AUO_EPAPER_PHYSICAL_V_RESOLUTION/2;
  2528. unsigned char *pic_array = vmalloc(pic_array_max, GFP_KERNEL);
  2529. if(copy_from_user(&partial_info, (_partial_update_info *) arg, sizeof(_partial_update_info)))
  2530. return -EFAULT;
  2531. if(copy_from_user(&pic_array_size, (unsigned long*) ((char *)arg+sizeof(_partial_update_info)), sizeof(unsigned long)))
  2532. return -EFAULT;
  2533. if(copy_from_user(pic_array, (char*) ((char *)arg+sizeof(_partial_update_info)+sizeof(unsigned long)), pic_array_size))
  2534. return -EFAULT;
  2535. stDisFrame.u16EpaperCommand = AUO_EPAPER_CMD_PARTIALDISP;
  2536. Epaper_Set_Partial_Update_Mode(partial_info.mode);
  2537. stDisFrame.tFrameRange.W = partial_info.w;
  2538. stDisFrame.tFrameRange.H = partial_info.h;
  2539. stDisFrame.tFrameRange.X = partial_info.x;
  2540. stDisFrame.tFrameRange.Y = partial_info.y;
  2541. if ( partial_info.x==0 || partial_info.y==0)
  2542. {
  2543. stDisFrame.tFrameRange.X = (H_RESOLUTION-partial_info.w)/2;
  2544. stDisFrame.tFrameRange.Y = (V_RESOLUTION-partial_info.h)/2;
  2545. if((stDisFrame.tFrameRange.X % 2) == 0)
  2546. stDisFrame.tFrameRange.X ++;
  2547. if((stDisFrame.tFrameRange.Y % 2) == 0)
  2548. stDisFrame.tFrameRange.Y ++;
  2549. }
  2550. stDisFrame.pFrameData = (unsigned short*)pic_array;
  2551. if(is_Epaper_Write_Ready())
  2552. {
  2553. printk("Show Image on EPD\n");
  2554. Epaper_Disp(stDisFrame);
  2555. }
  2556. else
  2557. {
  2558. printk("EPD not ready to show Image\n");
  2559. }
  2560. vfree(pic_array);
  2561. break;
  2562. }
  2563. /* } Qisda, Howard Hsu, 2010/01/11, Add show image ioctrl */
  2564. default:
  2565. return -EINVAL;
  2566. }
  2567. return 0;
  2568. }
  2569. /* ------------------------------------------------------------------------- */
  2570. /*
  2571. * Frame buffer operations
  2572. */
  2573. static struct fb_ops auofb_ops = {
  2574. .owner = THIS_MODULE,
  2575. .fb_check_var = auofb_check_var,
  2576. .fb_set_par = auofb_set_par,
  2577. .fb_blank = auofb_blank,
  2578. .fb_pan_display = auofb_pan_display,
  2579. .fb_setcolreg = auofb_setcolreg,
  2580. .fb_fillrect = cfb_fillrect,
  2581. .fb_copyarea = cfb_copyarea,
  2582. .fb_imageblit = cfb_imageblit,
  2583. //.fb_cursor = soft_cursor,
  2584. .fb_ioctl = auo_fb_ioctl,
  2585. .fb_mmap = auo_fb_mmap,
  2586. };
  2587. /* ------------------------------------------------------------------------- */
  2588. struct fb_monspecs monspecs __initdata = {
  2589. .hfmin = 30000,
  2590. .hfmax = 70000,
  2591. .vfmin = 50,
  2592. .vfmax = 65,
  2593. };
  2594. struct page *vmalloc_2_page(void *addr)
  2595. {
  2596. unsigned long lpage;
  2597. pgd_t *pgd;
  2598. pmd_t *pmd;
  2599. pte_t *pte;
  2600. struct page *page;
  2601. lpage = (unsigned long)(addr);
  2602. spin_lock(&init_mm.page_table_lock);
  2603. pgd = pgd_offset(&init_mm, lpage);
  2604. pmd = pmd_offset(pgd, lpage);
  2605. pte = pte_offset_map(pmd, lpage);
  2606. page = pte_page(*pte);
  2607. spin_unlock(&init_mm.page_table_lock);
  2608. return page;
  2609. //return vmalloc_to_page(addr);
  2610. }
  2611. int init_page_array(void)
  2612. {
  2613. int i;
  2614. numpages = (videomemorysize >> PAGE_SHIFT) + 1;
  2615. videopages = kmalloc(numpages * sizeof(struct page *), GFP_KERNEL);
  2616. if (videopages == NULL) {
  2617. return 1;
  2618. }
  2619. for (i = 0; (i << PAGE_SHIFT) < videomemorysize; i++) {
  2620. videopages[i] = vmalloc_2_page(pu8Framebuffer + (i << PAGE_SHIFT));
  2621. }
  2622. return 0;
  2623. }
  2624. int clear_page_array(void)
  2625. {
  2626. if (videopages != NULL) {
  2627. kfree(videopages);
  2628. }
  2629. return 0;
  2630. }
  2631. void auo_fb_init_fbinfo(struct auo_fb_info *finfo, char *drv_name, int index)
  2632. {
  2633. int i = 0;
  2634. //Epaper is open at boot code
  2635. #ifdef EPD_HW_ROTATE
  2636. //Epaper_Reset();
  2637. Epaper_Init(AUO_EPAPER_PHYSICAL_H_RESOLUTION, AUO_EPAPER_PHYSICAL_V_RESOLUTION, 0, 0, 90, 0, 0, 0, 0, 0);
  2638. #else
  2639. //Epaper_Reset();
  2640. Epaper_Init(AUO_EPAPER_PHYSICAL_H_RESOLUTION, AUO_EPAPER_PHYSICAL_V_RESOLUTION, 0, 0, 0, 0, 0, 0, 0, 0);
  2641. #endif
  2642. strcpy(finfo->fb.fix.id, drv_name);
  2643. finfo->win_id = index;
  2644. finfo->fb.fix.type = FB_TYPE_PACKED_PIXELS;
  2645. finfo->fb.fix.type_aux = 0;
  2646. finfo->fb.fix.xpanstep = 0;
  2647. finfo->fb.fix.ypanstep = 0;
  2648. finfo->fb.fix.ywrapstep = 0;
  2649. finfo->fb.fix.accel = FB_ACCEL_NONE;
  2650. finfo->fb.fbops = &auofb_ops;
  2651. finfo->fb.flags = FBINFO_FLAG_DEFAULT;
  2652. finfo->fb.monspecs = monspecs;
  2653. finfo->fb.pseudo_palette = &finfo->pseudo_pal;
  2654. finfo->fb.var.nonstd = 0;
  2655. finfo->fb.var.activate = FB_ACTIVATE_NOW;
  2656. finfo->fb.var.accel_flags = 0;
  2657. finfo->fb.var.vmode = FB_VMODE_NONINTERLACED;
  2658. finfo->fb.var.xoffset = auo_mach_info.xoffset;
  2659. finfo->fb.var.yoffset = auo_mach_info.yoffset;
  2660. if(index==0){
  2661. finfo->fb.var.height = auo_mach_info.height;
  2662. finfo->fb.var.width = auo_mach_info.width;
  2663. finfo->fb.var.xres = auo_mach_info.xres;
  2664. finfo->fb.var.xres_virtual = auo_mach_info.xres_virtual;
  2665. finfo->fb.var.yres = auo_mach_info.yres;
  2666. finfo->fb.var.yres_virtual = auo_mach_info.yres_virtual;
  2667. }
  2668. else{
  2669. finfo->fb.var.height = auo_mach_info.osd_height;
  2670. finfo->fb.var.width = auo_mach_info.osd_width;
  2671. finfo->fb.var.xres = auo_mach_info.osd_xres;
  2672. finfo->fb.var.xres_virtual = auo_mach_info.osd_xres_virtual;
  2673. finfo->fb.var.yres = auo_mach_info.osd_yres;
  2674. finfo->fb.var.yres_virtual = auo_mach_info.osd_yres_virtual;
  2675. }
  2676. finfo->fb.var.bits_per_pixel = auo_mach_info.bpp;
  2677. finfo->fb.var.pixclock = auo_mach_info.pixclock;
  2678. finfo->fb.var.hsync_len = auo_mach_info.hsync_len;
  2679. finfo->fb.var.left_margin = auo_mach_info.left_margin;
  2680. finfo->fb.var.right_margin = auo_mach_info.right_margin;
  2681. finfo->fb.var.vsync_len = auo_mach_info.vsync_len;
  2682. finfo->fb.var.upper_margin = auo_mach_info.upper_margin;
  2683. finfo->fb.var.lower_margin = auo_mach_info.lower_margin;
  2684. finfo->fb.var.sync = auo_mach_info.sync;
  2685. finfo->fb.var.grayscale = auo_mach_info.cmap_grayscale;
  2686. videomemorysize = finfo->fb.fix.smem_len = finfo->fb.var.xres_virtual * finfo->fb.var.yres_virtual *
  2687. auo_mach_info.bytes_per_pixel;
  2688. //DPRINTK("\nsmem_len=%d * %d * %d", finfo->fb.var.xres_virtual, finfo->fb.var.yres_virtual, auo_mach_info.bytes_per_pixel);
  2689. finfo->fb.fix.line_length = finfo->fb.var.width * auo_mach_info.bytes_per_pixel;
  2690. for (i = 0; i < 256; i++)
  2691. finfo->palette_buffer[i] = PALETTE_BUFF_CLEAR;
  2692. }
  2693. /* static int __init xxfb_probe (struct device *device) -- for platform devs */
  2694. int __init auo_fb_probe(struct platform_device *pdev)
  2695. {
  2696. char driver_name[]="s3c_fb";
  2697. int ret,i;
  2698. int index=0;
  2699. DPRINTK("\n!!!!!!!!!!!init AUO EINK");
  2700. auo_fb_init_fbinfo(&info, driver_name, 0);
  2701. #ifdef FRAMEBUFFER_DMA
  2702. if (!request_mem_region((unsigned long)S3C24XX_VA_LCD, SZ_1M, "s3c-lcd")) {
  2703. ret = -EBUSY;
  2704. return ret;
  2705. }
  2706. auofb_basic_display_setting(0,0);
  2707. #endif
  2708. /*
  2709. * Dynamically allocate info and par
  2710. */
  2711. //pu8Framebuffer = vmalloc(800*600*3);
  2712. ///pu8Framebuffer = vmalloc(info.fb.fix.smem_len);
  2713. pu8Framebuffer = vmalloc(V_RESOLUTION*H_RESOLUTION*2);
  2714. #ifdef FRAMEBUFFER_DMA
  2715. pu16Translatebuffer = cpu_VideoPhysicalTemp_f1;
  2716. #else
  2717. pu16Translatebuffer = vmalloc(V_RESOLUTION*H_RESOLUTION/2);
  2718. #endif
  2719. pu8RotateBuffer = vmalloc(V_RESOLUTION*H_RESOLUTION*2);
  2720. /*
  2721. * Here we set the screen_base to the virtual memory address
  2722. * for the framebuffer. Usually we obtain the resource address
  2723. * from the bus layer and then translate it to virtual memory
  2724. * space via ioremap. Consult ioport.h.
  2725. */
  2726. info.fb.screen_base = pu8Framebuffer;
  2727. //pu8Framebuffer = info.fb.screen_base = ioremap_nocache(S3C24XX_PA_LCD, SZ_1M);
  2728. info.fb.fbops = &auofb_ops;
  2729. info.fb.fix.smem_start = (unsigned long)pu8Framebuffer;
  2730. ///info.fb.fix.smem_start =S3C24XX_PA_LCD;
  2731. /*
  2732. * Set up flags to indicate what sort of acceleration your
  2733. * driver can provide (pan/wrap/copyarea/etc.) and whether it
  2734. * is a module -- see FBINFO_* in include/linux/fb.h
  2735. *
  2736. * If your hardware can support any of the hardware accelerated functions
  2737. * fbcon performance will improve if info->flags is set properly.
  2738. *
  2739. * FBINFO_HWACCEL_COPYAREA - hardware moves
  2740. * FBINFO_HWACCEL_FILLRECT - hardware fills
  2741. * FBINFO_HWACCEL_IMAGEBLIT - hardware mono->color expansion
  2742. * FBINFO_HWACCEL_YPAN - hardware can pan display in y-axis
  2743. * FBINFO_HWACCEL_YWRAP - hardware can wrap display in y-axis
  2744. * FBINFO_HWACCEL_DISABLED - supports hardware accels, but disabled
  2745. * FBINFO_READS_FAST - if set, prefer moves over mono->color expansion
  2746. * FBINFO_MISC_TILEBLITTING - hardware can do tile blits
  2747. *
  2748. * NOTE: These are for fbcon use only.
  2749. */
  2750. init_page_array();
  2751. /* This has to been done !!! */
  2752. fb_alloc_cmap(&info.fb.cmap, 256, 0);
  2753. //Ivan test
  2754. sema_init(&vma_list_semaphore, 1);
  2755. /*
  2756. * For drivers that can...
  2757. */
  2758. auofb_check_var(&info.fb.var, &info.fb);
  2759. /* The TCON MUST be inited before anythings! We can't wait for the
  2760. * bootloader to do all the things for us!! */
  2761. Epaper_SetLcdPort();
  2762. /*
  2763. * Does a call to fb_set_par() before register_framebuffer needed? This
  2764. * will depend on you and the hardware. If you are sure that your driver
  2765. * is the only device in the system, a call to fb_set_par() is safe.
  2766. *
  2767. * Hardware in x86 systems has a VGA core. Calling set_par() at thisEpaper_Enter_Sleep_Mode(1);
  2768. * point will corrupt the VGA console, so it might be safer to skip a
  2769. * call to set_par here and just allow fbcon to do it for you.
  2770. */
  2771. /* auofb_set_par(info); */
  2772. if (register_framebuffer(&info.fb) < 0)
  2773. return -EINVAL;
  2774. //start_update_display_thread();
  2775. //timer
  2776. /*
  2777. init_timer(&panel_timer_qisda);
  2778. panel_timer_qisda.function =panel_timer_handler_qisda;
  2779. INIT_WORK(&workq_panel_update,panel_update_workqueue);
  2780. panel_timer_qisda.expires = jiffies + (2*HZ);
  2781. add_timer(&panel_timer_qisda);
  2782. */
  2783. u32PowerState = EN_EPD_DEVICE_POWER_STATE_D0;
  2784. memset((unsigned char*)partial_info_queue, 0x0, sizeof(_partial_update_info)*PARTIAL_INFO_QUEUE_SIZE);
  2785. //refresh logo
  2786. if ( 0 == LOCK_AUOFB_ENTRY() )
  2787. {
  2788. //if(is_Epaper_Write_Ready())
  2789. {
  2790. w_partial_info.x = 0;
  2791. w_partial_info.y = 0;
  2792. w_partial_info.w = H_RESOLUTION;
  2793. w_partial_info.h = V_RESOLUTION;
  2794. w_partial_info.mode = 0; //test
  2795. w_partial_info.u16EpaperCommand = AUO_EPAPER_CMD_PARTIALDISP;
  2796. DPRINTK("\nAUOFB partial init, (%d,%d,%d,%d,%d)!!!", w_partial_info.mode, w_partial_info.x, w_partial_info.y, w_partial_info.w, w_partial_info.h);
  2797. Epaper_Set_Partial_Update_Mode(w_partial_info.mode);
  2798. }
  2799. LOCK_AUOFB_EXIT();
  2800. }
  2801. auofb_update_queue_put(w_partial_info);
  2802. wake_update_display_thread();
  2803. #ifdef CONFIG_LOGO_LINUX_SH060B00_6_INCH_CLUT224
  2804. #else
  2805. //start_boot_progress_bar_thread();
  2806. #endif
  2807. if(is_Epaper_Write_Ready())
  2808. Epaper_Read_R_TEMP(&u16Temperature,&u16EPDType,&u16PanelType,&u16LUTVersion);
  2809. printk("\nTCON Temperature=%d\nEPD Type=0x%x\nPanel Type=0x%x\nLUT=0x%x\n", u16Temperature/2,u16EPDType, u16PanelType, u16LUTVersion);
  2810. return 0;
  2811. }
  2812. /* -----------------------------------------
  2813. * s3c_fb_stop_lcd & s3c_fb_start_lcd
  2814. *
  2815. * shutdown/ start the lcd controller
  2816. */
  2817. static void s3c_fb_stop_lcd(void)
  2818. {
  2819. unsigned long flags;
  2820. unsigned long tmp;
  2821. local_irq_save(flags);
  2822. tmp = __raw_readl(S3C_VIDCON0);
  2823. __raw_writel(tmp & ~(S3C_VIDCON0_ENVID_ENABLE | S3C_VIDCON0_ENVID_F_ENABLE), S3C_VIDCON0);
  2824. local_irq_restore(flags);
  2825. }
  2826. void s3c_fb_start_lcd(void) {
  2827. unsigned long flags;
  2828. unsigned long tmp;
  2829. local_irq_save(flags);
  2830. tmp = __raw_readl(S3C_VIDCON0);
  2831. __raw_writel(tmp | S3C_VIDCON0_ENVID_ENABLE | S3C_VIDCON0_ENVID_F_ENABLE, S3C_VIDCON0);
  2832. local_irq_restore(flags);
  2833. }
  2834. /*
  2835. * Cleanup
  2836. */
  2837. static int auofb_remove(struct platform_device *pdev)
  2838. {
  2839. struct fb_info *fbinfo = platform_get_drvdata(pdev);
  2840. struct auo_fb_info *info = fbinfo->par;
  2841. int irq;
  2842. int index=0;
  2843. vfree(pu8Framebuffer);
  2844. #ifdef FRAMEBUFFER_DMA
  2845. dma_free_writecombine(((struct auo_fb_info *)&info[index])->dev, H_RESOLUTION*V_RESOLUTION/2, cpu_VideoPhysicalTemp_f1, map_VideoPhysicalTemp_f1);
  2846. release_mem_region((unsigned long)S3C24XX_VA_LCD, S3C24XX_SZ_LCD);
  2847. #else
  2848. vfree(pu16Translatebuffer);
  2849. #endif
  2850. vfree(pu8RotateBuffer);
  2851. unregister_framebuffer(&(info[index].fb));
  2852. return 0;
  2853. }
  2854. #ifdef CONFIG_PM
  2855. static struct sleep_save lcd_save[] = {
  2856. SAVE_ITEM(S3C_VIDCON0),SAVE_ITEM(S3C_VIDCON1),
  2857. SAVE_ITEM(S3C_VIDTCON0),SAVE_ITEM(S3C_VIDTCON1),
  2858. SAVE_ITEM(S3C_VIDTCON2),SAVE_ITEM(S3C_WINCON0),
  2859. SAVE_ITEM(S3C_WINCON1),
  2860. SAVE_ITEM(S3C_VIDINTCON),SAVE_ITEM(S3C_SYSIFCON0),
  2861. SAVE_ITEM(S3C_SIFCCON0),
  2862. SAVE_ITEM(S3C_CPUTRIGCON2),SAVE_ITEM(S3C_VIDOSD0A),
  2863. SAVE_ITEM(S3C_VIDOSD0B),SAVE_ITEM(S3C_VIDOSD0C),
  2864. SAVE_ITEM(S3C_VIDOSD1A),SAVE_ITEM(S3C_VIDOSD1B),
  2865. SAVE_ITEM(S3C_VIDOSD1C),SAVE_ITEM(S3C_VIDW00ADD0B0),
  2866. SAVE_ITEM(S3C_VIDW00ADD0B1),SAVE_ITEM(S3C_VIDW01ADD0),
  2867. SAVE_ITEM(S3C_VIDW00ADD1B0),SAVE_ITEM(S3C_VIDW00ADD1B1),
  2868. SAVE_ITEM(S3C_VIDW01ADD1),SAVE_ITEM(S3C_VIDW00ADD2B0),
  2869. SAVE_ITEM(S3C_VIDW00ADD2B1),SAVE_ITEM(S3C_VIDW01ADD2),
  2870. };
  2871. /* suspend and resume support for the AUO T-CON */
  2872. static int auofb_suspend(struct platform_device *dev, pm_message_t state)
  2873. {
  2874. #if 1
  2875. if(is_Epaper_Write_Ready())
  2876. {
  2877. //Suspend LCD controller
  2878. //s3c_fb_stop_lcd();
  2879. //s3c2410_pm_do_save(lcd_save, ARRAY_SIZE(lcd_save));
  2880. //AUO T-CON Standby
  2881. msleep(100);
  2882. Epaper_Enter_Standby_Mode(1);
  2883. msleep(100);
  2884. //AUO T-CON Sleep
  2885. Epaper_Enter_Sleep_Mode(1);
  2886. msleep(5);
  2887. //Shutdown T-CON Power
  2888. Epaper_Power(0);
  2889. //Shutdown i80 of s3c
  2890. EPaper_CloseLcdPort();
  2891. //msleep(1000);
  2892. DPRINTK("\nAUOFB Suspend");
  2893. u32PowerState = EN_EPD_DEVICE_POWER_STATE_D3;
  2894. return 0;
  2895. }
  2896. return -EINVAL;
  2897. #else
  2898. //EPaper_CloseLcdPort();
  2899. return 0;
  2900. #endif
  2901. }
  2902. static int auofb_resume(struct platform_device *dev)
  2903. {
  2904. Epaper_SetLcdPort();
  2905. #if 0
  2906. DPRINTK("\nAUOFB Resume");
  2907. //AUO T-CON leave standby (If shutdown power of TCON, then do not need to leave standby mode)
  2908. //Epaper_Enter_Standby_Mode(0);
  2909. //AUO T-CON leave sleep
  2910. //Epaper_Enter_Sleep_Mode(0);
  2911. msleep(100); //sleep for RST_N pull high
  2912. u32PowerState = EN_EPD_DEVICE_POWER_STATE_D0;
  2913. #if defined(EPD_ENABLE_PRE_DISPLAY)
  2914. auo_fb_put_epd_init_command();
  2915. #else
  2916. #ifdef EPD_HW_ROTATE
  2917. Epaper_Init(AUO_EPAPER_PHYSICAL_H_RESOLUTION, AUO_EPAPER_PHYSICAL_V_RESOLUTION, 0, 0, 90, 0, 0, 0, 0, 0);
  2918. #else
  2919. Epaper_Init(AUO_EPAPER_PHYSICAL_H_RESOLUTION, AUO_EPAPER_PHYSICAL_V_RESOLUTION, 0, 0, 0, 0, 0, 0, 0, 0);
  2920. #endif
  2921. #endif
  2922. #ifdef EPD_ENABLE_PRE_DISPLAY
  2923. atomic_set(&gPowerOnFirstDisplay, 1);
  2924. auo_fb_pre_display();
  2925. #endif
  2926. #endif
  2927. return 0;
  2928. }
  2929. #define auofb_shutdown NULL
  2930. #else //no CONFIG_PM
  2931. #define auofb_shutdown NULL
  2932. #define auofb_suspend NULL
  2933. #define auofb_resume NULL
  2934. #endif //CONFIG_PM
  2935. /* for platform devices */
  2936. static struct platform_driver auo_fb_driver = {
  2937. .probe = auo_fb_probe,
  2938. .remove = auofb_remove,
  2939. .shutdown = auofb_shutdown,
  2940. .suspend = auofb_suspend,
  2941. .resume = auofb_resume,
  2942. .driver = {
  2943. .name = "s3c-lcd",
  2944. .owner = THIS_MODULE,
  2945. },
  2946. };
  2947. int __devinit auofb_init(void)
  2948. {
  2949. int ret = 0;
  2950. return platform_driver_register(&auo_fb_driver);
  2951. }
  2952. static void __exit auofb_cleanup(void)
  2953. {
  2954. platform_driver_unregister(&auo_fb_driver);
  2955. }
  2956. /*
  2957. * Setup
  2958. */
  2959. /*
  2960. * Modularization
  2961. */
  2962. module_init(auofb_init);
  2963. module_exit(auofb_cleanup);
  2964. MODULE_AUTHOR("");
  2965. MODULE_DESCRIPTION("Framebuffer driver for the AUO-EINK");
  2966. MODULE_LICENSE("GPL");