|
|||||||||||||
News2022-11-14It happened during the Media Mini Summit Dublin - Sep 12 and 13, 2022 It mentioned that the report about the Kernel CAM topic that happened on would be posted later, so I'm pleased to finally post that. Thanks to all who participated in the meetings and the reviewing of this report. Kernel CAM (Ricardo Ribalda)Slides at https://drive.google.com/file/d/1Tew21xeKmFlQ7dQxMcIYqybVuQL7La1a/view Kernel Recipes talk about Kernel CAM: https://kernel-recipes.org/en/2022/talks/rethinking-the-kernel-camera-framework/ This discussion spanned two days: Monday morning on September 16th as part of the Media Mini-Summit Dublin, followed by another meeting in a smaller group on Tuesday morning. Many thanks to Google for organizing a room for us on Tuesday. On Monday morning the discussion was specifically around the Kernel CAM proposal, on Tuesday morning the discussion was more about how to proceed. This report attempts to capture the discussions of those two days, but does not necessarily reflect any final agreement between the parties involved. The report ends with two final comments from myself as submaintainer of the media subsystem (V4L2 in particular), and Mauro as maintainer of the media subsystem. Attendees
MondayIn Android, the vendor is responsible for implementation, between hardware and Android camera HAL you can have anything (e.g. user space drivers). ChromeOS currently supports several SoC vendors (Mediatek, Rockchip, Intel, Qualcomm, more to come) and expects that the kernel code is upstream. Documenting ISP algorithm parameters reveals information from image processing step internal implementation and vendors are not willing to do so. Can a driver be in upstream while being only usable by the original vendor? Even if it offers enough functionality to be used by anyone and only leaves un-documented a small percentage of advanced features? Vendors may be unwilling to reveal tuning parameters they use. Documentation requirements + difficulty in getting new features accepted to V4L2 are the (main?) reasons for downstream V4L2-alike drivers. Maxime notes that the slide about Vendors' Complaints has the same arguments used by GPU vendors against upstreaming drivers. API documentation is required for upstreaming. ISPs have traditionally been a pain point upstream-wise. There is more push to get these in upstream due to ChromeOS upstreaming requirement, and due to user-visible problems (e.g. IPU6). Also laptop vendors are unhappy with no upstream driver support for their computers. V4L2 more a technically limiting factor than before, e.g. 96 DMAs in one ISP. Nicolas and Hans noted that downsteam GPL drivers are fine. Upstreaming a driver requires opening up the driver interfaces. There appears to be near-unanimous consensus on this (apart from Ricardo). Ricardo said that he rather have a driver that supports all the standard use-cases than no driver at all. He is ok giving access to the vendor to the "advanced" cores for a proprietary userspace, if that core has no access to memory. If a vendor wishes to upstream a driver with partial functionality, that's fine. A downstream variant of this driver may support more functionality (that is not documented). Ricardo's preference would be to document only certain basic features and leave the rest undocumented. Vendors need to plan for upstreaming and understand requirements of getting drivers to upstream. Implementing Android camera HAL API 3 full profile entirely possible using V4L2. The Request API is not very helpful here, not used by ISP drivers. What developments API-wise do we expect in this area? Nokia FCAM and then Android camera HAL 3 introduced the concept of a request that binds the frame and the parameters. No major new developments since that, in almost 10 years. Minor changes: - Changing parameters from registers to buffers - New pixel formats If a new API for ISPs that is upstream would be developed, then that would be what we use for the next two decades. Sakari: V4L2 is not an impossible API for IPU6, just a poor one. Hans: V4L2 could be amended with support for disconnecting relation with DMAs and video devices. I.e., doing this directly through the media controller instead of having to deal with zillions of device nodes. Mauro: discussion with vendors' ISP teams would be useful. A short discussion of the proposed Kernel CAM API followed: - 3 concepts: * Entities: represent a hardware node and have: properties and events. Properties do not need to map hardware registers 1:1. * Operation: A set of read and write to an entity. Multiple can be queued at the same time and can be scheduled after one or more triggers: Events, Fences, Operation Completion, timers * Single device node, /dev/cam, to control all the entities to queue operation and get the response from them.
Some conclusions from this discussionEveryone agrees that the current V4L2 API is not very suitable for the current generation of ISPs: it is too cumbersome. We would be happy to work with ChromeOS and/or vendors to attempt to improve it. The proposed Kernel CAM API is considered much too vague to comment on. An example driver for real hardware will be needed first. A register level interface is too low level interface for a complex kernel driver. A number of newer ISPs implement a (slightly) higher level message-passing interface towards software rather than something that would provide more direct control of hardware such as what traditionally is meant by a register interface. For upstreaming ISP drivers (regardless of the API used), multiple options have been discussed, without any decision made yet regarding which options would be accepted by the community:
And of course, if no agreement can be reached on any of the options above, then we can keep everything out-of-tree. TuesdayThe main focus on the second day was on identifying the main painpoints and agree on a list of requirements that any new A{O should fulfill. ## Problems with existing V4L2-based camera stacks Ricardo initially went through the problems that vendors and ChromeOS is having with V4L2: Problems from vendors
Today the upstream community allows vendors to ship a closed source implementation of 3A algorithms, provided that an open source implementation can also be made. There are no plans to change this policy. Vendors want to leverage their investment in Android. And V4L2 does not map 1:1 with HAL3. Problems from Chrome OSChromeOS has a Upstream First commitment, but also wants to enable as much hardware as possible to as many users as possible. ChromeOS has provided a lot of resources in the past to upstream vendor code, but this is not scalable and cannot be done at the speed that is required by the market. Today downstream drivers can access features not available to the open-source stack. ChromeOS thinks that there should be a mechanism to access vendor features on the open-source stack assuming that the open source stack is feature complete. ## Looking at the future We listed a set of requirements that a kernel API should have to support ISP based cameras. The goal is not to replace V4L2 for every single type of device.
Final comments from Hans and MauroThese comments are added to clearly state the view of us as media maintainers. Hans (as media submaintainer): It is not an option to upstream a driver that has support for undocumented closed features. Basically maintainers can't put their name on something that contains unverifiable (for them) and unusable (by all except the vendor) features. Mauro (as media maintainer): My view as media maintainer is similar to Hans: the non-firmware code required for the camera to work (either Kernelspace or userspace) should be open-sourced, up to the point that video streams/images are properly captured on a non-proprietary video output format, in a way that it would be possible to use open-source implementations of 3A algorithms if someone is willing to do that. So, registers used for image enhancement and meta-data should be properly documented. This is specially important since, usually, chipset maintainers stop implementing features when newer generations of the hardware arrive, keeping users of the (not so) old hardware without decent support. With proper documentation, if enough developers want to keep their hardware working, they could implement their replacement code to the proprietary code if needed. |
||||