On Wed, 16 Jan 2002, Helge Hafting wrote:

> I use alsa 0.9.0beta10 for sound.  It used to work fine, but
> don't compile with linux kernel 2.5.2.  This seems to
> be a problem with the kdev_t type that have changed lately.
>
> Is there a patch for this?
>
> Helge Hafting

Here is a patch to get 0.9.0beta10 working under 2.5.x. Enjoy it :)

(2HH : sorry, first I forgot to CC the list)

Bye
--

        Tomas Kasparek (sioux, xkaspa06)
         [EMAIL PROTECTED]
         [EMAIL PROTECTED]
        student UIVT FEI VUT Brno
diff -N -r -u alsa-driver-0.9.0beta10/Makefile alsa-driver-own/Makefile
--- alsa-driver-0.9.0beta10/Makefile    Mon Oct  1 09:26:48 2001
+++ alsa-driver-own/Makefile    Wed Jan 16 11:40:25 2002
@@ -30,8 +30,9 @@
 
 all: compile
 
-sound:
+symlinks:
        ln -sf include sound
+       cd include && ln -sf /usr/include/linux/major.h majors.h
 
 include/sndversions.h:
        make dep
@@ -44,7 +45,7 @@
          cp utils/patches/byteswap.h /usr/include ; \
        fi
 
-compile: /usr/include/byteswap.h sound include/sndversions.h include/isapnp.h 
cards.config
+compile: /usr/include/byteswap.h symlinks include/sndversions.h include/isapnp.h 
+cards.config
        @for d in $(SUBDIRS); do if ! $(MAKE) -C $$d; then exit 1; fi; done
        @echo
        @echo "ALSA modules were successfully compiled."
@@ -109,14 +110,15 @@
        rm -f doc/*~
 
 mrproper: clean
+       $(MAKE) -C utils mrproper
+       $(MAKE) -C include mrproper
        rm -f config.cache config.log config.status Makefile.conf
-       rm -f utils/alsa-driver.spec
+       rm -f snddevices version cards.config sound
 
 cvsclean: mrproper
-       rm -f configure snddevices aclocal.m4 include/config.h include/isapnp.h
+       rm -f configure aclocal.m4 include/isapnp.h
 
 pack: mrproper
-       chmod 755 utils/alsasound
        mv ../alsa-driver ../alsa-driver-$(CONFIG_SND_VERSION)
        tar --exclude=CVS --owner=root --group=root -cvI -C .. -f 
../alsa-driver-$(CONFIG_SND_VERSION).tar.bz2 alsa-driver-$(CONFIG_SND_VERSION)
        mv ../alsa-driver-$(CONFIG_SND_VERSION) ../alsa-driver
diff -N -r -u alsa-driver-0.9.0beta10/configure.in alsa-driver-own/configure.in
--- alsa-driver-0.9.0beta10/configure.in        Wed Jan 16 11:22:45 2002
+++ alsa-driver-own/configure.in        Wed Jan 16 11:24:48 2002
@@ -634,7 +634,8 @@
 AC_SUBST(GENKSYMS)
 
 dnl Output files...
-AC_OUTPUT(version Makefile.conf snddevices utils/alsa-driver.spec utils/buildrpm 
cards.config)
+AC_OUTPUT(version Makefile.conf snddevices utils/alsa-driver.spec utils/buildrpm 
+cards.config utils/alsasound)
 
 dnl Make right rights for scripts
 chmod 755 $srcdir/snddevices
+chmod 755 $srcdir/utils/alsasound
diff -N -r -u alsa-driver-0.9.0beta10/include/Makefile 
alsa-driver-own/include/Makefile
--- alsa-driver-0.9.0beta10/include/Makefile    Wed May 12 00:07:17 1999
+++ alsa-driver-own/include/Makefile    Wed Jan 16 11:40:38 2002
@@ -11,3 +11,5 @@
 clean:
        rm -f core .depend *.o *.orig *~ modules/*.ver
 
+mrproper:
+       rm -f config.h config1.h version.h majors.h
diff -N -r -u alsa-driver-0.9.0beta10/kernel/control.c 
alsa-driver-own/kernel/control.c
--- alsa-driver-0.9.0beta10/kernel/control.c    Fri Oct 12 12:51:53 2001
+++ alsa-driver-own/kernel/control.c    Wed Jan 16 10:19:37 2002
@@ -36,7 +36,7 @@
 
 static int snd_ctl_open(struct inode *inode, struct file *file)
 {
-       int cardnum = SNDRV_MINOR_CARD(MINOR(inode->i_rdev));
+       int cardnum = SNDRV_MINOR_CARD(minor(inode->i_rdev));
        unsigned long flags;
        snd_card_t *card;
        snd_ctl_file_t *ctl;
diff -N -r -u alsa-driver-0.9.0beta10/kernel/hwdep.c alsa-driver-own/kernel/hwdep.c
--- alsa-driver-0.9.0beta10/kernel/hwdep.c      Sat Oct 13 12:44:14 2001
+++ alsa-driver-own/kernel/hwdep.c      Wed Jan 16 10:34:03 2002
@@ -23,6 +23,7 @@
 #include <sound/driver.h>
 #include <sound/control.h>
 #include <sound/minors.h>
+#include <sound/majors.h>
 #include <sound/hwdep.h>
 #include <sound/info.h>
 
@@ -69,7 +70,7 @@
 
 static int snd_hwdep_open(struct inode *inode, struct file * file)
 {
-       int major = MAJOR(inode->i_rdev);
+       int major = major(inode->i_rdev);
        int cardnum;
        int device;
        snd_hwdep_t *hw;
@@ -78,12 +79,12 @@
 
        switch (major) {
        case CONFIG_SND_MAJOR:
-               cardnum = SNDRV_MINOR_CARD(MINOR(inode->i_rdev));
-               device = SNDRV_MINOR_DEVICE(MINOR(inode->i_rdev)) - SNDRV_MINOR_HWDEP;
+               cardnum = SNDRV_MINOR_CARD(minor(inode->i_rdev));
+               device = SNDRV_MINOR_DEVICE(minor(inode->i_rdev)) - SNDRV_MINOR_HWDEP;
                break;
 #ifdef CONFIG_SND_OSSEMUL
        case SOUND_MAJOR:
-               cardnum = SNDRV_MINOR_OSS_CARD(MINOR(inode->i_rdev));
+               cardnum = SNDRV_MINOR_OSS_CARD(minor(inode->i_rdev));
                device = 0;
                break;
 #endif
diff -N -r -u alsa-driver-0.9.0beta10/kernel/info.c alsa-driver-own/kernel/info.c
--- alsa-driver-0.9.0beta10/kernel/info.c       Wed Nov 21 16:31:14 2001
+++ alsa-driver-own/kernel/info.c       Wed Jan 16 10:18:51 2002
@@ -851,7 +851,7 @@
 #else
 static inline void snd_info_device_entry_prepare(struct proc_dir_entry *de, 
snd_info_entry_t *entry)
 {
-       de->rdev = MKDEV(entry->c.device.major, entry->c.device.minor);
+       de->rdev = mk_kdev(entry->c.device.major, entry->c.device.minor);
        de->owner = THIS_MODULE;
 }
 #endif /* LINUX_2_3 */
diff -N -r -u alsa-driver-0.9.0beta10/kernel/oss/mixer_oss.c 
alsa-driver-own/kernel/oss/mixer_oss.c
--- alsa-driver-0.9.0beta10/kernel/oss/mixer_oss.c      Fri Oct 12 12:43:18 2001
+++ alsa-driver-own/kernel/oss/mixer_oss.c      Wed Jan 16 10:35:03 2002
@@ -33,7 +33,7 @@
 
 static int snd_mixer_oss_open(struct inode *inode, struct file *file)
 {
-       int cardnum = SNDRV_MINOR_OSS_CARD(MINOR(inode->i_rdev));
+       int cardnum = SNDRV_MINOR_OSS_CARD(minor(inode->i_rdev));
        snd_card_t *card;
        snd_mixer_oss_file_t *fmixer;
 
diff -N -r -u alsa-driver-0.9.0beta10/kernel/oss/pcm_oss.c 
alsa-driver-own/kernel/oss/pcm_oss.c
--- alsa-driver-0.9.0beta10/kernel/oss/pcm_oss.c        Fri Oct 12 12:43:18 2001
+++ alsa-driver-own/kernel/oss/pcm_oss.c        Wed Jan 16 10:35:38 2002
@@ -1488,7 +1488,7 @@
 
 static int snd_pcm_oss_open(struct inode *inode, struct file *file)
 {
-       int minor = MINOR(inode->i_rdev);
+       int minor = minor(inode->i_rdev);
        int cardnum = SNDRV_MINOR_OSS_CARD(minor);
        int device;
        int err;
diff -N -r -u alsa-driver-0.9.0beta10/kernel/pcm_native.c 
alsa-driver-own/kernel/pcm_native.c
--- alsa-driver-0.9.0beta10/kernel/pcm_native.c Mon Nov 19 17:13:44 2001
+++ alsa-driver-own/kernel/pcm_native.c Wed Jan 16 10:20:51 2002
@@ -1413,11 +1413,11 @@
                return 0;
        inode = file->f_dentry->d_inode;
        if (!S_ISCHR(inode->i_mode) ||
-           MAJOR(inode->i_rdev) != CONFIG_SND_MAJOR) {
+           major(inode->i_rdev) != CONFIG_SND_MAJOR) {
                fput(file);
                return 0;
        }
-       minor = MINOR(inode->i_rdev);
+       minor = minor(inode->i_rdev);
        if (minor >= 256 || 
            minor % SNDRV_MINOR_DEVICES < SNDRV_MINOR_PCM_PLAYBACK) {
                fput(file);
@@ -1887,8 +1887,8 @@
 
 int snd_pcm_open(struct inode *inode, struct file *file)
 {
-       int cardnum = SNDRV_MINOR_CARD(MINOR(inode->i_rdev));
-       int device = SNDRV_MINOR_DEVICE(MINOR(inode->i_rdev));
+       int cardnum = SNDRV_MINOR_CARD(minor(inode->i_rdev));
+       int device = SNDRV_MINOR_DEVICE(minor(inode->i_rdev));
        int err;
        snd_pcm_t *pcm;
        snd_pcm_file_t *pcm_file;
diff -N -r -u alsa-driver-0.9.0beta10/kernel/rawmidi.c 
alsa-driver-own/kernel/rawmidi.c
--- alsa-driver-0.9.0beta10/kernel/rawmidi.c    Fri Oct 12 12:57:23 2001
+++ alsa-driver-own/kernel/rawmidi.c    Wed Jan 16 10:31:36 2002
@@ -25,6 +25,7 @@
 #include <sound/info.h>
 #include <sound/control.h>
 #include <sound/minors.h>
+#include <sound/majors.h>
 #include <sound/initval.h>
 
 MODULE_AUTHOR("Jaroslav Kysela <[EMAIL PROTECTED]>");
@@ -331,7 +332,7 @@
 
 static int snd_rawmidi_open(struct inode *inode, struct file *file)
 {
-       int major = MAJOR(inode->i_rdev);
+       int major = major(inode->i_rdev);
        int cardnum;
        snd_card_t *card;
        int device, subdevice;
@@ -345,13 +346,13 @@
 
        switch (major) {
        case CONFIG_SND_MAJOR:
-               cardnum = SNDRV_MINOR_CARD(MINOR(inode->i_rdev));
-               device = SNDRV_MINOR_DEVICE(MINOR(inode->i_rdev)) - 
SNDRV_MINOR_RAWMIDI;
+               cardnum = SNDRV_MINOR_CARD(minor(inode->i_rdev));
+               device = SNDRV_MINOR_DEVICE(minor(inode->i_rdev)) - 
+SNDRV_MINOR_RAWMIDI;
                break;
 #ifdef CONFIG_SND_OSSEMUL
        case SOUND_MAJOR:
-               cardnum = SNDRV_MINOR_OSS_CARD(MINOR(inode->i_rdev));
-               device = SNDRV_MINOR_OSS_DEVICE(inode->i_rdev) == SNDRV_MINOR_OSS_MIDI 
?
+               cardnum = SNDRV_MINOR_OSS_CARD(minor(inode->i_rdev));
+               device = SNDRV_MINOR_OSS_DEVICE(kdev_t_to_nr(inode->i_rdev)) == 
+SNDRV_MINOR_OSS_MIDI ?
                        snd_midi_map[cardnum] : snd_amidi_map[cardnum];
                break;
 #endif
diff -N -r -u alsa-driver-0.9.0beta10/kernel/sound.c alsa-driver-own/kernel/sound.c
--- alsa-driver-0.9.0beta10/kernel/sound.c      Wed Nov 28 21:54:18 2001
+++ alsa-driver-own/kernel/sound.c      Wed Jan 16 10:16:29 2002
@@ -113,7 +113,7 @@
 
 static int snd_open(struct inode *inode, struct file *file)
 {
-       int minor = MINOR(inode->i_rdev);
+       int minor = minor(inode->i_rdev);
        int card = SNDRV_MINOR_CARD(minor);
        int dev = SNDRV_MINOR_DEVICE(minor);
        snd_minor_t *mptr = NULL;
diff -N -r -u alsa-driver-0.9.0beta10/readme4perex alsa-driver-own/readme4perex
--- alsa-driver-0.9.0beta10/readme4perex        Thu Jan  1 01:00:00 1970
+++ alsa-driver-own/readme4perex        Wed Jan 16 11:36:24 2002
@@ -0,0 +1,9 @@
+What I have done:
+
+- updated for kernel 2.5.2-pre10 (branch?)
+- modified make system (remove unneded files generated from .in)
+- updated /etc/init.d/alsasound creation - use @prefix@ there
+
+And you should:
+
+- remove snd drivers for iPAQ from TODO :)
diff -N -r -u alsa-driver-0.9.0beta10/utils/Makefile alsa-driver-own/utils/Makefile
--- alsa-driver-0.9.0beta10/utils/Makefile      Thu Aug 17 11:56:10 2000
+++ alsa-driver-own/utils/Makefile      Wed Jan 16 11:27:31 2002
@@ -18,7 +18,7 @@
        $(CC) $(INCLUDE) -c -o $*.o $<
 
 all: $(TARGETS)
-
+    
 snd-deps: snd-deps-find.o snd-deps-output.o
        $(CC) $(INCLUDE) snd-deps-find.o snd-deps-output.o -o $@ 
 
@@ -38,6 +38,12 @@
 
 clean:
        rm -f core .depend *.o *.orig *~
+       rm -f $(TARGETS)
+
+mrproper:
+       rm -f alsasound
+       rm -f alsa-driver.spec
+       rm -f buildrpm
 
 .depend:
        $(CPP) $(INCLUDE) *.c > .depend
diff -N -r -u alsa-driver-0.9.0beta10/utils/alsasound.in 
alsa-driver-own/utils/alsasound.in
--- alsa-driver-0.9.0beta10/utils/alsasound.in  Thu Jan  1 01:00:00 1970
+++ alsa-driver-own/utils/alsasound.in  Wed Jan 16 11:03:33 2002
@@ -0,0 +1,193 @@
+#!/bin/bash
+#
+# alsasound     This shell script takes care of starting and stopping
+#               the ALSA sound driver.
+#
+# This script requires /usr/sbin/alsactl and /usr/bin/aconnect programs
+# from the alsa-utils package.
+#
+# Copyright (c) by Jaroslav Kysela <[EMAIL PROTECTED]> 
+#
+#
+#  This program is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  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., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+#
+# For RedHat 5.0+:
+# chkconfig: 2345 87 14
+# description: ALSA driver
+#
+# modified to visually fit into SuSE 6.0+ by Philipp Thomas <[EMAIL PROTECTED]>
+# further improvements by Bernd Kaindl, Olaf Hering and Takashi Iwai.
+# 
+### BEGIN INIT INFO
+# Provides:       alsasound
+# Required-Start: $remote_fs
+# Required-Stop: $remote_fs
+# Default-Start:  2 3 5
+# Default-Stop:
+# Description:    Loading ALSA drivers and store/restore the current setting
+### END INIT INFO
+
+if [ -r /etc/rc.config ]; then
+  . /etc/rc.config
+  rc_warning="\033[33m\033[1m"
+else
+  rc_done="done"
+  rc_warning=""
+  rc_reset=""
+fi
+
+if [ x$START_ALSA != xno ]; then
+  START_ALSA=yes
+fi
+if [ x$START_ALSA_SEQ != xno ]; then
+  START_ALSA_SEQ=yes
+fi
+
+# Determine the base and follow a runlevel link name.
+base=${0##*/}
+link=${base#*[SK][0-9][0-9]}
+
+# Force execution if not called by a runlevel directory.
+test $link = $base && START_ALSA=yes
+test "$START_ALSA" = yes || exit 0
+
+alsactl=@prefix@/sbin/alsactl
+asoundcfg=/etc/asound.state
+aconnect=@prefix@/bin/aconnect
+alsascrdir=/etc/alsa.d
+
+function start() {
+  #
+  # insert all sound modules
+  #
+
+  drivers=`/sbin/modprobe -c | \
+    grep -E "^[[:space:]]*alias[[:space:]]+snd-card-[[:digit:]]" | \
+    awk '{print $3}'`
+  for i in $drivers; do
+    if [ "$i" != off ]; then
+      echo -n "Starting sound driver: $i "
+      /sbin/modprobe $i
+      echo -e "$rc_done"
+    fi
+  done
+  #
+  # insert sequencer modules
+  #
+  if [ x"$START_ALSA_SEQ" = xyes -a -r /proc/asound/seq/drivers ]; then
+    t=`cut -d , -f 1 /proc/asound/seq/drivers`
+    if [ "x$t" != "x" ]; then
+      /sbin/modprobe $t
+    fi
+  fi
+  #
+  # restore driver settings
+  #
+  if [ -d /proc/asound ]; then
+    if [ ! -r $asoundcfg ]; then
+      echo "No mixer config in $asoundcfg, you have to unmute your card!"
+    else
+      if [ -x $alsactl ]; then
+        $alsactl -f $asoundcfg restore
+      else
+        echo -e "${rc_warning}ERROR: alsactl not found${rc_reset}"
+      fi
+    fi
+  fi
+  #
+  # run card-dependent scripts
+  for i in $drivers; do
+    t=`echo $i | sed -e 's/snd-card-\(.*\)/\1/'`
+    if [ -x $alsascrdir/$t ]; then
+      $alsascrdir/$t
+    fi
+  done
+}
+
+function terminate() {
+  #
+  # Kill processes holding open sound devices
+  #
+  # DEVS=`find /dev/ -follow -type c -maxdepth 1 -print 2>/dev/null | xargs ls -dils 
+| grep "1*1[46]," | cut -d: -f2 | cut -d" " -f2; echo /proc/asound/dev/*`
+  ossdevs="/dev/admmidi? /dev/adsp? /dev/amidi? /dev/audio* /dev/dmfm* \
+     /dev/dmmidi? /dev/dsp* /dev/dspW* /dev/midi0? /dev/mixer? /dev/music \
+     /dev/patmgr? /dev/sequencer* /dev/sndstat"
+  alsadevs="/proc/asound/dev/*"
+  fuser -k $ossdevs $alsadevs 2> /dev/null 1>/dev/null
+  #
+  # remove all sequencer connections if any
+  #
+  if [ -f /proc/asound/seq/clients -a -x $aconnect ]; then
+    $aconnect --removeall
+  fi
+}
+
+function stop() {
+  #
+  # store driver settings
+  #
+  if [ -x $alsactl ]; then
+    $alsactl -f $asoundcfg store
+  else
+    echo -n -e "${rc_warning}!!!alsactl not found!!!${rc_reset} "
+  fi
+  #
+  # remove all sound modules
+  #
+  /sbin/lsmod | grep -E "^snd" | grep -v "snd-rme9652_mem" | while read line; do \
+     /sbin/rmmod `echo $line | cut -d ' ' -f 1`; \
+  done
+  # remove the 2.2 soundcore module (if possible)
+  /sbin/rmmod soundcore 2> /dev/null
+}
+
+# See how we were called.
+case "$1" in
+  start)
+        # Start driver if it isn't already up.
+       if [ ! -d /proc/asound ]; then
+         start
+       else
+         echo "ALSA driver is already running."
+       fi
+        ;;
+  stop)
+        # Stop daemons.
+       if [ -d /proc/asound ]; then
+          echo -n "Shutting down sound driver: "
+         terminate
+         stop
+         echo -e "$rc_done"
+       fi
+        ;;
+  restart|reload)
+       $0 stop
+       $0 start
+       ;;
+  status)
+        if [ -d /proc/asound ]; then
+          echo -n "ALSA sound driver loaded."
+        else
+          echo -n "ALSA sound driver not loaded."
+        fi
+        echo
+        ;;
+  *)
+        echo "Usage: alsasound {start|stop|restart|status}"
+        exit 1
+esac
+
+exit 0

Reply via email to