blob: e592d67dd0430e493f4531589117d7dc487bedb8 (
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
/* 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 <map>
#include <string>
#include <vector>
#include <libcamera/geometry.h>
#include "formats.h"
#include "log.h"
#include "media_object.h"
namespace libcamera {
class MediaDevice;
struct V4L2SubdeviceFormat {
uint32_t mbus_code;
uint32_t width;
uint32_t height;
const std::string toString() const;
};
class V4L2Subdevice : protected Loggable
{
public:
explicit V4L2Subdevice(const MediaEntity *entity);
V4L2Subdevice(const V4L2Subdevice &) = delete;
V4L2Subdevice &operator=(const V4L2Subdevice &) = delete;
~V4L2Subdevice();
int open();
bool isOpen() const;
void close();
const std::string &deviceNode() const { return entity_->deviceNode(); }
const std::string &entityName() const { return entity_->name(); }
int setCrop(unsigned int pad, Rectangle *rect);
int setCompose(unsigned int pad, Rectangle *rect);
FormatEnum formats(unsigned int pad);
int getFormat(unsigned int pad, V4L2SubdeviceFormat *format);
int setFormat(unsigned int pad, V4L2SubdeviceFormat *format);
static V4L2Subdevice *fromEntityName(const MediaDevice *media,
const std::string &entity);
protected:
std::string logPrefix() const;
private:
int enumPadSizes(unsigned int pad, unsigned int code,
std::vector<SizeRange> *size);
int setSelection(unsigned int pad, unsigned int target,
Rectangle *rect);
const MediaEntity *entity_;
int fd_;
};
} /* namespace libcamera */
#endif /* __LIBCAMERA_V4L2_SUBDEVICE_H__ */
|