xserver-xorg-video-avivo: Changes to 'upstream-experimental'

2007-09-27 Thread Brice Goglin
 avivotool/avivotool.c   |  192 +++-
 configure.ac|   22 +
 include/Makefile.am |1 
 include/avivo.h |7 
 include/avivo_chipset.h |  189 
 include/radeon_reg.h|  251 -
 xorg/avivo.c|  100 +++-
 xorg/avivo_bios.c   |2 
 xorg/avivo_chipset.c|  562 
 xorg/avivo_common.c |1 
 xorg/avivo_crtc.c   |   15 -
 xorg/avivo_cursor.c |2 
 xorg/avivo_output.c |  379 +++-
 xorg/avivo_state.c  |   82 +++
 14 files changed, 1055 insertions(+), 750 deletions(-)

New commits:
commit be7d380aba8d1ff2272bf2c931b2c9f78a549b46
Author: Matthew Garrett [EMAIL PROTECTED]
Date:   Sat Sep 15 00:46:47 2007 +0100

Minor include file cleanup

diff --git a/include/radeon_reg.h b/include/radeon_reg.h
index 5363fd9..c34fb92 100644
--- a/include/radeon_reg.h
+++ b/include/radeon_reg.h
@@ -3408,7 +3408,7 @@
 #define AVIVO_TMDSA_DCBALANCER_CONTROL  0x78d0
 #   define AVIVO_TMDSA_DCBALANCER_CONTROL_EN  (1  0)
 #   define AVIVO_TMDSA_DCBALANCER_CONTROL_TEST_EN (1  8)
-#   define AVIVO_TMDSA_DCBALANCER_CONTROL_TEST_IN (16)
+#   define AVIVO_TMDSA_DCBALANCER_CONTROL_TEST_IN_SHIFT   (16)
 #   define AVIVO_TMDSA_DCBALANCER_CONTROL_FORCE   (1  24)
 #define AVIVO_TMDSA_DATA_SYNCHRONIZATION0x78d8
 #   define AVIVO_TMDSA_DATA_SYNCHRONIZATION_DSYNSEL   (1  0)
@@ -3437,7 +3437,7 @@
 #define AVIVO_TMDSA_TRANSMITTER_CONTROL0x7910
 #  define AVIVO_TMDSA_TRANSMITTER_CONTROL_PLL_ENABLE   (1  0)
 #  define AVIVO_TMDSA_TRANSMITTER_CONTROL_PLL_RESET(1  1)
-#  define AVIVO_TMDSA_TRANSMITTER_CONTROL_PLL_HPD_MASK (2)
+#  define AVIVO_TMDSA_TRANSMITTER_CONTROL_PLL_HPD_MASK_SHIFT   (2)
 #  define AVIVO_TMDSA_TRANSMITTER_CONTROL_IDSCKSEL (1  4)
 #   define AVIVO_TMDSA_TRANSMITTER_CONTROL_BGSLEEP  (1  5)
 #  define AVIVO_TMDSA_TRANSMITTER_CONTROL_PLL_PWRUP_SEQ_EN (1  6)
@@ -3445,13 +3445,12 @@
 #  define AVIVO_TMDSA_TRANSMITTER_CONTROL_TMCLK_FROM_PADS  (1  13)
 #  define AVIVO_TMDSA_TRANSMITTER_CONTROL_TDCLK(1  14)
 #  define AVIVO_TMDSA_TRANSMITTER_CONTROL_TDCLK_FROM_PADS  (1  15)
-#   define AVIVO_TMDSA_TRANSMITTER_CONTROL_CLK_PATTERN  (16)
+#   define AVIVO_TMDSA_TRANSMITTER_CONTROL_CLK_PATTERN_SHIFT (16)
 #  define AVIVO_TMDSA_TRANSMITTER_CONTROL_BYPASS_PLL   (1  28)
 #   define AVIVO_TMDSA_TRANSMITTER_CONTROL_USE_CLK_DATA (1  29)
 #  define AVIVO_TMDSA_TRANSMITTER_CONTROL_INPUT_TEST_CLK_SEL   (1  
31)
 
 #define AVIVO_LVTMA_CNTL   0x7a80
-#define AVIVO_TMDSA_CNTL0x7880
 #   define AVIVO_LVTMA_CNTL_ENABLE   (1  0)
 #   define AVIVO_LVTMA_CNTL_HPD_MASK (1  4)
 #   define AVIVO_LVTMA_CNTL_HPD_SELECT   (1  8)
@@ -3473,7 +3472,7 @@
 #define AVIVO_LVTMA_DCBALANCER_CONTROL  0x7ad0
 #   define AVIVO_LVTMA_DCBALANCER_CONTROL_EN  (1  0)
 #   define AVIVO_LVTMA_DCBALANCER_CONTROL_TEST_EN (1  8)
-#   define AVIVO_LVTMA_DCBALANCER_CONTROL_TEST_IN (16)
+#   define AVIVO_LVTMA_DCBALANCER_CONTROL_TEST_IN_SHIFT   (16)
 #   define AVIVO_LVTMA_DCBALANCER_CONTROL_FORCE   (1  24)
 
 #define AVIVO_LVTMA_DATA_SYNCHRONIZATION0x78d8
@@ -3495,20 +3494,20 @@
 #   define AVIVO_LVTMA_TRANSMITTER_ENABLE_LNKDEN_HPD_MASK (1  18)
 
 #define AVIVO_LVTMA_TRANSMITTER_CONTROL0x7b10
-#  define AVIVO_LVTMA_TRANSMITTER_CONTROL_PLL_ENABLE   (1  0)
-#  define AVIVO_LVTMA_TRANSMITTER_CONTROL_PLL_RESET(1  1)
-#  define AVIVO_LVTMA_TRANSMITTER_CONTROL_PLL_HPD_MASK (2)
-#  define AVIVO_LVTMA_TRANSMITTER_CONTROL_IDSCKSEL (1  4)
-#   define AVIVO_LVTMA_TRANSMITTER_CONTROL_BGSLEEP  (1  5)
-#  define AVIVO_LVTMA_TRANSMITTER_CONTROL_PLL_PWRUP_SEQ_EN (1  6)
-#  define AVIVO_LVTMA_TRANSMITTER_CONTROL_TMCLK(1  8)
-#  define AVIVO_LVTMA_TRANSMITTER_CONTROL_TMCLK_FROM_PADS  (1  13)
-#  define AVIVO_LVTMA_TRANSMITTER_CONTROL_TDCLK(1  14)
-#  define AVIVO_LVTMA_TRANSMITTER_CONTROL_TDCLK_FROM_PADS  (1  15)
-#   define AVIVO_LVTMA_TRANSMITTER_CONTROL_CLK_PATTERN  (16)
-#  define AVIVO_LVTMA_TRANSMITTER_CONTROL_BYPASS_PLL   (1  28)
-#   define AVIVO_LVTMA_TRANSMITTER_CONTROL_USE_CLK_DATA (1  29)
-#  define AVIVO_LVTMA_TRANSMITTER_CONTROL_INPUT_TEST_CLK_SEL   (1  
31)
+#  define AVIVO_LVTMA_TRANSMITTER_CONTROL_PLL_ENABLE (1  0)
+#  define AVIVO_LVTMA_TRANSMITTER_CONTROL_PLL_RESET  (1  1)
+#  define AVIVO_LVTMA_TRANSMITTER_CONTROL_PLL_HPD_MASK_SHIFT (2)
+#  define 

xserver-xorg-video-avivo: Changes to 'upstream-experimental'

2007-08-05 Thread Brice Goglin
 avivotool/avivotool.c   |  144 +++--
 include/avivo.h |   52 
 include/avivo_chipset.h |   93 
 include/radeon_reg.h|   21 +
 xorg/Makefile.am|   20 +
 xorg/avivo.c|  268 +
 xorg/avivo_bios.c   |   87 ++--
 xorg/avivo_chipset.c|  511 
 xorg/avivo_common.c |4 
 xorg/avivo_crtc.c   |  194 --
 xorg/avivo_i2c.c|   56 +
 xorg/avivo_memory.c |   74 ++
 xorg/avivo_output.c |  316 ++---
 xorg/avivo_output_lfp.c |   76 +++
 xorg/avivo_state.c  |6 
 15 files changed, 1637 insertions(+), 285 deletions(-)

New commits:
commit 7800016506da80b09a94279d17c0675b40791db0
Author: Jerome Glisse [EMAIL PROTECTED]
Date:   Tue Jul 24 15:38:03 2007 +0200

avivo: rework output dpms handling.

This should have better behavior when dpms status change
is triggered.

diff --git a/include/avivo.h b/include/avivo.h
index 4b39b2e..5e644ed 100644
--- a/include/avivo.h
+++ b/include/avivo.h
@@ -73,6 +73,8 @@ struct avivo_output_private {
 unsigned long output_offset;
 int   number;
 char  *name;
+void (*setup)(xf86OutputPtr output);
+void (*dpms)(xf86OutputPtr output, int mode);
 };
 
 struct avivo_state
diff --git a/include/radeon_reg.h b/include/radeon_reg.h
index 5dc370e..6ef9fd2 100644
--- a/include/radeon_reg.h
+++ b/include/radeon_reg.h
@@ -3383,7 +3383,8 @@
 #define AVIVO_TMDS2_MYSTERY3   0x7b10
 
 #define AVIVO_LVDS_CNTL0x7af0
-#  define AVIVO_LVDS_EN((1  
0) | (1  4))
+#  define AVIVO_LVDS_EN((1  4))
+#  define AVIVO_LVDS_MYSTERY   ((1  
0) | (1  2) | (1  3))
 #define AVIVO_LVDS_BACKLIGHT_CNTL  0x7af8
 #  define AVIVO_LVDS_BACKLIGHT_CNTL_EN (1  0)
 #  define AVIVO_LVDS_BACKLIGHT_LEVEL_MASK  0xff00
diff --git a/xorg/avivo_crtc.c b/xorg/avivo_crtc.c
index 7dfae82..f48790e 100644
--- a/xorg/avivo_crtc.c
+++ b/xorg/avivo_crtc.c
@@ -172,6 +172,7 @@ avivo_crtc_set_pll(xf86CrtcPtr crtc, DisplayModePtr mode)
 }
 OUTREG(AVIVO_CRTC_PLL_SOURCE, (0  AVIVO_CRTC1_PLL_SOURCE_SHIFT)  
   | (1  AVIVO_CRTC2_PLL_SOURCE_SHIFT));
+OUTREG(0x454, INREG(0x454) | 0x2);
 avivo_wait_idle(avivo);
 }
 
diff --git a/xorg/avivo_output.c b/xorg/avivo_output.c
index 3406805..84b7489 100644
--- a/xorg/avivo_output.c
+++ b/xorg/avivo_output.c
@@ -28,11 +28,233 @@
 /* DPMS */
 #define DPMS_SERVER
 #include X11/extensions/dpms.h
+#include unistd.h
 
 #include avivo.h
 #include radeon_reg.h
 
+static void
+avivo_output_dac1_setup(xf86OutputPtr output)
+{
+struct avivo_output_private *avivo_output = output-driver_private;
+struct avivo_info *avivo = avivo_get_info(output-scrn);
+
+if (output-crtc) {
+struct avivo_crtc_private *avivo_crtc = output-crtc-driver_private;
+
+xf86DrvMsg(output-scrn-scrnIndex, X_INFO,
+   (DAC1) %s connector associated to crtc(%d)\n,
+   xf86ConnectorGetName(avivo_output-type),
+   avivo_crtc-crtc_number);
+OUTREG(AVIVO_DAC1_CRTC_SOURCE, avivo_crtc-crtc_number);
+}
+OUTREG(AVIVO_DAC1_MYSTERY1, 0);
+OUTREG(AVIVO_DAC1_MYSTERY2, 0);
+OUTREG(AVIVO_DAC1_CNTL, AVIVO_DAC_EN);
+}
+
+static void
+avivo_output_dac2_setup(xf86OutputPtr output)
+{
+struct avivo_output_private *avivo_output = output-driver_private;
+struct avivo_info *avivo = avivo_get_info(output-scrn);
+
+if (output-crtc) {
+struct avivo_crtc_private *avivo_crtc = output-crtc-driver_private;
+
+xf86DrvMsg(output-scrn-scrnIndex, X_INFO,
+   (DAC2) %s connector associated to crtc(%d)\n,
+   xf86ConnectorGetName(avivo_output-type),
+   avivo_crtc-crtc_number);
+OUTREG(AVIVO_DAC2_CRTC_SOURCE, avivo_crtc-crtc_number);
+}
+OUTREG(AVIVO_DAC2_MYSTERY1, 0);
+OUTREG(AVIVO_DAC2_MYSTERY2, 0);
+OUTREG(AVIVO_DAC2_CNTL, AVIVO_DAC_EN);
+}
+
+static void
+avivo_output_tmds1_setup(xf86OutputPtr output)
+{
+struct avivo_output_private *avivo_output = output-driver_private;
+struct avivo_info *avivo = avivo_get_info(output-scrn);
+
+if (output-crtc) {
+struct avivo_crtc_private *avivo_crtc = output-crtc-driver_private;
+
+xf86DrvMsg(output-scrn-scrnIndex, X_INFO,
+   (TMDS1) %s connector associated to crtc(%d)\n,
+   xf86ConnectorGetName(avivo_output-type),
+   avivo_crtc-crtc_number);
+OUTREG(AVIVO_TMDS1_CRTC_SOURCE, avivo_crtc-crtc_number);
+}
+OUTREG(AVIVO_TMDS1_MYSTERY1, AVIVO_TMDS_MYSTERY1_EN);
+

xserver-xorg-video-avivo: Changes to 'upstream-experimental'

2007-07-06 Thread Julien Cristau
 avivotool/avivotool.c |4 ++--
 avivotool/xf86i2c.c   |1 +
 configure.ac  |4 ++--
 include/avivo.h   |   47 ---
 xorg/avivo.c  |   34 ++
 xorg/avivo_bios.c |4 +++-
 xorg/avivo_common.c   |   44 ++--
 xorg/avivo_output.c   |   19 ++-
 xorg/avivo_state.c|6 +++---
 9 files changed, 89 insertions(+), 74 deletions(-)

New commits:
commit 8b28e959792caa4994d44b2c08780a06abe23571
Author: Jerome Glisse [EMAIL PROTECTED]
Date:   Mon Jul 2 20:09:29 2007 +0200

avivo: properly set version and bump version to 0.0.999.

diff --git a/configure.ac b/configure.ac
index 6673ba0..b193b73 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,7 +22,7 @@
 
 AC_PREREQ(2.57)
 AC_INIT([xf86-video-avivo],
-0.0.1,
+0.0.999,
 [http://home.fooishbar.org/wiki/Avivo],
 xf86-video-avivo)
 
diff --git a/include/avivo.h b/include/avivo.h
index e74de92..13d5bed 100644
--- a/include/avivo.h
+++ b/include/avivo.h
@@ -39,9 +39,12 @@
 #include pciaccess.h
 #endif
 
-#define AVIVO_NAME  Avivo-v0.2.90
-#define AVIVO_DRIVER_NAME   avivo-v0.2.90
-#define AVIVO_DRIVER_VERSION1000
+#define AVIVO_NAME  avivo
+#define AVIVO_DRIVER_NAME   avivo
+#define AVIVO_DRIVER_VERSION \
+((PACKAGE_VERSION_MAJOR  20) | \
+ (PACKAGE_VERSION_MINOR  10) | \
+ (PACKAGE_VERSION_PATCHLEVEL))
 
 #define RADEON_VBIOS_SIZE 0x0001
 
diff --git a/xorg/avivo.c b/xorg/avivo.c
index 2127e9d..2e69d46 100644
--- a/xorg/avivo.c
+++ b/xorg/avivo.c
@@ -239,8 +239,8 @@ avivo_identify(int flags)
 void fill_in_screen(ScrnInfoPtr screen_info)
 {
 screen_info-driverVersion = AVIVO_DRIVER_VERSION;
-screen_info-driverName = avivo;
-screen_info-name = Avivo;
+screen_info-driverName = AVIVO_DRIVER_NAME;
+screen_info-name = AVIVO_NAME;
 screen_info-Probe = avivo_old_probe;
 screen_info-PreInit = avivo_preinit;
 screen_info-ScreenInit = avivo_screen_init;

commit 8a6fb613d6f18d33aef84460fac0fe59bc00f729
Author: Jerome Glisse [EMAIL PROTECTED]
Date:   Mon Jul 2 19:50:23 2007 +0200

avivo: code cleanup.

diff --git a/configure.ac b/configure.ac
index c8e1f29..6673ba0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -58,7 +58,7 @@ PKG_CHECK_MODULES(XORG, xorg-server = 1.2.99.901 xproto 
$REQUIRED_MODULES)
 sdkdir=$(pkg-config --variable=sdkdir xorg-server)
 PKG_CHECK_MODULES([PCIACCESS], [pciaccess = 0.7.0])
 
-CFLAGS=$CFLAGS $XORG_CFLAGS 
+CFLAGS=$CFLAGS $XORG_CFLAGS -Wall
 INCLUDES=$XORG_INCS -I${sdkdir} '-I$(top_srcdir)/include'
 AC_SUBST([CFLAGS])
 AC_SUBST([INCLUDES])
diff --git a/include/avivo.h b/include/avivo.h
index da54946..e74de92 100644
--- a/include/avivo.h
+++ b/include/avivo.h
@@ -39,8 +39,8 @@
 #include pciaccess.h
 #endif
 
-#define AVIVO_NAME Avivo-v0.2.90
-#define AVIVO_DRIVER_NAME  avivo-v0.2.90
+#define AVIVO_NAME  Avivo-v0.2.90
+#define AVIVO_DRIVER_NAME   avivo-v0.2.90
 #define AVIVO_DRIVER_VERSION1000
 
 #define RADEON_VBIOS_SIZE 0x0001
@@ -195,8 +195,6 @@ struct avivo_info
 INT16 cursor_x, cursor_y;
 };
 
-int avivo_probe_info(ScrnInfoPtr screen_info);
-
 /*
  * avivo chipset
  */
@@ -205,27 +203,29 @@ void avivo_get_chipset(struct avivo_info *avivo);
 /*
  * avivo common functions
  */
-void radeon_set_indexed(ScrnInfoPtr screen_info,
-unsigned int index_offset,
-unsigned int data_offset,
-unsigned int offset,
-unsigned int value);
-unsigned int radeon_get_indexed(ScrnInfoPtr screen_info,
-unsigned int index_offset,
-unsigned int data_offset,
-unsigned int offset);
-unsigned int radeon_get_mc(ScrnInfoPtr screen_info, unsigned int offset);
-void radeon_set_mc(ScrnInfoPtr screen_info,
-   unsigned int offset,
-   unsigned int value);
+void avivo_set_indexed(ScrnInfoPtr screen_info,
+   unsigned int index_offset,
+   unsigned int data_offset,
+   unsigned int offset,
+   unsigned int value);
+unsigned int avivo_get_indexed(ScrnInfoPtr screen_info,
+   unsigned int index_offset,
+   unsigned int data_offset,
+   unsigned int offset);
+unsigned int avivo_get_mc(ScrnInfoPtr screen_info, unsigned int offset);
+void avivo_set_mc(ScrnInfoPtr screen_info,
+  unsigned int offset,
+  unsigned int value);
 struct avivo_info *avivo_get_info(ScrnInfoPtr screen_info);
 
-
 /*
  * avivo state handling
  */
+void avivo_wait_idle(struct avivo_info *avivo);
 void avivo_restore_state(ScrnInfoPtr screen_info);
 void avivo_save_state(ScrnInfoPtr screen_info);
+void 

xserver-xorg-video-avivo: Changes to 'upstream-experimental'

2007-07-01 Thread Julien Cristau
 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 [EMAIL PROTECTED]
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 [EMAIL PROTECTED]
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  108 / 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 = 108 / adjusted_clock;
-pdiv = 2;
-pmul = floor(((40.0 * adjusted_clock * pdiv * div) / 108.0) + 0.5);
+div = 8;
+pdiv = 6;
+pmul = floor(((40.0 * adjusted_clock * pdiv * div)
+ / 108.0) + 0.5);
 clock = (pmul * 108) / (40 * pdiv * div);
 diff = clock - adjusted_clock;
 while (1) {
-n_pdiv = pdiv + 1;
-n_pmul = floor(((40.0 * adjusted_clock * n_pdiv * div) / 108.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) / 108.0)
+ 0.5);
-clock = (n_pmul * 108) / (40 * n_pdiv * div);
+clock = (n_pmul * 108) / (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 [EMAIL PROTECTED]
Date:   Wed Jun 27 

xserver-xorg-video-avivo: Changes to 'upstream-experimental'

2007-06-14 Thread Julien Cristau
 include/avivo.h |   37 --
 xorg/Makefile.am|2 
 xorg/avivo.c|  156 ---
 xorg/avivo_bios.c   |   75 +
 xorg/avivo_crtc.c   |  200 ---
 xorg/avivo_cursor.c |2 
 xorg/avivo_output.c |  296 
 xorg/avivo_state.c  |4 
 8 files changed, 683 insertions(+), 89 deletions(-)

New commits:
commit 52e78cf2d65b33ab23a6bea22caf6da68fa77768
Author: Jerome Glisse [EMAIL PROTECTED]
Date:   Thu Jun 14 21:07:14 2007 +0200

avivo: randr1.2: initial support, not working enable with AVIVO_RR12

For some reason the server is not calling in driver crtc function
to set video mode thus launching with it will end up in a broken
display. This why this is disabled by default. Also randr 1.2 still
need work on rotation, allocating framebuffer, shadow buffer for
rotation, ...

diff --git a/include/avivo.h b/include/avivo.h
index ac136c0..e83e2b8 100644
--- a/include/avivo.h
+++ b/include/avivo.h
@@ -139,6 +139,7 @@ struct avivo_output_private {
 I2CBusPtr i2c;
 unsigned long output_offset;
 int   number;
+char  *name;
 };
 
 /**
diff --git a/xorg/Makefile.am b/xorg/Makefile.am
index 89c8dad..1a59543 100644
--- a/xorg/Makefile.am
+++ b/xorg/Makefile.am
@@ -33,5 +33,7 @@ avivo_drv_la_SOURCES = \
 avivo_state.c \
  avivo_bios.c \
 avivo_cursor.c \
+avivo_crtc.c \
+avivo_output.c \
 avivo_i2c.c \
  avivo.c
diff --git a/xorg/avivo.c b/xorg/avivo.c
index 9986ee9..4672ea4 100644
--- a/xorg/avivo.c
+++ b/xorg/avivo.c
@@ -409,6 +409,7 @@ avivo_get_chipset(struct avivo_info *avivo)
 static Bool
 avivo_preinit(ScrnInfoPtr screen_info, int flags)
 {
+xf86CrtcConfigPtr config;
 struct avivo_info *avivo;
 DisplayModePtr mode;
 ClockRangePtr clock_ranges;
@@ -461,7 +462,7 @@ avivo_preinit(ScrnInfoPtr screen_info, int flags)
 avivo_get_chipset(avivo);
 screen_info-chipset = avivo;
 screen_info-monitor = screen_info-confScreen-monitor;
-/* setup depth */
+
 if (!xf86SetDepthBpp(screen_info, 0, 0, 0, Support32bppFb))
 return FALSE;
 xf86PrintDepthBpp(screen_info);
@@ -476,10 +477,73 @@ avivo_preinit(ScrnInfoPtr screen_info, int flags)
 default:
 FatalError(Unsupported screen depth: %d\n, xf86GetDepth());
 }
-
-
+#if AVIVO_RR12
+if (!avivo_crtc_create(screen_info))
+return FALSE;
+#if 0
+if (!avivo_output_setup(screen_info))
+return FALSE;
+#else
+avivo_output_setup(screen_info);
+#endif
+/* color weight */
+if (!xf86SetWeight(screen_info, rzeros, rzeros))
+return FALSE;
+/* visual init */
+if (!xf86SetDefaultVisual(screen_info, -1))
+return FALSE;
+/* TODO: gamma correction */
+xf86SetGamma(screen_info, gzeros);
+/* Set display resolution */
+xf86SetDpi(screen_info, 100, 100);
+/* 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);
+/* check if there modes available */
+if (screen_info-modes == NULL) {
+xf86DrvMsg(screen_info-scrnIndex, X_ERROR, No modes available\n);
+return FALSE;
+}
+screen_info-currentMode = screen_info-modes;
+#else
 /* probe BIOS information */
 avivo_probe_info(screen_info);
+
 /* color weight */
 if (!xf86SetWeight(screen_info, rzeros, rzeros))

xserver-xorg-video-avivo: Changes to 'upstream-experimental'

2007-06-13 Thread Julien Cristau
New branch 'upstream-experimental' available with the following commits:
commit 23730b5c0988627f0a0bb6f948a35dfb3ec1b47c
Author: Jerome Glisse [EMAIL PROTECTED]
Date:   Wed Jun 13 23:57:25 2007 +0200

avivo: randr 1.2 support undergoing work (not compiled in yet)

commit 4ce363f2a81fecf78c22cc9fa412aa877728adf8
Author: Jerome Glisse [EMAIL PROTECTED]
Date:   Wed Jun 13 21:35:08 2007 +0200

avivo: (cleanup) kill blank line.

commit 5333773aff456ef8e07d8f5fdc480f97cc051cef
Author: Jerome Glisse [EMAIL PROTECTED]
Date:   Wed Jun 13 21:33:51 2007 +0200

avivo: move common avivo function in their own file (cleanup for randr 1.2)

commit 35015f19755266ee942ec2cbd6d13d7014badc19
Author: Jerome Glisse [EMAIL PROTECTED]
Date:   Wed Jun 13 21:27:12 2007 +0200

avivo: Move state saving in their own file (cleanup for randr 1.2)

commit b9d183813ca811d9a9cbf303331f60227843116d
Author: Jerome Glisse [EMAIL PROTECTED]
Date:   Wed Jun 13 21:18:38 2007 +0200

avivo: move cursor functions in their own file (cleanup for randr 1.2).

commit 1b48bb7378d0b86894faf1973558029b2cff5a3e
Author: Oliver McFadden [EMAIL PROTECTED]
Date:   Wed Jun 13 04:37:41 2007 +

avivo: Added 71c2 PCI ID; for Sapphire X1600 Pro HDMI.

commit 36537c19a0f6fc74e79fdbf2a1bbc2185f6a0db3
Author: Oliver McFadden [EMAIL PROTECTED]
Date:   Wed Jun 13 04:37:02 2007 +

avivotool: asm/page.h is deprecated.

commit d277c9f4c0e7fb325f85a17e07bb503314958d65
Author: Jerome Glisse [EMAIL PROTECTED]
Date:   Tue Jun 12 19:39:08 2007 +0200

avivo: Include stdint needed in avivo_i2c

commit 1e9fc429a8d81f1b040611bc9d5add9b53e94310
Author: Jerome Glisse [EMAIL PROTECTED]
Date:   Sun Jun 10 01:24:09 2007 +0200

avivo: Cleanup code a bit and use i2c bitbanging to select default output.

Do a ddc on each connector found in bios table and select
one with a monitor attached to it, if there is an lvds
output than it's the default one.

commit 255fad8d3e1d232404942e96bffbc16cff26add8
Author: Jerome Glisse [EMAIL PROTECTED]
Date:   Thu May 10 23:57:40 2007 +0200

avivo: Minor cleanup avoiding to print useless information.

commit 245dc3b76b5bc3b1213a62fa5b208d783aaccd58
Author: Jerome Glisse [EMAIL PROTECTED]
Date:   Thu May 10 23:57:02 2007 +0200

avivo: Fix gpu vram mapping.

Off course i did obviously setup memory mapping in
the wrong place, shame on me. Now this should work
smoothly.

commit 2a773916624aba3e8be07123a1f4d8450f731577
Author: Jerome Glisse [EMAIL PROTECTED]
Date:   Thu May 10 23:48:42 2007 +0200

avivo: Add gpu memory mapping setup.

You can setup where gpu sees vram, i basicly set it
to pci address (like a post from the bios should do).
This however doesn't seems to work yet properly after
newer fglrx run, even thought all involved regs are
know as i can fix the situation by setting register
myself.

commit 04b6bd487efa8baff3fe7242f6621dce8c29a42a
Author: Jerome Glisse [EMAIL PROTECTED]
Date:   Wed May 9 22:25:01 2007 +0200

avivo: Fix comment about pll i did give wrong computation instruction.

commit 299844522b118bc80f5efd2f23b6e4bcfe1d5e73
Author: Jerome Glisse [EMAIL PROTECTED]
Date:   Thu May 3 23:29:59 2007 +0200

avivo: Improve i2c handling.

We stop waiting after 3 NACK because this likely mean
that there is no one to speak with on this connector
or bus :).

Also added reset flags to i2c control register. So we
properly close and shutdown i2c bus.

commit a6a3eea833fa3c6b9b344df3b1ddda44e87f36bb
Author: Jerome Glisse [EMAIL PROTECTED]
Date:   Thu May 3 21:16:40 2007 +0200

avivo: Add some regs mostly mirror crtc1 regs for crtc2.

Small cleanup and add same regs for crtc2 as for crtc1.

commit 4840ddc3f6369f338b1cc85c9e8315cc04fb8f3c
Author: Jerome Glisse [EMAIL PROTECTED]
Date:   Thu May 3 20:46:32 2007 +0200

avivo: Avoid restoring crtc sync width register.

crtc sync width register shouldn't be zero when going
back to text mode otherwise we i don't get any things
on screen here with rv515.

commit 8f4d756a3bb3d70183ac1978e14ef4723963e630
Author: Jerome Glisse [EMAIL PROTECTED]
Date:   Thu May 3 20:45:13 2007 +0200

avivo: registers cleanup.

commit 1899f2556d99d6b81e1443f87318ad64b3ac85fc
Author: Jerome Glisse [EMAIL PROTECTED]
Date:   Thu May 3 19:35:04 2007 +0200

avivo: remove PLL mystery regs as they are useless for cold card init.

This 2 mysterys regs doesn't seems to be important on rv515
at least.

commit 01c4ce02936f4a81d450f80fe084af49d629f2db
Author: Jerome Glisse [EMAIL PROTECTED]
Date:   Thu May 3 19:21:52 2007 +0200

avivo: Forgot the divider cntl in previous commit.

commit e421892c764ad2737c7b27513351006d95a40539
Author: Jerome Glisse [EMAIL PROTECTED]
Date:   Thu May 3 17:53:19 2007 +0200

avivo: Add pll register which need to be initialized on rv515.

The two pll register need to be set on rv515 as they
aren't