summaryrefslogtreecommitdiff
path: root/src/libcamera/camera_sensor.cpp
AgeCommit message (Collapse)Author
2021-06-28libcamera: Add support for monochrome sensorsDavid Plowman
This commit adds support for monochrome (greyscale) raw sensors. These are sensors that have no colour filter array, so all pixels are the same and there are no distinct colour channels. These sensors still require many of an ISP's processing stages, such as denoise, tone mapping, but not those that involve colours (such as demosaic, or colour matrices). Signed-off-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-06-25libcamera/base: Move utils to the base libraryKieran Bingham
Move the utils functionality to the libcamera/base library. Reviewed-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-06-14libcamera: CameraSensor: Enable retrieving supported test pattern modesHirokazu Honda
This enables retrieving supported test pattern modes through CameraSensorInfo. Signed-off-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-05-24ipa: ipc: Rename CameraSensorInfo to IPACameraSensorInfoUmang Jain
This matches the naming convention for IPA IPC. Signed-off-by: Umang Jain <umang.jain@ideasonboard.com> Acked-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-05-24ipa: mojom: Move CameraSensorInfo struct exclusively to IPA IPCUmang Jain
CameraSensorInfo structure is designed to pass in camera sensor related information from pipeline-handler to IPA. Since the pipeline-handler and IPA are connected via mojom IPC IPA interface, the interface itself provides a more suitable placement of CameraSensorInfo, instead of camera_sensor.h (which is a libcamera internal header ultimately, at this point). As CameraSensorInfo is already defined in core.mojom, it is just a matter of removing [skipHeader] tag to allow code-generation of CameraSensorInfo. Finally, update header paths to include CameraSensorInfo definition from IPA interfaces instead of "libcamera/internal/camera_sensor.h". Signed-off-by: Umang Jain <umang.jain@ideasonboard.com> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-05-11libcamera: camera_sensor: Fix frame lengths calculated by sensorInfo()David Plowman
The minimum and maximum vblanking can change when a new format is applied to the sensor subdevice, so be sure to retrieve up-to-date values. The V4L2Device acquires the new updateControlInfo() method to perform this function, and which the CameraSensor calls automatically if its setFormat method is used to update the sensor. However, not all pipeline handlers invoke the setFormat method directly, so the new method must be made publicly available for pipeline handlers to call if they need to. Signed-off-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-05-10libcamera: camera_sensor: Register static propertiesJacopo Mondi
Register static properties in the CameraSensor class by inspecting the camera sensor properties database. Static properties are overridden by properties retrieved from the kernel interface at run-time if any overlap between the two sets occurs. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Reviewed-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-04-15libcamera: camera_sensor: Demote error messageJacopo Mondi
The CameraSensor class is noisy enough in reporting the missing sensor driver features. Demote an error message about defaulting the active sensor area when retrieving the camera sensor info to a warning. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-03-22libcamera: camera_sensor: Do not register Location if not availableJacopo Mondi
Do not register the Location property if not available from the firmware interface instead of defaulting it to External. Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-03-08libcamera: camera_sensor: Cap resolution to max frame sizeJacopo Mondi
Since commit 96aecfe36508 ("libcamera: camera_sensor: Use active area size as resolution") the CameraSensor::resolution() method returned the sensor's active pixel area size. As the CameraSensor::resolution() method is widely used in the library code base to retrieve the maximum frame size the sensor can produce, in case it is smaller than the pixel area size the returned size cannot be used to configure the sensor correctly. Fix this by returning the maximum frame resolution the sensor can produce, or the pixel area size in case the sensor embeds and ISP that can upscale and the supported maximum frame size is thus larger that the pixel array size. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-03-03libcamera: camera_sensor: Accept entities exposing the ISP functionLaurent Pinchart
Camera sensors can include an ISP, which may be reported as a separate entity from the pixel array in the media graph. Support such sensors by accepting MEDIA_ENT_F_PROC_VIDEO_ISP as a valid entity type. This allows using sensors that can be fully (or at least meaningfully) configured through the ISP's source pad only. Sensors that require further configuration, on the ISP sink pad and/or on the pixel array's source pad, will require further extension to the CameraSensor class. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2021-03-03libcamera: camera_sensor: Use active area size as resolutionLaurent Pinchart
When a sensor can upscale the image, the native sensor resolution isn't equal to the largest size reported by the sensor. Use the active area size instead, and default it to the largest enumerated size if the crop rectangle targets are not supported. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2021-02-24libcamera: camera_sensor: Print warning when orientation is unknownPaul Elder
Print a warning when the orientation of a sensor is unknown. The location property is still defaulted to external. Also add a recommended controls list, similar to the optional and mandatory controls list, to handle controls in a similar situation in the future. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-02-05libcamera: camera_sensor: Check control availability from idmapLaurent Pinchart
The presence of mandatory and optional controls is checked in CameraSensor::validateSensorDriver() by trying to retrieve them. This causes an error message to be printed in the V4L2Device class if an optional control isn't present, while this isn't an error. To fix this, use the control idmap reported by the V4L2Device to check for controls availability. The function can now print the whole list of missing controls, making debugging easier. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2021-02-05libcamera: camera_sensor: Restrict sensor info to raw sensorsLaurent Pinchart
YUV sensors don't provide the necessary information to fill CameraSensorInfo, as they include an ISP and provide a higher-level API that doesn't always expose low-level information. The CameraSensor class makes low-level V4L2 controls mandatory for all sensors, which prevents usage of YUV sensors with the simple pipeline handler. Make CameraSensor::sensorInfo() available for raw sensors only. This won't introduce any regression in pipeline handlers that currently use the sensorInfo() function as they all operate with raw sensors, and won't be a limitation for the simple pipeline handler as well as it doesn't use sensor info. If part of the sensor info (such as the active pixel array size for instance) becomes useful to expose for YUV sensors in the future, the sensorInfo() function can be extended to report that information only and skip data that is only available for raw sensors. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2021-02-05libcamera: camera_sensor: Store Bayer pattern in class memberLaurent Pinchart
The Bayer pattern is retrieved based on the media bus formats supported by the sensor, when registering camera sensor properties. To prepare for its usage elsewhere in the CameraSensor class, store it in a private member variable. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2021-02-05libcamera: camera_sensor: Add frame length limits to CameraSensorInfoNaushir Patuck
Sensor frame length is made up of active and inactive (blanking) lines. The minimum and maximum frame length values may be used by pipeline handlers to limit frame durations based on the sensor mode capabilities. Store the minimum and maximum allowable frame length values (in lines) in the CameraSensorInfo structure. These values are computed in CameraSensor::sensorInfo() by querying the sensor subdevice V4L2_CID_VBLANK control limits. This in turn means that V4L2_CID_VBLANK is now a mandatory subdevice control. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-02-05libcamera: camera_sensor: Make VBLANK mandatoryJacopo Mondi
Add the V4L2_CID_VBLANK control to the list of mandatory controls the sensor driver has to report and document the new requirement. The vertical blanking control is used to calculate the frame duration. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-01-29libcamera: camera_sensor: Expose the camera deviceNiklas Söderlund
Expose the device backing the CameraSensor instance. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-01-25libcamera: camera_sensor: Make V4L2_CID_EXPOSURE mandatoryJacopo Mondi
Add the V4L2_CID_EXPOSURE control to the list of mandatory controls the sensor driver has to report and document this new requirement. While at it, re-sort the mandatory V4L2 controls in alphabetical order in the CameraSensor class and remove the above comment as the usage of the controls is better reported in the documentation. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-01-25libcamera: CameraSensor: Mention V4L2 in get/setControls()Jacopo Mondi
The current CameraSensor interface for reading and writing controls is currently based on V4L2 controls. Mention that more clearly in the documentation and, while at it, re-sort the documentation to match the methods declaration order. Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-01-18libcamera: camera_sensor: Initialize VIMC propertiesJacopo Mondi
The VIMC driver does not yet support all the features required for all sensor drivers. As it is the main testing platforms and the driver changes might take a long time to land in the developments and testing platforms, temporary close the gap by skipping driver validation and initializing properties with static information such as the sensor resolution. Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-01-18libcamera: camera_sensor: Do not default 'rotation'Jacopo Mondi
The 'rotation' property is not critical. Only register it if the sensor driver reports it. Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-01-18libcamera: camera_sensor: Default 'location' to ExternalJacopo Mondi
If the sensor driver does not report the camera location default it to 'External' instead of 'Front'. As the camera location is used to construct the camera unique name presented to the user, it makes more sense to report multiple 'External' cameras instead of multiple 'Front' ones. Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-01-18libcamera: camera_sensor: Default analogue crop rectangleJacopo Mondi
As support for the V4L2_SEL_TGT_CROP selection target used to read the sensor analogue crop rectangle is schedule to become mandatory but is still optional, use the sensor's active area size as fallback value to allow the creation of the CameraSensorInfo in the case the driver does not support it. Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-01-18libcamera: camera_sensor: Provide fall-back for sensor propertiesJacopo Mondi
Support for the V4L2 selection API is currently optional in the CameraSensor class. Properties registered by using values read through that API are defaulted in several different places (the Android camera HAL or the CameraSensor class). In the future support for the selection API will be made mandatory, but to give time to sensor drivers in all test platforms to be updated, use sensor resolution as fallback values for sensor pixel array properties and cache them as class member variables. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-01-18libcamera: camera_sensor: Validate driver supportJacopo Mondi
The CameraSensor class requires the sensor driver to report information through V4L2 controls and through the V4L2 selection API, and uses that information to register Camera properties and to construct CameraSensorInfo class instances to provide them to the IPA. Currently, validation of the kernel support happens each time a feature is requested, with slighly similar debug/error messages output to the user in case a feature is not supported. Rationalize this by validating the sensor driver requirements in a single function Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-12-30libcamera: camera_sensor: Register ColorFilterArrangementJacopo Mondi
Inspect the list of media bus codes supported by the camera sensor in order to deduce the color filter arrangement and register the ColorFilterArrangement draft property. Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-12-07libcamera: camera_sensor: Initialize PixelArray propertiesJacopo Mondi
Initialize pixel array properties 'PixelArraySize' and 'PixelArrayActiveAreas' by inspecting the V4L2 CROP_BOUNDS and CROP_DEFAULT selection targets. The properties are registered only if the sensor subdevice support the above mentioned selection targets. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-12-07libcamera: camera_sensor: Break out properties initializationJacopo Mondi
Break out initialization to its own function in preparation to add more properties. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-12-07libcamera: camera_sensor: Adjust CameraSensorInfo::analogCropJacopo Mondi
The CameraSensorInfo::analogCrop top-left corner is defined relatively to the sensor active area. The analogCrop rectangle is constucted by retrieving the V4L2 selection target V4L2_SEL_TGT_CROP which is instead defined relatively to the whole sensor's pixel array size. Adjust the the analogCrop rectangle subtracting from its top-left corner the active area distance from the full pixel array. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-10-20libcamera: Omit extra semicolonsHirokazu Honda
The end semicolons with LOG_DEFINE_CATEGORY, LOG_DECLARE_CATEGORY and REGISTER_PIPELINE_HANDLER are unnecessary. Signed-off-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-10-02libcamera: camera_sensor: Set sensor model propertyNiklas Söderlund
Set the sensor model property. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-08-05libcamera: camera_sensor: Add accessors for sensor IDNiklas Söderlund
Add an accessors so that the sensor ID can be used outside CameraSensor. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2020-08-05libcamera: camera_sensor: Generate a sensor IDNiklas Söderlund
The ID is generated from information in the firmware description of the sensor if available or from module and model information if the sensor is virtual (for example VIMC). Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-07-23libcamera: v4l2_subdevice: Replace ImageFormats with a mapNiklas Söderlund
Replace the V4L2Subdevice usage of the ImageFormats class with a std::map and the utils::map_keys() helper. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-07-15libcamera: geometry: Give constructors to RectangleLaurent Pinchart
Rectangle, unlike Size, has no constructor, requiring the users to explicitly initialize the instances. This is error-prone, add constructors. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-05-21libcamera: camera_sensor: Update properties parsingJacopo Mondi
Update the properties parsing routine in the CameraSensor class to use the newly defined V4L2 control V4L2_CID_CAMERA_ORIENTATION in place of the downstream V4L2_CID_CAMERA_SENSOR_LOCATION which has now been removed. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-05-16libcamera: Move internal headers to include/libcamera/internal/Laurent Pinchart
The libcamera internal headers are located in src/libcamera/include/. The directory is added to the compiler headers search path with a meson include_directories() directive, and internal headers are included with (e.g. for the internal semaphore.h header) #include "semaphore.h" All was well, until libcxx decided to implement the C++20 synchronization library. The __threading_support header gained a #include <semaphore.h> to include the pthread's semaphore support. As include_directories() adds src/libcamera/include/ to the compiler search path with -I, the internal semaphore.h is included instead of the pthread version. Needless to say, the compiler isn't happy. Three options have been considered to fix this issue: - Use -iquote instead of -I. The -iquote option instructs gcc to only consider the header search path for headers included with the "" version. Meson unfortunately doesn't support this option. - Rename the internal semaphore.h header. This was deemed to be the beginning of a long whack-a-mole game, where namespace clashes with system libraries would appear over time (possibly dependent on particular system configurations) and would need to be constantly fixed. - Move the internal headers to another directory to create a unique namespace through path components. This causes lots of churn in all the existing source files through the all project. The first option would be best, but isn't available to us due to missing support in meson. Even if -iquote support was added, we would need to fix the problem before a new version of meson containing the required support would be released. The third option is thus the only practical solution available. Bite the bullet, and do it, moving headers to include/libcamera/internal/. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Jacopo Mondi <jacopo@jmondi.org>
2020-05-03libcamera: camera_sensor: Relax restriction on sizesLaurent Pinchart
The CameraSensor class assumes that camera sensors support the exact same list of sizes of all media bus codes. While allowing a simpler API, this assumption is incorrect and is blocking usage of some camera sensors. Relaxing the constraint is possible without changes to the CameraSensor API syntax, but requires changing its semantics. The sizes() function now returns the list of all sizes for all media bus codes, and the getFormat() function now searches in all supported media bus codes. The former is likely not the most useful option for pipeline handlers, but the sizes() function is currently unused. Designing a better API will require inspecting current and expected future use cases in pipeline handlers to determine proper heuristics. While at it, fix a small typo in an unrelated comment. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-05-03libcamera: camera_sensor: Prepare for multi-subdev camera sensorsLaurent Pinchart
While most camera sensors are exposed to userspace as a single subdev, this is not always the case. A notable exception is the smiapp driver, which exposes two or three subdevs. The subdev at the output of the camera sensor will thus have more than one pad. Prepare for this by removing the single-pad restriction, and locating the source pad dynamically. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-05-03libcamera: camera_sensor: Store subdevice in std::unique_ptrLaurent Pinchart
Avoid the need for a manual delete in the destructor by using a unique pointer. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-05-03libcamera: camera_sensor: Access entity directlyLaurent Pinchart
The CameraSensor::logPrefix() function accesses the entity from the subdev. Remove the level of indirection as we stored a pointer to the entity internally. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-04-28libcamera: camera_sensor: Add method to get sensor infoJacopo Mondi
Add a method to retrieve the CameraSensorInfo to the CameraSensor class. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-04-28libcamera: camera_sensor: Define CameraSensorInfoJacopo Mondi
Define the CameraSensorInfo structure that reports the current image sensor configuration. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-04-28libcamera: camera_sensor: Add model() functionLaurent Pinchart
Add a new model() function to the CameraSensor class to report the camera sensor model. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2020-04-28libcamera: v4l2_device: Simplify usage of getControls()Laurent Pinchart
The V4L2Device::getControls() function takes a ControlList that needs to be pre-populated with dummy entries for the controls that need to be read. This is a cumbersome API, especially when reading a single control. Make it nicer by passing the list of V4L2 controls as a vector of control IDs, and returning a ControlList. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-02-14libcamera: camera_sensor: Parse camera propertiesJacopo Mondi
Parse and collect camera sensor properties by inspecting the associated v4l2 controls. Augment the CameraSensor class with an operation to retrieve the collected properties. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-10-15libcamera: controls: Merge ControlInfoMap and V4L2ControlInfoMapLaurent Pinchart
The ControlInfoMap and V4L2ControlInfoMap classes are very similar, with the latter adding convenience accessors based on numerical IDs for the former, as well as a cached idmap. Both features can be useful for ControlInfoMap in the context of serialisation, and merging the two classes will further simplify the IPA API. Import all the features of V4L2ControlInfoMap into ControlInfoMap, turning the latter into a real class. A few new constructors and assignment operators are added for completeness. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-10-15libcamera: utils: Add hex stream output helperLaurent Pinchart
Add a utils::hex() function that simplifies writing hexadecimal values to an ostream. The function handles the '0x' prefix, the field width and the fill character automatically. Use it through the libcamera code base, and add a test. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>