summaryrefslogtreecommitdiff
path: root/src/ipa/rpi/controller/rpi/agc_channel.cpp
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2024-05-08 19:28:06 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2024-05-08 22:39:50 +0300
commit626172a16bba9a601c7652569ce9410631c1e6c0 (patch)
treef337079cde5d77b81b39023576c6ee5e91725f1e /src/ipa/rpi/controller/rpi/agc_channel.cpp
parentfdcd5d04ec6a3b3c98a46041762cdaf4bdb76190 (diff)
libcamera: Drop file name from header comment blocks
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>
Diffstat (limited to 'src/ipa/rpi/controller/rpi/agc_channel.cpp')
='n101' href='#n101'>101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 * Copyright (C) 2020, Google Inc.
 *
 * flags.cpp - Flags tests
 */

#include <iostream>

#include <libcamera/base/flags.h>

#include "test.h"

using namespace libcamera;
using namespace std;

class FlagsTest : public Test
{
protected:
	enum class Option {
		First = (1 << 0),
		Second = (1 << 1),
		Third = (1 << 2),
	};

	using Options = Flags<Option>;

	enum class Mode {
		Alpha = (1 << 0),
		Beta = (1 << 1),
		Gamma = (1 << 2),
	};

	using Modes = Flags<Mode>;

	int run() override;
};

namespace libcamera {

LIBCAMERA_FLAGS_ENABLE_OPERATORS(FlagsTest::Option)

} /* namespace libcamera */

int FlagsTest::run()
{
	/* Commented-out constructs are expected not to compile. */

	/* Flags<int> f; */

	/*
	 * Unary operators with enum argument.
	 */

	Options options;

	if (options) {
		cerr << "Default-constructed Flags<> is not zero" << endl;
		return TestFail;
	}

	options |= Option::First;
	if (!options || options != Option::First) {
		cerr << "Unary bitwise OR with enum failed" << endl;
		return TestFail;
	}

	/* options &= Mode::Alpha; */
	/* options |= Mode::Beta;  */
	/* options ^= Mode::Gamma; */

	options &= ~Option::First;
	if (options) {
		cerr << "Unary bitwise AND with enum failed" << endl;
		return TestFail;
	}

	options ^= Option::Second;
	if (options != Option::Second) {
		cerr << "Unary bitwise XOR with enum failed" << endl;
		return TestFail;
	}

	options = Options();

	/*
	 * Unary operators with Flags argument.
	 */

	options |= Options(Option::First);
	if (options != Option::First) {
		cerr << "Unary bitwise OR with Flags<> failed" << endl;
		return TestFail;
	}

	/* options &= Options(Mode::Alpha); */
	/* options |= Options(Mode::Beta);  */
	/* options ^= Options(Mode::Gamma); */

	options &= ~Options(Option::First);
	if (options) {
		cerr << "Unary bitwise AND with Flags<> failed" << endl;
		return TestFail;
	}

	options ^= Options(Option::Second);
	if (options != Option::Second) {
		cerr << "Unary bitwise XOR with Flags<> failed" << endl;
		return TestFail;
	}

	options = Options();

	/*
	 * Binary operators with enum argument.
	 */

	options = options | Option::First;
	if (!(options & Option::First)) {
		cerr << "Binary bitwise OR with enum failed" << endl;
		return TestFail;
	}

	/* options = options & Mode::Alpha; */
	/* options = options | Mode::Beta;  */
	/* options = options ^ Mode::Gamma; */

	options = options & ~Option::First;
	if (options != (Option::First & Option::Second)) {
		cerr << "Binary bitwise AND with enum failed" << endl;
		return TestFail;
	}

	options = options ^ (Option::First ^ Option::Second);
	if (options != (Option::First | Option::Second)) {
		cerr << "Binary bitwise XOR with enum failed" << endl;
		return TestFail;
	}

	options = Options();

	/*
	 * Binary operators with Flags argument.
	 */

	options |= Options(Option::First);
	if (!(options & Option::First)) {
		cerr << "Binary bitwise OR with Flags<> failed" << endl;
		return TestFail;
	}

	/* options = options & Options(Mode::Alpha); */
	/* options = options | Options(Mode::Beta);  */
	/* options = options ^ Options(Mode::Gamma); */

	options = options & ~Options(Option::First);
	if (options) {
		cerr << "Binary bitwise AND with Flags<> failed" << endl;
		return TestFail;
	}

	options = options ^ Options(Option::Second);
	if (options != Option::Second) {
		cerr << "Binary bitwise XOR with Flags<> failed" << endl;
		return TestFail;
	}

	options = Options();

	/*
	 * Conversion operators.
	 */

	options |= Option::First | Option::Second | Option::Third;
	if (static_cast<Options::Type>(options) != 7) {
		cerr << "Cast to underlying type failed" << endl;
		return TestFail;
	}

	/*
	 * Conversion of the result of ninary operators on the underlying enum.
	 */

	/* unsigned int val1 = Option::First; */
	/* unsigned int val2 = ~Option::First; */
	/* unsigned int val3 = Option::First | Option::Second; */
	/* Option val4 = ~Option::First; */
	/* Option val5 = Option::First | Option::Second; */

	return TestPass;
}

TEST_REGISTER(FlagsTest)