Jump to content

[News] Risoluzione Nativa per GMA4500


Giorgio_multi
 Share

7 posts in this topic

Recommended Posts

E' uscito un file boot modificato per Chameleon 2.0 RC4 che consente di avere la risoulzione nativa su tale scheda (no QE/CI).

 

L'ho provata su un Emachines e525 e funziona perfettamente. Per un uso Home-Office pur non avendo l'accelerazione grafica è assolutamente fluente.

 

Avendo installato Chameleon 2.0 RC4 è sufficiente sostituirlo a quello originale.

 

esistono altri sistemi per ottenerla, ma sono decisamente più complessi.

 

Non posto il link perchè è da altro Forum.

Link to comment
Share on other sites

Thanks della news.

Giorgione, potresti linkarmi in pm? Mi servono i sorgenti, please;)

 

I hope this help

cham-rc4-915patch.diff

 

[size=1]diff -Naur Chameleon-2.0-RC4-r684-src/i386/boot2/boot.c Chameleon-2.0-RC4-r684-mrk/i386/boot2/boot.c
--- Chameleon-2.0-RC4-r684-src/i386/boot2/boot.c	2009-11-22 17:31:14.000000000 +0100
+++ Chameleon-2.0-RC4-r684-mrk/i386/boot2/boot.c	2010-01-27 00:30:29.000000000 +0100
@@ -57,6 +57,10 @@
#include "libsa.h"
#include "ramdisk.h"
#include "gui.h"
+#include "graphics.h"
+#include "vbe.h"
+#include "915resolution.h"
+#include "edid.h"

long gBootMode; /* defaults to 0 == kBootModeNormal */
BOOL gOverrideKernel;
@@ -355,6 +359,36 @@
	// Check if GUI=n switch is present in config file
    if ( getBoolForKey(kGUIKey, &useGUI, &bootInfo->bootConfig) && !useGUI )
      useGUI = FALSE;
+
+	// Before initGui, path the video bios with the correct resolution
+	
+	UInt32 x = 0, y = 0; 
+	UInt32 bp = 0;
+	
+	getResolution(&x, &y, &bp);
+	
+	
+	if (x!=0 && y!=0) {
+		vbios_map * map;
+
+		map = open_vbios(CT_UNKWN);
+
+		unlock_vbios(map);
+			
+		set_mode(map, x, y, bp, 0, 0);
+			
+		relock_vbios(map);
+			
+		close_vbios(map);
+
+		verbose("Patched first resolution mode to %dx%d.\n", x, y);
+
+			
+	}
+		
+	
+	//printf("Press any key to continue...");
+	//getc();

    // Try initialising the GUI unless disabled
    if( useGUI )
@@ -485,7 +519,7 @@
			if ((ret != 0) || ((flags & kFileTypeMask) != kFileTypeFlat))
				break;

-			if (!forceresume && sleeptime+3<bvr->modTime)
+			if (!forceresume && ((sleeptime+3) < bvr->modTime))
			{
				printf ("Hibernate image is too old by %d seconds. Use ForceWake=y to override\n",bvr->modTime-sleeptime);
				break;
diff -Naur Chameleon-2.0-RC4-r684-src/i386/boot2/graphics.c Chameleon-2.0-RC4-r684-mrk/i386/boot2/graphics.c
--- Chameleon-2.0-RC4-r684-src/i386/boot2/graphics.c	2009-11-22 17:31:14.000000000 +0100
+++ Chameleon-2.0-RC4-r684-mrk/i386/boot2/graphics.c	2010-01-27 14:45:47.000000000 +0100
@@ -182,7 +182,7 @@
// Return the VESA mode that matches the properties specified.
// If a mode is not found, then return the "best" available mode.

-static unsigned short
+unsigned short
getVESAModeWithProperties( unsigned short     width,
                           unsigned short     height,
                           unsigned char      bitsPerPixel,
diff -Naur Chameleon-2.0-RC4-r684-src/i386/boot2/graphics.h Chameleon-2.0-RC4-r684-mrk/i386/boot2/graphics.h
--- Chameleon-2.0-RC4-r684-src/i386/boot2/graphics.h	2009-11-22 17:31:14.000000000 +0100
+++ Chameleon-2.0-RC4-r684-mrk/i386/boot2/graphics.h	2010-01-27 00:34:28.000000000 +0100
@@ -10,6 +10,7 @@
#include "boot.h"
#include "bootstruct.h"
#include "graphic_utils.h"
+#include "vbe.h"


#ifndef __BOOT_GRAPHICS_H
@@ -44,4 +45,14 @@
char *getVBEModeInfoString();
void getGraphicModeParams(unsigned long params[]);

+
+unsigned short getVESAModeWithProperties( unsigned short     width,
+						  unsigned short     height,
+						  unsigned char      bitsPerPixel,
+						  unsigned short     attributesSet,
+						  unsigned short     attributesClear,
+						  VBEModeInfoBlock * outModeInfo,
+						  unsigned short *   vesaVersion );
+
+
#endif /* !__BOOT_GRAPHICS_H */
\ No newline at end of file
diff -Naur Chameleon-2.0-RC4-r684-src/i386/boot2/gui.c Chameleon-2.0-RC4-r684-mrk/i386/boot2/gui.c
--- Chameleon-2.0-RC4-r684-src/i386/boot2/gui.c	2009-11-22 17:31:14.000000000 +0100
+++ Chameleon-2.0-RC4-r684-mrk/i386/boot2/gui.c	2010-02-06 18:38:15.000000000 +0100
@@ -11,6 +11,7 @@
#include "gui.h"
#include "appleboot.h"
#include "vers.h"
+#include "edid.h"

#ifdef EMBED_THEME
#include "art.h"
@@ -494,9 +495,11 @@

int initGUI()
{
-	int val, len;
+	int len;
	char dirspec[256];

+	
+
#ifdef EMBED_THEME

	config_file_t *embedded = &bootInfo->themeDefault;
@@ -504,12 +507,11 @@
	// build xml dictionary for embedded theme.plist
	ParseXMLFile( (char *) __theme_plist, &embedded->dictionary);

-	// parse display size parameters
-	if(getIntForKey("screen_width", &val, &bootInfo->themeDefault))
-		screen_params[0] = val;
+	// determine screen params from edid
+	getResolution(&screen_params[0], &screen_params[1], &screen_params[2]);
+
+

-	if(getIntForKey("screen_height", &val, &bootInfo->themeDefault))
-		screen_params[1] = val;
#else

	/*
@@ -523,22 +525,12 @@
  // Initalizing GUI strucutre.
  bzero(&gui, sizeof(gui_t));

-	screen_params[2] = 32;
-	
	// find theme name in boot.plist
	getValueForKey( "Theme", &theme_name, &len, &bootInfo->bootConfig );

	sprintf(dirspec, "/Extra/Themes/%s/theme.plist", theme_name);

-	if ( !loadConfigFile(dirspec, &bootInfo->themeConfig) )
-	{		
-		// parse display size parameters
-		if(getIntForKey("screen_width", &val, &bootInfo->themeConfig))
-			screen_params[0] = val;
-
-		if(getIntForKey("screen_height", &val, &bootInfo->themeConfig))
-			screen_params[1] = val;
-	}
+	loadConfigFile(dirspec, &bootInfo->themeConfig);

	// find best matching vesa mode for our requested width & height
	getGraphicModeParams(screen_params);
@@ -1710,11 +1702,13 @@

void drawBootGraphics()
{
-	int pos;
	int length;
	const char *dummyVal;
	BOOL legacy_logo;
	uint16_t x, y; 
+
+	/** Read default resolution from the graphics card, instead of the theme **/
+	getResolution(&screen_params[0], &screen_params[1], &screen_params[2]);

	if (getBoolForKey("Legacy Logo", &legacy_logo, &bootInfo->bootConfig) && legacy_logo)
		usePngImage = NO; 
@@ -1722,19 +1716,6 @@
	else if (bootImageData == NULL)
		loadBootGraphics();

-	// parse screen size parameters
-	if(getIntForKey("boot_width", &pos, &bootInfo->themeConfig))
-		screen_params[0] = pos;
-	else
-		screen_params[0] = DEFAULT_SCREEN_WIDTH;
-	
-	if(getIntForKey("boot_height", &pos, &bootInfo->themeConfig))
-		screen_params[1] = pos;
-	else
-		screen_params[1] = DEFAULT_SCREEN_HEIGHT;
-	
-	screen_params[2] = 32;
-	
	gui.screen.width = screen_params[0];
	gui.screen.height = screen_params[1];

diff -Naur Chameleon-2.0-RC4-r684-src/i386/libsaio/915resolution.c Chameleon-2.0-RC4-r684-mrk/i386/libsaio/915resolution.c
--- Chameleon-2.0-RC4-r684-src/i386/libsaio/915resolution.c	1970-01-01 01:00:00.000000000 +0100
+++ Chameleon-2.0-RC4-r684-mrk/i386/libsaio/915resolution.c	2010-02-06 19:01:55.000000000 +0100
@@ -0,0 +1,549 @@
+/* Copied from 915 resolution created by steve tomljenovic
+ * This source code is into the public domain.
+ *
+ * Included to Chameleon RC3 by meklort
+ *
+ * Included to RC4 and edited by deviato to match more intel chipsets
+ *
+ */
+
+#include "libsaio.h"
+#include "915resolution.h"
+
+char * chipset_type_names[] = {
+	"UNKNOWN", "830",  "845G", "855GM", "865G", "915G", "915GM", "945G", "945GM", "945GME",
+	"946GZ",   "G965", "Q965", "965GM", "G41", "G31", "G45", "GM45", "500"
+};
+
+char * bios_type_names[] = {"UNKNOWN", "TYPE 1", "TYPE 2", "TYPE 3"};
+
+int freqs[] = { 60, 75, 85 };
+
+UInt32 get_chipset_id(void) {
+	outl(0xcf8, 0x80000000);
+	return inl(0xcfc);
+}
+
+chipset_type get_chipset(UInt32 id) {
+	chipset_type type;
+	
+	switch (id) {
+		case 0x35758086:
+			type = CT_830;
+			break;
+		
+		case 0x25608086:
+			type = CT_845G;
+			break;
+				
+		case 0x35808086:
+			type = CT_855GM;
+			break;
+				
+		case 0x25708086:
+			type = CT_865G;
+			break;
+		
+		case 0x25808086:
+			type = CT_915G;
+			break;
+			
+		case 0x25908086:
+			type = CT_915GM;
+			break;
+			
+		case 0x27708086:
+			type = CT_945G;
+			break;
+		
+		case 0x27a08086:
+			type = CT_945GM;
+			break;
+			
+		case 0x27ac8086:
+			type = CT_945GME;
+			break;
+			
+		case 0x29708086:
+			type = CT_946GZ;
+			break;
+			
+		case 0x29a08086:
+			type = CT_G965;
+			break;
+			
+		case 0x29908086:
+			type = CT_Q965;
+			break;
+			
+		case 0x2a008086:
+			type = CT_965GM;
+			break;
+			
+		case 0x2a408086:
+			type = CT_GM45;
+			break;
+
+		case 0x2e308086:
+			type = CT_G41;
+			break;
+
+		case 0x29c08086:
+			type = CT_G31;
+			break;
+
+		case 0x2e208086:
+			type = CT_G45;
+			break;
+
+		case 0x81008086:
+			type = CT_500;
+			break;
+			
+			
+		default:
+			type = CT_UNKWN;
+			break;
+	}
+	return type;
+}
+
+vbios_resolution_type1 * map_type1_resolution(vbios_map * map, UInt16 res) {
+	vbios_resolution_type1 * ptr = ((vbios_resolution_type1*)(map->bios_ptr + res)); 
+	return ptr;
+}
+
+vbios_resolution_type2 * map_type2_resolution(vbios_map * map, UInt16 res) {
+	vbios_resolution_type2 * ptr = ((vbios_resolution_type2*)(map->bios_ptr + res)); 
+	return ptr;
+}
+
+vbios_resolution_type3 * map_type3_resolution(vbios_map * map, UInt16 res) {
+	vbios_resolution_type3 * ptr = ((vbios_resolution_type3*)(map->bios_ptr + res)); 
+	return ptr;
+}
+
+char detect_bios_type(vbios_map * map, char modeline, int entry_size) {
+	UInt32 i;
+	UInt16 r1, r2;
+	    
+	r1 = r2 = 32000;
+	
+	for (i=0; i < map->mode_table_size; i++) {
+		if (map->mode_table[i].resolution <= r1) {
+			r1 = map->mode_table[i].resolution;
+		}
+		else {
+			if (map->mode_table[i].resolution <= r2) {
+				r2 = map->mode_table[i].resolution;
+			}
+		}
+		
+		/*printf("r1 = %d  r2 = %d\n", r1, r2);*/
+	}
+
+	return (r2-r1-6) % entry_size == 0;
+}
+
+void close_vbios(vbios_map * map);
+
+vbios_map * open_vbios(chipset_type forced_chipset) {
+	UInt32 z;
+	vbios_map * map = NEW(vbios_map);
+	for(z=0; z<sizeof(vbios_map); z++) ((char*)map)[z]=0;
+	
+	/*
+	 * Determine chipset
+	 */
+	
+	if (forced_chipset == CT_UNKWN) {
+		map->chipset_id = get_chipset_id();
+		map->chipset = get_chipset(map->chipset_id);
+	}
+	else if (forced_chipset != CT_UNKWN) {
+		map->chipset = forced_chipset;
+	}
+	else {
+		map->chipset = CT_915GM;
+	}
+	    
+	/*
+	 *  Map the video bios to memory
+	 */
+	
+	map->bios_ptr=(char*)VBIOS_START;
+	
+	/*
+	 * check if we have ATI Radeon
+	 */
+	    
+	/*
+	 * check if we have NVIDIA
+	 */
+	    
+	/*
+	 * check if we have Intel
+	 */
+	    
+	/*
+	 * check for others
+	 */
+	
+	if (map->chipset == CT_UNKWN) {
+		printf("Unknown chipset type and unrecognized bios.\n");
+		printf("915resolution only works with Intel 800/900 series graphic chipsets.\n");
+	
+		printf("Chipset Id: %x\n", map->chipset_id);
+		close_vbios(map);
+		return 0;
+	}
+
+	/*
+	 * Figure out where the mode table is 
+	 */
+	
+	{
+		char* p = map->bios_ptr + 16;
+		char* limit = map->bios_ptr + VBIOS_SIZE - (3 * sizeof(vbios_mode));
+			
+		while (p < limit && map->mode_table == 0) {
+			vbios_mode * mode_ptr = (vbios_mode *) p;
+			            
+			if (((mode_ptr[0].mode & 0xf0) == 0x30) && ((mode_ptr[1].mode & 0xf0) == 0x30) &&
+				((mode_ptr[2].mode & 0xf0) == 0x30) && ((mode_ptr[3].mode & 0xf0) == 0x30)) {
+			
+				map->mode_table = mode_ptr;
+			}
+			            
+			p++;
+		}
+		
+		if (map->mode_table == 0) {
+			printf("Unable to locate the mode table.\n");
+			printf("Please run the program 'dump_bios' as root and\n");
+			printf("email the file 'vbios.dmp' to stomljen@yahoo.com.\n");
+			printf("Chipset: %s\n", chipset_type_names[map->chipset]);
+			close_vbios(map);
+			return 0;
+		}
+	}
+	
+	/*
+	 * Determine size of mode table
+	 */
+	    
+	{
+		vbios_mode * mode_ptr = map->mode_table;
+			
+		while (mode_ptr->mode != 0xff) {
+			map->mode_table_size++;
+			mode_ptr++;
+		}
+	}
+	
+	/*
+	 * Figure out what type of bios we have
+	 *  order of detection is important
+	 */
+	
+	if (detect_bios_type(map, TRUE, sizeof(vbios_modeline_type3))) {
+		map->bios = BT_3;
+	}
+	else if (detect_bios_type(map, TRUE, sizeof(vbios_modeline_type2))) {
+		map->bios = BT_2;
+	}
+	else if (detect_bios_type(map, FALSE, sizeof(vbios_resolution_type1))) {
+		map->bios = BT_1;
+	}
+	else {
+		printf("Unable to determine bios type.\n");
+		printf("Please run the program 'dump_bios' as root and\n");
+		printf("email the file 'vbios.dmp' to stomljen@yahoo.com.\n");
+	
+		printf("Chipset: %s\n", chipset_type_names[map->chipset]);
+		printf("Mode Table Offset: $C0000 + $%x\n", ((UInt32)map->mode_table) - ((UInt32)map->bios_ptr));
+		printf("Mode Table Entries: %u\n", map->mode_table_size);
+		return 0;
+	}
+	
+	return map;
+}
+
+void close_vbios(vbios_map * map) {
+	FREE(map);
+}
+
+void unlock_vbios(vbios_map * map) {
+
+	map->unlocked = TRUE;
+	    
+	switch (map->chipset) {
+		case CT_UNKWN:
+			break;
+		case CT_830:
+		case CT_855GM:
+			outl(0xcf8, 0x8000005a);
+			map->b1 = inb(0xcfe);
+				
+			outl(0xcf8, 0x8000005a);
+			outb(0xcfe, 0x33);
+			break;
+		case CT_845G:
+		case CT_865G:
+		case CT_915G:
+		case CT_915GM:
+		case CT_945G:
+		case CT_945GM:
+		case CT_945GME:
+		case CT_946GZ:
+		case CT_G965:
+		case CT_Q965:
+		case CT_965GM:
+		case CT_GM45:
+		case CT_G41:
+		case CT_G31:
+		case CT_G45:
+		case CT_500:
+			outl(0xcf8, 0x80000090);
+			map->b1 = inb(0xcfd);
+			map->b2 = inb(0xcfe);
+			
+			outl(0xcf8, 0x80000090);
+			outb(0xcfd, 0x33);
+			outb(0xcfe, 0x33);
+		break;
+	}
+	
+	#if DEBUG
+	{
+		UInt32 t = inl(0xcfc);
+		printf("unlock PAM: (0x%08x)\n", t);
+	}
+#endif
+}
+
+void relock_vbios(vbios_map * map) {
+
+	map->unlocked = FALSE;
+	
+	switch (map->chipset) {
+		case CT_UNKWN:
+			break;
+		case CT_830:
+		case CT_855GM:
+			outl(0xcf8, 0x8000005a);
+			outb(0xcfe, map->b1);
+			break;
+		case CT_845G:
+		case CT_865G:
+		case CT_915G:
+		case CT_915GM:
+		case CT_945G:
+		case CT_945GM:
+		case CT_945GME:
+		case CT_946GZ:
+		case CT_G965:
+		case CT_Q965:
+		case CT_965GM:
+		case CT_GM45:
+		case CT_G41:
+		case CT_G31:
+		case CT_G45:
+		case CT_500:
+			outl(0xcf8, 0x8000005a);
+			outb(0xcfd, map->b1);
+			outb(0xcfe, map->b2);
+			break;
+	}
+	
+	#if DEBUG
+	{
+        UInt32 t = inl(0xcfc);
+		printf("relock PAM: (0x%08x)\n", t);
+	}
+	#endif
+}
+ 
+
+void list_modes(vbios_map *map, UInt32 raw) {
+    UInt32 i, x, y;
+	
+    for (i=0; i < map->mode_table_size; i++) {
+        switch(map->bios) {
+			case BT_1:
+            {
+                vbios_resolution_type1 * res = map_type1_resolution(map, map->mode_table[i].resolution);
+                
+                x = ((((UInt32) res->x2) & 0xf0) << 4) | res->x1;
+                y = ((((UInt32) res->y2) & 0xf0) << 4) | res->y1;
+                
+                if (x != 0 && y != 0) {
+                    printf("Mode %02x : %dx%d, %d bits/pixel\n", map->mode_table[i].mode, x, y, map->mode_table[i].bits_per_pixel);
+                }
+				
+				if (raw)
+				{
+                    printf("Mode %02x (raw) :\n\t%02x %02x\n\t%02x\n\t%02x\n\t%02x\n\t%02x\n\t%02x\n\t%02x\n", map->mode_table[i].mode, res->unknow1[0],res->unknow1[1], res->x1,res->x_total,res->x2,res->y1,res->y_total,res->y2);
+				}
+				
+            }
+				break;
+			case BT_2:
+            {
+                vbios_resolution_type2 * res = map_type2_resolution(map, map->mode_table[i].resolution);
+                
+                x = res->modelines[0].x1+1;
+                y = res->modelines[0].y1+1;
+				
+                if (x != 0 && y != 0) {
+                    printf("Mode %02x : %dx%d, %d bits/pixel\n", map->mode_table[i].mode, x, y, map->mode_table[i].bits_per_pixel);
+                }
+            }
+				break;
+			case BT_3:
+            {
+                vbios_resolution_type3 * res = map_type3_resolution(map, map->mode_table[i].resolution);
+                
+                x = res->modelines[0].x1+1;
+                y = res->modelines[0].y1+1;
+                
+                if (x != 0 && y != 0) {
+                    printf("Mode %02x : %dx%d, %d bits/pixel\n", map->mode_table[i].mode, x, y, map->mode_table[i].bits_per_pixel);
+                }
+            }
+				break;
+			case BT_UNKWN:
+				break;
+        }
+    }
+}
+
+static void gtf_timings(UInt32 x, UInt32 y, UInt32 freq,
+						unsigned long *clock,
+						UInt16 *hsyncstart, UInt16 *hsyncend, UInt16 *hblank,
+						UInt16 *vsyncstart, UInt16 *vsyncend, UInt16 *vblank)
+{
+	UInt32 hbl, vbl, vfreq;
+
+	vbl = y + (y+1)/(20000.0/(11*freq) - 1) + 1.5;
+	vfreq = vbl * freq;
+	hbl = 16 * (int)(x * (30.0 - 300000.0 / vfreq) /
+						  +            (70.0 + 300000.0 / vfreq) / 16.0 + 0.5);
+
+	*vsyncstart = y;
+	*vsyncend = y + 3;
+	*vblank = vbl - 1;
+	*hsyncstart = x + hbl / 2 - (x + hbl + 50) / 100 * 8 - 1;
+	*hsyncend = x + hbl / 2 - 1;
+	*hblank = x + hbl - 1;
+	*clock = (x + hbl) * vfreq / 1000;
+}
+
+void set_mode(vbios_map * map, /*UInt32 mode,*/ UInt32 x, UInt32 y, UInt32 bp, UInt32 htotal, UInt32 vtotal) {
+	UInt32 xprev, yprev;
+	UInt32 i = 0, j;	// patch first available mode
+
+//	for (i=0; i < map->mode_table_size; i++) {
+//		if (map->mode_table[0].mode == mode) {
+			switch(map->bios) {
+				case BT_1:
+					{
+						vbios_resolution_type1 * res = map_type1_resolution(map, map->mode_table[i].resolution);
+						
+						if (bp) {
+							map->mode_table[i].bits_per_pixel = bp;
+						}
+						
+						res->x2 = (htotal?(((htotal-x) >> 8) & 0x0f) : (res->x2 & 0x0f)) | ((x >> 4) & 0xf0);
+						res->x1 = (x & 0xff);
+						
+						res->y2 = (vtotal?(((vtotal-y) >> 8) & 0x0f) : (res->y2 & 0x0f)) | ((y >> 4) & 0xf0);
+						res->y1 = (y & 0xff);
+						if (htotal)
+							res->x_total = ((htotal-x) & 0xff);
+						
+						if (vtotal)
+							res->y_total = ((vtotal-y) & 0xff);
+					}
+					break;
+				case BT_2:
+					{
+						vbios_resolution_type2 * res = map_type2_resolution(map, map->mode_table[i].resolution);
+						
+						res->xchars = x / 8;
+						res->ychars = y / 16 - 1;
+						xprev = res->modelines[0].x1;
+						yprev = res->modelines[0].y1;
+						
+						for(j=0; j < 3; j++) {
+							vbios_modeline_type2 * modeline = &res->modelines[j];
+							
+							if (modeline->x1 == xprev && modeline->y1 == yprev) {
+								modeline->x1 = modeline->x2 = x-1;
+								modeline->y1 = modeline->y2 = y-1;
+				
+								gtf_timings(x, y, freqs[j], &modeline->clock,
+											&modeline->hsyncstart, &modeline->hsyncend,
+											&modeline->hblank, &modeline->vsyncstart,
+											&modeline->vsyncend, &modeline->vblank);
+								
+								if (htotal)
+									modeline->htotal = htotal;
+								else
+									modeline->htotal = modeline->hblank;
+								
+								if (vtotal)
+									modeline->vtotal = vtotal;
+								else
+									modeline->vtotal = modeline->vblank;
+							}
+						}
+					}
+					break;
+				case BT_3:
+					{
+						vbios_resolution_type3 * res = map_type3_resolution(map, map->mode_table[i].resolution);
+						
+						xprev = res->modelines[0].x1;
+						yprev = res->modelines[0].y1;
+				
+						for (j=0; j < 3; j++) {
+							vbios_modeline_type3 * modeline = &res->modelines[j];
+							                        
+							if (modeline->x1 == xprev && modeline->y1 == yprev) {
+								modeline->x1 = modeline->x2 = x-1;
+								modeline->y1 = modeline->y2 = y-1;
+								                            
+								gtf_timings(x, y, freqs[j], &modeline->clock,
+											&modeline->hsyncstart, &modeline->hsyncend,
+											&modeline->hblank, &modeline->vsyncstart,
+											&modeline->vsyncend, &modeline->vblank);
+								if (htotal)
+									modeline->htotal = htotal;
+								else
+									modeline->htotal = modeline->hblank;
+								if (vtotal)
+									modeline->vtotal = vtotal;
+								else
+									modeline->vtotal = modeline->vblank;
+						
+								modeline->timing_h   = y-1;
+								modeline->timing_v   = x-1;
+							}
+						}
+					}
+					break;
+				case BT_UNKWN:
+					break;
+			}
+//		}
+//	}
+}   
+
+void display_map_info(vbios_map * map) {
+	printf("Chipset: %s\n", chipset_type_names[map->chipset]);
+	printf("BIOS: %s\n", bios_type_names[map->bios]);
+	
+	printf("Mode Table Offset: $C0000 + $%x\n", ((UInt32)map->mode_table) - ((UInt32)map->bios_ptr));
+	printf("Mode Table Entries: %u\n", map->mode_table_size);
+}
diff -Naur Chameleon-2.0-RC4-r684-src/i386/libsaio/915resolution.h Chameleon-2.0-RC4-r684-mrk/i386/libsaio/915resolution.h
--- Chameleon-2.0-RC4-r684-src/i386/libsaio/915resolution.h	1970-01-01 01:00:00.000000000 +0100
+++ Chameleon-2.0-RC4-r684-mrk/i386/libsaio/915resolution.h	2010-02-06 18:47:58.000000000 +0100
@@ -0,0 +1,140 @@
+/* Copied from 915 resolution created by steve tomljenovic
+ * This source code is into the public domain.
+ *
+ * Included to Chameleon RC3 by meklort
+ *
+ * Included to RC4 and edited by deviato to match more intel chipsets
+ *
+ */
+
+#ifndef __915_RESOLUTION_H
+#define __915_RESOLUTION_H
+
+#define NEW(a) ((a *)(malloc(sizeof(a))))
+#define FREE(a) (free(a))
+
+#define VBIOS_START         0xc0000
+#define VBIOS_SIZE          0x10000
+
+#define FALSE 0
+#define TRUE 1
+
+#define MODE_TABLE_OFFSET_845G 617
+
+
+#define ATI_SIGNATURE1 "ATI MOBILITY RADEON"
+#define ATI_SIGNATURE2 "ATI Technologies Inc"
+#define NVIDIA_SIGNATURE "NVIDIA Corp"
+#define INTEL_SIGNATURE "Intel Corp"
+
+
+
+
+typedef enum {
+	CT_UNKWN, CT_830, CT_845G, CT_855GM, CT_865G, CT_915G, CT_915GM, CT_945G, CT_945GM, CT_945GME,
+	CT_946GZ, CT_G965, CT_Q965, CT_965GM, CT_GM45, CT_G41, CT_G31, CT_G45, CT_500
+} chipset_type;
+
+
+typedef enum {
+	BT_UNKWN, BT_1, BT_2, BT_3
+} bios_type;
+
+
+typedef struct {
+	UInt8 mode;
+	UInt8 bits_per_pixel;
+	UInt16 resolution;
+	UInt8 unknown;
+} __attribute__((packed)) vbios_mode;
+
+typedef struct {
+	UInt8 unknow1[2];
+	UInt8 x1;
+	UInt8 x_total;
+	UInt8 x2;
+	UInt8 y1;
+	UInt8 y_total;
+	UInt8 y2;
+} __attribute__((packed)) vbios_resolution_type1;
+
+typedef struct {
+	unsigned long clock;
+	
+	UInt16 x1;
+	UInt16 htotal;
+	UInt16 x2;
+	UInt16 hblank;
+	UInt16 hsyncstart;
+	UInt16 hsyncend;
+	UInt16 y1;
+    UInt16 vtotal;
+    UInt16 y2;
+	UInt16 vblank;
+	UInt16 vsyncstart;
+	UInt16 vsyncend;
+} __attribute__((packed)) vbios_modeline_type2;
+
+typedef struct {
+	UInt8 xchars;
+	UInt8 ychars;
+	UInt8 unknown[4];
+	
+	vbios_modeline_type2 modelines[];
+} __attribute__((packed)) vbios_resolution_type2;
+
+typedef struct {
+	unsigned long clock;
+	
+	UInt16 x1;
+	UInt16 htotal;
+	UInt16 x2;
+	UInt16 hblank;
+	UInt16 hsyncstart;
+	UInt16 hsyncend;
+	
+	UInt16 y1;
+	UInt16 vtotal;
+	UInt16 y2;
+	UInt16 vblank;
+	UInt16 vsyncstart;
+	UInt16 vsyncend;
+	
+	UInt16 timing_h;
+	UInt16 timing_v;
+	
+	UInt8 unknown[6];
+} __attribute__((packed)) vbios_modeline_type3;
+
+typedef struct {
+	unsigned char unknown[6];
+	
+    vbios_modeline_type3 modelines[];
+} __attribute__((packed)) vbios_resolution_type3;
+
+typedef struct {
+	UInt32 chipset_id;
+	chipset_type chipset;
+	bios_type bios;
+	
+	UInt32 bios_fd;
+	char* bios_ptr;
+	
+	vbios_mode * mode_table;
+	UInt32 mode_table_size;
+	UInt8 b1, b2;
+	
+	UInt8 unlocked;
+} vbios_map;
+
+
+
+void display_map_info(vbios_map*);
+vbios_map * open_vbios(chipset_type);
+void close_vbios (vbios_map*);
+void unlock_vbios(vbios_map*);
+void relock_vbios(vbios_map*);
+void set_mode(vbios_map*, UInt32, UInt32, UInt32, UInt32, UInt32);
+void list_modes(vbios_map *map, UInt32 raw);
+
+#endif
diff -Naur Chameleon-2.0-RC4-r684-src/i386/libsaio/Makefile Chameleon-2.0-RC4-r684-mrk/i386/libsaio/Makefile
--- Chameleon-2.0-RC4-r684-src/i386/libsaio/Makefile	2009-11-22 17:31:14.000000000 +0100
+++ Chameleon-2.0-RC4-r684-mrk/i386/libsaio/Makefile	2010-01-27 01:10:16.000000000 +0100
@@ -40,7 +40,7 @@
	freq_detect.o platform.o dsdt_patcher.o \
	smbios_patcher.o fake_efi.o ext2fs.o \
	hpet.o spd.o usb.o pci_setup.o \
-	device_inject.o nvidia.o ati.o
+	device_inject.o nvidia.o ati.o 915resolution.o edid.o


SAIO_EXTERN_OBJS = console.o
diff -Naur Chameleon-2.0-RC4-r684-src/i386/libsaio/edid.c Chameleon-2.0-RC4-r684-mrk/i386/libsaio/edid.c
--- Chameleon-2.0-RC4-r684-src/i386/libsaio/edid.c	1970-01-01 01:00:00.000000000 +0100
+++ Chameleon-2.0-RC4-r684-mrk/i386/libsaio/edid.c	2010-01-27 01:06:15.000000000 +0100
@@ -0,0 +1,138 @@
+/*
+ *  edid.c
+ *  
+ *
+ *  Created by Evan Lojewski on 12/1/09.
+ *  Copyright 2009. All rights reserved.
+ *
+ */
+
+
+#include "libsaio.h"
+#include "edid.h"
+#include "vbe.h"
+//#include "graphics.h"
+
+static biosBuf_t bb;
+
+UInt32 xResolution = 0;
+UInt32 yResolution = 0;
+UInt32 bpResolution = 0;
+
+void getResolution(UInt32* x, UInt32* y, UInt32* bp)
+{
+	if(!xResolution && !yResolution && !bpResolution)
+	{
+		
+		char* edidInfo = readEDID();
+		
+		if(!edidInfo) return;
+		
+		// TODO: check *all* resolutions reported and eithe ruse the highest, or the native resolution (if there is a flag for that)
+		xResolution =  edidInfo[56] | ((edidInfo[58] & 0xF0) << 4);
+		yResolution = edidInfo[59] | ((edidInfo[61] & 0xF0) << 4);
+		
+		
+		//printf("H Active = %d", edidInfo[56] | ((edidInfo[58] & 0xF0) << 4) );
+		//printf("V Active = %d", edidInfo[59] | ((edidInfo[61] & 0xF0) << 4) );
+		
+		
+		bpResolution = 32;	// assume 32bits
+		
+		
+		free( edidInfo );
+		
+		if(!xResolution) xResolution = 1024; //DEFAULT_SCREEN_WIDTH;
+		if(!yResolution) yResolution = 768; //DEFAULT_SCREEN_HEIGTH;
+
+	}
+
+	*x  = xResolution;
+	*y  = yResolution;
+	*bp = bpResolution;
+
+}
+
+char* readEDID()
+{
+	SInt16 last_reported = -1;
+	UInt8 edidInfo[EDID_BLOCK_SIZE];
+
+	UInt8 pointer;
+
+	UInt8 header1[] = {0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00};
+	UInt8 header2[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+	
+	int status;
+	unsigned int blocks_left = 1;
+	
+	do
+	{
+		// TODO: This currently only retrieves the *last* block, make the block buffer expand as needed / calculated from the first block
+
+		bzero( edidInfo, EDID_BLOCK_SIZE);
+
+		status = getEDID(edidInfo, blocks_left);
+		
+				//printf("Buffer location: 0x%X\n", SEG(buffer) << 16 | OFF(buffer));
+
+		/*
+		int j, i;
+		for (j = 0; j < 8; j++) {
+			for(i = 0; i < 16; i++) printf("0x%X ", ebiosInfo[((i+1) * (j + 1)) - 1]);
+
+		}
+		printf("\n");
+		*/
+		
+		if(status == 0)
+		{
+			//if( edidInfo[0] == 0x00 || edidInfo[0] == 0xFF)
+			if((memcmp(edidInfo, header1, sizeof(header1)) != 0) ||
+			   (memcmp(edidInfo, header2, sizeof(header2)) != 0) )
+			{
+				blocks_left--;
+				int reported = edidInfo[ EDID_V1_BLOCKS_TO_GO_OFFSET ];
+				
+				if ( reported > blocks_left )
+				{
+					
+					printf("EDID claims %d more blocks left\n", reported);
+				}
+				
+				if ( (last_reported <= reported && last_reported != -1)
+					|| reported == 0xff
+					/* 0xff frequently comes up in corrupt edids */
+					//|| reported == MAGIC
+					)
+				{
+					printf("Last reported %d\n", last_reported);
+					printf( "EDID blocks left is wrong.\n"
+						   "Your EDID is probably invalid.\n");
+					return 0;
+				}
+				else
+				{
+					//printf("Reading EDID block\n");
+					//printf("H Active = %d", ebiosInfo[56] | ((ebiosInfo[58] & 0xF0) << 4) );
+					//printf("V Active = %d", ebiosInfo[59] | ((ebiosInfo[61] & 0xF0) << 4) );
+
+					last_reported = reported;
+					blocks_left = reported;
+				}
+			} 
+			else
+			{
+				printf("Invalid block %d\n", blocks_left);
+				printf("Header1 = %d", memcmp(edidInfo, header1, sizeof(header1)) );
+				printf("Header2 = %d", memcmp(edidInfo, header2, sizeof(header2)) );
+				return 0;
+			}
+		}
+		blocks_left = 0;	
+	} while(blocks_left);
+
+	UInt8* ret = malloc(sizeof(edidInfo));
+	memcpy(ret, edidInfo, sizeof(edidInfo));
+	return ret;
+}
diff -Naur Chameleon-2.0-RC4-r684-src/i386/libsaio/edid.h Chameleon-2.0-RC4-r684-mrk/i386/libsaio/edid.h
--- Chameleon-2.0-RC4-r684-src/i386/libsaio/edid.h	1970-01-01 01:00:00.000000000 +0100
+++ Chameleon-2.0-RC4-r684-mrk/i386/libsaio/edid.h	2010-01-27 01:06:15.000000000 +0100
@@ -0,0 +1,22 @@
+/*
+ *  edid.h
+ *  
+ *
+ *  Created by Evan Lojewski on 12/1/09.
+ *  Copyright 2009. All rights reserved.
+ *
+ */
+
+
+#define EDID_BLOCK_SIZE	128
+#define EDID_V1_BLOCKS_TO_GO_OFFSET 126
+
+#define SERVICE_REPORT_DDC	0
+#define SERVICE_READ_EDID	1
+#define SERVICE_LAST		1  // Read VDIF has been removed from the spec.
+
+#define FUNC_GET_EDID		0x4F15
+
+
+char* readEDID();
+void getResolution(UInt32* x, UInt32* y, UInt32* bp);
\ No newline at end of file
diff -Naur Chameleon-2.0-RC4-r684-src/i386/libsaio/vbe.c Chameleon-2.0-RC4-r684-mrk/i386/libsaio/vbe.c
--- Chameleon-2.0-RC4-r684-src/i386/libsaio/vbe.c	2009-11-22 17:31:14.000000000 +0100
+++ Chameleon-2.0-RC4-r684-mrk/i386/libsaio/vbe.c	2010-01-27 01:15:47.000000000 +0100
@@ -74,6 +74,21 @@
    return(bb.eax.r.h);
}

+int getEDID( void * edidBlock, UInt8 block)
+{
+	bzero(&bb, sizeof(bb));
+    bb.intno  = 0x10;
+    bb.eax.rr = funcGetEDID;
+	bb.ebx.r.l= 0x01;
+	bb.edx.rr = block;
+
+    bb.es     = SEG( edidBlock );
+    bb.edi.rr = OFF( edidBlock );
+
+    bios( &bb );
+    return(bb.eax.r.h);
+}
+
int getVBEModeInfo( int mode, void * minfo_p )
{
    bb.intno  = 0x10;
diff -Naur Chameleon-2.0-RC4-r684-src/i386/libsaio/vbe.h Chameleon-2.0-RC4-r684-mrk/i386/libsaio/vbe.h
--- Chameleon-2.0-RC4-r684-src/i386/libsaio/vbe.h	2009-11-22 17:31:14.000000000 +0100
+++ Chameleon-2.0-RC4-r684-mrk/i386/libsaio/vbe.h	2010-02-06 17:25:19.000000000 +0100
@@ -68,7 +68,8 @@
    funcGetSetPaletteFormat  = 0x4F08,
    funcGetSetPaletteData    = 0x4F09,
    funcGetProtModeInterdace = 0x4F0A,
-    funcGetSetPixelClock     = 0x4F0B
+    funcGetSetPixelClock     = 0x4F0B,
+    funcGetEDID              = 0x4F15
};

enum {
diff -Naur Chameleon-2.0-RC4-r684-src/version Chameleon-2.0-RC4-r684-mrk/version
--- Chameleon-2.0-RC4-r684-src/version	2009-11-22 17:31:14.000000000 +0100
+++ Chameleon-2.0-RC4-r684-mrk/version	2010-02-01 23:32:28.000000000 +0100
@@ -1 +1 @@
-2.0-RC4
\ No newline at end of file
+2.0-RC4-mrk
\ No newline at end of file
[/size]

 

Fabio

Link to comment
Share on other sites

Grazie Fabio e perdona il ritardo.

Ehm.. cosi' com'e', e' impossibile da aggiungere all'rc5, non e' una semplice mod aggiunta. E' codice scritto espressamente per l'rc4, andrebbe riscritto. Ho chiesto ad uno dei developer etc.etc., ma ... non lo faranno mai :o

L'unica e' usare per chi ha necessita' il boot indicato da Giorgio.

 

-_-

Link to comment
Share on other sites

Grazie Fabio e perdona il ritardo.

Ehm.. cosi' com'e', e' impossibile da aggiungere all'rc5, non e' una semplice mod aggiunta. E' codice scritto espressamente per l'rc4, andrebbe riscritto. Ho chiesto ad uno dei developer etc.etc., ma ... non lo faranno mai :censored2:

L'unica e' usare per chi ha necessita' il boot indicato da Giorgio.

 

:angel:

 

premessa:

Nel nuovo bootloader di AnVAL se guardi bene la parte relativa alle "Intel" e' abbastanza corposa...(rev 180)

Hai chiesto a loro due?

Altrimenti Mozodojo in parallelo sta' ealizzando un boot con i fiocchi (rev 345)... e lo vedo una persona molto disponibile...

 

Fabio

Link to comment
Share on other sites

Ciao;) No, a loro 2 non ho chiesto, ne' lo faro'. Non ho quella scheda, ergo non e' una cosa che mi preme sul pancino. Se fosse stata una semplice mod, l'avrei aggiunta tanto per, e buonanotte ai sognatori. Proprio come con le ultime, tante, mod, comparse negli ultimi periodi nell'universo "conosciuto" :(

 

bye!

Link to comment
Share on other sites

  • 1 month later...
 Share

×
×
  • Create New...