drivers/staging/media/tegra-video/vip.c
Source file repositories/reference/linux-study-clean/drivers/staging/media/tegra-video/vip.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/staging/media/tegra-video/vip.c- Extension
.c- Size
- 6932 bytes
- Lines
- 282
- 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.
- 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/device.hlinux/host1x.hlinux/module.hlinux/of.hlinux/of_graph.hlinux/platform_device.hlinux/pm_runtime.hmedia/v4l2-fwnode.hvip.hvideo.h
Detected Declarations
function modulefunction tegra_vip_enable_streamfunction tegra_vip_disable_streamfunction tegra_vip_s_streamfunction tegra_vip_channel_of_parsefunction tegra_vip_channel_initfunction tegra_vip_initfunction tegra_vip_exitfunction tegra_vip_probefunction tegra_vip_remove
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Parallel video capture module (VIP) for the Tegra VI.
*
* This file implements the VIP-specific infrastructure.
*
* Copyright (C) 2023 SKIDATA GmbH
* Author: Luca Ceresoli <luca.ceresoli@bootlin.com>
*/
#include <linux/device.h>
#include <linux/host1x.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_graph.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <media/v4l2-fwnode.h>
#include "vip.h"
#include "video.h"
static inline struct tegra_vip *host1x_client_to_vip(struct host1x_client *client)
{
return container_of(client, struct tegra_vip, client);
}
static inline struct tegra_vip_channel *subdev_to_vip_channel(struct v4l2_subdev *subdev)
{
return container_of(subdev, struct tegra_vip_channel, subdev);
}
static inline struct tegra_vip *vip_channel_to_vip(struct tegra_vip_channel *chan)
{
return container_of(chan, struct tegra_vip, chan);
}
/* Find the previous subdev in the pipeline (i.e. the one connected to our sink pad) */
static struct v4l2_subdev *tegra_vip_channel_get_prev_subdev(struct tegra_vip_channel *chan)
{
struct media_pad *remote_pad;
remote_pad = media_pad_remote_pad_first(&chan->pads[TEGRA_VIP_PAD_SINK]);
if (!remote_pad)
return NULL;
return media_entity_to_v4l2_subdev(remote_pad->entity);
}
static int tegra_vip_enable_stream(struct v4l2_subdev *subdev)
{
struct tegra_vip_channel *vip_chan = subdev_to_vip_channel(subdev);
struct tegra_vip *vip = vip_channel_to_vip(vip_chan);
struct v4l2_subdev *prev_subdev = tegra_vip_channel_get_prev_subdev(vip_chan);
int err;
err = pm_runtime_resume_and_get(vip->dev);
if (err)
return dev_err_probe(vip->dev, err, "failed to get runtime PM\n");
err = vip->soc->ops->vip_start_streaming(vip_chan);
if (err < 0)
goto err_start_streaming;
err = v4l2_subdev_call(prev_subdev, video, s_stream, true);
if (err < 0 && err != -ENOIOCTLCMD)
goto err_prev_subdev_start_stream;
return 0;
err_prev_subdev_start_stream:
err_start_streaming:
pm_runtime_put(vip->dev);
return err;
}
static int tegra_vip_disable_stream(struct v4l2_subdev *subdev)
{
struct tegra_vip_channel *vip_chan = subdev_to_vip_channel(subdev);
struct tegra_vip *vip = vip_channel_to_vip(vip_chan);
struct v4l2_subdev *prev_subdev = tegra_vip_channel_get_prev_subdev(vip_chan);
v4l2_subdev_call(prev_subdev, video, s_stream, false);
pm_runtime_put(vip->dev);
return 0;
}
Annotation
- Immediate include surface: `linux/device.h`, `linux/host1x.h`, `linux/module.h`, `linux/of.h`, `linux/of_graph.h`, `linux/platform_device.h`, `linux/pm_runtime.h`, `media/v4l2-fwnode.h`.
- Detected declarations: `function module`, `function tegra_vip_enable_stream`, `function tegra_vip_disable_stream`, `function tegra_vip_s_stream`, `function tegra_vip_channel_of_parse`, `function tegra_vip_channel_init`, `function tegra_vip_init`, `function tegra_vip_exit`, `function tegra_vip_probe`, `function tegra_vip_remove`.
- Atlas domain: Driver Families / drivers/staging.
- 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.