]> git.alsa-project.org Git - alsa.git/commitdiff
hda_analyzer: Fix mixer controls using pcm or card interface id
authorJaroslav Kysela <perex@perex.cz>
Wed, 2 May 2012 15:17:14 +0000 (17:17 +0200)
committerJaroslav Kysela <perex@perex.cz>
Wed, 2 May 2012 15:17:14 +0000 (17:17 +0200)
- 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 <perex@perex.cz>
hda-analyzer/hda_analyzer.py
hda-analyzer/hda_codec.py
hda-analyzer/hda_guilib.py
hda-analyzer/hda_mixer.py
hda-analyzer/hda_proc.py

index bc4285a04fd81d32414b6313e1d8b5fc874b80c7..eafece87cf1ba847bc5a3dbdd1c6bd61014ba878 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 #
-# Copyright (c) 2008-2010 by Jaroslav Kysela <perex@perex.cz>
+# Copyright (c) 2008-2012 by Jaroslav Kysela <perex@perex.cz>
 #
 #   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
index 275b0074234fc2dcf38faebd429b17153bdfafd8..ad9f5356defa358492c9f337c32e161f5a6b79d8 100644 (file)
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 #
-# Copyright (c) 2008-2010 by Jaroslav Kysela <perex@perex.cz>
+# Copyright (c) 2008-2012 by Jaroslav Kysela <perex@perex.cz>
 #
 #   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
 
index ae517a607e7e0e385ddd7f980b9937611bef2ffb..93c85e148dd648b3fbe6f186fcc7fb0f603421b0 100644 (file)
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 #
-# Copyright (c) 2008-2010 by Jaroslav Kysela <perex@perex.cz>
+# Copyright (c) 2008-2012 by Jaroslav Kysela <perex@perex.cz>
 #
 #   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))
index af12d5c5e2fc79796950fa874d1c0824e530ec10..0d729fcafda698de325654863f6e28a8abbd4d6f 100644 (file)
@@ -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
index 3363b0988c3385b4113ec8173dd631b915b5bc3d..a6dd3dca2c36d2eeb3815980f453f497c4837f51 100644 (file)
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 #
-# Copyright (c) 2008-2010 by Jaroslav Kysela <perex@perex.cz>
+# Copyright (c) 2008-2012 by Jaroslav Kysela <perex@perex.cz>
 #
 #   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]