Re: [RFC PATCH v1] AudiVal (Audio Validation Suite for Linux)

2012-05-21 Thread Kurt Taylor
On 17 May 2012 00:12, Harsh Prateek Bora  wrote:

>
>
> On 17 May 2012 01:35, Paul Larson  wrote:
>
>> On Wed, May 16, 2012 at 1:43 AM, Harsh Prateek Bora <
>> harsh.b...@linaro.org> wrote:
>>
>>>
>>>
>>> On 16 May 2012 09:38, Paul Larson  wrote:
>>>
 On Tue, May 15, 2012 at 4:24 PM, Tom Gall  wrote:

> HI Paul,
>
> On Tue, May 15, 2012 at 4:14 PM, Paul Larson 
> wrote:
> > Cool, does this replace the existing e2daudiotest I guess?
>
> Please consider it as complementary.
>
> Ah, I see after looking at it a bit more.  This one isn't completely
 automated and requires someone to listen to the sound :)

>>>
>>> Yes, Its the initial phase and therefore will evolve with time as
>>> required. We may want to plug-in e2eaudiotest and others if already
>>> available.
>>> As of now, it frees the user from finding out the card, device info for
>>> each audio playback/recording device on supported hardware and can help in
>>> identify issues where audio is almost ok, but not truly perfect (like
>>> choppy audio). Un-attended tests may treat imperfect audio as bad as no
>>> audio. I hope I am able to convey what I intend to do so.
>>>
>>> Ah, so if e2eaudiotest is plugged into it, it could act as a sort of
>> front-end for running it and making sure that the right audio device is set
>> up for that particular board?  So in this way, it could allow for automated
>> tests, not just interactive ones?
>>
>
The tests in question are really for different audiences. The e2eaudiotest
tool was designed to be in a fully automated environment as a build sniff
test that does not require a human to see if the entire audio stack on a
particular board/build works "good enough" using a default path.

The test script is to provide an interactive umbrella tool for the
developer to exhaustively test the stack before upstreaming. This can
include the former tool, but doesn't need to.


> Yes, we can add more as well !
>
> regards,
> Harsh
>
>
>>
>> Thanks,
>> Paul Larson
>>
>
>


-- 

Kurt Taylor (irc krtaylor)
Linaro Multimedia
Linaro.org * **│ *Open source software for ARM SoCs
Follow *Linaro: *Facebook  |
Twitter|
Blog 
___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


Re: [RFC PATCH v1] AudiVal (Audio Validation Suite for Linux)

2012-05-16 Thread Harsh Prateek Bora
On 17 May 2012 01:35, Paul Larson  wrote:

> On Wed, May 16, 2012 at 1:43 AM, Harsh Prateek Bora  > wrote:
>
>>
>>
>> On 16 May 2012 09:38, Paul Larson  wrote:
>>
>>> On Tue, May 15, 2012 at 4:24 PM, Tom Gall  wrote:
>>>
 HI Paul,

 On Tue, May 15, 2012 at 4:14 PM, Paul Larson 
 wrote:
 > Cool, does this replace the existing e2daudiotest I guess?

 Please consider it as complementary.

 Ah, I see after looking at it a bit more.  This one isn't completely
>>> automated and requires someone to listen to the sound :)
>>>
>>
>> Yes, Its the initial phase and therefore will evolve with time as
>> required. We may want to plug-in e2eaudiotest and others if already
>> available.
>> As of now, it frees the user from finding out the card, device info for
>> each audio playback/recording device on supported hardware and can help in
>> identify issues where audio is almost ok, but not truly perfect (like
>> choppy audio). Un-attended tests may treat imperfect audio as bad as no
>> audio. I hope I am able to convey what I intend to do so.
>>
>> Ah, so if e2eaudiotest is plugged into it, it could act as a sort of
> front-end for running it and making sure that the right audio device is set
> up for that particular board?  So in this way, it could allow for automated
> tests, not just interactive ones?
>

Yes, we can add more as well !

regards,
Harsh


>
> Thanks,
> Paul Larson
>
___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


Re: [RFC PATCH v1] AudiVal (Audio Validation Suite for Linux)

2012-05-16 Thread Paul Larson
On Wed, May 16, 2012 at 1:43 AM, Harsh Prateek Bora
wrote:

>
>
> On 16 May 2012 09:38, Paul Larson  wrote:
>
>> On Tue, May 15, 2012 at 4:24 PM, Tom Gall  wrote:
>>
>>> HI Paul,
>>>
>>> On Tue, May 15, 2012 at 4:14 PM, Paul Larson 
>>> wrote:
>>> > Cool, does this replace the existing e2daudiotest I guess?
>>>
>>> Please consider it as complementary.
>>>
>>> Ah, I see after looking at it a bit more.  This one isn't completely
>> automated and requires someone to listen to the sound :)
>>
>
> Yes, Its the initial phase and therefore will evolve with time as
> required. We may want to plug-in e2eaudiotest and others if already
> available.
> As of now, it frees the user from finding out the card, device info for
> each audio playback/recording device on supported hardware and can help in
> identify issues where audio is almost ok, but not truly perfect (like
> choppy audio). Un-attended tests may treat imperfect audio as bad as no
> audio. I hope I am able to convey what I intend to do so.
>
> Ah, so if e2eaudiotest is plugged into it, it could act as a sort of
front-end for running it and making sure that the right audio device is set
up for that particular board?  So in this way, it could allow for automated
tests, not just interactive ones?

Thanks,
Paul Larson
___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


Re: [RFC PATCH v1] AudiVal (Audio Validation Suite for Linux)

2012-05-15 Thread Harsh Prateek Bora
On 16 May 2012 09:38, Paul Larson  wrote:

> On Tue, May 15, 2012 at 4:24 PM, Tom Gall  wrote:
>
>> HI Paul,
>>
>> On Tue, May 15, 2012 at 4:14 PM, Paul Larson 
>> wrote:
>> > Cool, does this replace the existing e2daudiotest I guess?
>>
>> Please consider it as complementary.
>>
>> Ah, I see after looking at it a bit more.  This one isn't completely
> automated and requires someone to listen to the sound :)
>

Yes, Its the initial phase and therefore will evolve with time as required.
We may want to plug-in e2eaudiotest and others if already available.
As of now, it frees the user from finding out the card, device info for
each audio playback/recording device on supported hardware and can help in
identify issues where audio is almost ok, but not truly perfect (like
choppy audio). Un-attended tests may treat imperfect audio as bad as no
audio. I hope I am able to convey what I intend to do so.

thanks,
Harsh
___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


Re: [RFC PATCH v1] AudiVal (Audio Validation Suite for Linux)

2012-05-15 Thread Harsh Prateek Bora
On 16 May 2012 02:44, Paul Larson  wrote:

> Cool, does this replace the existing e2daudiotest I guess?


This script can serve as a unified interface to various audio tests that we
are developing.
Kurt (adding in CC) has suggested to plug-in e2eaudiotest into this as well.

Also, has it already been shown to work on all of the listed board?
>

It has been tested on Panda, imx6, Origen as of now, and the script works
as expected.
However, the tests obviously fail where audio recording is not supported by
underlying kernel.


>
> On Tue, May 15, 2012 at 9:00 AM, Harsh Prateek Bora  > wrote:
>
>>AudiVal (Audio Validation Suite for Linux)
>>
>> This is an attempt to automate and integrate various audio related tests
>> which
>> can help validate audio on various boards supported by Linaro. Motivation
>> for
>> this project comes from various audio tests listed at:
>> https://wiki.linaro.org/TomGall/LinaroAudioFeatureIndex
>>
>> The git repo for this project can be cloned from:
>> git://git.linaro.org/people/harshbora/audival.git
>>
>> Various files required by this script are available in the git repo.
>>
>> Requesting all to test this script on various boards that you may have
>> access
>> to and share feedback to make it better.
>>
>> TODO: Add tests for Audio over USB, Bluetooth.
>>
>> Signed-off-by: Harsh Prateek Bora 
>>
>> diff --git a/AudiVal.py b/AudiVal.py
>> new file mode 100755
>> index 000..7d56c4e
>> --- /dev/null
>> +++ b/AudiVal.py
>> @@ -0,0 +1,247 @@
>> +#!/usr/bin/env python
>> +#
>> +# Audival : Audio Validation Suite for Linux.
>> +#
>> +# Author: Harsh Prateek Bora
>> +# 
>> +# 
>> +
>> +import os
>> +import sys
>> +import getopt
>> +from subprocess import * # for calling external programs
>> +import commands # deprecated since python 2.6, Python 3.0 uses subprocess
>> +
>> +def usage():
>> +print "="
>> +print "AudiVal: Audio Validation Suite for Linux"
>> +print "="
>> +print "Usage:"
>> +print sys.argv[0], "[--check-info]"
>> +print
>> +print "Supported HW: PandaBoard (ES), BeagleBoard (XM), i.MX53,
>> i.MX6, Origen, Snowball"
>> +sys.exit(1)
>> +
>> +SpeakerJack = {
>> +'GenuineIntel': 'Analog',
>> +'Panda':'Headset',
>> +'Beagle':   'TWL4030',
>> +'i.MX53':   'HiFi',
>> +'i.MX6':'HiFi',
>> +'ORIGEN':   'Pri_Dai',
>> +'Snowball': 'Headset'
>> +}
>> +
>> +MicJack = {
>> +'GenuineIntel': 'Analog',
>> +'Panda':'Headset', # not sure though, arecord doesnt
>> work for me!
>> +'Beagle':   'TWL4030',
>> +'i.MX53':   'HiFi',
>> +'i.MX6':'HiFi',
>> +'ORIGEN':   'Pri_Dai',
>> +'Snowball': 'Headset'
>> +}
>> +
>> +# As and when HDMI out/in device string differs, we'll need 2
>> dictionaries.
>> +HDMI_Audio = {
>> +'GenuineIntel': 'HDMI',
>> +'Panda':'HDMI',
>> +'Beagle':   'HDMI',
>> +'i.MX53':   'HDMI',
>> +'i.MX6':'HDMI', # audio out only supported, audio in not
>> supported.
>> +'ORIGEN':   'HDMI',
>> +'Snowball': 'hdmi'  # odd one, lowercase
>> +}
>> +
>> +Audio_Devices = {
>> +'playback':'aplay-l.log',
>> +'capture': 'arecord-l.log'
>> +}
>> +
>> +def get_device_list(logfile):
>> +fobj = open(logfile)
>> +return fobj
>> +
>> +def get_card_device_info_by_name(devicestr, fobj):
>> +"""Helper routine to get card, device number by interface name"""
>> +optxt = fobj.readlines()
>> +card = ""
>> +device = ""
>> +for line in optxt:
>> +if devicestr in line:
>> +cardtext, colon, text = line.partition(':')
>> +pre, sep, card = cardtext.partition(' ')
>> +devtext, colon, text = text.partition(':')
>> +pre, sep, device = devtext.partition('device ')
>> +break
>> +hwstr = 'plughw:' + card + ',' + device
>> +if card is "" and device is "":
>> +return None
>> +return hwstr
>> +
>> +def speaker_test_audio_jack(board):
>> +fobj = get_device_list(Audio_Devices['playback'])
>> +print "speaker-test over audio jack .."
>> +headset_jack_id = get_card_device_info_by_name(SpeakerJack[board],
>> fobj)
>> +fobj.close()
>> +if headset_jack_id is None:
>> +print "No Audio Jack found !"
>> +return
>> +call("date > speaker-test-jack.log", shell=True)
>> +cmdstr = "speaker-test -D " + headset_jack_id + " -t s -c 2 -l 1 >
>> speaker-test-jack.log 2>&1"
>> +call(cmdstr, shell=True)
>> +print "If you heard beeps from left and right speaker, test passed."
>> +
>> +def aplay_over_jack(board):
>> +fobj = get_device_list(Audio_Devices['playback'])
>> +headset_jack_id = get_card_device_info_by_name(SpeakerJack[board],
>> fobj)
>> +print "Testi

Re: [RFC PATCH v1] AudiVal (Audio Validation Suite for Linux)

2012-05-15 Thread Paul Larson
On Tue, May 15, 2012 at 4:24 PM, Tom Gall  wrote:

> HI Paul,
>
> On Tue, May 15, 2012 at 4:14 PM, Paul Larson 
> wrote:
> > Cool, does this replace the existing e2daudiotest I guess?
>
> Please consider it as complementary.
>
> Ah, I see after looking at it a bit more.  This one isn't completely
automated and requires someone to listen to the sound :)
___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


Re: [RFC PATCH v1] AudiVal (Audio Validation Suite for Linux)

2012-05-15 Thread Tom Gall
HI Paul,

On Tue, May 15, 2012 at 4:14 PM, Paul Larson  wrote:
> Cool, does this replace the existing e2daudiotest I guess?

Please consider it as complementary.

> Also, has it
> already been shown to work on all of the listed board?

Yes but that's not to say there aren't issues here and there for a
variety of reasons!

Regards,
Tom

> On Tue, May 15, 2012 at 9:00 AM, Harsh Prateek Bora 
> wrote:
>>
>>    AudiVal (Audio Validation Suite for Linux)
>>
>> This is an attempt to automate and integrate various audio related tests
>> which
>> can help validate audio on various boards supported by Linaro. Motivation
>> for
>> this project comes from various audio tests listed at:
>> https://wiki.linaro.org/TomGall/LinaroAudioFeatureIndex
>>
>> The git repo for this project can be cloned from:
>> git://git.linaro.org/people/harshbora/audival.git
>>
>> Various files required by this script are available in the git repo.
>>
>> Requesting all to test this script on various boards that you may have
>> access
>> to and share feedback to make it better.
>>
>> TODO: Add tests for Audio over USB, Bluetooth.
>>
>> Signed-off-by: Harsh Prateek Bora 
>>
>> diff --git a/AudiVal.py b/AudiVal.py
>> new file mode 100755
>> index 000..7d56c4e
>> --- /dev/null
>> +++ b/AudiVal.py
>> @@ -0,0 +1,247 @@
>> +#!/usr/bin/env python
>> +#
>> +# Audival : Audio Validation Suite for Linux.
>> +#
>> +# Author: Harsh Prateek Bora
>> +#         
>> +#         
>> +
>> +import os
>> +import sys
>> +import getopt
>> +from subprocess import * # for calling external programs
>> +import commands # deprecated since python 2.6, Python 3.0 uses subprocess
>> +
>> +def usage():
>> +    print "="
>> +    print "AudiVal: Audio Validation Suite for Linux"
>> +    print "="
>> +    print "Usage:"
>> +    print sys.argv[0], "[--check-info]"
>> +    print
>> +    print "Supported HW: PandaBoard (ES), BeagleBoard (XM), i.MX53,
>> i.MX6, Origen, Snowball"
>> +    sys.exit(1)
>> +
>> +SpeakerJack = {
>> +    'GenuineIntel':     'Analog',
>> +    'Panda':            'Headset',
>> +    'Beagle':           'TWL4030',
>> +    'i.MX53':           'HiFi',
>> +    'i.MX6':            'HiFi',
>> +    'ORIGEN':           'Pri_Dai',
>> +    'Snowball':         'Headset'
>> +}
>> +
>> +MicJack = {
>> +    'GenuineIntel':     'Analog',
>> +    'Panda':            'Headset', # not sure though, arecord doesnt work
>> for me!
>> +    'Beagle':           'TWL4030',
>> +    'i.MX53':           'HiFi',
>> +    'i.MX6':            'HiFi',
>> +    'ORIGEN':           'Pri_Dai',
>> +    'Snowball':         'Headset'
>> +}
>> +
>> +# As and when HDMI out/in device string differs, we'll need 2
>> dictionaries.
>> +HDMI_Audio = {
>> +    'GenuineIntel':     'HDMI',
>> +    'Panda':            'HDMI',
>> +    'Beagle':           'HDMI',
>> +    'i.MX53':           'HDMI',
>> +    'i.MX6':            'HDMI', # audio out only supported, audio in not
>> supported.
>> +    'ORIGEN':           'HDMI',
>> +    'Snowball':         'hdmi'  # odd one, lowercase
>> +}
>> +
>> +Audio_Devices = {
>> +    'playback':    'aplay-l.log',
>> +    'capture':     'arecord-l.log'
>> +}
>> +
>> +def get_device_list(logfile):
>> +    fobj = open(logfile)
>> +    return fobj
>> +
>> +def get_card_device_info_by_name(devicestr, fobj):
>> +    """Helper routine to get card, device number by interface name"""
>> +    optxt = fobj.readlines()
>> +    card = ""
>> +    device = ""
>> +    for line in optxt:
>> +        if devicestr in line:
>> +            cardtext, colon, text = line.partition(':')
>> +            pre, sep, card = cardtext.partition(' ')
>> +            devtext, colon, text = text.partition(':')
>> +            pre, sep, device = devtext.partition('device ')
>> +            break
>> +    hwstr = 'plughw:' + card + ',' + device
>> +    if card is "" and device is "":
>> +        return None
>> +    return hwstr
>> +
>> +def speaker_test_audio_jack(board):
>> +    fobj = get_device_list(Audio_Devices['playback'])
>> +    print "speaker-test over audio jack .."
>> +    headset_jack_id = get_card_device_info_by_name(SpeakerJack[board],
>> fobj)
>> +    fobj.close()
>> +    if headset_jack_id is None:
>> +        print "No Audio Jack found !"
>> +        return
>> +    call("date > speaker-test-jack.log", shell=True)
>> +    cmdstr = "speaker-test -D " + headset_jack_id + " -t s -c 2 -l 1 >
>> speaker-test-jack.log 2>&1"
>> +    call(cmdstr, shell=True)
>> +    print "If you heard beeps from left and right speaker, test passed."
>> +
>> +def aplay_over_jack(board):
>> +    fobj = get_device_list(Audio_Devices['playback'])
>> +    headset_jack_id = get_card_device_info_by_name(SpeakerJack[board],
>> fobj)
>> +    print "Testing aplay over audio jack .."
>> +    fobj.close()
>> +    if headset_jack_id is None:
>> +        print "No Audio Jack found !"
>> +        return
>> +    cmdstr = "aplay login.wav -D " + headse

Re: [RFC PATCH v1] AudiVal (Audio Validation Suite for Linux)

2012-05-15 Thread Paul Larson
Cool, does this replace the existing e2daudiotest I guess? Also, has it
already been shown to work on all of the listed board?

On Tue, May 15, 2012 at 9:00 AM, Harsh Prateek Bora
wrote:

>AudiVal (Audio Validation Suite for Linux)
>
> This is an attempt to automate and integrate various audio related tests
> which
> can help validate audio on various boards supported by Linaro. Motivation
> for
> this project comes from various audio tests listed at:
> https://wiki.linaro.org/TomGall/LinaroAudioFeatureIndex
>
> The git repo for this project can be cloned from:
> git://git.linaro.org/people/harshbora/audival.git
>
> Various files required by this script are available in the git repo.
>
> Requesting all to test this script on various boards that you may have
> access
> to and share feedback to make it better.
>
> TODO: Add tests for Audio over USB, Bluetooth.
>
> Signed-off-by: Harsh Prateek Bora 
>
> diff --git a/AudiVal.py b/AudiVal.py
> new file mode 100755
> index 000..7d56c4e
> --- /dev/null
> +++ b/AudiVal.py
> @@ -0,0 +1,247 @@
> +#!/usr/bin/env python
> +#
> +# Audival : Audio Validation Suite for Linux.
> +#
> +# Author: Harsh Prateek Bora
> +# 
> +# 
> +
> +import os
> +import sys
> +import getopt
> +from subprocess import * # for calling external programs
> +import commands # deprecated since python 2.6, Python 3.0 uses subprocess
> +
> +def usage():
> +print "="
> +print "AudiVal: Audio Validation Suite for Linux"
> +print "="
> +print "Usage:"
> +print sys.argv[0], "[--check-info]"
> +print
> +print "Supported HW: PandaBoard (ES), BeagleBoard (XM), i.MX53,
> i.MX6, Origen, Snowball"
> +sys.exit(1)
> +
> +SpeakerJack = {
> +'GenuineIntel': 'Analog',
> +'Panda':'Headset',
> +'Beagle':   'TWL4030',
> +'i.MX53':   'HiFi',
> +'i.MX6':'HiFi',
> +'ORIGEN':   'Pri_Dai',
> +'Snowball': 'Headset'
> +}
> +
> +MicJack = {
> +'GenuineIntel': 'Analog',
> +'Panda':'Headset', # not sure though, arecord doesnt work
> for me!
> +'Beagle':   'TWL4030',
> +'i.MX53':   'HiFi',
> +'i.MX6':'HiFi',
> +'ORIGEN':   'Pri_Dai',
> +'Snowball': 'Headset'
> +}
> +
> +# As and when HDMI out/in device string differs, we'll need 2
> dictionaries.
> +HDMI_Audio = {
> +'GenuineIntel': 'HDMI',
> +'Panda':'HDMI',
> +'Beagle':   'HDMI',
> +'i.MX53':   'HDMI',
> +'i.MX6':'HDMI', # audio out only supported, audio in not
> supported.
> +'ORIGEN':   'HDMI',
> +'Snowball': 'hdmi'  # odd one, lowercase
> +}
> +
> +Audio_Devices = {
> +'playback':'aplay-l.log',
> +'capture': 'arecord-l.log'
> +}
> +
> +def get_device_list(logfile):
> +fobj = open(logfile)
> +return fobj
> +
> +def get_card_device_info_by_name(devicestr, fobj):
> +"""Helper routine to get card, device number by interface name"""
> +optxt = fobj.readlines()
> +card = ""
> +device = ""
> +for line in optxt:
> +if devicestr in line:
> +cardtext, colon, text = line.partition(':')
> +pre, sep, card = cardtext.partition(' ')
> +devtext, colon, text = text.partition(':')
> +pre, sep, device = devtext.partition('device ')
> +break
> +hwstr = 'plughw:' + card + ',' + device
> +if card is "" and device is "":
> +return None
> +return hwstr
> +
> +def speaker_test_audio_jack(board):
> +fobj = get_device_list(Audio_Devices['playback'])
> +print "speaker-test over audio jack .."
> +headset_jack_id = get_card_device_info_by_name(SpeakerJack[board],
> fobj)
> +fobj.close()
> +if headset_jack_id is None:
> +print "No Audio Jack found !"
> +return
> +call("date > speaker-test-jack.log", shell=True)
> +cmdstr = "speaker-test -D " + headset_jack_id + " -t s -c 2 -l 1 >
> speaker-test-jack.log 2>&1"
> +call(cmdstr, shell=True)
> +print "If you heard beeps from left and right speaker, test passed."
> +
> +def aplay_over_jack(board):
> +fobj = get_device_list(Audio_Devices['playback'])
> +headset_jack_id = get_card_device_info_by_name(SpeakerJack[board],
> fobj)
> +print "Testing aplay over audio jack .."
> +fobj.close()
> +if headset_jack_id is None:
> +print "No Audio Jack found !"
> +return
> +cmdstr = "aplay login.wav -D " + headset_jack_id
> +call(cmdstr, shell=True)
> +print "If you heard a stereo sound, test passed."
> +# Check dmesg to see if there is an error or I2C error
> +call("dmesg | tail | grep error", shell=True)
> +print "Note: Error, if any, shall be displayed above."
> +
> +def arecord_and_aplay_over_audio_jack(board):
> +# Record the WAV st

[RFC PATCH v1] AudiVal (Audio Validation Suite for Linux)

2012-05-15 Thread Harsh Prateek Bora
AudiVal (Audio Validation Suite for Linux)

This is an attempt to automate and integrate various audio related tests which
can help validate audio on various boards supported by Linaro. Motivation for
this project comes from various audio tests listed at:
https://wiki.linaro.org/TomGall/LinaroAudioFeatureIndex

The git repo for this project can be cloned from:
git://git.linaro.org/people/harshbora/audival.git

Various files required by this script are available in the git repo.

Requesting all to test this script on various boards that you may have access
to and share feedback to make it better.

TODO: Add tests for Audio over USB, Bluetooth.

Signed-off-by: Harsh Prateek Bora 

diff --git a/AudiVal.py b/AudiVal.py
new file mode 100755
index 000..7d56c4e
--- /dev/null
+++ b/AudiVal.py
@@ -0,0 +1,247 @@
+#!/usr/bin/env python
+#
+# Audival : Audio Validation Suite for Linux.
+#
+# Author: Harsh Prateek Bora 
+# 
+# 
+
+import os
+import sys
+import getopt
+from subprocess import * # for calling external programs
+import commands # deprecated since python 2.6, Python 3.0 uses subprocess
+
+def usage():
+print "="
+print "AudiVal: Audio Validation Suite for Linux"
+print "="
+print "Usage:"
+print sys.argv[0], "[--check-info]"
+print
+print "Supported HW: PandaBoard (ES), BeagleBoard (XM), i.MX53, i.MX6, 
Origen, Snowball"
+sys.exit(1)
+
+SpeakerJack = {
+'GenuineIntel': 'Analog',
+'Panda':'Headset',
+'Beagle':   'TWL4030',
+'i.MX53':   'HiFi',
+'i.MX6':'HiFi',
+'ORIGEN':   'Pri_Dai',
+'Snowball': 'Headset'
+}
+
+MicJack = {
+'GenuineIntel': 'Analog',
+'Panda':'Headset', # not sure though, arecord doesnt work for 
me!
+'Beagle':   'TWL4030',
+'i.MX53':   'HiFi',
+'i.MX6':'HiFi',
+'ORIGEN':   'Pri_Dai',
+'Snowball': 'Headset'
+}
+
+# As and when HDMI out/in device string differs, we'll need 2 dictionaries.
+HDMI_Audio = {
+'GenuineIntel': 'HDMI',
+'Panda':'HDMI',
+'Beagle':   'HDMI',
+'i.MX53':   'HDMI',
+'i.MX6':'HDMI', # audio out only supported, audio in not 
supported.
+'ORIGEN':   'HDMI',
+'Snowball': 'hdmi'  # odd one, lowercase
+}
+
+Audio_Devices = {
+'playback':'aplay-l.log',
+'capture': 'arecord-l.log'
+}
+
+def get_device_list(logfile):
+fobj = open(logfile)
+return fobj
+
+def get_card_device_info_by_name(devicestr, fobj):
+"""Helper routine to get card, device number by interface name"""
+optxt = fobj.readlines()
+card = ""
+device = ""
+for line in optxt:
+if devicestr in line:
+cardtext, colon, text = line.partition(':')
+pre, sep, card = cardtext.partition(' ')
+devtext, colon, text = text.partition(':')
+pre, sep, device = devtext.partition('device ')
+break
+hwstr = 'plughw:' + card + ',' + device
+if card is "" and device is "":
+return None
+return hwstr
+
+def speaker_test_audio_jack(board):
+fobj = get_device_list(Audio_Devices['playback'])
+print "speaker-test over audio jack .."
+headset_jack_id = get_card_device_info_by_name(SpeakerJack[board], fobj)
+fobj.close()
+if headset_jack_id is None:
+print "No Audio Jack found !"
+return
+call("date > speaker-test-jack.log", shell=True)
+cmdstr = "speaker-test -D " + headset_jack_id + " -t s -c 2 -l 1 > 
speaker-test-jack.log 2>&1"
+call(cmdstr, shell=True)
+print "If you heard beeps from left and right speaker, test passed."
+
+def aplay_over_jack(board):
+fobj = get_device_list(Audio_Devices['playback'])
+headset_jack_id = get_card_device_info_by_name(SpeakerJack[board], fobj)
+print "Testing aplay over audio jack .."
+fobj.close()
+if headset_jack_id is None:
+print "No Audio Jack found !"
+return
+cmdstr = "aplay login.wav -D " + headset_jack_id
+call(cmdstr, shell=True)
+print "If you heard a stereo sound, test passed."
+# Check dmesg to see if there is an error or I2C error
+call("dmesg | tail | grep error", shell=True)
+print "Note: Error, if any, shall be displayed above."
+
+def arecord_and_aplay_over_audio_jack(board):
+# Record the WAV stream and play it back.
+fobj = get_device_list(Audio_Devices['capture'])
+mic_jack_id = get_card_device_info_by_name(MicJack[board], fobj)
+if mic_jack_id is None:
+print "No Mic Jack found !"
+return
+cmdstr = "arecord -c 2 -f S16_LE -d 10 -r 44100 aud44k16S.wav -D " + 
mic_jack_id
+print "Testing arecord over audio jack .."
+print "Started recording audio over jack for 10 seconds (replay follows) 
.."
+call(cmdstr, sh