From: Jaroslav Kysela Date: Wed, 2 May 2012 15:17:14 +0000 (+0200) Subject: hda_analyzer: Fix mixer controls using pcm or card interface id X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=71f3a40f3b59293bb09b73a20b375311fcf6e562;p=alsa.git hda_analyzer: Fix mixer controls using pcm or card interface id - driver should be modified to export the interface id via procfs - use different volume thresholds for "silent" paths in graph - fix some pygtk warnings Signed-off-by: Jaroslav Kysela --- diff --git a/hda-analyzer/hda_analyzer.py b/hda-analyzer/hda_analyzer.py index bc4285a..eafece8 100755 --- a/hda-analyzer/hda_analyzer.py +++ b/hda-analyzer/hda_analyzer.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright (c) 2008-2010 by Jaroslav Kysela +# Copyright (c) 2008-2012 by Jaroslav Kysela # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/hda-analyzer/hda_codec.py b/hda-analyzer/hda_codec.py index 275b007..ad9f535 100644 --- a/hda-analyzer/hda_codec.py +++ b/hda-analyzer/hda_codec.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright (c) 2008-2010 by Jaroslav Kysela +# Copyright (c) 2008-2012 by Jaroslav Kysela # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -853,8 +853,18 @@ class HDANode: ctls = self.get_controls() res = [] for ctl in ctls: - id = AlsaMixerElemId(name=ctl.name, index=ctl.index, device=ctl.device) - e = AlsaMixerElem(self.codec.mixer, id) + for iface in (ctl.iface and [ctl.iface] or [None, 'card', 'pcm']): + try: + id = AlsaMixerElemId(iface=iface, name=ctl.name, index=ctl.index, device=ctl.device) + e = AlsaMixerElem(self.codec.mixer, id) + if iface and ctl.iface != iface: + ctl.iface = iface + break + except: + e = None + if not e: + print "Control ID not found:", ctl.dump_extra().strip().lstrip() + continue e.hdactl = ctl res.append(e) return res @@ -905,8 +915,9 @@ class HDANode: res[idx] = vals[idx] if res[0] is None and res[1] is None: return True + limit = self.wtype_id == 'AUD_OUT' and -3200 or -1200 for r in res: - if r >= -1200: + if r >= limit: return True return False diff --git a/hda-analyzer/hda_guilib.py b/hda-analyzer/hda_guilib.py index ae517a6..93c85e1 100644 --- a/hda-analyzer/hda_guilib.py +++ b/hda-analyzer/hda_guilib.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright (c) 2008-2010 by Jaroslav Kysela +# Copyright (c) 2008-2012 by Jaroslav Kysela # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -248,7 +248,7 @@ class NodeGui(gtk.ScrolledWindow): column = gtk.TreeViewColumn("Active", renderer, active=0) treeview.append_column(column) renderer = gtk.CellRendererText() - column = gtk.TreeViewColumn("Source Node", renderer, text=1, editable=False) + column = gtk.TreeViewColumn("Source Node", renderer, text=1, editable=1) treeview.append_column(column) sw.add(treeview) return frame @@ -584,7 +584,8 @@ class NodeGui(gtk.ScrolledWindow): for ctrl in ctrls: hbox1 = gtk.HBox(False, 0) vbox1.pack_start(hbox1, False, False) - s = 'name=' + str(ctrl.name) + ', index=' + str(ctrl.index) + \ + s = (ctrl.iface and ('iface=' + ctrl.iface + ',') or '') + \ + 'name=' + str(ctrl.name) + ', index=' + str(ctrl.index) + \ ', device=' + str(ctrl.device) label = gtk.Label(s) hbox1.pack_start(label, False, False) @@ -674,6 +675,7 @@ class NodeGui(gtk.ScrolledWindow): vbox.pack_start(self.__build_device(dev), False, False) ctrls = node.get_controls() if ctrls: + node.get_mixercontrols() # workaround vbox.pack_start(self.__build_controls(ctrls), False, False) hbox = gtk.HBox(False, 0) hbox.pack_start(self.__build_node_caps(node)) diff --git a/hda-analyzer/hda_mixer.py b/hda-analyzer/hda_mixer.py index af12d5c..0d729fc 100644 --- a/hda-analyzer/hda_mixer.py +++ b/hda-analyzer/hda_mixer.py @@ -46,9 +46,13 @@ CTL_ELEM_RTYPEs = {} for i in CTL_ELEM_TYPEs: CTL_ELEM_RTYPEs[CTL_ELEM_TYPEs[i]] = i +CTL_ELEM_IFACE_CARD = 0 CTL_ELEM_IFACE_MIXER = 2 +CTL_ELEM_IFACE_PCM = 3 CTL_ELEM_IFACEs = { + "card": 0, "mixer": 2, + "pcm": 3 } CTL_ELEM_RIFACEs = {} for i in CTL_ELEM_IFACEs: @@ -92,7 +96,10 @@ class AlsaMixerElemId: name=None, index=0): self.numid = numid - self.iface = iface + if type(iface) == type(''): + self.iface = CTL_ELEM_IFACEs[iface] + else: + self.iface = iface is None and CTL_ELEM_IFACE_MIXER or iface self.device = device self.subdevice = subdevice self.name = name diff --git a/hda-analyzer/hda_proc.py b/hda-analyzer/hda_proc.py index 3363b09..a6dd3dc 100644 --- a/hda-analyzer/hda_proc.py +++ b/hda-analyzer/hda_proc.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright (c) 2008-2010 by Jaroslav Kysela +# Copyright (c) 2008-2012 by Jaroslav Kysela # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -154,14 +154,15 @@ class HDApcmDevice: class HDApcmControl: - def __init__(self, name, index, device): + def __init__(self, iface, name, index, device): + self.iface = iface self.name = name self.index = index self.device = device self.amp_chs = None def dump_extra(self): - str = ' Control: name="%s", index=%s, device=%s\n' % (self.name, self.index, self.device) + str = ' Control: %sname="%s", index=%s, device=%s\n' % (self.iface and ("iface=\"%s\", " % self.iface) or "", self.name, self.index, self.device) if not self.amp_chs is None: str += ' ControlAmp: chs=%s, dir=%s, idx=%s, ofs=%s\n' % (self.amp_chs, self.amp_dir, self.amp_idx, self.amp_ofs) return str @@ -312,10 +313,13 @@ class ProcNode(HDABaseProc): self.add_param(PARAMS['STREAM'], tmp1) def add_control(self, line): + iface = None + if line.find('iface=') > 0: + line, iface = self.decodestrw(line, 'iface=') line, name = self.decodestrw(line, 'name=') line, index = self.decodeintw(line, 'index=') line, device = self.decodeintw(line, 'device=') - self.controls.append(HDApcmControl(name, index, device)) + self.controls.append(HDApcmControl(iface, name, index, device)) def add_controlamp(self, line): ctl = self.controls[-1]