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.
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitmap.hlinux/clk.hlinux/delay.hlinux/host1x.hlinux/lcm.hlinux/list.hlinux/module.hlinux/of.hlinux/of_graph.hlinux/of_platform.hlinux/platform_device.hlinux/regulator/consumer.hlinux/pm_runtime.hlinux/slab.hmedia/v4l2-dv-timings.hmedia/v4l2-event.hmedia/v4l2-fh.hmedia/v4l2-fwnode.hmedia/v4l2-ioctl.hmedia/videobuf2-dma-contig.hsoc/tegra/pmc.hvi.hvideo.h
Detected Declarations
struct tegra_vi_graph_entityfunction host1x_client_to_vifunction to_tegra_channel_bufferfunction to_tegra_vi_graph_entityfunction tegra_get_format_idx_by_codefunction tegra_get_format_fourcc_by_idxfunction tegra_get_format_by_fourccfunction tegra_channel_queue_setupfunction tegra_channel_buffer_preparefunction tegra_channel_buffer_queuefunction tegra_channel_get_remote_bridge_subdevfunction sourcefunction tegra_channel_enable_streamfunction tegra_channel_disable_streamfunction tegra_channel_set_streamfunction tegra_channel_release_buffersfunction tegra_channel_start_streamingfunction tegra_channel_stop_streamingfunction tegra_channel_querycapfunction tegra_channel_g_parmfunction tegra_channel_s_parmfunction tegra_channel_enum_framesizesfunction tegra_channel_enum_frameintervalsfunction tegra_channel_enum_formatfunction tegra_channel_get_formatfunction __tegra_channel_try_formatfunction tegra_channel_try_formatfunction tegra_channel_update_gangportsfunction tegra_channel_set_formatfunction tegra_channel_set_subdev_active_fmtfunction tegra_channel_subscribe_eventfunction tegra_channel_g_selectionfunction tegra_channel_s_selectionfunction tegra_channel_g_edidfunction tegra_channel_s_edidfunction tegra_channel_g_dv_timingsfunction tegra_channel_s_dv_timingsfunction tegra_channel_query_dv_timingsfunction tegra_channel_enum_dv_timingsfunction tegra_channel_dv_timings_capfunction tegra_channel_log_statusfunction tegra_channel_enum_inputfunction tegra_channel_g_inputfunction tegra_channel_s_inputfunction vi_s_ctrlfunction tegra_channel_setup_ctrl_handlerfunction vi_tpg_fmts_bitmap_initfunction vi_fmts_bitmap_init
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
- Immediate include surface: `linux/bitmap.h`, `linux/clk.h`, `linux/delay.h`, `linux/host1x.h`, `linux/lcm.h`, `linux/list.h`, `linux/module.h`, `linux/of.h`.
- Detected declarations: `struct tegra_vi_graph_entity`, `function host1x_client_to_vi`, `function to_tegra_channel_buffer`, `function to_tegra_vi_graph_entity`, `function tegra_get_format_idx_by_code`, `function tegra_get_format_fourcc_by_idx`, `function tegra_get_format_by_fourcc`, `function tegra_channel_queue_setup`, `function tegra_channel_buffer_prepare`, `function tegra_channel_buffer_queue`.
- Atlas domain: Driver Families / drivers/staging.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.