drm/vc4 Broadcom VC4 Graphics Driver
文章推薦指數: 80 %
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 5.18.0-rc6 TheLinuxkerneluser’sandadministrator’sguide KernelBuildSystem TheLinuxkernelfirmwareguide OpenFirmwareandDevicetree TheLinuxkerneluser-spaceAPIguide Workingwiththekerneldevelopmentcommunity Developmenttoolsforthekernel Howtowritekerneldocumentation KernelHackingGuides LinuxTracingTechnologies KernelMaintainerHandbook fault-injection KernelLivepatching TheLinuxdriverimplementer’sAPIguide CoreAPIDocumentation locking Accounting Block cdrom LinuxCPUFreq-CPUfrequencyandvoltagescalingcodeintheLinux(TM)kernel IntegratedDriveElectronics(IDE) FrameBuffer fpga HumanInterfaceDevices(HID) I2C/SMBusSubsystem IndustrialI/O ISDN InfiniBand LEDs NetLabel LinuxNetworkingDocumentation pcmcia PowerManagement TCMVirtualDevice timers SerialPeripheralInterface(SPI) 1-WireSubsystem LinuxWatchdogSupport LinuxVirtualizationSupport TheLinuxInputDocumentation LinuxHardwareMonitoring LinuxGPUDriverDeveloper’sGuide Introduction DRMInternals DRMMemoryManagement KernelModeSetting(KMS) ModeSettingHelperFunctions Userlandinterfaces DRMclientusagestats Driverspecificimplementations DRMDriveruAPI Kernelclients GPUDriverDocumentation drm/amdgpuAMDgpudriver drm/i915IntelGFXDriver drm/mcdeST-EricssonMCDEMulti-channeldisplayengine drm/mesonAmLogicMesonVideoProcessingUnit drm/pl111ARMPrimeCellPL110andPL111CLCDDriver drm/tegraNVIDIATegraGPUanddisplaydriver drm/tve200FaradayTVEncoder200 drm/v3dBroadcomV3DGraphicsDriver drm/vc4BroadcomVC4GraphicsDriver DisplayHardwareHandling MemoryManagementand3DCommandSubmission drm/vkmsVirtualKernelModesetting drm/bridge/dw-hdmiSynopsysDesignWareHDMIController drm/xen-frontXenpara-virtualizedfrontenddriver ArmFramebufferCompression(AFBC) drm/komedaArmdisplaydriver Backlightsupport VGASwitcheroo VGAArbiter TODOlist GPURFCSection SecurityDocumentation LinuxSoundSubsystemDocumentation LinuxKernelCryptoAPI FilesystemsintheLinuxkernel LinuxMemoryManagementDocumentation BPFDocumentation USBsupport LinuxPCIBusSubsystem LinuxSCSISubsystem AssortedMiscellaneousDevicesDocumentation LinuxScheduler MHI TTY LinuxPECISubsystem AssemblerAnnotations CPUArchitectures Kerneltools UnsortedDocumentation AtomicTypes Atomicbitops MemoryBarriers Generalnotificationmechanism Translations TheLinuxKernel Docs» LinuxGPUDriverDeveloper’sGuide» GPUDriverDocumentation» 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.
延伸文章資訊
- 1Raspberry Pi 4 Graphics Driver Update Improves 4K Output
The developer trying to bring support to the Linux kernel, Maxime Ripard, has revised the DRM of ...
- 2drm/vc4 Broadcom VC4 Graphics Driver
The Broadcom VideoCore 4 (present in the Raspberry Pi) contains a OpenGL ES 2.0-compatible 3D eng...
- 3vc4-kms-v3d driver not working with custom HDMI mode ...
The max pixel clock for vc4-kms-v3d is dictated by the driver, and there's no override provided. ...
- 4drm/vc4 Broadcom VC4 Graphics Driver - The Linux Kernel ...
The Broadcom VideoCore 4 (present in the Raspberry Pi) contains a OpenGL ES 2.0-compatible 3D eng...
- 5VC4 and V3D OpenGL drivers for Raspberry Pi: an update
The GPU bundled with Raspberry Pi 4 is a VideoCore VI capable of OpenGL ES 3.2, a significant ste...