drivers/media/platform/amlogic/c3/mipi-adapter/c3-mipi-adap.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/amlogic/c3/mipi-adapter/c3-mipi-adap.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/amlogic/c3/mipi-adapter/c3-mipi-adap.c- Extension
.c- Size
- 25557 bytes
- Lines
- 843
- 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.
- 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.
- 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/device.hlinux/module.hlinux/mutex.hlinux/platform_device.hlinux/pm_runtime.hmedia/mipi-csi2.hmedia/v4l2-async.hmedia/v4l2-common.hmedia/v4l2-device.hmedia/v4l2-fwnode.hmedia/v4l2-mc.hmedia/v4l2-subdev.h
Detected Declarations
struct c3_adap_infostruct c3_adap_devicestruct c3_adap_pix_formatfunction c3_mipi_adap_update_bitsfunction c3_mipi_adap_cfg_topfunction c3_mipi_adap_cfg_frontendfunction c3_mipi_adap_cfg_rd0function c3_mipi_adap_cfg_pixel0function c3_mipi_adap_cfg_aligfunction c3_mipi_adap_enable_streamsfunction c3_mipi_adap_disable_streamsfunction c3_mipi_adap_enum_mbus_codefunction c3_mipi_adap_set_fmtfunction c3_mipi_adap_init_statefunction c3_mipi_adap_runtime_suspendfunction c3_mipi_adap_runtime_resumefunction c3_mipi_adap_subdev_initfunction c3_mipi_adap_subdev_deinitfunction c3_mipi_adap_notify_boundfunction c3_mipi_adap_async_registerfunction c3_mipi_adap_async_unregisterfunction c3_mipi_adap_ioremap_resourcefunction c3_mipi_adap_get_clocksfunction c3_mipi_adap_probefunction c3_mipi_adap_remove
Annotated Snippet
struct c3_adap_info {
char *clocks[MIPI_ADAP_CLOCK_NUM_MAX];
u32 clock_num;
};
/*
* struct c3_adap_device - mipi adapter platform device
*
* @dev: pointer to the struct device
* @top: mipi adapter top register address
* @fd: mipi adapter frontend register address
* @rd: mipi adapter reader register address
* @clks: array of MIPI adapter clocks
* @sd: mipi adapter sub-device
* @pads: mipi adapter sub-device pads
* @notifier: notifier to register on the v4l2-async API
* @src_sd: source sub-device pad
* @info: version-specific MIPI adapter information
*/
struct c3_adap_device {
struct device *dev;
void __iomem *top;
void __iomem *fd;
void __iomem *rd;
struct clk_bulk_data clks[MIPI_ADAP_CLOCK_NUM_MAX];
struct v4l2_subdev sd;
struct media_pad pads[C3_MIPI_ADAP_PAD_MAX];
struct v4l2_async_notifier notifier;
struct media_pad *src_pad;
const struct c3_adap_info *info;
};
/* Format helpers */
struct c3_adap_pix_format {
u32 code;
u8 type;
};
static const struct c3_adap_pix_format c3_mipi_adap_formats[] = {
{ MEDIA_BUS_FMT_SBGGR10_1X10, MIPI_CSI2_DT_RAW10 },
{ MEDIA_BUS_FMT_SGBRG10_1X10, MIPI_CSI2_DT_RAW10 },
{ MEDIA_BUS_FMT_SGRBG10_1X10, MIPI_CSI2_DT_RAW10 },
{ MEDIA_BUS_FMT_SRGGB10_1X10, MIPI_CSI2_DT_RAW10 },
{ MEDIA_BUS_FMT_SBGGR12_1X12, MIPI_CSI2_DT_RAW12 },
{ MEDIA_BUS_FMT_SGBRG12_1X12, MIPI_CSI2_DT_RAW12 },
{ MEDIA_BUS_FMT_SGRBG12_1X12, MIPI_CSI2_DT_RAW12 },
{ MEDIA_BUS_FMT_SRGGB12_1X12, MIPI_CSI2_DT_RAW12 },
};
static const struct c3_adap_pix_format *c3_mipi_adap_find_format(u32 code)
{
for (unsigned int i = 0; i < ARRAY_SIZE(c3_mipi_adap_formats); i++)
if (code == c3_mipi_adap_formats[i].code)
return &c3_mipi_adap_formats[i];
return NULL;
}
/* Hardware configuration */
static void c3_mipi_adap_update_bits(struct c3_adap_device *adap, u32 reg,
u32 mask, u32 val)
{
void __iomem *addr;
u32 orig, tmp;
switch (ADAP_SUBMD(reg)) {
case SUBMD_TOP:
addr = adap->top + ADAP_REG_ADDR(reg);
break;
case SUBMD_FD:
addr = adap->fd + ADAP_REG_ADDR(reg);
break;
case SUBMD_RD:
addr = adap->rd + ADAP_REG_ADDR(reg);
break;
default:
dev_err(adap->dev,
"Invalid sub-module: %lu\n", ADAP_SUBMD(reg));
return;
}
orig = readl(addr);
tmp = orig & ~mask;
tmp |= val & mask;
if (tmp != orig)
Annotation
- Immediate include surface: `linux/clk.h`, `linux/device.h`, `linux/module.h`, `linux/mutex.h`, `linux/platform_device.h`, `linux/pm_runtime.h`, `media/mipi-csi2.h`, `media/v4l2-async.h`.
- Detected declarations: `struct c3_adap_info`, `struct c3_adap_device`, `struct c3_adap_pix_format`, `function c3_mipi_adap_update_bits`, `function c3_mipi_adap_cfg_top`, `function c3_mipi_adap_cfg_frontend`, `function c3_mipi_adap_cfg_rd0`, `function c3_mipi_adap_cfg_pixel0`, `function c3_mipi_adap_cfg_alig`, `function c3_mipi_adap_enable_streams`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source implementation candidate.
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.