blob: d232a672a74e7acaae975aa0ccc07f5e56ac01ea [file] [log] [blame]
Zhijun He8486e412016-09-12 15:30:51 -07001/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.hardware.camera.device@1.0;
18
19import android.hardware.camera.common@1.0::types;
20import ICameraDeviceCallback;
21import ICameraDevicePreviewCallback;
22
23/**
24 * Camera device HAL, legacy version
25 *
26 * DEPRECATED. New devices are strongly recommended to use Camera HAL v3.2 or
27 * newer.
28 *
29 * Supports the android.hardware.Camera API, and the android.hardware.camera2
30 * API in LEGACY mode only.
31 *
32 * Will be removed in the Android P release.
33 */
34interface ICameraDevice {
35
36 /**
37 * Get camera device resource cost information.
38 *
39 * This method may be called at any time, including before open()
40 *
41 * @return status Status code for the operation, one of:
42 * OK:
43 * On success.
44 * INTERNAL_ERROR:
45 * An unexpected internal camera HAL error occurred, and the
46 * resource cost is not available.
47 * CAMERA_DISCONNECTED:
48 * An external camera device has been disconnected, and is no longer
49 * available. This camera device interface is now stale, and a new
50 * instance must be acquired if the device is reconnected. All
51 * subsequent calls on this interface must return
52 * CAMERA_DISCONNECTED.
53 * @return resourceCost
54 * The resources required to open this camera device, or unspecified
55 * values if status is not OK.
56 */
57 getResourceCost() generates (Status status, CameraResourceCost resourceCost);
58
59 /**
60 * Get basic camera information.
61 *
62 * This method may be called at any time, including before open()
63 *
64 * @return status Status code for the operation, one of:
65 * OK:
66 * On success.
67 * INTERNAL_ERROR:
68 * An unexpected internal camera HAL error occurred, and the
69 * camera information is not available.
70 * CAMERA_DISCONNECTED:
71 * An external camera device has been disconnected, and is no longer
72 * available. This camera device interface is now stale, and a new
73 * instance must be acquired if the device is reconnected. All
74 * subsequent calls on this interface must return
75 * CAMERA_DISCONNECTED.
76 * @return info Basic information about this camera device, or unspecified
77 * values if status is not OK.
78 */
79 getCameraInfo() generates (Status status, CameraInfo info);
80
81 /**
82 * setTorchMode:
83 *
84 * Turn on or off the torch mode of the flash unit associated with a given
85 * camera ID. If the operation is successful, HAL must notify the framework
86 * torch state by invoking
87 * ICameraProviderCallback::torchModeStatusChange() with the new state.
88 *
89 * The camera device has a higher priority accessing the flash unit. When
90 * there are any resource conflicts, such as when open() is called to fully
91 * activate a camera device, the provider must notify the framework through
92 * ICameraProviderCallback::torchModeStatusChange() that the torch mode has
93 * been turned off and the torch mode state has become
94 * TORCH_MODE_STATUS_NOT_AVAILABLE. When resources to turn on torch mode
95 * become available again, the provider must notify the framework through
96 * ICameraProviderCallback::torchModeStatusChange() that the torch mode
97 * state has become TORCH_MODE_STATUS_AVAILABLE_OFF for set_torch_mode() to
98 * be called.
99 *
100 * When the framework calls setTorchMode() to turn on the torch mode of a
101 * flash unit, if HAL cannot keep multiple torch modes on simultaneously,
102 * HAL must turn off the torch mode that was turned on by
103 * a previous setTorchMode() call and notify the framework that the torch
104 * mode state of that flash unit has become TORCH_MODE_STATUS_AVAILABLE_OFF.
105 *
106 * @param torchMode The new mode to set the device flash unit to.
107 *
108 * @return status Status code for the operation, one of:
109 * OK:
110 * On a successful change to the torch state.
111 * INTERNAL_ERROR:
112 * The flash unit cannot be operated due to an unexpected internal
113 * error.
114 * ILLEGAL_ARGUMENT:
115 * The camera ID is unknown.
116 * CAMERA_IN_USE:
117 * This camera device has been opened, so the torch cannot be
118 * controlled until it is closed.
119 * MAX_CAMERAS_IN_USE:
120 * Due to other camera devices being open, or due to other
121 * resource constraints, the torch cannot be controlled currently.
122 * METHOD_NOT_SUPPORTED:
123 * This provider does not support direct operation of flashlight
124 * torch mode. The framework must open the camera device and turn
125 * the torch on through the device interface.
126 * OPERATION_NOT_SUPPORTED:
127 * This camera device does not have a flash unit. This must
128 * be returned if and only if android.flash.info.available is
129 * false.
130 * CAMERA_DISCONNECTED:
131 * An external camera device has been disconnected, and is no longer
132 * available. This camera device interface is now stale, and a new
133 * instance must be acquired if the device is reconnected. All
134 * subsequent calls on this interface must return
135 * CAMERA_DISCONNECTED.
136 *
137 */
138 setTorchMode(TorchMode mode) generates (Status status);
139
140 /**
141 * Dump state of the camera hardware.
142 *
143 * This must be callable at any time, whether the device is open or not.
144 *
145 * @param fd A native handle with one valid file descriptor. The descriptor
146 * must be able to be used with dprintf() or equivalent to dump the
147 * state of this camera device into the camera service dumpsys output.
148 *
149 * @return status The status code for this operation.
150 */
151 dumpState(handle fd) generates (Status status);
152
153 /**
154 * Open the camera device for active use.
155 *
156 * All methods besides getResourceCost(), getCameraInfo(), setTorchMode(),
157 * and dump() must not be called unless open() has been called successfully,
158 * and close() has not yet been called.
159 *
160 * @param callback Interface to invoke by the HAL for device callbacks.
161 * @return status Status code for the operation, one of:
162 * OK:
163 * On a successful open of the camera device.
164 * INTERNAL_ERROR:
165 * The camera device cannot be opened due to an internal
166 * error.
167 * ILLEGAL_ARGUMENT:
168 * The callback handle is invalid (for example, it is null).
169 * CAMERA_IN_USE:
170 * This camera device is already open.
171 * MAX_CAMERAS_IN_USE:
172 * The maximal number of camera devices that can be
173 * opened concurrently were opened already.
174 * CAMERA_DISCONNECTED:
175 * This external camera device has been disconnected, and is no
176 * longer available. This interface is now stale, and a new instance
177 * must be acquired if the device is reconnected. All subsequent
178 * calls on this interface must return CAMERA_DISCONNECTED.
179 */
180 open(ICameraDeviceCallback callback) generates (Status status);
181
182
183 /*****
184 * All methods below this point must only be called between a successful
185 * open() call and a close() call.
186 */
187
188 /** Set the callback interface through which preview frames are sent */
189 setPreviewWindow(ICameraDevicePreviewCallback window)
190 generates (Status status);
191
192 /**
193 * Enable a message, or set of messages.
194 *
195 * @param msgType The bitfield of messages to enable.
196 */
197 enableMsgType(FrameCallbackFlags msgType);
198
199 /**
200 * Disable a message, or a set of messages.
201 *
202 * Once received a call to disableMsgType(CAMERA_MSG_VIDEO_FRAME), camera
203 * HAL must not rely on its client to call releaseRecordingFrame() to
204 * release video recording frames sent out by the cameral HAL before and
205 * after the disableMsgType(CAMERA_MSG_VIDEO_FRAME) call. Camera HAL
206 * clients must not modify/access any video recording frame after calling
207 * disableMsgType(CAMERA_MSG_VIDEO_FRAME).
208 *
209 * @param msgType The bitfield of messages to disable.
210 */
211 disableMsgType(FrameCallbackFlags msgType);
212
213 /**
214 * Query whether a message, or a set of messages, is enabled. Note that
215 * this is operates as an AND, if any of the messages queried are off, this
216 * must return false.
217 *
218 * @param msgType The bitfield of messages to query.
219 * @return enabled Whether all the specified flags are enabled.
220 */
221 msgTypeEnabled(FrameCallbackFlags msgType) generates (bool enabled);
222
223 /**
224 * Start preview mode.
225 *
226 * @return status The status code for this operation.
227 */
228 startPreview() generates (Status status);
229
230 /**
231 * Stop a previously started preview.
232 */
233 stopPreview();
234
235 /**
236 * Returns true if preview is enabled.
237 *
238 * @return enabled Whether preview is currently enabled.
239 */
240 previewEnabled() generates (bool enabled);
241
242 /**
243 * Request the camera HAL to store meta data or real YUV data in the video
244 * buffers sent out via CAMERA_MSG_VIDEO_FRAME for a recording session. If
245 * it is not called, the default camera HAL behavior is to store real YUV
246 * data in the video buffers.
247 *
248 * This method must be called before startRecording() in order to be
249 * effective.
250 *
251 * If meta data is stored in the video buffers, it is up to the receiver of
252 * the video buffers to interpret the contents and to find the actual frame
253 * data with the help of the meta data in the buffer. How this is done is
254 * outside of the scope of this method.
255 *
256 * Some camera HALs may not support storing meta data in the video buffers,
257 * but all camera HALs must support storing real YUV data in the video
258 * buffers. If the camera HAL does not support storing the meta data in the
259 * video buffers when it is requested to do do, INVALID_OPERATION must be
260 * returned. It is very useful for the camera HAL to pass meta data rather
261 * than the actual frame data directly to the video encoder, since the
262 * amount of the uncompressed frame data can be very large if video size is
263 * large.
264 *
265 * @param enable Set to true to instruct the camera HAL to store meta data
266 * in the video buffers; false to instruct the camera HAL to store real
267 * YUV data in the video buffers.
268 *
269 * @return status OK on success.
270 */
271 storeMetaDataInBuffers(bool enable) generates (Status status);
272
273 /**
274 * Start record mode.
275 *
276 * When a record image is available, a CAMERA_MSG_VIDEO_FRAME message is
277 * sent with the corresponding frame. Every record frame must be released by
278 * a camera HAL client via releaseRecordingFrame() before the client calls
279 * disableMsgType(CAMERA_MSG_VIDEO_FRAME). After the client calls
280 * disableMsgType(CAMERA_MSG_VIDEO_FRAME), it is the camera HAL's
281 * responsibility to manage the life-cycle of the video recording frames,
282 * and the client must not modify/access any video recording frames.
283 *
284 * @return status The status code for the operation.
285 */
286 startRecording() generates (Status status);
287
288 /**
289 * Stop a previously started recording.
290 */
291 stopRecording();
292
293 /**
294 * Returns true if recording is enabled.
295 *
296 * @return enabled True if recording is currently active.
297 */
298 recordingEnabled() generates (bool enabled);
299
300 /**
301 * Release a record frame previously returned by CAMERA_MSG_VIDEO_FRAME.
302 *
303 * It is camera HAL client's responsibility to release video recording
304 * frames sent out by the camera HAL before the camera HAL receives a call
305 * to disableMsgType(CAMERA_MSG_VIDEO_FRAME). After it receives the call to
306 * disableMsgType(CAMERA_MSG_VIDEO_FRAME), it is the camera HAL's
307 * responsibility to manage the life-cycle of the video recording frames.
308 *
309 * @param data The memory buffer to release a recording frame from.
310 * @param bufferIndex The specific buffer index to return to the HAL.
311 */
312 releaseRecordingFrame(MemoryId data, uint32_t bufferIndex);
313
314 /**
315 * Start auto focus.
316 *
317 * The notification callback routine is called with
318 * CAMERA_MSG_FOCUS once when focusing is complete. autoFocus() can be
319 * called again after that if another auto focus is needed.
320 *
321 * @return status The status code for this operation.
322 */
323 autoFocus() generates (Status status);
324
325 /**
326 * Cancels auto-focus function.
327 *
328 * If the auto-focus is still in progress, this function must cancel
329 * it. Whether the auto-focus is in progress or not, this function must
330 * return the focus position to the default. If the camera does not support
331 * auto-focus, this is a no-op.
332 *
333 * @return status The status code for this operation.
334 */
335 cancelAutoFocus() generates (Status status);
336
337 /**
338 * Take a picture.
339 *
340 * @return status The status code for this operation.
341 */
342 takePicture() generates (Status status);
343
344 /**
345 * Cancel a picture that was started with takePicture. Calling this method
346 * when no picture is being taken is a no-op.
347 *
348 * @return status The status code for this operation.
349 */
350 cancelPicture() generates (Status status);
351
352 /**
353 * Set the camera parameters.
354 *
355 * @param parms The parameter string, consisting of
356 * '<key1>=<value1>; ...;<keyN>=<valueN>'.
357 * @return status The status code for this operation:
358 * OK: Parameter update was successful
359 * ILLEGAL_ARGUMENT: At least one parameter was invalid or not supported
360 *
361 */
362 setParameters(string parms) generates (Status status);
363
364 /**
365 * Retrieve the camera parameters.
366 */
367 getParameters() generates (string parms);
368
369 /**
370 * Send command to camera driver.
371 * The meaning of the arguments is defined by the value of cmd, documented
372 * in the CommandType definition.
373 *
374 * @param cmd The command to invoke.
375 * @param arg1 The first argument for the command, if needed.
376 * @param arg2 The second argument for the command, if needed.
377 *
378 * @return status The status code for this operation.
379 */
380 sendCommand(CommandType cmd, int32_t arg1, int32_t arg2)
381 generates (Status status);
382
383 /**
384 * Release the hardware resources owned by this object, shutting down the
385 * camera device.
386 */
387 close();
388
389};