disable most of the debug output

This commit is contained in:
Markus Fröschle
2016-10-17 04:05:50 +00:00
parent 42729fa2ea
commit cb31dffa64
17 changed files with 759 additions and 546 deletions

View File

@@ -79,7 +79,7 @@ extern void run_bios(struct radeonfb_info *rinfo);
0, \
0, \
(flags) | (CHIP_FAMILY_##family) \
}
}
struct pci_device_id radeonfb_pci_table[] =
{
@@ -236,8 +236,6 @@ extern struct fb_info *info_fb;
#define rinfo ((struct radeonfb_info *) info_fb->par)
static uint32_t inreg(uint32_t addr)
{
dbg("info_fb = %p, info_fb->par = %p\r\n", info_fb, info_fb->par);
dbg("retrieve from addr %p\r\n", rinfo->mmio_base + addr);
return INREG(addr);
}
@@ -282,8 +280,8 @@ void radeon_pll_errata_after_index(struct radeonfb_info *rinfo)
{
if (!(rinfo->errata & CHIP_ERRATA_PLL_DUMMYREADS))
return;
(void)INREG(CLOCK_CNTL_DATA);
(void)INREG(CRTC_GEN_CNTL);
(void) INREG(CLOCK_CNTL_DATA);
(void) INREG(CRTC_GEN_CNTL);
}
void radeon_pll_errata_after_data(struct radeonfb_info *rinfo)
@@ -363,9 +361,7 @@ static int radeon_map_ROM(struct radeonfb_info *rinfo)
dbg("bios_seg=%p\r\n", rinfo->bios_seg);
dbg("bios_seg_phys=%p\r\n", rinfo->bios_seg_phys);
dbg("before inreg\r\n");
temp = inreg(MPP_TB_CONFIG);
dbg("after inreg\r\n");
dbg("temp=%d\r\n", temp);
temp &= 0x00ffffffu;
@@ -445,12 +441,12 @@ anyway:
uint16_t pll_info_block = BIOS_IN16(rinfo->fp_bios_start + 0x30);
dbg("BIOS PLL info block offset: %p\r\n", BIOS_IN16(rinfo->fp_bios_start + 0x30));
rinfo->bios_pll.sclk = BIOS_IN16(pll_info_block + 0x08);
rinfo->bios_pll.mclk = BIOS_IN16(pll_info_block + 0x0a);
rinfo->bios_pll.sclk = BIOS_IN16(pll_info_block + 0x08);
rinfo->bios_pll.mclk = BIOS_IN16(pll_info_block + 0x0a);
rinfo->bios_pll.ref_clk = BIOS_IN16(pll_info_block + 0x0e);
rinfo->bios_pll.ref_div = BIOS_IN16(pll_info_block + 0x10);
rinfo->bios_pll.ppll_min = BIOS_IN32(pll_info_block + 0x12);
rinfo->bios_pll.ppll_max = BIOS_IN32(pll_info_block + 0x16);
rinfo->bios_pll.ppll_min = BIOS_IN32(pll_info_block + 0x12);
rinfo->bios_pll.ppll_max = BIOS_IN32(pll_info_block + 0x16);
}
return 0;
@@ -490,7 +486,8 @@ static int radeon_probe_pll_params(struct radeonfb_info *rinfo)
{
if ((get_timer() - start_tv) > US_TO_TIMER(10000000UL)) /* 10 sec */
{
timeout=1;
timeout = 1;
dbg("timeout\r\n");
break;
}
}
@@ -502,7 +499,8 @@ static int radeon_probe_pll_params(struct radeonfb_info *rinfo)
{
if ((get_timer() - start_tv) > US_TO_TIMER(1000000UL)) /* 1 sec */
{
timeout=1;
timeout = 1;
dbg("timeout2\r\n");
break;
}
}
@@ -512,7 +510,8 @@ static int radeon_probe_pll_params(struct radeonfb_info *rinfo)
{
if ((get_timer() - start_tv) > US_TO_TIMER(10000000UL)) /* 10 sec */
{
timeout=1;
timeout = 1;
dbg("timeout3\r\n");
break;
}
}
@@ -773,7 +772,10 @@ int radeonfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
}
if (radeon_match_mode(rinfo, &v, var))
{
dbg("invalid mode\r\n");
return -1; //-EINVAL;
}
switch (v.bits_per_pixel)
{
@@ -795,6 +797,7 @@ int radeonfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
break;
default:
dbg("invalid bits per pixel\r\n");
return -1; //-EINVAL;
}
@@ -2128,7 +2131,7 @@ int32_t radeonfb_pci_register(int32_t handle, const struct pci_device_id *ent)
info = framebuffer_alloc(sizeof(struct radeonfb_info));
if (!info)
{
dbg("could not allocate frame buffer\r\n");
dbg("could not allocate frame buffer info\r\n");
return -1; // -ENOMEM;
}
@@ -2376,7 +2379,7 @@ int32_t radeonfb_pci_register(int32_t handle, const struct pci_device_id *ent)
#endif
//rinfo->RageTheatreCrystal = rinfo->RageTheatreTunerPort=rinfo->RageTheatreCompositePort = rinfo->RageTheatreSVideoPort = -1;
//rinfo->tunerType = -1;
return(0);
return 0;
}
#if 0

216
radeon/radeon_i2c.c Normal file
View File

@@ -0,0 +1,216 @@
#include "radeonfb.h"
// #include "relocate.h"
#include "edid.h"
#include "driver_mem.h"
#ifdef CONFIG_FB_RADEON_I2C
#define RADEON_DDC 0x50
extern void mdelay(long msec);
extern void udelay(long usec);
static void radeon_gpio_setscl(void* data, int state)
{
struct radeon_i2c_chan *chan = data;
struct radeonfb_info *rinfo = chan->rinfo;
unsigned long val;
val = INREG(chan->ddc_reg) & ~(VGA_DDC_CLK_OUT_EN);
if(!state)
val |= VGA_DDC_CLK_OUT_EN;
OUTREG(chan->ddc_reg, val);
(void)INREG(chan->ddc_reg);
}
static void radeon_gpio_setsda(void* data, int state)
{
struct radeon_i2c_chan *chan = data;
struct radeonfb_info *rinfo = chan->rinfo;
unsigned long val;
val = INREG(chan->ddc_reg) & ~(VGA_DDC_DATA_OUT_EN);
if(!state)
val |= VGA_DDC_DATA_OUT_EN;
OUTREG(chan->ddc_reg, val);
(void)INREG(chan->ddc_reg);
}
static int radeon_gpio_getscl(void* data)
{
struct radeon_i2c_chan *chan = data;
struct radeonfb_info *rinfo = chan->rinfo;
unsigned long val;
val = INREG(chan->ddc_reg);
return(val & VGA_DDC_CLK_INPUT) ? 1 : 0;
}
static int radeon_gpio_getsda(void* data)
{
struct radeon_i2c_chan *chan = data;
struct radeonfb_info *rinfo = chan->rinfo;
unsigned long val;
val = INREG(chan->ddc_reg);
return(val & VGA_DDC_DATA_INPUT) ? 1 : 0;
}
static int radeon_setup_i2c_bus(struct radeon_i2c_chan *chan)
{
int rc;
chan->adapter.algo_data = &chan->algo;
chan->algo.setsda = radeon_gpio_setsda;
chan->algo.setscl = radeon_gpio_setscl;
chan->algo.getsda = radeon_gpio_getsda;
chan->algo.getscl = radeon_gpio_getscl;
chan->algo.udelay = 40;
chan->algo.timeout = 20;
chan->algo.data = chan;
/* Raise SCL and SDA */
radeon_gpio_setsda(chan, 1);
radeon_gpio_setscl(chan, 1);
udelay(20);
rc = i2c_bit_add_bus(&chan->adapter);
return rc;
}
void radeon_create_i2c_busses(struct radeonfb_info *rinfo)
{
rinfo->i2c[0].rinfo = rinfo;
rinfo->i2c[0].ddc_reg = GPIO_MONID;
radeon_setup_i2c_bus(&rinfo->i2c[0]);
rinfo->i2c[1].rinfo = rinfo;
rinfo->i2c[1].ddc_reg = GPIO_DVI_DDC;
radeon_setup_i2c_bus(&rinfo->i2c[1]);
rinfo->i2c[2].rinfo = rinfo;
rinfo->i2c[2].ddc_reg = GPIO_VGA_DDC;
radeon_setup_i2c_bus(&rinfo->i2c[2]);
rinfo->i2c[3].rinfo = rinfo;
rinfo->i2c[3].ddc_reg = GPIO_CRT2_DDC;
radeon_setup_i2c_bus(&rinfo->i2c[3]);
}
#if 0
void radeon_delete_i2c_busses(struct radeonfb_info *rinfo)
{
if(rinfo->i2c[0].rinfo)
i2c_bit_del_bus(&rinfo->i2c[0].adapter);
rinfo->i2c[0].rinfo = NULL;
if(rinfo->i2c[1].rinfo)
i2c_bit_del_bus(&rinfo->i2c[1].adapter);
rinfo->i2c[1].rinfo = NULL;
if(rinfo->i2c[2].rinfo)
i2c_bit_del_bus(&rinfo->i2c[2].adapter);
rinfo->i2c[2].rinfo = NULL;
if(rinfo->i2c[3].rinfo)
i2c_bit_del_bus(&rinfo->i2c[3].adapter);
rinfo->i2c[3].rinfo = NULL;
}
#endif
static unsigned char *radeon_do_probe_i2c_edid(struct radeon_i2c_chan *chan)
{
unsigned char start = 0x0;
struct i2c_msg msgs[] =
{
{
.addr = RADEON_DDC,
.len = 1,
.buf = &start,
},
{
.addr = RADEON_DDC,
.flags = I2C_M_RD,
.len = EDID_LENGTH,
},
};
unsigned char *buf;
buf = driver_mem_alloc(EDID_LENGTH * 3);
if (!buf)
return NULL;
msgs[1].buf = buf;
if(i2c_transfer(&chan->adapter, msgs, 2) == 2)
return buf;
driver_mem_free(buf);
return NULL;
}
int32_t radeon_probe_i2c_connector(struct radeonfb_info *rinfo, int32_t conn, uint8_t **out_edid)
{
unsigned long reg = rinfo->i2c[conn-1].ddc_reg;
unsigned char *edid = NULL;
int i, j;
// DPRINTVAL("radeonfb: radeon_probe_i2c_connector ", conn);
// DPRINT("\r\n");
OUTREG(reg, INREG(reg) & ~(VGA_DDC_DATA_OUTPUT | VGA_DDC_CLK_OUTPUT));
OUTREG(reg, INREG(reg) & ~(VGA_DDC_CLK_OUT_EN));
(void)INREG(reg);
for(i = 0; i < 3; i++)
{
/* For some old monitors we need the
* following process to initialize/stop DDC
*/
OUTREG(reg, INREG(reg) & ~(VGA_DDC_DATA_OUT_EN));
(void)INREG(reg);
mdelay(13);
OUTREG(reg, INREG(reg) & ~(VGA_DDC_CLK_OUT_EN));
(void)INREG(reg);
for(j = 0; j < 5; j++)
{
mdelay(10);
if(INREG(reg) & VGA_DDC_CLK_INPUT)
break;
}
if(j == 5)
continue;
OUTREG(reg, INREG(reg) | VGA_DDC_DATA_OUT_EN);
(void)INREG(reg);
mdelay(15);
OUTREG(reg, INREG(reg) | VGA_DDC_CLK_OUT_EN);
(void)INREG(reg);
mdelay(15);
OUTREG(reg, INREG(reg) & ~(VGA_DDC_DATA_OUT_EN));
(void)INREG(reg);
mdelay(15);
/* Do the real work */
edid = radeon_do_probe_i2c_edid(&rinfo->i2c[conn-1]);
OUTREG(reg, INREG(reg) | (VGA_DDC_DATA_OUT_EN | VGA_DDC_CLK_OUT_EN));
(void)INREG(reg);
mdelay(15);
OUTREG(reg, INREG(reg) & ~(VGA_DDC_CLK_OUT_EN));
(void)INREG(reg);
for(j = 0; j < 10; j++)
{
mdelay(10);
if(INREG(reg) & VGA_DDC_CLK_INPUT)
break;
}
OUTREG(reg, INREG(reg) & ~(VGA_DDC_DATA_OUT_EN));
(void)INREG(reg);
mdelay(15);
OUTREG(reg, INREG(reg) | (VGA_DDC_DATA_OUT_EN | VGA_DDC_CLK_OUT_EN));
(void)INREG(reg);
if(edid)
break;
}
/* Release the DDC lines when done or the Apple Cinema HD display
* will switch off */
OUTREG(reg, INREG(reg) & ~(VGA_DDC_CLK_OUT_EN | VGA_DDC_DATA_OUT_EN));
(void)INREG(reg);
if(out_edid)
*out_edid = edid;
if(!edid)
return MT_NONE;
if(edid[0x14] & 0x80)
{
/* Fix detection using BIOS tables */
if(rinfo->is_mobility /*&& conn == ddc_dvi*/ && (INREG(LVDS_GEN_CNTL) & LVDS_ON))
return MT_LCD;
else
return MT_DFP;
}
return MT_CRT;
}
#endif /* CONFIG_FB_RADEON_I2C */

View File

@@ -5,12 +5,8 @@
#include "bas_printf.h"
#include "bas_string.h"
//#define DBG_MONITOR
#ifdef DBG_MONITOR
#define dbg(format, arg...) do { xprintf("DEBUG: " format, ##arg); } while (0)
#else
#define dbg(format, arg...) do { ; } while (0)
#endif /* DBG_MONITOR */
// #define DEBUG
#include "debug.h"
#ifndef INT_MAX
#define INT_MAX ((int) (~0U >> 1))
@@ -136,7 +132,7 @@ static int radeon_parse_monitor_layout(struct radeonfb_info *rinfo, const char *
if ((monitor_layout == NULL) || (*monitor_layout == '\0'))
{
dbg("%s: monitor_layout missing\r\n");
dbg("monitor_layout missing\r\n");
return 0;
}
@@ -178,33 +174,33 @@ static int radeon_parse_monitor_layout(struct radeonfb_info *rinfo, const char *
if (strcmp(s1, "CRT"))
{
rinfo->mon1_type = MT_CRT;
dbg("%s: monitor 1 set to CRT\r\n", __FUNCTION__);
dbg("monitor 1 set to CRT\r\n");
}
else if (strcmp(s1, "TMDS"))
{
rinfo->mon1_type = MT_DFP;
dbg("%s: monitor 1 set to TMDS\r\n", __FUNCTION__);
dbg("monitor 1 set to TMDS\r\n");
}
else if (strcmp(s1, "LVDS"))
{
rinfo->mon1_type = MT_LCD;
dbg("%s: monitor 1 set to LVDS\r\n", __FUNCTION__);
dbg("monitor 1 set to LVDS\r\n");
}
if (strcmp(s2, "CRT"))
{
rinfo->mon2_type = MT_CRT;
dbg("%s: monitor 2 set to CRT\r\n", __FUNCTION__);
dbg("monitor 2 set to CRT\r\n");
}
else if (strcmp(s2, "TMDS"))
{
rinfo->mon2_type = MT_DFP;
dbg("%s: monitor 2 set to TMDS\r\n", __FUNCTION__);
dbg("monitor 2 set to TMDS\r\n");
}
else if (strcmp(s2, "LVDS"))
{
rinfo->mon2_type = MT_LCD;
dbg("%s: monitor 2 set to LVDS\r\n", __FUNCTION__);
dbg("monitor 2 set to LVDS\r\n");
}
return 1;
}
@@ -227,25 +223,25 @@ void radeon_probe_screens(struct radeonfb_info *rinfo, const char *monitor_layou
* a layout for each card ?
*/
#ifdef CONFIG_FB_RADEON_I2C
dbg("%s: use monitor layout\r\n", __FUNCTION__);
dbg("use monitor layout\r\n");
if (!ignore_edid)
{
if (rinfo->mon1_type != MT_NONE)
{
dbg("%s: probe ddc_dvi on MON1\r\n", __FUNCTION__);
dbg("probe ddc_dvi on MON1\r\n");
if (!radeon_probe_i2c_connector(rinfo, ddc_dvi, &rinfo->mon1_EDID))
{
dbg("%s: probe ddc_crt2 on MON1\r\n", __FUNCTION__);
dbg("probe ddc_crt2 on MON1\r\n");
radeon_probe_i2c_connector(rinfo, ddc_crt2, &rinfo->mon1_EDID);
ddc_crt2_used = 1;
}
}
if (rinfo->mon2_type != MT_NONE)
{
dbg("%s: probe ddc_vga on MON2\r\n", __FUNCTION__);
dbg("probe ddc_vga on MON2\r\n");
if (!radeon_probe_i2c_connector(rinfo, ddc_vga, &rinfo->mon2_EDID) && !ddc_crt2_used)
{
dbg("%s: probe ddc_crt2 on MON2\r\n", __FUNCTION__);
dbg("probe ddc_crt2 on MON2\r\n");
radeon_probe_i2c_connector(rinfo, ddc_crt2, &rinfo->mon2_EDID);
}
}
@@ -261,7 +257,7 @@ void radeon_probe_screens(struct radeonfb_info *rinfo, const char *monitor_layou
else
{
rinfo->mon1_type = MT_CRT;
dbg("%s: No valid monitor, assuming CRT on first port\r\n", __FUNCTION__);
dbg("No valid monitor, assuming CRT on first port\r\n");
}
rinfo->mon2_type = MT_NONE;
rinfo->mon2_EDID = NULL;
@@ -273,7 +269,7 @@ void radeon_probe_screens(struct radeonfb_info *rinfo, const char *monitor_layou
* Auto-detecting display type (well... trying to ...)
*/
#ifdef CONFIG_FB_RADEON_I2C
dbg("%s: Auto-detecting\r\n", __FUNCTION__);
dbg("Auto-detecting\r\n");
#endif
#if 0 //#if DEBUG && defined(CONFIG_FB_RADEON_I2C)
{
@@ -292,17 +288,17 @@ void radeon_probe_screens(struct radeonfb_info *rinfo, const char *monitor_layou
#ifdef CONFIG_FB_RADEON_I2C
if (rinfo->mon1_type == MT_NONE)
{
dbg("%s: probe ddc_dvi on MON1\r\n", __FUNCTION__);
dbg("probe ddc_dvi on MON1\r\n");
rinfo->mon1_type = radeon_probe_i2c_connector(rinfo, ddc_dvi, &rinfo->mon1_EDID);
}
if (rinfo->mon1_type == MT_NONE)
{
dbg("%s: probe ddc_vga on MON1\r\n", __FUNCTION__);
dbg("probe ddc_vga on MON1\r\n");
rinfo->mon1_type = radeon_probe_i2c_connector(rinfo, ddc_vga, &rinfo->mon1_EDID);
}
if (rinfo->mon1_type == MT_NONE)
{
dbg("%s: probe ddc_crt2 on MON1\r\n", __FUNCTION__);
dbg("probe ddc_crt2 on MON1\r\n");
rinfo->mon1_type = radeon_probe_i2c_connector(rinfo, ddc_crt2, &rinfo->mon1_EDID);
}
#endif /* CONFIG_FB_RADEON_I2C */
@@ -316,12 +312,12 @@ void radeon_probe_screens(struct radeonfb_info *rinfo, const char *monitor_layou
#ifdef CONFIG_FB_RADEON_I2C
if (rinfo->mon1_type == MT_NONE)
{
dbg("%s: probe ddc_dvi on MON1\r\n", __FUNCTION__);
dbg("probe ddc_dvi on MON1\r\n");
rinfo->mon1_type = radeon_probe_i2c_connector(rinfo, ddc_dvi, &rinfo->mon1_EDID);
}
if (rinfo->mon1_type == MT_NONE)
{
dbg("%s: probe ddc_crt2 on MON1\r\n", __FUNCTION__);
dbg("probe ddc_crt2 on MON1\r\n");
rinfo->mon1_type = radeon_probe_i2c_connector(rinfo, ddc_crt2, &rinfo->mon1_EDID);
if (rinfo->mon1_type != MT_NONE)
ddc_crt2_used = 1;
@@ -331,7 +327,7 @@ void radeon_probe_screens(struct radeonfb_info *rinfo, const char *monitor_layou
&& (INREG(LVDS_GEN_CNTL) & LVDS_ON))
{
rinfo->mon1_type = MT_LCD;
dbg("%s: Non-DDC laptop panel detected\r\n", __FUNCTION__);
dbg("Non-DDC laptop panel detected\r\n");
}
if (rinfo->mon1_type == MT_NONE)
rinfo->mon1_type = radeon_crt_is_connected(rinfo, rinfo->reversed_DAC);
@@ -341,12 +337,12 @@ void radeon_probe_screens(struct radeonfb_info *rinfo, const char *monitor_layou
#ifdef CONFIG_FB_RADEON_I2C
if (rinfo->mon2_type == MT_NONE)
{
dbg("%s: probe ddc_vga on MON2\r\n", __FUNCTION__);
dbg("probe ddc_vga on MON2\r\n");
rinfo->mon2_type = radeon_probe_i2c_connector(rinfo, ddc_vga, &rinfo->mon2_EDID);
}
if (rinfo->mon2_type == MT_NONE && !ddc_crt2_used)
{
dbg("%s: probe ddc_crt2 on MON2\r\n", __FUNCTION__);
dbg("probe ddc_crt2 on MON2\r\n");
rinfo->mon2_type = radeon_probe_i2c_connector(rinfo, ddc_crt2, &rinfo->mon2_EDID);
}
#endif /* CONFIG_FB_RADEON_I2C */
@@ -399,18 +395,18 @@ void radeon_probe_screens(struct radeonfb_info *rinfo, const char *monitor_layou
}
bail:
dbg("%s: Monitor 1 type %s found\r\n", __FUNCTION__, radeon_get_mon_name(rinfo->mon1_type));
dbg("Monitor 1 type %s found\r\n", radeon_get_mon_name(rinfo->mon1_type));
if (rinfo->mon1_EDID)
{
dbg("%s: EDID probed\r\n", __FUNCTION__);
dbg("EDID probed\r\n");
}
if (!rinfo->has_CRTC2)
return;
dbg("%s: Monitor 2 type %s\r\n", __FUNCTION__, radeon_get_mon_name(rinfo->mon2_type));
dbg("Monitor 2 type %s\r\n", radeon_get_mon_name(rinfo->mon2_type));
if (rinfo->mon2_EDID)
{
dbg("%s: EDID probed\r\n", __FUNCTION__);
dbg("EDID probed\r\n");
}
}
@@ -470,7 +466,7 @@ void radeon_check_modes(struct radeonfb_info *rinfo, struct mode_option *resolut
struct fb_info *info = rinfo->info;
int has_default_mode = 0;
struct mode_option xres_yres;
dbg("%s: radeon_check_modes\r\n", __FUNCTION__);
dbg("\r\n");
/*
* Fill default var first
@@ -487,7 +483,7 @@ void radeon_check_modes(struct radeonfb_info *rinfo, struct mode_option *resolut
{
struct fb_var_screeninfo var;
dbg("%s: fb_parse_edid\r\n", __FUNCTION__);
dbg("fb_parse_edid\r\n");
if (fb_parse_edid(rinfo->mon1_EDID, &var) == 0)
{
if ((var.xres >= rinfo->panel_info.xres) && (var.yres >= rinfo->panel_info.yres))
@@ -495,7 +491,7 @@ void radeon_check_modes(struct radeonfb_info *rinfo, struct mode_option *resolut
}
else
{
dbg("%s: no data to parse\r\n", __FUNCTION__);
dbg("no data to parse\r\n");
}
}
/*
@@ -505,7 +501,8 @@ void radeon_check_modes(struct radeonfb_info *rinfo, struct mode_option *resolut
if (rinfo->mon1_type != MT_CRT && rinfo->panel_info.valid)
{
struct fb_var_screeninfo *var = &info->var;
dbg("%s: setup the default mode based on panel info\r\n", __FUNCTION__);
dbg("setup the default mode based on panel info\r\n");
var->xres = rinfo->panel_info.xres;
var->yres = rinfo->panel_info.yres;
var->xres_virtual = rinfo->panel_info.xres;
@@ -664,7 +661,7 @@ int radeon_match_mode(struct radeonfb_info *rinfo,
int distance = INT_MAX;
const struct fb_videomode *candidate = NULL;
dbg("%s:\r\n", __FUNCTION__);
dbg("\r\n");
/* Start with a copy of the requested mode */
memcpy(dest, src, sizeof(struct fb_var_screeninfo));
@@ -698,7 +695,7 @@ int radeon_match_mode(struct radeonfb_info *rinfo,
}
return 0;
}
dbg("%s:look for a mode in the database\r\n", __FUNCTION__);
dbg("look for a mode in the database\r\n");
/* Now look for a mode in the database */
while(db)