Alex Ray | 7ee0b7a | 2012-11-06 00:12:49 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 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 | |
| 17 | #ifndef CAMERA_H_ |
| 18 | #define CAMERA_H_ |
| 19 | |
| 20 | #include <pthread.h> |
Alex Ray | a0ed4be | 2013-02-25 15:02:16 -0800 | [diff] [blame] | 21 | #include <hardware/hardware.h> |
| 22 | #include <hardware/camera3.h> |
Alex Ray | 7ee0b7a | 2012-11-06 00:12:49 -0800 | [diff] [blame] | 23 | |
| 24 | namespace default_camera_hal { |
| 25 | // Camera represents a physical camera on a device. |
| 26 | // This is constructed when the HAL module is loaded, one per physical camera. |
| 27 | // It is opened by the framework, and must be closed before it can be opened |
| 28 | // again. |
Alex Ray | 7ee0b7a | 2012-11-06 00:12:49 -0800 | [diff] [blame] | 29 | class Camera { |
| 30 | public: |
| 31 | // id is used to distinguish cameras. 0 <= id < NUM_CAMERAS. |
| 32 | // module is a handle to the HAL module, used when the device is opened. |
Alex Ray | a0ed4be | 2013-02-25 15:02:16 -0800 | [diff] [blame] | 33 | Camera(int id); |
Alex Ray | 7ee0b7a | 2012-11-06 00:12:49 -0800 | [diff] [blame] | 34 | ~Camera(); |
Alex Ray | a48dd3f | 2012-12-19 12:21:38 -0800 | [diff] [blame] | 35 | |
| 36 | // Common Camera Device Operations (see <hardware/camera_common.h>) |
Alex Ray | a0ed4be | 2013-02-25 15:02:16 -0800 | [diff] [blame] | 37 | int open(const hw_module_t *module, hw_device_t **device); |
Alex Ray | a48dd3f | 2012-12-19 12:21:38 -0800 | [diff] [blame] | 38 | int close(); |
Alex Ray | a0ed4be | 2013-02-25 15:02:16 -0800 | [diff] [blame] | 39 | |
| 40 | // Camera v3 Device Operations (see <hardware/camera3.h>) |
| 41 | int initialize(const camera3_callback_ops_t *callback_ops); |
| 42 | int configureStreams(camera3_stream_configuration_t *stream_list); |
| 43 | int registerStreamBuffers(const camera3_stream_buffer_set_t *buf_set); |
| 44 | const camera_metadata_t *constructDefaultRequestSettings(int type); |
| 45 | int processCaptureRequest(camera3_capture_request_t *request); |
| 46 | void getMetadataVendorTagOps(vendor_tag_query_ops_t *ops); |
| 47 | void dump(int fd); |
| 48 | |
| 49 | // Camera device handle returned to framework for use |
| 50 | camera3_device_t mDevice; |
Alex Ray | a48dd3f | 2012-12-19 12:21:38 -0800 | [diff] [blame] | 51 | |
Alex Ray | 7ee0b7a | 2012-11-06 00:12:49 -0800 | [diff] [blame] | 52 | private: |
Alex Ray | 7ee0b7a | 2012-11-06 00:12:49 -0800 | [diff] [blame] | 53 | // Identifier used by framework to distinguish cameras |
Alex Ray | 1f8af67 | 2013-02-28 15:40:08 -0800 | [diff] [blame] | 54 | const int mId; |
Alex Ray | a0ed4be | 2013-02-25 15:02:16 -0800 | [diff] [blame] | 55 | // Busy flag indicates camera is in use |
Alex Ray | 7ee0b7a | 2012-11-06 00:12:49 -0800 | [diff] [blame] | 56 | bool mBusy; |
Alex Ray | a0ed4be | 2013-02-25 15:02:16 -0800 | [diff] [blame] | 57 | // Camera device operations handle shared by all devices |
| 58 | const static camera3_device_ops_t sOps; |
| 59 | // Methods used to call back into the framework |
| 60 | const camera3_callback_ops_t *mCallbackOps; |
Alex Ray | 7ee0b7a | 2012-11-06 00:12:49 -0800 | [diff] [blame] | 61 | // Lock protecting the Camera object for modifications |
| 62 | pthread_mutex_t mMutex; |
| 63 | }; |
| 64 | } // namespace default_camera_hal |
| 65 | |
| 66 | #endif // CAMERA_H_ |