drivers/media/i2c/adv748x/adv748x-csi2.c
Source file repositories/reference/linux-study-clean/drivers/media/i2c/adv748x/adv748x-csi2.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/i2c/adv748x/adv748x-csi2.c- Extension
.c- Size
- 9845 bytes
- Lines
- 394
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hmedia/v4l2-ctrls.hmedia/v4l2-device.hmedia/v4l2-ioctl.hadv748x.h
Detected Declarations
function adv748x_csi2_set_virtual_channelfunction adv748x_csi2_register_linkfunction adv748x_csi2_init_statefunction subdevicesfunction adv748x_csi2_s_streamfunction adv748x_csi2_enum_mbus_codefunction adv748x_csi2_is_fmt_supportedfunction adv748x_csi2_set_formatfunction adv748x_csi2_get_mbus_configfunction adv748x_csi2_set_pixelratefunction adv748x_csi2_s_ctrlfunction adv748x_csi2_init_controlsfunction adv748x_csi2_initfunction adv748x_csi2_cleanup
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
/*
* Driver for Analog Devices ADV748X CSI-2 Transmitter
*
* Copyright (C) 2017 Renesas Electronics Corp.
*/
#include <linux/module.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-device.h>
#include <media/v4l2-ioctl.h>
#include "adv748x.h"
static const unsigned int adv748x_csi2_txa_fmts[] = {
MEDIA_BUS_FMT_UYVY8_1X16,
MEDIA_BUS_FMT_RGB888_1X24,
};
static const unsigned int adv748x_csi2_txb_fmts[] = {
MEDIA_BUS_FMT_UYVY8_1X16,
};
int adv748x_csi2_set_virtual_channel(struct adv748x_csi2 *tx, unsigned int vc)
{
return tx_write(tx, ADV748X_CSI_VC_REF, vc << ADV748X_CSI_VC_REF_SHIFT);
}
/**
* adv748x_csi2_register_link : Register and link internal entities
*
* @tx: CSI2 private entity
* @v4l2_dev: Video registration device
* @src: Source subdevice to establish link
* @src_pad: Pad number of source to link to this @tx
* @enable: Link enabled flag
*
* Ensure that the subdevice is registered against the v4l2_device, and link the
* source pad to the sink pad of the CSI2 bus entity.
*/
static int adv748x_csi2_register_link(struct adv748x_csi2 *tx,
struct v4l2_device *v4l2_dev,
struct v4l2_subdev *src,
unsigned int src_pad,
bool enable)
{
int ret;
if (!src->v4l2_dev) {
ret = v4l2_device_register_subdev(v4l2_dev, src);
if (ret)
return ret;
}
ret = media_create_pad_link(&src->entity, src_pad,
&tx->sd.entity, ADV748X_CSI2_SINK,
enable ? MEDIA_LNK_FL_ENABLED : 0);
if (ret)
return ret;
if (enable)
tx->src = src;
return 0;
}
/* -----------------------------------------------------------------------------
* v4l2_subdev_internal_ops
*/
static int adv748x_csi2_init_state(struct v4l2_subdev *sd,
struct v4l2_subdev_state *state)
{
static const struct v4l2_mbus_framefmt adv748x_csi2_default_fmt = {
.width = 1280,
.height = 720,
.code = MEDIA_BUS_FMT_UYVY8_1X16,
.colorspace = V4L2_COLORSPACE_SRGB,
.field = V4L2_FIELD_NONE,
.ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT,
.quantization = V4L2_QUANTIZATION_DEFAULT,
.xfer_func = V4L2_XFER_FUNC_DEFAULT,
};
struct v4l2_mbus_framefmt *fmt;
fmt = v4l2_subdev_state_get_format(state, ADV748X_CSI2_SINK);
*fmt = adv748x_csi2_default_fmt;
fmt = v4l2_subdev_state_get_format(state, ADV748X_CSI2_SOURCE);
Annotation
- Immediate include surface: `linux/module.h`, `media/v4l2-ctrls.h`, `media/v4l2-device.h`, `media/v4l2-ioctl.h`, `adv748x.h`.
- Detected declarations: `function adv748x_csi2_set_virtual_channel`, `function adv748x_csi2_register_link`, `function adv748x_csi2_init_state`, `function subdevices`, `function adv748x_csi2_s_stream`, `function adv748x_csi2_enum_mbus_code`, `function adv748x_csi2_is_fmt_supported`, `function adv748x_csi2_set_format`, `function adv748x_csi2_get_mbus_config`, `function adv748x_csi2_set_pixelrate`.
- Atlas domain: Driver Families / drivers/media.
- 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.