summaryrefslogtreecommitdiff
path: root/test/meson.build
diff options
context:
space:
mode:
Diffstat (limited to 'test/meson.build')
-rw-r--r--test/meson.build1
1 files changed, 1 insertions, 0 deletions
diff --git a/test/meson.build b/test/meson.build
index bd0e0d98..1f87319a 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -21,6 +21,7 @@ public_tests = [
internal_tests = [
['camera-sensor', 'camera-sensor.cpp'],
+ ['message', 'message.cpp'],
['threads', 'threads.cpp'],
]
'n84' href='#n84'>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
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
 * Copyright (C) 2019, Google Inc.
 *
 * camera_hal_manager.cpp - libcamera Android Camera Manager
 */

#include "camera_hal_manager.h"

#include <libcamera/camera.h>

#include "libcamera/internal/log.h"

#include "camera_device.h"

using namespace libcamera;

LOG_DECLARE_CATEGORY(HAL);

/*
 * \class CameraHalManager
 *
 * The HAL camera manager is initializated at camera_module_t 'hal_init()' time
 * and spawns its own thread where libcamera related events are dispatched to.
 * It wraps the libcamera CameraManager operations and provides helpers for the
 * camera_module_t operations, to retrieve the number of cameras in the system,
 * their static information and to open camera devices.
 */

CameraHalManager::CameraHalManager()
	: cameraManager_(nullptr)
{
}

CameraHalManager::~CameraHalManager()
{
	cameras_.clear();

	if (cameraManager_) {
		cameraManager_->stop();
		delete cameraManager_;
		cameraManager_ = nullptr;
	}
}

int CameraHalManager::init()
{
	cameraManager_ = new CameraManager();

	int ret = cameraManager_->start();
	if (ret) {
		LOG(HAL, Error) << "Failed to start camera manager: "
				<< strerror(-ret);
		delete cameraManager_;
		cameraManager_ = nullptr;
		return ret;
	}

	/*
	 * For each Camera registered in the system, a CameraDevice
	 * gets created here to wraps a libcamera Camera instance.
	 *
	 * \todo Support camera hotplug.
	 */
	unsigned int index = 0;
	for (auto &cam : cameraManager_->cameras()) {
		CameraDevice *camera = new CameraDevice(index, cam);
		cameras_.emplace_back(camera);

		++index;
	}

	return 0;
}

CameraDevice *CameraHalManager::open(unsigned int id,
				     const hw_module_t *hardwareModule)
{
	if (id >= numCameras()) {
		LOG(HAL, Error) << "Invalid camera id '" << id << "'";
		return nullptr;
	}

	CameraDevice *camera = cameras_[id].get();
	if (camera->open(hardwareModule))
		return nullptr;