debian/0000755000000000000000000000000012140640556007171 5ustar debian/menu0000644000000000000000000000026712140635164010064 0ustar ?package(i810switch): needs="text" title="i810rotate" \ section="Applications/System/Hardware" \ longtitle="Rotate video output on i810 chipset" \ command="/usr/bin/i810rotate" debian/README.Debian0000644000000000000000000000135212140635127011231 0ustar i810switch for Debian ---------------------- This program changes the video output on my Sony Vaio PCG-R505CT. Hopefully it works on other models too. Use with caution; you may want to search the web for others using this utility on your model of computer if you are unsure of the video hardware within it. I don't know if it will cause any problems for you if you have different hardware, but I don't know. James Bromberger , Sat, 14 Jun 2003 17:55:52 +0100 According to Keith Packard, some of the rotate (in the sense of flipping the video output to external) is now implemented in the X.org Intel driver (replacing the i810 driver). See xrandr(1). James Bromberger , Tue, 19 Jun 2007 13:25:52 +0100 debian/patches/0000755000000000000000000000000012140637616010623 5ustar debian/patches/15-makefile.patch0000644000000000000000000000155212140635164013643 0ustar From: James Bromberger Subject: Adjust install target in Makefile diff --git a/Makefile b/Makefile index 5359d39..4fdfee1 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,7 @@ OBJECTS = i810switch.o +INSTALL=/usr/bin/install +CC=gcc + %.o: %.c $(CC) $(CFLAGS) -c -o $@ $< @@ -9,10 +12,8 @@ i810switch: $(OBJECTS) $(CC) $(CFLAGS) -o $@ $(OBJECTS) install: i810switch - install -d $(DESTDIR)/usr/bin - install -d $(DESTDIR)/usr/share/man/man1 - install i810switch i810rotate $(DESTDIR)/usr/bin - install i810switch.1.gz i810rotate.1.gz $(DESTDIR)/usr/share/man/man1 + ${INSTALL} -D -m 4754 --group=video i810switch ${DESTDIR}/usr/bin/i810switch + ${INSTALL} -D -m 0754 --group=video i810rotate ${DESTDIR}/usr/bin/i810rotate uninstall: rm -f $(DESTDIR)/usr/bin/i810switch @@ -22,4 +23,3 @@ uninstall: clean: @rm -f $(OBJECTS) i810switch - debian/patches/10-i810switch.c.patch0000644000000000000000000000056412140635164014207 0ustar From: Unknown Subject: Use absolute path to call lspci(1) diff --git a/i810switch.c b/i810switch.c index 8831daa..4979b59 100644 --- a/i810switch.c +++ b/i810switch.c @@ -9,7 +9,7 @@ #include #define VERSION "0.6.5beta" -#define CMD_LSPCI "lspci" +#define CMD_LSPCI "/usr/bin/lspci" static const char *Opt_lcd = NULL; static const char *Opt_crt = NULL; debian/patches/20-support-945-940-macbook.patch0000644000000000000000000000146712140635164016045 0ustar From: Thomas Perl Subject: support for the Intel Corporation Mobile 945GM/GMS/940GML Express Integrated Graphics found in MacBooks Bug-Debian: http://bugs.debian.org/374638 --- i810switch-0.6.5/i810switch.c 2006-12-24 22:30:48.000000000 +0100 +++ i810switch-0.6.5-thp/i810switch.c 2006-12-24 22:27:47.000000000 +0100 @@ -60,6 +60,7 @@ #define I855STR "8086:3582" //#define I865STR "8086:2572" #define I915STR "8086:2592" +#define I945STR "8086:27a2" #define MEMSTR "Memory at" #define NONPRSTR "32-bit, non-prefetchable" @@ -279,6 +280,13 @@ return p; } + i = (p = strstr(*buff_ptr, I945STR)) != NULL; + if (i) + { + *chiptype = I855; + return p; + } + i = (p = strstr(*buff_ptr, I915STR)) != NULL; if (i) { Only in i810switch-0.6.5: i810switch.o debian/patches/series0000644000000000000000000000011112140637640012026 0ustar 10-i810switch.c.patch 15-makefile.patch 20-support-945-940-macbook.patch debian/compat0000644000000000000000000000000212140635164010366 0ustar 9 debian/control0000644000000000000000000000144712140635164010601 0ustar Source: i810switch Section: utils Priority: optional Maintainer: James Bromberger Build-Depends: debhelper (>= 9) Standards-Version: 3.9.4 Homepage: http://juljas.net/vaio Package: i810switch Architecture: i386 kfreebsd-i386 amd64 hurd-i386 kfreebsd-amd64 Depends: ${misc:Depends}, ${shlibs:Depends}, pciutils (>= 1:2.1.11-6) Description: Enables/disables video output to CRT/LCD on i810 video hardware i810switch enables/disables the output to the CRT display and LCD, depending on the i810 graphics controller hardware. Such hardware is found on some laptops (eg, Sony Vaios, some Dell models, etc). Chipsets also supported include i855, i830, i845. . This package includes the i810rotate script, which toggles the output between three states: LCD only, LCD + CRT, and CRT only. debian/i810switch.manpages0000644000000000000000000000005012140635127012602 0ustar debian/i810switch.1 debian/i810rotate.1 debian/i810switch.10000644000000000000000000000221512140635127011154 0ustar .TH I810SWITCH 1 .\" NAME should be all caps, SECTION should be 1-8, maybe w/ subsection .\" other parms are allowed: see man(7), man(1) .SH NAME i810switch \- enable/disable screen output on i810 video hardware .SH SYNOPSIS .B i810switch .B [ .I crt .B [ .I on | off .B ] ] [ .I lcd .B [ .I on | off .B ] ] .SH "DESCRIPTION" This manual page documents briefly the .BR i810switch , command. This manual page was written for the Debian GNU/Linux distribution because the original program does not have a manual page. .PP .B i810switch is a program that enables/disables the output to the CRT display and LCD, depending on the i810 graphics controller hardware. With no options, it displays the current output status. .SH OPTIONS A summary of options are included below. .TP .B lcd [ on | off ] Turn the main LCD display on or off. .TP .B crt [ on | off ] Turn the external video display on or off. .SH "SEE ALSO" sonypi(1) .SH AUTHOR i810switch was written by mano and Antonino Daplas . This manual page was written by James Bromberger , for the Debian GNU/Linux system (but may be used by others). debian/dirs0000644000000000000000000000001012140635127010042 0ustar usr/bin debian/changelog0000644000000000000000000001123212140640520011031 0ustar i810switch (0.6.5-7.1) unstable; urgency=low * Non-maintainer upload; ACKed by the maintainer. * Remove deprecated dpatch and upgrade to packaging format "3.0 quilt" (Closes: #670384). * Update Standards-Version to 3.9.4 and debhelper to 9. * Add build-arch and build-indep targets; use dh_prep in rules file. * Update homepage URL in control file and add a note about the new location to copyright file. * Remove unused file i810switch.c.new. Was not part of the original sources. See new patch 10. * debian/patches - (10): New. Contains in-line changes meant for original sources from i810switch.c.new. - (15): New. Contains in-line changes meant to original sources: Makefile. - (20): Rename. Macbook patch was number 01. * Lintian fixes - copyright-without-copyright-notice; also add authors Antonino Daplas and mano. - copyright-refers-to-symlink-license. - debian-rules-ignores-make-clean-error. - menu-item-uses-apps-section. - no-homepage-field. - unused-override. * Use hardened build flags http://wiki.debian.org/ReleaseGoals/SecurityHardeningBuildFlags -- Jari Aalto Fri, 03 May 2013 07:47:12 +0300 i810switch (0.6.5-7) unstable; urgency=low * Added kfreebsd-amd64 as an architecture for the package. Closes: #494980. -- James Bromberger Wed, 13 Aug 2008 22:06:33 +0100 i810switch (0.6.5-6) unstable; urgency=low * Added missing dependancy on dpatch. Closes: 493444. -- James Bromberger Tue, 12 Aug 2008 08:50:45 +0100 i810switch (0.6.5-5) unstable; urgency=low * Updated to standards version 3.8.0: no changes. * Added architecture hurd-i386: Closes #488303. -- James Bromberger Sat, 26 Jul 2008 16:18:02 +0100 i810switch (0.6.5-4) unstable; urgency=low * Apply patch for MacBooks, as unstream is not responding. Thanks to Thomas Perl. Closes: #374638. -- James Bromberger Tue, 19 Jun 2007 13:30:57 +0100 i810switch (0.6.5-3) unstable; urgency=low * Added AMD64 to list of supported arches, thanks Julien. Closes: #404039. * Corrected the address of the FSF in the copyright file to fix a Lintian warning. * Add a Lintian Override file to suppress warnings about the SetUID permissions on /usr/bin/i810switch. * Add read permissions to binaries/scripts (but no execute) as per Lintian warnings, and section 10.9 of Policy. -- James Bromberger Thu, 21 Dec 2006 23:03:15 +0000 i810switch (0.6.5-2) unstable; urgency=low * Add architecture kfreebsd-i386 Closes: #314267. -- James Bromberger Wed, 15 Jun 2005 17:09:03 +0100 i810switch (0.6.5-1) unstable; urgency=low * New upstream release. Closes: #313197. -- James Bromberger Sun, 12 Jun 2005 20:34:24 +0100 i810switch (0.6.2-2) unstable; urgency=low * Update the upstream ChangeLog for 0.6.2, which upstream accidentally left out. :) All fixed herein... -- James Bromberger Sun, 15 Feb 2004 23:07:28 +0000 i810switch (0.6.2-1) unstable; urgency=low * New upstream release. i845 support is added. -- James Bromberger Thu, 12 Feb 2004 23:25:31 +0000 i810switch (0.6.1-1) unstable; urgency=low * New upstream release. Closes: #221864. -- James Bromberger Mon, 5 Jan 2004 22:08:09 +0000 i810switch (0.6-1) unstable; urgency=low * New upstream release, only it incorporates some changes for bug #221864. However, this is currently a compile-time option to support these alternate i810 chipsets where the video is on a different Planar output, so not really a 'fix' per se, so not closing this bug yet... -- James Bromberger Sat, 27 Dec 2003 16:19:26 +0000 i810switch (0.5-2) unstable; urgency=low * lspic in pciutils changes location, and I have an absolute path in my diff to ensure that the wrong SUID binary isnt called. So, updated path here. Closes #219259. Thanks Remco for the bug report. -- James Bromberger Mon, 15 Dec 2003 00:19:55 +0000 i810switch (0.5-1) unstable; urgency=low * New upstream release * ... which fixes i830 up and adds i855 support. Well done Ken! -- James Bromberger Sat, 20 Sep 2003 01:22:30 +0100 i810switch (0.4-1) unstable; urgency=low * New upstream release * Security fix from Steve Kemp. Closes #204183. * Fix 'Depends' as well. Thanks again Steve! -- James Bromberger Wed, 13 Aug 2003 21:13:03 +0100 i810switch (0.3-1) unstable; urgency=low * Initial Release. Closes: #197406 -- James Bromberger Wed, 3 Jul 2003 23:49:44 +0100 debian/rules0000755000000000000000000000407112140635164010252 0ustar #!/usr/bin/make -f # Sample debian/rules that uses debhelper. # GNU copyright 1997 to 1999 by Joey Hess. # Uncomment this to turn on verbose mode. export DH_VERBOSE=1 export DEB_BUILD_MAINT_OPTIONS = hardening=+all DEB_CFLAGS_MAINT_APPEND = -Wall # Upstream does not support xxFLAGS, so get them explicitly DEB_CFLAGS_MAINT_APPEND += $(shell dpkg-buildflags --get CPPFLAGS) DEB_CFLAGS_MAINT_APPEND += $(shell dpkg-buildflags --get LDFLAGS) DEB_CFLAGS_MAINT_APPEND += -Wl,--as-needed export DEB_CFLAGS_MAINT_APPEND configure: configure-stamp configure-stamp: dh_testdir # Add here commands to configure the package. touch configure-stamp build-arch: build build-indep: build build: build-stamp build-stamp: configure-stamp dh_testdir # Add here commands to compile the package. dh_auto_build #/usr/bin/docbook-to-man debian/i810switch.sgml > i810switch.1 touch build-stamp clean: dh_testdir dh_testroot rm -f build-stamp configure-stamp \ i810switch *.o # Add here commands to clean up after the build process. dh_auto_clean dh_clean install: build dh_testdir dh_testroot dh_prep dh_installdirs # Add here commands to install the package into debian/i810switch. $(MAKE) install DESTDIR=$(CURDIR)/debian/i810switch # Build architecture-independent files here. binary-indep: build install # We have nothing to do by default. # Build architecture-dependent files here. binary-arch: build install dh_testdir dh_testroot dh_installchangelogs ChangeLog dh_installdocs # dh_installexamples # dh_install dh_installmenu # dh_installdebconf # dh_installlogrotate # dh_installemacsen # dh_installpam # dh_installmime # dh_installinit # dh_installcron # dh_installinfo dh_installman dh_link dh_strip dh_compress dh_fixperms -X usr/bin/i810switch install -m644 -D debian/lintian-override $(CURDIR)/debian/i810switch/usr/share/lintian/overrides/i810switch # dh_perl # dh_python # dh_makeshlibs dh_installdeb dh_shlibdeps dh_gencontrol dh_md5sums dh_builddeb binary: binary-indep binary-arch .PHONY: build clean binary-indep binary-arch binary install configure debian/docs0000644000000000000000000000001412140635127010035 0ustar README TODO debian/copyright0000644000000000000000000000136012140635164011123 0ustar This package was debianized by James Bromberger on Sat, 14 Jun 2003 17:55:52 +0100. It was downloaded from http://www.pm.waw.pl/~jslupski/vaio/ As of 2013-05-03 the page is located ad http://juljas.net/vaio Copyright: Copyright (C) 2003 Antonino Daplas (original author) Copyright (C) 2003 mano Copyright (C) 2003 Jeff Ames You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA On Debian GNU/Linux systems, the complete text of the GNU General Public License can be found in `/usr/share/common-licenses/GPL-2'. debian/lintian-override0000644000000000000000000000032712140635164012370 0ustar # SetUID required to rotate the video output i810switch binary: setuid-binary usr/bin/i810switch 4754 root/video # Due to patch 20 i810switch [any-i386] binary: wrong-file-owner-uid-or-gid usr/bin/i810switch 0/141 debian/source/0000755000000000000000000000000012140635164010470 5ustar debian/source/format0000644000000000000000000000001412140635164011676 0ustar 3.0 (quilt) debian/i810rotate.10000644000000000000000000000176012140635127011155 0ustar .TH I810ROTATE 1 .\" NAME should be all caps, SECTION should be 1-8, maybe w/ subsection .\" other parms are allowed: see man(7), man(1) .SH NAME i810rotate \- toggle the video output on i810 hardware using i810switch(1) .SH SYNOPSIS .B i810rotate .SH "DESCRIPTION" This manual page documents briefly the .BR i810rotate , command. This manual page was written for the Debian GNU/Linux distribution because the original program does not have a manual page. .PP .B i810rotate is a program that toggles the currently selected video output for i810 based video cards, as found on several laptops. It loops through three states: LCD only output, LCD and CRT output, and CRT only output. .SH OPTIONS There are none. It's a 5 line shell script. .SH "SEE ALSO" i810rotate(1) .SH AUTHOR i810rotate was written by mano and Antonino Daplas . This manual page was written by James Bromberger , for the Debian GNU/Linux system (but may be used by others). debian/upstream/0000755000000000000000000000000012140635751011032 5ustar debian/upstream/README0000644000000000000000000000071012140635751011710 0ustar The Debian package format 3.0 upgrade (debian/0.6.5-7.1) mandates that - No direct chnagesa are made to upstream sources - Any changes are stored in separate sets in debian/patches directory. This directory contains files that were in debian/0.6.5-7 release's source directory but which were not part of the upstream sources. They were also not used by the Debian packaging process in debian/rules. -- 2013-05-03 07:23 Jari Aalto debian/upstream/i810switch.c.new0000644000000000000000000003570512140635162013677 0ustar #include #include #include #include #include #include #include #include #include #define VERSION "0.6.5beta" #define CMD_LSPCI "/usr/bin/lspci" static const char *Opt_lcd = NULL; static const char *Opt_crt = NULL; struct i810_par { unsigned char *mmio; int mem; int flag; }; #define i810_readb(mmio_base, where) \ *((volatile char *) (mmio_base + where)) #define i810_readw(mmio_base, where) \ *((volatile short *) (mmio_base + where)) #define i810_readl(mmio_base, where) \ *((volatile int *) (mmio_base + where)) #define i810_writeb(mmio_base, where, val) \ *((volatile char *) (mmio_base + where)) = (volatile char) val #define i810_writew(mmio_base, where, val) \ *((volatile short *) (mmio_base + where)) = (volatile short) val #define i810_writel(mmio_base, where, val) \ *((volatile int *) (mmio_base + where)) = (volatile int) val #define I810_MEMOPEN 1 #define I810_MMIO 2 /* chip types */ #define I810 1 #define I830 2 #define I855 3 #define I915 4 /* PCI IDs */ #define I810STR "8086:7121" #define I810ESTR "8086:7123" #define I810_DC100STR_1 "8086:7125" #define I810_DC100STR_2 "8086:1102" #define I810_IGSTR "8086:1112" #define I810_CFCSTR "8086:1132" #define I830STR "8086:3577" #define I845STR "8086:2562" #define I855STR "8086:3582" //#define I865STR "8086:2572" #define I915STR "8086:2592" #define MEMSTR "Memory at" #define NONPRSTR "32-bit, non-prefetchable" /* I810 registers */ #define I810_HVSYNC 0x05000 #define I810_DCLK_0D 0x06000 #define I810_DCLK_1D 0x06004 #define I810_DCLK_0DS 0x06010 #define I810_PWR_CLKC 0x06014 #define I810_HTOTAL 0x60000 #define I810_HBLANK 0x60004 #define I810_HSYNC 0x60008 #define I810_VTOTAL 0x6000c #define I810_VBLANK 0x60010 #define I810_VSYNC 0x60014 #define I810_LCDTV_C 0x60018 #define I810_OVRACT 0x6001c #define I810_BCLRPAT 0x60020 #define I810_PIXCONF 0x70008 /* I830 registers */ #define I830_HTOTAL_A 0x60000 #define I830_HBLANK_A 0x60004 #define I830_HSYNC_A 0x60008 #define I830_VTOTAL_A 0x6000c #define I830_VBLANK_A 0x60010 #define I830_VSYNC_A 0x60014 #define I830_PIPEASRC 0x6001c #define I830_BCLRPAT_A 0x60020 #define I830_HTOTAL_B 0x61000 #define I830_HBLANK_B 0x61004 #define I830_HSYNC_B 0x61008 #define I830_VTOTAL_B 0x6100c #define I830_VBLANK_B 0x61010 #define I830_VSYNC_B 0x61014 #define I830_PIPEBSRC 0x6101c #define I830_BCLRPAT_B 0x61020 #define I830_DPLL_A 0x06014 #define I830_DPLL_B 0x06018 #define I830_FPA0 0x06040 #define I830_FPA1 0x06044 #define I830_FPA2 0x06048 #define I830_FPA3 0x0604c #define I830_ADPA 0x61100 #define I830_DVOA 0x61120 #define I830_DVOB 0x61140 #define I830_DVOC 0x61160 #define I830_LVDS 0x61180 #define I830_ADPA_SRCDIM 0x61104 #define I830_DVOA_SRCDIM 0x61124 #define I830_DVOB_SRCDIM 0x61144 #define I830_DVOC_SRCDIM 0x61164 #define I830_LVDS_SRCDIM 0x61184 #define I830_PIPEACONF 0x70008 #define I830_PIPEBCONF 0x71008 #define I830_DSPACTRL 0x70180 #define I830_DSPBCTRL 0x71180 #define I830_DSPABASE 0x70184 #define I830_DSPASTRIDE 0x70188 #define I830_DSPBBASE 0x71184 #define I830_DSPBSTRIDE 0x71188 #define I830_DCLK_0D 0x06000 #define I830_DCLK_1D 0x06004 #define I830_DCLK_0DS 0x06010 #define I830_SWF0 0x71410 #define I830_SWF1 0x71414 #define I830_SWF2 0x71418 #define I830_SWF3 0x7141c #define I830_SWF4 0x71420 #define I830_SWF5 0x71424 #define I830_SWF6 0x71428 #define I830_LCDTV_C 0x06014 #define I855_LCDTV_C 0x61204 static void release_resource(struct i810_par *par) { if (par->flag & I810_MEMOPEN) close(par->mem); if (par->flag & I810_MMIO) munmap(par->mmio, 512 * 1024); } void probe_card_I810(struct i810_par *par) { printf(" DCLK 0D=%08lX 1D=%08lX 0DS=%08lX\n", i810_readl(par->mmio, I810_DCLK_0D), i810_readl(par->mmio, I810_DCLK_1D), i810_readl(par->mmio, I810_DCLK_0DS)); printf(" PWR_CLKC=%08lX HVSYNC=%08lX\n", i810_readl(par->mmio, I810_PWR_CLKC), i810_readl(par->mmio, I810_HVSYNC)); printf(" 020cc=%08lX 020d8=%08lX 020dc=%08lX\n", i810_readl(par->mmio, 0x20cc), i810_readl(par->mmio, 0x20d8), i810_readl(par->mmio, 0x20dc)); printf(" HTOTAL=%08lX HBLANK=%08lX HSYNC=%08lX\n", i810_readl(par->mmio, I810_HTOTAL), i810_readl(par->mmio, I810_HBLANK), i810_readl(par->mmio, I810_HSYNC)); printf(" VTOTAL=%08lX VBLANK=%08lX VSYNC=%08lX\n", i810_readl(par->mmio, I810_VTOTAL), i810_readl(par->mmio, I810_VBLANK), i810_readl(par->mmio, I810_VSYNC)); printf(" OVRACT=%08lX PIXCONF=%08lX 70080=%08lX\n", i810_readl(par->mmio, I810_OVRACT), i810_readl(par->mmio, I810_PIXCONF), i810_readl(par->mmio, 0x70080)); } void probe_card_I830(struct i810_par *par) { printf(" DCLK 0D=%08lX 1D=%08lX 0DS=%08lX DPLL A=%08lX B=%08lX\n", i810_readl(par->mmio, I830_DCLK_0D), i810_readl(par->mmio, I830_DCLK_1D), i810_readl(par->mmio, I830_DCLK_0DS), i810_readl(par->mmio, I830_DPLL_A), i810_readl(par->mmio, I830_DPLL_B)); printf(" ADPA=%08lX DVO A=%08lX B=%08lX C=%08lX LVDS=%08lX\n", i810_readl(par->mmio, I830_ADPA), i810_readl(par->mmio, I830_DVOA), i810_readl(par->mmio, I830_DVOB), i810_readl(par->mmio, I830_DVOC), i810_readl(par->mmio, I830_LVDS)); printf(" DIM =%08lX DIM A=%08lX B=%08lX C=%08lX %08lX\n", i810_readl(par->mmio, I830_ADPA_SRCDIM), i810_readl(par->mmio, I830_DVOA_SRCDIM), i810_readl(par->mmio, I830_DVOB_SRCDIM), i810_readl(par->mmio, I830_DVOC_SRCDIM), i810_readl(par->mmio, I830_LVDS_SRCDIM)); printf(" FPA %08lX %08lX %08lX %08lX\n", i810_readl(par->mmio, I830_FPA0), i810_readl(par->mmio, I830_FPA1), i810_readl(par->mmio, I830_FPA2), i810_readl(par->mmio, I830_FPA3)); printf(" 020cc=%08lX 020d8=%08lX 020dc=%08lX\n", i810_readl(par->mmio, 0x20cc), i810_readl(par->mmio, 0x20d8), i810_readl(par->mmio, 0x20dc)); printf(" 71280=%08lX 71400=%08lX\n", i810_readl(par->mmio, 0x71280), i810_readl(par->mmio, 0x71400)); printf(" Pipe A\n"); printf(" HTOTAL=%08lX HBLANK=%08lX HSYNC=%08lX\n", i810_readl(par->mmio, I830_HTOTAL_A), i810_readl(par->mmio, I830_HBLANK_A), i810_readl(par->mmio, I830_HSYNC_A)); printf(" VTOTAL=%08lX VBLANK=%08lX VSYNC=%08lX\n", i810_readl(par->mmio, I830_VTOTAL_A), i810_readl(par->mmio, I830_VBLANK_A), i810_readl(par->mmio, I830_VSYNC_A)); printf(" SOURCE=%08lX CONFIG=%08lX 70030=%08lX 70080=%08lX\n", i810_readl(par->mmio, I830_PIPEASRC), i810_readl(par->mmio, I830_PIPEACONF), i810_readl(par->mmio, 0x70030), i810_readl(par->mmio, 0x70080)); printf(" Pipe B\n"); printf(" HTOTAL=%08lX HBLANK=%08lX HSYNC=%08lX\n", i810_readl(par->mmio, I830_HTOTAL_B), i810_readl(par->mmio, I830_HBLANK_B), i810_readl(par->mmio, I830_HSYNC_B)); printf(" VTOTAL=%08lX VBLANK=%08lX VSYNC=%08lX\n", i810_readl(par->mmio, I830_VTOTAL_B), i810_readl(par->mmio, I830_VBLANK_B), i810_readl(par->mmio, I830_VSYNC_B)); printf(" SOURCE=%08lX CONFIG=%08lX 71030=%08lX 71080=%08lX\n", i810_readl(par->mmio, I830_PIPEBSRC), i810_readl(par->mmio, I830_PIPEBCONF), i810_readl(par->mmio, 0x71030), i810_readl(par->mmio, 0x71080)); printf(" Display plane A\n"); printf(" CTRL=%08lX BASE=%08lX STRIDE=%08lX\n", i810_readl(par->mmio, I830_DSPACTRL), i810_readl(par->mmio, I830_DSPABASE), i810_readl(par->mmio, I830_DSPASTRIDE)); printf(" Display plane B\n"); printf(" CTRL=%08lX BASE=%08lX STRIDE=%08lX\n", i810_readl(par->mmio, I830_DSPBCTRL), i810_readl(par->mmio, I830_DSPBBASE), i810_readl(par->mmio, I830_DSPBSTRIDE)); } char *i810_chip(char **buff_ptr, int *len_ptr, FILE *pci_f, int* chiptype) { int i; char *p; while (getline(buff_ptr, len_ptr, pci_f) > 0) { i = (p = strstr(*buff_ptr, I810STR)) != NULL || (p = strstr(*buff_ptr, I810ESTR)) != NULL || (p = strstr(*buff_ptr, I810_DC100STR_1)) != NULL || (p = strstr(*buff_ptr, I810_DC100STR_2)) != NULL || (p = strstr(*buff_ptr, I810_IGSTR)) != NULL || (p = strstr(*buff_ptr, I810_CFCSTR)) != NULL; if (i) { *chiptype = I810; return p; } i = (p = strstr(*buff_ptr, I830STR)) != NULL || #if defined (I865STR) (p = strstr(*buff_ptr, I865STR)) != NULL || #endif /*defined (I865STR)*/ (p = strstr(*buff_ptr, I845STR)) != NULL; if (i) { *chiptype = I830; return p; } i = (p = strstr(*buff_ptr, I855STR)) != NULL; if (i) { *chiptype = I855; return p; } i = (p = strstr(*buff_ptr, I915STR)) != NULL; if (i) { *chiptype = I915; return p; } } return NULL; } unsigned long i810_addr(char **buff_ptr, int *len_ptr, FILE *pci_f) { char *p; while (getline(buff_ptr, len_ptr, pci_f) > 0) if (strstr(*buff_ptr, NONPRSTR) != NULL) { p = strstr(*buff_ptr, MEMSTR); if (p != NULL) return strtoul(p+sizeof(MEMSTR), NULL, 16); } return 0; } int i810_usage () { fprintf(stderr, "usage: i810switch [crt on/off] [lcd on/off] [probe]\n"); fprintf(stderr, " crt: enables/disables the output to the CRT display\n"); fprintf(stderr, " lcd: enables/disables the output to the LCD\n"); fprintf(stderr, " probe: dumps the video chipset registers\n"); fprintf(stderr, " no options: displays the current output status\n"); return 1; } int main (int argc, char *argv[]) { struct i810_par par; unsigned long addr; int i, crt = -1, lcd = -1, probe = 0, err = 0, count = 0, chiptype, len = 0; FILE *pci_f; char *buff = NULL; char lspcistr[] = CMD_LSPCI " -v -d xxxx:xxxx"; char *chip; putenv("PATH=/sbin:/usr/sbin:/bin:/usr/bin"); while (--argc > 0) { argv++; if (!strcmp(argv[0], "crt")) { if (--argc > 0) { argv++; if (!strcmp(argv[0], "on")) crt = 1; else if (!strcmp(argv[0], "off")) crt = 0; else exit(i810_usage()); } else { exit(i810_usage()); } } else if (!strcmp(argv[0], "lcd")) { argv++; if (--argc > 0) { if (!strcmp(argv[0], "on")) lcd = 1; else if (!strcmp(argv[0], "off")) lcd = 0; else exit(i810_usage()); } else { exit(i810_usage()); } } else if (!strcmp(argv[0], "probe")) { probe = 1; } else { exit(i810_usage()); } } pci_f = popen(CMD_LSPCI " -n", "r"); if (!pci_f) { fprintf(stderr, "Something is wrong with lspci.\n"); exit(1); } chip = i810_chip(&buff, &len, pci_f, &chiptype); if (chip == NULL) { fprintf(stderr, "PCI id of i810 is not recognized.\n"); exit(1); } pclose(pci_f); { char *p = strstr(lspcistr, "xxxx:xxxx"); if (p == 0) { fprintf(stderr, "CMD_LSPCI is wrong.\n"); exit(1); } memcpy(p, chip, 9); } pci_f = popen(lspcistr, "r"); if (!pci_f) { fprintf(stderr, "Something is wrong with lspci.\n"); exit(1); } addr = i810_addr(&buff, &len, pci_f); if (addr == 0) { fprintf(stderr, "Something is wrong with lspci.\n"); exit(1); } pclose(pci_f); memset(&par, 0, sizeof(struct i810_par)); par.mem = open("/dev/mem", (crt+lcd == -2) ? O_RDONLY : O_RDWR); if (par.mem == -1) { i = errno; perror("/dev/mem"); if (i == EACCES && geteuid() != 0) fprintf(stderr, "Must have access to `/dev/mem'.\n"); release_resource(&par); exit(1); } par.flag |= I810_MEMOPEN; par.mmio = mmap(NULL, 512 * 1024, (crt+lcd == -2) ? PROT_READ : PROT_WRITE | PROT_READ, MAP_SHARED, par.mem, addr); if (!par.mmio) { release_resource(&par); exit(1); } par.flag |= I810_MMIO; if (probe) { char *chipname = (chiptype == I810) ? "i810" : "i830"; printf("i810switch %s probe\n", VERSION); printf("%s (%s) io=0x%8lX\n", chipname, lspcistr + 12, addr); if (chiptype == I810) { probe_card_I810(&par); } else { probe_card_I830(&par); } release_resource(&par); exit(0); } if (crt+lcd == -2) { if (chiptype == I810) { printf("CRT: "); if (i810_readl(par.mmio, I810_PWR_CLKC) & 1) printf("on\n"); else printf("off\n"); printf("LCD: "); if (i810_readl(par.mmio, I810_LCDTV_C) & 0xc00) printf("off\n"); else printf("on\n"); } else if (chiptype == I830 || chiptype == I915) { printf("CRT: "); if (i810_readl(par.mmio, I830_ADPA) & 0x80000000) printf("on\n"); else printf("off\n"); printf("LCD: "); if (i810_readl(par.mmio, I830_LCDTV_C) & 0x40000000) printf("on\n"); else printf("off\n"); } else if (chiptype == I855) { printf("CRT: "); if (i810_readl(par.mmio, I830_ADPA) & 0x80000000) printf("on\n"); else printf("off\n"); printf("LCD: "); if (i810_readl(par.mmio, I855_LCDTV_C) & 1) printf("on\n"); else printf("off\n"); } } if (crt != -1) { if (chiptype == I810) { int pwr_clkc = i810_readl(par.mmio, I810_PWR_CLKC); int hvsync = i810_readl(par.mmio, I810_HVSYNC); if (crt == 0) { printf("Disabling CRT display...\n"); pwr_clkc &= ~1; hvsync = 0xa0000; } else { printf("Enabling CRT display...\n"); pwr_clkc |= 1; hvsync = 0; } i810_writel(par.mmio, I810_PWR_CLKC, pwr_clkc); i810_writel(par.mmio, I810_HVSYNC, hvsync); } else if (chiptype == I830 || chiptype == I855 || chiptype == I915) { int i830_adpa = i810_readl(par.mmio, I830_ADPA); int dspactrl = i810_readl(par.mmio, I830_DSPACTRL); int dspbctrl = i810_readl(par.mmio, I830_DSPBCTRL); int pipe = 0; /* Find active display plane, and use the same pipe it's using */ if (dspactrl & (1<<31)) pipe = (dspactrl & (1<<24)) >> 24; else if (dspbctrl & (1<<31)) pipe = (dspbctrl & (1<<24)) >> 24; else fprintf(stderr, "Warning: No active display plane detected. Trying pipe A.\n"); if (crt == 0) { printf("Disabling CRT display...\n"); i830_adpa = (i830_adpa & ~0x80000000 & ~(pipe<<30)) | 0xc00; } else { printf("Enabling CRT display...\n"); i830_adpa = (i830_adpa | 0x80000000 | (pipe<<30)) & ~0xc00; } i810_writel(par.mmio, I830_ADPA, i830_adpa); } } if (lcd != -1) { if (chiptype == I810) { int lcdtv_c = i810_readl(par.mmio, I810_LCDTV_C); if (lcd == 0) { printf("Disabling LCD...\n"); lcdtv_c |= 0xc00; } else { printf("Enabling LCD...\n"); lcdtv_c &= ~(0xc00); } i810_writel(par.mmio, I810_LCDTV_C, lcdtv_c); } else if (chiptype == I830 || chiptype == I915) { int lcdtv_c; if (lcd == 0) { printf("Disabling LCD...\n"); lcdtv_c = i810_readl(par.mmio, I830_LCDTV_C); lcdtv_c &= ~(0x40000000); i810_writel(par.mmio, I830_LCDTV_C, lcdtv_c); } else { printf("Enabling LCD...\n"); lcdtv_c = i810_readl(par.mmio, I830_LCDTV_C); lcdtv_c |= 0x40000000; i810_writel(par.mmio, I830_LCDTV_C, lcdtv_c); } } else if (chiptype == I855) { int lcdtv_c; if (lcd == 0) { printf("Disabling LCD...\n"); lcdtv_c = i810_readl(par.mmio, I855_LCDTV_C); lcdtv_c &= ~(1); i810_writel(par.mmio, I855_LCDTV_C, lcdtv_c); } else { printf("Enabling LCD...\n"); lcdtv_c |= 1; i810_writel(par.mmio, I855_LCDTV_C, lcdtv_c); } } else fprintf(stderr, "No LCD support for this chipset.\n"); } release_resource(&par); exit(0); }