drivers/staging/media/atomisp/pci/hive_isp_css_common/host/vmem.c
Source file repositories/reference/linux-study-clean/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/vmem.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/staging/media/atomisp/pci/hive_isp_css_common/host/vmem.c- Extension
.c- Size
- 8121 bytes
- Lines
- 276
- 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.
Dependency Surface
isp.hvmem.hvmem_local.hia_css_device_access.hassert_support.h
Detected Declarations
function subwordfunction inv_subwordfunction move_subwordfunction hive_sim_wide_unpackfunction hive_sim_wide_packfunction load_vectorfunction store_vectorfunction isp_vmem_2d_loadfunction isp_vmem_2d_store
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Support for Intel Camera Imaging ISP subsystem.
* Copyright (c) 2010 - 2016, Intel Corporation.
*/
#include "isp.h"
#include "vmem.h"
#include "vmem_local.h"
#if !defined(HRT_MEMORY_ACCESS)
#include "ia_css_device_access.h"
#endif
#include "assert_support.h"
typedef unsigned long long hive_uedge;
typedef hive_uedge *hive_wide;
/* Copied from SDK: sim_semantics.c */
/* subword bits move like this: MSB[____xxxx____]LSB -> MSB[00000000xxxx]LSB */
static inline hive_uedge
subword(hive_uedge w, unsigned int start, unsigned int end)
{
return (w & (((1ULL << (end - 1)) - 1) << 1 | 1)) >> start;
}
/* inverse subword bits move like this: MSB[xxxx____xxxx]LSB -> MSB[xxxx0000xxxx]LSB */
static inline hive_uedge
inv_subword(hive_uedge w, unsigned int start, unsigned int end)
{
return w & (~(((1ULL << (end - 1)) - 1) << 1 | 1) | ((1ULL << start) - 1));
}
#define uedge_bits (8 * sizeof(hive_uedge))
#define move_lower_bits(target, target_bit, src, src_bit) move_subword(target, target_bit, src, 0, src_bit)
#define move_upper_bits(target, target_bit, src, src_bit) move_subword(target, target_bit, src, src_bit, uedge_bits)
#define move_word(target, target_bit, src) move_subword(target, target_bit, src, 0, uedge_bits)
static void
move_subword(
hive_uedge *target,
unsigned int target_bit,
hive_uedge src,
unsigned int src_start,
unsigned int src_end)
{
unsigned int start_elem = target_bit / uedge_bits;
unsigned int start_bit = target_bit % uedge_bits;
unsigned int subword_width = src_end - src_start;
hive_uedge src_subword = subword(src, src_start, src_end);
if (subword_width + start_bit > uedge_bits) { /* overlap */
hive_uedge old_val1;
hive_uedge old_val0 = inv_subword(target[start_elem], start_bit, uedge_bits);
target[start_elem] = old_val0 | (src_subword << start_bit);
old_val1 = inv_subword(target[start_elem + 1], 0,
subword_width + start_bit - uedge_bits);
target[start_elem + 1] = old_val1 | (src_subword >> (uedge_bits - start_bit));
} else {
hive_uedge old_val = inv_subword(target[start_elem], start_bit,
start_bit + subword_width);
target[start_elem] = old_val | (src_subword << start_bit);
}
}
static void
hive_sim_wide_unpack(
hive_wide vector,
hive_wide elem,
hive_uint elem_bits,
hive_uint index)
{
/* pointers into wide_type: */
unsigned int start_elem = (elem_bits * index) / uedge_bits;
unsigned int start_bit = (elem_bits * index) % uedge_bits;
unsigned int end_elem = (elem_bits * (index + 1) - 1) / uedge_bits;
unsigned int end_bit = ((elem_bits * (index + 1) - 1) % uedge_bits) + 1;
if (elem_bits == uedge_bits) {
/* easy case for speedup: */
elem[0] = vector[index];
} else if (start_elem == end_elem) {
/* only one (<=64 bits) element needs to be (partly) copied: */
move_subword(elem, 0, vector[start_elem], start_bit, end_bit);
} else {
/* general case: handles edge spanning cases (includes >64bit elements) */
Annotation
- Immediate include surface: `isp.h`, `vmem.h`, `vmem_local.h`, `ia_css_device_access.h`, `assert_support.h`.
- Detected declarations: `function subword`, `function inv_subword`, `function move_subword`, `function hive_sim_wide_unpack`, `function hive_sim_wide_pack`, `function load_vector`, `function store_vector`, `function isp_vmem_2d_load`, `function isp_vmem_2d_store`.
- Atlas domain: Driver Families / drivers/staging.
- 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.