fb: Generalize framebuffer device initialization
This commit is contained in:
		| @@ -18,11 +18,14 @@ | ||||
|     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  */ | ||||
|  | ||||
| #include <types.h> | ||||
| #include <framebuffer.h> | ||||
| #include <init.h> | ||||
| #include <kmalloc.h> | ||||
| #include <print.h> | ||||
| #include <types.h> | ||||
|  | ||||
| #include <drivers/bcm2835_mailbox.h> | ||||
| #include <drivers/fb.h> | ||||
|  | ||||
| struct bcm2835_config { | ||||
| 	volatile uint32 width; | ||||
| @@ -43,7 +46,7 @@ struct bcm2835_config { | ||||
|  | ||||
| struct fbdev bcm2835_fb_device; | ||||
|  | ||||
| int bcm2835_videocore_init(struct fb *f, unsigned int color_depth) { | ||||
| int bcm2835_videocore_init_dev(struct fb *f, unsigned int color_depth) { | ||||
| 	struct bcm2835_config *cfg; | ||||
| 	uint32 result; | ||||
| 	void *mailbox_buffer_orig, *mailbox_buffer; | ||||
| @@ -108,3 +111,13 @@ int bcm2835_videocore_init(struct fb *f, unsigned int color_depth) { | ||||
|  | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| struct fb_dev videocore_dev = { | ||||
| 	.init = &bcm2835_videocore_init_dev | ||||
| }; | ||||
|  | ||||
| void bcm2835_videocore_init() { | ||||
| 	fb_register_device(&videocore_dev); | ||||
| } | ||||
|  | ||||
| device_initcall(bcm2835_videocore_init); | ||||
|   | ||||
							
								
								
									
										45
									
								
								drivers/fb.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								drivers/fb.c
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,45 @@ | ||||
| /* | ||||
|     Copyright (C) 2012, Aaron Lindsay <aaron@aclindsay.com> | ||||
|  | ||||
|     This file is part of Aedrix. | ||||
|  | ||||
|     This program is free software; you can redistribute it and/or modify | ||||
|     it under the terms of the GNU General Public License as published by | ||||
|     the Free Software Foundation; either version 2 of the License, or | ||||
|     (at your option) any later version. | ||||
|  | ||||
|     This program is distributed in the hope that it will be useful, | ||||
|     but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|     GNU General Public License for more details. | ||||
|  | ||||
|     You should have received a copy of the GNU General Public License along | ||||
|     with this program; if not, write to the Free Software Foundation, Inc., | ||||
|     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  */ | ||||
|  | ||||
| #include <init.h> | ||||
| #include <drivers/fb.h> | ||||
|  | ||||
| struct dlist_node fb_dev_list; | ||||
|  | ||||
| int fb_register_device(struct fb_dev *fbdev) { | ||||
| 	if (!fbdev) | ||||
| 		return -1; | ||||
|  | ||||
| 	insert_before(&fb_dev_list, &fbdev->list); | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| struct fb_dev *fb_first_device() { | ||||
| 	if (list_empty(&fb_dev_list)) | ||||
| 		return 0; | ||||
|  | ||||
| 	return container(fb_dev_list.next, struct fb_dev, list); | ||||
| } | ||||
|  | ||||
| void fb_init() { | ||||
| 	init_list(&fb_dev_list); | ||||
| } | ||||
|  | ||||
| driversubsys_initcall(fb_init); | ||||
| @@ -4,6 +4,7 @@ SUBDIRS := | ||||
| include $(BASEDIR)/header.mk | ||||
|  | ||||
| OBJS_$(d) := \ | ||||
| 	$(d)/fb.o \ | ||||
| 	$(d)/serial.o | ||||
|  | ||||
| OBJS_$(d)_$(CONFIG_VEXPRESS_A9) := \ | ||||
|   | ||||
| @@ -18,10 +18,13 @@ | ||||
|     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  */ | ||||
|  | ||||
| #include <types.h> | ||||
| #include <framebuffer.h> | ||||
| #include <mm.h> | ||||
| #include <init.h> | ||||
| #include <math.h> | ||||
| #include <mm.h> | ||||
| #include <types.h> | ||||
|  | ||||
| #include <drivers/fb.h> | ||||
|  | ||||
| #define PL111_CR_EN		0x001 | ||||
| #define PL111_CR_PWR		0x800 | ||||
| @@ -40,7 +43,7 @@ struct pl111_control { | ||||
|  | ||||
| struct fbdev pl111_fb_device; | ||||
|  | ||||
| int pl111_init(struct fb *f, unsigned int color_depth) { | ||||
| int pl111_init_dev(struct fb *f, unsigned int color_depth) { | ||||
| 	unsigned int width, height; | ||||
| 	unsigned int fb_size, power; | ||||
| 	struct pl111_control *plio = (struct pl111_control*)PL111_IOBASE; | ||||
| @@ -87,3 +90,13 @@ int pl111_init(struct fb *f, unsigned int color_depth) { | ||||
|  | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| struct fb_dev pl111_dev = { | ||||
| 	.init = &pl111_init_dev | ||||
| }; | ||||
|  | ||||
| void pl111_init() { | ||||
| 	fb_register_device(&pl111_dev); | ||||
| } | ||||
|  | ||||
| device_initcall(pl111_init); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user