drivers/gpu/drm/vboxvideo/vbox_main.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/vboxvideo/vbox_main.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/vboxvideo/vbox_main.c- Extension
.c- Size
- 4614 bytes
- Lines
- 176
- 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
linux/pci.hlinux/vbox_err.hdrm/drm_damage_helper.hdrm/drm_print.hvbox_drv.hvboxvideo_guest.hvboxvideo_vbe.h
Detected Declarations
function Copyrightfunction vbox_accel_initfunction vbox_accel_finifunction have_hgsmi_mode_hintsfunction vbox_check_supportedfunction vbox_hw_initfunction vbox_hw_fini
Annotated Snippet
// SPDX-License-Identifier: MIT
/*
* Copyright (C) 2013-2017 Oracle Corporation
* This file is based on ast_main.c
* Copyright 2012 Red Hat Inc.
* Authors: Dave Airlie <airlied@redhat.com>,
* Michael Thayer <michael.thayer@oracle.com,
* Hans de Goede <hdegoede@redhat.com>
*/
#include <linux/pci.h>
#include <linux/vbox_err.h>
#include <drm/drm_damage_helper.h>
#include <drm/drm_print.h>
#include "vbox_drv.h"
#include "vboxvideo_guest.h"
#include "vboxvideo_vbe.h"
void vbox_report_caps(struct vbox_private *vbox)
{
u32 caps = VBVACAPS_DISABLE_CURSOR_INTEGRATION |
VBVACAPS_IRQ | VBVACAPS_USE_VBVA_ONLY;
/* The host only accepts VIDEO_MODE_HINTS if it is send separately. */
hgsmi_send_caps_info(vbox->guest_pool, caps);
caps |= VBVACAPS_VIDEO_MODE_HINTS;
hgsmi_send_caps_info(vbox->guest_pool, caps);
}
static int vbox_accel_init(struct vbox_private *vbox)
{
struct pci_dev *pdev = to_pci_dev(vbox->ddev.dev);
struct vbva_buffer *vbva;
unsigned int i;
vbox->vbva_info = devm_kcalloc(vbox->ddev.dev, vbox->num_crtcs,
sizeof(*vbox->vbva_info), GFP_KERNEL);
if (!vbox->vbva_info)
return -ENOMEM;
/* Take a command buffer for each screen from the end of usable VRAM. */
vbox->available_vram_size -= vbox->num_crtcs * VBVA_MIN_BUFFER_SIZE;
vbox->vbva_buffers = pcim_iomap_range(
pdev, 0, vbox->available_vram_size,
vbox->num_crtcs * VBVA_MIN_BUFFER_SIZE);
if (IS_ERR(vbox->vbva_buffers))
return PTR_ERR(vbox->vbva_buffers);
for (i = 0; i < vbox->num_crtcs; ++i) {
vbva_setup_buffer_context(&vbox->vbva_info[i],
vbox->available_vram_size +
i * VBVA_MIN_BUFFER_SIZE,
VBVA_MIN_BUFFER_SIZE);
vbva = (void __force *)vbox->vbva_buffers +
i * VBVA_MIN_BUFFER_SIZE;
if (!vbva_enable(&vbox->vbva_info[i],
vbox->guest_pool, vbva, i)) {
/* very old host or driver error. */
DRM_ERROR("vboxvideo: vbva_enable failed\n");
}
}
return 0;
}
static void vbox_accel_fini(struct vbox_private *vbox)
{
unsigned int i;
for (i = 0; i < vbox->num_crtcs; ++i)
vbva_disable(&vbox->vbva_info[i], vbox->guest_pool, i);
}
/* Do we support the 4.3 plus mode hint reporting interface? */
static bool have_hgsmi_mode_hints(struct vbox_private *vbox)
{
u32 have_hints, have_cursor;
int ret;
ret = hgsmi_query_conf(vbox->guest_pool,
VBOX_VBVA_CONF32_MODE_HINT_REPORTING,
&have_hints);
if (ret)
return false;
ret = hgsmi_query_conf(vbox->guest_pool,
VBOX_VBVA_CONF32_GUEST_CURSOR_REPORTING,
Annotation
- Immediate include surface: `linux/pci.h`, `linux/vbox_err.h`, `drm/drm_damage_helper.h`, `drm/drm_print.h`, `vbox_drv.h`, `vboxvideo_guest.h`, `vboxvideo_vbe.h`.
- Detected declarations: `function Copyright`, `function vbox_accel_init`, `function vbox_accel_fini`, `function have_hgsmi_mode_hints`, `function vbox_check_supported`, `function vbox_hw_init`, `function vbox_hw_fini`.
- 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.