summaryrefslogtreecommitdiff
path: root/src/qcam/assets/feathericons/codesandbox.svg
blob: 49848f520d6212905ecca902be0846858153e0bd (plain)
1
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-codesandbox"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path><polyline points="7.5 4.21 12 6.81 16.5 4.21"></polyline><polyline points="7.5 19.79 7.5 14.6 3 12"></polyline><polyline points="21 12 16.5 14.6 16.5 19.79"></polyline><polyline points="3.27 6.96 12 12.01 20.73 6.96"></polyline><line x1="12" y1="22.08" x2="12" y2="12"></line></svg>
a id='n87' href='#n87'>87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
 * Copyright (C) 2024, Ideas On Board
 *
 * RkISP1 ISP Parameters
 */

#include "params.h"

#include <map>
#include <stddef.h>
#include <string.h>

#include <linux/rkisp1-config.h>
#include <linux/videodev2.h>

#include <libcamera/base/log.h>
#include <libcamera/base/utils.h>

namespace libcamera {

LOG_DEFINE_CATEGORY(RkISP1Params)

namespace ipa::rkisp1 {

namespace {

struct BlockTypeInfo {
	enum rkisp1_ext_params_block_type type;
	size_t size;
	size_t offset;
	uint32_t enableBit;
};

#define RKISP1_BLOCK_TYPE_ENTRY(block, id, type, category, bit)			\
	{ BlockType::block, {							\
		RKISP1_EXT_PARAMS_BLOCK_TYPE_##id,				\
		sizeof(struct rkisp1_cif_isp_##type##_config),			\
		offsetof(struct rkisp1_params_cfg, category.type##_config),	\
		RKISP1_CIF_ISP_MODULE_##bit,					\
	} }

#define RKISP1_BLOCK_TYPE_ENTRY_MEAS(block, id, type)				\
	RKISP1_BLOCK_TYPE_ENTRY(block, id##_MEAS, type, meas, id)

#define RKISP1_BLOCK_TYPE_ENTRY_OTHERS(block, id, type)				\
	RKISP1_BLOCK_TYPE_ENTRY(block, id, type, others, id)

#define RKISP1_BLOCK_TYPE_ENTRY_EXT(block, id, type)				\
	{ BlockType::block, {							\
		RKISP1_EXT_PARAMS_BLOCK_TYPE_##id,				\
		sizeof(struct rkisp1_cif_isp_##type##_config),			\
		0, 0,								\
	} }

const std::map<BlockType, BlockTypeInfo> kBlockTypeInfo = {
	RKISP1_BLOCK_TYPE_ENTRY_OTHERS(Bls, BLS, bls),
	RKISP1_BLOCK_TYPE_ENTRY_OTHERS(Dpcc, DPCC, dpcc),
	RKISP1_BLOCK_TYPE_ENTRY_OTHERS(Sdg, SDG, sdg),
	RKISP1_BLOCK_TYPE_ENTRY_OTHERS(AwbGain, AWB_GAIN, awb_gain),
	RKISP1_BLOCK_TYPE_ENTRY_OTHERS(Flt, FLT, flt),
	RKISP1_BLOCK_TYPE_ENTRY_OTHERS(Bdm, BDM, bdm),
	RKISP1_BLOCK_TYPE_ENTRY_OTHERS(Ctk, CTK, ctk),
	RKISP1_BLOCK_TYPE_ENTRY_OTHERS(Goc, GOC, goc),
	RKISP1_BLOCK_TYPE_ENTRY_OTHERS(Dpf, DPF, dpf),
	RKISP1_BLOCK_TYPE_ENTRY_OTHERS(DpfStrength, DPF_STRENGTH, dpf_strength),
	RKISP1_BLOCK_TYPE_ENTRY_OTHERS(Cproc, CPROC, cproc),
	RKISP1_BLOCK_TYPE_ENTRY_OTHERS(Ie, IE, ie),
	RKISP1_BLOCK_TYPE_ENTRY_OTHERS(Lsc, LSC, lsc),
	RKISP1_BLOCK_TYPE_ENTRY_MEAS(Awb, AWB, awb_meas),
	RKISP1_BLOCK_TYPE_ENTRY_MEAS(Hst, HST, hst),
	RKISP1_BLOCK_TYPE_ENTRY_MEAS(Aec, AEC, aec),
	RKISP1_BLOCK_TYPE_ENTRY_MEAS(Afc, AFC, afc),
	RKISP1_BLOCK_TYPE_ENTRY_EXT(CompandBls, COMPAND_BLS, compand_bls),
	RKISP1_BLOCK_TYPE_ENTRY_EXT(CompandExpand, COMPAND_EXPAND, compand_curve),
	RKISP1_BLOCK_TYPE_ENTRY_EXT(CompandCompress, COMPAND_COMPRESS, compand_curve),
};

} /* namespace */

RkISP1ParamsBlockBase::RkISP1ParamsBlockBase(RkISP1Params *params, BlockType type,
					     const Span<uint8_t> &data)
	: params_(params), type_(type)
{
	if (params_->format() == V4L2_META_FMT_RK_ISP1_EXT_PARAMS) {
		header_ = data.subspan(0, sizeof(rkisp1_ext_params_block_header));
		data_ = data.subspan(sizeof(rkisp1_ext_params_block_header));
	} else {
		data_ = data;
	}
}

void RkISP1ParamsBlockBase::setEnabled(bool enabled)
{
	/*