drivers/staging/media/ipu7/ipu7-cpd.c
Source file repositories/reference/linux-study-clean/drivers/staging/media/ipu7/ipu7-cpd.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/staging/media/ipu7/ipu7-cpd.c- Extension
.c- Size
- 6855 bytes
- Lines
- 277
- Domain
- Driver Families
- Bucket
- drivers/staging
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/device.hlinux/export.hlinux/gfp_types.hlinux/pci.hlinux/sizes.hlinux/slab.hlinux/types.hipu7.hipu7-cpd.h
Detected Declarations
struct ipu7_cpd_hdrstruct ipu7_cpd_entstruct ipu7_cpd_metadata_hdrstruct ipu7_cpd_metadata_attrstruct ipu7_cpd_metadata_iplstruct ipu7_cpd_metadatafunction ipu7_cpd_validate_cpdfunction ipu7_cpd_validate_metadatafunction ipu7_cpd_validate_cpd_filefunction ipu7_cpd_copy_binary
Annotated Snippet
struct ipu7_cpd_hdr {
u32 hdr_mark;
u32 ent_cnt;
u8 hdr_ver;
u8 ent_ver;
u8 hdr_len;
u8 rsvd;
u8 partition_name[4];
u32 crc32;
} __packed;
struct ipu7_cpd_ent {
u8 name[12];
u32 offset;
u32 len;
u8 rsvd[4];
} __packed;
struct ipu7_cpd_metadata_hdr {
u32 type;
u32 len;
} __packed;
struct ipu7_cpd_metadata_attr {
struct ipu7_cpd_metadata_hdr hdr;
u8 compression_type;
u8 encryption_type;
u8 rsvd[2];
u32 uncompressed_size;
u32 compressed_size;
u32 module_id;
u8 hash[48];
} __packed;
struct ipu7_cpd_metadata_ipl {
struct ipu7_cpd_metadata_hdr hdr;
u32 param[4];
u8 rsvd[8];
} __packed;
struct ipu7_cpd_metadata {
struct ipu7_cpd_metadata_attr attr;
struct ipu7_cpd_metadata_ipl ipl;
} __packed;
static inline struct ipu7_cpd_ent *ipu7_cpd_get_entry(const void *cpd, int idx)
{
const struct ipu7_cpd_hdr *cpd_hdr = cpd;
return ((struct ipu7_cpd_ent *)((u8 *)cpd + cpd_hdr->hdr_len)) + idx;
}
#define ipu7_cpd_get_manifest(cpd) ipu7_cpd_get_entry(cpd, 0)
static struct ipu7_cpd_metadata *ipu7_cpd_get_metadata(const void *cpd, int idx)
{
struct ipu7_cpd_ent *cpd_ent =
ipu7_cpd_get_entry(cpd, CPD_METADATA_START_IDX + idx * 2);
return (struct ipu7_cpd_metadata *)((u8 *)cpd + cpd_ent->offset);
}
static int ipu7_cpd_validate_cpd(struct ipu7_device *isp,
const void *cpd, unsigned long data_size)
{
const struct ipu7_cpd_hdr *cpd_hdr = cpd;
struct device *dev = &isp->pdev->dev;
struct ipu7_cpd_ent *ent;
unsigned int i;
u8 len;
len = cpd_hdr->hdr_len;
/* Ensure cpd hdr is within moduledata */
if (data_size < len) {
dev_err(dev, "Invalid CPD moduledata size\n");
return -EINVAL;
}
/* Check for CPD file marker */
if (cpd_hdr->hdr_mark != CPD_HDR_MARK) {
dev_err(dev, "Invalid CPD header marker\n");
return -EINVAL;
}
/* Sanity check for CPD entry header */
if (cpd_hdr->ent_cnt != CPD_ENTRY_NUM) {
dev_err(dev, "Invalid CPD entry number %d\n",
cpd_hdr->ent_cnt);
return -EINVAL;
Annotation
- Immediate include surface: `linux/device.h`, `linux/export.h`, `linux/gfp_types.h`, `linux/pci.h`, `linux/sizes.h`, `linux/slab.h`, `linux/types.h`, `ipu7.h`.
- Detected declarations: `struct ipu7_cpd_hdr`, `struct ipu7_cpd_ent`, `struct ipu7_cpd_metadata_hdr`, `struct ipu7_cpd_metadata_attr`, `struct ipu7_cpd_metadata_ipl`, `struct ipu7_cpd_metadata`, `function ipu7_cpd_validate_cpd`, `function ipu7_cpd_validate_metadata`, `function ipu7_cpd_validate_cpd_file`, `function ipu7_cpd_copy_binary`.
- Atlas domain: Driver Families / drivers/staging.
- Implementation status: integration 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.