drivers/media/platform/xilinx/xilinx-tpg.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/xilinx/xilinx-tpg.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/xilinx/xilinx-tpg.c- Extension
.c- Size
- 24511 bytes
- Lines
- 921
- 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.
- 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.
- 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/gpio/consumer.hlinux/module.hlinux/of.hlinux/of_graph.hlinux/platform_device.hlinux/xilinx-v4l2-controls.hmedia/v4l2-async.hmedia/v4l2-ctrls.hmedia/v4l2-subdev.hxilinx-vip.hxilinx-vtc.h
Detected Declarations
struct xtpg_devicefunction xtpg_get_bayer_phasefunction __xtpg_update_pattern_controlfunction xtpg_update_pattern_controlfunction xtpg_s_streamfunction __xtpg_get_pad_formatfunction xtpg_get_formatfunction xtpg_set_formatfunction xtpg_enum_frame_sizefunction xtpg_openfunction xtpg_closefunction xtpg_s_ctrlfunction xtpg_pm_suspendfunction xtpg_pm_resumefunction xtpg_parse_offunction for_each_of_graph_portfunction xtpg_probefunction xtpg_remove
Annotated Snippet
struct xtpg_device {
struct xvip_device xvip;
struct media_pad pads[2];
unsigned int npads;
bool has_input;
struct v4l2_mbus_framefmt formats[2];
struct v4l2_mbus_framefmt default_format;
const struct xvip_video_format *vip_format;
bool bayer;
struct v4l2_ctrl_handler ctrl_handler;
struct v4l2_ctrl *hblank;
struct v4l2_ctrl *vblank;
struct v4l2_ctrl *pattern;
bool streaming;
struct xvtc_device *vtc;
struct gpio_desc *vtmux_gpio;
};
static inline struct xtpg_device *to_tpg(struct v4l2_subdev *subdev)
{
return container_of(subdev, struct xtpg_device, xvip.subdev);
}
static u32 xtpg_get_bayer_phase(unsigned int code)
{
switch (code) {
case MEDIA_BUS_FMT_SRGGB8_1X8:
return XTPG_BAYER_PHASE_RGGB;
case MEDIA_BUS_FMT_SGRBG8_1X8:
return XTPG_BAYER_PHASE_GRBG;
case MEDIA_BUS_FMT_SGBRG8_1X8:
return XTPG_BAYER_PHASE_GBRG;
case MEDIA_BUS_FMT_SBGGR8_1X8:
return XTPG_BAYER_PHASE_BGGR;
default:
return XTPG_BAYER_PHASE_OFF;
}
}
static void __xtpg_update_pattern_control(struct xtpg_device *xtpg,
bool passthrough, bool pattern)
{
u32 pattern_mask = (1 << (xtpg->pattern->maximum + 1)) - 1;
/*
* If the TPG has no sink pad or no input connected to its sink pad
* passthrough mode can't be enabled.
*/
if (xtpg->npads == 1 || !xtpg->has_input)
passthrough = false;
/* If passthrough mode is allowed unmask bit 0. */
if (passthrough)
pattern_mask &= ~1;
/* If test pattern mode is allowed unmask all other bits. */
if (pattern)
pattern_mask &= 1;
__v4l2_ctrl_modify_range(xtpg->pattern, 0, xtpg->pattern->maximum,
pattern_mask, pattern ? 9 : 0);
}
static void xtpg_update_pattern_control(struct xtpg_device *xtpg,
bool passthrough, bool pattern)
{
mutex_lock(xtpg->ctrl_handler.lock);
__xtpg_update_pattern_control(xtpg, passthrough, pattern);
mutex_unlock(xtpg->ctrl_handler.lock);
}
/* -----------------------------------------------------------------------------
* V4L2 Subdevice Video Operations
*/
static int xtpg_s_stream(struct v4l2_subdev *subdev, int enable)
{
struct xtpg_device *xtpg = to_tpg(subdev);
unsigned int width = xtpg->formats[0].width;
unsigned int height = xtpg->formats[0].height;
bool passthrough;
u32 bayer_phase;
if (!enable) {
xvip_stop(&xtpg->xvip);
if (xtpg->vtc)
Annotation
- Immediate include surface: `linux/device.h`, `linux/gpio/consumer.h`, `linux/module.h`, `linux/of.h`, `linux/of_graph.h`, `linux/platform_device.h`, `linux/xilinx-v4l2-controls.h`, `media/v4l2-async.h`.
- Detected declarations: `struct xtpg_device`, `function xtpg_get_bayer_phase`, `function __xtpg_update_pattern_control`, `function xtpg_update_pattern_control`, `function xtpg_s_stream`, `function __xtpg_get_pad_format`, `function xtpg_get_format`, `function xtpg_set_format`, `function xtpg_enum_frame_size`, `function xtpg_open`.
- Atlas domain: Driver Families / drivers/media.
- 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.