drivers/media/platform/ti/cal/cal.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/ti/cal/cal.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/ti/cal/cal.c- Extension
.c- Size
- 34079 bytes
- Lines
- 1364
- 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.
- 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/clk.hlinux/interrupt.hlinux/mfd/syscon.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/pm_runtime.hlinux/regmap.hlinux/slab.hlinux/videodev2.hmedia/media-device.hmedia/v4l2-async.hmedia/v4l2-common.hmedia/v4l2-device.hmedia/videobuf2-core.hmedia/videobuf2-dma-contig.hcal.hcal_regs.h
Detected Declarations
struct cal_v4l2_async_subdevfunction cal_quickdump_regsfunction cal_reserve_pix_procfunction cal_release_pix_procfunction cal_ctx_csi2_configfunction cal_ctx_pix_proc_configfunction cal_ctx_wr_dma_configfunction cal_ctx_set_dma_addrfunction cal_ctx_wr_dma_enablefunction cal_ctx_wr_dma_disablefunction cal_ctx_wr_dma_stoppedfunction cal_get_remote_frame_desc_entryfunction cal_ctx_preparefunction cal_ctx_unpreparefunction cal_ctx_startfunction cal_ctx_stopfunction cal_update_seq_numberfunction cal_irq_wdma_startfunction cal_irq_wdma_endfunction cal_irq_handle_wdmafunction cal_irqfunction to_cal_asdfunction cal_async_notifier_boundfunction cal_async_notifier_completefunction cal_async_notifier_registerfunction cal_async_notifier_unregisterfunction cal_media_registerfunction cal_media_unregisterfunction cal_media_initfunction cal_media_cleanupfunction cal_ctx_destroyfunction cal_get_hwinfofunction cal_init_camerarx_regmapfunction cal_probefunction cal_removefunction cal_runtime_resume
Annotated Snippet
struct cal_v4l2_async_subdev {
struct v4l2_async_connection asd; /* Must be first */
struct cal_camerarx *phy;
};
static inline struct cal_v4l2_async_subdev *
to_cal_asd(struct v4l2_async_connection *asd)
{
return container_of(asd, struct cal_v4l2_async_subdev, asd);
}
static int cal_async_notifier_bound(struct v4l2_async_notifier *notifier,
struct v4l2_subdev *subdev,
struct v4l2_async_connection *asd)
{
struct cal_camerarx *phy = to_cal_asd(asd)->phy;
int pad;
int ret;
if (phy->source) {
phy_info(phy, "Rejecting subdev %s (Already set!!)",
subdev->name);
return 0;
}
phy_dbg(1, phy, "Using source %s for capture\n", subdev->name);
pad = media_entity_get_fwnode_pad(&subdev->entity,
of_fwnode_handle(phy->source_ep_node),
MEDIA_PAD_FL_SOURCE);
if (pad < 0) {
phy_err(phy, "Source %s has no connected source pad\n",
subdev->name);
return pad;
}
ret = media_create_pad_link(&subdev->entity, pad,
&phy->subdev.entity, CAL_CAMERARX_PAD_SINK,
MEDIA_LNK_FL_IMMUTABLE |
MEDIA_LNK_FL_ENABLED);
if (ret) {
phy_err(phy, "Failed to create media link for source %s\n",
subdev->name);
return ret;
}
phy->source = subdev;
phy->source_pad = pad;
return 0;
}
static int cal_async_notifier_complete(struct v4l2_async_notifier *notifier)
{
struct cal_dev *cal = container_of(notifier, struct cal_dev, notifier);
unsigned int i;
int ret;
for (i = 0; i < cal->num_contexts; ++i) {
ret = cal_ctx_v4l2_register(cal->ctx[i]);
if (ret)
goto err_ctx_unreg;
}
if (!cal_mc_api)
return 0;
ret = v4l2_device_register_subdev_nodes(&cal->v4l2_dev);
if (ret)
goto err_ctx_unreg;
return 0;
err_ctx_unreg:
for (; i > 0; --i) {
if (!cal->ctx[i - 1])
continue;
cal_ctx_v4l2_unregister(cal->ctx[i - 1]);
}
return ret;
}
static const struct v4l2_async_notifier_operations cal_async_notifier_ops = {
.bound = cal_async_notifier_bound,
.complete = cal_async_notifier_complete,
};
static int cal_async_notifier_register(struct cal_dev *cal)
Annotation
- Immediate include surface: `linux/clk.h`, `linux/interrupt.h`, `linux/mfd/syscon.h`, `linux/module.h`, `linux/of.h`, `linux/platform_device.h`, `linux/pm_runtime.h`, `linux/regmap.h`.
- Detected declarations: `struct cal_v4l2_async_subdev`, `function cal_quickdump_regs`, `function cal_reserve_pix_proc`, `function cal_release_pix_proc`, `function cal_ctx_csi2_config`, `function cal_ctx_pix_proc_config`, `function cal_ctx_wr_dma_config`, `function cal_ctx_set_dma_addr`, `function cal_ctx_wr_dma_enable`, `function cal_ctx_wr_dma_disable`.
- 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.
- 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.