libcamera: Rename V4L2Device to V4L2VideoDevice

In preparation of creating a new V4L2Device base class, rename
V4L2Device to V4L2VideoDevice.

This is a project wide rename without any intended functional change.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Jacopo Mondi 2019-06-12 13:09:57 +01:00
parent 20807a8c17
commit 3a6c4bd146
19 changed files with 130 additions and 129 deletions

View file

@ -59,7 +59,7 @@ private:
friend class BufferPool;
friend class PipelineHandler;
friend class Request;
friend class V4L2Device;
friend class V4L2VideoDevice;
void cancel();

View file

@ -2,10 +2,10 @@
/*
* Copyright (C) 2019, Google Inc.
*
* v4l2_device.h - V4L2 Device
* v4l2_videodevice.h - V4L2 Video Device
*/
#ifndef __LIBCAMERA_V4L2_DEVICE_H__
#define __LIBCAMERA_V4L2_DEVICE_H__
#ifndef __LIBCAMERA_V4L2_VIDEODEVICE_H__
#define __LIBCAMERA_V4L2_VIDEODEVICE_H__
#include <atomic>
#include <string>
@ -112,15 +112,15 @@ public:
const std::string toString() const;
};
class V4L2Device : protected Loggable
class V4L2VideoDevice : protected Loggable
{
public:
explicit V4L2Device(const std::string &deviceNode);
explicit V4L2Device(const MediaEntity *entity);
V4L2Device(const V4L2Device &) = delete;
~V4L2Device();
explicit V4L2VideoDevice(const std::string &deviceNode);
explicit V4L2VideoDevice(const MediaEntity *entity);
V4L2VideoDevice(const V4L2VideoDevice &) = delete;
~V4L2VideoDevice();
V4L2Device &operator=(const V4L2Device &) = delete;
V4L2VideoDevice &operator=(const V4L2VideoDevice &) = delete;
int open();
bool isOpen() const;
@ -145,8 +145,8 @@ public:
int streamOn();
int streamOff();
static V4L2Device *fromEntityName(const MediaDevice *media,
const std::string &entity);
static V4L2VideoDevice *fromEntityName(const MediaDevice *media,
const std::string &entity);
protected:
std::string logPrefix() const;
@ -186,4 +186,4 @@ private:
} /* namespace libcamera */
#endif /* __LIBCAMERA_V4L2_DEVICE_H__ */
#endif /* __LIBCAMERA_V4L2_VIDEODEVICE_H__ */

View file

@ -23,8 +23,8 @@ libcamera_sources = files([
'stream.cpp',
'timer.cpp',
'utils.cpp',
'v4l2_device.cpp',
'v4l2_subdevice.cpp',
'v4l2_videodevice.cpp',
])
libcamera_headers = files([
@ -41,8 +41,8 @@ libcamera_headers = files([
'include/media_object.h',
'include/pipeline_handler.h',
'include/utils.h',
'include/v4l2_device.h',
'include/v4l2_subdevice.h',
'include/v4l2_videodevice.h',
])
libcamera_internal_includes = include_directories('include')

View file

@ -22,8 +22,8 @@
#include "media_device.h"
#include "pipeline_handler.h"
#include "utils.h"
#include "v4l2_device.h"
#include "v4l2_subdevice.h"
#include "v4l2_videodevice.h"
namespace libcamera {
@ -39,7 +39,7 @@ public:
/* ImgU output descriptor: group data specific to an ImgU output. */
struct ImgUOutput {
V4L2Device *dev;
V4L2VideoDevice *dev;
unsigned int pad;
std::string name;
BufferPool *pool;
@ -85,7 +85,7 @@ public:
MediaDevice *media_;
V4L2Subdevice *imgu_;
V4L2Device *input_;
V4L2VideoDevice *input_;
ImgUOutput output_;
ImgUOutput viewfinder_;
ImgUOutput stat_;
@ -125,7 +125,7 @@ public:
static int mediaBusToFormat(unsigned int code);
V4L2Device *output_;
V4L2VideoDevice *output_;
V4L2Subdevice *csi2_;
CameraSensor *sensor_;
@ -943,7 +943,7 @@ void IPU3CameraData::cio2BufferReady(Buffer *buffer)
* Create and open the V4L2 devices and subdevices of the ImgU instance
* with \a index.
*
* In case of errors the created V4L2Device and V4L2Subdevice instances
* In case of errors the created V4L2VideoDevice and V4L2Subdevice instances
* are destroyed at pipeline handler delete time.
*
* \return 0 on success or a negative error code otherwise
@ -966,12 +966,12 @@ int ImgUDevice::init(MediaDevice *media, unsigned int index)
if (ret)
return ret;
input_ = V4L2Device::fromEntityName(media, name_ + " input");
input_ = V4L2VideoDevice::fromEntityName(media, name_ + " input");
ret = input_->open();
if (ret)
return ret;
output_.dev = V4L2Device::fromEntityName(media, name_ + " output");
output_.dev = V4L2VideoDevice::fromEntityName(media, name_ + " output");
ret = output_.dev->open();
if (ret)
return ret;
@ -980,8 +980,8 @@ int ImgUDevice::init(MediaDevice *media, unsigned int index)
output_.name = "output";
output_.pool = &outPool_;
viewfinder_.dev = V4L2Device::fromEntityName(media,
name_ + " viewfinder");
viewfinder_.dev = V4L2VideoDevice::fromEntityName(media,
name_ + " viewfinder");
ret = viewfinder_.dev->open();
if (ret)
return ret;
@ -990,7 +990,7 @@ int ImgUDevice::init(MediaDevice *media, unsigned int index)
viewfinder_.name = "viewfinder";
viewfinder_.pool = &vfPool_;
stat_.dev = V4L2Device::fromEntityName(media, name_ + " 3a stat");
stat_.dev = V4L2VideoDevice::fromEntityName(media, name_ + " 3a stat");
ret = stat_.dev->open();
if (ret)
return ret;
@ -1067,7 +1067,7 @@ int ImgUDevice::configureInput(const Size &size,
int ImgUDevice::configureOutput(ImgUOutput *output,
const StreamConfiguration &cfg)
{
V4L2Device *dev = output->dev;
V4L2VideoDevice *dev = output->dev;
unsigned int pad = output->pad;
V4L2SubdeviceFormat imguFormat = {};
@ -1337,7 +1337,7 @@ int CIO2Device::init(const MediaDevice *media, unsigned int index)
return ret;
std::string cio2Name = "ipu3-cio2 " + std::to_string(index);
output_ = V4L2Device::fromEntityName(media, cio2Name);
output_ = V4L2VideoDevice::fromEntityName(media, cio2Name);
ret = output_->open();
if (ret)
return ret;

View file

@ -23,8 +23,8 @@
#include "media_device.h"
#include "pipeline_handler.h"
#include "utils.h"
#include "v4l2_device.h"
#include "v4l2_subdevice.h"
#include "v4l2_videodevice.h"
namespace libcamera {
@ -106,7 +106,7 @@ private:
MediaDevice *media_;
V4L2Subdevice *dphy_;
V4L2Subdevice *isp_;
V4L2Device *video_;
V4L2VideoDevice *video_;
Camera *activeCamera_;
};
@ -458,7 +458,7 @@ bool PipelineHandlerRkISP1::match(DeviceEnumerator *enumerator)
return false;
/* Locate and open the capture video node. */
video_ = V4L2Device::fromEntityName(media_, "rkisp1_mainpath");
video_ = V4L2VideoDevice::fromEntityName(media_, "rkisp1_mainpath");
if (video_->open() < 0)
return false;

View file

@ -16,7 +16,7 @@
#include "media_device.h"
#include "pipeline_handler.h"
#include "utils.h"
#include "v4l2_device.h"
#include "v4l2_videodevice.h"
namespace libcamera {
@ -37,7 +37,7 @@ public:
void bufferReady(Buffer *buffer);
V4L2Device *video_;
V4L2VideoDevice *video_;
Stream stream_;
};
@ -250,7 +250,7 @@ bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator)
/* Locate and open the default video node. */
for (MediaEntity *entity : media->entities()) {
if (entity->flags() & MEDIA_ENT_FL_DEFAULT) {
data->video_ = new V4L2Device(entity);
data->video_ = new V4L2VideoDevice(entity);
break;
}
}

View file

@ -20,7 +20,7 @@
#include "media_device.h"
#include "pipeline_handler.h"
#include "utils.h"
#include "v4l2_device.h"
#include "v4l2_videodevice.h"
namespace libcamera {
@ -41,7 +41,7 @@ public:
void bufferReady(Buffer *buffer);
V4L2Device *video_;
V4L2VideoDevice *video_;
Stream stream_;
};
@ -262,7 +262,7 @@ bool PipelineHandlerVimc::match(DeviceEnumerator *enumerator)
std::unique_ptr<VimcCameraData> data = utils::make_unique<VimcCameraData>(this);
/* Locate and open the capture video node. */
data->video_ = new V4L2Device(media->getEntityByName("Raw Capture 1"));
data->video_ = new V4L2VideoDevice(media->getEntityByName("Raw Capture 1"));
if (data->video_->open())
return false;

View file

@ -44,7 +44,7 @@ LOG_DEFINE_CATEGORY(V4L2Subdev)
* as the "media bus format", and it is identified by a resolution and a pixel
* format identification code, known as the "media bus code", not to be confused
* with the fourcc code that identify the format of images when stored in memory
* (see V4L2Device::V4L2DeviceFormat).
* (see V4L2VideoDevice::V4L2DeviceFormat).
*
* Media Bus formats supported by the V4L2 APIs are described in Section
* 4.15.3.4.1 of the "Part I - Video for Linux API" chapter of the "Linux Media

View file

@ -2,10 +2,10 @@
/*
* Copyright (C) 2019, Google Inc.
*
* v4l2_device.cpp - V4L2 Device
* v4l2_videodevice.cpp - V4L2 Video Device
*/
#include "v4l2_device.h"
#include "v4l2_videodevice.h"
#include <fcntl.h>
#include <iomanip>
@ -25,8 +25,8 @@
#include "media_object.h"
/**
* \file v4l2_device.h
* \brief V4L2 Device API
* \file v4l2_videodevice.h
* \brief V4L2 Video Device API
*/
namespace libcamera {
@ -243,8 +243,8 @@ const std::string V4L2DeviceFormat::toString() const
}
/**
* \class V4L2Device
* \brief V4L2Device object and API
* \class V4L2VideoDevice
* \brief V4L2VideoDevice object and API
*
* The V4L2 Device API class models an instance of a V4L2 device node.
* It is constructed with the path to a V4L2 video device node. The device node
@ -257,7 +257,7 @@ const std::string V4L2DeviceFormat::toString() const
* No API call other than open(), isOpen() and close() shall be called on an
* unopened device instance.
*
* The V4L2Device class tracks queued buffers and handles buffer events. It
* The V4L2VideoDevice class tracks queued buffers and handles buffer events. It
* automatically dequeues completed buffers and emits the \ref bufferReady
* signal.
*
@ -266,10 +266,10 @@ const std::string V4L2DeviceFormat::toString() const
*/
/**
* \brief Construct a V4L2Device
* \brief Construct a V4L2VideoDevice
* \param[in] deviceNode The file-system path to the video device node
*/
V4L2Device::V4L2Device(const std::string &deviceNode)
V4L2VideoDevice::V4L2VideoDevice(const std::string &deviceNode)
: deviceNode_(deviceNode), fd_(-1), bufferPool_(nullptr),
queuedBuffersCount_(0), fdEvent_(nullptr)
{
@ -282,17 +282,17 @@ V4L2Device::V4L2Device(const std::string &deviceNode)
}
/**
* \brief Construct a V4L2Device from a MediaEntity
* \brief Construct a V4L2VideoDevice from a MediaEntity
* \param[in] entity The MediaEntity to build the device from
*
* Construct a V4L2Device from a MediaEntity's device node path.
* Construct a V4L2VideoDevice from a MediaEntity's device node path.
*/
V4L2Device::V4L2Device(const MediaEntity *entity)
: V4L2Device(entity->deviceNode())
V4L2VideoDevice::V4L2VideoDevice(const MediaEntity *entity)
: V4L2VideoDevice(entity->deviceNode())
{
}
V4L2Device::~V4L2Device()
V4L2VideoDevice::~V4L2VideoDevice()
{
close();
}
@ -301,7 +301,7 @@ V4L2Device::~V4L2Device()
* \brief Open a V4L2 device and query its capabilities
* \return 0 on success or a negative error code otherwise
*/
int V4L2Device::open()
int V4L2VideoDevice::open()
{
int ret;
@ -362,7 +362,7 @@ int V4L2Device::open()
return -EINVAL;
}
fdEvent_->activated.connect(this, &V4L2Device::bufferAvailable);
fdEvent_->activated.connect(this, &V4L2VideoDevice::bufferAvailable);
fdEvent_->setEnabled(false);
return 0;
@ -372,7 +372,7 @@ int V4L2Device::open()
* \brief Check if device is successfully opened
* \return True if the device is open, false otherwise
*/
bool V4L2Device::isOpen() const
bool V4L2VideoDevice::isOpen() const
{
return fd_ != -1;
}
@ -380,7 +380,7 @@ bool V4L2Device::isOpen() const
/**
* \brief Close the device, releasing any resources acquired by open()
*/
void V4L2Device::close()
void V4L2VideoDevice::close()
{
if (fd_ < 0)
return;
@ -393,30 +393,30 @@ void V4L2Device::close()
}
/**
* \fn V4L2Device::driverName()
* \fn V4L2VideoDevice::driverName()
* \brief Retrieve the name of the V4L2 device driver
* \return The string containing the driver name
*/
/**
* \fn V4L2Device::deviceName()
* \fn V4L2VideoDevice::deviceName()
* \brief Retrieve the name of the V4L2 device
* \return The string containing the device name
*/
/**
* \fn V4L2Device::busName()
* \fn V4L2VideoDevice::busName()
* \brief Retrieve the location of the device in the system
* \return The string containing the device location
*/
/**
* \fn V4L2Device::deviceNode()
* \fn V4L2VideoDevice::deviceNode()
* \brief Retrieve the video device node path
* \return The video device device node path
*/
std::string V4L2Device::logPrefix() const
std::string V4L2VideoDevice::logPrefix() const
{
return deviceNode_ + (V4L2_TYPE_IS_OUTPUT(bufferType_) ? "[out]" : "[cap]");
}
@ -426,7 +426,7 @@ std::string V4L2Device::logPrefix() const
* \param[out] format The image format applied on the device
* \return 0 on success or a negative error code otherwise
*/
int V4L2Device::getFormat(V4L2DeviceFormat *format)
int V4L2VideoDevice::getFormat(V4L2DeviceFormat *format)
{
if (caps_.isMeta())
return getFormatMeta(format);
@ -441,11 +441,11 @@ int V4L2Device::getFormat(V4L2DeviceFormat *format)
* \param[inout] format The image format to apply to the device
*
* Apply the supplied \a format to the device, and return the actually
* applied format parameters, as \ref V4L2Device::getFormat would do.
* applied format parameters, as \ref V4L2VideoDevice::getFormat would do.
*
* \return 0 on success or a negative error code otherwise
*/
int V4L2Device::setFormat(V4L2DeviceFormat *format)
int V4L2VideoDevice::setFormat(V4L2DeviceFormat *format)
{
if (caps_.isMeta())
return setFormatMeta(format);
@ -455,7 +455,7 @@ int V4L2Device::setFormat(V4L2DeviceFormat *format)
return setFormatSingleplane(format);
}
int V4L2Device::getFormatMeta(V4L2DeviceFormat *format)
int V4L2VideoDevice::getFormatMeta(V4L2DeviceFormat *format)
{
struct v4l2_format v4l2Format = {};
struct v4l2_meta_format *pix = &v4l2Format.fmt.meta;
@ -479,7 +479,7 @@ int V4L2Device::getFormatMeta(V4L2DeviceFormat *format)
return 0;
}
int V4L2Device::setFormatMeta(V4L2DeviceFormat *format)
int V4L2VideoDevice::setFormatMeta(V4L2DeviceFormat *format)
{
struct v4l2_format v4l2Format = {};
struct v4l2_meta_format *pix = &v4l2Format.fmt.meta;
@ -509,7 +509,7 @@ int V4L2Device::setFormatMeta(V4L2DeviceFormat *format)
return 0;
}
int V4L2Device::getFormatMultiplane(V4L2DeviceFormat *format)
int V4L2VideoDevice::getFormatMultiplane(V4L2DeviceFormat *format)
{
struct v4l2_format v4l2Format = {};
struct v4l2_pix_format_mplane *pix = &v4l2Format.fmt.pix_mp;
@ -536,7 +536,7 @@ int V4L2Device::getFormatMultiplane(V4L2DeviceFormat *format)
return 0;
}
int V4L2Device::setFormatMultiplane(V4L2DeviceFormat *format)
int V4L2VideoDevice::setFormatMultiplane(V4L2DeviceFormat *format)
{
struct v4l2_format v4l2Format = {};
struct v4l2_pix_format_mplane *pix = &v4l2Format.fmt.pix_mp;
@ -577,7 +577,7 @@ int V4L2Device::setFormatMultiplane(V4L2DeviceFormat *format)
return 0;
}
int V4L2Device::getFormatSingleplane(V4L2DeviceFormat *format)
int V4L2VideoDevice::getFormatSingleplane(V4L2DeviceFormat *format)
{
struct v4l2_format v4l2Format = {};
struct v4l2_pix_format *pix = &v4l2Format.fmt.pix;
@ -601,7 +601,7 @@ int V4L2Device::getFormatSingleplane(V4L2DeviceFormat *format)
return 0;
}
int V4L2Device::setFormatSingleplane(V4L2DeviceFormat *format)
int V4L2VideoDevice::setFormatSingleplane(V4L2DeviceFormat *format)
{
struct v4l2_format v4l2Format = {};
struct v4l2_pix_format *pix = &v4l2Format.fmt.pix;
@ -641,7 +641,7 @@ int V4L2Device::setFormatSingleplane(V4L2DeviceFormat *format)
*
* \return A list of the supported device formats
*/
ImageFormats V4L2Device::formats()
ImageFormats V4L2VideoDevice::formats()
{
ImageFormats formats;
@ -661,7 +661,7 @@ ImageFormats V4L2Device::formats()
return formats;
}
int V4L2Device::requestBuffers(unsigned int count)
int V4L2VideoDevice::requestBuffers(unsigned int count)
{
struct v4l2_requestbuffers rb = {};
int ret;
@ -690,7 +690,7 @@ int V4L2Device::requestBuffers(unsigned int count)
* \param[out] pool BufferPool to populate with buffers
* \return 0 on success or a negative error code otherwise
*/
int V4L2Device::exportBuffers(BufferPool *pool)
int V4L2VideoDevice::exportBuffers(BufferPool *pool)
{
unsigned int allocatedBuffers;
unsigned int i;
@ -704,7 +704,8 @@ int V4L2Device::exportBuffers(BufferPool *pool)
allocatedBuffers = ret;
if (allocatedBuffers < pool->count()) {
LOG(V4L2, Error) << "Not enough buffers provided by V4L2Device";
LOG(V4L2, Error)
<< "Not enough buffers provided by V4L2VideoDevice";
requestBuffers(0);
return -ENOMEM;
}
@ -758,8 +759,8 @@ int V4L2Device::exportBuffers(BufferPool *pool)
return 0;
}
int V4L2Device::createPlane(Buffer *buffer, unsigned int planeIndex,
unsigned int length)
int V4L2VideoDevice::createPlane(Buffer *buffer, unsigned int planeIndex,
unsigned int length)
{
struct v4l2_exportbuffer expbuf = {};
int ret;
@ -790,7 +791,7 @@ int V4L2Device::createPlane(Buffer *buffer, unsigned int planeIndex,
return 0;
}
std::vector<unsigned int> V4L2Device::enumPixelformats()
std::vector<unsigned int> V4L2VideoDevice::enumPixelformats()
{
std::vector<unsigned int> formats;
int ret;
@ -818,7 +819,7 @@ std::vector<unsigned int> V4L2Device::enumPixelformats()
return formats;
}
std::vector<SizeRange> V4L2Device::enumSizes(unsigned int pixelFormat)
std::vector<SizeRange> V4L2VideoDevice::enumSizes(unsigned int pixelFormat)
{
std::vector<SizeRange> sizes;
int ret;
@ -882,7 +883,7 @@ std::vector<SizeRange> V4L2Device::enumSizes(unsigned int pixelFormat)
* \param[in] pool BufferPool of buffers to import
* \return 0 on success or a negative error code otherwise
*/
int V4L2Device::importBuffers(BufferPool *pool)
int V4L2VideoDevice::importBuffers(BufferPool *pool)
{
unsigned int allocatedBuffers;
int ret;
@ -896,7 +897,7 @@ int V4L2Device::importBuffers(BufferPool *pool)
allocatedBuffers = ret;
if (allocatedBuffers < pool->count()) {
LOG(V4L2, Error)
<< "Not enough buffers provided by V4L2Device";
<< "Not enough buffers provided by V4L2VideoDevice";
requestBuffers(0);
return -ENOMEM;
}
@ -910,7 +911,7 @@ int V4L2Device::importBuffers(BufferPool *pool)
/**
* \brief Release all internally allocated buffers
*/
int V4L2Device::releaseBuffers()
int V4L2VideoDevice::releaseBuffers()
{
LOG(V4L2, Debug) << "Releasing bufferPool";
@ -930,7 +931,7 @@ int V4L2Device::releaseBuffers()
*
* \return 0 on success or a negative error code otherwise
*/
int V4L2Device::queueBuffer(Buffer *buffer)
int V4L2VideoDevice::queueBuffer(Buffer *buffer)
{
struct v4l2_buffer buf = {};
struct v4l2_plane planes[VIDEO_MAX_PLANES] = {};
@ -991,7 +992,7 @@ int V4L2Device::queueBuffer(Buffer *buffer)
*
* \return A pointer to the dequeued buffer on success, or nullptr otherwise
*/
Buffer *V4L2Device::dequeueBuffer()
Buffer *V4L2VideoDevice::dequeueBuffer()
{
struct v4l2_buffer buf = {};
struct v4l2_plane planes[VIDEO_MAX_PLANES] = {};
@ -1040,7 +1041,7 @@ Buffer *V4L2Device::dequeueBuffer()
* For Capture devices the Buffer will contain valid data.
* For Output devices the Buffer can be considered empty.
*/
void V4L2Device::bufferAvailable(EventNotifier *notifier)
void V4L2VideoDevice::bufferAvailable(EventNotifier *notifier)
{
Buffer *buffer = dequeueBuffer();
if (!buffer)
@ -1053,7 +1054,7 @@ void V4L2Device::bufferAvailable(EventNotifier *notifier)
}
/**
* \var V4L2Device::bufferReady
* \var V4L2VideoDevice::bufferReady
* \brief A Signal emitted when a buffer completes
*/
@ -1061,7 +1062,7 @@ void V4L2Device::bufferAvailable(EventNotifier *notifier)
* \brief Start the video stream
* \return 0 on success or a negative error code otherwise
*/
int V4L2Device::streamOn()
int V4L2VideoDevice::streamOn()
{
int ret;
@ -1084,7 +1085,7 @@ int V4L2Device::streamOn()
*
* \return 0 on success or a negative error code otherwise
*/
int V4L2Device::streamOff()
int V4L2VideoDevice::streamOff()
{
int ret;
@ -1111,16 +1112,16 @@ int V4L2Device::streamOff()
* Releasing memory of the newly created instance is responsibility of the
* caller of this function.
*
* \return A newly created V4L2Device on success, nullptr otherwise
* \return A newly created V4L2VideoDevice on success, nullptr otherwise
*/
V4L2Device *V4L2Device::fromEntityName(const MediaDevice *media,
const std::string &entity)
V4L2VideoDevice *V4L2VideoDevice::fromEntityName(const MediaDevice *media,
const std::string &entity)
{
MediaEntity *mediaEntity = media->getEntityByName(entity);
if (!mediaEntity)
return nullptr;
return new V4L2Device(mediaEntity);
return new V4L2VideoDevice(mediaEntity);
}
} /* namespace libcamera */

View file

@ -5,8 +5,8 @@ subdir('ipa')
subdir('media_device')
subdir('pipeline')
subdir('stream')
subdir('v4l2_device')
subdir('v4l2_subdevice')
subdir('v4l2_videodevice')
public_tests = [
['event', 'event.cpp'],

View file

@ -4,8 +4,8 @@
*
* libcamera V4L2 API tests
*
* Validate the function of exporting buffers from a V4L2Device and
* the ability to import them to another V4L2Device instance.
* Validate the function of exporting buffers from a V4L2VideoDevice and
* the ability to import them to another V4L2VideoDevice instance.
* Ensure that the Buffers can successfully be queued and dequeued
* between both devices.
*/
@ -17,19 +17,19 @@
#include <libcamera/event_dispatcher.h>
#include <libcamera/timer.h>
#include "v4l2_device_test.h"
#include "v4l2_videodevice_test.h"
class BufferSharingTest : public V4L2DeviceTest
class BufferSharingTest : public V4L2VideoDeviceTest
{
public:
BufferSharingTest()
: V4L2DeviceTest("vivid", "vivid-000-vid-cap"),
: V4L2VideoDeviceTest("vivid", "vivid-000-vid-cap"),
output_(nullptr), framesCaptured_(0), framesOutput_(0) {}
protected:
int init()
{
int ret = V4L2DeviceTest::init();
int ret = V4L2VideoDeviceTest::init();
if (ret)
return ret;
@ -38,7 +38,7 @@ protected:
if (!entity)
return TestSkip;
output_ = new V4L2Device(entity);
output_ = new V4L2VideoDevice(entity);
if (!output_) {
std::cout << "Failed to create output device" << std::endl;
return TestFail;
@ -171,13 +171,13 @@ protected:
delete output_;
V4L2DeviceTest::cleanup();
V4L2VideoDeviceTest::cleanup();
}
private:
const unsigned int bufferCount = 4;
V4L2Device *output_;
V4L2VideoDevice *output_;
unsigned int framesCaptured_;
unsigned int framesOutput_;

View file

@ -12,13 +12,13 @@
#include <iostream>
#include "v4l2_device_test.h"
#include "v4l2_videodevice_test.h"
class CaptureAsyncTest : public V4L2DeviceTest
class CaptureAsyncTest : public V4L2VideoDeviceTest
{
public:
CaptureAsyncTest()
: V4L2DeviceTest("vimc", "Raw Capture 0"), frames(0) {}
: V4L2VideoDeviceTest("vimc", "Raw Capture 0"), frames(0) {}
void receiveBuffer(Buffer *buffer)
{

View file

@ -7,15 +7,15 @@
#include <iostream>
#include "v4l2_device_test.h"
#include "v4l2_videodevice_test.h"
namespace {
class DoubleOpen : public V4L2DeviceTest
class DoubleOpen : public V4L2VideoDeviceTest
{
public:
DoubleOpen()
: V4L2DeviceTest("vimc", "Raw Capture 0") {}
: V4L2VideoDeviceTest("vimc", "Raw Capture 0") {}
protected:
int run()
{
@ -23,7 +23,7 @@ protected:
/*
* Expect failure: The device has already been opened by the
* V4L2DeviceTest base class
* V4L2VideoDeviceTest base class
*/
ret = capture_->open();
if (!ret) {

View file

@ -8,18 +8,18 @@
#include <climits>
#include <iostream>
#include "v4l2_device.h"
#include "v4l2_videodevice.h"
#include "v4l2_device_test.h"
#include "v4l2_videodevice_test.h"
using namespace std;
using namespace libcamera;
class Format : public V4L2DeviceTest
class Format : public V4L2VideoDeviceTest
{
public:
Format()
: V4L2DeviceTest("vimc", "Raw Capture 0") {}
: V4L2VideoDeviceTest("vimc", "Raw Capture 0") {}
protected:
int run()
{

View file

@ -1,6 +1,6 @@
# Tests are listed in order of complexity.
# They are not alphabetically sorted.
v4l2_device_tests = [
v4l2_videodevice_tests = [
[ 'double_open', 'double_open.cpp' ],
[ 'formats', 'formats.cpp' ],
[ 'request_buffers', 'request_buffers.cpp' ],
@ -9,10 +9,10 @@ v4l2_device_tests = [
[ 'buffer_sharing', 'buffer_sharing.cpp' ],
]
foreach t : v4l2_device_tests
exe = executable(t[0], [t[1], 'v4l2_device_test.cpp'],
foreach t : v4l2_videodevice_tests
exe = executable(t[0], [t[1], 'v4l2_videodevice_test.cpp'],
dependencies : libcamera_dep,
link_with : test_libraries,
include_directories : test_includes_internal)
test(t[0], exe, suite : 'v4l2_device', is_parallel : false)
test(t[0], exe, suite : 'v4l2_videodevice', is_parallel : false)
endforeach

View file

@ -5,13 +5,13 @@
* libcamera V4L2 API tests
*/
#include "v4l2_device_test.h"
#include "v4l2_videodevice_test.h"
class RequestBuffersTest : public V4L2DeviceTest
class RequestBuffersTest : public V4L2VideoDeviceTest
{
public:
RequestBuffersTest()
: V4L2DeviceTest("vimc", "Raw Capture 0") {}
: V4L2VideoDeviceTest("vimc", "Raw Capture 0") {}
protected:
int run()

View file

@ -5,13 +5,13 @@
* libcamera V4L2 API tests
*/
#include "v4l2_device_test.h"
#include "v4l2_videodevice_test.h"
class StreamOnStreamOffTest : public V4L2DeviceTest
class StreamOnStreamOffTest : public V4L2VideoDeviceTest
{
public:
StreamOnStreamOffTest()
: V4L2DeviceTest("vimc", "Raw Capture 0") {}
: V4L2VideoDeviceTest("vimc", "Raw Capture 0") {}
protected:
int run()
{

View file

@ -8,7 +8,7 @@
#include <iostream>
#include <sys/stat.h>
#include "v4l2_device_test.h"
#include "v4l2_videodevice_test.h"
#include "device_enumerator.h"
#include "media_device.h"
@ -26,7 +26,7 @@ bool exists(const std::string &path)
return false;
}
int V4L2DeviceTest::init()
int V4L2VideoDeviceTest::init()
{
enumerator_ = DeviceEnumerator::create();
if (!enumerator_) {
@ -50,7 +50,7 @@ int V4L2DeviceTest::init()
if (!entity)
return TestSkip;
capture_ = new V4L2Device(entity);
capture_ = new V4L2VideoDevice(entity);
if (!capture_)
return TestFail;
@ -77,7 +77,7 @@ int V4L2DeviceTest::init()
return TestPass;
}
void V4L2DeviceTest::cleanup()
void V4L2VideoDeviceTest::cleanup()
{
capture_->streamOff();
capture_->releaseBuffers();

View file

@ -15,14 +15,14 @@
#include "device_enumerator.h"
#include "media_device.h"
#include "v4l2_device.h"
#include "v4l2_videodevice.h"
using namespace libcamera;
class V4L2DeviceTest : public Test
class V4L2VideoDeviceTest : public Test
{
public:
V4L2DeviceTest(const char *driver, const char *entity)
V4L2VideoDeviceTest(const char *driver, const char *entity)
: driver_(driver), entity_(entity), capture_(nullptr)
{
}
@ -35,7 +35,7 @@ protected:
std::string entity_;
std::unique_ptr<DeviceEnumerator> enumerator_;
std::shared_ptr<MediaDevice> media_;
V4L2Device *capture_;
V4L2VideoDevice *capture_;
BufferPool pool_;
};