1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-11-24 00:45:52 +00:00

Add s3switch 0.1, enable TV-out on S3 graphics cards.

PR:		ports/50766
Submitted by:	Bruce M Simpson <bms@spc.org>
This commit is contained in:
Norikatsu Shigemura 2003-04-20 15:22:21 +00:00
parent 6d3edf0ac7
commit f01e723a66
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=79361
8 changed files with 308 additions and 0 deletions

View File

@ -323,6 +323,7 @@
SUBDIR += ruby-svg
SUBDIR += ruby-tgif
SUBDIR += s10sh
SUBDIR += s3switch
SUBDIR += sam2p
SUBDIR += sane-backends
SUBDIR += sane-frontends

View File

@ -0,0 +1,29 @@
# New ports collection makefile for: s3switch
# Date created: March 16, 2003
# Whom: Bruce M Simpson <bms@spc.org>
#
# $FreeBSD$
#
PORTNAME= s3switch
PORTVERSION= 0.1
CATEGORIES= graphics
MASTER_SITES= http://www.probo.com/timr/
DISTNAME= s3ssrc
MAINTAINER= bms@spc.org
COMMENT= Enable TV-out on S3 graphics cards
USE_ZIP= yes
USE_GMAKE= yes
USE_X_PREFIX= yes
NO_WRKSUBDIR= yes
MAKE_ENV+= FREEBSD=1
MAN1= s3switch.1
do-install:
${INSTALL_PROGRAM} ${WRKDIR}/s3switch ${PREFIX}/bin
${INSTALL_MAN} ${WRKDIR}/s3switch.1x ${PREFIX}/man/man1/s3switch.1
.include <bsd.port.mk>

View File

@ -0,0 +1 @@
MD5 (s3ssrc.zip) = 1328b070343ac79c5ed4c613a1113754

View File

@ -0,0 +1,15 @@
--- Makefile.orig Sun Mar 16 03:08:16 2003
+++ Makefile Sun Mar 16 03:08:38 2003
@@ -1,5 +1,11 @@
CC = gcc -g
+ifdef FREEBSD
+LRMIOBJ=
+else
+LRMIOBJ=lrmi.o
+endif
+
all: s3switch
-s3switch: s3switch.o lrmi.o
+s3switch: s3switch.o $(LRMIOBJ)

View File

@ -0,0 +1,14 @@
--- s3switch.1x.orig Wed Sep 11 23:21:19 2002
+++ s3switch.1x Sun Mar 16 03:49:59 2003
@@ -55,8 +55,10 @@
.I S3switch
will not allow you to activate devices which are not connected, on those
chips that are able to detect this.
-.SH AUTHOR
+.SH AUTHORS
Tim Roberts (timr@probo.com)
+.P
+Bruce M Simpson <bms@spc.org> (FreeBSD Port)
.SH "SEE ALSO"
.BR X(1x),
.BR Xserver(1x)

View File

@ -0,0 +1,240 @@
--- s3switch.c.orig Wed Sep 11 23:25:33 2002
+++ s3switch.c Sun Mar 16 03:15:54 2003
@@ -1,7 +1,37 @@
// Simple utility to switch a Savage board between CRT/LCD devices.
// T. N. Roberts, 99-Aug-26.
-// Linux x86 only.
+// Ported to FreeBSD/i386 by Bruce M Simpson <bms@spc.org>
+
+#if defined(__FreeBSD__)
+
+#include <sys/types.h>
+#include <machine/cpufunc.h>
+#include <machine/sysarch.h>
+#include <machine/vm86.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#define OUTB(val,port) outb(port,val)
+#define INB(port) inb(port)
+#define IOPERM(x,y,z) i386_set_ioperm(x,y,z)
+
+typedef struct vm86_intcall_args INTCALL_ARGS_T;
+#define EAX vmf.eax.r_ex
+#define EBX vmf.ebx.r_ex
+#define ECX vmf.ecx.r_ex
+#define EDX vmf.edx.r_ex
+
+#define INTCALL_INIT()
+
+static __inline
+INTCALL(int intnum, INTCALL_ARGS_T *args)
+{
+ args->intnum = intnum;
+ return(!i386_vm86(VM86_INTCALL, args));
+}
+
+#else /* Linux */
#include <stdio.h>
#define extern
@@ -10,6 +40,30 @@
#include "lrmi.h"
+#define OUTB(val,port) outb(val,port)
+#define INB(port) inb(port)
+#define IOPERM(x,y,z) ioperm(x,y,z)
+
+typedef struct LRMI_regs INTCALL_ARGS_T;
+#define EAX eax
+#define EBX ebx
+#define ECX ecx
+#define EDX edx
+
+#define INTCALL_INIT() \
+ do { \
+ if (!LRMI_init()) \
+ return (1); \
+ } while (0)
+
+static __inline
+INTCALL(int intnum, INTCALL_ARGS_T *args)
+{
+ return(LRMI_int(intnum, args));
+}
+
+#endif /* Linux */
+
// Usage:
// s3switch [-q] [crt|lcd|both]
@@ -97,10 +151,10 @@
{
/* Allow or disallow access to I/O ports. */
- ioperm( 0x40, 4, enable );
- ioperm( 0x61, 1, enable );
- ioperm( 0x80, 1, enable );
- ioperm( 0x3b0, 0x30, enable );
+ IOPERM( 0x40, 4, enable );
+ IOPERM( 0x61, 1, enable );
+ IOPERM( 0x80, 1, enable );
+ IOPERM( 0x3b0, 0x30, enable );
}
@@ -109,10 +163,10 @@
{
// Figure out what kind of Savage it is.
- outb( 0x2d, 0x3d4 );
- gPCIid = inb( 0x3d5 ) << 8;
- outb( 0x2e, 0x3d4 );
- gPCIid |= inb( 0x3d5 );
+ OUTB( 0x2d, 0x3d4 );
+ gPCIid = INB( 0x3d5 ) << 8;
+ OUTB( 0x2e, 0x3d4 );
+ gPCIid |= INB( 0x3d5 );
switch( gPCIid ) {
case PCI_CHIP_SAVAGE3D:
@@ -157,21 +211,21 @@
if( ChipClass == S3_SAVAGEMXIX )
{
- outb( 0xc0, 0x3d4 );
- jTvFormat = inb( 0x3d5 );
- outb( 0x6b, 0x3d4 );
- jDevices = inb( 0x3d5 );
+ OUTB( 0xc0, 0x3d4 );
+ jTvFormat = INB( 0x3d5 );
+ OUTB( 0x6b, 0x3d4 );
+ jDevices = INB( 0x3d5 );
}
else
{
- outb( 0x6b, 0x3d4 );
- jTvFormat = inb( 0x3d5 );
- outb( 0x6d, 0x3d4 );
- jDevices = inb( 0x3d5 );
+ OUTB( 0x6b, 0x3d4 );
+ jTvFormat = INB( 0x3d5 );
+ OUTB( 0x6d, 0x3d4 );
+ jDevices = INB( 0x3d5 );
}
- outb( 0x79, 0x3d4 );
- cr79 = inb( 0x3d5 );
+ OUTB( 0x79, 0x3d4 );
+ cr79 = INB( 0x3d5 );
//printf( "Device ID: %04x\n", gPCIid);
@@ -207,24 +261,23 @@
unsigned short
set_active_device( int iDevice )
{
- struct LRMI_regs r;
+ INTCALL_ARGS_T sa;
int iResult = 0;
- if (!LRMI_init())
- return 1;
+ INTCALL_INIT();
/* Go set the active device. */
- memset( &r, 0, sizeof(r) );
+ memset(&sa, 0, sizeof(sa));
- r.eax = 0x4f14; // S3 extended functions
- r.ebx = 0x0003; // set active device
- r.ecx = iDevice;
+ sa.EAX = 0x4F14;
+ sa.EBX = 0x0003;
+ sa.ECX = iDevice;
if( ChipClass == S3_SAVAGEMXIX )
- r.ecx |= DUO_ON;
+ sa.ECX |= DUO_ON;
- iResult = LRMI_int( 0x10, &r );
+ iResult = INTCALL(0x10, &sa);
if( !iResult )
{
@@ -232,7 +285,7 @@
return 1;
}
- if ( (r.eax & 0xffff) != 0x4f )
+ if ( (sa.EAX & 0xffff) != 0x4f )
{
fprintf( stderr, "BIOS returned error code.\n" );
return 1;
@@ -246,22 +299,21 @@
unsigned short
set_tv_state( int state )
{
- struct LRMI_regs r;
+ INTCALL_ARGS_T sa;
int iResult = 0;
- if (!LRMI_init())
- return 1;
+ INTCALL_INIT();
/* And go set the TV state. */
- memset( &r, 0, sizeof(r) );
+ memset(&sa, 0, sizeof(sa));
- r.eax = 0x4f14; // S3 extended functions
- r.ebx = 0x0007; // set tv state
- r.ecx = state;
- r.edx = TV_FORMAT_MASK;
+ sa.EAX = 0x4F14;
+ sa.EBX = 0x0007;
+ sa.ECX = state;
+ sa.EDX = TV_FORMAT_MASK;
- iResult = LRMI_int( 0x10, &r );
+ iResult = INTCALL(0x10, &sa);
if( !iResult )
{
@@ -269,7 +321,7 @@
return 1;
}
- if ( (r.eax & 0xffff) != 0x4f )
+ if ( (sa.EAX & 0xffff) != 0x4f )
{
fprintf( stderr, "BIOS returned error code.\n" );
return 1;
@@ -348,9 +400,9 @@
if( (cr79 == 5) || (cr79 == 8) )
{
cr79 = (cr79 == 5) ? 8 : 0x0e;
- ioperm( 0x3d4, 2, 1 );
+ IOPERM( 0x3d4, 2, 1 );
outw( (cr79 << 8) | 0x79, 0x3d4 );
- ioperm( 0x3d4, 2, 0 );
+ IOPERM( 0x3d4, 2, 0 );
}
}
else if( !(jDevices & LCD_ACTIVE) && (newstate & LCD_ACTIVE) )
@@ -360,9 +412,9 @@
if( (cr79 == 8) || (cr79 == 0xe) )
{
cr79 = (cr79 == 8) ? 5 : 8;
- ioperm( 0x3d4, 2, 1 );
+ IOPERM( 0x3d4, 2, 1 );
outw( (cr79 << 8) | 0x79, 0x3d4 );
- ioperm( 0x3d4, 2, 0 );
+ IOPERM( 0x3d4, 2, 0 );
}
}
}

View File

@ -0,0 +1,7 @@
This is a utility used to enable the TV output on S3 Savage based cards,
which I have ported to run under FreeBSD as well as Linux.
It must be run as root, though I leave you to do this at your discretion.
Bruce
bms@spc.org

View File

@ -0,0 +1 @@
bin/s3switch