Class: Yast::SoundClass
- Inherits:
-
Module
- Object
- Module
- Yast::SoundClass
- Defined in:
- ../../src/modules/Sound.rb
Instance Method Summary (collapse)
- - (Object) AllRequiredPackagesInstalled
-
- (Object) asound_state
returns path to the asound.state file.
-
- (Boolean) Changed
Status of configuration.
-
- (Hash) CollectOptions(modname)
this function converts options for modules from 'modules_conf' data structure to another - it is needed for writing options to /etc/modules conf.
- - (Object) ConfirmPackages
-
- (Array) CreateModprobeCommands
creates list of command that will be used for sound system start (emulates 'rcalsasound start' somehow).
-
- (Boolean) DetectHardware
do hardware detection.
-
- (Object) DetectOldCards
Detect old ISA cards (which hwinfo doesn't know) using alsaconf.
-
- (Hash) Export
Dump the sound settings to a single map.
- - (Object) ExportVolumeSettings(volume_setup)
-
- (Object) ForceReset
reset settings.
-
- (Array) getConfigurableCards(save_info)
returns list of autodetected sound cards that haven't been already configured.
-
- (Hash) GetJoystickSettings(modname)
Get joystick settings from sound database.
-
- (Boolean) GetModified
Functions which returns if the settings were modified.
-
- (Array) GetSoundCardList
returns list of configured/proposed sound cards.
-
- (Array) GetSoundCardListWithJoy
Return list of configured/proposed sound cards which support joystick.
-
- (Boolean) HasJoystick(c_id)
Test whether sound card supports joystick.
-
- (Boolean) Import(settings)
Get all sound settings from the first parameter (For autoinstallation use.).
- - (Object) ImportVolumeSettings(volume_setup)
-
- (Object) InitMixer(c_id, modname)
initialises volume after adding a new card.
-
- (void) LoadDatabase(use_ui)
opens alsa sound cards database.
-
- (void) LoadPackageDatabase
opens alsa sound cards database.
- - (Object) main
- - (Object) PollAbort
-
- (Object) ProbeOldChip(chip)
Probe one card with alsaconf call.
-
- (Boolean) Propose
create a proposal.
-
- (Boolean) Read(interactive)
Read all sound settings from the SCR (currently only for detecting with alsaconf).
-
- (void) ReadModulesConf
searches for sound alias in /etc/modules.conf.
-
- (Array) RequiredKernelModules
Get list of all kernel modules which are requied by the configured cards.
- - (Object) RequiredPackages(driver)
- - (Object) RequiredPackagesToInstall(driver)
- - (Object) RequiredPackagesToInstallSummary(driver)
-
- (Object) RestoreSettings
restore settings from backup variables.
-
- (void) Set(settings)
Just Set module data.
- - (Object) SetConfirmPackages(ask)
-
- (Object) SetModified
Function sets internal variable, which indicates, that any settings were modified, to “true”.
-
- (Object) SetVolume(c_id, channel, value)
sets the channel volume to value [0..100].
-
- (Object) Sound
sound module constructor.
-
- (Object) StoreMixer
store mixer settings.
-
- (Object) StoreSettings
copy settings to backup variables.
-
- (Object) StoreUniqueKeys
stores unique keys.
-
- (String) Summary
returns html formated configuration summary.
-
- (void) UpdateUnconfiguredCards
update list of unconfigured cards (necessary when deleting configured card).
-
- (Boolean) Write
Update the SCR according to sound settings.
Instance Method Details
- (Object) AllRequiredPackagesInstalled
835 836 837 838 839 840 841 842 843 844 845 846 847 848 |
# File '../../src/modules/Sound.rb', line 835 def AllRequiredPackagesInstalled all_mods = RequiredKernelModules() ret = true Builtins.foreach(all_mods) do |mod| if Ops.greater_than(Builtins.size(RequiredPackagesToInstall(mod)), 0) ret = false end end Builtins.y2milestone("All required packages are installed: %1", ret) ret end |
- (Object) asound_state
returns path to the asound.state file
176 177 178 |
# File '../../src/modules/Sound.rb', line 176 def asound_state "/var/lib/alsa/asound.state" end |
- (Boolean) Changed
Status of configuration
1111 1112 1113 1114 |
# File '../../src/modules/Sound.rb', line 1111 def Changed return true if @modules_conf != @modules_conf_b || @rc_vars != @rc_vars_b false end |
- (Hash) CollectOptions(modname)
this function converts options for modules from 'modules_conf' data structure to another - it is needed for writing options to /etc/modules conf. eg. we have these configured cards: [ $["model": "sblive", "module":"snd-emu10k1", "options" :$["opt1": "a", "opt2": "b"]], $["model": "sblive", "module":"snd-emu10k1", "options": $["opt2": "c"]], $["model": "other", "module":"mod2", "options": $["opt1": "a", "opt2": "b"]] ] CollectOptions ("snd-emu10k1") returns $["opt1":"a,", "opt2":"b,c"]
919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 |
# File '../../src/modules/Sound.rb', line 919 def CollectOptions(modname) # first filter out entries with other module mod_entries = Builtins.filter(@modules_conf) do |e| Ops.get_string(e, "module", "off") == modname end Builtins.y2debug("modules_conf: %1", @modules_conf) # create list of options (list of maps) mod_opts = Builtins.maplist( Convert.convert(mod_entries, :from => "list", :to => "list <map>") ) { |e| Ops.get_map(e, "options", {}) } opts = [] Builtins.foreach(mod_opts) { |card_opts| Builtins.foreach(card_opts) do |name, val| opts = Builtins.add(opts, name) end } opts = Builtins.toset(opts) opts = Builtins.filter(opts) { |e| e != "snd_id" } # not neccessary? res = {} # get the default module parameters from database params = get_module_params(modname) Builtins.y2milestone("Default module parameters: %1", params) # for each option collect their values Builtins.y2milestone("options: %1", opts) Builtins.y2milestone("module options: %1", mod_opts) Builtins.foreach(opts) do |opname| value = "" # is the value first? first_value = true # all options are default, not configured by user only_default = true Builtins.foreach(mod_opts) do |card_opts| # add the separator if needed value = Ops.add(value, ",") if !first_value # value for the card card_option_value = Ops.get_string(card_opts, opname, "") default_value = Ops.get_string(params, [opname, "default"], "") Builtins.y2debug("card_option_value: '%1'", card_option_value) Builtins.y2debug("default_value: '%1'", default_value) if card_option_value != default_value && card_option_value != "" only_default = false end # use default if if the value is not defined card_option_value = default_value if card_option_value == "" value = Ops.add(value, card_option_value) first_value = false end Builtins.y2debug("only_default: %1", only_default) # don't add the default options if !only_default || opname == "index" res = Builtins.add(res, opname, value) end end Builtins.y2milestone("collected options: %1", res) deep_copy(res) end |
- (Object) ConfirmPackages
1376 1377 1378 |
# File '../../src/modules/Sound.rb', line 1376 def ConfirmPackages @confirm_packages end |
- (Array) CreateModprobeCommands
creates list of command that will be used for sound system start (emulates 'rcalsasound start' somehow)
983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 |
# File '../../src/modules/Sound.rb', line 983 def CreateModprobeCommands outlist = [] # create distinct list of all modules mods = Builtins.toset(Builtins.maplist(@modules_conf) do |e| Ops.get_string(e, "module", "off") end) Builtins.maplist( Convert.convert(mods, :from => "list", :to => "list <string>") ) do |modname| opts = CollectOptions(modname) if Builtins.haskey(opts, "index") # ignore "index" options opts = Builtins.remove(opts, "index") end optstr = "" Builtins.maplist( Convert.convert(opts, :from => "map", :to => "map <string, string>") ) { |k, v| optstr = Ops.add(optstr, Builtins.sformat(" %1=%2", k, v)) } # we need to tell 'modprobe' not to look into modules.conf now, # because it may contain messed options for the module %1 that # would break the module loading. (modprobe will merge options # specified in param %2 with those specified in modules.conf) modprobe = Builtins.sformat( "/sbin/modprobe -C /dev/null %1 %2", modname, optstr ) outlist = Builtins.add(outlist, modprobe) end # add the extra module if Builtins.contains(mods, "snd-aoa") Builtins.y2milestone( "Adding extra module: snd-aoa-i2sbus, snd-aoa-fabric-layout" ) outlist = Builtins.add( outlist, "/sbin/modprobe -C /dev/null snd-aoa-i2sbus" ) outlist = Builtins.add( outlist, "/sbin/modprobe -C /dev/null snd-aoa-fabric-layout" ) end Builtins.y2milestone("Modprobe commands: %1", outlist) deep_copy(outlist) end |
- (Boolean) DetectHardware
do hardware detection
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 |
# File '../../src/modules/Sound.rb', line 410 def DetectHardware if Mode.test @detected_cards = [ { "bus" => "PCI", "class_id" => 4, "device" => "SB Live! EMU10000", "device_id" => 65538, "drivers" => [ { "active" => false, "modprobe" => true, "modules" => [["emu10k1", ""]] } ], "old_unique_key" => "LaV9.FfCiMJnnUxC", "resource" => { "io" => [ { "active" => true, "length" => 0, "mode" => "rw", "start" => 49152 } ], "irq" => [{ "count" => 41833, "enabled" => true, "irq" => 10 }] }, "rev" => "7", "slot_id" => 5, "sub_class_id" => 1, "sub_device" => "CT4832 SBLive! Value", "sub_device_id" => 98343, "sub_vendor" => "Creative Labs", "sub_vendor_id" => 69890, "unique_key" => "CvwD.FfCiMJnnUxC", "vendor" => "Creative Labs", "vendor_id" => 69890 } ] return true end @detected_cards = [] if Mode.config if @skip_detection @detected_cards = [] return true end # do noop if cards were already detected return true if Ops.greater_than(Builtins.size(@detected_cards), 0) @detected_cards = Convert.convert( SCR.Read(path(".probe.sound")), :from => "any", :to => "list <map>" ) true end |
- (Object) DetectOldCards
Detect old ISA cards (which hwinfo doesn't know) using alsaconf
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 |
# File '../../src/modules/Sound.rb', line 241 def DetectOldCards chips = [ "opl3sa2", "cs4236", "cs4232", "cs4231", "es18xx", "es1688", "sb16", "sb8" ] command = "/usr/sbin/alsaconf -P" out = Convert.to_map(SCR.Execute(path(".target.bash_output"), command)) return false if Ops.get_integer(out, "exit", 1) != 0 out_str = Builtins.deletechars(Ops.get_string(out, "stdout", ""), "\n") chips = Builtins.splitstring(out_str, " ") if out_str != "" probelist = [] Builtins.foreach(chips) do |chip| name = Ops.get_string( @db_modules, [Ops.add("snd-", chip), "description"], "" ) if name != "" name = Builtins.sformat("%1 (%2)", name, chip) else name = chip end probelist = Builtins.add(probelist, Item(Id(chip), name, true)) end height = Ops.add(Builtins.size(chips), 12) height = 25 if Ops.greater_than(height, 25) UI.OpenDialog( HBox( VSpacing(height), HSpacing(1), VBox( HSpacing(50), VSpacing(0.5), # label Label( Id(:l), _( "No card was found.\n" + "Attempt to detect the presence some old chips?\n" + "\n" + "Warning: The probe procedure can take some time and\n" + "could make your system unstable.\n" ) ), VSpacing(), MultiSelectionBox( Id(:probelist), # selection box label _("&Select the Drivers to Probe"), probelist ), HBox( # button label PushButton(Id(:ok), Opt(:key_F10, :default), _("&Yes, Probe")), # button label PushButton(Id(:cancel), Opt(:key_F9), Label.CancelButton) ), VSpacing(0.5) ), HSpacing(1) ) ) ret = Convert.to_symbol(UI.UserInput) if ret == :ok chips = Convert.convert( UI.QueryWidget(Id(:probelist), :SelectedItems), :from => "any", :to => "list <string>" ) UI.OpenDialog( HBox( VSpacing(7), VBox( HSpacing(40), # popup dialog header Label(_("Probing:")), HBox(HWeight(1, Label(Id(:probed), ""))), # progress bar label ProgressBar( Id(:progress), _("Progress:"), Builtins.size(chips), 0 ), VSpacing(0.5), PushButton(Id(:abort), Opt(:key_F9), Label.AbortButton) ) ) ) aborted = false Builtins.foreach(chips) do |chip| next if aborted aborted = UI.PollInput == :abort UI.ChangeWidget( Id(:probed), :Value, Ops.get_string( @db_modules, [Ops.add("snd-", chip), "description"], chip ) ) ret2 = ProbeOldChip(chip) if ret2 != "" # parse the output and add new entry to detected_cards chip = Builtins.sformat("snd-%1", chip) returned = Builtins.splitstring(ret2, "\n") Builtins.y2milestone("probed with alsaconf: %1", returned) # label (%1 is name of the chip) default_name = Builtins.sformat( _("Card with %1 Chip"), Ops.get_string(@db_modules, [chip, "description"], chip) ) model = Ops.get_string(returned, 1, default_name) model = default_name if model == "" ret2 = Ops.get_string(returned, 0, "") = {} Builtins.foreach(Builtins.splitstring(ret2, " ")) do |o| op = Builtins.splitstring(o, "=") if Builtins.size(op) == 2 = Builtins.add( , Ops.get_string(op, 0, ""), Ops.get_string(op, 1, "") ) end end @detected_cards = Builtins.add( @detected_cards, { "model" => model, "module" => chip, "options" => , "alsaconf_detected" => true } ) end # advance the progress bar UI.ChangeWidget( Id(:progress), :Value, Ops.add( Convert.to_integer(UI.QueryWidget(Id(:progress), :Value)), 1 ) ) end UI.CloseDialog #progress window end UI.CloseDialog true end |
- (Hash) Export
Dump the sound settings to a single map. self explaining (For use by autoinstallation.)
802 803 804 805 806 807 808 809 |
# File '../../src/modules/Sound.rb', line 802 def Export { "modules_conf" => @modules_conf, "rc_vars" => @rc_vars, "volume_settings" => ExportVolumeSettings(@volume_settings), "configure_detected" => @configure_detected } end |
- (Object) ExportVolumeSettings(volume_setup)
691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 |
# File '../../src/modules/Sound.rb', line 691 def ExportVolumeSettings(volume_setup) volume_setup = deep_copy(volume_setup) Builtins.y2milestone("ExportVolumeSettings: %1", volume_setup) ret = [] return deep_copy(ret) if volume_setup == nil Builtins.foreach(volume_setup) do |card| channels = [] Builtins.foreach( Convert.convert(card, :from => "list", :to => "list <list>") ) do |channel| ch = { "name" => Ops.get_string(channel, 0, "unknown"), "volume" => Ops.get_integer(channel, 1, 0), "mute" => Ops.get_boolean(channel, 2, false) } channels = Builtins.add(channels, ch) end ret = Builtins.add(ret, channels) end Builtins.y2milestone("Exported volume setting: %1", ret) deep_copy(ret) end |
- (Object) ForceReset
reset settings. used at installation time when user invokes 'reset to original proposal'
1035 1036 1037 1038 1039 1040 1041 1042 |
# File '../../src/modules/Sound.rb', line 1035 def ForceReset @modules_conf = [] DetectHardware() UpdateUnconfiguredCards() @proposal_created = false nil end |
- (Array) getConfigurableCards(save_info)
returns list of autodetected sound cards that haven't been already configured
484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 |
# File '../../src/modules/Sound.rb', line 484 def getConfigurableCards(save_info) save_info = deep_copy(save_info) snd = deep_copy(@detected_cards) snd = filter_configured(save_info, snd) # create save_info entries if Ops.greater_than(Builtins.size(snd), 0) if !@use_alsa snd = Builtins.maplist(snd) do |card| = Ops.get_list(card, "options", []) opts = {} Builtins.maplist() do |op| if Ops.get_string(op, "default", "") != "" opts = Builtins.add( opts, Ops.get_string(op, "name", ""), Ops.get_string(op, "default", "") ) end end modname = "" drivers = Ops.get_list(card, "drivers", []) if Ops.greater_than(Builtins.size(drivers), 0) driver = Ops.get_map(drivers, 0, {}) m = Ops.get_list(driver, "modules", []) if Ops.greater_than(Builtins.size(m), 0) modname = Ops.get_string(m, [0, 0], "") modname = String.FirstChunk(modname, ".") end end { "model" => get_card_label(card), "module" => modname, "unique_key" => Ops.get_string(card, "unique_key", ""), "options" => opts } end else snd = Builtins.maplist(snd) do |card| if Ops.get_boolean(card, "alsaconf_detected", false) next deep_copy(card) end # get all the apropriate information from the database mod = get_module(card) next {} if mod == {} opts = {} Builtins.maplist(Ops.get_map(mod, "params", {})) do |op, data| if Ops.get_string(data, "default", "") != "" opts = Builtins.add( opts, op, Ops.get_string(data, "default", "") ) end end entry = { "model" => get_card_label(card), "module" => Ops.get_string(mod, "name", ""), "unique_key" => Ops.get_string(card, "unique_key", ""), "options" => opts, "bus" => Ops.get_string(card, "bus_hwcfg", ""), "bus_id" => Ops.get_string(card, "sysfs_bus_id", ""), "vendor_id" => Ops.get_integer(card, "vendor_id", 0), "sub_vendor_id" => Ops.get_integer(card, "sub_vendor_id", 0), "device_id" => Ops.get_integer(card, "device_id", 0), "sub_device_id" => Ops.get_integer(card, "sub_device_id", 0) } deep_copy(entry) end end # filter out modules with unspecified module name # (sound card not supported by alsa / no module found) snd = Builtins.filter(snd) { |e| Ops.get_string(e, "module", "") != "" } end deep_copy(snd) end |
- (Hash) GetJoystickSettings(modname)
Get joystick settings from sound database
1167 1168 1169 |
# File '../../src/modules/Sound.rb', line 1167 def GetJoystickSettings(modname) Ops.get_map(@db_modules, [modname, "joystick"], {}) end |
- (Boolean) GetModified
Functions which returns if the settings were modified
171 172 173 |
# File '../../src/modules/Sound.rb', line 171 def GetModified @modified end |
- (Array) GetSoundCardList
returns list of configured/proposed sound cards.
1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 |
# File '../../src/modules/Sound.rb', line 1118 def GetSoundCardList if @installation || Mode.autoinst pos = -1 return Builtins.maplist(@modules_conf) do |card| pos = Ops.add(pos, 1) { "name" => Ops.get_locale(card, "model", _("Sound card")), "card_no" => pos } end else cards_path = path(".audio.alsa.cards") cards_numbers = SCR.Dir(cards_path) cards = [] cards = Builtins.maplist(cards_numbers) do |card_no| curcard_path = Builtins.add( cards_path, Builtins.sformat("%1", card_no) ) { "card_no" => Builtins.tointeger(card_no), "name" => SCR.Read(Ops.add(curcard_path, path(".name"))) } end if cards_numbers != nil Builtins.y2milestone("List of the sound cards: %1", cards) return deep_copy(cards) end end |
- (Array) GetSoundCardListWithJoy
Return list of configured/proposed sound cards which support joystick
1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 |
# File '../../src/modules/Sound.rb', line 1345 def GetSoundCardListWithJoy # get list of installed sound cards cards = GetSoundCardList() # cards which support joysticks filtered = [] # remove cards without joystick support Builtins.foreach( Convert.convert( cards, :from => "list", :to => "list <map <string, any>>" ) ) do |card| cid = Ops.get_integer(card, "card_no", -2) if cid != -2 && HasJoystick(cid) == true filtered = Builtins.add(filtered, card) end end deep_copy(filtered) end |
- (Boolean) HasJoystick(c_id)
Test whether sound card supports joystick
1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 |
# File '../../src/modules/Sound.rb', line 1331 def HasJoystick(c_id) return false if c_id == nil if @use_alsa == true entry = Ops.get(@modules_conf, c_id, {}) modname = Ops.get_string(entry, "module", "") return Ops.get_map(@db_modules, [modname, "joystick"], {}) != {} else return false end end |
- (Boolean) Import(settings)
Get all sound settings from the first parameter (For autoinstallation use.)
788 789 790 791 792 793 794 795 796 797 |
# File '../../src/modules/Sound.rb', line 788 def Import(settings) settings = deep_copy(settings) # initialize these unneeded values @detected_cards = [] @unconfigured_cards = [] Set(settings) true end |
- (Object) ImportVolumeSettings(volume_setup)
719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 |
# File '../../src/modules/Sound.rb', line 719 def ImportVolumeSettings(volume_setup) volume_setup = deep_copy(volume_setup) ret = [] Builtins.y2milestone("ImportVolumeSettings: %1", volume_setup) return deep_copy(ret) if volume_setup == nil Builtins.foreach( Convert.convert(volume_setup, :from => "list", :to => "list <list>") ) do |card| channels = [] Builtins.foreach(card) do |channel| ch = [] if Ops.is_map?(channel) channel_map = Convert.to_map(channel) # convert map to list ch = Builtins.add( ch, Ops.get_string(channel_map, "name", "unknown") ) ch = Builtins.add(ch, Ops.get_integer(channel_map, "volume", 0)) ch = Builtins.add(ch, Ops.get_boolean(channel_map, "mute", false)) elsif Ops.is_list?(channel) # use the list ch = Convert.to_list(channel) else # wrong type Builtins.y2error( "Wrong channel configuration '%1', expected list or map!", channel ) end channels = Builtins.add(channels, ch) end ret = Builtins.add(ret, channels) end Builtins.y2milestone("Imported volume setting: %1", ret) deep_copy(ret) end |
- (Object) InitMixer(c_id, modname)
initialises volume after adding a new card. unmutes and sets volume for some channels
1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 |
# File '../../src/modules/Sound.rb', line 1264 def InitMixer(c_id, modname) Builtins.y2milestone("InitMixer: %1, %2", c_id, modname) devs = Convert.convert( Ops.get(@db_modules, [modname, "mixer"]) do { "Master" => @default_volume, "PCM" => @default_volume, "CD" => @default_volume, "Synth" => @default_volume, "Front" => @default_volume, "Headphone" => @default_volume, "Master Mono" => @default_volume, "iSpeaker" => @default_volume } end, :from => "any", :to => "map <string, integer>" ) Builtins.y2milestone("Mixer devices: %1", devs) # now let's merge settings from volume_settings list if Ops.is_list?(Ops.get(@volume_settings, c_id)) Builtins.y2milestone( "cvolume_settings[c_id]:nil: %1", Ops.get(@volume_settings, c_id) ) Builtins.foreach(Ops.get(@volume_settings, c_id, [])) do |channel| Builtins.y2debug("devs: %1", devs) Builtins.y2debug("channel: %1", channel) # do not rewrite the values from DB if !Builtins.haskey(devs, Ops.get_string(channel, 0, "Master")) devs = Builtins.add( devs, Ops.get_string(channel, 0, "Master"), Ops.get_integer(channel, 1, @default_volume) ) end end end Builtins.y2milestone("Mixer devices after merge: %1", devs) devs2 = [] Builtins.foreach( Convert.convert(devs, :from => "map", :to => "map <string, integer>") ) do |dev, vol| SetVolume(c_id, dev, vol) Builtins.y2milestone( "Set volume: card: %1, channel: %2, volume: %3", c_id, dev, vol ) devs2 = Builtins.add(devs2, dev) end Builtins.y2milestone("unmute devices: %1", devs2) unmute(devs2, c_id) nil end |
- (void) LoadDatabase(use_ui)
This method returns an undefined value.
opens alsa sound cards database
576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 |
# File '../../src/modules/Sound.rb', line 576 def LoadDatabase(use_ui) sound_db = {} if @db_cards == nil || @db_cards == {} textdomain "sound_db" Builtins.y2debug("Reading card database") sound_db = YAML.load_file(Directory.datadir + "/sndcards.yml") rescue {} @db_cards = Ops.get_map(sound_db, "cards", {}) @db_modules = Ops.get_map(sound_db, "modules", {}) @db_indices = Ops.get_map(sound_db, "indices", {}) @db_module_index = Ops.get_map(sound_db, "mod_idx", {}) @db_vendors = Ops.get_map(sound_db, "vendors", {}) textdomain "sound" end nil end |
- (void) LoadPackageDatabase
This method returns an undefined value.
opens alsa sound cards database
599 600 601 602 603 604 605 606 607 608 609 |
# File '../../src/modules/Sound.rb', line 599 def LoadPackageDatabase Builtins.y2milestone("Reading required packages database...") @db_packages = YAML.load_file(Directory.datadir + "/alsa_packages.yml") rescue {} Builtins.y2milestone( "Loaded package list for %1 drivers", Builtins.size(@db_packages) ) nil end |
- (Object) main
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File '../../src/modules/Sound.rb', line 13 def main Yast.import "UI" textdomain "sound" Yast.import "Arch" Yast.import "Mode" Yast.import "Summary" Yast.import "Crash" Yast.import "Progress" Yast.import "Label" Yast.import "String" Yast.import "Package" Yast.import "Directory" # what sound system we're using (true=alsa, false=oss) @use_alsa = true Yast.include self, "sound/texts.rb" # id of current card @card_id = 0 # configuration map of current card @save_entry = {} # text constants for sound module @STRINGS = STRINGS_() # flag for letting the module know, that it's launched from then hardware # installation screen @installation = false # was the proposal already generated? @proposal_created = false # write only mode? (-> do not restart services during writing) @write_only = false # list for storing detected cards @detected_cards = nil # list for storing information about removed cards @removed_info = [] # list of detected and unconfigured cards @unconfigured_cards = nil # settings to save to /etc/modules.conf (only those concerning to sound) @modules_conf = [] # settings to save using .audio.alsa ... mixer @volume_settings = [] # rc settings @rc_vars = {} # alsa sound card database # card list @db_cards = nil # module details @db_modules = nil # @db_indices = nil # map of card vendors @db_vendors = nil # @db_module_index = nil @db_packages = nil # flag for showing/not showing ui stuff (eg when loading alsa database) @use_ui = false # currently used card vendor (pointer to table) @curr_vendor = "" # currently used card driver (pointer to table) @curr_driver = "" # currently used card model (pointer to table) @curr_model = "" # default value of volume for new card @default_volume = 75 # This is true, if sound data were read from /etc/modprobe.conf # On write, they shoud be removed and written only to /etc/modprobe.d/50-sound.conf @used_modprobe_conf = false # When true: # During autoinstallation, detected cards will be added automaticaly # even if they are not defined in control file @configure_detected = false # Do not detect sounc cards, skip hardware probing @skip_detection = false # backup structures for sound settings @modules_conf_b = nil @rc_vars_b = nil @volume_settings_b = nil @selected_uniq = "" # confirm package installation (e.g. alsa-firmware) @confirm_packages = true # default value of settings modified @modified = false # ----------- rest of included files: Yast.include self, "sound/read_routines.rb" Yast.include self, "sound/routines.rb" # ----------- function definitions: # tiwai: /usr/src/linux/Documentation/sound/alsa/Joystick.txt # PCI Cards # --------- # # For PCI cards, the joystick is enabled when the appropriate module # option is specified. Some drivers don't need options, and the # joystick support is always enabled. In the former ALSA version, there # was a dynamic control API for the joystick activation. It was # changed, however, to the static module options because of the system # stability and the resource management. # # The following PCI drivers support the joystick natively. @joystick_configuration = { "snd-als4000" => { "joystick_port" => "1" }, "snd-azt3328" => { "joystick" => "1" }, "snd-ens1370" => { "joystick" => "1" }, "snd-ens1371" => { "joystick_port" => "1" }, "snd-cmipci" => { "joystick_port" => "1" }, "snd-es1968" => { "joystick" => "1" }, "snd-intel8x0" => { "joystick" => "1" }, "snd-via82xx" => { "joystick" => "1" }, "snd-ymfpci" => { "joystick_port" => "1" } } Sound() end |
- (Object) PollAbort
570 571 572 |
# File '../../src/modules/Sound.rb', line 570 def PollAbort UI.PollInput == :abort end |
- (Object) ProbeOldChip(chip)
Probe one card with alsaconf call
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
# File '../../src/modules/Sound.rb', line 200 def ProbeOldChip(chip) command = Builtins.sformat("/usr/sbin/alsaconf -p %1", chip) name = Ops.get_string( @db_modules, [Ops.add("snd-", chip), "description"], chip ) # yes/no popup text, %1 is chip name if Crash.AskRun( command, Builtins.sformat( _( "It looks like probing the chip\n" + "%1\n" + "failed last time.\n" + "\n" + "Probe the chip now?\n" ), name ) ) Crash.Run(command) out = Convert.to_map(SCR.Execute(path(".target.bash_output"), command)) Crash.Finish(command) if Ops.get_string(out, "stderr", "") != "" Builtins.y2warning( "alsaconf returns error: %1", Ops.get_string(out, "stderr", "") ) end if Ops.get_integer(out, "exit", 1) == 0 return Ops.get_string(out, "stdout", "") end end "" end |
- (Boolean) Propose
create a proposal
1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 |
# File '../../src/modules/Sound.rb', line 1046 def Propose return true if @proposal_created # to enable initialization, run ForceReset for first time, # even if "force_reset" parameter was not set # TODO: but if force_reset is set, ForceReset is run twice! ForceReset() # fix for nm256 cards: see bug #10384: leave this card unconfigured. # loading of this module fails under some notebooks, nm256 module # also makes some problems on other notebooks: there are detected # two cards on some machines, althrough there is a sinlge card. # two cards are detected: one that use opl3sa module and second one # that uses nm256. # let's solve this problem by filtering the nm256 module out. @unconfigured_cards = Builtins.filter(@unconfigured_cards) do |card| Ops.get_string(card, "module", "") != "snd-nm256" end @modules_conf = recalc_save_entries(@unconfigured_cards) # card of Thinkpad 600E must be configured manually @modules_conf = Builtins.filter(@modules_conf) do |card| ok = true Builtins.foreach(@detected_cards) do |c| if Ops.get_string(c, "unique_key", "") == Ops.get_string(card, "unique_key", "") && Ops.get_integer(c, "sub_device_id", 0) == 69648 && Ops.get_integer(c, "sub_vendor_id", 0) == 69652 && Ops.get_string(card, "module", "") != "snd-cs4236" ok = false end end ok end @rc_vars = { "LOAD_ALSA_SEQ" => "yes" } @proposal_created = true true end |
- (Boolean) Read(interactive)
Read all sound settings from the SCR (currently only for detecting with alsaconf)
654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 |
# File '../../src/modules/Sound.rb', line 654 def Read(interactive) # sound Read dialog caption: caption = _("Initializing Sound Configuration") if Mode.test DetectHardware() @modules_conf = [] @rc_vars = {} UpdateUnconfiguredCards() return true end return false if interactive && PollAbort() # load cards database LoadDatabase(interactive) # load data from /etc/modules.conf ReadModulesConf() # detect sound cards DetectHardware() # check old isa cards (bug25285) if interactive && @detected_cards == [] && @modules_conf == [] DetectOldCards() end @rc_vars = read_rc_vars @volume_settings = get_vol_settings # create list of unconfigured cards UpdateUnconfiguredCards() true end |
- (void) ReadModulesConf
This method returns an undefined value.
searches for sound alias in /etc/modules.conf
472 473 474 475 476 477 |
# File '../../src/modules/Sound.rb', line 472 def ReadModulesConf @modules_conf = read_save_info Builtins.y2milestone("read_save_info: %1", @modules_conf) nil end |
- (Array) RequiredKernelModules
Get list of all kernel modules which are requied by the configured cards
813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 |
# File '../../src/modules/Sound.rb', line 813 def RequiredKernelModules # list of all unique modules mods = [] if @modules_conf != nil && Ops.greater_than(Builtins.size(@modules_conf), 0) Builtins.foreach(@modules_conf) do |m| modname = Ops.get_string(m, "module", "") if m != nil && Ops.greater_than(Builtins.size(m), 0) mods = Builtins.add(mods, modname) end end end # remove duplicates mods = Builtins.toset(mods) Builtins.y2milestone("Required kernel modules: %1", mods) deep_copy(mods) end |
- (Object) RequiredPackages(driver)
611 612 613 614 615 616 617 618 |
# File '../../src/modules/Sound.rb', line 611 def RequiredPackages(driver) LoadPackageDatabase() if @db_packages == nil ret = Ops.get_list(@db_packages, driver, []) Builtins.y2milestone("Driver %1 requires packages: %2", driver, ret) deep_copy(ret) end |
- (Object) RequiredPackagesToInstall(driver)
620 621 622 623 624 625 626 627 628 629 630 631 632 |
# File '../../src/modules/Sound.rb', line 620 def RequiredPackagesToInstall(driver) req_pkgs = RequiredPackages(driver) req_pkgs = Builtins.filter(req_pkgs) do |pkg| !Package.PackageInstalled(pkg) end Builtins.y2milestone( "Required packages to install for driver %1: %2", driver, req_pkgs ) deep_copy(req_pkgs) end |
- (Object) RequiredPackagesToInstallSummary(driver)
634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 |
# File '../../src/modules/Sound.rb', line 634 def RequiredPackagesToInstallSummary(driver) req_pkgs = RequiredPackagesToInstall(driver) pkg_summary = "" if Ops.greater_than(Builtins.size(req_pkgs), 0) # summary string, %1 is a list of packages pkg_summary = Builtins.sformat( _("Required packages to install: %1"), # separator for constructing package list Builtins.mergestring(req_pkgs, _(", ")) ) end pkg_summary end |
- (Object) RestoreSettings
restore settings from backup variables
1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 |
# File '../../src/modules/Sound.rb', line 1096 def RestoreSettings if @modules_conf_b == nil Builtins.y2error( "restoring sound setting without storing them before. bailing out." ) end @modules_conf = deep_copy(@modules_conf_b) @rc_vars = deep_copy(@rc_vars_b) @volume_settings = deep_copy(@volume_settings_b) nil end |
- (void) Set(settings)
This method returns an undefined value.
Just Set module data
768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 |
# File '../../src/modules/Sound.rb', line 768 def Set(settings) settings = deep_copy(settings) @modules_conf = Ops.get_list(settings, "modules_conf", []) @rc_vars = Ops.get_map(settings, "rc_vars", {}) @volume_settings = ImportVolumeSettings( Ops.get_list(settings, "volume_settings", []) ) @configure_detected = Ops.get_boolean( settings, "configure_detected", false ) nil end |
- (Object) SetConfirmPackages(ask)
1369 1370 1371 1372 1373 1374 |
# File '../../src/modules/Sound.rb', line 1369 def SetConfirmPackages(ask) Builtins.y2milestone("Confirm additional package installation: %1", ask) @confirm_packages = ask nil end |
- (Object) SetModified
Function sets internal variable, which indicates, that any settings were modified, to "true"
163 164 165 166 167 |
# File '../../src/modules/Sound.rb', line 163 def SetModified @modified = true nil end |
- (Object) SetVolume(c_id, channel, value)
sets the channel volume to value [0..100]
1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 |
# File '../../src/modules/Sound.rb', line 1209 def SetVolume(c_id, channel, value) # two cases: we have sound system already running: if !Mode.config && Ops.greater_than( Builtins.size(SCR.Dir(path(".audio.alsa.cards"))), c_id ) p = Builtins.sformat( ".audio.alsa.cards.%1.channels.%2.volume", c_id, channel ) p2 = Builtins.sformat( ".audio.alsa.cards.%1.channels.%2.mute", c_id, channel ) SCR.Write(Builtins.topath(p2), false) return SCR.Write(Builtins.topath(p), value) else # alsa is not running. probably autoinstallation or someone wants # to change proposed volume # store volume to volume_settings datastricure in autoinstallation tmp = Ops.get(@volume_settings, c_id, []) found = false updated_channels = [] Builtins.foreach(tmp) do |ch| new_ch = deep_copy(ch) if Ops.get_string(new_ch, 0, "") == channel Ops.set(new_ch, 1, value) found = true end updated_channels = Builtins.add(updated_channels, new_ch) end if found # the channel has been found, use the updates list tmp = deep_copy(updated_channels) else # the channel has not been found, add it to the list tmp = Builtins.add(tmp, [channel, value, false]) end Ops.set(@volume_settings, c_id, tmp) return true end end |
- (Object) Sound
sound module constructor
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File '../../src/modules/Sound.rb', line 181 def Sound @use_alsa = false if Arch.sparc Builtins.y2debug("Args: %1", WFM.Args) Builtins.maplist(WFM.Args) do |e| if Ops.is_string?(e) && e == ".oss" @use_alsa = false Builtins.y2milestone("Using OSS") end end Builtins.y2debug("use ALSA: %1", @use_alsa) nil end |
- (Object) StoreMixer
store mixer settings
1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 |
# File '../../src/modules/Sound.rb', line 1172 def StoreMixer return if Builtins.size(SCR.Dir(path(".audio.alsa.cards"))) == 0 @volume_settings = [] p = nil cards = SCR.Dir(path(".audio.alsa.cards")) Builtins.maplist(cards) do |c| p = Builtins.topath( Builtins.sformat(".audio.alsa.cards.%1.channels", c) ) channels = SCR.Dir(p) Builtins.maplist(channels) do |ch| p = Builtins.topath( Builtins.sformat(".audio.alsa.cards.%1.channels.%2.mute", c, ch) ) if !Convert.to_boolean(SCR.Read(p)) p = Builtins.topath( Builtins.sformat(".audio.alsa.cards.%1.channels.%2.volume", c, ch) ) # add the channel tmp = Ops.get(@volume_settings, Builtins.tointeger(c), []) tmp = Builtins.add(tmp, [ch, SCR.Read(p), "false"]) Ops.set(@volume_settings, Builtins.tointeger(c), tmp) end end end nil end |
- (Object) StoreSettings
copy settings to backup variables
1087 1088 1089 1090 1091 1092 1093 |
# File '../../src/modules/Sound.rb', line 1087 def StoreSettings @modules_conf_b = deep_copy(@modules_conf) @rc_vars_b = deep_copy(@rc_vars) @volume_settings_b = deep_copy(@volume_settings) nil end |
- (Object) StoreUniqueKeys
stores unique keys. this function is not part of sound_write module because it should not be called during autoinstallation
1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 |
# File '../../src/modules/Sound.rb', line 1151 def StoreUniqueKeys UpdateUnconfiguredCards() conf = Builtins.maplist(@modules_conf) do |e| Ops.get_string(e, "unique_key", "") end unconf = Builtins.maplist(@unconfigured_cards) do |e| Ops.get_string(e, "unique_key", "") end SaveUniqueKeys(conf, unconf) nil end |
- (String) Summary
returns html formated configuration summary
862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 |
# File '../../src/modules/Sound.rb', line 862 def Summary keys = Builtins.maplist(@modules_conf) do |card| Ops.get_string(card, "unique_key", "...") end retlist = Builtins.maplist(@modules_conf) do |card| package_summary = RequiredPackagesToInstallSummary( Ops.get_string(card, "module", "") ) if package_summary != "" package_summary = Ops.add("<BR>", package_summary) end Summary.Device( Ops.get_string(card, "model", "Sound card"), Ops.add( # summary text: '(sound card is) Configured as snd-card-1' Builtins.sformat( _("Configured as %1."), Ops.get_string(card, "alias", "snd-card-0") ), package_summary ) ) end if @detected_cards != nil Builtins.foreach(@detected_cards) do |card| if !Builtins.contains(keys, Ops.get_string(card, "unique_key", "...")) retlist = Builtins.add( retlist, Summary.Device(get_card_label(card), Summary.NotConfigured) ) end end else Builtins.y2milestone("detected_cards: nil") end Summary.DevicesList(retlist) end |
- (void) UpdateUnconfiguredCards
This method returns an undefined value.
update list of unconfigured cards (necessary when deleting configured card)
564 565 566 567 568 |
# File '../../src/modules/Sound.rb', line 564 def UpdateUnconfiguredCards @unconfigured_cards = getConfigurableCards(@modules_conf) nil end |
- (Boolean) Write
Update the SCR according to sound settings
852 853 854 855 856 857 858 |
# File '../../src/modules/Sound.rb', line 852 def Write if Mode.test == false settings = Export() WFM.CallFunction("sound_write", [settings]) end true end |