summaryrefslogtreecommitdiff
path: root/src/libcamera/include/v4l2_subdevice.h
blob: eac699a06109dbdda70d8e8153512258c0516437 (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
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
 * Copyright (C) 2019, Google Inc.
 *
 * v4l2_subdevice.h - V4L2 Subdevice
 */
#ifndef __LIBCAMERA_V4L2_SUBDEVICE_H__
#define __LIBCAMERA_V4L2_SUBDEVICE_H__

#include <string>

#include "media_object.h"

namespace libcamera {

struct Rectangle;

struct V4L2SubdeviceFormat {
	uint32_t mbus_code;
	uint32_t width;
	uint32_t height;
};

class V4L2Subdevice
{
public:
	explicit V4L2Subdevice(const MediaEntity *entity);
	V4L2Subdevice(const V4L2Subdevice &) = delete;
	V4L2Subdevice &operator=(const V4L2Subdevice &) = delete;

	int open();
	bool isOpen() const;
	void close();

	std::string deviceNode() const { return entity_->deviceNode(); }
	std::string deviceName() const { return entity_->name(); }

	int setCrop(unsigned int pad, Rectangle *rect);
	int setCompose(unsigned int pad, Rectangle *rect);

	int getFormat(unsigned int pad, V4L2SubdeviceFormat *format);
	int setFormat(unsigned int pad, V4L2SubdeviceFormat *format);

private:
	int setSelection(unsigned int pad, unsigned int target,
			 Rectangle *rect);

	const MediaEntity *entity_;
	int fd_;
};

} /* namespace libcamera */

#endif /* __LIBCAMERA_V4L2_SUBDEVICE_H__ */