libcamera/src/android/camera3_hal.cpp
Laurent Pinchart 626172a16b libcamera: Drop file name from header comment blocks
Source files in libcamera start by a comment block header, which
includes the file name and a one-line description of the file contents.
While the latter is useful to get a quick overview of the file contents
at a glance, the former is mostly a source of inconvenience. The name in
the comments can easily get out of sync with the file name when files
are renamed, and copy & paste during development have often lead to
incorrect names being used to start with.

Readers of the source code are expected to know which file they're
looking it. Drop the file name from the header comment block.

The change was generated with the following script:

----------------------------------------

dirs="include/libcamera src test utils"

declare -rA patterns=(
	['c']=' \* '
	['cpp']=' \* '
	['h']=' \* '
	['py']='# '
	['sh']='# '
)

for ext in ${!patterns[@]} ; do
	files=$(for dir in $dirs ; do find $dir -name "*.${ext}" ; done)
	pattern=${patterns[${ext}]}

	for file in $files ; do
		name=$(basename ${file})
		sed -i "s/^\(${pattern}\)${name} - /\1/" "$file"
	done
done
----------------------------------------

This misses several files that are out of sync with the comment block
header. Those will be addressed separately and manually.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
2024-05-08 22:39:50 +03:00

116 lines
2.6 KiB
C++

/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2019, Google Inc.
*
* Android Camera HALv3 module
*/
#include <hardware/camera_common.h>
#include <libcamera/base/log.h>
#include "camera_device.h"
#include "camera_hal_manager.h"
using namespace libcamera;
LOG_DEFINE_CATEGORY(HAL)
/*------------------------------------------------------------------------------
* Android Camera HAL callbacks
*/
static int hal_get_number_of_cameras()
{
return CameraHalManager::instance()->numCameras();
}
static int hal_get_camera_info(int id, struct camera_info *info)
{
return CameraHalManager::instance()->getCameraInfo(id, info);
}
static int hal_set_callbacks(const camera_module_callbacks_t *callbacks)
{
CameraHalManager::instance()->setCallbacks(callbacks);
return 0;
}
static int hal_open_legacy([[maybe_unused]] const struct hw_module_t *module,
[[maybe_unused]] const char *id,
[[maybe_unused]] uint32_t halVersion,
[[maybe_unused]] struct hw_device_t **device)
{
return -ENOSYS;
}
static int hal_set_torch_mode([[maybe_unused]] const char *camera_id,
[[maybe_unused]] bool enabled)
{
return -ENOSYS;
}
/*
* First entry point of the camera HAL module.
*
* Initialize the HAL but does not open any camera device yet (see hal_dev_open)
*/
static int hal_init()
{
LOG(HAL, Info) << "Initialising Android camera HAL";
CameraHalManager::instance()->init();
return 0;
}
/*------------------------------------------------------------------------------
* Android Camera Device
*/
static int hal_dev_open(const hw_module_t *module, const char *name,
hw_device_t **device)
{
LOG(HAL, Debug) << "Open camera " << name;
int id = atoi(name);
auto [camera, ret] = CameraHalManager::instance()->open(id, module);
if (!camera) {
LOG(HAL, Error)
<< "Failed to open camera module '" << id << "'";
return ret == -EBUSY ? -EUSERS : ret;
}
*device = &camera->camera3Device()->common;
return 0;
}
static struct hw_module_methods_t hal_module_methods = {
.open = hal_dev_open,
};
camera_module_t HAL_MODULE_INFO_SYM = {
.common = {
.tag = HARDWARE_MODULE_TAG,
.module_api_version = CAMERA_MODULE_API_VERSION_2_4,
.hal_api_version = HARDWARE_HAL_API_VERSION,
.id = CAMERA_HARDWARE_MODULE_ID,
.name = "libcamera camera HALv3 module",
.author = "libcamera",
.methods = &hal_module_methods,
.dso = nullptr,
.reserved = {},
},
.get_number_of_cameras = hal_get_number_of_cameras,
.get_camera_info = hal_get_camera_info,
.set_callbacks = hal_set_callbacks,
.get_vendor_tag_ops = nullptr,
.open_legacy = hal_open_legacy,
.set_torch_mode = hal_set_torch_mode,
.init = hal_init,
.reserved = {},
};