summaryrefslogtreecommitdiff
path: root/utils/codegen/gen-controls.py
AgeCommit message (Collapse)Author
2024-08-16utils: codegen: gen-controls.py: Move helper classes to separate fileLaurent Pinchart
The ControlEnum and Control helper classes defined in gen-controls.py are useful for other generator scripts. Move them to a separate file to make it possible to share them. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
2024-08-16utils: codegen: gen-controls.py: Convert to jinja2 templatesLaurent Pinchart
Jinja2 templates help separate the logic related to the template from the generation of the data. The python code becomes much clearer as a result. As an added bonus, we can use a single template file for both controls and properties. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2024-08-15meson: Move all code generation scripts to utils/codegen/Laurent Pinchart
We have multiple code generation scripts in utils/, mixed with other miscellaneous utilities, as well as a larger code base based on mojom in utils/ipc/. To make code sharing easier between the generator scripts, without creating a mess in the utils/ directory, move all the code generation code to utils/codegen/. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
='n11' href='#n11'>11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
 * Copyright (C) 2020, Raspberry Pi Ltd
 *
 * bayer_format.h - Bayer Pixel Format
 */

#pragma once

#include <ostream>
#include <stdint.h>
#include <string>

#include <libcamera/pixel_format.h>

#include "libcamera/internal/v4l2_pixelformat.h"

namespace libcamera {

enum class Transform;

class BayerFormat
{
public:
	enum Order : uint8_t {
		BGGR = 0,
		GBRG = 1,
		GRBG = 2,
		RGGB = 3,
		MONO = 4
	};

	enum class Packing : uint16_t {
		None = 0,
		CSI2 = 1,
		IPU3 = 2,
	};

	constexpr BayerFormat()
		: order(Order::BGGR), bitDepth(0), packing(Packing::None)
	{
	}

	constexpr BayerFormat(Order o, uint8_t b, Packing p)
		: order(o), bitDepth(b), packing(p)
	{
	}

	static const BayerFormat &fromMbusCode(unsigned int mbusCode);
	bool isValid() const { return bitDepth != 0; }

	std::string toString() const;

	V4L2PixelFormat toV4L2PixelFormat() const;
	static BayerFormat fromV4L2PixelFormat(V4L2PixelFormat v4l2Format);
	PixelFormat toPixelFormat() const;
	static BayerFormat fromPixelFormat(PixelFormat format);
	BayerFormat transform(Transform t) const;

	Order order;
	uint8_t bitDepth;

	Packing packing;
};

bool operator==(const BayerFormat &lhs, const BayerFormat &rhs);
static inline bool operator!=(const BayerFormat &lhs, const BayerFormat &rhs)
{
	return !(lhs == rhs);
}

std::ostream &operator<<(std::ostream &out, const BayerFormat &f);

} /* namespace libcamera */