diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index ee0e2c2d11..06669725cd 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -74,16 +74,6 @@ config GOLDFISH_FB_VIDEO_MODE GOLDFISH_FB_VIDEO_MODE = y enable video mode GOLDFISH_FB_VIDEO_MODE = n enable command mode -config GOLDFISH_FB_IRQ - int "Goldfish fb irq" - depends on GOLDFISH_FB - default 48 - -config GOLDFISH_FB_BASE - hex "Goldfish fb base" - depends on GOLDFISH_FB - default 0x0a020000 - config GOLDFISH_FB_FRAME_NBUFFER int "Goldfish fb vsync size" depends on GOLDFISH_FB diff --git a/drivers/video/goldfish_fb.c b/drivers/video/goldfish_fb.c index ce9d83749b..99d8378b29 100644 --- a/drivers/video/goldfish_fb.c +++ b/drivers/video/goldfish_fb.c @@ -223,10 +223,10 @@ static int goldfish_getplaneinfo(FAR struct fb_vtable_s *vtable, int planeno, ****************************************************************************/ /**************************************************************************** - * Name: up_fbinitialize + * Name: goldfish_fb_register ****************************************************************************/ -int up_fbinitialize(int display) +int goldfish_fb_register(int display, FAR void *regs, int irq) { FAR struct goldfish_fb_s *fb; uint32_t fmt; @@ -256,8 +256,8 @@ int up_fbinitialize(int display) return -ENOMEM; } - fb->base = (FAR void *)CONFIG_GOLDFISH_FB_BASE; - fb->irq = CONFIG_GOLDFISH_FB_IRQ; + fb->base = regs; + fb->irq = irq; fmt = getreg32(fb->base + GOLDFISH_FB_GET_FORMAT); @@ -300,38 +300,20 @@ int up_fbinitialize(int display) putreg32((uintptr_t)fb->planeinfo.fbmem, fb->base + GOLDFISH_FB_SET_BASE); + ret = fb_register_device(display, 0, (FAR struct fb_vtable_s *)fb); + if (ret < 0) + { + goto err_fb_register_failed; + } + g_goldfish_fb = fb; return OK; +err_fb_register_failed: + irq_detach(fb->irq); err_irq_attach_failed: kmm_free(fb->planeinfo.fbmem); err_fbmem_alloc_failed: kmm_free(fb); return ret; } - -/**************************************************************************** - * Name: up_fbgetvplane - ****************************************************************************/ - -FAR struct fb_vtable_s *up_fbgetvplane(int display, int vplane) -{ - return vplane || display ? NULL : &(g_goldfish_fb->vtable); -} - -/**************************************************************************** - * Name: up_fbuninitialize - ****************************************************************************/ - -void up_fbuninitialize(int display) -{ - if (display == 0) - { - FAR struct goldfish_fb_s *fb = g_goldfish_fb; - - irq_detach(fb->irq); - kmm_free(fb->planeinfo.fbmem); - kmm_free(fb); - g_goldfish_fb = NULL; - } -} diff --git a/include/nuttx/video/goldfish_fb.h b/include/nuttx/video/goldfish_fb.h new file mode 100644 index 0000000000..84f051e4f4 --- /dev/null +++ b/include/nuttx/video/goldfish_fb.h @@ -0,0 +1,63 @@ +/**************************************************************************** + * include/nuttx/video/goldfish_fb.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __INCLUDE_NUTTX_VIDEO_GOLDFISH_FB_H +#define __INCLUDE_NUTTX_VIDEO_GOLDFISH_FB_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#ifdef __cplusplus +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#ifdef CONFIG_GOLDFISH_FB +int goldfish_fb_register(int display, FAR void *regs, int irq); +#endif + +#undef EXTERN +#ifdef __cplusplus +} +#endif + +#endif /* __INCLUDE_NUTTX_VIDEO_GOLDFISH_FB_H */