/* * 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 parameter key flash-mode-values is not present. * 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 in * dataCallbackTimestamp. * * 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 memId The memory buffer to release a recording frame from. * @param bufferIndex The specific buffer index to return to the HAL. */ releaseRecordingFrame(MemoryId memId, uint32_t bufferIndex); /** * Release a record frame previously returned by CAMERA_MSG_VIDEO_FRAME in * handleCallbackTimestamp. * * 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 memId The memory buffer to release a recording frame from. * @param bufferIndex The specific buffer index to return to the HAL. * @param frame The handle for a released video frame */ releaseRecordingFrameHandle(MemoryId memId, uint32_t bufferIndex, handle frame); /** * Release a batch of record frames previously returned by CAMERA_MSG_VIDEO_FRAME * in handleCallbackTimestampBatch. * * 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 batch A batch of recording frames to be released by camera HAL. */ releaseRecordingFrameHandleBatch(vec batch); /** * 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 params The parameter string, consisting of * '=; ...;='. * @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 params) 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(); };