xserver-xorg-video-avivo: Changes to 'upstream-experimental'
avivotool/avivotool.c | 20 -
configure.ac | 13
include/avivo.h | 152 ++--------
include/avivo_chipset.h | 54 +++
include/radeon_reg.h | 61 ++--
xorg/Makefile.am | 1
xorg/avivo.c | 675 +++++++++---------------------------------------
xorg/avivo_bios.c | 258 +++---------------
xorg/avivo_chipset.c | 105 +++++++
xorg/avivo_common.c | 2
xorg/avivo_crtc.c | 96 ++++--
xorg/avivo_i2c.c | 315 ----------------------
xorg/avivo_output.c | 77 +++++
xorg/avivo_state.c | 55 +++
14 files changed, 612 insertions(+), 1272 deletions(-)
New commits:
commit c3d60875cd750d54f74b0cf7e06e551e01a723bd
Author: Jerome Glisse <glisse@freedesktop.org>
Date: Thu Jun 28 01:16:51 2007 +0200
avivo: fix typo
diff --git a/xorg/avivo_crtc.c b/xorg/avivo_crtc.c
index 1ffd6fc..724f0aa 100644
--- a/xorg/avivo_crtc.c
+++ b/xorg/avivo_crtc.c
@@ -242,7 +242,7 @@ avivo_crtc_mode_set(xf86CrtcPtr crtc,
adjusted_mode->CrtcHSyncEnd, adjusted_mode->CrtcHSkew,
avivo_crtc->h_sync_pol);
xf86DrvMsg(crtc->scrn->scrnIndex, X_INFO,
- "crtc(%d) vdisp %d, vtotal %d, vss %d, vse %d, vsc %di, vsp %d\n",
+ "crtc(%d) vdisp %d, vtotal %d, vss %d, vse %d, vsc %d, vsp %d\n",
avivo_crtc->crtc_number, adjusted_mode->CrtcVDisplay,
adjusted_mode->CrtcVTotal, adjusted_mode->CrtcVSyncStart,
adjusted_mode->CrtcVSyncEnd, adjusted_mode->VScan,
commit 4bae344da3ebdc1952962ecacd5a80a7dde1dd0b
Author: Jerome Glisse <glisse@freedesktop.org>
Date: Thu Jun 28 01:12:23 2007 +0200
avivo: change pll computation to meet new constraint.
It seems that AVIVO_PLL_POST_DIVIDER * AVIVO_PLL_DIVIDER needs
to be above 40 for PLL stability, changed PLL computation to
meet this. This seems to improve image stability and should fix
couple of bad behavior.
diff --git a/include/radeon_reg.h b/include/radeon_reg.h
index cf46a55..3b4ee8c 100644
--- a/include/radeon_reg.h
+++ b/include/radeon_reg.h
@@ -3192,17 +3192,9 @@
* (vclk is video mode clock)
* vclk = (1080 * AVIVO_PLL_POST_MUL) /
* (AVIVO_PLL_DIVIDER * AVIVO_PLL_POST_DIV * 40)
- *
- * So computation for register:
- * PLL_DIVIDER = 1080 / (vclk)
- * PLL_POST_DIV = 2
- * PLL_POST_MUL = (40 * vclk * PLL_DIVIDER * PLL_POST_DIV) / (1080)
- * AVIVO_PLL_POST_MUL must be inferior to 255
- * Then you repeat this until you come to the nearest value:
- * increment PLL_POST_MUL recompute PLL_POST_DIV
- * if new video mode clock value is better keep on otherwise last
- * previously found value should be the better.
- * Refclk appears to be 108MHz 1080000 / mode clock = this.
+ * It seems that AVIVO_PLL_DIVIDER * AVIVO_PLL_POST_DIV needs to be
+ * above 40 and that AVIVO_DIVIDER should be greater than AVIVO_PLL_POST_DIV
+ * Try to keep this constraint while computing PLL values.
*/
#define AVIVO_PLL1_POST_DIV_CNTL 0x0400
# define AVIVO_PLL_POST_DIV_EN (1 << 0)
diff --git a/xorg/avivo_crtc.c b/xorg/avivo_crtc.c
index a717cab..1ffd6fc 100644
--- a/xorg/avivo_crtc.c
+++ b/xorg/avivo_crtc.c
@@ -121,25 +121,37 @@ avivo_crtc_set_pll(xf86CrtcPtr crtc, DisplayModePtr mode)
struct avivo_info *avivo = avivo_get_info(crtc->scrn);
int adjusted_clock;
int div, pdiv, pmul;
- int n_pdiv, n_pmul;
+ int n_pdiv, n_pmul, n_div;
int clock;
int diff, n_diff;
- /* compute pll to be 0.1% above of mode clock */
adjusted_clock = mode->Clock;
- div = 1080000 / adjusted_clock;
- pdiv = 2;
- pmul = floor(((40.0 * adjusted_clock * pdiv * div) / 1080000.0) + 0.5);
+ div = 8;
+ pdiv = 6;
+ pmul = floor(((40.0 * adjusted_clock * pdiv * div)
+ / 1080000.0) + 0.5);
clock = (pmul * 1080000) / (40 * pdiv * div);
diff = clock - adjusted_clock;
while (1) {
- n_pdiv = pdiv + 1;
- n_pmul = floor(((40.0 * adjusted_clock * n_pdiv * div) / 1080000.0)
+ if (pmul > 255) {
+ if (pdiv > 2) {
+ n_pdiv = pdiv - 1;
+ n_div = div;
+ } else {
+ n_pdiv = pdiv;
+ n_div = div - 1;
+ }
+ } else {
+ n_pdiv = pdiv;
+ n_div = div + 1;
+ }
+ n_pmul = floor(((40.0 * adjusted_clock * n_pdiv * n_div) / 1080000.0)
+ 0.5);
- clock = (n_pmul * 1080000) / (40 * n_pdiv * div);
+ clock = (n_pmul * 1080000) / (40 * n_pdiv * n_div);
n_diff = clock - adjusted_clock;
- if ((diff >= 0 && fabsl(n_diff) >= diff) || n_pmul >= 255)
+ if (diff >= 0 && fabsl(n_diff) >= diff && pmul <= 255)
break;
+ div = n_div;
pdiv = n_pdiv;
pmul = n_pmul;
diff = n_diff;
commit 14e502a548b5cb3b9bc8a0ba47317cd673806364
Author: Jerome Glisse <glisse@freedesktop.org>
Date: Wed Jun 27 18:05:07 2007 +0200
avivo: improve connector/output creation from bios.
Now LFP represent TMDS2 if it exist as LFP as to be
driven by TMDS2 so we cannot create a separate output
for TMDS2.
diff --git a/xorg/avivo_bios.c b/xorg/avivo_bios.c
index 366ac83..31c0e6a 100644
--- a/xorg/avivo_bios.c
+++ b/xorg/avivo_bios.c
@@ -178,10 +178,12 @@ avivo_output_setup(ScrnInfoPtr screen_info)
}
switch (type) {
- case XF86ConnectorVGA:
case XF86ConnectorLFP:
+ number = 1;
+ case XF86ConnectorVGA:
case XF86ConnectorDVI_I:
- avivo_output_init(screen_info, type, number, ddc_reg);
+ if (!avivo_output_exist(screen_info, type, number, ddc_reg))
+ avivo_output_init(screen_info, type, number, ddc_reg);
break;
}
}
diff --git a/xorg/avivo_output.c b/xorg/avivo_output.c
index 0628e26..0c73a81 100644
--- a/xorg/avivo_output.c
+++ b/xorg/avivo_output.c
@@ -262,6 +262,29 @@ static const xf86OutputFuncsRec avivo_output_funcs = {
};
Bool
+avivo_output_exist(ScrnInfoPtr screen_info, xf86ConnectorType type,
+ int number, unsigned long ddc_reg)
+{
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(screen_info);
+ int i;
+
+ for (i = 0; i < config->num_output; i++) {
+ xf86OutputPtr output = config->output[i];
+ struct avivo_output_private *avivo_output = output->driver_private;
+ if (avivo_output->number == number && avivo_output->type == type)
+ return TRUE;
+ /* TMDS2 is shared by LFP & DVI-I */
+ if (avivo_output->type == XF86ConnectorLFP && number == 1)
+ return TRUE;
+ if (type == XF86ConnectorLFP && avivo_output->number == 1) {
+ avivo_output->i2c->DriverPrivate.uval = ddc_reg;
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+Bool
avivo_output_init(ScrnInfoPtr screen_info, xf86ConnectorType type,
int number, unsigned long ddc_reg)
{
commit fc0fd1494feeaa48703ca47597d865d2f93c56cb
Author: Jerome Glisse <glisse@freedesktop.org>
Date: Wed Jun 27 00:34:07 2007 +0200
avivo: print horizontal & vertical sync polarity flags.
diff --git a/xorg/avivo_crtc.c b/xorg/avivo_crtc.c
index aff2aa9..a717cab 100644
--- a/xorg/avivo_crtc.c
+++ b/xorg/avivo_crtc.c
@@ -224,15 +224,17 @@ avivo_crtc_mode_set(xf86CrtcPtr crtc,
FatalError("Unsupported screen depth: %d\n", xf86GetDepth());
}
xf86DrvMsg(crtc->scrn->scrnIndex, X_INFO,
- "crtc(%d) hdisp %d, htotal %d, hss %d, hse %d, hsk %d\n",
+ "crtc(%d) hdisp %d, htotal %d, hss %d, hse %d, hsk %d, hsp %d\n",
avivo_crtc->crtc_number, adjusted_mode->CrtcHDisplay,
adjusted_mode->CrtcHTotal, adjusted_mode->CrtcHSyncStart,
- adjusted_mode->CrtcHSyncEnd, adjusted_mode->CrtcHSkew);
+ adjusted_mode->CrtcHSyncEnd, adjusted_mode->CrtcHSkew,
+ avivo_crtc->h_sync_pol);
xf86DrvMsg(crtc->scrn->scrnIndex, X_INFO,
- "crtc(%d) vdisp %d, vtotal %d, vss %d, vse %d, vsc %d\n",
+ "crtc(%d) vdisp %d, vtotal %d, vss %d, vse %d, vsc %di, vsp %d\n",
avivo_crtc->crtc_number, adjusted_mode->CrtcVDisplay,
adjusted_mode->CrtcVTotal, adjusted_mode->CrtcVSyncStart,
- adjusted_mode->CrtcVSyncEnd, adjusted_mode->VScan);
+ adjusted_mode->CrtcVSyncEnd, adjusted_mode->VScan,
+ avivo_crtc->v_sync_pol);
/* TODO: find out what this regs truely are for.
* last guess: Switch from text to graphics mode.
*/
commit fc17fa764c7aef0232c21f5aa6ae2353d5efe7b7
Author: Jerome Glisse <glisse@freedesktop.org>
Date: Sun Jun 24 12:25:28 2007 +0200
avivo: fix a typo now truly assign LFP to TMDS2.
diff --git a/xorg/avivo_output.c b/xorg/avivo_output.c
index fe9171a..0628e26 100644
--- a/xorg/avivo_output.c
+++ b/xorg/avivo_output.c
@@ -320,7 +320,7 @@ avivo_output_init(ScrnInfoPtr screen_info, xf86ConnectorType type,
break;
}
}
- if (avivo_output->output_offset == XF86ConnectorLFP) {
+ if (avivo_output->type == XF86ConnectorLFP) {
avivo_output->output_offset = AVIVO_TMDS2_CNTL - AVIVO_TMDS1_CNTL;
}
commit 34b652d7f7f79e2e40ecb996a70cd51159b05965
Author: Jerome Glisse <glisse@freedesktop.org>
Date: Sun Jun 24 12:17:51 2007 +0200
avivo: properly set horizontal & vertical polarity.
diff --git a/xorg/avivo_crtc.c b/xorg/avivo_crtc.c
index 5309f07..aff2aa9 100644
--- a/xorg/avivo_crtc.c
+++ b/xorg/avivo_crtc.c
@@ -198,7 +198,7 @@ avivo_crtc_mode_set(xf86CrtcPtr crtc,
+ adjusted_mode->CrtcHDisplay);
avivo_crtc->h_sync_wid = (adjusted_mode->CrtcHSyncEnd
- adjusted_mode->CrtcHSyncStart) << 16;
- avivo_crtc->h_sync_pol = 0;
+ avivo_crtc->h_sync_pol = (adjusted_mode->Flags & V_NHSYNC) ? 1 : 0;
avivo_crtc->v_total = adjusted_mode->CrtcVTotal - 1;
avivo_crtc->v_blank =
((adjusted_mode->CrtcVTotal - adjusted_mode->CrtcVSyncStart) << 16)
@@ -206,6 +206,7 @@ avivo_crtc_mode_set(xf86CrtcPtr crtc,
+ adjusted_mode->CrtcVDisplay);
avivo_crtc->v_sync_wid = (adjusted_mode->CrtcVSyncEnd
- adjusted_mode->CrtcVSyncStart) << 16;
+ avivo_crtc->v_sync_pol = (adjusted_mode->Flags & V_NVSYNC) ? 1 : 0;
avivo_crtc->fb_width = adjusted_mode->CrtcHDisplay;
avivo_crtc->fb_height = adjusted_mode->CrtcVDisplay;
avivo_crtc->fb_pitch = adjusted_mode->CrtcHDisplay;
commit 9f40535f75b3dfb08efb6121294377e758070e56
Author: Jerome Glisse <glisse@freedesktop.org>
Date: Sat Jun 23 18:32:03 2007 +0200
avivo: increase driver verbosity.
diff --git a/xorg/avivo.c b/xorg/avivo.c
index f4dac5d..b73e8a7 100644
--- a/xorg/avivo.c
+++ b/xorg/avivo.c
@@ -388,8 +388,11 @@ avivo_preinit(ScrnInfoPtr screen_info, int flags)
}
#endif
xf86DrvMsg(screen_info->scrnIndex, X_INFO,
- "Control memory at %p, fb at %p\n", avivo->ctrl_addr,
- avivo->fb_addr);
+ "Control memory at %p[size = %d, 0x%08X]\n",
+ avivo->ctrl_addr, avivo->ctrl_size, avivo->ctrl_size);
+ xf86DrvMsg(screen_info->scrnIndex, X_INFO,
+ "Frame buffer memory at %p[size = %d, 0x%08X]\n",
+ avivo->fb_addr, avivo->fb_size, avivo->fb_size);
avivo_get_chipset(avivo);
screen_info->chipset = "avivo";
@@ -451,12 +454,11 @@ avivo_preinit(ScrnInfoPtr screen_info, int flags)
#ifdef WITH_VGAHW
xf86LoadSubModule(screen_info, "vgahw");
-
vgaHWGetHWRec (screen_info);
vgaHWGetIOBase(VGAHWPTR(screen_info));
#endif
-
- xf86DrvMsg(screen_info->scrnIndex, X_INFO, "[ScreenPreInit OK]\n");
+ xf86DrvMsg(screen_info->scrnIndex, X_INFO,
+ "pre-initialization successfull\n");
return TRUE;
}
@@ -532,7 +534,8 @@ avivo_screen_init(int index, ScreenPtr screen, int argc, char **argv)
(avivo->fb_addr >> 16) & AVIVO_MC_MEMORY_MAP_BASE_MASK);
OUTREG(AVIVO_VGA_FB_START, avivo->fb_addr);
avivo_wait_idle(avivo);
-
+ xf86DrvMsg(screen_info->scrnIndex, X_INFO,
+ "setup GPU memory mapping\n");
/* fb memory box */
#if 0
memset(&avivo->fb_memory_box, 0, sizeof(avivo->fb_memory_box));
@@ -546,13 +549,14 @@ avivo_screen_init(int index, ScreenPtr screen, int argc, char **argv)
return FALSE;
}
#endif
-
+ /* display width is the higher resolution from width & height */
if (screen_info->virtualX > screen_info->displayWidth)
screen_info->displayWidth = screen_info->virtualX;
-
+ /* display width * bpp need to be a multiple of 256 */
screen_info->displayWidth = ceil(screen_info->displayWidth * avivo->bpp
/ 256.0) * 256 / avivo->bpp;
-
+ xf86DrvMsg(screen_info->scrnIndex, X_INFO,
+ "padded display width %d\n", screen_info->displayWidth);
/* mi layer */
miClearVisualTypes();
if (!xf86SetDefaultVisual(screen_info, -1)) {
@@ -571,9 +575,8 @@ avivo_screen_init(int index, ScreenPtr screen, int argc, char **argv)
"Couldn't set pixmap depth\n");
return FALSE;
}
- ErrorF("scrninitparam: vx %d, vy %d, dw %d\n",
- screen_info->virtualX, screen_info->virtualY,
- screen_info->displayWidth);
+ ErrorF("VirtualX,Y %d, %d\n",
+ screen_info->virtualX, screen_info->virtualY);
if (!fbScreenInit(screen, avivo->fb_base + screen_info->fbOffset,
screen_info->virtualX, screen_info->virtualY,
screen_info->xDpi, screen_info->yDpi,
@@ -644,7 +647,7 @@ avivo_screen_init(int index, ScreenPtr screen, int argc, char **argv)
return FALSE;
}
- xf86DrvMsg(screen_info->scrnIndex, X_INFO, "[ScreenInit OK]\n");
+ xf86DrvMsg(screen_info->scrnIndex, X_INFO, "initialization successfull\n");
return TRUE;
}
diff --git a/xorg/avivo_output.c b/xorg/avivo_output.c
index 6196d8c..fe9171a 100644
--- a/xorg/avivo_output.c
+++ b/xorg/avivo_output.c
@@ -63,6 +63,7 @@ avivo_i2c_put_bits(I2CBusPtr b, int Clock, int data)
static void
avivo_output_dpms(xf86OutputPtr output, int mode)
{
+ ScrnInfoPtr screen_info = output->scrn;
struct avivo_output_private *avivo_output = output->driver_private;
struct avivo_info *avivo = avivo_get_info(output->scrn);
int crtc = 0;
@@ -85,6 +86,10 @@ avivo_output_dpms(xf86OutputPtr output, int mode)
value1 = 0;
value2 = 0;
value3 = AVIVO_DAC_EN;
+ if (!avivo_output->output_offset)
+ xf86DrvMsg(screen_info->scrnIndex, X_INFO, "enable DAC1\n");
+ else
+ xf86DrvMsg(screen_info->scrnIndex, X_INFO, "enable DAC2\n");
break;
case DPMSModeStandby:
case DPMSModeSuspend:
@@ -92,6 +97,10 @@ avivo_output_dpms(xf86OutputPtr output, int mode)
value1 = AVIVO_DAC_MYSTERY1_DIS;
value2 = AVIVO_DAC_MYSTERY2_DIS;
value3 = 0;
+ if (!avivo_output->output_offset)
+ xf86DrvMsg(screen_info->scrnIndex, X_INFO, "disable DAC1\n");
+ else
+ xf86DrvMsg(screen_info->scrnIndex, X_INFO, "disable DAC2\n");
break;
}
if (output->crtc) {
@@ -119,6 +128,10 @@ avivo_output_dpms(xf86OutputPtr output, int mode)
if (avivo_output->number == 2)
value4 |= 0x00000020;
value5 |= AVIVO_TMDS_EN;
+ if (!avivo_output->output_offset)
+ xf86DrvMsg(screen_info->scrnIndex, X_INFO, "enable TMDS1\n");
+ else
+ xf86DrvMsg(screen_info->scrnIndex, X_INFO, "enable TMDS2\n");
break;
case DPMSModeStandby:
case DPMSModeSuspend:
@@ -126,6 +139,10 @@ avivo_output_dpms(xf86OutputPtr output, int mode)
value1 = 0x04000000;
value2 = 0;
value4 = 0x00060000;
+ if (!avivo_output->output_offset)
+ xf86DrvMsg(screen_info->scrnIndex, X_INFO, "disable TMDS1\n");
+ else
+ xf86DrvMsg(screen_info->scrnIndex, X_INFO, "disable TMDS2\n");
break;
}
if (output->crtc) {
commit 9decf97be5f1aa5ae2001160fcc726236b398104
Author: Jerome Glisse <glisse@freedesktop.org>
Date: Fri Jun 22 16:41:04 2007 +0200
avivo: post randr 1.2 cleanup + always assignd LFP to TMDS2
diff --git a/include/avivo.h b/include/avivo.h
index 27ec0ab..44f217c 100644
--- a/include/avivo.h
+++ b/include/avivo.h
@@ -39,8 +39,8 @@
#include <pciaccess.h>
#endif
-#define AVIVO_NAME "Avivo"
-#define AVIVO_DRIVER_NAME "avivo"
+#define AVIVO_NAME "Avivo-v0.2.90"
+#define AVIVO_DRIVER_NAME "avivo-v0.2.90"
#define AVIVO_DRIVER_VERSION 1000
#define RADEON_VBIOS_SIZE 0x00010000
@@ -48,19 +48,6 @@
#define INREG(x) MMIO_IN32(avivo->ctrl_base, x)
#define OUTREG(x, y) MMIO_OUT32(avivo->ctrl_base, x, y)
-struct avivo_info;
-struct avivo_crtc {
- /* Bitmask of output IDs. */
- int id;
- int h_total, h_blank, h_sync_wid, h_sync_pol;
- int v_total, v_blank, v_sync_wid, v_sync_pol;
- int clock;
- unsigned long fb_offset;
- int fb_format, fb_length;
- int fb_pitch, fb_width, fb_height;
- struct avivo_crtc *next;
-};
-
struct avivo_crtc_private {
int crtc_number;
unsigned long crtc_offset;
@@ -74,48 +61,6 @@ struct avivo_crtc_private {
int fb_pitch, fb_width, fb_height;
};
-enum avivo_output_status {
- OUTPUT_ON,
- OUTPUT_BLANKED,
- OUTPUT_OFF,
-};
-
-enum avivo_output_type {
- OUTPUT_DAC,
- OUTPUT_TMDS,
- OUTPUT_LVDS,
- OUTPUT_TV,
-};
-
-enum avivo_connector_type {
- CONNECTOR_VGA,
- CONNECTOR_DVII,
- CONNECTOR_DVID,
- CONNECTOR_DVIA,
- CONNECTOR_STV,
- CONNECTOR_CTV,
- CONNECTOR_LVDS,
- CONNECTOR_DIGITAL,
- CONNECTOR_UNSUPPORTED,
-};
-
-/**
- * struct avivo_output - avivo output information structure
- * @is_enabled: is output enabled
- * @gpio_base: gpio base address register of this connector
- * @type: output type DAC, TMDS, LVDS, TV
- * @status: output status
- * @next: next output
- */
-struct avivo_output {
- struct avivo_crtc *crtc;
- int is_enabled;
- enum avivo_output_type type;
- enum avivo_output_status status;
- struct avivo_output *next;
-};
-
-
struct avivo_output_private {
xf86ConnectorType type;
I2CBusPtr i2c;
@@ -124,26 +69,6 @@ struct avivo_output_private {
char *name;
};
-/**
- * struct avivo_connector - avivo output connector information structure
- * @is_connected: is output connected
- * @connector_num: connector number
- * @gpio_base: gpio base address register of this connector
- * @type: connector type VGA, DVI-I, LVDS, STV, ...
- * @monitor: monitor information retrieven from DDC
- * @outputs: associated output
- * @next: next connector
- */
-struct avivo_connector {
- int is_connected;
- int connector_num;
- unsigned int gpio_base;
- enum avivo_connector_type type;
- xf86MonPtr monitor;
- struct avivo_output *outputs;
- struct avivo_connector *next;
-};
-
struct avivo_state
{
int mc_memory_map;
@@ -264,11 +189,6 @@ struct avivo_info
Bool (*close_screen)(int, ScreenPtr);
OptionInfoPtr options;
- I2CBusPtr i2c;
- unsigned int ddc_reg;
- struct avivo_crtc *crtcs;
- struct avivo_connector *connectors;
- struct avivo_connector *connector_default;
unsigned long cursor_offset;
int cursor_format, cursor_fg, cursor_bg;
int cursor_width, cursor_height;
diff --git a/xorg/avivo.c b/xorg/avivo.c
index a901b5c..f4dac5d 100644
--- a/xorg/avivo.c
+++ b/xorg/avivo.c
@@ -68,7 +68,6 @@ static Bool avivo_close_screen(int index, ScreenPtr screen);
static Bool avivo_save_screen(ScreenPtr screen, int mode);
static Bool avivo_switch_mode(int index, DisplayModePtr mode, int flags);
-static Bool avivo_set_mode(ScrnInfoPtr screen_info, DisplayModePtr mode);
static void avivo_adjust_frame(int index, int x, int y, int flags);
static void avivo_free_screen(int index, int flags);
static void avivo_free_info(ScrnInfoPtr screen_info);
@@ -333,12 +332,6 @@ avivo_old_probe(DriverPtr drv, int flags)
static void
avivo_free_info(ScrnInfoPtr screen_info)
{
-#if 0
- struct avivo_info *avivo = avivo_get_info(screen_info);
-
- xfree(screen_info->driverPrivate);
- screen_info->driverPrivate = NULL;
-#endif
}
/*
@@ -402,7 +395,6 @@ avivo_preinit(ScrnInfoPtr screen_info, int flags)
screen_info->chipset = "avivo";
screen_info->monitor = screen_info->confScreen->monitor;
-#ifdef AVIVO_RR12
if (!xf86SetDepthBpp(screen_info, 0, 0, 0, Support32bppFb))
return FALSE;
xf86PrintDepthBpp(screen_info);
@@ -440,57 +432,11 @@ avivo_preinit(ScrnInfoPtr screen_info, int flags)
xf86ProcessOptions(screen_info->scrnIndex, screen_info->options,
avivo->options);
-#if 0
- if (!avivo_output_setup(screen_info))
- return FALSE;
-#else
avivo_output_setup(screen_info);
-#endif
if (!xf86InitialConfiguration(screen_info, FALSE)) {
xf86DrvMsg(screen_info->scrnIndex, X_ERROR, "No valid modes.\n");
return FALSE;
}
-#if 0
- /* probe monitor found */
- monitor = NULL;
- config = XF86_CRTC_CONFIG_PTR(screen_info);
- for (i = 0; i < config->num_output; i++) {
- xf86OutputPtr output = config->output[i];
- struct avivo_output_private *avivo_output = output->driver_private;
- if (output->funcs->detect(output) == XF86OutputStatusConnected) {
- output->funcs->get_modes(output);
- monitor = output->MonInfo;
- xf86PrintEDID(monitor);
- }
- }
-
- if (monitor == NULL) {
- xf86DrvMsg(screen_info->scrnIndex, X_ERROR,
- "No monitor found.\n");
- return FALSE;
- }
- xf86SetDDCproperties(screen_info, monitor);
- /* validates mode */
- clock_ranges = xcalloc(sizeof(ClockRange), 1);
- if (clock_ranges == NULL) {
- xf86DrvMsg(screen_info->scrnIndex, X_ERROR,
- "Failed to allocate memory for clock range\n");
- return FALSE;
- }
- clock_ranges->minClock = 12000;
- clock_ranges->maxClock = 165000;
- clock_ranges->clockIndex = -1;
- clock_ranges->interlaceAllowed = FALSE;
- clock_ranges->doubleScanAllowed = FALSE;
- screen_info->progClock = TRUE;
- xf86ValidateModes(screen_info, screen_info->monitor->Modes,
- screen_info->display->modes, clock_ranges, 0, 320, 2048,
- 16 * screen_info->bitsPerPixel, 200, 2047,
- screen_info->display->virtualX,
- screen_info->display->virtualY,
- screen_info->videoRam, LOOKUP_BEST_REFRESH);
- xf86PruneDriverModes(screen_info);
-#endif
/* check if there modes available */
if (!xf86RandR12PreInit(screen_info)) {
xf86DrvMsg(screen_info->scrnIndex, X_ERROR,
@@ -502,86 +448,12 @@ avivo_preinit(ScrnInfoPtr screen_info, int flags)
return FALSE;
}
screen_info->currentMode = screen_info->modes;
-#else
- /* probe BIOS information */
- avivo_probe_info(screen_info);
- if (!xf86SetDepthBpp(screen_info, 0, 0, 0, Support32bppFb))
- return FALSE;
- xf86PrintDepthBpp(screen_info);
- switch (screen_info->depth) {
- case 16:
- avivo->bpp = 2;
- break;
- case 24:
- case 32:
- avivo->bpp = 4;
- break;
- default:
- FatalError("Unsupported screen depth: %d\n", xf86GetDepth());
- }
- /* color weight */
- if (!xf86SetWeight(screen_info, rzeros, rzeros))
- return FALSE;
- /* visual init */
- if (!xf86SetDefaultVisual(screen_info, -1))
- return FALSE;
- xf86SetGamma(screen_info, gzeros);
-#if 1
- avivo_probe_monitor(screen_info);
- if (avivo->connector_default && avivo->connector_default->monitor)
- xf86SetDDCproperties(screen_info,
- xf86PrintEDID(avivo->connector_default->monitor));
- else
- xf86DrvMsg(screen_info->scrnIndex, X_INFO,
- "EDID not found over DDC\n");
-#else
- avivo_i2c_init(screen_info);
- screen_info->monitor = screen_info->confScreen->monitor;
- monitor = avivo_ddc(screen_info);
- if (monitor)
- xf86SetDDCproperties(screen_info, xf86PrintEDID(monitor));
- else
- xf86DrvMsg(screen_info->scrnIndex, X_INFO,
- "EDID not found over DDC\n");
-#endif
- clock_ranges = xcalloc(sizeof(ClockRange), 1);
- clock_ranges->minClock = 12000;
- clock_ranges->maxClock = 165000;
- clock_ranges->clockIndex = -1;
- clock_ranges->interlaceAllowed = FALSE;
- clock_ranges->doubleScanAllowed = FALSE;
- screen_info->progClock = TRUE;
- xf86ValidateModes(screen_info, screen_info->monitor->Modes,
- screen_info->display->modes, clock_ranges, 0, 320, 2048,
- 16 * screen_info->bitsPerPixel, 200, 2047,
- screen_info->display->virtualX,
- screen_info->display->virtualY,
- screen_info->videoRam, LOOKUP_BEST_REFRESH);
- xf86PruneDriverModes(screen_info);
- xf86SetDpi(screen_info, 100, 100);
-
- if (screen_info->modes == NULL) {
- xf86DrvMsg(screen_info->scrnIndex, X_ERROR, "No modes available\n");
- return FALSE;
- }
- screen_info->currentMode = screen_info->modes;
-
- /* options */
- xf86CollectOptions(screen_info, NULL);
- avivo->options = xalloc(sizeof(avivo_options));
- if (avivo->options == NULL)
- return FALSE;
- memcpy(avivo->options, avivo_options, sizeof(avivo_options));
- xf86ProcessOptions(screen_info->scrnIndex, screen_info->options,
- avivo->options);
-#endif
#ifdef WITH_VGAHW
xf86LoadSubModule(screen_info, "vgahw");
vgaHWGetHWRec (screen_info);
vgaHWGetIOBase(VGAHWPTR(screen_info));
-
#endif
xf86DrvMsg(screen_info->scrnIndex, X_INFO, "[ScreenPreInit OK]\n");
@@ -726,7 +598,6 @@ avivo_screen_init(int index, ScreenPtr screen, int argc, char **argv)
fbPictureInit(screen, 0, 0);
xf86SetBlackWhitePixels(screen);
-#ifdef AVIVO_RR12
for (i = 0; i < xf86_config->num_crtc; i++) {
xf86CrtcPtr crtc = xf86_config->crtc[i];
/* Mark that we'll need to re-set the mode for sure */
@@ -746,24 +617,12 @@ avivo_screen_init(int index, ScreenPtr screen, int argc, char **argv)
return FALSE;
}
}
-#else
- /* set first video mode */
- if (!avivo_set_mode(screen_info, screen_info->currentMode))
- return FALSE;
-#endif
/* set the viewport */
avivo_adjust_frame(index, screen_info->frameX0, screen_info->frameY0, 0);
- xf86DPMSInit(screen, avivo_dpms, 0);
-
+ xf86DPMSInit(screen, xf86DPMSSet, 0);
miDCInitialize(screen, xf86GetPointerScreenFuncs());
-#ifdef AVIVO_RR12
-#else
- /* FIXME enormous hack ... */
- avivo->cursor_offset = screen_info->virtualX * screen_info->virtualY * 4;
- avivo_cursor_init(screen);
-#endif
if (!miCreateDefColormap(screen)) {
xf86DrvMsg(screen_info->scrnIndex, X_ERROR,
@@ -779,13 +638,11 @@ avivo_screen_init(int index, ScreenPtr screen, int argc, char **argv)
avivo->close_screen = screen->CloseScreen;
screen->CloseScreen = avivo_close_screen;
-#ifdef AVIVO_RR12
if (!xf86CrtcScreenInit(screen)) {
xf86DrvMsg(screen_info->scrnIndex, X_ERROR,
"Couldn't initialize crtc\n");
return FALSE;
}
-#endif
xf86DrvMsg(screen_info->scrnIndex, X_INFO, "[ScreenInit OK]\n");
return TRUE;
@@ -798,10 +655,9 @@ avivo_enter_vt(int index, int flags)
avivo_save_state(screen_info);
- if (!avivo_set_mode(screen_info, screen_info->currentMode))
+ screen_info->vtSema = TRUE;
+ if (!xf86SetDesiredModes(screen_info))
return FALSE;
-
- avivo_restore_cursor(screen_info);
avivo_adjust_frame(index, screen_info->frameX0, screen_info->frameY0, 0);
return TRUE;
@@ -812,251 +668,13 @@ avivo_leave_vt(int index, int flags)
{
ScrnInfoPtr screen_info = xf86Screens[index];
- avivo_save_cursor(screen_info);
avivo_restore_state(screen_info);
}
-static void
-avivo_enable_crtc(struct avivo_info *avivo, struct avivo_crtc *crtc,
- int enable)
-{
- int scan_enable, cntl;
-
- if (enable) {
- scan_enable = AVIVO_CRTC_SCAN_EN;
- cntl = 0x00010101;
- }
- else {
- scan_enable = 0;
- cntl = 0;
- }
-
- if (crtc->id == 0) {
- OUTREG(AVIVO_CRTC1_SCAN_ENABLE, scan_enable);
- OUTREG(AVIVO_CRTC1_CNTL, cntl);
- }
- else if (crtc->id == 1) {
- OUTREG(AVIVO_CRTC2_SCAN_ENABLE, scan_enable);
- OUTREG(AVIVO_CRTC2_CNTL, cntl);
- }
-
- avivo_wait_idle(avivo);
-}
-
-static void
-avivo_enable_output(struct avivo_info *avivo,
- struct avivo_connector *connector,
- struct avivo_output *output,
- struct avivo_crtc *crtc,
- int enable)
-{
- int value1, value2, value3, value4, value5;
-
- avivo_wait_idle(avivo);
- output->is_enabled = enable;
-
- if (output->type == OUTPUT_TMDS) {
- value3 = 0x10000011;
- value5 = 0x00001010;
-
- if (enable) {
- value1 = AVIVO_TMDS_MYSTERY1_EN;
- value2 = AVIVO_TMDS_MYSTERY2_EN;
- value4 = 0x00001f1f;
- if (connector->connector_num == 1)
- value4 |= 0x00000020;
- value5 |= AVIVO_TMDS_EN;
- }
- else {
- value1 = 0x04000000;
- value2 = 0;
- value4 = 0x00060000;
- }
-
- if (connector->connector_num == 0) {
- OUTREG(AVIVO_TMDS1_CRTC_SOURCE, crtc->id);
- OUTREG(AVIVO_TMDS1_MYSTERY1, value1);
- OUTREG(AVIVO_TMDS1_MYSTERY2, value2);
- OUTREG(AVIVO_TMDS1_MYSTERY3, value3);
- OUTREG(AVIVO_TMDS1_CLOCK_CNTL, value4);
- OUTREG(AVIVO_TMDS1_CNTL, value5);
- }
- else if (connector->connector_num == 1
- || connector->connector_num == 2) {
- OUTREG(AVIVO_TMDS2_CRTC_SOURCE, crtc->id);
- OUTREG(AVIVO_TMDS2_MYSTERY1, value1);
- OUTREG(AVIVO_TMDS2_MYSTERY2, value2);
- value3 |= 0x00630000;
- /* This needs to be set on TMDS, and unset on LVDS. */
- value3 |= INREG(AVIVO_TMDS2_MYSTERY3) & (1 << 29);
- OUTREG(AVIVO_TMDS2_MYSTERY3, value3);
- OUTREG(AVIVO_TMDS2_CLOCK_CNTL, value4);
- /* This needs to be set on LVDS, and unset on TMDS. Luckily, the
- * BIOS appears to set it up for us, so just carry it over. */
- value5 |= INREG(AVIVO_TMDS2_CNTL) & (1 << 24);
- OUTREG(AVIVO_TMDS2_CNTL, value5);
- }
- }
- else if (output->type == OUTPUT_DAC) {
- if (enable) {
- value1 = 0;
- value2 = 0;
- value3 = AVIVO_DAC_EN;
- }
- else {
- value1 = AVIVO_DAC_MYSTERY1_DIS;
- value2 = AVIVO_DAC_MYSTERY2_DIS;
- value3 = 0;
- }
-
- if (connector->connector_num == 0) {
- OUTREG(AVIVO_DAC1_CRTC_SOURCE, crtc->id);
- OUTREG(AVIVO_DAC1_MYSTERY1, value1);
- OUTREG(AVIVO_DAC1_MYSTERY2, value2);
- OUTREG(AVIVO_DAC1_CNTL, value3);
- }
- else if (connector->connector_num == 1) {
- OUTREG(AVIVO_DAC2_CRTC_SOURCE, crtc->id);
- OUTREG(AVIVO_DAC2_MYSTERY1, value1);
- OUTREG(AVIVO_DAC2_MYSTERY2, value2);
- OUTREG(AVIVO_DAC2_CNTL, value3);
- }
- }
-}
-
-static void
-avivo_set_pll(struct avivo_info *avivo, struct avivo_crtc *crtc)
-{
- int div, pdiv, pmul;
- int n_pdiv, n_pmul;
- int clock;
- int diff, n_diff;
-
- div = 1080000 / crtc->clock;
- pdiv = 2;
- pmul = floor(((40.0 * crtc->clock * pdiv * div) / 1080000.0) + 0.5);
- clock = (pmul * 1080000) / (40 * pdiv * div);
- diff = fabsl(clock - crtc->clock);
- while (1) {
- n_pdiv = pdiv + 1;
- n_pmul = floor(((40.0 * crtc->clock * n_pdiv * div) / 1080000.0) + 0.5);
- clock = (n_pmul * 1080000) / (40 * n_pdiv * div);
- n_diff = fabsl(clock - crtc->clock);
- if (n_diff >= diff)
- break;
- pdiv = n_pdiv;
- pmul = n_pmul;
- diff = n_diff;
- }
- clock = (pmul * 1080000) / (40 * pdiv * div);
- ErrorF("clock: %d requested: %d\n", clock, crtc->clock);
- ErrorF("pll: div %d, pmul 0x%X(%d), pdiv %d\n",
- div, pmul, pmul, pdiv);
-#if 0
- OUTREG(AVIVO_PLL_CNTL, 0);
- OUTREG(AVIVO_PLL_DIVIDER, div);
- OUTREG(AVIVO_PLL_DIVIDER_CNTL, AVIVO_PLL_EN);
- OUTREG(AVIVO_PLL_POST_DIV, pdiv);
- OUTREG(AVIVO_PLL_POST_MUL, (pmul << AVIVO_PLL_POST_MUL_SHIFT));
- OUTREG(AVIVO_PLL_CNTL, AVIVO_PLL_EN);
-#endif
-}
-
-static void
-avivo_crtc_enable(struct avivo_info *avivo, struct avivo_crtc *crtc, int on)
-{
- unsigned long fb_location = crtc->fb_offset + avivo->fb_addr;
-
- if (crtc->id == 0) {
- OUTREG(AVIVO_CRTC1_CNTL, 0);
-
- if (on) {
- /* Switch from text to graphics mode. */
- OUTREG(0x0330, 0x00010600);
- OUTREG(0x0338, 0x00000400);
-
- avivo_setup_cursor(avivo, 1, 1);
-
- OUTREG(AVIVO_CRTC1_FB_LOCATION, fb_location);
- OUTREG(AVIVO_CRTC1_FB_FORMAT, crtc->fb_format);
- OUTREG(AVIVO_CRTC1_FB_END, fb_location + crtc->fb_length);
- OUTREG(AVIVO_CRTC1_MODE, 0);
- OUTREG(AVIVO_CRTC1_60c0_MYSTERY, 0);
-
- avivo_set_pll(avivo, crtc);
-
- OUTREG(AVIVO_CRTC1_FB_HEIGHT, crtc->fb_height);
- OUTREG(AVIVO_CRTC1_EXPANSION_SOURCE, (crtc->fb_width << 16) |
- crtc->fb_height);
- OUTREG(AVIVO_CRTC1_EXPANSION_CNTL, AVIVO_CRTC_EXPANSION_EN);
-
- OUTREG(AVIVO_CRTC1_659C, AVIVO_CRTC1_659C_VALUE);
- OUTREG(AVIVO_CRTC1_65A8, AVIVO_CRTC1_65A8_VALUE);
- OUTREG(AVIVO_CRTC1_65AC, AVIVO_CRTC1_65AC_VALUE);
- OUTREG(AVIVO_CRTC1_65B8, AVIVO_CRTC1_65B8_VALUE);
- OUTREG(AVIVO_CRTC1_65BC, AVIVO_CRTC1_65BC_VALUE);
- OUTREG(AVIVO_CRTC1_65C8, AVIVO_CRTC1_65C8_VALUE);
- OUTREG(AVIVO_CRTC1_6594, AVIVO_CRTC1_6594_VALUE);
- OUTREG(AVIVO_CRTC1_65A4, AVIVO_CRTC1_65A4_VALUE);
- OUTREG(AVIVO_CRTC1_65B0, AVIVO_CRTC1_65B0_VALUE);
- OUTREG(AVIVO_CRTC1_65C0, AVIVO_CRTC1_65C0_VALUE);
-
- OUTREG(AVIVO_CRTC1_X_LENGTH, crtc->fb_width);
- OUTREG(AVIVO_CRTC1_Y_LENGTH, crtc->fb_height);
- OUTREG(AVIVO_CRTC1_PITCH, crtc->fb_pitch);
- OUTREG(AVIVO_CRTC1_H_TOTAL, crtc->h_total);
- OUTREG(AVIVO_CRTC1_H_BLANK, crtc->h_blank);
- OUTREG(AVIVO_CRTC1_H_SYNC_WID, crtc->h_sync_wid);
- OUTREG(AVIVO_CRTC1_H_SYNC_POL, crtc->h_sync_pol);
- OUTREG(AVIVO_CRTC1_V_TOTAL, crtc->v_total);
- OUTREG(AVIVO_CRTC1_V_BLANK, crtc->v_blank);
- OUTREG(AVIVO_CRTC1_V_SYNC_WID, crtc->v_sync_wid);
- OUTREG(AVIVO_CRTC1_V_SYNC_POL, crtc->v_sync_pol);
-
- OUTREG(AVIVO_CRTC1_CNTL, 0x00010101);
- OUTREG(AVIVO_CRTC1_SCAN_ENABLE, AVIVO_CRTC_SCAN_EN);
- }
- }
-}
-
-static void
-avivo_setup_crtc(struct avivo_info *avivo, struct avivo_crtc *crtc,
- DisplayModePtr mode)
-{
- ErrorF("mode: hdisp %d, htotal %d, hss %d, hse %d, hsk %d\n",
- mode->HDisplay, mode->HTotal, mode->HSyncStart, mode->HSyncEnd,
Reply to: