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
camera_sensor.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  * camera_sensor.h - A camera sensor
6  */
7 #ifndef __LIBCAMERA_INTERNAL_CAMERA_SENSOR_H__
8 #define __LIBCAMERA_INTERNAL_CAMERA_SENSOR_H__
9 
10 #include <memory>
11 #include <string>
12 #include <vector>
13 
14 #include <libcamera/class.h>
15 #include <libcamera/controls.h>
16 #include <libcamera/geometry.h>
17 
19 #include "libcamera/internal/log.h"
21 
22 namespace libcamera {
23 
24 class BayerFormat;
25 class MediaEntity;
26 
28  std::string model;
29 
30  uint32_t bitsPerPixel;
31 
35 
36  uint64_t pixelRate;
37  uint32_t lineLength;
38 
39  uint32_t minFrameLength;
40  uint32_t maxFrameLength;
41 };
42 
43 class CameraSensor : protected Loggable
44 {
45 public:
46  explicit CameraSensor(const MediaEntity *entity);
47  ~CameraSensor();
48 
49  int init();
50 
51  const std::string &model() const { return model_; }
52  const std::string &id() const { return id_; }
53  const MediaEntity *entity() const { return entity_; }
54  const std::vector<unsigned int> &mbusCodes() const { return mbusCodes_; }
55  const std::vector<Size> &sizes() const { return sizes_; }
56  Size resolution() const;
57 
58  V4L2SubdeviceFormat getFormat(const std::vector<unsigned int> &mbusCodes,
59  const Size &size) const;
60  int setFormat(V4L2SubdeviceFormat *format);
61 
62  const ControlInfoMap &controls() const;
63  ControlList getControls(const std::vector<uint32_t> &ids);
64  int setControls(ControlList *ctrls);
65 
66  V4L2Subdevice *device() { return subdev_.get(); }
67 
68  const ControlList &properties() const { return properties_; }
69  int sensorInfo(CameraSensorInfo *info) const;
70 
71 protected:
72  std::string logPrefix() const override;
73 
74 private:
76 
77  int generateId();
78  int validateSensorDriver();
79  void initVimcDefaultProperties();
80  int initProperties();
81 
82  const MediaEntity *entity_;
83  std::unique_ptr<V4L2Subdevice> subdev_;
84  unsigned int pad_;
85 
86  std::string model_;
87  std::string id_;
88 
89  V4L2Subdevice::Formats formats_;
90  std::vector<unsigned int> mbusCodes_;
91  std::vector<Size> sizes_;
92 
93  Size pixelArraySize_;
94  Rectangle activeArea_;
95  const BayerFormat *bayerFormat_;
96 
97  ControlList properties_;
98 };
99 
100 } /* namespace libcamera */
101 
102 #endif /* __LIBCAMERA_INTERNAL_CAMERA_SENSOR_H__ */
Utilities to help constructing class interfaces.
uint64_t pixelRate
The number of pixels produced in a second.
Definition: camera_sensor.h:36
Report the image sensor characteristics.
Definition: camera_sensor.h:27
const std::vector< Size > & sizes() const
Retrieve the frame sizes supported by the camera sensor.
Definition: camera_sensor.h:55
const std::vector< unsigned int > & mbusCodes() const
Retrieve the media bus codes supported by the camera sensor.
Definition: camera_sensor.h:54
const std::string & model() const
Retrieve the sensor model name.
Definition: camera_sensor.h:51
Base class to support log message extensions.
Definition: log.h:84
Top-level libcamera namespace.
Definition: bound_method.h:15
Rectangle analogCrop
The portion of the pixel array active area which is read-out and processed.
Definition: camera_sensor.h:33
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
const ControlList & properties() const
Retrieve the camera sensor properties.
Definition: camera_sensor.h:68
Size outputSize
The size of the images produced by the camera sensor.
Definition: camera_sensor.h:34
const std::string & id() const
Retrieve the sensor ID.
Definition: camera_sensor.h:52
uint32_t maxFrameLength
The maximum allowable frame length in units of lines.
Definition: camera_sensor.h:40
A map of ControlId to ControlInfo.
Definition: controls.h:301
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.
std::string model
The image sensor model name.
Definition: camera_sensor.h:28
Describe a rectangle&#39;s position and dimensions.
Definition: geometry.h:206
A camera sensor based on V4L2 subdevices.
Definition: camera_sensor.h:43
V4L2Subdevice * device()
Retrieve the camera sensor device.
Definition: camera_sensor.h:66
V4L2 Subdevice API.
uint32_t lineLength
Total line length in pixels.
Definition: camera_sensor.h:37
The V4L2 sub-device image format and sizes.
Definition: v4l2_subdevice.h:26
uint32_t minFrameLength
The minimum allowable frame length in units of lines.
Definition: camera_sensor.h:39
uint32_t bitsPerPixel
The number of bits per pixel of the image format produced by the image sensor.
Definition: camera_sensor.h:30
const MediaEntity * entity() const
Retrieve the sensor media entity.
Definition: camera_sensor.h:53
const ControlIdMap controls
List of all supported libcamera controls.
Definition: control_ids.cpp:893
Associate a list of ControlId with their values for an object.
Definition: controls.h:346
Framework to manage controls related to an object.
Data structures related to geometric objects.
Size activeAreaSize
The size of the pixel array active area of the sensor.
Definition: camera_sensor.h:32
Types and helper methods to handle libcamera image formats.
Logging infrastructure.
A V4L2 subdevice as exposed by the Linux kernel.
Definition: v4l2_subdevice.h:34
Class to represent a raw image Bayer format.
Definition: bayer_format.h:19