drivers/gpu/drm/vboxvideo/vbox_mode.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/vboxvideo/vbox_mode.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/vboxvideo/vbox_mode.c- Extension
.c- Size
- 26548 bytes
- Lines
- 888
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/iosys-map.hlinux/export.hdrm/drm_atomic.hdrm/drm_atomic_helper.hdrm/drm_edid.hdrm/drm_fb_helper.hdrm/drm_fourcc.hdrm/drm_framebuffer.hdrm/drm_gem_atomic_helper.hdrm/drm_gem_framebuffer_helper.hdrm/drm_plane_helper.hdrm/drm_print.hdrm/drm_probe_helper.hhgsmi_channels.hvbox_drv.hvboxvideo.h
Detected Declarations
function Copyrightfunction vbox_set_viewfunction vbox_set_up_input_mappingfunction vbox_crtc_set_base_and_modefunction list_for_each_entryfunction vbox_crtc_atomic_enablefunction vbox_crtc_destroyfunction vbox_primary_atomic_checkfunction vbox_primary_atomic_updatefunction vbox_primary_atomic_disablefunction vbox_cursor_atomic_checkfunction copy_cursor_imagefunction vbox_cursor_atomic_updatefunction vbox_cursor_atomic_disablefunction list_for_each_entryfunction vbox_encoder_destroyfunction vbox_set_edidfunction vbox_get_modesfunction vbox_connector_destroyfunction vbox_connector_detectfunction vbox_fill_modesfunction vbox_connector_initfunction vbox_mode_initfunction vbox_mode_fini
Annotated Snippet
if (!fb1) {
fb1 = fb;
if (fb1 == vbox->ddev.fb_helper->fb)
break;
} else if (fb != fb1) {
single_framebuffer = false;
}
}
if (!fb1)
return false;
if (single_framebuffer) {
vbox->single_framebuffer = true;
vbox->input_mapping_width = fb1->width;
vbox->input_mapping_height = fb1->height;
return old_single_framebuffer != vbox->single_framebuffer;
}
/* Otherwise calculate the total span of all screens. */
list_for_each_entry(connectori, &vbox->ddev.mode_config.connector_list,
head) {
struct vbox_connector *vbox_connector =
to_vbox_connector(connectori);
struct vbox_crtc *vbox_crtc = vbox_connector->vbox_crtc;
width = max_t(u16, width, vbox_crtc->x_hint +
vbox_connector->mode_hint.width);
height = max_t(u16, height, vbox_crtc->y_hint +
vbox_connector->mode_hint.height);
}
vbox->single_framebuffer = false;
vbox->input_mapping_width = width;
vbox->input_mapping_height = height;
return old_single_framebuffer != vbox->single_framebuffer;
}
static void vbox_crtc_set_base_and_mode(struct drm_crtc *crtc,
struct drm_framebuffer *fb,
int x, int y)
{
struct drm_gem_vram_object *gbo = drm_gem_vram_of_gem(fb->obj[0]);
struct vbox_private *vbox = to_vbox_dev(crtc->dev);
struct vbox_crtc *vbox_crtc = to_vbox_crtc(crtc);
bool needs_modeset = drm_atomic_crtc_needs_modeset(crtc->state);
mutex_lock(&vbox->hw_mutex);
if (crtc->state->enable) {
vbox_crtc->width = crtc->state->mode.hdisplay;
vbox_crtc->height = crtc->state->mode.vdisplay;
}
vbox_crtc->x = x;
vbox_crtc->y = y;
vbox_crtc->fb_offset = drm_gem_vram_offset(gbo);
/* vbox_do_modeset() checks vbox->single_framebuffer so update it now */
if (needs_modeset && vbox_set_up_input_mapping(vbox)) {
struct drm_crtc *crtci;
list_for_each_entry(crtci, &vbox->ddev.mode_config.crtc_list,
head) {
if (crtci == crtc)
continue;
vbox_do_modeset(crtci);
}
}
vbox_set_view(crtc);
vbox_do_modeset(crtc);
if (needs_modeset)
hgsmi_update_input_mapping(vbox->guest_pool, 0, 0,
vbox->input_mapping_width,
vbox->input_mapping_height);
mutex_unlock(&vbox->hw_mutex);
}
static void vbox_crtc_atomic_enable(struct drm_crtc *crtc,
struct drm_atomic_commit *state)
{
}
static void vbox_crtc_atomic_disable(struct drm_crtc *crtc,
struct drm_atomic_commit *state)
{
}
Annotation
- Immediate include surface: `linux/iosys-map.h`, `linux/export.h`, `drm/drm_atomic.h`, `drm/drm_atomic_helper.h`, `drm/drm_edid.h`, `drm/drm_fb_helper.h`, `drm/drm_fourcc.h`, `drm/drm_framebuffer.h`.
- Detected declarations: `function Copyright`, `function vbox_set_view`, `function vbox_set_up_input_mapping`, `function vbox_crtc_set_base_and_mode`, `function list_for_each_entry`, `function vbox_crtc_atomic_enable`, `function vbox_crtc_destroy`, `function vbox_primary_atomic_check`, `function vbox_primary_atomic_update`, `function vbox_primary_atomic_disable`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.