summaryrefslogtreecommitdiff
path: root/src/android/camera3_hal.cpp
diff options
context:
space:
mode:
authorJacopo Mondi <jacopo@jmondi.org>2020-12-30 17:15:51 +0100
committerJacopo Mondi <jacopo@jmondi.org>2021-01-18 10:39:14 +0100
commitc35123e6f91b6269cf6f5ae9216aeccebc545c75 (patch)
treeee6d5f281d06fe83e20654b19430e28c84d8d66d /src/android/camera3_hal.cpp
parent87ceac9c8cc0afb3be0f68155cd0f906cbb98120 (diff)
libcamera: camera_sensor: Do not default 'rotation'
The 'rotation' property is not critical. Only register it if the sensor driver reports it. Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'src/android/camera3_hal.cpp')
0 files changed, 0 insertions, 0 deletions
ef='#n118'>118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 * Copyright (C) 2019, Google Inc.
 *
 * V4L2 device controls handling test
 */

#include <algorithm>
#include <array>
#include <iostream>
#include <limits.h>

#include "libcamera/internal/v4l2_videodevice.h"

#include "v4l2_videodevice_test.h"

/* These come from the vivid driver. */
#define VIVID_CID_CUSTOM_BASE		(V4L2_CID_USER_BASE | 0xf000)
#define VIVID_CID_INTEGER64		(VIVID_CID_CUSTOM_BASE + 3)
#define VIVID_CID_U8_4D_ARRAY		(VIVID_CID_CUSTOM_BASE + 10)

/* Helper for VIVID_CID_U8_4D_ARRAY control array size: not from kernel. */
#define VIVID_CID_U8_ARRAY_SIZE		(2 * 3 * 4 * 5)

using namespace std;
using namespace libcamera;

class V4L2ControlTest : public V4L2VideoDeviceTest
{
public:
	V4L2ControlTest()
		: V4L2VideoDeviceTest("vivid", "vivid-000-vid-cap")
	{
	}

protected:
	int run()
	{
		const ControlInfoMap &infoMap = capture_->controls();

		/* Test control enumeration. */
		if (infoMap.empty()) {
			cerr << "Failed to enumerate controls" << endl;
			return TestFail;
		}

		if (infoMap.find(V4L2_CID_BRIGHTNESS) == infoMap.end() ||
		    infoMap.find(V4L2_CID_CONTRAST) == infoMap.end() ||
		    infoMap.find(V4L2_CID_SATURATION) == infoMap.end() ||
		    infoMap.find(VIVID_CID_INTEGER64) == infoMap.end() ||
		    infoMap.find(VIVID_CID_U8_4D_ARRAY) == infoMap.end()) {
			cerr << "Missing controls" << endl;
			return TestFail;
		}

		const ControlInfo &brightness = infoMap.find(V4L2_CID_BRIGHTNESS)->second;
		const ControlInfo &contrast = infoMap.find(V4L2_CID_CONTRAST)->second;
		const ControlInfo &saturation = infoMap.find(V4L2_CID_SATURATION)->second;
		const ControlInfo &int64 = infoMap.find(VIVID_CID_INTEGER64)->second;
		const ControlInfo &u8 = infoMap.find(VIVID_CID_U8_4D_ARRAY)->second;

		/* Test getting controls. */
		ControlList ctrls = capture_->getControls({ V4L2_CID_BRIGHTNESS,
							    V4L2_CID_CONTRAST,
							    V4L2_CID_SATURATION,
							    VIVID_CID_INTEGER64,
							    VIVID_CID_U8_4D_ARRAY });
		if (ctrls.empty()) {
			cerr << "Failed to get controls" << endl;
			return TestFail;
		}

		if (ctrls.infoMap() != &infoMap) {
			cerr << "Incorrect infoMap for retrieved controls" << endl;
			return TestFail;
		}

		if (ctrls.get(V4L2_CID_BRIGHTNESS).get<int32_t>() == -1 ||
		    ctrls.get(V4L2_CID_CONTRAST).get<int32_t>() == -1 ||