コード例 #1
0
ファイル: s5pv210-fb.c プロジェクト: qioixiy/xboot
static __init void s5pv210_fb_init(void)
{
	struct s5pv210fb_lcd * lcd;

	s5pv210_fb.priv = resource_get_data(s5pv210_fb.info->name);
	lcd = (struct s5pv210fb_lcd *)(s5pv210_fb.priv);

	if(! s5pv210_fb.priv)
	{
		LOG_W("can't get the resource of \'%s\'", s5pv210_fb.info->name);
		return;
	}

	if(! clk_get_rate("dsys-hclk", 0))
	{
		LOG_E("can't get the clock of \'dsys-hclk\'");
		return;
	}

	if( (lcd->bits_per_pixel != 16) && (lcd->bits_per_pixel != 24) && (lcd->bits_per_pixel != 32) )
		return;

	info.surface.info.bits_per_pixel = lcd->bits_per_pixel;
	info.surface.info.bytes_per_pixel = lcd->bytes_per_pixel;
	info.surface.info.red_mask_size = lcd->rgba.r_mask;
	info.surface.info.red_field_pos = lcd->rgba.r_field;
	info.surface.info.green_mask_size = lcd->rgba.g_mask;
	info.surface.info.green_field_pos = lcd->rgba.g_field;
	info.surface.info.blue_mask_size = lcd->rgba.b_mask;
	info.surface.info.blue_field_pos = lcd->rgba.b_field;
	info.surface.info.alpha_mask_size = lcd->rgba.a_mask;
	info.surface.info.alpha_field_pos = lcd->rgba.a_field;
	info.surface.info.fmt = get_pixel_format(&(info.surface.info));

	info.surface.w = lcd->width;
	info.surface.h = lcd->height;
	info.surface.pitch = lcd->width * lcd->bytes_per_pixel;
	info.surface.flag = SURFACE_PIXELS_DONTFREE;
	info.surface.pixels = lcd->vram_front;

	info.surface.clip.x = 0;
	info.surface.clip.y = 0;
	info.surface.clip.w = lcd->width;
	info.surface.clip.h = lcd->height;

	memset(&info.surface.maps, 0, sizeof(struct surface_maps));
	surface_set_maps(&info.surface.maps);

	if(! register_framebuffer(&s5pv210_fb))
		LOG_E("failed to register framebuffer driver '%s'", s5pv210_fb.info->name);
}
コード例 #2
0
ファイル: fb.c プロジェクト: adeelmunir/x210_ics_rtm_v13
/*
 * register framebuffer driver.
 */
bool_t register_framebuffer(struct fb * fb)
{
	struct chrdev * dev;
	struct console * console;
	struct fb_console_info * info;
	struct color_t col;
	u8_t brightness;

	if(!fb || !fb->info || !fb->info->name)
		return FALSE;

	surface_set_maps(&fb->info->surface.maps);

	dev = malloc(sizeof(struct chrdev));
	if(!dev)
		return FALSE;

	dev->name		= fb->info->name;
	dev->type		= CHR_DEV_FRAMEBUFFER;
	dev->open 		= fb_open;
	dev->read 		= fb_read;
	dev->write 		= fb_write;
	dev->ioctl 		= fb_ioctl;
	dev->close		= fb_close;
	dev->driver 	= fb;

	if(!register_chrdev(dev))
	{
		free(dev);
		return FALSE;
	}

	if(search_chrdev_with_type(dev->name, CHR_DEV_FRAMEBUFFER) == NULL)
	{
		unregister_chrdev(dev->name);
		free(dev);
		return FALSE;
	}

	if(fb->init)
		(fb->init)(fb);

	display_logo(fb);

	if(fb->ioctl)
	{
		brightness = 0xff;
		(fb->ioctl)(fb, IOCTL_SET_FB_BACKLIGHT, &brightness);
	}

	if(default_framebuffer == NULL)
		default_framebuffer = fb;

	/*
	 * register a console
	 */
	console = malloc(sizeof(struct console));
	info = malloc(sizeof(struct fb_console_info));
	if(!console || !info)
	{
		unregister_chrdev(dev->name);
		free(dev);
		free(console);
		free(info);
		return FALSE;
	}

	info->name = (char *)fb->info->name;
	info->fb = fb;
	info->fw = 8;
	info->fh = 16;
	info->w = fb->info->surface.w / info->fw;
	info->h = fb->info->surface.h / info->fh;
	info->x = 0;
	info->y = 0;
	info->f = TCOLOR_WHITE;
	info->b = TCOLOR_BLACK;
	tcolor_to_color(info->f, &col);
	info->fc = fb_map_color(fb, &col);
	tcolor_to_color(info->b, &col);
	info->bc = fb_map_color(fb, &col);
	info->cursor = TRUE;
	info->onoff = TRUE;
	info->clen = info->w * info->h;
	info->cell = malloc(info->clen * sizeof(struct fbcon_cell));
	if(!info->cell)
	{
		unregister_chrdev(dev->name);
		free(dev);
		free(console);
		free(info);
		return FALSE;
	}
	memset(info->cell, 0, info->clen * sizeof(struct fbcon_cell));

	console->name = info->name;
	console->getwh = fbcon_getwh;
	console->getxy = fbcon_getxy;
	console->gotoxy = fbcon_gotoxy;
	console->setcursor = fbcon_setcursor;
	console->getcursor = fbcon_getcursor;
	console->setcolor = fbcon_setcolor;
	console->getcolor = fbcon_getcolor;
	console->cls = fbcon_cls;
	console->getcode = NULL;
	console->putcode = fbcon_putcode;
	console->onoff = fbcon_onoff;
	console->priv = info;

	if(!register_console(console))
	{
		unregister_chrdev(dev->name);
		free(dev);
		free(console);
		free(info->cell);
		free(info);
		return FALSE;
	}

	return TRUE;
}