drm/vc4 Broadcom VC4 Graphics Driver - The Linux Kernel ...

文章推薦指數: 80 %
投票人數:10人

The Broadcom VideoCore 4 (present in the Raspberry Pi) contains a OpenGL ES 2.0-compatible 3D engine called V3D, and a highly configurable display output ... TheLinuxKernel 4.12.0 TheLinuxkerneluser’sandadministrator’sguide TheLinuxkerneluser-spaceAPIguide Workingwiththekerneldevelopmentcommunity Developmenttoolsforthekernel Howtowritekerneldocumentation TheLinuxdriverimplementer’sAPIguide CoreAPIDocumentation LinuxMediaSubsystemDocumentation TheLinuxInputDocumentation LinuxGPUDriverDeveloper’sGuide Introduction DRMInternals DRMMemoryManagement KernelModeSetting(KMS) ModeSettingHelperFunctions Userlandinterfaces drm/i915IntelGFXDriver drm/mesonAmLogicMesonVideoProcessingUnit drm/tinydrmDriverlibrary drm/vc4BroadcomVC4GraphicsDriver DisplayHardwareHandling PixelValve(DRMCRTC) HVS HVSplanes HDMIencoder DSIencoder DPIencoder VEC(CompositeTVout)encoder MemoryManagementand3DCommandSubmission GPUbufferobject(BO)management V3Dbinnercommandlist(BCL)validation V3Drendercommandlist(RCL)generation ShadervalidatorforVC4 V3DInterrupts VGASwitcheroo VGAArbiter drm/bridge/dw-hdmiSynopsysDesignWareHDMIController TODOlist Securitydocumentation LinuxSoundSubsystemDocumentation LinuxKernelCryptoAPI Koreantranslations Chinesetranslations Japanesetranslations TheLinuxKernel Docs» LinuxGPUDriverDeveloper’sGuide» drm/vc4BroadcomVC4GraphicsDriver Viewpagesource drm/vc4BroadcomVC4GraphicsDriver¶ TheBroadcomVideoCore4(presentintheRaspberryPi)containsa OpenGLES2.0-compatible3DenginecalledV3D,andahighly configurabledisplayoutputpipelinethatsupportsHDMI,DSI,DPI, andCompositeTVoutput. The3Denginealsohasaninterfaceforsubmittingarbitrary computeshader-stylejobsusingthesameshaderprocessorasis usedforvertexandfragmentshadersinGLES2.0.However,given thatthehardwareisn’tabletoexposeanystandardinterfaceslike OpenGLcomputeshadersorOpenCL,itisn’tsupportedbythis driver. DisplayHardwareHandling¶ Thissectioncoverseverythingrelatedtothedisplayhardwareincluding themodesettinginfrastructure,plane,spriteandcursorhandlingand display,outputprobingandrelatedtopics. PixelValve(DRMCRTC)¶ InVC4,thePixelValveiswhatmostcloselycorrespondstothe DRM’sconceptofaCRTC.ThePVgeneratesvideotimingsfromthe encoder’sclockplusitsconfiguration.Itpullsscaledpixelsfrom theHVSatthattiming,andfeedsittotheencoder. However,theDRMCRTCalsocollectstheconfigurationofallthe DRMplanesattachedtoit.Asaresult,theCRTCisalso responsibleforwritingthedisplaylistfortheHVSchannelthat theCRTCwilluse. The2835has3differentpixelvalves.pv0intheaudiopower domainfeedsDSI0orDPI,whilepv1feedsDS1orSMI.pv2inthe imagedomaincanfeedeitherHDMIortheSDTVcontroller.The pixelvalvechoosesfromtheCPRMANclocks(HSMforHDMI,VECfor SDTV,etc.)accordingtowhichoutputtypeischoseninthemux. Forpowermanagement,thepixelvalve’sregistersareallclocked bytheAXIclock,whilethetimingsandFIFOsmakeuseofthe output-specificclock.Sincetheencodersalsodirectlyconsume theCPRMANclocks,andknowwhattimingstheyneed,theyarethe onesthatsettheclock. HVS¶ TheHardwareVideoScaler(HVS)isthepieceofhardwarethatdoes translation,scaling,colorspaceconversion,andcompositingof pixelsstoredinframebuffersintoaFIFOofpixelsgoingoutto thePixelValve(CRTC).Itoperatesatthesystemclockrate(the systemaudioclockgate,specifically),whichismuchhigherthan thepixelclockrate. ThereisasingleglobalHVS,withmultipleoutputFIFOsthatcan beconsumedbythePVs.Thisfilejustmanagestheresourcesfor theHVS,whilethevc4_crtc.ccodeactuallydrivesHVSsetupfor eachCRTC. HVSplanes¶ EachDRMplaneisalayerofpixelsbeingscannedoutbytheHVS. Atatomicmodesetchecktime,wecomputetheHVSdisplayelement statethatwouldbenecessaryfordisplayingtheplane(givingusa chancetofigureoutifaplaneconfigurationisinvalid),thenat atomicflushtimetheCRTCwillaskustowriteourelementstate intotheregionoftheHVSthatithasallocatedforus. HDMIencoder¶ TheHDMIcorehasastatemachineandaPHY.OnBCM2835,mostof theunitoperatesoffoftheHSMclockfromCPRMAN.Italso internallyusesthePLLH_PIXclockforthePHY. HDMIinfoframesarekeptwithinasmallpacketram,whereeach packetcanbeindividuallyenabledforincludinginaframe. HDMIaudioisimplementedentirelywithintheHDMIIPblock.A registerintheHDMIencodertakesSPDIFframesfromtheDMAengine andtransfersthemoveraninternalMAI(multi-channelaudio interconnect)bustotheencodersideforinsertionintothevideo blankregions. Thedriver’sHDMIencoderdoesnotyetsupportpowermanagement. TheHDMIencoder’spowerdomainandtheHSM/pixelclocksarekept continuouslyrunning,andonlytheHDMIlogicandpacketramare poweredoff/onatdisable/enabletime. ThedriverdoesnotyetsupportCECcontrol,thoughtheHDMI encoderblockhasCECsupport. DSIencoder¶ BCM2835containstwoDSImodules,DSI0andDSI1.DSI0isa single-laneDSIcontroller,whileDSI1isamoremodern4-laneDSI controller. MostRaspberryPiboardsexposeDSI1astheir“DISPLAY”connector, whilethecomputemodulebringsbothDSI0andDSI1out. ThisdriverhasbeentestedforDSI1video-modedisplayonly currently,withmostoftheinformationnecessaryforDSI0 hopefullypresent. DPIencoder¶ TheVC4DPIhardwaresupportsMIPIDPItype4andNokiaViSSI signals.OnBCM2835,thesecanberoutedouttoGPIO0-27withthe ALT2function. VEC(CompositeTVout)encoder¶ TheVECencodergeneratesPALorNTSCcompositevideooutput. TVmodeselectionisdonebyanatomicpropertyontheencoder, becauseadrm_mode_modeinfoisinsufficienttodistinguishbetween PALandPAL-MorNTSCandNTSC-J. MemoryManagementand3DCommandSubmission¶ ThissectioncoverstheGEMimplementationinthevc4driver. GPUbufferobject(BO)management¶ TheVC4GPUarchitecture(bothscanoutandrendering)hasdirect accesstosystemmemorywithnoMMUinbetween.Tosupportit,we usetheGEMCMAhelperfunctionstoallocatecontiguousrangesof physicalmemoryforourBOs. SincetheCMAallocatorisveryslow,wekeepacacheofrecently freedBOsaroundsothatthekernel’sallocationofobjectsfor3D renderingcanreturnquickly. V3Dbinnercommandlist(BCL)validation¶ SincetheVC4hasnoIOMMUbetweenitandsystemmemory,auser withaccesstoexecutecommandlistscouldescalateprivilegeby overwritingsystemmemory(drawingtoitasaframebuffer)or readingsystemmemoryitshouldn’t(readingitasavertexbuffer orindexbuffer) Wevalidatebinnercommandliststoensurethatallaccessesare withintheboundsoftheGEMobjectsreferencedbythesubmitted job.Itexplicitlywhitelistspackets,andlooksattheoffsetsin anyaddressfieldstomakesurethey’recontainedwithintheBOs theyreference. NotethatbecauseCLvalidationisalreadyreadingthe user-submittedCLandwritingthevalidatedcopyouttothememory thattheGPUwillactuallyread,thisisalsowhereGEMrelocation processing(turningBOreferencesintoactualaddressesfortheGPU touse)happens. V3Drendercommandlist(RCL)generation¶ IntheV3Dhardware,rendercommandlistsarewhatloadandstore tilesofaframebufferandoptionallycallouttobinner-generated commandliststodothe3Ddrawingforthattile. IntheVC4driver,rendercommandlistgenerationisperformedbythe kernelinsteadofuserspace.Wedothisbecausevalidatinga user-submittedcommandlistishardtogetrightandhashighCPUoverhead, whilethenumberofvalidconfigurationsforrendercommandlistsis actuallyfairlylow. ShadervalidatorforVC4¶ SincetheVC4hasnoIOMMUbetweenitandsystemmemory,auser withaccesstoexecuteshaderscouldescalateprivilegeby overwritingsystemmemory(usingtheVPMwriteaddressregisterin thegeneral-purposeDMAmode)orreadingsystemmemoryitshouldn’t (readingitasatexture,uniformdata,ordirect-addressedTMU lookup). Theshadervalidatorwalksoverashader’sBO,ensuringthatits accessesareappropriatelybounded,andrecordingwheretexture accessesaremadesothatwecandorelocationsfortheminthe uniformstream. ShaderBOareimmutablefortheirlifetimes(enforcedbynot allowingmmaps,GEMprimeexport,orrenderingtofromaCL),so thisvalidationisonlyperformedatBOcreationtime. V3DInterrupts¶ Wehaveaninterruptstatusregister(V3D_INTCTL)whichreports interrupts,andwherewriting1bitsclearsthoseinterrupts. Therearealsoapairofinterruptregisters (V3D_INTENA/V3D_INTDIS)wherewritinga1totheirbitsenablesor disablesthatspecificinterrupt,and0swrittenareignored (readingeitheronereturnsthesetofenabledinterrupts). Whenwetakeabinningflushdoneinterrupt,weneedtosubmitthe nextframeforbinningandmovethefinishedframetotherender thread. Whenwetakearenderframeinterrupt,weneedtowakethe processeswaitingforsomeframetobedone,andgetthenextframe submittedASAP(sothehardwaredoesn’tsitidlewhenthere’swork todo). Whenwetakethebinneroutofmemoryinterrupt,weneedto allocatesomenewmemoryandpassittothebinnersothatthe currentjobcanmakeprogress.



請為這篇文章評分?