Add FunPlug

Bug: 17748382
Change-Id: I742e472106db81db19174e7e28c7da99de974f7d
diff --git a/src/devices/audio/images/funplug_assembled.jpg b/src/devices/audio/images/funplug_assembled.jpg
new file mode 100644
index 0000000..d1e1be1
--- /dev/null
+++ b/src/devices/audio/images/funplug_assembled.jpg
Binary files differ
diff --git a/src/devices/audio/images/funplug_circuit.png b/src/devices/audio/images/funplug_circuit.png
new file mode 100644
index 0000000..102c1f3
--- /dev/null
+++ b/src/devices/audio/images/funplug_circuit.png
Binary files differ
diff --git a/src/devices/audio/images/round_trip.png b/src/devices/audio/images/round_trip.png
new file mode 100644
index 0000000..663552c
--- /dev/null
+++ b/src/devices/audio/images/round_trip.png
Binary files differ
diff --git a/src/devices/audio_latency_measure.jd b/src/devices/audio_latency_measure.jd
index 7bb6ac5..1c6739b 100644
--- a/src/devices/audio_latency_measure.jd
+++ b/src/devices/audio_latency_measure.jd
@@ -88,27 +88,51 @@
   on the order of one millisecond or less, which is sufficiently low enough
   to ignore.</p>
 
+<h2 id="measuringRoundTrip">Measuring Round-Trip Latency</h2>
+
+<p>
+  Round-trip latency is the sum of output latency and input latency.
+</p>
+
 <h3>Larsen test</h3>
 <p>
   One of the easiest latency tests is an audio feedback
   (Larsen effect) test. This provides a crude measure of combined output
   and input latency by timing an impulse response loop. This test is not very useful
+  for detailed analysis
   by itself because of the nature of the test, but it can be useful for calibrating 
-  other tests</p>
+  other tests, and for establishing an upper bound.</p>
 
 <p>To conduct this test:</p>
 <ol>
   <li>Run an app that captures audio from the microphone and immediately plays the
   captured data back over the speaker.</li>
   <li>Create a sound externally,
-  such as tapping a pencil by the microphone. This noise generates a feedback loop.</li>
+  such as tapping a pencil by the microphone. This noise generates a feedback loop.
+  Alternatively, one can inject an impulse into the loop using software.</li>
   <li>Measure the time between feedback pulses to get the sum of the output latency, input latency, and application overhead.</li>
 </ol>
 
   <p>This method does not break down the
   component times, which is important when the output latency
-  and input latency are independent. So this method is not recommended for measuring output latency, but might be useful
-  to help measure output latency.</p>
+  and input latency are independent. So this method is not recommended for measuring
+  precise output latency or input latency values in isolation, but might be useful
+  for establishing rough estimates.</p>
+
+<h3>FunPlug</h3>
+
+<p>
+  The <a href="funplug.html">FunPlug</a> dongle is handy for
+  measuring round-trip latency over the headset connector.
+  The image below demonstrates the result of injecting an impulse
+  into the loop once, and then allowing the feedback loop to oscillate.
+  The period of the oscillations is the round-trip latency.
+  The specific device, software release, and
+  test conditions are not specified here.  The results shown
+  should not be extrapolated.
+</p>
+
+<img src="audio/images/round_trip.png" alt="round-trip measurement" />
 
 <h2 id="measuringInput">Measuring Input Latency</h2>
 
diff --git a/src/devices/devices_toc.cs b/src/devices/devices_toc.cs
index 8a5353f..22fa3d0 100644
--- a/src/devices/devices_toc.cs
+++ b/src/devices/devices_toc.cs
@@ -44,7 +44,8 @@
             <ul>
               <li><a href="<?cs var:toroot ?>devices/audio_latency_measure.html">Measure</a></li>
               <li><a href="<?cs var:toroot ?>devices/latency_design.html">Design</a></li>
-              <li><a href="<?cs var:toroot ?>devices/testing_circuit.html">Testing Circuit</a></li>
+              <li><a href="<?cs var:toroot ?>devices/testing_circuit.html">Light Testing Circuit</a></li>
+              <li><a href="<?cs var:toroot ?>devices/funplug.html">FunPlug Audio Dongle</a></li>
             </ul>
           </li>
           <li><a href="<?cs var:toroot ?>devices/audio_avoiding_pi.html">Priority Inversion</a></li>
diff --git a/src/devices/funplug.jd b/src/devices/funplug.jd
new file mode 100644
index 0000000..386b4db
--- /dev/null
+++ b/src/devices/funplug.jd
@@ -0,0 +1,53 @@
+page.title=FunPlug Audio Dongle
+@jd:body
+
+<!--
+    Copyright 2014 The Android Open Source Project
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<div id="qv-wrapper">
+  <div id="qv">
+    <h2>In this document</h2>
+    <ol id="auto-toc">
+    </ol>
+  </div>
+</div>
+
+<p>
+The diagram and photo below show an audio loopback
+<a href="http://en.wikipedia.org/wiki/Dongle">dongle</a>
+for the
+<a href="http://en.wikipedia.org/wiki/Phone_connector_(audio)">headset connector</a>
+that we call the "FunPlug".
+The Chrome hardware team designed this circuit and plug for functional testing,
+however it has many other uses too.  The Android audio team uses it to measure
+<a href="audio_latency_measure.html#measuringRoundTrip">round-trip audio latency</a>,
+via the Larsen effect (feedback loop).
+</p>
+
+<h2 id="funplugCircuit">FunPlug circuit</h2>
+
+<img src="audio/images/funplug_circuit.png" alt="FunPlug circuit" />
+
+<p>
+To ensure that the output signal will not overload the microphone input,
+we cut it down by about 20 dB.
+The resistor loads are there to tell the microphone polarity switch that
+it is a US/CTIA pinout plug.
+</p>
+
+<h2 id="funplugAssembled">FunPlug assembled</h2>
+
+<img src="audio/images/funplug_assembled.jpg" alt="FunPlug fully assembled" />
+
diff --git a/src/devices/testing_circuit.jd b/src/devices/testing_circuit.jd
index 7d672f3..604f85e 100644
--- a/src/devices/testing_circuit.jd
+++ b/src/devices/testing_circuit.jd
@@ -1,4 +1,4 @@
-page.title=Testing Circuit
+page.title=Light Testing Circuit
 @jd:body
 
 <!--