Introduction to HAL3
HAL3是Android相机API重构的重点,旨在提升应用对相机子系统的控制能力。相比HAL1,HAL3增加了3A控制、ISP控制等新功能,支持更丰富的控制操作,如高动态范围(HDR)和高帧率拍摄。HAL3通过异步请求机制处理捕获请求,确保返回结果的及时性。设备需按顺序处理请求,生成输出结果元数据和图像缓冲,支持部分结果返回以优化性能。同时,HAL3明确了两种操作模式:全模式和有限模式,全模式适用于高端设备,有限模式适用于资源受限设备。元数据类型包括静态、控制和动态类型,涉及多个相机控制参数。此外,HAL3支持高分辨率输出缓冲和快速调整设置功能。
目录
HAL3 behavior
Overview of HAL1 v.s HAL3
HAL3 behavior:
HAL3 - detail:
HAL3 operation and pipeline
Framework Diagram
Problem of current code
Operation mode
Full v.s limited
Do:
Don’t:
Metadata
Manual control – ISP control
Manual control – sensor control
Use case
Use case 2: high-speed
HAL3 behavior
Overview of HAL1 v.s HAL3
版本1的相机子系统采用了黑箱设计,具备高级控制功能。
Preview: startPreview()
Video Record: startRecording()
Still Capture: takePicture()
Hard to implement new feature
No per-frame control
The Android Camera API redesign has achieved significant performance improvements compared to asio, primarily attributed to its streamlined design and efficient code structure.
Per-frame control
Manual control (3A, ISP, etc)
HAL3 behavior:

HAL3 - detail:

Summary of Android Camera API use:
Listen for and enumerate camera devices.
Open device and connect listeners.
Set up output configurations for the intended use case, including still capture and recording functionalities.
Create request(s) for target use case.
Capture/repeat requests and bursts.
Receive result metadata and image data.
When switching use cases, return to step 3
HAL3 operation and pipeline

HAL Operation Summary:
Asynchronous requests for captures come from the framework.
The HAL must block the return of this call until it is ready to handle the next request.
HAL设备必须按照顺序处理请求。对于每个请求,需要生成输出结果元数据以及一个或多个输出图像缓冲区。请求和结果需遵循先来先处理的原则,同时对于后续请求所引用的流,也需遵循此规则。
Partial results could occur for urgent notifications, such as 3a notify. For performance optimization, it is recommended to send the results for what is known as early as possible in the pipeline.
For all outputs from a given request, the timestamps must be the same to enable matching when necessary.
Framework Diagram

Problem of current code

Operation mode
Full v.s limited
The camera 3 HAL device is capable of operating in either a limited mode or a full mode
Full support is expected from new higher-end devices.
有限模式的硬件要求大致与相机HAL设备v1实现所需相当,通常配备于较旧或较经济型的设备上。
Limited Mode Spec
Do:
3A control
Don’t:
control of ISP capture setting
high-rate capture of high-resolution images
raw sensor readout
The system supports YUV output streams exceeding the maximum recording resolution, with JPEG exclusively applicable to large images.
相机不支持每帧控制,因为设置与实际捕获到的图像数据之间无法准确同步。设置的变化可能在未来一段时间内生效,而且可能在不同的输出帧上生效。快速的设置变化可能导致某些设置在一次捕获中从未使用。然而,包含高分辨率输出缓冲区(>1080p)的捕获必须严格按照设置进行(下文将介绍处理速率)。
Metadata
Type:
Static
Control
Dynamic
ISP/3A member needs to study doc.html for each metadata tag’s property
./system/media/camera/docs/docs.html
* android.control.aeAntibandingMode (controls and dynamic)
* android.control.aeExposureCompensation (controls and dynamic)
* android.control.aeLock (controls and dynamic)
* android.control.aeMode (controls and dynamic)
* android.control.aeRegions (controls and dynamic)
* android.control.aeTargetFpsRange (controls and dynamic)
* android.control.aePrecaptureTrigger (controls and dynamic)
* android.control.afMode (controls and dynamic)
* android.control.afRegions (controls and dynamic)
* android.control.awbLock (controls and dynamic)
* android.control.awbMode (controls and dynamic)
* android.control.awbRegions (controls and dynamic)
* android.control.captureIntent (controls and dynamic)
* android.control.effectMode (controls and dynamic)
* android.control.mode (controls and dynamic)
* android.control.sceneMode (controls and dynamic)
* android.control.videoStabilizationMode (controls and dynamic)
* android.control.aeAvailableAntibandingModes (static)
* android.control.aeAvailableModes (static)
* android.control.aeAvailableTargetFpsRanges (static)
* android.control.aeCompensationRange (static)
* android.control.aeCompensationStep (static)
* android.control.afAvailableModes (static)
* android.control.availableEffects (static)
* android.control.availableSceneModes (static)
* android.control.availableVideoStabilizationModes (static)
* android.control.awbAvailableModes (static)
* android.control.maxRegions (static)
* android.control.sceneModeOverrides (static)
* android.control.aeState (dynamic)
* android.control.afState (dynamic)
* android.control.awbState (dynamic)…..
Manual control – ISP control
Color correction
Demosaic
Edge
Noise reduction
LSC
Tonemap
…
Manual control – sensor control
Exposure time
Frame duration
Sensitivity
….
Use case
Use Case: HDR
HAL3 is closely integrated with 3A and ISP functions. Let’s take HDR as an example.

Use case 2: high-speed


