Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 10 Apr 2003 04:41:53 +0100 (BST)
From:      Bruce M Simpson <bms@spc.org>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/50766: New port: s3switch - enable TV-Out on S3 chipsets
Message-ID:  <20030410034153.4922549D@saboteur.dollah.com>
Resent-Message-ID: <200304100350.h3A3o767093077@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         50766
>Category:       ports
>Synopsis:       New port: s3switch - enable TV-Out on S3 chipsets
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Apr 09 20:50:07 PDT 2003
>Closed-Date:
>Last-Modified:
>Originator:     Bruce M Simpson
>Release:        FreeBSD 5.0-RELEASE-p6 i386
>Organization:
>Environment:
System: FreeBSD saboteur.dollah.com 5.0-RELEASE-p6 FreeBSD 5.0-RELEASE-p6 #0: Fri Mar 28 09:51:11 GMT 2003 root@saboteur.dollah.com:/usr/src/sys/i386/compile/SABOTEUR_GEOM i386


	
>Description:
	s3switch enables switching between lcd, svga and tv-out on recent
	s3 graphics chipsets. essential for ThinkPad owners.
>How-To-Repeat:
	
>Fix:

	

--- s3switch.shar begins here ---
# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	s3switch
#	s3switch/pkg-descr
#	s3switch/distinfo
#	s3switch/Makefile
#	s3switch/pkg-comment
#	s3switch/pkg-plist
#	s3switch/files
#	s3switch/files/patch-s3switch.c
#	s3switch/files/patch-Makefile
#	s3switch/files/patch-s3switch.1x
#
echo c - s3switch
mkdir -p s3switch > /dev/null 2>&1
echo x - s3switch/pkg-descr
sed 's/^X//' >s3switch/pkg-descr << 'END-of-s3switch/pkg-descr'
XThis is a utility used to enable the TV output on S3 Savage based cards,
Xwhich I have ported to run under FreeBSD as well as Linux.
X
XIt must be run as root, though I leave you to do this at your discretion.
X
XBruce
Xbms@spc.org
END-of-s3switch/pkg-descr
echo x - s3switch/distinfo
sed 's/^X//' >s3switch/distinfo << 'END-of-s3switch/distinfo'
XMD5 (s3ssrc.zip) = 1328b070343ac79c5ed4c613a1113754
END-of-s3switch/distinfo
echo x - s3switch/Makefile
sed 's/^X//' >s3switch/Makefile << 'END-of-s3switch/Makefile'
X# New ports collection makefile for:	s3switch
X# Date created:				March 16, 2003
X# Whom:					Bruce M Simpson <bms@spc.org>
X#
X# $FreeBSD$
X#
X
XPORTNAME=	s3switch
XPORTVERSION=	0.1
XCATEGORIES=	graphics
XMASTER_SITES=	http://www.probo.com/timr/
XDISTNAME=	s3ssrc
X
XMAINTAINER=	bms@spc.org
X
XBUILD_DEPENDS+=	${LOCALBASE}/bin/unzip:${PORTSDIR}/archivers/unzip
X
XUSE_GMAKE=	yes
XUSE_ZIP=	yes
XUSE_X_PREFIX=	yes
XNO_WRKSUBDIR=
XMAKE_ENV+=	FREEBSD=1
X
XMAN1=	s3switch.1
X
Xdo-install:
X	${INSTALL_PROGRAM} ${WRKDIR}/s3switch ${PREFIX}/bin
X	${INSTALL_MAN} ${WRKDIR}/s3switch.1x ${PREFIX}/man/man1/s3switch.1
X
X.include <bsd.port.mk>
END-of-s3switch/Makefile
echo x - s3switch/pkg-comment
sed 's/^X//' >s3switch/pkg-comment << 'END-of-s3switch/pkg-comment'
XEnable TV-out on S3 graphics cards
END-of-s3switch/pkg-comment
echo x - s3switch/pkg-plist
sed 's/^X//' >s3switch/pkg-plist << 'END-of-s3switch/pkg-plist'
Xbin/s3switch
END-of-s3switch/pkg-plist
echo c - s3switch/files
mkdir -p s3switch/files > /dev/null 2>&1
echo x - s3switch/files/patch-s3switch.c
sed 's/^X//' >s3switch/files/patch-s3switch.c << 'END-of-s3switch/files/patch-s3switch.c'
X--- s3switch.c.orig	Wed Sep 11 23:25:33 2002
X+++ s3switch.c	Sun Mar 16 03:15:54 2003
X@@ -1,7 +1,37 @@
X // Simple utility to switch a Savage board between CRT/LCD devices.
X // T. N. Roberts, 99-Aug-26.
X 
X-// Linux x86 only.
X+// Ported to FreeBSD/i386 by Bruce M Simpson <bms@spc.org>
X+
X+#if defined(__FreeBSD__)
X+
X+#include <sys/types.h>
X+#include <machine/cpufunc.h>
X+#include <machine/sysarch.h>
X+#include <machine/vm86.h>
X+#include <stdlib.h>
X+#include <stdio.h>
X+
X+#define OUTB(val,port) outb(port,val)
X+#define INB(port) inb(port)
X+#define IOPERM(x,y,z) i386_set_ioperm(x,y,z)
X+
X+typedef struct vm86_intcall_args INTCALL_ARGS_T;
X+#define EAX vmf.eax.r_ex
X+#define EBX vmf.ebx.r_ex
X+#define ECX vmf.ecx.r_ex
X+#define EDX vmf.edx.r_ex
X+
X+#define INTCALL_INIT()
X+
X+static __inline
X+INTCALL(int intnum, INTCALL_ARGS_T *args)
X+{
X+	args->intnum = intnum;
X+	return(!i386_vm86(VM86_INTCALL, args));
X+}
X+
X+#else /* Linux */
X 
X #include <stdio.h>
X #define extern
X@@ -10,6 +40,30 @@
X 
X #include "lrmi.h"
X 
X+#define OUTB(val,port) outb(val,port)
X+#define INB(port) inb(port)
X+#define IOPERM(x,y,z) ioperm(x,y,z)
X+
X+typedef struct LRMI_regs INTCALL_ARGS_T;
X+#define EAX eax
X+#define EBX ebx
X+#define ECX ecx
X+#define EDX edx
X+
X+#define INTCALL_INIT()			\
X+	do {				\
X+		if (!LRMI_init())	\
X+			return (1);	\
X+	} while (0)
X+
X+static __inline
X+INTCALL(int intnum, INTCALL_ARGS_T *args)
X+{
X+	return(LRMI_int(intnum, args));
X+}
X+
X+#endif /* Linux */
X+
X // Usage:
X //  s3switch [-q] [crt|lcd|both]
X 
X@@ -97,10 +151,10 @@
X {
X     /* Allow or disallow access to I/O ports. */
X 
X-    ioperm( 0x40, 4, enable );
X-    ioperm( 0x61, 1, enable );
X-    ioperm( 0x80, 1, enable );
X-    ioperm( 0x3b0, 0x30, enable );
X+    IOPERM( 0x40, 4, enable );
X+    IOPERM( 0x61, 1, enable );
X+    IOPERM( 0x80, 1, enable );
X+    IOPERM( 0x3b0, 0x30, enable );
X }
X 
X 
X@@ -109,10 +163,10 @@
X {
X     // Figure out what kind of Savage it is.
X 
X-    outb( 0x2d, 0x3d4 );
X-    gPCIid = inb( 0x3d5 ) << 8;
X-    outb( 0x2e, 0x3d4 );
X-    gPCIid |= inb( 0x3d5 );
X+    OUTB( 0x2d, 0x3d4 );
X+    gPCIid = INB( 0x3d5 ) << 8;
X+    OUTB( 0x2e, 0x3d4 );
X+    gPCIid |= INB( 0x3d5 );
X 
X     switch( gPCIid ) {
X 	case PCI_CHIP_SAVAGE3D:
X@@ -157,21 +211,21 @@
X 
X     if( ChipClass == S3_SAVAGEMXIX ) 
X     {
X-	outb( 0xc0, 0x3d4 );
X-	jTvFormat = inb( 0x3d5 );
X-	outb( 0x6b, 0x3d4 );
X-	jDevices = inb( 0x3d5 );
X+	OUTB( 0xc0, 0x3d4 );
X+	jTvFormat = INB( 0x3d5 );
X+	OUTB( 0x6b, 0x3d4 );
X+	jDevices = INB( 0x3d5 );
X     }
X     else 
X     {
X-	outb( 0x6b, 0x3d4 );
X-	jTvFormat = inb( 0x3d5 );
X-	outb( 0x6d, 0x3d4 );
X-	jDevices = inb( 0x3d5 );
X+	OUTB( 0x6b, 0x3d4 );
X+	jTvFormat = INB( 0x3d5 );
X+	OUTB( 0x6d, 0x3d4 );
X+	jDevices = INB( 0x3d5 );
X     }
X 
X-    outb( 0x79, 0x3d4 );
X-    cr79 = inb( 0x3d5 );
X+    OUTB( 0x79, 0x3d4 );
X+    cr79 = INB( 0x3d5 );
X 
X     //printf( "Device ID: %04x\n", gPCIid);
X 
X@@ -207,24 +261,23 @@
X unsigned short
X set_active_device( int iDevice )
X {
X-    struct LRMI_regs r;
X+    INTCALL_ARGS_T sa;
X     int iResult = 0;
X 
X-    if (!LRMI_init())
X-	return 1;
X+    INTCALL_INIT();
X 
X     /* Go set the active device. */
X 
X-    memset( &r, 0, sizeof(r) );
X+    memset(&sa, 0, sizeof(sa));
X 
X-    r.eax = 0x4f14;	// S3 extended functions
X-    r.ebx = 0x0003;	// set active device
X-    r.ecx = iDevice;
X+    sa.EAX = 0x4F14;
X+    sa.EBX = 0x0003;
X+    sa.ECX = iDevice;
X 
X     if( ChipClass == S3_SAVAGEMXIX )
X-	r.ecx |= DUO_ON;
X+	sa.ECX |= DUO_ON;
X 
X-    iResult = LRMI_int( 0x10, &r );
X+    iResult = INTCALL(0x10, &sa);
X 
X     if( !iResult )
X     {
X@@ -232,7 +285,7 @@
X 	return 1;
X     }
X 
X-    if ( (r.eax & 0xffff) != 0x4f )
X+    if ( (sa.EAX & 0xffff) != 0x4f )
X     {
X 	fprintf( stderr, "BIOS returned error code.\n" );
X 	return 1;
X@@ -246,22 +299,21 @@
X unsigned short
X set_tv_state( int state )
X {
X-    struct LRMI_regs r;
X+    INTCALL_ARGS_T sa;
X     int iResult = 0;
X 
X-    if (!LRMI_init())
X-	return 1;
X+    INTCALL_INIT();
X 
X     /* And go set the TV state. */
X 
X-    memset( &r, 0, sizeof(r) );
X+    memset(&sa, 0, sizeof(sa));
X 
X-    r.eax = 0x4f14;	// S3 extended functions
X-    r.ebx = 0x0007;	// set tv state
X-    r.ecx = state;
X-    r.edx = TV_FORMAT_MASK;
X+    sa.EAX = 0x4F14;
X+    sa.EBX = 0x0007;
X+    sa.ECX = state;
X+    sa.EDX = TV_FORMAT_MASK;
X 
X-    iResult = LRMI_int( 0x10, &r );
X+    iResult = INTCALL(0x10, &sa);
X 
X     if( !iResult )
X     {
X@@ -269,7 +321,7 @@
X 	return 1;
X     }
X 
X-    if ( (r.eax & 0xffff) != 0x4f )
X+    if ( (sa.EAX & 0xffff) != 0x4f )
X     {
X 	fprintf( stderr, "BIOS returned error code.\n" );
X 	return 1;
X@@ -348,9 +400,9 @@
X 	    if( (cr79 == 5) || (cr79 == 8) )
X 	    {
X 		cr79 = (cr79 == 5) ? 8 : 0x0e;
X-		ioperm( 0x3d4, 2, 1 );
X+		IOPERM( 0x3d4, 2, 1 );
X 		outw( (cr79 << 8) | 0x79, 0x3d4 );
X-		ioperm( 0x3d4, 2, 0 );
X+		IOPERM( 0x3d4, 2, 0 );
X 	    }
X 	}
X 	else if( !(jDevices & LCD_ACTIVE) && (newstate & LCD_ACTIVE) )
X@@ -360,9 +412,9 @@
X 	    if( (cr79 == 8) || (cr79 == 0xe) )
X 	    {
X 		cr79 = (cr79 == 8) ? 5 : 8;
X-		ioperm( 0x3d4, 2, 1 );
X+		IOPERM( 0x3d4, 2, 1 );
X 		outw( (cr79 << 8) | 0x79, 0x3d4 );
X-		ioperm( 0x3d4, 2, 0 );
X+		IOPERM( 0x3d4, 2, 0 );
X 	    }
X 	}
X     }
END-of-s3switch/files/patch-s3switch.c
echo x - s3switch/files/patch-Makefile
sed 's/^X//' >s3switch/files/patch-Makefile << 'END-of-s3switch/files/patch-Makefile'
X--- Makefile.orig	Sun Mar 16 03:08:16 2003
X+++ Makefile	Sun Mar 16 03:08:38 2003
X@@ -1,5 +1,11 @@
X CC = gcc -g
X 
X+ifdef FREEBSD
X+LRMIOBJ=
X+else
X+LRMIOBJ=lrmi.o
X+endif
X+
X all: s3switch
X 
X-s3switch: s3switch.o lrmi.o
X+s3switch: s3switch.o $(LRMIOBJ)
END-of-s3switch/files/patch-Makefile
echo x - s3switch/files/patch-s3switch.1x
sed 's/^X//' >s3switch/files/patch-s3switch.1x << 'END-of-s3switch/files/patch-s3switch.1x'
X--- s3switch.1x.orig	Wed Sep 11 23:21:19 2002
X+++ s3switch.1x	Sun Mar 16 03:49:59 2003
X@@ -55,8 +55,10 @@
X .I S3switch
X will not allow you to activate devices which are not connected, on those
X chips that are able to detect this.
X-.SH AUTHOR
X+.SH AUTHORS
X Tim Roberts (timr@probo.com)
X+.P
X+Bruce M Simpson <bms@spc.org> (FreeBSD Port)
X .SH "SEE ALSO"
X .BR X(1x), 
X .BR Xserver(1x)
END-of-s3switch/files/patch-s3switch.1x
exit
--- s3switch.shar ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030410034153.4922549D>