summaryrefslogtreecommitdiff
path: root/src/libcamera/media_object.cpp
AgeCommit message (Collapse)Author
9 dayslibcamera: Drop file name from header comment blocksLaurent Pinchart
Source files in libcamera start by a comment block header, which includes the file name and a one-line description of the file contents. While the latter is useful to get a quick overview of the file contents at a glance, the former is mostly a source of inconvenience. The name in the comments can easily get out of sync with the file name when files are renamed, and copy & paste during development have often lead to incorrect names being used to start with. Readers of the source code are expected to know which file they're looking it. Drop the file name from the header comment block. The change was generated with the following script: ---------------------------------------- dirs="include/libcamera src test utils" declare -rA patterns=( ['c']=' \* ' ['cpp']=' \* ' ['h']=' \* ' ['py']='# ' ['sh']='# ' ) for ext in ${!patterns[@]} ; do files=$(for dir in $dirs ; do find $dir -name "*.${ext}" ; done) pattern=${patterns[${ext}]} for file in $files ; do name=$(basename ${file}) sed -i "s/^\(${pattern}\)${name} - /\1/" "$file" done done ---------------------------------------- This misses several files that are out of sync with the comment block header. Those will be addressed separately and manually. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
2022-03-15libcamera: Add members to MediaEntity to support ancillary entitiesDaniel Scally
With kernel support for ancillary links, we can describe the relationship between two devices represented individually as instances of MediaEntity. As the only property of that relationship is its existence, describe those relationships in libcamera simply as a vector of MediaEntity pointers to the ancillary devices. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Daniel Scally <djrscally@gmail.com> Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-08-31libcamera: media_object: Expose entity typeLaurent Pinchart
Add a new field to the MediaEntity class to identify the type of interface it exposes to userspace. The MediaEntity constructor is changed to take a media_v2_interface pointer instead of just the device node major and minor to have access to the interface type. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Tested-by: Martin Kepplinger <martin.kepplinger@puri.sm>
2021-06-25libcamera/base: Move extended base functionalityKieran Bingham
Move the functionality for the following components to the new base support library: - BoundMethod - EventDispatcher - EventDispatcherPoll - Log - Message - Object - Signal - Semaphore - Thread - Timer While it would be preferable to see these split to move one component per commit, these components are all interdependent upon each other, which leaves us with one big change performing the move for all of them. Reviewed-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-01-18libcamera: media_object: Add a const version of dev()Jacopo Mondi
Add a const version of the MediaObject::dev() method to be able to retrieve a pointer to a const MediaDevice from a constant instance of a MediaObject sub-class. 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-10-23libcamera: media_object: Remove unneeded destructorsLaurent Pinchart
The MediaEntity, MediaLink and MediaPad classes don't need custom destructors. For MediaEntity and MediaPad, the destructors clear a vector embedded in the classes, which will be done by the default destructor. For MediaLink, the destructor is already empty. Remove them. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Umang Jain <email@uajain.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-08-29libcamera: media_object: Make MediaLink::setEnabled() account for existing flagsDan Scally
The MediaDevice::setupLink() function fails (ioctl returns EINVAL) when it passes only the MEDIA_LNK_FL_ENABLE flag to a link that is already flagged with MEDIA_LNK_FL_ENABLE and MEDIA_LNK_FL_IMMUTABLE. Contrast to media-ctl's equivalent media_setup_link() which ORs the new flags with the existing values. Fix this by preserving all flags but MEDIA_LNK_FL_ENABLED in MediaLink::setEnabled(). Signed-off-by: Dan Scally <djrscally@gmail.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>
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>
2019-10-23libcamera: Standardise on C compatibility headersLaurent Pinchart
Now that our usage of C compatibility header is documented, use them consistently through the source code. While at it, group the C and C++ include statements as defined in the coding style, and fix a handful of #include ordering issues. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-04-19libcamera: Include header related to source file firstLaurent Pinchart
Include the header file corresponding to the source file in the very first position. This complies with the Google C++ coding style guideliens, and helps ensuring that the headers are self-contained. Three bugs are already caught by this change (missing includes or forward declarations) in device_enumerator.h, event_dispatcher_poll.h and pipeline_handler.h. Fix them. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-04-19libcamera: Document documentation style and update the code accordinglyLaurent Pinchart
The documentation style for the Doxygen comment blocks is inconsistent in the library. Document the expectations and update all existing comment blocks to match. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Jacopo Mondi <jacopo@jmondi.org>
2019-02-27libcamera: align the documentation for numeric error codesNiklas Söderlund
Rapid growth of the library have resulted in slightly different wording to document that a function returns 0 on success or a negative error code otherwise. Align all different variations. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-01-25libcamera: MediaEntity: expose the entity flagsNiklas Söderlund
The media entity flags can be useful for pipeline handlers to find the default device in a media graph which is marked with the MEDIA_ENT_FL_DEFAULT flag. This will be especially useful for the UVC pipeline handler where the entity names differ per device. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-01-22libcamera: Global s/devnode/deviceNode renameJacopo Mondi
Do not use the abreviated version for members, variables and getter methods. Library-wise rename, no intended functional changes. 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>
2019-01-21libcamera: Use log categoriesLaurent Pinchart
Use log categories in the whole existing code base. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-01-21libcamera: media_object: Set devnode in MediaEntityJacopo Mondi
The MediaEntity::setDeviceNode() function was designed to set the device node path associated with a MediaEntity. The function was there, but the devnode_ member field was never actually set. Fix this. While at there add a getter method for the devnode_ member as it will soon be used. 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-01-21libcamera: media_object: Add functions to entitiesJacopo Mondi
Media entities convey information about their main function in the 'function' field of 'struct media_v2_entity'. Store the main function in the MediaEntity function_ class member and provide a getter function for that. While at there update comments, keep the MediaPad description in sync with the MediaEntity one and remove a stale TODO entry. Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-01-09libcamera: Add link handling functionsJacopo Mondi
Add a function to the MediaLink class to set the state of a link to enabled or disabled. The function makes use of an internal MediaDevice method, which is defined private and only accessible by the MediaLink setEnabled() function itself. Also add to MediaDevice a function to reset all links registered in the media graph. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-01-08libcamera: Add pointer to MediaDevice to MediaObjectJacopo Mondi
Add a MediaDevice member field to the MediaObject class hierarcy. Each media object now has a reference to the media device it belongs to, and which it has been created by. 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>
2019-01-08libcamera: media_object: Rename major/minor functionsKieran Bingham
The system libraries define macro's for major/minor through <sys/types.h> on some versions of GCC/GLibc. To prevent namespace collisions with these macros, rename our major and minor device node accessors. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-01-02libcamera: media_device: Create entities with major and minor numbersJacopo Mondi
Extend the MediaEntity object with device node major and minor numbers, and retrieve them from the media graph using interfaces. They will be used by the DeviceEnumerator to retrieve the devnode path. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2018-12-31libcamera: Add MediaObject class hierarchyJacopo Mondi
Add a class hierarcy to represent all media objects a media graph represents. Add a base MediaObject class, which retains the global unique object id, and define the derived MediaEntity, MediaLink and MediaPad classes. This hierarchy will be used by the MediaDevice objects which represents and handles the media graph. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>