Drivers

The drivers controls the devices attached to the platform. The following type of devices are typically available:

  • DMA (Direct Memory Access) devices

  • DAI (Digital Audio Interface) devices

Registering the Devices

The devices are connected to other topology elements when the topology is being created. The infrastructure (lib) needs to know what devices are available and how to connect to their drivers’ APIs. The platform initialization routine is responsible for the device discovery and API registration. The discovery mechanism depends on the platform. It may be either very simple statically compiled list of the devices or a dynamic one based on capability information provided by the underlying HW at run-time.

participant "platform" as plat
participant lib

-> plat : platform_init()
   activate plat

   == DAI ==

   plat -> plat : dai_disco() : dai_desc_list
   plat -> lib : dai_install(dai_desc_list)

   == DMA ==

   plat -> plat : dma_disco() : dma_desc_list
   plat -> lib : dma_install(dma_desc_list)

<-- plat
deactivate plat

Figure 21 Device discovery and registration

Probing on Demand

Creation of the particular device may result in a significant resource allocation and increased power demand. Therefore the infrastructure does not create (probe) the devices immediately upon startup. A simple reference counting mechanism implemented inside the lib allows to probe the devices on demand and free (remove) them when no longer in use.

The device driver implementation of remove() API is required to free all the resources allocated in probe() and power-gate unused HW blocks.

participant "component" as comp
participant lib
participant ukernel
participant "driver" as drv
participant hw

-> comp : new()

comp -> lib : dai_get(type, ...)
   activate lib

   lib -> lib : lookup(dai_desc_list) : dai_desc
   opt dai_desc->sref == 0
      lib -> drv : dai_desc->ops->probe(dai_desc)
         activate drv
         drv -> hw : ungate power
         drv -> ukernel : alloc mem
      lib <-- drv : Success
      deactivate drv
   end opt
   lib -> lib : dai_desc->sref++

comp <-- lib : dev*
deactivate lib

Figure 22 Creating the device on the first use

participant "component" as comp
participant lib
participant ukernel
participant "driver" as drv
participant hw

-> comp : free()

comp -> lib : dai_put(dev*)
   activate lib

   opt --dai_desc->sref == 0
      lib -> drv : dai_desc->ops->remove(dev)
         activate drv
         drv -> ukernel : free mem
         drv -> hw : gate power
      lib <-- drv : Success
      deactivate drv
   end opt

comp <-- lib
deactivate lib

Figure 23 Removing the device when no longer in use

API

The drivers are located at: src/drivers