drivers/media/platform/qcom/camss/camss.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/qcom/camss/camss.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/qcom/camss/camss.c- Extension
.c- Size
- 137722 bytes
- Lines
- 5820
- 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/clk.hlinux/interconnect.hlinux/media-bus-format.hlinux/media.hlinux/module.hlinux/platform_device.hlinux/of.hlinux/of_device.hlinux/of_graph.hlinux/pm_runtime.hlinux/pm_domain.hlinux/slab.hlinux/videodev2.hmedia/media-device.hmedia/v4l2-async.hmedia/v4l2-device.hmedia/v4l2-mc.hmedia/v4l2-fwnode.hcamss.h
Detected Declarations
function camss_add_clock_marginfunction camss_enable_clocksfunction camss_disable_clocksfunction camss_get_link_freqfunction camss_get_pixel_clockfunction camss_pm_domain_onfunction camss_pm_domain_offfunction vfe_parent_dev_ops_getfunction vfe_parent_dev_ops_putfunction camss_parse_endpoint_nodefunction camss_parse_portsfunction fwnode_graph_for_each_endpointfunction camss_init_subdevicesfunction camss_link_errfunction camss_link_entitiesfunction camss_reg_updatefunction camss_buf_donefunction camss_register_entitiesfunction camss_unregister_entitiesfunction camss_subdev_notifier_boundfunction camss_subdev_notifier_completefunction list_for_each_entryfunction camss_configure_pdfunction camss_icc_getfunction camss_genpd_subdevice_cleanupfunction camss_genpd_cleanupfunction camss_probefunction camss_deletefunction camss_removefunction camss_runtime_suspendfunction camss_runtime_resume
Annotated Snippet
if (ret) {
dev_err(dev, "clock enable failed: %d\n", ret);
goto error;
}
}
return 0;
error:
for (i--; i >= 0; i--)
clk_disable_unprepare(clock[i].clk);
return ret;
}
/*
* camss_disable_clocks - Disable multiple clocks
* @nclocks: Number of clocks in clock array
* @clock: Clock array
*/
void camss_disable_clocks(int nclocks, struct camss_clock *clock)
{
int i;
for (i = nclocks - 1; i >= 0; i--)
clk_disable_unprepare(clock[i].clk);
}
/*
* camss_find_sensor_pad - Find the media pad via which the sensor is linked
* @entity: Media entity to start searching from
*
* Return a pointer to sensor media pad or NULL if not found
*/
struct media_pad *camss_find_sensor_pad(struct media_entity *entity)
{
struct media_pad *pad;
while (1) {
pad = &entity->pads[0];
if (!(pad->flags & MEDIA_PAD_FL_SINK))
return NULL;
pad = media_pad_remote_pad_first(pad);
if (!pad || !is_media_entity_v4l2_subdev(pad->entity))
return NULL;
entity = pad->entity;
if (entity->function == MEDIA_ENT_F_CAM_SENSOR)
return pad;
}
}
/**
* camss_get_link_freq - Get link frequency from sensor
* @entity: Media entity in the current pipeline
* @bpp: Number of bits per pixel for the current format
* @lanes: Number of lanes in the link to the sensor
*
* Return link frequency on success or a negative error code otherwise
*/
s64 camss_get_link_freq(struct media_entity *entity, unsigned int bpp,
unsigned int lanes)
{
struct media_pad *sensor_pad;
sensor_pad = camss_find_sensor_pad(entity);
if (!sensor_pad)
return -ENODEV;
return v4l2_get_link_freq(sensor_pad, bpp, 2 * lanes);
}
/*
* camss_get_pixel_clock - Get pixel clock rate from sensor
* @entity: Media entity in the current pipeline
* @pixel_clock: Received pixel clock value
*
* Return 0 on success or a negative error code otherwise
*/
int camss_get_pixel_clock(struct media_entity *entity, u64 *pixel_clock)
{
struct media_pad *sensor_pad;
struct v4l2_subdev *subdev;
struct v4l2_ctrl *ctrl;
sensor_pad = camss_find_sensor_pad(entity);
if (!sensor_pad)
return -ENODEV;
Annotation
- Immediate include surface: `linux/clk.h`, `linux/interconnect.h`, `linux/media-bus-format.h`, `linux/media.h`, `linux/module.h`, `linux/platform_device.h`, `linux/of.h`, `linux/of_device.h`.
- Detected declarations: `function camss_add_clock_margin`, `function camss_enable_clocks`, `function camss_disable_clocks`, `function camss_get_link_freq`, `function camss_get_pixel_clock`, `function camss_pm_domain_on`, `function camss_pm_domain_off`, `function vfe_parent_dev_ops_get`, `function vfe_parent_dev_ops_put`, `function camss_parse_endpoint_node`.
- 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.