gpu.tmpl 173 KB

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