From b860033fc16838ecf7f5ba8248c22dce7f213732 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Thu, 28 Jan 2010 13:35:30 +0100 Subject: [PATCH] hda-analyzer: Add possibility to get alsa-info.sh directly from web Signed-off-by: Jaroslav Kysela --- hda-analyzer/hda_analyzer.py | 26 ++++++++++++++++++++++++-- hda-analyzer/hda_proc.py | 13 ++++++++++--- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/hda-analyzer/hda_analyzer.py b/hda-analyzer/hda_analyzer.py index 406cf11..0e4d04d 100755 --- a/hda-analyzer/hda_analyzer.py +++ b/hda-analyzer/hda_analyzer.py @@ -19,9 +19,12 @@ Usage: hda_analyzer [[codec_proc] ...] codec_proc might specify multiple codec files per card: codec_proc_file1+codec_proc_file2 - or codec_proc file might be a dump from alsa-info.sh + or codec_proc might be a dump from alsa-info.sh + or codec_proc might be a hash for codec database at www.alsa-project.org + or codec_proc might be a URL for codec dump or alsa-info.sh dump """ +import os import sys import gobject import gtk @@ -37,6 +40,20 @@ from hda_proc import DecodeProcFile, HDACodecProc CODEC_TREE = {} DIFF_TREE = {} +def gethttpfile(url, size=1024*1024): + from urllib import splithost + from httplib import HTTP + if not url.startswith('http:'): + raise ValueError, "URL %s" % url + host, selector = splithost(url[5:]) + h = HTTP(host) + h.putrequest('GET', url) + h.endheaders() + h.getreply() + res = h.getfile().read(size) + h.close() + return res + def read_nodes2(card, codec): try: c = HDACodec(card, codec) @@ -74,7 +91,12 @@ def read_nodes(proc_files): a = f.split('+') idx = 0 if len(a) == 1: - proc_file = DecodeProcFile(a[0]) + if a[0].startswith('http://'): + proc_file = gethttpfile(a[0]) + elif len(a[0]) == 40 and not os.path.exists(a[0]): + proc_file = gethttpfile('http://www.alsa-project.org/db/?f=' + a[0]) + else: + proc_file = DecodeProcFile(a[0]) if proc_file.find("ALSA Information Script") > 0: a = [] pos = proc_file.find('HDA-Intel Codec information') diff --git a/hda-analyzer/hda_proc.py b/hda-analyzer/hda_proc.py index ab911dd..935cfb4 100644 --- a/hda-analyzer/hda_proc.py +++ b/hda-analyzer/hda_proc.py @@ -300,7 +300,12 @@ class ProcNode(HDABaseProc): def add_connection(self, line, conn): line, count = self.decodeintw(line) - conn = conn.strip() + res = 0 + if conn.startswith(' '): + conn = conn.strip() + res = 1 + else: + conn = '' conns = [] sel = -1 while len(conn): @@ -312,6 +317,7 @@ class ProcNode(HDABaseProc): self.wrongfile('connections %s != %s' % (count, len(conns))) self.connections = conns self.add_verb(VERBS['GET_CONNECT_SEL'], sel) + return res def add_unsolicited(self, line): line, tag = self.decodeintw(line, 'tag=') @@ -526,8 +532,7 @@ class HDACodecProc(HDACodec, HDABaseProc): elif line.startswith(' Amp-Out vals: '): node.add_ampvals(line[17:], HDA_OUTPUT) elif line.startswith(' Connection: '): - node.add_connection(line[13:], lines[idx+1]) - idx += 1 + idx += node.add_connection(line[13:], lines[idx+1]) elif line == ' PCM:': node.add_pcm(lines[idx+1], lines[idx+2], lines[idx+3]) idx += 3 @@ -545,6 +550,8 @@ class HDACodecProc(HDACodec, HDABaseProc): pass elif line.startswith(' Misc = '): pass + elif line.startswith(' Delay: '): + pass elif line.startswith(' Pin-ctls: '): node.add_pinctls(line[12:]) elif line.startswith(' EAPD '): -- 2.47.1