Cameras in embedded systems: Device tree and ACPI view
Sakari Ailus - Intel
Cameras in embedded systems: Device tree and ACPI view Sakari Ailus - - PowerPoint PPT Presentation
Cameras in embedded systems: Device tree and ACPI view Sakari Ailus - Intel A typical embedded system with a camera Image Signal Processor Raw camera sensor Lens voice coil vana camera regulator module vdig lens GPIO reset
Sakari Ailus - Intel
A typical embedded system with a camera
SoC camera module lens voice coil sensor lens voice coil lens ISP CSI-2 I²C I²C GPIO regulator reset vana vdig clock
Raw sensors
sensor itself
– Analogue and digital gain but not much more
This is how white looks like! -->
Image signal processors
for viewing
After ISP processing white looks like this --->
Video4Linux and Media controller
images
– Video capture cards – USB webcams – Cameras in embedded devices
media devices
– Image pipeline discovery and configuration – Device discovery
Example of a media graph
ISP sensor
Probing
probed separately
media device?
PCI, AMBA etc. ISP I2C controller sensor lens voice coil
Media device setup
1.media_device_init() 2.v4l2_device_register() 3.video_register_device() 5.v4l2_device_register_subd ev(isp) 6.v4l2_register_subdev_nod es() 7.media_device_register()
4.v4l2_device_register_subdev( sensor)
Media device driver sensor driver
V4L2 async
device registration
media device registration postponed after probe
use of firmware provided information
V4L2 async example (ISP)
device base ISP driver ISP DT node sensor DT node V4L2 async async sub-device li st async notifjer list probe(dev) parse local endpointsV4L2 async (sensor)
dev ice base ISP driver sensor driver sensor DT node V4L2 async async notifjer list probe(dev) v4l2_of_parse_endpoint() endpoint properties v4l2_async_register_subdev(sd) Look for a notifjer matchi n the sub-device Found it! notifjer->bound() notifjer->complete()Device tree
– ARM – Also PowerPC, Sparc and x86
– Nodes – Properties
Device Tree standard and bindings
devicetree.org
– Syntax and some semantics
and the software
– Bindings are Operating System specific – Linux Device tree binding documentation part of the Linux
kernel source
– FreeBSD developers appear to be converging towards
using Linux DT bindings
Device tree graphs
block)
a port [7]
Sensor node
&i2c2 { smia_1: camera@10 { compatible = "nokia,smia"; reg = <0x10>; /* No reset gpio */ vana-supply = <&vaux3>; clocks = <&isp 0>; clock-frequency = <9600000>; nokia,nvm-size = <(16 * 64)>; port { smia_1_1: endpoint { link-frequencies = /bits/ 64 <199200000 210000000 499200000>; clock-lanes = <0>; data-lanes = <1 2>; remote-endpoint = <&csi2a_ep>; }; }; }; }; source: arch/arm/boot/dts/omap3-n9.dts
ISP node board specific part
&isp { vdd-csiphy1-supply = <&vaux2>; vdd-csiphy2-supply = <&vaux2>; ports { port@2 { reg = <2>; csi2a_ep: endpoint { remote-endpoint = <&smia_1_1>; clock-lanes = <2>; data-lanes = <1 3>; crc = <1>; lane-polarities = <1 1 1>; }; }; }; }; source: arch/arm/boot/dts/omap3-n9.dts
OF graph API
nodes
– Based on the phandle value
ACPI
– Increasingly used in embedded systems
– Runnable code – ACPI virtual machine
ACPI
– Roughly one specification per year
– A new ACPI specification?
ACPI Device Specific Data
– Key-value pairs (property extension) and – Tree structures (hierarchical data extension)
used to implement very similar functionality to Devicetree
– Light-weight approach for registering _DSD properties
fwnode property API
firmware implementation
– Device Tree – ACPI
[2]
Fwnode graph API
– But is firmware independent
tree
extension [3] on ACPI
V4L2 fwnode API
– Embedded systems with I²C components – Requires both fwnode graph API and V4L2 fwnode API
– Sub-device driver using V4L2 fwnode works with a media
device driver using V4L2 OF
– and vice versa!
Flash
they're related to
– This is rather important if there are multiple
cameras in the system, such as most mobile phones nowadays
Camera module
the kernel (nor DT or ACPI)
user space
– Which sensor and lens are related? – What kind of lens is there? – What's the voice coil spring constant? – Is there an infra red filter? What kind of filter is it? – What's the aperture size?
Camera module power on and power off sequences
module components
specific
– Which order and when each resource may be enabled? – E.g. regulator and clock are enabled, then after 10 ms the reset
GPIO can be lifted and the device is ready for use
lens and sensor must be considered for module power-up sequence
camera module lens voice coil sensor lens voice coil lens CSI-2 I²C reset vana vdig clock
References
[1] http://www.uefi.org/acpi [2] http://www.uefi.org/sites/default/files/resources/_DSD-device-properties-UUID.pdf [3] http://www.uefi.org/sites/default/files/resources/_DSD-hierarchical-data-extension-UUID-v1.pdf [4] http://www.spinics.net/lists/linux-acpi/msg69547.html [5] http://www.spinics.net/lists/linux-media/msg106160.html [6] https://github.com/ahs3/dsd [7] Documentation/devicetree/bindings/graph.txt
Firmware logistics
Device tree ACPI
BIOS vendor system vendor BIOS in flash memory SoC vendor OS binaries runtime ACPI tables mother- board support website
selective table replacement (initrd)
SoC vendor OS binaries system vendor flash memory Linux kernel dts Device tree
appended to kernel image
ACPI camera example
Scope (\_SB.PCI0.I2C2) { Device (CAM0) { Name (_DSD, Package () { /* device specific data */ Package () { Package () { "compatible", Package () { "nokia,smia" } }, Package () { "lanes", 4 }, Package () { "clock-frequency", 24000000 }, }, /* data extension */ Package () { Package () { "ports", "PRTS" }, } })
ACPI camera example
Name (PRTS, Package() { /* data extension */ Package () { Package () { "port@0", "PRT0" }, } }) Name (PRT0, Package() { /* device specific data */ Package () { Package () { "port", 0 }, }, /* data extension */ Package () { Package () { "endpoint@0", "EP0" }, } })
ACPI camera example
Name (EP0, Package() { /* device specific data */ Package () { Package () { "endpoint", 0 }, Package () { "clock-lanes", 0 }, Package () { "data-lanes", Package () { 1, 2, 3, 4 } }, Package () { "link-frequencies", Package () { 209600000, 342000000, 451200000 } }, Package () { "remote-endpoint", Package() { \_SB.PCI0.ISP, 0, 0, 0 } }, }, }) } }
ACPI ISP example
Scope (\_SB.PCI0) { Device (ISP) { Name (_DSD, Package () { /* data extension */ Package () { Package () { "ports", "PRTS" }, } }) Name (PRTS, Package() { /* data extension */ Package () { Package () { "port@4", "PRT4" }, } })
ACPI ISP example
Name (PRT4, Package() { /* device specific data */ Package () { Package () { "port", 4 }, /* CSI-2 port number */ }, /* data extension */ Package () { Package () { "endpoint@0", "EP0" }, } }) Name (EP0, Package() { /* device specific data */ Package () { Package () { "endpoint", 0 }, Package () { "clock-lanes", 0 }, Package () { "data-lanes", Package () { 1, 2, 3, 4 } }, Package () { "remote-endpoint", Package () { \_SB.PCI0.I2C2.CAM0, 0, 0, 0 } }, }, }) } }