drivers/staging/media/sunxi/sun6i-isp/sun6i_isp.c
Source file repositories/reference/linux-study-clean/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/staging/media/sunxi/sun6i-isp/sun6i_isp.c- Extension
.c- Size
- 13529 bytes
- Lines
- 552
- 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.
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/clk.hlinux/dma-mapping.hlinux/err.hlinux/interrupt.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/pm_runtime.hlinux/regmap.hlinux/reset.hmedia/v4l2-device.hmedia/v4l2-mc.hsun6i_isp.hsun6i_isp_capture.hsun6i_isp_params.hsun6i_isp_proc.hsun6i_isp_reg.h
Detected Declarations
function sun6i_isp_load_readfunction sun6i_isp_load_writefunction sun6i_isp_state_readyfunction sun6i_isp_state_completefunction sun6i_isp_state_updatefunction sun6i_isp_table_setupfunction sun6i_isp_table_cleanupfunction sun6i_isp_tables_configurefunction sun6i_isp_tables_setupfunction sun6i_isp_tables_cleanupfunction sun6i_isp_v4l2_setupfunction sun6i_isp_v4l2_cleanupfunction sun6i_isp_interruptfunction sun6i_isp_suspendfunction sun6i_isp_resumefunction sun6i_isp_resources_setupfunction sun6i_isp_resources_cleanupfunction sun6i_isp_probefunction sun6i_isp_remove
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright 2021-2022 Bootlin
* Author: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
*/
#include <linux/clk.h>
#include <linux/dma-mapping.h>
#include <linux/err.h>
#include <linux/interrupt.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <linux/reset.h>
#include <media/v4l2-device.h>
#include <media/v4l2-mc.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 */
u32 sun6i_isp_load_read(struct sun6i_isp_device *isp_dev, u32 offset)
{
u32 *data = (u32 *)(isp_dev->tables.load.data + offset);
return *data;
}
void sun6i_isp_load_write(struct sun6i_isp_device *isp_dev, u32 offset,
u32 value)
{
u32 *data = (u32 *)(isp_dev->tables.load.data + offset);
*data = value;
}
/* State */
/*
* The ISP works with a load buffer, which gets copied to the actual registers
* by the hardware before processing a frame when a specific flag is set.
* This is represented by tracking the ISP state in the different parts of
* the code with explicit sync points:
* - state update: to update the load buffer for the next frame if necessary;
* - state complete: to indicate that the state update was applied.
*/
static void sun6i_isp_state_ready(struct sun6i_isp_device *isp_dev)
{
struct regmap *regmap = isp_dev->regmap;
u32 value;
regmap_read(regmap, SUN6I_ISP_FE_CTRL_REG, &value);
value |= SUN6I_ISP_FE_CTRL_PARA_READY;
regmap_write(regmap, SUN6I_ISP_FE_CTRL_REG, value);
}
static void sun6i_isp_state_complete(struct sun6i_isp_device *isp_dev)
{
unsigned long flags;
spin_lock_irqsave(&isp_dev->state_lock, flags);
sun6i_isp_capture_state_complete(isp_dev);
sun6i_isp_params_state_complete(isp_dev);
spin_unlock_irqrestore(&isp_dev->state_lock, flags);
}
void sun6i_isp_state_update(struct sun6i_isp_device *isp_dev, bool ready_hold)
{
bool update = false;
unsigned long flags;
spin_lock_irqsave(&isp_dev->state_lock, flags);
sun6i_isp_capture_state_update(isp_dev, &update);
sun6i_isp_params_state_update(isp_dev, &update);
if (update && !ready_hold)
sun6i_isp_state_ready(isp_dev);
spin_unlock_irqrestore(&isp_dev->state_lock, flags);
}
Annotation
- Immediate include surface: `linux/clk.h`, `linux/dma-mapping.h`, `linux/err.h`, `linux/interrupt.h`, `linux/module.h`, `linux/of.h`, `linux/platform_device.h`, `linux/pm_runtime.h`.
- Detected declarations: `function sun6i_isp_load_read`, `function sun6i_isp_load_write`, `function sun6i_isp_state_ready`, `function sun6i_isp_state_complete`, `function sun6i_isp_state_update`, `function sun6i_isp_table_setup`, `function sun6i_isp_table_cleanup`, `function sun6i_isp_tables_configure`, `function sun6i_isp_tables_setup`, `function sun6i_isp_tables_cleanup`.
- Atlas domain: Driver Families / drivers/staging.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.