drivers/staging/media/tegra-video/tegra210.c
Source file repositories/reference/linux-study-clean/drivers/staging/media/tegra-video/tegra210.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/staging/media/tegra-video/tegra210.c- Extension
.c- Size
- 39181 bytes
- Lines
- 1221
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/clk.hlinux/clk/tegra.hlinux/delay.hlinux/host1x.hlinux/kthread.hcsi.hvi.h
Detected Declarations
enum tegra210_image_formatfunction Copyrightfunction tegra_vi_readfunction vi_csi_writefunction vi_csi_readfunction tegra210_channel_host1x_syncpt_initfunction tegra210_channel_host1x_syncpt_freefunction tegra210_fmt_alignfunction tegra_channel_capture_setupfunction tegra_channel_vi_soft_resetfunction tegra_channel_capture_error_recoverfunction dequeue_buf_donefunction release_bufferfunction tegra_channel_vi_buffer_setupfunction tegra_channel_capture_framefunction tegra_channel_capture_donefunction chan_capture_kthread_startfunction chan_capture_kthread_finishfunction tegra210_vi_start_streamingfunction tegra210_vi_stop_streamingfunction csi_writefunction pp_writefunction pp_readfunction cil_writefunction cil_readfunction tpg_writefunction tegra210_csi_port_recoverfunction tegra210_csi_error_recoverfunction tegra210_csi_port_start_streamingfunction tegra210_csi_port_stop_streamingfunction tegra210_csi_start_streamingfunction tegra210_csi_stop_streaming
Annotated Snippet
if (!fs_sp) {
dev_err(vi->dev, "failed to request frame start syncpoint\n");
ret = -ENOMEM;
goto free_syncpts;
}
mw_sp = host1x_syncpt_request(&vi->client, flags);
if (!mw_sp) {
dev_err(vi->dev, "failed to request memory ack syncpoint\n");
host1x_syncpt_put(fs_sp);
ret = -ENOMEM;
goto free_syncpts;
}
chan->frame_start_sp[i] = fs_sp;
chan->mw_ack_sp[i] = mw_sp;
spin_lock_init(&chan->sp_incr_lock[i]);
}
return 0;
free_syncpts:
for (i = 0; i < chan->numgangports; i++) {
host1x_syncpt_put(chan->mw_ack_sp[i]);
host1x_syncpt_put(chan->frame_start_sp[i]);
}
return ret;
}
static void tegra210_channel_host1x_syncpt_free(struct tegra_vi_channel *chan)
{
int i;
for (i = 0; i < chan->numgangports; i++) {
host1x_syncpt_put(chan->mw_ack_sp[i]);
host1x_syncpt_put(chan->frame_start_sp[i]);
}
}
static void tegra210_fmt_align(struct v4l2_pix_format *pix, unsigned int bpp)
{
unsigned int min_bpl;
unsigned int max_bpl;
unsigned int bpl;
/*
* The transfer alignment requirements are expressed in bytes.
* Clamp the requested width and height to the limits.
*/
pix->width = clamp(pix->width, TEGRA210_MIN_WIDTH, TEGRA210_MAX_WIDTH);
pix->height = clamp(pix->height, TEGRA210_MIN_HEIGHT, TEGRA210_MAX_HEIGHT);
/* Clamp the requested bytes per line value. If the maximum bytes per
* line value is zero, the module doesn't support user configurable
* line sizes. Override the requested value with the minimum in that
* case.
*/
min_bpl = pix->width * bpp;
max_bpl = rounddown(TEGRA210_MAX_WIDTH, SURFACE_ALIGN_BYTES);
bpl = roundup(pix->bytesperline, SURFACE_ALIGN_BYTES);
pix->bytesperline = clamp(bpl, min_bpl, max_bpl);
pix->sizeimage = pix->bytesperline * pix->height;
if (pix->pixelformat == V4L2_PIX_FMT_NV16)
pix->sizeimage *= 2;
}
static int tegra_channel_capture_setup(struct tegra_vi_channel *chan,
u8 portno)
{
u32 height = chan->format.height;
u32 width = chan->format.width;
u32 format = chan->fmtinfo->img_fmt;
u32 data_type = chan->fmtinfo->img_dt;
u32 word_count = (width * chan->fmtinfo->bit_width) / 8;
u32 bypass_pixel_transform = BIT(BYPASS_PXL_TRANSFORM_OFFSET);
/*
* VI Pixel transformation unit converts source pixels data format
* into selected destination pixel format and aligns properly while
* interfacing with memory packer.
* This pixel transformation should be enabled for YUV and RGB
* formats and should be bypassed for RAW formats as RAW formats
* only support direct to memory.
*/
if (chan->pg_mode || data_type == TEGRA_IMAGE_DT_YUV422_8 ||
data_type == TEGRA_IMAGE_DT_RGB888)
bypass_pixel_transform = 0;
/*
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/clk.h`, `linux/clk/tegra.h`, `linux/delay.h`, `linux/host1x.h`, `linux/kthread.h`, `csi.h`, `vi.h`.
- Detected declarations: `enum tegra210_image_format`, `function Copyright`, `function tegra_vi_read`, `function vi_csi_write`, `function vi_csi_read`, `function tegra210_channel_host1x_syncpt_init`, `function tegra210_channel_host1x_syncpt_free`, `function tegra210_fmt_align`, `function tegra_channel_capture_setup`, `function tegra_channel_vi_soft_reset`.
- 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.
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.