drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_proc.c

Source file repositories/reference/linux-study-clean/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_proc.c

File Facts

System
Linux kernel
Corpus path
drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_proc.c
Extension
.c
Size
14950 bytes
Lines
582
Domain
Driver Families
Bucket
drivers/staging
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+
/*
 * Copyright 2021-2022 Bootlin
 * Author: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
 */

#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <media/v4l2-device.h>
#include <media/v4l2-fwnode.h>

#include "sun6i_isp.h"
#include "sun6i_isp_capture.h"
#include "sun6i_isp_params.h"
#include "sun6i_isp_proc.h"
#include "sun6i_isp_reg.h"

/* Helpers */

void sun6i_isp_proc_dimensions(struct sun6i_isp_device *isp_dev,
			       unsigned int *width, unsigned int *height)
{
	if (width)
		*width = isp_dev->proc.mbus_format.width;
	if (height)
		*height = isp_dev->proc.mbus_format.height;
}

/* Format */

static const struct sun6i_isp_proc_format sun6i_isp_proc_formats[] = {
	{
		.mbus_code	= MEDIA_BUS_FMT_SBGGR8_1X8,
		.input_format	= SUN6I_ISP_INPUT_FMT_RAW_BGGR,
	},
	{
		.mbus_code	= MEDIA_BUS_FMT_SGBRG8_1X8,
		.input_format	= SUN6I_ISP_INPUT_FMT_RAW_GBRG,
	},
	{
		.mbus_code	= MEDIA_BUS_FMT_SGRBG8_1X8,
		.input_format	= SUN6I_ISP_INPUT_FMT_RAW_GRBG,
	},
	{
		.mbus_code	= MEDIA_BUS_FMT_SRGGB8_1X8,
		.input_format	= SUN6I_ISP_INPUT_FMT_RAW_RGGB,
	},

	{
		.mbus_code	= MEDIA_BUS_FMT_SBGGR10_1X10,
		.input_format	= SUN6I_ISP_INPUT_FMT_RAW_BGGR,
	},
	{
		.mbus_code	= MEDIA_BUS_FMT_SGBRG10_1X10,
		.input_format	= SUN6I_ISP_INPUT_FMT_RAW_GBRG,
	},
	{
		.mbus_code	= MEDIA_BUS_FMT_SGRBG10_1X10,
		.input_format	= SUN6I_ISP_INPUT_FMT_RAW_GRBG,
	},
	{
		.mbus_code	= MEDIA_BUS_FMT_SRGGB10_1X10,
		.input_format	= SUN6I_ISP_INPUT_FMT_RAW_RGGB,
	},
};

const struct sun6i_isp_proc_format *sun6i_isp_proc_format_find(u32 mbus_code)
{
	unsigned int i;

	for (i = 0; i < ARRAY_SIZE(sun6i_isp_proc_formats); i++)
		if (sun6i_isp_proc_formats[i].mbus_code == mbus_code)
			return &sun6i_isp_proc_formats[i];

	return NULL;
}

/* Processor */

static void sun6i_isp_proc_irq_enable(struct sun6i_isp_device *isp_dev)
{
	struct regmap *regmap = isp_dev->regmap;

	regmap_write(regmap, SUN6I_ISP_FE_INT_EN_REG,
		     SUN6I_ISP_FE_INT_EN_FINISH |
		     SUN6I_ISP_FE_INT_EN_START |
		     SUN6I_ISP_FE_INT_EN_PARA_SAVE |
		     SUN6I_ISP_FE_INT_EN_PARA_LOAD |
		     SUN6I_ISP_FE_INT_EN_SRC0_FIFO |
		     SUN6I_ISP_FE_INT_EN_ROT_FINISH);

Annotation

Implementation Notes