drivers/media/platform/qcom/camss/camss-csiphy.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/qcom/camss/camss-csiphy.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/qcom/camss/camss-csiphy.c- Extension
.c- Size
- 21412 bytes
- Lines
- 834
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/clk.hlinux/delay.hlinux/interrupt.hlinux/io.hlinux/kernel.hlinux/of.hlinux/platform_device.hlinux/pm_runtime.hmedia/media-entity.hmedia/v4l2-device.hmedia/v4l2-subdev.hcamss-csiphy.hcamss.h
Detected Declarations
function csiphy_get_bppfunction csiphy_set_clock_ratesfunction csiphy_set_powerfunction csiphy_stream_onfunction csiphy_stream_offfunction csiphy_set_streamfunction __csiphy_get_formatfunction csiphy_try_formatfunction csiphy_enum_mbus_codefunction csiphy_enum_frame_sizefunction csiphy_get_formatfunction csiphy_set_formatfunction csiphy_init_formatsfunction __printffunction msm_csiphy_subdev_initfunction csiphy_link_setupfunction msm_csiphy_register_entityfunction msm_csiphy_unregister_entity
Annotated Snippet
if (csiphy->rate_set[i]) {
u64 min_rate = link_freq / 4;
long round_rate;
camss_add_clock_margin(&min_rate);
for (j = 0; j < clock->nfreqs; j++)
if (min_rate < clock->freq[j])
break;
if (j == clock->nfreqs) {
dev_err(dev,
"Pixel clock is too high for CSIPHY\n");
return -EINVAL;
}
/* if sensor pixel clock is not available */
/* set highest possible CSIPHY clock rate */
if (min_rate == 0)
j = clock->nfreqs - 1;
round_rate = clk_round_rate(clock->clk, clock->freq[j]);
if (round_rate < 0) {
dev_err(dev, "clk round rate failed: %ld\n",
round_rate);
return -EINVAL;
}
csiphy->timer_clk_rate = round_rate;
ret = clk_set_rate(clock->clk, csiphy->timer_clk_rate);
if (ret < 0) {
dev_err(dev, "clk set rate failed: %d\n", ret);
return ret;
}
}
}
return 0;
}
/*
* csiphy_set_power - Power on/off CSIPHY module
* @sd: CSIPHY V4L2 subdevice
* @on: Requested power state
*
* Return 0 on success or a negative error code otherwise
*/
static int csiphy_set_power(struct v4l2_subdev *sd, int on)
{
struct csiphy_device *csiphy = v4l2_get_subdevdata(sd);
struct device *dev = csiphy->camss->dev;
if (on) {
int ret;
ret = pm_runtime_resume_and_get(dev);
if (ret < 0)
return ret;
ret = regulator_bulk_enable(csiphy->num_supplies,
csiphy->supplies);
if (ret < 0) {
pm_runtime_put_sync(dev);
return ret;
}
ret = csiphy_set_clock_rates(csiphy);
if (ret < 0) {
regulator_bulk_disable(csiphy->num_supplies,
csiphy->supplies);
pm_runtime_put_sync(dev);
return ret;
}
ret = camss_enable_clocks(csiphy->nclocks, csiphy->clock, dev);
if (ret < 0) {
regulator_bulk_disable(csiphy->num_supplies,
csiphy->supplies);
pm_runtime_put_sync(dev);
return ret;
}
enable_irq(csiphy->irq);
csiphy->res->hw_ops->reset(csiphy);
csiphy->res->hw_ops->hw_version_read(csiphy, dev);
} else {
disable_irq(csiphy->irq);
Annotation
- Immediate include surface: `linux/clk.h`, `linux/delay.h`, `linux/interrupt.h`, `linux/io.h`, `linux/kernel.h`, `linux/of.h`, `linux/platform_device.h`, `linux/pm_runtime.h`.
- Detected declarations: `function csiphy_get_bpp`, `function csiphy_set_clock_rates`, `function csiphy_set_power`, `function csiphy_stream_on`, `function csiphy_stream_off`, `function csiphy_set_stream`, `function __csiphy_get_format`, `function csiphy_try_format`, `function csiphy_enum_mbus_code`, `function csiphy_enum_frame_size`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source implementation candidate.
- 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.