From 9f0acf1eb01ad8320f4da4cc5e498af25c0ecc5e Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 1 Feb 2007 15:44:18 -0800 Subject: [PATCH 01/29] Check for rotation change in xf86RandR12CrtcSet. xf86RandRCrtcSet was ignoring changes to only rotation, so the screen would be left incorrectly rotated. --- src/i830_randr.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/i830_randr.c b/src/i830_randr.c index 5eccf4bd..811fc50e 100644 --- a/src/i830_randr.c +++ b/src/i830_randr.c @@ -608,6 +608,9 @@ xf86RandR12CrtcSet (ScreenPtr pScreen, else if (mode && !xf86ModesEqual (&crtc->mode, mode)) changed = TRUE; + if (rotation != crtc->rotation) + changed = TRUE; + if (x != crtc->x || y != crtc->y) changed = TRUE; for (o = 0; o < config->num_output; o++) From 16f30b2e6c72e228c66946ff9efadd7278379745 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 1 Feb 2007 21:30:19 -0800 Subject: [PATCH 02/29] Add "Ignore" option to per-output monitor, removes output from server. Setting option "Ignore" "Yes" will cause the server to pretend as if the specified output does not exist at all. It will not be listed by the RandR1.2 extension, and the server will not attempt to detect monitors at startup time. --- src/i830_sdvo.c | 3 +-- src/i830_xf86Crtc.c | 48 ++++++++++++++++++++++++++++++++++++--------- 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/src/i830_sdvo.c b/src/i830_sdvo.c index ea62ad96..46a35f1c 100644 --- a/src/i830_sdvo.c +++ b/src/i830_sdvo.c @@ -1079,8 +1079,7 @@ i830_sdvo_init(ScrnInfoPtr pScrn, int output_device) char *name_prefix; char *name_suffix; - output = xf86OutputCreate (pScrn, &i830_sdvo_output_funcs, - "ADD2 PCIE card"); + output = xf86OutputCreate (pScrn, &i830_sdvo_output_funcs,NULL); if (!output) return; intel_output = xnfcalloc (sizeof (I830OutputPrivateRec) + diff --git a/src/i830_xf86Crtc.c b/src/i830_xf86Crtc.c index a2099149..0ea0cedd 100644 --- a/src/i830_xf86Crtc.c +++ b/src/i830_xf86Crtc.c @@ -273,6 +273,7 @@ typedef enum { OPTION_DISABLE, OPTION_MIN_CLOCK, OPTION_MAX_CLOCK, + OPTION_IGNORE, } OutputOpts; static OptionInfoRec xf86OutputOptions[] = { @@ -286,6 +287,7 @@ static OptionInfoRec xf86OutputOptions[] = { {OPTION_DISABLE, "Disable", OPTV_BOOLEAN, {0}, FALSE }, {OPTION_MIN_CLOCK, "MinClock", OPTV_FREQ, {0}, FALSE }, {OPTION_MAX_CLOCK, "MaxClock", OPTV_FREQ, {0}, FALSE }, + {OPTION_IGNORE, "Ignore", OPTV_BOOLEAN, {0}, FALSE }, {-1, NULL, OPTV_NONE, {0}, FALSE }, }; @@ -296,6 +298,9 @@ xf86OutputSetMonitor (xf86OutputPtr output) static const char monitor_prefix[] = "monitor-"; char *monitor; + if (!output->name) + return; + if (output->options) xfree (output->options); @@ -332,6 +337,12 @@ xf86OutputEnabled (xf86OutputPtr output) return TRUE; } +static Bool +xf86OutputIgnored (xf86OutputPtr output) +{ + return xf86ReturnOptValBool (output->options, OPTION_IGNORE, FALSE); +} + xf86OutputPtr xf86OutputCreate (ScrnInfoPtr scrn, const xf86OutputFuncsRec *funcs, @@ -339,20 +350,37 @@ xf86OutputCreate (ScrnInfoPtr scrn, { xf86OutputPtr output, *outputs; xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); - int len = strlen (name); + int len; - output = xcalloc (sizeof (xf86OutputRec) + len + 1, 1); + if (name) + len = strlen (name) + 1; + else + len = 0; + + output = xcalloc (sizeof (xf86OutputRec) + len, 1); if (!output) return NULL; output->scrn = scrn; output->funcs = funcs; - output->name = (char *) (output + 1); + if (name) + { + output->name = (char *) (output + 1); + strcpy (output->name, name); + } output->subpixel_order = SubPixelUnknown; - strcpy (output->name, name); #ifdef RANDR_12_INTERFACE output->randr_output = NULL; #endif - xf86OutputSetMonitor (output); + if (name) + { + xf86OutputSetMonitor (output); + if (xf86OutputIgnored (output)) + { + xfree (output); + return FALSE; + } + } + if (xf86_config->output) outputs = xrealloc (xf86_config->output, @@ -374,17 +402,19 @@ xf86OutputCreate (ScrnInfoPtr scrn, Bool xf86OutputRename (xf86OutputPtr output, const char *name) { - int len = strlen(name); - char *newname = xalloc (len + 1); + int len = strlen(name) + 1; + char *newname = xalloc (len); if (!newname) return FALSE; /* so sorry... */ strcpy (newname, name); - if (output->name != (char *) (output + 1)) + if (output->name && output->name != (char *) (output + 1)) xfree (output->name); output->name = newname; xf86OutputSetMonitor (output); + if (xf86OutputIgnored (output)) + return FALSE; return TRUE; } @@ -407,7 +437,7 @@ xf86OutputDestroy (xf86OutputPtr output) xf86_config->num_output--; break; } - if (output->name != (char *) (output + 1)) + if (output->name && output->name != (char *) (output + 1)) xfree (output->name); xfree (output); } From 785a59ead0e8d1d681b2cb6827ee58ad2c51f8c6 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 1 Feb 2007 22:48:44 -0800 Subject: [PATCH 03/29] Rename driver from i810 to intel. Permit old name for compatibility. Driver installs as intel_drv.so with symlink to i810_drv.so to ensure existing configurations continue to work. Updated manual page to reflect name change and add attributions for recent work. --- configure.ac | 6 +++--- man/{i810.man => intel.man} | 23 +++++++++-------------- src/Makefile.am | 17 ++++++++++++----- src/i810.h | 5 +++-- src/i810_driver.c | 19 ++++++++++++++++++- 5 files changed, 45 insertions(+), 25 deletions(-) rename man/{i810.man => intel.man} (91%) diff --git a/configure.ac b/configure.ac index 70ae8078..d45185ae 100644 --- a/configure.ac +++ b/configure.ac @@ -21,10 +21,10 @@ # Process this file with autoconf to produce a configure script AC_PREREQ(2.57) -AC_INIT([xf86-video-i810], +AC_INIT([xf86-video-intel], 1.7.2, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], - xf86-video-i810) + xf86-video-intel) AC_DEFINE_UNQUOTED([INTEL_VERSION_MAJOR], [$(echo $PACKAGE_VERSION | sed -e 's/^\([[0-9]]\)\.[[0-9]]\.[[0-9]]/\1/')], @@ -139,7 +139,7 @@ AC_SUBST([XORG_CFLAGS]) AC_SUBST([WARN_CFLAGS]) AC_SUBST([moduledir]) -DRIVER_NAME=i810 +DRIVER_NAME=intel AC_SUBST([DRIVER_NAME]) XORG_MANPAGE_SECTIONS diff --git a/man/i810.man b/man/intel.man similarity index 91% rename from man/i810.man rename to man/intel.man index 2215c7a4..b932632c 100644 --- a/man/i810.man +++ b/man/intel.man @@ -1,19 +1,18 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810.man,v 1.5 2003/10/18 02:27:07 dawes Exp $ .\" shorthand for double quote that works everywhere. .ds q \N'34' -.TH I810 __drivermansuffix__ __vendorversion__ +.TH intel __drivermansuffix__ __vendorversion__ .SH NAME -i810 \- Intel 8xx integrated graphics chipsets +intel \- Intel integrated graphics chipsets .SH SYNOPSIS .nf .B "Section \*qDevice\*q" .BI " Identifier \*q" devname \*q -.B " Driver \*qi810\*q" +.B " Driver \*qintel\*q" \ \ ... .B EndSection .fi .SH DESCRIPTION -.B i810 +.B intel is an __xservername__ driver for Intel integrated graphics chipsets. The driver supports depths 8, 15, 16 and 24. All visual types are supported in depth 8. For the i810/i815 other depths support the @@ -23,7 +22,7 @@ supports hardware accelerated 3D via the Direct Rendering Infrastructure (DRI), but only in depth 16 for the i810/i815 and depths 16 and 24 for the 830M and later. .SH SUPPORTED HARDWARE -.B i810 +.B intel supports the i810, i810-DC100, i810e, i815, i830M, 845G, 852GM, 855GM, 865G, 915G, 915GM, 945G, 945GM, 965G, 965Q and 946GZ chipsets. @@ -58,11 +57,6 @@ reduce performance for 3D applications. Note however, that increasing this value too much will reduce the amount of system memory available for other applications. .PP -The driver makes use of the video BIOS to program video modes for the 830M -and later. This limits the video modes that can be used to those provided -by the video BIOS, and to those that will fit into the amount of video memory -that the video BIOS is aware of. -.PP The following driver .B Options are supported @@ -179,6 +173,7 @@ Jeff Hartmann, Mark Vojkovich, Alan Hourihane, H. J. Lu. 830M and 845G support reworked for XFree86 4.3 by David Dawes and Keith Whitwell. 852GM, 855GM, and 865G support added by David Dawes and Keith Whitwell. 915G, 915GM, 945G, 945GM, 965G, 965Q and 946GZ support added by Alan Hourihane and -Keith Whitwell. Dual Head, Clone and lid status support added by Alan -Hourihane. Textured video support for 915G and later chips added by Keith -Packard and Eric Anholt. +Keith Whitwell. Lid status support added by Alan Hourihane. Textured video +support for 915G and later chips, RandR 1.2 and hardware modesetting added +by Eric Anholt and Keith Packard. EXA and Render acceleration added by Wang +Zhenyu. TV out support added by Zou Nan Hai and Keith Packard. diff --git a/src/Makefile.am b/src/Makefile.am index 7656e02e..f824a747 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -28,11 +28,11 @@ SUBDIRS = xvmc bios_reader ch7017 ch7xxx ivch sil164 AM_CFLAGS = @WARN_CFLAGS@ @XORG_CFLAGS@ @DRI_CFLAGS@ \ -DI830_XV -DI830_USE_XAA -DI830_USE_EXA -i810_drv_la_LTLIBRARIES = i810_drv.la -i810_drv_la_LDFLAGS = -module -avoid-version -i810_drv_ladir = @moduledir@/drivers +intel_drv_la_LTLIBRARIES = intel_drv.la +intel_drv_la_LDFLAGS = -module -avoid-version +intel_drv_ladir = @moduledir@/drivers -i810_drv_la_SOURCES = \ +intel_drv_la_SOURCES = \ brw_defines.h \ brw_structs.h \ sf_prog.h \ @@ -112,7 +112,7 @@ exa_wm_masknoca_prog.h: exa_wm_masknoca.g4a endif if DRI -i810_drv_la_SOURCES += \ +intel_drv_la_SOURCES += \ i810_dri.c \ i810_dri.h \ i830_dri.c \ @@ -123,3 +123,10 @@ endif EXTRA_DIST = \ packed_yuv_sf.g4a \ packed_yuv_wm.g4a + +install-data-local: install-intel_drv_laLTLIBRARIES + (cd $(DESTDIR)$(intel_drv_ladir) && rm -f i810_drv.so && ln -s intel_drv.so i810_drv.so) + +uninstall-local: + (cd $(DESTDIR)$(intel_drv_ladir) && rm -f i810_drv.so) + diff --git a/src/i810.h b/src/i810.h index 852a64a9..614de52c 100644 --- a/src/i810.h +++ b/src/i810.h @@ -62,8 +62,9 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "common.h" #define I810_VERSION 4000 -#define I810_NAME "I810" -#define I810_DRIVER_NAME "i810" +#define I810_NAME "intel" +#define I810_DRIVER_NAME "intel" +#define I810_LEGACY_DRIVER_NAME "i810" /* HWMC Surfaces */ #define I810_MAX_SURFACES 7 diff --git a/src/i810_driver.c b/src/i810_driver.c index e7c85071..04166b78 100644 --- a/src/i810_driver.c +++ b/src/i810_driver.c @@ -384,6 +384,21 @@ int I830EntityIndex = -1; static MODULESETUPPROTO(i810Setup); +static XF86ModuleVersionInfo intelVersRec = { + "intel", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + INTEL_VERSION_MAJOR, INTEL_VERSION_MINOR, INTEL_VERSION_PATCH, + ABI_CLASS_VIDEODRV, + ABI_VIDEODRV_VERSION, + MOD_CLASS_VIDEODRV, + {0, 0, 0, 0} +}; + +_X_EXPORT XF86ModuleData intelModuleData = { &intelVersRec, i810Setup, NULL }; + static XF86ModuleVersionInfo i810VersRec = { "i810", MODULEVENDORSTRING, @@ -521,7 +536,9 @@ I810Probe(DriverPtr drv, int flags) * driver, and return if there are none. */ if ((numDevSections = - xf86MatchDevice(I810_DRIVER_NAME, &devSections)) <= 0) { + xf86MatchDevice(I810_DRIVER_NAME, &devSections)) <= 0 && + (numDevSections = + xf86MatchDevice(I810_LEGACY_DRIVER_NAME, &devSections)) <= 0) { return FALSE; } From 76a4f2eea826036e2ac16b7e8c61ab946038c120 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 2 Feb 2007 17:34:41 -0800 Subject: [PATCH 04/29] Fix bad offsets in "right" rotation of the CRTC in cursor and update handling. --- src/i830_cursor.c | 2 +- src/i830_xf86Rotate.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/i830_cursor.c b/src/i830_cursor.c index 464eb6dd..70a8d52b 100644 --- a/src/i830_cursor.c +++ b/src/i830_cursor.c @@ -510,7 +510,7 @@ I830SetCursorPosition(ScrnInfoPtr pScrn, int x, int y) hotspoty = I810_CURSOR_Y; break; case RR_Rotate_270: - thisx = mode->VDisplay - (root_y - crtc->y); + thisx = mode->HDisplay - (root_y - crtc->y); thisy = (root_x - crtc->x); hotspotx = I810_CURSOR_Y; break; diff --git a/src/i830_xf86Rotate.c b/src/i830_xf86Rotate.c index bd4d5a60..2491e7b3 100644 --- a/src/i830_xf86Rotate.c +++ b/src/i830_xf86Rotate.c @@ -196,7 +196,7 @@ xf86RotateCrtcRedisplay (xf86CrtcPtr crtc, RegionPtr region) case RR_Rotate_270: transform.matrix[0][1] = IntToxFixed(1); transform.matrix[1][0] = IntToxFixed(-1); - transform.matrix[1][2] += IntToxFixed(crtc->mode.VDisplay); + transform.matrix[1][2] += IntToxFixed(crtc->mode.HDisplay); break; } From 681b91924c364a1c00732f548539f2767929ba0e Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 2 Feb 2007 17:40:34 -0800 Subject: [PATCH 05/29] Add subpixel offsets to fix accelerated rotated rendering on i915. This fixes the rendercheck "transformed src/mask coords 2" tests. Previously, the source pixels chosen would be off by one in some cases. The particular values were taken from Mesa, which uses .125 offsets (except apparently broken for y), but the signs are changed. I would be happier if I had better justification for why this worked. --- src/i830_render.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/i830_render.c b/src/i830_render.c index 99338439..96aeb3fa 100644 --- a/src/i830_render.c +++ b/src/i830_render.c @@ -557,8 +557,8 @@ i830_composite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, OUT_RING(PRIM3D_INLINE | PRIM3D_RECTLIST | (vertex_count-1)); - OUT_RING_F(dstX); - OUT_RING_F(dstY); + OUT_RING_F(-0.125 + dstX); + OUT_RING_F(-0.125 + dstY); OUT_RING_F(src_x[0] / pI830->scale_units[0][0]); OUT_RING_F(src_y[0] / pI830->scale_units[0][1]); if (has_mask) { @@ -566,8 +566,8 @@ i830_composite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, OUT_RING_F(mask_y[0] / pI830->scale_units[1][1]); } - OUT_RING_F(dstX); - OUT_RING_F(dstY + h); + OUT_RING_F(-0.125 + dstX); + OUT_RING_F(-0.125 + dstY + h); OUT_RING_F(src_x[1] / pI830->scale_units[0][0]); OUT_RING_F(src_y[1] / pI830->scale_units[0][1]); if (has_mask) { @@ -575,8 +575,8 @@ i830_composite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, OUT_RING_F(mask_y[1] / pI830->scale_units[1][1]); } - OUT_RING_F(dstX + w); - OUT_RING_F(dstY + h); + OUT_RING_F(-0.125 + dstX + w); + OUT_RING_F(-0.125 + dstY + h); OUT_RING_F(src_x[2] / pI830->scale_units[0][0]); OUT_RING_F(src_y[2] / pI830->scale_units[0][1]); if (has_mask) { From 44eacf2323454e26b535cc5a4f0789cb0ff0e7fb Mon Sep 17 00:00:00 2001 From: Wang Zhenyu Date: Wed, 7 Feb 2007 17:30:51 +0800 Subject: [PATCH 06/29] EXA: fix render issue with i965 Fix SF kernel with corrent coeffient work, and correct VUE storage in multi texture case. --- src/exa_sf_mask.g4a | 16 ++++++++-------- src/exa_sf_mask_prog.h | 16 ++++++++-------- src/i965_render.c | 35 ++++++++++++++++------------------- 3 files changed, 32 insertions(+), 35 deletions(-) diff --git a/src/exa_sf_mask.g4a b/src/exa_sf_mask.g4a index ab519cee..a7e2d324 100644 --- a/src/exa_sf_mask.g4a +++ b/src/exa_sf_mask.g4a @@ -22,25 +22,25 @@ mul (1) g7<1>F g7<0,1,0>F g6<0,1,0>F { align1 }; /* Cy[0] */ mul (1) g7.4<1>F g7.4<0,1,0>F g6.4<0,1,0>F { align1 }; /* Cx[2] */ -mul (1) g7.16<1>F g7.16<0,1,0>F g6<0,1,0>F { align1 }; +mul (1) g7.8<1>F g7.8<0,1,0>F g6<0,1,0>F { align1 }; /* Cy[2] */ -mul (1) g7.20<1>F g7.20<0,1,0>F g6.4<0,1,0>F { align1 }; +mul (1) g7.12<1>F g7.12<0,1,0>F g6.4<0,1,0>F { align1 }; /* src Cx[0], Cx[1] */ mov (8) m1<1>F g7<0,1,0>F { align1 }; /* mask Cx[2], Cx[3] */ -mov (1) m1.8<1>F g7.16<0,1,0>F { align1 }; -mov (1) m1.12<1>F g7.16<0,1,0>F { align1 }; +mov (1) m1.8<1>F g7.8<0,1,0>F { align1 }; +mov (1) m1.12<1>F g7.8<0,1,0>F { align1 }; /* src Cy[0], Cy[1] */ mov (8) m2<1>F g7.4<0,1,0>F { align1 }; /* mask Cy[2], Cy[3] */ -mov (1) m2.8<1>F g7.20<0,1,0>F { align1 }; -mov (1) m2.12<1>F g7.20<0,1,0>F { align1 }; +mov (1) m2.8<1>F g7.12<0,1,0>F { align1 }; +mov (1) m2.12<1>F g7.12<0,1,0>F { align1 }; /* src Co[0], Co[1] */ mov (8) m3<1>F g3<8,8,1>F { align1 }; /* mask Co[2], Co[3] */ -mov (1) m3.8<1>F g3.16<0,1,0>F { align1 }; -mov (1) m3.12<1>F g3.20<0,1,0>F { align1 }; +mov (1) m3.8<1>F g3.8<0,1,0>F { align1 }; +mov (1) m3.12<1>F g3.12<0,1,0>F { align1 }; send (8) 0 null g0<8,8,1>F urb 0 transpose used complete mlen 4 rlen 0 { align1 EOT }; nop; diff --git a/src/exa_sf_mask_prog.h b/src/exa_sf_mask_prog.h index cd7f460a..4e9114d6 100644 --- a/src/exa_sf_mask_prog.h +++ b/src/exa_sf_mask_prog.h @@ -3,17 +3,17 @@ { 0x00600040, 0x20e077bd, 0x008d0080, 0x008d4060 }, { 0x00000041, 0x20e077bd, 0x000000e0, 0x000000c0 }, { 0x00000041, 0x20e477bd, 0x000000e4, 0x000000c4 }, - { 0x00000041, 0x20f077bd, 0x000000f0, 0x000000c0 }, - { 0x00000041, 0x20f477bd, 0x000000f4, 0x000000c4 }, + { 0x00000041, 0x20e877bd, 0x000000e8, 0x000000c0 }, + { 0x00000041, 0x20ec77bd, 0x000000ec, 0x000000c4 }, { 0x00600001, 0x202003be, 0x000000e0, 0x00000000 }, - { 0x00000001, 0x202803be, 0x000000f0, 0x00000000 }, - { 0x00000001, 0x202c03be, 0x000000f0, 0x00000000 }, + { 0x00000001, 0x202803be, 0x000000e8, 0x00000000 }, + { 0x00000001, 0x202c03be, 0x000000e8, 0x00000000 }, { 0x00600001, 0x204003be, 0x000000e4, 0x00000000 }, - { 0x00000001, 0x204803be, 0x000000f4, 0x00000000 }, - { 0x00000001, 0x204c03be, 0x000000f4, 0x00000000 }, + { 0x00000001, 0x204803be, 0x000000ec, 0x00000000 }, + { 0x00000001, 0x204c03be, 0x000000ec, 0x00000000 }, { 0x00600001, 0x206003be, 0x008d0060, 0x00000000 }, - { 0x00000001, 0x206803be, 0x00000070, 0x00000000 }, - { 0x00000001, 0x206c03be, 0x00000074, 0x00000000 }, + { 0x00000001, 0x206803be, 0x00000068, 0x00000000 }, + { 0x00000001, 0x206c03be, 0x0000006c, 0x00000000 }, { 0x00600031, 0x20001fbc, 0x008d0000, 0x8640c800 }, { 0x0000007e, 0x00000000, 0x00000000, 0x00000000 }, { 0x0000007e, 0x00000000, 0x00000000, 0x00000000 }, diff --git a/src/i965_render.c b/src/i965_render.c index 266b461f..a2b21db1 100644 --- a/src/i965_render.c +++ b/src/i965_render.c @@ -948,44 +948,41 @@ i965_prepare_composite(int op, PicturePtr pSrcPicture, VB0_VERTEXDATA | ((4 * 2 * nelem) << VB0_BUFFER_PITCH_SHIFT)); OUT_RING(state_base_offset + vb_offset); - OUT_RING(2); // max index, prim has 4 coords + OUT_RING(3); OUT_RING(0); // ignore for VERTEXDATA, but still there /* Set up our vertex elements, sourced from the single vertex buffer. */ OUT_RING(BRW_3DSTATE_VERTEX_ELEMENTS | ((2 * nelem) - 1)); - /* offset 0: X,Y -> {X, Y, 1.0, 1.0} */ OUT_RING((0 << VE0_VERTEX_BUFFER_INDEX_SHIFT) | VE0_VALID | (BRW_SURFACEFORMAT_R32G32_FLOAT << VE0_FORMAT_SHIFT) | (0 << VE0_OFFSET_SHIFT)); OUT_RING((BRW_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_0_SHIFT) | (BRW_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_1_SHIFT) | - (BRW_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_2_SHIFT) | - (BRW_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_3_SHIFT) | + (BRW_VFCOMPONENT_NOSTORE << VE1_VFCOMPONENT_2_SHIFT) | + (BRW_VFCOMPONENT_NOSTORE << VE1_VFCOMPONENT_3_SHIFT) | (0 << VE1_DESTINATION_ELEMENT_OFFSET_SHIFT)); - /* offset 8: S0, T0 -> {S0, T0, 1.0, 1.0} */ - OUT_RING((0 << VE0_VERTEX_BUFFER_INDEX_SHIFT) | - VE0_VALID | - (BRW_SURFACEFORMAT_R32G32_FLOAT << VE0_FORMAT_SHIFT) | - (8 << VE0_OFFSET_SHIFT)); - OUT_RING((BRW_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_0_SHIFT) | - (BRW_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_1_SHIFT) | - (BRW_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_2_SHIFT) | - (BRW_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_3_SHIFT) | - (4 << VE1_DESTINATION_ELEMENT_OFFSET_SHIFT)); - if (pMask) { OUT_RING((0 << VE0_VERTEX_BUFFER_INDEX_SHIFT) | VE0_VALID | (BRW_SURFACEFORMAT_R32G32_FLOAT << VE0_FORMAT_SHIFT) | - (16 << VE0_OFFSET_SHIFT)); + (8 << VE0_OFFSET_SHIFT)); OUT_RING((BRW_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_0_SHIFT) | (BRW_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_1_SHIFT) | - (BRW_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_2_SHIFT) | - (BRW_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_3_SHIFT) | - (8 << VE1_DESTINATION_ELEMENT_OFFSET_SHIFT)); + (BRW_VFCOMPONENT_NOSTORE << VE1_VFCOMPONENT_2_SHIFT) | + (BRW_VFCOMPONENT_NOSTORE << VE1_VFCOMPONENT_3_SHIFT) | + (2 << VE1_DESTINATION_ELEMENT_OFFSET_SHIFT)); } + OUT_RING((0 << VE0_VERTEX_BUFFER_INDEX_SHIFT) | + VE0_VALID | + (BRW_SURFACEFORMAT_R32G32_FLOAT << VE0_FORMAT_SHIFT) | + ((pMask?16:8) << VE0_OFFSET_SHIFT)); /* offset vb in bytes */ + OUT_RING((BRW_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_0_SHIFT) | + (BRW_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_1_SHIFT) | + (BRW_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_2_SHIFT) | + (BRW_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_3_SHIFT) | + (4 << VE1_DESTINATION_ELEMENT_OFFSET_SHIFT)); /* VUE offset in dwords */ ADVANCE_LP_RING(); } From 10712c7a781e50475ee7e8ccd5bfd2d820f863e2 Mon Sep 17 00:00:00 2001 From: Wang Zhenyu Date: Thu, 8 Feb 2007 08:56:42 +0800 Subject: [PATCH 07/29] EXA: i965 pixmap pitch align This seems like a typo, which causes screen artifacts. --- src/i830_exa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/i830_exa.c b/src/i830_exa.c index 97b4a98e..c3a4c401 100644 --- a/src/i830_exa.c +++ b/src/i830_exa.c @@ -374,7 +374,7 @@ I830EXAInit(ScreenPtr pScreen) */ if (IS_I965G(pI830)) { pI830->EXADriverPtr->pixmapOffsetAlign = 4 * 2; - pI830->EXADriverPtr->pixmapPitchAlign = 1; + pI830->EXADriverPtr->pixmapPitchAlign = 16; pI830->EXADriverPtr->maxX = 8192; pI830->EXADriverPtr->maxY = 8192; } else { From fce4390c4f1a76c65423114bb479814787612cd7 Mon Sep 17 00:00:00 2001 From: Zou Nan hai Date: Fri, 9 Feb 2007 11:32:22 +0800 Subject: [PATCH 08/29] TV Enable --- src/i830_tv.c | 1192 ++++++++++++++++++++++++++++++------------------- 1 file changed, 737 insertions(+), 455 deletions(-) diff --git a/src/i830_tv.c b/src/i830_tv.c index 79b6ae8b..5ee8866a 100644 --- a/src/i830_tv.c +++ b/src/i830_tv.c @@ -37,7 +37,6 @@ #include "i830.h" #include "i830_display.h" #include - enum tv_type { TV_TYPE_NONE, TV_TYPE_UNKNOWN, @@ -94,11 +93,67 @@ typedef struct { float rv, gv, bv, av; } color_conversion_t; +static const CARD32 filter_table[] = { + 0xB1403000, 0x2E203500, 0x35002E20, 0x3000B140, + 0x35A0B160, 0x2DC02E80, 0xB1403480, 0xB1603000, + 0x2EA03640, 0x34002D80, 0x3000B120, 0x36E0B160, + 0x2D202EF0, 0xB1203380, 0xB1603000, 0x2F303780, + 0x33002CC0, 0x3000B100, 0x3820B160, 0x2C802F50, + 0xB10032A0, 0xB1603000, 0x2F9038C0, 0x32202C20, + 0x3000B0E0, 0x3980B160, 0x2BC02FC0, 0xB0E031C0, + 0xB1603000, 0x2FF03A20, 0x31602B60, 0xB020B0C0, + 0x3AE0B160, 0x2B001810, 0xB0C03120, 0xB140B020, + 0x18283BA0, 0x30C02A80, 0xB020B0A0, 0x3C60B140, + 0x2A201838, 0xB0A03080, 0xB120B020, 0x18383D20, + 0x304029C0, 0xB040B080, 0x3DE0B100, 0x29601848, + 0xB0803000, 0xB100B040, 0x18483EC0, 0xB0402900, + 0xB040B060, 0x3F80B0C0, 0x28801858, 0xB060B080, + 0xB0A0B060, 0x18602820, 0xB0A02820, 0x0000B060, + 0xB1403000, 0x2E203500, 0x35002E20, 0x3000B140, + 0x35A0B160, 0x2DC02E80, 0xB1403480, 0xB1603000, + 0x2EA03640, 0x34002D80, 0x3000B120, 0x36E0B160, + 0x2D202EF0, 0xB1203380, 0xB1603000, 0x2F303780, + 0x33002CC0, 0x3000B100, 0x3820B160, 0x2C802F50, + 0xB10032A0, 0xB1603000, 0x2F9038C0, 0x32202C20, + 0x3000B0E0, 0x3980B160, 0x2BC02FC0, 0xB0E031C0, + 0xB1603000, 0x2FF03A20, 0x31602B60, 0xB020B0C0, + 0x3AE0B160, 0x2B001810, 0xB0C03120, 0xB140B020, + 0x18283BA0, 0x30C02A80, 0xB020B0A0, 0x3C60B140, + 0x2A201838, 0xB0A03080, 0xB120B020, 0x18383D20, + 0x304029C0, 0xB040B080, 0x3DE0B100, 0x29601848, + 0xB0803000, 0xB100B040, 0x18483EC0, 0xB0402900, + 0xB040B060, 0x3F80B0C0, 0x28801858, 0xB060B080, + 0xB0A0B060, 0x18602820, 0xB0A02820, 0x0000B060, + 0x36403000, 0x2D002CC0, 0x30003640, 0x2D0036C0, + 0x35C02CC0, 0x37403000, 0x2C802D40, 0x30003540, + 0x2D8037C0, 0x34C02C40, 0x38403000, 0x2BC02E00, + 0x30003440, 0x2E2038C0, 0x34002B80, 0x39803000, + 0x2B402E40, 0x30003380, 0x2E603A00, 0x33402B00, + 0x3A803040, 0x2A802EA0, 0x30403300, 0x2EC03B40, + 0x32802A40, 0x3C003040, 0x2A002EC0, 0x30803240, + 0x2EC03C80, 0x320029C0, 0x3D403080, 0x29402F00, + 0x308031C0, 0x2F203DC0, 0x31802900, 0x3E8030C0, + 0x28802F40, 0x30C03140, 0x2F203F40, 0x31402840, + 0x28003100, 0x28002F00, 0x00003100, 0x36403000, + 0x2D002CC0, 0x30003640, 0x2D0036C0, + 0x35C02CC0, 0x37403000, 0x2C802D40, 0x30003540, + 0x2D8037C0, 0x34C02C40, 0x38403000, 0x2BC02E00, + 0x30003440, 0x2E2038C0, 0x34002B80, 0x39803000, + 0x2B402E40, 0x30003380, 0x2E603A00, 0x33402B00, + 0x3A803040, 0x2A802EA0, 0x30403300, 0x2EC03B40, + 0x32802A40, 0x3C003040, 0x2A002EC0, 0x30803240, + 0x2EC03C80, 0x320029C0, 0x3D403080, 0x29402F00, + 0x308031C0, 0x2F203DC0, 0x31802900, 0x3E8030C0, + 0x28802F40, 0x30C03140, 0x2F203F40, 0x31402840, + 0x28003100, 0x28002F00, 0x00003100, +}; + typedef struct { char *name; + int clock; CARD32 oversample; int hsync_end, hblank_start, hblank_end, htotal; - Bool progressive; + Bool progressive, trilevel_sync, component_only; int vsync_start_f1, vsync_start_f2, vsync_len; Bool veq_ena; int veq_start_f1, veq_start_f2, veq_len; @@ -120,9 +175,10 @@ typedef struct { */ video_levels_t composite_levels, svideo_levels; color_conversion_t composite_color, svideo_color; + const CARD32 *filter_table; + int max_srcw; } tv_mode_t; -#define TV_PLL_CLOCK 107520 /* * Sub carrier DDA @@ -157,25 +213,26 @@ typedef struct { const static tv_mode_t tv_modes[] = { { - .name = "NTSC 480i", + .name = "NTSC-M", + .clock = 107520, .oversample = TV_OVERSAMPLE_8X, - + .component_only = 0, /* 525 Lines, 60 Fields, 15.734KHz line, Sub-Carrier 3.580MHz */ .hsync_end = 64, .hblank_end = 124, .hblank_start = 836, .htotal = 857, - - .progressive = FALSE, - + + .progressive = FALSE, .trilevel_sync = FALSE, + .vsync_start_f1 = 6, .vsync_start_f2 = 7, .vsync_len = 6, - + .veq_ena = TRUE, .veq_start_f1 = 0, .veq_start_f2 = 1, .veq_len = 18, - + .vi_end_f1 = 20, .vi_end_f2 = 21, .nbr_end = 240, - + .burst_ena = TRUE, .hburst_start = 72, .hburst_len = 34, .vburst_start_f1 = 9, .vburst_end_f1 = 240, @@ -203,26 +260,78 @@ const static tv_mode_t tv_modes[] = { .ru =-0.0885, .gu =-0.1738, .bu = 0.2624, .au = 1.0000, .rv = 0.3693, .gv =-0.3092, .bv =-0.0601, .av = 1.0000, }, + .filter_table = filter_table, }, { - .name = "NTSC-Japan 480i", + .name = "NTSC-443", + .clock = 107520, .oversample = TV_OVERSAMPLE_8X, - - /* 525 Lines, 60 Fields, 15.734KHz line, Sub-Carrier 3.580MHz */ + .component_only = 0, + /* 525 Lines, 60 Fields, 15.734KHz line, Sub-Carrier 4.43MHz */ .hsync_end = 64, .hblank_end = 124, .hblank_start = 836, .htotal = 857, - - .progressive = FALSE, - - .vsync_start_f1 = 6, .vsync_start_f2 = 7, + + .progressive = FALSE, .trilevel_sync = FALSE, + + .vsync_start_f1 = 6, .vsync_start_f2 = 7, .vsync_len = 6, - + .veq_ena = TRUE, .veq_start_f1 = 0, .veq_start_f2 = 1, .veq_len = 18, - + .vi_end_f1 = 20, .vi_end_f2 = 21, .nbr_end = 240, - + + .burst_ena = 8, + .hburst_start = 72, .hburst_len = 34, + .vburst_start_f1 = 9, .vburst_end_f1 = 240, + .vburst_start_f2 = 10, .vburst_end_f2 = 240, + .vburst_start_f3 = 9, .vburst_end_f3 = 240, + .vburst_start_f4 = 10, .vburst_end_f4 = 240, + + /* desired 4.4336180 actual 4.4336180 clock 107.52 */ + .dda1_inc = 168, + .dda2_inc = 18557, .dda2_size = 20625, + .dda3_inc = 0, .dda3_size = 0, + .sc_reset = TV_SC_RESET_EVERY_8, + .pal_burst = TRUE, + + .composite_levels = { .blank = 225, .black = 267, .burst = 113 }, + .composite_color = { + .ry = 0.2990, .gy = 0.5870, .by = 0.1140, .ay = 0.5082, + .ru =-0.0749, .gu =-0.1471, .bu = 0.2220, .au = 1.0000, + .rv = 0.3125, .gv =-0.2616, .bv =-0.0508, .av = 1.0000, + }, + + .svideo_levels = { .blank = 266, .black = 316, .burst = 133 }, + .svideo_color = { + .ry = 0.2990, .gy = 0.5870, .by = 0.1140, .ay = 0.6006, + .ru =-0.0885, .gu =-0.1738, .bu = 0.2624, .au = 1.0000, + .rv = 0.3693, .gv =-0.3092, .bv =-0.0601, .av = 1.0000, + }, + .filter_table = filter_table, + }, + { + .name = "NTSC-J", + .clock = 107520, + .oversample = TV_OVERSAMPLE_8X, + .component_only = 0, + + /* 525 Lines, 60 Fields, 15.734KHz line, Sub-Carrier 3.580MHz */ + .hsync_end = 64, .hblank_end = 124, + .hblank_start = 836, .htotal = 857, + + .progressive = FALSE, .trilevel_sync = FALSE, + + .vsync_start_f1 = 6, .vsync_start_f2 = 7, + .vsync_len = 6, + + .veq_ena = TRUE, .veq_start_f1 = 0, + .veq_start_f2 = 1, .veq_len = 18, + + .vi_end_f1 = 20, .vi_end_f2 = 21, + .nbr_end = 240, + .burst_ena = TRUE, .hburst_start = 72, .hburst_len = 34, .vburst_start_f1 = 9, .vburst_end_f1 = 240, @@ -250,20 +359,74 @@ const static tv_mode_t tv_modes[] = { .ru =-0.0957, .gu =-0.1879, .bu = 0.2836, .au = 1.0000, .rv = 0.3992, .gv =-0.3343, .bv =-0.0649, .av = 1.0000, }, + .filter_table = filter_table, + }, + { + .name = "PAL-M", + .clock = 107520, + .oversample = TV_OVERSAMPLE_8X, + .component_only = 0, + + /* 525 Lines, 60 Fields, 15.734KHz line, Sub-Carrier 3.580MHz */ + .hsync_end = 64, .hblank_end = 124, + .hblank_start = 836, .htotal = 857, + + .progressive = FALSE, .trilevel_sync = FALSE, + + .vsync_start_f1 = 6, .vsync_start_f2 = 7, + .vsync_len = 6, + + .veq_ena = TRUE, .veq_start_f1 = 0, + .veq_start_f2 = 1, .veq_len = 18, + + .vi_end_f1 = 20, .vi_end_f2 = 21, + .nbr_end = 240, + + .burst_ena = TRUE, + .hburst_start = 72, .hburst_len = 34, + .vburst_start_f1 = 9, .vburst_end_f1 = 240, + .vburst_start_f2 = 10, .vburst_end_f2 = 240, + .vburst_start_f3 = 9, .vburst_end_f3 = 240, + .vburst_start_f4 = 10, .vburst_end_f4 = 240, + + /* desired 3.5800000 actual 3.5800000 clock 107.52 */ + .dda1_inc = 136, + .dda2_inc = 7624, .dda2_size = 20013, + .dda3_inc = 0, .dda3_size = 0, + .sc_reset = TV_SC_RESET_EVERY_4, + .pal_burst = FALSE, + + .composite_levels = { .blank = 225, .black = 267, .burst = 113 }, + .composite_color = { + .ry = 0.2990, .gy = 0.5870, .by = 0.1140, .ay = 0.5082, + .ru =-0.0749, .gu =-0.1471, .bu = 0.2220, .au = 1.0000, + .rv = 0.3125, .gv =-0.2616, .bv =-0.0508, .av = 1.0000, + }, + + .svideo_levels = { .blank = 266, .black = 316, .burst = 133 }, + .svideo_color = { + .ry = 0.2990, .gy = 0.5870, .by = 0.1140, .ay = 0.6006, + .ru =-0.0885, .gu =-0.1738, .bu = 0.2624, .au = 1.0000, + .rv = 0.3693, .gv =-0.3092, .bv =-0.0601, .av = 1.0000, + }, + .filter_table = filter_table, }, { /* 625 Lines, 50 Fields, 15.625KHz line, Sub-Carrier 4.434MHz */ - .name = "PAL 576i", + .name = "PAL-N", + .clock = 107520, .oversample = TV_OVERSAMPLE_8X, + .component_only = 0, .hsync_end = 64, .hblank_end = 128, - .hblank_start = 844, .htotal = 863, - - .progressive = FALSE, - - .vsync_start_f1 = 6, .vsync_start_f2 = 7, + .hblank_start = 844, .htotal = 863, + + .progressive = FALSE, .trilevel_sync = FALSE, + + + .vsync_start_f1 = 6, .vsync_start_f2 = 7, .vsync_len = 6, - + .veq_ena = TRUE, .veq_start_f1 = 0, .veq_start_f2 = 1, .veq_len = 18, @@ -271,44 +434,70 @@ const static tv_mode_t tv_modes[] = { .nbr_end = 286, .burst_ena = TRUE, - .hburst_start = 73, .hburst_len = 34, + .hburst_start = 73, .hburst_len = 34, + .vburst_start_f1 = 8, .vburst_end_f1 = 285, + .vburst_start_f2 = 8, .vburst_end_f2 = 286, + .vburst_start_f3 = 9, .vburst_end_f3 = 286, + .vburst_start_f4 = 9, .vburst_end_f4 = 285, + + + /* desired 4.4336180 actual 4.4336180 clock 107.52 */ + .dda1_inc = 168, + .dda2_inc = 18557, .dda2_size = 20625, + .dda3_inc = 0, .dda3_size = 0, + .sc_reset = TV_SC_RESET_EVERY_8, + .pal_burst = TRUE, + + .composite_levels = { .blank = 225, .black = 267, .burst = 118 }, + .composite_color = { + .ry = 0.2990, .gy = 0.5870, .by = 0.1140, .ay = 0.5082, + .ru =-0.0749, .gu =-0.1471, .bu = 0.2220, .au = 1.0000, + .rv = 0.3125, .gv =-0.2616, .bv =-0.0508, .av = 1.0000, + }, + + .svideo_levels = { .blank = 266, .black = 316, .burst = 139 }, + .svideo_color = { + .ry = 0.2990, .gy = 0.5870, .by = 0.1140, .ay = 0.6006, + .ru =-0.0885, .gu =-0.1738, .bu = 0.2624, .au = 1.0000, + .rv = 0.3693, .gv =-0.3092, .bv =-0.0601, .av = 1.0000, + }, + .filter_table = filter_table, + }, + { + /* 625 Lines, 50 Fields, 15.625KHz line, Sub-Carrier 4.434MHz */ + .name = "PAL", + .clock = 107520, + .oversample = TV_OVERSAMPLE_8X, + .component_only = 0, + + .hsync_end = 64, .hblank_end = 128, + .hblank_start = 844, .htotal = 863, + + .progressive = FALSE, .trilevel_sync = FALSE, + + .vsync_start_f1 = 5, .vsync_start_f2 = 6, + .vsync_len = 5, + + .veq_ena = TRUE, .veq_start_f1 = 0, + .veq_start_f2 = 1, .veq_len = 15, + + .vi_end_f1 = 24, .vi_end_f2 = 25, + .nbr_end = 286, + + .burst_ena = TRUE, + .hburst_start = 73, .hburst_len = 32, .vburst_start_f1 = 8, .vburst_end_f1 = 285, .vburst_start_f2 = 8, .vburst_end_f2 = 286, .vburst_start_f3 = 9, .vburst_end_f3 = 286, .vburst_start_f4 = 9, .vburst_end_f4 = 285, /* desired 4.4336180 actual 4.4336180 clock 107.52 */ - .dda1_inc = 168, - .dda2_inc = 18557, .dda2_size = 20625, - .dda3_inc = 0, .dda3_size = 0, + .dda1_inc = 168, + .dda2_inc = 18557, .dda2_size = 20625, + .dda3_inc = 0, .dda3_size = 0, .sc_reset = TV_SC_RESET_EVERY_8, .pal_burst = TRUE, - - .composite_levels = { .blank = 237, .black = 237, .burst = 118 }, - .composite_color = { - .ry = 0.2990, .gy = 0.5870, .by = 0.1140, .ay = 0.5379, - .ru =-0.0793, .gu =-0.1557, .bu = 0.2350, .au = 1.0000, - .rv = 0.3307, .gv =-0.2769, .bv =-0.0538, .av = 1.0000, - }, - - .svideo_levels = { .blank = 280, .black = 280, .burst = 139 }, - .svideo_color = { - .ry = 0.2990, .gy = 0.5870, .by = 0.1140, .ay = 0.6357, - .ru =-0.0937, .gu =-0.1840, .bu = 0.2777, .au = 1.0000, - .rv = 0.3908, .gv =-0.3273, .bv =-0.0636, .av = 1.0000, - }, - } -#if 0 - { - /* 625 Lines, 50 Fields, 15.625KHz line, Sub-Carrier 4.434MHz */ - .name = "PAL", - /* desired 4.4336180 actual 4.4336180 clock 107.52 */ - .dda1_inc = 168, - .dda2_inc = 18557, .dda2_size = 20625, - .dda3_inc = 0, .dda3_size = 0, - .sc_reset = TV_SC_RESET_EVERY_8, - .pal_burst = TRUE - + .composite_levels = { .blank = 237, .black = 237, .burst = 118 }, .composite_color = { .ry = 0.2990, .gy = 0.5870, .by = 0.1140, .ay = 0.5379, @@ -322,84 +511,226 @@ const static tv_mode_t tv_modes[] = { .ru =-0.0937, .gu =-0.1840, .bu = 0.2777, .au = 1.0000, .rv = 0.3908, .gv =-0.3273, .bv =-0.0636, .av = 1.0000, }, + .filter_table = filter_table, }, { - /* 525 Lines, 60 Fields, 15.734KHz line, Sub-Carrier 3.576MHz */ - .name = "PAL M", - /* desired 3.5756110 actual 3.5756110 clock 107.52 */ - .dda1_inc = 136, - .dda2_inc = 5611, .dda2_size = 26250, - .dda3_inc = 0, .dda3_size = 0, - .sc_reset = TV_SC_RESET_EVERY_8, - .pal_burst = TRUE - - .composite_levels = { .blank = 225, .black = 267, .burst = 113 }, - .composite_color = { - .ry = 0.2990, .gy = 0.5870, .by = 0.1140, .ay = 0.5082, - .ru =-0.0749, .gu =-0.1471, .bu = 0.2220, .au = 1.0000, - .rv = 0.3125, .gv =-0.2616, .bv =-0.0508, .av = 1.0000, - }, + .name = "480p@59.94Hz", + .clock = 107520, + .oversample = TV_OVERSAMPLE_4X, + .component_only = 1, - .svideo_levels = { .blank = 266, .black = 316, .burst = 133 }, - .svideo_color = { - .ry = 0.2990, .gy = 0.5870, .by = 0.1140, .ay = 0.6006, - .ru =-0.0885, .gu =-0.1738, .bu = 0.2624, .au = 1.0000, - .rv = 0.3693, .gv =-0.3092, .bv =-0.0601, .av = 1.0000, - }, + .hsync_end = 64, .hblank_end = 122, + .hblank_start = 842, .htotal = 857, + + .progressive = TRUE,.trilevel_sync = FALSE, + + .vsync_start_f1 = 12, .vsync_start_f2 = 12, + .vsync_len = 12, + + .veq_ena = FALSE, + + .vi_end_f1 = 44, .vi_end_f2 = 44, + .nbr_end = 496, + + .burst_ena = FALSE, + + .filter_table = filter_table, }, { - /* 625 Lines, 50 Fields, 15.625KHz line, Sub-Carrier 3.582MHz */ - .name = "PAL Nc", - /* desired 3.5820560 actual 3.5820560 clock 107.52 */ - .dda1_inc = 136, - .dda2_inc = 12056, .dda2_size = 26250, - .dda3_inc = 0, .dda3_size = 0, - .sc_reset = TV_SC_RESET_EVERY_8, - .pal_burst = TRUE - - .composite_levels = { .blank = 225, .black = 267, .burst = 113 }, - .composite_color = { - .ry = 0.2990, .gy = 0.5870, .by = 0.1140, .ay = 0.5082, - .ru =-0.0749, .gu =-0.1471, .bu = 0.2220, .au = 1.0000, - .rv = 0.3125, .gv =-0.2616, .bv =-0.0508, .av = 1.0000, - }, + .name = "480p@60Hz", + .clock = 107520, + .oversample = TV_OVERSAMPLE_4X, + .component_only = 1, - .svideo_levels = { .blank = 266, .black = 316, .burst = 133 }, - .svideo_color = { - .ry = 0.2990, .gy = 0.5870, .by = 0.1140, .ay = 0.6006, - .ru =-0.0885, .gu =-0.1738, .bu = 0.2624, .au = 1.0000, - .rv = 0.3693, .gv =-0.3092, .bv =-0.0601, .av = 1.0000, - }, + .hsync_end = 64, .hblank_end = 122, + .hblank_start = 842, .htotal = 856, + + .progressive = TRUE,.trilevel_sync = FALSE, + + .vsync_start_f1 = 12, .vsync_start_f2 = 12, + .vsync_len = 12, + + .veq_ena = FALSE, + + .vi_end_f1 = 44, .vi_end_f2 = 44, + .nbr_end = 496, + + .burst_ena = FALSE, + + .filter_table = filter_table, }, { - /* 525 lines, 60 fields, 15.734KHz line, Sub-Carrier 4.43MHz */ - .name = "NTSC-4.43(nonstandard)", - /* desired 4.4336180 actual 4.4336180 clock 107.52 */ - .dda1_inc = 168, - .dda2_inc = 18557, .dda2_size = 20625, - .dda3_inc = 0, .dda3_size = 0, - .sc_reset = TV_SC_RESET_NEVER, - .pal_burst = FALSE + .name = "576p", + .clock = 107520, + .oversample = TV_OVERSAMPLE_4X, + .component_only = 1, - .composite_levels = { .blank = 225, .black = 267, .burst = 113 }, - .composite_color = { - .ry = 0.2990, .gy = 0.5870, .by = 0.1140, .ay = 0.5082, - .ru =-0.0749, .gu =-0.1471, .bu = 0.2220, .au = 1.0000, - .rv = 0.3125, .gv =-0.2616, .bv =-0.0508, .av = 1.0000, - }, + .hsync_end = 64, .hblank_end = 139, + .hblank_start = 859, .htotal = 863, - .svideo_levels = { .blank = 266, .black = 316, .burst = 133 }, - .svideo_color = { - .ry = 0.2990, .gy = 0.5870, .by = 0.1140, .ay = 0.6006, - .ru =-0.0885, .gu =-0.1738, .bu = 0.2624, .au = 1.0000, - .rv = 0.3693, .gv =-0.3092, .bv =-0.0601, .av = 1.0000, - }, + .progressive = TRUE, .trilevel_sync = FALSE, + + .vsync_start_f1 = 10, .vsync_start_f2 = 10, + .vsync_len = 10, + + .veq_ena = FALSE, + + .vi_end_f1 = 48, .vi_end_f2 = 48, + .nbr_end = 575, + + .burst_ena = FALSE, + + .filter_table = filter_table, + }, + { + .name = "720p@60Hz", + .clock = 148800, + .oversample = TV_OVERSAMPLE_2X, + .component_only = 1, + + .hsync_end = 80, .hblank_end = 300, + .hblank_start = 1580, .htotal = 1649, + + .progressive = TRUE, .trilevel_sync = TRUE, + + .vsync_start_f1 = 10, .vsync_start_f2 = 10, + .vsync_len = 10, + + .veq_ena = FALSE, + + .vi_end_f1 = 29, .vi_end_f2 = 29, + .nbr_end = 719, + + .burst_ena = FALSE, + + .filter_table = filter_table, + }, + { + .name = "720p@59.94Hz", + .clock = 148800, + .oversample = TV_OVERSAMPLE_2X, + .component_only = 1, + + .hsync_end = 80, .hblank_end = 300, + .hblank_start = 1580, .htotal = 1651, + + .progressive = TRUE, .trilevel_sync = TRUE, + + .vsync_start_f1 = 10, .vsync_start_f2 = 10, + .vsync_len = 10, + + .veq_ena = FALSE, + + .vi_end_f1 = 29, .vi_end_f2 = 29, + .nbr_end = 719, + + .burst_ena = FALSE, + + .filter_table = filter_table, + }, + { + .name = "720p@50Hz", + .clock = 148800, + .oversample = TV_OVERSAMPLE_2X, + .component_only = 1, + + .hsync_end = 80, .hblank_end = 300, + .hblank_start = 1580, .htotal = 1979, + + .progressive = TRUE, .trilevel_sync = TRUE, + + .vsync_start_f1 = 10, .vsync_start_f2 = 10, + .vsync_len = 10, + + .veq_ena = FALSE, + + .vi_end_f1 = 29, .vi_end_f2 = 29, + .nbr_end = 719, + + .burst_ena = FALSE, + + .filter_table = filter_table, + .max_srcw = 800 + }, + { + .name = "1080i@50Hz", + .clock = 148800, + .oversample = TV_OVERSAMPLE_2X, + .component_only = 1, + + .hsync_end = 88, .hblank_end = 235, + .hblank_start = 2155, .htotal = 2639, + + .progressive = FALSE, .trilevel_sync = TRUE, + + .vsync_start_f1 = 4, .vsync_start_f2 = 5, + .vsync_len = 10, + + .veq_ena = TRUE, .veq_start_f1 = 4, + .veq_start_f2 = 4, .veq_len = 10, + + + .vi_end_f1 = 21, .vi_end_f2 = 22, + .nbr_end = 539, + + .burst_ena = FALSE, + + .filter_table = filter_table, + }, + { + .name = "1080i@60Hz", + .clock = 148800, + .oversample = TV_OVERSAMPLE_2X, + .component_only = 1, + + .hsync_end = 88, .hblank_end = 235, + .hblank_start = 2155, .htotal = 2199, + + .progressive = FALSE, .trilevel_sync = TRUE, + + .vsync_start_f1 = 4, .vsync_start_f2 = 5, + .vsync_len = 10, + + .veq_ena = TRUE, .veq_start_f1 = 4, + .veq_start_f2 = 4, .veq_len = 10, + + + .vi_end_f1 = 21, .vi_end_f2 = 22, + .nbr_end = 539, + + .burst_ena = FALSE, + + .filter_table = filter_table, + }, + { + .name = "1080i@59.94Hz", + .clock = 148800, + .oversample = TV_OVERSAMPLE_2X, + .component_only = 1, + + .hsync_end = 88, .hblank_end = 235, + .hblank_start = 2155, .htotal = 2200, + + .progressive = FALSE, .trilevel_sync = TRUE, + + .vsync_start_f1 = 4, .vsync_start_f2 = 5, + .vsync_len = 10, + + .veq_ena = TRUE, .veq_start_f1 = 4, + .veq_start_f2 = 4, .veq_len = 10, + + + .vi_end_f1 = 21, .vi_end_f2 = 22, + .nbr_end = 539, + + .burst_ena = FALSE, + + .filter_table = filter_table, }, -#endif }; static const video_levels_t component_level = { - .blank = 279, .black = 279 + .blank = 279, .black = 279 }; static const color_conversion_t sdtv_component_color = { @@ -407,13 +738,13 @@ static const color_conversion_t sdtv_component_color = { .ru =-0.1687, .gu =-0.3313, .bu = 0.5000, .au = 1.0000, .rv = 0.5000, .gv =-0.4187, .bv =-0.0813, .av = 1.0000, }; - + static const color_conversion_t hdtv_component_color = { .ry = 0.2126, .gy = 0.7152, .by = 0.0722, .ay = 0.6364, .ru =-0.1146, .gu =-0.3854, .bu = 0.5000, .au = 1.0000, .rv = 0.5000, .gv =-0.4542, .bv =-0.0458, .av = 1.0000, }; - + static void i830_tv_dpms(xf86OutputPtr output, int mode) { @@ -421,14 +752,14 @@ i830_tv_dpms(xf86OutputPtr output, int mode) I830Ptr pI830 = I830PTR(pScrn); switch(mode) { - case DPMSModeOn: - OUTREG(TV_CTL, INREG(TV_CTL) | TV_ENC_ENABLE); - break; - case DPMSModeStandby: - case DPMSModeSuspend: - case DPMSModeOff: - OUTREG(TV_CTL, INREG(TV_CTL) & ~TV_ENC_ENABLE); - break; + case DPMSModeOn: + OUTREG(TV_CTL, INREG(TV_CTL) | TV_ENC_ENABLE); + break; + case DPMSModeStandby: + case DPMSModeSuspend: + case DPMSModeOff: + OUTREG(TV_CTL, INREG(TV_CTL) & ~TV_ENC_ENABLE); + break; } } @@ -491,6 +822,11 @@ i830_tv_restore(xf86OutputPtr output) struct i830_tv_priv *dev_priv = intel_output->dev_priv; int i; + xf86CrtcPtr crtc = output->crtc; + I830CrtcPrivatePtr intel_crtc; + if (!crtc) + return; + intel_crtc = crtc->driver_private; OUTREG(TV_H_CTL_1, dev_priv->save_TV_H_CTL_1); OUTREG(TV_H_CTL_2, dev_priv->save_TV_H_CTL_2); OUTREG(TV_H_CTL_3, dev_priv->save_TV_H_CTL_3); @@ -513,11 +849,38 @@ i830_tv_restore(xf86OutputPtr output) OUTREG(TV_CSC_V2, dev_priv->save_TV_CSC_V2); OUTREG(TV_CLR_KNOBS, dev_priv->save_TV_CLR_KNOBS); OUTREG(TV_CLR_LEVEL, dev_priv->save_TV_CLR_LEVEL); - OUTREG(TV_WIN_POS, dev_priv->save_TV_WIN_POS); - OUTREG(TV_WIN_SIZE, dev_priv->save_TV_WIN_SIZE); - OUTREG(TV_FILTER_CTL_1, dev_priv->save_TV_FILTER_CTL_1); - OUTREG(TV_FILTER_CTL_2, dev_priv->save_TV_FILTER_CTL_2); - OUTREG(TV_FILTER_CTL_3, dev_priv->save_TV_FILTER_CTL_3); + + { + int pipeconf_reg = (intel_crtc->pipe == 0)?PIPEACONF:PIPEBCONF; + int dspcntr_reg = (intel_crtc->pipe == 0)?DSPACNTR : DSPBCNTR; + int pipeconf = INREG(pipeconf_reg); + int dspcntr = INREG(dspcntr_reg); + int dspbase_reg = (intel_crtc->pipe == 0) ? DSPABASE : DSPBBASE; + /* Pipe must be off here */ + OUTREG(dspcntr_reg, dspcntr & ~DISPLAY_PLANE_ENABLE); + /* Flush the plane changes */ + OUTREG(dspbase_reg, INREG(dspbase_reg)); + + if (!IS_I9XX(pI830)) { + /* Wait for vblank for the disable to take effect */ + i830WaitForVblank(pScrn); + } + + OUTREG(pipeconf_reg, pipeconf & ~PIPEACONF_ENABLE); + /* Wait for vblank for the disable to take effect. */ + i830WaitForVblank(pScrn); + + /* Filter ctl must be set before TV_WIN_SIZE */ + OUTREG(TV_FILTER_CTL_1, dev_priv->save_TV_FILTER_CTL_1); + OUTREG(TV_FILTER_CTL_2, dev_priv->save_TV_FILTER_CTL_2); + OUTREG(TV_FILTER_CTL_3, dev_priv->save_TV_FILTER_CTL_3); + OUTREG(TV_WIN_POS, dev_priv->save_TV_WIN_POS); + OUTREG(TV_WIN_SIZE, dev_priv->save_TV_WIN_SIZE); + OUTREG(pipeconf_reg, pipeconf); + OUTREG(dspcntr_reg, dspcntr); + /* Flush the plane changes */ + OUTREG(dspbase_reg, INREG(dspbase_reg)); + } for (i = 0; i < 60; i++) OUTREG(TV_H_LUMA_0 + (i <<2), dev_priv->save_TV_H_LUMA[i]); @@ -535,95 +898,32 @@ i830_tv_restore(xf86OutputPtr output) static int i830_tv_mode_valid(xf86OutputPtr output, DisplayModePtr pMode) { - return MODE_OK; + return MODE_OK; } -static const CARD32 h_luma[60] = { - 0xB1403000, 0x2E203500, 0x35002E20, 0x3000B140, - 0x35A0B160, 0x2DC02E80, 0xB1403480, 0xB1603000, - 0x2EA03640, 0x34002D80, 0x3000B120, 0x36E0B160, - 0x2D202EF0, 0xB1203380, 0xB1603000, 0x2F303780, - 0x33002CC0, 0x3000B100, 0x3820B160, 0x2C802F50, - 0xB10032A0, 0xB1603000, 0x2F9038C0, 0x32202C20, - 0x3000B0E0, 0x3980B160, 0x2BC02FC0, 0xB0E031C0, - 0xB1603000, 0x2FF03A20, 0x31602B60, 0xB020B0C0, - 0x3AE0B160, 0x2B001810, 0xB0C03120, 0xB140B020, - 0x18283BA0, 0x30C02A80, 0xB020B0A0, 0x3C60B140, - 0x2A201838, 0xB0A03080, 0xB120B020, 0x18383D20, - 0x304029C0, 0xB040B080, 0x3DE0B100, 0x29601848, - 0xB0803000, 0xB100B040, 0x18483EC0, 0xB0402900, - 0xB040B060, 0x3F80B0C0, 0x28801858, 0xB060B080, - 0xB0A0B060, 0x18602820, 0xB0A02820, 0x0000B060, -}; - -static const CARD32 h_chroma[60] = { - 0xB1403000, 0x2E203500, 0x35002E20, 0x3000B140, - 0x35A0B160, 0x2DC02E80, 0xB1403480, 0xB1603000, - 0x2EA03640, 0x34002D80, 0x3000B120, 0x36E0B160, - 0x2D202EF0, 0xB1203380, 0xB1603000, 0x2F303780, - 0x33002CC0, 0x3000B100, 0x3820B160, 0x2C802F50, - 0xB10032A0, 0xB1603000, 0x2F9038C0, 0x32202C20, - 0x3000B0E0, 0x3980B160, 0x2BC02FC0, 0xB0E031C0, - 0xB1603000, 0x2FF03A20, 0x31602B60, 0xB020B0C0, - 0x3AE0B160, 0x2B001810, 0xB0C03120, 0xB140B020, - 0x18283BA0, 0x30C02A80, 0xB020B0A0, 0x3C60B140, - 0x2A201838, 0xB0A03080, 0xB120B020, 0x18383D20, - 0x304029C0, 0xB040B080, 0x3DE0B100, 0x29601848, - 0xB0803000, 0xB100B040, 0x18483EC0, 0xB0402900, - 0xB040B060, 0x3F80B0C0, 0x28801858, 0xB060B080, - 0xB0A0B060, 0x18602820, 0xB0A02820, 0x0000B060, -}; - -static const CARD32 v_luma[43] = { - 0x36403000, 0x2D002CC0, 0x30003640, 0x2D0036C0, - 0x35C02CC0, 0x37403000, 0x2C802D40, 0x30003540, - 0x2D8037C0, 0x34C02C40, 0x38403000, 0x2BC02E00, - 0x30003440, 0x2E2038C0, 0x34002B80, 0x39803000, - 0x2B402E40, 0x30003380, 0x2E603A00, 0x33402B00, - 0x3A803040, 0x2A802EA0, 0x30403300, 0x2EC03B40, - 0x32802A40, 0x3C003040, 0x2A002EC0, 0x30803240, - 0x2EC03C80, 0x320029C0, 0x3D403080, 0x29402F00, - 0x308031C0, 0x2F203DC0, 0x31802900, 0x3E8030C0, - 0x28802F40, 0x30C03140, 0x2F203F40, 0x31402840, - 0x28003100, 0x28002F00, 0x00003100, -}; - -static const CARD32 v_chroma[43] = { - 0x36403000, 0x2D002CC0, 0x30003640, 0x2D0036C0, - 0x35C02CC0, 0x37403000, 0x2C802D40, 0x30003540, - 0x2D8037C0, 0x34C02C40, 0x38403000, 0x2BC02E00, - 0x30003440, 0x2E2038C0, 0x34002B80, 0x39803000, - 0x2B402E40, 0x30003380, 0x2E603A00, 0x33402B00, - 0x3A803040, 0x2A802EA0, 0x30403300, 0x2EC03B40, - 0x32802A40, 0x3C003040, 0x2A002EC0, 0x30803240, - 0x2EC03C80, 0x320029C0, 0x3D403080, 0x29402F00, - 0x308031C0, 0x2F203DC0, 0x31802900, 0x3E8030C0, - 0x28802F40, 0x30C03140, 0x2F203F40, 0x31402840, - 0x28003100, 0x28002F00, 0x00003100, -}; static Bool i830_tv_mode_fixup(xf86OutputPtr output, DisplayModePtr mode, - DisplayModePtr adjusted_mode) + DisplayModePtr adjusted_mode) { - ScrnInfoPtr pScrn = output->scrn; - xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); - int i; + ScrnInfoPtr pScrn = output->scrn; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); + int i; - for (i = 0; i < xf86_config->num_output; i++) { - xf86OutputPtr other_output = xf86_config->output[i]; + for (i = 0; i < xf86_config->num_output; i++) { + xf86OutputPtr other_output = xf86_config->output[i]; - if (other_output != output && other_output->crtc == output->crtc) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Can't enable TV and another output on the same " - "pipe\n"); - return FALSE; + if (other_output != output && other_output->crtc == output->crtc) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Can't enable TV and another output on the same " + "pipe\n"); + return FALSE; + } } - } - /* XXX: fill me in */ + /* XXX: fill me in */ - return TRUE; + return TRUE; } static CARD32 @@ -633,10 +933,10 @@ i830_float_to_csc (float fin) CARD32 mant; CARD32 ret; float f = fin; - + /* somehow the color conversion knows the signs of all the values */ if (f < 0) f = -f; - + if (f >= 1) { exp = 0x7; @@ -665,7 +965,7 @@ i830_float_to_luma (float f) static void i830_tv_mode_set(xf86OutputPtr output, DisplayModePtr mode, - DisplayModePtr adjusted_mode) + DisplayModePtr adjusted_mode) { ScrnInfoPtr pScrn = output->scrn; I830Ptr pI830 = I830PTR(pScrn); @@ -674,53 +974,52 @@ i830_tv_mode_set(xf86OutputPtr output, DisplayModePtr mode, I830CrtcPrivatePtr intel_crtc = crtc->driver_private; struct i830_tv_priv *dev_priv = intel_output->dev_priv; const tv_mode_t *tv_mode; - CARD32 tv_ctl, tv_filter_ctl; + CARD32 tv_ctl; CARD32 hctl1, hctl2, hctl3; CARD32 vctl1, vctl2, vctl3, vctl4, vctl5, vctl6, vctl7; CARD32 scctl1, scctl2, scctl3; - int i; + int i, j; const video_levels_t *video_levels; const color_conversion_t *color_conversion; - Bool burst_ena; - - /* Need to actually choose or construct the appropriate - * mode. For now, just set the first one in the list, with - * NTSC format. - */ - tv_mode = &tv_modes[0]; - + Bool burst_ena; + for (i = 0; i < sizeof(tv_modes) / sizeof (tv_modes[0]); i++) { + tv_mode = &tv_modes[i]; + if (strstr(mode->name, tv_mode->name)) + break; + } tv_ctl = 0; switch (dev_priv->type) { - default: - case TV_TYPE_UNKNOWN: - case TV_TYPE_COMPOSITE: - tv_ctl |= TV_ENC_OUTPUT_COMPOSITE; - video_levels = &tv_mode->composite_levels; - color_conversion = &tv_mode->composite_color; - burst_ena = tv_mode->burst_ena; - break; - case TV_TYPE_COMPONENT: - tv_ctl |= TV_ENC_OUTPUT_COMPONENT; - video_levels = &component_level; - if (tv_mode->burst_ena) - color_conversion = &sdtv_component_color; - else - color_conversion = &hdtv_component_color; - burst_ena = FALSE; - break; - case TV_TYPE_SVIDEO: - tv_ctl |= TV_ENC_OUTPUT_SVIDEO; - video_levels = &tv_mode->svideo_levels; - color_conversion = &tv_mode->svideo_color; - burst_ena = tv_mode->burst_ena; - break; + default: + case TV_TYPE_UNKNOWN: + case TV_TYPE_COMPOSITE: + tv_ctl |= TV_ENC_OUTPUT_COMPOSITE; + video_levels = &tv_mode->composite_levels; + color_conversion = &tv_mode->composite_color; + burst_ena = tv_mode->burst_ena; + break; + case TV_TYPE_COMPONENT: + tv_ctl |= TV_ENC_OUTPUT_COMPONENT; + video_levels = &component_level; + if (tv_mode->burst_ena) + color_conversion = &sdtv_component_color; + else + color_conversion = &hdtv_component_color; + burst_ena = FALSE; + break; + case TV_TYPE_SVIDEO: + tv_ctl |= TV_ENC_OUTPUT_SVIDEO; + video_levels = &tv_mode->svideo_levels; + color_conversion = &tv_mode->svideo_color; + burst_ena = tv_mode->burst_ena; + break; } hctl1 = (tv_mode->hsync_end << TV_HSYNC_END_SHIFT) | (tv_mode->htotal << TV_HTOTAL_SHIFT); hctl2 = (tv_mode->hburst_start << 16) | (tv_mode->hburst_len << TV_HBURST_LEN_SHIFT); + if (burst_ena) hctl2 |= TV_BURST_ENA; @@ -738,6 +1037,7 @@ i830_tv_mode_set(xf86OutputPtr output, DisplayModePtr mode, vctl3 = (tv_mode->veq_len << TV_VEQ_LEN_SHIFT) | (tv_mode->veq_start_f1 << TV_VEQ_START_F1_SHIFT) | (tv_mode->veq_start_f2 << TV_VEQ_START_F2_SHIFT); + if (tv_mode->veq_ena) vctl3 |= TV_EQUAL_ENA; @@ -755,21 +1055,24 @@ i830_tv_mode_set(xf86OutputPtr output, DisplayModePtr mode, if (intel_crtc->pipe == 1) tv_ctl |= TV_ENC_PIPEB_SELECT; - tv_ctl |= tv_mode->oversample; + if (tv_mode->progressive) tv_ctl |= TV_PROGRESSIVE; + if (tv_mode->trilevel_sync) + tv_ctl |= TV_TRILEVEL_SYNC; if (tv_mode->pal_burst) tv_ctl |= TV_PAL_BURST; + scctl1 = 0; + if (tv_mode->dda1_inc) + scctl1 |= TV_SC_DDA1_EN; - scctl1 = TV_SC_DDA1_EN; - if (tv_mode->dda2_inc) scctl1 |= TV_SC_DDA2_EN; - + if (tv_mode->dda3_inc) scctl1 |= TV_SC_DDA3_EN; - + scctl1 |= tv_mode->sc_reset; scctl1 |= video_levels->burst << TV_BURST_LEVEL_SHIFT; scctl1 |= tv_mode->dda1_inc << TV_SCDDA1_INC_SHIFT; @@ -784,10 +1087,6 @@ i830_tv_mode_set(xf86OutputPtr output, DisplayModePtr mode, if (pI830->PciInfo->chipType < PCI_CHIP_I945_G) tv_ctl |= TV_ENC_C0_FIX | TV_ENC_SDP_FIX; - tv_filter_ctl = TV_AUTO_SCALE; - if (mode->HDisplay > 1024) - tv_ctl |= TV_V_FILTER_BYPASS; - OUTREG(TV_H_CTL_1, hctl1); OUTREG(TV_H_CTL_2, hctl2); OUTREG(TV_H_CTL_3, hctl3); @@ -801,183 +1100,113 @@ i830_tv_mode_set(xf86OutputPtr output, DisplayModePtr mode, OUTREG(TV_SC_CTL_1, scctl1); OUTREG(TV_SC_CTL_2, scctl2); OUTREG(TV_SC_CTL_3, scctl3); - + OUTREG(TV_CSC_Y, - (i830_float_to_csc(color_conversion->ry) << 16) | - (i830_float_to_csc(color_conversion->gy))); + (i830_float_to_csc(color_conversion->ry) << 16) | + (i830_float_to_csc(color_conversion->gy))); OUTREG(TV_CSC_Y2, (i830_float_to_csc(color_conversion->by) << 16) | (i830_float_to_luma(color_conversion->ay))); - + OUTREG(TV_CSC_U, - (i830_float_to_csc(color_conversion->ru) << 16) | - (i830_float_to_csc(color_conversion->gu))); + (i830_float_to_csc(color_conversion->ru) << 16) | + (i830_float_to_csc(color_conversion->gu))); OUTREG(TV_CSC_U2, (i830_float_to_csc(color_conversion->bu) << 16) | (i830_float_to_luma(color_conversion->au))); - + OUTREG(TV_CSC_V, - (i830_float_to_csc(color_conversion->rv) << 16) | - (i830_float_to_csc(color_conversion->gv))); + (i830_float_to_csc(color_conversion->rv) << 16) | + (i830_float_to_csc(color_conversion->gv))); OUTREG(TV_CSC_V2, (i830_float_to_csc(color_conversion->bv) << 16) | (i830_float_to_luma(color_conversion->av))); - - OUTREG(TV_CLR_KNOBS, 0x00606000); - OUTREG(TV_CLR_LEVEL, ((video_levels->black << TV_BLACK_LEVEL_SHIFT) | - (video_levels->blank << TV_BLANK_LEVEL_SHIFT))); - - OUTREG(TV_WIN_POS, 0x00360024); - OUTREG(TV_WIN_SIZE, 0x02640198); - - OUTREG(TV_FILTER_CTL_1, 0x8000085E); - OUTREG(TV_FILTER_CTL_2, 0x00017878); - OUTREG(TV_FILTER_CTL_3, 0x0000BC3C); - for (i = 0; i < 60; i++) - OUTREG(TV_H_LUMA_0 + (i <<2), h_luma[i]); - for (i = 0; i < 60; i++) - OUTREG(TV_H_CHROMA_0 + (i <<2), h_chroma[i]); - for (i = 0; i < 43; i++) - OUTREG(TV_V_LUMA_0 + (i <<2), v_luma[i]); - for (i = 0; i < 43; i++) - OUTREG(TV_V_CHROMA_0 + (i <<2), v_chroma[i]); + OUTREG(TV_CLR_KNOBS, 0x10606000); + OUTREG(TV_CLR_LEVEL, ((video_levels->black << TV_BLACK_LEVEL_SHIFT) | + (video_levels->blank << TV_BLANK_LEVEL_SHIFT))); + { + int pipeconf_reg = (intel_crtc->pipe == 0)?PIPEACONF:PIPEBCONF; + int dspcntr_reg = (intel_crtc->pipe == 0)?DSPACNTR : DSPBCNTR; + int pipeconf = INREG(pipeconf_reg); + int dspcntr = INREG(dspcntr_reg); + int dspbase_reg = (intel_crtc->pipe == 0) ? DSPABASE : DSPBBASE; + int xpos = 0x0, ypos = 0x0; + unsigned int xsize, ysize; + /* Pipe must be off here */ + OUTREG(dspcntr_reg, dspcntr & ~DISPLAY_PLANE_ENABLE); + /* Flush the plane changes */ + OUTREG(dspbase_reg, INREG(dspbase_reg)); + + if (!IS_I9XX(pI830)) { + /* Wait for vblank for the disable to take effect */ + i830WaitForVblank(pScrn); + } + + OUTREG(pipeconf_reg, pipeconf & ~PIPEACONF_ENABLE); + /* Wait for vblank for the disable to take effect. */ + i830WaitForVblank(pScrn); + + /* Filter ctl must be set before TV_WIN_SIZE */ + OUTREG(TV_FILTER_CTL_1, TV_AUTO_SCALE); + xsize = tv_mode->hblank_start - tv_mode->hblank_end; + if (tv_mode->progressive) + ysize = tv_mode->nbr_end + 1; + else + ysize = 2*tv_mode->nbr_end + 1; + + OUTREG(TV_WIN_POS, (xpos<<16)|ypos); + OUTREG(TV_WIN_SIZE, (xsize<<16)|ysize); + + OUTREG(pipeconf_reg, pipeconf); + OUTREG(dspcntr_reg, dspcntr); + /* Flush the plane changes */ + OUTREG(dspbase_reg, INREG(dspbase_reg)); + } + + j = 0; + for (i = 0; i < 60; i++) + OUTREG(TV_H_LUMA_0 + (i<<2), tv_mode->filter_table[j++]); + for (i = 0; i < 60; i++) + OUTREG(TV_H_CHROMA_0 + (i<<2), tv_mode->filter_table[j++]); + for (i = 0; i < 43; i++) + OUTREG(TV_V_LUMA_0 + (i<<2), tv_mode->filter_table[j++]); + for (i = 0; i < 43; i++) + OUTREG(TV_V_CHROMA_0 + (i<<2), tv_mode->filter_table[j++]); OUTREG(TV_DAC, 0); OUTREG(TV_CTL, tv_ctl); } static const DisplayModeRec reported_modes[] = { - { - .name = "NTSC 480i", - .Clock = TV_PLL_CLOCK, - .HDisplay = 1280, - .HSyncStart = 1368, - .HSyncEnd = 1496, - .HTotal = 1712, + { + .name = "NTSC 480i", + .Clock = 107520, + .HDisplay = 1280, + .HSyncStart = 1368, + .HSyncEnd = 1496, + .HTotal = 1712, - .VDisplay = 1024, - .VSyncStart = 1027, - .VSyncEnd = 1034, - .VTotal = 1104, - .type = M_T_DRIVER - }, - { - .name = "NTSC 480i", - .Clock = TV_PLL_CLOCK, - .HDisplay = 1024, - .HSyncStart = 1080, - .HSyncEnd = 1184, - .HTotal = 1344, - - .VDisplay = 768, - .VSyncStart = 771, - .VSyncEnd = 777, - .VTotal = 806, - .type = M_T_DRIVER - }, - { - .name = "NTSC 480i", - .Clock = TV_PLL_CLOCK, - .HDisplay = 800, - .HSyncStart = 832, - .HSyncEnd = 912, - .HTotal = 1024, - - .VDisplay = 600, - .VSyncStart = 603, - .VSyncEnd = 607, - .VTotal = 650, - .type = M_T_DRIVER - }, - { - .name = "NTSC 480i", - .Clock = TV_PLL_CLOCK, - .HDisplay = 640, - .HSyncStart = 664, - .HSyncEnd = 720, - .HTotal = 800, - - .VDisplay = 480, - .VSyncStart = 483, - .VSyncEnd = 487, - .VTotal = 552, - .type = M_T_DRIVER - }, - { - .name = "PAL 576i", - .Clock = TV_PLL_CLOCK, - .HDisplay = 1280, - .HSyncStart = 1352, - .HSyncEnd = 1480, - .HTotal = 1680, - - .VDisplay = 1024, - .VSyncStart = 1027, - .VSyncEnd = 1034, - .VTotal = 1092, - - .type = M_T_DRIVER - }, - { - .name = "PAL 576i", - .Clock = TV_PLL_CLOCK, - .HDisplay = 1024, - .HSyncStart = 1072, - .HSyncEnd = 1168, - .HTotal = 1312, - .VDisplay = 768, - .VSyncStart = 771, - .VSyncEnd = 775, - .VTotal = 820, - .VRefresh = 50.0f, - - .type = M_T_DRIVER - }, - { - .name = "PAL 576i", - .Clock = TV_PLL_CLOCK, - .HDisplay = 800, - .HSyncStart = 832, - .HSyncEnd = 904, - .HTotal = 1008, - .VDisplay = 600, - .VSyncStart = 603, - .VSyncEnd = 607, - .VTotal = 642, - .VRefresh = 50.0f, - - .type = M_T_DRIVER - }, - { - .name = "PAL 576i", - .Clock = TV_PLL_CLOCK, - .HDisplay = 640, - .HSyncStart = 664, - .HSyncEnd = 720, - .HTotal = 800, - - .VDisplay = 480, - .VSyncStart = 483, - .VSyncEnd = 487, - .VTotal = 516, - .VRefresh = 50.0f, - .type = M_T_DRIVER - }, + .VDisplay = 1024, + .VSyncStart = 1027, + .VSyncEnd = 1034, + .VTotal = 1104, + .type = M_T_DRIVER + }, }; /** * Detects TV presence by checking for load. * * Requires that the current pipe's DPLL is active. - + * \return TRUE if TV is connected. * \return FALSE if TV is disconnected. */ static void i830_tv_detect_type (xf86CrtcPtr crtc, - xf86OutputPtr output) + xf86OutputPtr output) { ScrnInfoPtr pScrn = output->scrn; I830Ptr pI830 = I830PTR(pScrn); @@ -1002,13 +1231,13 @@ i830_tv_detect_type (xf86CrtcPtr crtc, tv_ctl |= TV_TEST_MODE_MONITOR_DETECT; tv_dac &= ~TVDAC_SENSE_MASK; tv_dac |= (TVDAC_STATE_CHG_EN | - TVDAC_A_SENSE_CTL | - TVDAC_B_SENSE_CTL | - TVDAC_C_SENSE_CTL | - DAC_CTL_OVERRIDE | - DAC_A_0_7_V | - DAC_B_0_7_V | - DAC_C_0_7_V); + TVDAC_A_SENSE_CTL | + TVDAC_B_SENSE_CTL | + TVDAC_C_SENSE_CTL | + DAC_CTL_OVERRIDE | + DAC_A_0_7_V | + DAC_B_0_7_V | + DAC_C_0_7_V); OUTREG(TV_CTL, tv_ctl); OUTREG(TV_DAC, tv_dac); i830WaitForVblank(pScrn); @@ -1024,22 +1253,22 @@ i830_tv_detect_type (xf86CrtcPtr crtc, */ if ((tv_dac & TVDAC_SENSE_MASK) == (TVDAC_B_SENSE | TVDAC_C_SENSE)) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Detected Composite TV connection\n"); + "Detected Composite TV connection\n"); type = TV_TYPE_COMPOSITE; } else if ((tv_dac & (TVDAC_A_SENSE|TVDAC_B_SENSE)) == TVDAC_A_SENSE) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Detected S-Video TV connection\n"); + "Detected S-Video TV connection\n"); type = TV_TYPE_SVIDEO; } else if ((tv_dac & TVDAC_SENSE_MASK) == 0) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Detected Component TV connection\n"); + "Detected Component TV connection\n"); type = TV_TYPE_COMPONENT; } else { xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "No TV connection detected\n"); + "No TV connection detected\n"); type = TV_TYPE_NONE; } - + dev_priv->type = type; } @@ -1060,55 +1289,108 @@ i830_tv_detect(xf86OutputPtr output) crtc = i830GetLoadDetectPipe (output); if (crtc) { - if (intel_output->load_detect_temp) - { - /* we only need the pixel clock set correctly here */ - mode = reported_modes[0]; - xf86SetModeCrtc (&mode, INTERLACE_HALVE_V); - xf86CrtcSetMode (crtc, &mode, RR_Rotate_0, 0, 0); - } - i830_tv_detect_type (crtc, output); - i830ReleaseLoadDetectPipe (output); + if (intel_output->load_detect_temp) + { + /* we only need the pixel clock set correctly here */ + mode = reported_modes[0]; + xf86SetModeCrtc (&mode, INTERLACE_HALVE_V); + crtc->funcs->mode_set(crtc, &mode, &mode, 0, 0); + } + i830_tv_detect_type (crtc, output); + i830ReleaseLoadDetectPipe (output); } - + switch (dev_priv->type) { case TV_TYPE_NONE: - return XF86OutputStatusDisconnected; + return XF86OutputStatusDisconnected; case TV_TYPE_UNKNOWN: - return XF86OutputStatusUnknown; + return XF86OutputStatusUnknown; default: - return XF86OutputStatusConnected; + return XF86OutputStatusConnected; } } +struct input_res { + char *name; + int w, h; +} input_res_table[] = +{ + {"640x480", 640, 480}, + {"800x600", 800, 600}, + {"1024x768", 1024, 768}, + {"1280x1024", 1280, 1024}, + {"848x480", 848, 480}, + {"1280x720", 1280, 720}, +}; + /** * Stub get_modes function. * * This should probably return a set of fixed modes, unless we can figure out * how to probe modes off of TV connections. */ + static DisplayModePtr i830_tv_get_modes(xf86OutputPtr output) { - ScrnInfoPtr pScrn = output->scrn; - I830Ptr pI830 = I830PTR(pScrn); - DisplayModePtr new, first = NULL, *tail = &first; - int i; + DisplayModePtr ret = NULL, mode_ptr; + int i, j; + I830OutputPrivatePtr intel_output = output->driver_private; + struct i830_tv_priv *dev_priv = intel_output->dev_priv; - (void) pI830; - - for (i = 0; i < sizeof (reported_modes) / sizeof (reported_modes[0]); i++) + for (i = 0; i < sizeof(tv_modes) / sizeof (tv_modes[0]); i++) { - new = xnfcalloc(1, sizeof (DisplayModeRec)); + const tv_mode_t *tv_mode = &tv_modes[i]; + unsigned int hactive = tv_mode->hblank_start - tv_mode->hblank_end; + unsigned int vactive = tv_mode->progressive + ?tv_mode->nbr_end + 1: 2*(tv_mode->nbr_end + 1); + unsigned int htotal = tv_mode->htotal + 1; + unsigned int vtotal = tv_mode->progressive + ?tv_mode->nbr_end + 1 + tv_mode->vi_end_f2: + 2*(tv_mode->nbr_end+1) + 2*(tv_mode->vi_end_f2); - *new = reported_modes[i]; - new->name = xnfalloc(strlen(reported_modes[i].name) + 1); - strcpy(new->name, reported_modes[i].name); - *tail = new; - tail = &new->next; + if (dev_priv->type != TV_TYPE_COMPONENT && tv_mode->component_only) + continue; + + for (j = 0; j < sizeof(input_res_table)/sizeof(input_res_table[0]); j++) { + struct input_res *input = &input_res_table[j]; + unsigned int hactive_s = input->w; + unsigned int vactive_s = input->h; + unsigned int htotal_s = htotal*hactive_s/hactive; + unsigned int vtotal_s = vtotal*vactive_s/vactive; + if (tv_mode->max_srcw && input->w > tv_mode->max_srcw) + continue; + if (input->w > 1024 && (!tv_mode->progressive + && !tv_mode->component_only)) + continue; + mode_ptr = xnfcalloc(1, sizeof(DisplayModeRec)); + mode_ptr->name = xnfalloc(strlen(tv_mode->name) + + strlen(input->name) + 4); + sprintf(mode_ptr->name, "%s %s", tv_mode->name, input->name); + + mode_ptr->Clock = tv_mode->clock; + + mode_ptr->HDisplay = hactive_s; + mode_ptr->HSyncStart = hactive_s + 1; + mode_ptr->HSyncEnd = htotal_s - 20; + if ( mode_ptr->HSyncEnd <= mode_ptr->HSyncStart) + mode_ptr->HSyncEnd = mode_ptr->HSyncStart + 1; + mode_ptr->HTotal = htotal_s; + + mode_ptr->VDisplay = vactive_s; + mode_ptr->VSyncStart = vactive_s + 1; + mode_ptr->VSyncEnd = vtotal_s - 20; + if ( mode_ptr->VSyncEnd <= mode_ptr->VSyncStart) + mode_ptr->VSyncEnd = mode_ptr->VSyncStart + 1; + mode_ptr->VTotal = vtotal_s; + + mode_ptr->type = M_T_DRIVER; + mode_ptr->next = ret; + ret = mode_ptr; + } } - return first; + return ret; } static void @@ -1138,7 +1420,7 @@ i830_tv_init(ScrnInfoPtr pScrn) I830OutputPrivatePtr intel_output; struct i830_tv_priv *dev_priv; CARD32 tv_dac_on, tv_dac_off, save_tv_dac; - + if ((INREG(TV_CTL) & TV_FUSE_STATE_MASK) == TV_FUSE_STATE_DISABLED) return; @@ -1147,31 +1429,31 @@ i830_tv_init(ScrnInfoPtr pScrn) * DAC register holds a value */ save_tv_dac = INREG(TV_DAC); - + OUTREG(TV_DAC, save_tv_dac | TVDAC_STATE_CHG_EN); tv_dac_on = INREG(TV_DAC); - + OUTREG(TV_DAC, save_tv_dac & ~TVDAC_STATE_CHG_EN); tv_dac_off = INREG(TV_DAC); - + OUTREG(TV_DAC, save_tv_dac); - + /* * If the register does not hold the state change enable * bit, (either as a 0 or a 1), assume it doesn't really * exist */ if ((tv_dac_on & TVDAC_STATE_CHG_EN) == 0 || - (tv_dac_off & TVDAC_STATE_CHG_EN) != 0) + (tv_dac_off & TVDAC_STATE_CHG_EN) != 0) return; - + output = xf86OutputCreate (pScrn, &i830_tv_output_funcs, "TV"); - + if (!output) return; - + intel_output = xnfcalloc (sizeof (I830OutputPrivateRec) + - sizeof (struct i830_tv_priv), 1); + sizeof (struct i830_tv_priv), 1); if (!intel_output) { xf86OutputDestroy (output); @@ -1181,7 +1463,7 @@ i830_tv_init(ScrnInfoPtr pScrn) intel_output->type = I830_OUTPUT_TVOUT; intel_output->dev_priv = dev_priv; dev_priv->type = TV_TYPE_UNKNOWN; - + output->driver_private = intel_output; output->interlaceAllowed = FALSE; output->doubleScanAllowed = FALSE; From 98318dfcc99264fb7b7ef34568712812aa6300b6 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Fri, 9 Feb 2007 16:20:57 +0200 Subject: [PATCH 09/29] add missing files to fix distcheck A bunch of files were missing from _SOURCES, and the build was also broken for missing files (from EXTRA_DIST) when building without gen4asm. --- src/Makefile.am | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index f824a747..6c63cc41 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -94,7 +94,16 @@ intel_drv_la_SOURCES = \ i830_xaa.c \ i830_render.c \ i915_render.c \ - i965_render.c + i965_render.c \ + i830_xf86Rename.h \ + local_xf86Rename.h \ + xf86Parser.h \ + xf86Optrec.h \ + i830_randr.h + +EXTRA_DIST = \ + packed_yuv_sf.g4a \ + packed_yuv_wm.g4a if HAVE_GEN4ASM sf_prog.h: packed_yuv_sf.g4a @@ -109,6 +118,14 @@ exa_wm_nomask_prog.h: exa_wm_nomask.g4a intel-gen4asm -o exa_wm_nomask_prog.h exa_wm_nomask.g4a exa_wm_masknoca_prog.h: exa_wm_masknoca.g4a intel-gen4asm -o exa_wm_masknoca_prog.h exa_wm_masknoca.g4a +else +EXTRA_DIST += \ + sf_prog.h \ + wm_prog.h \ + exa_sf_prog.h \ + exa_sf_mask_prog.h \ + exa_wm_nomask_prog.h \ + exa_wm_masknoca_prog.h endif if DRI @@ -120,10 +137,6 @@ intel_drv_la_SOURCES += \ i830_dri.h endif -EXTRA_DIST = \ - packed_yuv_sf.g4a \ - packed_yuv_wm.g4a - install-data-local: install-intel_drv_laLTLIBRARIES (cd $(DESTDIR)$(intel_drv_ladir) && rm -f i810_drv.so && ln -s intel_drv.so i810_drv.so) From c3aed56d46baba057d83dc6ea12c6b4e705e54ba Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 9 Feb 2007 13:16:37 -0800 Subject: [PATCH 10/29] Fix comments on 965 pitch alignment restrictions. --- src/i830_exa.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/i830_exa.c b/src/i830_exa.c index c3a4c401..42552d44 100644 --- a/src/i830_exa.c +++ b/src/i830_exa.c @@ -346,7 +346,8 @@ I830EXAInit(ScreenPtr pScreen) * i965 limits 3D surface to 4kB-aligned offset if tiled. * i965 limits 3D surfaces to w,h of ?,8192. * i965 limits 3D surface to pitch of 1B - 128kB. - * i965 limits 3D surface pitch alignment to 512B, only if tiled. + * i965 limits 3D surface pitch alignment to 1 or 2 times the element size. + * i965 limits 3D surface pitch alignment to 512B if tiled. * i965 limits 3D destination drawing rect to w,h of 8192,8192. * * i915 limits 3D textures to 4B-aligned offset if un-tiled. From 991439d4c78cf5b2a8f6bb8f5b36fffbfcc4e4fc Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 13 Feb 2007 10:07:47 -0800 Subject: [PATCH 11/29] Remove dead #if 0-ed structure. --- src/i830.h | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/i830.h b/src/i830.h index 42933f92..57d8da18 100644 --- a/src/i830.h +++ b/src/i830.h @@ -232,21 +232,6 @@ enum last_3d { LAST_3D_ROTATION }; -#if 0 -typedef struct _I830PipeRec { - Bool enabled; - int x; - int y; - Bool cursorInRange; - Bool cursorShown; - DisplayModeRec curMode; - DisplayModeRec desiredMode; -#ifdef RANDR_12_INTERFACE - RRCrtcPtr randr_crtc; -#endif -} I830PipeRec, *I830PipePtr; -#endif - typedef struct _I830Rec { unsigned char *MMIOBase; unsigned char *FbBase; From 6641aec0a1cbc869fba1956c556cdd204631545a Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 13 Feb 2007 10:21:12 -0800 Subject: [PATCH 12/29] Attempt to detect panel fixed mode from EDID or current programmed mode. These two sources are placed in higher priority to the BIOS data when available, since the BIOS data has proven unreliable. The BIOS data is still read, and warnings printed if it doesn't match what we probe. The BIOS data remains useful for the situation where we want to turn on LVDS but there is no EDID available and no current mode programmed (i.e. booting with VGA or TV connected). --- src/i830.h | 3 + src/i830_bios.c | 26 +++++---- src/i830_bios.h | 3 - src/i830_display.c | 85 +++++++++++++++++++++++++++ src/i830_display.h | 1 + src/i830_driver.c | 2 +- src/i830_lvds.c | 139 +++++++++++++++++++++++++++++++++------------ 7 files changed, 208 insertions(+), 51 deletions(-) diff --git a/src/i830.h b/src/i830.h index 57d8da18..96972eb5 100644 --- a/src/i830.h +++ b/src/i830.h @@ -590,6 +590,9 @@ extern Bool I830I2CInit(ScrnInfoPtr pScrn, I2CBusPtr *bus_ptr, int i2c_reg, /* return a mask of output indices matching outputs against type_mask */ int i830_output_clones (ScrnInfoPtr pScrn, int type_mask); +/* i830_bios.c */ +DisplayModePtr i830_bios_get_panel_mode(ScrnInfoPtr pScrn); + /* i830_display.c */ Bool i830PipeHasType (xf86CrtcPtr crtc, int type); diff --git a/src/i830_bios.c b/src/i830_bios.c index a9ef474d..cb886b54 100644 --- a/src/i830_bios.c +++ b/src/i830_bios.c @@ -122,8 +122,16 @@ i830GetBIOS(ScrnInfoPtr pScrn) return bios; } -Bool -i830GetLVDSInfoFromBIOS(ScrnInfoPtr pScrn) +/** + * Returns the BIOS's fixed panel mode. + * + * Note that many BIOSes will have the appropriate tables for a panel even when + * a panel is not attached. Additionally, many BIOSes adjust table sizes or + * offsets, such that this parsing fails. Thus, almost any other method for + * detecting the panel mode is preferable. + */ +DisplayModePtr +i830_bios_get_panel_mode(ScrnInfoPtr pScrn) { I830Ptr pI830 = I830PTR(pScrn); struct vbt_header *vbt; @@ -131,12 +139,11 @@ i830GetLVDSInfoFromBIOS(ScrnInfoPtr pScrn) int vbt_off, bdb_off, bdb_block_off, block_size; int panel_type = -1; unsigned char *bios; - Bool found_panel_info = FALSE; bios = i830GetBIOS(pScrn); if (bios == NULL) - return FALSE; + return NULL; vbt_off = INTEL_BIOS_16(0x1a); vbt = (struct vbt_header *)(bios + vbt_off); @@ -146,7 +153,7 @@ i830GetLVDSInfoFromBIOS(ScrnInfoPtr pScrn) if (memcmp(bdb->signature, "BIOS_DATA_BLOCK ", 16) != 0) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Bad BDB signature\n"); xfree(bios); - return FALSE; + return NULL; } for (bdb_block_off = bdb->header_size; bdb_block_off < bdb->bdb_size; @@ -163,7 +170,6 @@ i830GetLVDSInfoFromBIOS(ScrnInfoPtr pScrn) id = INTEL_BIOS_8(start); block_size = INTEL_BIOS_16(start + 1) + 3; - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Found BDB block type %d\n", id); switch (id) { case 40: lvds1 = (struct lvds_bdb_1 *)(bios + start); @@ -227,13 +233,11 @@ i830GetLVDSInfoFromBIOS(ScrnInfoPtr pScrn) "Found panel mode in BIOS VBT tables:\n"); xf86PrintModeline(pScrn->scrnIndex, fixed_mode); - pI830->panel_fixed_mode = fixed_mode; - - found_panel_info = TRUE; - break; + xfree(bios); + return fixed_mode; } } xfree(bios); - return found_panel_info; + return NULL; } diff --git a/src/i830_bios.h b/src/i830_bios.h index 9bd0db8a..881d5c86 100644 --- a/src/i830_bios.h +++ b/src/i830_bios.h @@ -114,6 +114,3 @@ struct lvds_bdb_2 { CARD8 table_size; /* not sure on this one */ struct lvds_bdb_2_entry panels[16]; } __attribute__((packed)); - -Bool -i830GetLVDSInfoFromBIOS(ScrnInfoPtr pScrn); diff --git a/src/i830_display.c b/src/i830_display.c index 82029850..345eea9f 100644 --- a/src/i830_display.c +++ b/src/i830_display.c @@ -1132,6 +1132,91 @@ i830ReleaseLoadDetectPipe(xf86OutputPtr output) } } +/* Returns the clock of the currently programmed mode of the given pipe. */ +static int +i830_crtc_clock_get(ScrnInfoPtr pScrn, xf86CrtcPtr crtc) +{ + I830Ptr pI830 = I830PTR(pScrn); + I830CrtcPrivatePtr intel_crtc = crtc->driver_private; + int pipe = intel_crtc->pipe; + CARD32 dpll = INREG((pipe == 0) ? DPLL_A : DPLL_B); + CARD32 fp; + intel_clock_t clock; + + if ((dpll & DISPLAY_RATE_SELECT_FPA1) == 0) + fp = INREG((pipe == 0) ? FPA0 : FPB0); + else + fp = INREG((pipe == 0) ? FPA1 : FPB1); + + clock.m1 = (fp & FP_M1_DIV_MASK) >> FP_M1_DIV_SHIFT; + clock.m2 = (fp & FP_M2_DIV_MASK) >> FP_M2_DIV_SHIFT; + clock.n = (fp & FP_N_DIV_MASK) >> FP_N_DIV_SHIFT; + clock.p1 = ffs((dpll & DPLL_FPA01_P1_POST_DIV_MASK) >> + DPLL_FPA01_P1_POST_DIV_SHIFT); + switch (dpll & DPLL_MODE_MASK) { + case DPLLB_MODE_DAC_SERIAL: + clock.p2 = dpll & DPLL_DAC_SERIAL_P2_CLOCK_DIV_5 ? 5 : 10; + break; + case DPLLB_MODE_LVDS: + clock.p2 = dpll & DPLLB_LVDS_P2_CLOCK_DIV_7 ? 7 : 14; + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Unknown DPLL mode %08x in programmed mode\n", + (int)(dpll & DPLL_MODE_MASK)); + return 0; + } + + /* XXX: Handle the 100Mhz refclk */ + if (IS_I9XX(pI830)) + i9xx_clock(96000, &clock); + else + i9xx_clock(48000, &clock); + + if (!i830PllIsValid(crtc, &clock)) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Bad clock found programmed in pipe %c\n", + pipe == 0 ? 'A' : 'B'); + i830PrintPll("", &clock); + } + + return clock.dot; +} + +/** Returns the currently programmed mode of the given pipe. */ +DisplayModePtr +i830_crtc_mode_get(ScrnInfoPtr pScrn, xf86CrtcPtr crtc) +{ + I830Ptr pI830 = I830PTR(pScrn); + I830CrtcPrivatePtr intel_crtc = crtc->driver_private; + int pipe = intel_crtc->pipe; + DisplayModePtr mode; + int htot = INREG((pipe == 0) ? HTOTAL_A : HTOTAL_B); + int hsync = INREG((pipe == 0) ? HSYNC_A : HSYNC_B); + int vtot = INREG((pipe == 0) ? VTOTAL_A : VTOTAL_B); + int vsync = INREG((pipe == 0) ? VSYNC_A : VSYNC_B); + + mode = xcalloc(1, sizeof(DisplayModeRec)); + if (mode == NULL) + return NULL; + + memset(mode, 0, sizeof(*mode)); + + mode->Clock = i830_crtc_clock_get(pScrn, crtc); + mode->HDisplay = (htot & 0xffff) + 1; + mode->HTotal = ((htot & 0xffff0000) >> 16) + 1; + mode->HSyncStart = (hsync & 0xffff) + 1; + mode->HSyncEnd = ((hsync & 0xffff0000) >> 16) + 1; + mode->VDisplay = (vtot & 0xffff) + 1; + mode->VTotal = ((vtot & 0xffff0000) >> 16) + 1; + mode->VSyncStart = (vsync & 0xffff) + 1; + mode->VSyncEnd = ((vsync & 0xffff0000) >> 16) + 1; + xf86SetModeDefaultName(mode); + xf86SetModeCrtc(mode, 0); + + return mode; +} + static const xf86CrtcFuncsRec i830_crtc_funcs = { .dpms = i830_crtc_dpms, .save = NULL, /* XXX */ diff --git a/src/i830_display.h b/src/i830_display.h index dc800553..dbd1ea8e 100644 --- a/src/i830_display.h +++ b/src/i830_display.h @@ -39,3 +39,4 @@ xf86CrtcPtr i830GetLoadDetectPipe(xf86OutputPtr output); void i830ReleaseLoadDetectPipe(xf86OutputPtr output); void i830_crtc_init(ScrnInfoPtr pScrn, int pipe); void i830_crtc_load_lut(xf86CrtcPtr crtc); +DisplayModePtr i830_crtc_mode_get(ScrnInfoPtr pScrn, xf86CrtcPtr crtc); diff --git a/src/i830_driver.c b/src/i830_driver.c index 0f663115..cb3dd878 100644 --- a/src/i830_driver.c +++ b/src/i830_driver.c @@ -1332,10 +1332,10 @@ I830PreInit(ScrnInfoPtr pScrn, int flags) } I830PreInitDDC(pScrn); - I830SetupOutputs(pScrn); for (i = 0; i < num_pipe; i++) { i830_crtc_init(pScrn, i); } + I830SetupOutputs(pScrn); SaveHWState(pScrn); /* Do an initial detection of the outputs while none are configured on yet. diff --git a/src/i830_lvds.c b/src/i830_lvds.c index 59af13b9..4c1afb05 100644 --- a/src/i830_lvds.c +++ b/src/i830_lvds.c @@ -32,6 +32,7 @@ #include "xf86.h" #include "i830.h" #include "i830_bios.h" +#include "i830_display.h" #include "X11/Xatom.h" /** @@ -406,42 +407,7 @@ i830_lvds_init(ScrnInfoPtr pScrn) I830Ptr pI830 = I830PTR(pScrn); xf86OutputPtr output; I830OutputPrivatePtr intel_output; - - - /* Get the LVDS fixed mode out of the BIOS. We should support LVDS with - * the BIOS being unavailable or broken, but lack the configuration options - * for now. - */ - if (!i830GetLVDSInfoFromBIOS(pScrn)) - return; - - /* Blacklist machines with BIOSes that list an LVDS panel without actually - * having one. - */ - if (pI830->PciInfo->chipType == PCI_CHIP_I945_GM) { - if (pI830->PciInfo->subsysVendor == 0xa0a0) /* aopen mini pc */ - return; - - if ((pI830->PciInfo->subsysVendor == 0x8086) && - (pI830->PciInfo->subsysCard == 0x7270)) { - /* It's a Mac Mini or Macbook Pro. - * - * Apple hardware is out to get us. The macbook pro has a real - * LVDS panel, but the mac mini does not, and they have the same - * device IDs. We'll distinguish by panel size, on the assumption - * that Apple isn't about to make any machines with an 800x600 - * display. - */ - - if (pI830->panel_fixed_mode != NULL && - pI830->panel_fixed_mode->HDisplay == 800 && - pI830->panel_fixed_mode->VDisplay == 600) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Suspected Mac Mini, ignoring the LVDS\n"); - return; - } - } - } + DisplayModePtr modes, scan, bios_mode; output = xf86OutputCreate (pScrn, &i830_lvds_output_funcs, "LVDS"); if (!output) @@ -462,4 +428,105 @@ i830_lvds_init(ScrnInfoPtr pScrn) * be useful if available. */ I830I2CInit(pScrn, &intel_output->pDDCBus, GPIOC, "LVDSDDC_C"); + + /* Attempt to get the fixed panel mode from DDC. Assume that the preferred + * mode is the right one. + */ + modes = i830_ddc_get_modes(output); + for (scan = modes; scan != NULL; scan = scan->next) { + if (scan->type & M_T_PREFERRED) + break; + } + if (scan != NULL) { + /* Pull our chosen mode out and make it the fixed mode */ + if (modes == scan) + modes = modes->next; + if (scan->prev != NULL) + scan->prev = scan->next; + if (scan->next != NULL) + scan->next = scan->prev; + pI830->panel_fixed_mode = scan; + } + /* Delete the mode list */ + while (modes != NULL) + xf86DeleteMode(&modes, modes); + + /* If we didn't get EDID, try checking if the panel is already turned on. + * If so, assume that whatever is currently programmed is the correct mode. + */ + if (pI830->panel_fixed_mode == NULL) { + CARD32 lvds = INREG(LVDS); + int pipe = (lvds & LVDS_PIPEB_SELECT) ? 1 : 0; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); + xf86CrtcPtr crtc = xf86_config->crtc[pipe]; + + if (lvds & LVDS_PORT_EN) { + pI830->panel_fixed_mode = i830_crtc_mode_get(pScrn, crtc); + if (pI830->panel_fixed_mode != NULL) + pI830->panel_fixed_mode->type |= M_T_PREFERRED; + } + } + + /* Get the LVDS fixed mode out of the BIOS. We should support LVDS with + * the BIOS being unavailable or broken, but lack the configuration options + * for now. + */ + bios_mode = i830_bios_get_panel_mode(pScrn); + if (bios_mode != NULL) { + if (pI830->panel_fixed_mode != NULL) { + if (!xf86ModesEqual(pI830->panel_fixed_mode, bios_mode)) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "BIOS panel mode data doesn't match probed data, " + "continuing with probed.\n"); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "BIOS mode:\n"); + xf86PrintModeline(pScrn->scrnIndex, bios_mode); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "probed mode:\n"); + xf86PrintModeline(pScrn->scrnIndex, pI830->panel_fixed_mode); + xfree(bios_mode->name); + xfree(bios_mode); + } + } else { + pI830->panel_fixed_mode = bios_mode; + } + } else { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Couldn't detect panel mode. Disabling panel\n"); + goto disable_exit; + } + + /* Blacklist machines with BIOSes that list an LVDS panel without actually + * having one. + */ + if (pI830->PciInfo->chipType == PCI_CHIP_I945_GM) { + if (pI830->PciInfo->subsysVendor == 0xa0a0) /* aopen mini pc */ + goto disable_exit; + + if ((pI830->PciInfo->subsysVendor == 0x8086) && + (pI830->PciInfo->subsysCard == 0x7270)) { + /* It's a Mac Mini or Macbook Pro. + * + * Apple hardware is out to get us. The macbook pro has a real + * LVDS panel, but the mac mini does not, and they have the same + * device IDs. We'll distinguish by panel size, on the assumption + * that Apple isn't about to make any machines with an 800x600 + * display. + */ + + if (pI830->panel_fixed_mode != NULL && + pI830->panel_fixed_mode->HDisplay == 800 && + pI830->panel_fixed_mode->VDisplay == 600) + { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Suspected Mac Mini, ignoring the LVDS\n"); + goto disable_exit; + } + } + } + + return; + +disable_exit: + xf86DestroyI2CBusRec(intel_output->pDDCBus, TRUE, TRUE); + xfree(intel_output); + xf86OutputDestroy(output); } From 0ec4ffcb4e8e5e707e68bef1b13a324677f19f8f Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 13 Feb 2007 13:18:15 -0800 Subject: [PATCH 13/29] Fix double free in the case of LVDS disabled through quirks. --- src/i830_lvds.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/i830_lvds.c b/src/i830_lvds.c index 4c1afb05..642dd8a3 100644 --- a/src/i830_lvds.c +++ b/src/i830_lvds.c @@ -527,6 +527,5 @@ i830_lvds_init(ScrnInfoPtr pScrn) disable_exit: xf86DestroyI2CBusRec(intel_output->pDDCBus, TRUE, TRUE); - xfree(intel_output); xf86OutputDestroy(output); } From 4bd4058dfdca84d6ebab82a1dfba99adf3852c9c Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 13 Feb 2007 14:29:52 -0800 Subject: [PATCH 14/29] Bug #9941: ViewSonic VX2025wm sync polarity quirk to fix mode distortion. --- src/i830_edid_modes.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/i830_edid_modes.c b/src/i830_edid_modes.c index 1bab4cd8..866b9bef 100644 --- a/src/i830_edid_modes.c +++ b/src/i830_edid_modes.c @@ -66,7 +66,11 @@ static Bool quirk_dt_sync_hm_vp (int scrnIndex, xf86MonPtr DDC) if (memcmp (DDC->vendor.name, "MAX", 4) == 0 && DDC->vendor.prod_id == 2007) return TRUE; - + /* ViewSonic VX2025wm (bug #9941) */ + if (memcmp (DDC->vendor.name, "VSC", 4) == 0 && + DDC->vendor.prod_id == 58653) + return TRUE; + return FALSE; } From 1623b47c4863f5362587cdac855e3e11c109b007 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 13 Feb 2007 17:37:56 -0800 Subject: [PATCH 15/29] Switch the RECTLIST vertex order to (x2, y2), (x1, y2), (x1, y1). This is the documented correct ordering, and while the previous ordering (reversed) worked on some hardware, it failed on others. Reported by: Wang Zhenyu --- src/i830_render.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/i830_render.c b/src/i830_render.c index 96aeb3fa..49d8fc11 100644 --- a/src/i830_render.c +++ b/src/i830_render.c @@ -557,13 +557,13 @@ i830_composite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, OUT_RING(PRIM3D_INLINE | PRIM3D_RECTLIST | (vertex_count-1)); - OUT_RING_F(-0.125 + dstX); - OUT_RING_F(-0.125 + dstY); - OUT_RING_F(src_x[0] / pI830->scale_units[0][0]); - OUT_RING_F(src_y[0] / pI830->scale_units[0][1]); + OUT_RING_F(-0.125 + dstX + w); + OUT_RING_F(-0.125 + dstY + h); + OUT_RING_F(src_x[2] / pI830->scale_units[0][0]); + OUT_RING_F(src_y[2] / pI830->scale_units[0][1]); if (has_mask) { - OUT_RING_F(mask_x[0] / pI830->scale_units[1][0]); - OUT_RING_F(mask_y[0] / pI830->scale_units[1][1]); + OUT_RING_F(mask_x[2] / pI830->scale_units[1][0]); + OUT_RING_F(mask_y[2] / pI830->scale_units[1][1]); } OUT_RING_F(-0.125 + dstX); @@ -575,13 +575,13 @@ i830_composite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, OUT_RING_F(mask_y[1] / pI830->scale_units[1][1]); } - OUT_RING_F(-0.125 + dstX + w); - OUT_RING_F(-0.125 + dstY + h); - OUT_RING_F(src_x[2] / pI830->scale_units[0][0]); - OUT_RING_F(src_y[2] / pI830->scale_units[0][1]); + OUT_RING_F(-0.125 + dstX); + OUT_RING_F(-0.125 + dstY); + OUT_RING_F(src_x[0] / pI830->scale_units[0][0]); + OUT_RING_F(src_y[0] / pI830->scale_units[0][1]); if (has_mask) { - OUT_RING_F(mask_x[2] / pI830->scale_units[1][0]); - OUT_RING_F(mask_y[2] / pI830->scale_units[1][1]); + OUT_RING_F(mask_x[0] / pI830->scale_units[1][0]); + OUT_RING_F(mask_y[0] / pI830->scale_units[1][1]); } ADVANCE_LP_RING(); } From a7c64d5e28f608d54c94fa7a5c92bd5b471179c7 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 14 Feb 2007 10:20:28 -0800 Subject: [PATCH 16/29] WIP DGA generic support. --- src/i830.h | 3 - src/i830_dga.c | 530 +++++++++++++++----------------------------- src/i830_driver.c | 4 +- src/i830_randr.c | 7 +- src/i830_xf86Crtc.h | 14 ++ 5 files changed, 195 insertions(+), 363 deletions(-) diff --git a/src/i830.h b/src/i830.h index 96972eb5..7a442d8c 100644 --- a/src/i830.h +++ b/src/i830.h @@ -521,9 +521,6 @@ extern void I830SelectBuffer(ScrnInfoPtr pScrn, int buffer); extern void I830RefreshRing(ScrnInfoPtr pScrn); extern void I830EmitFlush(ScrnInfoPtr pScrn); -extern Bool I830DGAReInit(ScreenPtr pScreen); -extern Bool I830DGAInit(ScreenPtr pScreen); - #ifdef I830_XV extern void I830InitVideo(ScreenPtr pScreen); extern void i830_crtc_dpms_video(xf86CrtcPtr crtc, Bool on); diff --git a/src/i830_dga.c b/src/i830_dga.c index 6d071ac3..817d96d9 100644 --- a/src/i830_dga.c +++ b/src/i830_dga.c @@ -41,407 +41,231 @@ #endif #include "xf86.h" +#include "xf86DDC.h" #include "xf86_OSproc.h" -#include "xf86Pci.h" -#include "xf86PciInfo.h" -#include "xaa.h" -#include "xaalocal.h" -#include "i830.h" -#include "i810_reg.h" #include "dgaproc.h" -#include "vgaHW.h" - -static Bool I830_OpenFramebuffer(ScrnInfoPtr, char **, unsigned char **, - int *, int *, int *); -static void I830_CloseFramebuffer(ScrnInfoPtr pScrn); -static Bool I830_SetMode(ScrnInfoPtr, DGAModePtr); -static void I830_Sync(ScrnInfoPtr); -static int I830_GetViewport(ScrnInfoPtr); -static void I830_SetViewport(ScrnInfoPtr, int, int, int); -static void I830_FillRect(ScrnInfoPtr, int, int, int, int, unsigned long); -static void I830_BlitRect(ScrnInfoPtr, int, int, int, int, int, int); - -#if 0 -static void I830_BlitTransRect(ScrnInfoPtr, int, int, int, int, int, int, - unsigned long); -#endif - -static -DGAFunctionRec I830DGAFuncs = { - I830_OpenFramebuffer, - I830_CloseFramebuffer, - I830_SetMode, - I830_SetViewport, - I830_GetViewport, - I830_Sync, - I830_FillRect, - I830_BlitRect, -#if 0 - I830_BlitTransRect -#else - NULL -#endif -}; +#include "i830_xf86Crtc.h" +#include "i830_xf86Modes.h" +#include "gcstruct.h" static DGAModePtr -I830DGAModes (ScreenPtr pScreen, int *nump) +xf86_dga_get_modes (ScreenPtr pScreen, int *nump) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - I830Ptr pI830 = I830PTR(pScrn); - DGAModePtr modes = NULL, newmodes = NULL, currentMode; - DisplayModePtr pMode, firstMode; - int Bpp = pScrn->bitsPerPixel >> 3; - int num = 0; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + DGAModePtr modes, mode; + DisplayModePtr display_mode; + int bpp = pScrn->bitsPerPixel >> 3; + int num; + PixmapPtr pPixmap = pScreen->GetScreenPixmap (pScreen); - pMode = firstMode = pScrn->modes; + if (!pPixmap) + return NULL; - while (pMode) { + num = 0; + display_mode = pScrn->modes; + while (display_mode) + { + num++; + display_mode = display_mode->next; + if (display_mode == pScrn->modes) + break; + } + + if (!num) + return NULL; + + modes = xalloc(num * sizeof(DGAModeRec)); + if (!modes) + return NULL; + + num = 0; + display_mode = pScrn->modes; + while (display_mode) + { + mode = modes + num++; - newmodes = xrealloc(modes, (num + 1) * sizeof(DGAModeRec)); + mode->mode = display_mode; + mode->flags = DGA_CONCURRENT_ACCESS | DGA_PIXMAP_AVAILABLE; + mode->flags |= DGA_FILL_RECT | DGA_BLIT_RECT; + if (display_mode->Flags & V_DBLSCAN) + mode->flags |= DGA_DOUBLESCAN; + if (display_mode->Flags & V_INTERLACE) + mode->flags |= DGA_INTERLACED; + mode->byteOrder = pScrn->imageByteOrder; + mode->depth = pScrn->depth; + mode->bitsPerPixel = pScrn->bitsPerPixel; + mode->red_mask = pScrn->mask.red; + mode->green_mask = pScrn->mask.green; + mode->blue_mask = pScrn->mask.blue; + mode->visualClass = (bpp == 1) ? PseudoColor : TrueColor; + mode->viewportWidth = display_mode->HDisplay; + mode->viewportHeight = display_mode->VDisplay; + mode->xViewportStep = (bpp == 3) ? 2 : 1; + mode->yViewportStep = 1; + mode->viewportFlags = DGA_FLIP_RETRACE; + mode->offset = 0; + mode->address = pPixmap->devPrivate.ptr; + mode->bytesPerScanline = pPixmap->devKind; + mode->imageWidth = pPixmap->drawable.width; + mode->imageHeight = pPixmap->drawable.height; + mode->pixmapWidth = mode->imageWidth; + mode->pixmapHeight = mode->imageHeight; + mode->maxViewportX = mode->imageWidth - mode->viewportWidth; + mode->maxViewportY = mode->imageHeight - mode->viewportHeight; - if (!newmodes) { - xfree(modes); - return NULL; - } - modes = newmodes; - - currentMode = modes + num; - num++; - - currentMode->mode = pMode; - currentMode->flags = DGA_CONCURRENT_ACCESS | DGA_PIXMAP_AVAILABLE; - if (!pI830->noAccel) - currentMode->flags |= DGA_FILL_RECT | DGA_BLIT_RECT; - if (pMode->Flags & V_DBLSCAN) - currentMode->flags |= DGA_DOUBLESCAN; - if (pMode->Flags & V_INTERLACE) - currentMode->flags |= DGA_INTERLACED; - currentMode->byteOrder = pScrn->imageByteOrder; - currentMode->depth = pScrn->depth; - currentMode->bitsPerPixel = pScrn->bitsPerPixel; - currentMode->red_mask = pScrn->mask.red; - currentMode->green_mask = pScrn->mask.green; - currentMode->blue_mask = pScrn->mask.blue; - currentMode->visualClass = (Bpp == 1) ? PseudoColor : TrueColor; - currentMode->viewportWidth = pMode->HDisplay; - currentMode->viewportHeight = pMode->VDisplay; - currentMode->xViewportStep = (Bpp == 3) ? 2 : 1; - currentMode->yViewportStep = 1; - currentMode->viewportFlags = DGA_FLIP_RETRACE; - currentMode->offset = 0; - if (I830IsPrimary(pScrn)) { - currentMode->address = pI830->FbBase + pI830->FrontBuffer.Start; - } else { - I830Ptr pI8301 = I830PTR(pI830->entityPrivate->pScrn_1); - currentMode->address = pI830->FbBase + pI8301->FrontBuffer2.Start; - } - - currentMode->bytesPerScanline = ((pI830->displayWidth * Bpp) + 3) & ~3L; - if (I830IsPrimary(pScrn)) { - currentMode->imageWidth = pI830->FbMemBox.x2; - currentMode->imageHeight = pI830->FbMemBox.y2; - } else { - I830Ptr pI8301 = I830PTR(pI830->entityPrivate->pScrn_1); - currentMode->imageWidth = pI8301->FbMemBox2.x2; - currentMode->imageHeight = pI8301->FbMemBox2.y2; - } - currentMode->pixmapWidth = currentMode->imageWidth; - currentMode->pixmapHeight = currentMode->imageHeight; - currentMode->maxViewportX = currentMode->imageWidth - - currentMode->viewportWidth; - /* this might need to get clamped to some maximum */ - currentMode->maxViewportY = currentMode->imageHeight - - currentMode->viewportHeight; - - pMode = pMode->next; - if (pMode == firstMode) - break; - } - *nump = num; - return modes; + display_mode = display_mode->next; + if (display_mode == pScrn->modes) + break; + } + *nump = num; + return modes; } -Bool -I830DGAReInit(ScreenPtr pScreen) -{ - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - I830Ptr pI830 = I830PTR(pScrn); - int num; - DGAModePtr modes; - - modes = I830DGAModes (pScreen, &num); - if (!modes) - return FALSE; - - if (pI830->DGAModes) - xfree (pI830->DGAModes); - - pI830->numDGAModes = num; - pI830->DGAModes = modes; - return DGAReInitModes (pScreen, modes, num); -} - -Bool -I830DGAInit(ScreenPtr pScreen) -{ - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - I830Ptr pI830 = I830PTR(pScrn); - int num; - DGAModePtr modes; - - modes = I830DGAModes (pScreen, &num); - if (!modes) - return FALSE; - - pI830->numDGAModes = num; - pI830->DGAModes = modes; - - return DGAInit(pScreen, &I830DGAFuncs, modes, num); -} - -static DisplayModePtr I830SavedDGAModes[MAXSCREENS]; - static Bool -I830_SetMode(ScrnInfoPtr pScrn, DGAModePtr pMode) +xf86_dga_set_mode(ScrnInfoPtr pScrn, DGAModePtr display_mode) { - int index = pScrn->pScreen->myNum; - I830Ptr pI830 = I830PTR(pScrn); + ScreenPtr pScreen = pScrn->pScreen; - MARKER(); + if (!display_mode) + xf86SwitchMode(pScreen, pScrn->currentMode); + else + xf86SwitchMode(pScreen, display_mode->mode); - if (!pMode) { /* restore the original mode */ - DPRINTF(PFX, "Restoring original mode (from DGA mode)\n"); - if (pI830->DGAactive) { - I830_CloseFramebuffer(pScrn); - pScrn->currentMode = I830SavedDGAModes[index]; - pScrn->SwitchMode(index, pScrn->currentMode, 0); - pScrn->AdjustFrame(index, 0, 0, 0); - pI830->DGAactive = FALSE; - } - } else { - if (!pI830->DGAactive) { - DPRINTF(PFX, "Setting DGA mode\n"); - I830SavedDGAModes[index] = pScrn->currentMode; - pI830->DGAactive = TRUE; - if (I830IsPrimary(pScrn)) { - pScrn->fbOffset = pI830->FrontBuffer.Start; - } - else { - I830Ptr pI8301 = I830PTR(pI830->entityPrivate->pScrn_1); - pScrn->fbOffset = pI8301->FrontBuffer2.Start; - } - pScrn->displayWidth = pI830->displayWidth; - I830SelectBuffer(pScrn, I830_SELECT_FRONT); - } - - pScrn->SwitchMode(index, pMode->mode, 0); - } - - return TRUE; + return TRUE; } static int -I830_GetViewport(ScrnInfoPtr pScrn) +xf86_dga_get_viewport(ScrnInfoPtr pScrn) { - I830Ptr pI830 = I830PTR(pScrn); - - MARKER(); - - return pI830->DGAViewportStatus; + return 0; } static void -I830_SetViewport(ScrnInfoPtr pScrn, int x, int y, int flags) +xf86_dga_set_viewport(ScrnInfoPtr pScrn, int x, int y, int flags) { - I830Ptr pI830 = I830PTR(pScrn); - vgaHWPtr hwp = VGAHWPTR(pScrn); - - MARKER(); - pScrn->AdjustFrame(pScrn->pScreen->myNum, x, y, flags); - - /* wait for retrace */ - while ((hwp->readST01(hwp) & 0x08)) ; - while (!(hwp->readST01(hwp) & 0x08)) ; - - pI830->DGAViewportStatus = 0; } static void -I830_FillRect(ScrnInfoPtr pScrn, - int x, int y, int w, int h, unsigned long color) +xf86_dga_fill_rect(ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned long color) { -#ifdef I830_USE_XAA - I830Ptr pI830 = I830PTR(pScrn); + ScreenPtr pScreen = pScrn->pScreen; + WindowPtr pRoot = WindowTable [pScreen->myNum]; + GCPtr pGC = GetScratchGC (pRoot->drawable.depth, pScreen); + XID vals[2]; + xRectangle r; - MARKER(); - - if (pI830->AccelInfoRec) { - (*pI830->AccelInfoRec->SetupForSolidFill) (pScrn, color, GXcopy, ~0); - (*pI830->AccelInfoRec->SubsequentSolidFillRect) (pScrn, x, y, w, h); - SET_SYNC_FLAG(pI830->AccelInfoRec); - } -#endif + if (!pGC) + return; + vals[0] = color; + vals[1] = IncludeInferiors; + ChangeGC (pGC, GCForeground|GCSubwindowMode, vals); + ValidateGC (&pRoot->drawable, pGC); + r.x = x; + r.y = y; + r.width = w; + r.height = h; + pGC->ops->PolyFillRect (&pRoot->drawable, pGC, 1, &r); + FreeScratchGC (pGC); } static void -I830_Sync(ScrnInfoPtr pScrn) +xf86_dga_sync(ScrnInfoPtr pScrn) { - I830Ptr pI830 = I830PTR(pScrn); - int flags = MI_WRITE_DIRTY_STATE | MI_INVALIDATE_MAP_CACHE; + ScreenPtr pScreen = pScrn->pScreen; + WindowPtr pRoot = WindowTable [pScreen->myNum]; + char buffer[4]; - MARKER(); - - if (pI830->noAccel) - return; - - if (IS_I965G(pI830)) - flags = 0; - - BEGIN_LP_RING(2); - OUT_RING(MI_FLUSH | flags); - OUT_RING(MI_NOOP); /* pad to quadword */ - ADVANCE_LP_RING(); - - I830WaitLpRing(pScrn, pI830->LpRing->mem.Size - 8, 0); - - pI830->LpRing->space = pI830->LpRing->mem.Size - 8; - pI830->nextColorExpandBuf = 0; + pScreen->GetImage (&pRoot->drawable, 0, 0, 1, 1, ZPixmap, ~0L, buffer); } static void -I830_BlitRect(ScrnInfoPtr pScrn, - int srcx, int srcy, int w, int h, int dstx, int dsty) +xf86_dga_blit_rect(ScrnInfoPtr pScrn, int srcx, int srcy, int w, int h, int dstx, int dsty) { -#ifdef I830_USE_XAA - I830Ptr pI830 = I830PTR(pScrn); + ScreenPtr pScreen = pScrn->pScreen; + WindowPtr pRoot = WindowTable [pScreen->myNum]; + GCPtr pGC = GetScratchGC (pRoot->drawable.depth, pScreen); + XID vals[1]; - MARKER(); - - if (pI830->AccelInfoRec) { - int xdir = ((srcx < dstx) && (srcy == dsty)) ? -1 : 1; - int ydir = (srcy < dsty) ? -1 : 1; - - (*pI830->AccelInfoRec->SetupForScreenToScreenCopy) (pScrn, xdir, ydir, - GXcopy, ~0, -1); - (*pI830->AccelInfoRec->SubsequentScreenToScreenCopy) (pScrn, srcx, srcy, - dstx, dsty, w, h); - SET_SYNC_FLAG(pI830->AccelInfoRec); - } -#endif + if (!pGC) + return; + vals[0] = IncludeInferiors; + ChangeGC (pGC, GCSubwindowMode, vals); + ValidateGC (&pRoot->drawable, pGC); + pGC->ops->CopyArea (&pRoot->drawable, &pRoot->drawable, pGC, + srcx, srcy, w, h, dstx, dsty); + FreeScratchGC (pGC); } -#if 0 -static void -I830_BlitTransRect(ScrnInfoPtr pScrn, - int srcx, int srcy, - int w, int h, int dstx, int dsty, unsigned long color) -{ - - MARKER(); - - /* this one should be separate since the XAA function would - * prohibit usage of ~0 as the key */ -} -#endif - static Bool -I830_OpenFramebuffer(ScrnInfoPtr pScrn, +xf86_dga_open_framebuffer(ScrnInfoPtr pScrn, char **name, unsigned char **mem, int *size, int *offset, int *flags) { - I830Ptr pI830 = I830PTR(pScrn); + ScreenPtr pScreen = pScrn->pScreen; + PixmapPtr pPixmap = pScreen->GetScreenPixmap (pScreen); + + if (!pPixmap) + return FALSE; + + *size = pPixmap->drawable.height * pPixmap->devKind; + *mem = (unsigned char *) (pScrn->memPhysBase + pScrn->fbOffset); + *offset = 0; + *flags = DGA_NEED_ROOT; - MARKER(); - - *name = NULL; /* no special device */ - if (I830IsPrimary(pScrn)) { - *size = pI830->FrontBuffer.Size; - *mem = (unsigned char *)(pI830->LinearAddr + pI830->FrontBuffer.Start); - pScrn->fbOffset = pI830->FrontBuffer.Start; - } - else { - I830Ptr pI8301 = I830PTR(pI830->entityPrivate->pScrn_1); - *size = pI8301->FrontBuffer2.Size; - *mem = (unsigned char *)(pI8301->LinearAddr + pI8301->FrontBuffer2.Start); - pScrn->fbOffset = pI8301->FrontBuffer2.Start; - } - pScrn->displayWidth = pI830->displayWidth; - I830SelectBuffer(pScrn, I830_SELECT_FRONT); - *offset = 0; - *flags = DGA_NEED_ROOT; - - DPRINTF(PFX, - " mem == 0x%.8x (pI830->LinearAddr)\n" - "size == %lu (pI830->FbMapSize)\n", *mem, *size); - - return TRUE; + return TRUE; } static void -I830_CloseFramebuffer(ScrnInfoPtr pScrn) +xf86_dga_close_framebuffer(ScrnInfoPtr pScrn) { - I830Ptr pI830 = I830PTR(pScrn); - int i; - /* Good pitches to allow tiling. Don't care about pitches < 1024. */ - static const int pitches[] = { -/* - 128 * 2, - 128 * 4, -*/ - 128 * 8, - 128 * 16, - 128 * 32, - 128 * 64, - 0 - }; - - if (I830IsPrimary(pScrn)) { - pScrn->fbOffset = pI830->FrontBuffer.Start; - } else { - I830Ptr pI8301 = I830PTR(pI830->entityPrivate->pScrn_1); - - pScrn->fbOffset = pI8301->FrontBuffer2.Start; - } - I830SelectBuffer(pScrn, I830_SELECT_FRONT); - - switch (pI830->rotation) { - case RR_Rotate_0: - pScrn->displayWidth = pI830->displayWidth; - break; - case RR_Rotate_90: - pScrn->displayWidth = pScrn->pScreen->width; - break; - case RR_Rotate_180: - pScrn->displayWidth = pI830->displayWidth; - break; - case RR_Rotate_270: - pScrn->displayWidth = pScrn->pScreen->width; - break; - } - - /* As DRI doesn't run on the secondary head, we know that disableTiling - * is always TRUE. - */ - if (I830IsPrimary(pScrn) && !pI830->disableTiling) { -#if 0 - int dWidth = pScrn->displayWidth; /* save current displayWidth */ -#endif - - for (i = 0; pitches[i] != 0; i++) { - if (pitches[i] >= pScrn->displayWidth) { - pScrn->displayWidth = pitches[i]; - break; - } - } - - /* - * If the displayWidth is a tilable pitch, test if there's enough - * memory available to enable tiling. - */ - if (pScrn->displayWidth == pitches[i]) { - /* TODO */ - } - } - } + +static DGAFunctionRec xf86_dga_funcs = { + xf86_dga_open_framebuffer, + xf86_dga_close_framebuffer, + xf86_dga_set_mode, + xf86_dga_set_viewport, + xf86_dga_get_viewport, + xf86_dga_sync, + xf86_dga_fill_rect, + xf86_dga_blit_rect, + NULL +}; + +static DGAModePtr xf86_dga_modes[MAXSCREENS]; + +Bool +xf86_dga_reinit (ScreenPtr pScreen) +{ + int num; + DGAModePtr modes; + + modes = xf86_dga_get_modes (pScreen, &num); + if (!modes) + return FALSE; + + if (xf86_dga_modes[pScreen->myNum]) + xfree (xf86_dga_modes[pScreen->myNum]); + + xf86_dga_modes[pScreen->myNum] = modes; + return DGAReInitModes (pScreen, modes, num); +} + +Bool +xf86_dga_init (ScreenPtr pScreen) +{ + int num; + DGAModePtr modes; + + modes = xf86_dga_get_modes (pScreen, &num); + if (!modes) + return FALSE; + + if (xf86_dga_modes[pScreen->myNum]) + xfree (xf86_dga_modes[pScreen->myNum]); + + xf86_dga_modes[pScreen->myNum] = modes; + return DGAInit(pScreen, &xf86_dga_funcs, modes, num); +} + diff --git a/src/i830_driver.c b/src/i830_driver.c index cb3dd878..4b87ec5e 100644 --- a/src/i830_driver.c +++ b/src/i830_driver.c @@ -2727,7 +2727,7 @@ I830ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) xf86SetBlackWhitePixels(pScreen); - I830DGAInit(pScreen); + xf86_dga_init (pScreen); DPRINTF(PFX, "assert( if(!I830InitFBManager(pScreen, &(pI830->FbMemBox))) )\n"); @@ -3393,7 +3393,7 @@ I830CheckDevicesTimer(OsTimerPtr timer, CARD32 now, pointer arg) xf86ProbeOutputModes (pScrn, 0, 0); xf86SetScrnInfoModes (pScrn); - I830DGAReInit (pScrn->pScreen); + xf86_dga_reinit (pScrn->pScreen); xf86SwitchMode(pScrn->pScreen, pScrn->currentMode); /* Clear the BIOS's hotkey press flags */ diff --git a/src/i830_randr.c b/src/i830_randr.c index 811fc50e..03ca5042 100644 --- a/src/i830_randr.c +++ b/src/i830_randr.c @@ -41,9 +41,6 @@ #include "i830_xf86Crtc.h" #include "i830_randr.h" -#include "i830_debug.h" -#include "i830_display.h" -#include "i830.h" typedef struct _xf86RandR12Info { int virtualX; @@ -97,7 +94,7 @@ xf86RandR12GetInfo (ScreenPtr pScreen, Rotation *rotations) /* Re-probe the outputs for new monitors or modes */ xf86ProbeOutputModes (scrp, 0, 0); xf86SetScrnInfoModes (scrp); - I830DGAReInit (pScreen); + xf86_dga_reinit (pScreen); for (mode = scrp->modes; ; mode = mode->next) { @@ -854,7 +851,7 @@ xf86RandR12GetInfo12 (ScreenPtr pScreen, Rotation *rotations) xf86ProbeOutputModes (pScrn, 0, 0); xf86SetScrnInfoModes (pScrn); - I830DGAReInit (pScreen); + xf86_dga_reinit (pScreen); return xf86RandR12SetInfo12 (pScreen); } diff --git a/src/i830_xf86Crtc.h b/src/i830_xf86Crtc.h index 6de2c923..2d773284 100644 --- a/src/i830_xf86Crtc.h +++ b/src/i830_xf86Crtc.h @@ -531,4 +531,18 @@ xf86OutputGetEDIDModes (xf86OutputPtr output); xf86MonPtr xf86OutputGetEDID (xf86OutputPtr output, I2CBusPtr pDDCBus); +/** + * Initialize dga for this screen + */ + +Bool +xf86_dga_init (ScreenPtr pScreen); + +/** + * Re-initialize dga for this screen (as when the set of modes changes) + */ + +Bool +xf86_dga_reinit (ScreenPtr pScreen); + #endif /* _XF86CRTC_H_ */ From 22a271555a46267c40448fa926d45692498ef7c6 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 14 Feb 2007 14:17:14 -0800 Subject: [PATCH 17/29] Create driver-independent DGA hooks, remove i830 DGA code. As RandR needs to poke at DGA code, and we want the RandR code to be driver-independent, it seemed easier to just make the DGA code driver-independent as well. --- src/Makefile.am | 2 +- src/i830_dga.c | 271 ---------------------------------------- src/i830_driver.c | 4 +- src/i830_randr.c | 4 +- src/i830_xf86Crtc.h | 11 +- src/i830_xf86DiDGA.c | 280 ++++++++++++++++++++++++++++++++++++++++++ src/i830_xf86Rename.h | 2 + 7 files changed, 295 insertions(+), 279 deletions(-) delete mode 100644 src/i830_dga.c create mode 100644 src/i830_xf86DiDGA.c diff --git a/src/Makefile.am b/src/Makefile.am index 6c63cc41..a94e14c8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -59,7 +59,6 @@ intel_drv_la_SOURCES = \ i830_cursor.c \ i830_debug.c \ i830_debug.h \ - i830_dga.c \ i830_display.c \ i830_display.h \ i830_driver.c \ @@ -85,6 +84,7 @@ intel_drv_la_SOURCES = \ i830_xf86Crtc.h \ i830_xf86Crtc.c \ i830_xf86Rotate.c \ + i830_xf86DiDGA.c \ i915_3d.c \ i915_3d.h \ i915_reg.h \ diff --git a/src/i830_dga.c b/src/i830_dga.c deleted file mode 100644 index 817d96d9..00000000 --- a/src/i830_dga.c +++ /dev/null @@ -1,271 +0,0 @@ -/* - * Copyright 2000 by Alan Hourihane, Sychdyn, North Wales, UK. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Alan Hourihane not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Alan Hourihane makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - * Authors: Alan Hourihane, - */ -/* - * Reformatted with GNU indent (2.2.8), using the following options: - * - * -bad -bap -c41 -cd0 -ncdb -ci6 -cli0 -cp0 -ncs -d0 -di3 -i3 -ip3 -l78 - * -lp -npcs -psl -sob -ss -br -ce -sc -hnl - * - * This provides a good match with the original i810 code and preferred - * XFree86 formatting conventions. - * - * When editing this driver, please follow the existing formatting, and edit - * with characters expanded at 8-column intervals. - */ - -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i830_dga.c,v 1.2 2002/11/05 02:01:18 dawes Exp $ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "xf86.h" -#include "xf86DDC.h" -#include "xf86_OSproc.h" -#include "dgaproc.h" -#include "i830_xf86Crtc.h" -#include "i830_xf86Modes.h" -#include "gcstruct.h" - -static DGAModePtr -xf86_dga_get_modes (ScreenPtr pScreen, int *nump) -{ - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - DGAModePtr modes, mode; - DisplayModePtr display_mode; - int bpp = pScrn->bitsPerPixel >> 3; - int num; - PixmapPtr pPixmap = pScreen->GetScreenPixmap (pScreen); - - if (!pPixmap) - return NULL; - - num = 0; - display_mode = pScrn->modes; - while (display_mode) - { - num++; - display_mode = display_mode->next; - if (display_mode == pScrn->modes) - break; - } - - if (!num) - return NULL; - - modes = xalloc(num * sizeof(DGAModeRec)); - if (!modes) - return NULL; - - num = 0; - display_mode = pScrn->modes; - while (display_mode) - { - mode = modes + num++; - - mode->mode = display_mode; - mode->flags = DGA_CONCURRENT_ACCESS | DGA_PIXMAP_AVAILABLE; - mode->flags |= DGA_FILL_RECT | DGA_BLIT_RECT; - if (display_mode->Flags & V_DBLSCAN) - mode->flags |= DGA_DOUBLESCAN; - if (display_mode->Flags & V_INTERLACE) - mode->flags |= DGA_INTERLACED; - mode->byteOrder = pScrn->imageByteOrder; - mode->depth = pScrn->depth; - mode->bitsPerPixel = pScrn->bitsPerPixel; - mode->red_mask = pScrn->mask.red; - mode->green_mask = pScrn->mask.green; - mode->blue_mask = pScrn->mask.blue; - mode->visualClass = (bpp == 1) ? PseudoColor : TrueColor; - mode->viewportWidth = display_mode->HDisplay; - mode->viewportHeight = display_mode->VDisplay; - mode->xViewportStep = (bpp == 3) ? 2 : 1; - mode->yViewportStep = 1; - mode->viewportFlags = DGA_FLIP_RETRACE; - mode->offset = 0; - mode->address = pPixmap->devPrivate.ptr; - mode->bytesPerScanline = pPixmap->devKind; - mode->imageWidth = pPixmap->drawable.width; - mode->imageHeight = pPixmap->drawable.height; - mode->pixmapWidth = mode->imageWidth; - mode->pixmapHeight = mode->imageHeight; - mode->maxViewportX = mode->imageWidth - mode->viewportWidth; - mode->maxViewportY = mode->imageHeight - mode->viewportHeight; - - display_mode = display_mode->next; - if (display_mode == pScrn->modes) - break; - } - *nump = num; - return modes; -} - -static Bool -xf86_dga_set_mode(ScrnInfoPtr pScrn, DGAModePtr display_mode) -{ - ScreenPtr pScreen = pScrn->pScreen; - - if (!display_mode) - xf86SwitchMode(pScreen, pScrn->currentMode); - else - xf86SwitchMode(pScreen, display_mode->mode); - - return TRUE; -} - -static int -xf86_dga_get_viewport(ScrnInfoPtr pScrn) -{ - return 0; -} - -static void -xf86_dga_set_viewport(ScrnInfoPtr pScrn, int x, int y, int flags) -{ - pScrn->AdjustFrame(pScrn->pScreen->myNum, x, y, flags); -} - -static void -xf86_dga_fill_rect(ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned long color) -{ - ScreenPtr pScreen = pScrn->pScreen; - WindowPtr pRoot = WindowTable [pScreen->myNum]; - GCPtr pGC = GetScratchGC (pRoot->drawable.depth, pScreen); - XID vals[2]; - xRectangle r; - - if (!pGC) - return; - vals[0] = color; - vals[1] = IncludeInferiors; - ChangeGC (pGC, GCForeground|GCSubwindowMode, vals); - ValidateGC (&pRoot->drawable, pGC); - r.x = x; - r.y = y; - r.width = w; - r.height = h; - pGC->ops->PolyFillRect (&pRoot->drawable, pGC, 1, &r); - FreeScratchGC (pGC); -} - -static void -xf86_dga_sync(ScrnInfoPtr pScrn) -{ - ScreenPtr pScreen = pScrn->pScreen; - WindowPtr pRoot = WindowTable [pScreen->myNum]; - char buffer[4]; - - pScreen->GetImage (&pRoot->drawable, 0, 0, 1, 1, ZPixmap, ~0L, buffer); -} - -static void -xf86_dga_blit_rect(ScrnInfoPtr pScrn, int srcx, int srcy, int w, int h, int dstx, int dsty) -{ - ScreenPtr pScreen = pScrn->pScreen; - WindowPtr pRoot = WindowTable [pScreen->myNum]; - GCPtr pGC = GetScratchGC (pRoot->drawable.depth, pScreen); - XID vals[1]; - - if (!pGC) - return; - vals[0] = IncludeInferiors; - ChangeGC (pGC, GCSubwindowMode, vals); - ValidateGC (&pRoot->drawable, pGC); - pGC->ops->CopyArea (&pRoot->drawable, &pRoot->drawable, pGC, - srcx, srcy, w, h, dstx, dsty); - FreeScratchGC (pGC); -} - -static Bool -xf86_dga_open_framebuffer(ScrnInfoPtr pScrn, - char **name, - unsigned char **mem, int *size, int *offset, int *flags) -{ - ScreenPtr pScreen = pScrn->pScreen; - PixmapPtr pPixmap = pScreen->GetScreenPixmap (pScreen); - - if (!pPixmap) - return FALSE; - - *size = pPixmap->drawable.height * pPixmap->devKind; - *mem = (unsigned char *) (pScrn->memPhysBase + pScrn->fbOffset); - *offset = 0; - *flags = DGA_NEED_ROOT; - - return TRUE; -} - -static void -xf86_dga_close_framebuffer(ScrnInfoPtr pScrn) -{ -} - -static DGAFunctionRec xf86_dga_funcs = { - xf86_dga_open_framebuffer, - xf86_dga_close_framebuffer, - xf86_dga_set_mode, - xf86_dga_set_viewport, - xf86_dga_get_viewport, - xf86_dga_sync, - xf86_dga_fill_rect, - xf86_dga_blit_rect, - NULL -}; - -static DGAModePtr xf86_dga_modes[MAXSCREENS]; - -Bool -xf86_dga_reinit (ScreenPtr pScreen) -{ - int num; - DGAModePtr modes; - - modes = xf86_dga_get_modes (pScreen, &num); - if (!modes) - return FALSE; - - if (xf86_dga_modes[pScreen->myNum]) - xfree (xf86_dga_modes[pScreen->myNum]); - - xf86_dga_modes[pScreen->myNum] = modes; - return DGAReInitModes (pScreen, modes, num); -} - -Bool -xf86_dga_init (ScreenPtr pScreen) -{ - int num; - DGAModePtr modes; - - modes = xf86_dga_get_modes (pScreen, &num); - if (!modes) - return FALSE; - - if (xf86_dga_modes[pScreen->myNum]) - xfree (xf86_dga_modes[pScreen->myNum]); - - xf86_dga_modes[pScreen->myNum] = modes; - return DGAInit(pScreen, &xf86_dga_funcs, modes, num); -} - diff --git a/src/i830_driver.c b/src/i830_driver.c index 4b87ec5e..56903e15 100644 --- a/src/i830_driver.c +++ b/src/i830_driver.c @@ -2727,7 +2727,7 @@ I830ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) xf86SetBlackWhitePixels(pScreen); - xf86_dga_init (pScreen); + xf86DiDGAInit (pScreen, pI830->LinearAddr + pScrn->fbOffset); DPRINTF(PFX, "assert( if(!I830InitFBManager(pScreen, &(pI830->FbMemBox))) )\n"); @@ -3393,7 +3393,7 @@ I830CheckDevicesTimer(OsTimerPtr timer, CARD32 now, pointer arg) xf86ProbeOutputModes (pScrn, 0, 0); xf86SetScrnInfoModes (pScrn); - xf86_dga_reinit (pScrn->pScreen); + xf86DiDGAReInit (pScrn->pScreen); xf86SwitchMode(pScrn->pScreen, pScrn->currentMode); /* Clear the BIOS's hotkey press flags */ diff --git a/src/i830_randr.c b/src/i830_randr.c index 03ca5042..b9cc9aa8 100644 --- a/src/i830_randr.c +++ b/src/i830_randr.c @@ -94,7 +94,7 @@ xf86RandR12GetInfo (ScreenPtr pScreen, Rotation *rotations) /* Re-probe the outputs for new monitors or modes */ xf86ProbeOutputModes (scrp, 0, 0); xf86SetScrnInfoModes (scrp); - xf86_dga_reinit (pScreen); + xf86DiDGAReInit (pScreen); for (mode = scrp->modes; ; mode = mode->next) { @@ -851,7 +851,7 @@ xf86RandR12GetInfo12 (ScreenPtr pScreen, Rotation *rotations) xf86ProbeOutputModes (pScrn, 0, 0); xf86SetScrnInfoModes (pScrn); - xf86_dga_reinit (pScreen); + xf86DiDGAReInit (pScreen); return xf86RandR12SetInfo12 (pScreen); } diff --git a/src/i830_xf86Crtc.h b/src/i830_xf86Crtc.h index 2d773284..53d2cdb7 100644 --- a/src/i830_xf86Crtc.h +++ b/src/i830_xf86Crtc.h @@ -414,7 +414,12 @@ typedef struct _xf86CrtcConfig { DamagePtr rotationDamage; /* DGA */ - unsigned int dga_flags; + unsigned int dga_flags; + unsigned long dga_address; + DGAModePtr dga_modes; + int dga_nmode; + int dga_width, dga_height, dga_stride; + DisplayModePtr dga_save_mode; } xf86CrtcConfigRec, *xf86CrtcConfigPtr; @@ -536,13 +541,13 @@ xf86OutputGetEDID (xf86OutputPtr output, I2CBusPtr pDDCBus); */ Bool -xf86_dga_init (ScreenPtr pScreen); +xf86DiDGAInit (ScreenPtr pScreen, unsigned long dga_address); /** * Re-initialize dga for this screen (as when the set of modes changes) */ Bool -xf86_dga_reinit (ScreenPtr pScreen); +xf86DiDGAReInit (ScreenPtr pScreen); #endif /* _XF86CRTC_H_ */ diff --git a/src/i830_xf86DiDGA.c b/src/i830_xf86DiDGA.c new file mode 100644 index 00000000..24a52973 --- /dev/null +++ b/src/i830_xf86DiDGA.c @@ -0,0 +1,280 @@ +/* + * Copyright © 2006 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "xf86.h" +#include "xf86DDC.h" +#include "xf86_OSproc.h" +#include "dgaproc.h" +#include "i830_xf86Crtc.h" +#include "i830_xf86Modes.h" +#include "gcstruct.h" + +static Bool +xf86_dga_get_modes (ScreenPtr pScreen) +{ + ScrnInfoPtr scrn = xf86Screens[pScreen->myNum]; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + DGAModePtr modes, mode; + DisplayModePtr display_mode; + int bpp = scrn->bitsPerPixel >> 3; + int num; + + num = 0; + display_mode = scrn->modes; + while (display_mode) + { + num++; + display_mode = display_mode->next; + if (display_mode == scrn->modes) + break; + } + + if (!num) + return FALSE; + + modes = xalloc(num * sizeof(DGAModeRec)); + if (!modes) + return FALSE; + + num = 0; + display_mode = scrn->modes; + while (display_mode) + { + mode = modes + num++; + + mode->mode = display_mode; + mode->flags = DGA_CONCURRENT_ACCESS | DGA_PIXMAP_AVAILABLE; + mode->flags |= DGA_FILL_RECT | DGA_BLIT_RECT; + if (display_mode->Flags & V_DBLSCAN) + mode->flags |= DGA_DOUBLESCAN; + if (display_mode->Flags & V_INTERLACE) + mode->flags |= DGA_INTERLACED; + mode->byteOrder = scrn->imageByteOrder; + mode->depth = scrn->depth; + mode->bitsPerPixel = scrn->bitsPerPixel; + mode->red_mask = scrn->mask.red; + mode->green_mask = scrn->mask.green; + mode->blue_mask = scrn->mask.blue; + mode->visualClass = (bpp == 1) ? PseudoColor : TrueColor; + mode->viewportWidth = display_mode->HDisplay; + mode->viewportHeight = display_mode->VDisplay; + mode->xViewportStep = (bpp == 3) ? 2 : 1; + mode->yViewportStep = 1; + mode->viewportFlags = DGA_FLIP_RETRACE; + mode->offset = 0; + mode->address = (unsigned char *) xf86_config->dga_address; + mode->bytesPerScanline = xf86_config->dga_stride; + mode->imageWidth = xf86_config->dga_width; + mode->imageHeight = xf86_config->dga_height; + mode->pixmapWidth = mode->imageWidth; + mode->pixmapHeight = mode->imageHeight; + mode->maxViewportX = mode->imageWidth - mode->viewportWidth; + mode->maxViewportY = mode->imageHeight - mode->viewportHeight; + + display_mode = display_mode->next; + if (display_mode == scrn->modes) + break; + } + if (xf86_config->dga_modes) + xfree (xf86_config->dga_modes); + xf86_config->dga_nmode = num; + xf86_config->dga_modes = modes; + return TRUE; +} + +static Bool +xf86_dga_set_mode(ScrnInfoPtr scrn, DGAModePtr display_mode) +{ + ScreenPtr pScreen = scrn->pScreen; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + + if (!display_mode) + { + if (xf86_config->dga_save_mode) + { + xf86SwitchMode(pScreen, xf86_config->dga_save_mode); + xf86_config->dga_save_mode = NULL; + } + } + else + { + if (!xf86_config->dga_save_mode) + { + xf86_config->dga_save_mode = scrn->currentMode; + xf86SwitchMode(pScreen, display_mode->mode); + } + } + return TRUE; +} + +static int +xf86_dga_get_viewport(ScrnInfoPtr scrn) +{ + return 0; +} + +static void +xf86_dga_set_viewport(ScrnInfoPtr scrn, int x, int y, int flags) +{ + scrn->AdjustFrame(scrn->pScreen->myNum, x, y, flags); +} + +static Bool +xf86_dga_get_drawable_and_gc (ScrnInfoPtr scrn, DrawablePtr *ppDrawable, GCPtr *ppGC) +{ + ScreenPtr pScreen = scrn->pScreen; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + PixmapPtr pPixmap; + GCPtr pGC; + + pPixmap = GetScratchPixmapHeader (pScreen, xf86_config->dga_width, xf86_config->dga_height, + scrn->depth, scrn->bitsPerPixel, xf86_config->dga_stride, + (char *) scrn->memPhysBase + scrn->fbOffset); + if (!pPixmap) + return FALSE; + pGC = GetScratchGC (scrn->depth, pScreen); + if (!pGC) + { + FreeScratchPixmapHeader (pPixmap); + return FALSE; + } + *ppDrawable = &pPixmap->drawable; + *ppGC = pGC; + return TRUE; +} + +static void +xf86_dga_release_drawable_and_gc (ScrnInfoPtr scrn, DrawablePtr pDrawable, GCPtr pGC) +{ + FreeScratchGC (pGC); + FreeScratchPixmapHeader ((PixmapPtr) pDrawable); +} + +static void +xf86_dga_fill_rect(ScrnInfoPtr scrn, int x, int y, int w, int h, unsigned long color) +{ + GCPtr pGC; + DrawablePtr pDrawable; + XID vals[1]; + xRectangle r; + + if (!xf86_dga_get_drawable_and_gc (scrn, &pDrawable, &pGC)) + return; + vals[0] = color; + ChangeGC (pGC, GCForeground, vals); + ValidateGC (pDrawable, pGC); + r.x = x; + r.y = y; + r.width = w; + r.height = h; + pGC->ops->PolyFillRect (pDrawable, pGC, 1, &r); + xf86_dga_release_drawable_and_gc (scrn, pDrawable, pGC); +} + +static void +xf86_dga_sync(ScrnInfoPtr scrn) +{ + ScreenPtr pScreen = scrn->pScreen; + WindowPtr pRoot = WindowTable [pScreen->myNum]; + char buffer[4]; + + pScreen->GetImage (&pRoot->drawable, 0, 0, 1, 1, ZPixmap, ~0L, buffer); +} + +static void +xf86_dga_blit_rect(ScrnInfoPtr scrn, int srcx, int srcy, int w, int h, int dstx, int dsty) +{ + DrawablePtr pDrawable; + GCPtr pGC; + + if (!xf86_dga_get_drawable_and_gc (scrn, &pDrawable, &pGC)) + return; + ValidateGC (pDrawable, pGC); + pGC->ops->CopyArea (pDrawable, pDrawable, pGC, srcx, srcy, w, h, dstx, dsty); + xf86_dga_release_drawable_and_gc (scrn, pDrawable, pGC); +} + +static Bool +xf86_dga_open_framebuffer(ScrnInfoPtr scrn, + char **name, + unsigned char **mem, int *size, int *offset, int *flags) +{ + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + + *size = xf86_config->dga_stride * xf86_config->dga_height; + *mem = (unsigned char *) (xf86_config->dga_address); + *offset = 0; + *flags = DGA_NEED_ROOT; + + return TRUE; +} + +static void +xf86_dga_close_framebuffer(ScrnInfoPtr scrn) +{ +} + +static DGAFunctionRec xf86_dga_funcs = { + xf86_dga_open_framebuffer, + xf86_dga_close_framebuffer, + xf86_dga_set_mode, + xf86_dga_set_viewport, + xf86_dga_get_viewport, + xf86_dga_sync, + xf86_dga_fill_rect, + xf86_dga_blit_rect, + NULL +}; + +Bool +xf86DiDGAReInit (ScreenPtr pScreen) +{ + ScrnInfoPtr scrn = xf86Screens[pScreen->myNum]; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + + if (!xf86_dga_get_modes (pScreen)) + return FALSE; + + return DGAReInitModes (pScreen, xf86_config->dga_modes, xf86_config->dga_nmode); +} + +Bool +xf86DiDGAInit (ScreenPtr pScreen, unsigned long dga_address) +{ + ScrnInfoPtr scrn = xf86Screens[pScreen->myNum]; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + + xf86_config->dga_flags = 0; + xf86_config->dga_address = dga_address; + xf86_config->dga_width = scrn->virtualX; + xf86_config->dga_height = scrn->virtualY; + xf86_config->dga_stride = scrn->displayWidth * scrn->bitsPerPixel >> 3; + + if (!xf86_dga_get_modes (pScreen)) + return FALSE; + + return DGAInit(pScreen, &xf86_dga_funcs, xf86_config->dga_modes, xf86_config->dga_nmode); +} diff --git a/src/i830_xf86Rename.h b/src/i830_xf86Rename.h index cf8de622..de2eb9a5 100644 --- a/src/i830_xf86Rename.h +++ b/src/i830_xf86Rename.h @@ -62,5 +62,7 @@ #define xf86ValidateModesSize XF86NAME(xf86ValidateModesSize) #define xf86ValidateModesSync XF86NAME(xf86ValidateModesSync) #define xf86ValidateModesUserConfig XF86NAME(xf86ValidateModesUserConfig) +#define xf86DiDGAInit XF86NAME(xf86DiDGAInit) +#define xf86DiDGAReInit XF86NAME(xf86DiDGAReInit) #endif /* _XF86RENAME_H_ */ From ec55dd16c4c5f7612d33ae22a6249b3b1c60e2b6 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 14 Feb 2007 14:37:02 -0800 Subject: [PATCH 18/29] Global namespace cleanups, filename fixes. Ensure all xf86 symbols created here are protected with XF86NAME. Remove accidentally exported symbols from namespace. Make all to-be-DI files prefixed with i830_xf86. --- src/Makefile.am | 20 +++++++++---------- src/i830.h | 2 +- src/i830_tv.c | 2 +- src/i830_xf86Crtc.c | 10 +++++----- ...i830_edid_modes.c => i830_xf86EdidModes.c} | 0 src/{i830_randr.c => i830_xf86RandR12.c} | 2 +- src/{i830_randr.h => i830_xf86RandR12.h} | 0 src/i830_xf86Rename.h | 9 +++++++++ src/i830_xf86Rotate.c | 2 +- 9 files changed, 28 insertions(+), 19 deletions(-) rename src/{i830_edid_modes.c => i830_xf86EdidModes.c} (100%) rename src/{i830_randr.c => i830_xf86RandR12.c} (99%) rename src/{i830_randr.h => i830_xf86RandR12.h} (100%) diff --git a/src/Makefile.am b/src/Makefile.am index a94e14c8..982a959d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -63,7 +63,6 @@ intel_drv_la_SOURCES = \ i830_display.h \ i830_driver.c \ i830_dvo.c \ - i830_edid_modes.c \ i830.h \ i830_i2c.c \ i830_io.c \ @@ -73,18 +72,10 @@ intel_drv_la_SOURCES = \ i830_video.c \ i830_video.h \ i830_reg.h \ - i830_randr.c \ i830_sdvo.c \ i830_sdvo.h \ i830_sdvo_regs.h \ i830_tv.c \ - i830_xf86Modes.h \ - i830_xf86Modes.c \ - i830_xf86cvt.c \ - i830_xf86Crtc.h \ - i830_xf86Crtc.c \ - i830_xf86Rotate.c \ - i830_xf86DiDGA.c \ i915_3d.c \ i915_3d.h \ i915_reg.h \ @@ -99,7 +90,16 @@ intel_drv_la_SOURCES = \ local_xf86Rename.h \ xf86Parser.h \ xf86Optrec.h \ - i830_randr.h + i830_xf86Modes.h \ + i830_xf86Modes.c \ + i830_xf86cvt.c \ + i830_xf86Crtc.h \ + i830_xf86Crtc.c \ + i830_xf86EdidModes.c \ + i830_xf86RandR12.c \ + i830_xf86RandR12.h \ + i830_xf86Rotate.c \ + i830_xf86DiDGA.c EXTRA_DIST = \ packed_yuv_sf.g4a \ diff --git a/src/i830.h b/src/i830.h index 7a442d8c..26d16e92 100644 --- a/src/i830.h +++ b/src/i830.h @@ -59,7 +59,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "vbe.h" #include "vgaHW.h" #include "i830_xf86Crtc.h" -#include "i830_randr.h" +#include "i830_xf86RandR12.h" #ifdef XF86DRI #include "xf86drm.h" diff --git a/src/i830_tv.c b/src/i830_tv.c index 5ee8866a..95612e41 100644 --- a/src/i830_tv.c +++ b/src/i830_tv.c @@ -1310,7 +1310,7 @@ i830_tv_detect(xf86OutputPtr output) } } -struct input_res { +static struct input_res { char *name; int w, h; } input_res_table[] = diff --git a/src/i830_xf86Crtc.c b/src/i830_xf86Crtc.c index 0ea0cedd..db05abab 100644 --- a/src/i830_xf86Crtc.c +++ b/src/i830_xf86Crtc.c @@ -33,7 +33,7 @@ /*#include "i830.h" */ #include "i830_xf86Crtc.h" #include "i830_xf86Modes.h" -#include "i830_randr.h" +#include "i830_xf86RandR12.h" #include "X11/extensions/render.h" #define DPMS_SERVER #include "X11/extensions/dpms.h" @@ -886,7 +886,7 @@ xf86PruneDuplicateMonitorModes (MonPtr Monitor) /** Return - 0 + if a should be earlier, same or later than b in list */ static int -i830xf86ModeCompare (DisplayModePtr a, DisplayModePtr b) +xf86ModeCompare (DisplayModePtr a, DisplayModePtr b) { int diff; @@ -904,7 +904,7 @@ i830xf86ModeCompare (DisplayModePtr a, DisplayModePtr b) * Insertion sort input in-place and return the resulting head */ static DisplayModePtr -i830xf86SortModes (DisplayModePtr input) +xf86SortModes (DisplayModePtr input) { DisplayModePtr output = NULL, i, o, n, *op, prev; @@ -914,7 +914,7 @@ i830xf86SortModes (DisplayModePtr input) i = input; input = input->next; for (op = &output; (o = *op); op = &o->next) - if (i830xf86ModeCompare (o, i) > 0) + if (xf86ModeCompare (o, i) > 0) break; i->next = *op; *op = i; @@ -1109,7 +1109,7 @@ xf86ProbeOutputModes (ScrnInfoPtr scrn, int maxX, int maxY) xf86PruneInvalidModes(scrn, &output->probed_modes, TRUE); - output->probed_modes = i830xf86SortModes (output->probed_modes); + output->probed_modes = xf86SortModes (output->probed_modes); /* Check for a configured preference for a particular mode */ preferred_mode = xf86GetOptValString (output->options, diff --git a/src/i830_edid_modes.c b/src/i830_xf86EdidModes.c similarity index 100% rename from src/i830_edid_modes.c rename to src/i830_xf86EdidModes.c diff --git a/src/i830_randr.c b/src/i830_xf86RandR12.c similarity index 99% rename from src/i830_randr.c rename to src/i830_xf86RandR12.c index b9cc9aa8..4ccbdad1 100644 --- a/src/i830_randr.c +++ b/src/i830_xf86RandR12.c @@ -40,7 +40,7 @@ #include #include "i830_xf86Crtc.h" -#include "i830_randr.h" +#include "i830_xf86RandR12.h" typedef struct _xf86RandR12Info { int virtualX; diff --git a/src/i830_randr.h b/src/i830_xf86RandR12.h similarity index 100% rename from src/i830_randr.h rename to src/i830_xf86RandR12.h diff --git a/src/i830_xf86Rename.h b/src/i830_xf86Rename.h index de2eb9a5..a00253d5 100644 --- a/src/i830_xf86Rename.h +++ b/src/i830_xf86Rename.h @@ -64,5 +64,14 @@ #define xf86ValidateModesUserConfig XF86NAME(xf86ValidateModesUserConfig) #define xf86DiDGAInit XF86NAME(xf86DiDGAInit) #define xf86DiDGAReInit XF86NAME(xf86DiDGAReInit) +#define xf86DDCGetModes XF86NAME(xf86DDCGetModes) +#define xf86RandR12CreateScreenResources XF86NAME(xf86RandR12CreateScreenResources) +#define xf86RandR12GetOriginalVirtualSize XF86NAME(xf86RandR12GetOriginalVirtualSize) +#define xf86RandR12GetRotation XF86NAME(xf86RandR12GetRotation) +#define xf86RandR12Init XF86NAME(xf86RandR12Init) +#define xf86RandR12PreInit XF86NAME(xf86RandR12PreInit) +#define xf86RandR12SetConfig XF86NAME(xf86RandR12SetConfig) +#define xf86RandR12SetRotations XF86NAME(xf86RandR12SetRotations) +#define xf86SaveScreen XF86NAME(xf86SaveScreen) #endif /* _XF86RENAME_H_ */ diff --git a/src/i830_xf86Rotate.c b/src/i830_xf86Rotate.c index 2491e7b3..8240f670 100644 --- a/src/i830_xf86Rotate.c +++ b/src/i830_xf86Rotate.c @@ -34,7 +34,7 @@ #include "windowstr.h" #include "i830_xf86Crtc.h" #include "i830_xf86Modes.h" -#include "i830_randr.h" +#include "i830_xf86RandR12.h" #include "X11/extensions/render.h" #define DPMS_SERVER #include "X11/extensions/dpms.h" From c010d28f0a91a9831d366ea490878ef3d958021f Mon Sep 17 00:00:00 2001 From: Wang Zhenyu Date: Thu, 15 Feb 2007 11:00:06 +0800 Subject: [PATCH 19/29] EXA: mask componentAlpha support we're getting load of multiple sf/wm programs for i965, might need to be cleanup in future. --- src/exa_wm_maskca.g4a | 202 ++++++++++++++++++++++++++++++ src/exa_wm_maskca_prog.h | 95 ++++++++++++++ src/exa_wm_maskca_srcalpha.g4a | 202 ++++++++++++++++++++++++++++++ src/exa_wm_maskca_srcalpha_prog.h | 95 ++++++++++++++ src/i965_render.c | 52 +++++--- 5 files changed, 626 insertions(+), 20 deletions(-) create mode 100644 src/exa_wm_maskca.g4a create mode 100644 src/exa_wm_maskca_prog.h create mode 100644 src/exa_wm_maskca_srcalpha.g4a create mode 100644 src/exa_wm_maskca_srcalpha_prog.h diff --git a/src/exa_wm_maskca.g4a b/src/exa_wm_maskca.g4a new file mode 100644 index 00000000..fa923f6c --- /dev/null +++ b/src/exa_wm_maskca.g4a @@ -0,0 +1,202 @@ +/* + * This's for exa composite operation in no mask picture case. + * The simplest case is just sending what src picture has to dst picture. + * XXX: This is still experimental, and should be fixed to support multiple texture + * map, and conditional mul actions. + */ + +/* I think this should be same as in g4a program for texture video, + as we also use 16-pixel dispatch. and SF scale in g3 is useful for us. */ + +/* The initial payload of the thread is always g0. + * WM_URB (incoming URB entries) is g3 + As mask texture coeffient needs extra setup urb starting from g4, we should + shift this location. + + * X0_R is g4->g6 + * X1_R is g5->g7 + * Y0_R is g6->g8 + * Y1_R is g7->g9 + + * X0: {ss0.x, ss0.x+1, ss0.x, ss0.x+1, ss1.x, ss1.x+1, ss1.x, ss1.x+y} + * Y0: {ss0.y, ss0.y, ss0.y+1, ss0.y+1, ss1.y, ss1.y, ss1.y+1, ss1.y+1} + * X1: {ss2.x, ss2.x+1, ss2.x, ss2.x+1, ss3.x, ss3.x+1, ss3.x, ss3.x+y} + * Y1: {ss2.y, ss2.y, ss2.y+1, ss2.y+1, ss3.y, ss3.y, ss3.y+1, ss3.y+1} + */ + +/* multitexture program with src and mask texture */ +/* - load src texture */ +/* - load mask texture */ +/* - mul src.X with mask's alpha */ +/* - write out src.X */ + + /* Set up ss0.x coordinates*/ +mov (1) g6<1>F g1.8<0,1,0>UW { align1 }; +add (1) g6.4<1>F g1.8<0,1,0>UW 1UB { align1 }; +mov (1) g6.8<1>F g1.8<0,1,0>UW { align1 }; +add (1) g6.12<1>F g1.8<0,1,0>UW 1UB { align1 }; + /* Set up ss0.y coordinates */ +mov (1) g8<1>F g1.10<0,1,0>UW { align1 }; +mov (1) g8.4<1>F g1.10<0,1,0>UW { align1 }; +add (1) g8.8<1>F g1.10<0,1,0>UW 1UB { align1 }; +add (1) g8.12<1>F g1.10<0,1,0>UW 1UB { align1 }; + /* set up ss1.x coordinates */ +mov (1) g6.16<1>F g1.12<0,1,0>UW { align1 }; +add (1) g6.20<1>F g1.12<0,1,0>UW 1UB { align1 }; +mov (1) g6.24<1>F g1.12<0,1,0>UW { align1 }; +add (1) g6.28<1>F g1.12<0,1,0>UW 1UB { align1 }; + /* set up ss1.y coordinates */ +mov (1) g8.16<1>F g1.14<0,1,0>UW { align1 }; +mov (1) g8.20<1>F g1.14<0,1,0>UW { align1 }; +add (1) g8.24<1>F g1.14<0,1,0>UW 1UB { align1 }; +add (1) g8.28<1>F g1.14<0,1,0>UW 1UB { align1 }; + /* Set up ss2.x coordinates */ +mov (1) g7<1>F g1.16<0,1,0>UW { align1 }; +add (1) g7.4<1>F g1.16<0,1,0>UW 1UB { align1 }; +mov (1) g7.8<1>F g1.16<0,1,0>UW { align1 }; +add (1) g7.12<1>F g1.16<0,1,0>UW 1UB { align1 }; + /* Set up ss2.y coordinates */ +mov (1) g9<1>F g1.18<0,1,0>UW { align1 }; +mov (1) g9.4<1>F g1.18<0,1,0>UW { align1 }; +add (1) g9.8<1>F g1.18<0,1,0>UW 1UB { align1 }; +add (1) g9.12<1>F g1.18<0,1,0>UW 1UB { align1 }; + /* Set up ss3.x coordinates */ +mov (1) g7.16<1>F g1.20<0,1,0>UW { align1 }; +add (1) g7.20<1>F g1.20<0,1,0>UW 1UB { align1 }; +mov (1) g7.24<1>F g1.20<0,1,0>UW { align1 }; +add (1) g7.28<1>F g1.20<0,1,0>UW 1UB { align1 }; + /* Set up ss3.y coordinates */ +mov (1) g9.16<1>F g1.22<0,1,0>UW { align1 }; +mov (1) g9.20<1>F g1.22<0,1,0>UW { align1 }; +add (1) g9.24<1>F g1.22<0,1,0>UW 1UB { align1 }; +add (1) g9.28<1>F g1.22<0,1,0>UW 1UB { align1 }; + + /* Now, map these screen space coordinates into texture coordinates. */ +/* This is for src texture */ +/* I don't want to change origin ssX coords, as it will be used later in mask */ +/* so store tex coords in g10, g11, g12, g13 */ + + /* subtract screen-space X origin of vertex 0. */ +add (8) g10<1>F g6<8,8,1>F -g1<0,1,0>F { align1 }; +add (8) g11<1>F g7<8,8,1>F -g1<0,1,0>F { align1 }; + /* scale by texture X increment */ +/* Cx[0] */ +mul (8) g10<1>F g10<8,8,1>F g3<0,1,0>F { align1 }; +mul (8) g11<1>F g11<8,8,1>F g3<0,1,0>F { align1 }; + /* add in texture X offset */ +/* Co[0] */ +add (8) g10<1>F g10<8,8,1>F g3.12<0,1,0>F { align1 }; +add (8) g11<1>F g11<8,8,1>F g3.12<0,1,0>F { align1 }; + /* subtract screen-space Y origin of vertex 0. */ +add (8) g12<1>F g8<8,8,1>F -g1.4<0,1,0>F { align1 }; +add (8) g13<1>F g9<8,8,1>F -g1.4<0,1,0>F { align1 }; + /* scale by texture Y increment */ +/* Cy[0] */ +mul (8) g12<1>F g12<8,8,1>F g3.4<0,1,0>F { align1 }; +mul (8) g13<1>F g13<8,8,1>F g3.4<0,1,0>F { align1 }; + /* add in texture Y offset */ +/* Co[1] */ +add (8) g12<1>F g12<8,8,1>F g3.28<0,1,0>F { align1 }; +add (8) g13<1>F g13<8,8,1>F g3.28<0,1,0>F { align1 }; + +/* prepare sampler read back gX register, which would be written back to output */ + +/* use simd16 sampler, param 0 is u, param 1 is v. */ +/* 'payload' loading, assuming tex coord start from g4 */ +mov (8) m1<1>F g10<8,8,1>F { align1 }; +mov (8) m2<1>F g11<8,8,1>F { align1 }; /* param 0 u in m1, m2 */ +mov (8) m3<1>F g12<8,8,1>F { align1 }; +mov (8) m4<1>F g13<8,8,1>F { align1 }; /* param 1 v in m3, m4 */ + +/* m0 will be copied with g0, as it contains send desc */ +/* emit sampler 'send' cmd */ + +/* src texture readback: g14-g21 */ +send (16) 0 /* msg reg index */ + g14<1>UW /* readback */ + g0<8,8,1>UW /* copy to msg start reg*/ + sampler (1,0,F) /* sampler message description, + (binding_table,sampler_index,datatype). + here(src->dst) we should use src_sampler and + src_surface */ + mlen 5 rlen 8 { align1 }; /* required message len 5, readback len 8 */ + +mov (8) g21<1>UD g21<8,8,1>UD { align1 }; /* wait sampler return */ + +/* sampler mask texture, use g10, g11, g12, g13 */ + /* subtract screen-space X origin of vertex 0. */ +add (8) g10<1>F g6<8,8,1>F -g1<0,1,0>F { align1 }; +add (8) g11<1>F g7<8,8,1>F -g1<0,1,0>F { align1 }; + /* scale by texture X increment */ +/* Cx[2] */ +mul (8) g10<1>F g10<8,8,1>F g4<0,1,0>F { align1 }; +mul (8) g11<1>F g11<8,8,1>F g4<0,1,0>F { align1 }; + /* add in texture X offset */ +/* Co[2] */ +add (8) g10<1>F g10<8,8,1>F g4.12<0,1,0>F { align1 }; +add (8) g11<1>F g11<8,8,1>F g4.12<0,1,0>F { align1 }; + /* subtract screen-space Y origin of vertex 0. */ +add (8) g12<1>F g8<8,8,1>F -g1.4<0,1,0>F { align1 }; +add (8) g13<1>F g9<8,8,1>F -g1.4<0,1,0>F { align1 }; + /* scale by texture Y increment */ +/* Cy[2] */ +mul (8) g12<1>F g12<8,8,1>F g4.4<0,1,0>F { align1 }; +mul (8) g13<1>F g13<8,8,1>F g4.4<0,1,0>F { align1 }; + /* add in texture Y offset */ +/* Co[3] */ +add (8) g12<1>F g12<8,8,1>F g4.28<0,1,0>F { align1 }; +add (8) g13<1>F g13<8,8,1>F g4.28<0,1,0>F { align1 }; + +mov (8) m1<1>F g10<8,8,1>F { align1 }; +mov (8) m2<1>F g11<8,8,1>F { align1 }; +mov (8) m3<1>F g12<8,8,1>F { align1 }; +mov (8) m4<1>F g13<8,8,1>F { align1 }; + +/* mask sampler g22-g29 */ +/* binding_table (2), sampler (1) */ +send (16) 0 g22<1>UW g0<8,8,1>UW sampler (2,1,F) mlen 5 rlen 8 { align1 }; +mov (8) g29<1>UD g29<8,8,1>UD { align1 }; /* wait sampler return */ + +/* mul mask's channel to src, then write out src */ +mul (8) g14<1>F g14<8,8,1>F g22<8,8,1>F { align1 }; +mul (8) g15<1>F g15<8,8,1>F g23<8,8,1>F { align1 }; +mul (8) g16<1>F g16<8,8,1>F g24<8,8,1>F { align1 }; +mul (8) g17<1>F g17<8,8,1>F g25<8,8,1>F { align1 }; +mul (8) g18<1>F g18<8,8,1>F g26<8,8,1>F { align1 }; +mul (8) g19<1>F g19<8,8,1>F g27<8,8,1>F { align1 }; +mul (8) g20<1>F g20<8,8,1>F g28<8,8,1>F { align1 }; +mul (8) g21<1>F g21<8,8,1>F g29<8,8,1>F { align1 }; + +/* prepare data in m2-m5 for subspan(1,0), m6-m9 for subspan(3,2), then it's ready to write */ +mov (8) m2<1>F g14<8,8,1>F { align1 }; +mov (8) m3<1>F g16<8,8,1>F { align1 }; +mov (8) m4<1>F g18<8,8,1>F { align1 }; +mov (8) m5<1>F g20<8,8,1>F { align1 }; +mov (8) m6<1>F g15<8,8,1>F { align1 }; +mov (8) m7<1>F g17<8,8,1>F { align1 }; +mov (8) m8<1>F g19<8,8,1>F { align1 }; +mov (8) m9<1>F g21<8,8,1>F { align1 }; + +/* m0, m1 are all direct passed by PS thread payload */ +mov (8) m1<1>UD g1<8,8,1>UD { align1 mask_disable }; + +/* write */ +send (16) 0 acc0<1>UW g0<8,8,1>UW write ( + 0, /* binding_table */ + 8, /* pixel scordboard clear, msg type simd16 single source */ + 4, /* render target write */ + 0 /* no write commit message */ + ) + mlen 10 + rlen 0 + { align1 EOT }; + +nop; +nop; +nop; +nop; +nop; +nop; +nop; +nop; +nop; diff --git a/src/exa_wm_maskca_prog.h b/src/exa_wm_maskca_prog.h new file mode 100644 index 00000000..d936412c --- /dev/null +++ b/src/exa_wm_maskca_prog.h @@ -0,0 +1,95 @@ + { 0x00000001, 0x20c0013d, 0x00000028, 0x00000000 }, + { 0x00000040, 0x20c40d3d, 0x00000028, 0x00000001 }, + { 0x00000001, 0x20c8013d, 0x00000028, 0x00000000 }, + { 0x00000040, 0x20cc0d3d, 0x00000028, 0x00000001 }, + { 0x00000001, 0x2100013d, 0x0000002a, 0x00000000 }, + { 0x00000001, 0x2104013d, 0x0000002a, 0x00000000 }, + { 0x00000040, 0x21080d3d, 0x0000002a, 0x00000001 }, + { 0x00000040, 0x210c0d3d, 0x0000002a, 0x00000001 }, + { 0x00000001, 0x20d0013d, 0x0000002c, 0x00000000 }, + { 0x00000040, 0x20d40d3d, 0x0000002c, 0x00000001 }, + { 0x00000001, 0x20d8013d, 0x0000002c, 0x00000000 }, + { 0x00000040, 0x20dc0d3d, 0x0000002c, 0x00000001 }, + { 0x00000001, 0x2110013d, 0x0000002e, 0x00000000 }, + { 0x00000001, 0x2114013d, 0x0000002e, 0x00000000 }, + { 0x00000040, 0x21180d3d, 0x0000002e, 0x00000001 }, + { 0x00000040, 0x211c0d3d, 0x0000002e, 0x00000001 }, + { 0x00000001, 0x20e0013d, 0x00000030, 0x00000000 }, + { 0x00000040, 0x20e40d3d, 0x00000030, 0x00000001 }, + { 0x00000001, 0x20e8013d, 0x00000030, 0x00000000 }, + { 0x00000040, 0x20ec0d3d, 0x00000030, 0x00000001 }, + { 0x00000001, 0x2120013d, 0x00000032, 0x00000000 }, + { 0x00000001, 0x2124013d, 0x00000032, 0x00000000 }, + { 0x00000040, 0x21280d3d, 0x00000032, 0x00000001 }, + { 0x00000040, 0x212c0d3d, 0x00000032, 0x00000001 }, + { 0x00000001, 0x20f0013d, 0x00000034, 0x00000000 }, + { 0x00000040, 0x20f40d3d, 0x00000034, 0x00000001 }, + { 0x00000001, 0x20f8013d, 0x00000034, 0x00000000 }, + { 0x00000040, 0x20fc0d3d, 0x00000034, 0x00000001 }, + { 0x00000001, 0x2130013d, 0x00000036, 0x00000000 }, + { 0x00000001, 0x2134013d, 0x00000036, 0x00000000 }, + { 0x00000040, 0x21380d3d, 0x00000036, 0x00000001 }, + { 0x00000040, 0x213c0d3d, 0x00000036, 0x00000001 }, + { 0x00600040, 0x214077bd, 0x008d00c0, 0x00004020 }, + { 0x00600040, 0x216077bd, 0x008d00e0, 0x00004020 }, + { 0x00600041, 0x214077bd, 0x008d0140, 0x00000060 }, + { 0x00600041, 0x216077bd, 0x008d0160, 0x00000060 }, + { 0x00600040, 0x214077bd, 0x008d0140, 0x0000006c }, + { 0x00600040, 0x216077bd, 0x008d0160, 0x0000006c }, + { 0x00600040, 0x218077bd, 0x008d0100, 0x00004024 }, + { 0x00600040, 0x21a077bd, 0x008d0120, 0x00004024 }, + { 0x00600041, 0x218077bd, 0x008d0180, 0x00000064 }, + { 0x00600041, 0x21a077bd, 0x008d01a0, 0x00000064 }, + { 0x00600040, 0x218077bd, 0x008d0180, 0x0000007c }, + { 0x00600040, 0x21a077bd, 0x008d01a0, 0x0000007c }, + { 0x00600001, 0x202003be, 0x008d0140, 0x00000000 }, + { 0x00600001, 0x204003be, 0x008d0160, 0x00000000 }, + { 0x00600001, 0x206003be, 0x008d0180, 0x00000000 }, + { 0x00600001, 0x208003be, 0x008d01a0, 0x00000000 }, + { 0x00800031, 0x21c01d29, 0x008d0000, 0x02580001 }, + { 0x00600001, 0x22a00021, 0x008d02a0, 0x00000000 }, + { 0x00600040, 0x214077bd, 0x008d00c0, 0x00004020 }, + { 0x00600040, 0x216077bd, 0x008d00e0, 0x00004020 }, + { 0x00600041, 0x214077bd, 0x008d0140, 0x00000080 }, + { 0x00600041, 0x216077bd, 0x008d0160, 0x00000080 }, + { 0x00600040, 0x214077bd, 0x008d0140, 0x0000008c }, + { 0x00600040, 0x216077bd, 0x008d0160, 0x0000008c }, + { 0x00600040, 0x218077bd, 0x008d0100, 0x00004024 }, + { 0x00600040, 0x21a077bd, 0x008d0120, 0x00004024 }, + { 0x00600041, 0x218077bd, 0x008d0180, 0x00000084 }, + { 0x00600041, 0x21a077bd, 0x008d01a0, 0x00000084 }, + { 0x00600040, 0x218077bd, 0x008d0180, 0x0000009c }, + { 0x00600040, 0x21a077bd, 0x008d01a0, 0x0000009c }, + { 0x00600001, 0x202003be, 0x008d0140, 0x00000000 }, + { 0x00600001, 0x204003be, 0x008d0160, 0x00000000 }, + { 0x00600001, 0x206003be, 0x008d0180, 0x00000000 }, + { 0x00600001, 0x208003be, 0x008d01a0, 0x00000000 }, + { 0x00800031, 0x22c01d29, 0x008d0000, 0x02580102 }, + { 0x00600001, 0x23a00021, 0x008d03a0, 0x00000000 }, + { 0x00600041, 0x21c077bd, 0x008d01c0, 0x008d02c0 }, + { 0x00600041, 0x21e077bd, 0x008d01e0, 0x008d02e0 }, + { 0x00600041, 0x220077bd, 0x008d0200, 0x008d0300 }, + { 0x00600041, 0x222077bd, 0x008d0220, 0x008d0320 }, + { 0x00600041, 0x224077bd, 0x008d0240, 0x008d0340 }, + { 0x00600041, 0x226077bd, 0x008d0260, 0x008d0360 }, + { 0x00600041, 0x228077bd, 0x008d0280, 0x008d0380 }, + { 0x00600041, 0x22a077bd, 0x008d02a0, 0x008d03a0 }, + { 0x00600001, 0x204003be, 0x008d01c0, 0x00000000 }, + { 0x00600001, 0x206003be, 0x008d0200, 0x00000000 }, + { 0x00600001, 0x208003be, 0x008d0240, 0x00000000 }, + { 0x00600001, 0x20a003be, 0x008d0280, 0x00000000 }, + { 0x00600001, 0x20c003be, 0x008d01e0, 0x00000000 }, + { 0x00600001, 0x20e003be, 0x008d0220, 0x00000000 }, + { 0x00600001, 0x210003be, 0x008d0260, 0x00000000 }, + { 0x00600001, 0x212003be, 0x008d02a0, 0x00000000 }, + { 0x00600201, 0x20200022, 0x008d0020, 0x00000000 }, + { 0x00800031, 0x24001d28, 0x008d0000, 0x85a04800 }, + { 0x0000007e, 0x00000000, 0x00000000, 0x00000000 }, + { 0x0000007e, 0x00000000, 0x00000000, 0x00000000 }, + { 0x0000007e, 0x00000000, 0x00000000, 0x00000000 }, + { 0x0000007e, 0x00000000, 0x00000000, 0x00000000 }, + { 0x0000007e, 0x00000000, 0x00000000, 0x00000000 }, + { 0x0000007e, 0x00000000, 0x00000000, 0x00000000 }, + { 0x0000007e, 0x00000000, 0x00000000, 0x00000000 }, + { 0x0000007e, 0x00000000, 0x00000000, 0x00000000 }, + { 0x0000007e, 0x00000000, 0x00000000, 0x00000000 }, diff --git a/src/exa_wm_maskca_srcalpha.g4a b/src/exa_wm_maskca_srcalpha.g4a new file mode 100644 index 00000000..e233968c --- /dev/null +++ b/src/exa_wm_maskca_srcalpha.g4a @@ -0,0 +1,202 @@ +/* + * This's for exa composite operation in no mask picture case. + * The simplest case is just sending what src picture has to dst picture. + * XXX: This is still experimental, and should be fixed to support multiple texture + * map, and conditional mul actions. + */ + +/* I think this should be same as in g4a program for texture video, + as we also use 16-pixel dispatch. and SF scale in g3 is useful for us. */ + +/* The initial payload of the thread is always g0. + * WM_URB (incoming URB entries) is g3 + As mask texture coeffient needs extra setup urb starting from g4, we should + shift this location. + + * X0_R is g4->g6 + * X1_R is g5->g7 + * Y0_R is g6->g8 + * Y1_R is g7->g9 + + * X0: {ss0.x, ss0.x+1, ss0.x, ss0.x+1, ss1.x, ss1.x+1, ss1.x, ss1.x+y} + * Y0: {ss0.y, ss0.y, ss0.y+1, ss0.y+1, ss1.y, ss1.y, ss1.y+1, ss1.y+1} + * X1: {ss2.x, ss2.x+1, ss2.x, ss2.x+1, ss3.x, ss3.x+1, ss3.x, ss3.x+y} + * Y1: {ss2.y, ss2.y, ss2.y+1, ss2.y+1, ss3.y, ss3.y, ss3.y+1, ss3.y+1} + */ + +/* multitexture program with src and mask texture */ +/* - load src texture */ +/* - load mask texture */ +/* - mul src.X with mask's alpha */ +/* - write out src.X */ + + /* Set up ss0.x coordinates*/ +mov (1) g6<1>F g1.8<0,1,0>UW { align1 }; +add (1) g6.4<1>F g1.8<0,1,0>UW 1UB { align1 }; +mov (1) g6.8<1>F g1.8<0,1,0>UW { align1 }; +add (1) g6.12<1>F g1.8<0,1,0>UW 1UB { align1 }; + /* Set up ss0.y coordinates */ +mov (1) g8<1>F g1.10<0,1,0>UW { align1 }; +mov (1) g8.4<1>F g1.10<0,1,0>UW { align1 }; +add (1) g8.8<1>F g1.10<0,1,0>UW 1UB { align1 }; +add (1) g8.12<1>F g1.10<0,1,0>UW 1UB { align1 }; + /* set up ss1.x coordinates */ +mov (1) g6.16<1>F g1.12<0,1,0>UW { align1 }; +add (1) g6.20<1>F g1.12<0,1,0>UW 1UB { align1 }; +mov (1) g6.24<1>F g1.12<0,1,0>UW { align1 }; +add (1) g6.28<1>F g1.12<0,1,0>UW 1UB { align1 }; + /* set up ss1.y coordinates */ +mov (1) g8.16<1>F g1.14<0,1,0>UW { align1 }; +mov (1) g8.20<1>F g1.14<0,1,0>UW { align1 }; +add (1) g8.24<1>F g1.14<0,1,0>UW 1UB { align1 }; +add (1) g8.28<1>F g1.14<0,1,0>UW 1UB { align1 }; + /* Set up ss2.x coordinates */ +mov (1) g7<1>F g1.16<0,1,0>UW { align1 }; +add (1) g7.4<1>F g1.16<0,1,0>UW 1UB { align1 }; +mov (1) g7.8<1>F g1.16<0,1,0>UW { align1 }; +add (1) g7.12<1>F g1.16<0,1,0>UW 1UB { align1 }; + /* Set up ss2.y coordinates */ +mov (1) g9<1>F g1.18<0,1,0>UW { align1 }; +mov (1) g9.4<1>F g1.18<0,1,0>UW { align1 }; +add (1) g9.8<1>F g1.18<0,1,0>UW 1UB { align1 }; +add (1) g9.12<1>F g1.18<0,1,0>UW 1UB { align1 }; + /* Set up ss3.x coordinates */ +mov (1) g7.16<1>F g1.20<0,1,0>UW { align1 }; +add (1) g7.20<1>F g1.20<0,1,0>UW 1UB { align1 }; +mov (1) g7.24<1>F g1.20<0,1,0>UW { align1 }; +add (1) g7.28<1>F g1.20<0,1,0>UW 1UB { align1 }; + /* Set up ss3.y coordinates */ +mov (1) g9.16<1>F g1.22<0,1,0>UW { align1 }; +mov (1) g9.20<1>F g1.22<0,1,0>UW { align1 }; +add (1) g9.24<1>F g1.22<0,1,0>UW 1UB { align1 }; +add (1) g9.28<1>F g1.22<0,1,0>UW 1UB { align1 }; + + /* Now, map these screen space coordinates into texture coordinates. */ +/* This is for src texture */ +/* I don't want to change origin ssX coords, as it will be used later in mask */ +/* so store tex coords in g10, g11, g12, g13 */ + + /* subtract screen-space X origin of vertex 0. */ +add (8) g10<1>F g6<8,8,1>F -g1<0,1,0>F { align1 }; +add (8) g11<1>F g7<8,8,1>F -g1<0,1,0>F { align1 }; + /* scale by texture X increment */ +/* Cx[0] */ +mul (8) g10<1>F g10<8,8,1>F g3<0,1,0>F { align1 }; +mul (8) g11<1>F g11<8,8,1>F g3<0,1,0>F { align1 }; + /* add in texture X offset */ +/* Co[0] */ +add (8) g10<1>F g10<8,8,1>F g3.12<0,1,0>F { align1 }; +add (8) g11<1>F g11<8,8,1>F g3.12<0,1,0>F { align1 }; + /* subtract screen-space Y origin of vertex 0. */ +add (8) g12<1>F g8<8,8,1>F -g1.4<0,1,0>F { align1 }; +add (8) g13<1>F g9<8,8,1>F -g1.4<0,1,0>F { align1 }; + /* scale by texture Y increment */ +/* Cy[0] */ +mul (8) g12<1>F g12<8,8,1>F g3.4<0,1,0>F { align1 }; +mul (8) g13<1>F g13<8,8,1>F g3.4<0,1,0>F { align1 }; + /* add in texture Y offset */ +/* Co[1] */ +add (8) g12<1>F g12<8,8,1>F g3.28<0,1,0>F { align1 }; +add (8) g13<1>F g13<8,8,1>F g3.28<0,1,0>F { align1 }; + +/* prepare sampler read back gX register, which would be written back to output */ + +/* use simd16 sampler, param 0 is u, param 1 is v. */ +/* 'payload' loading, assuming tex coord start from g4 */ +mov (8) m1<1>F g10<8,8,1>F { align1 }; +mov (8) m2<1>F g11<8,8,1>F { align1 }; /* param 0 u in m1, m2 */ +mov (8) m3<1>F g12<8,8,1>F { align1 }; +mov (8) m4<1>F g13<8,8,1>F { align1 }; /* param 1 v in m3, m4 */ + +/* m0 will be copied with g0, as it contains send desc */ +/* emit sampler 'send' cmd */ + +/* src texture readback: g14-g21 */ +send (16) 0 /* msg reg index */ + g14<1>UW /* readback */ + g0<8,8,1>UW /* copy to msg start reg*/ + sampler (1,0,F) /* sampler message description, + (binding_table,sampler_index,datatype). + here(src->dst) we should use src_sampler and + src_surface */ + mlen 5 rlen 8 { align1 }; /* required message len 5, readback len 8 */ + +mov (8) g21<1>UD g21<8,8,1>UD { align1 }; /* wait sampler return */ + +/* sampler mask texture, use g10, g11, g12, g13 */ + /* subtract screen-space X origin of vertex 0. */ +add (8) g10<1>F g6<8,8,1>F -g1<0,1,0>F { align1 }; +add (8) g11<1>F g7<8,8,1>F -g1<0,1,0>F { align1 }; + /* scale by texture X increment */ +/* Cx[2] */ +mul (8) g10<1>F g10<8,8,1>F g4<0,1,0>F { align1 }; +mul (8) g11<1>F g11<8,8,1>F g4<0,1,0>F { align1 }; + /* add in texture X offset */ +/* Co[2] */ +add (8) g10<1>F g10<8,8,1>F g4.12<0,1,0>F { align1 }; +add (8) g11<1>F g11<8,8,1>F g4.12<0,1,0>F { align1 }; + /* subtract screen-space Y origin of vertex 0. */ +add (8) g12<1>F g8<8,8,1>F -g1.4<0,1,0>F { align1 }; +add (8) g13<1>F g9<8,8,1>F -g1.4<0,1,0>F { align1 }; + /* scale by texture Y increment */ +/* Cy[2] */ +mul (8) g12<1>F g12<8,8,1>F g4.4<0,1,0>F { align1 }; +mul (8) g13<1>F g13<8,8,1>F g4.4<0,1,0>F { align1 }; + /* add in texture Y offset */ +/* Co[3] */ +add (8) g12<1>F g12<8,8,1>F g4.28<0,1,0>F { align1 }; +add (8) g13<1>F g13<8,8,1>F g4.28<0,1,0>F { align1 }; + +mov (8) m1<1>F g10<8,8,1>F { align1 }; +mov (8) m2<1>F g11<8,8,1>F { align1 }; +mov (8) m3<1>F g12<8,8,1>F { align1 }; +mov (8) m4<1>F g13<8,8,1>F { align1 }; + +/* mask sampler g22-g29 */ +/* binding_table (2), sampler (1) */ +send (16) 0 g22<1>UW g0<8,8,1>UW sampler (2,1,F) mlen 5 rlen 8 { align1 }; +mov (8) g29<1>UD g29<8,8,1>UD { align1 }; /* wait sampler return */ + +/* src channel has no more use, src.A * mask.C */ +mul (8) g14<1>F g22<8,8,1>F g20<8,8,1>F { align1 }; +mul (8) g15<1>F g23<8,8,1>F g21<8,8,1>F { align1 }; +mul (8) g16<1>F g24<8,8,1>F g20<8,8,1>F { align1 }; +mul (8) g17<1>F g25<8,8,1>F g21<8,8,1>F { align1 }; +mul (8) g18<1>F g26<8,8,1>F g20<8,8,1>F { align1 }; +mul (8) g19<1>F g27<8,8,1>F g21<8,8,1>F { align1 }; +mul (8) g20<1>F g28<8,8,1>F g20<8,8,1>F { align1 }; +mul (8) g21<1>F g29<8,8,1>F g21<8,8,1>F { align1 }; + +/* prepare data in m2-m5 for subspan(1,0), m6-m9 for subspan(3,2), then it's ready to write */ +mov (8) m2<1>F g14<8,8,1>F { align1 }; +mov (8) m3<1>F g16<8,8,1>F { align1 }; +mov (8) m4<1>F g18<8,8,1>F { align1 }; +mov (8) m5<1>F g20<8,8,1>F { align1 }; +mov (8) m6<1>F g15<8,8,1>F { align1 }; +mov (8) m7<1>F g17<8,8,1>F { align1 }; +mov (8) m8<1>F g19<8,8,1>F { align1 }; +mov (8) m9<1>F g21<8,8,1>F { align1 }; + +/* m0, m1 are all direct passed by PS thread payload */ +mov (8) m1<1>UD g1<8,8,1>UD { align1 mask_disable }; + +/* write */ +send (16) 0 acc0<1>UW g0<8,8,1>UW write ( + 0, /* binding_table */ + 8, /* pixel scordboard clear, msg type simd16 single source */ + 4, /* render target write */ + 0 /* no write commit message */ + ) + mlen 10 + rlen 0 + { align1 EOT }; + +nop; +nop; +nop; +nop; +nop; +nop; +nop; +nop; +nop; diff --git a/src/exa_wm_maskca_srcalpha_prog.h b/src/exa_wm_maskca_srcalpha_prog.h new file mode 100644 index 00000000..d83b119f --- /dev/null +++ b/src/exa_wm_maskca_srcalpha_prog.h @@ -0,0 +1,95 @@ + { 0x00000001, 0x20c0013d, 0x00000028, 0x00000000 }, + { 0x00000040, 0x20c40d3d, 0x00000028, 0x00000001 }, + { 0x00000001, 0x20c8013d, 0x00000028, 0x00000000 }, + { 0x00000040, 0x20cc0d3d, 0x00000028, 0x00000001 }, + { 0x00000001, 0x2100013d, 0x0000002a, 0x00000000 }, + { 0x00000001, 0x2104013d, 0x0000002a, 0x00000000 }, + { 0x00000040, 0x21080d3d, 0x0000002a, 0x00000001 }, + { 0x00000040, 0x210c0d3d, 0x0000002a, 0x00000001 }, + { 0x00000001, 0x20d0013d, 0x0000002c, 0x00000000 }, + { 0x00000040, 0x20d40d3d, 0x0000002c, 0x00000001 }, + { 0x00000001, 0x20d8013d, 0x0000002c, 0x00000000 }, + { 0x00000040, 0x20dc0d3d, 0x0000002c, 0x00000001 }, + { 0x00000001, 0x2110013d, 0x0000002e, 0x00000000 }, + { 0x00000001, 0x2114013d, 0x0000002e, 0x00000000 }, + { 0x00000040, 0x21180d3d, 0x0000002e, 0x00000001 }, + { 0x00000040, 0x211c0d3d, 0x0000002e, 0x00000001 }, + { 0x00000001, 0x20e0013d, 0x00000030, 0x00000000 }, + { 0x00000040, 0x20e40d3d, 0x00000030, 0x00000001 }, + { 0x00000001, 0x20e8013d, 0x00000030, 0x00000000 }, + { 0x00000040, 0x20ec0d3d, 0x00000030, 0x00000001 }, + { 0x00000001, 0x2120013d, 0x00000032, 0x00000000 }, + { 0x00000001, 0x2124013d, 0x00000032, 0x00000000 }, + { 0x00000040, 0x21280d3d, 0x00000032, 0x00000001 }, + { 0x00000040, 0x212c0d3d, 0x00000032, 0x00000001 }, + { 0x00000001, 0x20f0013d, 0x00000034, 0x00000000 }, + { 0x00000040, 0x20f40d3d, 0x00000034, 0x00000001 }, + { 0x00000001, 0x20f8013d, 0x00000034, 0x00000000 }, + { 0x00000040, 0x20fc0d3d, 0x00000034, 0x00000001 }, + { 0x00000001, 0x2130013d, 0x00000036, 0x00000000 }, + { 0x00000001, 0x2134013d, 0x00000036, 0x00000000 }, + { 0x00000040, 0x21380d3d, 0x00000036, 0x00000001 }, + { 0x00000040, 0x213c0d3d, 0x00000036, 0x00000001 }, + { 0x00600040, 0x214077bd, 0x008d00c0, 0x00004020 }, + { 0x00600040, 0x216077bd, 0x008d00e0, 0x00004020 }, + { 0x00600041, 0x214077bd, 0x008d0140, 0x00000060 }, + { 0x00600041, 0x216077bd, 0x008d0160, 0x00000060 }, + { 0x00600040, 0x214077bd, 0x008d0140, 0x0000006c }, + { 0x00600040, 0x216077bd, 0x008d0160, 0x0000006c }, + { 0x00600040, 0x218077bd, 0x008d0100, 0x00004024 }, + { 0x00600040, 0x21a077bd, 0x008d0120, 0x00004024 }, + { 0x00600041, 0x218077bd, 0x008d0180, 0x00000064 }, + { 0x00600041, 0x21a077bd, 0x008d01a0, 0x00000064 }, + { 0x00600040, 0x218077bd, 0x008d0180, 0x0000007c }, + { 0x00600040, 0x21a077bd, 0x008d01a0, 0x0000007c }, + { 0x00600001, 0x202003be, 0x008d0140, 0x00000000 }, + { 0x00600001, 0x204003be, 0x008d0160, 0x00000000 }, + { 0x00600001, 0x206003be, 0x008d0180, 0x00000000 }, + { 0x00600001, 0x208003be, 0x008d01a0, 0x00000000 }, + { 0x00800031, 0x21c01d29, 0x008d0000, 0x02580001 }, + { 0x00600001, 0x22a00021, 0x008d02a0, 0x00000000 }, + { 0x00600040, 0x214077bd, 0x008d00c0, 0x00004020 }, + { 0x00600040, 0x216077bd, 0x008d00e0, 0x00004020 }, + { 0x00600041, 0x214077bd, 0x008d0140, 0x00000080 }, + { 0x00600041, 0x216077bd, 0x008d0160, 0x00000080 }, + { 0x00600040, 0x214077bd, 0x008d0140, 0x0000008c }, + { 0x00600040, 0x216077bd, 0x008d0160, 0x0000008c }, + { 0x00600040, 0x218077bd, 0x008d0100, 0x00004024 }, + { 0x00600040, 0x21a077bd, 0x008d0120, 0x00004024 }, + { 0x00600041, 0x218077bd, 0x008d0180, 0x00000084 }, + { 0x00600041, 0x21a077bd, 0x008d01a0, 0x00000084 }, + { 0x00600040, 0x218077bd, 0x008d0180, 0x0000009c }, + { 0x00600040, 0x21a077bd, 0x008d01a0, 0x0000009c }, + { 0x00600001, 0x202003be, 0x008d0140, 0x00000000 }, + { 0x00600001, 0x204003be, 0x008d0160, 0x00000000 }, + { 0x00600001, 0x206003be, 0x008d0180, 0x00000000 }, + { 0x00600001, 0x208003be, 0x008d01a0, 0x00000000 }, + { 0x00800031, 0x22c01d29, 0x008d0000, 0x02580102 }, + { 0x00600001, 0x23a00021, 0x008d03a0, 0x00000000 }, + { 0x00600041, 0x21c077bd, 0x008d02c0, 0x008d0280 }, + { 0x00600041, 0x21e077bd, 0x008d02e0, 0x008d02a0 }, + { 0x00600041, 0x220077bd, 0x008d0300, 0x008d0280 }, + { 0x00600041, 0x222077bd, 0x008d0320, 0x008d02a0 }, + { 0x00600041, 0x224077bd, 0x008d0340, 0x008d0280 }, + { 0x00600041, 0x226077bd, 0x008d0360, 0x008d02a0 }, + { 0x00600041, 0x228077bd, 0x008d0380, 0x008d0280 }, + { 0x00600041, 0x22a077bd, 0x008d03a0, 0x008d02a0 }, + { 0x00600001, 0x204003be, 0x008d01c0, 0x00000000 }, + { 0x00600001, 0x206003be, 0x008d0200, 0x00000000 }, + { 0x00600001, 0x208003be, 0x008d0240, 0x00000000 }, + { 0x00600001, 0x20a003be, 0x008d0280, 0x00000000 }, + { 0x00600001, 0x20c003be, 0x008d01e0, 0x00000000 }, + { 0x00600001, 0x20e003be, 0x008d0220, 0x00000000 }, + { 0x00600001, 0x210003be, 0x008d0260, 0x00000000 }, + { 0x00600001, 0x212003be, 0x008d02a0, 0x00000000 }, + { 0x00600201, 0x20200022, 0x008d0020, 0x00000000 }, + { 0x00800031, 0x24001d28, 0x008d0000, 0x85a04800 }, + { 0x0000007e, 0x00000000, 0x00000000, 0x00000000 }, + { 0x0000007e, 0x00000000, 0x00000000, 0x00000000 }, + { 0x0000007e, 0x00000000, 0x00000000, 0x00000000 }, + { 0x0000007e, 0x00000000, 0x00000000, 0x00000000 }, + { 0x0000007e, 0x00000000, 0x00000000, 0x00000000 }, + { 0x0000007e, 0x00000000, 0x00000000, 0x00000000 }, + { 0x0000007e, 0x00000000, 0x00000000, 0x00000000 }, + { 0x0000007e, 0x00000000, 0x00000000, 0x00000000 }, + { 0x0000007e, 0x00000000, 0x00000000, 0x00000000 }, diff --git a/src/i965_render.c b/src/i965_render.c index a2b21db1..8474c483 100644 --- a/src/i965_render.c +++ b/src/i965_render.c @@ -133,7 +133,8 @@ static void i965_get_blend_cntl(int op, PicturePtr pMask, CARD32 dst_format, * the source blend factor is 0, and the source blend value is the mask * channels multiplied by the source picture's alpha. */ - if (pMask && pMask->componentAlpha && i965_blend_op[op].src_alpha) { + if (pMask && pMask->componentAlpha && PICT_FORMAT_RGB(pMask->format) + && i965_blend_op[op].src_alpha) { if (*dblend == BRW_BLENDFACTOR_SRC_ALPHA) { *dblend = BRW_BLENDFACTOR_SRC_COLOR; } else if (*dblend == BRW_BLENDFACTOR_INV_SRC_ALPHA) { @@ -223,7 +224,8 @@ i965_check_composite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture, if (op >= sizeof(i965_blend_op) / sizeof(i965_blend_op[0])) I830FALLBACK("Unsupported Composite op 0x%x\n", op); - if (pMaskPicture != NULL && pMaskPicture->componentAlpha) { + if (pMaskPicture && pMaskPicture->componentAlpha && + PICT_FORMAT_RGB(pMaskPicture->format)) { /* Check if it's component alpha that relies on a source alpha and on * the source value. We can only get one of those into the single * source value that we get to blend with. @@ -234,9 +236,7 @@ i965_check_composite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture, I830FALLBACK("Component alpha not supported with source " "alpha and source value blending.\n"); } - /* XXX: fallback now for mask with componentAlpha */ - I830FALLBACK("mask componentAlpha not ready.\n"); - } + } if (!i965_check_composite_texture(pSrcPicture, 0)) I830FALLBACK("Check Src picture texture\n"); @@ -337,17 +337,19 @@ static const CARD32 sf_kernel_static_mask[][4] = { /* ps kernels */ #define PS_KERNEL_NUM_GRF 32 #define PS_MAX_THREADS 32 -/* 1: no mask */ + static const CARD32 ps_kernel_static_nomask [][4] = { #include "exa_wm_nomask_prog.h" }; -/* 2: mask with componentAlpha, src * mask color, XXX: later */ static const CARD32 ps_kernel_static_maskca [][4] = { -/*#include "i965_composite_wm_maskca.h" */ +#include "exa_wm_maskca_prog.h" +}; + +static const CARD32 ps_kernel_static_maskca_srcalpha [][4] = { +#include "exa_wm_maskca_srcalpha_prog.h" }; -/* 3: mask without componentAlpha, src * mask alpha */ static const CARD32 ps_kernel_static_masknoca [][4] = { #include "exa_wm_masknoca_prog.h" }; @@ -442,13 +444,20 @@ i965_prepare_composite(int op, PicturePtr pSrcPicture, else next_offset = sf_kernel_offset + sizeof (sf_kernel_static); - /* XXX: ps_kernel may be seperated, fix with offset */ ps_kernel_offset = ALIGN(next_offset, 64); if (pMask) { - if (pMaskPicture->componentAlpha) - next_offset = ps_kernel_offset + sizeof(ps_kernel_static_maskca); - else - next_offset = ps_kernel_offset + sizeof(ps_kernel_static_masknoca); + if (pMaskPicture->componentAlpha && + PICT_FORMAT_RGB(pMaskPicture->format)) { + if (i965_blend_op[op].src_alpha) { + next_offset = ps_kernel_offset + + sizeof(ps_kernel_static_maskca_srcalpha); + } else { + next_offset = ps_kernel_offset + + sizeof(ps_kernel_static_maskca); + } + } else + next_offset = ps_kernel_offset + + sizeof(ps_kernel_static_masknoca); } else { next_offset = ps_kernel_offset + sizeof (ps_kernel_static_nomask); } @@ -746,7 +755,6 @@ i965_prepare_composite(int op, PicturePtr pSrcPicture, vs_state->vs6.vs_enable = 0; vs_state->vs6.vert_cache_disable = 1; - /* XXX: sf_kernel? keep it as now */ /* Set up the SF kernel to do coord interp: for each attribute, * calculate dA/dx and dA/dy. Hand these interpolation coefficients * back to SF which then hands pixels off to WM. @@ -788,10 +796,15 @@ i965_prepare_composite(int op, PicturePtr pSrcPicture, /* Set up the PS kernel (dispatched by WM) */ if (pMask) { - if (pMaskPicture->componentAlpha) - memcpy(ps_kernel, ps_kernel_static_maskca, - sizeof (ps_kernel_static_maskca)); - else + if (pMaskPicture->componentAlpha && + PICT_FORMAT_RGB(pMaskPicture->format)) { + if (i965_blend_op[op].src_alpha) + memcpy(ps_kernel, ps_kernel_static_maskca_srcalpha, + sizeof (ps_kernel_static_maskca_srcalpha)); + else + memcpy(ps_kernel, ps_kernel_static_maskca, + sizeof (ps_kernel_static_maskca)); + } else memcpy(ps_kernel, ps_kernel_static_masknoca, sizeof (ps_kernel_static_masknoca)); } else { @@ -812,7 +825,6 @@ i965_prepare_composite(int op, PicturePtr pSrcPicture, wm_state->thread2.scratch_space_base_pointer = (state_base_offset + wm_scratch_offset)>>10; wm_state->thread2.per_thread_scratch_space = 0; - // XXX: urb allocation wm_state->thread3.const_urb_entry_read_length = 0; wm_state->thread3.const_urb_entry_read_offset = 0; /* Each pair of attributes (src/mask coords) is one URB entry */ From d1be0dc4e9d443dcbd218a083cfb21a0b5d634ee Mon Sep 17 00:00:00 2001 From: Wang Zhenyu Date: Thu, 15 Feb 2007 11:03:12 +0800 Subject: [PATCH 20/29] EXA: fix i965 default color (0,0,0,1.0) -> (0,0,0,0) (0,0,0,1.0) is actually black... --- src/i965_render.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/i965_render.c b/src/i965_render.c index 8474c483..5c3f61d6 100644 --- a/src/i965_render.c +++ b/src/i965_render.c @@ -698,7 +698,7 @@ i965_prepare_composite(int op, PicturePtr pSrcPicture, default_color_state->color[0] = 0.0; /* R */ default_color_state->color[1] = 0.0; /* G */ default_color_state->color[2] = 0.0; /* B */ - default_color_state->color[3] = 1.0; /* A */ + default_color_state->color[3] = 0.0; /* A */ src_sampler_state->ss0.default_color_mode = 0; /* GL mode */ From 4541150cdce3f2f83b8530d0863aecf28c6610a9 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 15 Feb 2007 09:51:04 -0800 Subject: [PATCH 21/29] Detect core clock frequencies, to avoid double-wide mode when possible. Additionally, don't attempt to set double-wide on the 965, where there is no such thing any more (not that we'd ever see modes high enough to trigger it). --- src/i810_reg.h | 13 ++++++++ src/i830_display.c | 75 ++++++++++++++++++++++++++++++++++++---------- 2 files changed, 73 insertions(+), 15 deletions(-) diff --git a/src/i810_reg.h b/src/i810_reg.h index 68cce930..2c060564 100644 --- a/src/i810_reg.h +++ b/src/i810_reg.h @@ -1848,6 +1848,19 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define I852_GME 0x2 #define I852_GM 0x5 +#define I915_GCFGC 0xf0 +#define I915_LOW_FREQUENCY_ENABLE (1 << 7) +#define I915_DISPLAY_CLOCK_190_200_MHZ (0 << 4) +#define I915_DISPLAY_CLOCK_333_MHZ (4 << 4) +#define I915_DISPLAY_CLOCK_MASK (7 << 4) + +#define I855_HPLLCC 0xc0 +#define I855_CLOCK_CONTROL_MASK (3 << 0) +#define I855_CLOCK_133_200 (0 << 0) +#define I855_CLOCK_100_200 (1 << 0) +#define I855_CLOCK_100_133 (2 << 0) +#define I855_CLOCK_166_250 (3 << 0) + /* BLT commands */ #define COLOR_BLT_CMD ((2<<29)|(0x40<<22)|(0x3)) #define COLOR_BLT_WRITE_ALPHA (1<<21) diff --git a/src/i830_display.c b/src/i830_display.c index 345eea9f..f44a8bf3 100644 --- a/src/i830_display.c +++ b/src/i830_display.c @@ -591,6 +591,59 @@ i830_crtc_mode_fixup(xf86CrtcPtr crtc, DisplayModePtr mode, return TRUE; } +/** Returns the core display clock speed for i830 - i945 */ +static int +i830_get_core_clock_speed(ScrnInfoPtr pScrn) +{ + I830Ptr pI830 = I830PTR(pScrn); + + /* Core clock values taken from the published datasheets. + * The 830 may go up to 166 Mhz, which we should check. + */ + if (IS_I945G(pI830)) + return 400000; + else if (IS_I915G(pI830)) + return 333000; + else if (IS_I945GM(pI830) || IS_845G(pI830)) + return 200000; + else if (IS_I915GM(pI830)) { + CARD16 gcfgc = pciReadWord(pI830->PciTag, I915_GCFGC); + + if (gcfgc & I915_LOW_FREQUENCY_ENABLE) + return 133000; + else { + switch (gcfgc & I915_DISPLAY_CLOCK_MASK) { + case I915_DISPLAY_CLOCK_333_MHZ: + return 333000; + default: + case I915_DISPLAY_CLOCK_190_200_MHZ: + return 190000; + } + } + } else if (IS_I865G(pI830)) + return 266000; + else if (IS_I855(pI830)) { + PCITAG bridge = pciTag(0, 0, 0); /* This is always the host bridge */ + CARD16 hpllcc = pciReadWord(bridge, I855_HPLLCC); + + /* Assume that the hardware is in the high speed state. This + * should be the default. + */ + switch (hpllcc & I855_CLOCK_CONTROL_MASK) { + case I855_CLOCK_133_200: + case I855_CLOCK_100_200: + return 200000; + case I855_CLOCK_166_250: + return 250000; + case I855_CLOCK_100_133: + return 133000; + } + } else /* 852, 830 */ + return 133000; + + return 0; /* Silence gcc warning */ +} + /** * Sets up registers for the given mode/adjusted_mode pair. * @@ -749,23 +802,15 @@ i830_crtc_mode_set(xf86CrtcPtr crtc, DisplayModePtr mode, dspcntr |= DISPPLANE_SEL_PIPE_B; pipeconf = INREG(pipeconf_reg); - if (pipe == 0) + if (pipe == 0 && !IS_I965G(pI830)) { - /* - * The docs say this is needed when the dot clock is > 90% of the - * core speed. Core speeds are indicated by bits in the PCI - * config space, but that's a pain to go read, so we just guess - * based on the hardware age. AGP hardware is assumed to run - * at 133MHz while PCI-E hardware is assumed to run at 200MHz + /* Enable pixel doubling when the dot clock is > 90% of the (display) + * core speed. + * + * XXX: No double-wide on 915GM pipe B. Is that the only reason for the + * pipe == 0 check? */ - int core_clock; - - if (IS_I9XX(pI830)) - core_clock = 200000; - else - core_clock = 133000; - - if (mode->Clock > core_clock * 9 / 10) + if (mode->Clock > i830_get_core_clock_speed(pScrn) * 9 / 10) pipeconf |= PIPEACONF_DOUBLE_WIDE; else pipeconf &= ~PIPEACONF_DOUBLE_WIDE; From 6e33c4c44030e05d6d07ca9274cfe4d6df2c0387 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 15 Feb 2007 09:54:43 -0800 Subject: [PATCH 22/29] Print the correct meaning of bit 30 of pipeconf for 965 in debug output. --- src/i810_reg.h | 1 + src/i830_debug.c | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/i810_reg.h b/src/i810_reg.h index 2c060564..455c226a 100644 --- a/src/i810_reg.h +++ b/src/i810_reg.h @@ -1690,6 +1690,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define PIPEACONF_ENABLE (1<<31) #define PIPEACONF_DISABLE 0 #define PIPEACONF_DOUBLE_WIDE (1<<30) +#define I965_PIPECONF_ACTIVE (1<<30) #define PIPEACONF_SINGLE_WIDE 0 #define PIPEACONF_PIPE_UNLOCKED 0 #define PIPEACONF_PIPE_LOCKED (1<<25) diff --git a/src/i830_debug.c b/src/i830_debug.c index e0be0a4a..6716eaab 100644 --- a/src/i830_debug.c +++ b/src/i830_debug.c @@ -69,8 +69,12 @@ DEBUGSTRING(i830_debug_dspcntr) DEBUGSTRING(i830_debug_pipeconf) { char *enabled = val & PIPEACONF_ENABLE ? "enabled" : "disabled"; - char *wide = val & PIPEACONF_DOUBLE_WIDE ? "double-wide" : "single-wide"; - return XNFprintf("%s, %s", enabled, wide); + char *bit30; + if (IS_I965G(pI830)) + bit30 = val & I965_PIPECONF_ACTIVE ? "active" : "inactive"; + else + bit30 = val & PIPEACONF_DOUBLE_WIDE ? "double-wide" : "single-wide"; + return XNFprintf("%s, %s", enabled, bit30); } DEBUGSTRING(i830_debug_hvtotal) From 8e7bc4b1f95f5d62ff18cd94f14f5e3949ef6a29 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 15 Feb 2007 11:17:53 -0800 Subject: [PATCH 23/29] Use server sources for crtc/output generic code. As sources for these have been merged to the server, use them from the server source code instead of keeping copies in this driver. --- configure.ac | 36 ++++++++++++++++++++++++++++++++++++ src/Makefile.am | 28 +++++++++++++++------------- 2 files changed, 51 insertions(+), 13 deletions(-) diff --git a/configure.ac b/configure.ac index d45185ae..e0d828e8 100644 --- a/configure.ac +++ b/configure.ac @@ -70,6 +70,42 @@ AC_ARG_ENABLE(video-debug, AC_HELP_STRING([--enable-video-debug], [VIDEO_DEBUG="$enableval"], [VIDEO_DEBUG=no]) +AC_ARG_WITH(xserver-source,AC_HELP_STRING([--with-xserver-source=XSERVER_SOURCE], + [Path to X server source tree]), + [ XSERVER_SOURCE="$withval" ], + [ XSERVER_SOURCE="" ]) + + +PKG_CHECK_MODULES(XORG_XSERVER, xorg-server >= 1.2.99, [XMODES=yes], [XMODES=no]) + +AM_CONDITIONAL(XMODES, [test "x$XMODES" = xyes]) + +if test "x$XMODES" = xyes; then + AC_DEFINE(XMODES, 1,[X server as built-in mode code]) +else + if test "x$XSERVER_SOURCE" = x; then + if test -d ../../xserver; then + XSERVER_SOURCE="`cd ../../xserver && pwd`" + fi + fi + + if test "x$XSERVER_SOURCE" = x; then + AC_MSG_ERROR([Must have X server >= 1.3 source tree for mode setting code. Please specify --with-xserver-source]) + fi + + if test -f src/modes/xf86Crtc.h; then + : + else + ln -s $XSERVER_SOURCE/hw/xfree86/modes src/modes + fi + + if test -f src/parser/xf86Parser.h; then + : + else + ln -s $XSERVER_SOURCE/hw/xfree86/parser src/parser + fi + +fi # Checks for extensions XORG_DRIVER_CHECK_EXT(XINERAMA, xineramaproto) diff --git a/src/Makefile.am b/src/Makefile.am index 982a959d..e3a0fcca 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -28,6 +28,8 @@ SUBDIRS = xvmc bios_reader ch7017 ch7xxx ivch sil164 AM_CFLAGS = @WARN_CFLAGS@ @XORG_CFLAGS@ @DRI_CFLAGS@ \ -DI830_XV -DI830_USE_XAA -DI830_USE_EXA +AM_INCLUDES=-Iparser -Imodes + intel_drv_la_LTLIBRARIES = intel_drv.la intel_drv_la_LDFLAGS = -module -avoid-version intel_drv_ladir = @moduledir@/drivers @@ -86,20 +88,20 @@ intel_drv_la_SOURCES = \ i830_render.c \ i915_render.c \ i965_render.c \ - i830_xf86Rename.h \ local_xf86Rename.h \ - xf86Parser.h \ - xf86Optrec.h \ - i830_xf86Modes.h \ - i830_xf86Modes.c \ - i830_xf86cvt.c \ - i830_xf86Crtc.h \ - i830_xf86Crtc.c \ - i830_xf86EdidModes.c \ - i830_xf86RandR12.c \ - i830_xf86RandR12.h \ - i830_xf86Rotate.c \ - i830_xf86DiDGA.c + parser/xf86Rename.h \ + parser/xf86Parser.h \ + parser/xf86Optrec.h \ + modes/xf86Modes.h \ + modes/xf86Modes.c \ + modes/xf86cvt.c \ + modes/xf86Crtc.h \ + modes/xf86Crtc.c \ + modes/xf86EdidModes.c \ + modes/xf86RandR12.c \ + modes/xf86RandR12.h \ + modes/xf86Rotate.c \ + modes/xf86DiDGA.c EXTRA_DIST = \ packed_yuv_sf.g4a \ From 17e38e39a49b2a96e31cca4a0b922631c5f7879e Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 15 Feb 2007 23:09:43 -0800 Subject: [PATCH 24/29] Enable mode setting function renames from shared code. --- src/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile.am b/src/Makefile.am index e3a0fcca..3f680c71 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -26,7 +26,7 @@ SUBDIRS = xvmc bios_reader ch7017 ch7xxx ivch sil164 # _ladir passes a dummy rpath to libtool so the thing will actually link # TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc. AM_CFLAGS = @WARN_CFLAGS@ @XORG_CFLAGS@ @DRI_CFLAGS@ \ - -DI830_XV -DI830_USE_XAA -DI830_USE_EXA + -DI830_XV -DI830_USE_XAA -DI830_USE_EXA -DXF86_MODES_RENAME AM_INCLUDES=-Iparser -Imodes From 20e146a09e3b4907a6800588ebfa787bfc5b0d89 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 16 Feb 2007 00:57:44 -0800 Subject: [PATCH 25/29] Change rotation pixmap creation API to permit start-time rotation. Start time rotation requires that the pixmap be created after the server has initialized the screens. Delay the pixmap creation until the first block handler invocation. --- src/Makefile.am | 4 +-- src/i830.h | 4 +-- src/i830_crt.c | 2 +- src/i830_display.c | 68 ++++++++++++++++++++++++++++++---------------- src/i830_driver.c | 48 ++++++++++++++++---------------- src/i830_modes.c | 2 +- 6 files changed, 74 insertions(+), 54 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 3f680c71..f656270a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -25,11 +25,9 @@ SUBDIRS = xvmc bios_reader ch7017 ch7xxx ivch sil164 # -avoid-version prevents gratuitous .0.0.0 version numbers on the end # _ladir passes a dummy rpath to libtool so the thing will actually link # TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc. -AM_CFLAGS = @WARN_CFLAGS@ @XORG_CFLAGS@ @DRI_CFLAGS@ \ +AM_CFLAGS = @WARN_CFLAGS@ @XORG_CFLAGS@ @DRI_CFLAGS@ -Iparser -Imodes \ -DI830_XV -DI830_USE_XAA -DI830_USE_EXA -DXF86_MODES_RENAME -AM_INCLUDES=-Iparser -Imodes - intel_drv_la_LTLIBRARIES = intel_drv.la intel_drv_la_LDFLAGS = -module -avoid-version intel_drv_ladir = @moduledir@/drivers diff --git a/src/i830.h b/src/i830.h index 26d16e92..f52f1496 100644 --- a/src/i830.h +++ b/src/i830.h @@ -58,8 +58,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "xf86int10.h" #include "vbe.h" #include "vgaHW.h" -#include "i830_xf86Crtc.h" -#include "i830_xf86RandR12.h" +#include "xf86Crtc.h" +#include "xf86RandR12.h" #ifdef XF86DRI #include "xf86drm.h" diff --git a/src/i830_crt.c b/src/i830_crt.c index 573e6526..77061653 100644 --- a/src/i830_crt.c +++ b/src/i830_crt.c @@ -31,7 +31,7 @@ #include "xf86.h" #include "i830.h" -#include "i830_xf86Modes.h" +#include "xf86Modes.h" #include "i830_display.h" static void diff --git a/src/i830_display.c b/src/i830_display.c index f44a8bf3..e7a5605e 100644 --- a/src/i830_display.c +++ b/src/i830_display.c @@ -41,7 +41,7 @@ #include "i830_bios.h" #include "i830_display.h" #include "i830_debug.h" -#include "i830_xf86Modes.h" +#include "xf86Modes.h" typedef struct { /* given values */ @@ -342,9 +342,8 @@ i830PipeSetBase(xf86CrtcPtr crtc, int x, int y) int dspbase = (pipe == 0 ? DSPABASE : DSPBBASE); int dspsurf = (pipe == 0 ? DSPASURF : DSPBSURF); - if (crtc->rotatedPixmap != NULL) { - Start = (char *)crtc->rotatedPixmap->devPrivate.ptr - - (char *)pI830->FbBase; + if (crtc->rotatedData != NULL) { + Start = (char *)crtc->rotatedData - (char *)pI830->FbBase; } else if (I830IsPrimary(pScrn)) { Start = pI830->FrontBuffer.Start; } else { @@ -931,21 +930,18 @@ i830_crtc_gamma_set(xf86CrtcPtr crtc, CARD16 *red, CARD16 *green, CARD16 *blue, } /** - * Creates a locked-in-framebuffer pixmap of the given width and height for - * this CRTC's rotated shadow framebuffer. - * - * The current implementation uses fixed buffers allocated at startup at the - * maximal size. + * Allocates memory for a locked-in-framebuffer shadow of the given + * width and height for this CRTC's rotated shadow framebuffer. */ -static PixmapPtr -i830_crtc_shadow_create(xf86CrtcPtr crtc, int width, int height) + +static void * +i830_crtc_shadow_allocate (xf86CrtcPtr crtc, int width, int height) { ScrnInfoPtr pScrn = crtc->scrn; ScreenPtr pScreen = pScrn->pScreen; I830Ptr pI830 = I830PTR(pScrn); I830CrtcPrivatePtr intel_crtc = crtc->driver_private; unsigned long rotate_pitch; - PixmapPtr rotate_pixmap; unsigned long rotate_offset; int align = KB(4), size; @@ -994,12 +990,32 @@ i830_crtc_shadow_create(xf86CrtcPtr crtc, int width, int height) } #endif /* I830_USE_XAA */ + return pI830->FbBase + rotate_offset; +} + +/** + * Creates a pixmap for this CRTC's rotated shadow framebuffer. + */ +static PixmapPtr +i830_crtc_shadow_create(xf86CrtcPtr crtc, void *data, int width, int height) +{ + ScrnInfoPtr pScrn = crtc->scrn; + I830Ptr pI830 = I830PTR(pScrn); + unsigned long rotate_pitch; + PixmapPtr rotate_pixmap; + + if (!data) + data = i830_crtc_shadow_allocate (crtc, width, height); + + rotate_pitch = pI830->displayWidth * pI830->cpp; + rotate_pixmap = GetScratchPixmapHeader(pScrn->pScreen, width, height, pScrn->depth, pScrn->bitsPerPixel, rotate_pitch, - pI830->FbBase + rotate_offset); + data); + if (rotate_pixmap == NULL) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Couldn't allocate shadow pixmap for rotated CRTC\n"); @@ -1008,25 +1024,30 @@ i830_crtc_shadow_create(xf86CrtcPtr crtc, int width, int height) } static void -i830_crtc_shadow_destroy(xf86CrtcPtr crtc, PixmapPtr rotate_pixmap) +i830_crtc_shadow_destroy(xf86CrtcPtr crtc, PixmapPtr rotate_pixmap, void *data) { ScrnInfoPtr pScrn = crtc->scrn; I830Ptr pI830 = I830PTR(pScrn); I830CrtcPrivatePtr intel_crtc = crtc->driver_private; - FreeScratchPixmapHeader(rotate_pixmap); + if (rotate_pixmap) + FreeScratchPixmapHeader(rotate_pixmap); + + if (data) + { #ifdef I830_USE_EXA - if (pI830->useEXA && intel_crtc->rotate_mem_exa != NULL) { - exaOffscreenFree(pScrn->pScreen, intel_crtc->rotate_mem_exa); - intel_crtc->rotate_mem_exa = NULL; - } + if (pI830->useEXA && intel_crtc->rotate_mem_exa != NULL) { + exaOffscreenFree(pScrn->pScreen, intel_crtc->rotate_mem_exa); + intel_crtc->rotate_mem_exa = NULL; + } #endif /* I830_USE_EXA */ #ifdef I830_USE_XAA - if (!pI830->useEXA) { - xf86FreeOffscreenLinear(intel_crtc->rotate_mem_xaa); - intel_crtc->rotate_mem_xaa = NULL; - } + if (!pI830->useEXA) { + xf86FreeOffscreenLinear(intel_crtc->rotate_mem_xaa); + intel_crtc->rotate_mem_xaa = NULL; + } #endif /* I830_USE_XAA */ + } } @@ -1272,6 +1293,7 @@ static const xf86CrtcFuncsRec i830_crtc_funcs = { .mode_set = i830_crtc_mode_set, .gamma_set = i830_crtc_gamma_set, .shadow_create = i830_crtc_shadow_create, + .shadow_allocate = i830_crtc_shadow_allocate, .shadow_destroy = i830_crtc_shadow_destroy, .destroy = NULL, /* XXX */ }; diff --git a/src/i830_driver.c b/src/i830_driver.c index 56903e15..e46c0572 100644 --- a/src/i830_driver.c +++ b/src/i830_driver.c @@ -2695,6 +2695,30 @@ I830ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) DPRINTF(PFX, "assert( if(!I830EnterVT(scrnIndex, 0)) )\n"); + if (!pI830->useEXA) { + if (I830IsPrimary(pScrn)) { + if (!I830InitFBManager(pScreen, &(pI830->FbMemBox))) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Failed to init memory manager\n"); + } + + if (pI830->LinearAlloc && + xf86InitFBManagerLinear(pScreen, + pI830->LinearMem.Offset / pI830->cpp, + pI830->LinearMem.Size / pI830->cpp)) + { + xf86DrvMsg(scrnIndex, X_INFO, + "Using %ld bytes of offscreen memory for linear " + "(offset=0x%lx)\n", pI830->LinearMem.Size, + pI830->LinearMem.Offset); + } + } else { + if (!I830InitFBManager(pScreen, &(pI8301->FbMemBox2))) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Failed to init memory manager\n"); + } + } + } if (!I830EnterVT(scrnIndex, 0)) return FALSE; @@ -2731,30 +2755,6 @@ I830ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) DPRINTF(PFX, "assert( if(!I830InitFBManager(pScreen, &(pI830->FbMemBox))) )\n"); - if (!pI830->useEXA) { - if (I830IsPrimary(pScrn)) { - if (!I830InitFBManager(pScreen, &(pI830->FbMemBox))) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Failed to init memory manager\n"); - } - - if (pI830->LinearAlloc && - xf86InitFBManagerLinear(pScreen, - pI830->LinearMem.Offset / pI830->cpp, - pI830->LinearMem.Size / pI830->cpp)) - { - xf86DrvMsg(scrnIndex, X_INFO, - "Using %ld bytes of offscreen memory for linear " - "(offset=0x%lx)\n", pI830->LinearMem.Size, - pI830->LinearMem.Offset); - } - } else { - if (!I830InitFBManager(pScreen, &(pI8301->FbMemBox2))) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Failed to init memory manager\n"); - } - } - } if (!pI830->noAccel) { if (!I830AccelInit(pScreen)) { diff --git a/src/i830_modes.c b/src/i830_modes.c index 405dcc61..06921a50 100644 --- a/src/i830_modes.c +++ b/src/i830_modes.c @@ -52,7 +52,7 @@ #include "X11/Xatom.h" #include "i830.h" #include "i830_display.h" -#include "i830_xf86Modes.h" +#include "xf86Modes.h" #include DisplayModePtr From 972f1109d23c0a3f821fa573e2aa40cd17ce2795 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 16 Feb 2007 01:07:20 -0800 Subject: [PATCH 26/29] Remove common code that has moved to xserver/hw/xfree86/modes --- src/i830_xf86Crtc.c | 1588 -------------------------------------- src/i830_xf86Crtc.h | 553 ------------- src/i830_xf86DiDGA.c | 280 ------- src/i830_xf86EdidModes.c | 344 --------- src/i830_xf86Modes.c | 636 --------------- src/i830_xf86Modes.h | 82 -- src/i830_xf86RandR12.c | 950 ----------------------- src/i830_xf86RandR12.h | 37 - src/i830_xf86Rename.h | 77 -- src/i830_xf86Rotate.c | 402 ---------- src/i830_xf86cvt.c | 307 -------- 11 files changed, 5256 deletions(-) delete mode 100644 src/i830_xf86Crtc.c delete mode 100644 src/i830_xf86Crtc.h delete mode 100644 src/i830_xf86DiDGA.c delete mode 100644 src/i830_xf86EdidModes.c delete mode 100644 src/i830_xf86Modes.c delete mode 100644 src/i830_xf86Modes.h delete mode 100644 src/i830_xf86RandR12.c delete mode 100644 src/i830_xf86RandR12.h delete mode 100644 src/i830_xf86Rename.h delete mode 100644 src/i830_xf86Rotate.c delete mode 100644 src/i830_xf86cvt.c diff --git a/src/i830_xf86Crtc.c b/src/i830_xf86Crtc.c deleted file mode 100644 index db05abab..00000000 --- a/src/i830_xf86Crtc.c +++ /dev/null @@ -1,1588 +0,0 @@ -/* - * Copyright © 2006 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that copyright - * notice and this permission notice appear in supporting documentation, and - * that the name of the copyright holders not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. The copyright holders make no representations - * about the suitability of this software for any purpose. It is provided "as - * is" without express or implied warranty. - * - * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include - -#include "xf86.h" -#include "xf86DDC.h" -/*#include "i830.h" */ -#include "i830_xf86Crtc.h" -#include "i830_xf86Modes.h" -#include "i830_xf86RandR12.h" -#include "X11/extensions/render.h" -#define DPMS_SERVER -#include "X11/extensions/dpms.h" -#include "X11/Xatom.h" - -/* - * Initialize xf86CrtcConfig structure - */ - -int xf86CrtcConfigPrivateIndex = -1; - -void -xf86CrtcConfigInit (ScrnInfoPtr scrn) -{ - xf86CrtcConfigPtr config; - - if (xf86CrtcConfigPrivateIndex == -1) - xf86CrtcConfigPrivateIndex = xf86AllocateScrnInfoPrivateIndex(); - config = xnfcalloc (1, sizeof (xf86CrtcConfigRec)); - scrn->privates[xf86CrtcConfigPrivateIndex].ptr = config; -} - -void -xf86CrtcSetSizeRange (ScrnInfoPtr scrn, - int minWidth, int minHeight, - int maxWidth, int maxHeight) -{ - xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); - - config->minWidth = minWidth; - config->minHeight = minHeight; - config->maxWidth = maxWidth; - config->maxHeight = maxHeight; -} - -/* - * Crtc functions - */ -xf86CrtcPtr -xf86CrtcCreate (ScrnInfoPtr scrn, - const xf86CrtcFuncsRec *funcs) -{ - xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); - xf86CrtcPtr crtc, *crtcs; - - crtc = xcalloc (sizeof (xf86CrtcRec), 1); - if (!crtc) - return NULL; - crtc->scrn = scrn; - crtc->funcs = funcs; -#ifdef RANDR_12_INTERFACE - crtc->randr_crtc = NULL; -#endif - crtc->rotation = RR_Rotate_0; - crtc->desiredRotation = RR_Rotate_0; - if (xf86_config->crtc) - crtcs = xrealloc (xf86_config->crtc, - (xf86_config->num_crtc + 1) * sizeof (xf86CrtcPtr)); - else - crtcs = xalloc ((xf86_config->num_crtc + 1) * sizeof (xf86CrtcPtr)); - if (!crtcs) - { - xfree (crtc); - return NULL; - } - xf86_config->crtc = crtcs; - xf86_config->crtc[xf86_config->num_crtc++] = crtc; - return crtc; -} - -void -xf86CrtcDestroy (xf86CrtcPtr crtc) -{ - xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn); - int c; - - (*crtc->funcs->destroy) (crtc); - for (c = 0; c < xf86_config->num_crtc; c++) - if (xf86_config->crtc[c] == crtc) - { - memmove (&xf86_config->crtc[c], - &xf86_config->crtc[c+1], - xf86_config->num_crtc - (c + 1)); - xf86_config->num_crtc--; - break; - } - xfree (crtc); -} - - -/** - * Return whether any outputs are connected to the specified pipe - */ - -Bool -xf86CrtcInUse (xf86CrtcPtr crtc) -{ - ScrnInfoPtr pScrn = crtc->scrn; - xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); - int o; - - for (o = 0; o < xf86_config->num_output; o++) - if (xf86_config->output[o]->crtc == crtc) - return TRUE; - return FALSE; -} - -/** - * Sets the given video mode on the given crtc - */ -Bool -xf86CrtcSetMode (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation, - int x, int y) -{ - ScrnInfoPtr scrn = crtc->scrn; - xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); - int i; - Bool ret = FALSE; - Bool didLock = FALSE; - DisplayModePtr adjusted_mode; - DisplayModeRec saved_mode; - int saved_x, saved_y; - Rotation saved_rotation; - - adjusted_mode = xf86DuplicateMode(mode); - - crtc->enabled = xf86CrtcInUse (crtc); - - if (!crtc->enabled) - { - /* XXX disable crtc? */ - return TRUE; - } - - didLock = crtc->funcs->lock (crtc); - - saved_mode = crtc->mode; - saved_x = crtc->x; - saved_y = crtc->y; - saved_rotation = crtc->rotation; - /* Update crtc values up front so the driver can rely on them for mode - * setting. - */ - crtc->mode = *mode; - crtc->x = x; - crtc->y = y; - crtc->rotation = rotation; - - /* XXX short-circuit changes to base location only */ - - /* Pass our mode to the outputs and the CRTC to give them a chance to - * adjust it according to limitations or output properties, and also - * a chance to reject the mode entirely. - */ - for (i = 0; i < xf86_config->num_output; i++) { - xf86OutputPtr output = xf86_config->output[i]; - - if (output->crtc != crtc) - continue; - - if (!output->funcs->mode_fixup(output, mode, adjusted_mode)) { - goto done; - } - } - - if (!crtc->funcs->mode_fixup(crtc, mode, adjusted_mode)) { - goto done; - } - - if (!xf86CrtcRotate (crtc, mode, rotation)) { - goto done; - } - - /* Disable the outputs and CRTCs before setting the mode. */ - for (i = 0; i < xf86_config->num_output; i++) { - xf86OutputPtr output = xf86_config->output[i]; - - if (output->crtc != crtc) - continue; - - /* Disable the output as the first thing we do. */ - output->funcs->dpms(output, DPMSModeOff); - } - - crtc->funcs->dpms(crtc, DPMSModeOff); - - /* Set up the DPLL and any output state that needs to adjust or depend - * on the DPLL. - */ - crtc->funcs->mode_set(crtc, mode, adjusted_mode, x, y); - for (i = 0; i < xf86_config->num_output; i++) - { - xf86OutputPtr output = xf86_config->output[i]; - if (output->crtc == crtc) - output->funcs->mode_set(output, mode, adjusted_mode); - } - - /* Now, enable the clocks, plane, pipe, and outputs that we set up. */ - crtc->funcs->dpms(crtc, DPMSModeOn); - for (i = 0; i < xf86_config->num_output; i++) - { - xf86OutputPtr output = xf86_config->output[i]; - if (output->crtc == crtc) - output->funcs->dpms(output, DPMSModeOn); - } - - /* XXX free adjustedmode */ - ret = TRUE; -done: - if (!ret) { - crtc->x = saved_x; - crtc->y = saved_y; - crtc->rotation = saved_rotation; - crtc->mode = saved_mode; - } - - if (didLock) - crtc->funcs->unlock (crtc); - - return ret; -} - -/* - * Output functions - */ - -extern XF86ConfigPtr xf86configptr; - -typedef enum { - OPTION_PREFERRED_MODE, - OPTION_POSITION, - OPTION_BELOW, - OPTION_RIGHT_OF, - OPTION_ABOVE, - OPTION_LEFT_OF, - OPTION_ENABLE, - OPTION_DISABLE, - OPTION_MIN_CLOCK, - OPTION_MAX_CLOCK, - OPTION_IGNORE, -} OutputOpts; - -static OptionInfoRec xf86OutputOptions[] = { - {OPTION_PREFERRED_MODE, "PreferredMode", OPTV_STRING, {0}, FALSE }, - {OPTION_POSITION, "Position", OPTV_STRING, {0}, FALSE }, - {OPTION_BELOW, "Below", OPTV_STRING, {0}, FALSE }, - {OPTION_RIGHT_OF, "RightOf", OPTV_STRING, {0}, FALSE }, - {OPTION_ABOVE, "Above", OPTV_STRING, {0}, FALSE }, - {OPTION_LEFT_OF, "LeftOf", OPTV_STRING, {0}, FALSE }, - {OPTION_ENABLE, "Enable", OPTV_BOOLEAN, {0}, FALSE }, - {OPTION_DISABLE, "Disable", OPTV_BOOLEAN, {0}, FALSE }, - {OPTION_MIN_CLOCK, "MinClock", OPTV_FREQ, {0}, FALSE }, - {OPTION_MAX_CLOCK, "MaxClock", OPTV_FREQ, {0}, FALSE }, - {OPTION_IGNORE, "Ignore", OPTV_BOOLEAN, {0}, FALSE }, - {-1, NULL, OPTV_NONE, {0}, FALSE }, -}; - -static void -xf86OutputSetMonitor (xf86OutputPtr output) -{ - char *option_name; - static const char monitor_prefix[] = "monitor-"; - char *monitor; - - if (!output->name) - return; - - if (output->options) - xfree (output->options); - - output->options = xnfalloc (sizeof (xf86OutputOptions)); - memcpy (output->options, xf86OutputOptions, sizeof (xf86OutputOptions)); - - option_name = xnfalloc (strlen (monitor_prefix) + - strlen (output->name) + 1); - strcpy (option_name, monitor_prefix); - strcat (option_name, output->name); - monitor = xf86findOptionValue (output->scrn->options, option_name); - if (!monitor) - monitor = output->name; - else - xf86MarkOptionUsedByName (output->scrn->options, option_name); - xfree (option_name); - output->conf_monitor = xf86findMonitor (monitor, - xf86configptr->conf_monitor_lst); - if (output->conf_monitor) - xf86ProcessOptions (output->scrn->scrnIndex, - output->conf_monitor->mon_option_lst, - output->options); -} - -static Bool -xf86OutputEnabled (xf86OutputPtr output) -{ - /* Check to see if this output was disabled in the config file */ - if (xf86ReturnOptValBool (output->options, OPTION_ENABLE, TRUE) == FALSE || - xf86ReturnOptValBool (output->options, OPTION_DISABLE, FALSE) == TRUE) - { - return FALSE; - } - return TRUE; -} - -static Bool -xf86OutputIgnored (xf86OutputPtr output) -{ - return xf86ReturnOptValBool (output->options, OPTION_IGNORE, FALSE); -} - -xf86OutputPtr -xf86OutputCreate (ScrnInfoPtr scrn, - const xf86OutputFuncsRec *funcs, - const char *name) -{ - xf86OutputPtr output, *outputs; - xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); - int len; - - if (name) - len = strlen (name) + 1; - else - len = 0; - - output = xcalloc (sizeof (xf86OutputRec) + len, 1); - if (!output) - return NULL; - output->scrn = scrn; - output->funcs = funcs; - if (name) - { - output->name = (char *) (output + 1); - strcpy (output->name, name); - } - output->subpixel_order = SubPixelUnknown; -#ifdef RANDR_12_INTERFACE - output->randr_output = NULL; -#endif - if (name) - { - xf86OutputSetMonitor (output); - if (xf86OutputIgnored (output)) - { - xfree (output); - return FALSE; - } - } - - - if (xf86_config->output) - outputs = xrealloc (xf86_config->output, - (xf86_config->num_output + 1) * sizeof (xf86OutputPtr)); - else - outputs = xalloc ((xf86_config->num_output + 1) * sizeof (xf86OutputPtr)); - if (!outputs) - { - xfree (output); - return NULL; - } - - xf86_config->output = outputs; - xf86_config->output[xf86_config->num_output++] = output; - - return output; -} - -Bool -xf86OutputRename (xf86OutputPtr output, const char *name) -{ - int len = strlen(name) + 1; - char *newname = xalloc (len); - - if (!newname) - return FALSE; /* so sorry... */ - - strcpy (newname, name); - if (output->name && output->name != (char *) (output + 1)) - xfree (output->name); - output->name = newname; - xf86OutputSetMonitor (output); - if (xf86OutputIgnored (output)) - return FALSE; - return TRUE; -} - -void -xf86OutputDestroy (xf86OutputPtr output) -{ - ScrnInfoPtr scrn = output->scrn; - xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); - int o; - - (*output->funcs->destroy) (output); - while (output->probed_modes) - xf86DeleteMode (&output->probed_modes, output->probed_modes); - for (o = 0; o < xf86_config->num_output; o++) - if (xf86_config->output[o] == output) - { - memmove (&xf86_config->output[o], - &xf86_config->output[o+1], - xf86_config->num_output - (o + 1)); - xf86_config->num_output--; - break; - } - if (output->name && output->name != (char *) (output + 1)) - xfree (output->name); - xfree (output); -} - -static DisplayModePtr -xf86DefaultMode (xf86OutputPtr output, int width, int height) -{ - DisplayModePtr target_mode = NULL; - DisplayModePtr mode; - int target_diff = 0; - int target_preferred = 0; - int mm_height; - - mm_height = output->mm_height; - if (!mm_height) - mm_height = 203; /* 768 pixels at 96dpi */ - /* - * Pick a mode closest to 96dpi - */ - for (mode = output->probed_modes; mode; mode = mode->next) - { - int dpi; - int preferred = (mode->type & M_T_PREFERRED) != 0; - int diff; - - if (mode->HDisplay > width || mode->VDisplay > height) continue; - dpi = (mode->HDisplay * 254) / (mm_height * 10); - diff = dpi - 96; - diff = diff < 0 ? -diff : diff; - if (target_mode == NULL || (preferred > target_preferred) || - (preferred == target_preferred && diff < target_diff)) - { - target_mode = mode; - target_diff = diff; - target_preferred = preferred; - } - } - return target_mode; -} - -static DisplayModePtr -xf86ClosestMode (xf86OutputPtr output, DisplayModePtr match, - int width, int height) -{ - DisplayModePtr target_mode = NULL; - DisplayModePtr mode; - int target_diff = 0; - - /* - * Pick a mode closest to the specified mode - */ - for (mode = output->probed_modes; mode; mode = mode->next) - { - int dx, dy; - int diff; - - if (mode->HDisplay > width || mode->VDisplay > height) continue; - - /* exact matches are preferred */ - if (xf86ModesEqual (mode, match)) - return mode; - - dx = match->HDisplay - mode->HDisplay; - dy = match->VDisplay - mode->VDisplay; - diff = dx * dx + dy * dy; - if (target_mode == NULL || diff < target_diff) - { - target_mode = mode; - target_diff = diff; - } - } - return target_mode; -} - -static Bool -xf86OutputHasPreferredMode (xf86OutputPtr output, int width, int height) -{ - DisplayModePtr mode; - - for (mode = output->probed_modes; mode; mode = mode->next) - { - if (mode->HDisplay > width || mode->VDisplay > height) continue; - if (mode->type & M_T_PREFERRED) - return TRUE; - } - return FALSE; -} - -static int -xf86PickCrtcs (ScrnInfoPtr scrn, - xf86CrtcPtr *best_crtcs, - DisplayModePtr *modes, - int n, - int width, - int height) -{ - xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); - int c, o, l; - xf86OutputPtr output; - xf86CrtcPtr crtc; - xf86CrtcPtr *crtcs; - xf86CrtcPtr best_crtc; - int best_score; - int score; - int my_score; - - if (n == config->num_output) - return 0; - output = config->output[n]; - - /* - * Compute score with this output disabled - */ - best_crtcs[n] = NULL; - best_crtc = NULL; - best_score = xf86PickCrtcs (scrn, best_crtcs, modes, n+1, width, height); - if (modes[n] == NULL) - return best_score; - - crtcs = xalloc (config->num_output * sizeof (xf86CrtcPtr)); - if (!crtcs) - return best_score; - - my_score = 1; - /* Score outputs that are known to be connected higher */ - if (output->status == XF86OutputStatusConnected) - my_score++; - /* Score outputs with preferred modes higher */ - if (xf86OutputHasPreferredMode (output, width, height)) - my_score++; - /* - * Select a crtc for this output and - * then attempt to configure the remaining - * outputs - */ - for (c = 0; c < config->num_crtc; c++) - { - if ((output->possible_crtcs & (1 << c)) == 0) - continue; - - crtc = config->crtc[c]; - /* - * Check to see if some other output is - * using this crtc - */ - for (o = 0; o < n; o++) - if (best_crtcs[o] == crtc) - break; - if (o < n) - { - /* - * If the two outputs desire the same mode, - * see if they can be cloned - */ - if (xf86ModesEqual (modes[o], modes[n]) && - config->output[o]->initial_x == config->output[n]->initial_x && - config->output[o]->initial_y == config->output[n]->initial_y) - { - for (l = 0; l < config->num_output; l++) - if (output->possible_clones & (1 << l)) - break; - if (l == config->num_output) - continue; /* nope, try next CRTC */ - } - else - continue; /* different modes, can't clone */ - } - crtcs[n] = crtc; - memcpy (crtcs, best_crtcs, n * sizeof (xf86CrtcPtr)); - score = my_score + xf86PickCrtcs (scrn, crtcs, modes, n+1, width, height); - if (score > best_score) - { - best_crtc = crtc; - best_score = score; - memcpy (best_crtcs, crtcs, config->num_output * sizeof (xf86CrtcPtr)); - } - } - xfree (crtcs); - return best_score; -} - - -/* - * Compute the virtual size necessary to place all of the available - * crtcs in the specified configuration and also large enough to - * resize any crtc to the largest available mode - */ - -static void -xf86DefaultScreenLimits (ScrnInfoPtr scrn, int *widthp, int *heightp) -{ - xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); - int width = 0, height = 0; - int o; - int c; - int s; - - for (c = 0; c < config->num_crtc; c++) - { - int crtc_width = 0, crtc_height = 0; - xf86CrtcPtr crtc = config->crtc[c]; - - if (crtc->enabled) - { - crtc_width = crtc->x + crtc->desiredMode.HDisplay; - crtc_height = crtc->y + crtc->desiredMode.VDisplay; - } - for (o = 0; o < config->num_output; o++) - { - xf86OutputPtr output = config->output[o]; - - for (s = 0; s < config->num_crtc; s++) - if (output->possible_crtcs & (1 << s)) - { - DisplayModePtr mode; - for (mode = output->probed_modes; mode; mode = mode->next) - { - if (mode->HDisplay > crtc_width) - crtc_width = mode->HDisplay; - if (mode->VDisplay > crtc_height) - crtc_height = mode->VDisplay; - } - } - } - if (crtc_width > width) - width = crtc_width; - if (crtc_height > height) - height = crtc_height; - } - if (config->maxWidth && width > config->maxWidth) width = config->maxWidth; - if (config->maxHeight && height > config->maxHeight) height = config->maxHeight; - if (config->minWidth && width < config->minWidth) width = config->minWidth; - if (config->minHeight && height < config->minHeight) height = config->minHeight; - *widthp = width; - *heightp = height; -} - -#define POSITION_UNSET -100000 - -static Bool -xf86InitialOutputPositions (ScrnInfoPtr scrn, DisplayModePtr *modes) -{ - xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); - int o; - int min_x, min_y; - - for (o = 0; o < config->num_output; o++) - { - xf86OutputPtr output = config->output[o]; - - output->initial_x = output->initial_y = POSITION_UNSET; - } - - /* - * Loop until all outputs are set - */ - for (;;) - { - Bool any_set = FALSE; - Bool keep_going = FALSE; - - for (o = 0; o < config->num_output; o++) - { - static const OutputOpts relations[] = { - OPTION_BELOW, OPTION_RIGHT_OF, OPTION_ABOVE, OPTION_LEFT_OF - }; - xf86OutputPtr output = config->output[o]; - xf86OutputPtr relative; - char *relative_name; - char *position; - OutputOpts relation; - int r; - - if (output->initial_x != POSITION_UNSET) - continue; - position = xf86GetOptValString (output->options, - OPTION_POSITION); - /* - * Absolute position wins - */ - if (position) - { - int x, y; - if (sscanf (position, "%d %d", &x, &y) == 2) - { - output->initial_x = x; - output->initial_y = y; - } - else - { - xf86DrvMsg (scrn->scrnIndex, X_ERROR, - "Output %s position not of form \"x y\"\n", - output->name); - output->initial_x = output->initial_y = 0; - } - any_set = TRUE; - continue; - } - /* - * Next comes relative positions - */ - relation = 0; - relative_name = NULL; - for (r = 0; r < 4; r++) - { - relation = relations[r]; - relative_name = xf86GetOptValString (output->options, - relation); - if (relative_name) - break; - } - if (relative_name) - { - int or; - relative = NULL; - for (or = 0; or < config->num_output; or++) - { - xf86OutputPtr out_rel = config->output[or]; - XF86ConfMonitorPtr rel_mon = out_rel->conf_monitor; - char *name; - - if (rel_mon) - name = rel_mon->mon_identifier; - else - name = out_rel->name; - if (!strcmp (relative_name, name)) - { - relative = config->output[or]; - break; - } - } - if (!relative) - { - xf86DrvMsg (scrn->scrnIndex, X_ERROR, - "Cannot position output %s relative to unknown output %s\n", - output->name, relative_name); - output->initial_x = 0; - output->initial_y = 0; - any_set = TRUE; - continue; - } - if (relative->initial_x == POSITION_UNSET) - { - keep_going = TRUE; - continue; - } - output->initial_x = relative->initial_x; - output->initial_y = relative->initial_y; - switch (relation) { - case OPTION_BELOW: - output->initial_y += modes[or]->VDisplay; - break; - case OPTION_RIGHT_OF: - output->initial_x += modes[or]->HDisplay; - break; - case OPTION_ABOVE: - output->initial_y -= modes[o]->VDisplay; - break; - case OPTION_LEFT_OF: - output->initial_x -= modes[o]->HDisplay; - break; - default: - break; - } - any_set = TRUE; - continue; - } - - /* Nothing set, just stick them at 0,0 */ - output->initial_x = 0; - output->initial_y = 0; - any_set = TRUE; - } - if (!keep_going) - break; - if (!any_set) - { - for (o = 0; o < config->num_output; o++) - { - xf86OutputPtr output = config->output[o]; - if (output->initial_x == POSITION_UNSET) - { - xf86DrvMsg (scrn->scrnIndex, X_ERROR, - "Output position loop. Moving %s to 0,0\n", - output->name); - output->initial_x = output->initial_y = 0; - break; - } - } - } - } - - /* - * normalize positions - */ - min_x = 1000000; - min_y = 1000000; - for (o = 0; o < config->num_output; o++) - { - xf86OutputPtr output = config->output[o]; - - if (output->initial_x < min_x) - min_x = output->initial_x; - if (output->initial_y < min_y) - min_y = output->initial_y; - } - - for (o = 0; o < config->num_output; o++) - { - xf86OutputPtr output = config->output[o]; - - output->initial_x -= min_x; - output->initial_y -= min_y; - } - return TRUE; -} - -/* - * XXX walk the monitor mode list and prune out duplicates that - * are inserted by xf86DDCMonitorSet. In an ideal world, that - * function would do this work by itself. - */ - -static void -xf86PruneDuplicateMonitorModes (MonPtr Monitor) -{ - DisplayModePtr master, clone, next; - - for (master = Monitor->Modes; - master && master != Monitor->Last; - master = master->next) - { - for (clone = master->next; clone && clone != Monitor->Modes; clone = next) - { - next = clone->next; - if (xf86ModesEqual (master, clone)) - { - if (Monitor->Last == clone) - Monitor->Last = clone->prev; - xf86DeleteMode (&Monitor->Modes, clone); - } - } - } -} - -/** Return - 0 + if a should be earlier, same or later than b in list - */ -static int -xf86ModeCompare (DisplayModePtr a, DisplayModePtr b) -{ - int diff; - - diff = ((b->type & M_T_PREFERRED) != 0) - ((a->type & M_T_PREFERRED) != 0); - if (diff) - return diff; - diff = b->HDisplay * b->VDisplay - a->HDisplay * a->VDisplay; - if (diff) - return diff; - diff = b->Clock - a->Clock; - return diff; -} - -/** - * Insertion sort input in-place and return the resulting head - */ -static DisplayModePtr -xf86SortModes (DisplayModePtr input) -{ - DisplayModePtr output = NULL, i, o, n, *op, prev; - - /* sort by preferred status and pixel area */ - while (input) - { - i = input; - input = input->next; - for (op = &output; (o = *op); op = &o->next) - if (xf86ModeCompare (o, i) > 0) - break; - i->next = *op; - *op = i; - } - /* prune identical modes */ - for (o = output; o && (n = o->next); o = n) - { - if (!strcmp (o->name, n->name) && xf86ModesEqual (o, n)) - { - o->next = n->next; - xfree (n->name); - xfree (n); - n = o; - } - } - /* hook up backward links */ - prev = NULL; - for (o = output; o; o = o->next) - { - o->prev = prev; - prev = o; - } - return output; -} - -#define DEBUG_REPROBE 1 - -void -xf86ProbeOutputModes (ScrnInfoPtr scrn, int maxX, int maxY) -{ - xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); - int o; - - if (maxX == 0 || maxY == 0) - xf86RandR12GetOriginalVirtualSize (scrn, &maxX, &maxY); - - /* Elide duplicate modes before defaulting code uses them */ - xf86PruneDuplicateMonitorModes (scrn->monitor); - - /* Probe the list of modes for each output. */ - for (o = 0; o < config->num_output; o++) - { - xf86OutputPtr output = config->output[o]; - DisplayModePtr mode; - DisplayModePtr config_modes = NULL, output_modes, default_modes; - char *preferred_mode; - xf86MonPtr edid_monitor; - XF86ConfMonitorPtr conf_monitor; - MonRec mon_rec; - int min_clock = 0; - int max_clock = 0; - double clock; - enum { sync_config, sync_edid, sync_default } sync_source = sync_default; - - while (output->probed_modes != NULL) - xf86DeleteMode(&output->probed_modes, output->probed_modes); - - /* - * Check connection status - */ - output->status = (*output->funcs->detect)(output); - - if (output->status == XF86OutputStatusDisconnected) - continue; - - memset (&mon_rec, '\0', sizeof (mon_rec)); - - conf_monitor = output->conf_monitor; - - if (conf_monitor) - { - int i; - - for (i = 0; i < conf_monitor->mon_n_hsync; i++) - { - mon_rec.hsync[mon_rec.nHsync].lo = conf_monitor->mon_hsync[i].lo; - mon_rec.hsync[mon_rec.nHsync].hi = conf_monitor->mon_hsync[i].hi; - mon_rec.nHsync++; - sync_source = sync_config; - } - for (i = 0; i < conf_monitor->mon_n_vrefresh; i++) - { - mon_rec.vrefresh[mon_rec.nVrefresh].lo = conf_monitor->mon_vrefresh[i].lo; - mon_rec.vrefresh[mon_rec.nVrefresh].hi = conf_monitor->mon_vrefresh[i].hi; - mon_rec.nVrefresh++; - sync_source = sync_config; - } - config_modes = xf86GetMonitorModes (scrn, conf_monitor); - } - - output_modes = (*output->funcs->get_modes) (output); - - edid_monitor = output->MonInfo; - - if (edid_monitor) - { - int i; - Bool set_hsync = mon_rec.nHsync == 0; - Bool set_vrefresh = mon_rec.nVrefresh == 0; - - for (i = 0; i < sizeof (edid_monitor->det_mon) / sizeof (edid_monitor->det_mon[0]); i++) - { - if (edid_monitor->det_mon[i].type == DS_RANGES) - { - struct monitor_ranges *ranges = &edid_monitor->det_mon[i].section.ranges; - if (set_hsync && ranges->max_h) - { - mon_rec.hsync[mon_rec.nHsync].lo = ranges->min_h; - mon_rec.hsync[mon_rec.nHsync].hi = ranges->max_h; - mon_rec.nHsync++; - if (sync_source == sync_default) - sync_source = sync_edid; - } - if (set_vrefresh && ranges->max_v) - { - mon_rec.vrefresh[mon_rec.nVrefresh].lo = ranges->min_v; - mon_rec.vrefresh[mon_rec.nVrefresh].hi = ranges->max_v; - mon_rec.nVrefresh++; - if (sync_source == sync_default) - sync_source = sync_edid; - } - if (ranges->max_clock > max_clock) - max_clock = ranges->max_clock; - } - } - } - - if (xf86GetOptValFreq (output->options, OPTION_MIN_CLOCK, - OPTUNITS_KHZ, &clock)) - min_clock = (int) clock; - if (xf86GetOptValFreq (output->options, OPTION_MAX_CLOCK, - OPTUNITS_KHZ, &clock)) - max_clock = (int) clock; - - /* - * These limits will end up setting a 1024x768@60Hz mode by default, - * which seems like a fairly good mode to use when nothing else is - * specified - */ - if (mon_rec.nHsync == 0) - { - mon_rec.hsync[0].lo = 31.0; - mon_rec.hsync[0].hi = 55.0; - mon_rec.nHsync = 1; - } - if (mon_rec.nVrefresh == 0) - { - mon_rec.vrefresh[0].lo = 58.0; - mon_rec.vrefresh[0].hi = 62.0; - mon_rec.nVrefresh = 1; - } - default_modes = xf86GetDefaultModes (output->interlaceAllowed, - output->doubleScanAllowed); - - if (sync_source == sync_config) - { - /* - * Check output and config modes against sync range from config file - */ - xf86ValidateModesSync (scrn, output_modes, &mon_rec); - xf86ValidateModesSync (scrn, config_modes, &mon_rec); - } - /* - * Check default modes against sync range - */ - xf86ValidateModesSync (scrn, default_modes, &mon_rec); - /* - * Check default modes against monitor max clock - */ - if (max_clock) - xf86ValidateModesClocks(scrn, default_modes, - &min_clock, &max_clock, 1); - - output->probed_modes = NULL; - output->probed_modes = xf86ModesAdd (output->probed_modes, config_modes); - output->probed_modes = xf86ModesAdd (output->probed_modes, output_modes); - output->probed_modes = xf86ModesAdd (output->probed_modes, default_modes); - - /* - * Check all modes against max size - */ - if (maxX && maxY) - xf86ValidateModesSize (scrn, output->probed_modes, - maxX, maxY, 0); - - /* - * Check all modes against output - */ - for (mode = output->probed_modes; mode != NULL; mode = mode->next) - if (mode->status == MODE_OK) - mode->status = (*output->funcs->mode_valid)(output, mode); - - xf86PruneInvalidModes(scrn, &output->probed_modes, TRUE); - - output->probed_modes = xf86SortModes (output->probed_modes); - - /* Check for a configured preference for a particular mode */ - preferred_mode = xf86GetOptValString (output->options, - OPTION_PREFERRED_MODE); - - if (preferred_mode) - { - for (mode = output->probed_modes; mode; mode = mode->next) - { - if (!strcmp (preferred_mode, mode->name)) - { - if (mode != output->probed_modes) - { - if (mode->prev) - mode->prev->next = mode->next; - if (mode->next) - mode->next->prev = mode->prev; - mode->next = output->probed_modes; - output->probed_modes->prev = mode; - mode->prev = NULL; - output->probed_modes = mode; - } - mode->type |= M_T_PREFERRED; - break; - } - } - } - -#ifdef DEBUG_REPROBE - if (output->probed_modes != NULL) { - xf86DrvMsg(scrn->scrnIndex, X_INFO, - "Printing probed modes for output %s\n", - output->name); - } else { - xf86DrvMsg(scrn->scrnIndex, X_INFO, - "No remaining probed modes for output %s\n", - output->name); - } -#endif - for (mode = output->probed_modes; mode != NULL; mode = mode->next) - { - /* The code to choose the best mode per pipe later on will require - * VRefresh to be set. - */ - mode->VRefresh = xf86ModeVRefresh(mode); - xf86SetModeCrtc(mode, INTERLACE_HALVE_V); - -#ifdef DEBUG_REPROBE - xf86PrintModeline(scrn->scrnIndex, mode); -#endif - } - } -} - - -/** - * Copy one of the output mode lists to the ScrnInfo record - */ - -/* XXX where does this function belong? Here? */ -void -xf86RandR12GetOriginalVirtualSize(ScrnInfoPtr scrn, int *x, int *y); - -void -xf86SetScrnInfoModes (ScrnInfoPtr scrn) -{ - xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); - xf86OutputPtr output; - xf86CrtcPtr crtc; - DisplayModePtr last, mode; - - output = config->output[config->compat_output]; - if (!output->crtc) - { - int o; - - output = NULL; - for (o = 0; o < config->num_output; o++) - if (config->output[o]->crtc) - { - config->compat_output = o; - output = config->output[o]; - break; - } - /* no outputs are active, punt and leave things as they are */ - if (!output) - return; - } - crtc = output->crtc; - - /* Clear any existing modes from scrn->modes */ - while (scrn->modes != NULL) - xf86DeleteMode(&scrn->modes, scrn->modes); - - /* Set scrn->modes to the mode list for the 'compat' output */ - scrn->modes = xf86DuplicateModes(scrn, output->probed_modes); - - for (mode = scrn->modes; mode; mode = mode->next) - if (xf86ModesEqual (mode, &crtc->desiredMode)) - break; - - if (scrn->modes != NULL) { - /* For some reason, scrn->modes is circular, unlike the other mode - * lists. How great is that? - */ - for (last = scrn->modes; last && last->next; last = last->next) - ; - last->next = scrn->modes; - scrn->modes->prev = last; - if (mode) { - while (scrn->modes != mode) - scrn->modes = scrn->modes->next; - } - } - scrn->currentMode = scrn->modes; -} - -/** - * Construct default screen configuration - * - * Given auto-detected (and, eventually, configured) values, - * construct a usable configuration for the system - */ - -Bool -xf86InitialConfiguration (ScrnInfoPtr scrn) -{ - xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); - int o, c; - DisplayModePtr target_mode = NULL; - xf86CrtcPtr *crtcs; - DisplayModePtr *modes; - Bool *enabled; - int width; - int height; - - if (scrn->display->virtualX) - width = scrn->display->virtualX; - else - width = config->maxWidth; - if (scrn->display->virtualY) - height = scrn->display->virtualY; - else - height = config->maxHeight; - - xf86ProbeOutputModes (scrn, width, height); - - crtcs = xnfcalloc (config->num_output, sizeof (xf86CrtcPtr)); - modes = xnfcalloc (config->num_output, sizeof (DisplayModePtr)); - enabled = xnfcalloc (config->num_output, sizeof (Bool)); - - for (o = 0; o < config->num_output; o++) - { - xf86OutputPtr output = config->output[o]; - - modes[o] = NULL; - enabled[o] = (xf86OutputEnabled (output) && - output->status != XF86OutputStatusDisconnected); - } - - /* - * Let outputs with preferred modes drive screen size - */ - for (o = 0; o < config->num_output; o++) - { - xf86OutputPtr output = config->output[o]; - - if (enabled[o] && - xf86OutputHasPreferredMode (output, width, height)) - { - target_mode = xf86DefaultMode (output, width, height); - if (target_mode) - { - modes[o] = target_mode; - config->compat_output = o; - break; - } - } - } - if (!target_mode) - { - for (o = 0; o < config->num_output; o++) - { - xf86OutputPtr output = config->output[o]; - if (enabled[o]) - { - target_mode = xf86DefaultMode (output, width, height); - if (target_mode) - { - modes[o] = target_mode; - config->compat_output = o; - break; - } - } - } - } - for (o = 0; o < config->num_output; o++) - { - xf86OutputPtr output = config->output[o]; - - if (enabled[o] && !modes[o]) - modes[o] = xf86ClosestMode (output, target_mode, width, height); - } - - /* - * Set the position of each output - */ - if (!xf86InitialOutputPositions (scrn, modes)) - { - xfree (crtcs); - xfree (modes); - return FALSE; - } - - /* - * Assign CRTCs to fit output configuration - */ - if (!xf86PickCrtcs (scrn, crtcs, modes, 0, width, height)) - { - xfree (crtcs); - xfree (modes); - return FALSE; - } - - /* XXX override xf86 common frame computation code */ - - scrn->display->frameX0 = 0; - scrn->display->frameY0 = 0; - - for (c = 0; c < config->num_crtc; c++) - { - xf86CrtcPtr crtc = config->crtc[c]; - - crtc->enabled = FALSE; - memset (&crtc->desiredMode, '\0', sizeof (crtc->desiredMode)); - } - - /* - * Set initial configuration - */ - for (o = 0; o < config->num_output; o++) - { - xf86OutputPtr output = config->output[o]; - DisplayModePtr mode = modes[o]; - xf86CrtcPtr crtc = crtcs[o]; - - if (mode && crtc) - { - crtc->desiredMode = *mode; - crtc->enabled = TRUE; - crtc->x = output->initial_x; - crtc->y = output->initial_y; - output->crtc = crtc; - } - } - - if (scrn->display->virtualX == 0) - { - /* - * Expand virtual size to cover potential mode switches - */ - xf86DefaultScreenLimits (scrn, &width, &height); - - scrn->display->virtualX = width; - scrn->display->virtualY = height; - } - - if (width > scrn->virtualX) - scrn->virtualX = width; - if (height > scrn->virtualY) - scrn->virtualY = height; - - /* Mirror output modes to scrn mode list */ - xf86SetScrnInfoModes (scrn); - - xfree (crtcs); - xfree (modes); - return TRUE; -} - -/** - * Set the DPMS power mode of all outputs and CRTCs. - * - * If the new mode is off, it will turn off outputs and then CRTCs. - * Otherwise, it will affect CRTCs before outputs. - */ -void -xf86DPMSSet(ScrnInfoPtr scrn, int mode, int flags) -{ - xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); - int i; - - if (!scrn->vtSema) - return; - - if (mode == DPMSModeOff) { - for (i = 0; i < config->num_output; i++) { - xf86OutputPtr output = config->output[i]; - if (output->crtc != NULL) - (*output->funcs->dpms) (output, mode); - } - } - - for (i = 0; i < config->num_crtc; i++) { - xf86CrtcPtr crtc = config->crtc[i]; - if (crtc->enabled) - (*crtc->funcs->dpms) (crtc, mode); - } - - if (mode != DPMSModeOff) { - for (i = 0; i < config->num_output; i++) { - xf86OutputPtr output = config->output[i]; - if (output->crtc != NULL) - (*output->funcs->dpms) (output, mode); - } - } -} - -/** - * Implement the screensaver by just calling down into the driver DPMS hooks. - * - * Even for monitors with no DPMS support, by the definition of our DPMS hooks, - * the outputs will still get disabled (blanked). - */ -Bool -xf86SaveScreen(ScreenPtr pScreen, int mode) -{ - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - - if (xf86IsUnblank(mode)) - xf86DPMSSet(pScrn, DPMSModeOn, 0); - else - xf86DPMSSet(pScrn, DPMSModeOff, 0); - - return TRUE; -} - -/** - * Disable all inactive crtcs and outputs - */ -void -xf86DisableUnusedFunctions(ScrnInfoPtr pScrn) -{ - xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); - int o, c; - - for (o = 0; o < xf86_config->num_output; o++) - { - xf86OutputPtr output = xf86_config->output[o]; - if (!output->crtc) - (*output->funcs->dpms)(output, DPMSModeOff); - } - - for (c = 0; c < xf86_config->num_crtc; c++) - { - xf86CrtcPtr crtc = xf86_config->crtc[c]; - - if (!crtc->enabled) - { - crtc->funcs->dpms(crtc, DPMSModeOff); - memset(&crtc->mode, 0, sizeof(crtc->mode)); - } - } -} - -#ifdef RANDR_12_INTERFACE - -#define EDID_ATOM_NAME "EDID_DATA" - -/** - * Set the RandR EDID property - */ -static void -xf86OutputSetEDIDProperty (xf86OutputPtr output, void *data, int data_len) -{ - Atom edid_atom = MakeAtom(EDID_ATOM_NAME, sizeof(EDID_ATOM_NAME), TRUE); - - /* This may get called before the RandR resources have been created */ - if (output->randr_output == NULL) - return; - - if (data_len != 0) { - RRChangeOutputProperty(output->randr_output, edid_atom, XA_INTEGER, 8, - PropModeReplace, data_len, data, FALSE); - } else { - RRDeleteOutputProperty(output->randr_output, edid_atom); - } -} - -#endif - -/** - * Set the EDID information for the specified output - */ -void -xf86OutputSetEDID (xf86OutputPtr output, xf86MonPtr edid_mon) -{ - ScrnInfoPtr scrn = output->scrn; - xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); - int i; -#ifdef RANDR_12_INTERFACE - int size; -#endif - - if (output->MonInfo != NULL) - xfree(output->MonInfo); - - output->MonInfo = edid_mon; - - /* Debug info for now, at least */ - xf86DrvMsg(scrn->scrnIndex, X_INFO, "EDID for output %s\n", output->name); - xf86PrintEDID(edid_mon); - - /* Set the DDC properties for the 'compat' output */ - if (output == config->output[config->compat_output]) - xf86SetDDCproperties(scrn, edid_mon); - -#ifdef RANDR_12_INTERFACE - /* Set the RandR output properties */ - size = 0; - if (edid_mon) - { - if (edid_mon->ver.version == 1) - size = 128; - else if (edid_mon->ver.version == 2) - size = 256; - } - xf86OutputSetEDIDProperty (output, edid_mon ? edid_mon->rawData : NULL, size); -#endif - - if (edid_mon) - { - /* Pull out a phyiscal size from a detailed timing if available. */ - for (i = 0; i < 4; i++) { - if (edid_mon->det_mon[i].type == DT && - edid_mon->det_mon[i].section.d_timings.h_size != 0 && - edid_mon->det_mon[i].section.d_timings.v_size != 0) - { - output->mm_width = edid_mon->det_mon[i].section.d_timings.h_size; - output->mm_height = edid_mon->det_mon[i].section.d_timings.v_size; - break; - } - } - - /* if no mm size is available from a detailed timing, check the max size field */ - if ((!output->mm_width || !output->mm_height) && - (edid_mon->features.hsize && edid_mon->features.vsize)) - { - output->mm_width = edid_mon->features.hsize * 10; - output->mm_height = edid_mon->features.vsize * 10; - } - } -} - -/** - * Return the list of modes supported by the EDID information - * stored in 'output' - */ -DisplayModePtr -xf86OutputGetEDIDModes (xf86OutputPtr output) -{ - ScrnInfoPtr scrn = output->scrn; - xf86MonPtr edid_mon = output->MonInfo; - - if (!edid_mon) - return NULL; - return xf86DDCGetModes(scrn->scrnIndex, edid_mon); -} - -xf86MonPtr -xf86OutputGetEDID (xf86OutputPtr output, I2CBusPtr pDDCBus) -{ - ScrnInfoPtr scrn = output->scrn; - - return xf86DoEDID_DDC2 (scrn->scrnIndex, pDDCBus); -} diff --git a/src/i830_xf86Crtc.h b/src/i830_xf86Crtc.h deleted file mode 100644 index 53d2cdb7..00000000 --- a/src/i830_xf86Crtc.h +++ /dev/null @@ -1,553 +0,0 @@ -/* - * Copyright © 2006 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that copyright - * notice and this permission notice appear in supporting documentation, and - * that the name of the copyright holders not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. The copyright holders make no representations - * about the suitability of this software for any purpose. It is provided "as - * is" without express or implied warranty. - * - * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ -#ifndef _XF86CRTC_H_ -#define _XF86CRTC_H_ - -#include -#include "randrstr.h" -#include "i830_xf86Rename.h" -#include "i830_xf86Modes.h" -#include "xf86Parser.h" -#include "damage.h" - -/* Compat definitions for older X Servers. */ -#ifndef M_T_PREFERRED -#define M_T_PREFERRED 0x08 -#endif -#ifndef M_T_DRIVER -#define M_T_DRIVER 0x40 -#endif - -typedef struct _xf86Crtc xf86CrtcRec, *xf86CrtcPtr; -typedef struct _xf86Output xf86OutputRec, *xf86OutputPtr; - -typedef enum _xf86OutputStatus { - XF86OutputStatusConnected, - XF86OutputStatusDisconnected, - XF86OutputStatusUnknown, -} xf86OutputStatus; - -typedef struct _xf86CrtcFuncs { - /** - * Turns the crtc on/off, or sets intermediate power levels if available. - * - * Unsupported intermediate modes drop to the lower power setting. If the - * mode is DPMSModeOff, the crtc must be disabled sufficiently for it to - * be safe to call mode_set. - */ - void - (*dpms)(xf86CrtcPtr crtc, - int mode); - - /** - * Saves the crtc's state for restoration on VT switch. - */ - void - (*save)(xf86CrtcPtr crtc); - - /** - * Restore's the crtc's state at VT switch. - */ - void - (*restore)(xf86CrtcPtr crtc); - - /** - * Lock CRTC prior to mode setting, mostly for DRI. - * Returns whether unlock is needed - */ - Bool - (*lock) (xf86CrtcPtr crtc); - - /** - * Unlock CRTC after mode setting, mostly for DRI - */ - void - (*unlock) (xf86CrtcPtr crtc); - - /** - * Callback to adjust the mode to be set in the CRTC. - * - * This allows a CRTC to adjust the clock or even the entire set of - * timings, which is used for panels with fixed timings or for - * buses with clock limitations. - */ - Bool - (*mode_fixup)(xf86CrtcPtr crtc, - DisplayModePtr mode, - DisplayModePtr adjusted_mode); - - /** - * Callback for setting up a video mode after fixups have been made. - */ - void - (*mode_set)(xf86CrtcPtr crtc, - DisplayModePtr mode, - DisplayModePtr adjusted_mode, - int x, int y); - - /* Set the color ramps for the CRTC to the given values. */ - void - (*gamma_set)(xf86CrtcPtr crtc, CARD16 *red, CARD16 *green, CARD16 *blue, - int size); - - /** - * Create shadow pixmap for rotation support - */ - PixmapPtr - (*shadow_create) (xf86CrtcPtr crtc, int width, int height); - - /** - * Destroy shadow pixmap - */ - void - (*shadow_destroy) (xf86CrtcPtr crtc, PixmapPtr pPixmap); - - /** - * Clean up driver-specific bits of the crtc - */ - void - (*destroy) (xf86CrtcPtr crtc); -} xf86CrtcFuncsRec, *xf86CrtcFuncsPtr; - -struct _xf86Crtc { - /** - * Associated ScrnInfo - */ - ScrnInfoPtr scrn; - - /** - * Active state of this CRTC - * - * Set when this CRTC is driving one or more outputs - */ - Bool enabled; - - /** Track whether cursor is within CRTC range */ - Bool cursorInRange; - - /** Track state of cursor associated with this CRTC */ - Bool cursorShown; - - /** - * Active mode - * - * This reflects the mode as set in the CRTC currently - * It will be cleared when the VT is not active or - * during server startup - */ - DisplayModeRec mode; - Rotation rotation; - PixmapPtr rotatedPixmap; - /** - * Position on screen - * - * Locates this CRTC within the frame buffer - */ - int x, y; - - /** - * Desired mode - * - * This is set to the requested mode, independent of - * whether the VT is active. In particular, it receives - * the startup configured mode and saves the active mode - * on VT switch. - */ - DisplayModeRec desiredMode; - Rotation desiredRotation; - int desiredX, desiredY; - - /** crtc-specific functions */ - const xf86CrtcFuncsRec *funcs; - - /** - * Driver private - * - * Holds driver-private information - */ - void *driver_private; - -#ifdef RANDR_12_INTERFACE - /** - * RandR crtc - * - * When RandR 1.2 is available, this - * points at the associated crtc object - */ - RRCrtcPtr randr_crtc; -#else - void *randr_crtc; -#endif -}; - -typedef struct _xf86OutputFuncs { - /** - * Called to allow the output a chance to create properties after the - * RandR objects have been created. - */ - void - (*create_resources)(xf86OutputPtr output); - - /** - * Turns the output on/off, or sets intermediate power levels if available. - * - * Unsupported intermediate modes drop to the lower power setting. If the - * mode is DPMSModeOff, the output must be disabled, as the DPLL may be - * disabled afterwards. - */ - void - (*dpms)(xf86OutputPtr output, - int mode); - - /** - * Saves the output's state for restoration on VT switch. - */ - void - (*save)(xf86OutputPtr output); - - /** - * Restore's the output's state at VT switch. - */ - void - (*restore)(xf86OutputPtr output); - - /** - * Callback for testing a video mode for a given output. - * - * This function should only check for cases where a mode can't be supported - * on the output specifically, and not represent generic CRTC limitations. - * - * \return MODE_OK if the mode is valid, or another MODE_* otherwise. - */ - int - (*mode_valid)(xf86OutputPtr output, - DisplayModePtr pMode); - - /** - * Callback to adjust the mode to be set in the CRTC. - * - * This allows an output to adjust the clock or even the entire set of - * timings, which is used for panels with fixed timings or for - * buses with clock limitations. - */ - Bool - (*mode_fixup)(xf86OutputPtr output, - DisplayModePtr mode, - DisplayModePtr adjusted_mode); - - /** - * Callback for setting up a video mode after fixups have been made. - * - * This is only called while the output is disabled. The dpms callback - * must be all that's necessary for the output, to turn the output on - * after this function is called. - */ - void - (*mode_set)(xf86OutputPtr output, - DisplayModePtr mode, - DisplayModePtr adjusted_mode); - - /** - * Probe for a connected output, and return detect_status. - */ - xf86OutputStatus - (*detect)(xf86OutputPtr output); - - /** - * Query the device for the modes it provides. - * - * This function may also update MonInfo, mm_width, and mm_height. - * - * \return singly-linked list of modes or NULL if no modes found. - */ - DisplayModePtr - (*get_modes)(xf86OutputPtr output); - -#ifdef RANDR_12_INTERFACE - /** - * Callback when an output's property has changed. - */ - Bool - (*set_property)(xf86OutputPtr output, - Atom property, - RRPropertyValuePtr value); -#endif - /** - * Clean up driver-specific bits of the output - */ - void - (*destroy) (xf86OutputPtr output); -} xf86OutputFuncsRec, *xf86OutputFuncsPtr; - -struct _xf86Output { - /** - * Associated ScrnInfo - */ - ScrnInfoPtr scrn; - - /** - * Currently connected crtc (if any) - * - * If this output is not in use, this field will be NULL. - */ - xf86CrtcPtr crtc; - - /** - * Possible CRTCs for this output as a mask of crtc indices - */ - CARD32 possible_crtcs; - - /** - * Possible outputs to share the same CRTC as a mask of output indices - */ - CARD32 possible_clones; - - /** - * Whether this output can support interlaced modes - */ - Bool interlaceAllowed; - - /** - * Whether this output can support double scan modes - */ - Bool doubleScanAllowed; - - /** - * List of available modes on this output. - * - * This should be the list from get_modes(), plus perhaps additional - * compatible modes added later. - */ - DisplayModePtr probed_modes; - - /** - * Options parsed from the related monitor section - */ - OptionInfoPtr options; - - /** - * Configured monitor section - */ - XF86ConfMonitorPtr conf_monitor; - - /** - * Desired initial position - */ - int initial_x, initial_y; - - /** - * Current connection status - * - * This indicates whether a monitor is known to be connected - * to this output or not, or whether there is no way to tell - */ - xf86OutputStatus status; - - /** EDID monitor information */ - xf86MonPtr MonInfo; - - /** subpixel order */ - int subpixel_order; - - /** Physical size of the currently attached output device. */ - int mm_width, mm_height; - - /** Output name */ - char *name; - - /** output-specific functions */ - const xf86OutputFuncsRec *funcs; - - /** driver private information */ - void *driver_private; - -#ifdef RANDR_12_INTERFACE - /** - * RandR 1.2 output structure. - * - * When RandR 1.2 is available, this points at the associated - * RandR output structure and is created when this output is created - */ - RROutputPtr randr_output; -#else - void *randr_output; -#endif -}; - -typedef struct _xf86CrtcConfig { - int num_output; - xf86OutputPtr *output; - /** - * compat_output is used whenever we deal - * with legacy code that only understands a single - * output. pScrn->modes will be loaded from this output, - * adjust frame will whack this output, etc. - */ - int compat_output; - - int num_crtc; - xf86CrtcPtr *crtc; - - int minWidth, minHeight; - int maxWidth, maxHeight; - - /* For crtc-based rotation */ - DamagePtr rotationDamage; - - /* DGA */ - unsigned int dga_flags; - unsigned long dga_address; - DGAModePtr dga_modes; - int dga_nmode; - int dga_width, dga_height, dga_stride; - DisplayModePtr dga_save_mode; - -} xf86CrtcConfigRec, *xf86CrtcConfigPtr; - -extern int xf86CrtcConfigPrivateIndex; - -#define XF86_CRTC_CONFIG_PTR(p) ((xf86CrtcConfigPtr) ((p)->privates[xf86CrtcConfigPrivateIndex].ptr)) - -/* - * Initialize xf86CrtcConfig structure - */ - -void -xf86CrtcConfigInit (ScrnInfoPtr scrn); - -void -xf86CrtcSetSizeRange (ScrnInfoPtr scrn, - int minWidth, int minHeight, - int maxWidth, int maxHeight); - -/* - * Crtc functions - */ -xf86CrtcPtr -xf86CrtcCreate (ScrnInfoPtr scrn, - const xf86CrtcFuncsRec *funcs); - -void -xf86CrtcDestroy (xf86CrtcPtr crtc); - - -/** - * Allocate a crtc for the specified output - * - * Find a currently unused CRTC which is suitable for - * the specified output - */ - -xf86CrtcPtr -xf86AllocCrtc (xf86OutputPtr output); - -/** - * Free a crtc - * - * Mark the crtc as unused by any outputs - */ - -void -xf86FreeCrtc (xf86CrtcPtr crtc); - -/** - * Sets the given video mode on the given crtc - */ -Bool -xf86CrtcSetMode (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation, - int x, int y); - -/* - * Assign crtc rotation during mode set - */ -Bool -xf86CrtcRotate (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation); - -/** - * Return whether any output is assigned to the crtc - */ -Bool -xf86CrtcInUse (xf86CrtcPtr crtc); - -/* - * Output functions - */ -xf86OutputPtr -xf86OutputCreate (ScrnInfoPtr scrn, - const xf86OutputFuncsRec *funcs, - const char *name); - -Bool -xf86OutputRename (xf86OutputPtr output, const char *name); - -void -xf86OutputDestroy (xf86OutputPtr output); - -void -xf86ProbeOutputModes (ScrnInfoPtr pScrn, int maxX, int maxY); - -void -xf86SetScrnInfoModes (ScrnInfoPtr pScrn); - -Bool -xf86InitialConfiguration (ScrnInfoPtr pScrn); - -void -xf86DPMSSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags); - -Bool -xf86SaveScreen(ScreenPtr pScreen, int mode); - -void -xf86DisableUnusedFunctions(ScrnInfoPtr pScrn); - -/** - * Set the EDID information for the specified output - */ -void -xf86OutputSetEDID (xf86OutputPtr output, xf86MonPtr edid_mon); - -/** - * Return the list of modes supported by the EDID information - * stored in 'output' - */ -DisplayModePtr -xf86OutputGetEDIDModes (xf86OutputPtr output); - -xf86MonPtr -xf86OutputGetEDID (xf86OutputPtr output, I2CBusPtr pDDCBus); - -/** - * Initialize dga for this screen - */ - -Bool -xf86DiDGAInit (ScreenPtr pScreen, unsigned long dga_address); - -/** - * Re-initialize dga for this screen (as when the set of modes changes) - */ - -Bool -xf86DiDGAReInit (ScreenPtr pScreen); - -#endif /* _XF86CRTC_H_ */ diff --git a/src/i830_xf86DiDGA.c b/src/i830_xf86DiDGA.c deleted file mode 100644 index 24a52973..00000000 --- a/src/i830_xf86DiDGA.c +++ /dev/null @@ -1,280 +0,0 @@ -/* - * Copyright © 2006 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that copyright - * notice and this permission notice appear in supporting documentation, and - * that the name of the copyright holders not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. The copyright holders make no representations - * about the suitability of this software for any purpose. It is provided "as - * is" without express or implied warranty. - * - * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "xf86.h" -#include "xf86DDC.h" -#include "xf86_OSproc.h" -#include "dgaproc.h" -#include "i830_xf86Crtc.h" -#include "i830_xf86Modes.h" -#include "gcstruct.h" - -static Bool -xf86_dga_get_modes (ScreenPtr pScreen) -{ - ScrnInfoPtr scrn = xf86Screens[pScreen->myNum]; - xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); - DGAModePtr modes, mode; - DisplayModePtr display_mode; - int bpp = scrn->bitsPerPixel >> 3; - int num; - - num = 0; - display_mode = scrn->modes; - while (display_mode) - { - num++; - display_mode = display_mode->next; - if (display_mode == scrn->modes) - break; - } - - if (!num) - return FALSE; - - modes = xalloc(num * sizeof(DGAModeRec)); - if (!modes) - return FALSE; - - num = 0; - display_mode = scrn->modes; - while (display_mode) - { - mode = modes + num++; - - mode->mode = display_mode; - mode->flags = DGA_CONCURRENT_ACCESS | DGA_PIXMAP_AVAILABLE; - mode->flags |= DGA_FILL_RECT | DGA_BLIT_RECT; - if (display_mode->Flags & V_DBLSCAN) - mode->flags |= DGA_DOUBLESCAN; - if (display_mode->Flags & V_INTERLACE) - mode->flags |= DGA_INTERLACED; - mode->byteOrder = scrn->imageByteOrder; - mode->depth = scrn->depth; - mode->bitsPerPixel = scrn->bitsPerPixel; - mode->red_mask = scrn->mask.red; - mode->green_mask = scrn->mask.green; - mode->blue_mask = scrn->mask.blue; - mode->visualClass = (bpp == 1) ? PseudoColor : TrueColor; - mode->viewportWidth = display_mode->HDisplay; - mode->viewportHeight = display_mode->VDisplay; - mode->xViewportStep = (bpp == 3) ? 2 : 1; - mode->yViewportStep = 1; - mode->viewportFlags = DGA_FLIP_RETRACE; - mode->offset = 0; - mode->address = (unsigned char *) xf86_config->dga_address; - mode->bytesPerScanline = xf86_config->dga_stride; - mode->imageWidth = xf86_config->dga_width; - mode->imageHeight = xf86_config->dga_height; - mode->pixmapWidth = mode->imageWidth; - mode->pixmapHeight = mode->imageHeight; - mode->maxViewportX = mode->imageWidth - mode->viewportWidth; - mode->maxViewportY = mode->imageHeight - mode->viewportHeight; - - display_mode = display_mode->next; - if (display_mode == scrn->modes) - break; - } - if (xf86_config->dga_modes) - xfree (xf86_config->dga_modes); - xf86_config->dga_nmode = num; - xf86_config->dga_modes = modes; - return TRUE; -} - -static Bool -xf86_dga_set_mode(ScrnInfoPtr scrn, DGAModePtr display_mode) -{ - ScreenPtr pScreen = scrn->pScreen; - xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); - - if (!display_mode) - { - if (xf86_config->dga_save_mode) - { - xf86SwitchMode(pScreen, xf86_config->dga_save_mode); - xf86_config->dga_save_mode = NULL; - } - } - else - { - if (!xf86_config->dga_save_mode) - { - xf86_config->dga_save_mode = scrn->currentMode; - xf86SwitchMode(pScreen, display_mode->mode); - } - } - return TRUE; -} - -static int -xf86_dga_get_viewport(ScrnInfoPtr scrn) -{ - return 0; -} - -static void -xf86_dga_set_viewport(ScrnInfoPtr scrn, int x, int y, int flags) -{ - scrn->AdjustFrame(scrn->pScreen->myNum, x, y, flags); -} - -static Bool -xf86_dga_get_drawable_and_gc (ScrnInfoPtr scrn, DrawablePtr *ppDrawable, GCPtr *ppGC) -{ - ScreenPtr pScreen = scrn->pScreen; - xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); - PixmapPtr pPixmap; - GCPtr pGC; - - pPixmap = GetScratchPixmapHeader (pScreen, xf86_config->dga_width, xf86_config->dga_height, - scrn->depth, scrn->bitsPerPixel, xf86_config->dga_stride, - (char *) scrn->memPhysBase + scrn->fbOffset); - if (!pPixmap) - return FALSE; - pGC = GetScratchGC (scrn->depth, pScreen); - if (!pGC) - { - FreeScratchPixmapHeader (pPixmap); - return FALSE; - } - *ppDrawable = &pPixmap->drawable; - *ppGC = pGC; - return TRUE; -} - -static void -xf86_dga_release_drawable_and_gc (ScrnInfoPtr scrn, DrawablePtr pDrawable, GCPtr pGC) -{ - FreeScratchGC (pGC); - FreeScratchPixmapHeader ((PixmapPtr) pDrawable); -} - -static void -xf86_dga_fill_rect(ScrnInfoPtr scrn, int x, int y, int w, int h, unsigned long color) -{ - GCPtr pGC; - DrawablePtr pDrawable; - XID vals[1]; - xRectangle r; - - if (!xf86_dga_get_drawable_and_gc (scrn, &pDrawable, &pGC)) - return; - vals[0] = color; - ChangeGC (pGC, GCForeground, vals); - ValidateGC (pDrawable, pGC); - r.x = x; - r.y = y; - r.width = w; - r.height = h; - pGC->ops->PolyFillRect (pDrawable, pGC, 1, &r); - xf86_dga_release_drawable_and_gc (scrn, pDrawable, pGC); -} - -static void -xf86_dga_sync(ScrnInfoPtr scrn) -{ - ScreenPtr pScreen = scrn->pScreen; - WindowPtr pRoot = WindowTable [pScreen->myNum]; - char buffer[4]; - - pScreen->GetImage (&pRoot->drawable, 0, 0, 1, 1, ZPixmap, ~0L, buffer); -} - -static void -xf86_dga_blit_rect(ScrnInfoPtr scrn, int srcx, int srcy, int w, int h, int dstx, int dsty) -{ - DrawablePtr pDrawable; - GCPtr pGC; - - if (!xf86_dga_get_drawable_and_gc (scrn, &pDrawable, &pGC)) - return; - ValidateGC (pDrawable, pGC); - pGC->ops->CopyArea (pDrawable, pDrawable, pGC, srcx, srcy, w, h, dstx, dsty); - xf86_dga_release_drawable_and_gc (scrn, pDrawable, pGC); -} - -static Bool -xf86_dga_open_framebuffer(ScrnInfoPtr scrn, - char **name, - unsigned char **mem, int *size, int *offset, int *flags) -{ - xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); - - *size = xf86_config->dga_stride * xf86_config->dga_height; - *mem = (unsigned char *) (xf86_config->dga_address); - *offset = 0; - *flags = DGA_NEED_ROOT; - - return TRUE; -} - -static void -xf86_dga_close_framebuffer(ScrnInfoPtr scrn) -{ -} - -static DGAFunctionRec xf86_dga_funcs = { - xf86_dga_open_framebuffer, - xf86_dga_close_framebuffer, - xf86_dga_set_mode, - xf86_dga_set_viewport, - xf86_dga_get_viewport, - xf86_dga_sync, - xf86_dga_fill_rect, - xf86_dga_blit_rect, - NULL -}; - -Bool -xf86DiDGAReInit (ScreenPtr pScreen) -{ - ScrnInfoPtr scrn = xf86Screens[pScreen->myNum]; - xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); - - if (!xf86_dga_get_modes (pScreen)) - return FALSE; - - return DGAReInitModes (pScreen, xf86_config->dga_modes, xf86_config->dga_nmode); -} - -Bool -xf86DiDGAInit (ScreenPtr pScreen, unsigned long dga_address) -{ - ScrnInfoPtr scrn = xf86Screens[pScreen->myNum]; - xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); - - xf86_config->dga_flags = 0; - xf86_config->dga_address = dga_address; - xf86_config->dga_width = scrn->virtualX; - xf86_config->dga_height = scrn->virtualY; - xf86_config->dga_stride = scrn->displayWidth * scrn->bitsPerPixel >> 3; - - if (!xf86_dga_get_modes (pScreen)) - return FALSE; - - return DGAInit(pScreen, &xf86_dga_funcs, xf86_config->dga_modes, xf86_config->dga_nmode); -} diff --git a/src/i830_xf86EdidModes.c b/src/i830_xf86EdidModes.c deleted file mode 100644 index 866b9bef..00000000 --- a/src/i830_xf86EdidModes.c +++ /dev/null @@ -1,344 +0,0 @@ -/* - * Copyright 2006 Luc Verhaegen. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/** - * @file This is a copy of edid_modes.c from the X Server, for compatibility - * with old X Servers. - */ -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "xf86.h" -#include "xf86DDC.h" -#include -#include "property.h" -#include "propertyst.h" -#include "xf86DDC.h" -#include "i830.h" -#include "i830_display.h" -#include -#include - -#if XORG_VERSION_CURRENT <= XORG_VERSION_NUMERIC(7,2,99,2,0) - -/* - * Quirks to work around broken EDID data from various monitors. - */ - -typedef enum { - DDC_QUIRK_NONE = 0, - /* Force detailed sync polarity to -h +v */ - DDC_QUIRK_DT_SYNC_HM_VP = 1 << 0, - /* First detailed mode is bogus, prefer largest mode at 60hz */ - DDC_QUIRK_PREFER_LARGE_60 = 1 << 1, - /* 135MHz clock is too high, drop a bit */ - DDC_QUIRK_135_CLOCK_TOO_HIGH = 1 << 2 -} ddc_quirk_t; - -static Bool quirk_dt_sync_hm_vp (int scrnIndex, xf86MonPtr DDC) -{ - /* Belinea 1924S1W */ - if (memcmp (DDC->vendor.name, "MAX", 4) == 0 && - DDC->vendor.prod_id == 1932) - return TRUE; - /* Belinea 10 20 30W */ - if (memcmp (DDC->vendor.name, "MAX", 4) == 0 && - DDC->vendor.prod_id == 2007) - return TRUE; - /* ViewSonic VX2025wm (bug #9941) */ - if (memcmp (DDC->vendor.name, "VSC", 4) == 0 && - DDC->vendor.prod_id == 58653) - return TRUE; - - return FALSE; -} - -static Bool quirk_prefer_large_60 (int scrnIndex, xf86MonPtr DDC) -{ - /* Belinea 10 15 55 */ - if (memcmp (DDC->vendor.name, "MAX", 4) == 0 && - DDC->vendor.prod_id == 1516) - return TRUE; - - return FALSE; -} - -static Bool quirk_135_clock_too_high (int scrnIndex, xf86MonPtr DDC) -{ - /* Envision Peripherals, Inc. EN-7100e. See bug #9550. */ - if (memcmp (DDC->vendor.name, "EPI", 4) == 0 && - DDC->vendor.prod_id == 59264) - return TRUE; - - return FALSE; -} - -typedef struct { - Bool (*detect) (int scrnIndex, xf86MonPtr DDC); - ddc_quirk_t quirk; - char *description; -} ddc_quirk_map_t; - -static const ddc_quirk_map_t ddc_quirks[] = { - { - quirk_dt_sync_hm_vp, DDC_QUIRK_DT_SYNC_HM_VP, - "Set detailed timing sync polarity to -h +v" - }, - { - quirk_prefer_large_60, DDC_QUIRK_PREFER_LARGE_60, - "Detailed timing is not preferred, use largest mode at 60Hz" - }, - { - quirk_135_clock_too_high, DDC_QUIRK_135_CLOCK_TOO_HIGH, - "Recommended 135MHz pixel clock is too high" - }, - { - NULL, DDC_QUIRK_NONE, - "No known quirks" - }, -}; - -/* - * TODO: - * - for those with access to the VESA DMT standard; review please. - */ -#define MODEPREFIX(name) NULL, NULL, name, 0,M_T_DRIVER -#define MODESUFFIX 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,FALSE,FALSE,0,NULL,0,0.0,0.0 - -static DisplayModeRec DDCEstablishedModes[17] = { - { MODEPREFIX("800x600"), 40000, 800, 840, 968, 1056, 0, 600, 601, 605, 628, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@60Hz */ - { MODEPREFIX("800x600"), 36000, 800, 824, 896, 1024, 0, 600, 601, 603, 625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@56Hz */ - { MODEPREFIX("640x480"), 31500, 640, 656, 720, 840, 0, 480, 481, 484, 500, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@75Hz */ - { MODEPREFIX("640x480"), 31500, 640, 664, 704, 832, 0, 480, 489, 491, 520, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@72Hz */ - { MODEPREFIX("640x480"), 30240, 640, 704, 768, 864, 0, 480, 483, 486, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@67Hz */ - { MODEPREFIX("640x480"), 25200, 640, 656, 752, 800, 0, 480, 490, 492, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@60Hz */ - { MODEPREFIX("720x400"), 35500, 720, 738, 846, 900, 0, 400, 421, 423, 449, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 720x400@88Hz */ - { MODEPREFIX("720x400"), 28320, 720, 738, 846, 900, 0, 400, 412, 414, 449, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 720x400@70Hz */ - { MODEPREFIX("1280x1024"), 135000, 1280, 1296, 1440, 1688, 0, 1024, 1025, 1028, 1066, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x1024@75Hz */ - { MODEPREFIX("1024x768"), 78800, 1024, 1040, 1136, 1312, 0, 768, 769, 772, 800, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1024x768@75Hz */ - { MODEPREFIX("1024x768"), 75000, 1024, 1048, 1184, 1328, 0, 768, 771, 777, 806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768@70Hz */ - { MODEPREFIX("1024x768"), 65000, 1024, 1048, 1184, 1344, 0, 768, 771, 777, 806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768@60Hz */ - { MODEPREFIX("1024x768"), 44900, 1024, 1032, 1208, 1264, 0, 768, 768, 776, 817, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* 1024x768@43Hz */ - { MODEPREFIX("832x624"), 57284, 832, 864, 928, 1152, 0, 624, 625, 628, 667, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 832x624@75Hz */ - { MODEPREFIX("800x600"), 49500, 800, 816, 896, 1056, 0, 600, 601, 604, 625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@75Hz */ - { MODEPREFIX("800x600"), 50000, 800, 856, 976, 1040, 0, 600, 637, 643, 666, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@72Hz */ - { MODEPREFIX("1152x864"), 108000, 1152, 1216, 1344, 1600, 0, 864, 865, 868, 900, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1152x864@75Hz */ -}; - -static DisplayModePtr -DDCModesFromEstablished(int scrnIndex, struct established_timings *timing, - ddc_quirk_t quirks) -{ - DisplayModePtr Modes = NULL, Mode = NULL; - CARD32 bits = (timing->t1) | (timing->t2 << 8) | - ((timing->t_manu & 0x80) << 9); - int i; - - for (i = 0; i < 17; i++) { - if (bits & (0x01 << i)) { - Mode = xf86DuplicateMode(&DDCEstablishedModes[i]); - Modes = xf86ModesAdd(Modes, Mode); - } - } - - return Modes; -} - -/* - * - */ -static DisplayModePtr -DDCModesFromStandardTiming(int scrnIndex, struct std_timings *timing, - ddc_quirk_t quirks) -{ - DisplayModePtr Modes = NULL, Mode = NULL; - int i; - - for (i = 0; i < STD_TIMINGS; i++) { - if (timing[i].hsize && timing[i].vsize && timing[i].refresh) { - Mode = xf86CVTMode(timing[i].hsize, timing[i].vsize, - timing[i].refresh, FALSE, FALSE); - Mode->type = M_T_DRIVER; - Modes = xf86ModesAdd(Modes, Mode); - } - } - - return Modes; -} - -/* - * - */ -static DisplayModePtr -DDCModeFromDetailedTiming(int scrnIndex, struct detailed_timings *timing, - int preferred, ddc_quirk_t quirks) -{ - DisplayModePtr Mode; - - /* We don't do stereo */ - if (timing->stereo) { - xf86DrvMsg(scrnIndex, X_INFO, - "%s: Ignoring: We don't handle stereo.\n", __func__); - return NULL; - } - - /* We only do seperate sync currently */ - if (timing->sync != 0x03) { - xf86DrvMsg(scrnIndex, X_INFO, - "%s: %dx%d Warning: We only handle seperate" - " sync.\n", __func__, timing->h_active, timing->v_active); - } - - Mode = xnfalloc(sizeof(DisplayModeRec)); - memset(Mode, 0, sizeof(DisplayModeRec)); - - Mode->type = M_T_DRIVER; - if (preferred) - Mode->type |= M_T_PREFERRED; - - if( ( quirks & DDC_QUIRK_135_CLOCK_TOO_HIGH ) && - timing->clock == 135000000 ) - Mode->Clock = 108880; - else - Mode->Clock = timing->clock / 1000.0; - - Mode->HDisplay = timing->h_active; - Mode->HSyncStart = timing->h_active + timing->h_sync_off; - Mode->HSyncEnd = Mode->HSyncStart + timing->h_sync_width; - Mode->HTotal = timing->h_active + timing->h_blanking; - - Mode->VDisplay = timing->v_active; - Mode->VSyncStart = timing->v_active + timing->v_sync_off; - Mode->VSyncEnd = Mode->VSyncStart + timing->v_sync_width; - Mode->VTotal = timing->v_active + timing->v_blanking; - - xf86SetModeDefaultName(Mode); - - /* We ignore h/v_size and h/v_border for now. */ - - if (timing->interlaced) - Mode->Flags |= V_INTERLACE; - - if (quirks & DDC_QUIRK_DT_SYNC_HM_VP) - Mode->Flags |= V_NHSYNC | V_PVSYNC; - else - { - if (timing->misc & 0x02) - Mode->Flags |= V_PHSYNC; - else - Mode->Flags |= V_NHSYNC; - - if (timing->misc & 0x01) - Mode->Flags |= V_PVSYNC; - else - Mode->Flags |= V_NVSYNC; - } - - return Mode; -} - -DisplayModePtr -xf86DDCGetModes(int scrnIndex, xf86MonPtr DDC) -{ - int preferred, i; - DisplayModePtr Modes = NULL, Mode; - ddc_quirk_t quirks; - - xf86DrvMsg (scrnIndex, X_INFO, "EDID vendor \"%s\", prod id %d\n", - DDC->vendor.name, DDC->vendor.prod_id); - quirks = DDC_QUIRK_NONE; - for (i = 0; ddc_quirks[i].detect; i++) - if (ddc_quirks[i].detect (scrnIndex, DDC)) - { - xf86DrvMsg (scrnIndex, X_INFO, " EDID quirk: %s\n", - ddc_quirks[i].description); - quirks |= ddc_quirks[i].quirk; - } - - preferred = PREFERRED_TIMING_MODE(DDC->features.msc); - if (quirks & DDC_QUIRK_PREFER_LARGE_60) - preferred = 0; - - for (i = 0; i < DET_TIMINGS; i++) { - struct detailed_monitor_section *det_mon = &DDC->det_mon[i]; - - switch (det_mon->type) { - case DT: - Mode = DDCModeFromDetailedTiming(scrnIndex, - &det_mon->section.d_timings, - preferred, - quirks); - preferred = 0; - Modes = xf86ModesAdd(Modes, Mode); - break; - case DS_STD_TIMINGS: - Mode = DDCModesFromStandardTiming(scrnIndex, - det_mon->section.std_t, - quirks); - Modes = xf86ModesAdd(Modes, Mode); - break; - default: - break; - } - } - - /* Add established timings */ - Mode = DDCModesFromEstablished(scrnIndex, &DDC->timings1, quirks); - Modes = xf86ModesAdd(Modes, Mode); - - /* Add standard timings */ - Mode = DDCModesFromStandardTiming(scrnIndex, DDC->timings2, quirks); - Modes = xf86ModesAdd(Modes, Mode); - - if (quirks & DDC_QUIRK_PREFER_LARGE_60) - { - DisplayModePtr best = Modes; - for (Mode = Modes; Mode; Mode = Mode->next) - { - if (Mode == best) continue; - if (Mode->HDisplay * Mode->VDisplay > best->HDisplay * best->VDisplay) - { - best = Mode; - continue; - } - if (Mode->HDisplay * Mode->VDisplay == best->HDisplay * best->VDisplay) - { - double mode_refresh = xf86ModeVRefresh (Mode); - double best_refresh = xf86ModeVRefresh (best); - double mode_dist = fabs(mode_refresh - 60.0); - double best_dist = fabs(best_refresh - 60.0); - if (mode_dist < best_dist) - { - best = Mode; - continue; - } - } - } - if (best) - best->type |= M_T_PREFERRED; - } - return Modes; -} - -#endif /* XORG_VERSION_CURRENT <= XORG_VERSION_NUMERIC(7,2,99,2,0) */ diff --git a/src/i830_xf86Modes.c b/src/i830_xf86Modes.c deleted file mode 100644 index f620d4d5..00000000 --- a/src/i830_xf86Modes.c +++ /dev/null @@ -1,636 +0,0 @@ -/* -*- c-basic-offset: 4 -*- */ -/* $XdotOrg: xserver/xorg/hw/xfree86/common/xf86Mode.c,v 1.10 2006/03/07 16:00:57 libv Exp $ */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Mode.c,v 1.69 2003/10/08 14:58:28 dawes Exp $ */ -/* - * Copyright (c) 1997-2003 by The XFree86 Project, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of the copyright holder(s) - * and author(s) shall not be used in advertising or otherwise to promote - * the sale, use or other dealings in this Software without prior written - * authorization from the copyright holder(s) and author(s). - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include - -#include "xf86.h" -#include "i830.h" -#include "i830_xf86Modes.h" -#include "xf86Priv.h" - -extern XF86ConfigPtr xf86configptr; - -/** - * @file this file contains symbols from xf86Mode.c and friends that are static - * there but we still want to use. We need to come up with better API here. - */ - -#if XORG_VERSION_CURRENT <= XORG_VERSION_NUMERIC(7,2,99,2,0) -/** - * Calculates the horizontal sync rate of a mode. - * - * Exact copy of xf86Mode.c's. - */ -double -xf86ModeHSync(DisplayModePtr mode) -{ - double hsync = 0.0; - - if (mode->HSync > 0.0) - hsync = mode->HSync; - else if (mode->HTotal > 0) - hsync = (float)mode->Clock / (float)mode->HTotal; - - return hsync; -} - -/** - * Calculates the vertical refresh rate of a mode. - * - * Exact copy of xf86Mode.c's. - */ -double -xf86ModeVRefresh(DisplayModePtr mode) -{ - double refresh = 0.0; - - if (mode->VRefresh > 0.0) - refresh = mode->VRefresh; - else if (mode->HTotal > 0 && mode->VTotal > 0) { - refresh = mode->Clock * 1000.0 / mode->HTotal / mode->VTotal; - if (mode->Flags & V_INTERLACE) - refresh *= 2.0; - if (mode->Flags & V_DBLSCAN) - refresh /= 2.0; - if (mode->VScan > 1) - refresh /= (float)(mode->VScan); - } - return refresh; -} - -/** Sets a default mode name of x on a mode. */ -void -xf86SetModeDefaultName(DisplayModePtr mode) -{ - if (mode->name != NULL) - xfree(mode->name); - - mode->name = XNFprintf("%dx%d", mode->HDisplay, mode->VDisplay); -} - -/* - * xf86SetModeCrtc - * - * Initialises the Crtc parameters for a mode. The initialisation includes - * adjustments for interlaced and double scan modes. - * - * Exact copy of xf86Mode.c's. - */ -void -xf86SetModeCrtc(DisplayModePtr p, int adjustFlags) -{ - if ((p == NULL) || ((p->type & M_T_CRTC_C) == M_T_BUILTIN)) - return; - - p->CrtcHDisplay = p->HDisplay; - p->CrtcHSyncStart = p->HSyncStart; - p->CrtcHSyncEnd = p->HSyncEnd; - p->CrtcHTotal = p->HTotal; - p->CrtcHSkew = p->HSkew; - p->CrtcVDisplay = p->VDisplay; - p->CrtcVSyncStart = p->VSyncStart; - p->CrtcVSyncEnd = p->VSyncEnd; - p->CrtcVTotal = p->VTotal; - if (p->Flags & V_INTERLACE) { - if (adjustFlags & INTERLACE_HALVE_V) { - p->CrtcVDisplay /= 2; - p->CrtcVSyncStart /= 2; - p->CrtcVSyncEnd /= 2; - p->CrtcVTotal /= 2; - } - /* Force interlaced modes to have an odd VTotal */ - /* maybe we should only do this when INTERLACE_HALVE_V is set? */ - p->CrtcVTotal |= 1; - } - - if (p->Flags & V_DBLSCAN) { - p->CrtcVDisplay *= 2; - p->CrtcVSyncStart *= 2; - p->CrtcVSyncEnd *= 2; - p->CrtcVTotal *= 2; - } - if (p->VScan > 1) { - p->CrtcVDisplay *= p->VScan; - p->CrtcVSyncStart *= p->VScan; - p->CrtcVSyncEnd *= p->VScan; - p->CrtcVTotal *= p->VScan; - } - p->CrtcVBlankStart = min(p->CrtcVSyncStart, p->CrtcVDisplay); - p->CrtcVBlankEnd = max(p->CrtcVSyncEnd, p->CrtcVTotal); - p->CrtcHBlankStart = min(p->CrtcHSyncStart, p->CrtcHDisplay); - p->CrtcHBlankEnd = max(p->CrtcHSyncEnd, p->CrtcHTotal); - - p->CrtcHAdjusted = FALSE; - p->CrtcVAdjusted = FALSE; -} - -/** - * Allocates and returns a copy of pMode, including pointers within pMode. - */ -DisplayModePtr -xf86DuplicateMode(DisplayModePtr pMode) -{ - DisplayModePtr pNew; - - pNew = xnfalloc(sizeof(DisplayModeRec)); - *pNew = *pMode; - pNew->next = NULL; - pNew->prev = NULL; - if (pNew->name == NULL) { - xf86SetModeDefaultName(pMode); - } else { - pNew->name = xnfstrdup(pMode->name); - } - - return pNew; -} - -/** - * Duplicates every mode in the given list and returns a pointer to the first - * mode. - * - * \param modeList doubly-linked mode list - */ -DisplayModePtr -xf86DuplicateModes(ScrnInfoPtr pScrn, DisplayModePtr modeList) -{ - DisplayModePtr first = NULL, last = NULL; - DisplayModePtr mode; - - for (mode = modeList; mode != NULL; mode = mode->next) { - DisplayModePtr new; - - new = xf86DuplicateMode(mode); - - /* Insert pNew into modeList */ - if (last) { - last->next = new; - new->prev = last; - } else { - first = new; - new->prev = NULL; - } - new->next = NULL; - last = new; - } - - return first; -} - -/** - * Returns true if the given modes should program to the same timings. - * - * This doesn't use Crtc values, as it might be used on ModeRecs without the - * Crtc values set. So, it's assumed that the other numbers are enough. - * - * This isn't in xf86Modes.c, but it might deserve to be there. - */ -Bool -xf86ModesEqual(DisplayModePtr pMode1, DisplayModePtr pMode2) -{ - if (pMode1->Clock == pMode2->Clock && - pMode1->HDisplay == pMode2->HDisplay && - pMode1->HSyncStart == pMode2->HSyncStart && - pMode1->HSyncEnd == pMode2->HSyncEnd && - pMode1->HTotal == pMode2->HTotal && - pMode1->HSkew == pMode2->HSkew && - pMode1->VDisplay == pMode2->VDisplay && - pMode1->VSyncStart == pMode2->VSyncStart && - pMode1->VSyncEnd == pMode2->VSyncEnd && - pMode1->VTotal == pMode2->VTotal && - pMode1->VScan == pMode2->VScan && - pMode1->Flags == pMode2->Flags) - { - return TRUE; - } else { - return FALSE; - } -} - -/* exact copy of xf86Mode.c */ -static void -add(char **p, char *new) -{ - *p = xnfrealloc(*p, strlen(*p) + strlen(new) + 2); - strcat(*p, " "); - strcat(*p, new); -} - -/** - * Print out a modeline. - * - * Convenient VRefresh printing was added, though, compared to xf86Mode.c - */ -void -xf86PrintModeline(int scrnIndex,DisplayModePtr mode) -{ - char tmp[256]; - char *flags = xnfcalloc(1, 1); - - if (mode->HSkew) { - snprintf(tmp, 256, "hskew %i", mode->HSkew); - add(&flags, tmp); - } - if (mode->VScan) { - snprintf(tmp, 256, "vscan %i", mode->VScan); - add(&flags, tmp); - } - if (mode->Flags & V_INTERLACE) add(&flags, "interlace"); - if (mode->Flags & V_CSYNC) add(&flags, "composite"); - if (mode->Flags & V_DBLSCAN) add(&flags, "doublescan"); - if (mode->Flags & V_BCAST) add(&flags, "bcast"); - if (mode->Flags & V_PHSYNC) add(&flags, "+hsync"); - if (mode->Flags & V_NHSYNC) add(&flags, "-hsync"); - if (mode->Flags & V_PVSYNC) add(&flags, "+vsync"); - if (mode->Flags & V_NVSYNC) add(&flags, "-vsync"); - if (mode->Flags & V_PCSYNC) add(&flags, "+csync"); - if (mode->Flags & V_NCSYNC) add(&flags, "-csync"); -#if 0 - if (mode->Flags & V_CLKDIV2) add(&flags, "vclk/2"); -#endif - xf86DrvMsg(scrnIndex, X_INFO, - "Modeline \"%s\"x%.01f %6.2f %i %i %i %i %i %i %i %i%s " - "(%.01f kHz)\n", - mode->name, mode->VRefresh, mode->Clock/1000., mode->HDisplay, - mode->HSyncStart, mode->HSyncEnd, mode->HTotal, - mode->VDisplay, mode->VSyncStart, mode->VSyncEnd, - mode->VTotal, flags, xf86ModeHSync(mode)); - xfree(flags); -} -#endif /* XORG_VERSION_CURRENT <= 7.2.99.2 */ - -/** - * Marks as bad any modes with unsupported flags. - * - * \param modeList doubly-linked or circular list of modes. - * \param flags flags supported by the driver. - * - * \bug only V_INTERLACE and V_DBLSCAN are supported. Is that enough? - * - * This is not in xf86Modes.c, but would be part of the proposed new API. - */ -void -xf86ValidateModesFlags(ScrnInfoPtr pScrn, DisplayModePtr modeList, - int flags) -{ - DisplayModePtr mode; - - for (mode = modeList; mode != NULL; mode = mode->next) { - if (mode->Flags & V_INTERLACE && !(flags & V_INTERLACE)) - mode->status = MODE_NO_INTERLACE; - if (mode->Flags & V_DBLSCAN && !(flags & V_DBLSCAN)) - mode->status = MODE_NO_DBLESCAN; - } -} - -/** - * Marks as bad any modes extending beyond the given max X, Y, or pitch. - * - * \param modeList doubly-linked or circular list of modes. - * - * This is not in xf86Modes.c, but would be part of the proposed new API. - */ -void -xf86ValidateModesSize(ScrnInfoPtr pScrn, DisplayModePtr modeList, - int maxX, int maxY, int maxPitch) -{ - DisplayModePtr mode; - - for (mode = modeList; mode != NULL; mode = mode->next) { - if (maxPitch > 0 && mode->HDisplay > maxPitch) - mode->status = MODE_BAD_WIDTH; - - if (maxX > 0 && mode->HDisplay > maxX) - mode->status = MODE_VIRTUAL_X; - - if (maxY > 0 && mode->VDisplay > maxY) - mode->status = MODE_VIRTUAL_Y; - - if (mode->next == modeList) - break; - } -} - -/** - * Marks as bad any modes that aren't supported by the given monitor's - * hsync and vrefresh ranges. - * - * \param modeList doubly-linked or circular list of modes. - * - * This is not in xf86Modes.c, but would be part of the proposed new API. - */ -void -xf86ValidateModesSync(ScrnInfoPtr pScrn, DisplayModePtr modeList, - MonPtr mon) -{ - DisplayModePtr mode; - - for (mode = modeList; mode != NULL; mode = mode->next) { - Bool bad; - int i; - - bad = TRUE; - for (i = 0; i < mon->nHsync; i++) { - if (xf86ModeHSync(mode) >= mon->hsync[i].lo && - xf86ModeHSync(mode) <= mon->hsync[i].hi) - { - bad = FALSE; - } - } - if (bad) - mode->status = MODE_HSYNC; - - bad = TRUE; - for (i = 0; i < mon->nVrefresh; i++) { - if (xf86ModeVRefresh(mode) >= mon->vrefresh[i].lo && - xf86ModeVRefresh(mode) <= mon->vrefresh[i].hi) - { - bad = FALSE; - } - } - if (bad) - mode->status = MODE_VSYNC; - - if (mode->next == modeList) - break; - } -} - -/** - * Marks as bad any modes extending beyond outside of the given clock ranges. - * - * \param modeList doubly-linked or circular list of modes. - * \param min pointer to minimums of clock ranges - * \param max pointer to maximums of clock ranges - * \param n_ranges number of ranges. - * - * This is not in xf86Modes.c, but would be part of the proposed new API. - */ -void -xf86ValidateModesClocks(ScrnInfoPtr pScrn, DisplayModePtr modeList, - int *min, int *max, int n_ranges) -{ - DisplayModePtr mode; - int i; - - for (mode = modeList; mode != NULL; mode = mode->next) { - Bool good = FALSE; - for (i = 0; i < n_ranges; i++) { - if (mode->Clock >= min[i] && mode->Clock <= max[i]) { - good = TRUE; - break; - } - } - if (!good) - mode->status = MODE_CLOCK_RANGE; - } -} - -/** - * If the user has specified a set of mode names to use, mark as bad any modes - * not listed. - * - * The user mode names specified are prefixes to names of modes, so "1024x768" - * will match modes named "1024x768", "1024x768x75", "1024x768-good", but - * "1024x768x75" would only match "1024x768x75" from that list. - * - * MODE_BAD is used as the rejection flag, for lack of a better flag. - * - * \param modeList doubly-linked or circular list of modes. - * - * This is not in xf86Modes.c, but would be part of the proposed new API. - */ -void -xf86ValidateModesUserConfig(ScrnInfoPtr pScrn, DisplayModePtr modeList) -{ - DisplayModePtr mode; - - if (pScrn->display->modes[0] == NULL) - return; - - for (mode = modeList; mode != NULL; mode = mode->next) { - int i; - Bool good = FALSE; - - for (i = 0; pScrn->display->modes[i] != NULL; i++) { - if (strncmp(pScrn->display->modes[i], mode->name, - strlen(pScrn->display->modes[i])) == 0) { - good = TRUE; - break; - } - } - if (!good) - mode->status = MODE_BAD; - } -} - - -/** - * Frees any modes from the list with a status other than MODE_OK. - * - * \param modeList pointer to a doubly-linked or circular list of modes. - * \param verbose determines whether the reason for mode invalidation is - * printed. - * - * This is not in xf86Modes.c, but would be part of the proposed new API. - */ -void -xf86PruneInvalidModes(ScrnInfoPtr pScrn, DisplayModePtr *modeList, - Bool verbose) -{ - DisplayModePtr mode; - - for (mode = *modeList; mode != NULL;) { - DisplayModePtr next = mode->next, first = *modeList; - - if (mode->status != MODE_OK) { - if (verbose) { - char *type = ""; - if (mode->type & M_T_BUILTIN) - type = "built-in "; - else if (mode->type & M_T_DEFAULT) - type = "default "; - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Not using %smode \"%s\" (%s)\n", type, mode->name, - xf86ModeStatusToString(mode->status)); - } - xf86DeleteMode(modeList, mode); - } - - if (next == first) - break; - mode = next; - } -} - -/** - * Adds the new mode into the mode list, and returns the new list - * - * \param modes doubly-linked mode list. - */ -DisplayModePtr -xf86ModesAdd(DisplayModePtr modes, DisplayModePtr new) -{ - if (modes == NULL) - return new; - - if (new) { - DisplayModePtr mode = modes; - - while (mode->next) - mode = mode->next; - - mode->next = new; - new->prev = mode; - } - - return modes; -} - -/** - * Build a mode list from a list of config file modes - */ -static DisplayModePtr -xf86GetConfigModes (XF86ConfModeLinePtr conf_mode) -{ - DisplayModePtr head = NULL, prev = NULL, mode; - - for (; conf_mode; conf_mode = (XF86ConfModeLinePtr) conf_mode->list.next) - { - mode = xcalloc(1, sizeof(DisplayModeRec)); - if (!mode) - continue; - mode->name = xstrdup(conf_mode->ml_identifier); - if (!mode->name) - { - xfree (mode); - continue; - } - mode->type = 0; - mode->Clock = conf_mode->ml_clock; - mode->HDisplay = conf_mode->ml_hdisplay; - mode->HSyncStart = conf_mode->ml_hsyncstart; - mode->HSyncEnd = conf_mode->ml_hsyncend; - mode->HTotal = conf_mode->ml_htotal; - mode->VDisplay = conf_mode->ml_vdisplay; - mode->VSyncStart = conf_mode->ml_vsyncstart; - mode->VSyncEnd = conf_mode->ml_vsyncend; - mode->VTotal = conf_mode->ml_vtotal; - mode->Flags = conf_mode->ml_flags; - mode->HSkew = conf_mode->ml_hskew; - mode->VScan = conf_mode->ml_vscan; - - mode->prev = prev; - mode->next = NULL; - if (prev) - prev->next = mode; - else - head = mode; - prev = mode; - } - return head; -} - -/** - * Build a mode list from a monitor configuration - */ -DisplayModePtr -xf86GetMonitorModes (ScrnInfoPtr pScrn, XF86ConfMonitorPtr conf_monitor) -{ - DisplayModePtr modes = NULL; - XF86ConfModesLinkPtr modes_link; - - if (!conf_monitor) - return NULL; - - /* - * first we collect the mode lines from the UseModes directive - */ - for (modes_link = conf_monitor->mon_modes_sect_lst; - modes_link; - modes_link = modes_link->list.next) - { - /* If this modes link hasn't been resolved, go look it up now */ - if (!modes_link->ml_modes) - modes_link->ml_modes = xf86findModes (modes_link->ml_modes_str, - xf86configptr->conf_modes_lst); - if (modes_link->ml_modes) - modes = xf86ModesAdd (modes, - xf86GetConfigModes (modes_link->ml_modes->mon_modeline_lst)); - } - - return xf86ModesAdd (modes, - xf86GetConfigModes (conf_monitor->mon_modeline_lst)); -} - -/** - * Build a mode list containing all of the default modes - */ -DisplayModePtr -xf86GetDefaultModes (Bool interlaceAllowed, Bool doubleScanAllowed) -{ - DisplayModePtr head = NULL, prev = NULL, mode; - int i; - - for (i = 0; xf86DefaultModes[i].name != NULL; i++) - { - DisplayModePtr defMode = &xf86DefaultModes[i]; - - if (!interlaceAllowed && (defMode->Flags & V_INTERLACE)) - continue; - if (!doubleScanAllowed && (defMode->Flags & V_DBLSCAN)) - continue; - - mode = xalloc(sizeof(DisplayModeRec)); - if (!mode) - continue; - memcpy(mode,&xf86DefaultModes[i],sizeof(DisplayModeRec)); - mode->name = xstrdup(xf86DefaultModes[i].name); - if (!mode->name) - { - xfree (mode); - continue; - } - mode->prev = prev; - mode->next = NULL; - if (prev) - prev->next = mode; - else - head = mode; - prev = mode; - } - return head; -} diff --git a/src/i830_xf86Modes.h b/src/i830_xf86Modes.h deleted file mode 100644 index d032199d..00000000 --- a/src/i830_xf86Modes.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright © 2006 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Authors: - * Eric Anholt - * - */ - -#ifndef _I830_XF86MODES_H_ -#define _I830_XF86MODES_H_ -#include "xorgVersion.h" -#include "xf86Parser.h" -#include "i830_xf86Rename.h" - -double xf86ModeHSync(DisplayModePtr mode); -double xf86ModeVRefresh(DisplayModePtr mode); -DisplayModePtr xf86DuplicateMode(DisplayModePtr pMode); -DisplayModePtr xf86DuplicateModes(ScrnInfoPtr pScrn, - DisplayModePtr modeList); -void xf86SetModeDefaultName(DisplayModePtr mode); -void xf86SetModeCrtc(DisplayModePtr p, int adjustFlags); -Bool xf86ModesEqual(DisplayModePtr pMode1, DisplayModePtr pMode2); -void xf86PrintModeline(int scrnIndex,DisplayModePtr mode); -DisplayModePtr xf86ModesAdd(DisplayModePtr modes, DisplayModePtr new); - -DisplayModePtr xf86DDCGetModes(int scrnIndex, xf86MonPtr DDC); -DisplayModePtr xf86CVTMode(int HDisplay, int VDisplay, float VRefresh, - Bool Reduced, Bool Interlaced); - -void -xf86ValidateModesFlags(ScrnInfoPtr pScrn, DisplayModePtr modeList, - int flags); - -void -xf86ValidateModesClocks(ScrnInfoPtr pScrn, DisplayModePtr modeList, - int *min, int *max, int n_ranges); - -void -xf86ValidateModesSize(ScrnInfoPtr pScrn, DisplayModePtr modeList, - int maxX, int maxY, int maxPitch); - -void -xf86ValidateModesSync(ScrnInfoPtr pScrn, DisplayModePtr modeList, - MonPtr mon); - -void -xf86PruneInvalidModes(ScrnInfoPtr pScrn, DisplayModePtr *modeList, - Bool verbose); - -void -xf86ValidateModesFlags(ScrnInfoPtr pScrn, DisplayModePtr modeList, - int flags); - -void -xf86ValidateModesUserConfig(ScrnInfoPtr pScrn, DisplayModePtr modeList); - -DisplayModePtr -xf86GetMonitorModes (ScrnInfoPtr pScrn, XF86ConfMonitorPtr conf_monitor); - -DisplayModePtr -xf86GetDefaultModes (Bool interlaceAllowed, Bool doubleScanAllowed); - -#endif /* _I830_XF86MODES_H_ */ diff --git a/src/i830_xf86RandR12.c b/src/i830_xf86RandR12.c deleted file mode 100644 index 4ccbdad1..00000000 --- a/src/i830_xf86RandR12.c +++ /dev/null @@ -1,950 +0,0 @@ -/* $XdotOrg: xc/programs/Xserver/hw/xfree86/common/xf86RandR.c,v 1.3 2004/07/30 21:53:09 eich Exp $ */ -/* - * $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86RandR.c,v 1.7tsi Exp $ - * - * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that copyright - * notice and this permission notice appear in supporting documentation, and - * that the name of the copyright holders not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. The copyright holders make no representations - * about the suitability of this software for any purpose. It is provided "as - * is" without express or implied warranty. - * - * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "xf86.h" -#include "os.h" -#include "mibank.h" -#include "globals.h" -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86DDC.h" -#include "mipointer.h" -#include "windowstr.h" -#include -#include - -#include "i830_xf86Crtc.h" -#include "i830_xf86RandR12.h" - -typedef struct _xf86RandR12Info { - int virtualX; - int virtualY; - int mmWidth; - int mmHeight; - int maxX; - int maxY; - Rotation rotation; /* current mode */ - Rotation supported_rotations; /* driver supported */ -} XF86RandRInfoRec, *XF86RandRInfoPtr; - -#ifdef RANDR_12_INTERFACE -static Bool xf86RandR12Init12 (ScreenPtr pScreen); -static Bool xf86RandR12CreateScreenResources12 (ScreenPtr pScreen); -#endif - -static int xf86RandR12Index; -static int xf86RandR12Generation; - -#define XF86RANDRINFO(p) \ - ((XF86RandRInfoPtr)(p)->devPrivates[xf86RandR12Index].ptr) - -static int -xf86RandR12ModeRefresh (DisplayModePtr mode) -{ - if (mode->VRefresh) - return (int) (mode->VRefresh + 0.5); - else - return (int) (mode->Clock * 1000.0 / mode->HTotal / mode->VTotal + 0.5); -} - -static Bool -xf86RandR12GetInfo (ScreenPtr pScreen, Rotation *rotations) -{ - RRScreenSizePtr pSize; - ScrnInfoPtr scrp = XF86SCRNINFO(pScreen); - XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); - DisplayModePtr mode; - int refresh0 = 60; - int maxX = 0, maxY = 0; - - *rotations = randrp->supported_rotations; - - if (randrp->virtualX == -1 || randrp->virtualY == -1) - { - randrp->virtualX = scrp->virtualX; - randrp->virtualY = scrp->virtualY; - } - - /* Re-probe the outputs for new monitors or modes */ - xf86ProbeOutputModes (scrp, 0, 0); - xf86SetScrnInfoModes (scrp); - xf86DiDGAReInit (pScreen); - - for (mode = scrp->modes; ; mode = mode->next) - { - int refresh = xf86RandR12ModeRefresh (mode); - if (randrp->maxX == 0 || randrp->maxY == 0) - { - if (maxX < mode->HDisplay) - maxX = mode->HDisplay; - if (maxY < mode->VDisplay) - maxY = mode->VDisplay; - } - if (mode == scrp->modes) - refresh0 = refresh; - pSize = RRRegisterSize (pScreen, - mode->HDisplay, mode->VDisplay, - randrp->mmWidth, randrp->mmHeight); - if (!pSize) - return FALSE; - RRRegisterRate (pScreen, pSize, refresh); - - if (xf86ModesEqual(mode, scrp->currentMode) && - mode->HDisplay == scrp->virtualX && - mode->VDisplay == scrp->virtualY) - { - RRSetCurrentConfig (pScreen, randrp->rotation, refresh, pSize); - } - if (mode->next == scrp->modes) - break; - } - - if (randrp->maxX == 0 || randrp->maxY == 0) - { - randrp->maxX = maxX; - randrp->maxY = maxY; - } - - if (scrp->currentMode->HDisplay != randrp->virtualX || - scrp->currentMode->VDisplay != randrp->virtualY) - { - pSize = RRRegisterSize (pScreen, - randrp->virtualX, randrp->virtualY, - randrp->mmWidth, - randrp->mmHeight); - if (!pSize) - return FALSE; - RRRegisterRate (pScreen, pSize, refresh0); - if (scrp->virtualX == randrp->virtualX && - scrp->virtualY == randrp->virtualY) - { - RRSetCurrentConfig (pScreen, randrp->rotation, refresh0, pSize); - } - } - - return TRUE; -} - -static Bool -xf86RandR12SetMode (ScreenPtr pScreen, - DisplayModePtr mode, - Bool useVirtual, - int mmWidth, - int mmHeight) -{ - ScrnInfoPtr scrp = XF86SCRNINFO(pScreen); - XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); - int oldWidth = pScreen->width; - int oldHeight = pScreen->height; - int oldmmWidth = pScreen->mmWidth; - int oldmmHeight = pScreen->mmHeight; - WindowPtr pRoot = WindowTable[pScreen->myNum]; - DisplayModePtr currentMode = NULL; - Bool ret = TRUE; - PixmapPtr pspix = NULL; - - if (pRoot) - (*scrp->EnableDisableFBAccess) (pScreen->myNum, FALSE); - if (useVirtual) - { - scrp->virtualX = randrp->virtualX; - scrp->virtualY = randrp->virtualY; - } - else - { - scrp->virtualX = mode->HDisplay; - scrp->virtualY = mode->VDisplay; - } - - if(randrp->rotation & (RR_Rotate_90 | RR_Rotate_270)) - { - /* If the screen is rotated 90 or 270 degrees, swap the sizes. */ - pScreen->width = scrp->virtualY; - pScreen->height = scrp->virtualX; - pScreen->mmWidth = mmHeight; - pScreen->mmHeight = mmWidth; - } - else - { - pScreen->width = scrp->virtualX; - pScreen->height = scrp->virtualY; - pScreen->mmWidth = mmWidth; - pScreen->mmHeight = mmHeight; - } - if (scrp->currentMode == mode) { - /* Save current mode */ - currentMode = scrp->currentMode; - /* Reset, just so we ensure the drivers SwitchMode is called */ - scrp->currentMode = NULL; - } - /* - * We know that if the driver failed to SwitchMode to the rotated - * version, then it should revert back to it's prior mode. - */ - if (!xf86SwitchMode (pScreen, mode)) - { - ret = FALSE; - scrp->virtualX = pScreen->width = oldWidth; - scrp->virtualY = pScreen->height = oldHeight; - pScreen->mmWidth = oldmmWidth; - pScreen->mmHeight = oldmmHeight; - scrp->currentMode = currentMode; - } - /* - * Get the new Screen pixmap ptr as SwitchMode might have called - * ModifyPixmapHeader and xf86EnableDisableFBAccess will put it back... - * Unfortunately. - */ - pspix = (*pScreen->GetScreenPixmap) (pScreen); - if (pspix->devPrivate.ptr) - scrp->pixmapPrivate = pspix->devPrivate; - - /* - * Make sure the layout is correct - */ - xf86ReconfigureLayout(); - - /* - * Make sure the whole screen is visible - */ - xf86SetViewport (pScreen, pScreen->width, pScreen->height); - xf86SetViewport (pScreen, 0, 0); - if (pRoot) - (*scrp->EnableDisableFBAccess) (pScreen->myNum, TRUE); - return ret; -} - -Bool -xf86RandR12SetConfig (ScreenPtr pScreen, - Rotation rotation, - int rate, - RRScreenSizePtr pSize) -{ - ScrnInfoPtr scrp = XF86SCRNINFO(pScreen); - XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); - DisplayModePtr mode; - int px, py; - Bool useVirtual = FALSE; - int maxX = 0, maxY = 0; - Rotation oldRotation = randrp->rotation; - - randrp->rotation = rotation; - - if (randrp->virtualX == -1 || randrp->virtualY == -1) - { - randrp->virtualX = scrp->virtualX; - randrp->virtualY = scrp->virtualY; - } - - miPointerPosition (&px, &py); - for (mode = scrp->modes; ; mode = mode->next) - { - if (randrp->maxX == 0 || randrp->maxY == 0) - { - if (maxX < mode->HDisplay) - maxX = mode->HDisplay; - if (maxY < mode->VDisplay) - maxY = mode->VDisplay; - } - if (mode->HDisplay == pSize->width && - mode->VDisplay == pSize->height && - (rate == 0 || xf86RandR12ModeRefresh (mode) == rate)) - break; - if (mode->next == scrp->modes) - { - if (pSize->width == randrp->virtualX && - pSize->height == randrp->virtualY) - { - mode = scrp->modes; - useVirtual = TRUE; - break; - } - if (randrp->maxX == 0 || randrp->maxY == 0) - { - randrp->maxX = maxX; - randrp->maxY = maxY; - } - return FALSE; - } - } - - if (randrp->maxX == 0 || randrp->maxY == 0) - { - randrp->maxX = maxX; - randrp->maxY = maxY; - } - - if (!xf86RandR12SetMode (pScreen, mode, useVirtual, pSize->mmWidth, - pSize->mmHeight)) { - randrp->rotation = oldRotation; - return FALSE; - } - - /* - * Move the cursor back where it belongs; SwitchMode repositions it - */ - if (pScreen == miPointerCurrentScreen ()) - { - px = (px >= pScreen->width ? (pScreen->width - 1) : px); - py = (py >= pScreen->height ? (pScreen->height - 1) : py); - - xf86SetViewport(pScreen, px, py); - - (*pScreen->SetCursorPosition) (pScreen, px, py, FALSE); - } - - return TRUE; -} - -static Bool -xf86RandR12ScreenSetSize (ScreenPtr pScreen, - CARD16 width, - CARD16 height, - CARD32 mmWidth, - CARD32 mmHeight) -{ - XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); - ScrnInfoPtr pScrn = XF86SCRNINFO(pScreen); - WindowPtr pRoot = WindowTable[pScreen->myNum]; - Bool ret = TRUE; - - if (randrp->virtualX == -1 || randrp->virtualY == -1) - { - randrp->virtualX = pScrn->virtualX; - randrp->virtualY = pScrn->virtualY; - } - if (pRoot) - (*pScrn->EnableDisableFBAccess) (pScreen->myNum, FALSE); - pScrn->virtualX = width; - pScrn->virtualY = height; - - pScreen->width = pScrn->virtualX; - pScreen->height = pScrn->virtualY; - pScreen->mmWidth = mmWidth; - pScreen->mmHeight = mmHeight; - - xf86SetViewport (pScreen, pScreen->width-1, pScreen->height-1); - xf86SetViewport (pScreen, 0, 0); - if (pRoot) - (*pScrn->EnableDisableFBAccess) (pScreen->myNum, TRUE); -#if RANDR_12_INTERFACE - if (WindowTable[pScreen->myNum]) - RRScreenSizeNotify (pScreen); -#endif - return ret; -} - -Rotation -xf86RandR12GetRotation(ScreenPtr pScreen) -{ - XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); - - return randrp->rotation; -} - -Bool -xf86RandR12CreateScreenResources (ScreenPtr pScreen) -{ - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); - XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); - int c; - int width, height; - int mmWidth, mmHeight; -#ifdef PANORAMIX - /* XXX disable RandR when using Xinerama */ - if (!noPanoramiXExtension) - return TRUE; -#endif - - /* - * Compute size of screen - */ - width = 0; height = 0; - for (c = 0; c < config->num_crtc; c++) - { - xf86CrtcPtr crtc = config->crtc[c]; - int crtc_width = crtc->x + crtc->mode.HDisplay; - int crtc_height = crtc->y + crtc->mode.VDisplay; - - if (crtc->enabled && crtc_width > width) - width = crtc_width; - if (crtc->enabled && crtc_height > height) - height = crtc_height; - } - - if (width && height) - { - /* - * Compute physical size of screen - */ - if (monitorResolution) - { - mmWidth = width * 25.4 / monitorResolution; - mmHeight = height * 25.4 / monitorResolution; - } - else - { - mmWidth = pScreen->mmWidth; - mmHeight = pScreen->mmHeight; - } - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Setting screen physical size to %d x %d\n", - mmWidth, mmHeight); - xf86RandR12ScreenSetSize (pScreen, - width, - height, - mmWidth, - mmHeight); - } - - if (randrp->virtualX == -1 || randrp->virtualY == -1) - { - randrp->virtualX = pScrn->virtualX; - randrp->virtualY = pScrn->virtualY; - } -#if RANDR_12_INTERFACE - if (xf86RandR12CreateScreenResources12 (pScreen)) - return TRUE; -#endif - return TRUE; -} - - -Bool -xf86RandR12Init (ScreenPtr pScreen) -{ - rrScrPrivPtr rp; - XF86RandRInfoPtr randrp; - -#ifdef PANORAMIX - /* XXX disable RandR when using Xinerama */ - if (!noPanoramiXExtension) - return TRUE; -#endif - if (xf86RandR12Generation != serverGeneration) - { - xf86RandR12Index = AllocateScreenPrivateIndex(); - xf86RandR12Generation = serverGeneration; - } - - randrp = xalloc (sizeof (XF86RandRInfoRec)); - if (!randrp) - return FALSE; - - if (!RRScreenInit(pScreen)) - { - xfree (randrp); - return FALSE; - } - rp = rrGetScrPriv(pScreen); - rp->rrGetInfo = xf86RandR12GetInfo; - rp->rrSetConfig = xf86RandR12SetConfig; - - randrp->virtualX = -1; - randrp->virtualY = -1; - randrp->mmWidth = pScreen->mmWidth; - randrp->mmHeight = pScreen->mmHeight; - - randrp->rotation = RR_Rotate_0; /* initial rotated mode */ - - randrp->supported_rotations = RR_Rotate_0; - - randrp->maxX = randrp->maxY = 0; - - pScreen->devPrivates[xf86RandR12Index].ptr = randrp; - -#if RANDR_12_INTERFACE - if (!xf86RandR12Init12 (pScreen)) - return FALSE; -#endif - return TRUE; -} - -void -xf86RandR12SetRotations (ScreenPtr pScreen, Rotation rotations) -{ - XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); - int c; - - randrp->supported_rotations = rotations; - -#if RANDR_12_INTERFACE - for (c = 0; c < config->num_crtc; c++) { - xf86CrtcPtr crtc = config->crtc[c]; - - RRCrtcSetRotations (crtc->randr_crtc, rotations); - } -#endif -} - -void -xf86RandR12GetOriginalVirtualSize(ScrnInfoPtr pScrn, int *x, int *y) -{ - ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex]; - - if (xf86RandR12Generation != serverGeneration || - XF86RANDRINFO(pScreen)->virtualX == -1) - { - *x = pScrn->virtualX; - *y = pScrn->virtualY; - } else { - XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); - - *x = randrp->virtualX; - *y = randrp->virtualY; - } -} - -#if RANDR_12_INTERFACE -static Bool -xf86RandR12CrtcNotify (RRCrtcPtr randr_crtc) -{ - ScreenPtr pScreen = randr_crtc->pScreen; - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); - RRModePtr randr_mode = NULL; - int x; - int y; - Rotation rotation; - int numOutputs; - RROutputPtr *randr_outputs; - RROutputPtr randr_output; - xf86CrtcPtr crtc = randr_crtc->devPrivate; - xf86OutputPtr output; - int i, j; - DisplayModePtr mode = &crtc->mode; - Bool ret; - - randr_outputs = ALLOCATE_LOCAL(config->num_output * sizeof (RROutputPtr)); - if (!randr_outputs) - return FALSE; - x = crtc->x; - y = crtc->y; - rotation = crtc->rotation; - numOutputs = 0; - randr_mode = NULL; - for (i = 0; i < config->num_output; i++) - { - output = config->output[i]; - if (output->crtc == crtc) - { - randr_output = output->randr_output; - randr_outputs[numOutputs++] = randr_output; - /* - * We make copies of modes, so pointer equality - * isn't sufficient - */ - for (j = 0; j < randr_output->numModes; j++) - { - DisplayModePtr outMode = randr_output->modes[j]->devPrivate; - if (xf86ModesEqual(mode, outMode)) - { - randr_mode = randr_output->modes[j]; - break; - } - } - } - } - ret = RRCrtcNotify (randr_crtc, randr_mode, x, y, - rotation, numOutputs, randr_outputs); - DEALLOCATE_LOCAL(randr_outputs); - return ret; -} - -static Bool -xf86RandR12CrtcSet (ScreenPtr pScreen, - RRCrtcPtr randr_crtc, - RRModePtr randr_mode, - int x, - int y, - Rotation rotation, - int num_randr_outputs, - RROutputPtr *randr_outputs) -{ - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); - xf86CrtcPtr crtc = randr_crtc->devPrivate; - DisplayModePtr mode = randr_mode ? randr_mode->devPrivate : NULL; - Bool changed = FALSE; - int o, ro; - xf86CrtcPtr *save_crtcs; - Bool save_enabled = crtc->enabled; - - save_crtcs = ALLOCATE_LOCAL(config->num_crtc * sizeof (xf86CrtcPtr)); - if ((mode != NULL) != crtc->enabled) - changed = TRUE; - else if (mode && !xf86ModesEqual (&crtc->mode, mode)) - changed = TRUE; - - if (rotation != crtc->rotation) - changed = TRUE; - - if (x != crtc->x || y != crtc->y) - changed = TRUE; - for (o = 0; o < config->num_output; o++) - { - xf86OutputPtr output = config->output[o]; - xf86CrtcPtr new_crtc; - - save_crtcs[o] = output->crtc; - - if (output->crtc == crtc) - new_crtc = NULL; - else - new_crtc = output->crtc; - for (ro = 0; ro < num_randr_outputs; ro++) - if (output->randr_output == randr_outputs[ro]) - { - new_crtc = crtc; - break; - } - if (new_crtc != output->crtc) - { - changed = TRUE; - output->crtc = new_crtc; - } - } - /* XXX need device-independent mode setting code through an API */ - if (changed) - { - crtc->enabled = mode != NULL; - - if (mode) - { - if (!xf86CrtcSetMode (crtc, mode, rotation, x, y)) - { - crtc->enabled = save_enabled; - for (o = 0; o < config->num_output; o++) - { - xf86OutputPtr output = config->output[o]; - output->crtc = save_crtcs[o]; - } - DEALLOCATE_LOCAL(save_crtcs); - return FALSE; - } - /* - * Save the last successful setting for EnterVT - */ - crtc->desiredMode = *mode; - crtc->desiredRotation = rotation; - crtc->desiredX = x; - crtc->desiredY = y; - } - xf86DisableUnusedFunctions (pScrn); - } - DEALLOCATE_LOCAL(save_crtcs); - return xf86RandR12CrtcNotify (randr_crtc); -} - -static Bool -xf86RandR12CrtcSetGamma (ScreenPtr pScreen, - RRCrtcPtr randr_crtc) -{ - xf86CrtcPtr crtc = randr_crtc->devPrivate; - - if (crtc->funcs->gamma_set == NULL) - return FALSE; - - crtc->funcs->gamma_set(crtc, randr_crtc->gammaRed, randr_crtc->gammaGreen, - randr_crtc->gammaBlue, randr_crtc->gammaSize); - - return TRUE; -} - -static Bool -xf86RandR12OutputSetProperty (ScreenPtr pScreen, - RROutputPtr randr_output, - Atom property, - RRPropertyValuePtr value) -{ - xf86OutputPtr output = randr_output->devPrivate; - - /* If we don't have any property handler, then we don't care what the - * user is setting properties to. - */ - if (output->funcs->set_property == NULL) - return TRUE; - - return output->funcs->set_property(output, property, value); -} - -/** - * Given a list of xf86 modes and a RandR Output object, construct - * RandR modes and assign them to the output - */ -static Bool -xf86RROutputSetModes (RROutputPtr randr_output, DisplayModePtr modes) -{ - DisplayModePtr mode; - RRModePtr *rrmodes = NULL; - int nmode = 0; - int npreferred = 0; - Bool ret = TRUE; - int pref; - - for (mode = modes; mode; mode = mode->next) - nmode++; - - if (nmode) { - rrmodes = xalloc (nmode * sizeof (RRModePtr)); - - if (!rrmodes) - return FALSE; - nmode = 0; - - for (pref = 1; pref >= 0; pref--) { - for (mode = modes; mode; mode = mode->next) { - if ((pref != 0) == ((mode->type & M_T_PREFERRED) != 0)) { - xRRModeInfo modeInfo; - RRModePtr rrmode; - - modeInfo.nameLength = strlen (mode->name); - modeInfo.width = mode->HDisplay; - modeInfo.dotClock = mode->Clock * 1000; - modeInfo.hSyncStart = mode->HSyncStart; - modeInfo.hSyncEnd = mode->HSyncEnd; - modeInfo.hTotal = mode->HTotal; - modeInfo.hSkew = mode->HSkew; - - modeInfo.height = mode->VDisplay; - modeInfo.vSyncStart = mode->VSyncStart; - modeInfo.vSyncEnd = mode->VSyncEnd; - modeInfo.vTotal = mode->VTotal; - modeInfo.modeFlags = mode->Flags; - - rrmode = RRModeGet (&modeInfo, mode->name); - if (rrmode) { - rrmode->devPrivate = mode; - rrmodes[nmode++] = rrmode; - npreferred += pref; - } - } - } - } - } - - ret = RROutputSetModes (randr_output, rrmodes, nmode, npreferred); - xfree (rrmodes); - return ret; -} - -/* - * Mirror the current mode configuration to RandR - */ -static Bool -xf86RandR12SetInfo12 (ScreenPtr pScreen) -{ - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); - RROutputPtr *clones; - RRCrtcPtr *crtcs; - int ncrtc; - int o, c, l; - RRCrtcPtr randr_crtc; - int nclone; - - clones = ALLOCATE_LOCAL(config->num_output * sizeof (RROutputPtr)); - crtcs = ALLOCATE_LOCAL (config->num_crtc * sizeof (RRCrtcPtr)); - for (o = 0; o < config->num_output; o++) - { - xf86OutputPtr output = config->output[o]; - - ncrtc = 0; - for (c = 0; c < config->num_crtc; c++) - if (output->possible_crtcs & (1 << c)) - crtcs[ncrtc++] = config->crtc[c]->randr_crtc; - - if (output->crtc) - randr_crtc = output->crtc->randr_crtc; - else - randr_crtc = NULL; - - if (!RROutputSetCrtcs (output->randr_output, crtcs, ncrtc)) - { - DEALLOCATE_LOCAL (crtcs); - DEALLOCATE_LOCAL (clones); - return FALSE; - } - - RROutputSetCrtc (output->randr_output, randr_crtc); - RROutputSetPhysicalSize(output->randr_output, - output->mm_width, - output->mm_height); - xf86RROutputSetModes (output->randr_output, output->probed_modes); - - switch (output->status) { - case XF86OutputStatusConnected: - RROutputSetConnection (output->randr_output, RR_Connected); - break; - case XF86OutputStatusDisconnected: - RROutputSetConnection (output->randr_output, RR_Disconnected); - break; - case XF86OutputStatusUnknown: - RROutputSetConnection (output->randr_output, RR_UnknownConnection); - break; - } - - RROutputSetSubpixelOrder (output->randr_output, output->subpixel_order); - - /* - * Valid clones - */ - nclone = 0; - for (l = 0; l < config->num_output; l++) - { - xf86OutputPtr clone = config->output[l]; - - if (l != o && (output->possible_clones & (1 << l))) - clones[nclone++] = clone->randr_output; - } - if (!RROutputSetClones (output->randr_output, clones, nclone)) - { - DEALLOCATE_LOCAL (crtcs); - DEALLOCATE_LOCAL (clones); - return FALSE; - } - } - DEALLOCATE_LOCAL (crtcs); - DEALLOCATE_LOCAL (clones); - return TRUE; -} - - - -/* - * Query the hardware for the current state, then mirror - * that to RandR - */ -static Bool -xf86RandR12GetInfo12 (ScreenPtr pScreen, Rotation *rotations) -{ - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - - xf86ProbeOutputModes (pScrn, 0, 0); - xf86SetScrnInfoModes (pScrn); - xf86DiDGAReInit (pScreen); - return xf86RandR12SetInfo12 (pScreen); -} - -static Bool -xf86RandR12CreateObjects12 (ScreenPtr pScreen) -{ - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); - int c; - int o; - - if (!RRInit ()) - return FALSE; - - /* - * Configure crtcs - */ - for (c = 0; c < config->num_crtc; c++) - { - xf86CrtcPtr crtc = config->crtc[c]; - - crtc->randr_crtc = RRCrtcCreate (crtc); - RRCrtcAttachScreen (crtc->randr_crtc, pScreen); - RRCrtcGammaSetSize (crtc->randr_crtc, 256); - } - /* - * Configure outputs - */ - for (o = 0; o < config->num_output; o++) - { - xf86OutputPtr output = config->output[o]; - - output->randr_output = RROutputCreate (output->name, - strlen (output->name), - output); - RROutputAttachScreen (output->randr_output, pScreen); - - if (output->funcs->create_resources != NULL) - output->funcs->create_resources(output); - } - return TRUE; -} - -static Bool -xf86RandR12CreateScreenResources12 (ScreenPtr pScreen) -{ - int c; - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); - xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); - - for (c = 0; c < config->num_crtc; c++) - xf86RandR12CrtcNotify (config->crtc[c]->randr_crtc); - - - RRScreenSetSizeRange (pScreen, 320, 240, - randrp->virtualX, randrp->virtualY); - return TRUE; -} - -static void -xf86RandR12PointerMoved (int scrnIndex, int x, int y) -{ -} - -static Bool -xf86RandR12Init12 (ScreenPtr pScreen) -{ - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - rrScrPrivPtr rp = rrGetScrPriv(pScreen); - - rp->rrGetInfo = xf86RandR12GetInfo12; - rp->rrScreenSetSize = xf86RandR12ScreenSetSize; - rp->rrCrtcSet = xf86RandR12CrtcSet; - rp->rrCrtcSetGamma = xf86RandR12CrtcSetGamma; - rp->rrOutputSetProperty = xf86RandR12OutputSetProperty; - rp->rrSetConfig = NULL; - pScrn->PointerMoved = xf86RandR12PointerMoved; - if (!xf86RandR12CreateObjects12 (pScreen)) - return FALSE; - - /* - * Configure output modes - */ - if (!xf86RandR12SetInfo12 (pScreen)) - return FALSE; - return TRUE; -} - -#endif - -Bool -xf86RandR12PreInit (ScrnInfoPtr pScrn) -{ - return TRUE; -} diff --git a/src/i830_xf86RandR12.h b/src/i830_xf86RandR12.h deleted file mode 100644 index 8a4668b4..00000000 --- a/src/i830_xf86RandR12.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright © 2006 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that copyright - * notice and this permission notice appear in supporting documentation, and - * that the name of the copyright holders not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. The copyright holders make no representations - * about the suitability of this software for any purpose. It is provided "as - * is" without express or implied warranty. - * - * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#ifndef _XF86_RANDR_H_ -#define _XF86_RANDR_H_ -#include -#include - -Bool xf86RandR12CreateScreenResources (ScreenPtr pScreen); -Bool xf86RandR12Init(ScreenPtr pScreen); -void xf86RandR12SetRotations (ScreenPtr pScreen, Rotation rotation); -Bool xf86RandR12SetConfig(ScreenPtr pScreen, Rotation rotation, int rate, - RRScreenSizePtr pSize); -Rotation xf86RandR12GetRotation(ScreenPtr pScreen); -void xf86RandR12GetOriginalVirtualSize(ScrnInfoPtr pScrn, int *x, int *y); -Bool xf86RandR12PreInit (ScrnInfoPtr pScrn); - -#endif /* _XF86_RANDR_H_ */ diff --git a/src/i830_xf86Rename.h b/src/i830_xf86Rename.h deleted file mode 100644 index a00253d5..00000000 --- a/src/i830_xf86Rename.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright © 2006 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that copyright - * notice and this permission notice appear in supporting documentation, and - * that the name of the copyright holders not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. The copyright holders make no representations - * about the suitability of this software for any purpose. It is provided "as - * is" without express or implied warranty. - * - * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#ifndef _XF86RENAME_H_ -#define _XF86RENAME_H_ - -#include "local_xf86Rename.h" - -#define xf86CrtcConfigInit XF86NAME(xf86CrtcConfigInit) -#define xf86CrtcConfigPrivateIndex XF86NAME(xf86CrtcConfigPrivateIndex) -#define xf86CrtcCreate XF86NAME(xf86CrtcCreate) -#define xf86CrtcDestroy XF86NAME(xf86CrtcDestroy) -#define xf86CrtcInUse XF86NAME(xf86CrtcInUse) -#define xf86CrtcRotate XF86NAME(xf86CrtcRotate) -#define xf86CrtcSetMode XF86NAME(xf86CrtcSetMode) -#define xf86CrtcSetSizeRange XF86NAME(xf86CrtcSetSizeRange) -#define xf86CVTMode XF86NAME(xf86CVTMode) -#define xf86DisableUnusedFunctions XF86NAME(xf86DisableUnusedFunctions) -#define xf86DPMSSet XF86NAME(xf86DPMSSet) -#define xf86DuplicateMode XF86NAME(xf86DuplicateMode) -#define xf86DuplicateModes XF86NAME(xf86DuplicateModes) -#define xf86GetDefaultModes XF86NAME(xf86GetDefaultModes) -#define xf86GetMonitorModes XF86NAME(xf86GetMonitorModes) -#define xf86InitialConfiguration XF86NAME(xf86InitialConfiguration) -#define xf86ModeHSync XF86NAME(xf86ModeHSync) -#define xf86ModesAdd XF86NAME(xf86ModesAdd) -#define xf86ModesEqual XF86NAME(xf86ModesEqual) -#define xf86ModeVRefresh XF86NAME(xf86ModeVRefresh) -#define xf86OutputCreate XF86NAME(xf86OutputCreate) -#define xf86OutputDestroy XF86NAME(xf86OutputDestroy) -#define xf86OutputGetEDID XF86NAME(xf86OutputGetEDID) -#define xf86OutputGetEDIDModes XF86NAME(xf86OutputGetEDIDModes) -#define xf86OutputRename XF86NAME(xf86OutputRename) -#define xf86OutputSetEDID XF86NAME(xf86OutputSetEDID) -#define xf86PrintModeline XF86NAME(xf86PrintModeline) -#define xf86ProbeOutputModes XF86NAME(xf86ProbeOutputModes) -#define xf86PruneInvalidModes XF86NAME(xf86PruneInvalidModes) -#define xf86SetModeCrtc XF86NAME(xf86SetModeCrtc) -#define xf86SetModeDefaultName XF86NAME(xf86SetModeDefaultName) -#define xf86SetScrnInfoModes XF86NAME(xf86SetScrnInfoModes) -#define xf86ValidateModesClocks XF86NAME(xf86ValidateModesClocks) -#define xf86ValidateModesFlags XF86NAME(xf86ValidateModesFlags) -#define xf86ValidateModesSize XF86NAME(xf86ValidateModesSize) -#define xf86ValidateModesSync XF86NAME(xf86ValidateModesSync) -#define xf86ValidateModesUserConfig XF86NAME(xf86ValidateModesUserConfig) -#define xf86DiDGAInit XF86NAME(xf86DiDGAInit) -#define xf86DiDGAReInit XF86NAME(xf86DiDGAReInit) -#define xf86DDCGetModes XF86NAME(xf86DDCGetModes) -#define xf86RandR12CreateScreenResources XF86NAME(xf86RandR12CreateScreenResources) -#define xf86RandR12GetOriginalVirtualSize XF86NAME(xf86RandR12GetOriginalVirtualSize) -#define xf86RandR12GetRotation XF86NAME(xf86RandR12GetRotation) -#define xf86RandR12Init XF86NAME(xf86RandR12Init) -#define xf86RandR12PreInit XF86NAME(xf86RandR12PreInit) -#define xf86RandR12SetConfig XF86NAME(xf86RandR12SetConfig) -#define xf86RandR12SetRotations XF86NAME(xf86RandR12SetRotations) -#define xf86SaveScreen XF86NAME(xf86SaveScreen) - -#endif /* _XF86RENAME_H_ */ diff --git a/src/i830_xf86Rotate.c b/src/i830_xf86Rotate.c deleted file mode 100644 index 8240f670..00000000 --- a/src/i830_xf86Rotate.c +++ /dev/null @@ -1,402 +0,0 @@ -/* - * Copyright © 2006 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that copyright - * notice and this permission notice appear in supporting documentation, and - * that the name of the copyright holders not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. The copyright holders make no representations - * about the suitability of this software for any purpose. It is provided "as - * is" without express or implied warranty. - * - * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include - -#include "xf86.h" -#include "xf86DDC.h" -#include "fb.h" -#include "windowstr.h" -#include "i830_xf86Crtc.h" -#include "i830_xf86Modes.h" -#include "i830_xf86RandR12.h" -#include "X11/extensions/render.h" -#define DPMS_SERVER -#include "X11/extensions/dpms.h" -#include "X11/Xatom.h" - -static int -mode_height (DisplayModePtr mode, Rotation rotation) -{ - switch (rotation & 0xf) { - case RR_Rotate_0: - case RR_Rotate_180: - return mode->VDisplay; - case RR_Rotate_90: - case RR_Rotate_270: - return mode->HDisplay; - default: - return 0; - } -} - -static int -mode_width (DisplayModePtr mode, Rotation rotation) -{ - switch (rotation & 0xf) { - case RR_Rotate_0: - case RR_Rotate_180: - return mode->HDisplay; - case RR_Rotate_90: - case RR_Rotate_270: - return mode->VDisplay; - default: - return 0; - } -} - -/* borrowed from composite extension, move to Render and publish? */ - -static VisualPtr -compGetWindowVisual (WindowPtr pWin) -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - VisualID vid = wVisual (pWin); - int i; - - for (i = 0; i < pScreen->numVisuals; i++) - if (pScreen->visuals[i].vid == vid) - return &pScreen->visuals[i]; - return 0; -} - -static PictFormatPtr -compWindowFormat (WindowPtr pWin) -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - - return PictureMatchVisual (pScreen, pWin->drawable.depth, - compGetWindowVisual (pWin)); -} - -static void -xf86RotateBox (BoxPtr dst, BoxPtr src, Rotation rotation, - int dest_width, int dest_height) -{ - switch (rotation & 0xf) { - default: - case RR_Rotate_0: - *dst = *src; - break; - case RR_Rotate_90: - dst->x1 = src->y1; - dst->y1 = dest_height - src->x2; - dst->x2 = src->y2; - dst->y2 = dest_height - src->x1; - break; - case RR_Rotate_180: - dst->x1 = dest_width - src->x2; - dst->y1 = dest_height - src->y2; - dst->x2 = dest_width - src->x1; - dst->y2 = dest_height - src->y1; - break; - case RR_Rotate_270: - dst->x1 = dest_width - src->y2; - dst->y1 = src->x1; - dst->y2 = src->x2; - dst->x2 = dest_width - src->y1; - break; - } - if (rotation & RR_Reflect_X) { - int x1 = dst->x1; - dst->x1 = dest_width - dst->x2; - dst->x2 = dest_width - x1; - } - if (rotation & RR_Reflect_Y) { - int y1 = dst->y1; - dst->y1 = dest_height - dst->y2; - dst->y2 = dest_height - y1; - } -} - -static void -xf86RotateCrtcRedisplay (xf86CrtcPtr crtc, RegionPtr region) -{ - ScrnInfoPtr scrn = crtc->scrn; - ScreenPtr screen = scrn->pScreen; - WindowPtr root = WindowTable[screen->myNum]; - PixmapPtr dst_pixmap = crtc->rotatedPixmap; - PictFormatPtr format = compWindowFormat (WindowTable[screen->myNum]); - int error; - PicturePtr src, dst; - PictTransform transform; - int n = REGION_NUM_RECTS(region); - BoxPtr b = REGION_RECTS(region); - XID include_inferiors = IncludeInferiors; - - src = CreatePicture (None, - &root->drawable, - format, - CPSubwindowMode, - &include_inferiors, - serverClient, - &error); - if (!src) { - ErrorF("couldn't create src pict\n"); - return; - } - dst = CreatePicture (None, - &dst_pixmap->drawable, - format, - 0L, - NULL, - serverClient, - &error); - if (!dst) { - ErrorF("couldn't create src pict\n"); - return; - } - - memset (&transform, '\0', sizeof (transform)); - transform.matrix[2][2] = IntToxFixed(1); - transform.matrix[0][2] = IntToxFixed(crtc->x); - transform.matrix[1][2] = IntToxFixed(crtc->y); - switch (crtc->rotation & 0xf) { - default: - case RR_Rotate_0: - transform.matrix[0][0] = IntToxFixed(1); - transform.matrix[1][1] = IntToxFixed(1); - break; - case RR_Rotate_90: - transform.matrix[0][1] = IntToxFixed(-1); - transform.matrix[1][0] = IntToxFixed(1); - transform.matrix[0][2] += IntToxFixed(crtc->mode.VDisplay); - break; - case RR_Rotate_180: - transform.matrix[0][0] = IntToxFixed(-1); - transform.matrix[1][1] = IntToxFixed(-1); - transform.matrix[0][2] += IntToxFixed(crtc->mode.HDisplay); - transform.matrix[1][2] += IntToxFixed(crtc->mode.VDisplay); - break; - case RR_Rotate_270: - transform.matrix[0][1] = IntToxFixed(1); - transform.matrix[1][0] = IntToxFixed(-1); - transform.matrix[1][2] += IntToxFixed(crtc->mode.HDisplay); - break; - } - - /* handle reflection */ - if (crtc->rotation & RR_Reflect_X) - { - /* XXX figure this out */ - } - if (crtc->rotation & RR_Reflect_Y) - { - /* XXX figure this out too */ - } - - error = SetPictureTransform (src, &transform); - if (error) { - ErrorF("Couldn't set transform\n"); - return; - } - - while (n--) - { - BoxRec dst_box; - - xf86RotateBox (&dst_box, b, crtc->rotation, - crtc->mode.HDisplay, crtc->mode.VDisplay); - CompositePicture (PictOpSrc, - src, NULL, dst, - dst_box.x1, dst_box.y1, 0, 0, dst_box.x1, dst_box.y1, - dst_box.x2 - dst_box.x1, - dst_box.y2 - dst_box.y1); - b++; - } - FreePicture (src, None); - FreePicture (dst, None); -} - -static void -xf86RotateRedisplay(ScreenPtr pScreen) -{ - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); - DamagePtr damage = xf86_config->rotationDamage; - RegionPtr region; - - if (!damage) - return; - region = DamageRegion(damage); - if (REGION_NOTEMPTY(pScreen, region)) - { - int c; - - for (c = 0; c < xf86_config->num_crtc; c++) - { - xf86CrtcPtr crtc = xf86_config->crtc[c]; - - if (crtc->rotation != RR_Rotate_0) - { - BoxRec box; - RegionRec crtc_damage; - - /* compute portion of damage that overlaps crtc */ - box.x1 = crtc->x; - box.x2 = crtc->x + mode_width (&crtc->mode, crtc->rotation); - box.y1 = crtc->y; - box.y2 = crtc->y + mode_height (&crtc->mode, crtc->rotation); - REGION_INIT(pScreen, &crtc_damage, &box, 1); - REGION_INTERSECT (pScreen, &crtc_damage, &crtc_damage, region); - - /* update damaged region */ - if (REGION_NOTEMPTY(pScreen, &crtc_damage)) - xf86RotateCrtcRedisplay (crtc, &crtc_damage); - - REGION_UNINIT (pScreen, &crtc_damage); - } - } - DamageEmpty(damage); - } -} - -static void -xf86RotateBlockHandler(pointer data, OSTimePtr pTimeout, pointer pRead) -{ - ScreenPtr pScreen = (ScreenPtr) data; - - xf86RotateRedisplay(pScreen); -} - -static void -xf86RotateWakeupHandler(pointer data, int i, pointer LastSelectMask) -{ -} - -Bool -xf86CrtcRotate (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation) -{ - ScrnInfoPtr pScrn = crtc->scrn; - xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); - ScreenPtr pScreen = pScrn->pScreen; - - if (rotation == RR_Rotate_0) - { - /* Free memory from rotation */ - if (crtc->rotatedPixmap) - { - crtc->funcs->shadow_destroy (crtc, crtc->rotatedPixmap); - crtc->rotatedPixmap = NULL; - } - - if (xf86_config->rotationDamage) - { - /* Free damage structure */ - DamageUnregister (&(*pScreen->GetScreenPixmap)(pScreen)->drawable, - xf86_config->rotationDamage); - DamageDestroy (xf86_config->rotationDamage); - xf86_config->rotationDamage = NULL; - /* Free block/wakeup handler */ - RemoveBlockAndWakeupHandlers (xf86RotateBlockHandler, - xf86RotateWakeupHandler, - (pointer) pScreen); - } - } - else - { - /* - * these are the size of the shadow pixmap, which - * matches the mode, not the pre-rotated copy in the - * frame buffer - */ - int width = mode->HDisplay; - int height = mode->VDisplay; - PixmapPtr shadow = crtc->rotatedPixmap; - int old_width = shadow ? shadow->drawable.width : 0; - int old_height = shadow ? shadow->drawable.height : 0; - BoxRec damage_box; - RegionRec damage_region; - - /* Allocate memory for rotation */ - if (old_width != width || old_height != height) - { - if (shadow) - { - crtc->funcs->shadow_destroy (crtc, shadow); - crtc->rotatedPixmap = NULL; - } - shadow = crtc->funcs->shadow_create (crtc, width, height); - if (!shadow) - goto bail1; - crtc->rotatedPixmap = shadow; - } - - if (!xf86_config->rotationDamage) - { - /* Create damage structure */ - xf86_config->rotationDamage = DamageCreate (NULL, NULL, - DamageReportNone, - TRUE, pScreen, pScreen); - if (!xf86_config->rotationDamage) - goto bail2; - - /* Hook damage to screen pixmap */ - DamageRegister (&(*pScreen->GetScreenPixmap)(pScreen)->drawable, - xf86_config->rotationDamage); - - /* Assign block/wakeup handler */ - if (!RegisterBlockAndWakeupHandlers (xf86RotateBlockHandler, - xf86RotateWakeupHandler, - (pointer) pScreen)) - { - goto bail3; - } - damage_box.x1 = 0; - damage_box.y1 = 0; - damage_box.x2 = mode_width (mode, rotation); - damage_box.y2 = mode_height (mode, rotation); - REGION_INIT (pScreen, &damage_region, &damage_box, 1); - DamageDamageRegion (&(*pScreen->GetScreenPixmap)(pScreen)->drawable, - &damage_region); - REGION_UNINIT (pScreen, &damage_region); - } - if (0) - { -bail3: - DamageDestroy (xf86_config->rotationDamage); - xf86_config->rotationDamage = NULL; - -bail2: - if (shadow) - { - crtc->funcs->shadow_destroy (crtc, shadow); - crtc->rotatedPixmap = NULL; - } -bail1: - if (old_width && old_height) - crtc->rotatedPixmap = crtc->funcs->shadow_create (crtc, - old_width, - old_height); - return FALSE; - } - } - - /* All done */ - return TRUE; -} diff --git a/src/i830_xf86cvt.c b/src/i830_xf86cvt.c deleted file mode 100644 index 1a2b7869..00000000 --- a/src/i830_xf86cvt.c +++ /dev/null @@ -1,307 +0,0 @@ -/* - * Copyright 2005-2006 Luc Verhaegen. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * @file This is a copy of xf86cvt.c from the X Server, for compatibility with - * old servers (pre-1.2). - */ - -/* - * The reason for having this function in a file of its own is - * so that ../utils/cvt/cvt can link to it, and that xf86CVTMode - * code is shared directly. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "xf86.h" - -#include "i830.h" -#include "i830_display.h" -#include - -#if XORG_VERSION_CURRENT <= XORG_VERSION_NUMERIC(7,2,99,2,0) -/* - * Generate a CVT standard mode from HDisplay, VDisplay and VRefresh. - * - * These calculations are stolen from the CVT calculation spreadsheet written - * by Graham Loveridge. He seems to be claiming no copyright and there seems to - * be no license attached to this. He apparently just wants to see his name - * mentioned. - * - * This file can be found at http://www.vesa.org/Public/CVT/CVTd6r1.xls - * - * Comments and structure corresponds to the comments and structure of the xls. - * This should ease importing of future changes to the standard (not very - * likely though). - * - * About margins; i'm sure that they are to be the bit between HDisplay and - * HBlankStart, HBlankEnd and HTotal, VDisplay and VBlankStart, VBlankEnd and - * VTotal, where the overscan colour is shown. FB seems to call _all_ blanking - * outside sync "margin" for some reason. Since we prefer seeing proper - * blanking instead of the overscan colour, and since the Crtc* values will - * probably get altered after us, we will disable margins altogether. With - * these calculations, Margins will plainly expand H/VDisplay, and we don't - * want that. -- libv - * - */ -_X_EXPORT DisplayModePtr -xf86CVTMode(int HDisplay, int VDisplay, float VRefresh, Bool Reduced, - Bool Interlaced) -{ - DisplayModeRec *Mode = xnfalloc(sizeof(DisplayModeRec)); - - /* 1) top/bottom margin size (% of height) - default: 1.8 */ -#define CVT_MARGIN_PERCENTAGE 1.8 - - /* 2) character cell horizontal granularity (pixels) - default 8 */ -#define CVT_H_GRANULARITY 8 - - /* 4) Minimum vertical porch (lines) - default 3 */ -#define CVT_MIN_V_PORCH 3 - - /* 4) Minimum number of vertical back porch lines - default 6 */ -#define CVT_MIN_V_BPORCH 6 - - /* Pixel Clock step (kHz) */ -#define CVT_CLOCK_STEP 250 - - Bool Margins = FALSE; - float VFieldRate, HPeriod; - int HDisplayRnd, HMargin; - int VDisplayRnd, VMargin, VSync; - float Interlace; /* Please rename this */ - - memset(Mode, 0, sizeof(DisplayModeRec)); - - /* CVT default is 60.0Hz */ - if (!VRefresh) - VRefresh = 60.0; - - /* 1. Required field rate */ - if (Interlaced) - VFieldRate = VRefresh * 2; - else - VFieldRate = VRefresh; - - /* 2. Horizontal pixels */ - HDisplayRnd = HDisplay - (HDisplay % CVT_H_GRANULARITY); - - /* 3. Determine left and right borders */ - if (Margins) { - /* right margin is actually exactly the same as left */ - HMargin = (((float) HDisplayRnd) * CVT_MARGIN_PERCENTAGE / 100.0); - HMargin -= HMargin % CVT_H_GRANULARITY; - } else - HMargin = 0; - - /* 4. Find total active pixels */ - Mode->HDisplay = HDisplayRnd + 2*HMargin; - - /* 5. Find number of lines per field */ - if (Interlaced) - VDisplayRnd = VDisplay / 2; - else - VDisplayRnd = VDisplay; - - /* 6. Find top and bottom margins */ - /* nope. */ - if (Margins) - /* top and bottom margins are equal again. */ - VMargin = (((float) VDisplayRnd) * CVT_MARGIN_PERCENTAGE / 100.0); - else - VMargin = 0; - - Mode->VDisplay = VDisplay + 2*VMargin; - - /* 7. Interlace */ - if (Interlaced) - Interlace = 0.5; - else - Interlace = 0.0; - - /* Determine VSync Width from aspect ratio */ - if (!(VDisplay % 3) && ((VDisplay * 4 / 3) == HDisplay)) - VSync = 4; - else if (!(VDisplay % 9) && ((VDisplay * 16 / 9) == HDisplay)) - VSync = 5; - else if (!(VDisplay % 10) && ((VDisplay * 16 / 10) == HDisplay)) - VSync = 6; - else if (!(VDisplay % 4) && ((VDisplay * 5 / 4) == HDisplay)) - VSync = 7; - else if (!(VDisplay % 9) && ((VDisplay * 15 / 9) == HDisplay)) - VSync = 7; - else /* Custom */ - VSync = 10; - - if (!Reduced) { /* simplified GTF calculation */ - - /* 4) Minimum time of vertical sync + back porch interval (µs) - * default 550.0 */ -#define CVT_MIN_VSYNC_BP 550.0 - - /* 3) Nominal HSync width (% of line period) - default 8 */ -#define CVT_HSYNC_PERCENTAGE 8 - - float HBlankPercentage; - int VSyncAndBackPorch, VBackPorch; - int HBlank; - - /* 8. Estimated Horizontal period */ - HPeriod = ((float) (1000000.0 / VFieldRate - CVT_MIN_VSYNC_BP)) / - (VDisplayRnd + 2 * VMargin + CVT_MIN_V_PORCH + Interlace); - - /* 9. Find number of lines in sync + backporch */ - if (((int)(CVT_MIN_VSYNC_BP / HPeriod) + 1) < (VSync + CVT_MIN_V_PORCH)) - VSyncAndBackPorch = VSync + CVT_MIN_V_PORCH; - else - VSyncAndBackPorch = (int)(CVT_MIN_VSYNC_BP / HPeriod) + 1; - - /* 10. Find number of lines in back porch */ - VBackPorch = VSyncAndBackPorch - VSync; - - /* 11. Find total number of lines in vertical field */ - Mode->VTotal = VDisplayRnd + 2 * VMargin + VSyncAndBackPorch + Interlace - + CVT_MIN_V_PORCH; - - /* 5) Definition of Horizontal blanking time limitation */ - /* Gradient (%/kHz) - default 600 */ -#define CVT_M_FACTOR 600 - - /* Offset (%) - default 40 */ -#define CVT_C_FACTOR 40 - - /* Blanking time scaling factor - default 128 */ -#define CVT_K_FACTOR 128 - - /* Scaling factor weighting - default 20 */ -#define CVT_J_FACTOR 20 - -#define CVT_M_PRIME CVT_M_FACTOR * CVT_K_FACTOR / 256 -#define CVT_C_PRIME (CVT_C_FACTOR - CVT_J_FACTOR) * CVT_K_FACTOR / 256 + \ - CVT_J_FACTOR - - /* 12. Find ideal blanking duty cycle from formula */ - HBlankPercentage = CVT_C_PRIME - CVT_M_PRIME * HPeriod/1000.0; - - /* 13. Blanking time */ - if (HBlankPercentage < 20) - HBlankPercentage = 20; - - HBlank = Mode->HDisplay * HBlankPercentage/(100.0 - HBlankPercentage); - HBlank -= HBlank % (2*CVT_H_GRANULARITY); - - /* 14. Find total number of pixels in a line. */ - Mode->HTotal = Mode->HDisplay + HBlank; - - /* Fill in HSync values */ - Mode->HSyncEnd = Mode->HDisplay + HBlank / 2; - - Mode->HSyncStart = Mode->HSyncEnd - - (Mode->HTotal * CVT_HSYNC_PERCENTAGE) / 100; - Mode->HSyncStart += CVT_H_GRANULARITY - - Mode->HSyncStart % CVT_H_GRANULARITY; - - /* Fill in VSync values */ - Mode->VSyncStart = Mode->VDisplay + CVT_MIN_V_PORCH; - Mode->VSyncEnd = Mode->VSyncStart + VSync; - - } else { /* Reduced blanking */ - /* Minimum vertical blanking interval time (µs) - default 460 */ -#define CVT_RB_MIN_VBLANK 460.0 - - /* Fixed number of clocks for horizontal sync */ -#define CVT_RB_H_SYNC 32.0 - - /* Fixed number of clocks for horizontal blanking */ -#define CVT_RB_H_BLANK 160.0 - - /* Fixed number of lines for vertical front porch - default 3 */ -#define CVT_RB_VFPORCH 3 - - int VBILines; - - /* 8. Estimate Horizontal period. */ - HPeriod = ((float) (1000000.0 / VFieldRate - CVT_RB_MIN_VBLANK)) / - (VDisplayRnd + 2*VMargin); - - /* 9. Find number of lines in vertical blanking */ - VBILines = ((float) CVT_RB_MIN_VBLANK) / HPeriod + 1; - - /* 10. Check if vertical blanking is sufficient */ - if (VBILines < (CVT_RB_VFPORCH + VSync + CVT_MIN_V_BPORCH)) - VBILines = CVT_RB_VFPORCH + VSync + CVT_MIN_V_BPORCH; - - /* 11. Find total number of lines in vertical field */ - Mode->VTotal = VDisplayRnd + 2 * VMargin + Interlace + VBILines; - - /* 12. Find total number of pixels in a line */ - Mode->HTotal = Mode->HDisplay + CVT_RB_H_BLANK; - - /* Fill in HSync values */ - Mode->HSyncEnd = Mode->HDisplay + CVT_RB_H_BLANK / 2; - Mode->HSyncStart = Mode->HSyncEnd - CVT_RB_H_SYNC; - - /* Fill in VSync values */ - Mode->VSyncStart = Mode->VDisplay + CVT_RB_VFPORCH; - Mode->VSyncEnd = Mode->VSyncStart + VSync; - } - - /* 15/13. Find pixel clock frequency (kHz for xf86) */ - Mode->Clock = Mode->HTotal * 1000.0 / HPeriod; - Mode->Clock -= Mode->Clock % CVT_CLOCK_STEP; - - /* 16/14. Find actual Horizontal Frequency (kHz) */ - Mode->HSync = ((float) Mode->Clock) / ((float) Mode->HTotal); - - /* 17/15. Find actual Field rate */ - Mode->VRefresh = (1000.0 * ((float) Mode->Clock)) / - ((float) (Mode->HTotal * Mode->VTotal)); - - /* 18/16. Find actual vertical frame frequency */ - /* ignore - just set the mode flag for interlaced */ - if (Interlaced) - Mode->VTotal *= 2; - - { - char Name[256]; - Name[0] = 0; - - snprintf(Name, 256, "%dx%d", HDisplay, VDisplay); - - Mode->name = xnfalloc(strlen(Name) + 1); - memcpy(Mode->name, Name, strlen(Name) + 1); - } - - if (Reduced) - Mode->Flags |= V_PHSYNC | V_NVSYNC; - else - Mode->Flags |= V_NHSYNC | V_PVSYNC; - - if (Interlaced) - Mode->Flags |= V_INTERLACE; - - return Mode; -} -#endif /* XORG_VERSION_CURRENT <= XORG_VERSION_NUMERIC(7,2,99,2,0) */ From 0ca926e63c7fa9122a8cba1424ce4cdee1c7b215 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 16 Feb 2007 02:19:10 -0800 Subject: [PATCH 27/29] Check for presence of xf86Modes.h file. xf86Modes.h file signals the availability of the new modes API in the server; use that instead of counting on X server version numbers. Also, finish eliminating use of local copies of those header files. --- configure.ac | 71 +++++++++++++++++++++---------------- src/Makefile.am | 38 +++++++++++--------- src/bios_reader/Makefile.am | 2 +- src/ch7017/Makefile.am | 2 +- src/ch7017/ch7017.c | 2 +- src/ch7xxx/Makefile.am | 2 +- src/ch7xxx/ch7xxx.c | 2 +- src/ivch/Makefile.am | 2 +- src/ivch/ivch.c | 2 +- src/sil164/Makefile.am | 2 +- src/sil164/sil164.c | 2 +- 11 files changed, 71 insertions(+), 56 deletions(-) diff --git a/configure.ac b/configure.ac index e0d828e8..8a81859c 100644 --- a/configure.ac +++ b/configure.ac @@ -76,37 +76,6 @@ AC_ARG_WITH(xserver-source,AC_HELP_STRING([--with-xserver-source=XSERVER_SOURCE] [ XSERVER_SOURCE="" ]) -PKG_CHECK_MODULES(XORG_XSERVER, xorg-server >= 1.2.99, [XMODES=yes], [XMODES=no]) - -AM_CONDITIONAL(XMODES, [test "x$XMODES" = xyes]) - -if test "x$XMODES" = xyes; then - AC_DEFINE(XMODES, 1,[X server as built-in mode code]) -else - if test "x$XSERVER_SOURCE" = x; then - if test -d ../../xserver; then - XSERVER_SOURCE="`cd ../../xserver && pwd`" - fi - fi - - if test "x$XSERVER_SOURCE" = x; then - AC_MSG_ERROR([Must have X server >= 1.3 source tree for mode setting code. Please specify --with-xserver-source]) - fi - - if test -f src/modes/xf86Crtc.h; then - : - else - ln -s $XSERVER_SOURCE/hw/xfree86/modes src/modes - fi - - if test -f src/parser/xf86Parser.h; then - : - else - ln -s $XSERVER_SOURCE/hw/xfree86/parser src/parser - fi - -fi - # Checks for extensions XORG_DRIVER_CHECK_EXT(XINERAMA, xineramaproto) XORG_DRIVER_CHECK_EXT(RANDR, randrproto) @@ -144,6 +113,46 @@ if test x$DRI = xauto; then fi AC_MSG_RESULT([$DRI]) +save_CFLAGS="$CFLAGS" +CFLAGS="$XORG_CFLAGS" +AC_CHECK_HEADER(xf86Modes.h,[XMODES=yes],[XMODES=no],[#include "xorg-server.h"]) +CFLAGS="$save_CFLAGS" + +AM_CONDITIONAL(XMODES, test "x$XMODES" = xno) + +if test "x$XMODES" = xyes; then + echo built-in mode code + AC_DEFINE(XMODES, 1,[X server has built-in mode code]) + XMODES_CFLAGS= +else + echo symlink mode code + if test "x$XSERVER_SOURCE" = x; then + if test -d ../../xserver; then + XSERVER_SOURCE="`cd ../../xserver && pwd`" + fi + fi + + if test "x$XSERVER_SOURCE" = x; then + AC_MSG_ERROR([Must have X server >= 1.3 source tree for mode setting code. Please specify --with-xserver-source]) + fi + XMODES_CFLAGS='-DXF86_MODES_RENAME -I$(top_srcdir)/src/modes -I$(top_srcdir)/src/parser' +fi + +if test -d "$XSERVER_SOURCE"; then + if test -f src/modes/xf86Modes.h; then + : + else + ln -s $XSERVER_SOURCE/hw/xfree86/modes src/modes + fi + + if test -f src/parser/xf86Parser.h; then + : + else + ln -s $XSERVER_SOURCE/hw/xfree86/parser src/parser + fi +fi +AC_SUBST([XMODES_CFLAGS]) + dnl Use lots of warning flags with GCC WARN_CFLAGS="" diff --git a/src/Makefile.am b/src/Makefile.am index f656270a..1e0505f6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -25,13 +25,32 @@ SUBDIRS = xvmc bios_reader ch7017 ch7xxx ivch sil164 # -avoid-version prevents gratuitous .0.0.0 version numbers on the end # _ladir passes a dummy rpath to libtool so the thing will actually link # TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc. -AM_CFLAGS = @WARN_CFLAGS@ @XORG_CFLAGS@ @DRI_CFLAGS@ -Iparser -Imodes \ - -DI830_XV -DI830_USE_XAA -DI830_USE_EXA -DXF86_MODES_RENAME + +AM_CFLAGS = @WARN_CFLAGS@ @XORG_CFLAGS@ @DRI_CFLAGS@ @XMODES_CFLAGS@ \ + -DI830_XV -DI830_USE_XAA -DI830_USE_EXA intel_drv_la_LTLIBRARIES = intel_drv.la intel_drv_la_LDFLAGS = -module -avoid-version intel_drv_ladir = @moduledir@/drivers +if XMODES +XMODE_SRCS=\ + local_xf86Rename.h \ + parser/xf86Rename.h \ + parser/xf86Parser.h \ + parser/xf86Optrec.h \ + modes/xf86Modes.h \ + modes/xf86Modes.c \ + modes/xf86cvt.c \ + modes/xf86Crtc.h \ + modes/xf86Crtc.c \ + modes/xf86EdidModes.c \ + modes/xf86RandR12.c \ + modes/xf86RandR12.h \ + modes/xf86Rotate.c \ + modes/xf86DiDGA.c +endif + intel_drv_la_SOURCES = \ brw_defines.h \ brw_structs.h \ @@ -86,20 +105,7 @@ intel_drv_la_SOURCES = \ i830_render.c \ i915_render.c \ i965_render.c \ - local_xf86Rename.h \ - parser/xf86Rename.h \ - parser/xf86Parser.h \ - parser/xf86Optrec.h \ - modes/xf86Modes.h \ - modes/xf86Modes.c \ - modes/xf86cvt.c \ - modes/xf86Crtc.h \ - modes/xf86Crtc.c \ - modes/xf86EdidModes.c \ - modes/xf86RandR12.c \ - modes/xf86RandR12.h \ - modes/xf86Rotate.c \ - modes/xf86DiDGA.c + $(XMODE_SRCS) EXTRA_DIST = \ packed_yuv_sf.g4a \ diff --git a/src/bios_reader/Makefile.am b/src/bios_reader/Makefile.am index f18a00c3..a5c81a6c 100644 --- a/src/bios_reader/Makefile.am +++ b/src/bios_reader/Makefile.am @@ -1,4 +1,4 @@ -AM_CFLAGS = @XORG_CFLAGS@ +AM_CFLAGS = @XORG_CFLAGS@ @XMODES_CFLAGS@ noinst_PROGRAMS = bios_reader diff --git a/src/ch7017/Makefile.am b/src/ch7017/Makefile.am index 9cf2fa49..7fbb4408 100644 --- a/src/ch7017/Makefile.am +++ b/src/ch7017/Makefile.am @@ -3,7 +3,7 @@ # -avoid-version prevents gratuitous .0.0.0 version numbers on the end # _ladir passes a dummy rpath to libtool so the thing will actually link # TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc. -AM_CFLAGS = @XORG_CFLAGS@ @DRI_CFLAGS@ +AM_CFLAGS = @XORG_CFLAGS@ @DRI_CFLAGS@ -I$(srcdir)/.. -I$(srcdir)/../modes ch7017_la_LTLIBRARIES = ch7017.la ch7017_la_LDFLAGS = -module -avoid-version diff --git a/src/ch7017/ch7017.c b/src/ch7017/ch7017.c index 28bce0d2..019dcea0 100644 --- a/src/ch7017/ch7017.c +++ b/src/ch7017/ch7017.c @@ -37,7 +37,7 @@ #include "compiler.h" #include "miscstruct.h" #include "xf86i2c.h" -#include "../i830_xf86Crtc.h" +#include "xf86Crtc.h" #define DPMS_SERVER #include diff --git a/src/ch7xxx/Makefile.am b/src/ch7xxx/Makefile.am index 7f3b1e1e..b827bf8e 100644 --- a/src/ch7xxx/Makefile.am +++ b/src/ch7xxx/Makefile.am @@ -3,7 +3,7 @@ # -avoid-version prevents gratuitous .0.0.0 version numbers on the end # _ladir passes a dummy rpath to libtool so the thing will actually link # TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc. -AM_CFLAGS = @XORG_CFLAGS@ @DRI_CFLAGS@ -I$(srcdir)/../ +AM_CFLAGS = @XORG_CFLAGS@ @DRI_CFLAGS@ -I$(srcdir)/.. -I$(srcdir)/../modes ch7xxx_la_LTLIBRARIES = ch7xxx.la ch7xxx_la_LDFLAGS = -module -avoid-version diff --git a/src/ch7xxx/ch7xxx.c b/src/ch7xxx/ch7xxx.c index 161aebf4..9ce581fa 100644 --- a/src/ch7xxx/ch7xxx.c +++ b/src/ch7xxx/ch7xxx.c @@ -37,7 +37,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "compiler.h" #include "miscstruct.h" #include "xf86i2c.h" -#include "i830_xf86Crtc.h" +#include "xf86Crtc.h" #define DPMS_SERVER #include diff --git a/src/ivch/Makefile.am b/src/ivch/Makefile.am index fac074db..40e26277 100644 --- a/src/ivch/Makefile.am +++ b/src/ivch/Makefile.am @@ -3,7 +3,7 @@ # -avoid-version prevents gratuitous .0.0.0 version numbers on the end # _ladir passes a dummy rpath to libtool so the thing will actually link # TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc. -AM_CFLAGS = @XORG_CFLAGS@ @DRI_CFLAGS@ +AM_CFLAGS = @XORG_CFLAGS@ @DRI_CFLAGS@ -I$(srcdir)/.. -I$(srcdir)/../modes ivch_la_LTLIBRARIES = ivch.la ivch_la_LDFLAGS = -module -avoid-version diff --git a/src/ivch/ivch.c b/src/ivch/ivch.c index 085b542a..71f41f58 100644 --- a/src/ivch/ivch.c +++ b/src/ivch/ivch.c @@ -35,7 +35,7 @@ #include "compiler.h" #include "miscstruct.h" #include "xf86i2c.h" -#include "../i830_xf86Crtc.h" +#include "xf86Crtc.h" #define DPMS_SERVER #include diff --git a/src/sil164/Makefile.am b/src/sil164/Makefile.am index 927f5a77..4cf717c4 100644 --- a/src/sil164/Makefile.am +++ b/src/sil164/Makefile.am @@ -3,7 +3,7 @@ # -avoid-version prevents gratuitous .0.0.0 version numbers on the end # _ladir passes a dummy rpath to libtool so the thing will actually link # TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc. -AM_CFLAGS = @XORG_CFLAGS@ @DRI_CFLAGS@ -I$(srcdir)/../ +AM_CFLAGS = @XORG_CFLAGS@ @DRI_CFLAGS@ -I$(srcdir)/.. -I$(srcdir)/../modes sil164_la_LTLIBRARIES = sil164.la sil164_la_LDFLAGS = -module -avoid-version diff --git a/src/sil164/sil164.c b/src/sil164/sil164.c index 453ed044..80b1b6a8 100644 --- a/src/sil164/sil164.c +++ b/src/sil164/sil164.c @@ -37,7 +37,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "compiler.h" #include "miscstruct.h" #include "xf86i2c.h" -#include "i830_xf86Crtc.h" +#include "xf86Crtc.h" #define DPMS_SERVER #include From 5a1a04649c62aa4b1c0617560b813642ce0c67b5 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 17 Feb 2007 17:01:04 -0800 Subject: [PATCH 28/29] Make distcheck fixes. Distribute all sources needed even for older servers. Always allow (but do not require) link to server sources so that needed files can be included in the generated tar files. Add remaining .g4a files and assembly output to distributed file lists. --- configure.ac | 14 ++++----- src/Makefile.am | 83 +++++++++++++++++++++++++++++++++---------------- 2 files changed, 64 insertions(+), 33 deletions(-) diff --git a/configure.ac b/configure.ac index 8a81859c..395e9d4e 100644 --- a/configure.ac +++ b/configure.ac @@ -22,7 +22,7 @@ AC_PREREQ(2.57) AC_INIT([xf86-video-intel], - 1.7.2, + 1.9.90, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xf86-video-intel) @@ -120,18 +120,18 @@ CFLAGS="$save_CFLAGS" AM_CONDITIONAL(XMODES, test "x$XMODES" = xno) +if test "x$XSERVER_SOURCE" = x; then + if test -d ../../xserver; then + XSERVER_SOURCE="`cd ../../xserver && pwd`" + fi +fi + if test "x$XMODES" = xyes; then echo built-in mode code AC_DEFINE(XMODES, 1,[X server has built-in mode code]) XMODES_CFLAGS= else echo symlink mode code - if test "x$XSERVER_SOURCE" = x; then - if test -d ../../xserver; then - XSERVER_SOURCE="`cd ../../xserver && pwd`" - fi - fi - if test "x$XSERVER_SOURCE" = x; then AC_MSG_ERROR([Must have X server >= 1.3 source tree for mode setting code. Please specify --with-xserver-source]) fi diff --git a/src/Makefile.am b/src/Makefile.am index 1e0505f6..adb4c42d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -33,10 +33,8 @@ intel_drv_la_LTLIBRARIES = intel_drv.la intel_drv_la_LDFLAGS = -module -avoid-version intel_drv_ladir = @moduledir@/drivers -if XMODES XMODE_SRCS=\ local_xf86Rename.h \ - parser/xf86Rename.h \ parser/xf86Parser.h \ parser/xf86Optrec.h \ modes/xf86Modes.h \ @@ -47,9 +45,16 @@ XMODE_SRCS=\ modes/xf86EdidModes.c \ modes/xf86RandR12.c \ modes/xf86RandR12.h \ + modes/xf86Rename.h \ modes/xf86Rotate.c \ modes/xf86DiDGA.c -endif + +INTEL_DRI_SRCS = \ + i810_dri.c \ + i810_dri.h \ + i830_dri.c \ + i810_hwmc.c \ + i830_dri.h intel_drv_la_SOURCES = \ brw_defines.h \ @@ -104,43 +109,70 @@ intel_drv_la_SOURCES = \ i830_xaa.c \ i830_render.c \ i915_render.c \ - i965_render.c \ - $(XMODE_SRCS) + i965_render.c -EXTRA_DIST = \ - packed_yuv_sf.g4a \ - packed_yuv_wm.g4a +INTEL_G4A = \ + packed_yuv_sf.g4a \ + packed_yuv_wm.g4a \ + exa_sf.g4a \ + exa_sf_mask.g4a \ + exa_wm_maskca.g4a \ + exa_wm_maskca_srcalpha.g4a \ + exa_wm_masknoca.g4a \ + exa_wm_nomask.g4a +INTEL_G4H = \ + sf_prog.h \ + wm_prog.h \ + exa_sf_mask_prog.h \ + exa_sf_prog.h \ + exa_wm_maskca_prog.h \ + exa_wm_maskca_srcalpha_prog.h \ + exa_wm_masknoca_prog.h \ + exa_wm_nomask_prog.h + +EXTRA_DIST = \ + $(XMODE_SRCS) \ + $(INTEL_G4A) \ + $(INTEL_G4H) \ + $(INTEL_DRI_SRCS) + if HAVE_GEN4ASM + sf_prog.h: packed_yuv_sf.g4a intel-gen4asm -o sf_prog.h packed_yuv_sf.g4a + wm_prog.h: packed_yuv_wm.g4a intel-gen4asm -o wm_prog.h packed_yuv_wm.g4a -exa_sf_prog.h: exa_sf.g4a - intel-gen4asm -o exa_sf_prog.h exa_sf.g4a + exa_sf_mask_prog.h: exa_sf_mask.g4a intel-gen4asm -o exa_sf_mask_prog.h exa_sf_mask.g4a -exa_wm_nomask_prog.h: exa_wm_nomask.g4a - intel-gen4asm -o exa_wm_nomask_prog.h exa_wm_nomask.g4a + +exa_sf_prog.h: exa_sf.g4a + intel-gen4asm -o exa_sf_prog.h exa_sf.g4a + +exa_wm_maskca_prog.h: exa_wm_maskca.g4a + intel-gen4asm -o exa_wm_maskca_prog.h exa_wm_maskca.g4a + +exa_wm_maskca_srcalpha_prog.h: exa_wm_maskca_srcalpha.g4a + intel-gen4asm -o exa_wm_maskca_srcalpha_prog.h exa_wm_maskca_srcalpha.g4a + exa_wm_masknoca_prog.h: exa_wm_masknoca.g4a intel-gen4asm -o exa_wm_masknoca_prog.h exa_wm_masknoca.g4a -else -EXTRA_DIST += \ - sf_prog.h \ - wm_prog.h \ - exa_sf_prog.h \ - exa_sf_mask_prog.h \ - exa_wm_nomask_prog.h \ - exa_wm_masknoca_prog.h + +exa_wm_nomask_prog.h: exa_wm_nomask.g4a + intel-gen4asm -o exa_wm_nomask_prog.h exa_wm_nomask.g4a + +endif + +if XMODES +intel_drv_la_SOURCES += \ + $(XMODE_SRCS) endif if DRI intel_drv_la_SOURCES += \ - i810_dri.c \ - i810_dri.h \ - i830_dri.c \ - i810_hwmc.c \ - i830_dri.h + $(INTEL_DRI_SRCS) endif install-data-local: install-intel_drv_laLTLIBRARIES @@ -148,4 +180,3 @@ install-data-local: install-intel_drv_laLTLIBRARIES uninstall-local: (cd $(DESTDIR)$(intel_drv_ladir) && rm -f i810_drv.so) - From 3bce8bf0e95e5842399959a5d6f6413e96f03adb Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 20 Feb 2007 23:10:17 -0800 Subject: [PATCH 29/29] Pre-965 hardware had fixed pipe 1 for panel fitter. The pipe mode setting code needs to disable the panel fitter when using the pipe for things other than LVDS output. The driver was checking for panel fitter conflicts using bits that the 965 chipset defines for selecting which pipe the panel fitter is connected to. However, on pre-965 hardware, the panel fitter works only with pipe 1 and those bits returned 0. The result was that when pipe 1 was using the panel fitter, configuring pipe 0 would disable the panel fitter. The fix provided uses a model-specific test for the panel fitter pipe. --- src/i830_display.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/i830_display.c b/src/i830_display.c index e7a5605e..2e847051 100644 --- a/src/i830_display.c +++ b/src/i830_display.c @@ -643,6 +643,33 @@ i830_get_core_clock_speed(ScrnInfoPtr pScrn) return 0; /* Silence gcc warning */ } +/** + * Return the pipe currently connected to the panel fitter, + * or -1 if the panel fitter is not present or not in use + */ +static int +i830_panel_fitter_pipe (I830Ptr pI830) +{ + CARD32 pfit_control; + + /* i830 doesn't have a panel fitter */ + if (IS_I830(pI830)) + return -1; + + pfit_control = INREG(PFIT_CONTROL); + + /* See if the panel fitter is in use */ + if ((pfit_control & PFIT_ENABLE) == 0) + return -1; + + /* 965 can place panel fitter on either pipe */ + if (IS_I965G(pI830)) + return (pfit_control >> 29) & 0x3; + + /* older chips can only use pipe 1 */ + return 1; +} + /** * Sets up registers for the given mode/adjusted_mode pair. * @@ -830,7 +857,7 @@ i830_crtc_mode_set(xf86CrtcPtr crtc, DisplayModePtr mode, } /* Disable the panel fitter if it was on our pipe */ - if (!IS_I830(pI830) && ((INREG(PFIT_CONTROL) >> 29) & 0x3) == pipe) + if (i830_panel_fitter_pipe (pI830) == pipe) OUTREG(PFIT_CONTROL, 0); i830PrintPll("chosen", &clock);