Files
external_libcamera/include/libcamera/internal/v4l2_subdevice.h
Han-Lin Chen 5d2aad02e8 libcamera: add model() for retrieving model name in V4L2Subdevice
CameraSensor retrieves model name from media entity. Move the heuristics
method into V4L2Subdevice, so CameraLens can reuse the function.

Signed-off-by: Han-Lin Chen <hanlinchen@chromium.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-12-03 10:23:26 +00:00

85 lines
1.7 KiB
C++

/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2019, Google Inc.
*
* v4l2_subdevice.h - V4L2 Subdevice
*/
#pragma once
#include <memory>
#include <string>
#include <vector>
#include <libcamera/base/class.h>
#include <libcamera/base/log.h>
#include <libcamera/geometry.h>
#include "libcamera/internal/formats.h"
#include "libcamera/internal/media_object.h"
#include "libcamera/internal/v4l2_device.h"
namespace libcamera {
class MediaDevice;
struct V4L2SubdeviceFormat {
uint32_t mbus_code;
Size size;
const std::string toString() const;
uint8_t bitsPerPixel() const;
};
class V4L2Subdevice : public V4L2Device
{
public:
using Formats = std::map<unsigned int, std::vector<SizeRange>>;
enum Whence {
ActiveFormat,
TryFormat,
};
explicit V4L2Subdevice(const MediaEntity *entity);
~V4L2Subdevice();
int open();
const MediaEntity *entity() const { return entity_; }
int getSelection(unsigned int pad, unsigned int target,
Rectangle *rect);
int setSelection(unsigned int pad, unsigned int target,
Rectangle *rect);
Formats formats(unsigned int pad);
int getFormat(unsigned int pad, V4L2SubdeviceFormat *format,
Whence whence = ActiveFormat);
int setFormat(unsigned int pad, V4L2SubdeviceFormat *format,
Whence whence = ActiveFormat);
const std::string &model();
static std::unique_ptr<V4L2Subdevice>
fromEntityName(const MediaDevice *media, const std::string &entity);
protected:
std::string logPrefix() const override;
private:
LIBCAMERA_DISABLE_COPY(V4L2Subdevice)
std::vector<unsigned int> enumPadCodes(unsigned int pad);
std::vector<SizeRange> enumPadSizes(unsigned int pad,
unsigned int code);
const MediaEntity *entity_;
std::string model_;
};
} /* namespace libcamera */