diff options
Diffstat (limited to 'perl-install/harddrake')
-rw-r--r-- | perl-install/harddrake/TODO | 169 | ||||
-rw-r--r-- | perl-install/harddrake/autoconf.pm | 83 | ||||
-rwxr-xr-x | perl-install/harddrake/check_snd.pl | 2 | ||||
-rw-r--r-- | perl-install/harddrake/data.pm | 79 | ||||
-rw-r--r-- | perl-install/harddrake/sound.pm | 919 | ||||
-rw-r--r-- | perl-install/harddrake/v4l.pm | 4 |
6 files changed, 653 insertions, 603 deletions
diff --git a/perl-install/harddrake/TODO b/perl-install/harddrake/TODO deleted file mode 100644 index 29c28cb77..000000000 --- a/perl-install/harddrake/TODO +++ /dev/null @@ -1,169 +0,0 @@ --*- outline -*- - -* drakxtools -** drakxtools* need XF-{75,100}fonts that requires XFree86 - -* Harddrake TODO: -** ui -*** more usb mice infos -*** enable the user to force a module (isa, isapnp, ...) -*** print "(not loaded)" if module isn't loaded -*** add bus_position to make unique id in ui (check it does not confuse hw service) -*** cdrom (must be done by diskdrake): -**** ide-scsi / ide-cd switch (humm, the future (aka 2.6.x kernel) is ide-cd only) -*** use fbgtk+2 when booting on fbcon for smoother GUI => interactive::fbgtk -*** help: -**** print fields in black and their description in blue as for information fields -*** check there's at least one config option before showing the "condigure module" button -*** s/module/driver/ ? -** fixes -*** configure at boot-time (hw hooks shared by both harddrake & drakx ?): - all /etc/modules aliases -**** usb-interfaces (or rewrite usb service in perl for speed) -**** switch nvidia/nv in /etc/X11/XF86Config - if [[ -e /lib/modules/`uname -r`/kernel/drivers/video/NVdriver ]]; then - perl -pi -e 's!Driver "nv.*"!Driver "nvidia"!g;s!#HARDDRAKE (Load.*glx)!\1!g' /etc/X11/XF86Config-4 - else - perl -pi -e 's!Driver "nv.*"!Driver "nv"!g;s!(Load.*glx)!#HARDDRAKE \1!g' /etc/X11/XF86Config-4 - fi -*** non needed stuff to run X must be posponed after X11 startup -**** eg: scanner/audio/printer/floppy/cdrom/tape/tv/webcam/joystick/ ... -** packaging : separate version for harddrake & drakxtool -** configurators -*** new cd burner: offer to install cdrecord and one of its gui frontends -*** new dvd driver : offer to install xine||mplayer -*** draksound : -**** add a dialog so that the user choose its wavetable. -**** list all availables drivers, defaulting to first alternative, prepending old one with '*' -**** add 'ALSA/OSS': tag to modules list -** detect engine: -*** detect isapnp devices -*** set more field for fscking 0x0000:0x0000 usb controllers - -** move all drakx tools into just a small one-liner that uses real <tool>.pm - so that harddrake and mcc reduces their memory usage pattern and - be faster (the next fast step will be to use perl6/parrot) - - drawback : this would level down quite a lot the global mcc/harddrake robustness - -** check there're enough parameters in module config -** for to send a message for unknown hardware to install@mandrakesoft.com - - Subject: [UNKNOW HARDWARE] or a new other ml - -> do you konw how to configure it under linux ? - -> description - - -* #################################################################### -* #################################################################### - -* / no hope / useless : -** enable a string to be passed as detector; in that case, do ourself the =~ -** alter detect_devices in order to only probe one time -** detect *ALL* mouses if more than one (mousedrake?) - -** deeper data structure in Mandrake 9.2 ? - - "Mass storage" => (Floppy, - Disk, - Cdrom, - Tape) - - "Network" => (Ethernetcard, - Modem, - Isdn) - "Multimedia" => (Videocard, - Tvcard, - Soundcard, - Webcam) - "System" => (Bridge, - Cpu, - Memory) - - - "Publishing" => (Printer, - Scanner) - - "Pointing" => (Mouse, - Joystick) - - "Buses" => (Ideinterface, - Scsiinterface, - Usbinterface, - ); - - "Unknown/Others", - -* #################################################################### - -* Suggestions -** various -Subject: Re: [Cooker] Optional ALSA Support for SB Live! -From: Fabrice FACORAT <f.faber@netcourrier.com> -To: cooker@linux-mandrake.com -In-Reply-To: <m2ofhvtpaq.fsf@vador.mandrakesoft.com> -References: <20020311051222.47DC087CA5@yavin.mandrax.org> - <m2ofhvtpaq.fsf@vador.mandrakesoft.com> -Date: 11 Mar 2002 11:12:31 +0100 -Message-Id: <1015841551.3895.31.camel@bastard.localdomain> - -Le lun 11/03/2002 à 10:41, Thierry Vignaud a écrit : - -> > In Mandrake 8.1 rerunning Harddrake post-setup would switch over -> > to ALSA (which supports MIDI synth), however in 8.2 the only way to -> > get ALSA support is to manually edit the modules.conf file. This -> > would be disasterous for someone who isn't familar with -> > modules.conf, but had been instructed on the mandrake-expert/newbie -> > lists (as many had been) to simply rerun Harddrake on the sound card -> > to get ALSA (and hence MIDI synth support). -> -> give me the result of lspcidrake -f -v so that i switch your card -> from oss to alsa. - -no please. -just one month ago you switch SBLive from Alsa to OSS ( cause drakX -set it as OSS and harddrake as Alsa ). -There were also a discussion concerning the fact that Alsa doesn't -support emu-tools and so all available options. -Last but not least, several peoples report pbs with Alsa ( is sound is -too high you have disturbances ). So someone is going to ask you for -OSS as it want to use some features os SBLive, etc ... - -To my mind the best way for this ( but too late for 8.2 ) will be to -have a tool called soundrake. Thanks to this tools, you choose at the -beginning if you want to use OSS or alsa and then try to correctly -configure your sound card. This tool should be able to work in -embended mo in harddrake or harddrake2 ( infos concerning this so long -awaiting harddrake 2 ? ). - -In order to make this tool be a perfect tool, it should be able to -advice user concerning the advantage and the disadvantage of each -driver ( indeed alsa sometimes is better than OSS as it support full -duplex and wave mixing on more sound cards ). -It's also disturbing is harddrake set alsa by default and XrakX set -OSS by default as sometimes by lanching harddrake ( just to see what -happen ) you lose ( or seems to lose ) your sound card ( mute mixer ) - -For example : -+ launch harddrake -+ use autodetection : yes/no -+ if auto detects enable, it detects a SBLive. -+ explanations text concerning the fact that : - if I use OSS I will be able to use sounds effects, live drive and -others things ( AC-3 passthrough ) thanks to the emu10k1-tools packages -( available on CD sets and installable via Software Manager ) - if I use Alsa, I won't be able to use emu10k1-tools but at the -contrary I will be able to use midi software as alsa module support midi -+ ask user which one he wants to use : OSS / Alsa ? -+ set the sound card drivers and modules.conf according to user wishes -+ <mode= dream> if I select OSS, installed emu10k1-tools and provide a -GUI to configure them </mode = dream> -+ <mode= dream> if I select Alsa unmute at least PCM and Vol or display -a warning saying that by default Alsa mute everything ( configure alsa -service so that it save mixer settings ) -+ test the sound ( mandrake sound theme ) -+ do you hear something ? -+ yes -> your sound card have been properly set. -+ if no -> try the others drivers set or send lspcidrake -v to -somebody@somewhere.org to check for support for your sound card -+ Do you ahave another sound card ? diff --git a/perl-install/harddrake/autoconf.pm b/perl-install/harddrake/autoconf.pm index 9b16f5d3c..fba5078cd 100644 --- a/perl-install/harddrake/autoconf.pm +++ b/perl-install/harddrake/autoconf.pm @@ -3,7 +3,7 @@ package harddrake::autoconf; use common; sub xconf { - my ($modules_conf, $o) = @_; + my ($modules_conf, $o, $o_skip_fb_setup, $o_resolution_wanted) = @_; log::l('automatic XFree configuration'); @@ -12,8 +12,10 @@ sub xconf { my $do_pkgs = do_pkgs_standalone->new; $o->{raw_X} = Xconfig::default::configure($do_pkgs); + my $old_x = { if_($o_resolution_wanted, resolution_wanted => $o_resolution_wanted) }; + require Xconfig::main; - Xconfig::main::configure_everything_auto_install($o->{raw_X}, $do_pkgs, {}, { allowFB => listlength(cat_("/proc/fb")) }); + Xconfig::main::configure_everything_auto_install($o->{raw_X}, $do_pkgs, $old_x, { allowFB => listlength(cat_("/proc/fb")), skip_fb_setup => $o_skip_fb_setup }); #- always disable compositing desktop effects when configuring a new video card require Xconfig::glx; @@ -22,10 +24,43 @@ sub xconf { modules::load_category($modules_conf, 'various/agpgart'); } +sub setup_ethernet_device { + my ($in, $device) = @_; + + require network::connection; + require network::connection::ethernet; + require network::connection::wireless; + my @connection_types = qw(network::connection::ethernet network::connection::wireless); + my @all_connections = map { $_->get_connections(automatic_only => 1) } @connection_types; + my $interface = network::connection::ethernet::device_to_interface($device) + or return; + my $connection = find { $_->get_interface eq $interface } @all_connections + or return; + + require network::connection_manager; + my $net = {}; + network::network::read_net_conf($net); + my $cmanager = network::connection_manager->new($in, $net); + $cmanager->set_connection($connection); + + # this will installed required packages + $cmanager->setup_connection; +} + sub network_conf { - my ($obj) = @_; - require network::network; - network::network::easy_dhcp($obj->{net}, $obj->{modules_conf}); + my ($modules_conf, $in, $added) = @_; + $modules_conf->remove_alias_regexp('^(wlan|eth)[0-9]*$'); + modules::load_category($modules_conf, 'network/main|gigabit|usb|wireless|firewire|pcmcia'); + + setup_ethernet_device($in, $_) foreach @{$added || {}}; + + require network::connection::ethernet; + network::connection::ethernet::configure_eth_aliases($modules_conf); + require network::rfswitch; + network::rfswitch::configure(); + require network::shorewall; + network::shorewall::update_interfaces_list(); + $modules_conf->write; } sub mouse_conf { @@ -44,6 +79,11 @@ sub pcmcia { sub bluetooth { my ($enable) = @_; + # do not disable bluetooth service if adapter disappears + # (for example if disabled by Fn keys) + # systemd will automatically disable the service if needed + return if !$enable; + #- FIXME: make sure these packages are installed when needed # if ($enable) { # require do_pkgs; @@ -72,8 +112,7 @@ sub laptop { # $do_pkgs->ensure_is_installed("numlock", "/etc/rc.d/init.d/numlock"); # } require services; - services::set_status("cpufreq", $on_laptop); - services::set_status("apmd", $on_laptop); + services::set_status("apmd", -e "/proc/apm"); services::set_status("laptop-mode", $on_laptop); services::set_status("numlock", !$on_laptop); } @@ -83,4 +122,34 @@ sub cpufreq() { modules::set_preload_modules("cpufreq", cpufreq::get_modules()); } +sub floppy() { + require detect_devices; + modules::set_preload_modules("floppy", if_(detect_devices::floppy(), "floppy")); +} + +sub fix_aliases { + my ($modules_conf) = @_; + require modalias; + my %new_aliases; + #- first pass: find module targets whose modalias is not valid anymore + foreach my $module ($modules_conf->modules) { + if (my $aliased_to = $modules_conf->get_alias($module)) { + my @valid_modaliases = modalias::get_modules($module, 'skip_config') or next; + my ($found, $others) = partition { $_ eq $aliased_to } @valid_modaliases; + $new_aliases{$aliased_to} = @{$others || []} == 1 && $others->[0] if is_empty_array_ref($found); + } + } + #- second pass: adapt module targets that are not valid anymore + foreach my $module ($modules_conf->modules) { + if (my $aliased_to = $modules_conf->get_alias($module)) { + if (my $new = exists $new_aliases{$aliased_to} && $new_aliases{$aliased_to}) { + $modules_conf->set_alias($module, $new); + } else { + $modules_conf->remove_alias($module); + } + } + } + $modules_conf->write; +} + 1; diff --git a/perl-install/harddrake/check_snd.pl b/perl-install/harddrake/check_snd.pl index dfa007b80..4721bed40 100755 --- a/perl-install/harddrake/check_snd.pl +++ b/perl-install/harddrake/check_snd.pl @@ -10,7 +10,7 @@ use list_modules; my @listed_modules = @{$list_modules::l{multimedia}{sound}}; my @drivers = (keys %harddrake::sound::oss2alsa, keys %harddrake::sound::alsa2oss); -my @alternatives = uniq map { @{$_} } values %harddrake::sound::oss2alsa, values %harddrake::sound::alsa2oss; +my @alternatives = uniq map { @$_ } values %harddrake::sound::oss2alsa, values %harddrake::sound::alsa2oss; # check harddrake::sound's data structures're coherent print "unknown alternative drivers : [", join(', ', difference2(\@alternatives, \@drivers)), "]\n"; diff --git a/perl-install/harddrake/data.pm b/perl-install/harddrake/data.pm index 537cb177d..8d4d4de21 100644 --- a/perl-install/harddrake/data.pm +++ b/perl-install/harddrake/data.pm @@ -11,11 +11,20 @@ our ($version, $sbindir, $bindir) = ("10", "/usr/sbin", "/usr/bin"); my @devices = (detect_devices::probeall(), detect_devices::getSCSI()); +foreach my $dev (@devices) { + # normalize device IDs for devices that came from mouse.pm: + next if !defined $dev->{Synaptics}; + foreach my $field (qw(vendor id subvendor subid)) { + next if !defined $dev->{$field}; + $dev->{$field} = hex($dev->{$field}); + } +} + # Update me each time you handle one more devices class (aka configurator) sub unknown() { - grep { $_->{media_type} !~ /BRIDGE|class\|Mouse|DISPLAY|Hub|MEMORY_RAM|MULTIMEDIA_(VIDEO|AUDIO|OTHER)|NETWORK|Printer|SERIAL_(USB|SMBUS)|STORAGE_(IDE|OTHER|RAID|SCSI)|SYSTEM_OTHER|tape|UPS/ + grep { $_->{media_type} !~ /BRIDGE|class\|Mouse|DISPLAY|Hub|MEMORY_RAM|MULTIMEDIA_(VIDEO|AUDIO|OTHER)|NETWORK|Printer|SERIAL_(USB|SMBUS)|STORAGE_(IDE|OTHER|RAID|SCSI)|SYSTEM_(OTHER|SDHCI)|tape|UPS/ && !member($_->{driver}, qw(cpia_usb cyber2000fb forcedeth ibmcam megaraid mod_quickcam nvnet ohci1394 ov511 ov518_decomp scanner ultracam usbvideo usbvision)) - && $_->{driver} !~ /^ISDN|Mouse:USB|Removable:zip|class\|Mouse|sata|www.linmodems.org/ + && $_->{driver} !~ /^ISDN|Mouse:USB|Removable:zip|class\|Mouse|sata|www.linmodems.org|kbd|mouse|sysrq|usbhid/ && $_->{type} ne 'network' && $_->{description} !~ /Alcatel|ADSL Modem/; } @devices; @@ -36,7 +45,6 @@ sub f { # FIXME: add translated items sub is_removable { member($_[0], qw(FLOPPY ZIP DVDROM CDROM BURNER)) } -sub is_auto_configurable_class { is_removable($_[0]) || member($_[0], qw(HARDDISK)) } sub is_auto_configurable_media { !detect_devices::isKeyUsb($_[0]) } sub set_removable_configurator { @@ -44,16 +52,6 @@ sub set_removable_configurator { is_removable($class) ? "/usr/sbin/diskdrake --removable=$device->{device}" : undef; } -sub set_media_auto_configurator { - my ($device) = @_; - is_auto_configurable_media($device) ? "/usr/sbin/drakupdate_fstab --auto --add $device->{device}" : (); -} - -sub set_media_remover { - my ($device) = @_; - is_auto_configurable_media($device) ? "/usr/sbin/drakupdate_fstab --del $device->{device}" : (); -} - my $modules_conf = modules::any_conf->read; # Format is (HW class ID, l18n class name, icon, config tool , is_to_be_detected_on_boot) @@ -64,7 +62,8 @@ our @tree = string => N("SATA controllers"), icon => "ide_hd.png", configurator => "", - detector => sub { f(detect_devices::probe_category('disk/sata')) }, + detector => sub { f(grep { $_->{driver} !~ /^pata/ } detect_devices::probe_category('disk/sata')), + f(grep { $_->{description} =~ /AHCI/ } @devices) }, checked_on_boot => 1, }, @@ -84,7 +83,8 @@ our @tree = icon => "ide_hd.png", configurator => "", detector => sub { f(detect_devices::probe_category('disk/ide')), - f(grep { $_->{media_type} =~ /STORAGE_(IDE|OTHER)/ } @devices) }, + f(grep { $_->{driver} =~ /^pata/ && $_->{media_type} =~ /IDE|STORAGE_SATA/ } @devices), + f(grep { $_->{media_type} =~ /STORAGE_(IDE|OTHER)/ } @devices) }, checked_on_boot => 1, }, @@ -102,7 +102,7 @@ our @tree = string => N("Firewire controllers"), icon => "usb.png", configurator => "", - detector => sub { f(grep { $_->{driver} =~ /ohci1394/ } @devices) }, + detector => sub { f(grep { $_->{driver} =~ /firewire_ohci|ohci1394/ } @devices) }, checked_on_boot => 1, }, @@ -156,7 +156,7 @@ our @tree = string => N("Bridges and system controllers"), icon => "memory.png", configurator => "", - detector => sub { f(grep { $_->{media_type} =~ /BRIDGE|MEMORY_RAM|SYSTEM_OTHER|MEMORY_OTHER|SYSTEM_PIC/ + detector => sub { f(grep { $_->{media_type} =~ /BRIDGE|MEMORY_RAM|SYSTEM_(OTHER|SDHCI)|MEMORY_OTHER|SYSTEM_PIC|COMMUNICATION_OTHER/ || $_->{description} =~ /Parallel Port Adapter/; } @devices) }, checked_on_boot => 0, @@ -195,7 +195,7 @@ our @tree = icon => "harddisk.png", configurator => "$sbindir/diskdrake", detector => sub { f(detect_devices::hds()) }, - checked_on_boot => 1, + checked_on_boot => 0, automatic => 1, }, @@ -204,7 +204,7 @@ our @tree = string => N("USB Mass Storage Devices"), icon => "usb.png", configurator => "", - detector => sub { f(grep { member($_->{driver}, qw(usb_storage ub)) } @devices) }, + detector => sub { f(grep { member($_->{driver}, qw(usb_storage ub Removable:memory_card)) } @devices) }, checked_on_boot => 0, }, @@ -302,7 +302,8 @@ our @tree = detector => sub { require list_modules; my @modules = list_modules::category2modules('multimedia/sound'); - f(grep { $_->{media_type} =~ /MULTIMEDIA_AUDIO/ || member($_->{driver}, @modules) } @devices); + f(grep { $_->{media_type} =~ /MULTIMEDIA_AUDIO|PROCESSOR_CO/ || member($_->{driver}, @modules) + || $_->{description} =~ /^\|?HDA |PC Speaker/ } @devices); }, checked_on_boot => 1, }, @@ -315,7 +316,8 @@ our @tree = detector => sub { require list_modules; my @modules = (list_modules::category2modules('multimedia/webcam'), 'Removable:camera'); - f(grep { $_->{media_type} =~ /MULTIMEDIA_VIDEO|Video\|Video Control/ && $_->{bus} ne 'PCI' || member($_->{driver}, @modules) } @devices); + f(grep { $_->{media_type} =~ /MULTIMEDIA_VIDEO|Video\|Video Control|Imaging|Camera/ && $_->{bus} ne 'PCI' + || member($_->{driver}, @modules) || $_->{driver} =~ /^gpsca/ } @devices); }, # managed by hotplug: checked_on_boot => 0, @@ -383,7 +385,7 @@ our @tree = string => N("Bluetooth devices"), icon => "hw_network.png", configurator => "", - detector => sub { f(detect_devices::probe_category('bus/bluetooth')) }, + detector => sub { f(detect_devices::probe_category('bus/bluetooth')), f(grep { $_->{description} =~ /Bluetooth Dongle/ } @devices) }, checked_on_boot => 1, }, @@ -398,7 +400,8 @@ our @tree = f(grep { $_->{media_type} && $_->{media_type} =~ /^NETWORK/ || $_->{type} && $_->{type} eq 'network' - || member($_->{driver}, @net_modules); + || member($_->{driver}, @net_modules) + || $_->{description} =~ /WLAN/; } @devices); }, checked_on_boot => 1, @@ -409,7 +412,7 @@ our @tree = string => N("Modem"), icon => "modem.png", configurator => "$sbindir/drakconnect", - detector => sub { f(detect_devices::getModem($modules_conf)) }, + detector => sub { f(detect_devices::getModem($modules_conf)), f(grep { $_->{description} =~ /SoftModem/ } @devices) }, # we do not check these b/c this need user interaction (auth, ...): checked_on_boot => 0, }, @@ -431,7 +434,7 @@ our @tree = string => N("Memory"), icon => "hw-memory.png", configurator => "", - detector => sub { grep { member($_->{name}, 'Cache', 'Memory Module') } detect_devices::dmidecode() }, + detector => sub { grep { member($_->{name}, 'Cache', 'Memory Module') || $_->{name} eq 'Memory Device' && $_->{Size} ne 'No Module Installed' } detect_devices::dmidecode() }, checked_on_boot => 0, }, @@ -440,7 +443,7 @@ our @tree = string => N("Printer"), icon => "hw_printer.png", configurator => "$sbindir/printerdrake", - detector => sub { require printer::detect; printer::detect::local_detect() }, + detector => sub {}, # we do not check these b/c this need user interaction (auth, ...): checked_on_boot => 0, }, @@ -474,9 +477,10 @@ our @tree = icon => "hw-keyboard.png", configurator => "$sbindir/keyboarddrake", detector => sub { - f(grep { $_->{description} =~ /Keyboard/i || $_->{media_type} =~ /Subclass\|Keyboard/i } @devices), - # USB devices are filtered out since we already catch them through probeall(): - grep { $_->{bus} ne 'usb' && $_->{driver} eq 'kbd' && $_->{description} !~ /PC Speaker/ } detect_devices::getInputDevices(); + f(grep { $_->{description} =~ /Keyboard/i || $_->{media_type} =~ /Keyboard/i || + # USB devices are filtered out since we already catch them through probeall(): + $_->{bus} ne 'usb' && $_->{driver} =~ /^event|kbd|^usbhid/ && $_->{description} !~ /PC Speaker/; + } @devices); }, checked_on_boot => 0, }, @@ -496,9 +500,10 @@ our @tree = icon => "hw_mouse.png", configurator => "$sbindir/mousedrake", detector => sub { - f(grep { $_->{driver} =~ /^Mouse:|^Tablet:/ || $_->{media_type} =~ /class\|Mouse/ } @devices), - # USB devices are filtered out since we already catch them through probeall(): - grep { $_->{bus} ne 'usb' && $_->{Handlers}{mouse} } detect_devices::getInputDevices(); + f(grep { $_->{driver} =~ /^Mouse:|^Tablet:|^mouse/ || $_->{media_type} =~ /class\|Mouse/ || + # USB devices are filtered out since we already catch them through probeall(): + $_->{bus} ne 'usb' && $_->{Handlers}{mouse}; + } @devices); }, checked_on_boot => 1, automatic => 1, @@ -527,7 +532,7 @@ our @tree = icon => "scanner.png", configurator => "$sbindir/scannerdrake", detector => sub { - require scanner; f(map { $_->{drakx_device} } f(scanner::detect())); + require scanner; f(map { $_->{val}{drakx_device} } f(scanner::detect())); }, checked_on_boot => 0, }, @@ -553,7 +558,9 @@ sub pciusb_id { pci_device => 'usb_pci_device', vendor => 'usb_vendor', ); - join(':', map { $dev->{$alt{$_}} || $dev->{$_} } qw(bus pci_bus pci_device vendor id subvendor subid description)); + my @fields = ('bus', if_($dev->{bus} =~ /pci/, qw(pci_bus pci_device)), qw(vendor id subvendor subid), + if_($dev->{bus} !~ /usb/i, 'description')); + join(':', map { uc($dev->{$alt{$_}} || $dev->{$_}) } @fields); } @@ -565,9 +572,7 @@ sub custom_id { N("cpu # ") . $device->{processor} . ": " . $device->{'model name'} : $device->{"Socket Designation"} ? "$device->{name} (" . $device->{"Socket Designation"} . ")" : - $device->{name} ? $device->{name} : - (defined($device->{description}) ? $device->{description} : - (defined($device->{Vendor}) ? $device->{Vendor} : $str))); + $device->{name} || $device->{description} || $device->{Vendor} || $str); } 1; diff --git a/perl-install/harddrake/sound.pm b/perl-install/harddrake/sound.pm index e98ffdd5c..cdf24c219 100644 --- a/perl-install/harddrake/sound.pm +++ b/perl-install/harddrake/sound.pm @@ -1,14 +1,4 @@ package harddrake::sound; -# lists filled with Danny Tholen help, enhanced by Thierry Vignaud -# -# No ALSA for OSS's -# o isa cards: msnd_pinnacle, pas2, -# o pci cards: ad1889, sam9407 -# No OSS for ALSA's -# o pci cards: snd_als4000, snd_es968, snd_hdsp -# o isa cards: snd_azt2320, snd_cs4231, snd_cs4236, -# snd_dt0197h, snd_korg1212, snd_rme32 -# o pcmcia cards: snd_vxp440 snd_vxpocket # TODO: # o ensure sound is not user (either dsp/midi/sequencer/mixer) @@ -22,193 +12,23 @@ use list_modules; use detect_devices; use log; - -our %alsa2oss = - ( - if_(arch() =~ /ppc/, "snd_powermac" => [ "dmasound_pmac" ]), - if_(arch() =~ /sparc/, - "snd_sun_amd7930" => [ "unknown" ], - "snd_sun_cs4231" => [ "unknown" ], - "snd_sun_dbri" => [ "unknown" ], - ), - "snd_ad1816a" => [ "ad1816" ], # isa - "snd_ad1848" => [ "ad1848", "pss" ], # isa - "snd_ad1889" => [ "ad1889" ], - "snd_ali5451" => [ "trident" ], - "snd_als100" => [ "sb" ], # isa - "snd_als300" => [ "unknown" ], - "snd_als4000" => [ "unknown" ], - "snd_aoa" => [ "unknown" ], - "snd_asihpi" => [ "unknown" ], - "snd_atiixp" => [ "unknown" ], - "snd_au8810" => [ "unknown" ], - "snd_au8820" => [ "unknown" ], - "snd_au8830" => [ "unknown" ], - "snd_audigyls" => [ "unknown" ], # pci, renamed as snd_ca0106 - "snd_azt2320" => [ "unknown" ], # isa - "snd_azt3328" => [ "unknown" ], # isa - "snd_azx" => [ "unknown" ], - "snd_bt87x" => [ "btaudio" ], - "snd_ca0106" => [ "unknown" ], # pci - "snd_cmi8330" => [ "sb" ], # isa - "snd_cmi8788" => [ "unknown" ], # pci - "snd_cmipci" => [ "cmpci" ], - "snd_cs4231" => [ "unknown" ], # isa - "snd_cs4232" => [ "cs4232" ], # isa - "snd_cs4236" => [ "ad1848" ], # isa - "snd_cs4281" => [ "cs4281" ], - "snd_cs46xx" => [ "cs46xx" ], - "snd_cs5530" => [ "unknown" ], - "snd_cs5535audio" => [ "unknown" ], - "snd_darla20" => [ "unknown" ], - "snd_darla24" => [ "unknown" ], - "snd_dt0197h" => [ "unknown" ], # isa - "snd_dt019x" => [ "unknown" ], # isa - "snd_echo3g" => [ "unknown" ], - "snd_emu10k1" => [ "audigy", "emu10k1" ], - "snd_emu10k1x" => [ "unknown" ], - "snd_ens1370" => [ "es1370" ], - "snd_ens1371" => [ "es1371" ], - "snd_es1688" => [ "sb" ], # isa - "snd_es18xx" => [ "sb" ], # isa - "snd_es1938" => [ "esssolo1" ], - "snd_es1968" => [ "maestro" ], # isa - "snd_es968" => [ "sb" ], - "snd_fm801" => [ "forte" ], - "snd_gina20" => [ "unknown" ], - "snd_gina24" => [ "unknown" ], - "snd_gina3g" => [ "unknown" ], - "snd_gusclassic" => [ "gus" ], # isa - "snd_gusextreme" => [ "gus" ], # isa - "snd_gusmax" => [ "gus" ], # isa - "snd_hda_intel" => [ "unknown" ], - "snd_hdspm" => [ "unknown" ], - "snd_hdsp" => [ "unknown" ], - "snd_ice1712" => [ "unknown" ], # isa - "snd_ice1724" => [ "unknown" ], # isa - "snd_indi" => [ "unknown" ], # pci - "snd_indigo" => [ "unknown" ], # pci - "snd_indigodj" => [ "unknown" ], # pci - "snd_indigoio" => [ "unknown" ], # pci - "snd_intel8x0" => [ "ali5455", "i810_audio", "nvaudio" ], - "snd_interwave" => [ "gus" ], # isa - "snd_interwave_stb" => [ "unknown" ], # isa - "snd_korg1212" => [ "unknown" ], # isa - "snd_layla20" => [ "unknown" ], - "snd_layla24" => [ "unknown" ], - "snd_layla3g" => [ "unknown" ], - "snd_maestro3" => [ "maestro3" ], - "snd_mia" => [ "unknown" ], - "snd_mixart" => [ "unknown" ], - "snd_mona" => [ "unknown" ], - "snd_mpu401" => [ "mpu401" ], - "snd_nm256" => [ "nm256_audio" ], - "snd_opl3sa2" => [ "opl3", "opl3sa", "opl3sa2" ], # isa - "snd_opti92x_ad1848" => [ "unknown" ], # isa - "snd_opti92x_cs4231" => [ "unknown" ], # isa - "snd_opti93x" => [ "mad16" ], - "snd_pcxhr" => [ "unknown" ], # pci - "snd_riptide" => [ "unknown" ], - "snd_rme32" => [ "unknown" ], # isa - "snd_rme96" => [ "rme96xx" ], # pci - "snd_rme9652" => [ "rme96xx" ], # pci - "snd_sb16" => ["sscape", "sb"], - "snd_sb8" => [ "sb" ], - "snd_sbawe" => [ "awe_wave" ], - "snd_sgalaxy" => [ "sgalaxy" ], # isa - "snd_sonicvibes" => [ "sonicvibes" ], - "snd_sscape" => [ "sscape" ], # isa - "snd_trident" => [ "trident" ], - "snd_usb_audio" => [ "audio" ], # usb - "snd_usb_caiaq" => [ "unknown" ], - "snd_usb_usx2y" => [ "unknown" ], - "snd_via82xx" => [ "via82cxxx_audio" ], - "snd_vx222" => [ "unknown" ], - "snd_vxp440" => [ "unknown" ], # pcmcia - "snd_vxpocket" => [ "unknown" ], # pcmcia - "snd_wavefront" => [ "wavefront" ], # isa - "snd_ymfpci" => [ "ymfpci" ], - ); - - -our %oss2alsa = - ( - if_(arch() =~ /ppc/, "dmasound_pmac" => [ "snd_powermac" ]), - "ad1816" => [ "snd_ad1816a" ], - "ad1848" => [ "snd_ad1848", "snd_cs4236" ], - "ad1889" => [ "snd_ad1889" ], - "ali5455" => [ "snd_intel8x0" ], - "audigy" => [ "snd_emu10k1" ], - "audio" => [ "snd_usb_audio" ], # usb - "awe_wave" => [ "snd_sbawe" ], - "btaudio" => [ "snd_bt87x" ], - "cmpci" => [ "snd_cmipci" ], - "cs4232" => [ "snd_cs4232" ], - "cs4281" => [ "snd_cs4281" ], - "cs46xx" => [ "snd_cs46xx" ], - "emu10k1" => [ "snd_emu10k1" ], - "es1370" => [ "snd_ens1370" ], - "es1371" => [ "snd_ens1371" ], - "esssolo1" => [ "snd_es1938" ], - "forte" => [ "snd_fm801" ], - "gus" => ["snd_interwave", "snd_gusclassic", "snd_gusmax", "snd_gusextreme"], - "i810_audio" => [ "snd_intel8x0" ], - "ice1712" => [ "snd_ice1712" ], - "mad16" => [ "snd_opti93x" ], - "maestro" => [ "snd_es1968" ], - "maestro3" => [ "snd_maestro3" ], - "mpu401" => [ "snd_mpu401" ], - "msnd_pinnacle" => [ "unknown" ], - "nm256_audio" => [ "snd_nm256" ], - "nvaudio" => [ "snd_intel8x0" ], - "opl3" => [ "snd_opl3sa2" ], - "opl3sa" => [ "snd_opl3sa2" ], - "opl3sa2" => [ "snd_opl3sa2" ], - "pas2" => [ "unknown" ], - "pss" => [ "snd_ad1848" ], - "rme96xx" => [ "snd_rme96", "snd_rme9652" ], - "sam9407" => [ "unknown" ], - "sb" => [ "snd_als100", "snd_cmi8330", "snd_es1688", "snd_es18xx", "snd_es968", "snd_sb8", "snd_sb16" ], - "sgalaxy" => [ "snd_sgalaxy" ], - "sonicvibes" => [ "snd_sonicvibes" ], - "sscape" => [ "snd_sb16", "snd_sscape" ], - "trident" => [ "snd_ali5451", "snd_trident" ], - "via82cxxx_audio" => [ "snd_via82xx" ], - "wavefront" => [ "snd_wavefront" ], - "ymfpci" => [ "snd_ymfpci" ], - ); - -my @blacklist = qw(cs46xx cs4281); -my $blacklisted = 0; - -my $config_file = "$::prefix/etc/sysconfig/pulseaudio"; - -sub is_user_switching_enabled() { - my $output = run_program::get_stdout('polkit-action', '--action', - 'org.freedesktop.hal.device-access.sound'); - my ($val) = $output =~ /default_inactive: (.*)/; - to_bool($val eq 'no'); +sub is_pulseaudio_enabled { + my ($in) = @_; + my $soundprofile = common::read_alternative('soundprofile'); + return $in->do_pkgs->is_installed('task-pulseaudio') && $soundprofile =~ /pulse$/; } -sub set_user_switching { +sub set_pulseaudio { my ($val) = @_; - if ($val) { - run_program::get_stdout('polkit-action', '--reset-defaults', - 'org.freedesktop.hal.device-access.sound'); - } else { - run_program::get_stdout('polkit-action', '--set-defaults-inactive', - 'org.freedesktop.hal.device-access.sound', 'yes'); - } -} + my $alterative = '/etc/sound/profiles/' . ($val ? 'pulse' : 'alsa'); + return if ! -d $alterative; -sub is_pulseaudio_enabled() { - my %h = getVarsFromSh($config_file); - $h{PULSE_SERVER_TYPE} eq 'personal'; -} + common::symlinkf_update_alternatives('soundprofile', $alterative); -sub set_pulseaudio { - my ($val) = @_; + # (cg) This config file will eventually be dropped, but it is still needed for now + # as several packages/patches depend on it. + my $config_file = "$::prefix/etc/sysconfig/pulseaudio"; $val = 'PULSE_SERVER_TYPE=' . ($val ? 'personal' : 'none') . "\n"; my $done; substInFile { @@ -221,144 +41,520 @@ sub set_pulseaudio { } -my $alsa_routing_config_file = "$::prefix/etc/alsa/pulse-default.conf"; -my $disabling_routing = '#DRAKSOUND- '; +my $pa_startup_scriptfile = "$::prefix/etc/pulse/default.pa"; -sub is_pulseaudio_routing_enabled() { - return -f $alsa_routing_config_file && - cat_($alsa_routing_config_file) !~ /$disabling_routing/; +sub is_pulseaudio_glitchfree_enabled() { + return -f $pa_startup_scriptfile && + cat_($pa_startup_scriptfile) !~ /^load-module\s+module-(udev|hal)-detect\s+tsched=0/m; } -sub set_pulseaudio_routing { +sub set_pulseaudio_glitchfree { my ($val) = @_; + + return if ! -f $pa_startup_scriptfile; + substInFile { if ($val) { - s/^(?:$disabling_routing)*//g; + s/^(load-module\s+module-(udev|hal)-detect)\s+tsched=0/$1/; } else { - s/^/$disabling_routing/ if !/^$disabling_routing/; + s/^(load-module\s+module-(udev|hal)-detect).*/$1 tsched=0/; } - } $alsa_routing_config_file; + } $pa_startup_scriptfile; } +sub is_pipewire_wireplumber_enabled { + my ($in) = @_; + return $in->do_pkgs->is_installed('pipewire') && $in->do_pkgs->is_installed('wireplumber'); +} +sub is_pipewire_media_session_enabled { + my ($in) = @_; + return $in->do_pkgs->is_installed('pipewire') && $in->do_pkgs->is_installed('pipewire-media-session'); +} + +sub rooted { + run_program::rooted($::prefix, @_); +} -my $pulse_config_file = "$::prefix/etc/pulse/daemon.conf"; +sub unload { modules::unload(@_) if $::isStandalone } -sub is_5_1_in_pulseaudio_enabled() { - my ($val) = (cat_($pulse_config_file) =~ /^default-sample-channels\s*=\s*(\d+)/m); #^ - $val ||= 2; - $val == 6; +sub load { + my ($modules_conf, $name) = @_; + modules::load_and_configure($modules_conf, $name) if $::isStandalone; } -sub set_5_1_in_pulseaudio { - my ($val) = @_; - $val = 'default-sample-channels = ' . ($val ? 6 : 2) . "\n"; - my $done; - substInFile { - if (/^default-sample-channels\s*=/) { - $_ = $val; - $done = 1; +sub _pidof { + my ($name) = @_; + rooted('/usr/bin/pidof', $name); +} + +# return the pid of a running command +sub _pidof_pid { + my ($name) = @_; + my ($pid) = chomp_(run_program::rooted_get_stdout($::prefix, '/usr/bin/pidof', $name)); + + return $pid; +} + +# return the username of a running command +sub _user_pid { + my ($name) = @_; + my ($pid) = _pidof_pid($name); + my $user; + + if ($pid) { + ($user) = chomp_(run_program::rooted_get_stdout($::prefix, '/usr/bin/ps', '-o', 'uname=', '-p', $pid)); + } + + return $user; +} + +# stop pulseaudio for the running user +sub stop_pulseaudio { + my ($pulseaudio_user) = _user_pid('/usr/bin/pulseaudio'); + + if ($pulseaudio_user) { + if (-x $::prefix . '/usr/bin/pulseaudio') { + rooted('/usr/bin/su', '-l', $pulseaudio_user, '-c', '/usr/bin/pulseaudio --kill'); + } + } + + # try stopping again (in case the /usr/bin/pulseaudio process is still running, but the executable no longer available) + my ($pulseaudio_user) = _user_pid('/usr/bin/pulseaudio'); + if ($pulseaudio_user) { + my ($pulseaudio_pid) = _pidof_pid('/usr/bin/pulseaudio'); + if ($pulseaudio_pid) { + rooted('/usr/bin/su', '-l', $pulseaudio_user, '-c', '/usr/bin/kill -TERM ' . $pulseaudio_pid); } - } $pulse_config_file; - append_to_file($pulse_config_file, $val) if !$done; + } + return $pulseaudio_user; +} + +# stop pipewire services for the running user +sub stop_pipewire { + my ($pipewire_user) = _user_pid('/usr/bin/pipewire'); + + if ($pipewire_user) { + rooted('/usr/bin/systemctl', '--machine=' . $pipewire_user . '@.host', '--user', 'stop', 'pipewire-pulse.service', 'pipewire-pulse.socket', 'pipewire.service', 'pipewire.socket'); + } + + return $pipewire_user; } +# start pulseaudio for the specified user +sub start_pulseaudio { + my ($pulseaudio_user) = @_; -sub rooted { run_program::rooted($::prefix, @_) } + if ($pulseaudio_user) { + rooted('/usr/bin/su', '-l', $pulseaudio_user, '-c', '/usr/bin/pulseaudio --start'); + } +} -sub unload { modules::unload(@_) if $::isStandalone || $blacklisted } +# start pipewire services for the specified user +sub start_pipewire { + my ($pipewire_user) = @_; -sub load { - my ($modules_conf, $name) = @_; - modules::load_and_configure($modules_conf, $name) if $::isStandalone || $blacklisted; + if ($pipewire_user) { + rooted('/usr/bin/systemctl', '--machine=' . $pipewire_user . '@.host', '--user', 'start', 'pipewire.socket', 'pipewire.service', 'pipewire-pulse.socket', 'pipewire-pulse.service'); + } +} + +# stop wireplumber services for the running user +sub stop_wireplumber { + my ($pipewire_user) = _user_pid('/usr/bin/wireplumber'); + + if ($pipewire_user) { + rooted('/usr/bin/systemctl', '--machine=' . $pipewire_user . '@.host', '--user', 'stop', 'wireplumber.service'); + } + + return $pipewire_user; } -sub get_alternative { - my ($driver) = @_; - my $list = $alsa2oss{$driver} || $oss2alsa{$driver}; - $list ? @$list : "unknown"; +# start wireplumber +sub start_wireplumber { + my ($pipewire_user) = @_; + + if ($pipewire_user) { + rooted('/usr/bin/systemctl', '--machine=' . $pipewire_user . '@.host', '--user', 'start', 'wireplumber.service'); + } +} + +# stop pipewire-media-session services for the running user +sub stop_pipewire_media_session { + my ($pipewire_user) = _user_pid('/usr/bin/pipewire-media-session'); + + if ($pipewire_user) { + rooted('/usr/bin/systemctl', '--machine=' . $pipewire_user . '@.host', '--user', 'stop', 'pipewire-media-session.service'); + } + + return $pipewire_user; } -sub do_switch { - my ($in, $modules_conf, $old_driver, $new_driver, $index) = @_; - return if $old_driver eq $new_driver; - my $_wait = $in->wait_message(N("Please wait"), N("Please Wait... Applying the configuration")); - log::explanations("removing old $old_driver\n"); - if ($::isStandalone) { - rooted("service sound stop") unless $blacklisted; - rooted("service alsa stop") if $old_driver =~ /^snd_/ && !$blacklisted; - unload($old_driver); # run_program("/sbin/modprobe -r $driver"); # just in case ... - } - $modules_conf->remove_module($old_driver); - configure_one_sound_slot($modules_conf, $index, $new_driver); - $modules_conf->write; - if ($new_driver =~ /^snd_/) { # new driver is an alsa one - $in->do_pkgs->ensure_binary_is_installed(qw(alsa-utils alsactl), 1); - $in->do_pkgs->ensure_binary_is_installed(qw(aoss aoss), 1); - rooted("service alsa start") if $::isStandalone && !$blacklisted; - rooted("/sbin/chkconfig --add alsa") if $::isStandalone; - load($modules_conf, $new_driver) if $::isStandalone; # service alsa is buggy - } else { rooted("/sbin/chkconfig --del alsa") } - log::explanations("loading new $new_driver\n"); - rooted("/sbin/chkconfig --add sound"); # just in case ... - rooted("service sound start") if $::isStandalone && !$blacklisted; +# start pipewire-media-session services for the specified user +sub start_pipewire_media_session { + my ($pipewire_user) = @_; + + if ($pipewire_user) { + rooted('/usr/bin/systemctl', '--machine=' . $pipewire_user . '@.host', '--user', 'start', 'pipewire-media-session.service'); + } } -sub switch { +sub configure_pipewire_wireplumber { + my ($in) = @_; + my ($pipewire_wp_user); + + # preserve pulseaudio user + my ($pulseaudio_user) = _user_pid('/usr/bin/pulseaudio'); + + # stop pipewire and pipewire-media-session services (if any) before removing any packages + # and preserve pipewire-media-session user + $pipewire_wp_user = stop_pipewire_media_session(); + stop_pipewire(); + + my $plasma_installed = $in->do_pkgs->is_installed('plasma-desktop'); + my @pkgs = ( + 'task-pipewire', + 'wireplumber', + ); + if (!$in->do_pkgs->is_installed('pavucontrol-qt')) { + if ($plasma_installed) { + push(@pkgs, 'pavucontrol-qt'); + } + else { + push(@pkgs, 'pavucontrol'); + } + } + + + my $required_installed = $in->do_pkgs->ensure_are_installed( + \@pkgs + ); + + if (!$required_installed) + { + $in->ask_warn(N("Couldn't install the required packages"), + N("Please check the repositories are correctly configured") + ); + return; + } + + set_pulseaudio(0); + + # first of all disabling what has to be disabled to avoid conflicts + if ($in->do_pkgs->is_installed('pipewire-media-session')) { + rooted('/usr/bin/systemctl', '--global', 'disable', 'pipewire-media-session.service'); + } + + if ($in->do_pkgs->is_installed('pipewire')) { + foreach ('pipewire.socket', 'pipewire.service') { + rooted('/usr/bin/systemctl', '--global', 'enable', $_); + } + } + + if ($in->do_pkgs->is_installed('pipewire-pulseaudio')) { + foreach ('pipewire-pulse.socket', 'pipewire-pulse.service') { + rooted('/usr/bin/systemctl', '--global', 'enable', $_); + } + } + + if ($in->do_pkgs->is_installed('wireplumber')) { + rooted('/usr/bin/systemctl', '--global', 'enable', 'wireplumber.service'); + } + + + # stop pulseaudio process if still floating after the switch + stop_pulseaudio(); + + if ($pulseaudio_user) { + # restart pipewire and wireplumber with the same user as initial pulseaudio + start_pipewire($pulseaudio_user); + start_wireplumber($pulseaudio_user); + } + else { + if ($pipewire_wp_user) { + # restart pipewire and wireplumber with the same user as pipewire-media-session + start_pipewire($pipewire_wp_user); + start_wireplumber($pipewire_wp_user); + } + } + + #Plasma tricks + if ($plasma_installed) { + $in->do_pkgs->ensure_is_installed('kpipewire'); + } +} + +sub configure_pipewire_media_session { + my ($in) = @_; + my ($pipewire_ms_user); + + # preserve pulseaudio user + my ($pulseaudio_user) = _user_pid('/usr/bin/pulseaudio'); + + # stop pipewire and wireplumber services (if any) before removing any package + # and preserve wireplumber user + $pipewire_ms_user = stop_wireplumber(); + stop_pipewire(); + + + my $plasma_installed = $in->do_pkgs->is_installed('plasma-desktop'); + my @pkgs = ( + 'task-pipewire', + 'pipewire-media-session', + ); + if (!$in->do_pkgs->is_installed('pavucontrol-qt')) { + if ($plasma_installed) { + push(@pkgs, 'pavucontrol-qt'); + } + else { + push(@pkgs, 'pavucontrol'); + } + } + + my $required_installed = $in->do_pkgs->ensure_are_installed( + \@pkgs + ); + + if (!$required_installed) + { + $in->ask_warn(N("Couldn't install the required packages"), + N("Please check the repositories are correctly configured") + ); + return; + } + + set_pulseaudio(0); + + # first of all disabling what has to be disabled to avoid conflicts + if ($in->do_pkgs->is_installed('wireplumber')) { + rooted('/usr/bin/systemctl', '--global', 'disable', 'wireplumber.service'); + } + + if ($in->do_pkgs->is_installed('pipewire')) { + foreach ('pipewire.socket', 'pipewire.service') { + rooted('/usr/bin/systemctl', '--global', 'enable', $_); + } + } + + if ($in->do_pkgs->is_installed('pipewire-pulseaudio')) { + foreach ('pipewire-pulse.socket', 'pipewire-pulse.service') { + rooted('/usr/bin/systemctl', '--global', 'enable', $_); + } + } + + if ($in->do_pkgs->is_installed('pipewire-media-session')) { + rooted('/usr/bin/systemctl', '--global', 'enable', 'pipewire-media-session.service'); + } + + # stop pulseaudio process if still floating after the switch + stop_pulseaudio(); + + if ($pulseaudio_user) { + # restart pipewire and wireplumber with the same user as initial pulseaudio + start_pipewire($pulseaudio_user); + start_pipewire_media_session($pulseaudio_user); + } + else { + if ($pipewire_ms_user) { + # restart pipewire and wireplumber with the same user as pipewire-media-session + start_pipewire($pipewire_ms_user); + start_pipewire_media_session($pipewire_ms_user); + } + } + + #Plasma tricks + if ($plasma_installed) { + $in->do_pkgs->ensure_is_installed('kpipewire'); + } +} + +sub disable_all_pipewire { + my ($in) = @_; + + if ($in->do_pkgs->is_installed('wireplumber')) { + rooted('/usr/bin/systemctl', '--global', 'disable', 'wireplumber.service'); + } + + if ($in->do_pkgs->is_installed('pipewire-media-session')) { + rooted('/usr/bin/systemctl', '--global', 'disable', 'pipewire-media-session.service'); + } + + if ($in->do_pkgs->is_installed('pipewire-pulseaudio')) { + foreach ('pipewire-pulse.socket', 'pipewire-pulse.service') { + rooted('/usr/bin/systemctl', '--global', 'disable', $_); + } + } + + if ($in->do_pkgs->is_installed('pipewire')) { + foreach ('pipewire.socket', 'pipewire.service') { + rooted('/usr/bin/systemctl', '--global', 'disable', $_); + } + } +} + +sub configure_pulseaudio { + my ($in) = @_; + + # preserve pipewire running user + my ($pipewire_user) = _user_pid('/usr/bin/pipewire'); + + # stop pipewire, wireplumber and pipewire-media-session services (if any) before removing any packages + my ($wireplumber_user) = stop_wireplumber(); + my ($pipewire_media_session_user) = stop_pipewire_media_session(); + my ($pipewire_user_preserve) = stop_pipewire(); + + # now packages + $in->do_pkgs->remove('pipewire-alsa'); + + my $plasma_installed = $in->do_pkgs->is_installed('plasma-desktop'); + my @pkgs = 'task-pulseaudio'; + if (!$in->do_pkgs->is_installed('pavucontrol-qt')) { + if ($plasma_installed) { + push(@pkgs, 'pavucontrol-qt'); + } + else { + push(@pkgs, 'pavucontrol'); + } + } + + my $required_installed = $in->do_pkgs->ensure_are_installed( + \@pkgs + ); + + if (!$required_installed) + { + $in->ask_warn(N("Couldn't install the required packages"), + N("Please check the repositories are correctly configured") + ); + + # restore previous pipewire (if any) processes if something goes wrong with pulseaudio installation + if ($pipewire_user_preserve) { + start_pipewire($pipewire_user_preserve); + } + + if ($wireplumber_user) { + start_wireplumber($wireplumber_user); + } + + if ($pipewire_media_session_user) { + start_pipewire_media_session($pipewire_media_session_user); + } + + return; + } + + + # disable all the pipewire stuff before managing packages + disable_all_pipewire($in); + + # start pulseaudio with same pipewire preserved user + if ($pipewire_user) { + start_pulseaudio($pipewire_user); + } +} + +sub config { my ($in, $modules_conf, $device) = @_; my $driver = $device->{current_driver} || $device->{driver}; - foreach (@blacklist) { $blacklisted = 1 if $driver eq $_ } - my @alternative = $driver ne 'unknown' ? get_alternative($driver) : (); - unless ($driver eq $device->{driver} || member($device->{driver}, @alternative)) { - push @alternative, get_alternative($device->{driver}), $device->{driver}; - } - if (@alternative) { - my $new_driver = $driver; + my @alternative = $driver ne $device->{driver} ? $device->{driver} : (); + if ($driver eq "unknown") { + $in->ask_warn(N("No known driver"), + N("There's no known driver for your sound card (%s)", + $device->{description})); + } else { push @alternative, $driver; my %des = modules::category2modules_and_description('multimedia/sound'); - my $is_pulseaudio_enabled = is_pulseaudio_enabled(); - my $is_pulseaudio_routing_enabled = is_pulseaudio_routing_enabled(); - my $is_5_1_in_pulseaudio_enabled = is_5_1_in_pulseaudio_enabled(); - my $is_user_switching = is_user_switching_enabled(); - - my $old_value = $is_pulseaudio_enabled; + my $is_pulseaudio_enabled_val = is_pulseaudio_enabled($in); + my $is_pulseaudio_glitchfree_enabled_val = is_pulseaudio_glitchfree_enabled(); + + my $audiosystem = 'None'; + if ($is_pulseaudio_enabled_val && $is_pulseaudio_glitchfree_enabled_val) { + $audiosystem = 'PulseAudioGF'; + } elsif ($is_pulseaudio_enabled_val) { + $audiosystem = 'PulseAudio'; + } elsif (is_pipewire_wireplumber_enabled($in) || _pidof('/usr/bin/wireplumber')) { + $audiosystem = 'PipeWireWP'; + } elsif (is_pipewire_media_session_enabled($in) || _pidof('/usr/bin/pipewire-media-session')) { + $audiosystem = 'PipeWireMS'; + } my $write_config = sub { - set_pulseaudio($is_pulseaudio_enabled); - set_pulseaudio_routing($is_pulseaudio_enabled && $is_pulseaudio_routing_enabled); - set_5_1_in_pulseaudio($is_5_1_in_pulseaudio_enabled); - set_user_switching($is_user_switching); - if ($is_pulseaudio_routing_enabled) { - $in->do_pkgs->ensure_is_installed('alsa-plugins-pulseaudio', '/usr/' . (arch() =~ /x86_64/ ? 'lib64' : 'lib') - .'/alsa-lib/libasound_module_pcm_pulse.so'); + if ($audiosystem eq 'None') { + #### ALSA alone + disable_all_pipewire($in); + set_pulseaudio(0); + set_pulseaudio_glitchfree(0); + # TODO check if adding autospawn = no to /etc/pulse/client.conf is needed + } elsif ($audiosystem eq 'PulseAudio') { + #### PulseAudio + configure_pulseaudio($in); + set_pulseaudio(1); + set_pulseaudio_glitchfree(0); + my $lib = get_libdir(); + $in->do_pkgs->ensure_is_installed($lib . 'alsa-plugins-pulseaudio', + '/usr/' . $lib . '/alsa-lib/libasound_module_pcm_pulse.so'); + } elsif ($audiosystem eq 'PulseAudioGF') { + #### PulseAudio with Glitch-Free mode + configure_pulseaudio($in); + set_pulseaudio(1); + set_pulseaudio_glitchfree(1); + my $lib = get_libdir(); + $in->do_pkgs->ensure_is_installed($lib . 'alsa-plugins-pulseaudio', + '/usr/' . $lib . '/alsa-lib/libasound_module_pcm_pulse.so'); + } elsif ($audiosystem eq 'PipeWireWP') { + #### PipeWire with WirePlumber + configure_pipewire_wireplumber($in); + } elsif ($audiosystem eq 'PipeWireMS') { + #### PipeWire with PipeWire Media Session + configure_pipewire_media_session($in); + } else { + #### Unmanaged value + #TODO Error here } - if ($old_value ne $is_pulseaudio_enabled) { - require any; - any::ask_for_X_restart($in); - } + + $in->ask_warn('', N("You need to reboot for changes to take effect")) if $::isStandalone; + }; + my $warn_both = ($in->do_pkgs->is_installed('pipewire') && $in->do_pkgs->is_installed('pulseaudio') && (-e $::prefix . '/etc/systemd/user/sockets.target.wants/pipewire.socket' || -e $::prefix . '/etc/systemd/user/sockets.target.wants/pipewire.service')) ? + N("Warning: both pulseaudio and pipewire are installed and can conflict each other. Please fix your config by applying a choice") : + ""; + + my $is_pipewire_available = $in->do_pkgs->is_available('task-pipewire'); + my $warn_pipewire_unavailable = !$is_pipewire_available ? + N("Warning: task-pipewire is not available in any media sources, so only pulseaudio could be set up. Please fix your repo configuration.") : + ""; + + my @service_list = ( + 'None', + 'PulseAudio', + 'PulseAudioGF', + ); + if ($is_pipewire_available) { + push @service_list, 'PipeWireWP'; + push @service_list, 'PipeWireMS'; + } my @common = ( - get_any_driver_entry($in, $modules_conf, $driver, $device), - { - text => N("Enable PulseAudio"), - type => 'bool', val => \$is_pulseaudio_enabled, - }, - { - text => N("Automatic routing from ALSA to PulseAudio"), - type => 'bool', val => \$is_pulseaudio_routing_enabled, - disabled => sub { !$is_pulseaudio_enabled }, - }, { - text => N("Enable 5.1 sound with Pulse Audio"), - type => 'bool', val => \$is_5_1_in_pulseaudio_enabled, - disabled => sub { !$is_pulseaudio_enabled }, + label => N("Select the sound server"), + title => 1, }, { - text => N("Enable user switching for audio applications"), - type => 'bool', val => \$is_user_switching, + val => \$audiosystem, + list => \@service_list, + format => sub { + my ($choice) = @_; + +{ + 'None' => N("None"), + 'PulseAudio' => N("PulseAudio"), + 'PulseAudioGF' => N("PulseAudio with Glitch-Free mode"), + 'PipeWireWP' => N("PipeWire with WirePlumber"), + 'PipeWireMS' => N("PipeWire with PipeWire Media Session"), + }->{$choice}; + }, + type => 'list', }, { advanced => 1, @@ -366,13 +562,21 @@ sub switch { clicked => sub { run_program::run('reset_sound') } }, { - advanced => 1, - val => N("Trouble shooting"), disabled => sub {}, + val => N("Troubleshooting"), disabled => sub {}, clicked => sub { &trouble($in) } }, ); - if ($new_driver eq 'unknown') { + my @messages = ("<b><i>" . $device->{description} . "</i></b>", + N("Your card uses the <b>\"%s\"</b> driver\n", $driver)); + + if ($warn_both) { + push @messages, ("<b>" . $warn_both . "</b>"); + } + if (!$is_pipewire_available) { + push @messages, "<b>" . $warn_pipewire_unavailable . "</b>"; + } + if ($driver eq 'unknown') { if ($in->ask_from_({ title => N("No alternative driver"), messages => N("There's no known OSS/ALSA alternative driver for your sound card (%s) which currently uses \"%s\"", @@ -383,127 +587,68 @@ sub switch { $write_config->(); } } elsif ($in->ask_from_({ title => N("Sound configuration"), - messages => - N("Here you can select an alternative driver (either OSS or ALSA) for your sound card (%s).", - $device->{description}) . - #-PO: here the first %s is either "OSS" or "ALSA", - #-PO: the second %s is the name of the current driver - #-PO: and the third %s is the name of the default driver - N("\n\nYour card currently use the %s\"%s\" driver (default driver for your card is \"%s\")", ($driver =~ /^snd_/ ? "ALSA " : "OSS "), $driver, $device->{driver}), - interactive_help => sub { - N("OSS (Open Sound System) was the first sound API. It's an OS independent sound API (it's available on most UNIX(tm) systems) but it's a very basic and limited API. -What's more, OSS drivers all reinvent the wheel. - -ALSA (Advanced Linux Sound Architecture) is a modularized architecture which -supports quite a large range of ISA, USB and PCI cards.\n -It also provides a much higher API than OSS.\n -To use alsa, one can either use: -- the old compatibility OSS api -- the new ALSA api that provides many enhanced features but requires using the ALSA library. -"); - }, + interactive_help_id => 'soundConfig', + messages => \@messages }, - [ - { - label => N("Driver:"), val => \$new_driver, list => \@alternative, default => $new_driver, sort =>1, - allow_empty_list => 1, - format => sub { my ($drv) = @_; - $drv eq 'unknown' ? $drv : - sprintf(($des{$drv} ? "$des{$drv} (%s [%s])" - : "%s [%s]"), $drv, $drv =~ /^snd_/ ? 'ALSA' : 'OSS'); - } - }, - @common, - ])) + \@common, + )) { $write_config->(); - return if $new_driver eq $device->{current_driver}; - log::explanations("switching audio driver from '" . $device->{current_driver} . "' to '$new_driver'\n"); - $in->ask_warn(N("Warning"), N("The old \"%s\" driver is blacklisted.\n -It has been reported to oops the kernel on unloading.\n -The new \"%s\" driver will only be used on next bootstrap.", $device->{current_driver}, $new_driver)) if $blacklisted; - do_switch($in, $modules_conf, $device->{current_driver}, $new_driver, $device->{sound_slot_index}); - $device->{current_driver} = $new_driver; } - } elsif ($driver =~ /^Bad:/) { - $driver =~ s/^Bad://; - $in->ask_warn(N("No open source driver"), - N("There's no free driver for your sound card (%s), but there's a proprietary driver at \"%s\".", - $device->{description}, $driver)); - } elsif ($driver eq "unknown") { - $in->ask_from(N("No known driver"), - N("There's no known driver for your sound card (%s)", - $device->{description}), - [ get_any_driver_entry($in, $modules_conf, $driver, $device) ]); } - end: -} - -sub config { - my ($in, $modules_conf, $device) = @_; - switch($in, $modules_conf, $device); } - sub trouble { my ($in) = @_; - $in->ask_warn(N("Sound trouble shooting"), + $in->ask_warn(N("Sound troubleshooting"), formatAlaTeX( #-PO: keep the double empty lines between sections, this is formatted a la LaTeX - N("The classic bug sound tester is to run the following commands: + N("Below are some basic tips to help debug audio problems, but for accurate and up-to-date tips and tricks, please see: +https://wiki.mageia.org/en/Support:DebuggingSoundProblems -- \"lspcidrake -v | fgrep -i AUDIO\" will tell you which driver your card uses -by default -- \"grep sound-slot /etc/modprobe.conf\" will tell you what driver it -currently uses -- \"/sbin/lsmod\" will enable you to check if its module (driver) is -loaded or not +- General Recommendation: Enable PulseAudio. If you have opted to not to use PulseAudio, we would strongly advise you enable it. For the vast majority of desktop use cases, PulseAudio is the recommended and best supported option. -- \"/sbin/chkconfig --list sound\" and \"/sbin/chkconfig --list alsa\" will -tell you if sound and alsa services're configured to be run on -initlevel 3 -- \"aumix -q\" will tell you if the sound volume is muted or not -- \"/sbin/fuser -v /dev/dsp\" will tell which program uses the sound card. -"))); -} +- \"kmix\" (KDE), \"gnome-control-center sound\" (GNOME) and \"pavucontrol\" (generic) will launch graphical applications to allow you to view your sound devices and adjust volume levels -sub get_any_driver_entry { - my ($in, $modules_conf, $driver, $device) = @_; - return () if $::isInstall; - +{ - advanced => 1, - val => N("Let me pick any driver"), disabled => sub {}, - clicked => sub { - my $old_driver = $driver; - if ($in->ask_from(N("Choosing an arbitrary driver"), - formatAlaTeX( - #-PO: keep the double empty lines between sections, this is formatted a la LaTeX - N("If you really think that you know which driver is the right one for your card -you can pick one in the above list. - -The current driver for your \"%s\" sound card is \"%s\" ", $device->{description}, $driver)), - [ - { label => N("Driver:"), val => \$driver, list => [ category2modules("multimedia/sound") ], type => 'combo', default => $driver, sort =>1, separator => '|' }, - ] - )) { - do_switch($in, $modules_conf, $old_driver, $driver, $device->{sound_slot_index}); - goto end; - } - } - }; + +- \"ps aux | grep pulseaudio\" will check that PulseAudio is running. + + +- \"pactl stat\" will check that you can connect to the PulseAudio daemon correctly. + + +- \"pactl list sink-inputs\" will tell you which programs are currently playing sound via PulseAudio. + + +- \"systemctl status osspd.service\" will tell you the current state of the OSS Proxy Daemon. This is used to enable sound from legacy applications which use the OSS sound API. You should install the \"ossp\" package if you need this functionality. + + +- \"pacmd ls\" will give you a LOT of debug information about the current state of your audio. + + +- \"lspcidrake -v | grep -i audio\" will tell you which low-level driver your card uses by default. + + +- \"/usr/sbin/lsmod | grep snd\" will enable you to check which sound related kernel modules (drivers) are loaded. + + +- \"alsamixer -c 0\" will give you a text-based mixer to the low level ALSA mixer controls for first sound card + + +- \"/usr/sbin/fuser -v /dev/snd/pcm* /dev/dsp\" will tell which programs are currently using the sound card directly (normally this should only show PulseAudio) +"))); } sub configure_one_sound_slot { my ($modules_conf, $index, $driver) = @_; $modules_conf->set_sound_slot("sound-slot-$index", $driver); $modules_conf->set_options($driver, "xbox=1") if $driver eq "snd_intel8x0" && detect_devices::is_xbox(); - $modules_conf->set_options('snd-ac97-codec', "power_save=1") if $driver =~ /^snd/ && detect_devices::isLaptop() - && arch() !~ /mips/; + $modules_conf->set_options('snd-ac97-codec', "power_save=1") if $driver =~ /^snd/ && detect_devices::isLaptop(); } sub configure_sound_slots { @@ -511,7 +656,7 @@ sub configure_sound_slots { my $altered = 0; each_index { my $default_driver = $modules_conf->get_alias("sound-slot-$::i"); - if (!member($default_driver, get_alternative($_->{driver}), $_->{driver})) { + if (!member($default_driver, $_->{driver})) { $altered ||= $default_driver; configure_one_sound_slot($modules_conf, $::i, $_->{driver}); } diff --git a/perl-install/harddrake/v4l.pm b/perl-install/harddrake/v4l.pm index 7711c250a..bd7c649bb 100644 --- a/perl-install/harddrake/v4l.pm +++ b/perl-install/harddrake/v4l.pm @@ -473,7 +473,7 @@ sub config { if ($in->ask_from("BTTV configuration", N("For most modern TV cards, the bttv module of the GNU/Linux kernel just auto-detect the rights parameters. -If your card is misdetected, you can force the right tuner and card types here. Just select your tv card parameters if needed."), +If your card is misdetected, you can force the right tuner and card types here. Just select your TV card parameters if needed."), [ { label => N("Card model:"), val => \$conf{card}, list => [ keys %cards_list ], default => -1, sort =>1, separator => '|' }, { label => N("Tuner type:"), val => \$conf{tuner}, list => [keys %tuners_lst], format => sub { $tuners_lst{$_[0]} }, sort => 1, separator => '|' }, @@ -483,7 +483,7 @@ If your card is misdetected, you can force the right tuner and card types here. $conf{card} = $cards_list{$conf{card}}; if (my $options = join(' ', if_($driver eq 'bttv', 'radio=' . ($conf{radio} ? 1 : 0)), map { if_($conf{$_} ne -1, "$_=$conf{$_}") } qw(card pll tuner gbuffers))) { log::l(qq([harddrake::v4l] set "$options" options for $driver)); -# log::explanations("modified file /etc/modules.conf ($options)") if $::isStandalone; +# log::explanations("modified file /etc/modprobe.conf ($options)") if $::isStandalone; $modules_conf->set_options($driver, $options); } return 1; |