gpu.tmpl 172 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" []>
  4. <book id="gpuDevelopersGuide">
  5. <bookinfo>
  6. <title>Linux GPU Driver Developer's Guide</title>
  7. <authorgroup>
  8. <author>
  9. <firstname>Jesse</firstname>
  10. <surname>Barnes</surname>
  11. <contrib>Initial version</contrib>
  12. <affiliation>
  13. <orgname>Intel Corporation</orgname>
  14. <address>
  15. <email>jesse.barnes@intel.com</email>
  16. </address>
  17. </affiliation>
  18. </author>
  19. <author>
  20. <firstname>Laurent</firstname>
  21. <surname>Pinchart</surname>
  22. <contrib>Driver internals</contrib>
  23. <affiliation>
  24. <orgname>Ideas on board SPRL</orgname>
  25. <address>
  26. <email>laurent.pinchart@ideasonboard.com</email>
  27. </address>
  28. </affiliation>
  29. </author>
  30. <author>
  31. <firstname>Daniel</firstname>
  32. <surname>Vetter</surname>
  33. <contrib>Contributions all over the place</contrib>
  34. <affiliation>
  35. <orgname>Intel Corporation</orgname>
  36. <address>
  37. <email>daniel.vetter@ffwll.ch</email>
  38. </address>
  39. </affiliation>
  40. </author>
  41. <author>
  42. <firstname>Lukas</firstname>
  43. <surname>Wunner</surname>
  44. <contrib>vga_switcheroo documentation</contrib>
  45. <affiliation>
  46. <address>
  47. <email>lukas@wunner.de</email>
  48. </address>
  49. </affiliation>
  50. </author>
  51. </authorgroup>
  52. <copyright>
  53. <year>2008-2009</year>
  54. <year>2013-2014</year>
  55. <holder>Intel Corporation</holder>
  56. </copyright>
  57. <copyright>
  58. <year>2012</year>
  59. <holder>Laurent Pinchart</holder>
  60. </copyright>
  61. <copyright>
  62. <year>2015</year>
  63. <holder>Lukas Wunner</holder>
  64. </copyright>
  65. <legalnotice>
  66. <para>
  67. The contents of this file may be used under the terms of the GNU
  68. General Public License version 2 (the "GPL") as distributed in
  69. the kernel source COPYING file.
  70. </para>
  71. </legalnotice>
  72. <revhistory>
  73. <!-- Put document revisions here, newest first. -->
  74. <revision>
  75. <revnumber>1.0</revnumber>
  76. <date>2012-07-13</date>
  77. <authorinitials>LP</authorinitials>
  78. <revremark>Added extensive documentation about driver internals.
  79. </revremark>
  80. </revision>
  81. <revision>
  82. <revnumber>1.1</revnumber>
  83. <date>2015-10-11</date>
  84. <authorinitials>LW</authorinitials>
  85. <revremark>Added vga_switcheroo documentation.
  86. </revremark>
  87. </revision>
  88. </revhistory>
  89. </bookinfo>
  90. <toc></toc>
  91. <part id="drmCore">
  92. <title>DRM Core</title>
  93. <partintro>
  94. <para>
  95. This first part of the GPU Driver Developer's Guide documents core DRM
  96. code, helper libraries for writing drivers and generic userspace
  97. interfaces exposed by DRM drivers.
  98. </para>
  99. </partintro>
  100. <chapter id="drmIntroduction">
  101. <title>Introduction</title>
  102. <para>
  103. The Linux DRM layer contains code intended to support the needs
  104. of complex graphics devices, usually containing programmable
  105. pipelines well suited to 3D graphics acceleration. Graphics
  106. drivers in the kernel may make use of DRM functions to make
  107. tasks like memory management, interrupt handling and DMA easier,
  108. and provide a uniform interface to applications.
  109. </para>
  110. <para>
  111. A note on versions: this guide covers features found in the DRM
  112. tree, including the TTM memory manager, output configuration and
  113. mode setting, and the new vblank internals, in addition to all
  114. the regular features found in current kernels.
  115. </para>
  116. <para>
  117. [Insert diagram of typical DRM stack here]
  118. </para>
  119. </chapter>
  120. <!-- Internals -->
  121. <chapter id="drmInternals">
  122. <title>DRM Internals</title>
  123. <para>
  124. This chapter documents DRM internals relevant to driver authors
  125. and developers working to add support for the latest features to
  126. existing drivers.
  127. </para>
  128. <para>
  129. First, we go over some typical driver initialization
  130. requirements, like setting up command buffers, creating an
  131. initial output configuration, and initializing core services.
  132. Subsequent sections cover core internals in more detail,
  133. providing implementation notes and examples.
  134. </para>
  135. <para>
  136. The DRM layer provides several services to graphics drivers,
  137. many of them driven by the application interfaces it provides
  138. through libdrm, the library that wraps most of the DRM ioctls.
  139. These include vblank event handling, memory
  140. management, output management, framebuffer management, command
  141. submission &amp; fencing, suspend/resume support, and DMA
  142. services.
  143. </para>
  144. <!-- Internals: driver init -->
  145. <sect1>
  146. <title>Driver Initialization</title>
  147. <para>
  148. At the core of every DRM driver is a <structname>drm_driver</structname>
  149. structure. Drivers typically statically initialize a drm_driver structure,
  150. and then pass it to <function>drm_dev_alloc()</function> to allocate a
  151. device instance. After the device instance is fully initialized it can be
  152. registered (which makes it accessible from userspace) using
  153. <function>drm_dev_register()</function>.
  154. </para>
  155. <para>
  156. The <structname>drm_driver</structname> structure contains static
  157. information that describes the driver and features it supports, and
  158. pointers to methods that the DRM core will call to implement the DRM API.
  159. We will first go through the <structname>drm_driver</structname> static
  160. information fields, and will then describe individual operations in
  161. details as they get used in later sections.
  162. </para>
  163. <sect2>
  164. <title>Driver Information</title>
  165. <sect3>
  166. <title>Driver Features</title>
  167. <para>
  168. Drivers inform the DRM core about their requirements and supported
  169. features by setting appropriate flags in the
  170. <structfield>driver_features</structfield> field. Since those flags
  171. influence the DRM core behaviour since registration time, most of them
  172. must be set to registering the <structname>drm_driver</structname>
  173. instance.
  174. </para>
  175. <synopsis>u32 driver_features;</synopsis>
  176. <variablelist>
  177. <title>Driver Feature Flags</title>
  178. <varlistentry>
  179. <term>DRIVER_USE_AGP</term>
  180. <listitem><para>
  181. Driver uses AGP interface, the DRM core will manage AGP resources.
  182. </para></listitem>
  183. </varlistentry>
  184. <varlistentry>
  185. <term>DRIVER_REQUIRE_AGP</term>
  186. <listitem><para>
  187. Driver needs AGP interface to function. AGP initialization failure
  188. will become a fatal error.
  189. </para></listitem>
  190. </varlistentry>
  191. <varlistentry>
  192. <term>DRIVER_PCI_DMA</term>
  193. <listitem><para>
  194. Driver is capable of PCI DMA, mapping of PCI DMA buffers to
  195. userspace will be enabled. Deprecated.
  196. </para></listitem>
  197. </varlistentry>
  198. <varlistentry>
  199. <term>DRIVER_SG</term>
  200. <listitem><para>
  201. Driver can perform scatter/gather DMA, allocation and mapping of
  202. scatter/gather buffers will be enabled. Deprecated.
  203. </para></listitem>
  204. </varlistentry>
  205. <varlistentry>
  206. <term>DRIVER_HAVE_DMA</term>
  207. <listitem><para>
  208. Driver supports DMA, the userspace DMA API will be supported.
  209. Deprecated.
  210. </para></listitem>
  211. </varlistentry>
  212. <varlistentry>
  213. <term>DRIVER_HAVE_IRQ</term><term>DRIVER_IRQ_SHARED</term>
  214. <listitem><para>
  215. DRIVER_HAVE_IRQ indicates whether the driver has an IRQ handler
  216. managed by the DRM Core. The core will support simple IRQ handler
  217. installation when the flag is set. The installation process is
  218. described in <xref linkend="drm-irq-registration"/>.</para>
  219. <para>DRIVER_IRQ_SHARED indicates whether the device &amp; handler
  220. support shared IRQs (note that this is required of PCI drivers).
  221. </para></listitem>
  222. </varlistentry>
  223. <varlistentry>
  224. <term>DRIVER_GEM</term>
  225. <listitem><para>
  226. Driver use the GEM memory manager.
  227. </para></listitem>
  228. </varlistentry>
  229. <varlistentry>
  230. <term>DRIVER_MODESET</term>
  231. <listitem><para>
  232. Driver supports mode setting interfaces (KMS).
  233. </para></listitem>
  234. </varlistentry>
  235. <varlistentry>
  236. <term>DRIVER_PRIME</term>
  237. <listitem><para>
  238. Driver implements DRM PRIME buffer sharing.
  239. </para></listitem>
  240. </varlistentry>
  241. <varlistentry>
  242. <term>DRIVER_RENDER</term>
  243. <listitem><para>
  244. Driver supports dedicated render nodes.
  245. </para></listitem>
  246. </varlistentry>
  247. <varlistentry>
  248. <term>DRIVER_ATOMIC</term>
  249. <listitem><para>
  250. Driver supports atomic properties. In this case the driver
  251. must implement appropriate obj->atomic_get_property() vfuncs
  252. for any modeset objects with driver specific properties.
  253. </para></listitem>
  254. </varlistentry>
  255. </variablelist>
  256. </sect3>
  257. <sect3>
  258. <title>Major, Minor and Patchlevel</title>
  259. <synopsis>int major;
  260. int minor;
  261. int patchlevel;</synopsis>
  262. <para>
  263. The DRM core identifies driver versions by a major, minor and patch
  264. level triplet. The information is printed to the kernel log at
  265. initialization time and passed to userspace through the
  266. DRM_IOCTL_VERSION ioctl.
  267. </para>
  268. <para>
  269. The major and minor numbers are also used to verify the requested driver
  270. API version passed to DRM_IOCTL_SET_VERSION. When the driver API changes
  271. between minor versions, applications can call DRM_IOCTL_SET_VERSION to
  272. select a specific version of the API. If the requested major isn't equal
  273. to the driver major, or the requested minor is larger than the driver
  274. minor, the DRM_IOCTL_SET_VERSION call will return an error. Otherwise
  275. the driver's set_version() method will be called with the requested
  276. version.
  277. </para>
  278. </sect3>
  279. <sect3>
  280. <title>Name, Description and Date</title>
  281. <synopsis>char *name;
  282. char *desc;
  283. char *date;</synopsis>
  284. <para>
  285. The driver name is printed to the kernel log at initialization time,
  286. used for IRQ registration and passed to userspace through
  287. DRM_IOCTL_VERSION.
  288. </para>
  289. <para>
  290. The driver description is a purely informative string passed to
  291. userspace through the DRM_IOCTL_VERSION ioctl and otherwise unused by
  292. the kernel.
  293. </para>
  294. <para>
  295. The driver date, formatted as YYYYMMDD, is meant to identify the date of
  296. the latest modification to the driver. However, as most drivers fail to
  297. update it, its value is mostly useless. The DRM core prints it to the
  298. kernel log at initialization time and passes it to userspace through the
  299. DRM_IOCTL_VERSION ioctl.
  300. </para>
  301. </sect3>
  302. </sect2>
  303. <sect2>
  304. <title>Device Instance and Driver Handling</title>
  305. !Pdrivers/gpu/drm/drm_drv.c driver instance overview
  306. !Edrivers/gpu/drm/drm_drv.c
  307. </sect2>
  308. <sect2>
  309. <title>Driver Load</title>
  310. <sect3 id="drm-irq-registration">
  311. <title>IRQ Registration</title>
  312. <para>
  313. The DRM core tries to facilitate IRQ handler registration and
  314. unregistration by providing <function>drm_irq_install</function> and
  315. <function>drm_irq_uninstall</function> functions. Those functions only
  316. support a single interrupt per device, devices that use more than one
  317. IRQs need to be handled manually.
  318. </para>
  319. <sect4>
  320. <title>Managed IRQ Registration</title>
  321. <para>
  322. <function>drm_irq_install</function> starts by calling the
  323. <methodname>irq_preinstall</methodname> driver operation. The operation
  324. is optional and must make sure that the interrupt will not get fired by
  325. clearing all pending interrupt flags or disabling the interrupt.
  326. </para>
  327. <para>
  328. The passed-in IRQ will then be requested by a call to
  329. <function>request_irq</function>. If the DRIVER_IRQ_SHARED driver
  330. feature flag is set, a shared (IRQF_SHARED) IRQ handler will be
  331. requested.
  332. </para>
  333. <para>
  334. The IRQ handler function must be provided as the mandatory irq_handler
  335. driver operation. It will get passed directly to
  336. <function>request_irq</function> and thus has the same prototype as all
  337. IRQ handlers. It will get called with a pointer to the DRM device as the
  338. second argument.
  339. </para>
  340. <para>
  341. Finally the function calls the optional
  342. <methodname>irq_postinstall</methodname> driver operation. The operation
  343. usually enables interrupts (excluding the vblank interrupt, which is
  344. enabled separately), but drivers may choose to enable/disable interrupts
  345. at a different time.
  346. </para>
  347. <para>
  348. <function>drm_irq_uninstall</function> is similarly used to uninstall an
  349. IRQ handler. It starts by waking up all processes waiting on a vblank
  350. interrupt to make sure they don't hang, and then calls the optional
  351. <methodname>irq_uninstall</methodname> driver operation. The operation
  352. must disable all hardware interrupts. Finally the function frees the IRQ
  353. by calling <function>free_irq</function>.
  354. </para>
  355. </sect4>
  356. <sect4>
  357. <title>Manual IRQ Registration</title>
  358. <para>
  359. Drivers that require multiple interrupt handlers can't use the managed
  360. IRQ registration functions. In that case IRQs must be registered and
  361. unregistered manually (usually with the <function>request_irq</function>
  362. and <function>free_irq</function> functions, or their devm_* equivalent).
  363. </para>
  364. <para>
  365. When manually registering IRQs, drivers must not set the DRIVER_HAVE_IRQ
  366. driver feature flag, and must not provide the
  367. <methodname>irq_handler</methodname> driver operation. They must set the
  368. <structname>drm_device</structname> <structfield>irq_enabled</structfield>
  369. field to 1 upon registration of the IRQs, and clear it to 0 after
  370. unregistering the IRQs.
  371. </para>
  372. </sect4>
  373. </sect3>
  374. <sect3>
  375. <title>Memory Manager Initialization</title>
  376. <para>
  377. Every DRM driver requires a memory manager which must be initialized at
  378. load time. DRM currently contains two memory managers, the Translation
  379. Table Manager (TTM) and the Graphics Execution Manager (GEM).
  380. This document describes the use of the GEM memory manager only. See
  381. <xref linkend="drm-memory-management"/> for details.
  382. </para>
  383. </sect3>
  384. <sect3>
  385. <title>Miscellaneous Device Configuration</title>
  386. <para>
  387. Another task that may be necessary for PCI devices during configuration
  388. is mapping the video BIOS. On many devices, the VBIOS describes device
  389. configuration, LCD panel timings (if any), and contains flags indicating
  390. device state. Mapping the BIOS can be done using the pci_map_rom() call,
  391. a convenience function that takes care of mapping the actual ROM,
  392. whether it has been shadowed into memory (typically at address 0xc0000)
  393. or exists on the PCI device in the ROM BAR. Note that after the ROM has
  394. been mapped and any necessary information has been extracted, it should
  395. be unmapped; on many devices, the ROM address decoder is shared with
  396. other BARs, so leaving it mapped could cause undesired behaviour like
  397. hangs or memory corruption.
  398. <!--!Fdrivers/pci/rom.c pci_map_rom-->
  399. </para>
  400. </sect3>
  401. </sect2>
  402. <sect2>
  403. <title>Bus-specific Device Registration and PCI Support</title>
  404. <para>
  405. A number of functions are provided to help with device registration.
  406. The functions deal with PCI and platform devices respectively and are
  407. only provided for historical reasons. These are all deprecated and
  408. shouldn't be used in new drivers. Besides that there's a few
  409. helpers for pci drivers.
  410. </para>
  411. !Edrivers/gpu/drm/drm_pci.c
  412. !Edrivers/gpu/drm/drm_platform.c
  413. </sect2>
  414. </sect1>
  415. <!-- Internals: memory management -->
  416. <sect1 id="drm-memory-management">
  417. <title>Memory management</title>
  418. <para>
  419. Modern Linux systems require large amount of graphics memory to store
  420. frame buffers, textures, vertices and other graphics-related data. Given
  421. the very dynamic nature of many of that data, managing graphics memory
  422. efficiently is thus crucial for the graphics stack and plays a central
  423. role in the DRM infrastructure.
  424. </para>
  425. <para>
  426. The DRM core includes two memory managers, namely Translation Table Maps
  427. (TTM) and Graphics Execution Manager (GEM). TTM was the first DRM memory
  428. manager to be developed and tried to be a one-size-fits-them all
  429. solution. It provides a single userspace API to accommodate the need of
  430. all hardware, supporting both Unified Memory Architecture (UMA) devices
  431. and devices with dedicated video RAM (i.e. most discrete video cards).
  432. This resulted in a large, complex piece of code that turned out to be
  433. hard to use for driver development.
  434. </para>
  435. <para>
  436. GEM started as an Intel-sponsored project in reaction to TTM's
  437. complexity. Its design philosophy is completely different: instead of
  438. providing a solution to every graphics memory-related problems, GEM
  439. identified common code between drivers and created a support library to
  440. share it. GEM has simpler initialization and execution requirements than
  441. TTM, but has no video RAM management capabilities and is thus limited to
  442. UMA devices.
  443. </para>
  444. <sect2>
  445. <title>The Translation Table Manager (TTM)</title>
  446. <para>
  447. TTM design background and information belongs here.
  448. </para>
  449. <sect3>
  450. <title>TTM initialization</title>
  451. <warning><para>This section is outdated.</para></warning>
  452. <para>
  453. Drivers wishing to support TTM must fill out a drm_bo_driver
  454. structure. The structure contains several fields with function
  455. pointers for initializing the TTM, allocating and freeing memory,
  456. waiting for command completion and fence synchronization, and memory
  457. migration. See the radeon_ttm.c file for an example of usage.
  458. </para>
  459. <para>
  460. The ttm_global_reference structure is made up of several fields:
  461. </para>
  462. <programlisting>
  463. struct ttm_global_reference {
  464. enum ttm_global_types global_type;
  465. size_t size;
  466. void *object;
  467. int (*init) (struct ttm_global_reference *);
  468. void (*release) (struct ttm_global_reference *);
  469. };
  470. </programlisting>
  471. <para>
  472. There should be one global reference structure for your memory
  473. manager as a whole, and there will be others for each object
  474. created by the memory manager at runtime. Your global TTM should
  475. have a type of TTM_GLOBAL_TTM_MEM. The size field for the global
  476. object should be sizeof(struct ttm_mem_global), and the init and
  477. release hooks should point at your driver-specific init and
  478. release routines, which probably eventually call
  479. ttm_mem_global_init and ttm_mem_global_release, respectively.
  480. </para>
  481. <para>
  482. Once your global TTM accounting structure is set up and initialized
  483. by calling ttm_global_item_ref() on it,
  484. you need to create a buffer object TTM to
  485. provide a pool for buffer object allocation by clients and the
  486. kernel itself. The type of this object should be TTM_GLOBAL_TTM_BO,
  487. and its size should be sizeof(struct ttm_bo_global). Again,
  488. driver-specific init and release functions may be provided,
  489. likely eventually calling ttm_bo_global_init() and
  490. ttm_bo_global_release(), respectively. Also, like the previous
  491. object, ttm_global_item_ref() is used to create an initial reference
  492. count for the TTM, which will call your initialization function.
  493. </para>
  494. </sect3>
  495. </sect2>
  496. <sect2 id="drm-gem">
  497. <title>The Graphics Execution Manager (GEM)</title>
  498. <para>
  499. The GEM design approach has resulted in a memory manager that doesn't
  500. provide full coverage of all (or even all common) use cases in its
  501. userspace or kernel API. GEM exposes a set of standard memory-related
  502. operations to userspace and a set of helper functions to drivers, and let
  503. drivers implement hardware-specific operations with their own private API.
  504. </para>
  505. <para>
  506. The GEM userspace API is described in the
  507. <ulink url="http://lwn.net/Articles/283798/"><citetitle>GEM - the Graphics
  508. Execution Manager</citetitle></ulink> article on LWN. While slightly
  509. outdated, the document provides a good overview of the GEM API principles.
  510. Buffer allocation and read and write operations, described as part of the
  511. common GEM API, are currently implemented using driver-specific ioctls.
  512. </para>
  513. <para>
  514. GEM is data-agnostic. It manages abstract buffer objects without knowing
  515. what individual buffers contain. APIs that require knowledge of buffer
  516. contents or purpose, such as buffer allocation or synchronization
  517. primitives, are thus outside of the scope of GEM and must be implemented
  518. using driver-specific ioctls.
  519. </para>
  520. <para>
  521. On a fundamental level, GEM involves several operations:
  522. <itemizedlist>
  523. <listitem>Memory allocation and freeing</listitem>
  524. <listitem>Command execution</listitem>
  525. <listitem>Aperture management at command execution time</listitem>
  526. </itemizedlist>
  527. Buffer object allocation is relatively straightforward and largely
  528. provided by Linux's shmem layer, which provides memory to back each
  529. object.
  530. </para>
  531. <para>
  532. Device-specific operations, such as command execution, pinning, buffer
  533. read &amp; write, mapping, and domain ownership transfers are left to
  534. driver-specific ioctls.
  535. </para>
  536. <sect3>
  537. <title>GEM Initialization</title>
  538. <para>
  539. Drivers that use GEM must set the DRIVER_GEM bit in the struct
  540. <structname>drm_driver</structname>
  541. <structfield>driver_features</structfield> field. The DRM core will
  542. then automatically initialize the GEM core before calling the
  543. <methodname>load</methodname> operation. Behind the scene, this will
  544. create a DRM Memory Manager object which provides an address space
  545. pool for object allocation.
  546. </para>
  547. <para>
  548. In a KMS configuration, drivers need to allocate and initialize a
  549. command ring buffer following core GEM initialization if required by
  550. the hardware. UMA devices usually have what is called a "stolen"
  551. memory region, which provides space for the initial framebuffer and
  552. large, contiguous memory regions required by the device. This space is
  553. typically not managed by GEM, and must be initialized separately into
  554. its own DRM MM object.
  555. </para>
  556. </sect3>
  557. <sect3>
  558. <title>GEM Objects Creation</title>
  559. <para>
  560. GEM splits creation of GEM objects and allocation of the memory that
  561. backs them in two distinct operations.
  562. </para>
  563. <para>
  564. GEM objects are represented by an instance of struct
  565. <structname>drm_gem_object</structname>. Drivers usually need to extend
  566. GEM objects with private information and thus create a driver-specific
  567. GEM object structure type that embeds an instance of struct
  568. <structname>drm_gem_object</structname>.
  569. </para>
  570. <para>
  571. To create a GEM object, a driver allocates memory for an instance of its
  572. specific GEM object type and initializes the embedded struct
  573. <structname>drm_gem_object</structname> with a call to
  574. <function>drm_gem_object_init</function>. The function takes a pointer to
  575. the DRM device, a pointer to the GEM object and the buffer object size
  576. in bytes.
  577. </para>
  578. <para>
  579. GEM uses shmem to allocate anonymous pageable memory.
  580. <function>drm_gem_object_init</function> will create an shmfs file of
  581. the requested size and store it into the struct
  582. <structname>drm_gem_object</structname> <structfield>filp</structfield>
  583. field. The memory is used as either main storage for the object when the
  584. graphics hardware uses system memory directly or as a backing store
  585. otherwise.
  586. </para>
  587. <para>
  588. Drivers are responsible for the actual physical pages allocation by
  589. calling <function>shmem_read_mapping_page_gfp</function> for each page.
  590. Note that they can decide to allocate pages when initializing the GEM
  591. object, or to delay allocation until the memory is needed (for instance
  592. when a page fault occurs as a result of a userspace memory access or
  593. when the driver needs to start a DMA transfer involving the memory).
  594. </para>
  595. <para>
  596. Anonymous pageable memory allocation is not always desired, for instance
  597. when the hardware requires physically contiguous system memory as is
  598. often the case in embedded devices. Drivers can create GEM objects with
  599. no shmfs backing (called private GEM objects) by initializing them with
  600. a call to <function>drm_gem_private_object_init</function> instead of
  601. <function>drm_gem_object_init</function>. Storage for private GEM
  602. objects must be managed by drivers.
  603. </para>
  604. </sect3>
  605. <sect3>
  606. <title>GEM Objects Lifetime</title>
  607. <para>
  608. All GEM objects are reference-counted by the GEM core. References can be
  609. acquired and release by <function>calling drm_gem_object_reference</function>
  610. and <function>drm_gem_object_unreference</function> respectively. The
  611. caller must hold the <structname>drm_device</structname>
  612. <structfield>struct_mutex</structfield> lock when calling
  613. <function>drm_gem_object_reference</function>. As a convenience, GEM
  614. provides <function>drm_gem_object_unreference_unlocked</function>
  615. functions that can be called without holding the lock.
  616. </para>
  617. <para>
  618. When the last reference to a GEM object is released the GEM core calls
  619. the <structname>drm_driver</structname>
  620. <methodname>gem_free_object</methodname> operation. That operation is
  621. mandatory for GEM-enabled drivers and must free the GEM object and all
  622. associated resources.
  623. </para>
  624. <para>
  625. <synopsis>void (*gem_free_object) (struct drm_gem_object *obj);</synopsis>
  626. Drivers are responsible for freeing all GEM object resources. This includes
  627. the resources created by the GEM core, which need to be released with
  628. <function>drm_gem_object_release</function>.
  629. </para>
  630. </sect3>
  631. <sect3>
  632. <title>GEM Objects Naming</title>
  633. <para>
  634. Communication between userspace and the kernel refers to GEM objects
  635. using local handles, global names or, more recently, file descriptors.
  636. All of those are 32-bit integer values; the usual Linux kernel limits
  637. apply to the file descriptors.
  638. </para>
  639. <para>
  640. GEM handles are local to a DRM file. Applications get a handle to a GEM
  641. object through a driver-specific ioctl, and can use that handle to refer
  642. to the GEM object in other standard or driver-specific ioctls. Closing a
  643. DRM file handle frees all its GEM handles and dereferences the
  644. associated GEM objects.
  645. </para>
  646. <para>
  647. To create a handle for a GEM object drivers call
  648. <function>drm_gem_handle_create</function>. The function takes a pointer
  649. to the DRM file and the GEM object and returns a locally unique handle.
  650. When the handle is no longer needed drivers delete it with a call to
  651. <function>drm_gem_handle_delete</function>. Finally the GEM object
  652. associated with a handle can be retrieved by a call to
  653. <function>drm_gem_object_lookup</function>.
  654. </para>
  655. <para>
  656. Handles don't take ownership of GEM objects, they only take a reference
  657. to the object that will be dropped when the handle is destroyed. To
  658. avoid leaking GEM objects, drivers must make sure they drop the
  659. reference(s) they own (such as the initial reference taken at object
  660. creation time) as appropriate, without any special consideration for the
  661. handle. For example, in the particular case of combined GEM object and
  662. handle creation in the implementation of the
  663. <methodname>dumb_create</methodname> operation, drivers must drop the
  664. initial reference to the GEM object before returning the handle.
  665. </para>
  666. <para>
  667. GEM names are similar in purpose to handles but are not local to DRM
  668. files. They can be passed between processes to reference a GEM object
  669. globally. Names can't be used directly to refer to objects in the DRM
  670. API, applications must convert handles to names and names to handles
  671. using the DRM_IOCTL_GEM_FLINK and DRM_IOCTL_GEM_OPEN ioctls
  672. respectively. The conversion is handled by the DRM core without any
  673. driver-specific support.
  674. </para>
  675. <para>
  676. GEM also supports buffer sharing with dma-buf file descriptors through
  677. PRIME. GEM-based drivers must use the provided helpers functions to
  678. implement the exporting and importing correctly. See <xref linkend="drm-prime-support" />.
  679. Since sharing file descriptors is inherently more secure than the
  680. easily guessable and global GEM names it is the preferred buffer
  681. sharing mechanism. Sharing buffers through GEM names is only supported
  682. for legacy userspace. Furthermore PRIME also allows cross-device
  683. buffer sharing since it is based on dma-bufs.
  684. </para>
  685. </sect3>
  686. <sect3 id="drm-gem-objects-mapping">
  687. <title>GEM Objects Mapping</title>
  688. <para>
  689. Because mapping operations are fairly heavyweight GEM favours
  690. read/write-like access to buffers, implemented through driver-specific
  691. ioctls, over mapping buffers to userspace. However, when random access
  692. to the buffer is needed (to perform software rendering for instance),
  693. direct access to the object can be more efficient.
  694. </para>
  695. <para>
  696. The mmap system call can't be used directly to map GEM objects, as they
  697. don't have their own file handle. Two alternative methods currently
  698. co-exist to map GEM objects to userspace. The first method uses a
  699. driver-specific ioctl to perform the mapping operation, calling
  700. <function>do_mmap</function> under the hood. This is often considered
  701. dubious, seems to be discouraged for new GEM-enabled drivers, and will
  702. thus not be described here.
  703. </para>
  704. <para>
  705. The second method uses the mmap system call on the DRM file handle.
  706. <synopsis>void *mmap(void *addr, size_t length, int prot, int flags, int fd,
  707. off_t offset);</synopsis>
  708. DRM identifies the GEM object to be mapped by a fake offset passed
  709. through the mmap offset argument. Prior to being mapped, a GEM object
  710. must thus be associated with a fake offset. To do so, drivers must call
  711. <function>drm_gem_create_mmap_offset</function> on the object.
  712. </para>
  713. <para>
  714. Once allocated, the fake offset value
  715. must be passed to the application in a driver-specific way and can then
  716. be used as the mmap offset argument.
  717. </para>
  718. <para>
  719. The GEM core provides a helper method <function>drm_gem_mmap</function>
  720. to handle object mapping. The method can be set directly as the mmap
  721. file operation handler. It will look up the GEM object based on the
  722. offset value and set the VMA operations to the
  723. <structname>drm_driver</structname> <structfield>gem_vm_ops</structfield>
  724. field. Note that <function>drm_gem_mmap</function> doesn't map memory to
  725. userspace, but relies on the driver-provided fault handler to map pages
  726. individually.
  727. </para>
  728. <para>
  729. To use <function>drm_gem_mmap</function>, drivers must fill the struct
  730. <structname>drm_driver</structname> <structfield>gem_vm_ops</structfield>
  731. field with a pointer to VM operations.
  732. </para>
  733. <para>
  734. <synopsis>struct vm_operations_struct *gem_vm_ops
  735. struct vm_operations_struct {
  736. void (*open)(struct vm_area_struct * area);
  737. void (*close)(struct vm_area_struct * area);
  738. int (*fault)(struct vm_area_struct *vma, struct vm_fault *vmf);
  739. };</synopsis>
  740. </para>
  741. <para>
  742. The <methodname>open</methodname> and <methodname>close</methodname>
  743. operations must update the GEM object reference count. Drivers can use
  744. the <function>drm_gem_vm_open</function> and
  745. <function>drm_gem_vm_close</function> helper functions directly as open
  746. and close handlers.
  747. </para>
  748. <para>
  749. The fault operation handler is responsible for mapping individual pages
  750. to userspace when a page fault occurs. Depending on the memory
  751. allocation scheme, drivers can allocate pages at fault time, or can
  752. decide to allocate memory for the GEM object at the time the object is
  753. created.
  754. </para>
  755. <para>
  756. Drivers that want to map the GEM object upfront instead of handling page
  757. faults can implement their own mmap file operation handler.
  758. </para>
  759. </sect3>
  760. <sect3>
  761. <title>Memory Coherency</title>
  762. <para>
  763. When mapped to the device or used in a command buffer, backing pages
  764. for an object are flushed to memory and marked write combined so as to
  765. be coherent with the GPU. Likewise, if the CPU accesses an object
  766. after the GPU has finished rendering to the object, then the object
  767. must be made coherent with the CPU's view of memory, usually involving
  768. GPU cache flushing of various kinds. This core CPU&lt;-&gt;GPU
  769. coherency management is provided by a device-specific ioctl, which
  770. evaluates an object's current domain and performs any necessary
  771. flushing or synchronization to put the object into the desired
  772. coherency domain (note that the object may be busy, i.e. an active
  773. render target; in that case, setting the domain blocks the client and
  774. waits for rendering to complete before performing any necessary
  775. flushing operations).
  776. </para>
  777. </sect3>
  778. <sect3>
  779. <title>Command Execution</title>
  780. <para>
  781. Perhaps the most important GEM function for GPU devices is providing a
  782. command execution interface to clients. Client programs construct
  783. command buffers containing references to previously allocated memory
  784. objects, and then submit them to GEM. At that point, GEM takes care to
  785. bind all the objects into the GTT, execute the buffer, and provide
  786. necessary synchronization between clients accessing the same buffers.
  787. This often involves evicting some objects from the GTT and re-binding
  788. others (a fairly expensive operation), and providing relocation
  789. support which hides fixed GTT offsets from clients. Clients must take
  790. care not to submit command buffers that reference more objects than
  791. can fit in the GTT; otherwise, GEM will reject them and no rendering
  792. will occur. Similarly, if several objects in the buffer require fence
  793. registers to be allocated for correct rendering (e.g. 2D blits on
  794. pre-965 chips), care must be taken not to require more fence registers
  795. than are available to the client. Such resource management should be
  796. abstracted from the client in libdrm.
  797. </para>
  798. </sect3>
  799. </sect2>
  800. <sect2>
  801. <title>GEM Function Reference</title>
  802. !Edrivers/gpu/drm/drm_gem.c
  803. !Iinclude/drm/drm_gem.h
  804. </sect2>
  805. <sect2>
  806. <title>VMA Offset Manager</title>
  807. !Pdrivers/gpu/drm/drm_vma_manager.c vma offset manager
  808. !Edrivers/gpu/drm/drm_vma_manager.c
  809. !Iinclude/drm/drm_vma_manager.h
  810. </sect2>
  811. <sect2 id="drm-prime-support">
  812. <title>PRIME Buffer Sharing</title>
  813. <para>
  814. PRIME is the cross device buffer sharing framework in drm, originally
  815. created for the OPTIMUS range of multi-gpu platforms. To userspace
  816. PRIME buffers are dma-buf based file descriptors.
  817. </para>
  818. <sect3>
  819. <title>Overview and Driver Interface</title>
  820. <para>
  821. Similar to GEM global names, PRIME file descriptors are
  822. also used to share buffer objects across processes. They offer
  823. additional security: as file descriptors must be explicitly sent over
  824. UNIX domain sockets to be shared between applications, they can't be
  825. guessed like the globally unique GEM names.
  826. </para>
  827. <para>
  828. Drivers that support the PRIME
  829. API must set the DRIVER_PRIME bit in the struct
  830. <structname>drm_driver</structname>
  831. <structfield>driver_features</structfield> field, and implement the
  832. <methodname>prime_handle_to_fd</methodname> and
  833. <methodname>prime_fd_to_handle</methodname> operations.
  834. </para>
  835. <para>
  836. <synopsis>int (*prime_handle_to_fd)(struct drm_device *dev,
  837. struct drm_file *file_priv, uint32_t handle,
  838. uint32_t flags, int *prime_fd);
  839. int (*prime_fd_to_handle)(struct drm_device *dev,
  840. struct drm_file *file_priv, int prime_fd,
  841. uint32_t *handle);</synopsis>
  842. Those two operations convert a handle to a PRIME file descriptor and
  843. vice versa. Drivers must use the kernel dma-buf buffer sharing framework
  844. to manage the PRIME file descriptors. Similar to the mode setting
  845. API PRIME is agnostic to the underlying buffer object manager, as
  846. long as handles are 32bit unsigned integers.
  847. </para>
  848. <para>
  849. While non-GEM drivers must implement the operations themselves, GEM
  850. drivers must use the <function>drm_gem_prime_handle_to_fd</function>
  851. and <function>drm_gem_prime_fd_to_handle</function> helper functions.
  852. Those helpers rely on the driver
  853. <methodname>gem_prime_export</methodname> and
  854. <methodname>gem_prime_import</methodname> operations to create a dma-buf
  855. instance from a GEM object (dma-buf exporter role) and to create a GEM
  856. object from a dma-buf instance (dma-buf importer role).
  857. </para>
  858. <para>
  859. <synopsis>struct dma_buf * (*gem_prime_export)(struct drm_device *dev,
  860. struct drm_gem_object *obj,
  861. int flags);
  862. struct drm_gem_object * (*gem_prime_import)(struct drm_device *dev,
  863. struct dma_buf *dma_buf);</synopsis>
  864. These two operations are mandatory for GEM drivers that support
  865. PRIME.
  866. </para>
  867. </sect3>
  868. <sect3>
  869. <title>PRIME Helper Functions</title>
  870. !Pdrivers/gpu/drm/drm_prime.c PRIME Helpers
  871. </sect3>
  872. </sect2>
  873. <sect2>
  874. <title>PRIME Function References</title>
  875. !Edrivers/gpu/drm/drm_prime.c
  876. </sect2>
  877. <sect2>
  878. <title>DRM MM Range Allocator</title>
  879. <sect3>
  880. <title>Overview</title>
  881. !Pdrivers/gpu/drm/drm_mm.c Overview
  882. </sect3>
  883. <sect3>
  884. <title>LRU Scan/Eviction Support</title>
  885. !Pdrivers/gpu/drm/drm_mm.c lru scan roaster
  886. </sect3>
  887. </sect2>
  888. <sect2>
  889. <title>DRM MM Range Allocator Function References</title>
  890. !Edrivers/gpu/drm/drm_mm.c
  891. !Iinclude/drm/drm_mm.h
  892. </sect2>
  893. <sect2>
  894. <title>CMA Helper Functions Reference</title>
  895. !Pdrivers/gpu/drm/drm_gem_cma_helper.c cma helpers
  896. !Edrivers/gpu/drm/drm_gem_cma_helper.c
  897. !Iinclude/drm/drm_gem_cma_helper.h
  898. </sect2>
  899. </sect1>
  900. <!-- Internals: mode setting -->
  901. <sect1 id="drm-mode-setting">
  902. <title>Mode Setting</title>
  903. <para>
  904. Drivers must initialize the mode setting core by calling
  905. <function>drm_mode_config_init</function> on the DRM device. The function
  906. initializes the <structname>drm_device</structname>
  907. <structfield>mode_config</structfield> field and never fails. Once done,
  908. mode configuration must be setup by initializing the following fields.
  909. </para>
  910. <itemizedlist>
  911. <listitem>
  912. <synopsis>int min_width, min_height;
  913. int max_width, max_height;</synopsis>
  914. <para>
  915. Minimum and maximum width and height of the frame buffers in pixel
  916. units.
  917. </para>
  918. </listitem>
  919. <listitem>
  920. <synopsis>struct drm_mode_config_funcs *funcs;</synopsis>
  921. <para>Mode setting functions.</para>
  922. </listitem>
  923. </itemizedlist>
  924. <sect2>
  925. <title>Display Modes Function Reference</title>
  926. !Iinclude/drm/drm_modes.h
  927. !Edrivers/gpu/drm/drm_modes.c
  928. </sect2>
  929. <sect2>
  930. <title>Atomic Mode Setting Function Reference</title>
  931. !Edrivers/gpu/drm/drm_atomic.c
  932. </sect2>
  933. <sect2>
  934. <title>Frame Buffer Creation</title>
  935. <synopsis>struct drm_framebuffer *(*fb_create)(struct drm_device *dev,
  936. struct drm_file *file_priv,
  937. struct drm_mode_fb_cmd2 *mode_cmd);</synopsis>
  938. <para>
  939. Frame buffers are abstract memory objects that provide a source of
  940. pixels to scanout to a CRTC. Applications explicitly request the
  941. creation of frame buffers through the DRM_IOCTL_MODE_ADDFB(2) ioctls and
  942. receive an opaque handle that can be passed to the KMS CRTC control,
  943. plane configuration and page flip functions.
  944. </para>
  945. <para>
  946. Frame buffers rely on the underneath memory manager for low-level memory
  947. operations. When creating a frame buffer applications pass a memory
  948. handle (or a list of memory handles for multi-planar formats) through
  949. the <parameter>drm_mode_fb_cmd2</parameter> argument. For drivers using
  950. GEM as their userspace buffer management interface this would be a GEM
  951. handle. Drivers are however free to use their own backing storage object
  952. handles, e.g. vmwgfx directly exposes special TTM handles to userspace
  953. and so expects TTM handles in the create ioctl and not GEM handles.
  954. </para>
  955. <para>
  956. Drivers must first validate the requested frame buffer parameters passed
  957. through the mode_cmd argument. In particular this is where invalid
  958. sizes, pixel formats or pitches can be caught.
  959. </para>
  960. <para>
  961. If the parameters are deemed valid, drivers then create, initialize and
  962. return an instance of struct <structname>drm_framebuffer</structname>.
  963. If desired the instance can be embedded in a larger driver-specific
  964. structure. Drivers must fill its <structfield>width</structfield>,
  965. <structfield>height</structfield>, <structfield>pitches</structfield>,
  966. <structfield>offsets</structfield>, <structfield>depth</structfield>,
  967. <structfield>bits_per_pixel</structfield> and
  968. <structfield>pixel_format</structfield> fields from the values passed
  969. through the <parameter>drm_mode_fb_cmd2</parameter> argument. They
  970. should call the <function>drm_helper_mode_fill_fb_struct</function>
  971. helper function to do so.
  972. </para>
  973. <para>
  974. The initialization of the new framebuffer instance is finalized with a
  975. call to <function>drm_framebuffer_init</function> which takes a pointer
  976. to DRM frame buffer operations (struct
  977. <structname>drm_framebuffer_funcs</structname>). Note that this function
  978. publishes the framebuffer and so from this point on it can be accessed
  979. concurrently from other threads. Hence it must be the last step in the
  980. driver's framebuffer initialization sequence. Frame buffer operations
  981. are
  982. <itemizedlist>
  983. <listitem>
  984. <synopsis>int (*create_handle)(struct drm_framebuffer *fb,
  985. struct drm_file *file_priv, unsigned int *handle);</synopsis>
  986. <para>
  987. Create a handle to the frame buffer underlying memory object. If
  988. the frame buffer uses a multi-plane format, the handle will
  989. reference the memory object associated with the first plane.
  990. </para>
  991. <para>
  992. Drivers call <function>drm_gem_handle_create</function> to create
  993. the handle.
  994. </para>
  995. </listitem>
  996. <listitem>
  997. <synopsis>void (*destroy)(struct drm_framebuffer *framebuffer);</synopsis>
  998. <para>
  999. Destroy the frame buffer object and frees all associated
  1000. resources. Drivers must call
  1001. <function>drm_framebuffer_cleanup</function> to free resources
  1002. allocated by the DRM core for the frame buffer object, and must
  1003. make sure to unreference all memory objects associated with the
  1004. frame buffer. Handles created by the
  1005. <methodname>create_handle</methodname> operation are released by
  1006. the DRM core.
  1007. </para>
  1008. </listitem>
  1009. <listitem>
  1010. <synopsis>int (*dirty)(struct drm_framebuffer *framebuffer,
  1011. struct drm_file *file_priv, unsigned flags, unsigned color,
  1012. struct drm_clip_rect *clips, unsigned num_clips);</synopsis>
  1013. <para>
  1014. This optional operation notifies the driver that a region of the
  1015. frame buffer has changed in response to a DRM_IOCTL_MODE_DIRTYFB
  1016. ioctl call.
  1017. </para>
  1018. </listitem>
  1019. </itemizedlist>
  1020. </para>
  1021. <para>
  1022. The lifetime of a drm framebuffer is controlled with a reference count,
  1023. drivers can grab additional references with
  1024. <function>drm_framebuffer_reference</function>and drop them
  1025. again with <function>drm_framebuffer_unreference</function>. For
  1026. driver-private framebuffers for which the last reference is never
  1027. dropped (e.g. for the fbdev framebuffer when the struct
  1028. <structname>drm_framebuffer</structname> is embedded into the fbdev
  1029. helper struct) drivers can manually clean up a framebuffer at module
  1030. unload time with
  1031. <function>drm_framebuffer_unregister_private</function>.
  1032. </para>
  1033. </sect2>
  1034. <sect2>
  1035. <title>Dumb Buffer Objects</title>
  1036. <para>
  1037. The KMS API doesn't standardize backing storage object creation and
  1038. leaves it to driver-specific ioctls. Furthermore actually creating a
  1039. buffer object even for GEM-based drivers is done through a
  1040. driver-specific ioctl - GEM only has a common userspace interface for
  1041. sharing and destroying objects. While not an issue for full-fledged
  1042. graphics stacks that include device-specific userspace components (in
  1043. libdrm for instance), this limit makes DRM-based early boot graphics
  1044. unnecessarily complex.
  1045. </para>
  1046. <para>
  1047. Dumb objects partly alleviate the problem by providing a standard
  1048. API to create dumb buffers suitable for scanout, which can then be used
  1049. to create KMS frame buffers.
  1050. </para>
  1051. <para>
  1052. To support dumb objects drivers must implement the
  1053. <methodname>dumb_create</methodname>,
  1054. <methodname>dumb_destroy</methodname> and
  1055. <methodname>dumb_map_offset</methodname> operations.
  1056. </para>
  1057. <itemizedlist>
  1058. <listitem>
  1059. <synopsis>int (*dumb_create)(struct drm_file *file_priv, struct drm_device *dev,
  1060. struct drm_mode_create_dumb *args);</synopsis>
  1061. <para>
  1062. The <methodname>dumb_create</methodname> operation creates a driver
  1063. object (GEM or TTM handle) suitable for scanout based on the
  1064. width, height and depth from the struct
  1065. <structname>drm_mode_create_dumb</structname> argument. It fills the
  1066. argument's <structfield>handle</structfield>,
  1067. <structfield>pitch</structfield> and <structfield>size</structfield>
  1068. fields with a handle for the newly created object and its line
  1069. pitch and size in bytes.
  1070. </para>
  1071. </listitem>
  1072. <listitem>
  1073. <synopsis>int (*dumb_destroy)(struct drm_file *file_priv, struct drm_device *dev,
  1074. uint32_t handle);</synopsis>
  1075. <para>
  1076. The <methodname>dumb_destroy</methodname> operation destroys a dumb
  1077. object created by <methodname>dumb_create</methodname>.
  1078. </para>
  1079. </listitem>
  1080. <listitem>
  1081. <synopsis>int (*dumb_map_offset)(struct drm_file *file_priv, struct drm_device *dev,
  1082. uint32_t handle, uint64_t *offset);</synopsis>
  1083. <para>
  1084. The <methodname>dumb_map_offset</methodname> operation associates an
  1085. mmap fake offset with the object given by the handle and returns
  1086. it. Drivers must use the
  1087. <function>drm_gem_create_mmap_offset</function> function to
  1088. associate the fake offset as described in
  1089. <xref linkend="drm-gem-objects-mapping"/>.
  1090. </para>
  1091. </listitem>
  1092. </itemizedlist>
  1093. <para>
  1094. Note that dumb objects may not be used for gpu acceleration, as has been
  1095. attempted on some ARM embedded platforms. Such drivers really must have
  1096. a hardware-specific ioctl to allocate suitable buffer objects.
  1097. </para>
  1098. </sect2>
  1099. <sect2>
  1100. <title>Output Polling</title>
  1101. <synopsis>void (*output_poll_changed)(struct drm_device *dev);</synopsis>
  1102. <para>
  1103. This operation notifies the driver that the status of one or more
  1104. connectors has changed. Drivers that use the fb helper can just call the
  1105. <function>drm_fb_helper_hotplug_event</function> function to handle this
  1106. operation.
  1107. </para>
  1108. </sect2>
  1109. <sect2>
  1110. <title>Locking</title>
  1111. <para>
  1112. Beside some lookup structures with their own locking (which is hidden
  1113. behind the interface functions) most of the modeset state is protected
  1114. by the <code>dev-&lt;mode_config.lock</code> mutex and additionally
  1115. per-crtc locks to allow cursor updates, pageflips and similar operations
  1116. to occur concurrently with background tasks like output detection.
  1117. Operations which cross domains like a full modeset always grab all
  1118. locks. Drivers there need to protect resources shared between crtcs with
  1119. additional locking. They also need to be careful to always grab the
  1120. relevant crtc locks if a modset functions touches crtc state, e.g. for
  1121. load detection (which does only grab the <code>mode_config.lock</code>
  1122. to allow concurrent screen updates on live crtcs).
  1123. </para>
  1124. </sect2>
  1125. </sect1>
  1126. <!-- Internals: kms initialization and cleanup -->
  1127. <sect1 id="drm-kms-init">
  1128. <title>KMS Initialization and Cleanup</title>
  1129. <para>
  1130. A KMS device is abstracted and exposed as a set of planes, CRTCs, encoders
  1131. and connectors. KMS drivers must thus create and initialize all those
  1132. objects at load time after initializing mode setting.
  1133. </para>
  1134. <sect2>
  1135. <title>CRTCs (struct <structname>drm_crtc</structname>)</title>
  1136. <para>
  1137. A CRTC is an abstraction representing a part of the chip that contains a
  1138. pointer to a scanout buffer. Therefore, the number of CRTCs available
  1139. determines how many independent scanout buffers can be active at any
  1140. given time. The CRTC structure contains several fields to support this:
  1141. a pointer to some video memory (abstracted as a frame buffer object), a
  1142. display mode, and an (x, y) offset into the video memory to support
  1143. panning or configurations where one piece of video memory spans multiple
  1144. CRTCs.
  1145. </para>
  1146. <sect3>
  1147. <title>CRTC Initialization</title>
  1148. <para>
  1149. A KMS device must create and register at least one struct
  1150. <structname>drm_crtc</structname> instance. The instance is allocated
  1151. and zeroed by the driver, possibly as part of a larger structure, and
  1152. registered with a call to <function>drm_crtc_init</function> with a
  1153. pointer to CRTC functions.
  1154. </para>
  1155. </sect3>
  1156. <sect3 id="drm-kms-crtcops">
  1157. <title>CRTC Operations</title>
  1158. <sect4>
  1159. <title>Set Configuration</title>
  1160. <synopsis>int (*set_config)(struct drm_mode_set *set);</synopsis>
  1161. <para>
  1162. Apply a new CRTC configuration to the device. The configuration
  1163. specifies a CRTC, a frame buffer to scan out from, a (x,y) position in
  1164. the frame buffer, a display mode and an array of connectors to drive
  1165. with the CRTC if possible.
  1166. </para>
  1167. <para>
  1168. If the frame buffer specified in the configuration is NULL, the driver
  1169. must detach all encoders connected to the CRTC and all connectors
  1170. attached to those encoders and disable them.
  1171. </para>
  1172. <para>
  1173. This operation is called with the mode config lock held.
  1174. </para>
  1175. <note><para>
  1176. Note that the drm core has no notion of restoring the mode setting
  1177. state after resume, since all resume handling is in the full
  1178. responsibility of the driver. The common mode setting helper library
  1179. though provides a helper which can be used for this:
  1180. <function>drm_helper_resume_force_mode</function>.
  1181. </para></note>
  1182. </sect4>
  1183. <sect4>
  1184. <title>Page Flipping</title>
  1185. <synopsis>int (*page_flip)(struct drm_crtc *crtc, struct drm_framebuffer *fb,
  1186. struct drm_pending_vblank_event *event);</synopsis>
  1187. <para>
  1188. Schedule a page flip to the given frame buffer for the CRTC. This
  1189. operation is called with the mode config mutex held.
  1190. </para>
  1191. <para>
  1192. Page flipping is a synchronization mechanism that replaces the frame
  1193. buffer being scanned out by the CRTC with a new frame buffer during
  1194. vertical blanking, avoiding tearing. When an application requests a page
  1195. flip the DRM core verifies that the new frame buffer is large enough to
  1196. be scanned out by the CRTC in the currently configured mode and then
  1197. calls the CRTC <methodname>page_flip</methodname> operation with a
  1198. pointer to the new frame buffer.
  1199. </para>
  1200. <para>
  1201. The <methodname>page_flip</methodname> operation schedules a page flip.
  1202. Once any pending rendering targeting the new frame buffer has
  1203. completed, the CRTC will be reprogrammed to display that frame buffer
  1204. after the next vertical refresh. The operation must return immediately
  1205. without waiting for rendering or page flip to complete and must block
  1206. any new rendering to the frame buffer until the page flip completes.
  1207. </para>
  1208. <para>
  1209. If a page flip can be successfully scheduled the driver must set the
  1210. <code>drm_crtc-&gt;fb</code> field to the new framebuffer pointed to
  1211. by <code>fb</code>. This is important so that the reference counting
  1212. on framebuffers stays balanced.
  1213. </para>
  1214. <para>
  1215. If a page flip is already pending, the
  1216. <methodname>page_flip</methodname> operation must return
  1217. -<errorname>EBUSY</errorname>.
  1218. </para>
  1219. <para>
  1220. To synchronize page flip to vertical blanking the driver will likely
  1221. need to enable vertical blanking interrupts. It should call
  1222. <function>drm_vblank_get</function> for that purpose, and call
  1223. <function>drm_vblank_put</function> after the page flip completes.
  1224. </para>
  1225. <para>
  1226. If the application has requested to be notified when page flip completes
  1227. the <methodname>page_flip</methodname> operation will be called with a
  1228. non-NULL <parameter>event</parameter> argument pointing to a
  1229. <structname>drm_pending_vblank_event</structname> instance. Upon page
  1230. flip completion the driver must call <methodname>drm_send_vblank_event</methodname>
  1231. to fill in the event and send to wake up any waiting processes.
  1232. This can be performed with
  1233. <programlisting><![CDATA[
  1234. spin_lock_irqsave(&dev->event_lock, flags);
  1235. ...
  1236. drm_send_vblank_event(dev, pipe, event);
  1237. spin_unlock_irqrestore(&dev->event_lock, flags);
  1238. ]]></programlisting>
  1239. </para>
  1240. <note><para>
  1241. FIXME: Could drivers that don't need to wait for rendering to complete
  1242. just add the event to <literal>dev-&gt;vblank_event_list</literal> and
  1243. let the DRM core handle everything, as for "normal" vertical blanking
  1244. events?
  1245. </para></note>
  1246. <para>
  1247. While waiting for the page flip to complete, the
  1248. <literal>event-&gt;base.link</literal> list head can be used freely by
  1249. the driver to store the pending event in a driver-specific list.
  1250. </para>
  1251. <para>
  1252. If the file handle is closed before the event is signaled, drivers must
  1253. take care to destroy the event in their
  1254. <methodname>preclose</methodname> operation (and, if needed, call
  1255. <function>drm_vblank_put</function>).
  1256. </para>
  1257. </sect4>
  1258. <sect4>
  1259. <title>Miscellaneous</title>
  1260. <itemizedlist>
  1261. <listitem>
  1262. <synopsis>void (*set_property)(struct drm_crtc *crtc,
  1263. struct drm_property *property, uint64_t value);</synopsis>
  1264. <para>
  1265. Set the value of the given CRTC property to
  1266. <parameter>value</parameter>. See <xref linkend="drm-kms-properties"/>
  1267. for more information about properties.
  1268. </para>
  1269. </listitem>
  1270. <listitem>
  1271. <synopsis>void (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
  1272. uint32_t start, uint32_t size);</synopsis>
  1273. <para>
  1274. Apply a gamma table to the device. The operation is optional.
  1275. </para>
  1276. </listitem>
  1277. <listitem>
  1278. <synopsis>void (*destroy)(struct drm_crtc *crtc);</synopsis>
  1279. <para>
  1280. Destroy the CRTC when not needed anymore. See
  1281. <xref linkend="drm-kms-init"/>.
  1282. </para>
  1283. </listitem>
  1284. </itemizedlist>
  1285. </sect4>
  1286. </sect3>
  1287. </sect2>
  1288. <sect2>
  1289. <title>Planes (struct <structname>drm_plane</structname>)</title>
  1290. <para>
  1291. A plane represents an image source that can be blended with or overlayed
  1292. on top of a CRTC during the scanout process. Planes are associated with
  1293. a frame buffer to crop a portion of the image memory (source) and
  1294. optionally scale it to a destination size. The result is then blended
  1295. with or overlayed on top of a CRTC.
  1296. </para>
  1297. <para>
  1298. The DRM core recognizes three types of planes:
  1299. <itemizedlist>
  1300. <listitem>
  1301. DRM_PLANE_TYPE_PRIMARY represents a "main" plane for a CRTC. Primary
  1302. planes are the planes operated upon by CRTC modesetting and flipping
  1303. operations described in <xref linkend="drm-kms-crtcops"/>.
  1304. </listitem>
  1305. <listitem>
  1306. DRM_PLANE_TYPE_CURSOR represents a "cursor" plane for a CRTC. Cursor
  1307. planes are the planes operated upon by the DRM_IOCTL_MODE_CURSOR and
  1308. DRM_IOCTL_MODE_CURSOR2 ioctls.
  1309. </listitem>
  1310. <listitem>
  1311. DRM_PLANE_TYPE_OVERLAY represents all non-primary, non-cursor planes.
  1312. Some drivers refer to these types of planes as "sprites" internally.
  1313. </listitem>
  1314. </itemizedlist>
  1315. For compatibility with legacy userspace, only overlay planes are made
  1316. available to userspace by default. Userspace clients may set the
  1317. DRM_CLIENT_CAP_UNIVERSAL_PLANES client capability bit to indicate that
  1318. they wish to receive a universal plane list containing all plane types.
  1319. </para>
  1320. <sect3>
  1321. <title>Plane Initialization</title>
  1322. <para>
  1323. To create a plane, a KMS drivers allocates and
  1324. zeroes an instances of struct <structname>drm_plane</structname>
  1325. (possibly as part of a larger structure) and registers it with a call
  1326. to <function>drm_universal_plane_init</function>. The function takes a bitmask
  1327. of the CRTCs that can be associated with the plane, a pointer to the
  1328. plane functions, a list of format supported formats, and the type of
  1329. plane (primary, cursor, or overlay) being initialized.
  1330. </para>
  1331. <para>
  1332. Cursor and overlay planes are optional. All drivers should provide
  1333. one primary plane per CRTC (although this requirement may change in
  1334. the future); drivers that do not wish to provide special handling for
  1335. primary planes may make use of the helper functions described in
  1336. <xref linkend="drm-kms-planehelpers"/> to create and register a
  1337. primary plane with standard capabilities.
  1338. </para>
  1339. </sect3>
  1340. <sect3>
  1341. <title>Plane Operations</title>
  1342. <itemizedlist>
  1343. <listitem>
  1344. <synopsis>int (*update_plane)(struct drm_plane *plane, struct drm_crtc *crtc,
  1345. struct drm_framebuffer *fb, int crtc_x, int crtc_y,
  1346. unsigned int crtc_w, unsigned int crtc_h,
  1347. uint32_t src_x, uint32_t src_y,
  1348. uint32_t src_w, uint32_t src_h);</synopsis>
  1349. <para>
  1350. Enable and configure the plane to use the given CRTC and frame buffer.
  1351. </para>
  1352. <para>
  1353. The source rectangle in frame buffer memory coordinates is given by
  1354. the <parameter>src_x</parameter>, <parameter>src_y</parameter>,
  1355. <parameter>src_w</parameter> and <parameter>src_h</parameter>
  1356. parameters (as 16.16 fixed point values). Devices that don't support
  1357. subpixel plane coordinates can ignore the fractional part.
  1358. </para>
  1359. <para>
  1360. The destination rectangle in CRTC coordinates is given by the
  1361. <parameter>crtc_x</parameter>, <parameter>crtc_y</parameter>,
  1362. <parameter>crtc_w</parameter> and <parameter>crtc_h</parameter>
  1363. parameters (as integer values). Devices scale the source rectangle to
  1364. the destination rectangle. If scaling is not supported, and the source
  1365. rectangle size doesn't match the destination rectangle size, the
  1366. driver must return a -<errorname>EINVAL</errorname> error.
  1367. </para>
  1368. </listitem>
  1369. <listitem>
  1370. <synopsis>int (*disable_plane)(struct drm_plane *plane);</synopsis>
  1371. <para>
  1372. Disable the plane. The DRM core calls this method in response to a
  1373. DRM_IOCTL_MODE_SETPLANE ioctl call with the frame buffer ID set to 0.
  1374. Disabled planes must not be processed by the CRTC.
  1375. </para>
  1376. </listitem>
  1377. <listitem>
  1378. <synopsis>void (*destroy)(struct drm_plane *plane);</synopsis>
  1379. <para>
  1380. Destroy the plane when not needed anymore. See
  1381. <xref linkend="drm-kms-init"/>.
  1382. </para>
  1383. </listitem>
  1384. </itemizedlist>
  1385. </sect3>
  1386. </sect2>
  1387. <sect2>
  1388. <title>Encoders (struct <structname>drm_encoder</structname>)</title>
  1389. <para>
  1390. An encoder takes pixel data from a CRTC and converts it to a format
  1391. suitable for any attached connectors. On some devices, it may be
  1392. possible to have a CRTC send data to more than one encoder. In that
  1393. case, both encoders would receive data from the same scanout buffer,
  1394. resulting in a "cloned" display configuration across the connectors
  1395. attached to each encoder.
  1396. </para>
  1397. <sect3>
  1398. <title>Encoder Initialization</title>
  1399. <para>
  1400. As for CRTCs, a KMS driver must create, initialize and register at
  1401. least one struct <structname>drm_encoder</structname> instance. The
  1402. instance is allocated and zeroed by the driver, possibly as part of a
  1403. larger structure.
  1404. </para>
  1405. <para>
  1406. Drivers must initialize the struct <structname>drm_encoder</structname>
  1407. <structfield>possible_crtcs</structfield> and
  1408. <structfield>possible_clones</structfield> fields before registering the
  1409. encoder. Both fields are bitmasks of respectively the CRTCs that the
  1410. encoder can be connected to, and sibling encoders candidate for cloning.
  1411. </para>
  1412. <para>
  1413. After being initialized, the encoder must be registered with a call to
  1414. <function>drm_encoder_init</function>. The function takes a pointer to
  1415. the encoder functions and an encoder type. Supported types are
  1416. <itemizedlist>
  1417. <listitem>
  1418. DRM_MODE_ENCODER_DAC for VGA and analog on DVI-I/DVI-A
  1419. </listitem>
  1420. <listitem>
  1421. DRM_MODE_ENCODER_TMDS for DVI, HDMI and (embedded) DisplayPort
  1422. </listitem>
  1423. <listitem>
  1424. DRM_MODE_ENCODER_LVDS for display panels
  1425. </listitem>
  1426. <listitem>
  1427. DRM_MODE_ENCODER_TVDAC for TV output (Composite, S-Video, Component,
  1428. SCART)
  1429. </listitem>
  1430. <listitem>
  1431. DRM_MODE_ENCODER_VIRTUAL for virtual machine displays
  1432. </listitem>
  1433. </itemizedlist>
  1434. </para>
  1435. <para>
  1436. Encoders must be attached to a CRTC to be used. DRM drivers leave
  1437. encoders unattached at initialization time. Applications (or the fbdev
  1438. compatibility layer when implemented) are responsible for attaching the
  1439. encoders they want to use to a CRTC.
  1440. </para>
  1441. </sect3>
  1442. <sect3>
  1443. <title>Encoder Operations</title>
  1444. <itemizedlist>
  1445. <listitem>
  1446. <synopsis>void (*destroy)(struct drm_encoder *encoder);</synopsis>
  1447. <para>
  1448. Called to destroy the encoder when not needed anymore. See
  1449. <xref linkend="drm-kms-init"/>.
  1450. </para>
  1451. </listitem>
  1452. <listitem>
  1453. <synopsis>void (*set_property)(struct drm_plane *plane,
  1454. struct drm_property *property, uint64_t value);</synopsis>
  1455. <para>
  1456. Set the value of the given plane property to
  1457. <parameter>value</parameter>. See <xref linkend="drm-kms-properties"/>
  1458. for more information about properties.
  1459. </para>
  1460. </listitem>
  1461. </itemizedlist>
  1462. </sect3>
  1463. </sect2>
  1464. <sect2>
  1465. <title>Connectors (struct <structname>drm_connector</structname>)</title>
  1466. <para>
  1467. A connector is the final destination for pixel data on a device, and
  1468. usually connects directly to an external display device like a monitor
  1469. or laptop panel. A connector can only be attached to one encoder at a
  1470. time. The connector is also the structure where information about the
  1471. attached display is kept, so it contains fields for display data, EDID
  1472. data, DPMS &amp; connection status, and information about modes
  1473. supported on the attached displays.
  1474. </para>
  1475. <sect3>
  1476. <title>Connector Initialization</title>
  1477. <para>
  1478. Finally a KMS driver must create, initialize, register and attach at
  1479. least one struct <structname>drm_connector</structname> instance. The
  1480. instance is created as other KMS objects and initialized by setting the
  1481. following fields.
  1482. </para>
  1483. <variablelist>
  1484. <varlistentry>
  1485. <term><structfield>interlace_allowed</structfield></term>
  1486. <listitem><para>
  1487. Whether the connector can handle interlaced modes.
  1488. </para></listitem>
  1489. </varlistentry>
  1490. <varlistentry>
  1491. <term><structfield>doublescan_allowed</structfield></term>
  1492. <listitem><para>
  1493. Whether the connector can handle doublescan.
  1494. </para></listitem>
  1495. </varlistentry>
  1496. <varlistentry>
  1497. <term><structfield>display_info
  1498. </structfield></term>
  1499. <listitem><para>
  1500. Display information is filled from EDID information when a display
  1501. is detected. For non hot-pluggable displays such as flat panels in
  1502. embedded systems, the driver should initialize the
  1503. <structfield>display_info</structfield>.<structfield>width_mm</structfield>
  1504. and
  1505. <structfield>display_info</structfield>.<structfield>height_mm</structfield>
  1506. fields with the physical size of the display.
  1507. </para></listitem>
  1508. </varlistentry>
  1509. <varlistentry>
  1510. <term id="drm-kms-connector-polled"><structfield>polled</structfield></term>
  1511. <listitem><para>
  1512. Connector polling mode, a combination of
  1513. <variablelist>
  1514. <varlistentry>
  1515. <term>DRM_CONNECTOR_POLL_HPD</term>
  1516. <listitem><para>
  1517. The connector generates hotplug events and doesn't need to be
  1518. periodically polled. The CONNECT and DISCONNECT flags must not
  1519. be set together with the HPD flag.
  1520. </para></listitem>
  1521. </varlistentry>
  1522. <varlistentry>
  1523. <term>DRM_CONNECTOR_POLL_CONNECT</term>
  1524. <listitem><para>
  1525. Periodically poll the connector for connection.
  1526. </para></listitem>
  1527. </varlistentry>
  1528. <varlistentry>
  1529. <term>DRM_CONNECTOR_POLL_DISCONNECT</term>
  1530. <listitem><para>
  1531. Periodically poll the connector for disconnection.
  1532. </para></listitem>
  1533. </varlistentry>
  1534. </variablelist>
  1535. Set to 0 for connectors that don't support connection status
  1536. discovery.
  1537. </para></listitem>
  1538. </varlistentry>
  1539. </variablelist>
  1540. <para>
  1541. The connector is then registered with a call to
  1542. <function>drm_connector_init</function> with a pointer to the connector
  1543. functions and a connector type, and exposed through sysfs with a call to
  1544. <function>drm_connector_register</function>.
  1545. </para>
  1546. <para>
  1547. Supported connector types are
  1548. <itemizedlist>
  1549. <listitem>DRM_MODE_CONNECTOR_VGA</listitem>
  1550. <listitem>DRM_MODE_CONNECTOR_DVII</listitem>
  1551. <listitem>DRM_MODE_CONNECTOR_DVID</listitem>
  1552. <listitem>DRM_MODE_CONNECTOR_DVIA</listitem>
  1553. <listitem>DRM_MODE_CONNECTOR_Composite</listitem>
  1554. <listitem>DRM_MODE_CONNECTOR_SVIDEO</listitem>
  1555. <listitem>DRM_MODE_CONNECTOR_LVDS</listitem>
  1556. <listitem>DRM_MODE_CONNECTOR_Component</listitem>
  1557. <listitem>DRM_MODE_CONNECTOR_9PinDIN</listitem>
  1558. <listitem>DRM_MODE_CONNECTOR_DisplayPort</listitem>
  1559. <listitem>DRM_MODE_CONNECTOR_HDMIA</listitem>
  1560. <listitem>DRM_MODE_CONNECTOR_HDMIB</listitem>
  1561. <listitem>DRM_MODE_CONNECTOR_TV</listitem>
  1562. <listitem>DRM_MODE_CONNECTOR_eDP</listitem>
  1563. <listitem>DRM_MODE_CONNECTOR_VIRTUAL</listitem>
  1564. </itemizedlist>
  1565. </para>
  1566. <para>
  1567. Connectors must be attached to an encoder to be used. For devices that
  1568. map connectors to encoders 1:1, the connector should be attached at
  1569. initialization time with a call to
  1570. <function>drm_mode_connector_attach_encoder</function>. The driver must
  1571. also set the <structname>drm_connector</structname>
  1572. <structfield>encoder</structfield> field to point to the attached
  1573. encoder.
  1574. </para>
  1575. <para>
  1576. Finally, drivers must initialize the connectors state change detection
  1577. with a call to <function>drm_kms_helper_poll_init</function>. If at
  1578. least one connector is pollable but can't generate hotplug interrupts
  1579. (indicated by the DRM_CONNECTOR_POLL_CONNECT and
  1580. DRM_CONNECTOR_POLL_DISCONNECT connector flags), a delayed work will
  1581. automatically be queued to periodically poll for changes. Connectors
  1582. that can generate hotplug interrupts must be marked with the
  1583. DRM_CONNECTOR_POLL_HPD flag instead, and their interrupt handler must
  1584. call <function>drm_helper_hpd_irq_event</function>. The function will
  1585. queue a delayed work to check the state of all connectors, but no
  1586. periodic polling will be done.
  1587. </para>
  1588. </sect3>
  1589. <sect3>
  1590. <title>Connector Operations</title>
  1591. <note><para>
  1592. Unless otherwise state, all operations are mandatory.
  1593. </para></note>
  1594. <sect4>
  1595. <title>DPMS</title>
  1596. <synopsis>void (*dpms)(struct drm_connector *connector, int mode);</synopsis>
  1597. <para>
  1598. The DPMS operation sets the power state of a connector. The mode
  1599. argument is one of
  1600. <itemizedlist>
  1601. <listitem><para>DRM_MODE_DPMS_ON</para></listitem>
  1602. <listitem><para>DRM_MODE_DPMS_STANDBY</para></listitem>
  1603. <listitem><para>DRM_MODE_DPMS_SUSPEND</para></listitem>
  1604. <listitem><para>DRM_MODE_DPMS_OFF</para></listitem>
  1605. </itemizedlist>
  1606. </para>
  1607. <para>
  1608. In all but DPMS_ON mode the encoder to which the connector is attached
  1609. should put the display in low-power mode by driving its signals
  1610. appropriately. If more than one connector is attached to the encoder
  1611. care should be taken not to change the power state of other displays as
  1612. a side effect. Low-power mode should be propagated to the encoders and
  1613. CRTCs when all related connectors are put in low-power mode.
  1614. </para>
  1615. </sect4>
  1616. <sect4>
  1617. <title>Modes</title>
  1618. <synopsis>int (*fill_modes)(struct drm_connector *connector, uint32_t max_width,
  1619. uint32_t max_height);</synopsis>
  1620. <para>
  1621. Fill the mode list with all supported modes for the connector. If the
  1622. <parameter>max_width</parameter> and <parameter>max_height</parameter>
  1623. arguments are non-zero, the implementation must ignore all modes wider
  1624. than <parameter>max_width</parameter> or higher than
  1625. <parameter>max_height</parameter>.
  1626. </para>
  1627. <para>
  1628. The connector must also fill in this operation its
  1629. <structfield>display_info</structfield>
  1630. <structfield>width_mm</structfield> and
  1631. <structfield>height_mm</structfield> fields with the connected display
  1632. physical size in millimeters. The fields should be set to 0 if the value
  1633. isn't known or is not applicable (for instance for projector devices).
  1634. </para>
  1635. </sect4>
  1636. <sect4>
  1637. <title>Connection Status</title>
  1638. <para>
  1639. The connection status is updated through polling or hotplug events when
  1640. supported (see <xref linkend="drm-kms-connector-polled"/>). The status
  1641. value is reported to userspace through ioctls and must not be used
  1642. inside the driver, as it only gets initialized by a call to
  1643. <function>drm_mode_getconnector</function> from userspace.
  1644. </para>
  1645. <synopsis>enum drm_connector_status (*detect)(struct drm_connector *connector,
  1646. bool force);</synopsis>
  1647. <para>
  1648. Check to see if anything is attached to the connector. The
  1649. <parameter>force</parameter> parameter is set to false whilst polling or
  1650. to true when checking the connector due to user request.
  1651. <parameter>force</parameter> can be used by the driver to avoid
  1652. expensive, destructive operations during automated probing.
  1653. </para>
  1654. <para>
  1655. Return connector_status_connected if something is connected to the
  1656. connector, connector_status_disconnected if nothing is connected and
  1657. connector_status_unknown if the connection state isn't known.
  1658. </para>
  1659. <para>
  1660. Drivers should only return connector_status_connected if the connection
  1661. status has really been probed as connected. Connectors that can't detect
  1662. the connection status, or failed connection status probes, should return
  1663. connector_status_unknown.
  1664. </para>
  1665. </sect4>
  1666. <sect4>
  1667. <title>Miscellaneous</title>
  1668. <itemizedlist>
  1669. <listitem>
  1670. <synopsis>void (*set_property)(struct drm_connector *connector,
  1671. struct drm_property *property, uint64_t value);</synopsis>
  1672. <para>
  1673. Set the value of the given connector property to
  1674. <parameter>value</parameter>. See <xref linkend="drm-kms-properties"/>
  1675. for more information about properties.
  1676. </para>
  1677. </listitem>
  1678. <listitem>
  1679. <synopsis>void (*destroy)(struct drm_connector *connector);</synopsis>
  1680. <para>
  1681. Destroy the connector when not needed anymore. See
  1682. <xref linkend="drm-kms-init"/>.
  1683. </para>
  1684. </listitem>
  1685. </itemizedlist>
  1686. </sect4>
  1687. </sect3>
  1688. </sect2>
  1689. <sect2>
  1690. <title>Cleanup</title>
  1691. <para>
  1692. The DRM core manages its objects' lifetime. When an object is not needed
  1693. anymore the core calls its destroy function, which must clean up and
  1694. free every resource allocated for the object. Every
  1695. <function>drm_*_init</function> call must be matched with a
  1696. corresponding <function>drm_*_cleanup</function> call to cleanup CRTCs
  1697. (<function>drm_crtc_cleanup</function>), planes
  1698. (<function>drm_plane_cleanup</function>), encoders
  1699. (<function>drm_encoder_cleanup</function>) and connectors
  1700. (<function>drm_connector_cleanup</function>). Furthermore, connectors
  1701. that have been added to sysfs must be removed by a call to
  1702. <function>drm_connector_unregister</function> before calling
  1703. <function>drm_connector_cleanup</function>.
  1704. </para>
  1705. <para>
  1706. Connectors state change detection must be cleanup up with a call to
  1707. <function>drm_kms_helper_poll_fini</function>.
  1708. </para>
  1709. </sect2>
  1710. <sect2>
  1711. <title>Output discovery and initialization example</title>
  1712. <programlisting><![CDATA[
  1713. void intel_crt_init(struct drm_device *dev)
  1714. {
  1715. struct drm_connector *connector;
  1716. struct intel_output *intel_output;
  1717. intel_output = kzalloc(sizeof(struct intel_output), GFP_KERNEL);
  1718. if (!intel_output)
  1719. return;
  1720. connector = &intel_output->base;
  1721. drm_connector_init(dev, &intel_output->base,
  1722. &intel_crt_connector_funcs, DRM_MODE_CONNECTOR_VGA);
  1723. drm_encoder_init(dev, &intel_output->enc, &intel_crt_enc_funcs,
  1724. DRM_MODE_ENCODER_DAC);
  1725. drm_mode_connector_attach_encoder(&intel_output->base,
  1726. &intel_output->enc);
  1727. /* Set up the DDC bus. */
  1728. intel_output->ddc_bus = intel_i2c_create(dev, GPIOA, "CRTDDC_A");
  1729. if (!intel_output->ddc_bus) {
  1730. dev_printk(KERN_ERR, &dev->pdev->dev, "DDC bus registration "
  1731. "failed.\n");
  1732. return;
  1733. }
  1734. intel_output->type = INTEL_OUTPUT_ANALOG;
  1735. connector->interlace_allowed = 0;
  1736. connector->doublescan_allowed = 0;
  1737. drm_encoder_helper_add(&intel_output->enc, &intel_crt_helper_funcs);
  1738. drm_connector_helper_add(connector, &intel_crt_connector_helper_funcs);
  1739. drm_connector_register(connector);
  1740. }]]></programlisting>
  1741. <para>
  1742. In the example above (taken from the i915 driver), a CRTC, connector and
  1743. encoder combination is created. A device-specific i2c bus is also
  1744. created for fetching EDID data and performing monitor detection. Once
  1745. the process is complete, the new connector is registered with sysfs to
  1746. make its properties available to applications.
  1747. </para>
  1748. </sect2>
  1749. <sect2>
  1750. <title>KMS API Functions</title>
  1751. !Edrivers/gpu/drm/drm_crtc.c
  1752. </sect2>
  1753. <sect2>
  1754. <title>KMS Data Structures</title>
  1755. !Iinclude/drm/drm_crtc.h
  1756. </sect2>
  1757. <sect2>
  1758. <title>KMS Locking</title>
  1759. !Pdrivers/gpu/drm/drm_modeset_lock.c kms locking
  1760. !Iinclude/drm/drm_modeset_lock.h
  1761. !Edrivers/gpu/drm/drm_modeset_lock.c
  1762. </sect2>
  1763. </sect1>
  1764. <!-- Internals: kms helper functions -->
  1765. <sect1>
  1766. <title>Mode Setting Helper Functions</title>
  1767. <para>
  1768. The plane, CRTC, encoder and connector functions provided by the drivers
  1769. implement the DRM API. They're called by the DRM core and ioctl handlers
  1770. to handle device state changes and configuration request. As implementing
  1771. those functions often requires logic not specific to drivers, mid-layer
  1772. helper functions are available to avoid duplicating boilerplate code.
  1773. </para>
  1774. <para>
  1775. The DRM core contains one mid-layer implementation. The mid-layer provides
  1776. implementations of several plane, CRTC, encoder and connector functions
  1777. (called from the top of the mid-layer) that pre-process requests and call
  1778. lower-level functions provided by the driver (at the bottom of the
  1779. mid-layer). For instance, the
  1780. <function>drm_crtc_helper_set_config</function> function can be used to
  1781. fill the struct <structname>drm_crtc_funcs</structname>
  1782. <structfield>set_config</structfield> field. When called, it will split
  1783. the <methodname>set_config</methodname> operation in smaller, simpler
  1784. operations and call the driver to handle them.
  1785. </para>
  1786. <para>
  1787. To use the mid-layer, drivers call <function>drm_crtc_helper_add</function>,
  1788. <function>drm_encoder_helper_add</function> and
  1789. <function>drm_connector_helper_add</function> functions to install their
  1790. mid-layer bottom operations handlers, and fill the
  1791. <structname>drm_crtc_funcs</structname>,
  1792. <structname>drm_encoder_funcs</structname> and
  1793. <structname>drm_connector_funcs</structname> structures with pointers to
  1794. the mid-layer top API functions. Installing the mid-layer bottom operation
  1795. handlers is best done right after registering the corresponding KMS object.
  1796. </para>
  1797. <para>
  1798. The mid-layer is not split between CRTC, encoder and connector operations.
  1799. To use it, a driver must provide bottom functions for all of the three KMS
  1800. entities.
  1801. </para>
  1802. <sect2>
  1803. <title>Helper Functions</title>
  1804. <itemizedlist>
  1805. <listitem>
  1806. <synopsis>int drm_crtc_helper_set_config(struct drm_mode_set *set);</synopsis>
  1807. <para>
  1808. The <function>drm_crtc_helper_set_config</function> helper function
  1809. is a CRTC <methodname>set_config</methodname> implementation. It
  1810. first tries to locate the best encoder for each connector by calling
  1811. the connector <methodname>best_encoder</methodname> helper
  1812. operation.
  1813. </para>
  1814. <para>
  1815. After locating the appropriate encoders, the helper function will
  1816. call the <methodname>mode_fixup</methodname> encoder and CRTC helper
  1817. operations to adjust the requested mode, or reject it completely in
  1818. which case an error will be returned to the application. If the new
  1819. configuration after mode adjustment is identical to the current
  1820. configuration the helper function will return without performing any
  1821. other operation.
  1822. </para>
  1823. <para>
  1824. If the adjusted mode is identical to the current mode but changes to
  1825. the frame buffer need to be applied, the
  1826. <function>drm_crtc_helper_set_config</function> function will call
  1827. the CRTC <methodname>mode_set_base</methodname> helper operation. If
  1828. the adjusted mode differs from the current mode, or if the
  1829. <methodname>mode_set_base</methodname> helper operation is not
  1830. provided, the helper function performs a full mode set sequence by
  1831. calling the <methodname>prepare</methodname>,
  1832. <methodname>mode_set</methodname> and
  1833. <methodname>commit</methodname> CRTC and encoder helper operations,
  1834. in that order.
  1835. </para>
  1836. </listitem>
  1837. <listitem>
  1838. <synopsis>void drm_helper_connector_dpms(struct drm_connector *connector, int mode);</synopsis>
  1839. <para>
  1840. The <function>drm_helper_connector_dpms</function> helper function
  1841. is a connector <methodname>dpms</methodname> implementation that
  1842. tracks power state of connectors. To use the function, drivers must
  1843. provide <methodname>dpms</methodname> helper operations for CRTCs
  1844. and encoders to apply the DPMS state to the device.
  1845. </para>
  1846. <para>
  1847. The mid-layer doesn't track the power state of CRTCs and encoders.
  1848. The <methodname>dpms</methodname> helper operations can thus be
  1849. called with a mode identical to the currently active mode.
  1850. </para>
  1851. </listitem>
  1852. <listitem>
  1853. <synopsis>int drm_helper_probe_single_connector_modes(struct drm_connector *connector,
  1854. uint32_t maxX, uint32_t maxY);</synopsis>
  1855. <para>
  1856. The <function>drm_helper_probe_single_connector_modes</function> helper
  1857. function is a connector <methodname>fill_modes</methodname>
  1858. implementation that updates the connection status for the connector
  1859. and then retrieves a list of modes by calling the connector
  1860. <methodname>get_modes</methodname> helper operation.
  1861. </para>
  1862. <para>
  1863. If the helper operation returns no mode, and if the connector status
  1864. is connector_status_connected, standard VESA DMT modes up to
  1865. 1024x768 are automatically added to the modes list by a call to
  1866. <function>drm_add_modes_noedid</function>.
  1867. </para>
  1868. <para>
  1869. The function then filters out modes larger than
  1870. <parameter>max_width</parameter> and <parameter>max_height</parameter>
  1871. if specified. It finally calls the optional connector
  1872. <methodname>mode_valid</methodname> helper operation for each mode in
  1873. the probed list to check whether the mode is valid for the connector.
  1874. </para>
  1875. </listitem>
  1876. </itemizedlist>
  1877. </sect2>
  1878. <sect2>
  1879. <title>CRTC Helper Operations</title>
  1880. <itemizedlist>
  1881. <listitem id="drm-helper-crtc-mode-fixup">
  1882. <synopsis>bool (*mode_fixup)(struct drm_crtc *crtc,
  1883. const struct drm_display_mode *mode,
  1884. struct drm_display_mode *adjusted_mode);</synopsis>
  1885. <para>
  1886. Let CRTCs adjust the requested mode or reject it completely. This
  1887. operation returns true if the mode is accepted (possibly after being
  1888. adjusted) or false if it is rejected.
  1889. </para>
  1890. <para>
  1891. The <methodname>mode_fixup</methodname> operation should reject the
  1892. mode if it can't reasonably use it. The definition of "reasonable"
  1893. is currently fuzzy in this context. One possible behaviour would be
  1894. to set the adjusted mode to the panel timings when a fixed-mode
  1895. panel is used with hardware capable of scaling. Another behaviour
  1896. would be to accept any input mode and adjust it to the closest mode
  1897. supported by the hardware (FIXME: This needs to be clarified).
  1898. </para>
  1899. </listitem>
  1900. <listitem>
  1901. <synopsis>int (*mode_set_base)(struct drm_crtc *crtc, int x, int y,
  1902. struct drm_framebuffer *old_fb)</synopsis>
  1903. <para>
  1904. Move the CRTC on the current frame buffer (stored in
  1905. <literal>crtc-&gt;fb</literal>) to position (x,y). Any of the frame
  1906. buffer, x position or y position may have been modified.
  1907. </para>
  1908. <para>
  1909. This helper operation is optional. If not provided, the
  1910. <function>drm_crtc_helper_set_config</function> function will fall
  1911. back to the <methodname>mode_set</methodname> helper operation.
  1912. </para>
  1913. <note><para>
  1914. FIXME: Why are x and y passed as arguments, as they can be accessed
  1915. through <literal>crtc-&gt;x</literal> and
  1916. <literal>crtc-&gt;y</literal>?
  1917. </para></note>
  1918. </listitem>
  1919. <listitem>
  1920. <synopsis>void (*prepare)(struct drm_crtc *crtc);</synopsis>
  1921. <para>
  1922. Prepare the CRTC for mode setting. This operation is called after
  1923. validating the requested mode. Drivers use it to perform
  1924. device-specific operations required before setting the new mode.
  1925. </para>
  1926. </listitem>
  1927. <listitem>
  1928. <synopsis>int (*mode_set)(struct drm_crtc *crtc, struct drm_display_mode *mode,
  1929. struct drm_display_mode *adjusted_mode, int x, int y,
  1930. struct drm_framebuffer *old_fb);</synopsis>
  1931. <para>
  1932. Set a new mode, position and frame buffer. Depending on the device
  1933. requirements, the mode can be stored internally by the driver and
  1934. applied in the <methodname>commit</methodname> operation, or
  1935. programmed to the hardware immediately.
  1936. </para>
  1937. <para>
  1938. The <methodname>mode_set</methodname> operation returns 0 on success
  1939. or a negative error code if an error occurs.
  1940. </para>
  1941. </listitem>
  1942. <listitem>
  1943. <synopsis>void (*commit)(struct drm_crtc *crtc);</synopsis>
  1944. <para>
  1945. Commit a mode. This operation is called after setting the new mode.
  1946. Upon return the device must use the new mode and be fully
  1947. operational.
  1948. </para>
  1949. </listitem>
  1950. </itemizedlist>
  1951. </sect2>
  1952. <sect2>
  1953. <title>Encoder Helper Operations</title>
  1954. <itemizedlist>
  1955. <listitem>
  1956. <synopsis>bool (*mode_fixup)(struct drm_encoder *encoder,
  1957. const struct drm_display_mode *mode,
  1958. struct drm_display_mode *adjusted_mode);</synopsis>
  1959. <para>
  1960. Let encoders adjust the requested mode or reject it completely. This
  1961. operation returns true if the mode is accepted (possibly after being
  1962. adjusted) or false if it is rejected. See the
  1963. <link linkend="drm-helper-crtc-mode-fixup">mode_fixup CRTC helper
  1964. operation</link> for an explanation of the allowed adjustments.
  1965. </para>
  1966. </listitem>
  1967. <listitem>
  1968. <synopsis>void (*prepare)(struct drm_encoder *encoder);</synopsis>
  1969. <para>
  1970. Prepare the encoder for mode setting. This operation is called after
  1971. validating the requested mode. Drivers use it to perform
  1972. device-specific operations required before setting the new mode.
  1973. </para>
  1974. </listitem>
  1975. <listitem>
  1976. <synopsis>void (*mode_set)(struct drm_encoder *encoder,
  1977. struct drm_display_mode *mode,
  1978. struct drm_display_mode *adjusted_mode);</synopsis>
  1979. <para>
  1980. Set a new mode. Depending on the device requirements, the mode can
  1981. be stored internally by the driver and applied in the
  1982. <methodname>commit</methodname> operation, or programmed to the
  1983. hardware immediately.
  1984. </para>
  1985. </listitem>
  1986. <listitem>
  1987. <synopsis>void (*commit)(struct drm_encoder *encoder);</synopsis>
  1988. <para>
  1989. Commit a mode. This operation is called after setting the new mode.
  1990. Upon return the device must use the new mode and be fully
  1991. operational.
  1992. </para>
  1993. </listitem>
  1994. </itemizedlist>
  1995. </sect2>
  1996. <sect2>
  1997. <title>Connector Helper Operations</title>
  1998. <itemizedlist>
  1999. <listitem>
  2000. <synopsis>struct drm_encoder *(*best_encoder)(struct drm_connector *connector);</synopsis>
  2001. <para>
  2002. Return a pointer to the best encoder for the connecter. Device that
  2003. map connectors to encoders 1:1 simply return the pointer to the
  2004. associated encoder. This operation is mandatory.
  2005. </para>
  2006. </listitem>
  2007. <listitem>
  2008. <synopsis>int (*get_modes)(struct drm_connector *connector);</synopsis>
  2009. <para>
  2010. Fill the connector's <structfield>probed_modes</structfield> list
  2011. by parsing EDID data with <function>drm_add_edid_modes</function>,
  2012. adding standard VESA DMT modes with <function>drm_add_modes_noedid</function>,
  2013. or calling <function>drm_mode_probed_add</function> directly for every
  2014. supported mode and return the number of modes it has detected. This
  2015. operation is mandatory.
  2016. </para>
  2017. <para>
  2018. Note that the caller function will automatically add standard VESA
  2019. DMT modes up to 1024x768 if the <methodname>get_modes</methodname>
  2020. helper operation returns no mode and if the connector status is
  2021. connector_status_connected. There is no need to call
  2022. <function>drm_add_edid_modes</function> manually in that case.
  2023. </para>
  2024. <para>
  2025. When adding modes manually the driver creates each mode with a call to
  2026. <function>drm_mode_create</function> and must fill the following fields.
  2027. <itemizedlist>
  2028. <listitem>
  2029. <synopsis>__u32 type;</synopsis>
  2030. <para>
  2031. Mode type bitmask, a combination of
  2032. <variablelist>
  2033. <varlistentry>
  2034. <term>DRM_MODE_TYPE_BUILTIN</term>
  2035. <listitem><para>not used?</para></listitem>
  2036. </varlistentry>
  2037. <varlistentry>
  2038. <term>DRM_MODE_TYPE_CLOCK_C</term>
  2039. <listitem><para>not used?</para></listitem>
  2040. </varlistentry>
  2041. <varlistentry>
  2042. <term>DRM_MODE_TYPE_CRTC_C</term>
  2043. <listitem><para>not used?</para></listitem>
  2044. </varlistentry>
  2045. <varlistentry>
  2046. <term>
  2047. DRM_MODE_TYPE_PREFERRED - The preferred mode for the connector
  2048. </term>
  2049. <listitem>
  2050. <para>not used?</para>
  2051. </listitem>
  2052. </varlistentry>
  2053. <varlistentry>
  2054. <term>DRM_MODE_TYPE_DEFAULT</term>
  2055. <listitem><para>not used?</para></listitem>
  2056. </varlistentry>
  2057. <varlistentry>
  2058. <term>DRM_MODE_TYPE_USERDEF</term>
  2059. <listitem><para>not used?</para></listitem>
  2060. </varlistentry>
  2061. <varlistentry>
  2062. <term>DRM_MODE_TYPE_DRIVER</term>
  2063. <listitem>
  2064. <para>
  2065. The mode has been created by the driver (as opposed to
  2066. to user-created modes).
  2067. </para>
  2068. </listitem>
  2069. </varlistentry>
  2070. </variablelist>
  2071. Drivers must set the DRM_MODE_TYPE_DRIVER bit for all modes they
  2072. create, and set the DRM_MODE_TYPE_PREFERRED bit for the preferred
  2073. mode.
  2074. </para>
  2075. </listitem>
  2076. <listitem>
  2077. <synopsis>__u32 clock;</synopsis>
  2078. <para>Pixel clock frequency in kHz unit</para>
  2079. </listitem>
  2080. <listitem>
  2081. <synopsis>__u16 hdisplay, hsync_start, hsync_end, htotal;
  2082. __u16 vdisplay, vsync_start, vsync_end, vtotal;</synopsis>
  2083. <para>Horizontal and vertical timing information</para>
  2084. <screen><![CDATA[
  2085. Active Front Sync Back
  2086. Region Porch Porch
  2087. <-----------------------><----------------><-------------><-------------->
  2088. //////////////////////|
  2089. ////////////////////// |
  2090. ////////////////////// |.................. ................
  2091. _______________
  2092. <----- [hv]display ----->
  2093. <------------- [hv]sync_start ------------>
  2094. <--------------------- [hv]sync_end --------------------->
  2095. <-------------------------------- [hv]total ----------------------------->
  2096. ]]></screen>
  2097. </listitem>
  2098. <listitem>
  2099. <synopsis>__u16 hskew;
  2100. __u16 vscan;</synopsis>
  2101. <para>Unknown</para>
  2102. </listitem>
  2103. <listitem>
  2104. <synopsis>__u32 flags;</synopsis>
  2105. <para>
  2106. Mode flags, a combination of
  2107. <variablelist>
  2108. <varlistentry>
  2109. <term>DRM_MODE_FLAG_PHSYNC</term>
  2110. <listitem><para>
  2111. Horizontal sync is active high
  2112. </para></listitem>
  2113. </varlistentry>
  2114. <varlistentry>
  2115. <term>DRM_MODE_FLAG_NHSYNC</term>
  2116. <listitem><para>
  2117. Horizontal sync is active low
  2118. </para></listitem>
  2119. </varlistentry>
  2120. <varlistentry>
  2121. <term>DRM_MODE_FLAG_PVSYNC</term>
  2122. <listitem><para>
  2123. Vertical sync is active high
  2124. </para></listitem>
  2125. </varlistentry>
  2126. <varlistentry>
  2127. <term>DRM_MODE_FLAG_NVSYNC</term>
  2128. <listitem><para>
  2129. Vertical sync is active low
  2130. </para></listitem>
  2131. </varlistentry>
  2132. <varlistentry>
  2133. <term>DRM_MODE_FLAG_INTERLACE</term>
  2134. <listitem><para>
  2135. Mode is interlaced
  2136. </para></listitem>
  2137. </varlistentry>
  2138. <varlistentry>
  2139. <term>DRM_MODE_FLAG_DBLSCAN</term>
  2140. <listitem><para>
  2141. Mode uses doublescan
  2142. </para></listitem>
  2143. </varlistentry>
  2144. <varlistentry>
  2145. <term>DRM_MODE_FLAG_CSYNC</term>
  2146. <listitem><para>
  2147. Mode uses composite sync
  2148. </para></listitem>
  2149. </varlistentry>
  2150. <varlistentry>
  2151. <term>DRM_MODE_FLAG_PCSYNC</term>
  2152. <listitem><para>
  2153. Composite sync is active high
  2154. </para></listitem>
  2155. </varlistentry>
  2156. <varlistentry>
  2157. <term>DRM_MODE_FLAG_NCSYNC</term>
  2158. <listitem><para>
  2159. Composite sync is active low
  2160. </para></listitem>
  2161. </varlistentry>
  2162. <varlistentry>
  2163. <term>DRM_MODE_FLAG_HSKEW</term>
  2164. <listitem><para>
  2165. hskew provided (not used?)
  2166. </para></listitem>
  2167. </varlistentry>
  2168. <varlistentry>
  2169. <term>DRM_MODE_FLAG_BCAST</term>
  2170. <listitem><para>
  2171. not used?
  2172. </para></listitem>
  2173. </varlistentry>
  2174. <varlistentry>
  2175. <term>DRM_MODE_FLAG_PIXMUX</term>
  2176. <listitem><para>
  2177. not used?
  2178. </para></listitem>
  2179. </varlistentry>
  2180. <varlistentry>
  2181. <term>DRM_MODE_FLAG_DBLCLK</term>
  2182. <listitem><para>
  2183. not used?
  2184. </para></listitem>
  2185. </varlistentry>
  2186. <varlistentry>
  2187. <term>DRM_MODE_FLAG_CLKDIV2</term>
  2188. <listitem><para>
  2189. ?
  2190. </para></listitem>
  2191. </varlistentry>
  2192. </variablelist>
  2193. </para>
  2194. <para>
  2195. Note that modes marked with the INTERLACE or DBLSCAN flags will be
  2196. filtered out by
  2197. <function>drm_helper_probe_single_connector_modes</function> if
  2198. the connector's <structfield>interlace_allowed</structfield> or
  2199. <structfield>doublescan_allowed</structfield> field is set to 0.
  2200. </para>
  2201. </listitem>
  2202. <listitem>
  2203. <synopsis>char name[DRM_DISPLAY_MODE_LEN];</synopsis>
  2204. <para>
  2205. Mode name. The driver must call
  2206. <function>drm_mode_set_name</function> to fill the mode name from
  2207. <structfield>hdisplay</structfield>,
  2208. <structfield>vdisplay</structfield> and interlace flag after
  2209. filling the corresponding fields.
  2210. </para>
  2211. </listitem>
  2212. </itemizedlist>
  2213. </para>
  2214. <para>
  2215. The <structfield>vrefresh</structfield> value is computed by
  2216. <function>drm_helper_probe_single_connector_modes</function>.
  2217. </para>
  2218. <para>
  2219. When parsing EDID data, <function>drm_add_edid_modes</function> fills the
  2220. connector <structfield>display_info</structfield>
  2221. <structfield>width_mm</structfield> and
  2222. <structfield>height_mm</structfield> fields. When creating modes
  2223. manually the <methodname>get_modes</methodname> helper operation must
  2224. set the <structfield>display_info</structfield>
  2225. <structfield>width_mm</structfield> and
  2226. <structfield>height_mm</structfield> fields if they haven't been set
  2227. already (for instance at initialization time when a fixed-size panel is
  2228. attached to the connector). The mode <structfield>width_mm</structfield>
  2229. and <structfield>height_mm</structfield> fields are only used internally
  2230. during EDID parsing and should not be set when creating modes manually.
  2231. </para>
  2232. </listitem>
  2233. <listitem>
  2234. <synopsis>int (*mode_valid)(struct drm_connector *connector,
  2235. struct drm_display_mode *mode);</synopsis>
  2236. <para>
  2237. Verify whether a mode is valid for the connector. Return MODE_OK for
  2238. supported modes and one of the enum drm_mode_status values (MODE_*)
  2239. for unsupported modes. This operation is optional.
  2240. </para>
  2241. <para>
  2242. As the mode rejection reason is currently not used beside for
  2243. immediately removing the unsupported mode, an implementation can
  2244. return MODE_BAD regardless of the exact reason why the mode is not
  2245. valid.
  2246. </para>
  2247. <note><para>
  2248. Note that the <methodname>mode_valid</methodname> helper operation is
  2249. only called for modes detected by the device, and
  2250. <emphasis>not</emphasis> for modes set by the user through the CRTC
  2251. <methodname>set_config</methodname> operation.
  2252. </para></note>
  2253. </listitem>
  2254. </itemizedlist>
  2255. </sect2>
  2256. <sect2>
  2257. <title>Atomic Modeset Helper Functions Reference</title>
  2258. <sect3>
  2259. <title>Overview</title>
  2260. !Pdrivers/gpu/drm/drm_atomic_helper.c overview
  2261. </sect3>
  2262. <sect3>
  2263. <title>Implementing Asynchronous Atomic Commit</title>
  2264. !Pdrivers/gpu/drm/drm_atomic_helper.c implementing async commit
  2265. </sect3>
  2266. <sect3>
  2267. <title>Atomic State Reset and Initialization</title>
  2268. !Pdrivers/gpu/drm/drm_atomic_helper.c atomic state reset and initialization
  2269. </sect3>
  2270. !Iinclude/drm/drm_atomic_helper.h
  2271. !Edrivers/gpu/drm/drm_atomic_helper.c
  2272. </sect2>
  2273. <sect2>
  2274. <title>Modeset Helper Functions Reference</title>
  2275. !Iinclude/drm/drm_crtc_helper.h
  2276. !Edrivers/gpu/drm/drm_crtc_helper.c
  2277. !Pdrivers/gpu/drm/drm_crtc_helper.c overview
  2278. </sect2>
  2279. <sect2>
  2280. <title>Output Probing Helper Functions Reference</title>
  2281. !Pdrivers/gpu/drm/drm_probe_helper.c output probing helper overview
  2282. !Edrivers/gpu/drm/drm_probe_helper.c
  2283. </sect2>
  2284. <sect2>
  2285. <title>fbdev Helper Functions Reference</title>
  2286. !Pdrivers/gpu/drm/drm_fb_helper.c fbdev helpers
  2287. !Edrivers/gpu/drm/drm_fb_helper.c
  2288. !Iinclude/drm/drm_fb_helper.h
  2289. </sect2>
  2290. <sect2>
  2291. <title>Display Port Helper Functions Reference</title>
  2292. !Pdrivers/gpu/drm/drm_dp_helper.c dp helpers
  2293. !Iinclude/drm/drm_dp_helper.h
  2294. !Edrivers/gpu/drm/drm_dp_helper.c
  2295. </sect2>
  2296. <sect2>
  2297. <title>Display Port MST Helper Functions Reference</title>
  2298. !Pdrivers/gpu/drm/drm_dp_mst_topology.c dp mst helper
  2299. !Iinclude/drm/drm_dp_mst_helper.h
  2300. !Edrivers/gpu/drm/drm_dp_mst_topology.c
  2301. </sect2>
  2302. <sect2>
  2303. <title>MIPI DSI Helper Functions Reference</title>
  2304. !Pdrivers/gpu/drm/drm_mipi_dsi.c dsi helpers
  2305. !Iinclude/drm/drm_mipi_dsi.h
  2306. !Edrivers/gpu/drm/drm_mipi_dsi.c
  2307. </sect2>
  2308. <sect2>
  2309. <title>EDID Helper Functions Reference</title>
  2310. !Edrivers/gpu/drm/drm_edid.c
  2311. </sect2>
  2312. <sect2>
  2313. <title>Rectangle Utilities Reference</title>
  2314. !Pinclude/drm/drm_rect.h rect utils
  2315. !Iinclude/drm/drm_rect.h
  2316. !Edrivers/gpu/drm/drm_rect.c
  2317. </sect2>
  2318. <sect2>
  2319. <title>Flip-work Helper Reference</title>
  2320. !Pinclude/drm/drm_flip_work.h flip utils
  2321. !Iinclude/drm/drm_flip_work.h
  2322. !Edrivers/gpu/drm/drm_flip_work.c
  2323. </sect2>
  2324. <sect2>
  2325. <title>HDMI Infoframes Helper Reference</title>
  2326. <para>
  2327. Strictly speaking this is not a DRM helper library but generally useable
  2328. by any driver interfacing with HDMI outputs like v4l or alsa drivers.
  2329. But it nicely fits into the overall topic of mode setting helper
  2330. libraries and hence is also included here.
  2331. </para>
  2332. !Iinclude/linux/hdmi.h
  2333. !Edrivers/video/hdmi.c
  2334. </sect2>
  2335. <sect2>
  2336. <title id="drm-kms-planehelpers">Plane Helper Reference</title>
  2337. !Edrivers/gpu/drm/drm_plane_helper.c
  2338. !Pdrivers/gpu/drm/drm_plane_helper.c overview
  2339. </sect2>
  2340. <sect2>
  2341. <title>Tile group</title>
  2342. !Pdrivers/gpu/drm/drm_crtc.c Tile group
  2343. </sect2>
  2344. <sect2>
  2345. <title>Bridges</title>
  2346. <sect3>
  2347. <title>Overview</title>
  2348. !Pdrivers/gpu/drm/drm_bridge.c overview
  2349. </sect3>
  2350. <sect3>
  2351. <title>Default bridge callback sequence</title>
  2352. !Pdrivers/gpu/drm/drm_bridge.c bridge callbacks
  2353. </sect3>
  2354. !Edrivers/gpu/drm/drm_bridge.c
  2355. </sect2>
  2356. </sect1>
  2357. <!-- Internals: kms properties -->
  2358. <sect1 id="drm-kms-properties">
  2359. <title>KMS Properties</title>
  2360. <para>
  2361. Drivers may need to expose additional parameters to applications than
  2362. those described in the previous sections. KMS supports attaching
  2363. properties to CRTCs, connectors and planes and offers a userspace API to
  2364. list, get and set the property values.
  2365. </para>
  2366. <para>
  2367. Properties are identified by a name that uniquely defines the property
  2368. purpose, and store an associated value. For all property types except blob
  2369. properties the value is a 64-bit unsigned integer.
  2370. </para>
  2371. <para>
  2372. KMS differentiates between properties and property instances. Drivers
  2373. first create properties and then create and associate individual instances
  2374. of those properties to objects. A property can be instantiated multiple
  2375. times and associated with different objects. Values are stored in property
  2376. instances, and all other property information are stored in the property
  2377. and shared between all instances of the property.
  2378. </para>
  2379. <para>
  2380. Every property is created with a type that influences how the KMS core
  2381. handles the property. Supported property types are
  2382. <variablelist>
  2383. <varlistentry>
  2384. <term>DRM_MODE_PROP_RANGE</term>
  2385. <listitem><para>Range properties report their minimum and maximum
  2386. admissible values. The KMS core verifies that values set by
  2387. application fit in that range.</para></listitem>
  2388. </varlistentry>
  2389. <varlistentry>
  2390. <term>DRM_MODE_PROP_ENUM</term>
  2391. <listitem><para>Enumerated properties take a numerical value that
  2392. ranges from 0 to the number of enumerated values defined by the
  2393. property minus one, and associate a free-formed string name to each
  2394. value. Applications can retrieve the list of defined value-name pairs
  2395. and use the numerical value to get and set property instance values.
  2396. </para></listitem>
  2397. </varlistentry>
  2398. <varlistentry>
  2399. <term>DRM_MODE_PROP_BITMASK</term>
  2400. <listitem><para>Bitmask properties are enumeration properties that
  2401. additionally restrict all enumerated values to the 0..63 range.
  2402. Bitmask property instance values combine one or more of the
  2403. enumerated bits defined by the property.</para></listitem>
  2404. </varlistentry>
  2405. <varlistentry>
  2406. <term>DRM_MODE_PROP_BLOB</term>
  2407. <listitem><para>Blob properties store a binary blob without any format
  2408. restriction. The binary blobs are created as KMS standalone objects,
  2409. and blob property instance values store the ID of their associated
  2410. blob object.</para>
  2411. <para>Blob properties are only used for the connector EDID property
  2412. and cannot be created by drivers.</para></listitem>
  2413. </varlistentry>
  2414. </variablelist>
  2415. </para>
  2416. <para>
  2417. To create a property drivers call one of the following functions depending
  2418. on the property type. All property creation functions take property flags
  2419. and name, as well as type-specific arguments.
  2420. <itemizedlist>
  2421. <listitem>
  2422. <synopsis>struct drm_property *drm_property_create_range(struct drm_device *dev, int flags,
  2423. const char *name,
  2424. uint64_t min, uint64_t max);</synopsis>
  2425. <para>Create a range property with the given minimum and maximum
  2426. values.</para>
  2427. </listitem>
  2428. <listitem>
  2429. <synopsis>struct drm_property *drm_property_create_enum(struct drm_device *dev, int flags,
  2430. const char *name,
  2431. const struct drm_prop_enum_list *props,
  2432. int num_values);</synopsis>
  2433. <para>Create an enumerated property. The <parameter>props</parameter>
  2434. argument points to an array of <parameter>num_values</parameter>
  2435. value-name pairs.</para>
  2436. </listitem>
  2437. <listitem>
  2438. <synopsis>struct drm_property *drm_property_create_bitmask(struct drm_device *dev,
  2439. int flags, const char *name,
  2440. const struct drm_prop_enum_list *props,
  2441. int num_values);</synopsis>
  2442. <para>Create a bitmask property. The <parameter>props</parameter>
  2443. argument points to an array of <parameter>num_values</parameter>
  2444. value-name pairs.</para>
  2445. </listitem>
  2446. </itemizedlist>
  2447. </para>
  2448. <para>
  2449. Properties can additionally be created as immutable, in which case they
  2450. will be read-only for applications but can be modified by the driver. To
  2451. create an immutable property drivers must set the DRM_MODE_PROP_IMMUTABLE
  2452. flag at property creation time.
  2453. </para>
  2454. <para>
  2455. When no array of value-name pairs is readily available at property
  2456. creation time for enumerated or range properties, drivers can create
  2457. the property using the <function>drm_property_create</function> function
  2458. and manually add enumeration value-name pairs by calling the
  2459. <function>drm_property_add_enum</function> function. Care must be taken to
  2460. properly specify the property type through the <parameter>flags</parameter>
  2461. argument.
  2462. </para>
  2463. <para>
  2464. After creating properties drivers can attach property instances to CRTC,
  2465. connector and plane objects by calling the
  2466. <function>drm_object_attach_property</function>. The function takes a
  2467. pointer to the target object, a pointer to the previously created property
  2468. and an initial instance value.
  2469. </para>
  2470. <sect2>
  2471. <title>Existing KMS Properties</title>
  2472. <para>
  2473. The following table gives description of drm properties exposed by various
  2474. modules/drivers.
  2475. </para>
  2476. <table border="1" cellpadding="0" cellspacing="0">
  2477. <tbody>
  2478. <tr style="font-weight: bold;">
  2479. <td valign="top" >Owner Module/Drivers</td>
  2480. <td valign="top" >Group</td>
  2481. <td valign="top" >Property Name</td>
  2482. <td valign="top" >Type</td>
  2483. <td valign="top" >Property Values</td>
  2484. <td valign="top" >Object attached</td>
  2485. <td valign="top" >Description/Restrictions</td>
  2486. </tr>
  2487. <tr>
  2488. <td rowspan="37" valign="top" >DRM</td>
  2489. <td valign="top" >Generic</td>
  2490. <td valign="top" >“rotation”</td>
  2491. <td valign="top" >BITMASK</td>
  2492. <td valign="top" >{ 0, "rotate-0" },
  2493. { 1, "rotate-90" },
  2494. { 2, "rotate-180" },
  2495. { 3, "rotate-270" },
  2496. { 4, "reflect-x" },
  2497. { 5, "reflect-y" }</td>
  2498. <td valign="top" >CRTC, Plane</td>
  2499. <td valign="top" >rotate-(degrees) rotates the image by the specified amount in degrees
  2500. in counter clockwise direction. reflect-x and reflect-y reflects the
  2501. image along the specified axis prior to rotation</td>
  2502. </tr>
  2503. <tr>
  2504. <td rowspan="5" valign="top" >Connector</td>
  2505. <td valign="top" >“EDID”</td>
  2506. <td valign="top" >BLOB | IMMUTABLE</td>
  2507. <td valign="top" >0</td>
  2508. <td valign="top" >Connector</td>
  2509. <td valign="top" >Contains id of edid blob ptr object.</td>
  2510. </tr>
  2511. <tr>
  2512. <td valign="top" >“DPMS”</td>
  2513. <td valign="top" >ENUM</td>
  2514. <td valign="top" >{ “On”, “Standby”, “Suspend”, “Off” }</td>
  2515. <td valign="top" >Connector</td>
  2516. <td valign="top" >Contains DPMS operation mode value.</td>
  2517. </tr>
  2518. <tr>
  2519. <td valign="top" >“PATH”</td>
  2520. <td valign="top" >BLOB | IMMUTABLE</td>
  2521. <td valign="top" >0</td>
  2522. <td valign="top" >Connector</td>
  2523. <td valign="top" >Contains topology path to a connector.</td>
  2524. </tr>
  2525. <tr>
  2526. <td valign="top" >“TILE”</td>
  2527. <td valign="top" >BLOB | IMMUTABLE</td>
  2528. <td valign="top" >0</td>
  2529. <td valign="top" >Connector</td>
  2530. <td valign="top" >Contains tiling information for a connector.</td>
  2531. </tr>
  2532. <tr>
  2533. <td valign="top" >“CRTC_ID”</td>
  2534. <td valign="top" >OBJECT</td>
  2535. <td valign="top" >DRM_MODE_OBJECT_CRTC</td>
  2536. <td valign="top" >Connector</td>
  2537. <td valign="top" >CRTC that connector is attached to (atomic)</td>
  2538. </tr>
  2539. <tr>
  2540. <td rowspan="11" valign="top" >Plane</td>
  2541. <td valign="top" >“type”</td>
  2542. <td valign="top" >ENUM | IMMUTABLE</td>
  2543. <td valign="top" >{ "Overlay", "Primary", "Cursor" }</td>
  2544. <td valign="top" >Plane</td>
  2545. <td valign="top" >Plane type</td>
  2546. </tr>
  2547. <tr>
  2548. <td valign="top" >“SRC_X”</td>
  2549. <td valign="top" >RANGE</td>
  2550. <td valign="top" >Min=0, Max=UINT_MAX</td>
  2551. <td valign="top" >Plane</td>
  2552. <td valign="top" >Scanout source x coordinate in 16.16 fixed point (atomic)</td>
  2553. </tr>
  2554. <tr>
  2555. <td valign="top" >“SRC_Y”</td>
  2556. <td valign="top" >RANGE</td>
  2557. <td valign="top" >Min=0, Max=UINT_MAX</td>
  2558. <td valign="top" >Plane</td>
  2559. <td valign="top" >Scanout source y coordinate in 16.16 fixed point (atomic)</td>
  2560. </tr>
  2561. <tr>
  2562. <td valign="top" >“SRC_W”</td>
  2563. <td valign="top" >RANGE</td>
  2564. <td valign="top" >Min=0, Max=UINT_MAX</td>
  2565. <td valign="top" >Plane</td>
  2566. <td valign="top" >Scanout source width in 16.16 fixed point (atomic)</td>
  2567. </tr>
  2568. <tr>
  2569. <td valign="top" >“SRC_H”</td>
  2570. <td valign="top" >RANGE</td>
  2571. <td valign="top" >Min=0, Max=UINT_MAX</td>
  2572. <td valign="top" >Plane</td>
  2573. <td valign="top" >Scanout source height in 16.16 fixed point (atomic)</td>
  2574. </tr>
  2575. <tr>
  2576. <td valign="top" >“CRTC_X”</td>
  2577. <td valign="top" >SIGNED_RANGE</td>
  2578. <td valign="top" >Min=INT_MIN, Max=INT_MAX</td>
  2579. <td valign="top" >Plane</td>
  2580. <td valign="top" >Scanout CRTC (destination) x coordinate (atomic)</td>
  2581. </tr>
  2582. <tr>
  2583. <td valign="top" >“CRTC_Y”</td>
  2584. <td valign="top" >SIGNED_RANGE</td>
  2585. <td valign="top" >Min=INT_MIN, Max=INT_MAX</td>
  2586. <td valign="top" >Plane</td>
  2587. <td valign="top" >Scanout CRTC (destination) y coordinate (atomic)</td>
  2588. </tr>
  2589. <tr>
  2590. <td valign="top" >“CRTC_W”</td>
  2591. <td valign="top" >RANGE</td>
  2592. <td valign="top" >Min=0, Max=UINT_MAX</td>
  2593. <td valign="top" >Plane</td>
  2594. <td valign="top" >Scanout CRTC (destination) width (atomic)</td>
  2595. </tr>
  2596. <tr>
  2597. <td valign="top" >“CRTC_H”</td>
  2598. <td valign="top" >RANGE</td>
  2599. <td valign="top" >Min=0, Max=UINT_MAX</td>
  2600. <td valign="top" >Plane</td>
  2601. <td valign="top" >Scanout CRTC (destination) height (atomic)</td>
  2602. </tr>
  2603. <tr>
  2604. <td valign="top" >“FB_ID”</td>
  2605. <td valign="top" >OBJECT</td>
  2606. <td valign="top" >DRM_MODE_OBJECT_FB</td>
  2607. <td valign="top" >Plane</td>
  2608. <td valign="top" >Scanout framebuffer (atomic)</td>
  2609. </tr>
  2610. <tr>
  2611. <td valign="top" >“CRTC_ID”</td>
  2612. <td valign="top" >OBJECT</td>
  2613. <td valign="top" >DRM_MODE_OBJECT_CRTC</td>
  2614. <td valign="top" >Plane</td>
  2615. <td valign="top" >CRTC that plane is attached to (atomic)</td>
  2616. </tr>
  2617. <tr>
  2618. <td rowspan="2" valign="top" >DVI-I</td>
  2619. <td valign="top" >“subconnector”</td>
  2620. <td valign="top" >ENUM</td>
  2621. <td valign="top" >{ “Unknown”, “DVI-D”, “DVI-A” }</td>
  2622. <td valign="top" >Connector</td>
  2623. <td valign="top" >TBD</td>
  2624. </tr>
  2625. <tr>
  2626. <td valign="top" >“select subconnector”</td>
  2627. <td valign="top" >ENUM</td>
  2628. <td valign="top" >{ “Automatic”, “DVI-D”, “DVI-A” }</td>
  2629. <td valign="top" >Connector</td>
  2630. <td valign="top" >TBD</td>
  2631. </tr>
  2632. <tr>
  2633. <td rowspan="13" valign="top" >TV</td>
  2634. <td valign="top" >“subconnector”</td>
  2635. <td valign="top" >ENUM</td>
  2636. <td valign="top" >{ "Unknown", "Composite", "SVIDEO", "Component", "SCART" }</td>
  2637. <td valign="top" >Connector</td>
  2638. <td valign="top" >TBD</td>
  2639. </tr>
  2640. <tr>
  2641. <td valign="top" >“select subconnector”</td>
  2642. <td valign="top" >ENUM</td>
  2643. <td valign="top" >{ "Automatic", "Composite", "SVIDEO", "Component", "SCART" }</td>
  2644. <td valign="top" >Connector</td>
  2645. <td valign="top" >TBD</td>
  2646. </tr>
  2647. <tr>
  2648. <td valign="top" >“mode”</td>
  2649. <td valign="top" >ENUM</td>
  2650. <td valign="top" >{ "NTSC_M", "NTSC_J", "NTSC_443", "PAL_B" } etc.</td>
  2651. <td valign="top" >Connector</td>
  2652. <td valign="top" >TBD</td>
  2653. </tr>
  2654. <tr>
  2655. <td valign="top" >“left margin”</td>
  2656. <td valign="top" >RANGE</td>
  2657. <td valign="top" >Min=0, Max=100</td>
  2658. <td valign="top" >Connector</td>
  2659. <td valign="top" >TBD</td>
  2660. </tr>
  2661. <tr>
  2662. <td valign="top" >“right margin”</td>
  2663. <td valign="top" >RANGE</td>
  2664. <td valign="top" >Min=0, Max=100</td>
  2665. <td valign="top" >Connector</td>
  2666. <td valign="top" >TBD</td>
  2667. </tr>
  2668. <tr>
  2669. <td valign="top" >“top margin”</td>
  2670. <td valign="top" >RANGE</td>
  2671. <td valign="top" >Min=0, Max=100</td>
  2672. <td valign="top" >Connector</td>
  2673. <td valign="top" >TBD</td>
  2674. </tr>
  2675. <tr>
  2676. <td valign="top" >“bottom margin”</td>
  2677. <td valign="top" >RANGE</td>
  2678. <td valign="top" >Min=0, Max=100</td>
  2679. <td valign="top" >Connector</td>
  2680. <td valign="top" >TBD</td>
  2681. </tr>
  2682. <tr>
  2683. <td valign="top" >“brightness”</td>
  2684. <td valign="top" >RANGE</td>
  2685. <td valign="top" >Min=0, Max=100</td>
  2686. <td valign="top" >Connector</td>
  2687. <td valign="top" >TBD</td>
  2688. </tr>
  2689. <tr>
  2690. <td valign="top" >“contrast”</td>
  2691. <td valign="top" >RANGE</td>
  2692. <td valign="top" >Min=0, Max=100</td>
  2693. <td valign="top" >Connector</td>
  2694. <td valign="top" >TBD</td>
  2695. </tr>
  2696. <tr>
  2697. <td valign="top" >“flicker reduction”</td>
  2698. <td valign="top" >RANGE</td>
  2699. <td valign="top" >Min=0, Max=100</td>
  2700. <td valign="top" >Connector</td>
  2701. <td valign="top" >TBD</td>
  2702. </tr>
  2703. <tr>
  2704. <td valign="top" >“overscan”</td>
  2705. <td valign="top" >RANGE</td>
  2706. <td valign="top" >Min=0, Max=100</td>
  2707. <td valign="top" >Connector</td>
  2708. <td valign="top" >TBD</td>
  2709. </tr>
  2710. <tr>
  2711. <td valign="top" >“saturation”</td>
  2712. <td valign="top" >RANGE</td>
  2713. <td valign="top" >Min=0, Max=100</td>
  2714. <td valign="top" >Connector</td>
  2715. <td valign="top" >TBD</td>
  2716. </tr>
  2717. <tr>
  2718. <td valign="top" >“hue”</td>
  2719. <td valign="top" >RANGE</td>
  2720. <td valign="top" >Min=0, Max=100</td>
  2721. <td valign="top" >Connector</td>
  2722. <td valign="top" >TBD</td>
  2723. </tr>
  2724. <tr>
  2725. <td rowspan="2" valign="top" >Virtual GPU</td>
  2726. <td valign="top" >“suggested X”</td>
  2727. <td valign="top" >RANGE</td>
  2728. <td valign="top" >Min=0, Max=0xffffffff</td>
  2729. <td valign="top" >Connector</td>
  2730. <td valign="top" >property to suggest an X offset for a connector</td>
  2731. </tr>
  2732. <tr>
  2733. <td valign="top" >“suggested Y”</td>
  2734. <td valign="top" >RANGE</td>
  2735. <td valign="top" >Min=0, Max=0xffffffff</td>
  2736. <td valign="top" >Connector</td>
  2737. <td valign="top" >property to suggest an Y offset for a connector</td>
  2738. </tr>
  2739. <tr>
  2740. <td rowspan="3" valign="top" >Optional</td>
  2741. <td valign="top" >“scaling mode”</td>
  2742. <td valign="top" >ENUM</td>
  2743. <td valign="top" >{ "None", "Full", "Center", "Full aspect" }</td>
  2744. <td valign="top" >Connector</td>
  2745. <td valign="top" >TBD</td>
  2746. </tr>
  2747. <tr>
  2748. <td valign="top" >"aspect ratio"</td>
  2749. <td valign="top" >ENUM</td>
  2750. <td valign="top" >{ "None", "4:3", "16:9" }</td>
  2751. <td valign="top" >Connector</td>
  2752. <td valign="top" >DRM property to set aspect ratio from user space app.
  2753. This enum is made generic to allow addition of custom aspect
  2754. ratios.</td>
  2755. </tr>
  2756. <tr>
  2757. <td valign="top" >“dirty”</td>
  2758. <td valign="top" >ENUM | IMMUTABLE</td>
  2759. <td valign="top" >{ "Off", "On", "Annotate" }</td>
  2760. <td valign="top" >Connector</td>
  2761. <td valign="top" >TBD</td>
  2762. </tr>
  2763. <tr>
  2764. <td rowspan="20" valign="top" >i915</td>
  2765. <td rowspan="2" valign="top" >Generic</td>
  2766. <td valign="top" >"Broadcast RGB"</td>
  2767. <td valign="top" >ENUM</td>
  2768. <td valign="top" >{ "Automatic", "Full", "Limited 16:235" }</td>
  2769. <td valign="top" >Connector</td>
  2770. <td valign="top" >TBD</td>
  2771. </tr>
  2772. <tr>
  2773. <td valign="top" >“audio”</td>
  2774. <td valign="top" >ENUM</td>
  2775. <td valign="top" >{ "force-dvi", "off", "auto", "on" }</td>
  2776. <td valign="top" >Connector</td>
  2777. <td valign="top" >TBD</td>
  2778. </tr>
  2779. <tr>
  2780. <td rowspan="17" valign="top" >SDVO-TV</td>
  2781. <td valign="top" >“mode”</td>
  2782. <td valign="top" >ENUM</td>
  2783. <td valign="top" >{ "NTSC_M", "NTSC_J", "NTSC_443", "PAL_B" } etc.</td>
  2784. <td valign="top" >Connector</td>
  2785. <td valign="top" >TBD</td>
  2786. </tr>
  2787. <tr>
  2788. <td valign="top" >"left_margin"</td>
  2789. <td valign="top" >RANGE</td>
  2790. <td valign="top" >Min=0, Max= SDVO dependent</td>
  2791. <td valign="top" >Connector</td>
  2792. <td valign="top" >TBD</td>
  2793. </tr>
  2794. <tr>
  2795. <td valign="top" >"right_margin"</td>
  2796. <td valign="top" >RANGE</td>
  2797. <td valign="top" >Min=0, Max= SDVO dependent</td>
  2798. <td valign="top" >Connector</td>
  2799. <td valign="top" >TBD</td>
  2800. </tr>
  2801. <tr>
  2802. <td valign="top" >"top_margin"</td>
  2803. <td valign="top" >RANGE</td>
  2804. <td valign="top" >Min=0, Max= SDVO dependent</td>
  2805. <td valign="top" >Connector</td>
  2806. <td valign="top" >TBD</td>
  2807. </tr>
  2808. <tr>
  2809. <td valign="top" >"bottom_margin"</td>
  2810. <td valign="top" >RANGE</td>
  2811. <td valign="top" >Min=0, Max= SDVO dependent</td>
  2812. <td valign="top" >Connector</td>
  2813. <td valign="top" >TBD</td>
  2814. </tr>
  2815. <tr>
  2816. <td valign="top" >“hpos”</td>
  2817. <td valign="top" >RANGE</td>
  2818. <td valign="top" >Min=0, Max= SDVO dependent</td>
  2819. <td valign="top" >Connector</td>
  2820. <td valign="top" >TBD</td>
  2821. </tr>
  2822. <tr>
  2823. <td valign="top" >“vpos”</td>
  2824. <td valign="top" >RANGE</td>
  2825. <td valign="top" >Min=0, Max= SDVO dependent</td>
  2826. <td valign="top" >Connector</td>
  2827. <td valign="top" >TBD</td>
  2828. </tr>
  2829. <tr>
  2830. <td valign="top" >“contrast”</td>
  2831. <td valign="top" >RANGE</td>
  2832. <td valign="top" >Min=0, Max= SDVO dependent</td>
  2833. <td valign="top" >Connector</td>
  2834. <td valign="top" >TBD</td>
  2835. </tr>
  2836. <tr>
  2837. <td valign="top" >“saturation”</td>
  2838. <td valign="top" >RANGE</td>
  2839. <td valign="top" >Min=0, Max= SDVO dependent</td>
  2840. <td valign="top" >Connector</td>
  2841. <td valign="top" >TBD</td>
  2842. </tr>
  2843. <tr>
  2844. <td valign="top" >“hue”</td>
  2845. <td valign="top" >RANGE</td>
  2846. <td valign="top" >Min=0, Max= SDVO dependent</td>
  2847. <td valign="top" >Connector</td>
  2848. <td valign="top" >TBD</td>
  2849. </tr>
  2850. <tr>
  2851. <td valign="top" >“sharpness”</td>
  2852. <td valign="top" >RANGE</td>
  2853. <td valign="top" >Min=0, Max= SDVO dependent</td>
  2854. <td valign="top" >Connector</td>
  2855. <td valign="top" >TBD</td>
  2856. </tr>
  2857. <tr>
  2858. <td valign="top" >“flicker_filter”</td>
  2859. <td valign="top" >RANGE</td>
  2860. <td valign="top" >Min=0, Max= SDVO dependent</td>
  2861. <td valign="top" >Connector</td>
  2862. <td valign="top" >TBD</td>
  2863. </tr>
  2864. <tr>
  2865. <td valign="top" >“flicker_filter_adaptive”</td>
  2866. <td valign="top" >RANGE</td>
  2867. <td valign="top" >Min=0, Max= SDVO dependent</td>
  2868. <td valign="top" >Connector</td>
  2869. <td valign="top" >TBD</td>
  2870. </tr>
  2871. <tr>
  2872. <td valign="top" >“flicker_filter_2d”</td>
  2873. <td valign="top" >RANGE</td>
  2874. <td valign="top" >Min=0, Max= SDVO dependent</td>
  2875. <td valign="top" >Connector</td>
  2876. <td valign="top" >TBD</td>
  2877. </tr>
  2878. <tr>
  2879. <td valign="top" >“tv_chroma_filter”</td>
  2880. <td valign="top" >RANGE</td>
  2881. <td valign="top" >Min=0, Max= SDVO dependent</td>
  2882. <td valign="top" >Connector</td>
  2883. <td valign="top" >TBD</td>
  2884. </tr>
  2885. <tr>
  2886. <td valign="top" >“tv_luma_filter”</td>
  2887. <td valign="top" >RANGE</td>
  2888. <td valign="top" >Min=0, Max= SDVO dependent</td>
  2889. <td valign="top" >Connector</td>
  2890. <td valign="top" >TBD</td>
  2891. </tr>
  2892. <tr>
  2893. <td valign="top" >“dot_crawl”</td>
  2894. <td valign="top" >RANGE</td>
  2895. <td valign="top" >Min=0, Max=1</td>
  2896. <td valign="top" >Connector</td>
  2897. <td valign="top" >TBD</td>
  2898. </tr>
  2899. <tr>
  2900. <td valign="top" >SDVO-TV/LVDS</td>
  2901. <td valign="top" >“brightness”</td>
  2902. <td valign="top" >RANGE</td>
  2903. <td valign="top" >Min=0, Max= SDVO dependent</td>
  2904. <td valign="top" >Connector</td>
  2905. <td valign="top" >TBD</td>
  2906. </tr>
  2907. <tr>
  2908. <td rowspan="2" valign="top" >CDV gma-500</td>
  2909. <td rowspan="2" valign="top" >Generic</td>
  2910. <td valign="top" >"Broadcast RGB"</td>
  2911. <td valign="top" >ENUM</td>
  2912. <td valign="top" >{ “Full”, “Limited 16:235” }</td>
  2913. <td valign="top" >Connector</td>
  2914. <td valign="top" >TBD</td>
  2915. </tr>
  2916. <tr>
  2917. <td valign="top" >"Broadcast RGB"</td>
  2918. <td valign="top" >ENUM</td>
  2919. <td valign="top" >{ “off”, “auto”, “on” }</td>
  2920. <td valign="top" >Connector</td>
  2921. <td valign="top" >TBD</td>
  2922. </tr>
  2923. <tr>
  2924. <td rowspan="19" valign="top" >Poulsbo</td>
  2925. <td rowspan="1" valign="top" >Generic</td>
  2926. <td valign="top" >“backlight”</td>
  2927. <td valign="top" >RANGE</td>
  2928. <td valign="top" >Min=0, Max=100</td>
  2929. <td valign="top" >Connector</td>
  2930. <td valign="top" >TBD</td>
  2931. </tr>
  2932. <tr>
  2933. <td rowspan="17" valign="top" >SDVO-TV</td>
  2934. <td valign="top" >“mode”</td>
  2935. <td valign="top" >ENUM</td>
  2936. <td valign="top" >{ "NTSC_M", "NTSC_J", "NTSC_443", "PAL_B" } etc.</td>
  2937. <td valign="top" >Connector</td>
  2938. <td valign="top" >TBD</td>
  2939. </tr>
  2940. <tr>
  2941. <td valign="top" >"left_margin"</td>
  2942. <td valign="top" >RANGE</td>
  2943. <td valign="top" >Min=0, Max= SDVO dependent</td>
  2944. <td valign="top" >Connector</td>
  2945. <td valign="top" >TBD</td>
  2946. </tr>
  2947. <tr>
  2948. <td valign="top" >"right_margin"</td>
  2949. <td valign="top" >RANGE</td>
  2950. <td valign="top" >Min=0, Max= SDVO dependent</td>
  2951. <td valign="top" >Connector</td>
  2952. <td valign="top" >TBD</td>
  2953. </tr>
  2954. <tr>
  2955. <td valign="top" >"top_margin"</td>
  2956. <td valign="top" >RANGE</td>
  2957. <td valign="top" >Min=0, Max= SDVO dependent</td>
  2958. <td valign="top" >Connector</td>
  2959. <td valign="top" >TBD</td>
  2960. </tr>
  2961. <tr>
  2962. <td valign="top" >"bottom_margin"</td>
  2963. <td valign="top" >RANGE</td>
  2964. <td valign="top" >Min=0, Max= SDVO dependent</td>
  2965. <td valign="top" >Connector</td>
  2966. <td valign="top" >TBD</td>
  2967. </tr>
  2968. <tr>
  2969. <td valign="top" >“hpos”</td>
  2970. <td valign="top" >RANGE</td>
  2971. <td valign="top" >Min=0, Max= SDVO dependent</td>
  2972. <td valign="top" >Connector</td>
  2973. <td valign="top" >TBD</td>
  2974. </tr>
  2975. <tr>
  2976. <td valign="top" >“vpos”</td>
  2977. <td valign="top" >RANGE</td>
  2978. <td valign="top" >Min=0, Max= SDVO dependent</td>
  2979. <td valign="top" >Connector</td>
  2980. <td valign="top" >TBD</td>
  2981. </tr>
  2982. <tr>
  2983. <td valign="top" >“contrast”</td>
  2984. <td valign="top" >RANGE</td>
  2985. <td valign="top" >Min=0, Max= SDVO dependent</td>
  2986. <td valign="top" >Connector</td>
  2987. <td valign="top" >TBD</td>
  2988. </tr>
  2989. <tr>
  2990. <td valign="top" >“saturation”</td>
  2991. <td valign="top" >RANGE</td>
  2992. <td valign="top" >Min=0, Max= SDVO dependent</td>
  2993. <td valign="top" >Connector</td>
  2994. <td valign="top" >TBD</td>
  2995. </tr>
  2996. <tr>
  2997. <td valign="top" >“hue”</td>
  2998. <td valign="top" >RANGE</td>
  2999. <td valign="top" >Min=0, Max= SDVO dependent</td>
  3000. <td valign="top" >Connector</td>
  3001. <td valign="top" >TBD</td>
  3002. </tr>
  3003. <tr>
  3004. <td valign="top" >“sharpness”</td>
  3005. <td valign="top" >RANGE</td>
  3006. <td valign="top" >Min=0, Max= SDVO dependent</td>
  3007. <td valign="top" >Connector</td>
  3008. <td valign="top" >TBD</td>
  3009. </tr>
  3010. <tr>
  3011. <td valign="top" >“flicker_filter”</td>
  3012. <td valign="top" >RANGE</td>
  3013. <td valign="top" >Min=0, Max= SDVO dependent</td>
  3014. <td valign="top" >Connector</td>
  3015. <td valign="top" >TBD</td>
  3016. </tr>
  3017. <tr>
  3018. <td valign="top" >“flicker_filter_adaptive”</td>
  3019. <td valign="top" >RANGE</td>
  3020. <td valign="top" >Min=0, Max= SDVO dependent</td>
  3021. <td valign="top" >Connector</td>
  3022. <td valign="top" >TBD</td>
  3023. </tr>
  3024. <tr>
  3025. <td valign="top" >“flicker_filter_2d”</td>
  3026. <td valign="top" >RANGE</td>
  3027. <td valign="top" >Min=0, Max= SDVO dependent</td>
  3028. <td valign="top" >Connector</td>
  3029. <td valign="top" >TBD</td>
  3030. </tr>
  3031. <tr>
  3032. <td valign="top" >“tv_chroma_filter”</td>
  3033. <td valign="top" >RANGE</td>
  3034. <td valign="top" >Min=0, Max= SDVO dependent</td>
  3035. <td valign="top" >Connector</td>
  3036. <td valign="top" >TBD</td>
  3037. </tr>
  3038. <tr>
  3039. <td valign="top" >“tv_luma_filter”</td>
  3040. <td valign="top" >RANGE</td>
  3041. <td valign="top" >Min=0, Max= SDVO dependent</td>
  3042. <td valign="top" >Connector</td>
  3043. <td valign="top" >TBD</td>
  3044. </tr>
  3045. <tr>
  3046. <td valign="top" >“dot_crawl”</td>
  3047. <td valign="top" >RANGE</td>
  3048. <td valign="top" >Min=0, Max=1</td>
  3049. <td valign="top" >Connector</td>
  3050. <td valign="top" >TBD</td>
  3051. </tr>
  3052. <tr>
  3053. <td valign="top" >SDVO-TV/LVDS</td>
  3054. <td valign="top" >“brightness”</td>
  3055. <td valign="top" >RANGE</td>
  3056. <td valign="top" >Min=0, Max= SDVO dependent</td>
  3057. <td valign="top" >Connector</td>
  3058. <td valign="top" >TBD</td>
  3059. </tr>
  3060. <tr>
  3061. <td rowspan="11" valign="top" >armada</td>
  3062. <td rowspan="2" valign="top" >CRTC</td>
  3063. <td valign="top" >"CSC_YUV"</td>
  3064. <td valign="top" >ENUM</td>
  3065. <td valign="top" >{ "Auto" , "CCIR601", "CCIR709" }</td>
  3066. <td valign="top" >CRTC</td>
  3067. <td valign="top" >TBD</td>
  3068. </tr>
  3069. <tr>
  3070. <td valign="top" >"CSC_RGB"</td>
  3071. <td valign="top" >ENUM</td>
  3072. <td valign="top" >{ "Auto", "Computer system", "Studio" }</td>
  3073. <td valign="top" >CRTC</td>
  3074. <td valign="top" >TBD</td>
  3075. </tr>
  3076. <tr>
  3077. <td rowspan="9" valign="top" >Overlay</td>
  3078. <td valign="top" >"colorkey"</td>
  3079. <td valign="top" >RANGE</td>
  3080. <td valign="top" >Min=0, Max=0xffffff</td>
  3081. <td valign="top" >Plane</td>
  3082. <td valign="top" >TBD</td>
  3083. </tr>
  3084. <tr>
  3085. <td valign="top" >"colorkey_min"</td>
  3086. <td valign="top" >RANGE</td>
  3087. <td valign="top" >Min=0, Max=0xffffff</td>
  3088. <td valign="top" >Plane</td>
  3089. <td valign="top" >TBD</td>
  3090. </tr>
  3091. <tr>
  3092. <td valign="top" >"colorkey_max"</td>
  3093. <td valign="top" >RANGE</td>
  3094. <td valign="top" >Min=0, Max=0xffffff</td>
  3095. <td valign="top" >Plane</td>
  3096. <td valign="top" >TBD</td>
  3097. </tr>
  3098. <tr>
  3099. <td valign="top" >"colorkey_val"</td>
  3100. <td valign="top" >RANGE</td>
  3101. <td valign="top" >Min=0, Max=0xffffff</td>
  3102. <td valign="top" >Plane</td>
  3103. <td valign="top" >TBD</td>
  3104. </tr>
  3105. <tr>
  3106. <td valign="top" >"colorkey_alpha"</td>
  3107. <td valign="top" >RANGE</td>
  3108. <td valign="top" >Min=0, Max=0xffffff</td>
  3109. <td valign="top" >Plane</td>
  3110. <td valign="top" >TBD</td>
  3111. </tr>
  3112. <tr>
  3113. <td valign="top" >"colorkey_mode"</td>
  3114. <td valign="top" >ENUM</td>
  3115. <td valign="top" >{ "disabled", "Y component", "U component"
  3116. , "V component", "RGB", “R component", "G component", "B component" }</td>
  3117. <td valign="top" >Plane</td>
  3118. <td valign="top" >TBD</td>
  3119. </tr>
  3120. <tr>
  3121. <td valign="top" >"brightness"</td>
  3122. <td valign="top" >RANGE</td>
  3123. <td valign="top" >Min=0, Max=256 + 255</td>
  3124. <td valign="top" >Plane</td>
  3125. <td valign="top" >TBD</td>
  3126. </tr>
  3127. <tr>
  3128. <td valign="top" >"contrast"</td>
  3129. <td valign="top" >RANGE</td>
  3130. <td valign="top" >Min=0, Max=0x7fff</td>
  3131. <td valign="top" >Plane</td>
  3132. <td valign="top" >TBD</td>
  3133. </tr>
  3134. <tr>
  3135. <td valign="top" >"saturation"</td>
  3136. <td valign="top" >RANGE</td>
  3137. <td valign="top" >Min=0, Max=0x7fff</td>
  3138. <td valign="top" >Plane</td>
  3139. <td valign="top" >TBD</td>
  3140. </tr>
  3141. <tr>
  3142. <td rowspan="2" valign="top" >exynos</td>
  3143. <td valign="top" >CRTC</td>
  3144. <td valign="top" >“mode”</td>
  3145. <td valign="top" >ENUM</td>
  3146. <td valign="top" >{ "normal", "blank" }</td>
  3147. <td valign="top" >CRTC</td>
  3148. <td valign="top" >TBD</td>
  3149. </tr>
  3150. <tr>
  3151. <td valign="top" >Overlay</td>
  3152. <td valign="top" >“zpos”</td>
  3153. <td valign="top" >RANGE</td>
  3154. <td valign="top" >Min=0, Max=MAX_PLANE-1</td>
  3155. <td valign="top" >Plane</td>
  3156. <td valign="top" >TBD</td>
  3157. </tr>
  3158. <tr>
  3159. <td rowspan="2" valign="top" >i2c/ch7006_drv</td>
  3160. <td valign="top" >Generic</td>
  3161. <td valign="top" >“scale”</td>
  3162. <td valign="top" >RANGE</td>
  3163. <td valign="top" >Min=0, Max=2</td>
  3164. <td valign="top" >Connector</td>
  3165. <td valign="top" >TBD</td>
  3166. </tr>
  3167. <tr>
  3168. <td rowspan="1" valign="top" >TV</td>
  3169. <td valign="top" >“mode”</td>
  3170. <td valign="top" >ENUM</td>
  3171. <td valign="top" >{ "PAL", "PAL-M","PAL-N"}, ”PAL-Nc"
  3172. , "PAL-60", "NTSC-M", "NTSC-J" }</td>
  3173. <td valign="top" >Connector</td>
  3174. <td valign="top" >TBD</td>
  3175. </tr>
  3176. <tr>
  3177. <td rowspan="15" valign="top" >nouveau</td>
  3178. <td rowspan="6" valign="top" >NV10 Overlay</td>
  3179. <td valign="top" >"colorkey"</td>
  3180. <td valign="top" >RANGE</td>
  3181. <td valign="top" >Min=0, Max=0x01ffffff</td>
  3182. <td valign="top" >Plane</td>
  3183. <td valign="top" >TBD</td>
  3184. </tr>
  3185. <tr>
  3186. <td valign="top" >“contrast”</td>
  3187. <td valign="top" >RANGE</td>
  3188. <td valign="top" >Min=0, Max=8192-1</td>
  3189. <td valign="top" >Plane</td>
  3190. <td valign="top" >TBD</td>
  3191. </tr>
  3192. <tr>
  3193. <td valign="top" >“brightness”</td>
  3194. <td valign="top" >RANGE</td>
  3195. <td valign="top" >Min=0, Max=1024</td>
  3196. <td valign="top" >Plane</td>
  3197. <td valign="top" >TBD</td>
  3198. </tr>
  3199. <tr>
  3200. <td valign="top" >“hue”</td>
  3201. <td valign="top" >RANGE</td>
  3202. <td valign="top" >Min=0, Max=359</td>
  3203. <td valign="top" >Plane</td>
  3204. <td valign="top" >TBD</td>
  3205. </tr>
  3206. <tr>
  3207. <td valign="top" >“saturation”</td>
  3208. <td valign="top" >RANGE</td>
  3209. <td valign="top" >Min=0, Max=8192-1</td>
  3210. <td valign="top" >Plane</td>
  3211. <td valign="top" >TBD</td>
  3212. </tr>
  3213. <tr>
  3214. <td valign="top" >“iturbt_709”</td>
  3215. <td valign="top" >RANGE</td>
  3216. <td valign="top" >Min=0, Max=1</td>
  3217. <td valign="top" >Plane</td>
  3218. <td valign="top" >TBD</td>
  3219. </tr>
  3220. <tr>
  3221. <td rowspan="2" valign="top" >Nv04 Overlay</td>
  3222. <td valign="top" >“colorkey”</td>
  3223. <td valign="top" >RANGE</td>
  3224. <td valign="top" >Min=0, Max=0x01ffffff</td>
  3225. <td valign="top" >Plane</td>
  3226. <td valign="top" >TBD</td>
  3227. </tr>
  3228. <tr>
  3229. <td valign="top" >“brightness”</td>
  3230. <td valign="top" >RANGE</td>
  3231. <td valign="top" >Min=0, Max=1024</td>
  3232. <td valign="top" >Plane</td>
  3233. <td valign="top" >TBD</td>
  3234. </tr>
  3235. <tr>
  3236. <td rowspan="7" valign="top" >Display</td>
  3237. <td valign="top" >“dithering mode”</td>
  3238. <td valign="top" >ENUM</td>
  3239. <td valign="top" >{ "auto", "off", "on" }</td>
  3240. <td valign="top" >Connector</td>
  3241. <td valign="top" >TBD</td>
  3242. </tr>
  3243. <tr>
  3244. <td valign="top" >“dithering depth”</td>
  3245. <td valign="top" >ENUM</td>
  3246. <td valign="top" >{ "auto", "off", "on", "static 2x2", "dynamic 2x2", "temporal" }</td>
  3247. <td valign="top" >Connector</td>
  3248. <td valign="top" >TBD</td>
  3249. </tr>
  3250. <tr>
  3251. <td valign="top" >“underscan”</td>
  3252. <td valign="top" >ENUM</td>
  3253. <td valign="top" >{ "auto", "6 bpc", "8 bpc" }</td>
  3254. <td valign="top" >Connector</td>
  3255. <td valign="top" >TBD</td>
  3256. </tr>
  3257. <tr>
  3258. <td valign="top" >“underscan hborder”</td>
  3259. <td valign="top" >RANGE</td>
  3260. <td valign="top" >Min=0, Max=128</td>
  3261. <td valign="top" >Connector</td>
  3262. <td valign="top" >TBD</td>
  3263. </tr>
  3264. <tr>
  3265. <td valign="top" >“underscan vborder”</td>
  3266. <td valign="top" >RANGE</td>
  3267. <td valign="top" >Min=0, Max=128</td>
  3268. <td valign="top" >Connector</td>
  3269. <td valign="top" >TBD</td>
  3270. </tr>
  3271. <tr>
  3272. <td valign="top" >“vibrant hue”</td>
  3273. <td valign="top" >RANGE</td>
  3274. <td valign="top" >Min=0, Max=180</td>
  3275. <td valign="top" >Connector</td>
  3276. <td valign="top" >TBD</td>
  3277. </tr>
  3278. <tr>
  3279. <td valign="top" >“color vibrance”</td>
  3280. <td valign="top" >RANGE</td>
  3281. <td valign="top" >Min=0, Max=200</td>
  3282. <td valign="top" >Connector</td>
  3283. <td valign="top" >TBD</td>
  3284. </tr>
  3285. <tr>
  3286. <td valign="top" >omap</td>
  3287. <td valign="top" >Generic</td>
  3288. <td valign="top" >“zorder”</td>
  3289. <td valign="top" >RANGE</td>
  3290. <td valign="top" >Min=0, Max=3</td>
  3291. <td valign="top" >CRTC, Plane</td>
  3292. <td valign="top" >TBD</td>
  3293. </tr>
  3294. <tr>
  3295. <td valign="top" >qxl</td>
  3296. <td valign="top" >Generic</td>
  3297. <td valign="top" >“hotplug_mode_update"</td>
  3298. <td valign="top" >RANGE</td>
  3299. <td valign="top" >Min=0, Max=1</td>
  3300. <td valign="top" >Connector</td>
  3301. <td valign="top" >TBD</td>
  3302. </tr>
  3303. <tr>
  3304. <td rowspan="9" valign="top" >radeon</td>
  3305. <td valign="top" >DVI-I</td>
  3306. <td valign="top" >“coherent”</td>
  3307. <td valign="top" >RANGE</td>
  3308. <td valign="top" >Min=0, Max=1</td>
  3309. <td valign="top" >Connector</td>
  3310. <td valign="top" >TBD</td>
  3311. </tr>
  3312. <tr>
  3313. <td valign="top" >DAC enable load detect</td>
  3314. <td valign="top" >“load detection”</td>
  3315. <td valign="top" >RANGE</td>
  3316. <td valign="top" >Min=0, Max=1</td>
  3317. <td valign="top" >Connector</td>
  3318. <td valign="top" >TBD</td>
  3319. </tr>
  3320. <tr>
  3321. <td valign="top" >TV Standard</td>
  3322. <td valign="top" >"tv standard"</td>
  3323. <td valign="top" >ENUM</td>
  3324. <td valign="top" >{ "ntsc", "pal", "pal-m", "pal-60", "ntsc-j"
  3325. , "scart-pal", "pal-cn", "secam" }</td>
  3326. <td valign="top" >Connector</td>
  3327. <td valign="top" >TBD</td>
  3328. </tr>
  3329. <tr>
  3330. <td valign="top" >legacy TMDS PLL detect</td>
  3331. <td valign="top" >"tmds_pll"</td>
  3332. <td valign="top" >ENUM</td>
  3333. <td valign="top" >{ "driver", "bios" }</td>
  3334. <td valign="top" >-</td>
  3335. <td valign="top" >TBD</td>
  3336. </tr>
  3337. <tr>
  3338. <td rowspan="3" valign="top" >Underscan</td>
  3339. <td valign="top" >"underscan"</td>
  3340. <td valign="top" >ENUM</td>
  3341. <td valign="top" >{ "off", "on", "auto" }</td>
  3342. <td valign="top" >Connector</td>
  3343. <td valign="top" >TBD</td>
  3344. </tr>
  3345. <tr>
  3346. <td valign="top" >"underscan hborder"</td>
  3347. <td valign="top" >RANGE</td>
  3348. <td valign="top" >Min=0, Max=128</td>
  3349. <td valign="top" >Connector</td>
  3350. <td valign="top" >TBD</td>
  3351. </tr>
  3352. <tr>
  3353. <td valign="top" >"underscan vborder"</td>
  3354. <td valign="top" >RANGE</td>
  3355. <td valign="top" >Min=0, Max=128</td>
  3356. <td valign="top" >Connector</td>
  3357. <td valign="top" >TBD</td>
  3358. </tr>
  3359. <tr>
  3360. <td valign="top" >Audio</td>
  3361. <td valign="top" >“audio”</td>
  3362. <td valign="top" >ENUM</td>
  3363. <td valign="top" >{ "off", "on", "auto" }</td>
  3364. <td valign="top" >Connector</td>
  3365. <td valign="top" >TBD</td>
  3366. </tr>
  3367. <tr>
  3368. <td valign="top" >FMT Dithering</td>
  3369. <td valign="top" >“dither”</td>
  3370. <td valign="top" >ENUM</td>
  3371. <td valign="top" >{ "off", "on" }</td>
  3372. <td valign="top" >Connector</td>
  3373. <td valign="top" >TBD</td>
  3374. </tr>
  3375. <tr>
  3376. <td rowspan="3" valign="top" >rcar-du</td>
  3377. <td rowspan="3" valign="top" >Generic</td>
  3378. <td valign="top" >"alpha"</td>
  3379. <td valign="top" >RANGE</td>
  3380. <td valign="top" >Min=0, Max=255</td>
  3381. <td valign="top" >Plane</td>
  3382. <td valign="top" >TBD</td>
  3383. </tr>
  3384. <tr>
  3385. <td valign="top" >"colorkey"</td>
  3386. <td valign="top" >RANGE</td>
  3387. <td valign="top" >Min=0, Max=0x01ffffff</td>
  3388. <td valign="top" >Plane</td>
  3389. <td valign="top" >TBD</td>
  3390. </tr>
  3391. <tr>
  3392. <td valign="top" >"zpos"</td>
  3393. <td valign="top" >RANGE</td>
  3394. <td valign="top" >Min=1, Max=7</td>
  3395. <td valign="top" >Plane</td>
  3396. <td valign="top" >TBD</td>
  3397. </tr>
  3398. </tbody>
  3399. </table>
  3400. </sect2>
  3401. </sect1>
  3402. <!-- Internals: vertical blanking -->
  3403. <sect1 id="drm-vertical-blank">
  3404. <title>Vertical Blanking</title>
  3405. <para>
  3406. Vertical blanking plays a major role in graphics rendering. To achieve
  3407. tear-free display, users must synchronize page flips and/or rendering to
  3408. vertical blanking. The DRM API offers ioctls to perform page flips
  3409. synchronized to vertical blanking and wait for vertical blanking.
  3410. </para>
  3411. <para>
  3412. The DRM core handles most of the vertical blanking management logic, which
  3413. involves filtering out spurious interrupts, keeping race-free blanking
  3414. counters, coping with counter wrap-around and resets and keeping use
  3415. counts. It relies on the driver to generate vertical blanking interrupts
  3416. and optionally provide a hardware vertical blanking counter. Drivers must
  3417. implement the following operations.
  3418. </para>
  3419. <itemizedlist>
  3420. <listitem>
  3421. <synopsis>int (*enable_vblank) (struct drm_device *dev, int crtc);
  3422. void (*disable_vblank) (struct drm_device *dev, int crtc);</synopsis>
  3423. <para>
  3424. Enable or disable vertical blanking interrupts for the given CRTC.
  3425. </para>
  3426. </listitem>
  3427. <listitem>
  3428. <synopsis>u32 (*get_vblank_counter) (struct drm_device *dev, int crtc);</synopsis>
  3429. <para>
  3430. Retrieve the value of the vertical blanking counter for the given
  3431. CRTC. If the hardware maintains a vertical blanking counter its value
  3432. should be returned. Otherwise drivers can use the
  3433. <function>drm_vblank_count</function> helper function to handle this
  3434. operation.
  3435. </para>
  3436. </listitem>
  3437. </itemizedlist>
  3438. <para>
  3439. Drivers must initialize the vertical blanking handling core with a call to
  3440. <function>drm_vblank_init</function> in their
  3441. <methodname>load</methodname> operation. The function will set the struct
  3442. <structname>drm_device</structname>
  3443. <structfield>vblank_disable_allowed</structfield> field to 0. This will
  3444. keep vertical blanking interrupts enabled permanently until the first mode
  3445. set operation, where <structfield>vblank_disable_allowed</structfield> is
  3446. set to 1. The reason behind this is not clear. Drivers can set the field
  3447. to 1 after <function>calling drm_vblank_init</function> to make vertical
  3448. blanking interrupts dynamically managed from the beginning.
  3449. </para>
  3450. <para>
  3451. Vertical blanking interrupts can be enabled by the DRM core or by drivers
  3452. themselves (for instance to handle page flipping operations). The DRM core
  3453. maintains a vertical blanking use count to ensure that the interrupts are
  3454. not disabled while a user still needs them. To increment the use count,
  3455. drivers call <function>drm_vblank_get</function>. Upon return vertical
  3456. blanking interrupts are guaranteed to be enabled.
  3457. </para>
  3458. <para>
  3459. To decrement the use count drivers call
  3460. <function>drm_vblank_put</function>. Only when the use count drops to zero
  3461. will the DRM core disable the vertical blanking interrupts after a delay
  3462. by scheduling a timer. The delay is accessible through the vblankoffdelay
  3463. module parameter or the <varname>drm_vblank_offdelay</varname> global
  3464. variable and expressed in milliseconds. Its default value is 5000 ms.
  3465. Zero means never disable, and a negative value means disable immediately.
  3466. Drivers may override the behaviour by setting the
  3467. <structname>drm_device</structname>
  3468. <structfield>vblank_disable_immediate</structfield> flag, which when set
  3469. causes vblank interrupts to be disabled immediately regardless of the
  3470. drm_vblank_offdelay value. The flag should only be set if there's a
  3471. properly working hardware vblank counter present.
  3472. </para>
  3473. <para>
  3474. When a vertical blanking interrupt occurs drivers only need to call the
  3475. <function>drm_handle_vblank</function> function to account for the
  3476. interrupt.
  3477. </para>
  3478. <para>
  3479. Resources allocated by <function>drm_vblank_init</function> must be freed
  3480. with a call to <function>drm_vblank_cleanup</function> in the driver
  3481. <methodname>unload</methodname> operation handler.
  3482. </para>
  3483. <sect2>
  3484. <title>Vertical Blanking and Interrupt Handling Functions Reference</title>
  3485. !Edrivers/gpu/drm/drm_irq.c
  3486. !Finclude/drm/drmP.h drm_crtc_vblank_waitqueue
  3487. </sect2>
  3488. </sect1>
  3489. <!-- Internals: open/close, file operations and ioctls -->
  3490. <sect1>
  3491. <title>Open/Close, File Operations and IOCTLs</title>
  3492. <sect2>
  3493. <title>Open and Close</title>
  3494. <synopsis>int (*firstopen) (struct drm_device *);
  3495. void (*lastclose) (struct drm_device *);
  3496. int (*open) (struct drm_device *, struct drm_file *);
  3497. void (*preclose) (struct drm_device *, struct drm_file *);
  3498. void (*postclose) (struct drm_device *, struct drm_file *);</synopsis>
  3499. <abstract>Open and close handlers. None of those methods are mandatory.
  3500. </abstract>
  3501. <para>
  3502. The <methodname>firstopen</methodname> method is called by the DRM core
  3503. for legacy UMS (User Mode Setting) drivers only when an application
  3504. opens a device that has no other opened file handle. UMS drivers can
  3505. implement it to acquire device resources. KMS drivers can't use the
  3506. method and must acquire resources in the <methodname>load</methodname>
  3507. method instead.
  3508. </para>
  3509. <para>
  3510. Similarly the <methodname>lastclose</methodname> method is called when
  3511. the last application holding a file handle opened on the device closes
  3512. it, for both UMS and KMS drivers. Additionally, the method is also
  3513. called at module unload time or, for hot-pluggable devices, when the
  3514. device is unplugged. The <methodname>firstopen</methodname> and
  3515. <methodname>lastclose</methodname> calls can thus be unbalanced.
  3516. </para>
  3517. <para>
  3518. The <methodname>open</methodname> method is called every time the device
  3519. is opened by an application. Drivers can allocate per-file private data
  3520. in this method and store them in the struct
  3521. <structname>drm_file</structname> <structfield>driver_priv</structfield>
  3522. field. Note that the <methodname>open</methodname> method is called
  3523. before <methodname>firstopen</methodname>.
  3524. </para>
  3525. <para>
  3526. The close operation is split into <methodname>preclose</methodname> and
  3527. <methodname>postclose</methodname> methods. Drivers must stop and
  3528. cleanup all per-file operations in the <methodname>preclose</methodname>
  3529. method. For instance pending vertical blanking and page flip events must
  3530. be cancelled. No per-file operation is allowed on the file handle after
  3531. returning from the <methodname>preclose</methodname> method.
  3532. </para>
  3533. <para>
  3534. Finally the <methodname>postclose</methodname> method is called as the
  3535. last step of the close operation, right before calling the
  3536. <methodname>lastclose</methodname> method if no other open file handle
  3537. exists for the device. Drivers that have allocated per-file private data
  3538. in the <methodname>open</methodname> method should free it here.
  3539. </para>
  3540. <para>
  3541. The <methodname>lastclose</methodname> method should restore CRTC and
  3542. plane properties to default value, so that a subsequent open of the
  3543. device will not inherit state from the previous user. It can also be
  3544. used to execute delayed power switching state changes, e.g. in
  3545. conjunction with the vga_switcheroo infrastructure (see
  3546. <xref linkend="vga_switcheroo"/>). Beyond that KMS drivers should not
  3547. do any further cleanup. Only legacy UMS drivers might need to clean up
  3548. device state so that the vga console or an independent fbdev driver
  3549. could take over.
  3550. </para>
  3551. </sect2>
  3552. <sect2>
  3553. <title>File Operations</title>
  3554. <synopsis>const struct file_operations *fops</synopsis>
  3555. <abstract>File operations for the DRM device node.</abstract>
  3556. <para>
  3557. Drivers must define the file operations structure that forms the DRM
  3558. userspace API entry point, even though most of those operations are
  3559. implemented in the DRM core. The <methodname>open</methodname>,
  3560. <methodname>release</methodname> and <methodname>ioctl</methodname>
  3561. operations are handled by
  3562. <programlisting>
  3563. .owner = THIS_MODULE,
  3564. .open = drm_open,
  3565. .release = drm_release,
  3566. .unlocked_ioctl = drm_ioctl,
  3567. #ifdef CONFIG_COMPAT
  3568. .compat_ioctl = drm_compat_ioctl,
  3569. #endif
  3570. </programlisting>
  3571. </para>
  3572. <para>
  3573. Drivers that implement private ioctls that requires 32/64bit
  3574. compatibility support must provide their own
  3575. <methodname>compat_ioctl</methodname> handler that processes private
  3576. ioctls and calls <function>drm_compat_ioctl</function> for core ioctls.
  3577. </para>
  3578. <para>
  3579. The <methodname>read</methodname> and <methodname>poll</methodname>
  3580. operations provide support for reading DRM events and polling them. They
  3581. are implemented by
  3582. <programlisting>
  3583. .poll = drm_poll,
  3584. .read = drm_read,
  3585. .llseek = no_llseek,
  3586. </programlisting>
  3587. </para>
  3588. <para>
  3589. The memory mapping implementation varies depending on how the driver
  3590. manages memory. Pre-GEM drivers will use <function>drm_mmap</function>,
  3591. while GEM-aware drivers will use <function>drm_gem_mmap</function>. See
  3592. <xref linkend="drm-gem"/>.
  3593. <programlisting>
  3594. .mmap = drm_gem_mmap,
  3595. </programlisting>
  3596. </para>
  3597. <para>
  3598. No other file operation is supported by the DRM API.
  3599. </para>
  3600. </sect2>
  3601. <sect2>
  3602. <title>IOCTLs</title>
  3603. <synopsis>struct drm_ioctl_desc *ioctls;
  3604. int num_ioctls;</synopsis>
  3605. <abstract>Driver-specific ioctls descriptors table.</abstract>
  3606. <para>
  3607. Driver-specific ioctls numbers start at DRM_COMMAND_BASE. The ioctls
  3608. descriptors table is indexed by the ioctl number offset from the base
  3609. value. Drivers can use the DRM_IOCTL_DEF_DRV() macro to initialize the
  3610. table entries.
  3611. </para>
  3612. <para>
  3613. <programlisting>DRM_IOCTL_DEF_DRV(ioctl, func, flags)</programlisting>
  3614. <para>
  3615. <parameter>ioctl</parameter> is the ioctl name. Drivers must define
  3616. the DRM_##ioctl and DRM_IOCTL_##ioctl macros to the ioctl number
  3617. offset from DRM_COMMAND_BASE and the ioctl number respectively. The
  3618. first macro is private to the device while the second must be exposed
  3619. to userspace in a public header.
  3620. </para>
  3621. <para>
  3622. <parameter>func</parameter> is a pointer to the ioctl handler function
  3623. compatible with the <type>drm_ioctl_t</type> type.
  3624. <programlisting>typedef int drm_ioctl_t(struct drm_device *dev, void *data,
  3625. struct drm_file *file_priv);</programlisting>
  3626. </para>
  3627. <para>
  3628. <parameter>flags</parameter> is a bitmask combination of the following
  3629. values. It restricts how the ioctl is allowed to be called.
  3630. <itemizedlist>
  3631. <listitem><para>
  3632. DRM_AUTH - Only authenticated callers allowed
  3633. </para></listitem>
  3634. <listitem><para>
  3635. DRM_MASTER - The ioctl can only be called on the master file
  3636. handle
  3637. </para></listitem>
  3638. <listitem><para>
  3639. DRM_ROOT_ONLY - Only callers with the SYSADMIN capability allowed
  3640. </para></listitem>
  3641. <listitem><para>
  3642. DRM_CONTROL_ALLOW - The ioctl can only be called on a control
  3643. device
  3644. </para></listitem>
  3645. <listitem><para>
  3646. DRM_UNLOCKED - The ioctl handler will be called without locking
  3647. the DRM global mutex. This is the enforced default for kms drivers
  3648. (i.e. using the DRIVER_MODESET flag) and hence shouldn't be used
  3649. any more for new drivers.
  3650. </para></listitem>
  3651. </itemizedlist>
  3652. </para>
  3653. </para>
  3654. !Edrivers/gpu/drm/drm_ioctl.c
  3655. </sect2>
  3656. </sect1>
  3657. <sect1>
  3658. <title>Legacy Support Code</title>
  3659. <para>
  3660. The section very briefly covers some of the old legacy support code which
  3661. is only used by old DRM drivers which have done a so-called shadow-attach
  3662. to the underlying device instead of registering as a real driver. This
  3663. also includes some of the old generic buffer management and command
  3664. submission code. Do not use any of this in new and modern drivers.
  3665. </para>
  3666. <sect2>
  3667. <title>Legacy Suspend/Resume</title>
  3668. <para>
  3669. The DRM core provides some suspend/resume code, but drivers wanting full
  3670. suspend/resume support should provide save() and restore() functions.
  3671. These are called at suspend, hibernate, or resume time, and should perform
  3672. any state save or restore required by your device across suspend or
  3673. hibernate states.
  3674. </para>
  3675. <synopsis>int (*suspend) (struct drm_device *, pm_message_t state);
  3676. int (*resume) (struct drm_device *);</synopsis>
  3677. <para>
  3678. Those are legacy suspend and resume methods which
  3679. <emphasis>only</emphasis> work with the legacy shadow-attach driver
  3680. registration functions. New driver should use the power management
  3681. interface provided by their bus type (usually through
  3682. the struct <structname>device_driver</structname> dev_pm_ops) and set
  3683. these methods to NULL.
  3684. </para>
  3685. </sect2>
  3686. <sect2>
  3687. <title>Legacy DMA Services</title>
  3688. <para>
  3689. This should cover how DMA mapping etc. is supported by the core.
  3690. These functions are deprecated and should not be used.
  3691. </para>
  3692. </sect2>
  3693. </sect1>
  3694. </chapter>
  3695. <!-- TODO
  3696. - Add a glossary
  3697. - Document the struct_mutex catch-all lock
  3698. - Document connector properties
  3699. - Why is the load method optional?
  3700. - What are drivers supposed to set the initial display state to, and how?
  3701. Connector's DPMS states are not initialized and are thus equal to
  3702. DRM_MODE_DPMS_ON. The fbcon compatibility layer calls
  3703. drm_helper_disable_unused_functions(), which disables unused encoders and
  3704. CRTCs, but doesn't touch the connectors' DPMS state, and
  3705. drm_helper_connector_dpms() in reaction to fbdev blanking events. Do drivers
  3706. that don't implement (or just don't use) fbcon compatibility need to call
  3707. those functions themselves?
  3708. - KMS drivers must call drm_vblank_pre_modeset() and drm_vblank_post_modeset()
  3709. around mode setting. Should this be done in the DRM core?
  3710. - vblank_disable_allowed is set to 1 in the first drm_vblank_post_modeset()
  3711. call and never set back to 0. It seems to be safe to permanently set it to 1
  3712. in drm_vblank_init() for KMS driver, and it might be safe for UMS drivers as
  3713. well. This should be investigated.
  3714. - crtc and connector .save and .restore operations are only used internally in
  3715. drivers, should they be removed from the core?
  3716. - encoder mid-layer .save and .restore operations are only used internally in
  3717. drivers, should they be removed from the core?
  3718. - encoder mid-layer .detect operation is only used internally in drivers,
  3719. should it be removed from the core?
  3720. -->
  3721. <!-- External interfaces -->
  3722. <chapter id="drmExternals">
  3723. <title>Userland interfaces</title>
  3724. <para>
  3725. The DRM core exports several interfaces to applications,
  3726. generally intended to be used through corresponding libdrm
  3727. wrapper functions. In addition, drivers export device-specific
  3728. interfaces for use by userspace drivers &amp; device-aware
  3729. applications through ioctls and sysfs files.
  3730. </para>
  3731. <para>
  3732. External interfaces include: memory mapping, context management,
  3733. DMA operations, AGP management, vblank control, fence
  3734. management, memory management, and output management.
  3735. </para>
  3736. <para>
  3737. Cover generic ioctls and sysfs layout here. We only need high-level
  3738. info, since man pages should cover the rest.
  3739. </para>
  3740. <!-- External: render nodes -->
  3741. <sect1>
  3742. <title>Render nodes</title>
  3743. <para>
  3744. DRM core provides multiple character-devices for user-space to use.
  3745. Depending on which device is opened, user-space can perform a different
  3746. set of operations (mainly ioctls). The primary node is always created
  3747. and called card&lt;num&gt;. Additionally, a currently
  3748. unused control node, called controlD&lt;num&gt; is also
  3749. created. The primary node provides all legacy operations and
  3750. historically was the only interface used by userspace. With KMS, the
  3751. control node was introduced. However, the planned KMS control interface
  3752. has never been written and so the control node stays unused to date.
  3753. </para>
  3754. <para>
  3755. With the increased use of offscreen renderers and GPGPU applications,
  3756. clients no longer require running compositors or graphics servers to
  3757. make use of a GPU. But the DRM API required unprivileged clients to
  3758. authenticate to a DRM-Master prior to getting GPU access. To avoid this
  3759. step and to grant clients GPU access without authenticating, render
  3760. nodes were introduced. Render nodes solely serve render clients, that
  3761. is, no modesetting or privileged ioctls can be issued on render nodes.
  3762. Only non-global rendering commands are allowed. If a driver supports
  3763. render nodes, it must advertise it via the DRIVER_RENDER
  3764. DRM driver capability. If not supported, the primary node must be used
  3765. for render clients together with the legacy drmAuth authentication
  3766. procedure.
  3767. </para>
  3768. <para>
  3769. If a driver advertises render node support, DRM core will create a
  3770. separate render node called renderD&lt;num&gt;. There will
  3771. be one render node per device. No ioctls except PRIME-related ioctls
  3772. will be allowed on this node. Especially GEM_OPEN will be
  3773. explicitly prohibited. Render nodes are designed to avoid the
  3774. buffer-leaks, which occur if clients guess the flink names or mmap
  3775. offsets on the legacy interface. Additionally to this basic interface,
  3776. drivers must mark their driver-dependent render-only ioctls as
  3777. DRM_RENDER_ALLOW so render clients can use them. Driver
  3778. authors must be careful not to allow any privileged ioctls on render
  3779. nodes.
  3780. </para>
  3781. <para>
  3782. With render nodes, user-space can now control access to the render node
  3783. via basic file-system access-modes. A running graphics server which
  3784. authenticates clients on the privileged primary/legacy node is no longer
  3785. required. Instead, a client can open the render node and is immediately
  3786. granted GPU access. Communication between clients (or servers) is done
  3787. via PRIME. FLINK from render node to legacy node is not supported. New
  3788. clients must not use the insecure FLINK interface.
  3789. </para>
  3790. <para>
  3791. Besides dropping all modeset/global ioctls, render nodes also drop the
  3792. DRM-Master concept. There is no reason to associate render clients with
  3793. a DRM-Master as they are independent of any graphics server. Besides,
  3794. they must work without any running master, anyway.
  3795. Drivers must be able to run without a master object if they support
  3796. render nodes. If, on the other hand, a driver requires shared state
  3797. between clients which is visible to user-space and accessible beyond
  3798. open-file boundaries, they cannot support render nodes.
  3799. </para>
  3800. </sect1>
  3801. <!-- External: vblank handling -->
  3802. <sect1>
  3803. <title>VBlank event handling</title>
  3804. <para>
  3805. The DRM core exposes two vertical blank related ioctls:
  3806. <variablelist>
  3807. <varlistentry>
  3808. <term>DRM_IOCTL_WAIT_VBLANK</term>
  3809. <listitem>
  3810. <para>
  3811. This takes a struct drm_wait_vblank structure as its argument,
  3812. and it is used to block or request a signal when a specified
  3813. vblank event occurs.
  3814. </para>
  3815. </listitem>
  3816. </varlistentry>
  3817. <varlistentry>
  3818. <term>DRM_IOCTL_MODESET_CTL</term>
  3819. <listitem>
  3820. <para>
  3821. This was only used for user-mode-settind drivers around
  3822. modesetting changes to allow the kernel to update the vblank
  3823. interrupt after mode setting, since on many devices the vertical
  3824. blank counter is reset to 0 at some point during modeset. Modern
  3825. drivers should not call this any more since with kernel mode
  3826. setting it is a no-op.
  3827. </para>
  3828. </listitem>
  3829. </varlistentry>
  3830. </variablelist>
  3831. </para>
  3832. </sect1>
  3833. </chapter>
  3834. </part>
  3835. <part id="drmDrivers">
  3836. <title>DRM Drivers</title>
  3837. <partintro>
  3838. <para>
  3839. This second part of the GPU Driver Developer's Guide documents driver
  3840. code, implementation details and also all the driver-specific userspace
  3841. interfaces. Especially since all hardware-acceleration interfaces to
  3842. userspace are driver specific for efficiency and other reasons these
  3843. interfaces can be rather substantial. Hence every driver has its own
  3844. chapter.
  3845. </para>
  3846. </partintro>
  3847. <chapter id="drmI915">
  3848. <title>drm/i915 Intel GFX Driver</title>
  3849. <para>
  3850. The drm/i915 driver supports all (with the exception of some very early
  3851. models) integrated GFX chipsets with both Intel display and rendering
  3852. blocks. This excludes a set of SoC platforms with an SGX rendering unit,
  3853. those have basic support through the gma500 drm driver.
  3854. </para>
  3855. <sect1>
  3856. <title>Core Driver Infrastructure</title>
  3857. <para>
  3858. This section covers core driver infrastructure used by both the display
  3859. and the GEM parts of the driver.
  3860. </para>
  3861. <sect2>
  3862. <title>Runtime Power Management</title>
  3863. !Pdrivers/gpu/drm/i915/intel_runtime_pm.c runtime pm
  3864. !Idrivers/gpu/drm/i915/intel_runtime_pm.c
  3865. !Idrivers/gpu/drm/i915/intel_uncore.c
  3866. </sect2>
  3867. <sect2>
  3868. <title>Interrupt Handling</title>
  3869. !Pdrivers/gpu/drm/i915/i915_irq.c interrupt handling
  3870. !Fdrivers/gpu/drm/i915/i915_irq.c intel_irq_init intel_irq_init_hw intel_hpd_init
  3871. !Fdrivers/gpu/drm/i915/i915_irq.c intel_runtime_pm_disable_interrupts
  3872. !Fdrivers/gpu/drm/i915/i915_irq.c intel_runtime_pm_enable_interrupts
  3873. </sect2>
  3874. <sect2>
  3875. <title>Intel GVT-g Guest Support(vGPU)</title>
  3876. !Pdrivers/gpu/drm/i915/i915_vgpu.c Intel GVT-g guest support
  3877. !Idrivers/gpu/drm/i915/i915_vgpu.c
  3878. </sect2>
  3879. </sect1>
  3880. <sect1>
  3881. <title>Display Hardware Handling</title>
  3882. <para>
  3883. This section covers everything related to the display hardware including
  3884. the mode setting infrastructure, plane, sprite and cursor handling and
  3885. display, output probing and related topics.
  3886. </para>
  3887. <sect2>
  3888. <title>Mode Setting Infrastructure</title>
  3889. <para>
  3890. The i915 driver is thus far the only DRM driver which doesn't use the
  3891. common DRM helper code to implement mode setting sequences. Thus it
  3892. has its own tailor-made infrastructure for executing a display
  3893. configuration change.
  3894. </para>
  3895. </sect2>
  3896. <sect2>
  3897. <title>Frontbuffer Tracking</title>
  3898. !Pdrivers/gpu/drm/i915/intel_frontbuffer.c frontbuffer tracking
  3899. !Idrivers/gpu/drm/i915/intel_frontbuffer.c
  3900. !Fdrivers/gpu/drm/i915/i915_gem.c i915_gem_track_fb
  3901. </sect2>
  3902. <sect2>
  3903. <title>Display FIFO Underrun Reporting</title>
  3904. !Pdrivers/gpu/drm/i915/intel_fifo_underrun.c fifo underrun handling
  3905. !Idrivers/gpu/drm/i915/intel_fifo_underrun.c
  3906. </sect2>
  3907. <sect2>
  3908. <title>Plane Configuration</title>
  3909. <para>
  3910. This section covers plane configuration and composition with the
  3911. primary plane, sprites, cursors and overlays. This includes the
  3912. infrastructure to do atomic vsync'ed updates of all this state and
  3913. also tightly coupled topics like watermark setup and computation,
  3914. framebuffer compression and panel self refresh.
  3915. </para>
  3916. </sect2>
  3917. <sect2>
  3918. <title>Atomic Plane Helpers</title>
  3919. !Pdrivers/gpu/drm/i915/intel_atomic_plane.c atomic plane helpers
  3920. !Idrivers/gpu/drm/i915/intel_atomic_plane.c
  3921. </sect2>
  3922. <sect2>
  3923. <title>Output Probing</title>
  3924. <para>
  3925. This section covers output probing and related infrastructure like the
  3926. hotplug interrupt storm detection and mitigation code. Note that the
  3927. i915 driver still uses most of the common DRM helper code for output
  3928. probing, so those sections fully apply.
  3929. </para>
  3930. </sect2>
  3931. <sect2>
  3932. <title>Hotplug</title>
  3933. !Pdrivers/gpu/drm/i915/intel_hotplug.c Hotplug
  3934. !Idrivers/gpu/drm/i915/intel_hotplug.c
  3935. </sect2>
  3936. <sect2>
  3937. <title>High Definition Audio</title>
  3938. !Pdrivers/gpu/drm/i915/intel_audio.c High Definition Audio over HDMI and Display Port
  3939. !Idrivers/gpu/drm/i915/intel_audio.c
  3940. !Iinclude/drm/i915_component.h
  3941. </sect2>
  3942. <sect2>
  3943. <title>Panel Self Refresh PSR (PSR/SRD)</title>
  3944. !Pdrivers/gpu/drm/i915/intel_psr.c Panel Self Refresh (PSR/SRD)
  3945. !Idrivers/gpu/drm/i915/intel_psr.c
  3946. </sect2>
  3947. <sect2>
  3948. <title>Frame Buffer Compression (FBC)</title>
  3949. !Pdrivers/gpu/drm/i915/intel_fbc.c Frame Buffer Compression (FBC)
  3950. !Idrivers/gpu/drm/i915/intel_fbc.c
  3951. </sect2>
  3952. <sect2>
  3953. <title>Display Refresh Rate Switching (DRRS)</title>
  3954. !Pdrivers/gpu/drm/i915/intel_dp.c Display Refresh Rate Switching (DRRS)
  3955. !Fdrivers/gpu/drm/i915/intel_dp.c intel_dp_set_drrs_state
  3956. !Fdrivers/gpu/drm/i915/intel_dp.c intel_edp_drrs_enable
  3957. !Fdrivers/gpu/drm/i915/intel_dp.c intel_edp_drrs_disable
  3958. !Fdrivers/gpu/drm/i915/intel_dp.c intel_edp_drrs_invalidate
  3959. !Fdrivers/gpu/drm/i915/intel_dp.c intel_edp_drrs_flush
  3960. !Fdrivers/gpu/drm/i915/intel_dp.c intel_dp_drrs_init
  3961. </sect2>
  3962. <sect2>
  3963. <title>DPIO</title>
  3964. !Pdrivers/gpu/drm/i915/i915_reg.h DPIO
  3965. <table id="dpiox2">
  3966. <title>Dual channel PHY (VLV/CHV/BXT)</title>
  3967. <tgroup cols="8">
  3968. <colspec colname="c0" />
  3969. <colspec colname="c1" />
  3970. <colspec colname="c2" />
  3971. <colspec colname="c3" />
  3972. <colspec colname="c4" />
  3973. <colspec colname="c5" />
  3974. <colspec colname="c6" />
  3975. <colspec colname="c7" />
  3976. <spanspec spanname="ch0" namest="c0" nameend="c3" />
  3977. <spanspec spanname="ch1" namest="c4" nameend="c7" />
  3978. <spanspec spanname="ch0pcs01" namest="c0" nameend="c1" />
  3979. <spanspec spanname="ch0pcs23" namest="c2" nameend="c3" />
  3980. <spanspec spanname="ch1pcs01" namest="c4" nameend="c5" />
  3981. <spanspec spanname="ch1pcs23" namest="c6" nameend="c7" />
  3982. <thead>
  3983. <row>
  3984. <entry spanname="ch0">CH0</entry>
  3985. <entry spanname="ch1">CH1</entry>
  3986. </row>
  3987. </thead>
  3988. <tbody valign="top" align="center">
  3989. <row>
  3990. <entry spanname="ch0">CMN/PLL/REF</entry>
  3991. <entry spanname="ch1">CMN/PLL/REF</entry>
  3992. </row>
  3993. <row>
  3994. <entry spanname="ch0pcs01">PCS01</entry>
  3995. <entry spanname="ch0pcs23">PCS23</entry>
  3996. <entry spanname="ch1pcs01">PCS01</entry>
  3997. <entry spanname="ch1pcs23">PCS23</entry>
  3998. </row>
  3999. <row>
  4000. <entry>TX0</entry>
  4001. <entry>TX1</entry>
  4002. <entry>TX2</entry>
  4003. <entry>TX3</entry>
  4004. <entry>TX0</entry>
  4005. <entry>TX1</entry>
  4006. <entry>TX2</entry>
  4007. <entry>TX3</entry>
  4008. </row>
  4009. <row>
  4010. <entry spanname="ch0">DDI0</entry>
  4011. <entry spanname="ch1">DDI1</entry>
  4012. </row>
  4013. </tbody>
  4014. </tgroup>
  4015. </table>
  4016. <table id="dpiox1">
  4017. <title>Single channel PHY (CHV/BXT)</title>
  4018. <tgroup cols="4">
  4019. <colspec colname="c0" />
  4020. <colspec colname="c1" />
  4021. <colspec colname="c2" />
  4022. <colspec colname="c3" />
  4023. <spanspec spanname="ch0" namest="c0" nameend="c3" />
  4024. <spanspec spanname="ch0pcs01" namest="c0" nameend="c1" />
  4025. <spanspec spanname="ch0pcs23" namest="c2" nameend="c3" />
  4026. <thead>
  4027. <row>
  4028. <entry spanname="ch0">CH0</entry>
  4029. </row>
  4030. </thead>
  4031. <tbody valign="top" align="center">
  4032. <row>
  4033. <entry spanname="ch0">CMN/PLL/REF</entry>
  4034. </row>
  4035. <row>
  4036. <entry spanname="ch0pcs01">PCS01</entry>
  4037. <entry spanname="ch0pcs23">PCS23</entry>
  4038. </row>
  4039. <row>
  4040. <entry>TX0</entry>
  4041. <entry>TX1</entry>
  4042. <entry>TX2</entry>
  4043. <entry>TX3</entry>
  4044. </row>
  4045. <row>
  4046. <entry spanname="ch0">DDI2</entry>
  4047. </row>
  4048. </tbody>
  4049. </tgroup>
  4050. </table>
  4051. </sect2>
  4052. <sect2>
  4053. <title>CSR firmware support for DMC</title>
  4054. !Pdrivers/gpu/drm/i915/intel_csr.c csr support for dmc
  4055. !Idrivers/gpu/drm/i915/intel_csr.c
  4056. </sect2>
  4057. </sect1>
  4058. <sect1>
  4059. <title>Memory Management and Command Submission</title>
  4060. <para>
  4061. This sections covers all things related to the GEM implementation in the
  4062. i915 driver.
  4063. </para>
  4064. <sect2>
  4065. <title>Batchbuffer Parsing</title>
  4066. !Pdrivers/gpu/drm/i915/i915_cmd_parser.c batch buffer command parser
  4067. !Idrivers/gpu/drm/i915/i915_cmd_parser.c
  4068. </sect2>
  4069. <sect2>
  4070. <title>Batchbuffer Pools</title>
  4071. !Pdrivers/gpu/drm/i915/i915_gem_batch_pool.c batch pool
  4072. !Idrivers/gpu/drm/i915/i915_gem_batch_pool.c
  4073. </sect2>
  4074. <sect2>
  4075. <title>Logical Rings, Logical Ring Contexts and Execlists</title>
  4076. !Pdrivers/gpu/drm/i915/intel_lrc.c Logical Rings, Logical Ring Contexts and Execlists
  4077. !Idrivers/gpu/drm/i915/intel_lrc.c
  4078. </sect2>
  4079. <sect2>
  4080. <title>Global GTT views</title>
  4081. !Pdrivers/gpu/drm/i915/i915_gem_gtt.c Global GTT views
  4082. !Idrivers/gpu/drm/i915/i915_gem_gtt.c
  4083. </sect2>
  4084. <sect2>
  4085. <title>GTT Fences and Swizzling</title>
  4086. !Idrivers/gpu/drm/i915/i915_gem_fence.c
  4087. <sect3>
  4088. <title>Global GTT Fence Handling</title>
  4089. !Pdrivers/gpu/drm/i915/i915_gem_fence.c fence register handling
  4090. </sect3>
  4091. <sect3>
  4092. <title>Hardware Tiling and Swizzling Details</title>
  4093. !Pdrivers/gpu/drm/i915/i915_gem_fence.c tiling swizzling details
  4094. </sect3>
  4095. </sect2>
  4096. <sect2>
  4097. <title>Object Tiling IOCTLs</title>
  4098. !Idrivers/gpu/drm/i915/i915_gem_tiling.c
  4099. !Pdrivers/gpu/drm/i915/i915_gem_tiling.c buffer object tiling
  4100. </sect2>
  4101. <sect2>
  4102. <title>Buffer Object Eviction</title>
  4103. <para>
  4104. This section documents the interface functions for evicting buffer
  4105. objects to make space available in the virtual gpu address spaces.
  4106. Note that this is mostly orthogonal to shrinking buffer objects
  4107. caches, which has the goal to make main memory (shared with the gpu
  4108. through the unified memory architecture) available.
  4109. </para>
  4110. !Idrivers/gpu/drm/i915/i915_gem_evict.c
  4111. </sect2>
  4112. <sect2>
  4113. <title>Buffer Object Memory Shrinking</title>
  4114. <para>
  4115. This section documents the interface function for shrinking memory
  4116. usage of buffer object caches. Shrinking is used to make main memory
  4117. available. Note that this is mostly orthogonal to evicting buffer
  4118. objects, which has the goal to make space in gpu virtual address
  4119. spaces.
  4120. </para>
  4121. !Idrivers/gpu/drm/i915/i915_gem_shrinker.c
  4122. </sect2>
  4123. </sect1>
  4124. <sect1>
  4125. <title>GuC</title>
  4126. <sect2>
  4127. <title>GuC-specific firmware loader</title>
  4128. !Pdrivers/gpu/drm/i915/intel_guc_loader.c GuC-specific firmware loader
  4129. !Idrivers/gpu/drm/i915/intel_guc_loader.c
  4130. </sect2>
  4131. <sect2>
  4132. <title>GuC-based command submission</title>
  4133. !Pdrivers/gpu/drm/i915/i915_guc_submission.c GuC-based command submission
  4134. !Idrivers/gpu/drm/i915/i915_guc_submission.c
  4135. </sect2>
  4136. <sect2>
  4137. <title>GuC Firmware Layout</title>
  4138. !Pdrivers/gpu/drm/i915/intel_guc_fwif.h GuC Firmware Layout
  4139. </sect2>
  4140. </sect1>
  4141. <sect1>
  4142. <title> Tracing </title>
  4143. <para>
  4144. This sections covers all things related to the tracepoints implemented in
  4145. the i915 driver.
  4146. </para>
  4147. <sect2>
  4148. <title> i915_ppgtt_create and i915_ppgtt_release </title>
  4149. !Pdrivers/gpu/drm/i915/i915_trace.h i915_ppgtt_create and i915_ppgtt_release tracepoints
  4150. </sect2>
  4151. <sect2>
  4152. <title> i915_context_create and i915_context_free </title>
  4153. !Pdrivers/gpu/drm/i915/i915_trace.h i915_context_create and i915_context_free tracepoints
  4154. </sect2>
  4155. <sect2>
  4156. <title> switch_mm </title>
  4157. !Pdrivers/gpu/drm/i915/i915_trace.h switch_mm tracepoint
  4158. </sect2>
  4159. </sect1>
  4160. </chapter>
  4161. !Cdrivers/gpu/drm/i915/i915_irq.c
  4162. </part>
  4163. <part id="vga_switcheroo">
  4164. <title>vga_switcheroo</title>
  4165. <partintro>
  4166. !Pdrivers/gpu/vga/vga_switcheroo.c Overview
  4167. </partintro>
  4168. <chapter id="modes_of_use">
  4169. <title>Modes of Use</title>
  4170. <sect1>
  4171. <title>Manual switching and manual power control</title>
  4172. !Pdrivers/gpu/vga/vga_switcheroo.c Manual switching and manual power control
  4173. </sect1>
  4174. <sect1>
  4175. <title>Driver power control</title>
  4176. !Pdrivers/gpu/vga/vga_switcheroo.c Driver power control
  4177. </sect1>
  4178. </chapter>
  4179. <chapter id="pubfunctions">
  4180. <title>Public functions</title>
  4181. !Edrivers/gpu/vga/vga_switcheroo.c
  4182. </chapter>
  4183. <chapter id="pubstructures">
  4184. <title>Public structures</title>
  4185. !Finclude/linux/vga_switcheroo.h vga_switcheroo_handler
  4186. !Finclude/linux/vga_switcheroo.h vga_switcheroo_client_ops
  4187. </chapter>
  4188. <chapter id="pubconstants">
  4189. <title>Public constants</title>
  4190. !Finclude/linux/vga_switcheroo.h vga_switcheroo_client_id
  4191. !Finclude/linux/vga_switcheroo.h vga_switcheroo_state
  4192. </chapter>
  4193. <chapter id="privstructures">
  4194. <title>Private structures</title>
  4195. !Fdrivers/gpu/vga/vga_switcheroo.c vgasr_priv
  4196. !Fdrivers/gpu/vga/vga_switcheroo.c vga_switcheroo_client
  4197. </chapter>
  4198. !Cdrivers/gpu/vga/vga_switcheroo.c
  4199. !Cinclude/linux/vga_switcheroo.h
  4200. </part>
  4201. </book>