drivers/media/platform/qcom/camss/camss-tpg.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/qcom/camss/camss-tpg.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/qcom/camss/camss-tpg.c- Extension
.c- Size
- 11258 bytes
- Lines
- 520
- 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/clk.hlinux/io.hlinux/kernel.hlinux/of.hlinux/platform_device.hlinux/pm_runtime.hmedia/media-entity.hmedia/v4l2-device.hmedia/v4l2-subdev.hmedia/mipi-csi2.hcamss-tpg.hcamss.h
Detected Declarations
function tpg_set_clock_ratesfunction tpg_set_powerfunction tpg_set_streamfunction __tpg_get_formatfunction tpg_try_formatfunction tpg_enum_mbus_codefunction tpg_enum_frame_sizefunction tpg_get_formatfunction tpg_set_formatfunction tpg_init_formatsfunction tpg_s_ctrlfunction msm_tpg_subdev_initfunction tpg_link_setupfunction msm_tpg_register_entityfunction msm_tpg_unregister_entity
Annotated Snippet
if (clock->freq) {
round_rate = clk_round_rate(clock->clk, clock->freq[0]);
if (round_rate < 0) {
dev_err(dev, "clk round rate failed: %ld\n",
round_rate);
return -EINVAL;
}
ret = clk_set_rate(clock->clk, round_rate);
if (ret < 0) {
dev_err(dev, "clk set rate failed: %d\n", ret);
return ret;
}
}
}
return 0;
}
static int tpg_set_power(struct v4l2_subdev *sd, int on)
{
struct tpg_device *tpg = v4l2_get_subdevdata(sd);
struct device *dev = tpg->camss->dev;
if (on) {
int ret;
ret = pm_runtime_resume_and_get(dev);
if (ret < 0)
return ret;
ret = tpg_set_clock_rates(tpg);
if (ret < 0) {
pm_runtime_put_sync(dev);
return ret;
}
ret = camss_enable_clocks(tpg->nclocks, tpg->clock, dev);
if (ret < 0) {
pm_runtime_put_sync(dev);
return ret;
}
tpg->res->hw_ops->reset(tpg);
tpg->res->hw_ops->hw_version(tpg);
} else {
camss_disable_clocks(tpg->nclocks, tpg->clock);
pm_runtime_put_sync(dev);
}
return 0;
}
static int tpg_set_stream(struct v4l2_subdev *sd, int enable)
{
struct tpg_device *tpg = v4l2_get_subdevdata(sd);
int ret;
if (enable) {
ret = v4l2_ctrl_handler_setup(&tpg->ctrls);
if (ret < 0) {
dev_err(tpg->camss->dev,
"could not sync v4l2 controls: %d\n", ret);
return ret;
}
}
return tpg->res->hw_ops->configure_stream(tpg, enable);
}
static struct v4l2_mbus_framefmt *
__tpg_get_format(struct tpg_device *tpg,
struct v4l2_subdev_state *sd_state,
unsigned int pad,
enum v4l2_subdev_format_whence which)
{
if (which == V4L2_SUBDEV_FORMAT_TRY)
return v4l2_subdev_state_get_format(sd_state,
pad);
return &tpg->fmt;
}
static void tpg_try_format(struct tpg_device *tpg,
struct v4l2_mbus_framefmt *fmt)
{
unsigned int i;
Annotation
- Immediate include surface: `linux/clk.h`, `linux/io.h`, `linux/kernel.h`, `linux/of.h`, `linux/platform_device.h`, `linux/pm_runtime.h`, `media/media-entity.h`, `media/v4l2-device.h`.
- Detected declarations: `function tpg_set_clock_rates`, `function tpg_set_power`, `function tpg_set_stream`, `function __tpg_get_format`, `function tpg_try_format`, `function tpg_enum_mbus_code`, `function tpg_enum_frame_size`, `function tpg_get_format`, `function tpg_set_format`, `function tpg_init_formats`.
- 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.