libcamera: Add V4L2Subdevice

Add V4L2Subdevice class that provides an interface to interact with
V4L2 defined sub-devices.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
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>
This commit is contained in:
Jacopo Mondi
2019-01-29 15:16:22 +01:00
committed by Laurent Pinchart
parent 8dbc203bb2
commit 468176fa07
3 changed files with 317 additions and 0 deletions
+51
View File
@@ -0,0 +1,51 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2019, Google Inc.
*
* v4l2_subdevice.h - V4L2 Subdevice
*/
#ifndef __LIBCAMERA_V4L2_SUBDEVICE_H__
#define __LIBCAMERA_V4L2_SUBDEVICE_H__
#include <string>
namespace libcamera {
struct Rectangle;
struct V4L2SubdeviceFormat {
uint32_t mbus_code;
uint32_t width;
uint32_t height;
};
class V4L2Subdevice
{
public:
explicit V4L2Subdevice(const MediaEntity *entity);
V4L2Subdevice(const V4L2Subdevice &) = delete;
V4L2Subdevice &operator=(const V4L2Subdevice &) = delete;
int open();
bool isOpen() const;
void close();
std::string deviceNode() const { return deviceNode_; }
int setCrop(unsigned int pad, Rectangle *rect);
int setCompose(unsigned int pad, Rectangle *rect);
int getFormat(unsigned int pad, V4L2SubdeviceFormat *format);
int setFormat(unsigned int pad, V4L2SubdeviceFormat *format);
private:
int setSelection(unsigned int pad, unsigned int target,
Rectangle *rect);
std::string deviceNode_;
int fd_;
};
} /* namespace libcamera */
#endif /* __LIBCAMERA_V4L2_SUBDEVICE_H__ */