summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTormod Volden <debian.tormod@gmail.com>2012-05-27 17:13:08 +0200
committerTormod Volden <debian.tormod@gmail.com>2012-05-27 17:13:08 +0200
commit59f393823859956ebd1d2ac1844cda7ec527ddcf (patch)
tree6ddcf2bcd63636f0e211dee1766dd99bb1aab941
parent4a86e32b8caa9fd37ae4dcecd21e4ef771c76545 (diff)
Consistently use /* */ style comments instead of //HEADmaster
Also clean up some obsolete comments Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
-rw-r--r--s3switch.c61
1 files changed, 26 insertions, 35 deletions
diff --git a/s3switch.c b/s3switch.c
index aa5d863..5d73a5a 100644
--- a/s3switch.c
+++ b/s3switch.c
@@ -1,9 +1,5 @@
-// Simple utility to switch a Savage board between CRT/LCD devices.
-// T. N. Roberts, 99-Aug-26.
-
-// Modified by mADAR
-// added S3 Virge/GX2 support
-
+/* Simple utility to switch a Savage board between CRT/LCD devices.
+ T. N. Roberts, 99-Aug-26. */
#include <stdio.h>
#include <stdlib.h>
@@ -18,10 +14,7 @@
#define S3SWITCH_VERSION_STRING "0.1"
-// Usage:
-// s3switch [-q] [crt|lcd|both]
-
-// Define the Savage chip classes. PCI id's stolen from xf86PciInfo.h
+/* Define the Savage chip classes. PCI IDs taken from xorg driver */
#define PCI_CHIP_VIRGEGX2 0x8A10
#define PCI_CHIP_SAVAGE3D 0x8A20
@@ -58,10 +51,10 @@ enum {
S3_SUPERSAVAGE
} ChipClass;
-// Define the device attachment bits. This is CR6D on the non-mobile
-// chips, and CR6B on the mobiles.
+/* Define the device attachment bits. This is CR6D on the non-mobile
+ chips, and CR6B on the mobiles.
-// Savage3D does not support LCD, and the Savage4 does not support TV.
+ Savage3D does not support LCD, and the Savage4 does not support TV. */
#define CRT_ACTIVE 0x01
#define LCD_ACTIVE 0x02
@@ -75,14 +68,14 @@ static char * devices[] = {
" CRT", " LCD", " TV"
};
-// Define the TV format bits in CR6B (non-mobile) or CRC0 (mobile).
+/* Define the TV format bits in CR6B (non-mobile) or CRC0 (mobile). */
#define TV_FORMAT_MASK 0x0c
#define TV_FORMAT_NTSCJ 0x00
#define TV_FORMAT_NTSC 0x04
#define TV_FORMAT_PAL 0x08
-// Global state:
+/* Global state: */
unsigned int gPCIid = 0;
unsigned char jTvFormat = 0;
@@ -122,7 +115,7 @@ IOAccess( int enable )
void
fetch_bios_data()
{
- // Figure out what kind of Savage it is.
+ /* Figure out what kind of Savage it is. */
outb( 0x2d, 0x3d4 );
gPCIid = inb( 0x3d5 ) << 8;
@@ -198,10 +191,8 @@ fetch_bios_data()
outb( 0x79, 0x3d4 );
cr79 = inb( 0x3d5 );
- //printf( "Device ID: %04x\n", gPCIid);
-
- // The Savage4 and Savage2000 are the only chips which actually detect
- // the presence of the devices. For the others, we just have to assume.
+ /* The Savage4 and Savage2000 are the only chips which actually detect
+ the presence of the devices. For the others, we just have to assume. */
switch( ChipClass )
{
@@ -248,8 +239,8 @@ set_active_device( int iDevice )
memset( &r, 0, sizeof(r) );
- r.eax = 0x4f14; // S3 extended functions
- r.ebx = 0x0003; // set active device
+ r.eax = 0x4f14; /* S3 extended functions */
+ r.ebx = 0x0003; /* set active device */
r.ecx = iDevice;
if( ChipClass == S3_SAVAGEMXIX )
@@ -287,8 +278,8 @@ set_tv_state( int state )
memset( &r, 0, sizeof(r) );
- r.eax = 0x4f14; // S3 extended functions
- r.ebx = 0x0007; // set tv state
+ r.eax = 0x4f14; /* S3 extended functions */
+ r.ebx = 0x0007; /* set TV state */
r.ecx = state;
r.edx = TV_FORMAT_MASK;
@@ -318,7 +309,7 @@ print_current_state()
if( !(jDevices & 0x70) )
{
- // How can this be?
+ /* How can this be? */
printf( "none" );
}
else
@@ -330,7 +321,7 @@ print_current_state()
if( !(jDevices & 0x07) )
{
- // How can this be?
+ /* How can this be? */
printf( "none\n" );
}
else
@@ -355,26 +346,26 @@ print_current_state()
void
set_new_state( int newstate )
{
- // We should prohibit TV on Savage4.
+ /* We should prohibit TV on Savage4. */
if( ((jDevices >> 4) & newstate) != newstate )
{
fprintf( stderr, "You attempted to activate a device which is not connected.\n" );
- // Alternatively, quiet = 0, return.
+ /* Alternatively, quiet = 0, return. */
print_current_state();
exit( -2 );
}
set_active_device( newstate );
- // If the LCD state changed, we need to adjust cr79 in Savage4.
- // These values are somewhat magical, and are set by the X server.
+ /* If the LCD state changed, we need to adjust cr79 in Savage4.
+ These values are somewhat magical, and are set by the X server. */
if( (ChipClass == S3_SAVAGE4) || (ChipClass == S3_SAVAGE2000) )
{
if( (jDevices & LCD_ACTIVE) && !(newstate & LCD_ACTIVE) )
{
- // The LCD was alive and now it isn't. We can increase cr79.
+ /* The LCD was alive and now it isn't. We can increase cr79. */
if( (cr79 == 5) || (cr79 == 8) )
{
@@ -386,7 +377,7 @@ set_new_state( int newstate )
}
else if( !(jDevices & LCD_ACTIVE) && (newstate & LCD_ACTIVE) )
{
- // The LCD was off and now it's on. We must cut back cr79.
+ /* The LCD was off and now it's on. We must cut back cr79. */
if( (cr79 == 8) || (cr79 == 0xe) )
{
@@ -422,7 +413,7 @@ dump_regs()
{
int i;
- // Print out sequential registers
+ /* Print out sequential registers */
printf( "\nSR x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF" );
for ( i = 0; i < 0x70; i++ ) {
if ( !(i % 16) )
@@ -432,7 +423,7 @@ dump_regs()
}
printf( "\n" );
- // Print out CRT controller registers
+ /* Print out CRT controller registers */
printf( "\nCR x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF" );
for ( i = 0; i < 0xb7; i++ ) {
if ( !(i % 16) )
@@ -451,7 +442,7 @@ main( int argc, char ** argv )
int newtv = -1;
int regdump = 0;
- // Scan through the argument list. We do very primitive checking here.
+ /* Scan through the argument list. We do very primitive checking here. */
while( *++argv )
{