]> git.alsa-project.org Git - alsa.git/commitdiff
hda-analyzer: add run.py, about dialog (revert is not functional yet)
authorJaroslav Kysela <perex@t61.perex-int.cz>
Mon, 1 Dec 2008 10:14:55 +0000 (11:14 +0100)
committerJaroslav Kysela <perex@t61.perex-int.cz>
Mon, 1 Dec 2008 10:14:55 +0000 (11:14 +0100)
hda-analyzer/hda_analyzer.py
hda-analyzer/hda_codec.py
hda-analyzer/run.py [new file with mode: 0755]

index da77a8c3f7f25c27a4f49aa0a1823e35b0c1535f..c117b1dc8dd618e35e1f0c1f3a4603396c7150a5 100755 (executable)
@@ -37,6 +37,11 @@ def read_nodes():
     CODEC_TREE[c.card] = {}
     for i in range(4):
       read_nodes2(c.card, i)
+  cnt = 0
+  for c in l:
+    if len(CODEC_TREE[c.card]) > 0:
+      cnt += 1
+  return cnt    
 
 (
     TITLE_COLUMN,
@@ -62,16 +67,30 @@ class HDAAnalyzer(gtk.Window):
     self.set_title(self.__class__.__name__)
     self.set_border_width(10)
 
+    self.tooltips = gtk.Tooltips()
+
     hbox = gtk.HBox(False, 3)
     self.add(hbox)
     
+    vbox = gtk.VBox(False, 0)
     scrolled_window = gtk.ScrolledWindow()
     scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
     scrolled_window.set_shadow_type(gtk.SHADOW_IN)
     treeview = self.__create_treeview()
     treeview.set_size_request(250, 600)
     scrolled_window.add(treeview)
-    hbox.pack_start(scrolled_window, False, False)
+    vbox.pack_start(scrolled_window)
+    hbox1 = gtk.HBox(False, 0)
+    button = gtk.Button("About")
+    button.connect("clicked", self.__about_clicked)
+    self.tooltips.set_tip(button, "README! Show the purpose of this program.")
+    hbox1.pack_start(button)
+    button = gtk.Button("Revert")
+    button.connect("clicked", self.__revert_clicked)
+    self.tooltips.set_tip(button, "Revert settings for all codecs.")
+    hbox1.pack_start(button)
+    vbox.pack_start(hbox1, False, False)
+    hbox.pack_start(vbox, False, False)
     
     self.notebook = gtk.Notebook()
     hbox.pack_start(self.notebook, expand=True)
@@ -84,6 +103,43 @@ class HDAAnalyzer(gtk.Window):
 
     self.show_all()    
 
+  def __about_clicked(self, button):
+    dialog = gtk.Dialog('About', self,
+                        gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
+                          (gtk.STOCK_OK, gtk.RESPONSE_OK))
+    text_view = gtk.TextView()
+    text_view.set_border_width(4)
+    str =  """\
+HDA Analyzer
+
+This tool allows change the HDA codec setting using direct hardware access
+bypassing driver's mixer layer.
+
+To learn more about HDA (High Definition Audio), see
+http://www.intel.com/standards/hdaudio/ for more details.
+
+Please, if you find how your codec work, send this information to alsa-devel
+mailing list - http://www.alsa-project.org .
+"""
+    buffer = gtk.TextBuffer(None)
+    iter = buffer.get_iter_at_offset(0)
+    buffer.insert(iter, str[:-1])
+    text_view.set_buffer(buffer)
+    text_view.set_editable(False)
+    text_view.set_cursor_visible(False)
+    dialog.vbox.pack_start(text_view, False, False)
+    dialog.show_all()
+    dialog.run()
+    dialog.destroy()
+    
+  def __revert_clicked(self, button):
+    self.__refresh()
+    pass
+
+  def __refresh(self):
+    self.load()
+    self.__dump_visibility(None, None)
+
   def __dump_visibility(self, textview, event):
     codec = self.codec
     node = self.node
@@ -762,9 +818,14 @@ class HDAAnalyzer(gtk.Window):
     w.add_with_viewport(mframe)
 
 def main():
-  read_nodes()
-  HDAAnalyzer()
-  gtk.main()
+  if read_nodes() == 0:
+    print "No HDA codecs were found or insufficient priviledges for "
+    print "/dev/snd/controlC* and /dev/snd/hwdepC*D* device files."
+    print
+    print "Try run this program as root user."
+  else:
+    HDAAnalyzer()
+    gtk.main()
 
 if __name__ == '__main__':
   main()
index 02663e6f336766451bfbc2fc2c02325d31dd4861..01daa8d9a409b60f8ad73e78fc5002dc08d442b2 100644 (file)
@@ -388,7 +388,7 @@ class HDANode:
     self.active_connection = None
     if self.conn_list:
       self.connections = self.codec.get_connections(self.nid)
-      if self.wtype_id != 'AUD_MIX':
+      if not self.wtype_id in ['AUD_MIX', 'POWER']:
         self.active_connection = self.codec.rw(self.nid, VERBS['GET_CONNECT_SEL'], 0)
     if self.in_amp:
       self.amp_caps_in = HDAAmpCaps(self.codec, self.nid, HDA_INPUT)
diff --git a/hda-analyzer/run.py b/hda-analyzer/run.py
new file mode 100755 (executable)
index 0000000..7bb91a1
--- /dev/null
@@ -0,0 +1,36 @@
+#!/usr/bin/env python
+
+URL="http://git.alsa-project.org/?p=alsa.git;a=blob_plain;f=hda-analyzer/"
+FILES=["hda_analyzer.py", "hda_codec.py"]
+
+try:
+  import gobject
+  import gtk
+  import pango
+except:
+  print "Please, install pygtk2 package"
+
+import os
+from urllib import splithost
+from httplib import HTTP
+
+if os.path.exists("/dev/shm"):
+  TMPDIR="/dev/shm"
+else:
+  TMPDIR="/tmp"
+TMPDIR += "/hda-analyzer"
+print "Creating temporary directory: %s" % TMPDIR
+if not os.path.exists(TMPDIR):
+  os.mkdir(TMPDIR)
+for f in FILES:
+  print "Downloading file %s" % f
+  host, selector = splithost(URL[5:])
+  h = HTTP(host)
+  h.putrequest('GET', URL + f)
+  h.endheaders()
+  h.getreply()
+  contents = h.getfile().read(2*1024*1024)
+  h.close()
+  open(TMPDIR + '/' + f, "w+").write(contents)
+print "Downloaded all files, executing %s" % FILES[0]
+os.system("python %s" % TMPDIR + '/' + FILES[0])