drivers/media/i2c/cvs/v4l2.c
Source file repositories/reference/linux-study-clean/drivers/media/i2c/cvs/v4l2.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/i2c/cvs/v4l2.c- Extension
.c- Size
- 16374 bytes
- Lines
- 619
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/cleanup.hlinux/device.hlinux/module.hlinux/pm_runtime.hlinux/property.hmedia/v4l2-async.hmedia/v4l2-common.hmedia/v4l2-ctrls.hmedia/v4l2-event.hmedia/v4l2-fwnode.hmedia/v4l2-mc.hmedia/v4l2-subdev.hicvs.h
Detected Declarations
function Copyrightfunction csi_set_link_cfgfunction cvs_csi_enable_streamsfunction cvs_csi_disable_streamsfunction cvs_csi_init_statefunction cvs_csi_set_fmtfunction cvs_csi_get_mbus_configfunction cvs_csi_notify_boundfunction cvs_csi_notify_unbindfunction cvs_csi_init_controlsfunction Firmwarefunction cvs_csi_initfunction cvs_csi_remove
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (C) 2026 Intel Corporation
* CVS driver - CSI/V4L2 subdev support
*/
#include <linux/cleanup.h>
#include <linux/device.h>
#include <linux/module.h>
#include <linux/pm_runtime.h>
#include <linux/property.h>
#include <media/v4l2-async.h>
#include <media/v4l2-common.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-event.h>
#include <media/v4l2-fwnode.h>
#include <media/v4l2-mc.h>
#include <media/v4l2-subdev.h>
#include "icvs.h"
/*
* Helpers
*/
static inline struct icvs *notifier_to_csi(struct v4l2_async_notifier *n)
{
return container_of(n, struct icvs, notifier);
}
static inline struct icvs *sd_to_csi(struct v4l2_subdev *sd)
{
return container_of(sd, struct icvs, subdev);
}
/*
* Default formats
*/
static const struct v4l2_mbus_framefmt cvs_csi_format_mbus_default = {
.width = 1,
.height = 1,
.code = MEDIA_BUS_FMT_Y8_1X8,
.field = V4L2_FIELD_NONE,
};
/**
* csi_set_link_cfg - Program default CSI-2 link parameters
* @ctx: CVS device context
*
* Populates a HOST_SET_MIPI_CONFIG command using current lane count and
* link frequency, then submits it to the device.
* Rest of the link parameters are left at firmware defaults.
*
* Return: 0 on success or negative errno.
*/
static int csi_set_link_cfg(struct icvs *ctx)
{
struct icvs_cmd cmd = {
.cmd_id = cpu_to_be16(ICVS_HOST_SET_MIPI_CONFIG),
.param.conf.nr_of_lanes = ctx->nr_of_lanes,
.param.conf.link_freq = ctx->link_freq,
};
size_t cmd_size = sizeof(cmd.cmd_id) + sizeof(cmd.param.conf);
guard(mutex)(&ctx->lock);
return cvs_send(ctx, &cmd, cmd_size);
}
/*
* Streaming
*/
/**
* cvs_csi_enable_streams - Start streaming through the bridge
* @sd: Sub-device pointer
* @state: Active state
* @pad: Pad identifier (must be ICVS_CSI_PAD_SOURCE)
* @streams_mask: Streams to enable (bit 0 supported)
*
* Runtime-resumes the bridge (triggering cvs_runtime_resume() to claim CSI-2
* link ownership), fetches the link frequency, programs the MIPI configuration,
* and forwards the enable request downstream.
*
* Return: 0 on success or negative errno.
*/
static int cvs_csi_enable_streams(struct v4l2_subdev *sd,
struct v4l2_subdev_state *state,
u32 pad, u64 streams_mask)
{
struct icvs *ctx = sd_to_csi(sd);
Annotation
- Immediate include surface: `linux/cleanup.h`, `linux/device.h`, `linux/module.h`, `linux/pm_runtime.h`, `linux/property.h`, `media/v4l2-async.h`, `media/v4l2-common.h`, `media/v4l2-ctrls.h`.
- Detected declarations: `function Copyright`, `function csi_set_link_cfg`, `function cvs_csi_enable_streams`, `function cvs_csi_disable_streams`, `function cvs_csi_init_state`, `function cvs_csi_set_fmt`, `function cvs_csi_get_mbus_config`, `function cvs_csi_notify_bound`, `function cvs_csi_notify_unbind`, `function cvs_csi_init_controls`.
- 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.