summaryrefslogtreecommitdiff
path: root/src/libcamera/include/camera_sensor.h
blob: b823480241a7eeb21c7bd9e0ed9868c036b24853 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
 * Copyright (C) 2019, Google Inc.
 *
 * camera_sensor.h - A camera sensor
 */
#ifndef __LIBCAMERA_CAMERA_SENSOR_H__
#define __LIBCAMERA_CAMERA_SENSOR_H__

#include <string>
#include <vector>

#include <libcamera/geometry.h>

#include "log.h"

namespace libcamera {

class MediaEntity;
class V4L2Subdevice;

struct V4L2SubdeviceFormat;

class CameraSensor : protected Loggable
{
public:
	explicit CameraSensor(const MediaEntity *entity);
	~CameraSensor();

	CameraSensor(const CameraSensor &) = delete;
	CameraSensor &operator=(const CameraSensor &) = delete;

	int init();

	const MediaEntity *entity() const { return entity_; }
	const std::vector<unsigned int> &mbusCodes() const { return mbusCodes_; }
	const std::vector<Size> &sizes() const { return sizes_; }
	const Size &resolution() const;

	V4L2SubdeviceFormat getFormat(const std::vector<unsigned int> &mbusCodes,
				      const Size &size) const;
	int setFormat(V4L2SubdeviceFormat *format);

protected:
	std::string logPrefix() const;

private:
	const MediaEntity *entity_;
	V4L2Subdevice *subdev_;

	std::vector<unsigned int> mbusCodes_;
	std::vector<Size> sizes_;
};

} /* namespace libcamera */

#endif /* __LIBCAMERA_CAMERA_SENSOR_H__ */