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.

Dependency Surface

Detected Declarations

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

Implementation Notes