summaryrefslogtreecommitdiffstats
path: root/camera/device/1.0/ICameraDevice.hal
blob: d232a672a74e7acaae975aa0ccc07f5e56ac01ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.hardware.camera.device@1.0;

import android.hardware.camera.common@1.0::types;
import ICameraDeviceCallback;
import ICameraDevicePreviewCallback;

/**
 * Camera device HAL, legacy version
 *
 * DEPRECATED. New devices are strongly recommended to use Camera HAL v3.2 or
 * newer.
 *
 * Supports the android.hardware.Camera API, and the android.hardware.camera2
 * API in LEGACY mode only.
 *
 * Will be removed in the Android P release.
 */
interface ICameraDevice {

    /**
     * Get camera device resource cost information.
     *
     * This method may be called at any time, including before open()
     *
     * @return status Status code for the operation, one of:
     *     OK:
     *         On success.
     *     INTERNAL_ERROR:
     *         An unexpected internal camera HAL error occurred, and the
     *         resource cost is not available.
     *     CAMERA_DISCONNECTED:
     *         An external camera device has been disconnected, and is no longer
     *         available. This camera device interface is now stale, and a new
     *         instance must be acquired if the device is reconnected. All
     *         subsequent calls on this interface must return
     *         CAMERA_DISCONNECTED.
     * @return resourceCost
     *     The resources required to open this camera device, or unspecified
     *     values if status is not OK.
     */
    getResourceCost() generates (Status status, CameraResourceCost resourceCost);

    /**
     * Get basic camera information.
     *
     * This method may be called at any time, including before open()
     *
     * @return status Status code for the operation, one of:
     *     OK:
     *         On success.
     *     INTERNAL_ERROR:
     *         An unexpected internal camera HAL error occurred, and the
     *         camera information is not available.
     *     CAMERA_DISCONNECTED:
     *         An external camera device has been disconnected, and is no longer
     *         available. This camera device interface is now stale, and a new
     *         instance must be acquired if the device is reconnected. All
     *         subsequent calls on this interface must return
     *         CAMERA_DISCONNECTED.
     * @return info Basic information about this camera device, or unspecified
     *     values if status is not OK.
     */
    getCameraInfo() generates (Status status, CameraInfo info);

    /**
     * setTorchMode:
     *
     * Turn on or off the torch mode of the flash unit associated with a given
     * camera ID. If the operation is successful, HAL must notify the framework
     * torch state by invoking
     * ICameraProviderCallback::torchModeStatusChange() with the new state.
     *
     * The camera device has a higher priority accessing the flash unit. When
     * there are any resource conflicts, such as when open() is called to fully
     * activate a camera device, the provider must notify the framework through
     * ICameraProviderCallback::torchModeStatusChange() that the torch mode has
     * been turned off and the torch mode state has become
     * TORCH_MODE_STATUS_NOT_AVAILABLE. When resources to turn on torch mode
     * become available again, the provider must notify the framework through
     * ICameraProviderCallback::torchModeStatusChange() that the torch mode
     * state has become TORCH_MODE_STATUS_AVAILABLE_OFF for set_torch_mode() to
     * be called.
     *
     * When the framework calls setTorchMode() to turn on the torch mode of a
     * flash unit, if HAL cannot keep multiple torch modes on simultaneously,
     * HAL must turn off the torch mode that was turned on by
     * a previous setTorchMode() call and notify the framework that the torch
     * mode state of that flash unit has become TORCH_MODE_STATUS_AVAILABLE_OFF.
     *
     * @param torchMode The new mode to set the device flash unit to.
     *
     * @return status Status code for the operation, one of:
     *     OK:
     *         On a successful change to the torch state.
     *     INTERNAL_ERROR:
     *         The flash unit cannot be operated due to an unexpected internal
     *         error.
     *     ILLEGAL_ARGUMENT:
     *         The camera ID is unknown.
     *     CAMERA_IN_USE:
     *         This camera device has been opened, so the torch cannot be
     *         controlled until it is closed.
     *     MAX_CAMERAS_IN_USE:
     *         Due to other camera devices being open, or due to other
     *         resource constraints, the torch cannot be controlled currently.
     *     METHOD_NOT_SUPPORTED:
     *         This provider does not support direct operation of flashlight
     *         torch mode. The framework must open the camera device and turn
     *         the torch on through the device interface.
     *     OPERATION_NOT_SUPPORTED:
     *         This camera device does not have a flash unit. This must
     *         be returned if and only if android.flash.info.available is
     *         false.
     *     CAMERA_DISCONNECTED:
     *         An external camera device has been disconnected, and is no longer
     *         available. This camera device interface is now stale, and a new
     *         instance must be acquired if the device is reconnected. All
     *         subsequent calls on this interface must return
     *         CAMERA_DISCONNECTED.
     *
     */
    setTorchMode(TorchMode mode) generates (Status status);

    /**
     * Dump state of the camera hardware.
     *
     * This must be callable at any time, whether the device is open or not.
     *
     * @param fd A native handle with one valid file descriptor. The descriptor
     *     must be able to be used with dprintf() or equivalent to dump the
     *     state of this camera device into the camera service dumpsys output.
     *
     * @return status The status code for this operation.
     */
    dumpState(handle fd) generates (Status status);

    /**
     * Open the camera device for active use.
     *
     * All methods besides getResourceCost(), getCameraInfo(), setTorchMode(),
     * and dump() must not be called unless open() has been called successfully,
     * and close() has not yet been called.
     *
     * @param callback Interface to invoke by the HAL for device callbacks.
     * @return status Status code for the operation, one of:
     *     OK:
     *         On a successful open of the camera device.
     *     INTERNAL_ERROR:
     *         The camera device cannot be opened due to an internal
     *         error.
     *     ILLEGAL_ARGUMENT:
     *         The callback handle is invalid (for example, it is null).
     *     CAMERA_IN_USE:
     *         This camera device is already open.
     *     MAX_CAMERAS_IN_USE:
     *         The maximal number of camera devices that can be
     *         opened concurrently were opened already.
     *     CAMERA_DISCONNECTED:
     *         This external camera device has been disconnected, and is no
     *         longer available. This interface is now stale, and a new instance
     *         must be acquired if the device is reconnected. All subsequent
     *         calls on this interface must return CAMERA_DISCONNECTED.
     */
    open(ICameraDeviceCallback callback) generates (Status status);


    /*****
     * All methods below this point must only be called between a successful
     * open() call and a close() call.
     */

    /** Set the callback interface through which preview frames are sent */
    setPreviewWindow(ICameraDevicePreviewCallback window)
            generates (Status status);

    /**
     * Enable a message, or set of messages.
     *
     * @param msgType The bitfield of messages to enable.
     */
    enableMsgType(FrameCallbackFlags msgType);

    /**
     * Disable a message, or a set of messages.
     *
     * Once received a call to disableMsgType(CAMERA_MSG_VIDEO_FRAME), camera
     * HAL must not rely on its client to call releaseRecordingFrame() to
     * release video recording frames sent out by the cameral HAL before and
     * after the disableMsgType(CAMERA_MSG_VIDEO_FRAME) call. Camera HAL
     * clients must not modify/access any video recording frame after calling
     * disableMsgType(CAMERA_MSG_VIDEO_FRAME).
     *
     * @param msgType The bitfield of messages to disable.
     */
    disableMsgType(FrameCallbackFlags msgType);

    /**
     * Query whether a message, or a set of messages, is enabled. Note that
     * this is operates as an AND, if any of the messages queried are off, this
     * must return false.
     *
     * @param msgType The bitfield of messages to query.
     * @return enabled Whether all the specified flags are enabled.
     */
    msgTypeEnabled(FrameCallbackFlags msgType) generates (bool enabled);

    /**
     * Start preview mode.
     *
     * @return status The status code for this operation.
     */
    startPreview() generates (Status status);

    /**
     * Stop a previously started preview.
     */
    stopPreview();

    /**
     * Returns true if preview is enabled.
     *
     * @return enabled Whether preview is currently enabled.
     */
    previewEnabled() generates (bool enabled);

    /**
     * Request the camera HAL to store meta data or real YUV data in the video
     * buffers sent out via CAMERA_MSG_VIDEO_FRAME for a recording session. If
     * it is not called, the default camera HAL behavior is to store real YUV
     * data in the video buffers.
     *
     * This method must be called before startRecording() in order to be
     * effective.
     *
     * If meta data is stored in the video buffers, it is up to the receiver of
     * the video buffers to interpret the contents and to find the actual frame
     * data with the help of the meta data in the buffer. How this is done is
     * outside of the scope of this method.
     *
     * Some camera HALs may not support storing meta data in the video buffers,
     * but all camera HALs must support storing real YUV data in the video
     * buffers. If the camera HAL does not support storing the meta data in the
     * video buffers when it is requested to do do, INVALID_OPERATION must be
     * returned. It is very useful for the camera HAL to pass meta data rather
     * than the actual frame data directly to the video encoder, since the
     * amount of the uncompressed frame data can be very large if video size is
     * large.
     *
     * @param enable Set to true to instruct the camera HAL to store meta data
     *     in the video buffers; false to instruct the camera HAL to store real
     *     YUV data in the video buffers.
     *
     * @return status OK on success.
     */
    storeMetaDataInBuffers(bool enable) generates (Status status);

    /**
     * Start record mode.
     *
     * When a record image is available, a CAMERA_MSG_VIDEO_FRAME message is
     * sent with the corresponding frame. Every record frame must be released by
     * a camera HAL client via releaseRecordingFrame() before the client calls
     * disableMsgType(CAMERA_MSG_VIDEO_FRAME). After the client calls
     * disableMsgType(CAMERA_MSG_VIDEO_FRAME), it is the camera HAL's
     * responsibility to manage the life-cycle of the video recording frames,
     * and the client must not modify/access any video recording frames.
     *
     * @return status The status code for the operation.
     */
    startRecording() generates (Status status);

    /**
     * Stop a previously started recording.
     */
    stopRecording();

    /**
     * Returns true if recording is enabled.
     *
     * @return enabled True if recording is currently active.
     */
    recordingEnabled() generates (bool enabled);

    /**
     * Release a record frame previously returned by CAMERA_MSG_VIDEO_FRAME.
     *
     * It is camera HAL client's responsibility to release video recording
     * frames sent out by the camera HAL before the camera HAL receives a call
     * to disableMsgType(CAMERA_MSG_VIDEO_FRAME). After it receives the call to
     * disableMsgType(CAMERA_MSG_VIDEO_FRAME), it is the camera HAL's
     * responsibility to manage the life-cycle of the video recording frames.
     *
     * @param data The memory buffer to release a recording frame from.
     * @param bufferIndex The specific buffer index to return to the HAL.
     */
    releaseRecordingFrame(MemoryId data, uint32_t bufferIndex);

    /**
     * Start auto focus.
     *
     * The notification callback routine is called with
     * CAMERA_MSG_FOCUS once when focusing is complete. autoFocus() can be
     * called again after that if another auto focus is needed.
     *
     * @return status The status code for this operation.
     */
    autoFocus() generates (Status status);

    /**
     * Cancels auto-focus function.
     *
     * If the auto-focus is still in progress, this function must cancel
     * it. Whether the auto-focus is in progress or not, this function must
     * return the focus position to the default. If the camera does not support
     * auto-focus, this is a no-op.
     *
     * @return status The status code for this operation.
     */
    cancelAutoFocus() generates (Status status);

    /**
     * Take a picture.
     *
     * @return status The status code for this operation.
     */
    takePicture() generates (Status status);

    /**
     * Cancel a picture that was started with takePicture. Calling this method
     * when no picture is being taken is a no-op.
     *
     * @return status The status code for this operation.
     */
    cancelPicture() generates (Status status);

    /**
     * Set the camera parameters.
     *
     * @param parms The parameter string, consisting of
     *    '<key1>=<value1>; ...;<keyN>=<valueN>'.
     * @return status The status code for this operation:
     *     OK: Parameter update was successful
     *     ILLEGAL_ARGUMENT: At least one parameter was invalid or not supported
     *
     */
    setParameters(string parms) generates (Status status);

    /**
     * Retrieve the camera parameters.
     */
    getParameters() generates (string parms);

    /**
     * Send command to camera driver.
     * The meaning of the arguments is defined by the value of cmd, documented
     * in the CommandType definition.
     *
     * @param cmd The command to invoke.
     * @param arg1 The first argument for the command, if needed.
     * @param arg2 The second argument for the command, if needed.
     *
     * @return status The status code for this operation.
     */
    sendCommand(CommandType cmd, int32_t arg1, int32_t arg2)
            generates (Status status);

    /**
     * Release the hardware resources owned by this object, shutting down the
     * camera device.
     */
    close();

};