drivers/media/test-drivers/vimc/vimc-streamer.c
Source file repositories/reference/linux-study-clean/drivers/media/test-drivers/vimc/vimc-streamer.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/test-drivers/vimc/vimc-streamer.c- Extension
.c- Size
- 7178 bytes
- Lines
- 274
- 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/init.hlinux/freezer.hlinux/kthread.hvimc-streamer.h
Detected Declarations
function Copyrightfunction vimc_streamer_pipeline_terminatefunction vimc_streamer_s_streamfunction vimc_streamer_get_sensorfunction zerofunction vimc_streamer_s_stream
Annotated Snippet
if (!ved) {
vimc_streamer_pipeline_terminate(stream);
return -EINVAL;
}
stream->ved_pipeline[stream->pipe_size++] = ved;
if (is_media_entity_v4l2_subdev(ved->ent)) {
sd = media_entity_to_v4l2_subdev(ved->ent);
ret = v4l2_subdev_call(sd, video, s_stream, 1);
if (ret && ret != -ENOIOCTLCMD) {
dev_err(ved->dev, "subdev_call error %s\n",
ved->ent->name);
vimc_streamer_pipeline_terminate(stream);
return ret;
}
}
entity = vimc_get_source_entity(ved->ent);
/* Check if the end of the pipeline was reached */
if (!entity) {
/* the first entity of the pipe should be source only */
if (!vimc_is_source(ved->ent)) {
dev_err(ved->dev,
"first entity in the pipe '%s' is not a source\n",
ved->ent->name);
vimc_streamer_pipeline_terminate(stream);
return -EPIPE;
}
return 0;
}
/* Get the next device in the pipeline */
if (is_media_entity_v4l2_subdev(entity)) {
sd = media_entity_to_v4l2_subdev(entity);
ved = v4l2_get_subdevdata(sd);
} else {
vdev = container_of(entity,
struct video_device,
entity);
ved = video_get_drvdata(vdev);
}
}
vimc_streamer_pipeline_terminate(stream);
return -EINVAL;
}
/**
* vimc_streamer_get_sensor() - Get sensor from pipeline
* @stream: the pipeline
*
* Helper function to find the sensor device in the pipeline.
* Returns pointer to sensor device or NULL if not found.
*/
static struct vimc_sensor_device *vimc_streamer_get_sensor(struct vimc_stream *stream)
{
int i;
for (i = 0; i < stream->pipe_size; i++) {
struct vimc_ent_device *ved = stream->ved_pipeline[i];
if (ved && ved->ent &&
ved->ent->function == MEDIA_ENT_F_CAM_SENSOR) {
return container_of(ved, struct vimc_sensor_device, ved);
}
}
return NULL;
}
/**
* vimc_streamer_thread - Process frames through the pipeline
*
* @data: vimc_stream struct of the current stream
*
* From the source to the sink, gets a frame from each subdevice and send to
* the next one of the pipeline at a fixed framerate.
*
* Return:
* Always zero (created as ``int`` instead of ``void`` to comply with
* kthread API).
*/
static int vimc_streamer_thread(void *data)
{
struct vimc_stream *stream = data;
struct vimc_sensor_device *vsensor;
u8 *frame = NULL;
int i;
unsigned long fps_jiffies;
const unsigned long default_jiffies = HZ / 30;
Annotation
- Immediate include surface: `linux/init.h`, `linux/freezer.h`, `linux/kthread.h`, `vimc-streamer.h`.
- Detected declarations: `function Copyright`, `function vimc_streamer_pipeline_terminate`, `function vimc_streamer_s_stream`, `function vimc_streamer_get_sensor`, `function zero`, `function vimc_streamer_s_stream`.
- 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.