drivers/gpu/drm/vmwgfx/vmwgfx_devcaps.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/vmwgfx/vmwgfx_devcaps.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/vmwgfx/vmwgfx_devcaps.c- Extension
.c- Size
- 4299 bytes
- Lines
- 144
- 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.
- 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/vmalloc.hvmwgfx_devcaps.hvmwgfx_drv.h
Detected Declarations
struct svga_3d_compat_capfunction vmw_mask_legacy_multisamplefunction vmw_fill_compat_capfunction vmw_devcaps_createfunction vmw_devcaps_destroyfunction vmw_devcaps_sizefunction vmw_devcaps_copy
Annotated Snippet
struct svga_3d_compat_cap {
SVGA3dFifoCapsRecordHeader header;
SVGA3dFifoCapPair pairs[SVGA3D_DEVCAP_MAX];
};
static u32 vmw_mask_legacy_multisample(unsigned int cap, u32 fmt_value)
{
/*
* A version of user-space exists which use MULTISAMPLE_MASKABLESAMPLES
* to check the sample count supported by virtual device. Since there
* never was support for multisample count for backing MOB return 0.
*
* MULTISAMPLE_MASKABLESAMPLES devcap is marked as deprecated by virtual
* device.
*/
if (cap == SVGA3D_DEVCAP_DEAD5)
return 0;
return fmt_value;
}
static int vmw_fill_compat_cap(struct vmw_private *dev_priv, void *bounce,
size_t size)
{
struct svga_3d_compat_cap *compat_cap =
(struct svga_3d_compat_cap *) bounce;
unsigned int i;
size_t pair_offset = offsetof(struct svga_3d_compat_cap, pairs);
unsigned int max_size;
if (size < pair_offset)
return -EINVAL;
max_size = (size - pair_offset) / sizeof(SVGA3dFifoCapPair);
if (max_size > SVGA3D_DEVCAP_MAX)
max_size = SVGA3D_DEVCAP_MAX;
compat_cap->header.length =
(pair_offset + max_size * sizeof(SVGA3dFifoCapPair)) / sizeof(u32);
compat_cap->header.type = SVGA3D_FIFO_CAPS_RECORD_DEVCAPS;
for (i = 0; i < max_size; ++i) {
compat_cap->pairs[i][0] = i;
compat_cap->pairs[i][1] = vmw_mask_legacy_multisample
(i, dev_priv->devcaps[i]);
}
return 0;
}
int vmw_devcaps_create(struct vmw_private *vmw)
{
bool gb_objects = !!(vmw->capabilities & SVGA_CAP_GBOBJECTS);
uint32_t i;
if (gb_objects) {
vmw->devcaps = vzalloc(sizeof(uint32_t) * SVGA3D_DEVCAP_MAX);
if (!vmw->devcaps)
return -ENOMEM;
for (i = 0; i < SVGA3D_DEVCAP_MAX; ++i) {
vmw_write(vmw, SVGA_REG_DEV_CAP, i);
vmw->devcaps[i] = vmw_read(vmw, SVGA_REG_DEV_CAP);
}
}
return 0;
}
void vmw_devcaps_destroy(struct vmw_private *vmw)
{
vfree(vmw->devcaps);
vmw->devcaps = NULL;
}
uint32 vmw_devcaps_size(const struct vmw_private *vmw,
bool gb_aware)
{
bool gb_objects = !!(vmw->capabilities & SVGA_CAP_GBOBJECTS);
if (gb_objects && gb_aware)
return SVGA3D_DEVCAP_MAX * sizeof(uint32_t);
else if (gb_objects)
return sizeof(struct svga_3d_compat_cap) +
sizeof(uint32_t);
else if (vmw->fifo_mem != NULL)
return (SVGA_FIFO_3D_CAPS_LAST - SVGA_FIFO_3D_CAPS + 1) *
sizeof(uint32_t);
else
return 0;
Annotation
- Immediate include surface: `linux/vmalloc.h`, `vmwgfx_devcaps.h`, `vmwgfx_drv.h`.
- Detected declarations: `struct svga_3d_compat_cap`, `function vmw_mask_legacy_multisample`, `function vmw_fill_compat_cap`, `function vmw_devcaps_create`, `function vmw_devcaps_destroy`, `function vmw_devcaps_size`, `function vmw_devcaps_copy`.
- 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.