drivers/media/platform/arm/mali-c55/mali-c55-params.c

Source file repositories/reference/linux-study-clean/drivers/media/platform/arm/mali-c55/mali-c55-params.c

File Facts

System
Linux kernel
Corpus path
drivers/media/platform/arm/mali-c55/mali-c55-params.c
Extension
.c
Size
32639 bytes
Lines
941
Domain
Driver Families
Bucket
drivers/media
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

// SPDX-License-Identifier: GPL-2.0
/*
 * ARM Mali-C55 ISP Driver - Configuration parameters output device
 *
 * Copyright (C) 2025 Ideas on Board Oy
 */
#include <linux/media/arm/mali-c55-config.h>
#include <linux/pm_runtime.h>

#include <media/media-entity.h>
#include <media/v4l2-dev.h>
#include <media/v4l2-event.h>
#include <media/v4l2-fh.h>
#include <media/v4l2-ioctl.h>
#include <media/v4l2-isp.h>
#include <media/videobuf2-core.h>
#include <media/videobuf2-dma-contig.h>

#include "mali-c55-common.h"
#include "mali-c55-registers.h"

/**
 * union mali_c55_params_block - Generalisation of a parameter block
 *
 * This union allows the driver to treat a block as a generic pointer to this
 * union and safely access the header and block-specific struct without having
 * to resort to casting. The header member is accessed first, and the type field
 * checked which allows the driver to determine which of the other members
 * should be used. The data member at the end allows a pointer to an address
 * within the data member of :c:type:`mali_c55_params_buffer` to initialise a
 * union variable.
 *
 * @header:		Pointer to the shared header struct embedded as the
 *			first member of all the possible other members (except
 *			@data). This member would be accessed first and the type
 *			field checked to determine which of the other members
 *			should be accessed.
 * @sensor_offs:	For header->type == MALI_C55_PARAM_BLOCK_SENSOR_OFFS
 * @aexp_hist:		For header->type == MALI_C55_PARAM_BLOCK_AEXP_HIST and
 *			header->type == MALI_C55_PARAM_BLOCK_AEXP_IHIST
 * @aexp_weights:	For header->type == MALI_C55_PARAM_BLOCK_AEXP_HIST_WEIGHTS
 *			and header->type =  MALI_C55_PARAM_BLOCK_AEXP_IHIST_WEIGHTS
 * @digital_gain:	For header->type == MALI_C55_PARAM_BLOCK_DIGITAL_GAIN
 * @awb_gains:		For header->type == MALI_C55_PARAM_BLOCK_AWB_GAINS and
 *			header->type = MALI_C55_PARAM_BLOCK_AWB_GAINS_AEXP
 * @awb_config:		For header->type == MALI_C55_PARAM_BLOCK_AWB_CONFIG
 * @shading_config:	For header->type == MALI_C55_PARAM_MESH_SHADING_CONFIG
 * @shading_selection:	For header->type == MALI_C55_PARAM_MESH_SHADING_SELECTION
 * @data:		Allows easy initialisation of a union variable with a
 *			pointer into a __u8 array.
 */
union mali_c55_params_block {
	const struct v4l2_isp_params_block_header *header;
	const struct mali_c55_params_sensor_off_preshading *sensor_offs;
	const struct mali_c55_params_aexp_hist *aexp_hist;
	const struct mali_c55_params_aexp_weights *aexp_weights;
	const struct mali_c55_params_digital_gain *digital_gain;
	const struct mali_c55_params_awb_gains *awb_gains;
	const struct mali_c55_params_awb_config *awb_config;
	const struct mali_c55_params_mesh_shading_config *shading_config;
	const struct mali_c55_params_mesh_shading_selection *shading_selection;
	const __u8 *data;
};

typedef void (*mali_c55_params_handler)(struct mali_c55 *mali_c55,
					union mali_c55_params_block block);

#define to_mali_c55_params_buf(vbuf) \
	container_of(vbuf, struct mali_c55_params_buf, vb)

static void mali_c55_params_sensor_offs(struct mali_c55 *mali_c55,
					union mali_c55_params_block block)
{
	const struct mali_c55_params_sensor_off_preshading *p;
	__u32 global_offset;

	p = block.sensor_offs;

	if (block.header->flags & V4L2_ISP_PARAMS_FL_BLOCK_DISABLE) {
		mali_c55_ctx_update_bits(mali_c55, MALI_C55_REG_BYPASS_3,
			MALI_C55_REG_BYPASS_3_SENSOR_OFFSET_PRE_SH,
			MALI_C55_REG_BYPASS_3_SENSOR_OFFSET_PRE_SH);
		return;
	}

	if (!(p->chan00 || p->chan01 || p->chan10 || p->chan11))
		return;

	mali_c55_ctx_write(mali_c55, MALI_C55_REG_SENSOR_OFF_PRE_SHA_00,
			   p->chan00 & MALI_C55_SENSOR_OFF_PRE_SHA_MASK);

Annotation

Implementation Notes