libcamera  v0.0.0
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 <string>
11 #include <vector>
12 
13 #include <libcamera/geometry.h>
14 
16 #include "libcamera/internal/log.h"
19 
20 namespace libcamera {
21 
22 class MediaDevice;
23 
25  uint32_t mbus_code;
27 
28  const std::string toString() const;
29  uint8_t bitsPerPixel() const;
30 };
31 
32 class V4L2Subdevice : public V4L2Device
33 {
34 public:
35  enum Whence {
38  };
39 
40  explicit V4L2Subdevice(const MediaEntity *entity);
41  V4L2Subdevice(const V4L2Subdevice &) = delete;
42  V4L2Subdevice &operator=(const V4L2Subdevice &) = delete;
43  ~V4L2Subdevice();
44 
45  int open();
46 
47  const MediaEntity *entity() const { return entity_; }
48 
49  int getSelection(unsigned int pad, unsigned int target,
50  Rectangle *rect);
51  int setSelection(unsigned int pad, unsigned int target,
52  Rectangle *rect);
53 
54  ImageFormats formats(unsigned int pad);
55 
56  int getFormat(unsigned int pad, V4L2SubdeviceFormat *format,
57  Whence whence = ActiveFormat);
58  int setFormat(unsigned int pad, V4L2SubdeviceFormat *format,
59  Whence whence = ActiveFormat);
60 
61  static V4L2Subdevice *fromEntityName(const MediaDevice *media,
62  const std::string &entity);
63 
64 protected:
65  std::string logPrefix() const override;
66 
67 private:
68  std::vector<unsigned int> enumPadCodes(unsigned int pad);
69  std::vector<SizeRange> enumPadSizes(unsigned int pad,
70  unsigned int code);
71 
72  const MediaEntity *entity_;
73 };
74 
75 } /* namespace libcamera */
76 
77 #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:26
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:21
The format operation applies to TRY formats.
Definition: v4l2_subdevice.h:37
const std::string toString() const
Assemble and return a string describing the format.
Definition: v4l2_subdevice.cpp:174
Definition: bound_method.h:15
Describe V4L2Device and V4L2SubDevice image formats.
Definition: formats.h:21
const MediaEntity * entity() const
Retrieve the media entity associated with the subdevice.
Definition: v4l2_subdevice.h:47
Describe a two-dimensional size.
Definition: geometry.h:30
uint32_t mbus_code
The image format bus code.
Definition: v4l2_subdevice.h:25
The MediaEntity represents an entity in the media graph.
Definition: media_object.h:85
Describe a rectangle&#39;s position and dimensions.
Definition: geometry.h:15
Common base for V4L2 devices and subdevices.
The format operation applies to ACTIVE formats.
Definition: v4l2_subdevice.h:36
The V4L2 sub-device image format and sizes.
Definition: v4l2_subdevice.h:24
Data structures related to geometric objects.
Whence
Specify the type of format for getFormat() and setFormat() operations.
Definition: v4l2_subdevice.h:35
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:32