blob: ff5b0573d2fc6e0193a742c40c3f5da727eea636 [file] [log] [blame]
Eino-Ville Talvala61ab9f92012-05-17 10:30:54 -07001/*
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#define LOG_TAG "Camera2Device"
18//#define LOG_NDEBUG 0
19
20#include <utils/Log.h>
21#include "Camera2Device.h"
22
23namespace android {
24
25Camera2Device::Camera2Device(const char *name):
26 mName(name),
27 mDevice(NULL)
28{
29
30}
31
32Camera2Device::~Camera2Device()
33{
34 if (mDevice) {
35 status_t res;
36 res = mDevice->common.close(&mDevice->common);
37 if (res != OK) {
38 ALOGE("Could not close camera2 %s: %s (%d)",
39 mName, strerror(-res), res);
40 }
41 }
42}
43
44status_t Camera2Device::initialize(hw_module_t *module)
45{
46 status_t res;
47 res = module->methods->open(module, mName,
48 reinterpret_cast<hw_device_t**>(&mDevice));
49
50 if (res != OK) {
51 ALOGE("Could not open camera %s: %s (%d)", mName, strerror(-res), res);
52 return res;
53 }
54
55 if (mDevice->common.version != CAMERA_DEVICE_API_VERSION_2_0) {
56 ALOGE("Could not open camera %s: "
57 "Camera device is not version 2.0, reports %x instead",
58 mName, mDevice->common.version);
59 return BAD_VALUE;
60 }
61
62 return OK;
63}
64
65
66}; // namespace android