Пример #1
0
static adv_error vgaline_mode_generate_text(vgaline_video_mode* mode, const adv_crtc* crtc, unsigned flags)
{

	mode->is_text = 1;
	mode->crtc = *crtc;

	if (crtc->hde % 9 == 0 && crtc->hrs % 9 == 0 && crtc->hre % 9 == 0 && crtc->ht % 9 == 0) {
		mode->font_x = 9;
	} else if (crtc->hde % 8 == 0 && crtc->hrs % 2 == 0 && crtc->hre % 2 == 0 && crtc->ht % 2 == 0) {
		mode->font_x = 8;
	} else {
		error_nolog_set("Unsupported horizontal crtc values. Only multiple of 8 or 9 pixels are supported.\n");
		return -1;
	}

	if (video_mode_generate_check("vgaline", vgaline_flags(), 1, 1024, crtc, flags)!=0)
		return -1;

	mode->font_y = crtc->vde / 25;
	if (mode->font_y >= 16)
		mode->font_y = 16;
	else if (mode->font_y >= 14)
		mode->font_y = 14;
	else
		mode->font_y = 8;

	return 0;
}
Пример #2
0
/**
 * Check if a horizontal and vertical clocks are acceptable.
 * \param monitor Monitor clock specification.
 * \param hclock Horizontal clock.
 * \param vclock Vertical clock.
 */
adv_bool monitor_hvclock_check(const adv_monitor* monitor, double hclock, double vclock)
{
	unsigned i;

	for(i=0;i<monitor->mode_mac;++i)
		if (monitor_mode_hvclock_check(&monitor->mode_map[i], hclock, vclock))
			return 1;

	error_nolog_set("Horizontal/Vertical clocks of %.2f/%.2f Hz/kHz are out of range of your monitor", (double)hclock / 1E3, (double)vclock);
	return 0;
}
Пример #3
0
adv_error vgaline_mode_generate(vgaline_video_mode* mode, const adv_crtc* crtc, unsigned flags)
{
	unsigned pixelclock;

	assert(vgaline_is_active());

	if (crtc_is_fake(crtc)) {
		error_nolog_set("Not programmable modes are not supported.\n");
		return -1;
	}

	switch (flags & MODE_FLAGS_INDEX_MASK) {
	case MODE_FLAGS_INDEX_PALETTE8 :
		if (vgaline_mode_generate_graphics(mode, crtc, flags) != 0)
			return -1;
		break;
	case MODE_FLAGS_INDEX_TEXT :
		if (vgaline_mode_generate_text(mode, crtc, flags) != 0)
			return -1;
		break;
	default :
		return -1;
	}

	pixelclock = crtc->pixelclock;

	/* get the real pixelclock */
	pixelclock = vga_pixelclock_nearest_get(pixelclock, mode->is_text);

	if (vgaline_acceptable_pixelclock(crtc->pixelclock, pixelclock)!=0) {
		error_nolog_set("Pixel clock not supported. Nearest supported value is %d Hz.\n", pixelclock);
		return -1;
	}

	return 0;
}
Пример #4
0
adv_error mouseb_init(void)
{
	unsigned i;

	assert(mouseb_state.driver_current == 0);
	assert(!mouseb_state.is_active_flag);

	if (!mouseb_state.is_initialized_flag) {
		mouseb_default();
	}

	/* store the error prefix */
	error_nolog_set("Unable to initialize the mouse driver. The errors are:\n");

	for (i = 0; i < mouseb_state.driver_mac; ++i) {
		const adv_device* dev;

		dev = device_match(mouseb_state.name, (const adv_driver*)mouseb_state.driver_map[i], 1);

		error_cat_set(mouseb_state.driver_map[i]->name, 1);

		if (dev && mouseb_state.driver_map[i]->init(dev->id) == 0) {
			mouseb_state.driver_current = mouseb_state.driver_map[i];
			break;
		}
	}

	error_cat_set(0, 0);

	if (!mouseb_state.driver_current)
		return -1;

	error_reset();

	log_std(("mouseb: select driver %s\n", mouseb_state.driver_current->name));

	mouseb_state.is_active_flag = 1;
	mouseb_state.is_enabled_flag = 0;

	for (i = 0; i < mouseb_count_get(); ++i) {
		char name[DEVICE_NAME_MAX];
		if (mouseb_device_name_get(i, name) != 0)
			strcpy(name, DEVICE_NONAME);
		log_std(("mouseb: identifier %u '%s'\n", i, name));
	}

	return 0;
}
Пример #5
0
adv_error keyb_init(adv_bool disable_special)
{
	unsigned i;

	assert(keyb_state.driver_current == 0);
	assert(!keyb_state.is_active_flag);

	if (!keyb_state.is_initialized_flag) {
		keyb_default();
	}

	/* store the error prefix */
	error_nolog_set("Unable to initialize the keyboard driver. The errors are:\n");

	for (i = 0; i < keyb_state.driver_mac; ++i) {
		const adv_device* dev;

		dev = device_match(keyb_state.name, (const adv_driver*)keyb_state.driver_map[i], 0);

		error_cat_set(keyb_state.driver_map[i]->name, 1);

		if (dev && keyb_state.driver_map[i]->init(dev->id, disable_special) == 0) {
			keyb_state.driver_current = keyb_state.driver_map[i];
			break;
		}
	}

	error_cat_set(0, 0);

	if (!keyb_state.driver_current)
		return -1;

	error_reset();

	log_std(("keyb: select driver %s\n", keyb_state.driver_current->name));

	keyb_state.is_active_flag = 1;
	keyb_state.is_enabled_flag = 0;

	for (i = 0; i < keyb_count_get(); ++i) {
		char name[DEVICE_NAME_MAX];
		if (keyb_device_name_get(i, name) != 0)
			strcpy(name, DEVICE_NONAME);
		log_std(("keyb: identifier %u '%s'\n", i, name));
	}

	return 0;
}
Пример #6
0
static adv_error vgaline_mode_generate_graphics(vgaline_video_mode* mode, const adv_crtc* crtc, unsigned flags)
{
	if (video_mode_generate_check("vgaline", vgaline_flags(), 2, 1024, crtc, flags)!=0)
		return -1;

	if (crtc->hde * crtc->vde > 64 * 1024) {
		error_nolog_set("Mode to big for the VGA memory.\n");
		return -1;
	}

	mode->is_text = 0;
	mode->crtc = *crtc;
	mode->font_x = 0;
	mode->font_y = 0;

	return 0;
}
Пример #7
0
adv_error fb_mode_generate(fb_video_mode* mode, const adv_crtc* crtc, unsigned flags)
{
	assert(fb_is_active());

	if (crtc_is_fake(crtc)) {
		error_nolog_set("Not programmable modes are not supported.\n");
		return -1;
	}

	if (video_mode_generate_check("fb", fb_flags(), 8, 2048, crtc, flags)!=0)
		return -1;

	mode->crtc = *crtc;
	mode->index = flags & MODE_FLAGS_INDEX_MASK;

	return 0;
}
Пример #8
0
/**
 * Import information for one video mode.
 * \param mode Mode to write.
 * \param vbe_mode Mode to import.
 * \return 0 if successful
 */
adv_error vbe_mode_import(adv_mode* mode, const vbe_video_mode* vbe_mode)
{
	vbe_ModeInfoBlock info;

	snprintf(mode->name, MODE_NAME_MAX, "vbe_bios_%x", vbe_mode->mode);
	*DRIVER(mode) = *vbe_mode;

	if (vbe_mode_info_get(&info, DRIVER(mode)->mode) != 0) {
		error_set("VBE report that mode %d is unsupported", DRIVER(mode)->mode);
		return -1;
	}
	if ((info.ModeAttributes & vbeMdAvailable) == 0) {
		error_set("VBE report that mode %d is not avaliable", DRIVER(mode)->mode);
		return -1;
	}

	if ((info.ModeAttributes & vbeMdGraphMode) == 0) {
		error_nolog_set("Text modes are unsupported");
		return -1;
	} else {
		if ((DRIVER(mode)->mode & vbeLinearBuffer) != 0) {
			if (vbe_state.info.VESAVersion < 0x200) {
				error_nolog_set("Linear frame buffer not available on VBE version prior 2.0");
				return -1;
			}
			if ((info.ModeAttributes & vbeMdLinear) == 0) {
				error_nolog_set("Linear frame buffer not available in this mode");
				return -1;
			}
		} else {
			if ((info.ModeAttributes & vbeMdNonBanked) != 0) {
				error_nolog_set("Banked frame buffer not available in this mode");
				return -1;
			} else {
				error_nolog_set("Banked frame buffer isn't supported");
				return -1;
			}
		}
		/* Packed or RGB memory model */
		if (info.MemoryModel != vbeMemPK && info.MemoryModel != vbeMemRGB) {
			error_nolog_set("Unsupported memory model");
			return -1;
		}
		/* Non planar mode */
		if (info.NumberOfPlanes != 1) {
			error_nolog_set("Unsupported number of planes");
			return -1;
		}
	}

	mode->driver = &video_vbe_driver;
	mode->flags = MODE_FLAGS_RETRACE_WAIT_SYNC | MODE_FLAGS_RETRACE_SCROLL_SYNC
		| (mode->flags & MODE_FLAGS_USER_MASK);
	if ((info.ModeAttributes & vbeMdTripleBuffer) != 0)
		mode->flags |= MODE_FLAGS_RETRACE_SCROLL_ASYNC;
	switch (info.MemoryModel) {
	case vbeMemTXT:
		mode->flags |= MODE_FLAGS_INDEX_TEXT;
		break;
	case vbeMemPK:
		mode->flags |= MODE_FLAGS_INDEX_PALETTE8;
		break;
	case vbeMemRGB:
		switch (info.BitsPerPixel) {
		case 15: mode->flags |= MODE_FLAGS_INDEX_BGR15; break;
		case 16: mode->flags |= MODE_FLAGS_INDEX_BGR16; break;
		case 24: mode->flags |= MODE_FLAGS_INDEX_BGR24; break;
		case 32: mode->flags |= MODE_FLAGS_INDEX_BGR32; break;
		default:
			return -1;
		}
		break;
	default:
		return -1;
	}

	mode->size_x = info.XResolution;
	mode->size_y = info.YResolution;
	if (info.MemoryModel == vbeMemTXT) {
		mode->size_x *= info.XCharSize;
		mode->size_y *= info.YCharSize;
	}
	mode->vclock = 0;
	mode->hclock = 0;
	if (info.YResolution <= 300)
		mode->scan = 1; /* assume doublescan */
	else
		mode->scan = 0; /* assume singlescan */

	return 0;
}