libcamera  v0.0.0+100-debian/0_git20200629+e7aa92a-8-9-g77f5237c-dirty (2021-05-05T16:20:29+01:00)
Supporting cameras in Linux since 2019
v4l2_subdevice.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 /*
3  * Copyright (C) 2019, Google Inc.
4  *
5  * v4l2_subdevice.h - V4L2 Subdevice
6  */
7 #ifndef __LIBCAMERA_INTERNAL_V4L2_SUBDEVICE_H__
8 #define __LIBCAMERA_INTERNAL_V4L2_SUBDEVICE_H__
9 
10 #include <memory>
11 #include <string>
12 #include <vector>
13 
14 #include <libcamera/class.h>
15 #include <libcamera/geometry.h>
16 
18 #include "libcamera/internal/log.h"
21 
22 namespace libcamera {
23 
24 class MediaDevice;
25 
27  uint32_t mbus_code;
29 
30  const std::string toString() const;
31  uint8_t bitsPerPixel() const;
32 };
33 
34 class V4L2Subdevice : public V4L2Device
35 {
36 public:
37  using Formats = std::map<unsigned int, std::vector<SizeRange>>;
38 
39  enum Whence {
42  };
43 
44  explicit V4L2Subdevice(const MediaEntity *entity);
45  ~V4L2Subdevice();
46 
47  int open();
48 
49  const MediaEntity *entity() const { return entity_; }
50 
51  int getSelection(unsigned int pad, unsigned int target,
52  Rectangle *rect);
53  int setSelection(unsigned int pad, unsigned int target,
54  Rectangle *rect);
55 
56  Formats formats(unsigned int pad);
57 
58  int getFormat(unsigned int pad, V4L2SubdeviceFormat *format,
59  Whence whence = ActiveFormat);
60  int setFormat(unsigned int pad, V4L2SubdeviceFormat *format,
61  Whence whence = ActiveFormat);
62 
63  static std::unique_ptr<V4L2Subdevice>
64  fromEntityName(const MediaDevice *media, const std::string &entity);
65 
66 protected:
67  std::string logPrefix() const override;
68 
69 private:
71 
72  std::vector<unsigned int> enumPadCodes(unsigned int pad);
73  std::vector<SizeRange> enumPadSizes(unsigned int pad,
74  unsigned int code);
75 
76  const MediaEntity *entity_;
77 };
78 
79 } /* namespace libcamera */
80 
81 #endif /* __LIBCAMERA_INTERNAL_V4L2_SUBDEVICE_H__ */
Provides a class hierarchy that represents the media objects exposed by the Linux kernel Media Contro...
Size size
The image size in pixels.
Definition: v4l2_subdevice.h:28
Utilities to help constructing class interfaces.
The MediaDevice represents a Media Controller device with its full graph of connected objects...
Definition: media_device.h:24
Base class for V4L2VideoDevice and V4L2Subdevice.
Definition: v4l2_device.h:26
The format operation applies to TRY formats.
Definition: v4l2_subdevice.h:41
const std::string toString() const
Assemble and return a string describing the format.
Definition: v4l2_subdevice.cpp:174
Top-level libcamera namespace.
Definition: bound_method.h:15
const MediaEntity * entity() const
Retrieve the media entity associated with the subdevice.
Definition: v4l2_subdevice.h:49
Describe a two-dimensional size.
Definition: geometry.h:50
std::map< unsigned int, std::vector< SizeRange > > Formats
A map of supported media bus formats to frame sizes.
Definition: v4l2_subdevice.h:37
uint32_t mbus_code
The image format bus code.
Definition: v4l2_subdevice.h:27
The MediaEntity represents an entity in the media graph.
Definition: media_object.h:88
#define LIBCAMERA_DISABLE_COPY(klass)
Disable copy construction and assignment of the klass.
Describe a rectangle&#39;s position and dimensions.
Definition: geometry.h:206
Common base for V4L2 devices and subdevices.
The format operation applies to ACTIVE formats.
Definition: v4l2_subdevice.h:40
The V4L2 sub-device image format and sizes.
Definition: v4l2_subdevice.h:26
Data structures related to geometric objects.
Whence
Specify the type of format for getFormat() and setFormat() operations.
Definition: v4l2_subdevice.h:39
Types and helper methods to handle libcamera image formats.
Logging infrastructure.
uint8_t bitsPerPixel() const
Retrieve the number of bits per pixel for the V4L2 subdevice format.
Definition: v4l2_subdevice.cpp:194
A V4L2 subdevice as exposed by the Linux kernel.
Definition: v4l2_subdevice.h:34