summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
authorThierry Vignaud <tvignaud@mandriva.org>2002-08-20 17:15:47 +0000
committerThierry Vignaud <tvignaud@mandriva.org>2002-08-20 17:15:47 +0000
commit250ef385d4f7a7825b7490c42681d6b9a809432b (patch)
tree06a3d0bfd6acc577c50cf2a2a200ffdf3d72db49 /perl-install
parent899f293944ef786470f73e7497da3453313cb320 (diff)
downloaddrakx-250ef385d4f7a7825b7490c42681d6b9a809432b.tar
drakx-250ef385d4f7a7825b7490c42681d6b9a809432b.tar.gz
drakx-250ef385d4f7a7825b7490c42681d6b9a809432b.tar.bz2
drakx-250ef385d4f7a7825b7490c42681d6b9a809432b.tar.xz
drakx-250ef385d4f7a7825b7490c42681d6b9a809432b.zip
add draksound: allow to switch between alsa and oss;
should result in better sound support
Diffstat (limited to 'perl-install')
-rw-r--r--perl-install/harddrake/Makefile2
-rwxr-xr-xperl-install/harddrake/gen_snd_list18
-rw-r--r--perl-install/harddrake/sound.pm193
-rwxr-xr-xperl-install/standalone/draksound59
4 files changed, 272 insertions, 0 deletions
diff --git a/perl-install/harddrake/Makefile b/perl-install/harddrake/Makefile
new file mode 100644
index 000000000..313fc2eca
--- /dev/null
+++ b/perl-install/harddrake/Makefile
@@ -0,0 +1,2 @@
+sound_drivers.pm: ../../kernel/list_modules.pm gen_snd_list
+ ./gen_snd_list > $@
diff --git a/perl-install/harddrake/gen_snd_list b/perl-install/harddrake/gen_snd_list
new file mode 100755
index 000000000..e791ae431
--- /dev/null
+++ b/perl-install/harddrake/gen_snd_list
@@ -0,0 +1,18 @@
+#!/usr/bin/perl
+#
+# Copyright (C) 2002 MandrakeSoft (tvignaud@mandrakesoft.com)
+# Released under the GNU General Public License
+
+use lib qw(/usr/lib/libDrakX);
+use common;
+use list_modules;
+use Data::Dumper;
+
+$Data::Dumper::Terse = 1; # don't output names where feasible
+$Data::Dumper::Purity = 1; # fill in the holes for eval
+
+# ne '' for missing modules ... if_($i ne '', $i, '<none>')
+print "package harddrake::sound_drivers;\n#This is an autogenrated file by gen_snd_list from list_modules.pm\nour\$sound_drivers = ", Dumper({map { my $i=qx((/sbin/modinfo -d $_)|head -1|tr -d \\\"|perl -pi -e 's!\n!!g'); $_ => $i } category2modules("multimedia/sound")}), ";\n1;";
+#print qq(
+#sub
+#)
diff --git a/perl-install/harddrake/sound.pm b/perl-install/harddrake/sound.pm
new file mode 100644
index 000000000..9069966ef
--- /dev/null
+++ b/perl-install/harddrake/sound.pm
@@ -0,0 +1,193 @@
+package harddrake::sound;
+# lists filled with Danny Tholen help, enhanced by Thierry Vignaud
+#
+# No ALSA for OSS's
+# o btaudio (tv card),
+# o isa cards: msnd_pinnacle, pas2,
+# No OSS for ALSA's
+# o pci cards: snd-ali5451, snd-als4000, snd-es968, snd-fm801,
+# snd-hdsp, snd-via8233
+# o isa cards: snd-als100, snd-azt2320, snd-cmi8330, snd-cs4231,
+# snd-cs4236, snd-dt0197h, snd-es18xx,snd-es1688, snd-ice1712,
+# snd-korg1212, snd-rme32, snd-rme96
+# o usb cards: snd-usb-audio
+
+# TODO:
+# o ensure sound isn't user (either dsp/midi/sequencer/mixer)
+# o fix sound/alsa services
+
+use strict;
+use common;
+use interactive;
+use run_program;
+use modules;
+use harddrake::sound_drivers; # autogenerated
+use standalone;
+
+my %alsa2oss =
+ (
+ "snd-ad1816a" => [ "ad1816" ], # isa
+ "snd-ad1848" => [ "ad1848" ], # isa
+ "snd-ali5451" => [ "unknown" ],
+ "snd-als100" => [ "unknown" ], # isa
+ "snd-als4000" => [ "unknown" ],
+ "snd-azt2320" => [ "unknown" ], # isa
+ "snd-cmi8330" => [ "unknown" ], # isa
+ "snd-cmipci" => [ "cmpci" ],
+ "snd-cs4231" => [ "unknown" ], # isa
+ "snd-cs4232" => [ "cs4232" ], # isa
+ "snd-cs4236" => [ "unknown" ], # isa
+ "snd-cs4281" => [ "cs4281" ],
+ "snd-cs46xx" => [ "cs46xx" ],
+ "snd-dt0197h" => [ "unknown" ], # isa
+ "snd-emu10k1" => [ "audigy", "emu10k1" ],
+ "snd-ens1370" => [ "es1370" ],
+ "snd-ens1371" => [ "es1371" ],
+ "snd-es1688" => [ "unknown" ], # isa
+ "snd-es18xx" => [ "unknown" ], # isa
+ "snd-es1938" => [ "esssolo1" ],
+ "snd-es1968" => [ "maestro" ], # isa
+ "snd-es968" => [ "unknown" ],
+ "snd-fm801" => [ "unknown"],
+ "snd-gusclassic" => [ "gus" ], # isa
+ "snd-gusextreme" => [ "gus" ], # isa
+ "snd-gusmax" => [ "gus" ], # isa
+ "snd-hdsp" => [ "unknown" ],
+ "snd-ice1712" => [ "unknown" ], # isa
+ "snd-intel8x0" => [ "i810_audio" ],
+ "snd-interwave" => [ "gus" ], # isa
+ "snd-korg1212" => [ "unknown" ], # isa
+ "snd-maestro3" => [ "maestro3" ],
+ "snd-mpu401" => [ "mpu401" ],
+ "snd-nm256" => [ "nm256_audio" ],
+ "snd-opl3sa2" => [ "opl3", "opl3sa", "opl3sa2" ], # isa
+ "snd-opti93x" => [ "mad16" ],
+ "snd-rme32" => [ "unknown" ], # isa
+ "snd-rme96" => [ "unknown" ], # isa
+ "snd-rme9652g" => [ "rme96xx" ],
+ "snd-sb16" => ["sscape", "sb"],
+ "snd-sb8" => [ "sb" ],
+ "snd-sbawe" => [ "awe_wave" ],
+ "snd-sgalaxy" => [ "sgalaxy" ], # isa
+ "snd-sonicvibes" => [ "sonicvibes" ],
+ "snd-trident" => [ "trident" ],
+ "snd-usb-audio" => [ "unknown" ], # usb
+ "snd-via686" => [ "via82cxxx_audio" ],
+ "snd-via8233" => [ "unknown" ],
+ "snd-wavefront" => [ "wavefront" ], # isa
+ "snd-ymfpci" => [ "ymfpci" ]
+ );
+
+
+my %oss2alsa =
+ (
+ "ad1816" => [ "snd-ad1816a" ],
+ "ad1848" => [ "snd-ad1848" ],
+ "audigy" => [ "snd-emu10k1" ],
+ "awe_wave" => [ "snd-sbawe" ],
+ "btaudio" => [ "unknown" ],
+ "cmpci" => [ "snd-cmipci" ],
+ "cs4232" => [ "snd-cs4232" ],
+ "cs4281" => [ "snd-cs4281" ],
+ "cs46xx" => [ "snd-cs46xx" ],
+ "emu10k1" => [ "snd-emu10k1" ],
+ "es1370" => [ "snd-ens1370" ],
+ "es1371" => [ "snd-ens1371" ],
+ "esssolo1" => [ "snd-es1938" ],
+ "gus" => ["snd-interwave", "snd-gusclassic", "snd-gusmax", "snd-gusextreme"],
+ "i810_audio" => [ "snd-intel8x0"],
+ "mad16" => [ "snd-opti93x" ],
+ "maestro" => [ "snd-es1968" ],
+ "maestro3" => [ "snd-maestro3" ],
+ "mpu401" => [ "snd-mpu401" ],
+ "msnd_pinnacle" => [ "unknown" ],
+ "msnd_pinnacle" => [ "unknown" ],
+ "nm256_audio" => [ "snd-nm256" ],
+ "opl3" => [ "snd-opl3sa2" ],
+ "opl3sa" => [ "snd-opl3sa2" ],
+ "opl3sa2" => [ "snd-opl3sa2" ],
+ "pas2" => [ "unknown" ],
+ "rme96xx" => [ "snd-rme9652.o.g" ],
+ "sb" => ["snd-sb8", "snd-sb16"],
+ "sgalaxy" => [ "snd-sgalaxy" ],
+ "sonicvibes" => [ "snd-sonicvibes" ],
+ "sscape" => [ "snd-sb16" ],
+ "trident" => [ "snd-trident" ],
+ "via82cxxx_audio" => [ "snd-via686" ],
+ "wavefront" => [ "snd-wavefront" ],
+ "ymfpci" => [ "snd-ymfpci" ]
+ );
+
+my $drivers_description = $harddrake::sound_drivers::sound_drivers;
+
+
+sub get_alternative {
+ my ($driver) = @_;
+ if ($alsa2oss{$driver}) {
+ $alsa2oss{$driver};
+ } elsif ($oss2alsa{$driver}) {
+ $oss2alsa{$driver}
+ } else { {} }
+}
+
+sub do_switch {
+ my ($old_driver, $new_driver) = @_;
+ standalone::explanations("removing old $old_driver\n");
+ run_program::run("service sound stop");
+ run_program::run("service alsa stop") if $old_driver =~ /^snd-/;
+ modules::unload($old_driver); # run_program("/sbin/modprobe -r $driver"); # just in case ...
+ modules::remove_module($old_driver); # completed by the next add_alias()
+ modules::add_alias('sound-slot-0', $new_driver);
+ modules::write_conf;
+ if ($new_driver =~ /^snd-/) {
+ run_program::run("service alsa start");
+ run_program::run("/sbin/chkconfig --add alsa");
+ modules::load($new_driver); # service alsa is buggy
+ } else { run_program::run("/sbin/chkconfig --del alsa") }
+ standalone::explanations("loading new $new_driver\n");
+ run_program::run("/sbin/chkconfig --add sound"); # just in case ...
+ run_program::run("service sound start");
+}
+
+sub switch {
+ my ($in, $device) = @_;
+ my $driver = $device->{driver};
+ my $alternative = get_alternative($driver);
+# $alternative = [ "i810_audio", "snd-intel8x0"];
+ if ($alternative) {
+ my $new_driver = $alternative->[0];
+ if ($driver eq "unknown") {
+ $in->ask_warn(_("No alternative driver"),
+ _("There's no known OSS/ALSA alternative driver for your sound card (%s)",
+ $device->{description}));
+ } elsif ($in->ask_from(_("Sound configuration"),
+ _("Here you can select an alternative driver (either OSS or ALSA) for your sound card (%s)",
+ $device->{description}),
+ [
+ { label => _("Driver :"), val => \$new_driver, list => $alternative, default => $new_driver, sort =>1, format => sub { "$_[0] ($drivers_description->{$_[0]})" }, allow_empty_list => 1 }
+ ]
+ ))
+ {
+ standalone::explanations("switching audio driver from '$driver' to '$new_driver'\n");
+ do_switch($driver, $new_driver);
+ }
+ } elsif ($driver eq "unknown") {
+ $in->ask_warn(_("No known driver"),
+ _("There's no known driver for your sound card (%s)",
+ $device->{description}));
+ } elsif (is_listed($driver)) {
+ } else {
+ $in->ask_warn(_("Unkown driver"),
+ _("The \"%s\" driver for your sound card is unlisted\n
+Please send the output of the \"lspcidrake -v\" command to
+Thierry Vignaud <tvignaud at mandrakesoft dot com>
+with subject: unlisted sound driver")
+ , $driver);
+ }
+}
+
+sub config {
+ my ($in, $device) = @_;
+ switch($in, $device);
+
+}
diff --git a/perl-install/standalone/draksound b/perl-install/standalone/draksound
new file mode 100755
index 000000000..1744df1b4
--- /dev/null
+++ b/perl-install/standalone/draksound
@@ -0,0 +1,59 @@
+#!/usr/bin/perl
+# DrakxSound
+# Copyright (C) 2002 MandrakeSoft (tvignaud@mandrakesoft.com)
+#
+# 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+use lib qw(/usr/lib/libDrakX);
+
+use standalone; #- warning, standalone must be loaded very first, for 'explanations'
+
+use strict;
+use interactive;
+use detect_devices;
+use common;
+use harddrake::sound;
+
+("@ARGV" =~ /--help|-h/) and die "usage: draksound [-h] [--help]\n";
+
+
+my $in = 'interactive'->vnew();
+
+use modules;
+
+#no strict 'subs';
+modules::mergein_conf('/etc/modules.conf');
+
+my @devices = grep { $_->{media_type} eq 'MULTIMEDIA_AUDIO' } detect_devices::probeall(1);
+if (@devices) {
+ # TODO: That need some work for multiples sound cards
+ foreach (@devices) {
+ # we should overwrite $device->{driver} with the right sound-slot-XX
+ $_->{driver} = modules::get_alias('sound-slot-0');
+ harddrake::sound::config($in, $_);
+ }
+} else {
+ $in->ask_warn(_("No Sound Card detected!"), formatAlaTeX(
+ _("No Sound Card has been detected on your machine. Please verify that a Linux-supported Sound Card is correctly plugged in.
+
+
+You can visit our hardware database at:
+
+
+http://www.linux-mandrake.com/en/hardware.php3")));
+}
+
+modules::write_conf;
+$in->exit(0);