drivers/media/platform/raspberrypi/rp1-cfe/csi2.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/raspberrypi/rp1-cfe/csi2.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/raspberrypi/rp1-cfe/csi2.c- Extension
.c- Size
- 16671 bytes
- Lines
- 587
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/delay.hlinux/moduleparam.hlinux/pm_runtime.hlinux/seq_file.hmedia/videobuf2-dma-contig.hcfe.hcsi2.hcfe-trace.h
Detected Declarations
function CSI2_STATUS_IRQ_FE_ACKfunction csi2_reg_writefunction set_fieldfunction csi2_regs_showfunction csi2_errors_showfunction csi2_isr_handle_errorsfunction csi2_isrfunction csi2_set_bufferfunction csi2_set_compressionfunction csi2_start_channelfunction csi2_stop_channelfunction csi2_open_rxfunction csi2_close_rxfunction csi2_init_statefunction csi2_pad_set_fmtfunction csi2_set_routingfunction csi2_initfunction csi2_uninit
Annotated Snippet
if (!cfe_fmt) {
cfe_fmt = find_format_by_code(MEDIA_BUS_FMT_SRGGB10_1X10);
format->format.code = cfe_fmt->code;
}
struct v4l2_mbus_framefmt *fmt;
fmt = v4l2_subdev_state_get_format(state, format->pad,
format->stream);
if (!fmt)
return -EINVAL;
*fmt = format->format;
fmt = v4l2_subdev_state_get_opposite_stream_format(state,
format->pad,
format->stream);
if (!fmt)
return -EINVAL;
format->format.field = V4L2_FIELD_NONE;
*fmt = format->format;
} else {
/* Only allow changing the source pad mbus code. */
struct v4l2_mbus_framefmt *sink_fmt, *source_fmt;
u32 sink_code;
u32 code;
sink_fmt = v4l2_subdev_state_get_opposite_stream_format(state,
format->pad,
format->stream);
if (!sink_fmt)
return -EINVAL;
source_fmt = v4l2_subdev_state_get_format(state, format->pad,
format->stream);
if (!source_fmt)
return -EINVAL;
sink_code = sink_fmt->code;
code = format->format.code;
/*
* Only allow changing the mbus code to:
* - The sink's mbus code
* - The 16-bit version of the sink's mbus code
* - The compressed version of the sink's mbus code
*/
if (code == sink_code ||
code == cfe_find_16bit_code(sink_code) ||
code == cfe_find_compressed_code(sink_code))
source_fmt->code = code;
format->format.code = source_fmt->code;
}
return 0;
}
static int csi2_set_routing(struct v4l2_subdev *sd,
struct v4l2_subdev_state *state,
enum v4l2_subdev_format_whence which,
struct v4l2_subdev_krouting *routing)
{
int ret;
ret = v4l2_subdev_routing_validate(sd, routing,
V4L2_SUBDEV_ROUTING_ONLY_1_TO_1 |
V4L2_SUBDEV_ROUTING_NO_SOURCE_MULTIPLEXING);
if (ret)
return ret;
/* Only stream ID 0 allowed on source pads */
for (unsigned int i = 0; i < routing->num_routes; ++i) {
const struct v4l2_subdev_route *route = &routing->routes[i];
if (route->source_stream != 0)
return -ENXIO;
}
ret = v4l2_subdev_set_routing_with_fmt(sd, state, routing,
&cfe_default_format);
if (ret)
return ret;
return 0;
}
Annotation
- Immediate include surface: `linux/delay.h`, `linux/moduleparam.h`, `linux/pm_runtime.h`, `linux/seq_file.h`, `media/videobuf2-dma-contig.h`, `cfe.h`, `csi2.h`, `cfe-trace.h`.
- Detected declarations: `function CSI2_STATUS_IRQ_FE_ACK`, `function csi2_reg_write`, `function set_field`, `function csi2_regs_show`, `function csi2_errors_show`, `function csi2_isr_handle_errors`, `function csi2_isr`, `function csi2_set_buffer`, `function csi2_set_compression`, `function csi2_start_channel`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.