MCPcopy Create free account
hub / github.com/F-Stack/f-stack / a10fb_configure

Function a10fb_configure

freebsd/arm/allwinner/a10_fb.c:463–526  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

461}
462
463static int
464a10fb_configure(struct a10fb_softc *sc, const struct videomode *mode)
465{
466 size_t fbsize;
467 int error;
468
469 fbsize = round_page(mode->hdisplay * mode->vdisplay * (FB_BPP / NBBY));
470
471 /* Detach the old FB device */
472 if (sc->fbdev != NULL) {
473 device_delete_child(sc->dev, sc->fbdev);
474 sc->fbdev = NULL;
475 }
476
477 /* If the FB size has changed, free the old FB memory */
478 if (sc->fbsize > 0 && sc->fbsize != fbsize) {
479 a10fb_freefb(sc);
480 sc->vaddr = 0;
481 }
482
483 /* Allocate the FB if necessary */
484 sc->fbsize = fbsize;
485 if (sc->vaddr == 0) {
486 error = a10fb_allocfb(sc);
487 if (error != 0) {
488 device_printf(sc->dev, "failed to allocate FB memory\n");
489 return (ENXIO);
490 }
491 }
492
493 /* Setup display backend */
494 error = a10fb_setup_debe(sc, mode);
495 if (error != 0)
496 return (error);
497
498 /* Setup display timing controller */
499 error = a10fb_setup_tcon(sc, mode);
500 if (error != 0)
501 return (error);
502
503 /* Attach framebuffer device */
504 sc->info.fb_name = device_get_nameunit(sc->dev);
505 sc->info.fb_vbase = (intptr_t)sc->vaddr;
506 sc->info.fb_pbase = sc->paddr;
507 sc->info.fb_size = sc->fbsize;
508 sc->info.fb_bpp = sc->info.fb_depth = FB_BPP;
509 sc->info.fb_stride = mode->hdisplay * (FB_BPP / NBBY);
510 sc->info.fb_width = mode->hdisplay;
511 sc->info.fb_height = mode->vdisplay;
512
513 sc->fbdev = device_add_child(sc->dev, "fbd", device_get_unit(sc->dev));
514 if (sc->fbdev == NULL) {
515 device_printf(sc->dev, "failed to add fbd child\n");
516 return (ENOENT);
517 }
518
519 error = device_probe_and_attach(sc->fbdev);
520 if (error != 0) {

Callers 1

a10fb_hdmi_eventFunction · 0.85

Calls 10

device_delete_childFunction · 0.85
a10fb_freefbFunction · 0.85
a10fb_allocfbFunction · 0.85
device_printfFunction · 0.85
a10fb_setup_debeFunction · 0.85
a10fb_setup_tconFunction · 0.85
device_get_nameunitFunction · 0.85
device_add_childFunction · 0.85
device_get_unitFunction · 0.85
device_probe_and_attachFunction · 0.85

Tested by

no test coverage detected