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>
95 lines
2.3 KiB
C++
95 lines
2.3 KiB
C++
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
|
/*
|
|
* Copyright (C) 2018, Google Inc.
|
|
*
|
|
* Media device handler
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <map>
|
|
#include <sstream>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include <linux/media.h>
|
|
|
|
#include <libcamera/base/log.h>
|
|
#include <libcamera/base/signal.h>
|
|
#include <libcamera/base/unique_fd.h>
|
|
|
|
#include "libcamera/internal/media_object.h"
|
|
|
|
namespace libcamera {
|
|
|
|
class MediaDevice : protected Loggable
|
|
{
|
|
public:
|
|
MediaDevice(const std::string &deviceNode);
|
|
~MediaDevice();
|
|
|
|
bool acquire();
|
|
void release();
|
|
bool busy() const { return acquired_; }
|
|
|
|
bool lock();
|
|
void unlock();
|
|
|
|
int populate();
|
|
bool isValid() const { return valid_; }
|
|
|
|
const std::string &driver() const { return driver_; }
|
|
const std::string &deviceNode() const { return deviceNode_; }
|
|
const std::string &model() const { return model_; }
|
|
unsigned int version() const { return version_; }
|
|
unsigned int hwRevision() const { return hwRevision_; }
|
|
|
|
const std::vector<MediaEntity *> &entities() const { return entities_; }
|
|
MediaEntity *getEntityByName(const std::string &name) const;
|
|
|
|
MediaLink *link(const std::string &sourceName, unsigned int sourceIdx,
|
|
const std::string &sinkName, unsigned int sinkIdx);
|
|
MediaLink *link(const MediaEntity *source, unsigned int sourceIdx,
|
|
const MediaEntity *sink, unsigned int sinkIdx);
|
|
MediaLink *link(const MediaPad *source, const MediaPad *sink);
|
|
int disableLinks();
|
|
|
|
Signal<> disconnected;
|
|
|
|
protected:
|
|
std::string logPrefix() const override;
|
|
|
|
private:
|
|
int open();
|
|
void close();
|
|
|
|
MediaObject *object(unsigned int id);
|
|
bool addObject(MediaObject *object);
|
|
void clear();
|
|
|
|
struct media_v2_interface *findInterface(const struct media_v2_topology &topology,
|
|
unsigned int entityId);
|
|
bool populateEntities(const struct media_v2_topology &topology);
|
|
bool populatePads(const struct media_v2_topology &topology);
|
|
bool populateLinks(const struct media_v2_topology &topology);
|
|
void fixupEntityFlags(struct media_v2_entity *entity);
|
|
|
|
friend int MediaLink::setEnabled(bool enable);
|
|
int setupLink(const MediaLink *link, unsigned int flags);
|
|
|
|
std::string driver_;
|
|
std::string deviceNode_;
|
|
std::string model_;
|
|
unsigned int version_;
|
|
unsigned int hwRevision_;
|
|
|
|
UniqueFD fd_;
|
|
bool valid_;
|
|
bool acquired_;
|
|
|
|
std::map<unsigned int, MediaObject *> objects_;
|
|
std::vector<MediaEntity *> entities_;
|
|
};
|
|
|
|
} /* namespace libcamera */
|