drivers/video/fbdev/macmodes.c
Source file repositories/reference/linux-study-clean/drivers/video/fbdev/macmodes.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/video/fbdev/macmodes.c- Extension
.c- Size
- 12769 bytes
- Lines
- 417
- Domain
- Driver Families
- Bucket
- drivers/video
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/errno.hlinux/export.hlinux/fb.hlinux/string.hlinux/module.hmacmodes.h
Detected Declarations
function mac_vmode_to_varfunction mac_var_to_vmodefunction mac_map_monitor_sensefunction fb_find_modeexport mac_vmode_to_varexport mac_map_monitor_senseexport mac_find_mode
Annotated Snippet
switch (cmode) {
case CMODE_8:
var->bits_per_pixel = 8;
var->red.offset = 0;
var->red.length = 8;
var->green.offset = 0;
var->green.length = 8;
var->blue.offset = 0;
var->blue.length = 8;
break;
case CMODE_16:
var->bits_per_pixel = 16;
var->red.offset = 10;
var->red.length = 5;
var->green.offset = 5;
var->green.length = 5;
var->blue.offset = 0;
var->blue.length = 5;
break;
case CMODE_32:
var->bits_per_pixel = 32;
var->red.offset = 16;
var->red.length = 8;
var->green.offset = 8;
var->green.length = 8;
var->blue.offset = 0;
var->blue.length = 8;
var->transp.offset = 24;
var->transp.length = 8;
break;
default:
return -EINVAL;
}
var->xres = mode->xres;
var->yres = mode->yres;
var->xres_virtual = mode->xres;
var->yres_virtual = mode->yres;
var->height = -1;
var->width = -1;
var->pixclock = mode->pixclock;
var->left_margin = mode->left_margin;
var->right_margin = mode->right_margin;
var->upper_margin = mode->upper_margin;
var->lower_margin = mode->lower_margin;
var->hsync_len = mode->hsync_len;
var->vsync_len = mode->vsync_len;
var->sync = mode->sync;
var->vmode = mode->vmode;
return 0;
}
EXPORT_SYMBOL(mac_vmode_to_var);
/**
* mac_var_to_vmode - convert var structure to MacOS vmode/cmode pair
* @var: frame buffer video mode structure
* @vmode: MacOS video mode
* @cmode: MacOS color mode
*
* Converts a frame buffer video mode structure to a MacOS
* vmode/cmode pair.
*
* Returns negative errno on error, or zero for success.
*
*/
int mac_var_to_vmode(const struct fb_var_screeninfo *var, int *vmode,
int *cmode)
{
const struct mode_map *map;
if (var->bits_per_pixel <= 8)
*cmode = CMODE_8;
else if (var->bits_per_pixel <= 16)
*cmode = CMODE_16;
else if (var->bits_per_pixel <= 32)
*cmode = CMODE_32;
else
return -EINVAL;
/*
* Find the mac_mode with a matching resolution or failing that, the
* closest larger resolution. Skip modes with a shorter pixel clock period.
*/
for (map = mac_modes; map->vmode != -1; map++) {
const struct fb_videomode *mode = map->mode;
if (var->xres > mode->xres || var->yres > mode->yres)
Annotation
- Immediate include surface: `linux/errno.h`, `linux/export.h`, `linux/fb.h`, `linux/string.h`, `linux/module.h`, `macmodes.h`.
- Detected declarations: `function mac_vmode_to_var`, `function mac_var_to_vmode`, `function mac_map_monitor_sense`, `function fb_find_mode`, `export mac_vmode_to_var`, `export mac_map_monitor_sense`, `export mac_find_mode`.
- Atlas domain: Driver Families / drivers/video.
- 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.