more dependencies resolved

This commit is contained in:
Markus Fröschle
2013-12-29 08:58:58 +00:00
parent cc48a7be12
commit c4772fa216
11 changed files with 191 additions and 249 deletions

View File

@@ -83,6 +83,8 @@ SECTIONS
OBJDIR/videl.o OBJDIR/videl.o
OBJDIR/fbmem.o OBJDIR/fbmem.o
OBJDIR/biosemu.o
OBJDIR/radeon_base.o OBJDIR/radeon_base.o
OBJDIR/radeon_accel.o OBJDIR/radeon_accel.o
OBJDIR/radeon_cursor.o OBJDIR/radeon_cursor.o

View File

@@ -28,6 +28,7 @@
extern int strncmp(const char *s1, const char *s2, size_t max); extern int strncmp(const char *s1, const char *s2, size_t max);
extern char *strcpy(char *dst, const char *src); extern char *strcpy(char *dst, const char *src);
char *strncpy(char *dst, const char *src, size_t max); char *strncpy(char *dst, const char *src, size_t max);
extern int strcmp(const char *s1, const char *s2);
extern size_t strlen(const char *str); extern size_t strlen(const char *str);
extern char *strcat(char *dst, const char *src); extern char *strcat(char *dst, const char *src);
extern char *strncat(char *dst, const char *src, size_t max); extern char *strncat(char *dst, const char *src, size_t max);

View File

@@ -468,7 +468,7 @@ struct fb_info {
extern int fb_pan_display(struct fb_info *info, struct fb_var_screeninfo *var); extern int fb_pan_display(struct fb_info *info, struct fb_var_screeninfo *var);
extern int fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var); extern int fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var);
extern int fb_blank(struct fb_info *info, int blank); extern int fb_blank(struct fb_info *info, int blank);
extern int fb_ioctl(unsigned int cmd, unsigned long arg); extern int fb_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg);
extern struct fb_info *framebuffer_alloc(unsigned long size); extern struct fb_info *framebuffer_alloc(unsigned long size);
extern void framebuffer_release(struct fb_info *info); extern void framebuffer_release(struct fb_info *info);

View File

@@ -9,6 +9,7 @@
#include "i2c.h" #include "i2c.h"
#include "i2c-algo-bit.h" #include "i2c-algo-bit.h"
#include "util.h" /* for swpX() */ #include "util.h" /* for swpX() */
#include "wait.h"
//#include "radeon_theatre.h" //#include "radeon_theatre.h"
#include "radeon_reg.h" #include "radeon_reg.h"
@@ -470,7 +471,7 @@ struct radeonfb_info
*/ */
static inline void _radeon_msleep(struct radeonfb_info *rinfo, uint32_t ms) static inline void _radeon_msleep(struct radeonfb_info *rinfo, uint32_t ms)
{ {
mdelay(ms); wait_ms(ms);
} }
#define radeon_msleep(ms) _radeon_msleep(rinfo,ms) #define radeon_msleep(ms) _radeon_msleep(rinfo,ms)

View File

@@ -41,6 +41,7 @@ typedef bool (*checker_func)(void);
extern __inline__ void wait(uint32_t) __attribute__((always_inline)); extern __inline__ void wait(uint32_t) __attribute__((always_inline));
extern __inline__ bool waitfor(uint32_t us, checker_func condition) __attribute__((always_inline)); extern __inline__ bool waitfor(uint32_t us, checker_func condition) __attribute__((always_inline));
/* /*
* wait for the specified number of us on slice timer 0. Replaces the original routines that had * wait for the specified number of us on slice timer 0. Replaces the original routines that had
* the number of useconds to wait for hardcoded in their name. * the number of useconds to wait for hardcoded in their name.
@@ -52,6 +53,13 @@ extern __inline__ void wait(uint32_t us)
while (MCF_SLT_SCNT(0) - target > 0); while (MCF_SLT_SCNT(0) - target > 0);
} }
/*
* same as above, but with milliseconds wait time
*/
extern __inline__ void wait_ms(uint32_t ms)
{
wait(ms * 1000);
}
/* /*
* the same as above, with a checker function which gets called while * the same as above, with a checker function which gets called while
* busy waiting and allows for an early return if it returns true * busy waiting and allows for an early return if it returns true

View File

@@ -315,12 +315,13 @@ typedef struct {
extern "C" { /* Use "C" linkage when in C++ mode */ extern "C" { /* Use "C" linkage when in C++ mode */
#endif #endif
/* Global emulator machine state. /* Global emulator machine state.
* *
* We keep it global to avoid pointer dereferences in the code for speed. * We keep it global to avoid pointer dereferences in the code for speed.
*/ */
extern X86EMU_sysEnv _X86EMU_env;
extern X86EMU_sysEnv _X86EMU_env;
#define M _X86EMU_env #define M _X86EMU_env
#define X86_EAX M.x86.R_EAX #define X86_EAX M.x86.R_EAX

View File

@@ -57,6 +57,7 @@
#include "radeonfb.h" #include "radeonfb.h"
#include "edid.h" #include "edid.h"
#include "ati_ids.h" #include "ati_ids.h"
#include "driver_mem.h"
#include "bas_printf.h" #include "bas_printf.h"
#include "exceptions.h" /* for set_ipl() */ #include "exceptions.h" /* for set_ipl() */
@@ -68,8 +69,6 @@
#endif /* DBG_RADEON */ #endif /* DBG_RADEON */
extern void run_bios(struct radeonfb_info *rinfo); extern void run_bios(struct radeonfb_info *rinfo);
extern void mdelay(int32_t msec);
extern void udelay(int32_t usec);
#define MAX_MAPPED_VRAM (2048*2048*4) #define MAX_MAPPED_VRAM (2048*2048*4)
#define MIN_MAPPED_VRAM (1024*768*4) #define MIN_MAPPED_VRAM (1024*768*4)
@@ -1011,7 +1010,7 @@ int32_t radeon_screen_blank(struct radeonfb_info *rinfo, int32_t blank, int32_t
OUTPLLP(PIXCLKS_CNTL, 0, ~PIXCLK_LVDS_ALWAYS_ONb); OUTPLLP(PIXCLKS_CNTL, 0, ~PIXCLK_LVDS_ALWAYS_ONb);
val &= ~(LVDS_BL_MOD_EN); val &= ~(LVDS_BL_MOD_EN);
OUTREG(LVDS_GEN_CNTL, val); OUTREG(LVDS_GEN_CNTL, val);
udelay(100); wait(100);
val &= ~(LVDS_ON | LVDS_EN); val &= ~(LVDS_ON | LVDS_EN);
OUTREG(LVDS_GEN_CNTL, val); OUTREG(LVDS_GEN_CNTL, val);
val &= ~LVDS_DIGON; val &= ~LVDS_DIGON;
@@ -1525,7 +1524,7 @@ int radeonfb_set_par(struct fb_info *info)
int depth = var_to_depth(mode); int depth = var_to_depth(mode);
int use_rmx = 0; int use_rmx = 0;
newmode = (struct radeon_regs *)Funcs_malloc(sizeof(struct radeon_regs),3); newmode = (struct radeon_regs *) driver_mem_alloc(sizeof(struct radeon_regs));
if (!newmode) if (!newmode)
return -1; //-ENOMEM; return -1; //-ENOMEM;
/* We always want engine to be idle on a mode switch, even /* We always want engine to be idle on a mode switch, even
@@ -1774,7 +1773,7 @@ int radeonfb_set_par(struct fb_info *info)
/* Update fix */ /* Update fix */
info->fix.line_length = rinfo->pitch*64; info->fix.line_length = rinfo->pitch*64;
info->fix.visual = rinfo->depth == 8 ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_DIRECTCOLOR; info->fix.visual = rinfo->depth == 8 ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_DIRECTCOLOR;
Funcs_free(newmode); driver_mem_free(newmode);
return 0; return 0;
} }
@@ -2186,9 +2185,9 @@ void radeonfb_pci_unregister(void)
// radeonfb_pm_exit(rinfo); // radeonfb_pm_exit(rinfo);
uninstall_vbl_timer(radeon_timer_func); uninstall_vbl_timer(radeon_timer_func);
if (rinfo->mon1_EDID!=NULL) if (rinfo->mon1_EDID!=NULL)
Funcs_free(rinfo->mon1_EDID); driver_mem_free(rinfo->mon1_EDID);
if (rinfo->mon2_EDID!=NULL) if (rinfo->mon2_EDID!=NULL)
Funcs_free(rinfo->mon2_EDID); driver_mem_free(rinfo->mon2_EDID);
if (rinfo->mon1_modedb) if (rinfo->mon1_modedb)
fb_destroy_modedb(rinfo->mon1_modedb); fb_destroy_modedb(rinfo->mon1_modedb);
#ifdef CONFIG_FB_RADEON_I2C #ifdef CONFIG_FB_RADEON_I2C

View File

@@ -1,5 +1,8 @@
#include "radeonfb.h" #include "radeonfb.h"
#include "wait.h"
#include "edid.h" #include "edid.h"
#include "driver_mem.h"
#include "bas_string.h"
#define DBG_MONITOR #define DBG_MONITOR
#ifdef DBG_MONITOR #ifdef DBG_MONITOR
@@ -72,7 +75,7 @@ static int radeon_crt_is_connected(struct radeonfb_info *rinfo, int is_crt_dac)
/* the monitor either wasn't connected or it is a non-DDC CRT. /* the monitor either wasn't connected or it is a non-DDC CRT.
* try to probe it * try to probe it
*/ */
if(is_crt_dac) if (is_crt_dac)
{ {
unsigned long ulOrigVCLK_ECP_CNTL; unsigned long ulOrigVCLK_ECP_CNTL;
unsigned long ulOrigDAC_CNTL; unsigned long ulOrigDAC_CNTL;
@@ -93,7 +96,7 @@ static int radeon_crt_is_connected(struct radeonfb_info *rinfo, int is_crt_dac)
ulData = ulOrigDAC_EXT_CNTL; ulData = ulOrigDAC_EXT_CNTL;
ulData &= ~DAC_FORCE_DATA_MASK; ulData &= ~DAC_FORCE_DATA_MASK;
ulData |= (DAC_FORCE_BLANK_OFF_EN | DAC_FORCE_DATA_EN | DAC_FORCE_DATA_SEL_MASK); ulData |= (DAC_FORCE_BLANK_OFF_EN | DAC_FORCE_DATA_EN | DAC_FORCE_DATA_SEL_MASK);
if((rinfo->family == CHIP_FAMILY_RV250) || (rinfo->family == CHIP_FAMILY_RV280)) if ((rinfo->family == CHIP_FAMILY_RV250) || (rinfo->family == CHIP_FAMILY_RV280))
ulData |= (0x01b6 << DAC_FORCE_DATA_SHIFT); ulData |= (0x01b6 << DAC_FORCE_DATA_SHIFT);
else else
ulData |= (0x01ac << DAC_FORCE_DATA_SHIFT); ulData |= (0x01ac << DAC_FORCE_DATA_SHIFT);
@@ -104,7 +107,7 @@ static int radeon_crt_is_connected(struct radeonfb_info *rinfo, int is_crt_dac)
ulData &= ~(DAC_RANGE_CNTL_MASK | DAC_PDWN); ulData &= ~(DAC_RANGE_CNTL_MASK | DAC_PDWN);
ulData |= 0x2; ulData |= 0x2;
OUTREG(DAC_CNTL, ulData); OUTREG(DAC_CNTL, ulData);
mdelay(1); wait_ms(1);
ulData = INREG(DAC_CNTL); ulData = INREG(DAC_CNTL);
connected = (DAC_CMP_OUTPUT & ulData) ? 1 : 0; connected = (DAC_CMP_OUTPUT & ulData) ? 1 : 0;
ulData = ulOrigVCLK_ECP_CNTL; ulData = ulOrigVCLK_ECP_CNTL;
@@ -126,7 +129,7 @@ static int radeon_parse_monitor_layout(struct radeonfb_info *rinfo, const char *
char s1[5], s2[5]; char s1[5], s2[5];
int i = 0, second = 0; int i = 0, second = 0;
const char *s; const char *s;
if((monitor_layout == NULL) || (*monitor_layout == '\0')) if ((monitor_layout == NULL) || (*monitor_layout == '\0'))
return 0; return 0;
s = monitor_layout; s = monitor_layout;
do do
@@ -142,9 +145,9 @@ static int radeon_parse_monitor_layout(struct radeonfb_info *rinfo, const char *
case '\0': case '\0':
break; break;
default: default:
if(i >= 4) if (i >= 4)
break; break;
if(second) if (second)
s2[i] = *s; s2[i] = *s;
else else
s1[i] = *s; s1[i] = *s;
@@ -153,24 +156,24 @@ static int radeon_parse_monitor_layout(struct radeonfb_info *rinfo, const char *
} }
} }
while(*s++); while(*s++);
if(second) if (second)
s2[i] = '\0'; s2[i] = '\0';
else else
{ {
s1[i] = '\0'; s1[i] = '\0';
s2[0] = '\0'; s2[0] = '\0';
} }
if(Funcs_equal(s1, "CRT")) if (strcmp(s1, "CRT"))
rinfo->mon1_type = MT_CRT; rinfo->mon1_type = MT_CRT;
else if(Funcs_equal(s1, "TMDS")) else if (strcmp(s1, "TMDS"))
rinfo->mon1_type = MT_DFP; rinfo->mon1_type = MT_DFP;
else if(Funcs_equal(s1, "LVDS")) else if (strcmp(s1, "LVDS"))
rinfo->mon1_type = MT_LCD; rinfo->mon1_type = MT_LCD;
if(Funcs_equal(s2, "CRT")) if (strcmp(s2, "CRT"))
rinfo->mon2_type = MT_CRT; rinfo->mon2_type = MT_CRT;
else if(Funcs_equal(s2, "TMDS")) else if (strcmp(s2, "TMDS"))
rinfo->mon2_type = MT_DFP; rinfo->mon2_type = MT_DFP;
else if(Funcs_equal(s2, "LVDS")) else if (strcmp(s2, "LVDS"))
rinfo->mon2_type = MT_LCD; rinfo->mon2_type = MT_LCD;
return 1; return 1;
} }
@@ -186,7 +189,7 @@ void radeon_probe_screens(struct radeonfb_info *rinfo,
#ifdef CONFIG_FB_RADEON_I2C #ifdef CONFIG_FB_RADEON_I2C
int ddc_crt2_used = 0; int ddc_crt2_used = 0;
#endif #endif
if(radeon_parse_monitor_layout(rinfo, monitor_layout)) if (radeon_parse_monitor_layout(rinfo, monitor_layout))
{ {
/* /*
* If user specified a monitor_layout option, use it instead * If user specified a monitor_layout option, use it instead
@@ -196,22 +199,22 @@ void radeon_probe_screens(struct radeonfb_info *rinfo,
*/ */
#ifdef CONFIG_FB_RADEON_I2C #ifdef CONFIG_FB_RADEON_I2C
dbg("radeonfb: radeon_probe_screens: use monitor layout\r\n"); dbg("radeonfb: radeon_probe_screens: use monitor layout\r\n");
if(!ignore_edid) if (!ignore_edid)
{ {
if(rinfo->mon1_type != MT_NONE) if (rinfo->mon1_type != MT_NONE)
{ {
dbg("radeonfb: radeon_probe_screens: probe ddc_dvi on MON1\r\n"); dbg("radeonfb: radeon_probe_screens: probe ddc_dvi on MON1\r\n");
if(!radeon_probe_i2c_connector(rinfo, ddc_dvi, &rinfo->mon1_EDID)) if (!radeon_probe_i2c_connector(rinfo, ddc_dvi, &rinfo->mon1_EDID))
{ {
dbg("radeonfb: radeon_probe_screens: probe ddc_crt2 on MON1\r\n"); dbg("radeonfb: radeon_probe_screens: probe ddc_crt2 on MON1\r\n");
radeon_probe_i2c_connector(rinfo, ddc_crt2, &rinfo->mon1_EDID); radeon_probe_i2c_connector(rinfo, ddc_crt2, &rinfo->mon1_EDID);
ddc_crt2_used = 1; ddc_crt2_used = 1;
} }
} }
if(rinfo->mon2_type != MT_NONE) if (rinfo->mon2_type != MT_NONE)
{ {
dbg("radeonfb: radeon_probe_screens: probe ddc_vga on MON2\r\n"); dbg("radeonfb: radeon_probe_screens: probe ddc_vga on MON2\r\n");
if(!radeon_probe_i2c_connector(rinfo, ddc_vga, &rinfo->mon2_EDID) && !ddc_crt2_used) if (!radeon_probe_i2c_connector(rinfo, ddc_vga, &rinfo->mon2_EDID) && !ddc_crt2_used)
{ {
dbg("radeonfb: radeon_probe_screens: probe ddc_crt2 on MON2\r\n"); dbg("radeonfb: radeon_probe_screens: probe ddc_crt2 on MON2\r\n");
radeon_probe_i2c_connector(rinfo, ddc_crt2, &rinfo->mon2_EDID); radeon_probe_i2c_connector(rinfo, ddc_crt2, &rinfo->mon2_EDID);
@@ -219,9 +222,9 @@ void radeon_probe_screens(struct radeonfb_info *rinfo,
} }
} }
#endif /* CONFIG_FB_RADEON_I2C */ #endif /* CONFIG_FB_RADEON_I2C */
if(rinfo->mon1_type == MT_NONE) if (rinfo->mon1_type == MT_NONE)
{ {
if(rinfo->mon2_type != MT_NONE) if (rinfo->mon2_type != MT_NONE)
{ {
rinfo->mon1_type = rinfo->mon2_type; rinfo->mon1_type = rinfo->mon2_type;
rinfo->mon1_EDID = rinfo->mon2_EDID; rinfo->mon1_EDID = rinfo->mon2_EDID;
@@ -255,26 +258,26 @@ void radeon_probe_screens(struct radeonfb_info *rinfo,
/* /*
* Old single head cards * Old single head cards
*/ */
if(!rinfo->has_CRTC2) if (!rinfo->has_CRTC2)
{ {
#ifdef CONFIG_FB_RADEON_I2C #ifdef CONFIG_FB_RADEON_I2C
if(rinfo->mon1_type == MT_NONE) if (rinfo->mon1_type == MT_NONE)
{ {
dbg("radeonfb: radeon_probe_screens: probe ddc_dvi on MON1\r\n"); dbg("radeonfb: radeon_probe_screens: probe ddc_dvi on MON1\r\n");
rinfo->mon1_type = radeon_probe_i2c_connector(rinfo, ddc_dvi, &rinfo->mon1_EDID); rinfo->mon1_type = radeon_probe_i2c_connector(rinfo, ddc_dvi, &rinfo->mon1_EDID);
} }
if(rinfo->mon1_type == MT_NONE) if (rinfo->mon1_type == MT_NONE)
{ {
dbg("radeonfb: radeon_probe_screens: probe ddc_vga on MON1\r\n"); dbg("radeonfb: radeon_probe_screens: probe ddc_vga on MON1\r\n");
rinfo->mon1_type = radeon_probe_i2c_connector(rinfo, ddc_vga, &rinfo->mon1_EDID); rinfo->mon1_type = radeon_probe_i2c_connector(rinfo, ddc_vga, &rinfo->mon1_EDID);
} }
if(rinfo->mon1_type == MT_NONE) if (rinfo->mon1_type == MT_NONE)
{ {
dbg("radeonfb: radeon_probe_screens: probe ddc_crt2 on MON1\r\n"); dbg("radeonfb: radeon_probe_screens: probe ddc_crt2 on MON1\r\n");
rinfo->mon1_type = radeon_probe_i2c_connector(rinfo, ddc_crt2, &rinfo->mon1_EDID); rinfo->mon1_type = radeon_probe_i2c_connector(rinfo, ddc_crt2, &rinfo->mon1_EDID);
} }
#endif /* CONFIG_FB_RADEON_I2C */ #endif /* CONFIG_FB_RADEON_I2C */
if(rinfo->mon1_type == MT_NONE) if (rinfo->mon1_type == MT_NONE)
rinfo->mon1_type = MT_CRT; rinfo->mon1_type = MT_CRT;
goto bail; goto bail;
} }
@@ -282,52 +285,52 @@ void radeon_probe_screens(struct radeonfb_info *rinfo,
* Probe primary head (DVI or laptop internal panel) * Probe primary head (DVI or laptop internal panel)
*/ */
#ifdef CONFIG_FB_RADEON_I2C #ifdef CONFIG_FB_RADEON_I2C
if(rinfo->mon1_type == MT_NONE) if (rinfo->mon1_type == MT_NONE)
{ {
dbg("radeonfb: radeon_probe_screens: probe ddc_dvi on MON1\r\n"); dbg("radeonfb: radeon_probe_screens: probe ddc_dvi on MON1\r\n");
rinfo->mon1_type = radeon_probe_i2c_connector(rinfo, ddc_dvi, &rinfo->mon1_EDID); rinfo->mon1_type = radeon_probe_i2c_connector(rinfo, ddc_dvi, &rinfo->mon1_EDID);
} }
if(rinfo->mon1_type == MT_NONE) if (rinfo->mon1_type == MT_NONE)
{ {
dbg("radeonfb: radeon_probe_screens: probe ddc_crt2 on MON1\r\n"); dbg("radeonfb: radeon_probe_screens: probe ddc_crt2 on MON1\r\n");
rinfo->mon1_type = radeon_probe_i2c_connector(rinfo, ddc_crt2, &rinfo->mon1_EDID); rinfo->mon1_type = radeon_probe_i2c_connector(rinfo, ddc_crt2, &rinfo->mon1_EDID);
if(rinfo->mon1_type != MT_NONE) if (rinfo->mon1_type != MT_NONE)
ddc_crt2_used = 1; ddc_crt2_used = 1;
} }
#endif /* CONFIG_FB_RADEON_I2C */ #endif /* CONFIG_FB_RADEON_I2C */
if(rinfo->mon1_type == MT_NONE && rinfo->is_mobility if (rinfo->mon1_type == MT_NONE && rinfo->is_mobility
&& (INREG(LVDS_GEN_CNTL) & LVDS_ON)) && (INREG(LVDS_GEN_CNTL) & LVDS_ON))
{ {
rinfo->mon1_type = MT_LCD; rinfo->mon1_type = MT_LCD;
dbg("Non-DDC laptop panel detected\r\n"); dbg("Non-DDC laptop panel detected\r\n");
} }
if(rinfo->mon1_type == MT_NONE) if (rinfo->mon1_type == MT_NONE)
rinfo->mon1_type = radeon_crt_is_connected(rinfo, rinfo->reversed_DAC); rinfo->mon1_type = radeon_crt_is_connected(rinfo, rinfo->reversed_DAC);
/* /*
* Probe secondary head (mostly VGA, can be DVI) * Probe secondary head (mostly VGA, can be DVI)
*/ */
#ifdef CONFIG_FB_RADEON_I2C #ifdef CONFIG_FB_RADEON_I2C
if(rinfo->mon2_type == MT_NONE) if (rinfo->mon2_type == MT_NONE)
{ {
dbg("radeonfb: radeon_probe_screens: probe ddc_vga on MON2\r\n"); dbg("radeonfb: radeon_probe_screens: probe ddc_vga on MON2\r\n");
rinfo->mon2_type = radeon_probe_i2c_connector(rinfo, ddc_vga, &rinfo->mon2_EDID); rinfo->mon2_type = radeon_probe_i2c_connector(rinfo, ddc_vga, &rinfo->mon2_EDID);
} }
if(rinfo->mon2_type == MT_NONE && !ddc_crt2_used) if (rinfo->mon2_type == MT_NONE && !ddc_crt2_used)
{ {
dbg("radeonfb: radeon_probe_screens: probe ddc_crt2 on MON2\r\n"); dbg("radeonfb: radeon_probe_screens: probe ddc_crt2 on MON2\r\n");
rinfo->mon2_type = radeon_probe_i2c_connector(rinfo, ddc_crt2, &rinfo->mon2_EDID); rinfo->mon2_type = radeon_probe_i2c_connector(rinfo, ddc_crt2, &rinfo->mon2_EDID);
} }
#endif /* CONFIG_FB_RADEON_I2C */ #endif /* CONFIG_FB_RADEON_I2C */
if(rinfo->mon2_type == MT_NONE) if (rinfo->mon2_type == MT_NONE)
rinfo->mon2_type = radeon_crt_is_connected(rinfo, !rinfo->reversed_DAC); rinfo->mon2_type = radeon_crt_is_connected(rinfo, !rinfo->reversed_DAC);
/* /*
* If we only detected port 2, we swap them, if none detected, * If we only detected port 2, we swap them, if none detected,
* assume CRT (maybe fallback to old BIOS_SCRATCH stuff ? or look * assume CRT (maybe fallback to old BIOS_SCRATCH stuff ? or look
* at FP registers ?) * at FP registers ?)
*/ */
if(rinfo->mon1_type == MT_NONE) if (rinfo->mon1_type == MT_NONE)
{ {
if(rinfo->mon2_type != MT_NONE) if (rinfo->mon2_type != MT_NONE)
{ {
rinfo->mon1_type = rinfo->mon2_type; rinfo->mon1_type = rinfo->mon2_type;
rinfo->mon1_EDID = rinfo->mon2_EDID; rinfo->mon1_EDID = rinfo->mon2_EDID;
@@ -340,10 +343,10 @@ void radeon_probe_screens(struct radeonfb_info *rinfo,
/* /*
* Deal with reversed TMDS * Deal with reversed TMDS
*/ */
if(rinfo->reversed_TMDS) if (rinfo->reversed_TMDS)
{ {
/* Always keep internal TMDS as primary head */ /* Always keep internal TMDS as primary head */
if(rinfo->mon1_type == MT_DFP || rinfo->mon2_type == MT_DFP) if (rinfo->mon1_type == MT_DFP || rinfo->mon2_type == MT_DFP)
{ {
int tmp_type = rinfo->mon1_type; int tmp_type = rinfo->mon1_type;
unsigned char *tmp_EDID = rinfo->mon1_EDID; unsigned char *tmp_EDID = rinfo->mon1_EDID;
@@ -351,28 +354,28 @@ void radeon_probe_screens(struct radeonfb_info *rinfo,
rinfo->mon1_EDID = rinfo->mon2_EDID; rinfo->mon1_EDID = rinfo->mon2_EDID;
rinfo->mon2_type = tmp_type; rinfo->mon2_type = tmp_type;
rinfo->mon2_EDID = tmp_EDID; rinfo->mon2_EDID = tmp_EDID;
if(rinfo->mon1_type == MT_CRT || rinfo->mon2_type == MT_CRT) if (rinfo->mon1_type == MT_CRT || rinfo->mon2_type == MT_CRT)
rinfo->reversed_DAC ^= 1; rinfo->reversed_DAC ^= 1;
} }
} }
} }
if(ignore_edid) if (ignore_edid)
{ {
Funcs_free(rinfo->mon1_EDID); driver_mem_free(rinfo->mon1_EDID);
rinfo->mon1_EDID = NULL; rinfo->mon1_EDID = NULL;
Funcs_free(rinfo->mon2_EDID); driver_mem_free(rinfo->mon2_EDID);
rinfo->mon2_EDID = NULL; rinfo->mon2_EDID = NULL;
} }
bail: bail:
dbg("radeonfb: Monitor 1 type %s found\r\n", radeon_get_mon_name(rinfo->mon1_type)); dbg("radeonfb: Monitor 1 type %s found\r\n", radeon_get_mon_name(rinfo->mon1_type));
if(rinfo->mon1_EDID) if (rinfo->mon1_EDID)
{ {
dbg("radeonfb: EDID probed\r\n"); dbg("radeonfb: EDID probed\r\n");
} }
if(!rinfo->has_CRTC2) if (!rinfo->has_CRTC2)
return; return;
dbg("radeonfb: Monitor 2 type %s\r\n", radeon_get_mon_name(rinfo->mon2_type)); dbg("radeonfb: Monitor 2 type %s\r\n", radeon_get_mon_name(rinfo->mon2_type));
if(rinfo->mon2_EDID) if (rinfo->mon2_EDID)
{ {
dbg("radeonfb: EDID probed\r\n"); dbg("radeonfb: EDID probed\r\n");
} }
@@ -443,14 +446,14 @@ void radeon_check_modes(struct radeonfb_info *rinfo, struct mode_option *resolut
* we only deal with first entry returned by parse_EDID, we may do better * we only deal with first entry returned by parse_EDID, we may do better
* some day... * some day...
*/ */
if(!rinfo->panel_info.use_bios_dividers if (!rinfo->panel_info.use_bios_dividers
&& rinfo->mon1_type != MT_CRT && rinfo->mon1_EDID) && rinfo->mon1_type != MT_CRT && rinfo->mon1_EDID)
{ {
struct fb_var_screeninfo var; struct fb_var_screeninfo var;
dbg("radeonfb: radeon_check_modes: fb_parse_edid\r\n"); dbg("radeonfb: radeon_check_modes: fb_parse_edid\r\n");
if(fb_parse_edid(rinfo->mon1_EDID, &var) == 0) if (fb_parse_edid(rinfo->mon1_EDID, &var) == 0)
{ {
if((var.xres >= rinfo->panel_info.xres) && (var.yres >= rinfo->panel_info.yres)) if ((var.xres >= rinfo->panel_info.xres) && (var.yres >= rinfo->panel_info.yres))
radeon_var_to_panel_info(rinfo, &var); radeon_var_to_panel_info(rinfo, &var);
} }
else else
@@ -462,7 +465,7 @@ void radeon_check_modes(struct radeonfb_info *rinfo, struct mode_option *resolut
* If we have some valid panel infos, we setup the default mode based on * If we have some valid panel infos, we setup the default mode based on
* those * those
*/ */
if(rinfo->mon1_type != MT_CRT && rinfo->panel_info.valid) if (rinfo->mon1_type != MT_CRT && rinfo->panel_info.valid)
{ {
struct fb_var_screeninfo *var = &info->var; struct fb_var_screeninfo *var = &info->var;
dbg("radeonfb: radeon_check_modes: setup the default mode based on panel info\r\n"); dbg("radeonfb: radeon_check_modes: setup the default mode based on panel info\r\n");
@@ -480,9 +483,9 @@ void radeon_check_modes(struct radeonfb_info *rinfo, struct mode_option *resolut
var->hsync_len = rinfo->panel_info.hSync_width; var->hsync_len = rinfo->panel_info.hSync_width;
var->vsync_len = rinfo->panel_info.vSync_width; var->vsync_len = rinfo->panel_info.vSync_width;
var->sync = 0; var->sync = 0;
if(rinfo->panel_info.hAct_high) if (rinfo->panel_info.hAct_high)
var->sync |= FB_SYNC_HOR_HIGH_ACT; var->sync |= FB_SYNC_HOR_HIGH_ACT;
if(rinfo->panel_info.vAct_high) if (rinfo->panel_info.vAct_high)
var->sync |= FB_SYNC_VERT_HIGH_ACT; var->sync |= FB_SYNC_VERT_HIGH_ACT;
var->vmode = 0; var->vmode = 0;
has_default_mode = 1; has_default_mode = 1;
@@ -490,7 +493,7 @@ void radeon_check_modes(struct radeonfb_info *rinfo, struct mode_option *resolut
/* /*
* Now build modedb from EDID * Now build modedb from EDID
*/ */
if(rinfo->mon1_EDID) if (rinfo->mon1_EDID)
{ {
fb_edid_to_monspecs(rinfo->mon1_EDID, &info->monspecs); fb_edid_to_monspecs(rinfo->mon1_EDID, &info->monspecs);
rinfo->mon1_modedb = info->monspecs.modedb; rinfo->mon1_modedb = info->monspecs.modedb;
@@ -501,18 +504,18 @@ void radeon_check_modes(struct radeonfb_info *rinfo, struct mode_option *resolut
* we try to read it from card), we try to pick a default mode * we try to read it from card), we try to pick a default mode
* and create some panel infos. Whatever... * and create some panel infos. Whatever...
*/ */
if(rinfo->mon1_type != MT_CRT && !rinfo->panel_info.valid) if (rinfo->mon1_type != MT_CRT && !rinfo->panel_info.valid)
{ {
struct fb_videomode *modedb; struct fb_videomode *modedb;
int dbsize; int dbsize;
if(rinfo->panel_info.xres == 0 || rinfo->panel_info.yres == 0) if (rinfo->panel_info.xres == 0 || rinfo->panel_info.yres == 0)
{ {
unsigned long tmp = INREG(FP_HORZ_STRETCH) & HORZ_PANEL_SIZE; unsigned long tmp = INREG(FP_HORZ_STRETCH) & HORZ_PANEL_SIZE;
rinfo->panel_info.xres = ((tmp >> HORZ_PANEL_SHIFT) + 1) * 8; rinfo->panel_info.xres = ((tmp >> HORZ_PANEL_SHIFT) + 1) * 8;
tmp = INREG(FP_VERT_STRETCH) & VERT_PANEL_SIZE; tmp = INREG(FP_VERT_STRETCH) & VERT_PANEL_SIZE;
rinfo->panel_info.yres = (tmp >> VERT_PANEL_SHIFT) + 1; rinfo->panel_info.yres = (tmp >> VERT_PANEL_SHIFT) + 1;
} }
if((rinfo->panel_info.xres <= 8) || (rinfo->panel_info.yres <= 1)) if ((rinfo->panel_info.xres <= 8) || (rinfo->panel_info.yres <= 1))
{ {
rinfo->mon1_type = MT_CRT; rinfo->mon1_type = MT_CRT;
goto pickup_default; goto pickup_default;
@@ -523,7 +526,7 @@ void radeon_check_modes(struct radeonfb_info *rinfo, struct mode_option *resolut
xres_yres.width = rinfo->panel_info.xres; xres_yres.width = rinfo->panel_info.xres;
xres_yres.height = rinfo->panel_info.yres; xres_yres.height = rinfo->panel_info.yres;
xres_yres.bpp = xres_yres.freq = 0; xres_yres.bpp = xres_yres.freq = 0;
if(fb_find_mode(&info->var, info, &xres_yres, modedb, dbsize, NULL, (resolution->bpp >= 8) ? (unsigned int)resolution->bpp : 8) == 0) if (fb_find_mode(&info->var, info, &xres_yres, modedb, dbsize, NULL, (resolution->bpp >= 8) ? (unsigned int)resolution->bpp : 8) == 0)
{ {
rinfo->mon1_type = MT_CRT; rinfo->mon1_type = MT_CRT;
goto pickup_default; goto pickup_default;
@@ -535,26 +538,26 @@ pickup_default:
/* /*
* Apply passed-in mode option if any * Apply passed-in mode option if any
*/ */
if(resolution->used) if (resolution->used)
{ {
if(fb_find_mode(&info->var, info, resolution, info->monspecs.modedb, if (fb_find_mode(&info->var, info, resolution, info->monspecs.modedb,
info->monspecs.modedb_len, NULL, (resolution->bpp >= 8) ? (unsigned int)resolution->bpp : 8) != 0) info->monspecs.modedb_len, NULL, (resolution->bpp >= 8) ? (unsigned int)resolution->bpp : 8) != 0)
has_default_mode = 1; has_default_mode = 1;
} }
/* /*
* Still no mode, let's pick up a default from the db * Still no mode, let's pick up a default from the db
*/ */
if(!has_default_mode && info->monspecs.modedb != NULL) if (!has_default_mode && info->monspecs.modedb != NULL)
{ {
struct fb_monspecs *specs = &info->monspecs; struct fb_monspecs *specs = &info->monspecs;
struct fb_videomode *modedb = NULL; struct fb_videomode *modedb = NULL;
/* get preferred timing */ /* get preferred timing */
if(specs->misc & FB_MISC_1ST_DETAIL) if (specs->misc & FB_MISC_1ST_DETAIL)
{ {
int i; int i;
for(i = 0; i < specs->modedb_len; i++) for(i = 0; i < specs->modedb_len; i++)
{ {
if(specs->modedb[i].flag & FB_MODE_IS_FIRST) if (specs->modedb[i].flag & FB_MODE_IS_FIRST)
{ {
modedb = &specs->modedb[i]; modedb = &specs->modedb[i];
break; break;
@@ -566,7 +569,7 @@ pickup_default:
/* otherwise, get first mode in database */ /* otherwise, get first mode in database */
modedb = &specs->modedb[0]; modedb = &specs->modedb[0];
} }
if(modedb != NULL) if (modedb != NULL)
{ {
info->var.bits_per_pixel = 8; info->var.bits_per_pixel = 8;
radeon_videomode_to_var(&info->var, modedb); radeon_videomode_to_var(&info->var, modedb);
@@ -614,7 +617,7 @@ int radeon_match_mode(struct radeonfb_info *rinfo,
/* Start with a copy of the requested mode */ /* Start with a copy of the requested mode */
memcpy(dest, src, sizeof(struct fb_var_screeninfo)); memcpy(dest, src, sizeof(struct fb_var_screeninfo));
/* Check if we have a modedb built from EDID */ /* Check if we have a modedb built from EDID */
if(rinfo->mon1_modedb) if (rinfo->mon1_modedb)
{ {
db = rinfo->mon1_modedb; db = rinfo->mon1_modedb;
dbsize = rinfo->mon1_dbsize; dbsize = rinfo->mon1_dbsize;
@@ -626,7 +629,7 @@ int radeon_match_mode(struct radeonfb_info *rinfo,
* FB_ACTIVATE_NOW, just do basic checking and return if the * FB_ACTIVATE_NOW, just do basic checking and return if the
* mode match * mode match
*/ */
if((src->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_TEST if ((src->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_TEST
|| (src->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW) || (src->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW)
{ {
/* We don't have an RMX, validate timings. If we don't have /* We don't have an RMX, validate timings. If we don't have
@@ -634,9 +637,9 @@ int radeon_match_mode(struct radeonfb_info *rinfo,
* 640x480-60, but I assume userland knows what it's doing here * 640x480-60, but I assume userland knows what it's doing here
* (though I may be proven wrong...) * (though I may be proven wrong...)
*/ */
if((has_rmx == 0) && rinfo->mon1_modedb) if ((has_rmx == 0) && rinfo->mon1_modedb)
{ {
if(fb_validate_mode((struct fb_var_screeninfo *)src, rinfo->info)) if (fb_validate_mode((struct fb_var_screeninfo *)src, rinfo->info))
return -1; //-EINVAL; return -1; //-EINVAL;
} }
return 0; return 0;
@@ -648,13 +651,13 @@ int radeon_match_mode(struct radeonfb_info *rinfo,
for(i = 0; i < dbsize; i++) for(i = 0; i < dbsize; i++)
{ {
int d; int d;
if((db[i].yres < src->yres) || (db[i].xres < src->xres)) if ((db[i].yres < src->yres) || (db[i].xres < src->xres))
continue; continue;
d = radeon_compare_modes(src, &db[i]); d = radeon_compare_modes(src, &db[i]);
/* If the new mode is at least as good as the previous one, /* If the new mode is at least as good as the previous one,
* then it's our new candidate * then it's our new candidate
*/ */
if(d < distance) if (d < distance)
{ {
candidate = &db[i]; candidate = &db[i];
distance = d; distance = d;
@@ -662,7 +665,7 @@ int radeon_match_mode(struct radeonfb_info *rinfo,
} }
db = NULL; db = NULL;
/* If we have a scaler, we allow any mode from the database */ /* If we have a scaler, we allow any mode from the database */
if(native_db && has_rmx) if (native_db && has_rmx)
{ {
db = vesa_modes; db = vesa_modes;
dbsize = 34; dbsize = 34;
@@ -670,13 +673,13 @@ int radeon_match_mode(struct radeonfb_info *rinfo,
} }
} }
/* If we have found a match, return it */ /* If we have found a match, return it */
if(candidate != NULL) if (candidate != NULL)
{ {
radeon_videomode_to_var(dest, candidate); radeon_videomode_to_var(dest, candidate);
return 0; return 0;
} }
/* If we haven't and don't have a scaler, fail */ /* If we haven't and don't have a scaler, fail */
if(!has_rmx) if (!has_rmx)
return -1; //-EINVAL; return -1; //-EINVAL;
return 0; return 0;
} }

View File

@@ -68,6 +68,19 @@ int memcmp(const char *s1, const char *s2, size_t max)
return cmp; return cmp;
} }
int strcmp(const char *s1, const char *s2)
{
int i;
int cmp;
for (i = 0; *s1++ && *s2++; i++)
{
cmp * (*s1 - *s2);
if (cmp != 0) return cmp;
}
return cmp;
}
int strncmp(const char *s1, const char *s2, size_t max) int strncmp(const char *s1, const char *s2, size_t max)
{ {
int i; int i;

View File

@@ -11,15 +11,25 @@
* for more details. * for more details.
*/ */
#include <bas_string.h> #include "bas_types.h"
#include "bas_printf.h"
#include "bas_string.h"
#include "fb.h" #include "fb.h"
#include "radeonfb.h" #include "radeonfb.h"
#include "driver_mem.h"
#define DBG_FBMEM
#ifdef DBG_FBMEM
#define dbg(format, arg...) do { xprintf("DEBUG: " format, ##arg); } while (0)
#else
#define dbg(format, arg...) do { ; } while (0)
#endif /* DBG_FBMEM */
long mem_cmp(char *p1, char *p2, long size) long mem_cmp(char *p1, char *p2, long size)
{ {
while(size--) while(size--)
{ {
if(*p1++ != *p2++) if (*p1++ != *p2++)
return(1); return(1);
} }
return(0); return(0);
@@ -37,14 +47,14 @@ int fb_pan_display(struct fb_info *info, struct fb_var_screeninfo *var)
int yoffset = var->yoffset; int yoffset = var->yoffset;
int err; int err;
// DPRINT("fb_pan_display\r\n"); // DPRINT("fb_pan_display\r\n");
if((xoffset < 0) || (yoffset < 0) if ((xoffset < 0) || (yoffset < 0)
|| ((xoffset + info->var.xres) > info->var.xres_virtual)) || ((xoffset + info->var.xres) > info->var.xres_virtual))
return -1; //-EINVAL; return -1; //-EINVAL;
if((err = info->fbops->fb_pan_display(var, info))) if ((err = info->fbops->fb_pan_display(var, info)))
return err; return err;
info->var.xoffset = var->xoffset; info->var.xoffset = var->xoffset;
info->var.yoffset = var->yoffset; info->var.yoffset = var->yoffset;
if(var->vmode & FB_VMODE_YWRAP) if (var->vmode & FB_VMODE_YWRAP)
info->var.vmode |= FB_VMODE_YWRAP; info->var.vmode |= FB_VMODE_YWRAP;
else else
info->var.vmode &= ~FB_VMODE_YWRAP; info->var.vmode &= ~FB_VMODE_YWRAP;
@@ -55,15 +65,15 @@ int fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var)
{ {
int err; int err;
// DPRINT("fb_set_var\r\n"); // DPRINT("fb_set_var\r\n");
if(var->activate & FB_ACTIVATE_INV_MODE) if (var->activate & FB_ACTIVATE_INV_MODE)
/* return 1 if equal */ /* return 1 if equal */
return(!mem_cmp((char *)&info->var, (char *)var, sizeof(struct fb_var_screeninfo))); return(!mem_cmp((char *)&info->var, (char *)var, sizeof(struct fb_var_screeninfo)));
if((var->activate & FB_ACTIVATE_FORCE) if ((var->activate & FB_ACTIVATE_FORCE)
|| mem_cmp((char *)&info->var, (char *)var, sizeof(struct fb_var_screeninfo))) || mem_cmp((char *)&info->var, (char *)var, sizeof(struct fb_var_screeninfo)))
{ {
if((err = info->fbops->fb_check_var(var, info))) if ((err = info->fbops->fb_check_var(var, info)))
return err; return err;
if((var->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW) if ((var->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW)
{ {
memcpy(&info->var, var, sizeof(struct fb_var_screeninfo)); memcpy(&info->var, var, sizeof(struct fb_var_screeninfo));
info->fbops->fb_set_par(info); info->fbops->fb_set_par(info);
@@ -75,19 +85,19 @@ int fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var)
int fb_blank(struct fb_info *info, int blank) int fb_blank(struct fb_info *info, int blank)
{ {
// DPRINT("fb_blank\r\n"); dbg("fb_blank\r\n");
if(blank > FB_BLANK_POWERDOWN) if (blank > FB_BLANK_POWERDOWN)
blank = FB_BLANK_POWERDOWN; blank = FB_BLANK_POWERDOWN;
return(info->fbops->fb_blank(blank, info)); return(info->fbops->fb_blank(blank, info));
} }
int fb_ioctl(unsigned int cmd, unsigned long arg) int fb_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg)
{ {
struct fb_info *info = info_fvdi;
struct fb_var_screeninfo var; struct fb_var_screeninfo var;
struct fb_fix_screeninfo fix; struct fb_fix_screeninfo fix;
void *argp = (void *)arg; void *argp = (void *) arg;
int i; int i;
switch(cmd) switch(cmd)
{ {
case FBIOGET_VSCREENINFO: case FBIOGET_VSCREENINFO:
@@ -96,7 +106,7 @@ int fb_ioctl(unsigned int cmd, unsigned long arg)
case FBIOPUT_VSCREENINFO: case FBIOPUT_VSCREENINFO:
memcpy(&var, argp, sizeof(var)); memcpy(&var, argp, sizeof(var));
i = fb_set_var(info, &var); i = fb_set_var(info, &var);
if(i) if (i)
return i; return i;
memcpy(argp, &var, sizeof(var)); memcpy(argp, &var, sizeof(var));
return 0; return 0;
@@ -106,7 +116,7 @@ int fb_ioctl(unsigned int cmd, unsigned long arg)
case FBIOPAN_DISPLAY: case FBIOPAN_DISPLAY:
memcpy(&var, argp, sizeof(var)); memcpy(&var, argp, sizeof(var));
i = fb_pan_display(info, &var); i = fb_pan_display(info, &var);
if(i) if (i)
return i; return i;
memcpy(argp, &var, sizeof(var)); memcpy(argp, &var, sizeof(var));
return 0; return 0;
@@ -123,10 +133,6 @@ int fb_ioctl(unsigned int cmd, unsigned long arg)
} }
#if 1
static struct radeonfb_info struct_radeon_info;
/** /**
* framebuffer_alloc - creates a new frame buffer info structure * framebuffer_alloc - creates a new frame buffer info structure
* *
@@ -142,24 +148,23 @@ static struct radeonfb_info struct_radeon_info;
*/ */
struct fb_info *framebuffer_alloc(unsigned long size) struct fb_info *framebuffer_alloc(unsigned long size)
{ {
static struct fb_info struct_info; struct fb_info *info = driver_mem_alloc(sizeof(struct fb_info));
struct fb_info *info = &struct_info;
memset(info, 0, sizeof(struct fb_info)); if (info == NULL)
if(size)
{ {
if(size <= sizeof(struct radeonfb_info)) dbg("%s: could not allocate fb_info structure\r\n", __FUNCTION__);
{ return 0;
memset(&struct_radeon_info, 0, sizeof(struct radeonfb_info)); }
info->par = (void *)&struct_radeon_info; memset(info, 0, sizeof(struct fb_info));
}
else if (size)
{ {
char *p = Funcs_malloc(size, 3); char *p = driver_mem_alloc(size);
if(!p)
return NULL; if (!p)
memset(p, 0, size); return NULL;
info->par = p; memset(p, 0, size);
} info->par = p;
} }
return info; return info;
} }
@@ -175,59 +180,6 @@ struct fb_info *framebuffer_alloc(unsigned long size)
*/ */
void framebuffer_release(struct fb_info *info) void framebuffer_release(struct fb_info *info)
{ {
if(info->par != (void *)&struct_radeon_info) driver_mem_free(info->par);
Funcs_free(info->par);
} }
#else
/**
* framebuffer_alloc - creates a new frame buffer info structure
*
* @size: size of driver private data, can be zero
* @dev: pointer to the device for this fb, this can be NULL
*
* Creates a new frame buffer info structure. Also reserves @size bytes
* for driver private data (info->par). info->par (if any) will be
* aligned to sizeof(long).
*
* Returns the new structure, or NULL if an error occured.
*
*/
struct fb_info *framebuffer_alloc(unsigned long size)
{
#define BYTES_PER_LONG (32/8)
#define PADDING (BYTES_PER_LONG - (sizeof(struct fb_info) % BYTES_PER_LONG))
int fb_info_size = sizeof(struct fb_info);
struct fb_info *info;
char *p;
if(size)
fb_info_size += PADDING;
p = Funcs_malloc(fb_info_size + size, 3);
if(!p)
return NULL;
memset(p, 0, fb_info_size + size);
info = (struct fb_info *) p;
if(size)
info->par = p + fb_info_size;
return info;
#undef PADDING
#undef BYTES_PER_LONG
}
/**
* framebuffer_release - marks the structure available for freeing
*
* @info: frame buffer info structure
*
* Drop the reference count of the class_device embedded in the
* framebuffer info structure.
*
*/
void framebuffer_release(struct fb_info *info)
{
Funcs_free(info);
}
#endif

View File

@@ -1,11 +1,20 @@
#define RINFO_ONLY #define RINFO_ONLY
#include "radeonfb.h" #include "radeonfb.h"
#include "bas_printf.h"
#include "bas_string.h" #include "bas_string.h"
#include "util.h"
#include "x86emu.h" #include "x86emu.h"
#include "pci.h" #include "pci.h"
#include "pci_ids.h" #include "pci_ids.h"
// #include "vgatables.h" // #include "vgatables.h"
#define DBG_EMULATOR
#ifdef DBG_EMULATOR
#define dbg(format, arg...) do { xprintf("DEBUG: " format, ##arg); } while (0)
#else
#define dbg(format, arg...) do { ; } while (0)
#endif /* DBG_EMULATOR */
#define USE_SDRAM #define USE_SDRAM
#define DIRECT_ACCESS #define DIRECT_ACCESS
@@ -22,11 +31,6 @@
#define SYS_BIOS 0xF0000 #define SYS_BIOS 0xF0000
#define SIZE_EMU 0x100000 #define SIZE_EMU 0x100000
#ifdef DIRECT_ACCESS
extern uint16_t swpw(uint16_t val);
extern uint32_t swap_long(uint32_t val);
#endif
typedef struct typedef struct
{ {
long ident; long ident;
@@ -103,17 +107,12 @@ static uint8_t inb(uint16_t port)
{ {
uint8_t val = 0; uint8_t val = 0;
if ((port >= offset_port) && (port <= offset_port+0xFF)) if ((port >= offset_port) && (port <= offset_port + 0xFF))
{ {
#ifdef DEBUG_X86EMU_PCI dbg("inb(");
DPRINTVALHEX("inb(", port);
#endif
val = *(uint8_t *)(offset_io+(uint32_t)port); val = *(uint8_t *)(offset_io+(uint32_t)port);
#ifdef DEBUG_X86EMU_PCI dbg("0x%x) = 0x%x\r\n", port, val);
DPRINTVALHEX(") = ", val);
DPRINT("\r\n");
#endif
} }
return val; return val;
} }
@@ -124,14 +123,9 @@ static uint16_t inw(uint16_t port)
if ((port >= offset_port) && (port <= offset_port+0xFF)) if ((port >= offset_port) && (port <= offset_port+0xFF))
{ {
#ifdef DEBUG_X86EMU_PCI dbg("inw(");
DPRINTVALHEX("inw(", port);
#endif
val = swpw(*(uint16_t *)(offset_io+(uint32_t)port)); val = swpw(*(uint16_t *)(offset_io+(uint32_t)port));
#ifdef DEBUG_X86EMU_PCI dbg("0x%x) = 0x%x\r\n", port, val);
DPRINTVALHEX(") = ", val);
DPRINT("\r\n");
#endif
} }
return val; return val;
} }
@@ -141,27 +135,19 @@ static uint32_t inl(uint16_t port)
uint32_t val = 0; uint32_t val = 0;
if ((port >= offset_port) && (port <= offset_port+0xFF)) if ((port >= offset_port) && (port <= offset_port+0xFF))
{ {
#ifdef DEBUG_X86EMU_PCI dbg("inl(");
DPRINTVALHEX("inl(", port);
#endif
val = swpl(*(uint32_t *)(offset_io+(uint32_t)port)); val = swpl(*(uint32_t *)(offset_io+(uint32_t)port));
#ifdef DEBUG_X86EMU_PCI dbg("0x%x) = 0x%x\r\n", port, val);
DPRINTVALHEX(") = ", val);
DPRINT("\r\n");
#endif
} }
else if (port == 0xCF8) else if (port == 0xCF8)
{ {
dbg("inl(");
val = config_address_reg; val = config_address_reg;
#ifdef DEBUG_X86EMU_PCI dbg("0x%x) = 0x%x\r\n", port, val);
DPRINTVALHEX("inl(", port);
DPRINTVALHEX(") = ", val);
DPRINT("\r\n");
#endif
} }
else if ((port == 0xCFC) && ((config_address_reg & 0x80000000) !=0)) else if ((port == 0xCFC) && ((config_address_reg & 0x80000000) != 0))
{ {
switch(config_address_reg & 0xFC) switch (config_address_reg & 0xFC)
{ {
case PCIIDR: case PCIIDR:
val = ((uint32_t) rinfo_biosemu->chipset << 16) + PCI_VENDOR_ID_ATI; val = ((uint32_t) rinfo_biosemu->chipset << 16) + PCI_VENDOR_ID_ATI;
@@ -173,59 +159,39 @@ static uint32_t inl(uint16_t port)
val = pci_read_config_longword(rinfo_biosemu->handle, config_address_reg & 0xFC); val = pci_read_config_longword(rinfo_biosemu->handle, config_address_reg & 0xFC);
break; break;
} }
#ifdef DEBUG_X86EMU_PCI dbg("inl(0x%x) = 0x%x\r\n", port, val);
DPRINTVALHEX("inl(", port);
DPRINTVALHEX(") = ", val);
DPRINT("\r\n");
#endif
} }
return val; return val;
} }
void outb(uint8_t val, uint16_t port) void outb(uint8_t val, uint16_t port)
{ {
if ((port >= offset_port) && (port <= offset_port+0xFF)) if ((port >= offset_port) && (port <= offset_port + 0xFF))
{ {
#ifdef DEBUG_X86EMU_PCI dbg("outb(0x%x, 0x%x)\r\n", port, val);
DPRINTVALHEX("outb(", port);
DPRINTVALHEX(") = ", val);
DPRINT("\r\n");
#endif
*(uint8_t *)(offset_io + (uint32_t) port) = val; *(uint8_t *)(offset_io + (uint32_t) port) = val;
} }
} }
void outw(uint16_t val, uint16_t port) void outw(uint16_t val, uint16_t port)
{ {
if ((port >= offset_port) && (port <= offset_port+0xFF)) if ((port >= offset_port) && (port <= offset_port + 0xFF))
{ {
#ifdef DEBUG_X86EMU_PCI dbg("outw(0x%x, 0x%x)\r\n", port, val);
DPRINTVALHEX("outw(", port);
DPRINTVALHEX(") = ", val);
DPRINT("\r\n");
#endif
*(uint16_t *)(offset_io + (uint32_t) port) = swpw(val); *(uint16_t *)(offset_io + (uint32_t) port) = swpw(val);
} }
} }
void outl(uint32_t val, uint16_t port) void outl(uint32_t val, uint16_t port)
{ {
if ((port >= offset_port) && (port <= offset_port+0xFF)) if ((port >= offset_port) && (port <= offset_port + 0xFF))
{ {
#ifdef DEBUG_X86EMU_PCI dbg("outl(0x%x, 0x%x)\r\n", port, val);
DPRINTVALHEX("outl(", port);
DPRINTVALHEX(") = ", val);
DPRINT("\r\n");
#endif
*(uint32_t *)(offset_io + (uint32_t) port) = swpl(val); *(uint32_t *)(offset_io + (uint32_t) port) = swpl(val);
} }
else if (port == 0xCF8) else if (port == 0xCF8)
{ {
#ifdef DEBUG_X86EMU_PCI dbg("outl(0x%x, 0x%x)\r\n", port, val);
DPRINTVALHEX("outl(", port);
DPRINTVALHEX(") = ", val);
DPRINT("\r\n");
#endif
config_address_reg = val; config_address_reg = val;
} }
else if ((port == 0xCFC) && ((config_address_reg & 0x80000000) !=0)) else if ((port == 0xCFC) && ((config_address_reg & 0x80000000) !=0))
@@ -234,11 +200,7 @@ void outl(uint32_t val, uint16_t port)
offset_port = (uint16_t)val & 0xFFFC; offset_port = (uint16_t)val & 0xFFFC;
else else
{ {
#ifdef DEBUG_X86EMU_PCI dbg("outl(0x%x, 0x%x)\r\n", port, val);
DPRINTVALHEX("outl(", port);
DPRINTVALHEX(") = ", val);
DPRINT("\r\n");
#endif
pci_write_config_longword(rinfo_biosemu->handle, config_address_reg & 0xFC, val); pci_write_config_longword(rinfo_biosemu->handle, config_address_reg & 0xFC, val);
} }
} }
@@ -554,11 +516,11 @@ void biosfn_set_video_mode(uint8_t mode)
memsetw(vga_modes[line].sstart,0x0000,0x4000); // 32k memsetw(vga_modes[line].sstart,0x0000,0x4000); // 32k
else else
{ {
outb(0x02,VGAREG_SEQU_ADDRESS); outb(0x02, VGAREG_SEQU_ADDRESS);
mmask = inb( VGAREG_SEQU_DATA ); mmask = inb(VGAREG_SEQU_DATA);
outb(0x0f,VGAREG_SEQU_DATA); // all planes outb(0x0f, VGAREG_SEQU_DATA); // all planes
memsetw(vga_modes[line].sstart,0x0000,0x8000); // 64k memsetw(vga_modes[line].sstart, 0x0000, 0x8000); // 64k
outb(mmask,VGAREG_SEQU_DATA); outb(mmask, VGAREG_SEQU_DATA);
} }
} }
@@ -572,7 +534,7 @@ void run_bios(struct radeonfb_info *rinfo)
struct pci_data *rom_data; struct pci_data *rom_data;
unsigned long rom_size=0; unsigned long rom_size=0;
unsigned long image_size=0; unsigned long image_size=0;
unsigned long biosmem=0x01000000; /* when run_bios() is called, SDRAM is valid but not added to the system */ unsigned long biosmem = 0x01000000; /* when run_bios() is called, SDRAM is valid but not added to the system */
unsigned long addr; unsigned long addr;
unsigned short initialcs; unsigned short initialcs;
unsigned short initialip; unsigned short initialip;