#!/bin/sh -e

# 09_alpha_build_fixes.dpatch by Steve Kowalik

# DP: Fix the ISA Pinnacle driver by using phys_to_virt rather than the
# DP: undefined (on Alpha, anyway), __ISA_IO_base.

. debian/patches/patch-opts

if [ $# -ne 1 ]; then
    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
    exit 1
fi

case "$1" in
       -patch) patch $patch_opts -p1 < $0;;
       -unpatch) patch $patch_opts -p1 -R < $0;;
        *)
                echo >&2 "`basename $0`: script expects -patch|-unpatch as argum
ent"
                exit 1;;
esac

exit 0

@DPATCH@

--- alsa-driver/isa/msnd/msnd_pinnacle.c~	23 Apr 2003 10:01:18 -0000	1.1.1.2
+++ alsa-driver/isa/msnd/msnd_pinnacle.c	14 May 2003 13:02:29 -0000
@@ -421,7 +421,7 @@
 		#endif
 		#ifdef CONFIG_SND_DEBUG0
 		{
-			int xx = *(short int*)(__ISA_IO_base + 0x7F40 + dev.base);
+			int xx = *(short int*)(phys_to_virt(0) + 0x7F40 + dev.base);
 			printk(  "%08X: P %X\n", (unsigned)jiffies, xx);
 		}
 		#endif
@@ -940,7 +940,7 @@
 	snd_msnd_enable_irq( &dev);
 
 	runtime->dma_area =	dev.mappedbase;
-	//memset( __ISA_IO_base + dev.base, 0, 3*0x2400);
+	//memset( phys_to_virt(0) + dev.base, 0, 3*0x2400);
 	runtime->dma_bytes =	0x3000;
 
 	dpcm->timer.data =	(unsigned long) dpcm;
@@ -992,13 +992,13 @@
 	/* stuff i used to get it basically making noise:
 	{
 	double phase = 0.0;
-	generate_sine((short int*)(__ISA_IO_base + dev.base), dev.play_channels,
+	generate_sine((short int*)(phys_to_virt(0) + dev.base), dev.play_channels,
 				  0,
 				  0x2400, &phase, 4, dev.play_sample_rate) ;
-	generate_sine((short int*)(__ISA_IO_base + dev.base + 1*0x2400), dev.play_channels,
+	generate_sine((short int*)(phys_to_virt(0) + dev.base + 1*0x2400), dev.play_channels,
 				  0,
 				  0x2400, &phase, 4, dev.play_sample_rate);
-	generate_sine((short int*)(__ISA_IO_base + dev.base + 2*0x2400), dev.play_channels,
+	generate_sine((short int*)(phys_to_virt(0) + dev.base + 2*0x2400), dev.play_channels,
 				  0,
 				  0x2400, &phase, 4, dev.play_sample_rate);
 	}*/
@@ -1068,7 +1068,7 @@
 	/*	with the following mess i tried to generate a more precise pointer position
 	 *	it generated errors with the alsa framework i could not resolve.....
 	//int pos = dev.playDMAPos;
-	unsigned	remaining = *(short int*)(__ISA_IO_base + 0x7F40 + dev.base),
+	unsigned	remaining = *(short int*)(phys_to_virt(0) + 0x7F40 + dev.base),
 	 		ljiffies = (unsigned)jiffies;
 	int		diff;
 	if( -1 == played_bytes){
@@ -1280,13 +1280,13 @@
 	}
 	request_region(dev.io, dev.numio, dev.name);
 
-	dev.mappedbase = (void*)( __ISA_IO_base + dev.base);
+	dev.mappedbase = (void*)( phys_to_virt(0) + dev.base);
 
 	/* geht nich!!!!!
 		useless, don't do this at home.
 		the multisound has shared isa memory that is by default already maped.
 
-	if( ( dev.mappedbase = request_mem_region( (unsigned)(__ISA_IO_base + dev.base), BUFFSIZE, "MSNDPINNACLE")) == NULL) {
+	if( ( dev.mappedbase = request_mem_region( (unsigned)(phys_to_virt(0) + dev.base), BUFFSIZE, "MSNDPINNACLE")) == NULL) {
 		printk( KERN_ERR LOGNAME ": unable to grab memory region 0x%lx-0x%lx\n",
 			   dev.base, dev.base + BUFFSIZE - 1);
 		release_region( dev.io, dev.numio);
