drivers/gpu/drm/imagination/pvr_stream.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/imagination/pvr_stream.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/imagination/pvr_stream.c- Extension
.c- Size
- 7837 bytes
- Lines
- 282
- Domain
- Driver Families
- Bucket
- drivers/gpu
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
pvr_device.hpvr_rogue_fwif_stream.hpvr_stream.hlinux/align.hlinux/slab.hlinux/types.huapi/drm/pvr_drm.h
Detected Declarations
function stream_def_is_supportedfunction pvr_stream_get_datafunction pvr_stream_process_1function pvr_stream_process_ext_streamfunction pvr_stream_processfunction pvr_stream_create_musthave_masks
Annotated Snippet
pvr_device_has_feature(pvr_dev, stream_def->feature)) {
return true;
}
if ((stream_def->feature & PVR_FEATURE_NOT) &&
!pvr_device_has_feature(pvr_dev, stream_def->feature & ~PVR_FEATURE_NOT)) {
return true;
}
return false;
}
static int
pvr_stream_get_data(u8 *stream, u32 *stream_offset, u32 stream_size, u32 data_size, u32 align_size,
void *dest)
{
*stream_offset = ALIGN(*stream_offset, align_size);
if ((*stream_offset + data_size) > stream_size)
return -EINVAL;
memcpy(dest, stream + *stream_offset, data_size);
(*stream_offset) += data_size;
return 0;
}
/**
* pvr_stream_process_1() - Process a single stream and fill destination structure
* @pvr_dev: Device pointer.
* @stream_def: Stream definition.
* @nr_entries: Number of entries in &stream_def.
* @stream: Pointer to stream.
* @stream_offset: Starting offset within stream.
* @stream_size: Size of input stream, in bytes.
* @dest: Pointer to destination structure.
* @dest_size: Size of destination structure.
* @stream_offset_out: Pointer to variable to write updated stream offset to. May be NULL.
*
* Returns:
* * 0 on success, or
* * -%EINVAL on malformed stream.
*/
static int
pvr_stream_process_1(struct pvr_device *pvr_dev, const struct pvr_stream_def *stream_def,
u32 nr_entries, u8 *stream, u32 stream_offset, u32 stream_size,
u8 *dest, u32 dest_size, u32 *stream_offset_out)
{
int err = 0;
for (u32 i = 0; i < nr_entries; i++) {
if (stream_def[i].offset >= dest_size) {
err = -EINVAL;
break;
}
if (!stream_def_is_supported(pvr_dev, &stream_def[i]))
continue;
switch (stream_def[i].size) {
case PVR_STREAM_SIZE_8:
err = pvr_stream_get_data(stream, &stream_offset, stream_size, sizeof(u8),
sizeof(u8), dest + stream_def[i].offset);
if (err)
return err;
break;
case PVR_STREAM_SIZE_16:
err = pvr_stream_get_data(stream, &stream_offset, stream_size, sizeof(u16),
sizeof(u16), dest + stream_def[i].offset);
if (err)
return err;
break;
case PVR_STREAM_SIZE_32:
err = pvr_stream_get_data(stream, &stream_offset, stream_size, sizeof(u32),
sizeof(u32), dest + stream_def[i].offset);
if (err)
return err;
break;
case PVR_STREAM_SIZE_64:
err = pvr_stream_get_data(stream, &stream_offset, stream_size, sizeof(u64),
sizeof(u64), dest + stream_def[i].offset);
if (err)
return err;
break;
case PVR_STREAM_SIZE_ARRAY:
Annotation
- Immediate include surface: `pvr_device.h`, `pvr_rogue_fwif_stream.h`, `pvr_stream.h`, `linux/align.h`, `linux/slab.h`, `linux/types.h`, `uapi/drm/pvr_drm.h`.
- Detected declarations: `function stream_def_is_supported`, `function pvr_stream_get_data`, `function pvr_stream_process_1`, `function pvr_stream_process_ext_stream`, `function pvr_stream_process`, `function pvr_stream_create_musthave_masks`.
- Atlas domain: Driver Families / drivers/gpu.
- 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.