drivers/staging/media/atomisp/pci/atomisp_cmd.c
Source file repositories/reference/linux-study-clean/drivers/staging/media/atomisp/pci/atomisp_cmd.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/staging/media/atomisp/pci/atomisp_cmd.c- Extension
.c- Size
- 136043 bytes
- Lines
- 4671
- Domain
- Driver Families
- Bucket
- drivers/staging
- 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 user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/errno.hlinux/firmware.hlinux/pci.hlinux/interrupt.hlinux/io.hlinux/kernel.hlinux/kfifo.hlinux/pm_runtime.hlinux/timer.hasm/iosf_mbi.hmedia/v4l2-event.hatomisp_trace_event.hatomisp_cmd.hatomisp_common.hatomisp_fops.hatomisp_internal.hatomisp_ioctl.hatomisp-regs.hatomisp_tables.hatomisp_compat.hatomisp_subdev.hatomisp_dfs_tables.hhmm/hmm.hsh_css_hrt.hsh_css_defs.hsystem_global.hsh_css_internal.hsh_css_sp.hgp_device.hdevice_access.hirq.hia_css_types.h
Detected Declarations
function atomisp_get_sensor_fpsfunction write_target_freq_to_hwfunction atomisp_freq_scalingfunction atomisp_resetfunction disable_isp_irqfunction clear_isp_irqfunction atomisp_msi_irq_initfunction atomisp_msi_irq_uninitfunction atomisp_sof_eventfunction atomisp_eof_eventfunction atomisp_3a_stats_ready_eventfunction atomisp_metadata_ready_eventfunction atomisp_reset_eventfunction print_csi_rx_errorsfunction clear_irq_regfunction atomisp_isrfunction atomisp_clear_css_buffer_countersfunction dump_sp_dmemfunction atomisp_buffers_in_cssfunction atomisp_buffer_donefunction atomisp_flush_video_pipefunction list_for_each_entry_safefunction list_for_each_entry_safefunction atomisp_flush_params_queuefunction atomisp_recover_params_queuefunction atomisp_buf_donefunction list_for_each_entry_safefunction list_for_each_entry_safefunction atomisp_assert_recovery_workfunction atomisp_isr_threadfunction v4l2_fmt_to_sh_fmtfunction raw_output_format_match_inputfunction atomisp_get_pixel_depthfunction atomisp_is_mbuscode_rawfunction atomisp_update_capture_modefunction correctionfunction atomisp_low_lightfunction atomisp_xnrfunction atomisp_nrfunction reductionfunction atomisp_black_levelfunction atomisp_eefunction atomisp_gammafunction atomisp_ctcfunction atomisp_gamma_correctionfunction atomisp_formatsfunction atomisp_free_internal_buffersfunction atomisp_update_grid_info
Annotated Snippet
while ((isp_sspm1 & ISP_FREQ_VALID_MASK) && timeout) {
iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ, ISPSSPM1, &isp_sspm1);
dev_dbg(isp->dev, "waiting for ISPSSPM1 valid bit to be 0.\n");
udelay(100);
timeout--;
}
if (timeout != 0)
break;
}
if (timeout == 0) {
dev_err(isp->dev, "DFS failed due to HW error.\n");
return -EINVAL;
}
iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ, ISPSSPM1, &isp_sspm1);
timeout = 10;
while (((isp_sspm1 >> ISP_FREQ_STAT_OFFSET) != ratio) && timeout) {
iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ, ISPSSPM1, &isp_sspm1);
dev_dbg(isp->dev, "waiting for ISPSSPM1 status bit to be 0x%x.\n",
new_freq);
udelay(100);
timeout--;
}
if (timeout == 0) {
dev_err(isp->dev, "DFS target freq is rejected by HW.\n");
return -EINVAL;
}
return 0;
}
int atomisp_freq_scaling(struct atomisp_device *isp,
enum atomisp_dfs_mode mode,
bool force)
{
const struct atomisp_dfs_config *dfs;
unsigned int new_freq;
struct atomisp_freq_scaling_rule curr_rules;
int i, ret;
unsigned short fps = 0;
dfs = isp->dfs;
if (dfs->lowest_freq == 0 || dfs->max_freq_at_vmin == 0 ||
dfs->highest_freq == 0 || dfs->dfs_table_size == 0 ||
!dfs->dfs_table) {
dev_err(isp->dev, "DFS configuration is invalid.\n");
return -EINVAL;
}
if (mode == ATOMISP_DFS_MODE_LOW) {
new_freq = dfs->lowest_freq;
goto done;
}
if (mode == ATOMISP_DFS_MODE_MAX) {
new_freq = dfs->highest_freq;
goto done;
}
fps = atomisp_get_sensor_fps(&isp->asd);
if (fps == 0) {
dev_info(isp->dev,
"Sensor didn't report FPS. Using DFS max mode.\n");
new_freq = dfs->highest_freq;
goto done;
}
curr_rules.width = isp->asd.fmt[ATOMISP_SUBDEV_PAD_SOURCE].fmt.width;
curr_rules.height = isp->asd.fmt[ATOMISP_SUBDEV_PAD_SOURCE].fmt.height;
curr_rules.fps = fps;
curr_rules.run_mode = isp->asd.run_mode->val;
/* search for the target frequency by looping freq rules*/
for (i = 0; i < dfs->dfs_table_size; i++) {
if (curr_rules.width != dfs->dfs_table[i].width &&
dfs->dfs_table[i].width != ISP_FREQ_RULE_ANY)
continue;
if (curr_rules.height != dfs->dfs_table[i].height &&
dfs->dfs_table[i].height != ISP_FREQ_RULE_ANY)
continue;
if (curr_rules.fps != dfs->dfs_table[i].fps &&
dfs->dfs_table[i].fps != ISP_FREQ_RULE_ANY)
continue;
if (curr_rules.run_mode != dfs->dfs_table[i].run_mode &&
dfs->dfs_table[i].run_mode != ISP_FREQ_RULE_ANY)
continue;
break;
Annotation
- Immediate include surface: `linux/errno.h`, `linux/firmware.h`, `linux/pci.h`, `linux/interrupt.h`, `linux/io.h`, `linux/kernel.h`, `linux/kfifo.h`, `linux/pm_runtime.h`.
- Detected declarations: `function atomisp_get_sensor_fps`, `function write_target_freq_to_hw`, `function atomisp_freq_scaling`, `function atomisp_reset`, `function disable_isp_irq`, `function clear_isp_irq`, `function atomisp_msi_irq_init`, `function atomisp_msi_irq_uninit`, `function atomisp_sof_event`, `function atomisp_eof_event`.
- Atlas domain: Driver Families / drivers/staging.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.