xref: /aosp_15_r20/hardware/interfaces/camera/device/3.2/ICameraDevice.hal (revision 4d7e907c777eeecc4c5bd7cf640a754fac206ff7)
1*4d7e907cSAndroid Build Coastguard Worker/*
2*4d7e907cSAndroid Build Coastguard Worker * Copyright (C) 2016 The Android Open Source Project
3*4d7e907cSAndroid Build Coastguard Worker *
4*4d7e907cSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License");
5*4d7e907cSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License.
6*4d7e907cSAndroid Build Coastguard Worker * You may obtain a copy of the License at
7*4d7e907cSAndroid Build Coastguard Worker *
8*4d7e907cSAndroid Build Coastguard Worker *      http://www.apache.org/licenses/LICENSE-2.0
9*4d7e907cSAndroid Build Coastguard Worker *
10*4d7e907cSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software
11*4d7e907cSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS,
12*4d7e907cSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*4d7e907cSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and
14*4d7e907cSAndroid Build Coastguard Worker * limitations under the License.
15*4d7e907cSAndroid Build Coastguard Worker */
16*4d7e907cSAndroid Build Coastguard Worker
17*4d7e907cSAndroid Build Coastguard Workerpackage [email protected];
18*4d7e907cSAndroid Build Coastguard Worker
19*4d7e907cSAndroid Build Coastguard Workerimport [email protected]::types;
20*4d7e907cSAndroid Build Coastguard Workerimport ICameraDeviceSession;
21*4d7e907cSAndroid Build Coastguard Workerimport ICameraDeviceCallback;
22*4d7e907cSAndroid Build Coastguard Worker
23*4d7e907cSAndroid Build Coastguard Worker/**
24*4d7e907cSAndroid Build Coastguard Worker * Camera device HAL, first modern version
25*4d7e907cSAndroid Build Coastguard Worker *
26*4d7e907cSAndroid Build Coastguard Worker * Supports the android.hardware.Camera API, and the android.hardware.camera2
27*4d7e907cSAndroid Build Coastguard Worker * API at LIMITED or better hardware level.
28*4d7e907cSAndroid Build Coastguard Worker *
29*4d7e907cSAndroid Build Coastguard Worker */
30*4d7e907cSAndroid Build Coastguard Workerinterface ICameraDevice {
31*4d7e907cSAndroid Build Coastguard Worker
32*4d7e907cSAndroid Build Coastguard Worker    /**
33*4d7e907cSAndroid Build Coastguard Worker     * Get camera device resource cost information.
34*4d7e907cSAndroid Build Coastguard Worker     *
35*4d7e907cSAndroid Build Coastguard Worker     * @return status Status code for the operation, one of:
36*4d7e907cSAndroid Build Coastguard Worker     *     OK:
37*4d7e907cSAndroid Build Coastguard Worker     *         On success
38*4d7e907cSAndroid Build Coastguard Worker     *     INTERNAL_ERROR:
39*4d7e907cSAndroid Build Coastguard Worker     *         An unexpected internal camera HAL error occurred, and the
40*4d7e907cSAndroid Build Coastguard Worker     *         resource cost is not available.
41*4d7e907cSAndroid Build Coastguard Worker     *     CAMERA_DISCONNECTED:
42*4d7e907cSAndroid Build Coastguard Worker     *         An external camera device has been disconnected, and is no longer
43*4d7e907cSAndroid Build Coastguard Worker     *         available. This camera device interface is now stale, and a new
44*4d7e907cSAndroid Build Coastguard Worker     *         instance must be acquired if the device is reconnected. All
45*4d7e907cSAndroid Build Coastguard Worker     *         subsequent calls on this interface must return
46*4d7e907cSAndroid Build Coastguard Worker     *         CAMERA_DISCONNECTED.
47*4d7e907cSAndroid Build Coastguard Worker     * @return resourceCost
48*4d7e907cSAndroid Build Coastguard Worker     *     The resources required to open this camera device, or unspecified
49*4d7e907cSAndroid Build Coastguard Worker     *     values if status is not OK.
50*4d7e907cSAndroid Build Coastguard Worker     */
51*4d7e907cSAndroid Build Coastguard Worker    getResourceCost() generates (Status status, CameraResourceCost resourceCost);
52*4d7e907cSAndroid Build Coastguard Worker
53*4d7e907cSAndroid Build Coastguard Worker    /**
54*4d7e907cSAndroid Build Coastguard Worker     * getCameraCharacteristics:
55*4d7e907cSAndroid Build Coastguard Worker     *
56*4d7e907cSAndroid Build Coastguard Worker     * Return the static camera information for this camera device. This
57*4d7e907cSAndroid Build Coastguard Worker     * information may not change between consecutive calls.
58*4d7e907cSAndroid Build Coastguard Worker     *
59*4d7e907cSAndroid Build Coastguard Worker     * When an external camera is disconnected, its camera id becomes
60*4d7e907cSAndroid Build Coastguard Worker     * invalid. Calling this method with this invalid camera id must result in
61*4d7e907cSAndroid Build Coastguard Worker     * ILLEGAL_ARGUMENT; this may happen even before the device status callback
62*4d7e907cSAndroid Build Coastguard Worker     * is invoked by the HAL.
63*4d7e907cSAndroid Build Coastguard Worker     *
64*4d7e907cSAndroid Build Coastguard Worker     * @return status Status code for the operation, one of:
65*4d7e907cSAndroid Build Coastguard Worker     *     OK:
66*4d7e907cSAndroid Build Coastguard Worker     *         On a successful open of the camera device.
67*4d7e907cSAndroid Build Coastguard Worker     *     INTERNAL_ERROR:
68*4d7e907cSAndroid Build Coastguard Worker     *         The camera device cannot be opened due to an internal
69*4d7e907cSAndroid Build Coastguard Worker     *         error.
70*4d7e907cSAndroid Build Coastguard Worker     *     CAMERA_DISCONNECTED:
71*4d7e907cSAndroid Build Coastguard Worker     *         An external camera device has been disconnected, and is no longer
72*4d7e907cSAndroid Build Coastguard Worker     *         available. This camera device interface is now stale, and a new
73*4d7e907cSAndroid Build Coastguard Worker     *         instance must be acquired if the device is reconnected. All
74*4d7e907cSAndroid Build Coastguard Worker     *         subsequent calls on this interface must return
75*4d7e907cSAndroid Build Coastguard Worker     *         CAMERA_DISCONNECTED.
76*4d7e907cSAndroid Build Coastguard Worker     *
77*4d7e907cSAndroid Build Coastguard Worker     * @return cameraCharacteristics
78*4d7e907cSAndroid Build Coastguard Worker     *     The static metadata for this camera device, or an empty metadata
79*4d7e907cSAndroid Build Coastguard Worker     *     structure if status is not OK.
80*4d7e907cSAndroid Build Coastguard Worker     *
81*4d7e907cSAndroid Build Coastguard Worker     */
82*4d7e907cSAndroid Build Coastguard Worker    getCameraCharacteristics() generates
83*4d7e907cSAndroid Build Coastguard Worker            (Status status, CameraMetadata cameraCharacteristics);
84*4d7e907cSAndroid Build Coastguard Worker
85*4d7e907cSAndroid Build Coastguard Worker    /**
86*4d7e907cSAndroid Build Coastguard Worker     * setTorchMode:
87*4d7e907cSAndroid Build Coastguard Worker     *
88*4d7e907cSAndroid Build Coastguard Worker     * Turn on or off the torch mode of the flash unit associated with this
89*4d7e907cSAndroid Build Coastguard Worker     * camera device. If the operation is successful, HAL must notify the
90*4d7e907cSAndroid Build Coastguard Worker     * framework torch state by invoking
91*4d7e907cSAndroid Build Coastguard Worker     * ICameraProviderCallback::torchModeStatusChange() with the new state.
92*4d7e907cSAndroid Build Coastguard Worker     *
93*4d7e907cSAndroid Build Coastguard Worker     * An active camera session has a higher priority accessing the flash
94*4d7e907cSAndroid Build Coastguard Worker     * unit. When there are any resource conflicts, such as when open() is
95*4d7e907cSAndroid Build Coastguard Worker     * called to fully activate a camera device, the provider must notify the
96*4d7e907cSAndroid Build Coastguard Worker     * framework through ICameraProviderCallback::torchModeStatusChange() that
97*4d7e907cSAndroid Build Coastguard Worker     * the torch mode has been turned off and the torch mode state has become
98*4d7e907cSAndroid Build Coastguard Worker     * TORCH_MODE_STATUS_NOT_AVAILABLE. When resources to turn on torch mode
99*4d7e907cSAndroid Build Coastguard Worker     * become available again, the provider must notify the framework through
100*4d7e907cSAndroid Build Coastguard Worker     * ICameraProviderCallback::torchModeStatusChange() that the torch mode
101*4d7e907cSAndroid Build Coastguard Worker     * state has become TORCH_MODE_STATUS_AVAILABLE_OFF for set_torch_mode() to
102*4d7e907cSAndroid Build Coastguard Worker     * be called.
103*4d7e907cSAndroid Build Coastguard Worker     *
104*4d7e907cSAndroid Build Coastguard Worker     * When the client calls setTorchMode() to turn on the torch mode of a flash
105*4d7e907cSAndroid Build Coastguard Worker     * unit, if the HAL cannot keep multiple torch modes on simultaneously, the
106*4d7e907cSAndroid Build Coastguard Worker     * HAL must turn off the torch mode(s) that were turned on by previous
107*4d7e907cSAndroid Build Coastguard Worker     * setTorchMode() calls and notify the framework that the torch mode state
108*4d7e907cSAndroid Build Coastguard Worker     * of those flash unit(s) has become TORCH_MODE_STATUS_AVAILABLE_OFF.
109*4d7e907cSAndroid Build Coastguard Worker     *
110*4d7e907cSAndroid Build Coastguard Worker     * @param torchMode The new mode to set the device flash unit to.
111*4d7e907cSAndroid Build Coastguard Worker     *
112*4d7e907cSAndroid Build Coastguard Worker     * @return status Status code for the operation, one of:
113*4d7e907cSAndroid Build Coastguard Worker     *     OK:
114*4d7e907cSAndroid Build Coastguard Worker     *         On a successful change to the torch state
115*4d7e907cSAndroid Build Coastguard Worker     *     INTERNAL_ERROR:
116*4d7e907cSAndroid Build Coastguard Worker     *         The flash unit cannot be operated due to an unexpected internal
117*4d7e907cSAndroid Build Coastguard Worker     *         error.
118*4d7e907cSAndroid Build Coastguard Worker     *     ILLEGAL_ARGUMENT:
119*4d7e907cSAndroid Build Coastguard Worker     *         The camera ID is unknown.
120*4d7e907cSAndroid Build Coastguard Worker     *     CAMERA_IN_USE:
121*4d7e907cSAndroid Build Coastguard Worker     *         This camera device has been opened, so the torch cannot be
122*4d7e907cSAndroid Build Coastguard Worker     *         controlled until it is closed.
123*4d7e907cSAndroid Build Coastguard Worker     *     MAX_CAMERAS_IN_USE:
124*4d7e907cSAndroid Build Coastguard Worker     *         Due to other camera devices being open, or due to other
125*4d7e907cSAndroid Build Coastguard Worker     *         resource constraints, the torch cannot be controlled currently.
126*4d7e907cSAndroid Build Coastguard Worker     *     METHOD_NOT_SUPPORTED:
127*4d7e907cSAndroid Build Coastguard Worker     *         This provider does not support direct operation of flashlight
128*4d7e907cSAndroid Build Coastguard Worker     *         torch mode. The framework must open the camera device and turn
129*4d7e907cSAndroid Build Coastguard Worker     *         the torch on through the device interface.
130*4d7e907cSAndroid Build Coastguard Worker     *     OPERATION_NOT_SUPPORTED:
131*4d7e907cSAndroid Build Coastguard Worker     *         This camera device does not have a flash unit. This can
132*4d7e907cSAndroid Build Coastguard Worker     *         be returned if and only if android.flash.info.available is
133*4d7e907cSAndroid Build Coastguard Worker     *         false.
134*4d7e907cSAndroid Build Coastguard Worker     *     CAMERA_DISCONNECTED:
135*4d7e907cSAndroid Build Coastguard Worker     *         An external camera device has been disconnected, and is no longer
136*4d7e907cSAndroid Build Coastguard Worker     *         available. This camera device interface is now stale, and a new
137*4d7e907cSAndroid Build Coastguard Worker     *         instance must be acquired if the device is reconnected. All
138*4d7e907cSAndroid Build Coastguard Worker     *         subsequent calls on this interface must return
139*4d7e907cSAndroid Build Coastguard Worker     *         CAMERA_DISCONNECTED.
140*4d7e907cSAndroid Build Coastguard Worker     *
141*4d7e907cSAndroid Build Coastguard Worker     */
142*4d7e907cSAndroid Build Coastguard Worker    setTorchMode(TorchMode mode) generates (Status status);
143*4d7e907cSAndroid Build Coastguard Worker
144*4d7e907cSAndroid Build Coastguard Worker    /**
145*4d7e907cSAndroid Build Coastguard Worker     * open:
146*4d7e907cSAndroid Build Coastguard Worker     *
147*4d7e907cSAndroid Build Coastguard Worker     * Power on and initialize this camera device for active use, returning a
148*4d7e907cSAndroid Build Coastguard Worker     * session handle for active operations.
149*4d7e907cSAndroid Build Coastguard Worker     *
150*4d7e907cSAndroid Build Coastguard Worker     * @param callback Interface to invoke by the HAL for device asynchronous
151*4d7e907cSAndroid Build Coastguard Worker     *     events. For HALs newer than version 3.2, HAL must use castFrom
152*4d7e907cSAndroid Build Coastguard Worker     *     method to check the exact version of callback sent by camera service.
153*4d7e907cSAndroid Build Coastguard Worker     *
154*4d7e907cSAndroid Build Coastguard Worker     * @return status Status code for the operation, one of:
155*4d7e907cSAndroid Build Coastguard Worker     *     OK:
156*4d7e907cSAndroid Build Coastguard Worker     *         On a successful open of the camera device.
157*4d7e907cSAndroid Build Coastguard Worker     *     INTERNAL_ERROR:
158*4d7e907cSAndroid Build Coastguard Worker     *         The camera device cannot be opened due to an internal
159*4d7e907cSAndroid Build Coastguard Worker     *         error.
160*4d7e907cSAndroid Build Coastguard Worker     *     ILLEGAL_ARGUMENT:
161*4d7e907cSAndroid Build Coastguard Worker     *         The callbacks handle is invalid (for example, it is null).
162*4d7e907cSAndroid Build Coastguard Worker     *     CAMERA_IN_USE:
163*4d7e907cSAndroid Build Coastguard Worker     *         This camera device is already open.
164*4d7e907cSAndroid Build Coastguard Worker     *     MAX_CAMERAS_IN_USE:
165*4d7e907cSAndroid Build Coastguard Worker     *         The maximal number of camera devices that can be
166*4d7e907cSAndroid Build Coastguard Worker     *         opened concurrently were opened already.
167*4d7e907cSAndroid Build Coastguard Worker     *     CAMERA_DISCONNECTED:
168*4d7e907cSAndroid Build Coastguard Worker     *         This external camera device has been disconnected, and is no
169*4d7e907cSAndroid Build Coastguard Worker     *         longer available. This interface is now stale, and a new instance
170*4d7e907cSAndroid Build Coastguard Worker     *         must be acquired if the device is reconnected. All subsequent
171*4d7e907cSAndroid Build Coastguard Worker     *         calls on this interface must return CAMERA_DISCONNECTED.
172*4d7e907cSAndroid Build Coastguard Worker     * @return session The interface to the newly-opened camera session,
173*4d7e907cSAndroid Build Coastguard Worker     *     or null if status is not OK.
174*4d7e907cSAndroid Build Coastguard Worker     */
175*4d7e907cSAndroid Build Coastguard Worker    open(ICameraDeviceCallback callback) generates
176*4d7e907cSAndroid Build Coastguard Worker            (Status status, ICameraDeviceSession session);
177*4d7e907cSAndroid Build Coastguard Worker
178*4d7e907cSAndroid Build Coastguard Worker    /**
179*4d7e907cSAndroid Build Coastguard Worker     * dumpState:
180*4d7e907cSAndroid Build Coastguard Worker     *
181*4d7e907cSAndroid Build Coastguard Worker     * Print out debugging state for the camera device. This may be called by
182*4d7e907cSAndroid Build Coastguard Worker     * the framework when the camera service is asked for a debug dump, which
183*4d7e907cSAndroid Build Coastguard Worker     * happens when using the dumpsys tool, or when capturing a bugreport.
184*4d7e907cSAndroid Build Coastguard Worker     *
185*4d7e907cSAndroid Build Coastguard Worker     * The passed-in file descriptor can be used to write debugging text using
186*4d7e907cSAndroid Build Coastguard Worker     * dprintf() or write(). The text must be in ASCII encoding only.
187*4d7e907cSAndroid Build Coastguard Worker     *
188*4d7e907cSAndroid Build Coastguard Worker     * In case this camera device has been disconnected, the dump must not fail,
189*4d7e907cSAndroid Build Coastguard Worker     * but may simply print out 'Device disconnected' or equivalent.
190*4d7e907cSAndroid Build Coastguard Worker     *
191*4d7e907cSAndroid Build Coastguard Worker     * Performance requirements:
192*4d7e907cSAndroid Build Coastguard Worker     *
193*4d7e907cSAndroid Build Coastguard Worker     * This must be a non-blocking call. The HAL should return from this call
194*4d7e907cSAndroid Build Coastguard Worker     * in 1ms, must return from this call in 10ms. This call must avoid
195*4d7e907cSAndroid Build Coastguard Worker     * deadlocks, as it may be called at any point during camera operation.
196*4d7e907cSAndroid Build Coastguard Worker     * Any synchronization primitives used (such as mutex locks or semaphores)
197*4d7e907cSAndroid Build Coastguard Worker     * must be acquired with a timeout.
198*4d7e907cSAndroid Build Coastguard Worker     */
199*4d7e907cSAndroid Build Coastguard Worker    dumpState(handle fd);
200*4d7e907cSAndroid Build Coastguard Worker
201*4d7e907cSAndroid Build Coastguard Worker};
202