drivers/staging/media/tegra-video/vi.c

Source file repositories/reference/linux-study-clean/drivers/staging/media/tegra-video/vi.c

File Facts

System
Linux kernel
Corpus path
drivers/staging/media/tegra-video/vi.c
Extension
.c
Size
51264 bytes
Lines
1963
Domain
Driver Families
Bucket
drivers/staging
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

struct tegra_vi_graph_entity {
	struct v4l2_async_connection asd;
	struct media_entity *entity;
	struct v4l2_subdev *subdev;
};

static inline struct tegra_vi *
host1x_client_to_vi(struct host1x_client *client)
{
	return container_of(client, struct tegra_vi, client);
}

static inline struct tegra_channel_buffer *
to_tegra_channel_buffer(struct vb2_v4l2_buffer *vb)
{
	return container_of(vb, struct tegra_channel_buffer, buf);
}

static inline struct tegra_vi_graph_entity *
to_tegra_vi_graph_entity(struct v4l2_async_connection *asd)
{
	return container_of(asd, struct tegra_vi_graph_entity, asd);
}

static int tegra_get_format_idx_by_code(struct tegra_vi *vi,
					unsigned int code,
					unsigned int offset)
{
	unsigned int i;

	for (i = offset; i < vi->soc->nformats; ++i) {
		if (vi->soc->video_formats[i].code == code)
			return i;
	}

	return -1;
}

static u32 tegra_get_format_fourcc_by_idx(struct tegra_vi *vi,
					  unsigned int index)
{
	if (WARN_ON_ONCE(index >= vi->soc->nformats))
		return vi->soc->video_formats[0].fourcc;

	return vi->soc->video_formats[index].fourcc;
}

static const struct tegra_video_format *
tegra_get_format_by_fourcc(struct tegra_vi *vi, u32 fourcc)
{
	unsigned int i;

	for (i = 0; i < vi->soc->nformats; ++i) {
		if (vi->soc->video_formats[i].fourcc == fourcc)
			return &vi->soc->video_formats[i];
	}

	return NULL;
}

/*
 * videobuf2 queue operations
 */

static int tegra_channel_queue_setup(struct vb2_queue *vq,
				     unsigned int *nbuffers,
				     unsigned int *nplanes,
				     unsigned int sizes[],
				     struct device *alloc_devs[])
{
	struct tegra_vi_channel *chan = vb2_get_drv_priv(vq);

	if (*nplanes)
		return sizes[0] < chan->format.sizeimage ? -EINVAL : 0;

	*nplanes = 1;
	sizes[0] = chan->format.sizeimage;
	alloc_devs[0] = chan->vi->dev;

	if (chan->vi->ops->channel_queue_setup)
		chan->vi->ops->channel_queue_setup(chan);

	return 0;
}

static int tegra_channel_buffer_prepare(struct vb2_buffer *vb)
{
	struct tegra_vi_channel *chan = vb2_get_drv_priv(vb->vb2_queue);
	struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
	struct tegra_channel_buffer *buf = to_tegra_channel_buffer(vbuf);

Annotation

Implementation Notes