Exemplo n.º 1
0
int omb_open_framebuffer()
{
	omb_fb_fd = open(OMB_FB_DEVICE, O_RDWR);
	if (omb_fb_fd == -1) {
		omb_log(LOG_ERROR, "cannot open framebuffer device");
		return OMB_ERROR;
	}
	omb_log(LOG_DEBUG, "the framebuffer device was opened successfully");
	
	if (omb_read_screen_info() == OMB_ERROR)
		return OMB_ERROR;
	
	if ((omb_var_screen_info.xres != OMB_SCREEN_WIDTH)
		|| (omb_var_screen_info.yres != OMB_SCREEN_HEIGHT)
		|| (omb_var_screen_info.bits_per_pixel != OMB_SCREEN_BPP)) {
			
		if (omb_set_screen_info(OMB_SCREEN_WIDTH, OMB_SCREEN_HEIGHT, OMB_SCREEN_BPP) == OMB_ERROR)
			return OMB_ERROR;
	
		if (omb_read_screen_info() == OMB_ERROR)
			return OMB_ERROR;
	}
	
	if (omb_map_framebuffer() == OMB_ERROR)
		return OMB_ERROR;
	
	if (omb_make_palette() == OMB_ERROR)
		return OMB_ERROR;
	
	if (omb_set_manual_blit() == OMB_ERROR)
		return OMB_ERROR;
	
	return OMB_SUCCESS;
}
Exemplo n.º 2
0
int omb_set_screen_info(int width, int height, int bpp)
{
	omb_var_screen_info.xres_virtual = omb_var_screen_info.xres = width;
	omb_var_screen_info.yres_virtual = omb_var_screen_info.yres = height;
	omb_var_screen_info.bits_per_pixel = bpp;
	omb_var_screen_info.xoffset = omb_var_screen_info.yoffset = 0;
	omb_var_screen_info.height = 0;
	omb_var_screen_info.width = 0;
	
	if (ioctl(omb_fb_fd, FBIOPUT_VSCREENINFO, &omb_var_screen_info) < 0) {
		omb_log(LOG_ERROR, "cannot set variable information");
		return OMB_ERROR;
	}
	
	if ((omb_var_screen_info.xres != width) && (omb_var_screen_info.yres != height) && (omb_var_screen_info.bits_per_pixel != bpp)) {
		omb_log(LOG_ERROR, "cannot set variable information: got %dx%dx%d instead of %dx%dx%d",
			omb_var_screen_info.xres, omb_var_screen_info.yres, omb_var_screen_info.bits_per_pixel, width, height, bpp);
		return OMB_ERROR;
	}
	
	if (ioctl(omb_fb_fd, FBIOGET_FSCREENINFO, &omb_fix_screen_info) == -1) {
		omb_log(LOG_ERROR, "cannot read fixed information");
		return OMB_ERROR;
	}
	
	return OMB_SUCCESS;
}
Exemplo n.º 3
0
int omb_make_palette()
{
	int r = 8, g = 8, b = 4, i;

	struct fb_cmap colormap;
	colormap.start=0;
	colormap.len=256;
	colormap.red=red;
	colormap.green = green;
	colormap.blue = blue;
	colormap.transp=trans;

	int rs = 256 / (r - 1);
	int gs = 256 / (g - 1);
	int bs = 256 / (b - 1);

	for (i = 0; i < 256; i++) {
		colormap.red[i]   = (rs * ((i / (g * b)) % r)) * 255;
		colormap.green[i] = (gs * ((i / b) % g)) * 255;
		colormap.blue[i]  = (bs * ((i) % b)) * 255;
	}

	omb_log(LOG_DEBUG, "set color palette");
	if (ioctl(omb_fb_fd, FBIOPUTCMAP, &colormap) == -1) {
		omb_log(LOG_ERROR, "failed to set color palette");
		//return OMB_ERROR;
		return OMB_SUCCESS; // NEED TO BE FIXED FOR VU+ BOXES !!
	}
	
	return OMB_SUCCESS;
}
Exemplo n.º 4
0
int omb_set_manual_blit()
{
	omb_log(LOG_DEBUG, "set manual blit");
	
	unsigned char tmp = 1;
	if (ioctl(omb_fb_fd, FBIO_SET_MANUAL_BLIT, &tmp)) {
		omb_log(LOG_ERROR, "failed to set manual blit");
		return OMB_ERROR;
	}
	
	return OMB_SUCCESS;
}
Exemplo n.º 5
0
int omb_map_framebuffer()
{
	omb_fb_map = (unsigned char *)mmap(0, omb_screen_size, PROT_READ | PROT_WRITE, MAP_SHARED, omb_fb_fd, 0);
	if (omb_fb_map == MAP_FAILED) {
		omb_log(LOG_ERROR, "failed to map framebuffer device to memory");
		return OMB_ERROR;
	}
	
	omb_log(LOG_DEBUG, "the framebuffer device was mapped to memory successfully");
	
	return OMB_SUCCESS;
}
Exemplo n.º 6
0
int omb_read_screen_info()
{
	if (ioctl(omb_fb_fd, FBIOGET_FSCREENINFO, &omb_fix_screen_info) == -1) {
		omb_log(LOG_ERROR, "cannot read fixed information");
		return OMB_ERROR;
	}

	if (ioctl(omb_fb_fd, FBIOGET_VSCREENINFO, &omb_var_screen_info) == -1) {
		omb_log(LOG_ERROR, "cannot read variable information");
		return OMB_ERROR;
	}

	omb_log(LOG_DEBUG, "current mode is %dx%d, %dbpp, stride %d",
		omb_var_screen_info.xres, omb_var_screen_info.yres, omb_var_screen_info.bits_per_pixel, omb_fix_screen_info.line_length);
	
	omb_screen_size = omb_fix_screen_info.smem_len;//omb_var_screen_info.xres * omb_var_screen_info.yres * omb_var_screen_info.bits_per_pixel / 8;
	
	return OMB_SUCCESS;
}
Exemplo n.º 7
0
int main(int argc, char *argv[]) 
{
	int is_rebooting = 0;
	if (argc > 1 && getppid() > 1) {
		omb_log(LOG_DEBUG, "argc > 1, before sysvinit");
		omb_utils_sysvinit(NULL, argv[1]);
		omb_log(LOG_DEBUG, "argc > 1, after sysvinit");
	}
	else {
		omb_utils_init_system();
		omb_device_item *item = NULL;
		omb_device_item *items = NULL;
		char *selected = NULL;
		char *nextboot = NULL;
		omb_log(LOG_DEBUG, "Before find_and_mount if");
		if (omb_utils_find_and_mount() == OMB_SUCCESS) {
			omb_log(LOG_DEBUG, "Inside find_and_mount if");
			items = omb_utils_get_images();
			omb_menu_set(items);
			selected = omb_utils_read(OMB_SETTINGS_SELECTED);
			if (!selected) {
				selected = malloc(6);
				strcpy(selected, "flash");
			}
			omb_menu_set_selected(selected);
			item = omb_menu_get_selected();
		}
		omb_log(LOG_DEBUG, "After find_and_mount if");

		omb_log(LOG_DEBUG, "Before load modules");
		omb_utils_load_modules(item);
		omb_log(LOG_DEBUG, "After load modules");

		int force = omb_utils_read_int(OMB_SETTINGS_FORCE);
		omb_log(LOG_DEBUG, "Before !force and items if");
		if (!force && items) {
			omb_log(LOG_DEBUG, "Inside !force and items if");

			omb_utils_update_background(item);
			omb_utils_backup_kernel(item);

			nextboot = omb_utils_read(OMB_SETTINGS_NEXTBOOT);
			if (nextboot) {
				omb_menu_set_selected(nextboot);
				omb_utils_remove_nextboot();
				item = omb_menu_get_selected();
				omb_utils_update_background(item);
				free(nextboot);
			}

			omb_show_menu();
		}
		else {
			omb_utils_save_int(OMB_SETTINGS_FORCE, 0);
		}
		omb_log(LOG_DEBUG, "After !force and items if");


		item = omb_menu_get_selected();
		omb_log(LOG_DEBUG, "Before selected if");
		if (item && selected && strcmp(selected, item->identifier) != 0) {
			omb_log(LOG_DEBUG, "Inside selected if");
			omb_utils_restore_kernel(item);
			omb_utils_save(OMB_SETTINGS_SELECTED, item->identifier);
			omb_utils_save_int(OMB_SETTINGS_FORCE, 1);
			omb_utils_umount(OMB_MAIN_DIR);
			omb_utils_reboot();
			is_rebooting = 1;
		}
		
		omb_log(LOG_DEBUG, "Before !is rebooting if");
		if (!is_rebooting) {
			omb_log(LOG_DEBUG, "Inside !is rebooting if");
			if (item != NULL && strcmp(item->identifier, "flash") != 0)
				omb_utils_remount_media(item);
			omb_utils_umount(OMB_MAIN_DIR);
			omb_utils_sysvinit(item, NULL);
		}

		omb_log(LOG_DEBUG, "Before frees");
		if (items) omb_utils_free_items(items);
		if (selected) free(selected);
	}

	omb_log(LOG_DEBUG, "Before end of main");
	return OMB_SUCCESS;
}
Exemplo n.º 8
0
void omb_blit()
{
	if (ioctl(omb_fb_fd, FBIO_BLIT) == -1)
		omb_log(LOG_WARNING, "cannot blit the framebuffer");
}