Merge "Progress status notification" into gingerbread
diff --git a/api/9.xml b/api/9.xml
index b7596bd..076bed7 100644
--- a/api/9.xml
+++ b/api/9.xml
@@ -167794,6 +167794,38 @@
</parameter>
</constructor>
</class>
+<class name="InputEvent"
+ extends="java.lang.Object"
+ abstract="true"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<implements name="android.os.Parcelable">
+</implements>
+<method name="getDeviceId"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<field name="mDeviceId"
+ type="int"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="protected"
+>
+</field>
+</class>
<class name="KeyCharacterMap"
extends="java.lang.Object"
abstract="false"
@@ -168130,7 +168162,7 @@
</field>
</class>
<class name="KeyEvent"
- extends="java.lang.Object"
+ extends="android.view.InputEvent"
abstract="false"
static="false"
final="false"
@@ -168423,17 +168455,6 @@
<parameter name="c" type="int">
</parameter>
</method>
-<method name="getDeviceId"
- return="int"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</method>
<method name="getDisplayLabel"
return="char"
abstract="false"
@@ -171308,7 +171329,7 @@
</method>
</interface>
<class name="MotionEvent"
- extends="java.lang.Object"
+ extends="android.view.InputEvent"
abstract="false"
static="false"
final="true"
@@ -171397,17 +171418,6 @@
visibility="public"
>
</method>
-<method name="getDeviceId"
- return="int"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</method>
<method name="getDownTime"
return="long"
abstract="false"
diff --git a/api/current.xml b/api/current.xml
index f448b85..5cbdc0e 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -38302,6 +38302,17 @@
visibility="public"
>
</field>
+<field name="STORAGE_SERVICE"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value=""storage""
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
<field name="TELEPHONY_SERVICE"
type="java.lang.String"
transient="false"
@@ -125618,6 +125629,74 @@
</method>
</class>
</package>
+<package name="android.os.storage"
+>
+<class name="StorageManager"
+ extends="java.lang.Object"
+ abstract="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<method name="getMountedObbPath"
+ return="java.lang.String"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="filename" type="java.lang.String">
+</parameter>
+</method>
+<method name="isObbMounted"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="filename" type="java.lang.String">
+</parameter>
+</method>
+<method name="mountObb"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="filename" type="java.lang.String">
+</parameter>
+<parameter name="key" type="java.lang.String">
+</parameter>
+</method>
+<method name="unmountObb"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="filename" type="java.lang.String">
+</parameter>
+<parameter name="force" type="boolean">
+</parameter>
+</method>
+</class>
+</package>
<package name="android.preference"
>
<class name="CheckBoxPreference"
@@ -133966,6 +134045,17 @@
deprecated="not deprecated"
visibility="protected"
>
+<field name="CONTACT_CHAT_CAPABILITY"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value=""contact_chat_capability""
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
<field name="CONTACT_PRESENCE"
type="java.lang.String"
transient="false"
@@ -135943,6 +136033,50 @@
visibility="public"
>
</field>
+<field name="CAPABILITY_HAS_CAMERA"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="4"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="CAPABILITY_HAS_VIDEO_PLAYBACK_ONLY"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="1"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="CAPABILITY_HAS_VOICE"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="2"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="CHAT_CAPABILITY"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value=""chat_capability""
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
<field name="DO_NOT_DISTURB"
type="int"
transient="false"
@@ -173010,6 +173144,506 @@
</parameter>
</constructor>
</class>
+<class name="InputDevice"
+ extends="java.lang.Object"
+ abstract="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<constructor name="InputDevice"
+ type="android.view.InputDevice"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</constructor>
+<method name="getDevice"
+ return="android.view.InputDevice"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="id" type="int">
+</parameter>
+</method>
+<method name="getKeyCharacterMap"
+ return="android.view.KeyCharacterMap"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getMotionRange"
+ return="android.view.InputDevice.MotionRange"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="range" type="int">
+</parameter>
+</method>
+<method name="getName"
+ return="java.lang.String"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getSources"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="hasKey"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="keyCode" type="int">
+</parameter>
+</method>
+<field name="MOTION_RANGE_ORIENTATION"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="8"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="MOTION_RANGE_PRESSURE"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="2"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="MOTION_RANGE_SIZE"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="3"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="MOTION_RANGE_TOOL_MAJOR"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="6"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="MOTION_RANGE_TOOL_MINOR"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="7"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="MOTION_RANGE_TOUCH_MAJOR"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="4"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="MOTION_RANGE_TOUCH_MINOR"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="5"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="MOTION_RANGE_X"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="0"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="MOTION_RANGE_Y"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="1"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="SOURCE_CLASS_BUTTON"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="1"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="SOURCE_CLASS_JOYSTICK"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="SOURCE_CLASS_MASK"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="255"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="SOURCE_CLASS_POINTER"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="2"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="SOURCE_CLASS_POSITION"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="8"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="SOURCE_CLASS_TRACKBALL"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="4"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="SOURCE_DPAD"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="513"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="SOURCE_GAMEPAD"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="1025"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="SOURCE_JOYSTICK_LEFT"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16777232"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="SOURCE_JOYSTICK_RIGHT"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="33554448"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="SOURCE_KEYBOARD"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="257"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="SOURCE_MOUSE"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="8194"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="SOURCE_TOUCHPAD"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="1048584"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="SOURCE_TOUCHSCREEN"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="4098"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="SOURCE_TRACKBALL"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="65540"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="SOURCE_UNKNOWN"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="0"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+</class>
+<class name="InputDevice.MotionRange"
+ extends="java.lang.Object"
+ abstract="false"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<constructor name="InputDevice.MotionRange"
+ type="android.view.InputDevice.MotionRange"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</constructor>
+<method name="getFlat"
+ return="float"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getFuzz"
+ return="float"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getMax"
+ return="float"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getMin"
+ return="float"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getRange"
+ return="float"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+</class>
+<class name="InputEvent"
+ extends="java.lang.Object"
+ abstract="true"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<implements name="android.os.Parcelable">
+</implements>
+<method name="getDevice"
+ return="android.view.InputDevice"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getDeviceId"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getSource"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<field name="mDeviceId"
+ type="int"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="protected"
+>
+</field>
+<field name="mSource"
+ type="int"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="protected"
+>
+</field>
+</class>
<class name="InputQueue"
extends="java.lang.Object"
abstract="false"
@@ -173389,7 +174023,7 @@
</field>
</class>
<class name="KeyEvent"
- extends="java.lang.Object"
+ extends="android.view.InputEvent"
abstract="false"
static="false"
final="false"
@@ -173467,7 +174101,7 @@
</parameter>
<parameter name="metaState" type="int">
</parameter>
-<parameter name="device" type="int">
+<parameter name="deviceId" type="int">
</parameter>
<parameter name="scancode" type="int">
</parameter>
@@ -173491,7 +174125,7 @@
</parameter>
<parameter name="metaState" type="int">
</parameter>
-<parameter name="device" type="int">
+<parameter name="deviceId" type="int">
</parameter>
<parameter name="scancode" type="int">
</parameter>
@@ -173505,11 +174139,39 @@
deprecated="not deprecated"
visibility="public"
>
+<parameter name="downTime" type="long">
+</parameter>
+<parameter name="eventTime" type="long">
+</parameter>
+<parameter name="action" type="int">
+</parameter>
+<parameter name="code" type="int">
+</parameter>
+<parameter name="repeat" type="int">
+</parameter>
+<parameter name="metaState" type="int">
+</parameter>
+<parameter name="deviceId" type="int">
+</parameter>
+<parameter name="scancode" type="int">
+</parameter>
+<parameter name="flags" type="int">
+</parameter>
+<parameter name="source" type="int">
+</parameter>
+</constructor>
+<constructor name="KeyEvent"
+ type="android.view.KeyEvent"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
<parameter name="time" type="long">
</parameter>
<parameter name="characters" type="java.lang.String">
</parameter>
-<parameter name="device" type="int">
+<parameter name="deviceId" type="int">
</parameter>
<parameter name="flags" type="int">
</parameter>
@@ -173682,17 +174344,6 @@
<parameter name="c" type="int">
</parameter>
</method>
-<method name="getDeviceId"
- return="int"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</method>
<method name="getDisplayLabel"
return="char"
abstract="false"
@@ -176776,7 +177427,7 @@
</method>
</interface>
<class name="MotionEvent"
- extends="java.lang.Object"
+ extends="android.view.InputEvent"
abstract="false"
static="false"
final="true"
@@ -176808,6 +177459,23 @@
<parameter name="metaState" type="int">
</parameter>
</method>
+<method name="addBatch"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="eventTime" type="long">
+</parameter>
+<parameter name="pointerCoords" type="android.view.MotionEvent.PointerCoords[]">
+</parameter>
+<parameter name="metaState" type="int">
+</parameter>
+</method>
<method name="describeContents"
return="int"
abstract="false"
@@ -176865,17 +177533,6 @@
visibility="public"
>
</method>
-<method name="getDeviceId"
- return="int"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</method>
<method name="getDownTime"
return="long"
abstract="false"
@@ -176922,6 +177579,51 @@
<parameter name="pos" type="int">
</parameter>
</method>
+<method name="getHistoricalOrientation"
+ return="float"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="pos" type="int">
+</parameter>
+</method>
+<method name="getHistoricalOrientation"
+ return="float"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="pointerIndex" type="int">
+</parameter>
+<parameter name="pos" type="int">
+</parameter>
+</method>
+<method name="getHistoricalPointerCoords"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="pointerIndex" type="int">
+</parameter>
+<parameter name="pos" type="int">
+</parameter>
+<parameter name="outPointerCoords" type="android.view.MotionEvent.PointerCoords">
+</parameter>
+</method>
<method name="getHistoricalPressure"
return="float"
abstract="false"
@@ -176978,6 +177680,118 @@
<parameter name="pos" type="int">
</parameter>
</method>
+<method name="getHistoricalToolMajor"
+ return="float"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="pos" type="int">
+</parameter>
+</method>
+<method name="getHistoricalToolMajor"
+ return="float"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="pointerIndex" type="int">
+</parameter>
+<parameter name="pos" type="int">
+</parameter>
+</method>
+<method name="getHistoricalToolMinor"
+ return="float"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="pos" type="int">
+</parameter>
+</method>
+<method name="getHistoricalToolMinor"
+ return="float"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="pointerIndex" type="int">
+</parameter>
+<parameter name="pos" type="int">
+</parameter>
+</method>
+<method name="getHistoricalTouchMajor"
+ return="float"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="pos" type="int">
+</parameter>
+</method>
+<method name="getHistoricalTouchMajor"
+ return="float"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="pointerIndex" type="int">
+</parameter>
+<parameter name="pos" type="int">
+</parameter>
+</method>
+<method name="getHistoricalTouchMinor"
+ return="float"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="pos" type="int">
+</parameter>
+</method>
+<method name="getHistoricalTouchMinor"
+ return="float"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="pointerIndex" type="int">
+</parameter>
+<parameter name="pos" type="int">
+</parameter>
+</method>
<method name="getHistoricalX"
return="float"
abstract="false"
@@ -177056,6 +177870,45 @@
visibility="public"
>
</method>
+<method name="getOrientation"
+ return="float"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getOrientation"
+ return="float"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="pointerIndex" type="int">
+</parameter>
+</method>
+<method name="getPointerCoords"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="pointerIndex" type="int">
+</parameter>
+<parameter name="outPointerCoords" type="android.view.MotionEvent.PointerCoords">
+</parameter>
+</method>
<method name="getPointerCount"
return="int"
abstract="false"
@@ -177150,6 +178003,102 @@
<parameter name="pointerIndex" type="int">
</parameter>
</method>
+<method name="getToolMajor"
+ return="float"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getToolMajor"
+ return="float"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="pointerIndex" type="int">
+</parameter>
+</method>
+<method name="getToolMinor"
+ return="float"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getToolMinor"
+ return="float"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="pointerIndex" type="int">
+</parameter>
+</method>
+<method name="getTouchMajor"
+ return="float"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getTouchMajor"
+ return="float"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="pointerIndex" type="int">
+</parameter>
+</method>
+<method name="getTouchMinor"
+ return="float"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getTouchMinor"
+ return="float"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="pointerIndex" type="int">
+</parameter>
+</method>
<method name="getX"
return="float"
abstract="false"
@@ -177236,6 +178185,41 @@
</parameter>
<parameter name="action" type="int">
</parameter>
+<parameter name="pointers" type="int">
+</parameter>
+<parameter name="pointerIds" type="int[]">
+</parameter>
+<parameter name="pointerCoords" type="android.view.MotionEvent.PointerCoords[]">
+</parameter>
+<parameter name="metaState" type="int">
+</parameter>
+<parameter name="xPrecision" type="float">
+</parameter>
+<parameter name="yPrecision" type="float">
+</parameter>
+<parameter name="deviceId" type="int">
+</parameter>
+<parameter name="edgeFlags" type="int">
+</parameter>
+<parameter name="source" type="int">
+</parameter>
+</method>
+<method name="obtain"
+ return="android.view.MotionEvent"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="downTime" type="long">
+</parameter>
+<parameter name="eventTime" type="long">
+</parameter>
+<parameter name="action" type="int">
+</parameter>
<parameter name="x" type="float">
</parameter>
<parameter name="y" type="float">
@@ -177676,6 +178660,113 @@
>
</field>
</class>
+<class name="MotionEvent.PointerCoords"
+ extends="java.lang.Object"
+ abstract="false"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<constructor name="MotionEvent.PointerCoords"
+ type="android.view.MotionEvent.PointerCoords"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</constructor>
+<field name="orientation"
+ type="float"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="pressure"
+ type="float"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="size"
+ type="float"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="toolMajor"
+ type="float"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="toolMinor"
+ type="float"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="touchMajor"
+ type="float"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="touchMinor"
+ type="float"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="x"
+ type="float"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="y"
+ type="float"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+</class>
<class name="OrientationEventListener"
extends="java.lang.Object"
abstract="true"
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index 0fb2b49..c88e086 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -3102,7 +3102,9 @@
* For system applications on userdebug/eng builds, log stack
* traces of disk and network access to dropbox for analysis.
*/
- if ((data.appInfo.flags&ApplicationInfo.FLAG_SYSTEM) != 0 &&
+ if ((data.appInfo.flags &
+ (ApplicationInfo.FLAG_SYSTEM |
+ ApplicationInfo.FLAG_UPDATED_SYSTEM_APP)) != 0 &&
!"user".equals(Build.TYPE)) {
StrictMode.setThreadBlockingPolicy(
StrictMode.DISALLOW_DISK_WRITE |
diff --git a/core/java/android/app/ApplicationErrorReport.java b/core/java/android/app/ApplicationErrorReport.java
index 9834c4c..6981cd6 100644
--- a/core/java/android/app/ApplicationErrorReport.java
+++ b/core/java/android/app/ApplicationErrorReport.java
@@ -27,6 +27,7 @@
import android.os.SystemProperties;
import android.provider.Settings;
import android.util.Printer;
+
import java.io.PrintWriter;
import java.io.StringWriter;
diff --git a/core/java/android/app/NativeActivity.java b/core/java/android/app/NativeActivity.java
index ccc9ae3..eaf0675 100644
--- a/core/java/android/app/NativeActivity.java
+++ b/core/java/android/app/NativeActivity.java
@@ -1,11 +1,15 @@
package android.app;
+import com.android.internal.view.IInputMethodCallback;
+import com.android.internal.view.IInputMethodSession;
+
import dalvik.system.PathClassLoader;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
+import android.content.res.AssetManager;
import android.graphics.PixelFormat;
import android.os.Build;
import android.os.Bundle;
@@ -24,6 +28,7 @@
import android.view.inputmethod.InputMethodManager;
import java.io.File;
+import java.lang.ref.WeakReference;
/**
* Convenience for implementing an activity that will be implemented
@@ -35,6 +40,7 @@
private NativeContentView mNativeContentView;
private InputMethodManager mIMM;
+ private InputMethodCallback mInputMethodCallback;
private int mNativeHandle;
@@ -52,7 +58,8 @@
private boolean mDestroyed;
private native int loadNativeCode(String path, MessageQueue queue,
- String internalDataPath, String externalDataPath, int sdkVersion);
+ String internalDataPath, String externalDataPath, int sdkVersion,
+ AssetManager assetMgr);
private native void unloadNativeCode(int handle);
private native void onStartNative(int handle);
@@ -71,6 +78,7 @@
private native void onInputChannelDestroyedNative(int handle, InputChannel channel);
private native void onContentRectChangedNative(int handle, int x, int y, int w, int h);
private native void dispatchKeyEventNative(int handle, KeyEvent event);
+ private native void finishPreDispatchKeyEventNative(int handle, int seq, boolean handled);
static class NativeContentView extends View {
NativeActivity mActivity;
@@ -84,12 +92,34 @@
}
}
+ static class InputMethodCallback extends IInputMethodCallback.Stub {
+ WeakReference<NativeActivity> mNa;
+
+ InputMethodCallback(NativeActivity na) {
+ mNa = new WeakReference<NativeActivity>(na);
+ }
+
+ @Override
+ public void finishedEvent(int seq, boolean handled) {
+ NativeActivity na = mNa.get();
+ if (na != null) {
+ na.finishPreDispatchKeyEventNative(na.mNativeHandle, seq, handled);
+ }
+ }
+
+ @Override
+ public void sessionCreated(IInputMethodSession session) {
+ // Stub -- not for use in the client.
+ }
+ }
+
@Override
protected void onCreate(Bundle savedInstanceState) {
String libname = "main";
ActivityInfo ai;
mIMM = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
+ mInputMethodCallback = new InputMethodCallback(this);
getWindow().takeSurface(this);
getWindow().takeInputQueue(this);
@@ -138,7 +168,7 @@
mNativeHandle = loadNativeCode(path, Looper.myQueue(),
getFilesDir().toString(),
Environment.getExternalStorageAppFilesDirectory(ai.packageName).toString(),
- Build.VERSION.SDK_INT);
+ Build.VERSION.SDK_INT, getAssets());
if (mNativeHandle == 0) {
throw new IllegalArgumentException("Unable to load native library: " + path);
@@ -290,6 +320,11 @@
}
}
+ void preDispatchKeyEvent(KeyEvent event, int seq) {
+ mIMM.dispatchKeyEvent(this, seq, event,
+ mInputMethodCallback);
+ }
+
void setWindowFlags(int flags, int mask) {
getWindow().setFlags(flags, mask);
}
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java
index a14bd8f..e3b7731 100644
--- a/core/java/android/content/Context.java
+++ b/core/java/android/content/Context.java
@@ -1372,9 +1372,8 @@
public static final String SENSOR_SERVICE = "sensor";
/**
- * @hide
* Use with {@link #getSystemService} to retrieve a {@link
- * android.os.storage.StorageManager} for accesssing system storage
+ * android.os.storage.StorageManager} for accessing system storage
* functions.
*
* @see #getSystemService
diff --git a/core/java/android/content/res/AssetManager.java b/core/java/android/content/res/AssetManager.java
index 1070f08..73d9458 100644
--- a/core/java/android/content/res/AssetManager.java
+++ b/core/java/android/content/res/AssetManager.java
@@ -70,6 +70,7 @@
// For communication with native code.
private int mObject;
+ private int mNObject; // used by the NDK
private StringBlock mStringBlocks[] = null;
diff --git a/core/java/android/content/res/ObbInfo.aidl b/core/java/android/content/res/ObbInfo.aidl
new file mode 100755
index 0000000..636ad6a
--- /dev/null
+++ b/core/java/android/content/res/ObbInfo.aidl
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+package android.content.res;
+
+parcelable ObbInfo;
diff --git a/core/java/android/content/res/ObbInfo.java b/core/java/android/content/res/ObbInfo.java
new file mode 100644
index 0000000..b18d784
--- /dev/null
+++ b/core/java/android/content/res/ObbInfo.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+package android.content.res;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+/**
+ * Basic information about a Opaque Binary Blob (OBB) that reflects
+ * the info from the footer on the OBB file.
+ * @hide
+ */
+public class ObbInfo implements Parcelable {
+ /**
+ * The name of the package to which the OBB file belongs.
+ */
+ public String packageName;
+
+ /**
+ * The version of the package to which the OBB file belongs.
+ */
+ public int version;
+
+ public ObbInfo() {
+ }
+
+ public String toString() {
+ return "ObbInfo{"
+ + Integer.toHexString(System.identityHashCode(this))
+ + " packageName=" + packageName + ",version=" + version + "}";
+ }
+
+ public int describeContents() {
+ return 0;
+ }
+
+ public void writeToParcel(Parcel dest, int parcelableFlags) {
+ dest.writeString(packageName);
+ dest.writeInt(version);
+ }
+
+ public static final Parcelable.Creator<ObbInfo> CREATOR
+ = new Parcelable.Creator<ObbInfo>() {
+ public ObbInfo createFromParcel(Parcel source) {
+ return new ObbInfo(source);
+ }
+
+ public ObbInfo[] newArray(int size) {
+ return new ObbInfo[size];
+ }
+ };
+
+ private ObbInfo(Parcel source) {
+ packageName = source.readString();
+ version = source.readInt();
+ }
+}
diff --git a/core/java/android/content/res/ObbScanner.java b/core/java/android/content/res/ObbScanner.java
new file mode 100644
index 0000000..eb383c3
--- /dev/null
+++ b/core/java/android/content/res/ObbScanner.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+package android.content.res;
+
+/**
+ * Class to scan Opaque Binary Blob (OBB) files.
+ * @hide
+ */
+public class ObbScanner {
+ // Don't allow others to instantiate this class
+ private ObbScanner() {}
+
+ public static ObbInfo getObbInfo(String filePath) {
+ if (filePath == null) {
+ return null;
+ }
+
+ ObbInfo obbInfo = new ObbInfo();
+ if (!getObbInfo_native(filePath, obbInfo)) {
+ throw new IllegalArgumentException("Could not read OBB file: " + filePath);
+ }
+ return obbInfo;
+ }
+
+ private native static boolean getObbInfo_native(String filePath, ObbInfo obbInfo);
+}
diff --git a/core/java/android/database/DatabaseUtils.java b/core/java/android/database/DatabaseUtils.java
index 9bfbb74..66406ca 100644
--- a/core/java/android/database/DatabaseUtils.java
+++ b/core/java/android/database/DatabaseUtils.java
@@ -108,7 +108,7 @@
* @see Parcel#readException
*/
public static final void readExceptionFromParcel(Parcel reply) {
- int code = reply.readInt();
+ int code = reply.readExceptionCode();
if (code == 0) return;
String msg = reply.readString();
DatabaseUtils.readExceptionFromParcel(reply, msg, code);
@@ -116,7 +116,7 @@
public static void readExceptionWithFileNotFoundExceptionFromParcel(
Parcel reply) throws FileNotFoundException {
- int code = reply.readInt();
+ int code = reply.readExceptionCode();
if (code == 0) return;
String msg = reply.readString();
if (code == 1) {
@@ -128,7 +128,7 @@
public static void readExceptionWithOperationApplicationExceptionFromParcel(
Parcel reply) throws OperationApplicationException {
- int code = reply.readInt();
+ int code = reply.readExceptionCode();
if (code == 0) return;
String msg = reply.readString();
if (code == 10) {
diff --git a/core/java/android/hardware/Camera.java b/core/java/android/hardware/Camera.java
index 1100886..19e578f 100644
--- a/core/java/android/hardware/Camera.java
+++ b/core/java/android/hardware/Camera.java
@@ -32,23 +32,79 @@
import android.os.Message;
/**
- * The Camera class is used to connect/disconnect with the camera service,
- * set capture settings, start/stop preview, snap a picture, and retrieve
- * frames for encoding for video.
- * <p>There is no default constructor for this class. Use {@link #open()} to
- * get a Camera object.</p>
+ * The Camera class is used to set image capture settings, start/stop preview,
+ * snap pictures, and retrieve frames for encoding for video. This class is a
+ * client for the Camera service, which manages the actual camera hardware.
*
- * <p>In order to use the device camera, you must declare the
+ * <p>To access the device camera, you must declare the
* {@link android.Manifest.permission#CAMERA} permission in your Android
* Manifest. Also be sure to include the
* <a href="{@docRoot}guide/topics/manifest/uses-feature-element.html"><uses-feature></a>
- * manifest element in order to declare camera features used by your application.
+ * manifest element to declare camera features used by your application.
* For example, if you use the camera and auto-focus feature, your Manifest
* should include the following:</p>
* <pre> <uses-permission android:name="android.permission.CAMERA" />
* <uses-feature android:name="android.hardware.camera" />
* <uses-feature android:name="android.hardware.camera.autofocus" /></pre>
*
+ * <p>To take pictures with this class, use the following steps:</p>
+ *
+ * <ol>
+ * <li>Obtain an instance of Camera from {@link #open(int)}.
+ *
+ * <li>Get existing (default) settings with {@link #getParameters()}.
+ *
+ * <li>If necessary, modify the returned {@link Camera.Parameters} object and call
+ * {@link #setParameters(Camera.Parameters)}.
+ *
+ * <li>If desired, call {@link #setDisplayOrientation(int)}.
+ *
+ * <li><b>Important</b>: Pass a fully initialized {@link SurfaceHolder} to
+ * {@link #setPreviewDisplay(SurfaceHolder)}. Without a surface, the camera
+ * will be unable to start the preview.
+ *
+ * <li><b>Important</b>: Call {@link #startPreview()} to start updating the
+ * preview surface. Preview must be started before you can take a picture.
+ *
+ * <li>When you want, call {@link #takePicture(Camera.ShutterCallback,
+ * Camera.PictureCallback, Camera.PictureCallback, Camera.PictureCallback)} to
+ * capture a photo. Wait for the callbacks to provide the actual image data.
+ *
+ * <li>After taking a picture, preview display will have stopped. To take more
+ * photos, call {@link #startPreview()} again first.
+ *
+ * <li>Call {@link #stopPreview()} to stop updating the preview surface.
+ *
+ * <li><b>Important:</b> Call {@link #release()} to release the camera for
+ * use by other applications. Applications should release the camera
+ * immediately in {@link android.app.Activity#onPause()} (and re-{@link #open()}
+ * it in {@link android.app.Activity#onResume()}).
+ * </ol>
+ *
+ * <p>To quickly switch to video recording mode, use these steps:</p>
+ *
+ * <ol>
+ * <li>Obtain and initialize a Camera and start preview as described above.
+ *
+ * <li>Call {@link #unlock()} to allow the media process to access the camera.
+ *
+ * <li>Pass the camera to {@link android.media.MediaRecorder#setCamera(Camera)}.
+ * See {@link android.media.MediaRecorder} information about video recording.
+ *
+ * <li>When finished recording, call {@link #reconnect()} to re-acquire
+ * and re-lock the camera.
+ *
+ * <li>If desired, restart preview and take more photos or videos.
+ *
+ * <li>Call {@link #stopPreview()} and {@link #release()} as described above.
+ * </ol>
+ *
+ * <p>This class is not thread-safe, and is meant for use from one event thread.
+ * Most long-running operations (preview, focus, photo capture, etc) happen
+ * asynchronously and invoke callbacks as necessary. Callbacks will be invoked
+ * on the event thread {@link #open(int)} was called from. This class's methods
+ * must never be called from multiple threads at once.</p>
+ *
* <p class="caution"><strong>Caution:</strong> Different Android-powered devices
* may have different hardware specifications, such as megapixel ratings and
* auto-focus capabilities. In order for your application to be compatible with
@@ -84,12 +140,12 @@
private boolean mWithBuffer;
/**
- * Returns the number of Cameras available.
+ * Returns the number of physical cameras available on this device.
*/
public native static int getNumberOfCameras();
/**
- * Returns the information about the camera.
+ * Returns the information about a particular camera.
* If {@link #getNumberOfCameras()} returns N, the valid id is 0 to N-1.
*/
public native static void getCameraInfo(int cameraId, CameraInfo cameraInfo);
@@ -123,9 +179,30 @@
};
/**
- * Returns a new Camera object.
- * If {@link #getNumberOfCameras()} returns N, the valid id is 0 to N-1.
- * The id 0 is the default camera.
+ * Creates a new Camera object to access a particular hardware camera.
+ *
+ * <p>You must call {@link #release()} when you are done using the camera,
+ * otherwise it will remain locked and be unavailable to other applications.
+ *
+ * <p>Your application should only have one Camera object active at a time
+ * for a particular hardware camera.
+ *
+ * <p>Callbacks from other methods are delivered to the event loop of the
+ * thread which called open(). If this thread has no event loop, then
+ * callbacks are delivered to the main application event loop. If there
+ * is no main application event loop, callbacks are not delivered.
+ *
+ * <p class="caution"><b>Caution:</b> On some devices, this method may
+ * take a long time to complete. It is best to call this method from a
+ * worker thread (possibly using {@link android.os.AsyncTask}) to avoid
+ * blocking the main application UI thread.
+ *
+ * @param cameraId the hardware camera to access, between 0 and
+ * {@link #getNumberOfCameras()}-1. Use {@link #CAMERA_ID_DEFAULT}
+ * to access the default camera.
+ * @return a new Camera object, connected, locked and ready for use.
+ * @throws RuntimeException if connection to the camera service fails (for
+ * example, if the camera is in use by another process).
*/
public static Camera open(int cameraId) {
return new Camera(cameraId);
@@ -137,7 +214,8 @@
public static int CAMERA_ID_DEFAULT = 0;
/**
- * Returns a new Camera object. This returns the default camera.
+ * Equivalent to Camera.open(Camera.CAMERA_ID_DEFAULT).
+ * Creates a new Camera object to access the default camera.
*/
public static Camera open() {
return new Camera(CAMERA_ID_DEFAULT);
@@ -173,56 +251,83 @@
/**
* Disconnects and releases the Camera object resources.
- * <p>It is recommended that you call this as soon as you're done with the
- * Camera object.</p>
+ *
+ * <p>You must call this as soon as you're done with the Camera object.</p>
*/
public final void release() {
native_release();
}
/**
- * Reconnect to the camera after passing it to MediaRecorder. To save
- * setup/teardown time, a client of Camera can pass an initialized Camera
- * object to a MediaRecorder to use for video recording. Once the
- * MediaRecorder is done with the Camera, this method can be used to
- * re-establish a connection with the camera hardware. NOTE: The Camera
- * object must first be unlocked by the process that owns it before it
- * can be connected to another process.
+ * Unlocks the camera to allow another process to access it.
+ * Normally, the camera is locked to the process with an active Camera
+ * object until {@link #release()} is called. To allow rapid handoff
+ * between processes, you can call this method to release the camera
+ * temporarily for another process to use; once the other process is done
+ * you can call {@link #reconnect()} to reclaim the camera.
*
- * @throws IOException if the method fails.
- */
- public native final void reconnect() throws IOException;
-
- /**
- * Lock the camera to prevent other processes from accessing it. To save
- * setup/teardown time, a client of Camera can pass an initialized Camera
- * object to another process. This method is used to re-lock the Camera
- * object prevent other processes from accessing it. By default, the
- * Camera object is locked. Locking it again from the same process will
- * have no effect. Attempting to lock it from another process if it has
- * not been unlocked will fail.
+ * <p>This must be done before calling
+ * {@link android.media.MediaRecorder#setCamera(Camera)}.
*
- * @throws RuntimeException if the method fails.
- */
- public native final void lock();
-
- /**
- * Unlock the camera to allow another process to access it. To save
- * setup/teardown time, a client of Camera can pass an initialized Camera
- * object to another process. This method is used to unlock the Camera
- * object before handing off the Camera object to the other process.
+ * <p>If you are not recording video, you probably do not need this method.
*
- * @throws RuntimeException if the method fails.
+ * @throws RuntimeException if the camera cannot be unlocked.
*/
public native final void unlock();
/**
- * Sets the SurfaceHolder to be used for a picture preview. If the surface
- * changed since the last call, the screen will blank. Nothing happens
- * if the same surface is re-set.
+ * Re-locks the camera to prevent other processes from accessing it.
+ * Camera objects are locked by default unless {@link #unlock()} is
+ * called. Normally {@link #reconnect()} is used instead.
*
- * @param holder the SurfaceHolder upon which to place the picture preview
- * @throws IOException if the method fails.
+ * <p>If you are not recording video, you probably do not need this method.
+ *
+ * @throws RuntimeException if the camera cannot be re-locked (for
+ * example, if the camera is still in use by another process).
+ */
+ public native final void lock();
+
+ /**
+ * Reconnects to the camera service after another process used it.
+ * After {@link #unlock()} is called, another process may use the
+ * camera; when the process is done, you must reconnect to the camera,
+ * which will re-acquire the lock and allow you to continue using the
+ * camera.
+ *
+ * <p>This must be done after {@link android.media.MediaRecorder} is
+ * done recording if {@link android.media.MediaRecorder#setCamera(Camera)}
+ * was used.
+ *
+ * <p>If you are not recording video, you probably do not need this method.
+ *
+ * @throws IOException if a connection cannot be re-established (for
+ * example, if the camera is still in use by another process).
+ */
+ public native final void reconnect() throws IOException;
+
+ /**
+ * Sets the {@link Surface} to be used for live preview.
+ * A surface is necessary for preview, and preview is necessary to take
+ * pictures. The same surface can be re-set without harm.
+ *
+ * <p>The {@link SurfaceHolder} must already contain a surface when this
+ * method is called. If you are using {@link android.view.SurfaceView},
+ * you will need to register a {@link SurfaceHolder.Callback} with
+ * {@link SurfaceHolder#addCallback(SurfaceHolder.Callback)} and wait for
+ * {@link SurfaceHolder.Callback#surfaceCreated(SurfaceHolder)} before
+ * calling setPreviewDisplay() or starting preview.
+ *
+ * <p>This method must be called before {@link #startPreview()}. The
+ * one exception is that if the preview surface is not set (or set to null)
+ * before startPreview() is called, then this method may be called once
+ * with a non-null parameter to set the preview surface. (This allows
+ * camera setup and surface creation to happen in parallel, saving time.)
+ * The preview surface may not otherwise change while preview is running.
+ *
+ * @param holder containing the Surface on which to place the preview,
+ * or null to remove the preview surface
+ * @throws IOException if the method fails (for example, if the surface
+ * is unavailable or unsuitable).
*/
public final void setPreviewDisplay(SurfaceHolder holder) throws IOException {
if (holder != null) {
@@ -235,31 +340,47 @@
private native final void setPreviewDisplay(Surface surface);
/**
- * Used to get a copy of each preview frame.
+ * Callback interface used to deliver copies of preview frames as
+ * they are displayed.
+ *
+ * @see #setPreviewCallback(Camera.PreviewCallback)
+ * @see #setOneShotPreviewCallback(Camera.PreviewCallback)
+ * @see #setPreviewCallbackWithBuffer(Camera.PreviewCallback)
+ * @see #startPreview()
*/
public interface PreviewCallback
{
/**
- * The callback that delivers the preview frames.
+ * Called as preview frames are displayed. This callback is invoked
+ * on the event thread {@link #open(int)} was called from.
*
- * @param data The contents of the preview frame in the format defined
+ * @param data the contents of the preview frame in the format defined
* by {@link android.graphics.ImageFormat}, which can be queried
* with {@link android.hardware.Camera.Parameters#getPreviewFormat()}.
* If {@link android.hardware.Camera.Parameters#setPreviewFormat(int)}
* is never called, the default will be the YCbCr_420_SP
* (NV21) format.
- * @param camera The Camera service object.
+ * @param camera the Camera service object.
*/
void onPreviewFrame(byte[] data, Camera camera);
};
/**
- * Start drawing preview frames to the surface.
+ * Starts capturing and drawing preview frames to the screen.
+ * Preview will not actually start until a surface is supplied with
+ * {@link #setPreviewDisplay(SurfaceHolder)}.
+ *
+ * <p>If {@link #setPreviewCallback(Camera.PreviewCallback)},
+ * {@link #setOneShotPreviewCallback(Camera.PreviewCallback)}, or
+ * {@link #setPreviewCallbackWithBuffer(Camera.PreviewCallback)} were
+ * called, {@link Camera.PreviewCallback#onPreviewFrame(byte[], Camera)}
+ * will be called when preview data becomes available.
*/
public native final void startPreview();
/**
- * Stop drawing preview frames to the surface.
+ * Stops capturing and drawing preview frames to the surface, and
+ * resets the camera for a future call to {@link #startPreview()}.
*/
public native final void stopPreview();
@@ -272,11 +393,13 @@
public native final boolean previewEnabled();
/**
- * Can be called at any time to instruct the camera to use a callback for
- * each preview frame in addition to displaying it.
+ * Installs a callback to be invoked for every preview frame in addition
+ * to displaying them on the screen. The callback will be repeatedly called
+ * for as long as preview is active. This method can be called at any time,
+ * even while preview is live. Any other preview callbacks are overridden.
*
- * @param cb A callback object that receives a copy of each preview frame.
- * Pass null to stop receiving callbacks at any time.
+ * @param cb a callback object that receives a copy of each preview frame,
+ * or null to stop receiving callbacks.
*/
public final void setPreviewCallback(PreviewCallback cb) {
mPreviewCallback = cb;
@@ -288,10 +411,13 @@
}
/**
- * Installs a callback to retrieve a single preview frame, after which the
- * callback is cleared.
+ * Installs a callback to be invoked for the next preview frame in addition
+ * to displaying it on the screen. After one invocation, the callback is
+ * cleared. This method can be called any time, even when preview is live.
+ * Any other preview callbacks are overridden.
*
- * @param cb A callback object that receives a copy of the preview frame.
+ * @param cb a callback object that receives a copy of the next preview frame,
+ * or null to stop receiving callbacks.
*/
public final void setOneShotPreviewCallback(PreviewCallback cb) {
mPreviewCallback = cb;
@@ -303,17 +429,24 @@
private native final void setHasPreviewCallback(boolean installed, boolean manualBuffer);
/**
- * Installs a callback which will get called as long as there are buffers in the
- * preview buffer queue, which minimizes dynamic allocation of preview buffers.
+ * Installs a callback to be invoked for every preview frame, using buffers
+ * supplied with {@link #addCallbackBuffer(byte[])}, in addition to
+ * displaying them on the screen. The callback will be repeatedly called
+ * for as long as preview is active and buffers are available.
+ * Any other preview callbacks are overridden.
*
- * Apps must call addCallbackBuffer to explicitly register the buffers to use, or no callbacks
- * will be received. addCallbackBuffer may be safely called before or after
- * a call to setPreviewCallbackWithBuffer with a non-null callback parameter.
+ * <p>The purpose of this method is to improve preview efficiency and frame
+ * rate by allowing preview frame memory reuse. You must call
+ * {@link #addCallbackBuffer(byte[])} at some point -- before or after
+ * calling this method -- or no callbacks will received.
*
- * The buffer queue will be cleared upon any calls to setOneShotPreviewCallback,
- * setPreviewCallback, or to this method with a null callback parameter.
+ * The buffer queue will be cleared if this method is called with a null
+ * callback, {@link #setPreviewCallback(Camera.PreviewCallback)} is called,
+ * or {@link #setOneShotPreviewCallback(Camera.PreviewCallback)} is called.
*
- * @param cb A callback object that receives a copy of the preview frame. A null value will clear the queue.
+ * @param cb a callback object that receives a copy of the preview frame,
+ * or null to stop receiving callbacks and clear the buffer queue.
+ * @see #addCallbackBuffer(byte[])
*/
public final void setPreviewCallbackWithBuffer(PreviewCallback cb) {
mPreviewCallback = cb;
@@ -325,21 +458,27 @@
/**
* Adds a pre-allocated buffer to the preview callback buffer queue.
* Applications can add one or more buffers to the queue. When a preview
- * frame arrives and there is still available buffer, buffer will be filled
- * and it is removed from the queue. Then preview callback is invoked with
- * the buffer. If a frame arrives and there is no buffer left, the frame is
- * discarded. Applications should add the buffers back when they finish the
- * processing.
+ * frame arrives and there is still at least one available buffer, the
+ * buffer will be used and removed from the queue. Then preview callback is
+ * invoked with the buffer. If a frame arrives and there is no buffer left,
+ * the frame is discarded. Applications should add buffers back when they
+ * finish processing the data in them.
*
- * The image format of the callback buffer can be read from {@link
- * android.hardware.Camera.Parameters#getPreviewFormat()}. bitsPerPixel can
- * be read from {@link android.graphics.ImageFormat#getBitsPerPixel(int)}.
- * Preview width and height can be determined from getPreviewSize.
+ * <p>The size of the buffer is determined by multiplying the preview
+ * image width, height, and bytes per pixel. The width and height can be
+ * read from {@link Camera.Parameters#getPreviewSize()}. Bytes per pixel
+ * can be computed from
+ * {@link android.graphics.ImageFormat#getBitsPerPixel(int)} / 8,
+ * using the image format from {@link Camera.Parameters#getPreviewFormat()}.
*
- * Alternatively, a buffer from a previous callback may be passed in or used
- * to determine the size of new preview frame buffers.
+ * <p>This method is only necessary when
+ * {@link #setPreviewCallbackWithBuffer(PreviewCallback)} is used. When
+ * {@link #setPreviewCallback(PreviewCallback)} or
+ * {@link #setOneShotPreviewCallback(PreviewCallback)} are used, buffers
+ * are automatically allocated.
*
- * @param callbackBuffer The buffer to register. Size should be width * height * bitsPerPixel / 8.
+ * @param callbackBuffer the buffer to add to the queue.
+ * The size should be width * height * bits_per_pixel / 8.
* @see #setPreviewCallbackWithBuffer(PreviewCallback)
*/
public native final void addCallbackBuffer(byte[] callbackBuffer);
@@ -438,7 +577,8 @@
}
/**
- * Handles the callback for the camera auto focus.
+ * Callback interface used to notify on completion of camera auto focus.
+ *
* <p>Devices that do not support auto-focus will receive a "fake"
* callback to this interface. If your application needs auto-focus and
* should not be installed on devices <em>without</em> auto-focus, you must
@@ -446,13 +586,15 @@
* {@code android.hardware.camera.autofocus} feature, in the
* <a href="{@docRoot}guide/topics/manifest/uses-feature-element.html"><uses-feature></a>
* manifest element.</p>
+ *
+ * @see #autoFocus(AutoFocusCallback)
*/
public interface AutoFocusCallback
{
/**
- * Callback for the camera auto focus. If the camera does not support
- * auto-focus and autoFocus is called, onAutoFocus will be called
- * immediately with success.
+ * Called when the camera auto focus completes. If the camera does not
+ * support auto-focus and autoFocus is called, onAutoFocus will be
+ * called immediately with success.
*
* @param success true if focus was successful, false if otherwise
* @param camera the Camera service object
@@ -461,23 +603,28 @@
};
/**
- * Starts auto-focus function and registers a callback function to run when
- * camera is focused. Only valid after startPreview() has been called.
- * Applications should call {@link
- * android.hardware.Camera.Parameters#getFocusMode()} to determine if this
- * method should be called. If the camera does not support auto-focus, it is
- * a no-op and {@link AutoFocusCallback#onAutoFocus(boolean, Camera)}
+ * Starts camera auto-focus and registers a callback function to run when
+ * the camera is focused. This method is only valid when preview is active
+ * (between {@link #startPreview()} and before {@link #stopPreview()}).
+ *
+ * <p>Callers should check
+ * {@link android.hardware.Camera.Parameters#getFocusMode()} to determine if
+ * this method should be called. If the camera does not support auto-focus,
+ * it is a no-op and {@link AutoFocusCallback#onAutoFocus(boolean, Camera)}
* callback will be called immediately.
+ *
* <p>If your application should not be installed
* on devices without auto-focus, you must declare that your application
* uses auto-focus with the
* <a href="{@docRoot}guide/topics/manifest/uses-feature-element.html"><uses-feature></a>
* manifest element.</p>
+ *
* <p>If the current flash mode is not
* {@link android.hardware.Camera.Parameters#FLASH_MODE_OFF}, flash may be
- * fired during auto-focus depending on the driver.<p>
+ * fired during auto-focus, depending on the driver and camera hardware.<p>
*
* @param cb the callback to run
+ * @see #cancelAutoFocus()
*/
public final void autoFocus(AutoFocusCallback cb)
{
@@ -487,10 +634,12 @@
private native final void native_autoFocus();
/**
- * Cancels auto-focus function. If the auto-focus is still in progress,
- * this function will cancel it. Whether the auto-focus is in progress
- * or not, this function will return the focus position to the default.
+ * Cancels any auto-focus function in progress.
+ * Whether or not auto-focus is currently in progress,
+ * this function will return the focus position to the default.
* If the camera does not support auto-focus, this is a no-op.
+ *
+ * @see #autoFocus(Camera.AutoFocusCallback)
*/
public final void cancelAutoFocus()
{
@@ -500,23 +649,32 @@
private native final void native_cancelAutoFocus();
/**
- * An interface which contains a callback for the shutter closing after taking a picture.
+ * Callback interface used to signal the moment of actual image capture.
+ *
+ * @see #takePicture(ShutterCallback, PictureCallback, PictureCallback, PictureCallback)
*/
public interface ShutterCallback
{
/**
- * Can be used to play a shutter sound as soon as the image has been captured, but before
- * the data is available.
+ * Called as near as possible to the moment when a photo is captured
+ * from the sensor. This is a good opportunity to play a shutter sound
+ * or give other feedback of camera operation. This may be some time
+ * after the photo was triggered, but some time before the actual data
+ * is available.
*/
void onShutter();
}
/**
- * Handles the callback for when a picture is taken.
+ * Callback interface used to supply image data from a photo capture.
+ *
+ * @see #takePicture(ShutterCallback, PictureCallback, PictureCallback, PictureCallback)
*/
public interface PictureCallback {
/**
- * Callback for when a picture is taken.
+ * Called when image data is available after a picture is taken.
+ * The format of the data depends on the context of the callback
+ * and {@link Camera.Parameters} settings.
*
* @param data a byte array of the picture data
* @param camera the Camera service object
@@ -525,24 +683,9 @@
};
/**
- * Triggers an asynchronous image capture. The camera service will initiate
- * a series of callbacks to the application as the image capture progresses.
- * The shutter callback occurs after the image is captured. This can be used
- * to trigger a sound to let the user know that image has been captured. The
- * raw callback occurs when the raw image data is available (NOTE: the data
- * may be null if the hardware does not have enough memory to make a copy).
- * The jpeg callback occurs when the compressed image is available. If the
- * application does not need a particular callback, a null can be passed
- * instead of a callback method.
+ * Equivalent to takePicture(shutter, raw, null, jpeg).
*
- * This method is only valid after {@link #startPreview()} has been called.
- * This method will stop the preview. Applications should not call {@link
- * #stopPreview()} before this. After jpeg callback is received,
- * applications can call {@link #startPreview()} to restart the preview.
- *
- * @param shutter callback after the image is captured, may be null
- * @param raw callback with raw image data, may be null
- * @param jpeg callback with jpeg image data, may be null
+ * @see #takePicture(ShutterCallback, PictureCallback, PictureCallback, PictureCallback)
*/
public final void takePicture(ShutterCallback shutter, PictureCallback raw,
PictureCallback jpeg) {
@@ -563,15 +706,18 @@
* application does not need a particular callback, a null can be passed
* instead of a callback method.
*
- * This method is only valid after {@link #startPreview()} has been called.
- * This method will stop the preview. Applications should not call {@link
- * #stopPreview()} before this. After jpeg callback is received,
- * applications can call {@link #startPreview()} to restart the preview.
+ * <p>This method is only valid when preview is active (after
+ * {@link #startPreview()}). Preview will be stopped after the image is
+ * taken; callers must call {@link #startPreview()} again if they want to
+ * re-start preview or take more pictures.
*
- * @param shutter callback after the image is captured, may be null
- * @param raw callback with raw image data, may be null
+ * <p>After calling this method, you must not call {@link #startPreview()}
+ * or take another picture until the JPEG callback has returned.
+ *
+ * @param shutter the callback for image capture moment, or null
+ * @param raw the callback for raw (uncompressed) image data, or null
* @param postview callback with postview image data, may be null
- * @param jpeg callback with jpeg image data, may be null
+ * @param jpeg the callback for JPEG image data, or null
*/
public final void takePicture(ShutterCallback shutter, PictureCallback raw,
PictureCallback postview, PictureCallback jpeg) {
@@ -583,26 +729,29 @@
}
/**
- * Zooms to the requested value smoothly. Driver will notify {@link
+ * Zooms to the requested value smoothly. The driver will notify {@link
* OnZoomChangeListener} of the zoom value and whether zoom is stopped at
* the time. For example, suppose the current zoom is 0 and startSmoothZoom
- * is called with value 3. Method onZoomChange will be called three times
- * with zoom value 1, 2, and 3. The applications can call {@link
- * #stopSmoothZoom} to stop the zoom earlier. The applications should not
- * call startSmoothZoom again or change the zoom value before zoom stops. If
- * the passing zoom value equals to the current zoom value, no zoom callback
- * will be generated. This method is supported if {@link
- * android.hardware.Camera.Parameters#isSmoothZoomSupported} is true.
+ * is called with value 3. The
+ * {@link Camera.OnZoomChangeListener#onZoomChange(int, boolean, Camera)}
+ * method will be called three times with zoom values 1, 2, and 3.
+ * Applications can call {@link #stopSmoothZoom} to stop the zoom earlier.
+ * Applications should not call startSmoothZoom again or change the zoom
+ * value before zoom stops. If the supplied zoom value equals to the current
+ * zoom value, no zoom callback will be generated. This method is supported
+ * if {@link android.hardware.Camera.Parameters#isSmoothZoomSupported}
+ * returns true.
*
* @param value zoom value. The valid range is 0 to {@link
* android.hardware.Camera.Parameters#getMaxZoom}.
* @throws IllegalArgumentException if the zoom value is invalid.
* @throws RuntimeException if the method fails.
+ * @see #setZoomChangeListener(OnZoomChangeListener)
*/
public native final void startSmoothZoom(int value);
/**
- * Stops the smooth zoom. The applications should wait for the {@link
+ * Stops the smooth zoom. Applications should wait for the {@link
* OnZoomChangeListener} to know when the zoom is actually stopped. This
* method is supported if {@link
* android.hardware.Camera.Parameters#isSmoothZoomSupported} is true.
@@ -649,20 +798,21 @@
public native final void setDisplayOrientation(int degrees);
/**
- * Interface for a callback to be invoked when zoom value changes.
+ * Callback interface for zoom changes during a smooth zoom operation.
+ *
+ * @see #setZoomChangeListener(OnZoomChangeListener)
+ * @see #startSmoothZoom(int)
*/
public interface OnZoomChangeListener
{
/**
- * Called when the zoom value has changed.
+ * Called when the zoom value has changed during a smooth zoom.
*
* @param zoomValue the current zoom value. In smooth zoom mode, camera
* calls this for every new zoom value.
* @param stopped whether smooth zoom is stopped. If the value is true,
* this is the last zoom update for the application.
- *
* @param camera the Camera service object
- * @see #startSmoothZoom(int)
*/
void onZoomChange(int zoomValue, boolean stopped, Camera camera);
};
@@ -679,15 +829,25 @@
mZoomListener = listener;
}
- // These match the enum in include/ui/Camera.h
- /** Unspecified camerar error. @see #ErrorCallback */
+ // Error codes match the enum in include/ui/Camera.h
+
+ /**
+ * Unspecified camera error.
+ * @see Camera.ErrorCallback
+ */
public static final int CAMERA_ERROR_UNKNOWN = 1;
- /** Media server died. In this case, the application must release the
- * Camera object and instantiate a new one. @see #ErrorCallback */
+
+ /**
+ * Media server died. In this case, the application must release the
+ * Camera object and instantiate a new one.
+ * @see Camera.ErrorCallback
+ */
public static final int CAMERA_ERROR_SERVER_DIED = 100;
/**
- * Handles the camera error callback.
+ * Callback interface for camera error notification.
+ *
+ * @see #setErrorCallback(ErrorCallback)
*/
public interface ErrorCallback
{
@@ -705,7 +865,7 @@
/**
* Registers a callback to be invoked when an error occurs.
- * @param cb the callback to run
+ * @param cb The callback to run
*/
public final void setErrorCallback(ErrorCallback cb)
{
@@ -716,16 +876,21 @@
private native final String native_getParameters();
/**
- * Sets the Parameters for pictures from this Camera service.
+ * Changes the settings for this Camera service.
*
* @param params the Parameters to use for this Camera service
+ * @see #getParameters()
*/
public void setParameters(Parameters params) {
native_setParameters(params.flatten());
}
/**
- * Returns the picture Parameters for this Camera service.
+ * Returns the current settings for this Camera service.
+ * If modifications are made to the returned Parameters, they must be passed
+ * to {@link #setParameters(Camera.Parameters)} to take effect.
+ *
+ * @see #setParameters(Camera.Parameters)
*/
public Parameters getParameters() {
Parameters p = new Parameters();
@@ -735,7 +900,7 @@
}
/**
- * Handles the picture size (dimensions).
+ * Image size (width and height dimensions).
*/
public class Size {
/**
@@ -774,18 +939,21 @@
};
/**
- * Handles the parameters for pictures created by a Camera service.
+ * Camera service settings.
*
* <p>To make camera parameters take effect, applications have to call
- * Camera.setParameters. For example, after setWhiteBalance is called, white
- * balance is not changed until Camera.setParameters() is called.
+ * {@link Camera#setParameters(Camera.Parameters)}. For example, after
+ * {@link Camera.Parameters#setWhiteBalance} is called, white balance is not
+ * actually changed until {@link Camera#setParameters(Camera.Parameters)}
+ * is called with the changed parameters object.
*
* <p>Different devices may have different camera capabilities, such as
* picture size or flash modes. The application should query the camera
* capabilities before setting parameters. For example, the application
- * should call getSupportedColorEffects before calling setEffect. If the
- * camera does not support color effects, getSupportedColorEffects will
- * return null.
+ * should call {@link Camera.Parameters#getSupportedColorEffects()} before
+ * calling {@link Camera.Parameters#setColorEffect(String)}. If the
+ * camera does not support color effects,
+ * {@link Camera.Parameters#getSupportedColorEffects()} will return null.
*/
public class Parameters {
// Parameter keys to communicate with the camera driver.
diff --git a/core/java/android/os/BatteryStats.java b/core/java/android/os/BatteryStats.java
index e3f3b87..0afd6cd 100644
--- a/core/java/android/os/BatteryStats.java
+++ b/core/java/android/os/BatteryStats.java
@@ -1237,10 +1237,9 @@
linePrefix);
if (!linePrefix.equals(": ")) {
sb.append(" realtime");
- } else {
- sb.append(": (nothing executed)");
+ // Only print out wake locks that were held
+ pw.println(sb.toString());
}
- pw.println(sb.toString());
}
}
}
@@ -1453,11 +1452,10 @@
"window", which, linePrefix);
if (!linePrefix.equals(": ")) {
sb.append(" realtime");
- } else {
- sb.append(": (nothing executed)");
+ // Only print out wake locks that were held
+ pw.println(sb.toString());
+ uidActivity = true;
}
- pw.println(sb.toString());
- uidActivity = true;
}
}
diff --git a/core/java/android/os/Binder.java b/core/java/android/os/Binder.java
index c9df567..59b8274 100644
--- a/core/java/android/os/Binder.java
+++ b/core/java/android/os/Binder.java
@@ -101,7 +101,30 @@
* @see #clearCallingIdentity
*/
public static final native void restoreCallingIdentity(long token);
-
+
+ /**
+ * Sets the native thread-local StrictMode policy mask.
+ *
+ * <p>The StrictMode settings are kept in two places: a Java-level
+ * threadlocal for libcore/Dalvik, and a native threadlocal (set
+ * here) for propagation via Binder calls. This is a little
+ * unfortunate, but necessary to break otherwise more unfortunate
+ * dependencies either of Dalvik on Android, or Android
+ * native-only code on Dalvik.
+ *
+ * @see StrictMode
+ * @hide
+ */
+ public static final native void setThreadStrictModePolicy(int policyMask);
+
+ /**
+ * Gets the current native thread-local StrictMode policy mask.
+ *
+ * @see #setThreadStrictModePolicy
+ * @hide
+ */
+ public static final native int getThreadStrictModePolicy();
+
/**
* Flush any Binder commands pending in the current thread to the kernel
* driver. This can be
@@ -276,6 +299,8 @@
private native final void init();
private native final void destroy();
+
+ // Entry point from android_util_Binder.cpp's onTransact
private boolean execTransact(int code, int dataObj, int replyObj,
int flags) {
Parcel data = Parcel.obtain(dataObj);
diff --git a/core/java/android/os/Parcel.java b/core/java/android/os/Parcel.java
index 8ad600c..31f8719 100644
--- a/core/java/android/os/Parcel.java
+++ b/core/java/android/os/Parcel.java
@@ -176,6 +176,7 @@
*/
public final class Parcel {
private static final boolean DEBUG_RECYCLE = false;
+ private static final String TAG = "Parcel";
@SuppressWarnings({"UnusedDeclaration"})
private int mObject; // used by native code
@@ -214,12 +215,14 @@
private static final int VAL_BOOLEANARRAY = 23;
private static final int VAL_CHARSEQUENCEARRAY = 24;
+ // The initial int32 in a Binder call's reply Parcel header:
private static final int EX_SECURITY = -1;
private static final int EX_BAD_PARCELABLE = -2;
private static final int EX_ILLEGAL_ARGUMENT = -3;
private static final int EX_NULL_POINTER = -4;
private static final int EX_ILLEGAL_STATE = -5;
-
+ private static final int EX_HAS_REPLY_HEADER = -128; // special; see below
+
public final static Parcelable.Creator<String> STRING_CREATOR
= new Parcelable.Creator<String>() {
public String createFromParcel(Parcel source) {
@@ -437,6 +440,12 @@
/**
* Write a FileDescriptor into the parcel at the current dataPosition(),
* growing dataCapacity() if needed.
+ *
+ * <p class="caution">The file descriptor will not be closed, which may
+ * result in file descriptor leaks when objects are returned from Binder
+ * calls. Use {@link ParcelFileDescriptor#writeToParcel} instead, which
+ * accepts contextual flags and will close the original file descriptor
+ * if {@link Parcelable#PARCELABLE_WRITE_RETURN_VALUE} is set.</p>
*/
public final native void writeFileDescriptor(FileDescriptor val);
@@ -1000,7 +1009,7 @@
/**
* Flatten a generic object in to a parcel. The given Object value may
* currently be one of the following types:
- *
+ *
* <ul>
* <li> null
* <li> String
@@ -1023,7 +1032,7 @@
* <li> Parcelable[]
* <li> CharSequence (as supported by {@link TextUtils#writeToParcel}).
* <li> List (as supported by {@link #writeList}).
- * <li> {@link SparseArray} (as supported by {@link #writeSparseArray}).
+ * <li> {@link SparseArray} (as supported by {@link #writeSparseArray(SparseArray)}).
* <li> {@link IBinder}
* <li> Any object that implements Serializable (but see
* {@link #writeSerializable} for caveats). Note that all of the
@@ -1032,6 +1041,13 @@
* approach is much less efficient and should be avoided whenever
* possible.
* </ul>
+ *
+ * <p class="caution">{@link Parcelable} objects are written with
+ * {@link Parcelable#writeToParcel} using contextual flags of 0. When
+ * serializing objects containing {@link ParcelFileDescriptor}s,
+ * this may result in file descriptor leaks when they are returned from
+ * Binder calls (where {@link Parcelable#PARCELABLE_WRITE_RETURN_VALUE}
+ * should be used).</p>
*/
public final void writeValue(Object v) {
if (v == null) {
@@ -1120,7 +1136,7 @@
/**
* Flatten the name of the class of the Parcelable and its contents
* into the parcel.
- *
+ *
* @param p The Parcelable object to be written.
* @param parcelableFlags Contextual flags as per
* {@link Parcelable#writeToParcel(Parcel, int) Parcelable.writeToParcel()}.
@@ -1199,6 +1215,7 @@
code = EX_ILLEGAL_STATE;
}
writeInt(code);
+ StrictMode.clearGatheredViolations();
if (code == 0) {
if (e instanceof RuntimeException) {
throw (RuntimeException) e;
@@ -1216,7 +1233,31 @@
* @see #readException
*/
public final void writeNoException() {
- writeInt(0);
+ // Despite the name of this function ("write no exception"),
+ // it should instead be thought of as "write the RPC response
+ // header", but because this function name is written out by
+ // the AIDL compiler, we're not going to rename it.
+ //
+ // The response header, in the non-exception case (see also
+ // writeException above, also called by the AIDL compiler), is
+ // either a 0 (the default case), or EX_HAS_REPLY_HEADER if
+ // StrictMode has gathered up violations that have occurred
+ // during a Binder call, in which case we write out the number
+ // of violations and their details, serialized, before the
+ // actual RPC respons data. The receiving end of this is
+ // readException(), below.
+ if (StrictMode.hasGatheredViolations()) {
+ writeInt(EX_HAS_REPLY_HEADER);
+ final int sizePosition = dataPosition();
+ writeInt(0); // total size of fat header, to be filled in later
+ StrictMode.writeGatheredViolationsToParcel(this);
+ final int payloadPosition = dataPosition();
+ setDataPosition(sizePosition);
+ writeInt(payloadPosition - sizePosition); // header size
+ setDataPosition(payloadPosition);
+ } else {
+ writeInt(0);
+ }
}
/**
@@ -1229,10 +1270,44 @@
* @see #writeNoException
*/
public final void readException() {
+ int code = readExceptionCode();
+ if (code != 0) {
+ String msg = readString();
+ readException(code, msg);
+ }
+ }
+
+ /**
+ * Parses the header of a Binder call's response Parcel and
+ * returns the exception code. Deals with lite or fat headers.
+ * In the common successful case, this header is generally zero.
+ * In less common cases, it's a small negative number and will be
+ * followed by an error string.
+ *
+ * This exists purely for android.database.DatabaseUtils and
+ * insulating it from having to handle fat headers as returned by
+ * e.g. StrictMode-induced RPC responses.
+ *
+ * @hide
+ */
+ public final int readExceptionCode() {
int code = readInt();
- if (code == 0) return;
- String msg = readString();
- readException(code, msg);
+ if (code == EX_HAS_REPLY_HEADER) {
+ int headerSize = readInt();
+ if (headerSize == 0) {
+ Log.e(TAG, "Unexpected zero-sized Parcel reply header.");
+ } else {
+ // Currently the only thing in the header is StrictMode stacks,
+ // but discussions around event/RPC tracing suggest we might
+ // put that here too. If so, switch on sub-header tags here.
+ // But for now, just parse out the StrictMode stuff.
+ StrictMode.readAndHandleBinderCallViolations(this);
+ }
+ // And fat response headers are currently only used when
+ // there are no exceptions, so return no error:
+ return 0;
+ }
+ return code;
}
/**
@@ -1872,13 +1947,13 @@
creator = (Parcelable.Creator)f.get(null);
}
catch (IllegalAccessException e) {
- Log.e("Parcel", "Class not found when unmarshalling: "
+ Log.e(TAG, "Class not found when unmarshalling: "
+ name + ", e: " + e);
throw new BadParcelableException(
"IllegalAccessException when unmarshalling: " + name);
}
catch (ClassNotFoundException e) {
- Log.e("Parcel", "Class not found when unmarshalling: "
+ Log.e(TAG, "Class not found when unmarshalling: "
+ name + ", e: " + e);
throw new BadParcelableException(
"ClassNotFoundException when unmarshalling: " + name);
@@ -1983,7 +2058,7 @@
if (DEBUG_RECYCLE) {
mStack = new RuntimeException();
}
- //Log.i("Parcel", "Initializing obj=0x" + Integer.toHexString(obj), mStack);
+ //Log.i(TAG, "Initializing obj=0x" + Integer.toHexString(obj), mStack);
init(obj);
}
@@ -1991,7 +2066,7 @@
protected void finalize() throws Throwable {
if (DEBUG_RECYCLE) {
if (mStack != null) {
- Log.w("Parcel", "Client did not call Parcel.recycle()", mStack);
+ Log.w(TAG, "Client did not call Parcel.recycle()", mStack);
}
}
destroy();
@@ -2015,7 +2090,7 @@
ClassLoader loader) {
while (N > 0) {
Object value = readValue(loader);
- //Log.d("Parcel", "Unmarshalling value=" + value);
+ //Log.d(TAG, "Unmarshalling value=" + value);
outVal.add(value);
N--;
}
@@ -2025,7 +2100,7 @@
ClassLoader loader) {
for (int i = 0; i < N; i++) {
Object value = readValue(loader);
- //Log.d("Parcel", "Unmarshalling value=" + value);
+ //Log.d(TAG, "Unmarshalling value=" + value);
outVal[i] = value;
}
}
@@ -2035,7 +2110,7 @@
while (N > 0) {
int key = readInt();
Object value = readValue(loader);
- //Log.i("Parcel", "Unmarshalling key=" + key + " value=" + value);
+ //Log.i(TAG, "Unmarshalling key=" + key + " value=" + value);
outVal.append(key, value);
N--;
}
@@ -2046,7 +2121,7 @@
while (N > 0) {
int key = readInt();
boolean value = this.readByte() == 1;
- //Log.i("Parcel", "Unmarshalling key=" + key + " value=" + value);
+ //Log.i(TAG, "Unmarshalling key=" + key + " value=" + value);
outVal.append(key, value);
N--;
}
diff --git a/core/java/android/os/ParcelFileDescriptor.java b/core/java/android/os/ParcelFileDescriptor.java
index d26f066..9d213b3 100644
--- a/core/java/android/os/ParcelFileDescriptor.java
+++ b/core/java/android/os/ParcelFileDescriptor.java
@@ -250,6 +250,11 @@
return Parcelable.CONTENTS_FILE_DESCRIPTOR;
}
+ /**
+ * {@inheritDoc}
+ * If {@link Parcelable#PARCELABLE_WRITE_RETURN_VALUE} is set in flags,
+ * the file descriptor will be closed after a copy is written to the Parcel.
+ */
public void writeToParcel(Parcel out, int flags) {
out.writeFileDescriptor(mFileDescriptor);
if ((flags&PARCELABLE_WRITE_RETURN_VALUE) != 0 && !mClosed) {
diff --git a/core/java/android/os/StrictMode.java b/core/java/android/os/StrictMode.java
index 9b18719..dc92590 100644
--- a/core/java/android/os/StrictMode.java
+++ b/core/java/android/os/StrictMode.java
@@ -23,6 +23,9 @@
import dalvik.system.BlockGuard;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.ArrayList;
import java.util.HashMap;
/**
@@ -31,6 +34,7 @@
*/
public final class StrictMode {
private static final String TAG = "StrictMode";
+ private static final boolean LOG_V = false;
// Only log a duplicate stack trace to the logs every second.
private static final long MIN_LOG_INTERVAL_MS = 1000;
@@ -69,18 +73,60 @@
*/
public static final int PENALTY_DROPBOX = 0x80;
+ /**
+ * Non-public penalty mode which overrides all the other penalty
+ * bits and signals that we're in a Binder call and we should
+ * ignore the other penalty bits and instead serialize back all
+ * our offending stack traces to the caller to ultimately handle
+ * in the originating process.
+ *
+ * This must be kept in sync with the constant in libs/binder/Parcel.cpp
+ *
+ * @hide
+ */
+ public static final int PENALTY_GATHER = 0x100;
+
/** @hide */
public static final int PENALTY_MASK =
PENALTY_LOG | PENALTY_DIALOG |
PENALTY_DROPBOX | PENALTY_DEATH;
/**
+ * Log of strict mode violation stack traces that have occurred
+ * during a Binder call, to be serialized back later to the caller
+ * via Parcel.writeNoException() (amusingly) where the caller can
+ * choose how to react.
+ */
+ private static ThreadLocal<ArrayList<ApplicationErrorReport.CrashInfo>> gatheredViolations =
+ new ThreadLocal<ArrayList<ApplicationErrorReport.CrashInfo>>() {
+ @Override protected ArrayList<ApplicationErrorReport.CrashInfo> initialValue() {
+ // Starts null to avoid unnecessary allocations when
+ // checking whether there are any violations or not in
+ // hasGatheredViolations() below.
+ return null;
+ }
+ };
+
+ /**
* Sets the policy for what actions the current thread is denied,
* as well as the penalty for violating the policy.
*
* @param policyMask a bitmask of DISALLOW_* and PENALTY_* values.
*/
public static void setThreadBlockingPolicy(final int policyMask) {
+ // In addition to the Java-level thread-local in Dalvik's
+ // BlockGuard, we also need to keep a native thread-local in
+ // Binder in order to propagate the value across Binder calls,
+ // even across native-only processes. The two are kept in
+ // sync via the callback to onStrictModePolicyChange, below.
+ setBlockGuardPolicy(policyMask);
+
+ // And set the Android native version...
+ Binder.setThreadStrictModePolicy(policyMask);
+ }
+
+ // Sets the policy in Dalvik/libcore (BlockGuard)
+ private static void setBlockGuardPolicy(final int policyMask) {
if (policyMask == 0) {
BlockGuard.setThreadPolicy(BlockGuard.LAX_POLICY);
return;
@@ -94,6 +140,24 @@
}
}
+ private static class StrictModeNetworkViolation extends BlockGuard.BlockGuardPolicyException {
+ public StrictModeNetworkViolation(int policyMask) {
+ super(policyMask, DISALLOW_NETWORK);
+ }
+ }
+
+ private static class StrictModeDiskReadViolation extends BlockGuard.BlockGuardPolicyException {
+ public StrictModeDiskReadViolation(int policyMask) {
+ super(policyMask, DISALLOW_DISK_READ);
+ }
+ }
+
+ private static class StrictModeDiskWriteViolation extends BlockGuard.BlockGuardPolicyException {
+ public StrictModeDiskWriteViolation(int policyMask) {
+ super(policyMask, DISALLOW_DISK_WRITE);
+ }
+ }
+
/**
* Returns the bitmask of the current thread's blocking policy.
*
@@ -103,6 +167,52 @@
return BlockGuard.getThreadPolicy().getPolicyMask();
}
+ /**
+ * Parses the BlockGuard policy mask out from the Exception's
+ * getMessage() String value. Kinda gross, but least
+ * invasive. :/
+ *
+ * Input is of form "policy=137 violation=64"
+ *
+ * Returns 0 on failure, which is a valid policy, but not a
+ * valid policy during a violation (else there must've been
+ * some policy in effect to violate).
+ */
+ private static int parsePolicyFromMessage(String message) {
+ if (message == null || !message.startsWith("policy=")) {
+ return 0;
+ }
+ int spaceIndex = message.indexOf(' ');
+ if (spaceIndex == -1) {
+ return 0;
+ }
+ String policyString = message.substring(7, spaceIndex);
+ try {
+ return Integer.valueOf(policyString).intValue();
+ } catch (NumberFormatException e) {
+ return 0;
+ }
+ }
+
+ /**
+ * Like parsePolicyFromMessage(), but returns the violation.
+ */
+ private static int parseViolationFromMessage(String message) {
+ if (message == null) {
+ return 0;
+ }
+ int violationIndex = message.indexOf("violation=");
+ if (violationIndex == -1) {
+ return 0;
+ }
+ String violationString = message.substring(violationIndex + 10);
+ try {
+ return Integer.valueOf(violationString).intValue();
+ } catch (NumberFormatException e) {
+ return 0;
+ }
+ }
+
private static class AndroidBlockGuardPolicy implements BlockGuard.Policy {
private int mPolicyMask;
@@ -115,6 +225,11 @@
mPolicyMask = policyMask;
}
+ @Override
+ public String toString() {
+ return "AndroidBlockGuardPolicy; mPolicyMask=" + mPolicyMask;
+ }
+
// Part of BlockGuard.Policy interface:
public int getPolicyMask() {
return mPolicyMask;
@@ -125,7 +240,7 @@
if ((mPolicyMask & DISALLOW_DISK_WRITE) == 0) {
return;
}
- handleViolation(DISALLOW_DISK_WRITE);
+ startHandlingViolationException(new StrictModeDiskWriteViolation(mPolicyMask));
}
// Part of BlockGuard.Policy interface:
@@ -133,7 +248,7 @@
if ((mPolicyMask & DISALLOW_DISK_READ) == 0) {
return;
}
- handleViolation(DISALLOW_DISK_READ);
+ startHandlingViolationException(new StrictModeDiskReadViolation(mPolicyMask));
}
// Part of BlockGuard.Policy interface:
@@ -141,17 +256,23 @@
if ((mPolicyMask & DISALLOW_NETWORK) == 0) {
return;
}
- handleViolation(DISALLOW_NETWORK);
+ startHandlingViolationException(new StrictModeNetworkViolation(mPolicyMask));
}
public void setPolicyMask(int policyMask) {
mPolicyMask = policyMask;
}
- private void handleViolation(int violationBit) {
- final BlockGuard.BlockGuardPolicyException violation =
- new BlockGuard.BlockGuardPolicyException(mPolicyMask, violationBit);
- violation.fillInStackTrace();
+ // Start handling a violation that just started and hasn't
+ // actually run yet (e.g. no disk write or network operation
+ // has yet occurred). This sees if we're in an event loop
+ // thread and, if so, uses it to roughly measure how long the
+ // violation took.
+ void startHandlingViolationException(BlockGuard.BlockGuardPolicyException e) {
+ e.fillInStackTrace();
+ final ApplicationErrorReport.CrashInfo crashInfo = new ApplicationErrorReport.CrashInfo(e);
+ crashInfo.durationMillis = -1; // unknown
+ final int savedPolicy = mPolicyMask;
Looper looper = Looper.myLooper();
if (looper == null) {
@@ -159,35 +280,55 @@
// violation takes place. This case should be rare,
// as most users will care about timing violations
// that happen on their main UI thread.
- handleViolationWithTime(violation, -1L /* no time */);
+ handleViolation(crashInfo, savedPolicy);
} else {
MessageQueue queue = Looper.myQueue();
final long violationTime = SystemClock.uptimeMillis();
queue.addIdleHandler(new MessageQueue.IdleHandler() {
public boolean queueIdle() {
long afterViolationTime = SystemClock.uptimeMillis();
- handleViolationWithTime(violation, afterViolationTime - violationTime);
+ crashInfo.durationMillis = afterViolationTime - violationTime;
+ handleViolation(crashInfo, savedPolicy);
return false; // remove this idle handler from the array
}
});
}
+
}
- private void handleViolationWithTime(
- BlockGuard.BlockGuardPolicyException violation,
- long durationMillis) {
+ // Note: It's possible (even quite likely) that the
+ // thread-local policy mask has changed from the time the
+ // violation fired and now (after the violating code ran) due
+ // to people who push/pop temporary policy in regions of code,
+ // hence the policy being passed around.
+ void handleViolation(
+ final ApplicationErrorReport.CrashInfo crashInfo,
+ int policy) {
+ if (crashInfo.stackTrace == null) {
+ Log.d(TAG, "unexpected null stacktrace");
+ return;
+ }
- // It's possible (even quite likely) that mPolicyMask has
- // changed from the time the violation fired and now
- // (after the violating code ran) due to people who
- // push/pop temporary policy in regions of code. So use
- // the old policy here.
- int policy = violation.getPolicy();
+ if (LOG_V) Log.d(TAG, "handleViolation; policy=" + policy);
- // Not _really_ a Crash, but we use the same data structure...
- ApplicationErrorReport.CrashInfo crashInfo =
- new ApplicationErrorReport.CrashInfo(violation);
- crashInfo.durationMillis = durationMillis;
+ if ((policy & PENALTY_GATHER) != 0) {
+ ArrayList<ApplicationErrorReport.CrashInfo> violations = gatheredViolations.get();
+ if (violations == null) {
+ violations = new ArrayList<ApplicationErrorReport.CrashInfo>(1);
+ gatheredViolations.set(violations);
+ } else if (violations.size() >= 5) {
+ // Too many. In a loop or something? Don't gather them all.
+ return;
+ }
+ for (ApplicationErrorReport.CrashInfo previous : violations) {
+ if (crashInfo.stackTrace.equals(previous.stackTrace)) {
+ // Duplicate. Don't log.
+ return;
+ }
+ }
+ violations.add(crashInfo);
+ return;
+ }
// Not perfect, but fast and good enough for dup suppression.
Integer crashFingerprint = crashInfo.stackTrace.hashCode();
@@ -202,11 +343,11 @@
if ((policy & PENALTY_LOG) != 0 &&
timeSinceLastViolationMillis > MIN_LOG_INTERVAL_MS) {
- if (durationMillis != -1) {
- Log.d(TAG, "StrictMode policy violation; ~duration=" + durationMillis + " ms",
- violation);
+ if (crashInfo.durationMillis != -1) {
+ Log.d(TAG, "StrictMode policy violation; ~duration=" +
+ crashInfo.durationMillis + " ms: " + crashInfo.stackTrace);
} else {
- Log.d(TAG, "StrictMode policy violation.", violation);
+ Log.d(TAG, "StrictMode policy violation: " + crashInfo.stackTrace);
}
}
@@ -226,14 +367,25 @@
}
if (violationMask != 0) {
- violationMask |= violation.getPolicyViolation();
+ int violationBit = parseViolationFromMessage(crashInfo.exceptionMessage);
+ violationMask |= violationBit;
+ final int savedPolicy = getThreadBlockingPolicy();
try {
+ // First, remove any policy before we call into the Activity Manager,
+ // otherwise we'll infinite recurse as we try to log policy violations
+ // to disk, thus violating policy, thus requiring logging, etc...
+ // We restore the current policy below, in the finally block.
+ setThreadBlockingPolicy(0);
+
ActivityManagerNative.getDefault().handleApplicationStrictModeViolation(
RuntimeInit.getApplicationObject(),
violationMask,
- new ApplicationErrorReport.CrashInfo(violation));
+ crashInfo);
} catch (RemoteException e) {
Log.e(TAG, "RemoteException trying to handle StrictMode violation", e);
+ } finally {
+ // Restore the policy.
+ setThreadBlockingPolicy(savedPolicy);
}
}
@@ -244,4 +396,91 @@
}
}
}
+
+ /**
+ * Called from Parcel.writeNoException()
+ */
+ /* package */ static boolean hasGatheredViolations() {
+ return gatheredViolations.get() != null;
+ }
+
+ /**
+ * Called from Parcel.writeException(), so we drop this memory and
+ * don't incorrectly attribute it to the wrong caller on the next
+ * Binder call on this thread.
+ */
+ /* package */ static void clearGatheredViolations() {
+ gatheredViolations.set(null);
+ }
+
+ /**
+ * Called from Parcel.writeNoException()
+ */
+ /* package */ static void writeGatheredViolationsToParcel(Parcel p) {
+ ArrayList<ApplicationErrorReport.CrashInfo> violations = gatheredViolations.get();
+ if (violations == null) {
+ p.writeInt(0);
+ } else {
+ p.writeInt(violations.size());
+ for (int i = 0; i < violations.size(); ++i) {
+ violations.get(i).writeToParcel(p, 0 /* unused flags? */);
+ }
+ if (LOG_V) Log.d(TAG, "wrote violations to response parcel; num=" + violations.size());
+ violations.clear(); // somewhat redundant, as we're about to null the threadlocal
+ }
+ gatheredViolations.set(null);
+ }
+
+ private static class LogStackTrace extends Exception {}
+
+ /**
+ * Called from Parcel.readException() when the exception is EX_STRICT_MODE_VIOLATIONS,
+ * we here read back all the encoded violations.
+ */
+ /* package */ static void readAndHandleBinderCallViolations(Parcel p) {
+ // Our own stack trace to append
+ Exception e = new LogStackTrace();
+ StringWriter sw = new StringWriter();
+ e.printStackTrace(new PrintWriter(sw));
+ String ourStack = sw.toString();
+
+ int policyMask = getThreadBlockingPolicy();
+
+ int numViolations = p.readInt();
+ for (int i = 0; i < numViolations; ++i) {
+ if (LOG_V) Log.d(TAG, "strict mode violation stacks read from binder call. i=" + i);
+ ApplicationErrorReport.CrashInfo crashInfo = new ApplicationErrorReport.CrashInfo(p);
+ crashInfo.stackTrace += "# via Binder call with stack:\n" + ourStack;
+
+ // Unlike the in-process violations in which case we
+ // trigger an error _before_ the thing occurs, in this
+ // case the violating thing has already occurred, so we
+ // can't use our heuristic of waiting for the next event
+ // loop idle cycle to measure the approximate violation
+ // duration. Instead, just skip that step and use -1
+ // (unknown duration) for now.
+ // TODO: keep a thread-local on remote process of first
+ // violation time's uptimeMillis, and when writing that
+ // back out in Parcel reply, include in the header the
+ // violation time and use it here.
+ crashInfo.durationMillis = -1;
+
+ BlockGuard.Policy policy = BlockGuard.getThreadPolicy();
+ if (policy instanceof AndroidBlockGuardPolicy) {
+ ((AndroidBlockGuardPolicy) policy).handleViolation(crashInfo, policyMask);
+ }
+ }
+ }
+
+ /**
+ * Called from android_util_Binder.cpp's
+ * android_os_Parcel_enforceInterface when an incoming Binder call
+ * requires changing the StrictMode policy mask. The role of this
+ * function is to ask Binder for its current (native) thread-local
+ * policy value and synchronize it to libcore's (Java)
+ * thread-local policy value.
+ */
+ private static void onBinderStrictModePolicyChange(int newPolicy) {
+ setBlockGuardPolicy(newPolicy);
+ }
}
diff --git a/core/java/android/os/storage/IMountService.aidl b/core/java/android/os/storage/IMountService.aidl
index 4862f80..ca7efe7 100644
--- a/core/java/android/os/storage/IMountService.aidl
+++ b/core/java/android/os/storage/IMountService.aidl
@@ -152,4 +152,26 @@
* processing the media status update request.
*/
void finishMediaUpdate();
+
+ /**
+ * Mounts an Opaque Binary Blob (OBB) with the specified decryption key and only
+ * allows the calling process's UID access to the contents.
+ */
+ int mountObb(String filename, String key);
+
+ /**
+ * Unmounts an Opaque Binary Blob (OBB). When the force flag is specified, any
+ * program using it will be forcibly killed to unmount the image.
+ */
+ int unmountObb(String filename, boolean force);
+
+ /**
+ * Checks whether the specified Opaque Binary Blob (OBB) is mounted somewhere.
+ */
+ boolean isObbMounted(String filename);
+
+ /**
+ * Gets the path to the mounted Opaque Binary Blob (OBB).
+ */
+ String getMountedObbPath(String filename);
}
diff --git a/core/java/android/os/storage/StorageManager.java b/core/java/android/os/storage/StorageManager.java
index a12603c..96bf2d5 100644
--- a/core/java/android/os/storage/StorageManager.java
+++ b/core/java/android/os/storage/StorageManager.java
@@ -44,9 +44,6 @@
* Get an instance of this class by calling
* {@link android.content.Context#getSystemService(java.lang.String)} with an argument
* of {@link android.content.Context#STORAGE_SERVICE}.
- *
- * @hide
- *
*/
public class StorageManager
@@ -209,6 +206,7 @@
*
* @param listener A {@link android.os.storage.StorageEventListener StorageEventListener} object.
*
+ * @hide
*/
public void registerListener(StorageEventListener listener) {
if (listener == null) {
@@ -225,6 +223,7 @@
*
* @param listener A {@link android.os.storage.StorageEventListener StorageEventListener} object.
*
+ * @hide
*/
public void unregisterListener(StorageEventListener listener) {
if (listener == null) {
@@ -245,6 +244,8 @@
/**
* Enables USB Mass Storage (UMS) on the device.
+ *
+ * @hide
*/
public void enableUsbMassStorage() {
try {
@@ -256,6 +257,8 @@
/**
* Disables USB Mass Storage (UMS) on the device.
+ *
+ * @hide
*/
public void disableUsbMassStorage() {
try {
@@ -268,6 +271,8 @@
/**
* Query if a USB Mass Storage (UMS) host is connected.
* @return true if UMS host is connected.
+ *
+ * @hide
*/
public boolean isUsbMassStorageConnected() {
try {
@@ -281,6 +286,8 @@
/**
* Query if a USB Mass Storage (UMS) is enabled on the device.
* @return true if UMS host is enabled.
+ *
+ * @hide
*/
public boolean isUsbMassStorageEnabled() {
try {
@@ -290,4 +297,55 @@
}
return false;
}
+
+ /**
+ * Mount an OBB file.
+ */
+ public boolean mountObb(String filename, String key) {
+ try {
+ return mMountService.mountObb(filename, key)
+ == StorageResultCode.OperationSucceeded;
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to mount OBB", e);
+ }
+
+ return false;
+ }
+
+ /**
+ * Mount an OBB file.
+ */
+ public boolean unmountObb(String filename, boolean force) {
+ try {
+ return mMountService.unmountObb(filename, force)
+ == StorageResultCode.OperationSucceeded;
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to mount OBB", e);
+ }
+
+ return false;
+ }
+
+ public boolean isObbMounted(String filename) {
+ try {
+ return mMountService.isObbMounted(filename);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to check if OBB is mounted", e);
+ }
+
+ return false;
+ }
+
+ /**
+ * Check the mounted path of an OBB file.
+ */
+ public String getMountedObbPath(String filename) {
+ try {
+ return mMountService.getMountedObbPath(filename);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to find mounted path for OBB", e);
+ }
+
+ return null;
+ }
}
diff --git a/core/java/android/provider/ContactsContract.java b/core/java/android/provider/ContactsContract.java
index 40a408a..f0ee838 100644
--- a/core/java/android/provider/ContactsContract.java
+++ b/core/java/android/provider/ContactsContract.java
@@ -409,6 +409,13 @@
public static final String CONTACT_PRESENCE = "contact_presence";
/**
+ * Contact Chat Capabilities. See {@link StatusUpdates} for individual
+ * definitions.
+ * <p>Type: NUMBER</p>
+ */
+ public static final String CONTACT_CHAT_CAPABILITY = "contact_chat_capability";
+
+ /**
* Contact's latest status update.
* <p>Type: TEXT</p>
*/
@@ -1950,6 +1957,29 @@
* <p>Type: NUMBER</p>
*/
public static final String STATUS_ICON = "status_icon";
+
+ /**
+ * Contact's audio/video chat capability level.
+ * <P>Type: INTEGER (one of the values below)</P>
+ */
+ public static final String CHAT_CAPABILITY = "chat_capability";
+
+ /**
+ * An allowed value of {@link #CHAT_CAPABILITY}. Indicates that the contact's device can
+ * display a video feed.
+ */
+ public static final int CAPABILITY_HAS_VIDEO_PLAYBACK_ONLY = 1;
+
+ /**
+ * An allowed value of {@link #CHAT_CAPABILITY}. Indicates audio-chat capability.
+ */
+ public static final int CAPABILITY_HAS_VOICE = 2;
+
+ /**
+ * An allowed value of {@link #CHAT_CAPABILITY}. Indicates that the contact's device has a
+ * camera that can be used for video chat (e.g. a front-facing camera on a phone).
+ */
+ public static final int CAPABILITY_HAS_CAMERA = 4;
}
/**
@@ -3095,6 +3125,25 @@
* </td>
* </tr>
* <tr>
+ * <td>int</td>
+ * <td>{@link #CHAT_CAPABILITY}</td>
+ * <td>read/write</td>
+ * <td>Contact IM chat compatibility value. The allowed values are:
+ * <p>
+ * <ul>
+ * <li>{@link #CAPABILITY_HAS_VIDEO_PLAYBACK_ONLY}</li>
+ * <li>{@link #CAPABILITY_HAS_VOICE}</li>
+ * <li>{@link #CAPABILITY_HAS_CAMERA}</li>
+ * </ul>
+ * </p>
+ * <p>
+ * Since chat compatibility is inherently volatile as the contact's availability moves from
+ * one device to another, the content provider may choose not to store this field in long-term
+ * storage.
+ * </p>
+ * </td>
+ * </tr>
+ * <tr>
* <td>String</td>
* <td>{@link #STATUS}</td>
* <td>read/write</td>
diff --git a/core/java/android/server/BluetoothService.java b/core/java/android/server/BluetoothService.java
index 31e5a7b..f00389b 100644
--- a/core/java/android/server/BluetoothService.java
+++ b/core/java/android/server/BluetoothService.java
@@ -919,7 +919,7 @@
Log.e(TAG, "Error:Adapter Property at index" + i + "is null");
continue;
}
- if (name.equals("Devices")) {
+ if (name.equals("Devices") || name.equals("UUIDs")) {
StringBuilder str = new StringBuilder();
len = Integer.valueOf(properties[++i]);
for (int j = 0; j < len; j++) {
diff --git a/core/java/android/service/wallpaper/WallpaperService.java b/core/java/android/service/wallpaper/WallpaperService.java
index e26a090..57a72bf 100644
--- a/core/java/android/service/wallpaper/WallpaperService.java
+++ b/core/java/android/service/wallpaper/WallpaperService.java
@@ -41,6 +41,7 @@
import android.view.Gravity;
import android.view.IWindowSession;
import android.view.InputChannel;
+import android.view.InputDevice;
import android.view.InputHandler;
import android.view.InputQueue;
import android.view.KeyEvent;
@@ -214,9 +215,12 @@
final InputHandler mInputHandler = new BaseInputHandler() {
@Override
- public void handleTouch(MotionEvent event, Runnable finishedCallback) {
+ public void handleMotion(MotionEvent event, Runnable finishedCallback) {
try {
- dispatchPointer(event);
+ int source = event.getSource();
+ if ((source & InputDevice.SOURCE_CLASS_POINTER) != 0) {
+ dispatchPointer(event);
+ }
} finally {
finishedCallback.run();
}
diff --git a/core/java/android/view/InputChannel.java b/core/java/android/view/InputChannel.java
index e24c3c9..f2cad2f 100644
--- a/core/java/android/view/InputChannel.java
+++ b/core/java/android/view/InputChannel.java
@@ -30,6 +30,8 @@
public final class InputChannel implements Parcelable {
private static final String TAG = "InputChannel";
+ private static final boolean DEBUG = false;
+
public static final Parcelable.Creator<InputChannel> CREATOR
= new Parcelable.Creator<InputChannel>() {
public InputChannel createFromParcel(Parcel source) {
@@ -84,8 +86,10 @@
if (name == null) {
throw new IllegalArgumentException("name must not be null");
}
-
- Slog.d(TAG, "Opening input channel pair '" + name + "'");
+
+ if (DEBUG) {
+ Slog.d(TAG, "Opening input channel pair '" + name + "'");
+ }
return nativeOpenInputChannelPair(name);
}
diff --git a/core/java/android/view/InputDevice.java b/core/java/android/view/InputDevice.java
new file mode 100755
index 0000000..21c2976
--- /dev/null
+++ b/core/java/android/view/InputDevice.java
@@ -0,0 +1,351 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+package android.view;
+
+/**
+ * Describes the capabilities of a particular input device.
+ * <p>
+ * Each input device may support multiple classes of input. For example, a multifunction
+ * keyboard may compose the capabilities of a standard keyboard together with a track pad mouse
+ * or other pointing device.
+ * </p><p>
+ * Some input devices present multiple distinguishable sources of input. For example, a
+ * game pad may have two analog joysticks, a directional pad and a full complement of buttons.
+ * Applications can query the framework about the characteristics of each distinct source.
+ * </p><p>
+ * As a further wrinkle, different kinds of input sources uses different coordinate systems
+ * to describe motion events. Refer to the comments on the input source constants for
+ * the appropriate interpretation.
+ */
+public final class InputDevice {
+ private int mId;
+ private String mName;
+ private int mSources;
+
+ /**
+ * A mask for input source classes.
+ *
+ * Each distinct input source constant has one or more input source class bits set to
+ * specify the desired interpretation for its input events.
+ */
+ public static final int SOURCE_CLASS_MASK = 0x000000ff;
+
+ /**
+ * The input source has buttons or keys.
+ * Examples: {@link #SOURCE_KEYBOARD}, {@link #SOURCE_GAMEPAD}, {@link #SOURCE_DPAD}.
+ *
+ * A {@link KeyEvent} should be interpreted as a button or key press.
+ *
+ * Use {@link #hasKey} to query whether the device supports a particular button or key.
+ */
+ public static final int SOURCE_CLASS_BUTTON = 0x00000001;
+
+ /**
+ * The input source is a pointing device associated with a display.
+ * Examples: {@link #SOURCE_TOUCHSCREEN}, {@link #SOURCE_MOUSE}.
+ *
+ * A {@link MotionEvent} should be interpreted as absolute coordinates in
+ * display units according to the {@link View} hierarchy. Pointer down/up indicated when
+ * the finger touches the display or when the selection button is pressed/released.
+ *
+ * Use {@link #getMotionRange} to query the range of the pointing device. Some devices permit
+ * touches outside the display area so the effective range may be somewhat smaller or larger
+ * than the actual display size.
+ */
+ public static final int SOURCE_CLASS_POINTER = 0x00000002;
+
+ /**
+ * The input source is a trackball navigation device.
+ * Examples: {@link #SOURCE_TRACKBALL}.
+ *
+ * A {@link MotionEvent} should be interpreted as relative movements in device-specific
+ * units used for navigation purposes. Pointer down/up indicates when the selection button
+ * is pressed/released.
+ *
+ * Use {@link #getMotionRange} to query the range of motion.
+ */
+ public static final int SOURCE_CLASS_TRACKBALL = 0x00000004;
+
+ /**
+ * The input source is an absolute positioning device not associated with a display
+ * (unlike {@link #SOURCE_CLASS_POINTER}).
+ *
+ * A {@link MotionEvent} should be interpreted as absolute coordinates in
+ * device-specific surface units.
+ *
+ * Use {@link #getMotionRange} to query the range of positions.
+ */
+ public static final int SOURCE_CLASS_POSITION = 0x00000008;
+
+ /**
+ * The input source is a joystick.
+ *
+ * A {@link KeyEvent} should be interpreted as a joystick button press.
+ *
+ * A {@link MotionEvent} should be interpreted in absolute coordinates as a joystick
+ * position in normalized device-specific units nominally between -1.0 and 1.0.
+ *
+ * Use {@link #getMotionRange} to query the range and precision of motion.
+ */
+ public static final int SOURCE_CLASS_JOYSTICK = 0x00000010;
+
+ /**
+ * The input source is unknown.
+ */
+ public static final int SOURCE_UNKNOWN = 0x00000000;
+
+ /**
+ * The input source is a keyboard.
+ *
+ * @see #SOURCE_CLASS_BUTTON
+ */
+ public static final int SOURCE_KEYBOARD = 0x00000100 | SOURCE_CLASS_BUTTON;
+
+ /**
+ * The input source is a DPad.
+ *
+ * @see #SOURCE_CLASS_BUTTON
+ */
+ public static final int SOURCE_DPAD = 0x00000200 | SOURCE_CLASS_BUTTON;
+
+ /**
+ * The input source is a gamepad.
+ *
+ * @see #SOURCE_CLASS_BUTTON
+ */
+ public static final int SOURCE_GAMEPAD = 0x00000400 | SOURCE_CLASS_BUTTON;
+
+ /**
+ * The input source is a touch screen pointing device.
+ *
+ * @see #SOURCE_CLASS_POINTER
+ */
+ public static final int SOURCE_TOUCHSCREEN = 0x00001000 | SOURCE_CLASS_POINTER;
+
+ /**
+ * The input source is a mouse pointing device.
+ * This code is also used for other mouse-like pointing devices such as trackpads
+ * and trackpoints.
+ *
+ * @see #SOURCE_CLASS_POINTER
+ */
+ public static final int SOURCE_MOUSE = 0x00002000 | SOURCE_CLASS_POINTER;
+
+ /**
+ * The input source is a trackball.
+ *
+ * @see #SOURCE_CLASS_TRACKBALL
+ */
+ public static final int SOURCE_TRACKBALL = 0x00010000 | SOURCE_CLASS_TRACKBALL;
+
+ /**
+ * The input source is a touch pad or digitizer tablet that is not
+ * associated with a display (unlike {@link #SOURCE_TOUCHSCREEN}).
+ *
+ * @see #SOURCE_CLASS_POSITION
+ */
+ public static final int SOURCE_TOUCHPAD = 0x00100000 | SOURCE_CLASS_POSITION;
+
+ /**
+ * The input source is a joystick mounted on the left or is a standalone joystick.
+ *
+ * @see #SOURCE_CLASS_JOYSTICK
+ */
+ public static final int SOURCE_JOYSTICK_LEFT = 0x01000000 | SOURCE_CLASS_JOYSTICK;
+
+ /**
+ * The input source is a joystick mounted on the right.
+ *
+ * @see #SOURCE_CLASS_JOYSTICK
+ */
+ public static final int SOURCE_JOYSTICK_RIGHT = 0x02000000 | SOURCE_CLASS_JOYSTICK;
+
+ /**
+ * Constant for retrieving the range of values for {@link MotionEvent.PointerCoords#x}.
+ *
+ * @see #getMotionRange
+ */
+ public static final int MOTION_RANGE_X = 0;
+
+ /**
+ * Constant for retrieving the range of values for {@link MotionEvent.PointerCoords#y}.
+ *
+ * @see #getMotionRange
+ */
+ public static final int MOTION_RANGE_Y = 1;
+
+ /**
+ * Constant for retrieving the range of values for {@link MotionEvent.PointerCoords#pressure}.
+ *
+ * @see #getMotionRange
+ */
+ public static final int MOTION_RANGE_PRESSURE = 2;
+
+ /**
+ * Constant for retrieving the range of values for {@link MotionEvent.PointerCoords#size}.
+ *
+ * @see #getMotionRange
+ */
+ public static final int MOTION_RANGE_SIZE = 3;
+
+ /**
+ * Constant for retrieving the range of values for {@link MotionEvent.PointerCoords#touchMajor}.
+ *
+ * @see #getMotionRange
+ */
+ public static final int MOTION_RANGE_TOUCH_MAJOR = 4;
+
+ /**
+ * Constant for retrieving the range of values for {@link MotionEvent.PointerCoords#touchMinor}.
+ *
+ * @see #getMotionRange
+ */
+ public static final int MOTION_RANGE_TOUCH_MINOR = 5;
+
+ /**
+ * Constant for retrieving the range of values for {@link MotionEvent.PointerCoords#toolMajor}.
+ *
+ * @see #getMotionRange
+ */
+ public static final int MOTION_RANGE_TOOL_MAJOR = 6;
+
+ /**
+ * Constant for retrieving the range of values for {@link MotionEvent.PointerCoords#toolMinor}.
+ *
+ * @see #getMotionRange
+ */
+ public static final int MOTION_RANGE_TOOL_MINOR = 7;
+
+ /**
+ * Constant for retrieving the range of values for
+ * {@link MotionEvent.PointerCoords#orientation}.
+ *
+ * @see #getMotionRange
+ */
+ public static final int MOTION_RANGE_ORIENTATION = 8;
+
+ /**
+ * Gets information about the input device with the specified id.
+ * @param id The device id.
+ * @return The input device or null if not found.
+ */
+ public static InputDevice getDevice(int id) {
+ // TODO
+ return null;
+ }
+
+ /**
+ * Gets the name of this input device.
+ * @return The input device name.
+ */
+ public String getName() {
+ return mName;
+ }
+
+ /**
+ * Gets the input sources supported by this input device as a combined bitfield.
+ * @return The supported input sources.
+ */
+ public int getSources() {
+ return mSources;
+ }
+
+ /**
+ * Gets the key character map associated with this input device.
+ * @return The key character map.
+ */
+ public KeyCharacterMap getKeyCharacterMap() {
+ return KeyCharacterMap.load(mId);
+ }
+
+ /**
+ * Gets information about the range of values for a particular {@link MotionEvent}
+ * coordinate.
+ * @param range The motion range constant.
+ * @return The range of values, or null if the requested coordinate is not
+ * supported by the device.
+ */
+ public MotionRange getMotionRange(int range) {
+ // TODO
+ return null;
+ }
+
+ /**
+ * Returns true if the device supports a particular button or key.
+ * @param keyCode The key code.
+ * @return True if the device supports the key.
+ */
+ public boolean hasKey(int keyCode) {
+ // TODO
+ return false;
+ }
+
+ /**
+ * Provides information about the range of values for a particular {@link MotionEvent}
+ * coordinate.
+ */
+ public static final class MotionRange {
+ /**
+ * Gets the minimum value for the coordinate.
+ * @return The minimum value.
+ */
+ public float getMin() {
+ // TODO
+ return 0;
+ }
+
+ /**
+ * Gets the maximum value for the coordinate.
+ * @return The minimum value.
+ */
+ public float getMax() {
+ // TODO
+ return 0;
+ }
+
+ /**
+ * Gets the range of the coordinate (difference between maximum and minimum).
+ * @return The range of values.
+ */
+ public float getRange() {
+ // TODO
+ return 0;
+ }
+
+ /**
+ * Gets the extent of the center flat position with respect to this coordinate.
+ * For example, a flat value of 8 means that the center position is between -8 and +8.
+ * This value is mainly useful for calibrating joysticks.
+ * @return The extent of the center flat position.
+ */
+ public float getFlat() {
+ // TODO
+ return 0;
+ }
+
+ /**
+ * Gets the error tolerance for input device measurements with respect to this coordinate.
+ * For example, a value of 2 indicates that the measured value may be up to +/- 2 units
+ * away from the actual value due to noise and device sensitivity limitations.
+ * @return The error tolerance.
+ */
+ public float getFuzz() {
+ // TODO
+ return 0;
+ }
+ }
+}
diff --git a/core/java/android/view/InputEvent.java b/core/java/android/view/InputEvent.java
new file mode 100755
index 0000000..78b73fe
--- /dev/null
+++ b/core/java/android/view/InputEvent.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+package android.view;
+
+import android.os.Parcelable;
+
+/**
+ * Common base class for input events.
+ */
+public abstract class InputEvent implements Parcelable {
+ protected int mDeviceId;
+ protected int mSource;
+
+ /*package*/ InputEvent() {
+ }
+
+ /**
+ * Gets the id for the device that this event came from. An id of
+ * zero indicates that the event didn't come from a physical device
+ * and maps to the default keymap. The other numbers are arbitrary and
+ * you shouldn't depend on the values.
+ *
+ * @return The device id.
+ * @see InputDevice#getDevice
+ */
+ public final int getDeviceId() {
+ return mDeviceId;
+ }
+
+ /**
+ * Gets the device that this event came from.
+ *
+ * @return The device, or null if unknown.
+ */
+ public final InputDevice getDevice() {
+ return InputDevice.getDevice(mDeviceId);
+ }
+
+ /**
+ * Gets the source of the event.
+ *
+ * @return The event source or {@link InputDevice#SOURCE_UNKNOWN} if unknown.
+ * @see InputDevice#getSourceInfo
+ */
+ public final int getSource() {
+ return mSource;
+ }
+
+ /**
+ * Modifies the source of the event.
+ * @param source The source.
+ *
+ * @hide
+ */
+ public final void setSource(int source) {
+ mSource = source;
+ }
+}
diff --git a/core/java/android/view/InputHandler.java b/core/java/android/view/InputHandler.java
index 816f622..41a152d 100644
--- a/core/java/android/view/InputHandler.java
+++ b/core/java/android/view/InputHandler.java
@@ -32,22 +32,12 @@
public void handleKey(KeyEvent event, Runnable finishedCallback);
/**
- * Handle a touch event.
+ * Handle a motion event.
* It is the responsibility of the callee to ensure that the finished callback is
* eventually invoked when the event processing is finished and the input system
* can send the next event.
* @param event The motion event data.
* @param finishedCallback The callback to invoke when event processing is finished.
*/
- public void handleTouch(MotionEvent event, Runnable finishedCallback);
-
- /**
- * Handle a trackball event.
- * It is the responsibility of the callee to ensure that the finished callback is
- * eventually invoked when the event processing is finished and the input system
- * can send the next event.
- * @param event The motion event data.
- * @param finishedCallback The callback to invoke when event processing is finished.
- */
- public void handleTrackball(MotionEvent event, Runnable finishedCallback);
+ public void handleMotion(MotionEvent event, Runnable finishedCallback);
}
diff --git a/core/java/android/view/InputQueue.java b/core/java/android/view/InputQueue.java
index 7feee38..997246f 100644
--- a/core/java/android/view/InputQueue.java
+++ b/core/java/android/view/InputQueue.java
@@ -26,6 +26,8 @@
public final class InputQueue {
private static final String TAG = "InputQueue";
+ private static final boolean DEBUG = false;
+
public static interface Callback {
void onInputQueueCreated(InputQueue queue);
void onInputQueueDestroyed(InputQueue queue);
@@ -33,15 +35,6 @@
final InputChannel mChannel;
- // Describes the interpretation of an event.
- // XXX This concept is tentative. See comments in android/input.h.
- /** @hide */
- public static final int INPUT_EVENT_NATURE_KEY = 1;
- /** @hide */
- public static final int INPUT_EVENT_NATURE_TOUCH = 2;
- /** @hide */
- public static final int INPUT_EVENT_NATURE_TRACKBALL = 3;
-
private static Object sLock = new Object();
private static native void nativeRegisterInputChannel(InputChannel inputChannel,
@@ -79,7 +72,10 @@
}
synchronized (sLock) {
- Slog.d(TAG, "Registering input channel '" + inputChannel + "'");
+ if (DEBUG) {
+ Slog.d(TAG, "Registering input channel '" + inputChannel + "'");
+ }
+
nativeRegisterInputChannel(inputChannel, inputHandler, messageQueue);
}
}
@@ -96,35 +92,26 @@
}
synchronized (sLock) {
- Slog.d(TAG, "Unregistering input channel '" + inputChannel + "'");
+ if (DEBUG) {
+ Slog.d(TAG, "Unregistering input channel '" + inputChannel + "'");
+ }
+
nativeUnregisterInputChannel(inputChannel);
}
}
@SuppressWarnings("unused")
private static void dispatchKeyEvent(InputHandler inputHandler,
- KeyEvent event, int nature, long finishedToken) {
+ KeyEvent event, long finishedToken) {
Runnable finishedCallback = new FinishedCallback(finishedToken);
-
- if (nature == INPUT_EVENT_NATURE_KEY) {
- inputHandler.handleKey(event, finishedCallback);
- } else {
- Slog.d(TAG, "Unsupported nature for key event: " + nature);
- }
+ inputHandler.handleKey(event, finishedCallback);
}
@SuppressWarnings("unused")
private static void dispatchMotionEvent(InputHandler inputHandler,
- MotionEvent event, int nature, long finishedToken) {
+ MotionEvent event, long finishedToken) {
Runnable finishedCallback = new FinishedCallback(finishedToken);
-
- if (nature == INPUT_EVENT_NATURE_TOUCH) {
- inputHandler.handleTouch(event, finishedCallback);
- } else if (nature == INPUT_EVENT_NATURE_TRACKBALL) {
- inputHandler.handleTrackball(event, finishedCallback);
- } else {
- Slog.d(TAG, "Unsupported nature for motion event: " + nature);
- }
+ inputHandler.handleMotion(event, finishedCallback);
}
// TODO consider recycling finished callbacks when done
diff --git a/core/java/android/view/KeyCharacterMap.java b/core/java/android/view/KeyCharacterMap.java
index 25958aa..9981d87 100644
--- a/core/java/android/view/KeyCharacterMap.java
+++ b/core/java/android/view/KeyCharacterMap.java
@@ -26,6 +26,9 @@
import java.lang.Character;
import java.lang.ref.WeakReference;
+/**
+ * Describes the keys provided by a device and their associated labels.
+ */
public class KeyCharacterMap
{
/**
@@ -59,6 +62,11 @@
private static SparseArray<WeakReference<KeyCharacterMap>> sInstances
= new SparseArray<WeakReference<KeyCharacterMap>>();
+ /**
+ * Loads the key character maps for the keyboard with the specified device id.
+ * @param keyboard The device id of the keyboard.
+ * @return The associated key character map.
+ */
public static KeyCharacterMap load(int keyboard)
{
synchronized (sLock) {
diff --git a/core/java/android/view/KeyEvent.java b/core/java/android/view/KeyEvent.java
index 9c05008..dd0d21a3 100755
--- a/core/java/android/view/KeyEvent.java
+++ b/core/java/android/view/KeyEvent.java
@@ -26,7 +26,7 @@
/**
* Contains constants for key events.
*/
-public class KeyEvent implements Parcelable {
+public class KeyEvent extends InputEvent implements Parcelable {
// key codes
public static final int KEYCODE_UNKNOWN = 0;
public static final int KEYCODE_SOFT_LEFT = 1;
@@ -349,7 +349,6 @@
private int mKeyCode;
private int mScanCode;
private int mRepeatCount;
- private int mDeviceId;
private int mFlags;
private long mDownTime;
private long mEventTime;
@@ -484,19 +483,19 @@
* @param repeat A repeat count for down events (> 0 if this is after the
* initial down) or event count for multiple events.
* @param metaState Flags indicating which meta keys are currently pressed.
- * @param device The device ID that generated the key event.
+ * @param deviceId The device ID that generated the key event.
* @param scancode Raw device scan code of the event.
*/
public KeyEvent(long downTime, long eventTime, int action,
int code, int repeat, int metaState,
- int device, int scancode) {
+ int deviceId, int scancode) {
mDownTime = downTime;
mEventTime = eventTime;
mAction = action;
mKeyCode = code;
mRepeatCount = repeat;
mMetaState = metaState;
- mDeviceId = device;
+ mDeviceId = deviceId;
mScanCode = scancode;
}
@@ -513,44 +512,79 @@
* @param repeat A repeat count for down events (> 0 if this is after the
* initial down) or event count for multiple events.
* @param metaState Flags indicating which meta keys are currently pressed.
- * @param device The device ID that generated the key event.
+ * @param deviceId The device ID that generated the key event.
* @param scancode Raw device scan code of the event.
* @param flags The flags for this key event
*/
public KeyEvent(long downTime, long eventTime, int action,
int code, int repeat, int metaState,
- int device, int scancode, int flags) {
+ int deviceId, int scancode, int flags) {
mDownTime = downTime;
mEventTime = eventTime;
mAction = action;
mKeyCode = code;
mRepeatCount = repeat;
mMetaState = metaState;
- mDeviceId = device;
+ mDeviceId = deviceId;
mScanCode = scancode;
mFlags = flags;
}
/**
+ * Create a new key event.
+ *
+ * @param downTime The time (in {@link android.os.SystemClock#uptimeMillis})
+ * at which this key code originally went down.
+ * @param eventTime The time (in {@link android.os.SystemClock#uptimeMillis})
+ * at which this event happened.
+ * @param action Action code: either {@link #ACTION_DOWN},
+ * {@link #ACTION_UP}, or {@link #ACTION_MULTIPLE}.
+ * @param code The key code.
+ * @param repeat A repeat count for down events (> 0 if this is after the
+ * initial down) or event count for multiple events.
+ * @param metaState Flags indicating which meta keys are currently pressed.
+ * @param deviceId The device ID that generated the key event.
+ * @param scancode Raw device scan code of the event.
+ * @param flags The flags for this key event
+ * @param source The input source such as {@link InputDevice#SOURCE_KEYBOARD}.
+ */
+ public KeyEvent(long downTime, long eventTime, int action,
+ int code, int repeat, int metaState,
+ int deviceId, int scancode, int flags, int source) {
+ mDownTime = downTime;
+ mEventTime = eventTime;
+ mAction = action;
+ mKeyCode = code;
+ mRepeatCount = repeat;
+ mMetaState = metaState;
+ mDeviceId = deviceId;
+ mScanCode = scancode;
+ mFlags = flags;
+ mSource = source;
+ }
+
+ /**
* Create a new key event for a string of characters. The key code,
- * action, and repeat could will automatically be set to
- * {@link #KEYCODE_UNKNOWN}, {@link #ACTION_MULTIPLE}, and 0 for you.
+ * action, repeat count and source will automatically be set to
+ * {@link #KEYCODE_UNKNOWN}, {@link #ACTION_MULTIPLE}, 0, and
+ * {@link InputDevice#SOURCE_KEYBOARD} for you.
*
* @param time The time (in {@link android.os.SystemClock#uptimeMillis})
* at which this event occured.
* @param characters The string of characters.
- * @param device The device ID that generated the key event.
+ * @param deviceId The device ID that generated the key event.
* @param flags The flags for this key event
*/
- public KeyEvent(long time, String characters, int device, int flags) {
+ public KeyEvent(long time, String characters, int deviceId, int flags) {
mDownTime = time;
mEventTime = time;
mCharacters = characters;
mAction = ACTION_MULTIPLE;
mKeyCode = KEYCODE_UNKNOWN;
mRepeatCount = 0;
- mDeviceId = device;
+ mDeviceId = deviceId;
mFlags = flags;
+ mSource = InputDevice.SOURCE_KEYBOARD;
}
/**
@@ -564,6 +598,7 @@
mRepeatCount = origEvent.mRepeatCount;
mMetaState = origEvent.mMetaState;
mDeviceId = origEvent.mDeviceId;
+ mSource = origEvent.mSource;
mScanCode = origEvent.mScanCode;
mFlags = origEvent.mFlags;
mCharacters = origEvent.mCharacters;
@@ -589,6 +624,7 @@
mRepeatCount = newRepeat;
mMetaState = origEvent.mMetaState;
mDeviceId = origEvent.mDeviceId;
+ mSource = origEvent.mSource;
mScanCode = origEvent.mScanCode;
mFlags = origEvent.mFlags;
mCharacters = origEvent.mCharacters;
@@ -642,6 +678,7 @@
mRepeatCount = origEvent.mRepeatCount;
mMetaState = origEvent.mMetaState;
mDeviceId = origEvent.mDeviceId;
+ mSource = origEvent.mSource;
mScanCode = origEvent.mScanCode;
mFlags = origEvent.mFlags;
// Don't copy mCharacters, since one way or the other we'll lose it
@@ -897,18 +934,6 @@
}
/**
- * Return the id for the keyboard that this event came from. A device
- * id of 0 indicates the event didn't come from a physical device and
- * maps to the default keymap. The other numbers are arbitrary and
- * you shouldn't depend on the values.
- *
- * @see KeyCharacterMap#load
- */
- public final int getDeviceId() {
- return mDeviceId;
- }
-
- /**
* Renamed to {@link #getDeviceId}.
*
* @hide
@@ -1204,6 +1229,7 @@
out.writeInt(mRepeatCount);
out.writeInt(mMetaState);
out.writeInt(mDeviceId);
+ out.writeInt(mSource);
out.writeInt(mScanCode);
out.writeInt(mFlags);
out.writeLong(mDownTime);
@@ -1216,6 +1242,7 @@
mRepeatCount = in.readInt();
mMetaState = in.readInt();
mDeviceId = in.readInt();
+ mSource = in.readInt();
mScanCode = in.readInt();
mFlags = in.readInt();
mDownTime = in.readLong();
diff --git a/core/java/android/view/MotionEvent.java b/core/java/android/view/MotionEvent.java
index ae8c21d..13360d9 100644
--- a/core/java/android/view/MotionEvent.java
+++ b/core/java/android/view/MotionEvent.java
@@ -19,16 +19,17 @@
import android.os.Parcel;
import android.os.Parcelable;
import android.os.SystemClock;
-import android.util.Log;
/**
* Object used to report movement (mouse, pen, finger, trackball) events. This
* class may hold either absolute or relative movements, depending on what
* it is being used for.
+ *
+ * Refer to {@link InputDevice} for information about how different kinds of
+ * input devices and sources represent pointer coordinates.
*/
-public final class MotionEvent implements Parcelable {
+public final class MotionEvent extends InputEvent implements Parcelable {
private static final long MS_PER_NS = 1000000;
- static final boolean DEBUG_POINTERS = false;
/**
* Bit mask of the parts of the action code that are the action itself.
@@ -189,22 +190,52 @@
static public final int SAMPLE_Y = 1;
/**
- * Offset for the sample's X coordinate.
+ * Offset for the sample's pressure.
* @hide
*/
static public final int SAMPLE_PRESSURE = 2;
/**
- * Offset for the sample's X coordinate.
+ * Offset for the sample's size
* @hide
*/
static public final int SAMPLE_SIZE = 3;
/**
+ * Offset for the sample's touch major axis length.
+ * @hide
+ */
+ static public final int SAMPLE_TOUCH_MAJOR = 4;
+
+ /**
+ * Offset for the sample's touch minor axis length.
+ * @hide
+ */
+ static public final int SAMPLE_TOUCH_MINOR = 5;
+
+ /**
+ * Offset for the sample's tool major axis length.
+ * @hide
+ */
+ static public final int SAMPLE_TOOL_MAJOR = 6;
+
+ /**
+ * Offset for the sample's tool minor axis length.
+ * @hide
+ */
+ static public final int SAMPLE_TOOL_MINOR = 7;
+
+ /**
+ * Offset for the sample's orientation.
+ * @hide
+ */
+ static public final int SAMPLE_ORIENTATION = 8;
+
+ /**
* Number of data items for each sample.
* @hide
*/
- static public final int NUM_SAMPLE_DATA = 4;
+ static public final int NUM_SAMPLE_DATA = 9;
/**
* Number of possible pointers.
@@ -225,7 +256,6 @@
private float mYOffset;
private float mXPrecision;
private float mYPrecision;
- private int mDeviceId;
private int mEdgeFlags;
private int mMetaState;
@@ -298,18 +328,16 @@
*
* @param downTime The time (in ms) when the user originally pressed down to start
* a stream of position events. This must be obtained from {@link SystemClock#uptimeMillis()}.
- * @param eventTime The the time (in ms) when this specific event was generated. This
+ * @param eventTime The the time (in ms) when this specific event was generated. This
* must be obtained from {@link SystemClock#uptimeMillis()}.
- * @param eventTimeNano The the time (in ns) when this specific event was generated. This
- * must be obtained from {@link System#nanoTime()}.
* @param action The kind of action being performed -- one of either
* {@link #ACTION_DOWN}, {@link #ACTION_MOVE}, {@link #ACTION_UP}, or
* {@link #ACTION_CANCEL}.
* @param pointers The number of points that will be in this event.
- * @param inPointerIds An array of <em>pointers</em> values providing
+ * @param pointerIds An array of <em>pointers</em> values providing
* an identifier for each pointer.
- * @param inData An array of <em>pointers*NUM_SAMPLE_DATA</em> of initial
- * data samples for the event.
+ * @param pointerCoords An array of <em>pointers</em> values providing
+ * a {@link PointerCoords} coordinate object for each pointer.
* @param metaState The state of any meta / modifier keys that were in effect when
* the event was generated.
* @param xPrecision The precision of the X coordinate being reported.
@@ -319,14 +347,15 @@
* numbers are arbitrary and you shouldn't depend on the values.
* @param edgeFlags A bitfield indicating which edges, if any, where touched by this
* MotionEvent.
- *
- * @hide
+ * @param source The source of this event.
*/
- static public MotionEvent obtainNano(long downTime, long eventTime, long eventTimeNano,
- int action, int pointers, int[] inPointerIds, float[] inData, int metaState,
- float xPrecision, float yPrecision, int deviceId, int edgeFlags) {
+ static public MotionEvent obtain(long downTime, long eventTime,
+ int action, int pointers, int[] pointerIds, PointerCoords[] pointerCoords,
+ int metaState, float xPrecision, float yPrecision, int deviceId,
+ int edgeFlags, int source) {
MotionEvent ev = obtain(pointers, 1);
ev.mDeviceId = deviceId;
+ ev.mSource = source;
ev.mEdgeFlags = edgeFlags;
ev.mDownTimeNano = downTime * MS_PER_NS;
ev.mAction = action;
@@ -342,26 +371,11 @@
ev.mLastDataSampleIndex = 0;
ev.mLastEventTimeNanoSampleIndex = 0;
- System.arraycopy(inPointerIds, 0, ev.mPointerIdentifiers, 0, pointers);
+ System.arraycopy(pointerIds, 0, ev.mPointerIdentifiers, 0, pointers);
- ev.mEventTimeNanoSamples[0] = eventTimeNano;
+ ev.mEventTimeNanoSamples[0] = eventTime * MS_PER_NS;
- System.arraycopy(inData, 0, ev.mDataSamples, 0, pointers * NUM_SAMPLE_DATA);
-
- if (DEBUG_POINTERS) {
- StringBuilder sb = new StringBuilder(128);
- sb.append("New:");
- for (int i = 0; i < pointers; i++) {
- sb.append(" #");
- sb.append(ev.getPointerId(i));
- sb.append("(");
- sb.append(ev.getX(i));
- sb.append(",");
- sb.append(ev.getY(i));
- sb.append(")");
- }
- Log.v("MotionEvent", sb.toString());
- }
+ ev.setPointerCoordsAtSampleIndex(0, pointerCoords);
return ev;
}
@@ -402,6 +416,7 @@
float xPrecision, float yPrecision, int deviceId, int edgeFlags) {
MotionEvent ev = obtain(1, 1);
ev.mDeviceId = deviceId;
+ ev.mSource = InputDevice.SOURCE_UNKNOWN;
ev.mEdgeFlags = edgeFlags;
ev.mDownTimeNano = downTime * MS_PER_NS;
ev.mAction = action;
@@ -421,11 +436,7 @@
ev.mEventTimeNanoSamples[0] = eventTime * MS_PER_NS;
- float[] dataSamples = ev.mDataSamples;
- dataSamples[SAMPLE_X] = x;
- dataSamples[SAMPLE_Y] = y;
- dataSamples[SAMPLE_PRESSURE] = pressure;
- dataSamples[SAMPLE_SIZE] = size;
+ ev.setPointerCoordsAtSampleIndex(0, x, y, pressure, size);
return ev;
}
@@ -501,6 +512,7 @@
static public MotionEvent obtain(MotionEvent o) {
MotionEvent ev = obtain(o.mNumPointers, o.mNumSamples);
ev.mDeviceId = o.mDeviceId;
+ ev.mSource = o.mSource;
ev.mEdgeFlags = o.mEdgeFlags;
ev.mDownTimeNano = o.mDownTimeNano;
ev.mAction = o.mAction;
@@ -531,6 +543,7 @@
static public MotionEvent obtainNoHistory(MotionEvent o) {
MotionEvent ev = obtain(o.mNumPointers, 1);
ev.mDeviceId = o.mDeviceId;
+ ev.mSource = o.mSource;
ev.mEdgeFlags = o.mEdgeFlags;
ev.mDownTimeNano = o.mDownTimeNano;
ev.mAction = o.mAction;
@@ -602,6 +615,10 @@
history[i + SAMPLE_Y] *= scale;
// no need to scale pressure
history[i + SAMPLE_SIZE] *= scale; // TODO: square this?
+ history[i + SAMPLE_TOUCH_MAJOR] *= scale;
+ history[i + SAMPLE_TOUCH_MINOR] *= scale;
+ history[i + SAMPLE_TOOL_MAJOR] *= scale;
+ history[i + SAMPLE_TOOL_MINOR] *= scale;
}
}
@@ -696,6 +713,46 @@
public final float getSize() {
return mDataSamples[mLastDataSampleIndex + SAMPLE_SIZE];
}
+
+ /**
+ * {@link #getTouchMajor(int)} for the first pointer index (may be an
+ * arbitrary pointer identifier).
+ */
+ public final float getTouchMajor() {
+ return mDataSamples[mLastDataSampleIndex + SAMPLE_TOUCH_MAJOR];
+ }
+
+ /**
+ * {@link #getTouchMinor(int)} for the first pointer index (may be an
+ * arbitrary pointer identifier).
+ */
+ public final float getTouchMinor() {
+ return mDataSamples[mLastDataSampleIndex + SAMPLE_TOUCH_MINOR];
+ }
+
+ /**
+ * {@link #getToolMajor(int)} for the first pointer index (may be an
+ * arbitrary pointer identifier).
+ */
+ public final float getToolMajor() {
+ return mDataSamples[mLastDataSampleIndex + SAMPLE_TOOL_MAJOR];
+ }
+
+ /**
+ * {@link #getToolMinor(int)} for the first pointer index (may be an
+ * arbitrary pointer identifier).
+ */
+ public final float getToolMinor() {
+ return mDataSamples[mLastDataSampleIndex + SAMPLE_TOOL_MINOR];
+ }
+
+ /**
+ * {@link #getOrientation(int)} for the first pointer index (may be an
+ * arbitrary pointer identifier).
+ */
+ public final float getOrientation() {
+ return mDataSamples[mLastDataSampleIndex + SAMPLE_ORIENTATION];
+ }
/**
* The number of pointers of data contained in this event. Always
@@ -796,6 +853,93 @@
return mDataSamples[mLastDataSampleIndex
+ pointerIndex * NUM_SAMPLE_DATA + SAMPLE_SIZE];
}
+
+ /**
+ * Returns the length of the major axis of an ellipse that describes the touch
+ * area at the point of contact for the given pointer
+ * <em>index</em> (use {@link #getPointerId(int)} to find the pointer
+ * identifier for this index).
+ * @param pointerIndex Raw index of pointer to retrieve. Value may be from 0
+ * (the first pointer that is down) to {@link #getPointerCount()}-1.
+ */
+ public final float getTouchMajor(int pointerIndex) {
+ return mDataSamples[mLastDataSampleIndex
+ + pointerIndex * NUM_SAMPLE_DATA + SAMPLE_TOUCH_MAJOR];
+ }
+
+ /**
+ * Returns the length of the minor axis of an ellipse that describes the touch
+ * area at the point of contact for the given pointer
+ * <em>index</em> (use {@link #getPointerId(int)} to find the pointer
+ * identifier for this index).
+ * @param pointerIndex Raw index of pointer to retrieve. Value may be from 0
+ * (the first pointer that is down) to {@link #getPointerCount()}-1.
+ */
+ public final float getTouchMinor(int pointerIndex) {
+ return mDataSamples[mLastDataSampleIndex
+ + pointerIndex * NUM_SAMPLE_DATA + SAMPLE_TOUCH_MINOR];
+ }
+
+ /**
+ * Returns the length of the major axis of an ellipse that describes the size of
+ * the approaching tool for the given pointer
+ * <em>index</em> (use {@link #getPointerId(int)} to find the pointer
+ * identifier for this index).
+ * The tool area represents the estimated size of the finger or pen that is
+ * touching the device independent of its actual touch area at the point of contact.
+ * @param pointerIndex Raw index of pointer to retrieve. Value may be from 0
+ * (the first pointer that is down) to {@link #getPointerCount()}-1.
+ */
+ public final float getToolMajor(int pointerIndex) {
+ return mDataSamples[mLastDataSampleIndex
+ + pointerIndex * NUM_SAMPLE_DATA + SAMPLE_TOOL_MAJOR];
+ }
+
+ /**
+ * Returns the length of the minor axis of an ellipse that describes the size of
+ * the approaching tool for the given pointer
+ * <em>index</em> (use {@link #getPointerId(int)} to find the pointer
+ * identifier for this index).
+ * The tool area represents the estimated size of the finger or pen that is
+ * touching the device independent of its actual touch area at the point of contact.
+ * @param pointerIndex Raw index of pointer to retrieve. Value may be from 0
+ * (the first pointer that is down) to {@link #getPointerCount()}-1.
+ */
+ public final float getToolMinor(int pointerIndex) {
+ return mDataSamples[mLastDataSampleIndex
+ + pointerIndex * NUM_SAMPLE_DATA + SAMPLE_TOOL_MINOR];
+ }
+
+ /**
+ * Returns the orientation of the touch area and tool area in radians clockwise from vertical
+ * for the given pointer <em>index</em> (use {@link #getPointerId(int)} to find the pointer
+ * identifier for this index).
+ * An angle of 0 degrees indicates that the major axis of contact is oriented
+ * upwards, is perfectly circular or is of unknown orientation. A positive angle
+ * indicates that the major axis of contact is oriented to the right. A negative angle
+ * indicates that the major axis of contact is oriented to the left.
+ * The full range is from -PI/4 radians (finger pointing fully left) to PI/4 radians
+ * (finger pointing fully right).
+ * @param pointerIndex Raw index of pointer to retrieve. Value may be from 0
+ * (the first pointer that is down) to {@link #getPointerCount()}-1.
+ */
+ public final float getOrientation(int pointerIndex) {
+ return mDataSamples[mLastDataSampleIndex
+ + pointerIndex * NUM_SAMPLE_DATA + SAMPLE_ORIENTATION];
+ }
+
+ /**
+ * Populates a {@link PointerCoords} object with pointer coordinate data for
+ * the specified pointer index.
+ *
+ * @param pointerIndex Raw index of pointer to retrieve. Value may be from 0
+ * (the first pointer that is down) to {@link #getPointerCount()}-1.
+ * @param outPointerCoords The pointer coordinate object to populate.
+ */
+ public final void getPointerCoords(int pointerIndex, PointerCoords outPointerCoords) {
+ final int sampleIndex = mLastDataSampleIndex + pointerIndex * NUM_SAMPLE_DATA;
+ getPointerCoordsAtSampleIndex(sampleIndex, outPointerCoords);
+ }
/**
* Returns the state of any meta / modifier keys that were in effect when
@@ -820,7 +964,7 @@
public final float getRawX() {
return mDataSamples[mLastDataSampleIndex + SAMPLE_X];
}
-
+
/**
* Returns the original raw Y coordinate of this event. For touch
* events on the screen, this is the original location of the event
@@ -910,6 +1054,46 @@
}
/**
+ * {@link #getHistoricalTouchMajor(int)} for the first pointer index (may be an
+ * arbitrary pointer identifier).
+ */
+ public final float getHistoricalTouchMajor(int pos) {
+ return mDataSamples[pos * mNumPointers * NUM_SAMPLE_DATA + SAMPLE_TOUCH_MAJOR];
+ }
+
+ /**
+ * {@link #getHistoricalTouchMinor(int)} for the first pointer index (may be an
+ * arbitrary pointer identifier).
+ */
+ public final float getHistoricalTouchMinor(int pos) {
+ return mDataSamples[pos * mNumPointers * NUM_SAMPLE_DATA + SAMPLE_TOUCH_MINOR];
+ }
+
+ /**
+ * {@link #getHistoricalToolMajor(int)} for the first pointer index (may be an
+ * arbitrary pointer identifier).
+ */
+ public final float getHistoricalToolMajor(int pos) {
+ return mDataSamples[pos * mNumPointers * NUM_SAMPLE_DATA + SAMPLE_TOOL_MAJOR];
+ }
+
+ /**
+ * {@link #getHistoricalToolMinor(int)} for the first pointer index (may be an
+ * arbitrary pointer identifier).
+ */
+ public final float getHistoricalToolMinor(int pos) {
+ return mDataSamples[pos * mNumPointers * NUM_SAMPLE_DATA + SAMPLE_TOOL_MINOR];
+ }
+
+ /**
+ * {@link #getHistoricalOrientation(int)} for the first pointer index (may be an
+ * arbitrary pointer identifier).
+ */
+ public final float getHistoricalOrientation(int pos) {
+ return mDataSamples[pos * mNumPointers * NUM_SAMPLE_DATA + SAMPLE_ORIENTATION];
+ }
+
+ /**
* Returns a historical X coordinate, as per {@link #getX(int)}, that
* occurred between this event and the previous event for the given pointer.
* Only applies to ACTION_MOVE events.
@@ -980,17 +1164,119 @@
return mDataSamples[(pos * mNumPointers + pointerIndex)
* NUM_SAMPLE_DATA + SAMPLE_SIZE];
}
-
+
/**
- * Return the id for the device that this event came from. An id of
- * zero indicates that the event didn't come from a physical device; other
- * numbers are arbitrary and you shouldn't depend on the values.
+ * Returns a historical touch major axis coordinate, as per {@link #getTouchMajor(int)}, that
+ * occurred between this event and the previous event for the given pointer.
+ * Only applies to ACTION_MOVE events.
+ *
+ * @param pointerIndex Raw index of pointer to retrieve. Value may be from 0
+ * (the first pointer that is down) to {@link #getPointerCount()}-1.
+ * @param pos Which historical value to return; must be less than
+ * {@link #getHistorySize}
+ *
+ * @see #getHistorySize
+ * @see #getTouchMajor
*/
- public final int getDeviceId() {
- return mDeviceId;
+ public final float getHistoricalTouchMajor(int pointerIndex, int pos) {
+ return mDataSamples[(pos * mNumPointers + pointerIndex)
+ * NUM_SAMPLE_DATA + SAMPLE_TOUCH_MAJOR];
}
/**
+ * Returns a historical touch minor axis coordinate, as per {@link #getTouchMinor(int)}, that
+ * occurred between this event and the previous event for the given pointer.
+ * Only applies to ACTION_MOVE events.
+ *
+ * @param pointerIndex Raw index of pointer to retrieve. Value may be from 0
+ * (the first pointer that is down) to {@link #getPointerCount()}-1.
+ * @param pos Which historical value to return; must be less than
+ * {@link #getHistorySize}
+ *
+ * @see #getHistorySize
+ * @see #getTouchMinor
+ */
+ public final float getHistoricalTouchMinor(int pointerIndex, int pos) {
+ return mDataSamples[(pos * mNumPointers + pointerIndex)
+ * NUM_SAMPLE_DATA + SAMPLE_TOUCH_MINOR];
+ }
+
+ /**
+ * Returns a historical tool major axis coordinate, as per {@link #getToolMajor(int)}, that
+ * occurred between this event and the previous event for the given pointer.
+ * Only applies to ACTION_MOVE events.
+ *
+ * @param pointerIndex Raw index of pointer to retrieve. Value may be from 0
+ * (the first pointer that is down) to {@link #getPointerCount()}-1.
+ * @param pos Which historical value to return; must be less than
+ * {@link #getHistorySize}
+ *
+ * @see #getHistorySize
+ * @see #getToolMajor
+ */
+ public final float getHistoricalToolMajor(int pointerIndex, int pos) {
+ return mDataSamples[(pos * mNumPointers + pointerIndex)
+ * NUM_SAMPLE_DATA + SAMPLE_TOOL_MAJOR];
+ }
+
+ /**
+ * Returns a historical tool minor axis coordinate, as per {@link #getToolMinor(int)}, that
+ * occurred between this event and the previous event for the given pointer.
+ * Only applies to ACTION_MOVE events.
+ *
+ * @param pointerIndex Raw index of pointer to retrieve. Value may be from 0
+ * (the first pointer that is down) to {@link #getPointerCount()}-1.
+ * @param pos Which historical value to return; must be less than
+ * {@link #getHistorySize}
+ *
+ * @see #getHistorySize
+ * @see #getToolMinor
+ */
+ public final float getHistoricalToolMinor(int pointerIndex, int pos) {
+ return mDataSamples[(pos * mNumPointers + pointerIndex)
+ * NUM_SAMPLE_DATA + SAMPLE_TOOL_MINOR];
+ }
+
+ /**
+ * Returns a historical orientation coordinate, as per {@link #getOrientation(int)}, that
+ * occurred between this event and the previous event for the given pointer.
+ * Only applies to ACTION_MOVE events.
+ *
+ * @param pointerIndex Raw index of pointer to retrieve. Value may be from 0
+ * (the first pointer that is down) to {@link #getPointerCount()}-1.
+ * @param pos Which historical value to return; must be less than
+ * {@link #getHistorySize}
+ *
+ * @see #getHistorySize
+ * @see #getOrientation
+ */
+ public final float getHistoricalOrientation(int pointerIndex, int pos) {
+ return mDataSamples[(pos * mNumPointers + pointerIndex)
+ * NUM_SAMPLE_DATA + SAMPLE_ORIENTATION];
+ }
+
+ /**
+ * Populates a {@link PointerCoords} object with historical pointer coordinate data,
+ * as per {@link #getPointerCoords}, that occurred between this event and the previous
+ * event for the given pointer.
+ * Only applies to ACTION_MOVE events.
+ *
+ * @param pointerIndex Raw index of pointer to retrieve. Value may be from 0
+ * (the first pointer that is down) to {@link #getPointerCount()}-1.
+ * @param pos Which historical value to return; must be less than
+ * {@link #getHistorySize}
+ * @param outPointerCoords The pointer coordinate object to populate.
+ *
+ * @see #getHistorySize
+ * @see #getPointerCoords
+ */
+ public final void getHistoricalPointerCoords(int pointerIndex, int pos,
+ PointerCoords outPointerCoords) {
+ final int sampleIndex = (pos * mNumPointers + pointerIndex) * NUM_SAMPLE_DATA;
+ getPointerCoordsAtSampleIndex(sampleIndex, outPointerCoords);
+ }
+
+ /**
* Returns a bitfield indicating which edges, if any, were touched by this
* MotionEvent. For touch events, clients can use this to determine if the
* user's finger was touching the edge of the display.
@@ -1044,6 +1330,54 @@
mYOffset = y - mDataSamples[mLastDataSampleIndex + SAMPLE_Y];
}
+ private final void getPointerCoordsAtSampleIndex(int sampleIndex,
+ PointerCoords outPointerCoords) {
+ outPointerCoords.x = mDataSamples[sampleIndex + SAMPLE_X] + mXOffset;
+ outPointerCoords.y = mDataSamples[sampleIndex + SAMPLE_Y] + mYOffset;
+ outPointerCoords.pressure = mDataSamples[sampleIndex + SAMPLE_PRESSURE];
+ outPointerCoords.size = mDataSamples[sampleIndex + SAMPLE_SIZE];
+ outPointerCoords.touchMajor = mDataSamples[sampleIndex + SAMPLE_TOUCH_MAJOR];
+ outPointerCoords.touchMinor = mDataSamples[sampleIndex + SAMPLE_TOUCH_MINOR];
+ outPointerCoords.toolMajor = mDataSamples[sampleIndex + SAMPLE_TOOL_MAJOR];
+ outPointerCoords.toolMinor = mDataSamples[sampleIndex + SAMPLE_TOOL_MINOR];
+ outPointerCoords.orientation = mDataSamples[sampleIndex + SAMPLE_ORIENTATION];
+ }
+
+ private final void setPointerCoordsAtSampleIndex(int sampleIndex,
+ PointerCoords[] pointerCoords) {
+ final int numPointers = mNumPointers;
+ for (int i = 0; i < numPointers; i++) {
+ setPointerCoordsAtSampleIndex(sampleIndex, pointerCoords[i]);
+ sampleIndex += NUM_SAMPLE_DATA;
+ }
+ }
+
+ private final void setPointerCoordsAtSampleIndex(int sampleIndex,
+ PointerCoords pointerCoords) {
+ mDataSamples[sampleIndex + SAMPLE_X] = pointerCoords.x - mXOffset;
+ mDataSamples[sampleIndex + SAMPLE_Y] = pointerCoords.y - mYOffset;
+ mDataSamples[sampleIndex + SAMPLE_PRESSURE] = pointerCoords.pressure;
+ mDataSamples[sampleIndex + SAMPLE_SIZE] = pointerCoords.size;
+ mDataSamples[sampleIndex + SAMPLE_TOUCH_MAJOR] = pointerCoords.touchMajor;
+ mDataSamples[sampleIndex + SAMPLE_TOUCH_MINOR] = pointerCoords.touchMinor;
+ mDataSamples[sampleIndex + SAMPLE_TOOL_MAJOR] = pointerCoords.toolMajor;
+ mDataSamples[sampleIndex + SAMPLE_TOOL_MINOR] = pointerCoords.toolMinor;
+ mDataSamples[sampleIndex + SAMPLE_ORIENTATION] = pointerCoords.orientation;
+ }
+
+ private final void setPointerCoordsAtSampleIndex(int sampleIndex,
+ float x, float y, float pressure, float size) {
+ mDataSamples[sampleIndex + SAMPLE_X] = x - mXOffset;
+ mDataSamples[sampleIndex + SAMPLE_Y] = y - mYOffset;
+ mDataSamples[sampleIndex + SAMPLE_PRESSURE] = pressure;
+ mDataSamples[sampleIndex + SAMPLE_SIZE] = size;
+ mDataSamples[sampleIndex + SAMPLE_TOUCH_MAJOR] = pressure;
+ mDataSamples[sampleIndex + SAMPLE_TOUCH_MINOR] = pressure;
+ mDataSamples[sampleIndex + SAMPLE_TOOL_MAJOR] = size;
+ mDataSamples[sampleIndex + SAMPLE_TOOL_MINOR] = size;
+ mDataSamples[sampleIndex + SAMPLE_ORIENTATION] = 0;
+ }
+
private final void incrementNumSamplesAndReserveStorage(int dataSampleStride) {
if (mNumSamples == mEventTimeNanoSamples.length) {
long[] newEventTimeNanoSamples = new long[mNumSamples + BASE_AVAIL_SAMPLES];
@@ -1066,11 +1400,12 @@
/**
* Add a new movement to the batch of movements in this event. The event's
- * current location, position and size is updated to the new values. In
- * the future, the current values in the event will be added to a list of
- * historic values.
+ * current location, position and size is updated to the new values.
+ * The current values in the event are added to a list of historical values.
+ *
+ * Only applies to {@link #ACTION_MOVE} events.
*
- * @param eventTime The time stamp for this data.
+ * @param eventTime The time stamp (in ms) for this data.
* @param x The new X position.
* @param y The new Y position.
* @param pressure The new pressure.
@@ -1082,62 +1417,30 @@
incrementNumSamplesAndReserveStorage(NUM_SAMPLE_DATA);
mEventTimeNanoSamples[mLastEventTimeNanoSampleIndex] = eventTime * MS_PER_NS;
-
- float[] dataSamples = mDataSamples;
- dataSamples[mLastDataSampleIndex + SAMPLE_X] = x - mXOffset;
- dataSamples[mLastDataSampleIndex + SAMPLE_Y] = y - mYOffset;
- dataSamples[mLastDataSampleIndex + SAMPLE_PRESSURE] = pressure;
- dataSamples[mLastDataSampleIndex + SAMPLE_SIZE] = size;
+ setPointerCoordsAtSampleIndex(mLastDataSampleIndex, x, y, pressure, size);
mMetaState |= metaState;
}
/**
- * Add a new movement to the batch of movements in this event. The
- * input data must contain (NUM_SAMPLE_DATA * {@link #getPointerCount()})
- * samples of data.
- *
- * @param eventTime The time stamp for this data.
- * @param inData The actual data.
- * @param metaState Meta key state.
+ * Add a new movement to the batch of movements in this event. The event's
+ * current location, position and size is updated to the new values.
+ * The current values in the event are added to a list of historical values.
*
- * @hide
+ * Only applies to {@link #ACTION_MOVE} events.
+ *
+ * @param eventTime The time stamp (in ms) for this data.
+ * @param pointerCoords The new pointer coordinates.
+ * @param metaState Meta key state.
*/
- public final void addBatch(long eventTime, float[] inData, int metaState) {
- final int numPointers = mNumPointers;
- final int dataSampleStride = numPointers * NUM_SAMPLE_DATA;
+ public final void addBatch(long eventTime, PointerCoords[] pointerCoords, int metaState) {
+ final int dataSampleStride = mNumPointers * NUM_SAMPLE_DATA;
incrementNumSamplesAndReserveStorage(dataSampleStride);
mEventTimeNanoSamples[mLastEventTimeNanoSampleIndex] = eventTime * MS_PER_NS;
-
- float[] dataSamples = mDataSamples;
- System.arraycopy(inData, 0, dataSamples, mLastDataSampleIndex, dataSampleStride);
-
- if (mXOffset != 0 || mYOffset != 0) {
- int index = mLastEventTimeNanoSampleIndex;
- for (int i = 0; i < numPointers; i++) {
- dataSamples[index + SAMPLE_X] -= mXOffset;
- dataSamples[index + SAMPLE_Y] -= mYOffset;
- index += NUM_SAMPLE_DATA;
- }
- }
+ setPointerCoordsAtSampleIndex(mLastDataSampleIndex, pointerCoords);
mMetaState |= metaState;
-
- if (DEBUG_POINTERS) {
- StringBuilder sb = new StringBuilder(128);
- sb.append("Add:");
- for (int i = 0; i < mNumPointers; i++) {
- sb.append(" #");
- sb.append(getPointerId(i));
- sb.append("(");
- sb.append(getX(i));
- sb.append(",");
- sb.append(getY(i));
- sb.append(")");
- }
- Log.v("MotionEvent", sb.toString());
- }
}
@Override
@@ -1165,6 +1468,7 @@
ev.mXPrecision = in.readFloat();
ev.mYPrecision = in.readFloat();
ev.mDeviceId = in.readInt();
+ ev.mSource = in.readInt();
ev.mEdgeFlags = in.readInt();
ev.mMetaState = in.readInt();
@@ -1212,6 +1516,7 @@
out.writeFloat(mXPrecision);
out.writeFloat(mYPrecision);
out.writeInt(mDeviceId);
+ out.writeInt(mSource);
out.writeInt(mEdgeFlags);
out.writeInt(mMetaState);
@@ -1230,4 +1535,108 @@
out.writeFloat(dataSamples[i]);
}
}
+
+ /**
+ * Transfer object for pointer coordinates.
+ *
+ * Objects of this type can be used to manufacture new {@link MotionEvent} objects
+ * and to query pointer coordinate information in bulk.
+ *
+ * Refer to {@link InputDevice} for information about how different kinds of
+ * input devices and sources represent pointer coordinates.
+ */
+ public static final class PointerCoords {
+ /**
+ * The X coordinate of the pointer movement.
+ * The interpretation varies by input source and may represent the position of
+ * the center of the contact area, a relative displacement in device-specific units
+ * or something else.
+ */
+ public float x;
+
+ /**
+ * The Y coordinate of the pointer movement.
+ * The interpretation varies by input source and may represent the position of
+ * the center of the contact area, a relative displacement in device-specific units
+ * or something else.
+ */
+ public float y;
+
+ /**
+ * A scaled value that describes the pressure applied to the pointer.
+ * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure),
+ * however values higher than 1 may be generated depending on the calibration of
+ * the input device.
+ */
+ public float pressure;
+
+ /**
+ * A scaled value of the approximate size of the pointer touch area.
+ * This represents some approximation of the area of the screen being
+ * pressed; the actual value in pixels corresponding to the
+ * touch is normalized with the device specific range of values
+ * and scaled to a value between 0 and 1. The value of size can be used to
+ * determine fat touch events.
+ */
+ public float size;
+
+ /**
+ * The length of the major axis of an ellipse that describes the touch area at
+ * the point of contact.
+ */
+ public float touchMajor;
+
+ /**
+ * The length of the minor axis of an ellipse that describes the touch area at
+ * the point of contact.
+ */
+ public float touchMinor;
+
+ /**
+ * The length of the major axis of an ellipse that describes the size of
+ * the approaching tool.
+ * The tool area represents the estimated size of the finger or pen that is
+ * touching the device independent of its actual touch area at the point of contact.
+ */
+ public float toolMajor;
+
+ /**
+ * The length of the minor axis of an ellipse that describes the size of
+ * the approaching tool.
+ * The tool area represents the estimated size of the finger or pen that is
+ * touching the device independent of its actual touch area at the point of contact.
+ */
+ public float toolMinor;
+
+ /**
+ * The orientation of the touch area and tool area in radians clockwise from vertical.
+ * An angle of 0 degrees indicates that the major axis of contact is oriented
+ * upwards, is perfectly circular or is of unknown orientation. A positive angle
+ * indicates that the major axis of contact is oriented to the right. A negative angle
+ * indicates that the major axis of contact is oriented to the left.
+ * The full range is from -PI/4 radians (finger pointing fully left) to PI/4 radians
+ * (finger pointing fully right).
+ */
+ public float orientation;
+
+ /*
+ private static final float PI_8 = (float) (Math.PI / 8);
+
+ public float getTouchWidth() {
+ return Math.abs(orientation) > PI_8 ? touchMajor : touchMinor;
+ }
+
+ public float getTouchHeight() {
+ return Math.abs(orientation) > PI_8 ? touchMinor : touchMajor;
+ }
+
+ public float getToolWidth() {
+ return Math.abs(orientation) > PI_8 ? toolMajor : toolMinor;
+ }
+
+ public float getToolHeight() {
+ return Math.abs(orientation) > PI_8 ? toolMinor : toolMajor;
+ }
+ */
+ }
}
diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java
index 260bf7bc..7ce04cf 100644
--- a/core/java/android/view/ViewRoot.java
+++ b/core/java/android/view/ViewRoot.java
@@ -516,7 +516,7 @@
}
mPendingContentInsets.set(mAttachInfo.mContentInsets);
mPendingVisibleInsets.set(0, 0, 0, 0);
- if (Config.LOGV) Log.v("ViewRoot", "Added window " + mWindow);
+ if (Config.LOGV) Log.v(TAG, "Added window " + mWindow);
if (res < WindowManagerImpl.ADD_OKAY) {
mView = null;
mAttachInfo.mRootView = null;
@@ -769,7 +769,7 @@
desiredWindowWidth = frame.width();
desiredWindowHeight = frame.height();
if (desiredWindowWidth != mWidth || desiredWindowHeight != mHeight) {
- if (DEBUG_ORIENTATION) Log.v("ViewRoot",
+ if (DEBUG_ORIENTATION) Log.v(TAG,
"View " + host + " resized to: " + frame);
fullRedrawNeeded = true;
mLayoutRequested = true;
@@ -833,7 +833,7 @@
childHeightMeasureSpec = getRootMeasureSpec(desiredWindowHeight, lp.height);
// Ask host how big it wants to be
- if (DEBUG_ORIENTATION || DEBUG_LAYOUT) Log.v("ViewRoot",
+ if (DEBUG_ORIENTATION || DEBUG_LAYOUT) Log.v(TAG,
"Measuring " + host + " in display " + desiredWindowWidth
+ "x" + desiredWindowHeight + "...");
host.measure(childWidthMeasureSpec, childHeightMeasureSpec);
@@ -1010,7 +1010,7 @@
}
if (DEBUG_ORIENTATION) Log.v(
- "ViewRoot", "Relayout returned: frame=" + frame + ", surface=" + mSurface);
+ TAG, "Relayout returned: frame=" + frame + ", surface=" + mSurface);
attachInfo.mWindowLeft = frame.left;
attachInfo.mWindowTop = frame.top;
@@ -1131,7 +1131,7 @@
mLayoutRequested = false;
mScrollMayChange = true;
if (DEBUG_ORIENTATION || DEBUG_LAYOUT) Log.v(
- "ViewRoot", "Laying out " + host + " to (" +
+ TAG, "Laying out " + host + " to (" +
host.mMeasuredWidth + ", " + host.mMeasuredHeight + ")");
long startTime = 0L;
if (Config.DEBUG && ViewDebug.profileLayout) {
@@ -1260,7 +1260,7 @@
if ((relayoutResult&WindowManagerImpl.RELAYOUT_FIRST_TIME) != 0
|| mReportNextDraw) {
if (LOCAL_LOGV) {
- Log.v("ViewRoot", "FINISHED DRAWING: " + mWindowAttributes.getTitle());
+ Log.v(TAG, "FINISHED DRAWING: " + mWindowAttributes.getTitle());
}
mReportNextDraw = false;
if (mSurfaceHolder != null && mSurface.isValid()) {
@@ -1437,7 +1437,7 @@
}
if (DEBUG_ORIENTATION || DEBUG_DRAW) {
- Log.v("ViewRoot", "Draw " + mView + "/"
+ Log.v(TAG, "Draw " + mView + "/"
+ mWindowAttributes.getTitle()
+ ": dirty={" + dirty.left + "," + dirty.top
+ "," + dirty.right + "," + dirty.bottom + "} surface="
@@ -1462,12 +1462,12 @@
// TODO: Do this in native
canvas.setDensity(mDensity);
} catch (Surface.OutOfResourcesException e) {
- Log.e("ViewRoot", "OutOfResourcesException locking surface", e);
+ Log.e(TAG, "OutOfResourcesException locking surface", e);
// TODO: we should ask the window manager to do something!
// for now we just do nothing
return;
} catch (IllegalArgumentException e) {
- Log.e("ViewRoot", "IllegalArgumentException locking surface", e);
+ Log.e(TAG, "IllegalArgumentException locking surface", e);
// TODO: we should ask the window manager to do something!
// for now we just do nothing
return;
@@ -1478,7 +1478,7 @@
long startTime = 0L;
if (DEBUG_ORIENTATION || DEBUG_DRAW) {
- Log.v("ViewRoot", "Surface " + surface + " drawing to bitmap w="
+ Log.v(TAG, "Surface " + surface + " drawing to bitmap w="
+ canvas.getWidth() + ", h=" + canvas.getHeight());
//canvas.drawARGB(255, 255, 0, 0);
}
@@ -1547,7 +1547,7 @@
}
if (LOCAL_LOGV) {
- Log.v("ViewRoot", "Surface " + surface + " unlockCanvasAndPost");
+ Log.v(TAG, "Surface " + surface + " unlockCanvasAndPost");
}
if (scrolling) {
@@ -1739,7 +1739,7 @@
}
void dispatchDetachedFromWindow() {
- if (Config.LOGV) Log.v("ViewRoot", "Detaching in " + this + " of " + mSurface);
+ if (Config.LOGV) Log.v(TAG, "Detaching in " + this + " of " + mSurface);
if (mView != null) {
mView.dispatchDetachedFromWindow();
@@ -1867,7 +1867,7 @@
break;
case DISPATCH_KEY:
if (LOCAL_LOGV) Log.v(
- "ViewRoot", "Dispatching key "
+ TAG, "Dispatching key "
+ msg.obj + " to " + mView);
deliverKeyEvent((KeyEvent)msg.obj, true);
break;
@@ -1989,7 +1989,7 @@
break;
case DISPATCH_KEY_FROM_IME: {
if (LOCAL_LOGV) Log.v(
- "ViewRoot", "Dispatching key "
+ TAG, "Dispatching key "
+ msg.obj + " from IME to " + mView);
KeyEvent event = (KeyEvent)msg.obj;
if ((event.getFlags()&KeyEvent.FLAG_FROM_SYSTEM) != 0) {
@@ -2484,7 +2484,7 @@
if (handled) {
if (sendDone) {
if (LOCAL_LOGV) Log.v(
- "ViewRoot", "Telling window manager key is finished");
+ TAG, "Telling window manager key is finished");
finishKeyEvent(event);
}
return;
@@ -2517,10 +2517,10 @@
return;
} else if (sendDone) {
if (LOCAL_LOGV) Log.v(
- "ViewRoot", "Telling window manager key is finished");
+ TAG, "Telling window manager key is finished");
finishKeyEvent(event);
} else {
- Log.w("ViewRoot", "handleFinishedEvent(seq=" + seq
+ Log.w(TAG, "handleFinishedEvent(seq=" + seq
+ " handled=" + handled + " ev=" + event
+ ") neither delivering nor finishing key");
}
@@ -2592,7 +2592,7 @@
} finally {
if (sendDone) {
if (LOCAL_LOGV) Log.v(
- "ViewRoot", "Telling window manager key is finished");
+ TAG, "Telling window manager key is finished");
finishKeyEvent(event);
}
// Let the exception fall through -- the looper will catch
@@ -2715,7 +2715,7 @@
void doDie() {
checkThread();
- if (Config.LOGV) Log.v("ViewRoot", "DIE in " + this + " of " + mSurface);
+ if (Config.LOGV) Log.v(TAG, "DIE in " + this + " of " + mSurface);
synchronized (this) {
if (mAdded && !mFirst) {
int viewVisibility = mView.getVisibility();
@@ -2781,16 +2781,10 @@
dispatchKey(event);
}
- public void handleTouch(MotionEvent event, Runnable finishedCallback) {
+ public void handleMotion(MotionEvent event, Runnable finishedCallback) {
finishedCallback.run();
- dispatchPointer(event);
- }
-
- public void handleTrackball(MotionEvent event, Runnable finishedCallback) {
- finishedCallback.run();
-
- dispatchTrackball(event);
+ dispatchMotion(event);
}
};
@@ -2812,10 +2806,22 @@
msg.obj = event;
if (LOCAL_LOGV) Log.v(
- "ViewRoot", "sending key " + event + " to " + mView);
+ TAG, "sending key " + event + " to " + mView);
sendMessageAtTime(msg, event.getEventTime());
}
+
+ public void dispatchMotion(MotionEvent event) {
+ int source = event.getSource();
+ if ((source & InputDevice.SOURCE_CLASS_POINTER) != 0) {
+ dispatchPointer(event);
+ } else if ((source & InputDevice.SOURCE_CLASS_TRACKBALL) != 0) {
+ dispatchTrackball(event);
+ } else {
+ // TODO
+ Log.v(TAG, "Dropping unsupported motion event (unimplemented): " + event);
+ }
+ }
public void dispatchPointer(MotionEvent event) {
Message msg = obtainMessage(DISPATCH_POINTER);
diff --git a/core/java/com/android/internal/app/IMediaContainerService.aidl b/core/java/com/android/internal/app/IMediaContainerService.aidl
index 0f817b7..89649a9 100755
--- a/core/java/com/android/internal/app/IMediaContainerService.aidl
+++ b/core/java/com/android/internal/app/IMediaContainerService.aidl
@@ -28,4 +28,4 @@
in ParcelFileDescriptor outStream);
PackageInfoLite getMinimalPackageInfo(in Uri fileUri, int flags);
boolean checkFreeStorage(boolean external, in Uri fileUri);
-}
\ No newline at end of file
+}
diff --git a/core/java/com/android/internal/view/BaseInputHandler.java b/core/java/com/android/internal/view/BaseInputHandler.java
index 6fe5063..e943a7d 100644
--- a/core/java/com/android/internal/view/BaseInputHandler.java
+++ b/core/java/com/android/internal/view/BaseInputHandler.java
@@ -29,11 +29,7 @@
finishedCallback.run();
}
- public void handleTouch(MotionEvent event, Runnable finishedCallback) {
- finishedCallback.run();
- }
-
- public void handleTrackball(MotionEvent event, Runnable finishedCallback) {
+ public void handleMotion(MotionEvent event, Runnable finishedCallback) {
finishedCallback.run();
}
}
diff --git a/core/jni/Android.mk b/core/jni/Android.mk
index 468f844..89fea41 100644
--- a/core/jni/Android.mk
+++ b/core/jni/Android.mk
@@ -134,7 +134,8 @@
android_backup_BackupDataInput.cpp \
android_backup_BackupDataOutput.cpp \
android_backup_FileBackupHelperBase.cpp \
- android_backup_BackupHelperDispatcher.cpp
+ android_backup_BackupHelperDispatcher.cpp \
+ android_content_res_ObbScanner.cpp
LOCAL_C_INCLUDES += \
$(JNI_H_INCLUDE) \
diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp
index 6fb1369..fc1f4884 100644
--- a/core/jni/AndroidRuntime.cpp
+++ b/core/jni/AndroidRuntime.cpp
@@ -166,6 +166,7 @@
extern int register_android_view_InputQueue(JNIEnv* env);
extern int register_android_view_KeyEvent(JNIEnv* env);
extern int register_android_view_MotionEvent(JNIEnv* env);
+extern int register_android_content_res_ObbScanner(JNIEnv* env);
static AndroidRuntime* gCurRuntime = NULL;
@@ -1298,6 +1299,8 @@
REG_JNI(register_android_view_InputQueue),
REG_JNI(register_android_view_KeyEvent),
REG_JNI(register_android_view_MotionEvent),
+
+ REG_JNI(register_android_content_res_ObbScanner),
};
/*
diff --git a/core/jni/android_app_NativeActivity.cpp b/core/jni/android_app_NativeActivity.cpp
index acbf854..1feb3b3 100644
--- a/core/jni/android_app_NativeActivity.cpp
+++ b/core/jni/android_app_NativeActivity.cpp
@@ -24,6 +24,7 @@
#include <android_runtime/AndroidRuntime.h>
#include <android_runtime/android_view_Surface.h>
#include <android_runtime/android_app_NativeActivity.h>
+#include <android_runtime/android_util_AssetManager.h>
#include <surfaceflinger/Surface.h>
#include <ui/egl/android_natives.h>
#include <ui/InputTransport.h>
@@ -44,6 +45,7 @@
jclass clazz;
jmethodID dispatchUnhandledKeyEvent;
+ jmethodID preDispatchKeyEvent;
jmethodID setWindowFlags;
jmethodID setWindowFormat;
jmethodID showIme;
@@ -103,7 +105,7 @@
using namespace android;
AInputQueue::AInputQueue(const sp<InputChannel>& channel, int workWrite) :
- mWorkWrite(workWrite), mConsumer(channel) {
+ mWorkWrite(workWrite), mConsumer(channel), mSeq(0) {
int msgpipe[2];
if (pipe(msgpipe)) {
LOGW("could not create pipe: %s", strerror(errno));
@@ -156,6 +158,8 @@
int32_t AInputQueue::getEvent(AInputEvent** outEvent) {
*outEvent = NULL;
+ bool finishNow = false;
+
char byteread;
ssize_t nRead = read(mDispatchKeyRead, &byteread, 1);
if (nRead == 1) {
@@ -164,10 +168,34 @@
KeyEvent* kevent = mDispatchingKeys[0];
*outEvent = kevent;
mDispatchingKeys.removeAt(0);
- mDeliveringKeys.add(kevent);
+ in_flight_event inflight;
+ inflight.event = kevent;
+ inflight.seq = -1;
+ inflight.doFinish = false;
+ mInFlightEvents.push(inflight);
+ }
+ if (mFinishPreDispatches.size() > 0) {
+ finish_pre_dispatch finish(mFinishPreDispatches[0]);
+ mFinishPreDispatches.removeAt(0);
+ const size_t N = mInFlightEvents.size();
+ for (size_t i=0; i<N; i++) {
+ const in_flight_event& inflight(mInFlightEvents[i]);
+ if (inflight.seq == finish.seq) {
+ *outEvent = inflight.event;
+ finishNow = finish.handled;
+ }
+ }
+ if (*outEvent == NULL) {
+ LOGW("getEvent couldn't find inflight for seq %d", finish.seq);
+ }
}
mLock.unlock();
- if (*outEvent != NULL) {
+
+ if (finishNow) {
+ finishEvent(*outEvent, true);
+ *outEvent = NULL;
+ return -1;
+ } else if (*outEvent != NULL) {
return 0;
}
}
@@ -180,7 +208,7 @@
}
InputEvent* myEvent = NULL;
- res = mConsumer.consume(&mInputEventFactory, &myEvent);
+ res = mConsumer.consume(this, &myEvent);
if (res != android::OK) {
LOGW("channel '%s' ~ Failed to consume input event. status=%d",
mConsumer.getChannel()->getName().string(), res);
@@ -188,39 +216,69 @@
return -1;
}
+ in_flight_event inflight;
+ inflight.event = myEvent;
+ inflight.seq = -1;
+ inflight.doFinish = true;
+ mInFlightEvents.push(inflight);
+
*outEvent = myEvent;
return 0;
}
-void AInputQueue::finishEvent(AInputEvent* event, bool handled) {
- bool needFinished = true;
+bool AInputQueue::preDispatchEvent(AInputEvent* event) {
+ if (((InputEvent*)event)->getType() != AINPUT_EVENT_TYPE_KEY) {
+ // The IME only cares about key events.
+ return false;
+ }
- if (!handled && ((InputEvent*)event)->getType() == INPUT_EVENT_TYPE_KEY
+ // For now we only send system keys to the IME... this avoids having
+ // critical keys like DPAD go through this path. We really need to have
+ // the IME report which keys it wants.
+ if (!((KeyEvent*)event)->isSystemKey()) {
+ return false;
+ }
+
+ return preDispatchKey((KeyEvent*)event);
+}
+
+void AInputQueue::finishEvent(AInputEvent* event, bool handled) {
+ LOG_TRACE("finishEvent: %p handled=%d", event, handled ? 1 : 0);
+
+ if (!handled && ((InputEvent*)event)->getType() == AINPUT_EVENT_TYPE_KEY
&& ((KeyEvent*)event)->hasDefaultAction()) {
// The app didn't handle this, but it may have a default action
// associated with it. We need to hand this back to Java to be
// executed.
- doDefaultKey((KeyEvent*)event);
- needFinished = false;
+ doUnhandledKey((KeyEvent*)event);
+ return;
}
- const size_t N = mDeliveringKeys.size();
+ mLock.lock();
+ const size_t N = mInFlightEvents.size();
for (size_t i=0; i<N; i++) {
- if (mDeliveringKeys[i] == event) {
- delete event;
- mDeliveringKeys.removeAt(i);
- needFinished = false;
- break;
+ const in_flight_event& inflight(mInFlightEvents[i]);
+ if (inflight.event == event) {
+ if (inflight.doFinish) {
+ int32_t res = mConsumer.sendFinishedSignal();
+ if (res != android::OK) {
+ LOGW("Failed to send finished signal on channel '%s'. status=%d",
+ mConsumer.getChannel()->getName().string(), res);
+ }
+ }
+ if (static_cast<InputEvent*>(event)->getType() == AINPUT_EVENT_TYPE_KEY) {
+ mAvailKeyEvents.push(static_cast<KeyEvent*>(event));
+ } else {
+ mAvailMotionEvents.push(static_cast<MotionEvent*>(event));
+ }
+ mInFlightEvents.removeAt(i);
+ mLock.unlock();
+ return;
}
}
+ mLock.unlock();
- if (needFinished) {
- int32_t res = mConsumer.sendFinishedSignal();
- if (res != android::OK) {
- LOGW("Failed to send finished signal on channel '%s'. status=%d",
- mConsumer.getChannel()->getName().string(), res);
- }
- }
+ LOGW("finishEvent called for unknown event: %p", event);
}
void AInputQueue::dispatchEvent(android::KeyEvent* event) {
@@ -228,8 +286,120 @@
LOG_TRACE("dispatchEvent: dispatching=%d write=%d\n", mDispatchingKeys.size(),
mDispatchKeyWrite);
mDispatchingKeys.add(event);
+ wakeupDispatch();
mLock.unlock();
-
+}
+
+void AInputQueue::finishPreDispatch(int seq, bool handled) {
+ mLock.lock();
+ LOG_TRACE("finishPreDispatch: seq=%d handled=%d\n", seq, handled ? 1 : 0);
+ finish_pre_dispatch finish;
+ finish.seq = seq;
+ finish.handled = handled;
+ mFinishPreDispatches.add(finish);
+ wakeupDispatch();
+ mLock.unlock();
+}
+
+KeyEvent* AInputQueue::consumeUnhandledEvent() {
+ KeyEvent* event = NULL;
+
+ mLock.lock();
+ if (mUnhandledKeys.size() > 0) {
+ event = mUnhandledKeys[0];
+ mUnhandledKeys.removeAt(0);
+ }
+ mLock.unlock();
+
+ LOG_TRACE("consumeUnhandledEvent: KeyEvent=%p", event);
+
+ return event;
+}
+
+KeyEvent* AInputQueue::consumePreDispatchingEvent(int* outSeq) {
+ KeyEvent* event = NULL;
+
+ mLock.lock();
+ if (mPreDispatchingKeys.size() > 0) {
+ const in_flight_event& inflight(mPreDispatchingKeys[0]);
+ event = static_cast<KeyEvent*>(inflight.event);
+ *outSeq = inflight.seq;
+ mPreDispatchingKeys.removeAt(0);
+ }
+ mLock.unlock();
+
+ LOG_TRACE("consumePreDispatchingEvent: KeyEvent=%p", event);
+
+ return event;
+}
+
+KeyEvent* AInputQueue::createKeyEvent() {
+ mLock.lock();
+ KeyEvent* event;
+ if (mAvailKeyEvents.size() <= 0) {
+ event = new KeyEvent();
+ } else {
+ event = mAvailKeyEvents.top();
+ mAvailKeyEvents.pop();
+ }
+ mLock.unlock();
+ return event;
+}
+
+MotionEvent* AInputQueue::createMotionEvent() {
+ mLock.lock();
+ MotionEvent* event;
+ if (mAvailMotionEvents.size() <= 0) {
+ event = new MotionEvent();
+ } else {
+ event = mAvailMotionEvents.top();
+ mAvailMotionEvents.pop();
+ }
+ mLock.unlock();
+ return event;
+}
+
+void AInputQueue::doUnhandledKey(KeyEvent* keyEvent) {
+ mLock.lock();
+ LOG_TRACE("Unhandled key: pending=%d write=%d\n", mUnhandledKeys.size(), mWorkWrite);
+ if (mUnhandledKeys.size() <= 0 && mWorkWrite >= 0) {
+ write_work(mWorkWrite, CMD_DEF_KEY);
+ }
+ mUnhandledKeys.add(keyEvent);
+ mLock.unlock();
+}
+
+bool AInputQueue::preDispatchKey(KeyEvent* keyEvent) {
+ mLock.lock();
+ LOG_TRACE("preDispatch key: pending=%d write=%d\n", mPreDispatchingKeys.size(), mWorkWrite);
+ const size_t N = mInFlightEvents.size();
+ for (size_t i=0; i<N; i++) {
+ in_flight_event& inflight(mInFlightEvents.editItemAt(i));
+ if (inflight.event == keyEvent) {
+ if (inflight.seq >= 0) {
+ // This event has already been pre-dispatched!
+ LOG_TRACE("Event already pre-dispatched!");
+ mLock.unlock();
+ return false;
+ }
+ mSeq++;
+ if (mSeq < 0) mSeq = 1;
+ inflight.seq = mSeq;
+
+ if (mPreDispatchingKeys.size() <= 0 && mWorkWrite >= 0) {
+ write_work(mWorkWrite, CMD_DEF_KEY);
+ }
+ mPreDispatchingKeys.add(inflight);
+ mLock.unlock();
+ return true;
+ }
+ }
+
+ LOGW("preDispatchKey called for unknown event: %p", keyEvent);
+ return false;
+}
+
+void AInputQueue::wakeupDispatch() {
restart:
char dummy = 0;
int res = write(mDispatchKeyWrite, &dummy, sizeof(dummy));
@@ -243,31 +413,6 @@
else LOGW("Truncated writing to dispatch fd: %d", res);
}
-KeyEvent* AInputQueue::consumeUnhandledEvent() {
- KeyEvent* event = NULL;
-
- mLock.lock();
- if (mPendingKeys.size() > 0) {
- event = mPendingKeys[0];
- mPendingKeys.removeAt(0);
- }
- mLock.unlock();
-
- LOG_TRACE("consumeUnhandledEvent: KeyEvent=%p", event);
-
- return event;
-}
-
-void AInputQueue::doDefaultKey(KeyEvent* keyEvent) {
- mLock.lock();
- LOG_TRACE("Default key: pending=%d write=%d\n", mPendingKeys.size(), mWorkWrite);
- if (mPendingKeys.size() <= 0 && mWorkWrite >= 0) {
- write_work(mWorkWrite, CMD_DEF_KEY);
- }
- mPendingKeys.add(keyEvent);
- mLock.unlock();
-}
-
namespace android {
// ------------------------------------------------------------------------
@@ -416,11 +561,14 @@
code->env, keyEvent);
code->env->CallVoidMethod(code->clazz,
gNativeActivityClassInfo.dispatchUnhandledKeyEvent, inputEventObj);
- int32_t res = code->nativeInputQueue->getConsumer().sendFinishedSignal();
- if (res != OK) {
- LOGW("Failed to send finished signal on channel '%s'. status=%d",
- code->nativeInputQueue->getConsumer().getChannel()->getName().string(), res);
- }
+ code->nativeInputQueue->finishEvent(keyEvent, true);
+ }
+ int seq;
+ while ((keyEvent=code->nativeInputQueue->consumePreDispatchingEvent(&seq)) != NULL) {
+ jobject inputEventObj = android_view_KeyEvent_fromNative(
+ code->env, keyEvent);
+ code->env->CallVoidMethod(code->clazz,
+ gNativeActivityClassInfo.preDispatchKeyEvent, inputEventObj, seq);
}
} break;
case CMD_SET_WINDOW_FORMAT: {
@@ -451,7 +599,8 @@
static jint
loadNativeCode_native(JNIEnv* env, jobject clazz, jstring path, jobject messageQueue,
- jstring internalDataDir, jstring externalDataDir, int sdkVersion)
+ jstring internalDataDir, jstring externalDataDir, int sdkVersion,
+ jobject jAssetMgr)
{
LOG_TRACE("loadNativeCode_native");
@@ -502,7 +651,7 @@
}
code->env = env;
code->clazz = env->NewGlobalRef(clazz);
-
+
const char* dirStr = env->GetStringUTFChars(internalDataDir, NULL);
code->internalDataPath = dirStr;
code->internalDataPath = code->internalDataPath.string();
@@ -512,9 +661,11 @@
code->externalDataPath = dirStr;
code->externalDataPath = code->externalDataPath.string();
env->ReleaseStringUTFChars(path, dirStr);
-
+
code->sdkVersion = sdkVersion;
+ code->assetManager = assetManagerForJavaObject(env, jAssetMgr);
+
code->createActivityFunc(code, NULL, 0);
}
@@ -762,15 +913,28 @@
if (handle != 0) {
NativeCode* code = (NativeCode*)handle;
if (code->nativeInputQueue != NULL) {
- KeyEvent* event = new KeyEvent();
- android_view_KeyEvent_toNative(env, eventObj, INPUT_EVENT_NATURE_KEY, event);
+ KeyEvent* event = code->nativeInputQueue->createKeyEvent();
+ android_view_KeyEvent_toNative(env, eventObj, event);
code->nativeInputQueue->dispatchEvent(event);
}
}
}
+static void
+finishPreDispatchKeyEvent_native(JNIEnv* env, jobject clazz, jint handle,
+ jint seq, jboolean handled)
+{
+ LOG_TRACE("finishPreDispatchKeyEvent_native");
+ if (handle != 0) {
+ NativeCode* code = (NativeCode*)handle;
+ if (code->nativeInputQueue != NULL) {
+ code->nativeInputQueue->finishPreDispatch(seq, handled ? true : false);
+ }
+ }
+}
+
static const JNINativeMethod g_methods[] = {
- { "loadNativeCode", "(Ljava/lang/String;Landroid/os/MessageQueue;Ljava/lang/String;Ljava/lang/String;I)I",
+ { "loadNativeCode", "(Ljava/lang/String;Landroid/os/MessageQueue;Ljava/lang/String;Ljava/lang/String;ILandroid/content/res/AssetManager;)I",
(void*)loadNativeCode_native },
{ "unloadNativeCode", "(I)V", (void*)unloadNativeCode_native },
{ "onStartNative", "(I)V", (void*)onStart_native },
@@ -788,6 +952,7 @@
{ "onInputChannelDestroyedNative", "(ILandroid/view/InputChannel;)V", (void*)onInputChannelDestroyed_native },
{ "onContentRectChangedNative", "(IIIII)V", (void*)onContentRectChanged_native },
{ "dispatchKeyEventNative", "(ILandroid/view/KeyEvent;)V", (void*)dispatchKeyEvent_native },
+ { "finishPreDispatchKeyEventNative", "(IIZ)V", (void*)finishPreDispatchKeyEvent_native },
};
static const char* const kNativeActivityPathName = "android/app/NativeActivity";
@@ -810,6 +975,9 @@
GET_METHOD_ID(gNativeActivityClassInfo.dispatchUnhandledKeyEvent,
gNativeActivityClassInfo.clazz,
"dispatchUnhandledKeyEvent", "(Landroid/view/KeyEvent;)V");
+ GET_METHOD_ID(gNativeActivityClassInfo.preDispatchKeyEvent,
+ gNativeActivityClassInfo.clazz,
+ "preDispatchKeyEvent", "(Landroid/view/KeyEvent;I)V");
GET_METHOD_ID(gNativeActivityClassInfo.setWindowFlags,
gNativeActivityClassInfo.clazz,
diff --git a/core/jni/android_content_res_ObbScanner.cpp b/core/jni/android_content_res_ObbScanner.cpp
new file mode 100644
index 0000000..1239274
--- /dev/null
+++ b/core/jni/android_content_res_ObbScanner.cpp
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2010, 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.
+ */
+
+#define LOG_TAG "ObbScanner"
+
+#include <utils/Log.h>
+#include <utils/String8.h>
+#include <utils/ObbFile.h>
+
+#include "jni.h"
+#include "utils/misc.h"
+#include "android_runtime/AndroidRuntime.h"
+
+namespace android {
+
+static struct {
+ jclass clazz;
+
+ jfieldID packageName;
+ jfieldID version;
+} gObbInfoClassInfo;
+
+static jboolean android_content_res_ObbScanner_getObbInfo(JNIEnv* env, jobject clazz, jstring file,
+ jobject obbInfo)
+{
+ const char* filePath = env->GetStringUTFChars(file, JNI_FALSE);
+
+ sp<ObbFile> obb = new ObbFile();
+ if (!obb->readFrom(filePath)) {
+ env->ReleaseStringUTFChars(file, filePath);
+ return JNI_FALSE;
+ }
+
+ env->ReleaseStringUTFChars(file, filePath);
+
+ const char* packageNameStr = obb->getPackageName().string();
+
+ jstring packageName = env->NewStringUTF(packageNameStr);
+ if (packageName == NULL) {
+ return JNI_FALSE;
+ }
+
+ env->SetObjectField(obbInfo, gObbInfoClassInfo.packageName, packageName);
+ env->SetIntField(obbInfo, gObbInfoClassInfo.version, obb->getVersion());
+
+ return JNI_TRUE;
+}
+
+/*
+ * JNI registration.
+ */
+static JNINativeMethod gMethods[] = {
+ /* name, signature, funcPtr */
+ { "getObbInfo_native", "(Ljava/lang/String;Landroid/content/res/ObbInfo;)Z",
+ (void*) android_content_res_ObbScanner_getObbInfo },
+};
+
+#define FIND_CLASS(var, className) \
+ var = env->FindClass(className); \
+ LOG_FATAL_IF(! var, "Unable to find class " className); \
+ var = jclass(env->NewGlobalRef(var));
+
+#define GET_FIELD_ID(var, clazz, fieldName, fieldDescriptor) \
+ var = env->GetFieldID(clazz, fieldName, fieldDescriptor); \
+ LOG_FATAL_IF(! var, "Unable to find field " fieldName);
+
+int register_android_content_res_ObbScanner(JNIEnv* env)
+{
+ FIND_CLASS(gObbInfoClassInfo.clazz, "android/content/res/ObbInfo");
+
+ GET_FIELD_ID(gObbInfoClassInfo.packageName, gObbInfoClassInfo.clazz,
+ "packageName", "Ljava/lang/String;");
+ GET_FIELD_ID(gObbInfoClassInfo.version, gObbInfoClassInfo.clazz,
+ "version", "I");
+
+ return AndroidRuntime::registerNativeMethods(env, "android/content/res/ObbScanner", gMethods,
+ NELEM(gMethods));
+}
+
+}; // namespace android
+
diff --git a/core/jni/android_util_Binder.cpp b/core/jni/android_util_Binder.cpp
index d26cd28..040b324 100644
--- a/core/jni/android_util_Binder.cpp
+++ b/core/jni/android_util_Binder.cpp
@@ -134,6 +134,12 @@
jmethodID mConstructor;
} gParcelFileDescriptorOffsets;
+static struct strict_mode_callback_offsets_t
+{
+ jclass mClass;
+ jmethodID mCallback;
+} gStrictModeCallbackOffsets;
+
// ****************************************************************************
// ****************************************************************************
// ****************************************************************************
@@ -214,6 +220,15 @@
env->DeleteLocalRef(msgstr);
}
+static void set_dalvik_blockguard_policy(JNIEnv* env, jint strict_policy)
+{
+ // Call back into android.os.StrictMode#onBinderStrictModePolicyChange
+ // to sync our state back to it. See the comments in StrictMode.java.
+ env->CallStaticVoidMethod(gStrictModeCallbackOffsets.mClass,
+ gStrictModeCallbackOffsets.mCallback,
+ strict_policy);
+}
+
class JavaBBinderHolder;
class JavaBBinder : public BBinder
@@ -253,12 +268,28 @@
LOGV("onTransact() on %p calling object %p in env %p vm %p\n", this, mObject, env, mVM);
+ IPCThreadState* thread_state = IPCThreadState::self();
+ const int strict_policy_before = thread_state->getStrictModePolicy();
+
//printf("Transact from %p to Java code sending: ", this);
//data.print();
//printf("\n");
jboolean res = env->CallBooleanMethod(mObject, gBinderOffsets.mExecTransact,
code, (int32_t)&data, (int32_t)reply, flags);
jthrowable excep = env->ExceptionOccurred();
+
+ // Restore the Java binder thread's state if it changed while
+ // processing a call (as it would if the Parcel's header had a
+ // new policy mask and Parcel.enforceInterface() changed
+ // it...)
+ const int strict_policy_after = thread_state->getStrictModePolicy();
+ if (strict_policy_after != strict_policy_before) {
+ // Our thread-local...
+ thread_state->setStrictModePolicy(strict_policy_before);
+ // And the Java-level thread-local...
+ set_dalvik_blockguard_policy(env, strict_policy_before);
+ }
+
if (excep) {
report_exception(env, excep,
"*** Uncaught remote exception! "
@@ -574,6 +605,16 @@
IPCThreadState::self()->restoreCallingIdentity(token);
}
+static void android_os_Binder_setThreadStrictModePolicy(JNIEnv* env, jobject clazz, jint policyMask)
+{
+ IPCThreadState::self()->setStrictModePolicy(policyMask);
+}
+
+static jint android_os_Binder_getThreadStrictModePolicy(JNIEnv* env, jobject clazz)
+{
+ return IPCThreadState::self()->getStrictModePolicy();
+}
+
static void android_os_Binder_flushPendingCommands(JNIEnv* env, jobject clazz)
{
IPCThreadState::self()->flushCommands();
@@ -618,6 +659,8 @@
{ "getCallingUid", "()I", (void*)android_os_Binder_getCallingUid },
{ "clearCallingIdentity", "()J", (void*)android_os_Binder_clearCallingIdentity },
{ "restoreCallingIdentity", "(J)V", (void*)android_os_Binder_restoreCallingIdentity },
+ { "setThreadStrictModePolicy", "(I)V", (void*)android_os_Binder_setThreadStrictModePolicy },
+ { "getThreadStrictModePolicy", "()I", (void*)android_os_Binder_getThreadStrictModePolicy },
{ "flushPendingCommands", "()V", (void*)android_os_Binder_flushPendingCommands },
{ "init", "()V", (void*)android_os_Binder_init },
{ "destroy", "()V", (void*)android_os_Binder_destroy }
@@ -1523,9 +1566,24 @@
if (parcel != NULL) {
const jchar* str = env->GetStringCritical(name, 0);
if (str) {
- bool isValid = parcel->enforceInterface(String16(str, env->GetStringLength(name)));
+ const int32_t old_strict_policy =
+ IPCThreadState::self()->getStrictModePolicy();
+ int32_t strict_policy;
+ bool isValid = parcel->enforceInterface(
+ String16(str, env->GetStringLength(name)),
+ &strict_policy);
env->ReleaseStringCritical(name, str);
if (isValid) {
+ if (old_strict_policy != strict_policy) {
+ // Need to keep the Java-level thread-local strict
+ // mode policy in sync for the libcore
+ // enforcements, which involves an upcall back
+ // into Java. (We can't modify the
+ // Parcel.enforceInterface signature, as it's
+ // pseudo-public, and used via AIDL
+ // auto-generation...)
+ set_dalvik_blockguard_policy(env, strict_policy);
+ }
return; // everything was correct -> return silently
}
}
@@ -1611,6 +1669,14 @@
gParcelOffsets.mOwnObject
= env->GetFieldID(clazz, "mOwnObject", "I");
+ clazz = env->FindClass("android/os/StrictMode");
+ LOG_FATAL_IF(clazz == NULL, "Unable to find class android.os.StrictMode");
+ gStrictModeCallbackOffsets.mClass = (jclass) env->NewGlobalRef(clazz);
+ gStrictModeCallbackOffsets.mCallback = env->GetStaticMethodID(
+ clazz, "onBinderStrictModePolicyChange", "(I)V");
+ LOG_FATAL_IF(gStrictModeCallbackOffsets.mCallback == NULL,
+ "Unable to find strict mode callback.");
+
return AndroidRuntime::registerNativeMethods(
env, kParcelPathName,
gParcelMethods, NELEM(gParcelMethods));
diff --git a/core/jni/android_view_InputQueue.cpp b/core/jni/android_view_InputQueue.cpp
index 6fb3cf7..556d367 100644
--- a/core/jni/android_view_InputQueue.cpp
+++ b/core/jni/android_view_InputQueue.cpp
@@ -326,12 +326,11 @@
// the input handler object itself for the same reason.
int32_t inputEventType = inputEvent->getType();
- int32_t inputEventNature = inputEvent->getNature();
jobject inputEventObj;
jmethodID dispatchMethodId;
switch (inputEventType) {
- case INPUT_EVENT_TYPE_KEY:
+ case AINPUT_EVENT_TYPE_KEY:
#if DEBUG_DISPATCH_CYCLE
LOGD("channel '%s' ~ Received key event.", connection->getInputChannelName());
#endif
@@ -340,7 +339,7 @@
dispatchMethodId = gInputQueueClassInfo.dispatchKeyEvent;
break;
- case INPUT_EVENT_TYPE_MOTION:
+ case AINPUT_EVENT_TYPE_MOTION:
#if DEBUG_DISPATCH_CYCLE
LOGD("channel '%s' ~ Received motion event.", connection->getInputChannelName());
#endif
@@ -367,7 +366,7 @@
#endif
env->CallStaticVoidMethod(gInputQueueClassInfo.clazz,
dispatchMethodId, inputHandlerObjLocal, inputEventObj,
- jint(inputEventNature), jlong(finishedToken));
+ jlong(finishedToken));
#if DEBUG_DISPATCH_CYCLE
LOGD("Returned from input handler.");
#endif
@@ -414,6 +413,7 @@
jobject inputChannelObj, jobject inputHandlerObj, jobject messageQueueObj) {
status_t status = gNativeInputQueue.registerInputChannel(
env, inputChannelObj, inputHandlerObj, messageQueueObj);
+
if (status) {
jniThrowRuntimeException(env, "Failed to register input channel. "
"Check logs for details.");
@@ -423,6 +423,7 @@
static void android_view_InputQueue_nativeUnregisterInputChannel(JNIEnv* env, jclass clazz,
jobject inputChannelObj) {
status_t status = gNativeInputQueue.unregisterInputChannel(env, inputChannelObj);
+
if (status) {
jniThrowRuntimeException(env, "Failed to unregister input channel. "
"Check logs for details.");
@@ -433,7 +434,11 @@
jlong finishedToken) {
status_t status = gNativeInputQueue.finished(
env, finishedToken, false /*ignoreSpuriousFinish*/);
- if (status) {
+
+ // We ignore the case where an event could not be finished because the input channel
+ // was no longer registered (DEAD_OBJECT) since it is a common race that can occur
+ // during application shutdown. The input dispatcher recovers gracefully anyways.
+ if (status != OK && status != DEAD_OBJECT) {
jniThrowRuntimeException(env, "Failed to finish input event. "
"Check logs for details.");
}
@@ -471,11 +476,11 @@
GET_STATIC_METHOD_ID(gInputQueueClassInfo.dispatchKeyEvent, gInputQueueClassInfo.clazz,
"dispatchKeyEvent",
- "(Landroid/view/InputHandler;Landroid/view/KeyEvent;IJ)V");
+ "(Landroid/view/InputHandler;Landroid/view/KeyEvent;J)V");
GET_STATIC_METHOD_ID(gInputQueueClassInfo.dispatchMotionEvent, gInputQueueClassInfo.clazz,
"dispatchMotionEvent",
- "(Landroid/view/InputHandler;Landroid/view/MotionEvent;IJ)V");
+ "(Landroid/view/InputHandler;Landroid/view/MotionEvent;J)V");
return 0;
}
diff --git a/core/jni/android_view_KeyEvent.cpp b/core/jni/android_view_KeyEvent.cpp
index 8f648f4..7e7583c 100644
--- a/core/jni/android_view_KeyEvent.cpp
+++ b/core/jni/android_view_KeyEvent.cpp
@@ -32,12 +32,13 @@
jmethodID ctor;
+ jfieldID mDeviceId;
+ jfieldID mSource;
jfieldID mMetaState;
jfieldID mAction;
jfieldID mKeyCode;
jfieldID mScanCode;
jfieldID mRepeatCount;
- jfieldID mDeviceId;
jfieldID mFlags;
jfieldID mDownTime;
jfieldID mEventTime;
@@ -56,22 +57,24 @@
event->getMetaState(),
event->getDeviceId(),
event->getScanCode(),
- event->getFlags());
+ event->getFlags(),
+ event->getSource());
}
-void android_view_KeyEvent_toNative(JNIEnv* env, jobject eventObj, int32_t nature,
+void android_view_KeyEvent_toNative(JNIEnv* env, jobject eventObj,
KeyEvent* event) {
+ jint deviceId = env->GetIntField(eventObj, gKeyEventClassInfo.mDeviceId);
+ jint source = env->GetIntField(eventObj, gKeyEventClassInfo.mSource);
jint metaState = env->GetIntField(eventObj, gKeyEventClassInfo.mMetaState);
jint action = env->GetIntField(eventObj, gKeyEventClassInfo.mAction);
jint keyCode = env->GetIntField(eventObj, gKeyEventClassInfo.mKeyCode);
jint scanCode = env->GetIntField(eventObj, gKeyEventClassInfo.mScanCode);
jint repeatCount = env->GetIntField(eventObj, gKeyEventClassInfo.mRepeatCount);
- jint deviceId = env->GetIntField(eventObj, gKeyEventClassInfo.mDeviceId);
jint flags = env->GetIntField(eventObj, gKeyEventClassInfo.mFlags);
jlong downTime = env->GetLongField(eventObj, gKeyEventClassInfo.mDownTime);
jlong eventTime = env->GetLongField(eventObj, gKeyEventClassInfo.mEventTime);
- event->initialize(deviceId, nature, action, flags, keyCode, scanCode, metaState, repeatCount,
+ event->initialize(deviceId, source, action, flags, keyCode, scanCode, metaState, repeatCount,
milliseconds_to_nanoseconds(downTime),
milliseconds_to_nanoseconds(eventTime));
}
@@ -91,8 +94,6 @@
{ "native_hasDefaultAction", "(I)Z", (void*)native_hasDefaultAction },
};
-static const char* const kKeyEventPathName = "android/view/KeyEvent";
-
#define FIND_CLASS(var, className) \
var = env->FindClass(className); \
LOG_FATAL_IF(! var, "Unable to find class " className); \
@@ -107,11 +108,15 @@
LOG_FATAL_IF(! var, "Unable to find field " fieldName);
int register_android_view_KeyEvent(JNIEnv* env) {
- FIND_CLASS(gKeyEventClassInfo.clazz, kKeyEventPathName);
+ FIND_CLASS(gKeyEventClassInfo.clazz, "android/view/KeyEvent");
GET_METHOD_ID(gKeyEventClassInfo.ctor, gKeyEventClassInfo.clazz,
- "<init>", "(JJIIIIIII)V");
+ "<init>", "(JJIIIIIIII)V");
+ GET_FIELD_ID(gKeyEventClassInfo.mDeviceId, gKeyEventClassInfo.clazz,
+ "mDeviceId", "I");
+ GET_FIELD_ID(gKeyEventClassInfo.mSource, gKeyEventClassInfo.clazz,
+ "mSource", "I");
GET_FIELD_ID(gKeyEventClassInfo.mMetaState, gKeyEventClassInfo.clazz,
"mMetaState", "I");
GET_FIELD_ID(gKeyEventClassInfo.mAction, gKeyEventClassInfo.clazz,
@@ -122,8 +127,6 @@
"mScanCode", "I");
GET_FIELD_ID(gKeyEventClassInfo.mRepeatCount, gKeyEventClassInfo.clazz,
"mRepeatCount", "I");
- GET_FIELD_ID(gKeyEventClassInfo.mDeviceId, gKeyEventClassInfo.clazz,
- "mDeviceId", "I");
GET_FIELD_ID(gKeyEventClassInfo.mFlags, gKeyEventClassInfo.clazz,
"mFlags", "I");
GET_FIELD_ID(gKeyEventClassInfo.mDownTime, gKeyEventClassInfo.clazz,
@@ -134,8 +137,7 @@
"mCharacters", "Ljava/lang/String;");
return AndroidRuntime::registerNativeMethods(
- env, kKeyEventPathName,
- g_methods, NELEM(g_methods));
+ env, "android/view/KeyEvent", g_methods, NELEM(g_methods));
}
} // namespace android
diff --git a/core/jni/android_view_KeyEvent.h b/core/jni/android_view_KeyEvent.h
index 3c71b1a..0bd410c 100644
--- a/core/jni/android_view_KeyEvent.h
+++ b/core/jni/android_view_KeyEvent.h
@@ -27,7 +27,7 @@
extern jobject android_view_KeyEvent_fromNative(JNIEnv* env, const KeyEvent* event);
/* Copies the contents of a DVM KeyEvent object to a native KeyEvent instance. */
-extern void android_view_KeyEvent_toNative(JNIEnv* env, jobject eventObj, int32_t nature,
+extern void android_view_KeyEvent_toNative(JNIEnv* env, jobject eventObj,
KeyEvent* event);
} // namespace android
diff --git a/core/jni/android_view_MotionEvent.cpp b/core/jni/android_view_MotionEvent.cpp
index 78137e2..fe247e8 100644
--- a/core/jni/android_view_MotionEvent.cpp
+++ b/core/jni/android_view_MotionEvent.cpp
@@ -24,7 +24,7 @@
#include "android_view_MotionEvent.h"
// Number of float items per entry in a DVM sample data array
-#define NUM_SAMPLE_DATA 4
+#define NUM_SAMPLE_DATA 9
namespace android {
@@ -36,13 +36,14 @@
jmethodID obtain;
jmethodID recycle;
+ jfieldID mDeviceId;
+ jfieldID mSource;
jfieldID mDownTimeNano;
jfieldID mAction;
jfieldID mXOffset;
jfieldID mYOffset;
jfieldID mXPrecision;
jfieldID mYPrecision;
- jfieldID mDeviceId;
jfieldID mEdgeFlags;
jfieldID mMetaState;
jfieldID mNumPointers;
@@ -70,6 +71,10 @@
return NULL;
}
+ env->SetIntField(eventObj, gMotionEventClassInfo.mDeviceId,
+ event->getDeviceId());
+ env->SetIntField(eventObj, gMotionEventClassInfo.mSource,
+ event->getSource());
env->SetLongField(eventObj, gMotionEventClassInfo.mDownTimeNano,
event->getDownTime());
env->SetIntField(eventObj, gMotionEventClassInfo.mAction,
@@ -82,8 +87,6 @@
event->getXPrecision());
env->SetFloatField(eventObj, gMotionEventClassInfo.mYPrecision,
event->getYPrecision());
- env->SetIntField(eventObj, gMotionEventClassInfo.mDeviceId,
- event->getDeviceId());
env->SetIntField(eventObj, gMotionEventClassInfo.mEdgeFlags,
event->getEdgeFlags());
env->SetIntField(eventObj, gMotionEventClassInfo.mMetaState,
@@ -129,6 +132,11 @@
*(destDataSamples++) = srcSamplePointerCoords->y;
*(destDataSamples++) = srcSamplePointerCoords->pressure;
*(destDataSamples++) = srcSamplePointerCoords->size;
+ *(destDataSamples++) = srcSamplePointerCoords->touchMajor;
+ *(destDataSamples++) = srcSamplePointerCoords->touchMinor;
+ *(destDataSamples++) = srcSamplePointerCoords->toolMajor;
+ *(destDataSamples++) = srcSamplePointerCoords->toolMinor;
+ *(destDataSamples++) = srcSamplePointerCoords->orientation;
srcSamplePointerCoords += 1;
}
@@ -142,15 +150,16 @@
return eventObj;
}
-void android_view_MotionEvent_toNative(JNIEnv* env, jobject eventObj, int32_t nature,
+void android_view_MotionEvent_toNative(JNIEnv* env, jobject eventObj,
MotionEvent* event) {
+ jint deviceId = env->GetIntField(eventObj, gMotionEventClassInfo.mDeviceId);
+ jint source = env->GetIntField(eventObj, gMotionEventClassInfo.mSource);
jlong downTimeNano = env->GetLongField(eventObj, gMotionEventClassInfo.mDownTimeNano);
jint action = env->GetIntField(eventObj, gMotionEventClassInfo.mAction);
jfloat xOffset = env->GetFloatField(eventObj, gMotionEventClassInfo.mXOffset);
jfloat yOffset = env->GetFloatField(eventObj, gMotionEventClassInfo.mYOffset);
jfloat xPrecision = env->GetFloatField(eventObj, gMotionEventClassInfo.mXPrecision);
jfloat yPrecision = env->GetFloatField(eventObj, gMotionEventClassInfo.mYPrecision);
- jint deviceId = env->GetIntField(eventObj, gMotionEventClassInfo.mDeviceId);
jint edgeFlags = env->GetIntField(eventObj, gMotionEventClassInfo.mEdgeFlags);
jint metaState = env->GetIntField(eventObj, gMotionEventClassInfo.mMetaState);
jint numPointers = env->GetIntField(eventObj, gMotionEventClassInfo.mNumPointers);
@@ -180,9 +189,14 @@
samplePointerCoords[j].y = *(srcDataSamples++);
samplePointerCoords[j].pressure = *(srcDataSamples++);
samplePointerCoords[j].size = *(srcDataSamples++);
+ samplePointerCoords[j].touchMajor = *(srcDataSamples++);
+ samplePointerCoords[j].touchMinor = *(srcDataSamples++);
+ samplePointerCoords[j].toolMajor = *(srcDataSamples++);
+ samplePointerCoords[j].toolMinor = *(srcDataSamples++);
+ samplePointerCoords[j].orientation = *(srcDataSamples++);
}
- event->initialize(deviceId, nature, action, edgeFlags, metaState,
+ event->initialize(deviceId, source, action, edgeFlags, metaState,
xOffset, yOffset, xPrecision, yPrecision, downTimeNano, sampleEventTime,
numPointers, pointerIdentifiers, samplePointerCoords);
@@ -193,6 +207,11 @@
samplePointerCoords[j].y = *(srcDataSamples++);
samplePointerCoords[j].pressure = *(srcDataSamples++);
samplePointerCoords[j].size = *(srcDataSamples++);
+ samplePointerCoords[j].touchMajor = *(srcDataSamples++);
+ samplePointerCoords[j].touchMinor = *(srcDataSamples++);
+ samplePointerCoords[j].toolMajor = *(srcDataSamples++);
+ samplePointerCoords[j].toolMinor = *(srcDataSamples++);
+ samplePointerCoords[j].orientation = *(srcDataSamples++);
}
event->addSample(sampleEventTime, samplePointerCoords);
}
@@ -242,6 +261,10 @@
GET_METHOD_ID(gMotionEventClassInfo.recycle, gMotionEventClassInfo.clazz,
"recycle", "()V");
+ GET_FIELD_ID(gMotionEventClassInfo.mDeviceId, gMotionEventClassInfo.clazz,
+ "mDeviceId", "I");
+ GET_FIELD_ID(gMotionEventClassInfo.mSource, gMotionEventClassInfo.clazz,
+ "mSource", "I");
GET_FIELD_ID(gMotionEventClassInfo.mDownTimeNano, gMotionEventClassInfo.clazz,
"mDownTimeNano", "J");
GET_FIELD_ID(gMotionEventClassInfo.mAction, gMotionEventClassInfo.clazz,
@@ -254,8 +277,6 @@
"mXPrecision", "F");
GET_FIELD_ID(gMotionEventClassInfo.mYPrecision, gMotionEventClassInfo.clazz,
"mYPrecision", "F");
- GET_FIELD_ID(gMotionEventClassInfo.mDeviceId, gMotionEventClassInfo.clazz,
- "mDeviceId", "I");
GET_FIELD_ID(gMotionEventClassInfo.mEdgeFlags, gMotionEventClassInfo.clazz,
"mEdgeFlags", "I");
GET_FIELD_ID(gMotionEventClassInfo.mMetaState, gMotionEventClassInfo.clazz,
diff --git a/core/jni/android_view_MotionEvent.h b/core/jni/android_view_MotionEvent.h
index 03ee32f..86e4bde 100644
--- a/core/jni/android_view_MotionEvent.h
+++ b/core/jni/android_view_MotionEvent.h
@@ -27,7 +27,7 @@
extern jobject android_view_MotionEvent_fromNative(JNIEnv* env, const MotionEvent* event);
/* Copies the contents of a DVM MotionEvent object to a native MotionEvent instance. */
-extern void android_view_MotionEvent_toNative(JNIEnv* env, jobject eventObj, int32_t nature,
+extern void android_view_MotionEvent_toNative(JNIEnv* env, jobject eventObj,
MotionEvent* event);
/* Recycles a DVM MotionEvent object. */
diff --git a/core/jni/android_view_Surface.cpp b/core/jni/android_view_Surface.cpp
index 7305032..c4d6d1b 100644
--- a/core/jni/android_view_Surface.cpp
+++ b/core/jni/android_view_Surface.cpp
@@ -237,7 +237,7 @@
return;
}
- sp<Surface> sur(Surface::readFromParcel(*parcel, 0));
+ sp<Surface> sur(Surface::readFromParcel(*parcel));
setSurface(env, clazz, sur);
}
@@ -616,8 +616,7 @@
return;
}
- const sp<Surface>& curr(getSurface(env, clazz));
- sp<Surface> sur(Surface::readFromParcel(*parcel, curr));
+ sp<Surface> sur(Surface::readFromParcel(*parcel));
setSurface(env, clazz, sur);
}
@@ -729,4 +728,3 @@
}
};
-
diff --git a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/ConnectivityManagerTestActivity.java b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/ConnectivityManagerTestActivity.java
index 7392ad4..e42b657 100644
--- a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/ConnectivityManagerTestActivity.java
+++ b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/ConnectivityManagerTestActivity.java
@@ -24,6 +24,7 @@
import android.os.Bundle;
import android.provider.Settings;
import android.util.Log;
+import android.view.KeyEvent;
import java.util.List;
import android.widget.LinearLayout;
import android.net.ConnectivityManager;
@@ -64,6 +65,8 @@
public int mWifiState;
public NetworkInfo mWifiNetworkInfo;
public String mBssid;
+ public String mPowerSsid = "GoogleGuest"; //Default power SSID
+ private Context mContext;
/*
* Control Wifi States
@@ -404,4 +407,44 @@
}
Log.v(LOG_TAG, "onDestroy, inst=" + Integer.toHexString(hashCode()));
}
+
+ @Override
+ public void onStart() {
+ super.onStart();
+ mContext = this;
+ Bundle bundle = this.getIntent().getExtras();
+ if (bundle != null){
+ mPowerSsid = bundle.getString("power_ssid");
+ }
+ }
+ //A thread to set the device into airplane mode then turn on wifi.
+ Thread setDeviceWifiAndAirplaneThread = new Thread(new Runnable() {
+ public void run() {
+ setAirplaneMode(mContext, true);
+ connectToWifi(mPowerSsid);
+ }
+ });
+
+ //A thread to set the device into wifi
+ Thread setDeviceInWifiOnlyThread = new Thread(new Runnable() {
+ public void run() {
+ connectToWifi(mPowerSsid);
+ }
+ });
+
+ @Override
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
+ switch (keyCode) {
+ //This is a tricky way for the scripted monkey to
+ //set the device in wifi and wifi in airplane mode.
+ case KeyEvent.KEYCODE_1:
+ setDeviceWifiAndAirplaneThread.start();
+ break;
+
+ case KeyEvent.KEYCODE_2:
+ setDeviceInWifiOnlyThread.start();
+ break;
+ }
+ return super.onKeyDown(keyCode, event);
+ }
}
diff --git a/docs/html/guide/developing/eclipse-adt.jd b/docs/html/guide/developing/eclipse-adt.jd
index 66379a3..9c77ece 100644
--- a/docs/html/guide/developing/eclipse-adt.jd
+++ b/docs/html/guide/developing/eclipse-adt.jd
@@ -785,6 +785,8 @@
have first started <a href="{@docRoot}guide/developing/tools/ddms.html">DDMS</a>). </p>
+
+
<!-- TODO: clean this up and expand it to cover more wizards and features
<h3>ADT Wizards</h3>
diff --git a/docs/html/guide/developing/tools/avd.jd b/docs/html/guide/developing/tools/avd.jd
index acebb7e..ca197cf 100644
--- a/docs/html/guide/developing/tools/avd.jd
+++ b/docs/html/guide/developing/tools/avd.jd
@@ -11,16 +11,13 @@
hardware options, system image, and data storage.
<li>You create AVD configurations to model different device environments
in the Android emulator.</li>
- <li>The <code>android</code> tool offers a graphical Android AVD
- Manager and a command-line interface for creating AVDs.</li>
- </ul>
+ <li>You can launch a graphical Android AVD Manager either through Eclipse or
+through the <code>android</code> tool. The <code>android</code> tool also offers
+a command-line interface for creating and managing AVDs.</li> </ul>
<h2>In this document</h2>
<ol>
<li><a href="#creating">Creating an AVD</a>
<ol>
- <li><a href="#listingtargets">Listing targets</a></li>
- <li><a href="#selectingtarget">Selecting a target</a></li>
- <li><a href="#createavd">Creating the AVD</a></li>
<li><a href="#hardwareopts">Setting hardware emulation options</a></li>
<li><a href="#location">Default location of the AVD files</a></li>
</ol>
@@ -74,15 +71,12 @@
href="{@docRoot}guide/developing/tools/emulator.html">Emulator</a>
documentation. </p>
-<p>To create and manage AVDs, you use the <code>android</code> tool provided in
-the <code>tools/</code> directory of the Android SDK. The tool provides both a
-graphical AVD manager and a command-line interface that you can use to
-create AVDs. To access the graphical AVD manager, run the
-<code>android</code> tool without options. The sections below describe how to
-use the <code>android</code> command-line interface to create and manage AVDs.
-Note that some functionality, such as the capability to create an AVD with a
-custom hardware configuration, are only available through the command-line
-interface. </p>
+<p>The easiest way to create an AVD is to use the graphical AVD Manager, which
+you can launch from Eclipse or from the command line using the
+<code>android</code> tool. The <code>android</code> tool is provided in the
+<code>tools/</code> directory of the Android SDK. When you run the
+<code>android</code> tool without options, it launches the graphical AVD
+Manager.</p>
<p>For more information about how to work with AVDs from inside your development
environment, see <a
@@ -99,146 +93,51 @@
(even the Hello World application).</p>
</div>
</div>
+<p>The easiest way to create an AVD is to use the graphical AVD Manager, but the
+<code>android</code> tool also offers a <a href="#options">command line option</a>.</p>
+<p>To create an AVD:</p>
+<ol>
+ <li>In Eclipse, choose <strong>Window > Android SDK and AVD Manager</strong>. </li>
+ <p>Alternatively, you can launch the graphical AVD Manager by running the
+<code>android</code> tool with no options.</p>
+ <li>Select <strong>Virtual Devices</strong> in the left panel.</li>
-<p>To create an AVD, you use the <code>android</code> tool, a command-line
-utility available in the <code><sdk>/tools/</code> directory. Managing
-AVDs is one of the two main function of the <code>android</code> tool (the other
-is creating and updating Android projects). Open a terminal window and change to
-the <code><sdk>/tools/</code> directory, if needed</p>
+ <li>Click <strong>New</strong>. </li>
-<p>To create each AVD, you issue the command <code>android create avd</code>,
-with options that specify a name for the new AVD and the system image you want
-to run on the emulator when the AVD is invoked. You can specify other options on
-the command line also, such as to create an emulated SD card for the new AVD, set
-the emulator skin to use, or set a custom location for the AVD's files.</p>
+<p>The <strong>Create New AVD</strong> dialog appears.</p> <a
+href="{@docRoot}images/developing/avd-dialog.png"><img
+src="{@docRoot}images/developing/avd-dialog.png" alt="AVD
+Dialog" /></a>
-<p>Here's the command-line usage for creating an AVD: </p>
-
-<pre>android create avd -n <name> -t <targetID> [-<option> <value>] ... </pre>
-
-<p>You can use any name you want for the AVD, but since you are likely to be
-creating multiple AVDs, you should choose a name that lets you recognize the
-general characteristics offered by the AVD. </p>
-
-<p>As shown in the usage above, you must use the <code>-t</code> (or
-<code>--target</code>) argument when creating a new AVD. The argument sets up a
-mapping between the AVD and the system image that you want to use whenever the
-AVD is invoked. You can specify any Android system image that is available in
-your local SDK — it can be the system image of a standard Android platform
-version or that of any SDK add-on. Later, when applications use the AVD, they'll
-be running on the system that you specify in the <code>-t</code> argument.<p>
-
-<p>To specify the system image to use, you refer to its <em>target ID</em>
-— an integer — as assigned by the <code>android</code> tool. The
-target ID is not derived from the system image name, version, or API Level, or
-other attribute, so you need to have the <code>android</code> tool list the
-available system images and the target ID of each, as described in the next
-section. You should do this <em>before</em> you run the <code>android create
-avd</code> command.
-</p>
-
-<h3 id="listingtargets">Listing targets</h3>
-
-<p>To generate a list of system image targets, use this command: </p>
-
-<pre>android list targets</pre>
-
-<p>The <code>android</code> tool scans the <code><sdk>/platforms</code> and
-<code><sdk>/add-ons</code> directories looking for valid system images and
-then generates the list of targets. Here's an example of the command output:
-</p>
-
-<pre>Available Android targets:
-id:1
- Name: Android 1.1
- Type: platform
- API level: 2
- Skins: HVGA (default), HVGA-L, HVGA-P, QVGA-L, QVGA-P
-id:2
- Name: Android 1.5
- Type: platform
- API level: 3
- Skins: HVGA (default), HVGA-L, HVGA-P, QVGA-L, QVGA-P
-id:3
- Name: Google APIs
- Type: add-on
- Vendor: Google Inc.
- Description: Android + Google APIs
- Based on Android 1.5 (API level 3)
- Libraries:
- * com.google.android.maps (maps.jar)
- API for Google Maps
- Skins: HVGA (default), HVGA-L, QVGA-P, HVGA-P, QVGA-L</pre>
-
-<h3 id="selectingtarget">Selecting a target</h3>
-
-<p>Once you have generated the list of targets available, you can look at the
-characteristics of each system image — name, API Level, external
-libraries, and so on — and determine which target is appropriate for the
-new AVD. </p>
-
-<p>Keep these points in mind when you are selecting a system image target for
-your AVD:</p>
-<ul>
-<li>The API Level of the target is important, because your application will not
-be able to run on a system image whose API Level is less than that required by
-your application, as specified in the <code>minSdkVersion</code> attribute of
-the application's manifest file. For more information about the relationship
-between system API Level and application <code>minSdkVersion</code>, see <a
-href="{@docRoot}guide/publishing/versioning.html#minsdkversion">Specifying
-Minimum System API Version</a>.
-<li>Creating at least one AVD that uses a target whose API Level is greater than
-that required by your application is strongly encouraged, because it allows you to
-test the forward-compatibility of your application. Forward-compatibility
-testing ensures that, when users who have downloaded your application receive a
-system update, your application will continue to function normally. </li>
-<li>If your application declares a <code>uses-library</code> element in its
-manifest file, the application can only run on a system image in which that
-external library is present. If you want your application to run on the AVD you
-are creating, check the application's <code>uses-library</code> element and
-select a system image target that includes that library.
-
-</ul>
-
-<h3 id="createavd">Creating the AVD</h3>
-
-<p>When you've selected the target you want to use and made a note of its ID,
-use the <code>android create avd</code> command to create the AVD, supplying the
-target ID as the <code>-t</code> argument. Here's an example that creates an
-AVD with name "my_android1.5" and target ID "2" (the standard Android 1.5
-system image in the list above): </p>
-
-<pre>android create avd -n my_android1.5 -t 2</pre>
-
-<p>If the target you selected was a standard Android system image ("Type:
-platform"), the <code>android</code> tool next asks you whether you want to
-create a custom hardware profile. </p>
-<pre>Android 1.5 is a basic Android platform.
-Do you wish to create a custom hardware profile [no]</pre>
-
-<p>If you want to set custom hardware emulation options for the AVD, enter
-"yes" and set values as needed. If you want to use the default hardware
-emulation options for the AVD, just press the return key (the default is "no").
-The <code>android</code> tool creates the AVD with name and system image mapping you
-requested, with the options you specified.
-
-<p class="note">If you are creating an AVD whose target is an SDK add-on, the
-<code>android</code> tool does not allow you to set hardware emulation options.
-It assumes that the provider of the add-on has set emulation options
-appropriately for the device that the add-on is modeling, and so prevents you
-from resetting the options. </p>
-<p>For a list of options you can use in the <code>android create avd</code>
-command, see the table in <a href="#options">Command-line options for AVDs</a>,
-at the bottom of
-this page. </p>
+ <li>Type the name of the AVD, such as "my_avd".</li>
+ <li>Choose a target. </li>
+<p>The target is the system image that you want to run on the emulator,
+from the set of platforms that are installed in your SDK environment. You can
+choose a version of the standard Android platform or an SDK add-on. For more
+information about how to add platforms to your SDK, see <a
+href="{@docRoot}sdk/adding-components.html">Adding SDK Components</a>. </p>
+ <li>Optionally specify any additional settings: </li>
+ <dl>
+ <dt><em>SD Card</em></dt> <dd>The path to the SD card image to use with this
+AVD, or the size of a new SD card image to create for this AVD.</dd> </dl>
+<dt><em>Skin</em></dt>
+ <dd>The skin to use for this AVD, identified by name or dimensions.</dd>
+<dt><em>Hardware</em></dt>
+ <dd>The hardware emulation options for the device. For a list of the options, see
+<a href="#hardwareopts">Setting hardware emulation options</a>.</dd>
+ </dl>
+ <li>Click <strong>Create AVD</strong>.</li>
+</ol>
<h3 id="hardwareopts">Setting hardware emulation options</h3>
-<p>When are creating a new AVD that uses a standard Android system image ("Type:
-platform"), the <code>android</code> tool lets you set hardware emulation
-options for virtual device. The table below lists the options available and the
+<p>When you create a new AVD that uses a standard Android system image ("Type:
+platform"), the AVD Manager
+ lets you set hardware emulation
+options for your virtual device.
+The table below lists the options available and the
default values, as well as the names of properties that store the emulated
-hardware options in the AVD's configuration file (the config.ini file in the
+hardware options in the AVD's configuration file (the <code>config.ini</code> file in the
AVD's local directory). </p>
<table>
@@ -266,6 +165,7 @@
</tr>
<tr>
+
<td>Keyboard support</td>
<td>Whether the device has a QWERTY keyboard. Default value is "yes".</td>
<td>hw.keyboard</td>
@@ -299,6 +199,7 @@
<td>Maximum vertical camera pixels</td>
<td>Default value is "480".</td>
<td>hw.camera.maxVerticalPixels</td>
+
</tr>
<tr>
@@ -311,6 +212,7 @@
<td>Battery support</td>
<td>Whether the device can run on a battery. Default value is "yes".</td>
<td>hw.battery</td>
+
</tr>
<tr>
@@ -323,6 +225,7 @@
<td>Audio recording support</td>
<td>Whether the device can record audio. Default value is "yes".</td>
<td>hw.audioInput</td>
+
</tr>
<tr>
@@ -335,6 +238,7 @@
<td>SD Card support</td>
<td>Whether the device supports insertion/removal of virtual SD Cards. Default value is "yes".</td>
<td>hw.sdCard</td>
+
</tr>
<tr>
@@ -347,43 +251,55 @@
<td>Cache partition size</td>
<td>Default value is "66MB".</td>
<td>disk.cachePartition.size </td>
+
</tr>
<tr>
<td>Abstracted LCD density</td>
-<td>Sets the generalized density characteristic used by the AVD's screen. Default value is "160".</td>
+<td>Sets the generalized density characteristic used by the AVD's screen. Most
+skins come with a value (which you can modify), but if a skin doesn't provide
+its own value, the default is 160. </td>
<td>hw.lcd.density </td>
</tr>
+<tr>
+<td>Max VM application heap size</td>
+<td>The maximum heap size a Dalvik application might allocate before being
+killed by the system. Value is in megabytes. Most skins come with a value (which
+you can modify), but if a skin doesn't provide its own value, the default is
+16.</td>
+<td>vm.heapSize</td>
+</tr>
+
</table>
<h3 id="location">Default location of the AVD files</h3>
-<p>When you create an AVD, the <code>android</code> tool creates a dedicated directory for it
+<p>When you create an AVD, the AVD Manager creates a dedicated directory for it
on your development computer. The directory contains the AVD configuration file,
the user data image and SD card image (if available), and any other files
associated with the device. Note that the directory does not contain a system
image — instead, the AVD configuration file contains a mapping to the
system image, which it loads when the AVD is launched. </p>
-<p>The <code>android</code> tool also creates a <AVD name>.ini file for the AVD at the
-root of the .android/avd directory on your computer. The file specifies the
-location of the AVD directory and always remains at the root the .android
-directory.</p>
+<p>The AVD Manager also creates a <code><AVD name>.ini</code> file for the
+AVD at the root of the <code>.android/avd</code> directory on your computer. The file
+specifies the location of the AVD directory and always remains at the root the
+.android directory.</p>
-<p>By default, the <code>android</code> tool creates the AVD directory inside
+<p>By default, the AVD Manager creates the AVD directory inside
<code>~/.android/avd/</code> (on Linux/Mac), <code>C:\Documents and
Settings\<user>\.android\</code> on Windows XP, and
<code>C:\Users\<user>\.android\</code> on Windows Vista.
If you want to use a custom location for the AVD directory, you
can do so by using the <code>-p <path></code> option when
-you create the AVD: </p>
+you create the AVD (command line tool only): </p>
<pre>android create avd -n my_android1.5 -t 2 -p path/to/my/avd</pre>
-<p>If the .android directory is hosted on a network drive, we recommend using
+<p>If the <code>.android</code> directory is hosted on a network drive, we recommend using
the <code>-p</code> option to place the AVD directory in another location.
-The AVD's .ini file remains in the .android directory on the network
+The AVD's <code>.ini</code> file remains in the <code>.android</code> directory on the network
drive, regardless of the location of the AVD directory. </p>
<h2 id="managing">Managing AVDs</h2>
@@ -401,18 +317,15 @@
<h3 id="updating">Updating an AVD</h3>
-<p>If, for any reason, the platform/add-on root folder has its name changed (maybe because the user has installed an update of the platform/add-on) then the AVD will not be able to load the system image that it is mapped to. In this case, the <code>android list targets</code> command will produce this output:
-
-<pre>The following Android Virtual Devices could not be loaded:
-Name: foo
-Path: <path>/.android/avd/foo.avd
-Error: Invalid value in image.sysdir. Run 'android update avd -n foo' </pre>
-
-<p>To fix this error, use the <code>android update avd</code> command to recompute the path to the system images.</p>
+<p>
+If you rename or move the root directory of a platform (or add-on), an AVD configured to use that platform will no longer be able to load the system image properly. To fix the AVD, use the <strong>Repair...</strong> button in the AVD Manager. From the command line, you can also use the <code>android update avd</code> command to recompute the path to the system images.</p>
<h3 id="deleting">Deleting an AVD</h3>
-<p>You can use the <code>android</code> tool to delete an AVD. Here is the command usage:</p>
+<p>You can delete an AVD in the AVD Manager by selecting the
+AVD and clicking <strong>Delete</strong>.</p>
+
+<p>Alternatively, you can use the <code>android</code> tool to delete an AVD. Here is the command usage:</p>
<pre>android delete avd -n <name> </pre>
@@ -420,7 +333,21 @@
specified name deletes the AVD's directory and files. </p>
-<h2 id="options">Command-line options for AVDs</h2>
+<h2 id="options">Command-line options</h2>
+
+<p>You can use the <code>android</code> tool to create and manage AVDs.</p>
+
+<p>The command line for creating an AVD has the following syntax:</p>
+
+<pre>
+android create avd -n <name> -t <targetID> [-<option> <value>] ...
+</pre>
+
+<p>Here's an example that creates an AVD with the name "my_android2.2" and target ID "3":</p>
+
+<pre>
+android create avd -n my_android2.2 -t 3
+</pre>
<p>The table below lists the command-line options you can use with the
<code>android</code> tool. </p>
diff --git a/docs/html/guide/topics/resources/drawable-resource.jd b/docs/html/guide/topics/resources/drawable-resource.jd
index 1e4cca7..1c3cc4d 100644
--- a/docs/html/guide/topics/resources/drawable-resource.jd
+++ b/docs/html/guide/topics/resources/drawable-resource.jd
@@ -12,9 +12,10 @@
</div>
</div>
-<p>A drawable resource is a general concept for a graphic that you
-can retrieve with {@link android.content.res.Resources#getDrawable(int)}
-and draw on the screen. There are several different types of drawables:</p>
+<p>A drawable resource is a general concept for a graphic that can be drawn to the screen and which
+you can retrieve with APIs such as {@link android.content.res.Resources#getDrawable(int)} or apply
+to another XML resource with attributes such as {@code android:drawable} and {@code android:icon}.
+There are several different types of drawables:</p>
<dl>
<dt><a href="#Bitmap">Bitmap File</a><dt>
<dd>A bitmap graphic file ({@code .png}, {@code .jpg}, or {@code .gif}).
@@ -51,6 +52,12 @@
<p>Also see the <a href="animation-resource.html">Animation Resource</a> document for how to
create an {@link android.graphics.drawable.AnimationDrawable}.</p>
+<p class="note"><strong>Note:</strong> A <a
+href="{@docRoot}guide/topics/resources/more-resources.html#Color">color resource</a> can also be
+used as a drawable in XML. For example, when creating a <a href="#StateList">state list
+drawable</a>, you can reference a color resource for the {@code android:drawable} attribute ({@code
+android:drawable="@color/green"}).</p>
+
diff --git a/docs/html/guide/topics/resources/more-resources.jd b/docs/html/guide/topics/resources/more-resources.jd
index 22abbb2..1f03446 100644
--- a/docs/html/guide/topics/resources/more-resources.jd
+++ b/docs/html/guide/topics/resources/more-resources.jd
@@ -114,8 +114,9 @@
<h2 id="Color">Color</h2>
<p>A color value defined in XML.
-The color is specified with an RGB value and alpha channel. You can use color resource
-any place that accepts a hexadecimal color value.</p>
+The color is specified with an RGB value and alpha channel. You can use a color resource
+any place that accepts a hexadecimal color value. You can also use a color resource when a
+drawable resource is expected in XML (for example, {@code android:drawable="@color/green"}).</p>
<p>The value always begins with a pound (#) character and then followed by the
Alpha-Red-Green-Blue information in one of the following formats:</p>
diff --git a/docs/html/guide/topics/search/adding-custom-suggestions.jd b/docs/html/guide/topics/search/adding-custom-suggestions.jd
index 9ea4c8b..ce0c619 100644
--- a/docs/html/guide/topics/search/adding-custom-suggestions.jd
+++ b/docs/html/guide/topics/search/adding-custom-suggestions.jd
@@ -5,74 +5,88 @@
<div id="qv-wrapper">
<div id="qv">
-<h2>Key classes</h2>
-<ol>
-<li>{@link android.app.SearchManager}</li>
-<li>{@link android.content.SearchRecentSuggestionsProvider}</li>
-<li>{@link android.content.ContentProvider}</li>
-</ol>
<h2>In this document</h2>
<ol>
<li><a href="#TheBasics">The Basics</a></li>
-<li><a href="#CustomSearchableConfiguration">Modifying the searchable configuration</a></li>
+<li><a href="#CustomSearchableConfiguration">Modifying the Searchable Configuration</a></li>
<li><a href="#CustomContentProvider">Creating a Content Provider</a>
<ol>
<li><a href="#HandlingSuggestionQuery">Handling a suggestion query</a></li>
<li><a href="#SuggestionTable">Building a suggestion table</a></li>
</ol>
</li>
-<li><a href="#IntentForSuggestions">Declaring an Intent for suggestions</a>
+<li><a href="#IntentForSuggestions">Declaring an Intent for Suggestions</a>
<ol>
<li><a href="#IntentAction">Declaring the Intent action</a></li>
<li><a href="#IntentData">Declaring the Intent data</a></li>
</ol>
</li>
<li><a href="#HandlingIntent">Handling the Intent</a></li>
-<li><a href="#RewritingQueryText">Rewriting the query text</a></li>
-<li><a href="#QSB">Exposing search suggestions to Quick Search Box</a></li>
+<li><a href="#RewritingQueryText">Rewriting the Query Text</a></li>
+<li><a href="#QSB">Exposing Search Suggestions to Quick Search Box</a></li>
</ol>
+
+<h2>Key classes</h2>
+<ol>
+<li>{@link android.app.SearchManager}</li>
+<li>{@link android.content.SearchRecentSuggestionsProvider}</li>
+<li>{@link android.content.ContentProvider}</li>
+</ol>
+
+<h2>Related Samples</h2>
+<ol>
+<li><a href="{@docRoot}resources/samples/SearchableDictionary/index.html">Searchable
+Dictionary</a></li>
+</ol>
+
<h2>See also</h2>
<ol>
<li><a href="searchable-config.html">Searchable Configuration</a></li>
<li><a href="{@docRoot}guide/topics/providers/content-providers.html">Content Providers</a></li>
-<li><a href="{@docRoot}resources/samples/SearchableDictionary/index.html">Searchable
-Dictionary sample app</a></li>
</ol>
</div>
</div>
-<p>The Android search framework provides the ability for your application to
-provide suggestions while the user types into the Android search dialog. In this guide, you'll learn
-how to create custom suggestions. These are suggestions based on custom data provided by your
-application. For example, if your application is a word dictionary, you can suggest words from the
-dictionary that match the text entered so far. These are the most valuable suggestions because you
-can effectively predict what the user wants and provide instant access to it. Once you provide
-custom suggestions, you then make them available to the system-wide Quick Search Box, providing
-access to your content from outside your application.</p>
+<p>When using the Android search dialog, you can provide custom search suggestions that are
+created from data in your application. For example, if your application is a word
+dictionary, you can suggest words from the
+dictionary that match the text entered so far. These are the most valuable suggestions, because you
+can effectively predict what the user wants and provide instant access to it. Figure 1 shows
+an example of a search dialog with custom suggestions.</p>
-<p>Before you begin, you need to have implemented the Android search dialog for searches in your
-application. If you haven't done this, see <a href="search-dialog.html">Using the Android Search
+<p>Once you provide custom suggestions, you can also make them available to the system-wide Quick
+Search Box, providing access to your content from outside your application.</p>
+
+<p>Before you begin with this guide to add custom suggestions, you need to have implemented the
+Android search dialog for searches in your
+application. If you haven't, see <a href="search-dialog.html">Using the Android Search
Dialog</a>.</p>
<h2 id="TheBasics">The Basics</h2>
-<img src="{@docRoot}images/search/search-suggest-custom.png" alt="" height="417"
-style="float:right;clear:right;" />
+<div class="figure" style="width:250px">
+<img src="{@docRoot}images/search/search-suggest-custom.png" alt="" height="417" />
+<p class="img-caption"><strong>Figure 1.</strong> Screenshot of a search dialog with custom
+search suggestions.</p>
+</div>
-<p>When the user selects a custom suggestions, the Search Manager will send a customized Intent to
-your searchable Activity. Whereas a normal search query will send an Intent with the {@link
+<p>When the user selects a custom suggestion, the Search Manager sends an {@link
+android.content.Intent} to
+your searchable Activity. Whereas a normal search query sends an Intent with the {@link
android.content.Intent#ACTION_SEARCH} action, you can instead define your custom suggestions to use
-{@link android.content.Intent#ACTION_VIEW} (or any other action), and also include additional data
+{@link android.content.Intent#ACTION_VIEW} (or any other Intent action), and also include data
that's relevant to the selected suggestion. Continuing
the dictionary example, when the user selects a suggestion, your application can immediately
open the definition for that word, instead of searching the dictionary for matches.</p>
-<p>To provide custom suggestions, you need to do the following:</p>
+<p>To provide custom suggestions, do the following:</p>
<ul>
<li>Implement a basic searchable Activity, as described in <a
href="search-dialog.html">Using the Android Search Dialog</a>.</li>
+ <li>Modify the searchable configuration with information about the content provider that
+provides custom suggestions.</li>
<li>Build a table (such as in an {@link android.database.sqlite.SQLiteDatabase}) for your
suggestions and format the table with required columns.</li>
<li>Create a <a href="{@docRoot}guide/topics/providers/content-providers.html">Content
@@ -80,36 +94,32 @@
in your manifest.</li>
<li>Declare the type of {@link android.content.Intent} to be sent when the user selects a
suggestion (including a custom action and custom data). </li>
- <li>Modify the searchable configuration with information about the content provider.</li>
</ul>
-<p>Just like the Search Manager handles the rendering of the search dialog, it will also do the work
-to display all search suggestions below the search dialog. All you need to do is provide a source
-from which the suggestions can be retrieved.</p>
-
-<p class="note"><strong>Note:</strong> If you're not familiar with creating Content
-Providers, please read the <a href="{@docRoot}guide/topics/providers/content-providers.html">Content
+<p>Just like the Search Manager displays the search dialog, it also displays your search
+suggestions. All you need is a content provider from which the Search Manager can retrieve your
+suggestions. If you're not familiar with creating content
+providers, read the <a href="{@docRoot}guide/topics/providers/content-providers.html">Content
Providers</a> developer guide before you continue.</p>
-<p>When the Search Manager identifies that your Activity is searchable and also provides search
-suggestions, the following procedure will take place as soon as the user types into the Android
-search box:</p>
+<p>When the Search Manager identifies that your Activity is searchable and provides search
+suggestions, the following procedure takes place as soon as the user enters text into the
+search dialog:</p>
-<ul>
- <li>The Search Manager takes the search query text (whatever has been typed so far) and performs a
-query to the content provider that manages your suggestions.</li>
- <li>Your content provider then returns a {@link android.database.Cursor} that points to all
+<ol>
+ <li>Search Manager takes the search query text (whatever has been typed so far) and performs a
+query to your content provider that manages your suggestions.</li>
+ <li>Your content provider returns a {@link android.database.Cursor} that points to all
suggestions that are relevant to the search query text.</li>
- <li>The Search Manager then displays the list of suggestions provided by the Cursor (as
-demonstrated in the screenshot to the right).</li>
-</ul>
+ <li>Search Manager displays the list of suggestions provided by the Cursor.</li>
+</ol>
-<p>At this point, the following may happen:</p>
+<p>Once the custom suggestions are displayed, the following might happen:</p>
<ul>
<li>If the user types another key, or changes the query in any way, the above steps are repeated
and the suggestion list is updated as appropriate. </li>
- <li>If the user executes the search, the suggestions are ignored and the search is delivered
+ <li>If the user executes the search, the suggestions are ignored and the search is delivered
to your searchable Activity using the normal {@link android.content.Intent#ACTION_SEARCH}
Intent.</li>
<li>If the user selects a suggestion, an Intent is sent to your searchable Activity, carrying a
@@ -124,56 +134,64 @@
to the {@code <searchable>} element in your searchable configuration file. For example:</p>
<pre>
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:label="@string/app_label"
android:hint="@string/search_hint"
- android:searchSuggestAuthority="my.package.MyCustomSuggestionProvider" >
-</searchable>
+ <b>android:searchSuggestAuthority="com.example.MyCustomSuggestionProvider"</b>>
+</searchable>
</pre>
-<p>You may require some additional attributes, depending on the type of Intent you attach
+<p>You might need some additional attributes, depending on the type of Intent you attach
to each suggestion and how you want to format queries to your content provider. The other optional
-attributes are discussed in the relevant sections below.</p>
+attributes are discussed in the following sections.</p>
+
<h2 id="CustomContentProvider">Creating a Content Provider</h2>
-<p>Creating a content provider for custom suggestions requires previous knowledge about Content
-Providers that's covered in the <a
+<p>Creating a content provider for custom suggestions requires previous knowledge about content
+providers that's covered in the <a
href="{@docRoot}guide/topics/providers/content-providers.html">Content Provider</a> developer
guide. For the most part, a content provider for custom suggestions is the
same as any other content provider. However, for each suggestion you provide, the respective row in
the {@link android.database.Cursor} must include specific columns that the Search Manager
-understands.</p>
+understands and uses to format the suggestions.</p>
-<p>When the user starts typing into the search dialog, the Search Manager will query your Content
-Provider for suggestions by calling {@link
+<p>When the user starts typing into the search dialog, the Search Manager queries your content
+provider for suggestions by calling {@link
android.content.ContentProvider#query(Uri,String[],String,String[],String) query()} each time
a letter is typed. In your implementation of {@link
android.content.ContentProvider#query(Uri,String[],String,String[],String) query()}, your
content provider must search your suggestion data and return a {@link
-android.database.Cursor} that points to the rows you determine to be good suggestions.</p>
+android.database.Cursor} that points to the rows you have determined to be good suggestions.</p>
-<p>The following two sections describe how the Search Manager will send requests to your Content
-Provider and how you can handle them, and define the columns that the Search Manager understands and
-expects to be provided in the {@link android.database.Cursor} returned with each query.</p>
+<p>Details about creating a content provider for custom suggestions are discussed in the following
+two sections:</p>
+<dl>
+ <dt><a href="#HandlingSuggestionQuery">Handling the suggestion query</a></dt>
+ <dd>How the Search Manager sends requests to your content provider and how to handle them</dd>
+ <dt><a href="#SuggestionTable">Building a suggestion table</a></dt>
+ <dd>How to define the columns that the Search Manager expects in the {@link
+android.database.Cursor} returned with each query</dd>
+</dl>
<h3 id="HandlingSuggestionQuery">Handling the suggestion query</h3>
-<p>When the Search Manager makes a request for suggestions from your content provider, it will call
-{@link android.content.ContentProvider#query(Uri,String[],String,String[],String)}. You must
-implement this method in your content provider so that it will search your suggestions and return a
-Cursor that contains the suggestions you deem relevant.</p>
+<p>When the Search Manager requests suggestions from your content provider, it calls your content
+provider's {@link android.content.ContentProvider#query(Uri,String[],String,String[],String)
+query()} method. You must
+implement this method to search your suggestion data and return a
+{@link android.database.Cursor} pointing to the suggestions you deem relevant.</p>
-<p>Here's a summary of the parameters that the Search Manager will pass to your {@link
+<p>Here's a summary of the parameters that the Search Manager passes to your {@link
android.content.ContentProvider#query(Uri,String[],String,String[],String) query()} method
(listed in order):</p>
<dl>
<dt><code>uri</code></dt>
- <dd>This will always be a content {@link android.net.Uri}, formatted as:
+ <dd>Always a content {@link android.net.Uri}, formatted as:
<pre class="no-pretty-print">
content://<em>your.authority</em>/<em>optional.suggest.path</em>/<em>{@link
android.app.SearchManager#SUGGEST_URI_PATH_QUERY}</em>
@@ -184,46 +202,48 @@
content://<em>your.authority</em>/<em>optional.suggest.path</em>/<em>{@link
android.app.SearchManager#SUGGEST_URI_PATH_QUERY}</em>/puppies
</pre>
-<p>The query text on the end will be encoded using URI encoding rules, so you may need to decode
-it.</p>
+<p>The query text on the end is encoded using URI encoding rules, so you might need to decode
+it before performing a search.</p>
<p>The <em>{@code optional.suggest.path}</em> portion is only included in the URI if you have set
such a path in your searchable configuration file with the {@code android:searchSuggestPath}
attribute. This is only needed if you use the same content provider for multiple searchable
-activities, in which case you need to disambiguate the source of the suggestion query.</p>
-<p>Note that {@link android.app.SearchManager#SUGGEST_URI_PATH_QUERY} is not the literal
+activities, in which case, you need to disambiguate the source of the suggestion query.</p>
+<p class="note"><strong>Note:</strong> {@link
+android.app.SearchManager#SUGGEST_URI_PATH_QUERY} is not the literal
string provided in the URI, but a constant that you should use if you need to refer to this
path.</p>
</dd>
<dt><code>projection</code></dt>
- <dd>This is always null</dd>
+ <dd>Always null</dd>
<dt><code>selection</code></dt>
- <dd>This is the value provided in the {@code android:searchSuggestSelection} attribute of
+ <dd>The value provided in the {@code android:searchSuggestSelection} attribute of
your searchable configuration file, or null if you have not declared the {@code
-android:searchSuggestSelection} attribute. More about this below.</dd>
+android:searchSuggestSelection} attribute. More about using this to <a href="#GetTheQuery">get the
+query</a> below.</dd>
<dt><code>selectionArgs</code></dt>
- <dd>This contains the search query as the first (and only) element of the array if you have
+ <dd>Contains the search query as the first (and only) element of the array if you have
declared the {@code android:searchSuggestSelection} attribute in your searchable configuration. If
you have not declared {@code android:searchSuggestSelection}, then this parameter is null. More
-about this below.</dd>
+about using this to <a href="#GetTheQuery">get the query</a> below.</dd>
<dt><code>sortOrder</code></dt>
- <dd>This is always null</dd>
+ <dd>Always null</dd>
</dl>
-<p>As you may have realized, there are two ways by which the Search Manager can send you the search
-query text. The default manner is for the query text to be included as the last path of the content
-URI that is passed in the {@code uri} parameter. However, if you include a selection value in your
+<p>The Search Manager can send you the search query text in two ways. The
+default manner is for the query text to be included as the last path of the content
+URI passed in the {@code uri} parameter. However, if you include a selection value in your
searchable configuration's {@code
-android:searchSuggestSelection} attribute, then the query text will instead be passed as the first
-element of the {@code selectionArgs} string array. Both options are summarized below.</p>
+android:searchSuggestSelection} attribute, then the query text is instead passed as the first
+element of the {@code selectionArgs} string array. Both options are summarized next.</p>
-<h4>Get the query in the Uri</h4>
+<h4 id="GetTheQueryUri">Get the query in the Uri</h4>
-<p>By default, the query will be appended as the last segment of the {@code uri}
+<p>By default, the query is appended as the last segment of the {@code uri}
parameter (a {@link android.net.Uri} object). To retrieve the query text in this case, simply use
{@link android.net.Uri#getLastPathSegment()}. For example:</p>
@@ -231,52 +251,59 @@
String query = uri.getLastPathSegment().toLowerCase();
</pre>
-<p>This will return the last segment of the Uri, which is the query text entered in the search
-dialog.</p>
+<p>This returns the last segment of the {@link android.net.Uri}, which is the query text entered in
+the search dialog.</p>
-<h4>Get the query in the selection arguments</h4>
+<h4 id="GetTheQuery">Get the query in the selection arguments</h4>
-<p>Instead of using the URI, you may decide it makes more sense for your {@link
+<p>Instead of using the URI, you might decide it makes more sense for your {@link
android.content.ContentProvider#query(Uri,String[],String,String[],String) query()} method to
receive everything it needs to perform the look-up and you want the
-{@code selection} and {@code selectionArgs} parameters to carry values. In this case, you can
-add the {@code android:searchSuggestSelection} attribute to your searchable configuration with your
-SQLite selection string. In this selection string, you can include a question mark ("?") as
-a placeholder for the actual search query. This selection string will be delivered as the
-{@code selection} string parameter, and the query entered into the search dialog will be delivered
-as the first element in the {@code selectionArgs} string array parameter.</p>
+{@code selection} and {@code selectionArgs} parameters to carry the appropriate values. In such a
+case, add the {@code android:searchSuggestSelection} attribute to your searchable configuration with
+your SQLite selection string. In the selection string, include a question mark ("?") as
+a placeholder for the actual search query. The Search Manager calls {@link
+android.content.ContentProvider#query(Uri,String[],String,String[],String) query()} with the
+selection string as the {@code selection} parameter and the search query as the first
+element in the {@code selectionArgs} array.</p>
<p>For example, here's how you might form the {@code android:searchSuggestSelection} attribute to
create a full-text search statement:</p>
<pre>
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:label="@string/app_label"
android:hint="@string/search_hint"
- android:searchSuggestAuthority="my.package.MyCustomSuggestionProvider"
+ android:searchSuggestAuthority="com.example.MyCustomSuggestionProvider"
android:searchSuggestIntentAction="android.Intent.action.VIEW"
- android:searchSuggestSelection="word MATCH ?">
-</searchable>
+ <b>android:searchSuggestSelection="word MATCH ?"</b>>
+</searchable>
</pre>
-<p>When you then receive the {@code selection} and {@code selectionArgs} parameters in your {@link
-android.content.ContentProvider#query(Uri,String[],String,String[],String) ContentProvider.query()}
-method, they will carry the selection ("word MATCH ?") and the query text, respectively. When
-these are passed to an SQLite {@link
-android.database.sqlite.SQLiteDatabase#query(String,String[],String,String[],String,String,
-String) query} method, they will be synthesized together (replacing the question mark with the query
-text, wrapped in single-quotes). Note that if you chose this method and need to add any wildcards to
-your query text, you must do so by appending (and/or prefixing) them to the {@code selectionArgs}
-parameter, because this is the value that will be wrapped in quotes and inserted in place of the
+<p>With this configuration, your {@link
+android.content.ContentProvider#query(Uri,String[],String,String[],String) query()} method
+delivers the {@code selection} parameter as "word MATCH ?" and the {@code selectionArgs}
+parameter as whatever the user entered in the search dialog. When you pass these to an SQLite
+{@link android.database.sqlite.SQLiteDatabase#query(String,String[],String,String[],String,String,
+String) query()} method, as their respective arguments, they are synthesized together (the
+question mark is replaced with the query
+text). If you chose to receive suggestion queries this way and need to add wildcards to
+the query text, append (and/or prefix) them to the {@code selectionArgs}
+parameter, because this value is wrapped in quotes and inserted in place of the
question mark.</p>
+<p>Another new attribute in the example above is {@code android:searchSuggestIntentAction}, which
+defines the Intent action sent with each Intent when the user selects a suggestion. It is
+discussed further in the section about <a href="#IntentForSuggestions">Declaring an Intent for
+suggestions</a>.</p>
+
<p class="note"><strong>Tip:</strong> If you don't want to define a selection clause in
the {@code android:searchSuggestSelection} attribute, but would still like to receive the query
text in the {@code selectionArgs} parameter, simply provide a non-null value for the {@code
-android:searchSuggestSelection} attribute. This will trigger the query to be passed in {@code
+android:searchSuggestSelection} attribute. This triggers the query to be passed in {@code
selectionArgs} and you can ignore the {@code selection} parameter. In this way, you can instead
define the actual selection clause at a lower level so that your content provider doesn't have to
handle it.</p>
@@ -287,11 +314,12 @@
<div class="sidebox-wrapper">
<div class="sidebox">
-<h2>Creating a Cursor on the fly</h2>
-<p>If your search suggestions are not stored in a table format using the columns required by the
+<h2>Creating a Cursor without a table</h2>
+<p>If your search suggestions are not stored in a table format (such as an SQLite table) using the
+columns required by the
Search Manager, then you can search your suggestion data for matches and then format them
-into the necessary table on the fly. To do so, create a {@link android.database.MatrixCursor} using
-the required column names and then add a row for each suggestion using {@link
+into the necessary table on each request. To do so, create a {@link android.database.MatrixCursor}
+using the required column names and then add a row for each suggestion using {@link
android.database.MatrixCursor#addRow(Object[])}. Return the final product from your Content
Provider's {@link
android.content.ContentProvider#query(Uri,String[],String,String[],String) query()} method.</p>
@@ -299,97 +327,94 @@
</div>
<p>When you return suggestions to the Search Manager with a {@link android.database.Cursor}, the
-Search Manager expects there to be specific columns in each row. So, regardless of whether you
+Search Manager expects specific columns in each row. So, regardless of whether you
decide to store
your suggestion data in an SQLite database on the device, a database on a web server, or another
format on the device or web, you must format the suggestions as rows in a table and
-present them with a {@link android.database.Cursor}. There are several columns that the Search
-Manager will understand, but only two are required:</p>
+present them with a {@link android.database.Cursor}. The Search
+Manager understands several columns, but only two are required:</p>
<dl>
<dt>{@link android.provider.BaseColumns#_ID}</dt>
- <dd>This is the unique row ID for each suggestion. The search dialog requires this in order
-to present the suggestions in a ListView.</dd>
+ <dd>A unique integer row ID for each suggestion. The search dialog requires this in order
+to present suggestions in a ListView.</dd>
<dt>{@link android.app.SearchManager#SUGGEST_COLUMN_TEXT_1}</dt>
- <dd>This is the line of text that will be presented to the user as a suggestion.</dd>
+ <dd>The string that is presented as a suggestion.</dd>
</dl>
-<p>The following columns are all optional (and most will be discussed further in the following
-sections, so you may want to skip this list for now):</p>
+<p>The following columns are all optional (and most are discussed further in the following
+sections):</p>
<dl>
<dt>{@link android.app.SearchManager#SUGGEST_COLUMN_TEXT_2}</dt>
- <dd>If your Cursor includes this column, then all suggestions will be provided in a two-line
-format. The data in this column will be displayed as a second, smaller line of text below the
+ <dd>A string. If your Cursor includes this column, then all suggestions are provided in a
+two-line format. The string in this column is displayed as a second, smaller line of text below the
primary suggestion text. It can be null or empty to indicate no secondary text.</dd>
<dt>{@link android.app.SearchManager#SUGGEST_COLUMN_ICON_1}</dt>
- <dd>If your Cursor includes this column, then all suggestions will be provided in an
-icon-plus-text format with the icon on the left side. This value should be a reference to the
-icon. It can be null or zero to indicate no icon in this row.</dd>
+ <dd>A drawable resource, content, or file URI string. If your Cursor includes this column, then
+all suggestions are provided in an icon-plus-text format with the drawable icon on the left side.
+This can be null or zero to indicate no icon in this row.</dd>
<dt>{@link android.app.SearchManager#SUGGEST_COLUMN_ICON_2}</dt>
- <dd>If your Cursor includes this column, then all suggestions will be provided in an
-icon-plus-text format with the icon on the right side. This value should be a reference to the
-icon. It can be null or zero to indicate no icon in this row.</dd>
+ <dd>A drawable resource, content, or file URI string. If your Cursor includes this column, then
+all suggestions are provided in an icon-plus-text format with the icon on the right side. This can
+be null or zero to indicate no icon in this row.</dd>
<dt>{@link android.app.SearchManager#SUGGEST_COLUMN_INTENT_ACTION}</dt>
- <dd>If this column exists and this element exists at the given row, this is the action that will
-be used when forming the suggestion's Intent . If the element is not provided, the action will be
-taken from the {@code android:searchSuggestIntentAction} field in your searchable configuration. At
-least one of these
-must be present for the suggestion to generate an Intent. Note: If your action is the same for all
+ <dd>An Intent action string. If this column exists and contains a value at the given row, the
+action defined here is used when forming the suggestion's Intent. If the element is not
+provided, the action is taken from the {@code android:searchSuggestIntentAction} field in your
+searchable configuration. If your action is the same for all
suggestions, it is more efficient to specify the action using {@code
-android:searchSuggestIntentAction} and omit this column from the Cursor .</dd>
+android:searchSuggestIntentAction} and omit this column.</dd>
<dt>{@link android.app.SearchManager#SUGGEST_COLUMN_INTENT_DATA}</dt>
- <dd>If this column exists and this element exists at the given row, this is the data that will be
-used when forming the suggestion's Intent. If the element is not provided, the data will be taken
-from the {@code android:searchSuggestIntentData} field in your searchable configuration. If neither
-source is provided,
-the Intent's data field will be null. Note: If your data is the same for all suggestions, or can be
+ <dd>A data URI string. If this column exists and contains a value at the given row, this is the
+data that is used when forming the suggestion's Intent. If the element is not provided, the data is
+taken from the {@code android:searchSuggestIntentData} field in your searchable configuration. If
+neither source is provided,
+the Intent's data field is null. If your data is the same for all suggestions, or can be
described using a constant part and a specific ID, it is more efficient to specify it using {@code
-android:searchSuggestIntentData} and omit this column from the Cursor .
+android:searchSuggestIntentData} and omit this column.
</dd>
<dt>{@link android.app.SearchManager#SUGGEST_COLUMN_INTENT_DATA_ID}</dt>
- <dd>If this column exists and this element exists at the given row, then "/" and this value will
-be appended to the data field in the Intent. This should only be used if the data field specified
+ <dd>A URI path string. If this column exists and contains a value at the given row, then "/" and
+this value is appended to the data field in the Intent. This should only be used if the data field
+specified
by the {@code android:searchSuggestIntentData} attribute in the searchable configuration has already
been set to an appropriate base string.</dd>
<dt>{@link android.app.SearchManager#SUGGEST_COLUMN_INTENT_EXTRA_DATA}</dt>
- <dd>If this column exists and this element exists at a given row, this is the <em>extra</em> data
-that will be used when forming the suggestion's Intent. If not provided, the Intent's extra data
-field will be
-null. This column allows suggestions to provide additional arbitrary data which will be
+ <dd>Arbitrary data. If this column exists and contains a value at a given row, this is the
+<em>extra</em> data used when forming the suggestion's Intent. If not provided, the
+Intent's extra data field is null. This column allows suggestions to provide additional data that is
included as an extra in the Intent's {@link android.app.SearchManager#EXTRA_DATA_KEY} key.</dd>
<dt>{@link android.app.SearchManager#SUGGEST_COLUMN_QUERY}</dt>
- <dd>If this column exists and this element exists at the given row, this is the data that will be
+ <dd>If this column exists and this element exists at the given row, this is the data that is
used when forming the suggestion's query, included as an extra in the Intent's {@link
android.app.SearchManager#QUERY} key. Required if suggestion's action is {@link
android.content.Intent#ACTION_SEARCH}, optional otherwise.</dd>
<dt>{@link android.app.SearchManager#SUGGEST_COLUMN_SHORTCUT_ID}</dt>
- <dd>Only used when providing suggestions for Quick Search Box. This column is used to indicate
+ <dd>Only used when providing suggestions for Quick Search Box. This column indicates
whether a search suggestion should be stored as a
-shortcut, and whether it should be validated. Shortcuts are usually formed when the user clicks a
-suggestion from Quick Search Box. If missing, the result will be stored as a shortcut and never
-refreshed. If set to {@link android.app.SearchManager#SUGGEST_NEVER_MAKE_SHORTCUT}, the result will
-not be stored as a shortcut.
-Otherwise, the shortcut id will be used to check back for for an up to date suggestion using
+shortcut and whether it should be validated. Shortcuts are usually formed when the user clicks a
+suggestion from Quick Search Box. If missing, the result is stored as a shortcut and never
+refreshed. If set to {@link android.app.SearchManager#SUGGEST_NEVER_MAKE_SHORTCUT}, the result is
+not stored as a shortcut.
+Otherwise, the shortcut ID is used to check back for an up to date suggestion using
{@link android.app.SearchManager#SUGGEST_URI_PATH_SHORTCUT}.</dd>
<dt>{@link android.app.SearchManager#SUGGEST_COLUMN_SPINNER_WHILE_REFRESHING}</dt>
- <dd>Only used when providing suggestions for Quick Search Box. This column is used to specify that
+ <dd>Only used when providing suggestions for Quick Search Box. This column specifies that
a spinner should be shown instead of an icon from {@link
android.app.SearchManager#SUGGEST_COLUMN_ICON_2}
while the shortcut of this suggestion is being refreshed in Quick Search Box.</dd>
</dl>
-<p>Again, most of these columns will be discussed in the relevant sections below, so don't worry if
-they don't make sense to you now.</p>
+<p>Some of these columns are discussed more in the following sections.</p>
<h2 id="IntentForSuggestions">Declaring an Intent for suggestions</h2>
-<p>When the user selects a suggestion from the list that appears below the search
-dialog (instead of performing a search), the Search Manager will send
-a custom {@link android.content.Intent} to your searchable Activity. You must define both the
-<em>action</em> and <em>data</em> for the Intent.</p>
+<p>When the user selects a suggestion from the list that appears below the search dialog, the Search
+Manager sends a custom {@link android.content.Intent} to your searchable Activity. You must define
+the action and data for the Intent.</p>
<h3 id="IntentAction">Declaring the Intent action</h3>
@@ -397,34 +422,42 @@
<p>The most common Intent action for a custom suggestion is {@link
android.content.Intent#ACTION_VIEW}, which is appropriate when
you want to open something, like the definition for a word, a person's contact information, or a web
-page. However, the Intent action can be whatever you want and can even be different for each
+page. However, the Intent action can be any other action and can even be different for each
suggestion.</p>
-<p>To declare an Intent action that will be the same for all suggestions, define the action in
-the {@code android:searchSuggestIntentAction} attribute of your searchable configuration file. For
-example:</p>
+<p>Depending on whether you want all suggestions to use the same Intent action, you
+can define the action in two ways:</p>
+
+<ol type="a">
+ <li>Use the {@code android:searchSuggestIntentAction} attribute of your searchable configuration
+file to define the action for all suggestions. <p>For example:</p>
<pre>
<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:label="@string/app_label"
android:hint="@string/search_hint"
- android:searchSuggestAuthority="my.package.MySuggestionProvider"
- android:searchSuggestIntentAction="android.Intent.action.VIEW" >
+ android:searchSuggestAuthority="com.example.MyCustomSuggestionProvider"
+ <b>android:searchSuggestIntentAction="android.Intent.action.VIEW"</b> >
</searchable>
</pre>
-<p>If you want to declare an Intent action that's unique for each suggestion, add the {@link
-android.app.SearchManager#SUGGEST_COLUMN_INTENT_ACTION} column to
+ </li>
+ <li>Use the {@link android.app.SearchManager#SUGGEST_COLUMN_INTENT_ACTION} column to define the
+action for individual suggestions.
+ <p>Add the {@link android.app.SearchManager#SUGGEST_COLUMN_INTENT_ACTION} column to
your suggestions table and, for each suggestion, place in it the action to use (such as
-{@code "android.Intent.action.VIEW"}). </p>
+{@code "android.Intent.action.VIEW"}).</p>
+
+ </li>
+</ol>
<p>You can also combine these two techniques. For instance, you can include the {@code
android:searchSuggestIntentAction} attribute with an action to be used with all suggestions by
default, then override this action for some suggestions by declaring a different action in the
{@link android.app.SearchManager#SUGGEST_COLUMN_INTENT_ACTION} column. If you do not include
a value in the {@link android.app.SearchManager#SUGGEST_COLUMN_INTENT_ACTION} column, then the
-Intent provided in the {@code android:searchSuggestIntentAction} attribute will be used.</p>
+Intent provided in the {@code android:searchSuggestIntentAction} attribute is used.</p>
<p class="note"><strong>Note</strong>: If you do not include the
{@code android:searchSuggestIntentAction} attribute in your searchable configuration, then you
@@ -432,45 +465,45 @@
column for every suggestion, or the Intent will fail.</p>
+
<h3 id="IntentData">Declaring Intent data</h3>
-<p>When the user selects a suggestion, your searchable Activity will receive the Intent with the
+<p>When the user selects a suggestion, your searchable Activity receives the Intent with the
action you've defined (as discussed in the previous section), but the Intent must also carry
-data in order for your Activity to identify which suggestions was selected. Specifically,
+data in order for your Activity to identify which suggestion was selected. Specifically,
the data should be something unique for each suggestion, such as the row ID for the suggestion in
-your suggestions table. When the Intent is received,
+your SQLite table. When the Intent is received,
you can retrieve the attached data with {@link android.content.Intent#getData()} or {@link
android.content.Intent#getDataString()}.</p>
-<p>There are two ways to define the data that is included with the Intent:</p>
+<p>You can define the data included with the Intent in two ways:</p>
<ol type="a">
<li>Define the data for each suggestion inside the {@link
-android.app.SearchManager#SUGGEST_COLUMN_INTENT_DATA} column of your suggestions table.</li>
+android.app.SearchManager#SUGGEST_COLUMN_INTENT_DATA} column of your suggestions table.
+
+<p>Provide all necessary data information for each Intent in the suggestions table by including the
+{@link android.app.SearchManager#SUGGEST_COLUMN_INTENT_DATA} column and then populating it with
+unique data for each row. The data from this column is attached to the Intent exactly as you
+define it in this column. You can then retrieve it with with {@link
+android.content.Intent#getData()} or {@link android.content.Intent#getDataString()}.</p>
+
+<p class="note"><strong>Tip</strong>: It's usually easiest to use the table's row ID as the
+Intent data, because it's always unique. And the easiest way to do that is by using the
+{@link android.app.SearchManager#SUGGEST_COLUMN_INTENT_DATA} column name as an alias for the row ID
+column. See the <a
+href="{@docRoot}resources/samples/SearchableDictionary/index.html">Searchable Dictionary sample
+app</a> for an example in which {@link android.database.sqlite.SQLiteQueryBuilder} creates a
+projection map of column names to aliases.</p>
+ </li>
+
<li>Fragment a data URI into two pieces: the portion common to all suggestions and the portion
unique to each suggestion. Place these parts into the {@code android:searchSuggestIntentData}
attribute of the searchable configuration and the {@link
android.app.SearchManager#SUGGEST_COLUMN_INTENT_DATA_ID} column of your
-suggestions table, respectively.</li>
-</ol>
+suggestions table, respectively.
-<p>The first option is straight-forward. Simply provide all necessary data information for each
-Intent in the suggestions table by including the {@link
-android.app.SearchManager#SUGGEST_COLUMN_INTENT_DATA} column and then populating it with unique
-data for each row. The data from this column will be attached to the Intent exactly as it
-is found in this column. You can then retrieve it with with {@link android.content.Intent#getData()}
-or {@link android.content.Intent#getDataString()}.</p>
-
-<p class="note"><strong>Tip</strong>: It's usually easiest to use the table's row ID as the
-Intent data because it's always unique. And the easiest way to do that is by using the
-{@link android.app.SearchManager#SUGGEST_COLUMN_INTENT_DATA} column name as an alias for the row ID
-column. See the <a
-href="{@docRoot}resources/samples/SearchableDictionary/index.html">Searchable Dictionary sample
-app</a> for an example in which {@link android.database.sqlite.SQLiteQueryBuilder} is used to
-create a projection map of column names to aliases.</p>
-
-<p>The second option is to fragment your data URI into the common piece and the unique piece.
-Declare the piece of the URI that is common to all suggestions in the {@code
+<p>Declare the piece of the URI that is common to all suggestions in the {@code
android:searchSuggestIntentData} attribute of your searchable configuration. For example:</p>
<pre>
@@ -478,35 +511,40 @@
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:label="@string/app_label"
android:hint="@string/search_hint"
- android:searchSuggestAuthority="my.package.MySuggestionProvider"
+ android:searchSuggestAuthority="com.example.MyCustomSuggestionProvider"
android:searchSuggestIntentAction="android.Intent.action.VIEW"
- android:searchSuggestIntentData="content://my.package/datatable" >
+ <b>android:searchSuggestIntentData="content://com.example/datatable"</b> >
</searchable>
</pre>
-<p>Now include the final path for each suggestion (the unique part) in the {@link
+<p>Then include the final path for each suggestion (the unique part) in the {@link
android.app.SearchManager#SUGGEST_COLUMN_INTENT_DATA_ID}
-column of your suggestions table. When the user selects a suggestion, the Search Manager will take
-the string from {@code android:searchSuggestIntentData}, append a slash ("/") and then add the
+column of your suggestions table. When the user selects a suggestion, the Search Manager takes
+the string from {@code android:searchSuggestIntentData}, appends a slash ("/") and then adds the
respective value from the {@link android.app.SearchManager#SUGGEST_COLUMN_INTENT_DATA_ID} column to
form a complete content URI. You can then retrieve the {@link android.net.Uri} with with {@link
android.content.Intent#getData()}.</p>
+ </li>
+</ol>
+
<h4>Add more data</h4>
<p>If you need to express even more information with your Intent, you can add another table column,
{@link android.app.SearchManager#SUGGEST_COLUMN_INTENT_EXTRA_DATA}, which can store additional
-information about the suggestion. The data saved in this column will be placed in {@link
+information about the suggestion. The data saved in this column is placed in {@link
android.app.SearchManager#EXTRA_DATA_KEY} of the Intent's extra Bundle.</p>
+
<h2 id="HandlingIntent">Handling the Intent</h2>
-<p>Now that your search dialog provides custom search suggestions with custom formatted Intents, you
-need your searchable Activity to handle these Intents as they are delivered once the user selects a
-suggestion. (This is, of course, in addition to handling the {@link
-android.content.Intent#ACTION_SEARCH} Intent, which your searchable Activity already does.)
-Accepting the new Intent is rather self-explanatory, so we'll skip straight to an example:</p>
+<p>Now that your search dialog provides custom search suggestions with custom Intents, you
+need your searchable Activity to handle these Intents when the user selects a
+suggestion. This is in addition to handling the {@link
+android.content.Intent#ACTION_SEARCH} Intent, which your searchable Activity already does.
+Here's an example of how you can handle the Intents during your Activity {@link
+android.app.Activity#onCreate(Bundle) onCreate()} callback:</p>
<pre>
Intent intent = getIntent();
@@ -515,26 +553,32 @@
String query = intent.getStringExtra(SearchManager.QUERY);
doSearch(query);
} else if (Intent.ACTION_VIEW.equals(intent.getAction())) {
- // Handle a suggestions click (because my suggestions all use ACTION_VIEW)
- Uri data = intent.getData());
- showResult(rowId);
+ // Handle a suggestions click (because the suggestions all use ACTION_VIEW)
+ Uri data = intent.getData();
+ showResult(data);
}
</pre>
<p>In this example, the Intent action is {@link
android.content.Intent#ACTION_VIEW} and the data carries a complete URI pointing to the suggested
item, as synthesized by the {@code android:searchSuggestIntentData} string and {@link
-android.app.SearchManager#SUGGEST_COLUMN_INTENT_DATA_ID} column. The URI is then passed to a local
-method that will query the content provider for the item specified by the URI and show it.</p>
+android.app.SearchManager#SUGGEST_COLUMN_INTENT_DATA_ID} column. The URI is then passed to the local
+{@code showResult()} method that queries the content provider for the item specified by the URI.</p>
+<p class="note"><strong>Note:</strong> You do <em>not</em> need to add an Intent filter to your
+Android manifest file for the Intent action you defined with the {@code
+android:searchSuggestIntentAction} attribute or {@link
+android.app.SearchManager#SUGGEST_COLUMN_INTENT_ACTION} column. The Search Manager opens your
+searchable Activity by name to deliver the suggestion's Intent, so the Activity does not need to
+declare the accepted action.</p>
<h2 id="RewritingQueryText">Rewriting the query text</h2>
-<p>If the user navigates through the suggestions list using the device directional controls, the
-text in the search dialog won't change, by default. However, you can temporarily rewrite the
-user's query text as it appears in the text box with
-a query that matches the currently selected suggestion. This enables the user to see what query is
+<p>If the user navigates through the suggestions list using the directional controls (trackball or
+d-pad), the text in the search dialog won't change, by default. However, you can temporarily rewrite
+the user's query text as it appears in the text box with
+a query that matches the suggestion currently in focus. This enables the user to see what query is
being suggested (if appropriate) and then select the search box and edit the query before
dispatching it as a search.</p>
@@ -544,39 +588,40 @@
<li>Add the {@code android:searchMode} attribute to your searchable configuration with the
"queryRewriteFromText" value. In this case, the content from the suggestion's {@link
android.app.SearchManager#SUGGEST_COLUMN_TEXT_1}
-column will be used to rewrite the query text.</li>
+column is used to rewrite the query text.</li>
<li>Add the {@code android:searchMode} attribute to your searchable configuration with the
"queryRewriteFromData" value. In this case, the content from the suggestion's
-{@link android.app.SearchManager#SUGGEST_COLUMN_INTENT_DATA} column will be used to rewrite the
-query text. Note that this should only
-be used with Uri's or other data formats that are intended to be user-visible, such as HTTP URLs.
-Internal Uri schemes should not be used to rewrite the query in this way.</li>
+{@link android.app.SearchManager#SUGGEST_COLUMN_INTENT_DATA} column is used to rewrite the
+query text. This should only
+be used with URI's or other data formats that are intended to be user-visible, such as HTTP URLs.
+Internal URI schemes should not be used to rewrite the query in this way.</li>
<li>Provide a unique query text string in the {@link
android.app.SearchManager#SUGGEST_COLUMN_QUERY} column of your suggestions table. If this column is
-present and contains a value for the current suggestion, it will be used to rewrite the query text
+present and contains a value for the current suggestion, it is used to rewrite the query text
(and override either of the previous implementations).</li>
</ol>
+
<h2 id="QSB">Exposing search suggestions to Quick Search Box</h2>
-<p>Once your application is configured to provide custom search suggestions, making them available
-to the globally-accessible Quick Search Box is as easy as modifying your searchable configuration to
+<p>Once you configure your application to provide custom search suggestions, making them available
+to the globally accessible Quick Search Box is as easy as modifying your searchable configuration to
include {@code android:includeInGlobalSearch} as "true".</p>
-<p>The only scenario in which additional work will be required is if your content provider for
-custom suggestions requires a permission for read access. In which case, you need to add a special
-{@code <path-permission>} element for the provider to grant Quick Search Box read access to your
-content provider. For example:</p>
+<p>The only scenario in which additional work is necessary is when your content provider demands a
+read permission. In which case, you need to add a special
+{@code <path-permission>} element for the provider to grant Quick Search Box read access to
+your content provider. For example:</p>
<pre>
<provider android:name="MySuggestionProvider"
- android:authorities="my.package.authority"
+ android:authorities="com.example.MyCustomSuggestionProvider"
android:readPermission="com.example.provider.READ_MY_DATA"
- android:writePermission="com.example.provider.WRITE_MY_DATA">
+ android:writePermission="com.example.provider.WRITE_MY_DATA">
<path-permission android:pathPrefix="/search_suggest_query"
- android:readPermission="android.permission.GLOBAL_SEARCH" />
-</provider>
+ android:readPermission="android.permission.GLOBAL_SEARCH" />
+</provider>
</pre>
<p>In this example, the provider restricts read and write access to the content. The
@@ -585,8 +630,8 @@
"android.permission.GLOBAL_SEARCH"} permission exists. This grants access to Quick Search Box
so that it may query your content provider for suggestions.</p>
-<p>Content providers that enforce no permissions are already available to the search
-infrastructure.</p>
+<p>If your content provider does not enforce read permissions, then Quick Search Box can read
+it by default.</p>
<h3 id="EnablingSuggestions">Enabling suggestions on a device</h3>
@@ -608,89 +653,93 @@
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:label="@string/app_label"
android:hint="@string/search_hint"
- android:searchSuggestAuthority="my.package.MySuggestionProvider"
+ android:searchSuggestAuthority="com.example.MyCustomSuggestionProvider"
android:searchSuggestIntentAction="android.Intent.action.VIEW"
android:includeInGlobalSearch="true"
- android:searchSettingsDescription="@string/search_description" >
+ <b>android:searchSettingsDescription="@string/search_description"</b> >
</searchable>
</pre>
<p>The string for {@code android:searchSettingsDescription} should be as concise as possible and
state the content that is searchable. For example, "Artists, albums, and tracks" for a music
application, or "Saved notes" for a notepad application. Providing this description is important so
-the user knows what kind of suggestions will be provided. This attribute should always be included
+the user knows what kind of suggestions are provided. You should always include this attribute
when {@code android:includeInGlobalSearch} is "true".</p>
-<p>Remember that the user must visit this settings menu to enable search suggestions for your
-application before your search suggestions will appear in Quick Search Box. As such, if search is an
-important aspect of your application, then you may want to consider a way to message this to your
-users — perhaps with a note the first time they launch the app about how to enable search
-suggestions for Quick Search Box.</p>
+<p>Remember that the user must visit the settings menu to enable search suggestions for your
+application before your search suggestions appear in Quick Search Box. As such, if search is an
+important aspect of your application, then you might want to consider a way to convey that to
+your users — you might provide a note the first time they launch the app that instructs
+them how to enable search suggestions for Quick Search Box.</p>
<h3 id="ManagingShortcuts">Managing Quick Search Box suggestion shortcuts</h3>
-<p>Suggestions that the user selects from Quick Search Box may be automatically made into shortcuts.
+<p>Suggestions that the user selects from Quick Search Box can be automatically made into shortcuts.
These are suggestions that the Search Manager has copied from your content provider so it can
quickly access the suggestion without the need to re-query your content provider. </p>
<p>By default, this is enabled for all suggestions retrieved by Quick Search Box, but if your
-suggestion data may change over time, then you can request that the shortcuts be refreshed. For
+suggestion data changes over time, then you can request that the shortcuts be refreshed. For
instance, if your suggestions refer to dynamic data, such as a contact's presence status, then you
should request that the suggestion shortcuts be refreshed when shown to the user. To do so,
include the {@link android.app.SearchManager#SUGGEST_COLUMN_SHORTCUT_ID} in your suggestions table.
Using this column, you can
-configure the shortcut behavior for each suggestion in the following ways:</p>
+configure the shortcut behavior for each suggestion in one of the following ways:</p>
<ol type="a">
- <li>Have Quick Search Box re-query your content provider for a fresh version of the shortcutted
-suggestion.
+ <li>Have Quick Search Box re-query your content provider for a fresh version of the suggestion
+shortcut.
<p>Provide a value in the {@link android.app.SearchManager#SUGGEST_COLUMN_SHORTCUT_ID} column
-and the suggestion will be
-re-queried for a fresh version of the suggestion each time the shortcut is displayed. The shortcut
-will be quickly displayed with whatever data was most recently available until the refresh query
-returns, after which the suggestion will be dynamically refreshed with the new information. The
-refresh query will be sent to your content provider with a URI path of {@link
+and the suggestion is
+re-queried for a fresh version each time the shortcut is displayed. The shortcut
+is quickly displayed with whatever data was most recently available until the refresh query
+returns, at which point the suggestion is refreshed with the new information. The
+refresh query is sent to your content provider with a URI path of {@link
android.app.SearchManager#SUGGEST_URI_PATH_SHORTCUT}
-(instead of {@link android.app.SearchManager#SUGGEST_URI_PATH_QUERY}). The Cursor you return should
-contain one suggestion using the
+(instead of {@link android.app.SearchManager#SUGGEST_URI_PATH_QUERY}).</p>
+ <p>The {@link android.database.Cursor} you return should contain one suggestion using the
same columns as the original suggestion, or be empty, indicating that the shortcut is no
-longer valid (in which case, the suggestion will disappear and the shortcut will be removed).</p>
- <p>If a suggestion refers to data that could take longer to refresh, such as a network based
-refresh, you may also add the {@link
+longer valid (in which case, the suggestion disappears and the shortcut is removed).</p>
+ <p>If a suggestion refers to data that could take longer to refresh, such as a network-based
+refresh, you can also add the {@link
android.app.SearchManager#SUGGEST_COLUMN_SPINNER_WHILE_REFRESHING} column to your suggestions
table with a value
of "true" in order to show a progress spinner for the right hand icon until the refresh is complete.
-(Any value other than "true" will not show the progress spinner.)</p></li>
+Any value other than "true" does not show the progress spinner.</p>
+ </li>
+
<li>Prevent the suggestion from being copied into a shortcut at all.
<p>Provide a value of {@link android.app.SearchManager#SUGGEST_NEVER_MAKE_SHORTCUT} in the
{@link android.app.SearchManager#SUGGEST_COLUMN_SHORTCUT_ID} column. In
-this case, the suggestion will never be copied into a shortcut. This should only be necessary if you
-absolutely do not want the previously copied suggestion to appear at all. (Recall that if you
-provide a normal value for the column then the suggestion shortcut will appear only until the
+this case, the suggestion is never copied into a shortcut. This should only be necessary if you
+absolutely do not want the previously copied suggestion to appear. (Recall that if you
+provide a normal value for the column, then the suggestion shortcut appears only until the
refresh query returns.)</p></li>
<li>Allow the default shortcut behavior to apply.
- <p>Simply leave the {@link android.app.SearchManager#SUGGEST_COLUMN_SHORTCUT_ID} empty for each
+ <p>Leave the {@link android.app.SearchManager#SUGGEST_COLUMN_SHORTCUT_ID} empty for each
suggestion that will not change and can be saved as a shortcut.</p></li>
</ol>
-<p>Of course, if none of your suggestions will ever change, then you do not need the
+<p>If none of your suggestions ever change, then you do not need the
{@link android.app.SearchManager#SUGGEST_COLUMN_SHORTCUT_ID} column at all.</p>
-<p class="note"><strong>Note</strong>: Quick Search Box will ultimately decide whether to shortcut
-your app's suggestions, considering these values as a strong request from your application.</p>
+<p class="note"><strong>Note</strong>: Quick Search Box ultimately decides whether or not to create
+a shortcut for a suggestion, considering these values as a strong request from your
+application—there is no guarantee that the behavior you have requested for your suggestion
+shortcuts will be honored.</p>
<h3 id="AboutRanking">About Quick Search Box suggestion ranking</h3>
-<p>Once your application's search results are made available to Quick Search Box, how they surface
-to the user for a particular query will be determined as appropriate by Quick Search Box ranking.
-This may depend on how many other apps have results for that query, and how often the user has
-selected on your results compared to those of the other apps. There is no guarantee about how
-ranking will occur, or whether your app's suggestions will show at all for a given query. In
-general, you can expect that providing quality results will increase the likelihood that your app's
-suggestions are provided in a prominent position, and apps that provide lower quality suggestions
-will be more likely to be ranked lower and/or not displayed.</p>
+<p>Once you make your application's search suggestions available to Quick Search Box, the Quick
+Search Box ranking determines how the suggestions are surfaced to the user for a particular query.
+This might depend on how many other apps have results for that query, and how often the user has
+selected your results compared to those from other apps. There is no guarantee about how your
+suggestions are ranked, or whether your app's suggestions show at all for a given query. In
+general, you can expect that providing quality results increases the likelihood that your app's
+suggestions are provided in a prominent position and apps that provide low quality suggestions
+are more likely to be ranked lower or not displayed.</p>
<div class="special">
<p>See the <a href="{@docRoot}resources/samples/SearchableDictionary/index.html">Searchable
diff --git a/docs/html/guide/topics/search/adding-recent-query-suggestions.jd b/docs/html/guide/topics/search/adding-recent-query-suggestions.jd
index 37e0e82..cb063a1 100644
--- a/docs/html/guide/topics/search/adding-recent-query-suggestions.jd
+++ b/docs/html/guide/topics/search/adding-recent-query-suggestions.jd
@@ -5,20 +5,22 @@
<div id="qv-wrapper">
<div id="qv">
+<h2>In this document</h2>
+<ol>
+<li><a href="#TheBasics">The Basics</a></li>
+<li><a href="#RecentQueryContentProvider">Creating a Content Provider</a></li>
+<li><a href="#RecentQuerySearchableConfiguration">Modifying the Searchable
+Configuration</a></li>
+<li><a href="#SavingQueries">Saving Queries</a></li>
+<li><a href="#ClearingSuggestionData">Clearing the Suggestion Data</a></li>
+</ol>
+
<h2>Key classes</h2>
<ol>
<li>{@link android.provider.SearchRecentSuggestions}</li>
<li>{@link android.content.SearchRecentSuggestionsProvider}</li>
</ol>
-<h2>In this document</h2>
-<ol>
-<li><a href="#TheBasics">The Basics</a></li>
-<li><a href="#RecentQuerySearchableConfiguration">Modifying the searchable
-configuration</a></li>
-<li><a href="#RecentQueryContentProvider">Creating a Content Provider</a></li>
-<li><a href="#SavingQueries">Saving queries</a></li>
-<li><a href="#ClearingSuggestionData">Clearing the suggestion data</a></li>
-</ol>
+
<h2>See also</h2>
<ol>
<li><a href="searchable-config.html">Searchable Configuration</a></li>
@@ -26,99 +28,76 @@
</div>
</div>
-<p>The Android search framework provides the ability for your application to
-provide suggestions while the user types into the Android search dialog. In this guide, you'll learn
-how to create recent query suggestions. These are suggestions based
-on queries previously entered by the user. So, if the user previously searched for "puppies" then it
-will appear as a suggestion as they begin typing the same string of text. The screenshot below
-shows an example of recent query suggestions.</p>
+<p>When using the Android search dialog, you can provide search suggestions based on recent search
+queries. For example, if a user previously searched for "puppies," then that query appears as a
+suggestion once he or she begins typing the same query. Figure 1 shows an example of a search dialog
+with recent query suggestions.</p>
-<p>Before you begin, you need to have implemented the Android search dialog for searches in your
-application. If you haven't done this, see <a href="search-dialog.html">Using the Android Search
-Dialog</a>.</p>
+<p>Before you begin, you need to implement the search dialog for basic searches in your application.
+If you haven't, see <a href="search-dialog.html">Using the Android Search Dialog</a>.</p>
+
<h2 id="TheBasics">The Basics</h2>
-<img src="{@docRoot}images/search/search-suggest-recent-queries.png" alt="" height="417"
-style="float:right;clear:right;" />
+<div class="figure" style="width:250px">
+<img src="{@docRoot}images/search/search-suggest-recent-queries.png" alt="" height="417" />
+<p class="img-caption"><strong>Figure 1.</strong> Screenshot of a search dialog with recent query
+suggestions.</p>
+</div>
<p>Recent query suggestions are simply saved searches. When the user selects one of
-the suggestions, your searchable Activity will receive a normal {@link
+the suggestions, your searchable Activity receives a {@link
android.content.Intent#ACTION_SEARCH} Intent with the suggestion as the search query, which your
-searchable Activity will already handle.</p>
+searchable Activity already handles (as described in <a href="search-dialog.html">Using the Android
+Search Dialog</a>).</p>
<p>To provide recent queries suggestions, you need to:</p>
<ul>
- <li>Implement a basic searchable Activity, as documented in <a
-href="{@docRoot}guide/topics/search/search-dialog.html">Using the Android Search Dialog</a>.</li>
+ <li>Implement a searchable Activity, <a
+href="{@docRoot}guide/topics/search/search-dialog.html">using the Android Search Dialog</a>.</li>
<li>Create a content provider that extends {@link
android.content.SearchRecentSuggestionsProvider} and declare it in your application manifest.</li>
- <li>Modify the searchable configuration with information about the content provider.</li>
- <li>Save queries to your content provider each time a search is made.</li>
+ <li>Modify the searchable configuration with information about the content provider that
+provides search suggestions.</li>
+ <li>Save queries to your content provider each time a search is executed.</li>
</ul>
-<p>Just like the Search Manager handles the rendering of the search dialog, it will also do the work
-to display all search suggestions below the search dialog. All you need to do is provide a source
-from which the suggestions can be retrieved.</p>
+<p>Just as the Search Manager displays the search dialog, it also displays the
+search suggestions. All you need to do is provide a source from which the suggestions can be
+retrieved.</p>
-<p>When the Search Manager identifies that your Activity is searchable and also provides search
-suggestions, the following procedure will take place as soon as the user types into the Android
-search box:</p>
+<p>When the Search Manager identifies that your Activity is searchable and provides search
+suggestions, the following procedure takes place as soon as the user types into the search
+dialog:</p>
+
+<ol>
+ <li>Search Manager takes the search query text (whatever has been typed so far) and performs a
+query to the content provider that contains your suggestions.</li>
+ <li>Your content provider returns a {@link android.database.Cursor} that points to all
+suggestions that match the search query text.</li>
+ <li>Search Manager displays the list of suggestions provided by the Cursor.</li>
+</ol>
+
+<p>Once the recent query suggestions are displayed, the following might happen:</p>
<ul>
- <li>The Search Manager takes the search query text (whatever has been typed so far) and performs a
-query to the content provider that manages your suggestions.</li>
- <li>Your content provider then returns a {@link android.database.Cursor} that points to all
-suggestions that are relevant to the search query text.</li>
- <li>The Search Manager then displays the list of suggestions provided by the Cursor (as
-demonstrated in the screenshot to the right).</li>
-</ul>
-
-<p>At this point, the following may happen:</p>
-
-<ul>
- <li>If the user types another key, or changes the query in any way, the above steps are repeated
-and the suggestion list is updated as appropriate.</li>
+ <li>If the user types another key, or changes the query in any way, the aforementioned steps are
+repeated and the suggestion list is updated.</li>
<li>If the user executes the search, the suggestions are ignored and the search is delivered
to your searchable Activity using the normal {@link android.content.Intent#ACTION_SEARCH}
Intent.</li>
- <li>If the user selects a suggestion, a normal
-{@link android.content.Intent#ACTION_SEARCH} Intent is triggered, using the suggested text as the
-query.</li>
+ <li>If the user selects a suggestion, an
+{@link android.content.Intent#ACTION_SEARCH} Intent is delivered to your searchable Activity using
+the suggested text as the query.</li>
</ul>
-<p>As you'll soon discover, the {@link android.content.SearchRecentSuggestionsProvider} class that
-you'll extend for your content provider will automatically do the work described above, so there's
+<p>The {@link android.content.SearchRecentSuggestionsProvider} class that
+you extend for your content provider automatically does the work described above, so there's
actually very little code to write.</p>
-<h2 id="RecentQuerySearchableConfiguration">Modifying the searchable configuration</h2>
-
-<p>First, you need to add the {@code android:searchSuggestAuthority} and
-{@code android:searchSuggestSelection} attributes to the {@code <searchable>} element in your
-searchable configuration file. For example:</p>
-
-<pre>
-<?xml version="1.0" encoding="utf-8"?>
-<searchable xmlns:android="http://schemas.android.com/apk/res/android"
- android:label="@string/app_label"
- android:hint="@string/search_hint"
- android:searchSuggestAuthority="my.package.MySuggestionProvider"
- android:searchSuggestSelection=" ?" >
-</searchable>
-</pre>
-
-<p>The value for {@code android:searchSuggestAuthority} should be a fully-qualified name for
-your content provider: your application package name followed by the name of your content provider.
-This string must match the authority used in the content provider (discussed in the next section).
-</p>
-
-<p>The value for {@code android:searchSuggestSelection} must be a single question-mark, preceded by
-a space (" ?"), which is simply a placeholder for the SQLite selection argument (which will be
-automatically replaced by the query text entered by the user).</p>
-
<h2 id="RecentQueryContentProvider">Creating a Content Provider</h2>
@@ -131,7 +110,7 @@
<pre>
public class MySuggestionProvider extends SearchRecentSuggestionsProvider {
- public final static String AUTHORITY = "my.package.MySuggestionProvider";
+ public final static String AUTHORITY = "com.example.MySuggestionProvider";
public final static int MODE = DATABASE_MODE_QUERIES;
public MySuggestionProvider() {
@@ -140,41 +119,72 @@
}
</pre>
-<p>The call to {@link android.content.SearchRecentSuggestionsProvider#setupSuggestions(String,int)}
-passes the name of the search authority (matching the one in the searchable configuration) and a
-database mode. The database mode must include {@link
+<p>The call to {@link android.content.SearchRecentSuggestionsProvider#setupSuggestions(String,int)
+setupSuggestions()} passes the name of the search authority and a
+database mode. The search authority can be any unique string, but the best practice is to use a
+fully qualified name for your content provider
+(package name followed by the provider's class name; for example,
+"com.example.MySuggestionProvider"). The database mode must include {@link
android.content.SearchRecentSuggestionsProvider#DATABASE_MODE_QUERIES} and can optionally include
{@link
-android.content.SearchRecentSuggestionsProvider#DATABASE_MODE_2LINES}, which will add another column
+android.content.SearchRecentSuggestionsProvider#DATABASE_MODE_2LINES}, which adds another column
to the suggestions table that allows you to provide a second line of text with each suggestion. For
-example:</p>
+example, if you want to provide two lines in each suggestion:</p>
+
<pre>
public final static int MODE = DATABASE_MODE_QUERIES | DATABASE_MODE_2LINES;
</pre>
-<p>In the following section, you'll see how to save both lines of text.</p>
-
-<p>Now simply declare the content provider in your application manifest with the same authority
-string used in the class (and in the searchable configuration). For example:</p>
+<p>Now declare the content provider in your application manifest with the same authority
+string used in your {@link android.content.SearchRecentSuggestionsProvider} class (and in the
+searchable configuration). For example:</p>
<pre>
<application>
<provider android:name=".MySuggestionProvider"
- android:authorities="my.package.authority" />
+ android:authorities="com.example.MySuggestionProvider" />
...
</application>
</pre>
-<h2 id="SavingQueries">Saving queries</h2>
-<p>In order to populate your collection of recent queries, you need to add each query
-received by your searchable Activity to the content provider you've just built. To do this, create
-an instance of {@link
+<h2 id="RecentQuerySearchableConfiguration">Modifying the Searchable Configuration</h2>
+
+<p>To configure your search dialog to use your suggestions provider, you need to add
+the {@code android:searchSuggestAuthority} and {@code android:searchSuggestSelection} attributes to
+the {@code <searchable>} element in your searchable configuration file. For example:</p>
+
+<pre>
+<?xml version="1.0" encoding="utf-8"?>
+<searchable xmlns:android="http://schemas.android.com/apk/res/android"
+ android:label="@string/app_label"
+ android:hint="@string/search_hint"
+ <b>android:searchSuggestAuthority="com.example.MySuggestionProvider"
+ android:searchSuggestSelection=" ?"</b> >
+</searchable>
+</pre>
+
+<p>The value for {@code android:searchSuggestAuthority} should be a fully qualified name for
+your content provider that exactly matches the authority used in the content provider (the {@code
+AUTHORITY} string in the above example).
+</p>
+
+<p>The value for {@code android:searchSuggestSelection} must be a single question mark, preceded by
+a space ({@code " ?"}), which is simply a placeholder for the SQLite selection argument (which is
+automatically replaced by the query text entered by the user).</p>
+
+
+
+<h2 id="SavingQueries">Saving Queries</h2>
+
+<p>To populate your collection of recent queries, add each query
+received by your searchable Activity to your {@link
+android.content.SearchRecentSuggestionsProvider}. To do this, create an instance of {@link
android.provider.SearchRecentSuggestions} and call {@link
-android.provider.SearchRecentSuggestions#saveRecentQuery(String,String)} each time your searchable
-Activity receives a query. For example, here's how you can save the query during your
-Activity's {@link android.app.Activity#onCreate(Bundle) onCreate()} method:</p>
+android.provider.SearchRecentSuggestions#saveRecentQuery(String,String) saveRecentQuery()} each time
+your searchable Activity receives a query. For example, here's how you can save the query during
+your Activity's {@link android.app.Activity#onCreate(Bundle) onCreate()} method:</p>
<pre>
@Override
@@ -193,24 +203,24 @@
}
</pre>
-<p>Notice that the {@link android.content.SearchRecentSuggestionsProvider} constructor requires the
+<p>The {@link android.content.SearchRecentSuggestionsProvider} constructor requires the
same authority and database mode declared by your content provider.</p>
-<p>The {@link android.provider.SearchRecentSuggestions#saveRecentQuery(String,String)} method takes
+<p>The {@link android.provider.SearchRecentSuggestions#saveRecentQuery(String,String)
+saveRecentQuery()} method takes
the search query string as the first parameter and, optionally, a second string to include as the
-second line of the suggestion. The second parameter is only used if you've enabled two-line mode
-for the search suggestions with {@link
+second line of the suggestion (or null). The second parameter is only used if you've enabled
+two-line mode for the search suggestions with {@link
android.content.SearchRecentSuggestionsProvider#DATABASE_MODE_2LINES}. If you have enabled
-two-line mode, then the query text will be matched against this second line as well.</p>
-
-<p>That's all that's needed to build a recent queries suggestion provider. However, there's one
-other important thing to do: provide the ability for the user to clear this search history.</p>
+two-line mode, then the query text is also matched against this second line when the Search Manager
+looks for matching suggestions.</p>
-<h2 id="ClearingSuggestionData">Clearing the suggestion data</h2>
+
+<h2 id="ClearingSuggestionData">Clearing the Suggestion Data</h2>
<p>To protect the user's privacy, you should always provide a way for the user to clear the recent
-query suggestions. To clear the recent queries, simply call {@link
+query suggestions. To clear the query history, call {@link
android.provider.SearchRecentSuggestions#clearHistory()}. For example:</p>
<pre>
@@ -219,7 +229,7 @@
suggestions.clearHistory();
</pre>
-<p>Simply execute this from your choice of a "Clear Search History" menu item,
-preference item, or button. You should also provide a confirmation dialog when this is pressed, to
+<p>Execute this from your choice of a "Clear Search History" menu item,
+preference item, or button. You should also provide a confirmation dialog to
verify that the user wants to delete their search history.</p>
diff --git a/docs/html/guide/topics/search/index.jd b/docs/html/guide/topics/search/index.jd
index b2252bb..78e0be2 100644
--- a/docs/html/guide/topics/search/index.jd
+++ b/docs/html/guide/topics/search/index.jd
@@ -13,98 +13,96 @@
<ol>
<li><a href="searchable-config.html">Searchable Configuration</a></li>
</ol>
-<h2>See also</h2>
+<h2>Related Samples</h2>
<ol>
<li><a href="{@docRoot}resources/samples/SearchableDictionary/index.html">Searchable
-Dictionary sample app</a></li>
+Dictionary</a></li>
</ol>
</div>
</div>
-<p>The ability to search is considered to be a core user feature on Android. The user should be able
-to search any data that is available to them, whether the content is located on the device or the
-Internet. This experience should be seamless and consistent across the entire
-system, which is why Android provides a simple search framework to help you provide users with
+<p>Search is a core user feature on Android. Users should be able
+to search any data that is available to them, whether the content is located on the device or
+the Internet. The search experience should be seamless and consistent across the entire
+system, which is why Android provides a search framework to help you provide users with
a familiar search dialog and a great search experience.</p>
-<img src="{@docRoot}images/search/search-suggest-custom.png" alt="" height="417"
-style="float:right;clear:right;" />
+<div class="figure" style="width:250px">
+<img src="{@docRoot}images/search/search-suggest-custom.png" alt="" height="417" />
+<p class="img-caption"><strong>Figure 1.</strong> Screenshot of a search dialog with custom
+search suggestions.</p>
+</div>
-<p>Android's search framework provides a user interface in which the user can perform a search and
-an interaction layer that communicates with your application. This way, you don't have to build
-a search box that the user must find in order to begin a search. Instead,
-a custom search dialog will appear at the top of the screen at the user's command.
-The search framework will manage the search dialog and when the user executes their search, the
-search framework will pass the query text to your application so that your application can begin a
-search. The screenshot to the right shows an example of the search dialog (using
-search suggestions).</p>
+<p>Android's search framework provides a user interface in which users can perform a search and
+an interaction layer that communicates with your application, so you don't have to build
+your own search Activity. Instead, a search dialog appears at the top of the screen at the user's
+command without interrupting the current Activity.</p>
+
+<p>The search framework manages the life of the search dialog. When users execute a search, the
+search framework passes the query text to your application so your application can perform a
+search. Figure 1 shows an example of the search dialog with optional search suggestions.</p>
<p>Once your application is set up to use the search dialog, you can:</p>
<ul>
-<li>Customize some of the search dialog characteristics</li>
<li>Enable voice search</li>
<li>Provide search suggestions based on recent user queries</li>
-<li>Provide search suggestions that match actual results in your application data</li>
+<li>Provide custom search suggestions that match actual results in your application data</li>
<li>Offer your application's search suggestions in the system-wide Quick Search Box</li>
</ul>
-<p>The following documents will teach you how to use the search dialog in
-your application:</p>
+<p class="note"><strong>Note</strong>: The search framework does <em>not</em> provide APIs to
+search your data. To perform a search, you need to use APIs appropriate for your data. For example,
+if your data is stored in an SQLite database, you should use the {@link android.database.sqlite}
+APIs to perform searches.</p>
+
+<p>The following documents show you how to use the search dialog in your application:</p>
<dl>
<dt><strong><a href="search-dialog.html">Using the Android Search Dialog</a></strong></dt>
- <dd>How to set up your application to use the search dialog for searches. </dd>
+ <dd>How to set up your application to use the search dialog. </dd>
<dt><strong><a href="adding-recent-query-suggestions.html">Adding Recent Query
Suggestions</a></strong></dt>
<dd>How to show suggestions based on queries previously used in the search dialog.</dd>
<dt><strong><a href="adding-custom-suggestions.html">Adding Custom Suggestions</a></strong></dt>
<dd>How to show suggestions based on custom data from your application and offer your suggestions
in the system-wide Quick Search Box.</dd>
+ <dt><strong><a href="searchable-config.html">Searchable Configuration</a></strong></dt>
+ <dd>A reference for the searchable configuration file (though the other
+documents also discuss the configuration file in terms of specific behaviors).</dd>
</dl>
-<p>Also, the <strong><a href="searchable-config.html">Searchable Configuration</a></strong> document
-provides a reference for the searchable configuration file (though the above
-documents also discuss the configuration file in terms of specific behaviors).</p>
-
-<p class="note"><strong>Note</strong>: The search framework does <em>not</em> provide APIs to
-perform searches on your data. Performing actual searches is a task that you must accomplish
-using APIs appropriate for your data, such as those in {@link android.database.sqlite}
-if your data is in an SQLite database.</p>
-
<h2>Protecting User Privacy</h2>
-<p>When you implement search in your application, you should take steps to protect the user's
-privacy whenever possible. Many users consider their activities on the phone, including searches, to
-be private information. To protect the user's privacy, you should abide by the following
+<p>When you implement search in your application, take steps to protect the user's
+privacy. Many users consider their activities on the phone—including searches—to
+be private information. To protect each user's privacy, you should abide by the following
principles:</p>
<ul>
-<li><strong>Don't send personal information to servers, and if you do, don't log it.</strong>
-<p>"Personal information" is information that can personally identify your users, such as their
-name, email address, billing information, or other data which can be reasonably linked to such
-information. If
-your application implements search with the assistance of a server, try to avoid sending personal
-information along with the search queries. For example, if you are searching for businesses near a
-zip code,
-you don't need to send the user ID as well — send only the zip code to the server. If you must
-send the personal information, you should take steps to avoid logging it. If you must log it, you
-should protect that data very carefully and erase it as soon as possible.</p>
+<li><strong>Don't send personal information to servers, but if you must, do not log it.</strong>
+<p>Personal information is any information that can personally identify your users, such as their
+names, email addresses, billing information, or other data that can be reasonably linked to such
+information. If your application implements search with the assistance of a server, avoid sending
+personal information along with the search queries. For example, if you are searching for businesses
+near a zip code,
+you don't need to send the user ID as well; send only the zip code to the server. If you must
+send the personal information, you should not log it. If you must log it, protect that data
+very carefully and erase it as soon as possible.</p>
</li>
<li><strong>Provide the user with a way to clear their search history.</strong>
-<p>The search framework helps your application provide context-specific suggestions while they type.
-Sometimes these
-suggestions are based on previous searches, or other actions taken by the user in an earlier
-session. A user may not wish for previous searches to be revealed to other users, for instance if
-they share their phone with a friend. If your application provides suggestions that can reveal
-previous activities, you should implement a "Clear History" menu item, preference, or button. If you
-are
-using {@link android.provider.SearchRecentSuggestions}, you can simply call its {@link
-android.provider.SearchRecentSuggestions#clearHistory()} method. If you are implementing custom
-suggestions, you'll need to provide a
-similar "clear history" method in your provider that can be invoked by the user.</p>
+<p>The search framework helps your application provide context-specific suggestions while the user
+types. Sometimes these
+suggestions are based on previous searches or other actions taken by the user in an earlier
+session. A user might not wish for previous searches to be revealed to other device users, for
+instance, if they share their phone with a friend. If your application provides suggestions that can
+reveal previous activities, you should implement the ability for the user to clear the search
+history. If you are using {@link android.provider.SearchRecentSuggestions}, you can simply call the
+{@link android.provider.SearchRecentSuggestions#clearHistory()} method. If you are implementing
+custom suggestions, you'll need to provide a similar "clear history" method in your provider that
+the user can execute.</p>
</li>
</ul>
diff --git a/docs/html/guide/topics/search/search-dialog.jd b/docs/html/guide/topics/search/search-dialog.jd
index a5f99c7..49c6627 100644
--- a/docs/html/guide/topics/search/search-dialog.jd
+++ b/docs/html/guide/topics/search/search-dialog.jd
@@ -5,10 +5,6 @@
<div id="qv-wrapper">
<div id="qv">
-<h2>Key classes</h2>
-<ol>
-<li>{@link android.app.SearchManager}</li>
-</ol>
<h2>In this document</h2>
<ol>
<li><a href="#TheBasics">The Basics</a></li>
@@ -27,64 +23,81 @@
<li><a href="#SearchContextData">Passing Search Context Data</a></li>
<li><a href="#VoiceSearch">Adding Voice Search</a></li>
</ol>
+
+<h2>Key classes</h2>
+<ol>
+<li>{@link android.app.SearchManager}</li>
+</ol>
+
+<h2>Related Samples</h2>
+<ol>
+<li><a href="{@docRoot}resources/samples/SearchableDictionary/index.html">Searchable
+Dictionary</a></li>
+</ol>
+
+<h2>Downloads</h2>
+<ol>
+<li><a href="{@docRoot}shareables/search_icons.zip">search_icons.zip</a></li>
+</ol>
+
<h2>See also</h2>
<ol>
<li><a href="adding-recent-query-suggestions.html">Adding Recent Query Suggestions</a></li>
<li><a href="adding-custom-suggestions.html">Adding Custom Suggestions</a></li>
<li><a href="searchable-config.html">Searchable Configuration</a></li>
-<li><a href="{@docRoot}resources/samples/SearchableDictionary/index.html">Searchable
-Dictionary App</a></li>
</ol>
+
</div>
</div>
-<p>When you want to provide search in your application, the last thing you should have to worry
-about is where to put your search box. By using the Android search framework, your application will
-reveal a custom search dialog whenever the user requests it. At the
-press of a dedicated search key or an API call from your application, the search dialog will
-appear at the top of the screen and will automatically show your application icon. An example is
-shown in the screenshot below.</p>
+<p>When you want to implement search in your application, the last thing you should have to worry
+about is where to put the search box. When you implement search with the Android search framework,
+you don't have to. When the user invokes search, a search dialog appears at the top of the screen
+with your application icon to the left of the search box. When the user executes the search, your
+application receives the query so it can search your application's data. An example of the search
+dialog is shown in figure 1.</p>
-<p>This guide will teach you how to set up your application to provide search in a custom search
-dialog. In doing so, you will provide a standardized search experience and be able to add
-features like voice search and search suggestions.</p>
+<p>This guide shows you how to set up your application to provide search in the search
+dialog. When you use the search dialog, you provide a standardized search
+experience and can add features such as voice search and search suggestions.</p>
<h2 id="TheBasics">The Basics</h2>
-<img src="{@docRoot}images/search/search-ui.png" alt="" height="417"
-style="float:right;clear:right;" />
+<div class="figure" style="width:250px">
+<img src="{@docRoot}images/search/search-ui.png" alt="" height="417" />
+<p class="img-caption"><strong>Figure 1.</strong> Screenshot of an application's search dialog.</p>
+</div>
-<p>The Android search framework will manage the search dialog on your behalf; you never need
-to draw it or worry about where it is, and your current Activity will not be
-interrupted. The {@link android.app.SearchManager} is the component that does this work for
-you (hereafter, referred to as "the Search Manager"). It manages the life of the Android search
-dialog and will send your application the search query when executed by the user.</p>
+<p>The Android search framework manages the search dialog for your application. You never need
+to draw it or worry about where it is, and your Activity is not interrupted when the search dialog
+appears. The Search Manager ({@link android.app.SearchManager}) is the component that does this work
+for you. It manages the life of the search dialog and sends your application the user's search
+query.</p>
-<p>When the user executes a search, the Search Manager will use a specially-formed Intent to pass
-the search query to the Activity that you've declared to handle searches. Essentially, all you
-need is an Activity that receives this Intent, performs the search, and presents the results.
-Specifically, what you need is the following:</p>
+<p>When the user executes a search, the Search Manager creates an {@link android.content.Intent} to
+pass the search query to the Activity that you've declared to handle searches. Basically, all you
+need is an Activity that receives the search Intent, performs the search, and presents the results.
+Specifically, you need the following:</p>
<dl>
<dt>A searchable configuration</dt>
- <dd>This is an XML file that configures the search dialog and includes settings for
-features such as the hint text shown in text box and settings voice search and search
-suggestion.</dd>
+ <dd>An XML file that configures the search dialog and includes settings for features such as voice
+search, search suggestion, and the hint text.</dd>
<dt>A searchable Activity</dt>
- <dd>This is the {@link android.app.Activity} that receives the search query then
-searches your data and displays the search results.</dd>
+ <dd>The {@link android.app.Activity} that receives the search query, then searches your data and
+displays the search results.</dd>
<dt>A mechanism by which the user can invoke search</dt>
- <dd>By default, the device search key (if available) will invoke the search dialog once
-you've configured a searchable Activity. However, you should always provide another means by
-which the user can invoke a search, such as with a search button in the Options Menu or elsewhere in
-the Activity UI, because not all devices provide a dedicated search key.</dd>
+ <dd>The device search key invokes the search dialog, by default. However, a dedicated search key
+is not guaranteed on all devices, so provide another means by which the user can invoke a search,
+such as a search button in the Options Menu or elsewhere in the Activity UI.</dd>
</dl>
+
<h2 id="SearchableConfiguration">Creating a Searchable Configuration</h2>
-<p>The searchable configuration is an XML file that defines several settings for the Android search
+<p>The searchable configuration is an XML file that defines several settings for the search
dialog in your application. This file is traditionally named {@code searchable.xml} and must be
saved in the {@code res/xml/} project directory.</p>
@@ -94,45 +107,61 @@
<pre>
<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
- android:label="@string/app_label" >
+ android:label="@string/app_label"
+ android:hint="@string/search_hint" >
</searchable>
</pre>
-<p>This is the minimum configuration required in order to provide the search dialog. The {@code
-android:label} attribute is the only required attribute and points to a string resource, which
-should normally be the same as the application. (Although it's required, this
-label isn't actually shown to the user until you enable suggestions for Quick Search Box.)</p>
+<p>The {@code android:label} attribute is the only required attribute and points to a string
+resource, which should be the same as the application name. This label isn't actually visible to the
+user until you enable suggestions for Quick Search Box, at which point, this label is visible in the
+list of Searchable items in the system Settings.</p>
-<p>There are several other attributes accepted by the {@code <searchable>} element. Most of
-which apply only when configuring features such as search suggestions and voice
-search. However, we recommend that you always include the {@code android:hint} attribute, which
-specifies a string resource for the text to display in the search dialog's text box before the user
-enters their query—it provides important clues to the user about what they can search. </p>
+<p>Though it's not required, we recommend that you always include the {@code android:hint}
+attribute, which provides a hint string in the search dialog's text box before the user
+enters their query. The hint is important because it provides important clues to users about what
+they can search.</p>
<p class="note"><strong>Tip:</strong> For consistency among other
Android applications, you should format the string for {@code android:hint} as "Search
<em><content-or-product></em>". For example, "Search songs and artists" or "Search
YouTube".</p>
-<p>Next, you'll hook this configuration into your application.</p>
+<p>The {@code <searchable>} element accepts several other attributes. Most attributes apply
+only when configuring features such as search suggestions and voice search.</p>
+
+<p>For more details about the searchable configuration file, see the <a
+href="{@docRoot}guide/topics/search/searchable-config.html">Searchable Configuration</a>
+reference.</p>
+
<h2 id="SearchableActivity">Creating a Searchable Activity</h2>
-<p>When the user executes a search from the search dialog, the Search Manager will send
-your searchable {@link android.app.Activity} the search query with the {@link
-android.content.Intent#ACTION_SEARCH} {@link android.content.Intent}. Your searchable Activity will
-then search your data and present the results.</p>
+<p>When the user executes a search from the search dialog, the Search Manager takes the query
+and sends it to your searchable {@link android.app.Activity} in the {@link
+android.content.Intent#ACTION_SEARCH} {@link android.content.Intent}. Your searchable Activity
+then searches your data using the query and presents the results to the user.</p>
+
+<p>In order for the Search Manager to know where to deliver the search query, you must declare your
+searchable Activity in the Android manifest file.</p>
<h3 id="DeclaringSearchableActivity">Declaring a searchable Activity</h3>
-<p>If you don't have one already, create an {@link android.app.Activity} that will be used to
-perform searches, then declare it to
-accept the {@link android.content.Intent#ACTION_SEARCH} {@link android.content.Intent} and apply the
-searchable configuration. To do so, you need to add an {@code
-<intent-filter>} element and a {@code <meta-data>} element to the
-appropriate {@code <activity>} element in your manifest file. For example:</p>
+<p>If you don't have one already, create an {@link android.app.Activity} that performs
+searches and present search results. To set up this Activity as your searchable Activity:</p>
+<ol>
+ <li>Declare the Activity to accept the {@link android.content.Intent#ACTION_SEARCH} {@link
+android.content.Intent}, in an <a
+href="{@docRoot}guide/topics/manifest/intent-filter-element.html">{@code <intent-filter>}</a>
+element.</li>
+ <li>Apply the searchable configuration, in a <a
+href="{@docRoot}guide/topics/manifest/meta-data-element.html">{@code <meta-data>}</a>
+element.</li>
+</ol>
+
+<p>For example:</p>
<pre>
<application ... >
@@ -147,29 +176,27 @@
</application>
</pre>
-<p>The {@code android:name} attribute in the {@code <meta-data>} element must be defined with
-{@code "android.app.searchable"} and the {@code android:resource} attribute value must be a
-reference to the searchable configuration file saved in {@code res/xml} (in this example, it
+<p>The {@code <meta-data>} element must include the {@code android:name} attribute with a
+value of {@code "android.app.searchable"} and the {@code android:resource} attribute with a
+reference to the searchable configuration file (in this example, it
refers to the {@code res/xml/searchable.xml} file).</p>
-<p class="note">If you're wondering why the {@code
-<intent-filter>} does not include a {@code <category>} with the {@code DEFAULT}
-value, it's because the Intent that is delivered to this Activity when a search is executed will
-explicitly define this Activity as the component for the Intent (which the Search Manager knows
-from the searcahble meta-data declared for the Activity).</p>
+<p class="note"><strong>Note:</strong> The {@code <intent-filter>} does not need a <a
+href="{@docRoot}guide/topics/manifest/category-element.html">{@code <category>}</a> with the
+{@code DEFAULT} value, because the Search Manager delivers the {@link
+android.content.Intent#ACTION_SEARCH} Intent explicitly to your searchable Activity by name.</p>
-<p>Be aware that the search dialog will not be available from within every
-Activity of your application, by default. Rather, the search dialog will be presented to
-users only when they
+<p>The search dialog is not, by default, available from every Activity of your
+application. Rather, the search dialog is presented to users only when they
invoke search from a searchable context of your application. A searchable context is any Activity
for which you have
declared searchable meta-data in the manifest file. For example, the searchable Activity itself
(declared in the manifest snippet above) is
-a searchable context because it contains searchable meta-data that defines the
+a searchable context because it includes meta-data that defines the
searchable configuration. Any other Activity in your application is not a searchable context, by
-default, and thus, will not reveal the search dialog. You probably do want the
-search dialog to be available from every Activity in your application, so this can be easily
-fixed.</p>
+default, and thus, does not reveal the search dialog. However, you probably do want the search
+dialog available from your other activities (and to launch the searchable Activity when the user
+executes a search). You can do exactly that.</p>
<p>If you want all of your activities to provide the search dialog, add another {@code
<meta-data>} element inside the {@code
@@ -187,9 +214,9 @@
</activity>
<activity android:name=".AnotherActivity" ... >
</activity>
- <!-- this one declares the searchable Activity for the whole app -->
- <meta-data android:name="android.app.default_searchable"
- android:value=".MySearchableActivity" />
+ <!-- declare the default searchable Activity for the whole app -->
+ <b><meta-data android:name="android.app.default_searchable"
+ android:value=".MySearchableActivity" /></b>
...
</application>
</pre>
@@ -199,28 +226,34 @@
which it is placed (which, in this case, is the entire application). The searchable Activity to
use is specified with the {@code android:value} attribute. All other activities in the
application, such as {@code AnotherActivity}, are now considered a searchable context and can invoke
-the search dialog. When a search is executed, {@code MySearchableActivity} will
-be launched to handle the search query.</p>
+the search dialog. When a search is executed, {@code MySearchableActivity} is launched to handle
+the search query.</p>
-<p>Notice that this allows you to control which activities provide search at a more granular level.
-To specify only an individual Activity as a searchable context, simply place the {@code
+<p>You can also control which activities provide search at a more granular level.
+To specify only an individual Activity as a searchable context, place the {@code
<meta-data>} with the {@code
"android.app.default_searchable"} name inside the respective {@code <activity>}
-element (rather than inside the {@code <application>}). And, while it is uncommon, you can
-even create more than one searchable Activity and provide each one in different contexts of your
+element (rather than inside the {@code <application>} element). While uncommon, you
+can also create more than one searchable Activity and provide each one in different contexts of your
application, either by declaring a different searchable Activity in each {@code <activity>}
-element, or declaring a default searchable Activity for the entire application and then overriding
-it with a different {@code <meta-data>} element inside certain activities.</p>
+element, or by declaring a default searchable Activity for the entire application and then
+overriding it with a {@code <meta-data>} element inside certain activities. (You might do
+this if you want to search different sets of data that cannot be handled by the same
+searchable Activity, depending on the currently open Activity.)</p>
<h3 id="PerformingSearch">Performing a search</h3>
-<p>Once your Activity is declared searchable, performing the actual search involves three steps:
-receiving the query, searching your data, and presenting the results.</p>
+<p>Once you have declared your searchable Activity, performing a search for the user involves
+three steps:</p>
+<ol>
+ <li><a href="#ReceivingTheQuery">Receiving the query</a></li>
+ <li><a href="#SearchingYourData">Searching your data</a></li>
+ <li><a href="#PresentingTheResults">Presenting the results</a></li>
+</ol>
-<p>Traditionally, your search results should be presented in a {@link android.widget.ListView}
-(assuming that our results are text-based), so
-you may want your searchable Activity to extend {@link android.app.ListActivity}, which
+<p>Traditionally, your search results should be presented in a {@link android.widget.ListView}, so
+you might want your searchable Activity to extend {@link android.app.ListActivity}, which
provides easy access to {@link android.widget.ListView} APIs. (See the <a
href="{@docRoot}resources/tutorials/views/hello-listview.html">List View Tutorial</a> for a simple
{@link android.app.ListActivity} sample.)</p>
@@ -228,12 +261,12 @@
<h4 id="ReceivingTheQuery">Receiving the query</h4>
-<p>When a search is executed from the search dialog, your searchable Activity will be opened
-with the {@link android.content.Intent#ACTION_SEARCH} {@link android.content.Intent}, which carries
-the search query in the
-{@link android.app.SearchManager#QUERY QUERY} extra. All you need to do is check for
-this Intent and extract the string. For example, here's how you can get the query when your
-Activity launches:</p>
+<p>When a user executes a search from the search dialog, the Search Manager sends the {@link
+android.content.Intent#ACTION_SEARCH} {@link android.content.Intent} to your searchable Activity.
+This Intent carries the search query in the
+{@link android.app.SearchManager#QUERY QUERY} string extra. You must check for
+this Intent when the Activity starts and extract the string. For example, here's how you can get the
+query when your Activity starts:</p>
<pre>
@Override
@@ -258,22 +291,21 @@
<h4 id="SearchingYourData">Searching your data</h4>
-<p>The process of storing and searching your data is a process that's unique to your application.
-There are many ways that you might do this and discussing all options is beyond the scope of
-this document. This guide will not teach you how to store your data and search it; this
-is something you must carefully consider in terms of your needs and your data. However, here are
-some tips you may be able to apply:</p>
+<p>The process of storing and searching your data is unique to your application.
+You can store and search your data in many ways, but this guide does not show you how to store your
+data and search it. Storing and searching your data is something you should carefully consider in
+terms of your needs and your data. However, here are some tips you might be able to apply:</p>
<ul>
<li>If your data is stored in a SQLite database on the device, performing a full-text search
(using FTS3, rather than a LIKE query) can provide a more robust search across text data and can
-produce results many, many times faster. See <a href="http://sqlite.org/fts3.html">sqlite.org</a>
+produce results significantly faster. See <a href="http://sqlite.org/fts3.html">sqlite.org</a>
for information about FTS3 and the {@link android.database.sqlite.SQLiteDatabase} class for
information about SQLite on Android. Also look at the <a
href="{@docRoot}resources/samples/SearchableDictionary/index.html">Searchable Dictionary</a> sample
application to see a complete SQLite implementation that performs searches with FTS3.</li>
- <li>If your data is stored online, then the perceived search performance may be
-inhibited by the user's data connection. You may want to display a spinning progress wheel until
+ <li>If your data is stored online, then the perceived search performance might be
+inhibited by the user's data connection. You might want to display a spinning progress wheel until
your search returns. See {@link android.net} for a reference of network APIs and <a
href="{@docRoot}guide/topics/ui/dialogs.html#ProgressDialog">Creating a Progress Dialog</a> to see
how you can display a progress wheel.</li>
@@ -283,32 +315,32 @@
<div class="sidebox-wrapper">
<div class="sidebox">
<h2>About Adapters</h2>
-<p>An Adapter will bind individual items from a set of data into individual {@link
+<p>An Adapter binds individual items from a set of data into individual {@link
android.view.View} objects. When the Adapter
is applied to a {@link android.widget.ListView}, the Views are injected as individual items of the
list. {@link
android.widget.Adapter} is simply an interface, so implementations such as {@link
android.widget.CursorAdapter} (for binding data from a {@link android.database.Cursor}) are needed.
If none of the existing implementations work for your data, then you should implement your own from
-{@link android.widget.BaseAdapter}. Install the SDK Samples package for API Level 4 to see a
-version of the Searchable Dictionary that creates a custom BaseAdapter.</p>
+{@link android.widget.BaseAdapter}. Install the SDK Samples package for API Level 4 to see the
+original version of the Searchable Dictionary, which creates a custom BaseAdapter.</p>
</div>
</div>
<p>Regardless of where your data lives and how you search it, we recommend that you return search
results to your searchable Activity with an {@link android.widget.Adapter}. This way, you can easily
present all the search results in a {@link android.widget.ListView}. If your data comes from a
-SQLite database query, then you can easily apply your results to a {@link android.widget.ListView}
+SQLite database query, then you can apply your results to a {@link android.widget.ListView}
using a {@link android.widget.CursorAdapter}. If your data comes in some other type of format, then
you can create an extension of the {@link android.widget.BaseAdapter}.</p>
<h4 id="PresentingTheResults">Presenting the results</h4>
-<p>Presenting your search results is mostly a UI detail and not something covered by the search
-framework APIs. However, a simple solution is to create your searchable Activity to extend {@link
-android.app.ListActivity} and then call {@link
+<p>Presenting your search results is mostly a UI detail that is not handled by the search APIs.
+However, one option is to create your searchable Activity to extend {@link
+android.app.ListActivity} and call {@link
android.app.ListActivity#setListAdapter(ListAdapter)}, passing it an {@link
-android.widget.Adapter} that is bound to your data. This will automatically project all the
+android.widget.Adapter} that is bound to your data. This injects all the
results into the Activity {@link android.widget.ListView}.</p>
<p>For more help presenting your results, see the {@link android.app.ListActivity}
@@ -316,29 +348,27 @@
<p>Also see the <a
href="{@docRoot}resources/samples/SearchableDictionary/index.html">Searchable Dictionary</a> sample
-application for an a complete demonstration of how to search an SQLite database and use an
-{@link android.widget.Adapter} to provide resuls in a {@link android.widget.ListView}.</p>
+for an a complete demonstration of how to search an SQLite database and use an
+{@link android.widget.Adapter} to provide results in a {@link android.widget.ListView}.</p>
+
<h2 id="InvokingTheSearchDialog">Invoking the Search Dialog</h2>
-<p>Once you have a searchable Activity in place, invoking the search dialog so the user can
-submit a
-query is easy. Many Android devices provide a dedicated search key and when it is pressed while the
-user is within a searchable context of your application, the search dialog will be revealed.
-However,
-you should never assume that a search key is available on the user's device and should always
-provide a search button in your UI that will invoke search.</p>
+<p>Once you have a searchable Activity, invoking the search dialog is easy. Many Android
+devices provide a dedicated SEARCH key, which reveals the search dialog when the user presses it
+from a searchable context of your application. However, you should not assume that a SEARCH
+key is available on the user's device and should always provide a search button in your UI that
+invokes search.</p>
-<p>To invoke search from your Activity, simply call {@link
-android.app.Activity#onSearchRequested()}.</p>
+<p>To invoke search from your Activity, call {@link android.app.Activity#onSearchRequested()}.</p>
-<p>For example, you should provide a menu item in your <a
+<p>For instance, you should provide a menu item in your <a
href="{@docRoot}guide/topics/ui/menus.html#options-menu">Options Menu</a> or a button in your UI to
-invoke search with this method. For your convenience, this <a
+invoke search with this method. The <a
href="{@docRoot}shareables/search_icons.zip">search_icons.zip</a> file includes icons for
-medium and high density screens, which you can use for your menu item or button (low density
-screens will automatically scale-down the hdpi image by one half). </p>
+medium and high density screens, which you can use for your search menu item or button (low density
+screens automatically scale-down the hdpi image by one half). </p>
<!-- ... maybe this should go into the Creating Menus document ....
<p>If you chose to provide a shortcut key for the menu item, using {@link
@@ -346,28 +376,29 @@
key character, representing the default search key.</p>
-->
-<p>You can also enable "type-to-search" functionality in your Activity by calling {@link
-android.app.Activity#setDefaultKeyMode(int) setDefaultKeyMode}({@link
-android.app.Activity#DEFAULT_KEYS_SEARCH_LOCAL}). When this is enabled and the user begins typing on
-the keyboard, search will automatically be
-invoked and the keystrokes will be inserted in the search dialog. Be sure to enable this mode
-during your Activity {@link android.app.Activity#onCreate(Bundle) onCreate()} method.</p>
+<p>You can also enable "type-to-search" functionality, which reveals the search dialog when the
+user starts typing on the keyboard and the keystrokes are inserted into the search dialog. You can
+enable type-to-search in your Activity by calling
+{@link android.app.Activity#setDefaultKeyMode(int) setDefaultKeyMode}({@link
+android.app.Activity#DEFAULT_KEYS_SEARCH_LOCAL}) during your Activity's
+{@link android.app.Activity#onCreate(Bundle) onCreate()} method.</p>
-<h3 id="LifeCycle">The impact of the search dialog on your Activity life-cycle</h3>
+<h3 id="LifeCycle">The impact of the search dialog on your Activity lifecycle</h3>
-<p>The search dialog behaves like a {@link android.app.Dialog} that floats at the top of the
-screen. It
-does not cause any change in the Activity stack, so no life-cycle methods (such as {@link
-android.app.Activity#onPause()}) will
-be called. All that happens is your Activity loses input focus as it is given to the search dialog.
+<p>The search dialog is a {@link android.app.Dialog} that floats at the top of the
+screen. It does not cause any change in the Activity stack, so when the search dialog appears, no
+lifecycle methods for the currently open Activity (such as {@link
+android.app.Activity#onPause()}) are called. Your Activity just loses input focus as it is given to
+the search dialog.
</p>
-<p>If you want to be notified when search is invoked, simply override the {@link
-android.app.Activity#onSearchRequested()} method. When this is called, you can do any work you may
-want to do when your Activity looses input focus (such as pause animations). But unless you are
-<a href="#SearchContextData">Passing Search Context Data</a> (discussed above), you should always
-call the super class implementation. For example:</p>
+<p>If you want to be notified when search is invoked, override the {@link
+android.app.Activity#onSearchRequested()} method. When the system calls this method, you can do any
+work you want to when your Activity looses input focus to the search dialog (such as pause
+animations). Unless you are <a href="#SearchContextData">passing search context data</a>
+(discussed below), you should end the method by calling the super class implementation. For
+example:</p>
<pre>
@Override
@@ -377,35 +408,37 @@
}
</pre>
-<p>If the user cancels search by pressing the device Back key, the Activity in which search was
-invoked will re-gain input focus. You can register to be notified when the search dialog is
-closed with {@link android.app.SearchManager#setOnDismissListener(SearchManager.OnDismissListener)}
-and/or {@link android.app.SearchManager#setOnCancelListener(SearchManager.OnCancelListener)}. You
-should normally only need to register the {@link android.app.SearchManager.OnDismissListener
-OnDismissListener}, because this is called every time that the search dialog is closed. The {@link
+<p>If the user cancels search by pressing the BACK key, the Activity in which search was
+invoked re-gains input focus. You can register to be notified when the search dialog is
+closed with {@link android.app.SearchManager#setOnDismissListener(SearchManager.OnDismissListener)
+setOnDismissListener()}
+and/or {@link android.app.SearchManager#setOnCancelListener(SearchManager.OnCancelListener)
+setOnCancelListener()}. You
+should need to register only the {@link android.app.SearchManager.OnDismissListener
+OnDismissListener}, because it is called every time the search dialog closes. The {@link
android.app.SearchManager.OnCancelListener OnCancelListener} only pertains to events in which the
-user explicitly left the search dialog, so it is not called when a search is executed (in which
+user explicitly exited the search dialog, so it is not called when a search is executed (in which
case, the search dialog naturally disappears).</p>
-<p>If the current Activity is not the searchable Activity, then the normal Activity life-cycle
-events will be triggered once the user executes a search (the current Activity will receive {@link
+<p>If the current Activity is not the searchable Activity, then the normal Activity lifecycle
+events are triggered once the user executes a search (the current Activity receives {@link
android.app.Activity#onPause()} and so forth, as
described in <a href="{@docRoot}guide/topics/fundamentals.html#lcycles">Application
Fundamentals</a>). If, however, the current Activity is the searchable Activity, then one of two
-things will happen:</p>
+things happens:</p>
-<ul>
- <li>By default, the searchable Activity will receive the {@link
+<ol type="a">
+ <li>By default, the searchable Activity receives the {@link
android.content.Intent#ACTION_SEARCH} Intent with a call to {@link
android.app.Activity#onCreate(Bundle) onCreate()} and a new instance of the
-Activity will be brought to the top of the stack. You'll now have two instances of your searchable
-Activity in the Activity stack (so pressing the Back key will go back to the previous instance of
-the searchable Activity, rather than exiting the searchable Activity).</li>
- <li>On the other hand, if the Activity has set {@code android:launchMode} to "singleTop" then the
-searchable Activity will receive the {@link android.content.Intent#ACTION_SEARCH} Intent with a call
+Activity is brought to the top of the Activity stack. There are now two instances of your
+searchable Activity in the Activity stack (so pressing the BACK key goes back to the previous
+instance of the searchable Activity, rather than exiting the searchable Activity).</li>
+ <li>If you set {@code android:launchMode} to "singleTop", then the
+searchable Activity receives the {@link android.content.Intent#ACTION_SEARCH} Intent with a call
to {@link android.app.Activity#onNewIntent(Intent)}, passing the new {@link
-android.content.Intent#ACTION_SEARCH} Intent here. For example, here's how you might want to handle
-this case:
+android.content.Intent#ACTION_SEARCH} Intent here. For example, here's how you might handle
+this case, in which the searchable Activity's launch mode is "singleTop":
<pre>
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -430,28 +463,30 @@
<p>Compared to the example code in the section about <a href="#PerfomingSearch">Performing a
Search</a>, all the code to handle the
-search Intent has been moved outside the {@link android.app.Activity#onCreate(Bundle)
-onCreate()} method so it can also be executed from {@link android.app.Activity#onNewIntent(Intent)
-onNewIntent()}.
-It's important to note that when {@link android.app.Activity#onNewIntent(Intent)} is
-called, the Activity has not been restarted, so the {@link android.app.Activity#getIntent()} method
-will still return the Intent that was first received with {@link
-android.app.Activity#onCreate(Bundle) onCreate()}. This is why {@link
-android.app.Activity#setIntent(Intent)} is called inside {@link
-android.app.Activity#onNewIntent(Intent)} (just in case you call {@link
-android.app.Activity#getIntent()} at a later time).</p>
+search Intent is now in the {@code handleIntent()} method, so that both {@link
+android.app.Activity#onCreate(Bundle)
+onCreate()} and {@link android.app.Activity#onNewIntent(Intent) onNewIntent()} can execute it.</p>
+
+<p>When the system calls {@link android.app.Activity#onNewIntent(Intent)}, the Activity has
+not been restarted, so the {@link android.app.Activity#getIntent()} method
+returns the same Intent that was received with {@link
+android.app.Activity#onCreate(Bundle) onCreate()}. This is why you should call {@link
+android.app.Activity#setIntent(Intent)} inside {@link
+android.app.Activity#onNewIntent(Intent)} (so that the Intent saved by the Activity is updated in
+case you call {@link android.app.Activity#getIntent()} in the future).</p>
</li>
-</ul>
+</ol>
-<p>This second scenario is normally ideal, because the chances are good that once a search is
-completed, the user will perform additional searches and it's a bad experience if your application
-piles multiple instances of the searchable Activity on the stack. So we recommend that you set your
-searchable Activity to "singleTop" launch mode in the application manifest. For example:</p>
+<p>The second scenario using "singleTop" launch mode is usually ideal, because chances are good that
+once a search is done, the user will perform additional searches and it's a bad experience if your
+application creates multiple instances of the searchable Activity. So, we recommend that you set
+your searchable Activity to "singleTop" launch mode in the application
+manifest. For example:</p>
<pre>
<activity android:name=".MySearchableActivity"
- android:launchMode="singleTop" >
+ <b>android:launchMode="singleTop"</b> >
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
@@ -461,19 +496,20 @@
</pre>
+
<h2 id="SearchContextData">Passing Search Context Data</h2>
-<p>In order to refine your search criteria, you may want to provide some additional
-data to your searchable Activity when a search is executed. For instance, when you search your data,
-you may want to filter results based on more than just the search query text. In a simple
-case, you could just make your refinements inside the searchable Activity, for every search made.
-If, however, your
-search criteria may vary from one searchable context to another, then you can pass whatever data is
-necessary to refine your search in the {@link android.app.SearchManager#APP_DATA} Bundle, which is
-included in the {@link android.content.Intent#ACTION_SEARCH} Intent.</p>
+<p>To refine your search criteria from the current Activity instead of depending only on the user's
+search query, you can provide additional data in the Intent that the Search Manager sends to your
+searchable Activity. In a simple case, you can make your refinements inside the searchable
+Activity, for every search made, but if your
+search criteria varies from one searchable context to another, then you can pass whatever data
+is necessary to refine your search in the {@link android.app.SearchManager#APP_DATA} {@link
+android.os.Bundle}, which is included in the {@link android.content.Intent#ACTION_SEARCH}
+Intent.</p>
-<p>To pass this kind of data to your searchable Activity, you need to override {@link
-android.app.Activity#onSearchRequested()} method for the Activity in which search will be invoked.
+<p>To pass this kind of data to your searchable Activity, override {@link
+android.app.Activity#onSearchRequested()} method for the Activity in which search can be invoked.
For example:</p>
<pre>
@@ -487,56 +523,54 @@
</pre>
<p>Returning "true" indicates that you have successfully handled this callback event. Then in your
-searchable Activity, you can extract this data from the {@link
+searchable Activity, you can extract the data placed inside {@code appdata} from the {@link
android.app.SearchManager#APP_DATA} {@link android.os.Bundle} to refine the search. For example:</p>
<pre>
- Bundle appData = getIntent().getBundleExtra(SearchManager.APP_DATA);
- if (appData != null) {
- boolean jargon = appData.getBoolean(MySearchableActivity.JARGON);
- }
+Bundle appData = getIntent().getBundleExtra(SearchManager.APP_DATA);
+if (appData != null) {
+ boolean jargon = appData.getBoolean(MySearchableActivity.JARGON);
+}
</pre>
-<p class="caution"><strong>Note:</strong> You should never call the {@link
+<p class="caution"><strong>Caution:</strong> Never call the {@link
android.app.Activity#startSearch(String,boolean,Bundle,boolean) startSearch()} method from outside
-the {@link android.app.Activity#onSearchRequested()} callback method. When you want to invoke the
-search dialog, always call {@link android.app.Activity#onSearchRequested()} so that custom
-implementations (such as the addition of {@code appData}, in the above example) can be accounted
-for.</p>
+the {@link android.app.Activity#onSearchRequested()} callback method. To invoke the search dialog
+in your Activity, always call {@link android.app.Activity#onSearchRequested()}. Otherwise, {@link
+android.app.Activity#onSearchRequested()} is not called and customizations (such as the addition of
+{@code appData} in the above example) are missed.</p>
<h2 id="VoiceSearch">Adding Voice Search</h2>
-<p>You can easily add voice search functionality to your search dialog by adding the {@code
-android:voiceSearchMode} attribute to your searchable configuration. This will add a voice search
-button in the search dialog that, when clicked, will launch a voice prompt. When the user
-has finished speaking, the transcribed search query will be sent to your searchable
+<p>You can add voice search functionality to your search dialog by adding the {@code
+android:voiceSearchMode} attribute to your searchable configuration. This adds a voice search
+button in the search dialog that launches a voice prompt. When the user
+has finished speaking, the transcribed search query is sent to your searchable
Activity.</p>
-<p>To enable voice search for your activity, add the {@code android:voiceSearchMode}
-attribute to your searchable configuration. For example:</p>
+<p>For example:</p>
<pre>
<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:label="@string/search_label"
android:hint="@string/search_hint"
- android:voiceSearchMode="showVoiceSearchButton|launchRecognizer" >
+ <b>android:voiceSearchMode="showVoiceSearchButton|launchRecognizer"</b> >
</searchable>
</pre>
<p>The value {@code showVoiceSearchButton} is required to enable voice
search, while the second value, {@code launchRecognizer}, specifies that the voice search button
-should launch a recognizer that returns the transcribed text to the searchable Activity. This is
-how most applications should declare this attribute.</p>
+should launch a recognizer that returns the transcribed text to the searchable Activity.</p>
-<p>There are some additional attributes you can provide to specify the voice search behavior, such
+<p>You can provide additional attributes to specify the voice search behavior, such
as the language to be expected and the maximum number of results to return. See the <a
-href="searchable-config.html">Searchable Configuration</a> for more information about the
+href="searchable-config.html">Searchable Configuration</a> reference for more information about the
available attributes.</p>
<p class="note"><strong>Note:</strong> Carefully consider whether voice search is appropriate for
-your application. All searches performed with the voice search button will be immediately sent to
-your searchable Activity without a chance for the user to review the transcribed query. Be sure to
-sufficiently test the voice recognition and ensure that it understands the types of queries that
-the user will submit inside your application.</p>
+your application. All searches performed with the voice search button are immediately sent to
+your searchable Activity without a chance for the user to review the transcribed query. Sufficiently
+test the voice recognition and ensure that it understands the types of queries that
+the user might submit inside your application.</p>
diff --git a/docs/html/guide/topics/search/searchable-config.jd b/docs/html/guide/topics/search/searchable-config.jd
index 71566de..2aa2db6 100644
--- a/docs/html/guide/topics/search/searchable-config.jd
+++ b/docs/html/guide/topics/search/searchable-config.jd
@@ -14,18 +14,18 @@
</div>
</div>
-<p>In order to utilize the Android search framework and provide a custom search dialog, your
+<p>To utilize the Android search framework and provide a custom search dialog, your
application must provide a search
configuration in the form of an XML resource. This document describes the search configuration XML
-in terms of its syntax and usage. For a more complete discussion about how to implement search
-features for your application, see the companion documents about <a
+in terms of its syntax and usage. For more information about how to implement search
+features for your application, see the developer guide about <a
href="index.html">Search</a>.</p>
<dl class="xml">
<dt>file location:</dt>
<dd><code>res/xml/<em>filename</em>.xml</code><br/>
-The filename will be used as the resource ID.</dd>
+Android uses the filename as the resource ID.</dd>
<dt>syntax:</dt>
<dd>
@@ -70,174 +70,187 @@
<p class="caps">attributes:</p>
<dl class="atn-list">
<dt><code>android:label</code></dt>
- <dd><em>String resource</em>. <strong>Required</strong>. This is the name of your application.
-It should normally be the same as the name applied to the {@code android:label} attribute of your <a
+ <dd><em>String resource</em>. (Required.) The name of your application.
+It should be the same as the name applied to the {@code android:label} attribute of your <a
href="{@docRoot}guide/topics/manifest/activity-element.html#label">{@code <activity>}</a> or
<a href="{@docRoot}guide/topics/manifest/application-element.html#label">{@code
-<application>}</a> manifest element. This is only visible to the user when you set
-<code>android:includeInGlobalSearch</code> "true", in which case, this label is used to identify
+<application>}</a> manifest element. This label is only visible to the user when you set
+<code>android:includeInGlobalSearch</code> to "true", in which case, this label is used to identify
your application as a searchable item in the system's search settings.</dd>
+
<dt><code>android:hint</code></dt>
- <dd><em>String resource</em>. The text to display in the search text field when no text has
- been entered. This is recommended in order to provide a hint to the user about what
-content is searchable. For consistency among other Android applications, you should format the
+ <dd><em>String resource</em>. (Recommended.) The text to display in the search text field when
+no text has been entered. It provides a hint to the user about what
+content is searchable. For consistency with other Android applications, you should format the
string for {@code android:hint} as "Search <em><content-or-product></em>". For example,
"Search songs and artists" or "Search YouTube".</dd>
+
<dt><code>android:searchMode</code></dt>
- <dd><em>Keyword</em>. Sets additional modes that control the search presentation.
-Specifically, the available modes define how the query text in the search dialog's text box
-should be rewritten when a suggestion is focused. The following mode values are accepted:
+ <dd><em>Keyword</em>. Sets additional modes that control the search dialog presentation.
+Currently available modes define how the query text that appears in the search dialog
+should be rewritten when a custom suggestion receives focus. The following mode values are accepted:
<table>
<tr><th>Value</th><th>Description</th></tr>
<tr>
- <td><code>"queryRewriteFromData"</code></td>
- <td>If set, this causes the suggestion column
- {@link android.app.SearchManager#SUGGEST_COLUMN_INTENT_DATA} to be considered as the
-text for suggestion query
- rewriting. This should only be used when the values in
- {@link android.app.SearchManager#SUGGEST_COLUMN_INTENT_DATA} are suitable for user
-inspection and editing -
- typically, HTTP/HTTPS Uri's.</td>
+ <td><code>"queryRewriteFromText"</code></td>
+ <td>Use the value from the {@link android.app.SearchManager#SUGGEST_COLUMN_TEXT_1}
+colum to rewrite the query text in the search dialog.</td>
</tr>
<tr>
- <td><code>"queryRewriteFromText"</code></td>
- <td>If set, this causes the suggestion
- column {@link android.app.SearchManager#SUGGEST_COLUMN_TEXT_1} to be considered as the
-text for suggestion query
- rewriting. This should be used for suggestions in which no query
- text is provided and the {@link android.app.SearchManager#SUGGEST_COLUMN_INTENT_DATA}
-values are not suitable
- for user inspection and editing.</td>
+ <td><code>"queryRewriteFromData"</code></td>
+ <td>Use the value from the
+ {@link android.app.SearchManager#SUGGEST_COLUMN_INTENT_DATA} column to rewrite the
+query text in the search dialog. This should only be used when the values in
+ {@link android.app.SearchManager#SUGGEST_COLUMN_INTENT_DATA} are suitable for user
+inspection and editing, typically HTTP URI's.</td>
</tr>
</table>
<p>For more information, see the discussion about rewriting the query text in <a
href="adding-custom-suggestions.html#RewritingQueryText">Adding Custom Suggestions</a>.</p>
</dd>
+
<dt><code>android:searchButtonText</code></dt>
- <dd><em>String resource</em>. The text to display in the button that executes the search. By
+ <dd><em>String resource</em>. The text to display in the button that executes search. By
default, the button shows a search icon (a magnifying glass), which is ideal for
-internationalization.</dd>
+internationalization, so you should not use this attribute to change the button unless the
+behavior is something other than a search (such as a URL request in a web browser).</dd>
+
<dt><code>android:inputType</code></dt>
- <dd><em>Keyword</em>. Defines the type of input method (soft-keyboard) to use with the search
-dialog. For most searches, in which free form text is expected, this attribute is not needed and
-the default input method should be used. See {@link android.R.attr#inputType} for a list of suitable
-values for this attribute.</dd>
+ <dd><em>Keyword</em>. Defines the type of input method (such as the type of soft keyboard)
+to use with the search dialog. For most searches, in which free-form text is expected, you don't
+need this attribute. See {@link android.R.attr#inputType} for a list of suitable values for this
+attribute.</dd>
+
<dt><code>android:imeOptions</code></dt>
<dd><em>Keyword</em>. Supplies additional options for the input method.
- For most searches, in which free form text is expected, this attribute is not needed,
- and will default to "actionSearch" (provides the "search" button instead of a carriage
-return). See {@link android.R.attr#imeOptions} for a list of suitable values for this attribute.
+ For most searches, in which free-form text is expected, you don't need this attribute. The
+default IME is "actionSearch" (provides the "search" button instead of a carriage
+return in the soft keyboard). See {@link android.R.attr#imeOptions} for a list of suitable values
+for this attribute.
</dd>
</dl>
+
+ <h4>Search suggestion attributes</h4>
+
<p>If you have defined a content provider to generate search suggestions, you need to
- define additional attributes in order to configure communications with the Content
- Provider. When providing search suggestions, you'll need some of the following
+ define additional attributes that configure communications with the content
+ provider. When providing search suggestions, you need some of the following
{@code <searchable>} attributes:</p><br/>
<dl class="atn-list">
<dt><code>android:searchSuggestAuthority</code></dt>
- <dd><em>String</em>. <strong>Required to provide search suggestions</strong>.
+ <dd><em>String</em>. (Required to provide search suggestions.)
This value must match the authority string provided in the {@code android:authorities}
-attribute of the {@code <provider>} element.</dd>
+attribute of the Android manifest {@code <provider>} element.</dd>
+
<dt><code>android:searchSuggestPath</code></dt>
- <dd><em>String</em>. This path will be used as a portion of the suggestions
+ <dd><em>String</em>. This path is used as a portion of the suggestions
query {@link android.net.Uri}, after the prefix and authority, but before
the standard suggestions path.
This is only required if you have a single content provider issuing different types
- of suggestions (e.g. for different data types) and you need
- a way to disambiguate the suggestions queries when they are received.</dd>
+ of suggestions (such as for different data types) and you need
+ a way to disambiguate the suggestions queries when you receive them.</dd>
+
<dt><code>android:searchSuggestSelection</code></dt>
- <dd><em>String</em>. This value will be passed into your
- query function as the {@code selection} parameter. Typically this will be a WHERE clause
-for your database, and should contain a single question mark, which is a place-holder for the
-actual query string that has been typed by the user. However, you can also use any non-null
-value to simply trigger the delivery of the query text via the {@code
+ <dd><em>String</em>. This value is passed into your
+ query function as the {@code selection} parameter. Typically this is a WHERE clause
+for your database, and should contain a single question mark, which is a placeholder for the
+actual query string that has been typed by the user (for example, {@code "query=?"}). However, you
+can also use any non-null value to trigger the delivery of the query text via the {@code
selectionArgs} parameter (and then ignore the {@code selection} parameter).</dd>
+
<dt><code>android:searchSuggestIntentAction</code></dt>
<dd><em>String</em>. The default Intent action to be used when a user
- clicks on a search suggestion (such as {@code "android.intent.action.VIEW"}).
- If not overridden by the selected suggestion (via the {@link
-android.app.SearchManager#SUGGEST_COLUMN_INTENT_ACTION} column), this value will
- be placed in the action field of the {@link android.content.Intent} when the
- user clicks a suggestion.</dd>
+ clicks on a custom search suggestion (such as {@code "android.intent.action.VIEW"}).
+ If this is not overridden by the selected suggestion (via the {@link
+android.app.SearchManager#SUGGEST_COLUMN_INTENT_ACTION} column), this value is placed in the action
+field of the {@link android.content.Intent} when the user clicks a suggestion.</dd>
+
<dt><code>android:searchSuggestIntentData</code></dt>
<dd><em>String</em>. The default Intent data to be used when a user
- clicks on a search suggestion.
+ clicks on a custom search suggestion.
If not overridden by the selected suggestion (via the {@link
-android.app.SearchManager#SUGGEST_COLUMN_INTENT_DATA} column), this value will be
+android.app.SearchManager#SUGGEST_COLUMN_INTENT_DATA} column), this value is
placed in the data field of the {@link android.content.Intent} when the user clicks
a suggestion.</dd>
+
<dt><code>android:searchSuggestThreshold</code></dt>
<dd><em>Integer</em>. The minimum number of characters needed to
- trigger a suggestion look-up. Only guarantees that a source will not be
- queried for anything shorter than the threshold. The default value is 0.</dd>
+ trigger a suggestion look-up. Only guarantees that the Search Manager will not query your
+ content provider for anything shorter than the threshold. The default value is 0.</dd>
</dl>
<p>For more information about the above attributes for search suggestions, see the guides for
<a href="adding-recent-query-suggestions.html">Adding Recent Query Suggestions</a> and
<a href="adding-custom-suggestions.html">Adding Custom Suggestions</a>.</p>
- <p>Beyond providing search suggestions while using your application's search dialog, you
- can also configure your search suggestions to be made available to Quick Search Box,
- which will allow users so receive search suggestions from your application content from outside
- your application. When providing search suggestions to Quick Search Box, you'll need some of the
+
+ <h4>Quick Search Box attributes</h4>
+
+ <p>To make your custom search suggestions available to Quick Search Box, you need some of the
following {@code <searchable>} attributes:</p><br/>
<dl class="atn-list">
<dt><code>android:includeInGlobalSearch</code></dt>
- <dd><em>Boolean</em>. <strong>Required to provide search suggestions in
- Quick Search Box</strong>. "true" if you want your suggestions to be
- included in the globally accessible Quick Search Box. Note that the user must
- still enable your application as a searchable item in the system search settings in order
- for your suggestions to appear in Quick Search Box.</dd>
+ <dd><em>Boolean</em>. (Required to provide search suggestions in
+ Quick Search Box.) Set to "true" if you want your suggestions to be
+ included in the globally accessible Quick Search Box. The user must
+ still enable your application as a searchable item in the system search settings before
+ your suggestions will appear in Quick Search Box.</dd>
+
<dt><code>android:searchSettingsDescription</code></dt>
<dd><em>String</em>. Provides a brief description of the search suggestions that you provide
-to Quick Search Box, which will be displayed in the searchable items entry for your application.
+to Quick Search Box, which is displayed in the searchable items entry for your application.
Your description should concisely describe the content that is searchable. For example, "Artists,
albums, and tracks" for a music application, or "Saved notes" for a notepad application.</dd>
+
<dt><code>android:queryAfterZeroResults</code></dt>
- <dd><em>Boolean</em>. "true" if you want your content provider to be invoked for
- supersets of queries that have returned zero results for in the past. For example, if a
- source returned zero results for "bo", it would be ignored for "bob". If "false",
- this source will only be ignored for a single session; the next time the search dialog
- is invoked, all sources will be queried. The default value is false.</dd>
+ <dd><em>Boolean</em>. Set to "true" if you want your content provider to be invoked for
+ supersets of queries that have returned zero results in the past. For example, if
+your content provider returned zero results for "bo", it should be requiried for "bob". If set to
+"false", supersets are ignored for a single session ("bob" does not invoke a requery). This lasts
+only for the life of the search dialog (when the search dialog is reopened, "bo" queries your
+content provider again). The default value is false.</dd>
</dl>
+
+ <h4>Voice search attributes</h4>
+
<p>To enable voice search for your search dialog, you'll need some of the
following {@code <searchable>} attributes:</p><br/>
<dl class="atn-list">
<dt><code>android:voiceSearchMode</code></dt>
- <dd><em>Keyword</em>. <strong>Required to provide voice search capabilities</strong>.
+ <dd><em>Keyword</em>. (Required to provide voice search capabilities.)
Enables voice search for the search dialog, with a specific mode for voice search.
- (Voice search may not be provided by the device, in which case these flags will
+ (Voice search may not be provided by the device, in which case these flags
have no effect.) The following mode values are accepted:
<table>
<tr><th>Value</th><th>Description</th></tr>
<tr>
<td><code>"showVoiceSearchButton"</code></td>
- <td>Display a voice search button. This only
- takes effect if voice search is available on the device. If set, then either
- {@code "launchWebSearch"} or {@code "launchRecognizer"} must also be set
+ <td>Display a voice search button, if voice search is available on the device. If set,
+then either {@code "launchWebSearch"} or {@code "launchRecognizer"} must also be set
(separated by the pipe | character).</td>
</tr>
<tr>
<td><code>"launchWebSearch"</code></td>
- <td>The voice search button will take the user directly
- to a built-in voice web search activity. Most applications will not use this flag, as
- it will take the user away from the Activity in which search was invoked.</td>
+ <td>The voice search button takes the user directly
+ to a built-in voice web search activity. Most applications don't need this flag, as
+ it takes the user away from the Activity in which search was invoked.</td>
</tr>
<tr>
<td><code>"launchRecognizer"</code></td>
- <td>The voice search button will take
+ <td>The voice search button takes
the user directly to a built-in voice recording activity. This Activity
- will prompt the user to speak, transcribe the spoken text, and forward the resulting
- query text to the searchable Activity, just as if the user had typed it into the
+ prompts the user to speak, transcribes the spoken text, and forwards the resulting
+ query text to the searchable Activity, just as if the user typed it into the
search UI and clicked the search button.</td>
</tr>
</table>
</dd>
+
<dt><code>android:voiceLanguageModel</code></dt>
<dd><em>Keyword</em>. The language model that
should be used by the voice recognition system. The following values are accepted:
@@ -245,92 +258,99 @@
<tr><th>Value</th><th>Description</th></tr>
<tr>
<td><code>"free_form"</code></td>
- <td>Use a language model based on free-form speech recognition. This is the
-default.</td>
+ <td>Use free-form speech recognition for dictating queries. This is primarily
+optimized for English. This is the default.</td>
</tr>
<tr>
<td><code>"web_search"</code></td>
- <td>Use a language model based on web search terms.</td>
+ <td>Use web-search-term recognition for shorter, search-like phrases. This is
+available in more languages than "free_form".</td>
</tr>
</table>
<p>Also see
{@link android.speech.RecognizerIntent#EXTRA_LANGUAGE_MODEL} for more
information.</p></dd>
+
<dt><code>android:voicePromptText</code></dt>
<dd><em>String</em>. An additional message to display in the voice input dialog.</dd>
+
<dt><code>android:voiceLanguage</code></dt>
<dd><em>String</em>. The spoken language to be expected, expressed as the string value of
-a constants in {@link java.util.Locale} (for example, {@code "de"} for German or {@code "fr"} for
-French). This is only needed if it is different from the current value of {@link
+a constants in {@link java.util.Locale} (such as {@code "de"} for German or {@code "fr"} for
+French). This is needed only if it is different from the current value of {@link
java.util.Locale#getDefault() Locale.getDefault()}.</dd>
+
<dt><code>android:voiceMaxResults</code></dt>
<dd><em>Integer</em>. Forces the maximum number of results to return,
- including the "best" result which will always be provided as the {@link
+ including the "best" result which is always provided as the {@link
android.content.Intent#ACTION_SEARCH} Intent's primary
query. Must be 1 or greater. Use {@link android.speech.RecognizerIntent#EXTRA_RESULTS} to
get the results from the Intent.
- If not provided, the recognizer will choose how many results to return.</dd>
+ If not provided, the recognizer chooses how many results to return.</dd>
</dl>
</dd> <!-- end searchable element -->
+
<dt id="actionkey-element"><code><actionkey></code></dt>
- <dd>Defines a shortcut key for a search action, in order to provide special behaviors at the touch
-of a button, based on the current query or focused suggestion. ​For example, the Contacts
-application enables the device call key for suggestions. So, when
-the user focuses on a search suggestion using the directional controls and then presses the call
-key, the application will immediately initiate a phone call to the suggested contact.
+ <dd>Defines a device key and behavior for a search action. A search action provides a
+special behavior at the touch of a button on the device, based on the current query or focused
+suggestion. For example, the Contacts application provides a search action to initiate a phone call
+to the currenly focused contact suggestion at the press of the CALL button.
<p>Not all action keys are available on every device, and not
all keys are allowed to be overriden in this way. For example, the "Home" key cannot be used and
must always return to the home screen. Also be sure not to define an action
key for a key that's needed for typing a search query. This essentially limits the
available and reasonable action keys to the call button and menu button. Also note that action
keys are not generally discoverable, so you should not provide them as a core user feature.</p>
+ <p>You must define the <code>android:keycode</code> to define the key and at least one of the
+other three attributes in order to define the search action.</p>
<p class="caps">attributes:</p>
<dl class="atn-list">
<dt><code>android:keycode</code></dt>
- <dd><em>String</em>. <strong>Required</strong>. A key code from {@link
+ <dd><em>String</em>. (Required.) A key code from {@link
android.view.KeyEvent} that represents the action key
- you wish to respond to (for example {@code "KEYCODE_CALL"}). This will be added to the
- {@link android.content.Intent#ACTION_SEARCH ACTION_SEARCH} Intent that is passed to your
- searchable Activity. To examine the key code, use
- {@link android.content.Intent#getIntExtra getIntExtra(SearchManager.ACTION_KEY)}.
- In addition to the key code, you must also provide one or more of
- the action specifier attributes below. Not all action keys
-are actually supported using this mechanism, as many of them are used for typing,
- navigation, or system functions. Note that although each of the action message elements are
-optional, at least one must be present for the action key to have any effect.</dd>
+ you wish to respond to (for example {@code "KEYCODE_CALL"}). This is added to the
+ {@link android.content.Intent#ACTION_SEARCH ACTION_SEARCH} Intent that is passed to your
+ searchable Activity. To examine the key code, use
+ {@link android.content.Intent#getIntExtra getIntExtra(SearchManager.ACTION_KEY)}. Not all
+keys are supported for a search action, as many of them are used for typing, navigation, or system
+functions.</dd>
+
<dt><code>android:queryActionMsg</code></dt>
<dd><em>String</em>. An action message to be sent if the action key is pressed while the
-user is simply entering query text. This will be added to the
- {@link android.content.Intent#ACTION_SEARCH ACTION_SEARCH} Intent that is
- passed to your searchable Activity. To examine the string, use
+user is entering query text. This is added to the
+ {@link android.content.Intent#ACTION_SEARCH ACTION_SEARCH} Intent that the Search Manager
+ passes to your searchable Activity. To examine the string, use
{@link android.content.Intent#getStringExtra
getStringExtra(SearchManager.ACTION_MSG)}.</dd>
+
<dt><code>android:suggestActionMsg</code></dt>
<dd><em>String</em>. An action message to be sent if the action key is pressed while a
- suggestion is focused. This will be added to the
- Intent that is passed to your searchable Activity (using the action you've defined for
- the suggestion). To examine the string,
+ suggestion is in focus. This is added to the
+ Intent that that the Search Manager passes to your searchable Activity (using the action
+you've defined for the suggestion). To examine the string,
use {@link android.content.Intent#getStringExtra
- getStringExtra(SearchManager.ACTION_MSG)}. Note that this should only be used if all your
+ getStringExtra(SearchManager.ACTION_MSG)}. This should only be used if all your
suggestions support this action key. If not all suggestions can handle the same action key, then
you must instead use the following {@code android:suggestActionMsgColumn} attribute.</dd>
+
<dt><code>android:suggestActionMsgColumn</code></dt>
<dd><em>String</em>. The name of the column in your content provider that defines the
-action message for this action key, which is to be sent if the action key is pressed while a
- suggestion is focused. This attribute lets you control the
+action message for this action key, which is to be sent if the user presses the action key while a
+ suggestion is in focus. This attribute lets you control the
action key on a suggestion-by-suggestion basis, because, instead of using the {@code
android:suggestActionMsg} attribute to define the action message for all suggestions, each entry in
-your content provider provides its own action message. First, you must define a column in your
+your content provider provides its own action message.
+ <p>First, you must define a column in your
content provider for each suggestion to provide an action message, then provide the name of that
-column in this attribute. The search manager will look at your suggestion cursor,
- using the string provided here in order to select your action message column, and
- then select the action message string from the cursor. That string will be added to the
- Intent that is passed to your searchable Activity (using the action you've defined for
- suggestions). To examine the string, use {@link
+column in this attribute. The Search Manager looks at your suggestion cursor,
+ using the string provided here to select your action message column, and
+ then select the action message string from the Cursor. That string is added to the
+ Intent that the Search Manager passes to your searchable Activity (using the action you've
+defined for suggestions). To examine the string, use {@link
android.content.Intent#getStringExtra getStringExtra(SearchManager.ACTION_MSG)}. If the data
-does not exist for the selected suggestion, the action key will be ignored.</dd>
+does not exist for the selected suggestion, the action key is ignored.</dd>
</dl>
</dd><!-- end action key -->
</dl>
diff --git a/docs/html/images/developing/avd-dialog.png b/docs/html/images/developing/avd-dialog.png
new file mode 100755
index 0000000..693aa42
--- /dev/null
+++ b/docs/html/images/developing/avd-dialog.png
Binary files differ
diff --git a/docs/html/resources/dashboard/platform-versions.jd b/docs/html/resources/dashboard/platform-versions.jd
index 6cb7228..d4b6db5 100644
--- a/docs/html/resources/dashboard/platform-versions.jd
+++ b/docs/html/resources/dashboard/platform-versions.jd
@@ -52,7 +52,7 @@
<div class="dashboard-panel">
<img alt="" height="250" width="460"
-src="http://chart.apis.google.com/chart?&cht=p&chs=460x250&chd=t:0.3,21.3,23.5,53.1,1.8&chl=Other*|
+src="http://chart.apis.google.com/chart?&cht=p&chs=460x250&chd=t:0.3,18.9,22.1,55.5,3.3&chl=Other*|
Android%201.5|Android%201.6|Android%202.1|Android%202.2&chco=c4df9b,6fad0c" />
<table>
@@ -61,13 +61,13 @@
<th>API Level</th>
<th>Distribution</th>
</tr>
-<tr><td>Android 1.5</td><td>3</td><td>21.3%</td></tr>
-<tr><td>Android 1.6</td><td>4</td><td>23.5%</td></tr>
-<tr><td>Android 2.1</td><td>7</td><td>53.1%</td></tr>
-<tr><td>Android 2.2</td><td>8</td><td>1.8%</td></tr>
+<tr><td>Android 1.5</td><td>3</td><td>18.9%</td></tr>
+<tr><td>Android 1.6</td><td>4</td><td>22.1%</td></tr>
+<tr><td>Android 2.1</td><td>7</td><td>55.5%</td></tr>
+<tr><td>Android 2.2</td><td>8</td><td>3.3%</td></tr>
</table>
-<p><em>Data collected during two weeks ending on July 1, 2010</em></p>
+<p><em>Data collected during two weeks ending on July 15, 2010</em></p>
<p style="font-size:.9em">* <em>Other: 0.3% of devices running obsolete versions</em></p>
</div><!-- end dashboard-panel -->
diff --git a/docs/html/resources/dashboard/screens.jd b/docs/html/resources/dashboard/screens.jd
index 89fdd2d..b20b17d 100644
--- a/docs/html/resources/dashboard/screens.jd
+++ b/docs/html/resources/dashboard/screens.jd
@@ -49,7 +49,7 @@
<div class="dashboard-panel">
<img alt="" width="460" height="250"
-src="http://chart.apis.google.com/chart?&cht=p&chs=460x250&chd=t:1.4,54.5,44.1&chl=Small%20/%20ldpi|
+src="http://chart.apis.google.com/chart?&cht=p&chs=460x250&chd=t:1.8,51.5,46.6&chl=Small%20/%20ldpi|
Normal%20/%20mdpi|Normal%20/%20hdpi&chco=c4df9b,6fad0c" />
<table>
@@ -60,22 +60,22 @@
<th scope="col">High Density</th>
</tr>
<tr><th scope="row">Small</th>
-<td class='cent hi'>1.4%</td>
+<td class='cent hi'>1.8%</td>
<td></td>
<td></td>
</tr>
<tr><th scope="row">Normal</th>
<td></td>
-<td class='cent hi'>54.5%</td>
-<td class='cent hi'>44.1%</td>
+<td class='cent hi'>51.5%</td>
+<td class='cent hi'>46.6%</td>
</tr>
<tr><th scope="row">Large</th>
<td></td>
<td></td>
<td></td>
-</tr>
+</tr>
</table>
-<p><em>Data collected during two weeks ending on July 1, 2010</em></p>
+<p><em>Data collected during two weeks ending on July 15, 2010</em></p>
</div>
diff --git a/docs/html/resources/tutorials/notepad/codelab/NotepadCodeLab.zip b/docs/html/resources/tutorials/notepad/codelab/NotepadCodeLab.zip
index 502a326..cd30f29 100644
--- a/docs/html/resources/tutorials/notepad/codelab/NotepadCodeLab.zip
+++ b/docs/html/resources/tutorials/notepad/codelab/NotepadCodeLab.zip
Binary files differ
diff --git a/docs/html/resources/tutorials/notepad/notepad-ex2.jd b/docs/html/resources/tutorials/notepad/notepad-ex2.jd
index a945a62..289b5fe 100644
--- a/docs/html/resources/tutorials/notepad/notepad-ex2.jd
+++ b/docs/html/resources/tutorials/notepad/notepad-ex2.jd
@@ -393,7 +393,11 @@
<pre>setContentView(R.layout.note_edit);</pre>
</li>
<li>
- Find the edit and button components we need:
+ Change the Activity title to the "Edit Note" string:
+ <pre>setTitle(R.string.edit_note);</pre>
+ </li>
+ <li>
+ Find the {@link android.widget.EditText} and {@link android.widget.Button} components we need:
<p>These are found by the
IDs associated to them in the R class, and need to be cast to the right
type of <code>View</code> (<code>EditText</code> for the two text views,
diff --git a/include/android_runtime/android_app_NativeActivity.h b/include/android_runtime/android_app_NativeActivity.h
index d7a9a2c..c388ba8 100644
--- a/include/android_runtime/android_app_NativeActivity.h
+++ b/include/android_runtime/android_app_NativeActivity.h
@@ -42,8 +42,26 @@
/*
* NDK input queue API.
+ *
+ * Here is the event flow:
+ * 1. Event arrives in input consumer, and is returned by getEvent().
+ * 2. Application calls preDispatchEvent():
+ * a. Event is assigned a sequence ID and enqueued in mPreDispatchingKeys.
+ * b. Main thread picks up event, hands to input method.
+ * c. Input method eventually returns sequence # and whether it was handled.
+ * d. finishPreDispatch() is called to enqueue the information.
+ * e. next getEvent() call will:
+ * - finish any pre-dispatch events that the input method handled
+ * - return the next pre-dispatched event that the input method didn't handle.
+ * f. (A preDispatchEvent() call on this event will now return false).
+ * 3. Application calls finishEvent() with whether it was handled.
+ * - If handled is true, the event is finished.
+ * - If handled is false, the event is put on mUnhandledKeys, and:
+ * a. Main thread receives event from consumeUnhandledEvent().
+ * b. Java sends event through default key handler.
+ * c. event is finished.
*/
-struct AInputQueue {
+struct AInputQueue : public android::InputEventFactoryInterface {
public:
/* Creates a consumer associated with an input channel. */
explicit AInputQueue(const android::sp<android::InputChannel>& channel, int workWrite);
@@ -59,8 +77,9 @@
int32_t getEvent(AInputEvent** outEvent);
- void finishEvent(AInputEvent* event, bool handled);
+ bool preDispatchEvent(AInputEvent* event);
+ void finishEvent(AInputEvent* event, bool handled);
// ----------------------------------------------------------
@@ -68,28 +87,63 @@
void dispatchEvent(android::KeyEvent* event);
+ void finishPreDispatch(int seq, bool handled);
+
android::KeyEvent* consumeUnhandledEvent();
+ android::KeyEvent* consumePreDispatchingEvent(int* outSeq);
+
+ virtual android::KeyEvent* createKeyEvent();
+ virtual android::MotionEvent* createMotionEvent();
int mWorkWrite;
private:
- void doDefaultKey(android::KeyEvent* keyEvent);
+ void doUnhandledKey(android::KeyEvent* keyEvent);
+ bool preDispatchKey(android::KeyEvent* keyEvent);
+ void wakeupDispatch();
android::InputConsumer mConsumer;
- android::PreallocatedInputEventFactory mInputEventFactory;
android::sp<android::PollLoop> mPollLoop;
int mDispatchKeyRead;
int mDispatchKeyWrite;
- // This is only touched by the event reader thread. It is the current
- // key events that came out of the mDispatchingKeys list and are now
- //Êdelivered to the app.
- android::Vector<android::KeyEvent*> mDeliveringKeys;
+ struct in_flight_event {
+ android::InputEvent* event;
+ int seq;
+ bool doFinish;
+ };
+
+ struct finish_pre_dispatch {
+ int seq;
+ bool handled;
+ };
android::Mutex mLock;
- android::Vector<android::KeyEvent*> mPendingKeys;
+
+ int mSeq;
+
+ // Cache of previously allocated key events.
+ android::Vector<android::KeyEvent*> mAvailKeyEvents;
+ // Cache of previously allocated motion events.
+ android::Vector<android::MotionEvent*> mAvailMotionEvents;
+
+ // All input events that are actively being processed.
+ android::Vector<in_flight_event> mInFlightEvents;
+
+ // Key events that the app didn't handle, and are pending for
+ // delivery to the activity's default key handling.
+ android::Vector<android::KeyEvent*> mUnhandledKeys;
+
+ // Keys that arrived in the Java framework and need to be
+ // dispatched to the app.
android::Vector<android::KeyEvent*> mDispatchingKeys;
+
+ // Key events that are pending to be pre-dispatched to the IME.
+ android::Vector<in_flight_event> mPreDispatchingKeys;
+
+ // Event sequence numbers that we have finished pre-dispatching.
+ android::Vector<finish_pre_dispatch> mFinishPreDispatches;
};
#endif // _ANDROID_APP_NATIVEACTIVITY_H
diff --git a/include/binder/Parcel.h b/include/binder/Parcel.h
index 3aba5f6..fd0fc1f 100644
--- a/include/binder/Parcel.h
+++ b/include/binder/Parcel.h
@@ -58,9 +58,13 @@
// Writes the RPC header.
status_t writeInterfaceToken(const String16& interface);
+
// Parses the RPC header, returning true if the interface name
// in the header matches the expected interface from the caller.
- bool enforceInterface(const String16& interface) const;
+ // If strict_policy_out is non-NULL, the RPC header's StrictMode policy
+ // mask is returned.
+ bool enforceInterface(const String16& interface,
+ int32_t* strict_policy_out = NULL) const;
bool checkInterface(IBinder*) const;
void freeData();
diff --git a/include/media/AudioSystem.h b/include/media/AudioSystem.h
index 194f23a..9fd905f 100644
--- a/include/media/AudioSystem.h
+++ b/include/media/AudioSystem.h
@@ -168,6 +168,15 @@
TX_DISABLE = 0
};
+ // special audio session values
+ enum audio_sessions {
+ SESSION_OUTPUT_STAGE = -1, // session for effects attached to a particular output stream
+ // (value must be less than 0)
+ SESSION_OUTPUT_MIX = 0, // session for effects applied to output mix. These effects can
+ // be moved by audio policy manager to another output stream
+ // (value must be 0)
+ };
+
/* These are static methods to control the system-wide AudioFlinger
* only privileged processes can have access to them
*/
@@ -353,8 +362,12 @@
uint32_t format = FORMAT_DEFAULT,
uint32_t channels = CHANNEL_OUT_STEREO,
output_flags flags = OUTPUT_FLAG_INDIRECT);
- static status_t startOutput(audio_io_handle_t output, AudioSystem::stream_type stream);
- static status_t stopOutput(audio_io_handle_t output, AudioSystem::stream_type stream);
+ static status_t startOutput(audio_io_handle_t output,
+ AudioSystem::stream_type stream,
+ int session = 0);
+ static status_t stopOutput(audio_io_handle_t output,
+ AudioSystem::stream_type stream,
+ int session = 0);
static void releaseOutput(audio_io_handle_t output);
static audio_io_handle_t getInput(int inputSource,
uint32_t samplingRate = 0,
@@ -370,6 +383,16 @@
static status_t setStreamVolumeIndex(stream_type stream, int index);
static status_t getStreamVolumeIndex(stream_type stream, int *index);
+ static uint32_t getStrategyForStream(stream_type stream);
+
+ static audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc);
+ static status_t registerEffect(effect_descriptor_t *desc,
+ audio_io_handle_t output,
+ uint32_t strategy,
+ int session,
+ int id);
+ static status_t unregisterEffect(int id);
+
static const sp<IAudioPolicyService>& get_audio_policy_service();
// ----------------------------------------------------------------------------
diff --git a/include/media/EffectApi.h b/include/media/EffectApi.h
index 9f3d0b6..8c120e5 100644
--- a/include/media/EffectApi.h
+++ b/include/media/EffectApi.h
@@ -455,7 +455,7 @@
//--------------------------------------------------------------------------------------------------
// description:
// Set and get volume. Used by audio framework to delegate volume control to effect engine.
-// The effect implementation must set EFFECT_FLAG_VOLUME_IND and/or EFFECT_FLAG_VOLUME_CTRL flag in
+// The effect implementation must set EFFECT_FLAG_VOLUME_IND or EFFECT_FLAG_VOLUME_CTRL flag in
// its descriptor to receive this command before every call to process() function
// If EFFECT_FLAG_VOLUME_CTRL flag is set in the effect descriptor, the effect engine must return
// the volume that should be applied before the effect is processed. The overall volume (the volume
diff --git a/include/media/IAudioFlinger.h b/include/media/IAudioFlinger.h
index 5814fd6..70e505e 100644
--- a/include/media/IAudioFlinger.h
+++ b/include/media/IAudioFlinger.h
@@ -161,6 +161,8 @@
status_t *status,
int *id,
int *enabled) = 0;
+
+ virtual status_t moveEffects(int session, int srcOutput, int dstOutput) = 0;
};
diff --git a/include/media/IAudioPolicyService.h b/include/media/IAudioPolicyService.h
index 4804bbd..49eee59 100644
--- a/include/media/IAudioPolicyService.h
+++ b/include/media/IAudioPolicyService.h
@@ -53,8 +53,12 @@
uint32_t format = AudioSystem::FORMAT_DEFAULT,
uint32_t channels = 0,
AudioSystem::output_flags flags = AudioSystem::OUTPUT_FLAG_INDIRECT) = 0;
- virtual status_t startOutput(audio_io_handle_t output, AudioSystem::stream_type stream) = 0;
- virtual status_t stopOutput(audio_io_handle_t output, AudioSystem::stream_type stream) = 0;
+ virtual status_t startOutput(audio_io_handle_t output,
+ AudioSystem::stream_type stream,
+ int session = 0) = 0;
+ virtual status_t stopOutput(audio_io_handle_t output,
+ AudioSystem::stream_type stream,
+ int session = 0) = 0;
virtual void releaseOutput(audio_io_handle_t output) = 0;
virtual audio_io_handle_t getInput(int inputSource,
uint32_t samplingRate = 0,
@@ -69,6 +73,14 @@
int indexMax) = 0;
virtual status_t setStreamVolumeIndex(AudioSystem::stream_type stream, int index) = 0;
virtual status_t getStreamVolumeIndex(AudioSystem::stream_type stream, int *index) = 0;
+ virtual uint32_t getStrategyForStream(AudioSystem::stream_type stream) = 0;
+ virtual audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc) = 0;
+ virtual status_t registerEffect(effect_descriptor_t *desc,
+ audio_io_handle_t output,
+ uint32_t strategy,
+ int session,
+ int id) = 0;
+ virtual status_t unregisterEffect(int id) = 0;
};
diff --git a/include/media/stagefright/AudioPlayer.h b/include/media/stagefright/AudioPlayer.h
index 9af5871..9a09586 100644
--- a/include/media/stagefright/AudioPlayer.h
+++ b/include/media/stagefright/AudioPlayer.h
@@ -86,6 +86,10 @@
bool mStarted;
+ bool mIsFirstBuffer;
+ status_t mFirstBufferResult;
+ MediaBuffer *mFirstBuffer;
+
sp<MediaPlayerBase::AudioSink> mAudioSink;
static void AudioCallback(int event, void *user, void *info);
diff --git a/include/surfaceflinger/Surface.h b/include/surfaceflinger/Surface.h
index 4fd0681..294c867 100644
--- a/include/surfaceflinger/Surface.h
+++ b/include/surfaceflinger/Surface.h
@@ -20,6 +20,7 @@
#include <stdint.h>
#include <sys/types.h>
+#include <utils/KeyedVector.h>
#include <utils/RefBase.h>
#include <utils/threads.h>
@@ -147,8 +148,7 @@
static status_t writeToParcel(
const sp<Surface>& control, Parcel* parcel);
- static sp<Surface> readFromParcel(
- const Parcel& data, const sp<Surface>& other);
+ static sp<Surface> readFromParcel(const Parcel& data);
static bool isValid(const sp<Surface>& surface) {
return (surface != 0) && surface->isValid();
@@ -244,6 +244,8 @@
uint32_t *pWidth, uint32_t *pHeight,
uint32_t *pFormat, uint32_t *pUsage) const;
+ static void cleanCachedSurfaces();
+
class BufferInfo {
uint32_t mWidth;
uint32_t mHeight;
@@ -298,6 +300,10 @@
// Inherently thread-safe
mutable Mutex mSurfaceLock;
mutable Mutex mApiLock;
+
+ // A cache of Surface objects that have been deserialized into this process.
+ static Mutex sCachedSurfacesLock;
+ static DefaultKeyedVector<wp<IBinder>, wp<Surface> > sCachedSurfaces;
};
}; // namespace android
diff --git a/include/ui/EventHub.h b/include/ui/EventHub.h
index d322a34..5be17d3 100644
--- a/include/ui/EventHub.h
+++ b/include/ui/EventHub.h
@@ -60,6 +60,32 @@
class KeyLayoutMap;
/*
+ * Input device classes.
+ */
+enum {
+ /* The input device is a keyboard. */
+ INPUT_DEVICE_CLASS_KEYBOARD = 0x00000001,
+
+ /* The input device is an alpha-numeric keyboard (not just a dial pad). */
+ INPUT_DEVICE_CLASS_ALPHAKEY = 0x00000002,
+
+ /* The input device is a touchscreen (either single-touch or multi-touch). */
+ INPUT_DEVICE_CLASS_TOUCHSCREEN = 0x00000004,
+
+ /* The input device is a trackball. */
+ INPUT_DEVICE_CLASS_TRACKBALL = 0x00000008,
+
+ /* The input device is a multi-touch touchscreen. */
+ INPUT_DEVICE_CLASS_TOUCHSCREEN_MT= 0x00000010,
+
+ /* The input device is a directional pad. */
+ INPUT_DEVICE_CLASS_DPAD = 0x00000020,
+
+ /* The input device is a gamepad (implies keyboard). */
+ INPUT_DEVICE_CLASS_GAMEPAD = 0x00000040
+};
+
+/*
* Grand Central Station for events.
*
* The event hub aggregates input events received across all known input
diff --git a/include/ui/Input.h b/include/ui/Input.h
index a7d23d4..d9b1091 100644
--- a/include/ui/Input.h
+++ b/include/ui/Input.h
@@ -32,7 +32,7 @@
/*
* Private control to determine when an app is tracking a key sequence.
*/
- KEY_EVENT_FLAG_START_TRACKING = 0x40000000
+ AKEY_EVENT_FLAG_START_TRACKING = 0x40000000
};
/*
@@ -130,6 +130,11 @@
float y;
float pressure;
float size;
+ float touchMajor;
+ float touchMinor;
+ float toolMajor;
+ float toolMinor;
+ float orientation;
};
/*
@@ -143,14 +148,15 @@
inline int32_t getDeviceId() const { return mDeviceId; }
- inline int32_t getNature() const { return mNature; }
+ inline int32_t getSource() const { return mSource; }
protected:
- void initialize(int32_t deviceId, int32_t nature);
+ void initialize(int32_t deviceId, int32_t source);
+ void initialize(const InputEvent& from);
private:
int32_t mDeviceId;
- int32_t mNature;
+ int32_t mSource;
};
/*
@@ -160,7 +166,7 @@
public:
virtual ~KeyEvent() { }
- virtual int32_t getType() const { return INPUT_EVENT_TYPE_KEY; }
+ virtual int32_t getType() const { return AINPUT_EVENT_TYPE_KEY; }
inline int32_t getAction() const { return mAction; }
@@ -188,7 +194,7 @@
void initialize(
int32_t deviceId,
- int32_t nature,
+ int32_t source,
int32_t action,
int32_t flags,
int32_t keyCode,
@@ -197,6 +203,7 @@
int32_t repeatCount,
nsecs_t downTime,
nsecs_t eventTime);
+ void initialize(const KeyEvent& from);
private:
int32_t mAction;
@@ -216,7 +223,7 @@
public:
virtual ~MotionEvent() { }
- virtual int32_t getType() const { return INPUT_EVENT_TYPE_MOTION; }
+ virtual int32_t getType() const { return AINPUT_EVENT_TYPE_MOTION; }
inline int32_t getAction() const { return mAction; }
@@ -264,6 +271,26 @@
return getCurrentPointerCoords(pointerIndex).size;
}
+ inline float getTouchMajor(size_t pointerIndex) const {
+ return getCurrentPointerCoords(pointerIndex).touchMajor;
+ }
+
+ inline float getTouchMinor(size_t pointerIndex) const {
+ return getCurrentPointerCoords(pointerIndex).touchMinor;
+ }
+
+ inline float getToolMajor(size_t pointerIndex) const {
+ return getCurrentPointerCoords(pointerIndex).toolMajor;
+ }
+
+ inline float getToolMinor(size_t pointerIndex) const {
+ return getCurrentPointerCoords(pointerIndex).toolMinor;
+ }
+
+ inline float getOrientation(size_t pointerIndex) const {
+ return getCurrentPointerCoords(pointerIndex).orientation;
+ }
+
inline size_t getHistorySize() const { return mSampleEventTimes.size() - 1; }
inline nsecs_t getHistoricalEventTime(size_t historicalIndex) const {
@@ -294,9 +321,29 @@
return getHistoricalPointerCoords(pointerIndex, historicalIndex).size;
}
+ inline float getHistoricalTouchMajor(size_t pointerIndex, size_t historicalIndex) const {
+ return getHistoricalPointerCoords(pointerIndex, historicalIndex).touchMajor;
+ }
+
+ inline float getHistoricalTouchMinor(size_t pointerIndex, size_t historicalIndex) const {
+ return getHistoricalPointerCoords(pointerIndex, historicalIndex).touchMinor;
+ }
+
+ inline float getHistoricalToolMajor(size_t pointerIndex, size_t historicalIndex) const {
+ return getHistoricalPointerCoords(pointerIndex, historicalIndex).toolMajor;
+ }
+
+ inline float getHistoricalToolMinor(size_t pointerIndex, size_t historicalIndex) const {
+ return getHistoricalPointerCoords(pointerIndex, historicalIndex).toolMinor;
+ }
+
+ inline float getHistoricalOrientation(size_t pointerIndex, size_t historicalIndex) const {
+ return getHistoricalPointerCoords(pointerIndex, historicalIndex).orientation;
+ }
+
void initialize(
int32_t deviceId,
- int32_t nature,
+ int32_t source,
int32_t action,
int32_t edgeFlags,
int32_t metaState,
diff --git a/include/ui/InputDevice.h b/include/ui/InputDevice.h
index 4420600..3b9c70e 100644
--- a/include/ui/InputDevice.h
+++ b/include/ui/InputDevice.h
@@ -42,6 +42,7 @@
extern int32_t updateMetaState(int32_t keyCode, bool down, int32_t oldMetaState);
extern int32_t rotateKeyCode(int32_t keyCode, int32_t orientation);
+
/*
* An input device structure tracks the state of a single input device.
*
@@ -168,8 +169,11 @@
FIELD_ABS_MT_POSITION_X = 1,
FIELD_ABS_MT_POSITION_Y = 2,
FIELD_ABS_MT_TOUCH_MAJOR = 4,
- FIELD_ABS_MT_WIDTH_MAJOR = 8,
- FIELD_ABS_MT_TRACKING_ID = 16
+ FIELD_ABS_MT_TOUCH_MINOR = 8,
+ FIELD_ABS_MT_WIDTH_MAJOR = 16,
+ FIELD_ABS_MT_WIDTH_MINOR = 32,
+ FIELD_ABS_MT_ORIENTATION = 64,
+ FIELD_ABS_MT_TRACKING_ID = 128
};
uint32_t pointerCount;
@@ -179,7 +183,10 @@
int32_t absMTPositionX;
int32_t absMTPositionY;
int32_t absMTTouchMajor;
+ int32_t absMTTouchMinor;
int32_t absMTWidthMajor;
+ int32_t absMTWidthMinor;
+ int32_t absMTOrientation;
int32_t absMTTrackingId;
inline void clear() {
@@ -206,6 +213,11 @@
int32_t y;
int32_t pressure;
int32_t size;
+ int32_t touchMajor;
+ int32_t touchMinor;
+ int32_t toolMajor;
+ int32_t toolMinor;
+ int32_t orientation;
};
struct TouchData {
@@ -236,6 +248,7 @@
AbsoluteAxisInfo yAxis;
AbsoluteAxisInfo pressureAxis;
AbsoluteAxisInfo sizeAxis;
+ AbsoluteAxisInfo orientationAxis;
} parameters;
// The touch data of the current sample being processed.
@@ -290,6 +303,8 @@
int32_t sizeOrigin;
float sizeScale;
+
+ float orientationScale;
} precalculated;
void reset();
diff --git a/include/ui/InputDispatcher.h b/include/ui/InputDispatcher.h
index eb8f820..674852a 100644
--- a/include/ui/InputDispatcher.h
+++ b/include/ui/InputDispatcher.h
@@ -167,10 +167,10 @@
*/
virtual void notifyConfigurationChanged(nsecs_t eventTime) = 0;
virtual void notifyAppSwitchComing(nsecs_t eventTime) = 0;
- virtual void notifyKey(nsecs_t eventTime, int32_t deviceId, int32_t nature,
+ virtual void notifyKey(nsecs_t eventTime, int32_t deviceId, int32_t source,
uint32_t policyFlags, int32_t action, int32_t flags, int32_t keyCode,
int32_t scanCode, int32_t metaState, nsecs_t downTime) = 0;
- virtual void notifyMotion(nsecs_t eventTime, int32_t deviceId, int32_t nature,
+ virtual void notifyMotion(nsecs_t eventTime, int32_t deviceId, int32_t source,
uint32_t policyFlags, int32_t action, int32_t metaState, int32_t edgeFlags,
uint32_t pointerCount, const int32_t* pointerIds, const PointerCoords* pointerCoords,
float xPrecision, float yPrecision, nsecs_t downTime) = 0;
@@ -232,10 +232,10 @@
virtual void notifyConfigurationChanged(nsecs_t eventTime);
virtual void notifyAppSwitchComing(nsecs_t eventTime);
- virtual void notifyKey(nsecs_t eventTime, int32_t deviceId, int32_t nature,
+ virtual void notifyKey(nsecs_t eventTime, int32_t deviceId, int32_t source,
uint32_t policyFlags, int32_t action, int32_t flags, int32_t keyCode,
int32_t scanCode, int32_t metaState, nsecs_t downTime);
- virtual void notifyMotion(nsecs_t eventTime, int32_t deviceId, int32_t nature,
+ virtual void notifyMotion(nsecs_t eventTime, int32_t deviceId, int32_t source,
uint32_t policyFlags, int32_t action, int32_t metaState, int32_t edgeFlags,
uint32_t pointerCount, const int32_t* pointerIds, const PointerCoords* pointerCoords,
float xPrecision, float yPrecision, nsecs_t downTime);
@@ -281,7 +281,7 @@
struct KeyEntry : EventEntry {
int32_t deviceId;
- int32_t nature;
+ int32_t source;
uint32_t policyFlags;
int32_t action;
int32_t flags;
@@ -301,7 +301,7 @@
struct MotionEntry : EventEntry {
int32_t deviceId;
- int32_t nature;
+ int32_t source;
uint32_t policyFlags;
int32_t action;
int32_t metaState;
@@ -424,11 +424,11 @@
ConfigurationChangedEntry* obtainConfigurationChangedEntry(nsecs_t eventTime);
KeyEntry* obtainKeyEntry(nsecs_t eventTime,
- int32_t deviceId, int32_t nature, uint32_t policyFlags, int32_t action,
+ int32_t deviceId, int32_t source, uint32_t policyFlags, int32_t action,
int32_t flags, int32_t keyCode, int32_t scanCode, int32_t metaState,
int32_t repeatCount, nsecs_t downTime);
MotionEntry* obtainMotionEntry(nsecs_t eventTime,
- int32_t deviceId, int32_t nature, uint32_t policyFlags, int32_t action,
+ int32_t deviceId, int32_t source, uint32_t policyFlags, int32_t action,
int32_t metaState, int32_t edgeFlags, float xPrecision, float yPrecision,
nsecs_t downTime, uint32_t pointerCount,
const int32_t* pointerIds, const PointerCoords* pointerCoords);
diff --git a/include/ui/InputReader.h b/include/ui/InputReader.h
index 85a0084..14bea65 100644
--- a/include/ui/InputReader.h
+++ b/include/ui/InputReader.h
@@ -286,7 +286,8 @@
int32_t keyEventAction, int32_t keyEventFlags);
void dispatchTouches(nsecs_t when, InputDevice* device, uint32_t policyFlags);
void dispatchTouch(nsecs_t when, InputDevice* device, uint32_t policyFlags,
- InputDevice::TouchData* touch, BitSet32 idBits, int32_t motionEventAction);
+ InputDevice::TouchData* touch, BitSet32 idBits, uint32_t changedId,
+ int32_t motionEventAction);
// display
void resetDisplayProperties();
diff --git a/include/ui/InputTransport.h b/include/ui/InputTransport.h
index 226d1d5..31ec701 100644
--- a/include/ui/InputTransport.h
+++ b/include/ui/InputTransport.h
@@ -119,7 +119,7 @@
};
int32_t deviceId;
- int32_t nature;
+ int32_t source;
union {
struct {
@@ -198,7 +198,7 @@
*/
status_t publishKeyEvent(
int32_t deviceId,
- int32_t nature,
+ int32_t source,
int32_t action,
int32_t flags,
int32_t keyCode,
@@ -216,7 +216,7 @@
*/
status_t publishMotionEvent(
int32_t deviceId,
- int32_t nature,
+ int32_t source,
int32_t action,
int32_t edgeFlags,
int32_t metaState,
@@ -233,7 +233,7 @@
/* Appends a motion sample to a motion event unless already consumed.
*
* Returns OK on success.
- * Returns INVALID_OPERATION if the current event is not a MOTION_EVENT_ACTION_MOVE event.
+ * Returns INVALID_OPERATION if the current event is not a AMOTION_EVENT_ACTION_MOVE event.
* Returns FAILED_TRANSACTION if the current event has already been consumed.
* Returns NO_MEMORY if the buffer is full and no additional samples can be added.
*/
@@ -272,7 +272,7 @@
status_t publishInputEvent(
int32_t type,
int32_t deviceId,
- int32_t nature);
+ int32_t source);
};
/*
diff --git a/include/utils/AssetManager.h b/include/utils/AssetManager.h
index d8994e0..97694ff 100644
--- a/include/utils/AssetManager.h
+++ b/include/utils/AssetManager.h
@@ -29,6 +29,24 @@
#include <utils/ZipFileRO.h>
#include <utils/threads.h>
+/*
+ * Native-app access is via the opaque typedef struct AAssetManager in the C namespace.
+ */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct AAssetManager { };
+
+#ifdef __cplusplus
+};
+#endif
+
+
+/*
+ * Now the proper C++ android-namespace definitions
+ */
+
namespace android {
class Asset; // fwd decl for things that include Asset.h first
@@ -48,7 +66,7 @@
* The asset hierarchy may be examined like a filesystem, using
* AssetDir objects to peruse a single directory.
*/
-class AssetManager {
+class AssetManager : public AAssetManager {
public:
typedef enum CacheMode {
CACHE_UNKNOWN = 0,
diff --git a/include/utils/String8.h b/include/utils/String8.h
index c4b18a4..0b18fe3 100644
--- a/include/utils/String8.h
+++ b/include/utils/String8.h
@@ -171,6 +171,8 @@
status_t append(const char* other);
status_t append(const char* other, size_t numChars);
+ status_t appendFormat(const char* fmt, ...);
+
// Note that this function takes O(N) time to calculate the value.
// No cache value is stored.
size_t getUtf32Length() const;
diff --git a/libs/binder/IPCThreadState.cpp b/libs/binder/IPCThreadState.cpp
index 28706ba..f6582e6 100644
--- a/libs/binder/IPCThreadState.cpp
+++ b/libs/binder/IPCThreadState.cpp
@@ -372,8 +372,8 @@
mStrictModePolicy = policy;
}
-
-int32_t IPCThreadState::getStrictModePolicy() const {
+int32_t IPCThreadState::getStrictModePolicy() const
+{
return mStrictModePolicy;
}
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp
index 47be1bf..60babad 100644
--- a/libs/binder/Parcel.cpp
+++ b/libs/binder/Parcel.cpp
@@ -48,6 +48,12 @@
#define PAD_SIZE(s) (((s)+3)&~3)
+// Note: must be kept in sync with android/os/StrictMode.java's PENALTY_GATHER
+#define STRICT_MODE_PENALTY_GATHER 0x100
+
+// Note: must be kept in sync with android/os/Parcel.java's EX_HAS_REPLY_HEADER
+#define EX_HAS_REPLY_HEADER -128
+
// XXX This can be made public if we want to provide
// support for typed data.
struct small_flat_data
@@ -440,7 +446,8 @@
// Write RPC headers. (previously just the interface token)
status_t Parcel::writeInterfaceToken(const String16& interface)
{
- writeInt32(IPCThreadState::self()->getStrictModePolicy());
+ writeInt32(IPCThreadState::self()->getStrictModePolicy() |
+ STRICT_MODE_PENALTY_GATHER);
// currently the interface identification token is just its name as a string
return writeString16(interface);
}
@@ -450,9 +457,14 @@
return enforceInterface(binder->getInterfaceDescriptor());
}
-bool Parcel::enforceInterface(const String16& interface) const
+bool Parcel::enforceInterface(const String16& interface,
+ int32_t* strict_policy_out) const
{
int32_t strict_policy = readInt32();
+ IPCThreadState::self()->setStrictModePolicy(strict_policy);
+ if (strict_policy_out != NULL) {
+ *strict_policy_out = strict_policy;
+ }
const String16 str(readString16());
if (str == interface) {
return true;
@@ -950,7 +962,15 @@
int32_t Parcel::readExceptionCode() const
{
int32_t exception_code = readAligned<int32_t>();
- // TODO: skip over the response header here, once that's in.
+ if (exception_code == EX_HAS_REPLY_HEADER) {
+ int32_t header_size = readAligned<int32_t>();
+ // Skip over fat responses headers. Not used (or propagated) in
+ // native code
+ setDataPosition(dataPosition() + header_size);
+ // And fat response headers are currently only used when there are no
+ // exceptions, so return no error:
+ return 0;
+ }
return exception_code;
}
diff --git a/libs/surfaceflinger_client/Surface.cpp b/libs/surfaceflinger_client/Surface.cpp
index dc6332c..5ab72cd 100644
--- a/libs/surfaceflinger_client/Surface.cpp
+++ b/libs/surfaceflinger_client/Surface.cpp
@@ -374,15 +374,34 @@
}
-sp<Surface> Surface::readFromParcel(
- const Parcel& data, const sp<Surface>& other)
-{
- sp<Surface> result(other);
+
+Mutex Surface::sCachedSurfacesLock;
+DefaultKeyedVector<wp<IBinder>, wp<Surface> > Surface::sCachedSurfaces(wp<Surface>(0));
+
+sp<Surface> Surface::readFromParcel(const Parcel& data) {
+ Mutex::Autolock _l(sCachedSurfacesLock);
sp<IBinder> binder(data.readStrongBinder());
- if (other==0 || binder != other->mSurface->asBinder()) {
- result = new Surface(data, binder);
+ sp<Surface> surface = sCachedSurfaces.valueFor(binder).promote();
+ if (surface == 0) {
+ surface = new Surface(data, binder);
+ sCachedSurfaces.add(binder, surface);
}
- return result;
+ if (surface->mSurface == 0) {
+ surface = 0;
+ }
+ cleanCachedSurfaces();
+ return surface;
+}
+
+// Remove the stale entries from the surface cache. This should only be called
+// with sCachedSurfacesLock held.
+void Surface::cleanCachedSurfaces() {
+ for (int i = sCachedSurfaces.size()-1; i >= 0; --i) {
+ wp<Surface> s(sCachedSurfaces.valueAt(i));
+ if (s == 0 || s.promote() == 0) {
+ sCachedSurfaces.removeItemsAt(i);
+ }
+ }
}
void Surface::init()
@@ -1003,4 +1022,3 @@
// ----------------------------------------------------------------------------
}; // namespace android
-
diff --git a/libs/ui/EventHub.cpp b/libs/ui/EventHub.cpp
index 768b04e..33dd3732 100644
--- a/libs/ui/EventHub.cpp
+++ b/libs/ui/EventHub.cpp
@@ -168,12 +168,12 @@
device_t* device = mDevicesById[i].device;
if (device != NULL && (device->classes & deviceClasses) != 0) {
int32_t result = getScanCodeStateLocked(device, scanCode);
- if (result >= KEY_STATE_DOWN) {
+ if (result >= AKEY_STATE_DOWN) {
return result;
}
}
}
- return KEY_STATE_UP;
+ return AKEY_STATE_UP;
} else {
device_t* device = getDevice(deviceId);
if (device != NULL) {
@@ -181,7 +181,7 @@
}
}
}
- return KEY_STATE_UNKNOWN;
+ return AKEY_STATE_UNKNOWN;
}
int32_t EventHub::getScanCodeStateLocked(device_t* device, int32_t scanCode) const {
@@ -189,9 +189,9 @@
memset(key_bitmask, 0, sizeof(key_bitmask));
if (ioctl(mFDs[id_to_index(device->id)].fd,
EVIOCGKEY(sizeof(key_bitmask)), key_bitmask) >= 0) {
- return test_bit(scanCode, key_bitmask) ? KEY_STATE_DOWN : KEY_STATE_UP;
+ return test_bit(scanCode, key_bitmask) ? AKEY_STATE_DOWN : AKEY_STATE_UP;
}
- return KEY_STATE_UNKNOWN;
+ return AKEY_STATE_UNKNOWN;
}
int32_t EventHub::getKeyCodeState(int32_t deviceId, int32_t deviceClasses,
@@ -202,19 +202,19 @@
device_t* device = mDevicesById[i].device;
if (device != NULL && (device->classes & deviceClasses) != 0) {
int32_t result = getKeyCodeStateLocked(device, keyCode);
- if (result >= KEY_STATE_DOWN) {
+ if (result >= AKEY_STATE_DOWN) {
return result;
}
}
}
- return KEY_STATE_UP;
+ return AKEY_STATE_UP;
} else {
device_t* device = getDevice(deviceId);
if (device != NULL) {
return getKeyCodeStateLocked(device, keyCode);
}
}
- return KEY_STATE_UNKNOWN;
+ return AKEY_STATE_UNKNOWN;
}
int32_t EventHub::getKeyCodeStateLocked(device_t* device, int32_t keyCode) const {
@@ -235,12 +235,12 @@
int32_t sc = scanCodes.itemAt(i);
//LOGI("Code %d: down=%d", sc, test_bit(sc, key_bitmask));
if (sc >= 0 && sc <= KEY_MAX && test_bit(sc, key_bitmask)) {
- return KEY_STATE_DOWN;
+ return AKEY_STATE_DOWN;
}
}
- return KEY_STATE_UP;
+ return AKEY_STATE_UP;
}
- return KEY_STATE_UNKNOWN;
+ return AKEY_STATE_UNKNOWN;
}
int32_t EventHub::getSwitchState(int32_t deviceId, int32_t deviceClasses, int32_t sw) const {
@@ -251,19 +251,19 @@
if (deviceId == -1) {
deviceId = mSwitches[sw];
if (deviceId == 0) {
- return KEY_STATE_UNKNOWN;
+ return AKEY_STATE_UNKNOWN;
}
}
device_t* device = getDevice(deviceId);
if (device == NULL) {
- return KEY_STATE_UNKNOWN;
+ return AKEY_STATE_UNKNOWN;
}
return getSwitchStateLocked(device, sw);
}
#endif
- return KEY_STATE_UNKNOWN;
+ return AKEY_STATE_UNKNOWN;
}
int32_t EventHub::getSwitchStateLocked(device_t* device, int32_t sw) const {
@@ -271,9 +271,9 @@
memset(sw_bitmask, 0, sizeof(sw_bitmask));
if (ioctl(mFDs[id_to_index(device->id)].fd,
EVIOCGSW(sizeof(sw_bitmask)), sw_bitmask) >= 0) {
- return test_bit(sw, sw_bitmask) ? KEY_STATE_DOWN : KEY_STATE_UP;
+ return test_bit(sw, sw_bitmask) ? AKEY_STATE_DOWN : AKEY_STATE_UP;
}
- return KEY_STATE_UNKNOWN;
+ return AKEY_STATE_UNKNOWN;
}
status_t EventHub::scancodeToKeycode(int32_t deviceId, int scancode,
diff --git a/libs/ui/Input.cpp b/libs/ui/Input.cpp
index 1f19c2c..5253c72 100644
--- a/libs/ui/Input.cpp
+++ b/libs/ui/Input.cpp
@@ -13,9 +13,14 @@
// class InputEvent
-void InputEvent::initialize(int32_t deviceId, int32_t nature) {
+void InputEvent::initialize(int32_t deviceId, int32_t source) {
mDeviceId = deviceId;
- mNature = nature;
+ mSource = source;
+}
+
+void InputEvent::initialize(const InputEvent& from) {
+ mDeviceId = from.mDeviceId;
+ mSource = from.mSource;
}
// class KeyEvent
@@ -86,7 +91,7 @@
void KeyEvent::initialize(
int32_t deviceId,
- int32_t nature,
+ int32_t source,
int32_t action,
int32_t flags,
int32_t keyCode,
@@ -95,7 +100,7 @@
int32_t repeatCount,
nsecs_t downTime,
nsecs_t eventTime) {
- InputEvent::initialize(deviceId, nature);
+ InputEvent::initialize(deviceId, source);
mAction = action;
mFlags = flags;
mKeyCode = keyCode;
@@ -106,11 +111,23 @@
mEventTime = eventTime;
}
+void KeyEvent::initialize(const KeyEvent& from) {
+ InputEvent::initialize(from);
+ mAction = from.mAction;
+ mFlags = from.mFlags;
+ mKeyCode = from.mKeyCode;
+ mScanCode = from.mScanCode;
+ mMetaState = from.mMetaState;
+ mRepeatCount = from.mRepeatCount;
+ mDownTime = from.mDownTime;
+ mEventTime = from.mEventTime;
+}
+
// class MotionEvent
void MotionEvent::initialize(
int32_t deviceId,
- int32_t nature,
+ int32_t source,
int32_t action,
int32_t edgeFlags,
int32_t metaState,
@@ -123,7 +140,7 @@
size_t pointerCount,
const int32_t* pointerIds,
const PointerCoords* pointerCoords) {
- InputEvent::initialize(deviceId, nature);
+ InputEvent::initialize(deviceId, source);
mAction = action;
mEdgeFlags = edgeFlags;
mMetaState = metaState;
diff --git a/libs/ui/InputDevice.cpp b/libs/ui/InputDevice.cpp
index 6014017..b2a4d6c 100644
--- a/libs/ui/InputDevice.cpp
+++ b/libs/ui/InputDevice.cpp
@@ -108,7 +108,7 @@
// --- InputDevice::KeyboardState ---
void InputDevice::KeyboardState::reset() {
- current.metaState = META_NONE;
+ current.metaState = AMETA_NONE;
current.downTime = 0;
}
diff --git a/libs/ui/InputDispatcher.cpp b/libs/ui/InputDispatcher.cpp
index c4ffce1..a55864b 100644
--- a/libs/ui/InputDispatcher.cpp
+++ b/libs/ui/InputDispatcher.cpp
@@ -245,14 +245,14 @@
void InputDispatcher::processKeyLockedInterruptible(
nsecs_t currentTime, KeyEntry* entry, nsecs_t keyRepeatTimeout) {
#if DEBUG_OUTBOUND_EVENT_DETAILS
- LOGD("processKey - eventTime=%lld, deviceId=0x%x, nature=0x%x, policyFlags=0x%x, action=0x%x, "
+ LOGD("processKey - eventTime=%lld, deviceId=0x%x, source=0x%x, policyFlags=0x%x, action=0x%x, "
"flags=0x%x, keyCode=0x%x, scanCode=0x%x, metaState=0x%x, downTime=%lld",
- entry->eventTime, entry->deviceId, entry->nature, entry->policyFlags, entry->action,
+ entry->eventTime, entry->deviceId, entry->source, entry->policyFlags, entry->action,
entry->flags, entry->keyCode, entry->scanCode, entry->metaState,
entry->downTime);
#endif
- if (entry->action == KEY_EVENT_ACTION_DOWN && ! entry->isInjected()) {
+ if (entry->action == AKEY_EVENT_ACTION_DOWN && ! entry->isInjected()) {
if (mKeyRepeatState.lastKeyEntry
&& mKeyRepeatState.lastKeyEntry->keyCode == entry->keyCode) {
// We have seen two identical key downs in a row which indicates that the device
@@ -287,7 +287,7 @@
if (queuedEntry->type == EventEntry::TYPE_KEY) {
KeyEntry* queuedKeyEntry = static_cast<KeyEntry*>(queuedEntry);
if (queuedKeyEntry->deviceId == entry->deviceId
- && entry->action == KEY_EVENT_ACTION_UP) {
+ && entry->action == AKEY_EVENT_ACTION_UP) {
resetKeyRepeatLocked();
return;
}
@@ -303,7 +303,7 @@
entry->repeatCount += 1;
} else {
KeyEntry* newEntry = mAllocator.obtainKeyEntry(currentTime,
- entry->deviceId, entry->nature, policyFlags,
+ entry->deviceId, entry->source, policyFlags,
entry->action, entry->flags, entry->keyCode, entry->scanCode,
entry->metaState, entry->repeatCount + 1, entry->downTime);
@@ -314,16 +314,16 @@
}
if (entry->repeatCount == 1) {
- entry->flags |= KEY_EVENT_FLAG_LONG_PRESS;
+ entry->flags |= AKEY_EVENT_FLAG_LONG_PRESS;
}
mKeyRepeatState.nextRepeatTime = currentTime + keyRepeatTimeout;
#if DEBUG_OUTBOUND_EVENT_DETAILS
- LOGD("processKeyRepeat - eventTime=%lld, deviceId=0x%x, nature=0x%x, policyFlags=0x%x, "
+ LOGD("processKeyRepeat - eventTime=%lld, deviceId=0x%x, source=0x%x, policyFlags=0x%x, "
"action=0x%x, flags=0x%x, keyCode=0x%x, scanCode=0x%x, metaState=0x%x, "
"repeatCount=%d, downTime=%lld",
- entry->eventTime, entry->deviceId, entry->nature, entry->policyFlags,
+ entry->eventTime, entry->deviceId, entry->source, entry->policyFlags,
entry->action, entry->flags, entry->keyCode, entry->scanCode, entry->metaState,
entry->repeatCount, entry->downTime);
#endif
@@ -334,9 +334,9 @@
void InputDispatcher::processMotionLockedInterruptible(
nsecs_t currentTime, MotionEntry* entry) {
#if DEBUG_OUTBOUND_EVENT_DETAILS
- LOGD("processMotion - eventTime=%lld, deviceId=0x%x, nature=0x%x, policyFlags=0x%x, action=0x%x, "
+ LOGD("processMotion - eventTime=%lld, deviceId=0x%x, source=0x%x, policyFlags=0x%x, action=0x%x, "
"metaState=0x%x, edgeFlags=0x%x, xPrecision=%f, yPrecision=%f, downTime=%lld",
- entry->eventTime, entry->deviceId, entry->nature, entry->policyFlags, entry->action,
+ entry->eventTime, entry->deviceId, entry->source, entry->policyFlags, entry->action,
entry->metaState, entry->edgeFlags, entry->xPrecision, entry->yPrecision,
entry->downTime);
@@ -357,7 +357,7 @@
// Keep in mind that due to batching, it is possible for the number of samples actually
// dispatched to change before the application finally consumed them.
- if (entry->action == MOTION_EVENT_ACTION_MOVE) {
+ if (entry->action == AMOTION_EVENT_ACTION_MOVE) {
LOGD(" ... Total movement samples currently batched %d ...", sampleCount);
}
#endif
@@ -375,7 +375,7 @@
mCurrentInputTargetsValid = false;
mLock.unlock();
- mReusableKeyEvent.initialize(entry->deviceId, entry->nature, entry->action, entry->flags,
+ mReusableKeyEvent.initialize(entry->deviceId, entry->source, entry->action, entry->flags,
entry->keyCode, entry->scanCode, entry->metaState, entry->repeatCount,
entry->downTime, entry->eventTime);
@@ -404,7 +404,7 @@
mCurrentInputTargetsValid = false;
mLock.unlock();
- mReusableMotionEvent.initialize(entry->deviceId, entry->nature, entry->action,
+ mReusableMotionEvent.initialize(entry->deviceId, entry->source, entry->action,
entry->edgeFlags, entry->metaState,
0, 0, entry->xPrecision, entry->yPrecision,
entry->downTime, entry->eventTime, entry->pointerCount, entry->pointerIds,
@@ -611,11 +611,11 @@
int32_t action = keyEntry->action;
int32_t flags = keyEntry->flags;
if (dispatchEntry->targetFlags & InputTarget::FLAG_CANCEL) {
- flags |= KEY_EVENT_FLAG_CANCELED;
+ flags |= AKEY_EVENT_FLAG_CANCELED;
}
// Publish the key event.
- status = connection->inputPublisher.publishKeyEvent(keyEntry->deviceId, keyEntry->nature,
+ status = connection->inputPublisher.publishKeyEvent(keyEntry->deviceId, keyEntry->source,
action, flags, keyEntry->keyCode, keyEntry->scanCode,
keyEntry->metaState, keyEntry->repeatCount, keyEntry->downTime,
keyEntry->eventTime);
@@ -635,10 +635,10 @@
// Apply target flags.
int32_t action = motionEntry->action;
if (dispatchEntry->targetFlags & InputTarget::FLAG_OUTSIDE) {
- action = MOTION_EVENT_ACTION_OUTSIDE;
+ action = AMOTION_EVENT_ACTION_OUTSIDE;
}
if (dispatchEntry->targetFlags & InputTarget::FLAG_CANCEL) {
- action = MOTION_EVENT_ACTION_CANCEL;
+ action = AMOTION_EVENT_ACTION_CANCEL;
}
// If headMotionSample is non-NULL, then it points to the first new sample that we
@@ -650,10 +650,20 @@
firstMotionSample = & motionEntry->firstSample;
}
+ // Set the X and Y offset depending on the input source.
+ float xOffset, yOffset;
+ if (motionEntry->source & AINPUT_SOURCE_CLASS_POINTER) {
+ xOffset = dispatchEntry->xOffset;
+ yOffset = dispatchEntry->yOffset;
+ } else {
+ xOffset = 0.0f;
+ yOffset = 0.0f;
+ }
+
// Publish the motion event and the first motion sample.
status = connection->inputPublisher.publishMotionEvent(motionEntry->deviceId,
- motionEntry->nature, action, motionEntry->edgeFlags, motionEntry->metaState,
- dispatchEntry->xOffset, dispatchEntry->yOffset,
+ motionEntry->source, action, motionEntry->edgeFlags, motionEntry->metaState,
+ xOffset, yOffset,
motionEntry->xPrecision, motionEntry->yPrecision,
motionEntry->downTime, firstMotionSample->eventTime,
motionEntry->pointerCount, motionEntry->pointerIds,
@@ -964,13 +974,13 @@
} // release lock
}
-void InputDispatcher::notifyKey(nsecs_t eventTime, int32_t deviceId, int32_t nature,
+void InputDispatcher::notifyKey(nsecs_t eventTime, int32_t deviceId, int32_t source,
uint32_t policyFlags, int32_t action, int32_t flags,
int32_t keyCode, int32_t scanCode, int32_t metaState, nsecs_t downTime) {
#if DEBUG_INBOUND_EVENT_DETAILS
- LOGD("notifyKey - eventTime=%lld, deviceId=0x%x, nature=0x%x, policyFlags=0x%x, action=0x%x, "
+ LOGD("notifyKey - eventTime=%lld, deviceId=0x%x, source=0x%x, policyFlags=0x%x, action=0x%x, "
"flags=0x%x, keyCode=0x%x, scanCode=0x%x, metaState=0x%x, downTime=%lld",
- eventTime, deviceId, nature, policyFlags, action, flags,
+ eventTime, deviceId, source, policyFlags, action, flags,
keyCode, scanCode, metaState, downTime);
#endif
@@ -980,7 +990,7 @@
int32_t repeatCount = 0;
KeyEntry* newEntry = mAllocator.obtainKeyEntry(eventTime,
- deviceId, nature, policyFlags, action, flags, keyCode, scanCode,
+ deviceId, source, policyFlags, action, flags, keyCode, scanCode,
metaState, repeatCount, downTime);
wasEmpty = mInboundQueue.isEmpty();
@@ -992,15 +1002,15 @@
}
}
-void InputDispatcher::notifyMotion(nsecs_t eventTime, int32_t deviceId, int32_t nature,
+void InputDispatcher::notifyMotion(nsecs_t eventTime, int32_t deviceId, int32_t source,
uint32_t policyFlags, int32_t action, int32_t metaState, int32_t edgeFlags,
uint32_t pointerCount, const int32_t* pointerIds, const PointerCoords* pointerCoords,
float xPrecision, float yPrecision, nsecs_t downTime) {
#if DEBUG_INBOUND_EVENT_DETAILS
- LOGD("notifyMotion - eventTime=%lld, deviceId=0x%x, nature=0x%x, policyFlags=0x%x, "
+ LOGD("notifyMotion - eventTime=%lld, deviceId=0x%x, source=0x%x, policyFlags=0x%x, "
"action=0x%x, metaState=0x%x, edgeFlags=0x%x, xPrecision=%f, yPrecision=%f, "
"downTime=%lld",
- eventTime, deviceId, nature, policyFlags, action, metaState, edgeFlags,
+ eventTime, deviceId, source, policyFlags, action, metaState, edgeFlags,
xPrecision, yPrecision, downTime);
for (uint32_t i = 0; i < pointerCount; i++) {
LOGD(" Pointer %d: id=%d, x=%f, y=%f, pressure=%f, size=%f",
@@ -1014,7 +1024,7 @@
AutoMutex _l(mLock);
// Attempt batching and streaming of move events.
- if (action == MOTION_EVENT_ACTION_MOVE) {
+ if (action == AMOTION_EVENT_ACTION_MOVE) {
// BATCHING CASE
//
// Try to append a move sample to the tail of the inbound queue for this device.
@@ -1033,7 +1043,7 @@
continue;
}
- if (motionEntry->action != MOTION_EVENT_ACTION_MOVE
+ if (motionEntry->action != AMOTION_EVENT_ACTION_MOVE
|| motionEntry->pointerCount != pointerCount
|| motionEntry->isInjected()) {
// Last motion event in the queue for this device is not compatible for
@@ -1094,7 +1104,7 @@
MotionEntry* syncedMotionEntry = static_cast<MotionEntry*>(
dispatchEntry->eventEntry);
- if (syncedMotionEntry->action != MOTION_EVENT_ACTION_MOVE
+ if (syncedMotionEntry->action != AMOTION_EVENT_ACTION_MOVE
|| syncedMotionEntry->deviceId != deviceId
|| syncedMotionEntry->pointerCount != pointerCount
|| syncedMotionEntry->isInjected()) {
@@ -1124,7 +1134,7 @@
// Just enqueue a new motion event.
MotionEntry* newEntry = mAllocator.obtainMotionEntry(eventTime,
- deviceId, nature, policyFlags, action, metaState, edgeFlags,
+ deviceId, source, policyFlags, action, metaState, edgeFlags,
xPrecision, yPrecision, downTime,
pointerCount, pointerIds, pointerCoords);
@@ -1224,19 +1234,19 @@
InputDispatcher::EventEntry* InputDispatcher::createEntryFromInputEventLocked(
const InputEvent* event) {
switch (event->getType()) {
- case INPUT_EVENT_TYPE_KEY: {
+ case AINPUT_EVENT_TYPE_KEY: {
const KeyEvent* keyEvent = static_cast<const KeyEvent*>(event);
uint32_t policyFlags = 0; // XXX consider adding a policy flag to track injected events
KeyEntry* keyEntry = mAllocator.obtainKeyEntry(keyEvent->getEventTime(),
- keyEvent->getDeviceId(), keyEvent->getNature(), policyFlags,
+ keyEvent->getDeviceId(), keyEvent->getSource(), policyFlags,
keyEvent->getAction(), keyEvent->getFlags(),
keyEvent->getKeyCode(), keyEvent->getScanCode(), keyEvent->getMetaState(),
keyEvent->getRepeatCount(), keyEvent->getDownTime());
return keyEntry;
}
- case INPUT_EVENT_TYPE_MOTION: {
+ case AINPUT_EVENT_TYPE_MOTION: {
const MotionEvent* motionEvent = static_cast<const MotionEvent*>(event);
uint32_t policyFlags = 0; // XXX consider adding a policy flag to track injected events
@@ -1245,7 +1255,7 @@
size_t pointerCount = motionEvent->getPointerCount();
MotionEntry* motionEntry = mAllocator.obtainMotionEntry(*sampleEventTimes,
- motionEvent->getDeviceId(), motionEvent->getNature(), policyFlags,
+ motionEvent->getDeviceId(), motionEvent->getSource(), policyFlags,
motionEvent->getAction(), motionEvent->getMetaState(), motionEvent->getEdgeFlags(),
motionEvent->getXPrecision(), motionEvent->getYPrecision(),
motionEvent->getDownTime(), uint32_t(pointerCount),
@@ -1500,14 +1510,14 @@
}
InputDispatcher::KeyEntry* InputDispatcher::Allocator::obtainKeyEntry(nsecs_t eventTime,
- int32_t deviceId, int32_t nature, uint32_t policyFlags, int32_t action,
+ int32_t deviceId, int32_t source, uint32_t policyFlags, int32_t action,
int32_t flags, int32_t keyCode, int32_t scanCode, int32_t metaState,
int32_t repeatCount, nsecs_t downTime) {
KeyEntry* entry = mKeyEntryPool.alloc();
initializeEventEntry(entry, EventEntry::TYPE_KEY, eventTime);
entry->deviceId = deviceId;
- entry->nature = nature;
+ entry->source = source;
entry->policyFlags = policyFlags;
entry->action = action;
entry->flags = flags;
@@ -1520,7 +1530,7 @@
}
InputDispatcher::MotionEntry* InputDispatcher::Allocator::obtainMotionEntry(nsecs_t eventTime,
- int32_t deviceId, int32_t nature, uint32_t policyFlags, int32_t action,
+ int32_t deviceId, int32_t source, uint32_t policyFlags, int32_t action,
int32_t metaState, int32_t edgeFlags, float xPrecision, float yPrecision,
nsecs_t downTime, uint32_t pointerCount,
const int32_t* pointerIds, const PointerCoords* pointerCoords) {
@@ -1529,7 +1539,7 @@
entry->eventTime = eventTime;
entry->deviceId = deviceId;
- entry->nature = nature;
+ entry->source = source;
entry->policyFlags = policyFlags;
entry->action = action;
entry->metaState = metaState;
diff --git a/libs/ui/InputReader.cpp b/libs/ui/InputReader.cpp
index 0a21db7..30e391f 100644
--- a/libs/ui/InputReader.cpp
+++ b/libs/ui/InputReader.cpp
@@ -29,6 +29,7 @@
#include <unistd.h>
#include <errno.h>
#include <limits.h>
+#include <math.h>
/** Amount that trackball needs to move in order to generate a key event. */
#define TRACKBALL_MOVEMENT_THRESHOLD 6
@@ -60,33 +61,33 @@
int32_t mask;
switch (keyCode) {
case AKEYCODE_ALT_LEFT:
- mask = META_ALT_LEFT_ON;
+ mask = AMETA_ALT_LEFT_ON;
break;
case AKEYCODE_ALT_RIGHT:
- mask = META_ALT_RIGHT_ON;
+ mask = AMETA_ALT_RIGHT_ON;
break;
case AKEYCODE_SHIFT_LEFT:
- mask = META_SHIFT_LEFT_ON;
+ mask = AMETA_SHIFT_LEFT_ON;
break;
case AKEYCODE_SHIFT_RIGHT:
- mask = META_SHIFT_RIGHT_ON;
+ mask = AMETA_SHIFT_RIGHT_ON;
break;
case AKEYCODE_SYM:
- mask = META_SYM_ON;
+ mask = AMETA_SYM_ON;
break;
default:
return oldMetaState;
}
int32_t newMetaState = down ? oldMetaState | mask : oldMetaState & ~ mask
- & ~ (META_ALT_ON | META_SHIFT_ON);
+ & ~ (AMETA_ALT_ON | AMETA_SHIFT_ON);
- if (newMetaState & (META_ALT_LEFT_ON | META_ALT_RIGHT_ON)) {
- newMetaState |= META_ALT_ON;
+ if (newMetaState & (AMETA_ALT_LEFT_ON | AMETA_ALT_RIGHT_ON)) {
+ newMetaState |= AMETA_ALT_ON;
}
- if (newMetaState & (META_SHIFT_LEFT_ON | META_SHIFT_RIGHT_ON)) {
- newMetaState |= META_SHIFT_ON;
+ if (newMetaState & (AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_RIGHT_ON)) {
+ newMetaState |= AMETA_SHIFT_ON;
}
return newMetaState;
@@ -269,6 +270,10 @@
device->trackball.accumulator.fields |=
InputDevice::TrackballState::Accumulator::FIELD_BTN_MOUSE;
device->trackball.accumulator.btnMouse = down;
+
+ // Process the trackball change now since we may not receive a sync immediately.
+ onTrackballStateChanged(rawEvent->when, device);
+ device->trackball.accumulator.clear();
return;
}
}
@@ -324,11 +329,26 @@
InputDevice::MultiTouchScreenState::Accumulator::FIELD_ABS_MT_TOUCH_MAJOR;
pointer->absMTTouchMajor = rawEvent->value;
break;
+ case ABS_MT_TOUCH_MINOR:
+ pointer->fields |=
+ InputDevice::MultiTouchScreenState::Accumulator::FIELD_ABS_MT_TOUCH_MINOR;
+ pointer->absMTTouchMinor = rawEvent->value;
+ break;
case ABS_MT_WIDTH_MAJOR:
pointer->fields |=
InputDevice::MultiTouchScreenState::Accumulator::FIELD_ABS_MT_WIDTH_MAJOR;
pointer->absMTWidthMajor = rawEvent->value;
break;
+ case ABS_MT_WIDTH_MINOR:
+ pointer->fields |=
+ InputDevice::MultiTouchScreenState::Accumulator::FIELD_ABS_MT_WIDTH_MINOR;
+ pointer->absMTWidthMinor = rawEvent->value;
+ break;
+ case ABS_MT_ORIENTATION:
+ pointer->fields |=
+ InputDevice::MultiTouchScreenState::Accumulator::FIELD_ABS_MT_ORIENTATION;
+ pointer->absMTOrientation = rawEvent->value;
+ break;
case ABS_MT_TRACKING_ID:
pointer->fields |=
InputDevice::MultiTouchScreenState::Accumulator::FIELD_ABS_MT_TRACKING_ID;
@@ -408,17 +428,17 @@
int32_t keyEventAction;
if (down) {
device->keyboard.current.downTime = when;
- keyEventAction = KEY_EVENT_ACTION_DOWN;
+ keyEventAction = AKEY_EVENT_ACTION_DOWN;
} else {
- keyEventAction = KEY_EVENT_ACTION_UP;
+ keyEventAction = AKEY_EVENT_ACTION_UP;
}
- int32_t keyEventFlags = KEY_EVENT_FLAG_FROM_SYSTEM;
+ int32_t keyEventFlags = AKEY_EVENT_FLAG_FROM_SYSTEM;
if (policyActions & InputReaderPolicyInterface::ACTION_WOKE_HERE) {
- keyEventFlags = keyEventFlags | KEY_EVENT_FLAG_WOKE_HERE;
+ keyEventFlags = keyEventFlags | AKEY_EVENT_FLAG_WOKE_HERE;
}
- mDispatcher->notifyKey(when, device->id, INPUT_EVENT_NATURE_KEY, policyFlags,
+ mDispatcher->notifyKey(when, device->id, AINPUT_SOURCE_KEYBOARD, policyFlags,
keyEventAction, keyEventFlags, keyCode, scanCode,
device->keyboard.current.metaState,
device->keyboard.current.downTime);
@@ -473,11 +493,29 @@
continue;
}
+ out->pointers[outCount].x = in->accumulator.pointers[inIndex].absMTPositionX;
+ out->pointers[outCount].y = in->accumulator.pointers[inIndex].absMTPositionY;
+
+ out->pointers[outCount].touchMajor = in->accumulator.pointers[inIndex].absMTTouchMajor;
+ out->pointers[outCount].touchMinor = (fields
+ & InputDevice::MultiTouchScreenState::Accumulator::FIELD_ABS_MT_TOUCH_MINOR) != 0
+ ? in->accumulator.pointers[inIndex].absMTTouchMinor
+ : in->accumulator.pointers[inIndex].absMTTouchMajor;
+
+ out->pointers[outCount].toolMajor = in->accumulator.pointers[inIndex].absMTWidthMajor;
+ out->pointers[outCount].toolMinor = (fields
+ & InputDevice::MultiTouchScreenState::Accumulator::FIELD_ABS_MT_WIDTH_MINOR) != 0
+ ? in->accumulator.pointers[inIndex].absMTWidthMinor
+ : in->accumulator.pointers[inIndex].absMTWidthMajor;
+
+ out->pointers[outCount].orientation = (fields
+ & InputDevice::MultiTouchScreenState::Accumulator::FIELD_ABS_MT_ORIENTATION) != 0
+ ? in->accumulator.pointers[inIndex].absMTOrientation : 0;
+
+ // Derive an approximation of pressure and size.
// FIXME assignment of pressure may be incorrect, probably better to let
// pressure = touch / width. Later on we pass width to MotionEvent as a size, which
// isn't quite right either. Should be using touch for that.
- out->pointers[outCount].x = in->accumulator.pointers[inIndex].absMTPositionX;
- out->pointers[outCount].y = in->accumulator.pointers[inIndex].absMTPositionY;
out->pointers[outCount].pressure = in->accumulator.pointers[inIndex].absMTTouchMajor;
out->pointers[outCount].size = in->accumulator.pointers[inIndex].absMTWidthMajor;
@@ -556,6 +594,11 @@
out->pointers[0].y = in->current.y;
out->pointers[0].pressure = in->current.pressure;
out->pointers[0].size = in->current.size;
+ out->pointers[0].touchMajor = in->current.pressure;
+ out->pointers[0].touchMinor = in->current.pressure;
+ out->pointers[0].toolMajor = in->current.size;
+ out->pointers[0].toolMinor = in->current.size;
+ out->pointers[0].orientation = 0;
out->idToIndex[0] = 0;
out->idBits.markBit(0);
}
@@ -635,8 +678,8 @@
device->touchScreen.currentVirtualKey.keyCode,
device->touchScreen.currentVirtualKey.scanCode);
#endif
- dispatchVirtualKey(when, device, policyFlags, KEY_EVENT_ACTION_UP,
- KEY_EVENT_FLAG_FROM_SYSTEM | KEY_EVENT_FLAG_VIRTUAL_HARD_KEY);
+ dispatchVirtualKey(when, device, policyFlags, AKEY_EVENT_ACTION_UP,
+ AKEY_EVENT_FLAG_FROM_SYSTEM | AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY);
return true; // consumed
}
@@ -658,9 +701,9 @@
device->touchScreen.currentVirtualKey.keyCode,
device->touchScreen.currentVirtualKey.scanCode);
#endif
- dispatchVirtualKey(when, device, policyFlags, KEY_EVENT_ACTION_UP,
- KEY_EVENT_FLAG_FROM_SYSTEM | KEY_EVENT_FLAG_VIRTUAL_HARD_KEY
- | KEY_EVENT_FLAG_CANCELED);
+ dispatchVirtualKey(when, device, policyFlags, AKEY_EVENT_ACTION_UP,
+ AKEY_EVENT_FLAG_FROM_SYSTEM | AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY
+ | AKEY_EVENT_FLAG_CANCELED);
return true; // consumed
default:
@@ -679,8 +722,8 @@
device->touchScreen.currentVirtualKey.keyCode,
device->touchScreen.currentVirtualKey.scanCode);
#endif
- dispatchVirtualKey(when, device, policyFlags, KEY_EVENT_ACTION_DOWN,
- KEY_EVENT_FLAG_FROM_SYSTEM | KEY_EVENT_FLAG_VIRTUAL_HARD_KEY);
+ dispatchVirtualKey(when, device, policyFlags, AKEY_EVENT_ACTION_DOWN,
+ AKEY_EVENT_FLAG_FROM_SYSTEM | AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY);
return true; // consumed
}
}
@@ -698,15 +741,15 @@
nsecs_t downTime = device->touchScreen.currentVirtualKey.downTime;
int32_t metaState = globalMetaState();
- if (keyEventAction == KEY_EVENT_ACTION_DOWN) {
+ if (keyEventAction == AKEY_EVENT_ACTION_DOWN) {
mPolicy->virtualKeyDownFeedback();
}
int32_t policyActions = mPolicy->interceptKey(when, device->id,
- keyEventAction == KEY_EVENT_ACTION_DOWN, keyCode, scanCode, policyFlags);
+ keyEventAction == AKEY_EVENT_ACTION_DOWN, keyCode, scanCode, policyFlags);
if (applyStandardInputDispatchPolicyActions(when, policyActions, & policyFlags)) {
- mDispatcher->notifyKey(when, device->id, INPUT_EVENT_NATURE_KEY, policyFlags,
+ mDispatcher->notifyKey(when, device->id, AINPUT_SOURCE_KEYBOARD, policyFlags,
keyEventAction, keyEventFlags, keyCode, scanCode, metaState, downTime);
}
}
@@ -725,9 +768,9 @@
if (currentIdBits == lastIdBits) {
// No pointer id changes so this is a move event.
// The dispatcher takes care of batching moves so we don't have to deal with that here.
- int32_t motionEventAction = MOTION_EVENT_ACTION_MOVE;
+ int32_t motionEventAction = AMOTION_EVENT_ACTION_MOVE;
dispatchTouch(when, device, policyFlags, & device->touchScreen.currentTouch,
- currentIdBits, motionEventAction);
+ currentIdBits, -1, motionEventAction);
} else {
// There may be pointers going up and pointers going down at the same time when pointer
// ids are reported by the device driver.
@@ -743,14 +786,13 @@
int32_t motionEventAction;
if (activeIdBits.isEmpty()) {
- motionEventAction = MOTION_EVENT_ACTION_UP;
+ motionEventAction = AMOTION_EVENT_ACTION_UP;
} else {
- motionEventAction = MOTION_EVENT_ACTION_POINTER_UP
- | (upId << MOTION_EVENT_ACTION_POINTER_INDEX_SHIFT);
+ motionEventAction = AMOTION_EVENT_ACTION_POINTER_UP;
}
dispatchTouch(when, device, policyFlags, & device->touchScreen.lastTouch,
- oldActiveIdBits, motionEventAction);
+ oldActiveIdBits, upId, motionEventAction);
}
while (! downIdBits.isEmpty()) {
@@ -761,21 +803,20 @@
int32_t motionEventAction;
if (oldActiveIdBits.isEmpty()) {
- motionEventAction = MOTION_EVENT_ACTION_DOWN;
+ motionEventAction = AMOTION_EVENT_ACTION_DOWN;
device->touchScreen.downTime = when;
} else {
- motionEventAction = MOTION_EVENT_ACTION_POINTER_DOWN
- | (downId << MOTION_EVENT_ACTION_POINTER_INDEX_SHIFT);
+ motionEventAction = AMOTION_EVENT_ACTION_POINTER_DOWN;
}
dispatchTouch(when, device, policyFlags, & device->touchScreen.currentTouch,
- activeIdBits, motionEventAction);
+ activeIdBits, downId, motionEventAction);
}
}
}
void InputReader::dispatchTouch(nsecs_t when, InputDevice* device, uint32_t policyFlags,
- InputDevice::TouchData* touch, BitSet32 idBits,
+ InputDevice::TouchData* touch, BitSet32 idBits, uint32_t changedId,
int32_t motionEventAction) {
int32_t orientedWidth, orientedHeight;
switch (mDisplayOrientation) {
@@ -813,11 +854,17 @@
float size = float(touch->pointers[index].size
- precalculated.sizeOrigin) * precalculated.sizeScale;
+ float orientation = float(touch->pointers[index].orientation)
+ * precalculated.orientationScale;
+
+ bool vertical = abs(orientation) <= M_PI / 8;
+
switch (mDisplayOrientation) {
case InputReaderPolicyInterface::ROTATION_90: {
float xTemp = x;
x = y;
y = mDisplayWidth - xTemp;
+ vertical = ! vertical;
break;
}
case InputReaderPolicyInterface::ROTATION_180: {
@@ -829,39 +876,61 @@
float xTemp = x;
x = mDisplayHeight - y;
y = xTemp;
+ vertical = ! vertical;
break;
}
}
+ float touchMajor, touchMinor, toolMajor, toolMinor;
+ if (vertical) {
+ touchMajor = float(touch->pointers[index].touchMajor) * precalculated.yScale;
+ touchMinor = float(touch->pointers[index].touchMinor) * precalculated.xScale;
+ toolMajor = float(touch->pointers[index].toolMajor) * precalculated.yScale;
+ toolMinor = float(touch->pointers[index].toolMinor) * precalculated.xScale;
+ } else {
+ touchMajor = float(touch->pointers[index].touchMajor) * precalculated.xScale;
+ touchMinor = float(touch->pointers[index].touchMinor) * precalculated.yScale;
+ toolMajor = float(touch->pointers[index].toolMajor) * precalculated.xScale;
+ toolMinor = float(touch->pointers[index].toolMinor) * precalculated.yScale;
+ }
+
pointerIds[pointerCount] = int32_t(id);
pointerCoords[pointerCount].x = x;
pointerCoords[pointerCount].y = y;
pointerCoords[pointerCount].pressure = pressure;
pointerCoords[pointerCount].size = size;
+ pointerCoords[pointerCount].touchMajor = touchMajor;
+ pointerCoords[pointerCount].touchMinor = touchMinor;
+ pointerCoords[pointerCount].toolMajor = toolMajor;
+ pointerCoords[pointerCount].toolMinor = toolMinor;
+ pointerCoords[pointerCount].orientation = orientation;
+
+ if (id == changedId) {
+ motionEventAction |= pointerCount << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
+ }
pointerCount += 1;
}
// Check edge flags by looking only at the first pointer since the flags are
// global to the event.
- // XXX Maybe we should revise the edge flags API to work on a per-pointer basis.
int32_t motionEventEdgeFlags = 0;
- if (motionEventAction == MOTION_EVENT_ACTION_DOWN) {
+ if (motionEventAction == AMOTION_EVENT_ACTION_DOWN) {
if (pointerCoords[0].x <= 0) {
- motionEventEdgeFlags |= MOTION_EVENT_EDGE_FLAG_LEFT;
+ motionEventEdgeFlags |= AMOTION_EVENT_EDGE_FLAG_LEFT;
} else if (pointerCoords[0].x >= orientedWidth) {
- motionEventEdgeFlags |= MOTION_EVENT_EDGE_FLAG_RIGHT;
+ motionEventEdgeFlags |= AMOTION_EVENT_EDGE_FLAG_RIGHT;
}
if (pointerCoords[0].y <= 0) {
- motionEventEdgeFlags |= MOTION_EVENT_EDGE_FLAG_TOP;
+ motionEventEdgeFlags |= AMOTION_EVENT_EDGE_FLAG_TOP;
} else if (pointerCoords[0].y >= orientedHeight) {
- motionEventEdgeFlags |= MOTION_EVENT_EDGE_FLAG_BOTTOM;
+ motionEventEdgeFlags |= AMOTION_EVENT_EDGE_FLAG_BOTTOM;
}
}
nsecs_t downTime = device->touchScreen.downTime;
- mDispatcher->notifyMotion(when, device->id, INPUT_EVENT_NATURE_TOUCH, policyFlags,
+ mDispatcher->notifyMotion(when, device->id, AINPUT_SOURCE_TOUCHSCREEN, policyFlags,
motionEventAction, globalMetaState(), motionEventEdgeFlags,
pointerCount, pointerIds, pointerCoords,
0, 0, downTime);
@@ -912,9 +981,9 @@
int32_t motionEventAction;
if (downChanged) {
- motionEventAction = down ? MOTION_EVENT_ACTION_DOWN : MOTION_EVENT_ACTION_UP;
+ motionEventAction = down ? AMOTION_EVENT_ACTION_DOWN : AMOTION_EVENT_ACTION_UP;
} else {
- motionEventAction = MOTION_EVENT_ACTION_MOVE;
+ motionEventAction = AMOTION_EVENT_ACTION_MOVE;
}
int32_t pointerId = 0;
@@ -925,6 +994,11 @@
? device->trackball.accumulator.relY * device->trackball.precalculated.yScale : 0;
pointerCoords.pressure = 1.0f; // XXX Consider making this 1.0f if down, 0 otherwise.
pointerCoords.size = 0;
+ pointerCoords.touchMajor = 0;
+ pointerCoords.touchMinor = 0;
+ pointerCoords.toolMajor = 0;
+ pointerCoords.toolMinor = 0;
+ pointerCoords.orientation = 0;
float temp;
switch (mDisplayOrientation) {
@@ -946,8 +1020,8 @@
break;
}
- mDispatcher->notifyMotion(when, device->id, INPUT_EVENT_NATURE_TRACKBALL, policyFlags,
- motionEventAction, globalMetaState(), MOTION_EVENT_EDGE_FLAG_NONE,
+ mDispatcher->notifyMotion(when, device->id, AINPUT_SOURCE_TRACKBALL, policyFlags,
+ motionEventAction, globalMetaState(), AMOTION_EVENT_EDGE_FLAG_NONE,
1, & pointerId, & pointerCoords,
device->trackball.precalculated.xPrecision,
device->trackball.precalculated.yPrecision,
@@ -1079,6 +1153,8 @@
& device->touchScreen.parameters.pressureAxis);
configureAbsoluteAxisInfo(device, ABS_MT_WIDTH_MAJOR, "Size",
& device->touchScreen.parameters.sizeAxis);
+ configureAbsoluteAxisInfo(device, ABS_MT_ORIENTATION, "Orientation",
+ & device->touchScreen.parameters.orientationAxis);
} else if (device->isSingleTouchScreen()) {
configureAbsoluteAxisInfo(device, ABS_X, "X",
& device->touchScreen.parameters.xAxis);
@@ -1088,6 +1164,7 @@
& device->touchScreen.parameters.pressureAxis);
configureAbsoluteAxisInfo(device, ABS_TOOL_WIDTH, "Size",
& device->touchScreen.parameters.sizeAxis);
+ device->touchScreen.parameters.orientationAxis.valid = false;
}
if (device->isTouchScreen()) {
@@ -1117,6 +1194,14 @@
device->touchScreen.precalculated.sizeOrigin = 0;
device->touchScreen.precalculated.sizeScale = 1.0f;
}
+
+ if (device->touchScreen.parameters.orientationAxis.valid
+ && device->touchScreen.parameters.orientationAxis.maxValue > 0) {
+ device->touchScreen.precalculated.orientationScale =
+ M_PI_4 / device->touchScreen.parameters.orientationAxis.maxValue;
+ } else {
+ device->touchScreen.precalculated.orientationScale = 0.0f;
+ }
}
if (device->isTrackball()) {
@@ -1347,7 +1432,7 @@
AutoMutex _l(mExportedStateLock);
if (mExportedVirtualScanCode == scanCode) {
- return KEY_STATE_VIRTUAL;
+ return AKEY_STATE_VIRTUAL;
}
} // release exported state lock
@@ -1360,7 +1445,7 @@
AutoMutex _l(mExportedStateLock);
if (mExportedVirtualKeyCode == keyCode) {
- return KEY_STATE_VIRTUAL;
+ return AKEY_STATE_VIRTUAL;
}
} // release exported state lock
diff --git a/libs/ui/InputTransport.cpp b/libs/ui/InputTransport.cpp
index fc83e31..cf0f63e 100644
--- a/libs/ui/InputTransport.cpp
+++ b/libs/ui/InputTransport.cpp
@@ -270,7 +270,7 @@
status_t InputPublisher::publishInputEvent(
int32_t type,
int32_t deviceId,
- int32_t nature) {
+ int32_t source) {
if (mPinned) {
LOGE("channel '%s' publisher ~ Attempted to publish a new event but publisher has "
"not yet been reset.", mChannel->getName().string());
@@ -302,13 +302,13 @@
mSharedMessage->consumed = false;
mSharedMessage->type = type;
mSharedMessage->deviceId = deviceId;
- mSharedMessage->nature = nature;
+ mSharedMessage->source = source;
return OK;
}
status_t InputPublisher::publishKeyEvent(
int32_t deviceId,
- int32_t nature,
+ int32_t source,
int32_t action,
int32_t flags,
int32_t keyCode,
@@ -318,15 +318,15 @@
nsecs_t downTime,
nsecs_t eventTime) {
#if DEBUG_TRANSPORT_ACTIONS
- LOGD("channel '%s' publisher ~ publishKeyEvent: deviceId=%d, nature=%d, "
+ LOGD("channel '%s' publisher ~ publishKeyEvent: deviceId=%d, source=%d, "
"action=%d, flags=%d, keyCode=%d, scanCode=%d, metaState=%d, repeatCount=%d,"
"downTime=%lld, eventTime=%lld",
mChannel->getName().string(),
- deviceId, nature, action, flags, keyCode, scanCode, metaState, repeatCount,
+ deviceId, source, action, flags, keyCode, scanCode, metaState, repeatCount,
downTime, eventTime);
#endif
- status_t result = publishInputEvent(INPUT_EVENT_TYPE_KEY, deviceId, nature);
+ status_t result = publishInputEvent(AINPUT_EVENT_TYPE_KEY, deviceId, source);
if (result < 0) {
return result;
}
@@ -344,7 +344,7 @@
status_t InputPublisher::publishMotionEvent(
int32_t deviceId,
- int32_t nature,
+ int32_t source,
int32_t action,
int32_t edgeFlags,
int32_t metaState,
@@ -358,12 +358,12 @@
const int32_t* pointerIds,
const PointerCoords* pointerCoords) {
#if DEBUG_TRANSPORT_ACTIONS
- LOGD("channel '%s' publisher ~ publishMotionEvent: deviceId=%d, nature=%d, "
+ LOGD("channel '%s' publisher ~ publishMotionEvent: deviceId=%d, source=%d, "
"action=%d, edgeFlags=%d, metaState=%d, xOffset=%f, yOffset=%f, "
"xPrecision=%f, yPrecision=%f, downTime=%lld, eventTime=%lld, "
"pointerCount=%d",
mChannel->getName().string(),
- deviceId, nature, action, edgeFlags, metaState, xOffset, yOffset,
+ deviceId, source, action, edgeFlags, metaState, xOffset, yOffset,
xPrecision, yPrecision, downTime, eventTime, pointerCount);
#endif
@@ -373,7 +373,7 @@
return BAD_VALUE;
}
- status_t result = publishInputEvent(INPUT_EVENT_TYPE_MOTION, deviceId, nature);
+ status_t result = publishInputEvent(AINPUT_EVENT_TYPE_MOTION, deviceId, source);
if (result < 0) {
return result;
}
@@ -399,7 +399,7 @@
// Cache essential information about the motion event to ensure that a malicious consumer
// cannot confuse the publisher by modifying the contents of the shared memory buffer while
// it is being updated.
- if (action == MOTION_EVENT_ACTION_MOVE) {
+ if (action == AMOTION_EVENT_ACTION_MOVE) {
mMotionEventPointerCount = pointerCount;
mMotionEventSampleDataStride = InputMessage::sampleDataStride(pointerCount);
mMotionEventSampleDataTail = InputMessage::sampleDataPtrIncrement(
@@ -420,7 +420,7 @@
if (! mPinned || ! mMotionEventSampleDataTail) {
LOGE("channel '%s' publisher ~ Cannot append motion sample because there is no current "
- "MOTION_EVENT_ACTION_MOVE event.", mChannel->getName().string());
+ "AMOTION_EVENT_ACTION_MOVE event.", mChannel->getName().string());
return INVALID_OPERATION;
}
@@ -588,7 +588,7 @@
mSharedMessage->consumed = true;
switch (mSharedMessage->type) {
- case INPUT_EVENT_TYPE_KEY: {
+ case AINPUT_EVENT_TYPE_KEY: {
KeyEvent* keyEvent = factory->createKeyEvent();
if (! keyEvent) return NO_MEMORY;
@@ -598,7 +598,7 @@
break;
}
- case INPUT_EVENT_TYPE_MOTION: {
+ case AINPUT_EVENT_TYPE_MOTION: {
MotionEvent* motionEvent = factory->createMotionEvent();
if (! motionEvent) return NO_MEMORY;
@@ -648,7 +648,7 @@
void InputConsumer::populateKeyEvent(KeyEvent* keyEvent) const {
keyEvent->initialize(
mSharedMessage->deviceId,
- mSharedMessage->nature,
+ mSharedMessage->source,
mSharedMessage->key.action,
mSharedMessage->key.flags,
mSharedMessage->key.keyCode,
@@ -662,7 +662,7 @@
void InputConsumer::populateMotionEvent(MotionEvent* motionEvent) const {
motionEvent->initialize(
mSharedMessage->deviceId,
- mSharedMessage->nature,
+ mSharedMessage->source,
mSharedMessage->motion.action,
mSharedMessage->motion.edgeFlags,
mSharedMessage->motion.metaState,
diff --git a/libs/ui/tests/InputPublisherAndConsumer_test.cpp b/libs/ui/tests/InputPublisherAndConsumer_test.cpp
index 55504f2..3bc21fa 100644
--- a/libs/ui/tests/InputPublisherAndConsumer_test.cpp
+++ b/libs/ui/tests/InputPublisherAndConsumer_test.cpp
@@ -73,17 +73,17 @@
status_t status;
const int32_t deviceId = 1;
- const int32_t nature = INPUT_EVENT_NATURE_KEY;
- const int32_t action = KEY_EVENT_ACTION_DOWN;
- const int32_t flags = KEY_EVENT_FLAG_FROM_SYSTEM;
+ const int32_t source = AINPUT_SOURCE_KEYBOARD;
+ const int32_t action = AKEY_EVENT_ACTION_DOWN;
+ const int32_t flags = AKEY_EVENT_FLAG_FROM_SYSTEM;
const int32_t keyCode = AKEYCODE_ENTER;
const int32_t scanCode = 13;
- const int32_t metaState = META_ALT_LEFT_ON | META_ALT_ON;
+ const int32_t metaState = AMETA_ALT_LEFT_ON | AMETA_ALT_ON;
const int32_t repeatCount = 1;
const nsecs_t downTime = 3;
const nsecs_t eventTime = 4;
- status = mPublisher->publishKeyEvent(deviceId, nature, action, flags,
+ status = mPublisher->publishKeyEvent(deviceId, source, action, flags,
keyCode, scanCode, metaState, repeatCount, downTime, eventTime);
ASSERT_EQ(OK, status)
<< "publisher publishKeyEvent should return OK";
@@ -103,12 +103,12 @@
ASSERT_TRUE(event != NULL)
<< "consumer should have returned non-NULL event";
- ASSERT_EQ(INPUT_EVENT_TYPE_KEY, event->getType())
+ ASSERT_EQ(AINPUT_EVENT_TYPE_KEY, event->getType())
<< "consumer should have returned a key event";
KeyEvent* keyEvent = static_cast<KeyEvent*>(event);
EXPECT_EQ(deviceId, keyEvent->getDeviceId());
- EXPECT_EQ(nature, keyEvent->getNature());
+ EXPECT_EQ(source, keyEvent->getSource());
EXPECT_EQ(action, keyEvent->getAction());
EXPECT_EQ(flags, keyEvent->getFlags());
EXPECT_EQ(keyCode, keyEvent->getKeyCode());
@@ -136,10 +136,10 @@
status_t status;
const int32_t deviceId = 1;
- const int32_t nature = INPUT_EVENT_NATURE_TOUCH;
- const int32_t action = MOTION_EVENT_ACTION_MOVE;
- const int32_t edgeFlags = MOTION_EVENT_EDGE_FLAG_TOP;
- const int32_t metaState = META_ALT_LEFT_ON | META_ALT_ON;
+ const int32_t source = AINPUT_SOURCE_TOUCHSCREEN;
+ const int32_t action = AMOTION_EVENT_ACTION_MOVE;
+ const int32_t edgeFlags = AMOTION_EVENT_EDGE_FLAG_TOP;
+ const int32_t metaState = AMETA_ALT_LEFT_ON | AMETA_ALT_ON;
const float xOffset = -10;
const float yOffset = -20;
const float xPrecision = 0.25;
@@ -159,10 +159,15 @@
samplePointerCoords.editTop().y = 200 * i + j;
samplePointerCoords.editTop().pressure = 0.5 * i + j;
samplePointerCoords.editTop().size = 0.7 * i + j;
+ samplePointerCoords.editTop().touchMajor = 1.5 * i + j;
+ samplePointerCoords.editTop().touchMinor = 1.7 * i + j;
+ samplePointerCoords.editTop().toolMajor = 2.5 * i + j;
+ samplePointerCoords.editTop().toolMinor = 2.7 * i + j;
+ samplePointerCoords.editTop().orientation = 3.5 * i + j;
}
}
- status = mPublisher->publishMotionEvent(deviceId, nature, action, edgeFlags,
+ status = mPublisher->publishMotionEvent(deviceId, source, action, edgeFlags,
metaState, xOffset, yOffset, xPrecision, yPrecision,
downTime, sampleEventTimes[0], pointerCount, pointerIds, samplePointerCoords.array());
ASSERT_EQ(OK, status)
@@ -199,14 +204,14 @@
ASSERT_TRUE(event != NULL)
<< "consumer should have returned non-NULL event";
- ASSERT_EQ(INPUT_EVENT_TYPE_MOTION, event->getType())
+ ASSERT_EQ(AINPUT_EVENT_TYPE_MOTION, event->getType())
<< "consumer should have returned a motion event";
size_t lastSampleIndex = samplesToAppendBeforeDispatch + samplesToAppendAfterDispatch;
MotionEvent* motionEvent = static_cast<MotionEvent*>(event);
EXPECT_EQ(deviceId, motionEvent->getDeviceId());
- EXPECT_EQ(nature, motionEvent->getNature());
+ EXPECT_EQ(source, motionEvent->getSource());
EXPECT_EQ(action, motionEvent->getAction());
EXPECT_EQ(edgeFlags, motionEvent->getEdgeFlags());
EXPECT_EQ(metaState, motionEvent->getMetaState());
@@ -241,6 +246,16 @@
motionEvent->getHistoricalPressure(i, sampleIndex));
EXPECT_EQ(samplePointerCoords[offset].size,
motionEvent->getHistoricalSize(i, sampleIndex));
+ EXPECT_EQ(samplePointerCoords[offset].touchMajor,
+ motionEvent->getHistoricalTouchMajor(i, sampleIndex));
+ EXPECT_EQ(samplePointerCoords[offset].touchMinor,
+ motionEvent->getHistoricalTouchMinor(i, sampleIndex));
+ EXPECT_EQ(samplePointerCoords[offset].toolMajor,
+ motionEvent->getHistoricalToolMajor(i, sampleIndex));
+ EXPECT_EQ(samplePointerCoords[offset].toolMinor,
+ motionEvent->getHistoricalToolMinor(i, sampleIndex));
+ EXPECT_EQ(samplePointerCoords[offset].orientation,
+ motionEvent->getHistoricalOrientation(i, sampleIndex));
}
}
@@ -255,6 +270,11 @@
EXPECT_EQ(samplePointerCoords[offset].y + yOffset, motionEvent->getY(i));
EXPECT_EQ(samplePointerCoords[offset].pressure, motionEvent->getPressure(i));
EXPECT_EQ(samplePointerCoords[offset].size, motionEvent->getSize(i));
+ EXPECT_EQ(samplePointerCoords[offset].touchMajor, motionEvent->getTouchMajor(i));
+ EXPECT_EQ(samplePointerCoords[offset].touchMinor, motionEvent->getTouchMinor(i));
+ EXPECT_EQ(samplePointerCoords[offset].toolMajor, motionEvent->getToolMajor(i));
+ EXPECT_EQ(samplePointerCoords[offset].toolMinor, motionEvent->getToolMinor(i));
+ EXPECT_EQ(samplePointerCoords[offset].orientation, motionEvent->getOrientation(i));
}
status = mConsumer->sendFinishedSignal();
@@ -300,7 +320,7 @@
const size_t pointerCount = 1;
int32_t pointerIds[pointerCount] = { 0 };
- PointerCoords pointerCoords[pointerCount] = { { 0, 0, 0, 0 } };
+ PointerCoords pointerCoords[pointerCount] = { { 0, 0, 0, 0, 0, 0, 0, 0, 0 } };
status = mPublisher->publishMotionEvent(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
pointerCount, pointerIds, pointerCoords);
@@ -381,7 +401,7 @@
int32_t pointerIds[pointerCount];
PointerCoords pointerCoords[pointerCount];
- status = mPublisher->publishMotionEvent(0, 0, MOTION_EVENT_ACTION_DOWN,
+ status = mPublisher->publishMotionEvent(0, 0, AMOTION_EVENT_ACTION_DOWN,
0, 0, 0, 0, 0, 0, 0, 0, pointerCount, pointerIds, pointerCoords);
ASSERT_EQ(OK, status);
@@ -398,7 +418,7 @@
int32_t pointerIds[pointerCount];
PointerCoords pointerCoords[pointerCount];
- status = mPublisher->publishMotionEvent(0, 0, MOTION_EVENT_ACTION_MOVE,
+ status = mPublisher->publishMotionEvent(0, 0, AMOTION_EVENT_ACTION_MOVE,
0, 0, 0, 0, 0, 0, 0, 0, pointerCount, pointerIds, pointerCoords);
ASSERT_EQ(OK, status);
@@ -425,7 +445,7 @@
int32_t pointerIds[pointerCount];
PointerCoords pointerCoords[pointerCount];
- status = mPublisher->publishMotionEvent(0, 0, MOTION_EVENT_ACTION_MOVE,
+ status = mPublisher->publishMotionEvent(0, 0, AMOTION_EVENT_ACTION_MOVE,
0, 0, 0, 0, 0, 0, 0, 0, pointerCount, pointerIds, pointerCoords);
ASSERT_EQ(OK, status);
diff --git a/libs/utils/String8.cpp b/libs/utils/String8.cpp
index 82776f4..1c4f80c 100644
--- a/libs/utils/String8.cpp
+++ b/libs/utils/String8.cpp
@@ -372,6 +372,27 @@
return real_append(other, otherLen);
}
+status_t String8::appendFormat(const char* fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+
+ int result = NO_ERROR;
+ int n = vsnprintf(NULL, 0, fmt, ap);
+ if (n != 0) {
+ size_t oldLength = length();
+ char* buf = lockBuffer(oldLength + n);
+ if (buf) {
+ vsnprintf(buf + oldLength, n + 1, fmt, ap);
+ } else {
+ result = NO_MEMORY;
+ }
+ }
+
+ va_end(ap);
+ return result;
+}
+
status_t String8::real_append(const char* other, size_t otherLen)
{
const size_t myLen = bytes();
@@ -411,15 +432,16 @@
if (size != this->size()) {
SharedBuffer* buf = SharedBuffer::bufferFromData(mString)
->editResize(size+1);
- if (buf) {
- char* str = (char*)buf->data();
- str[size] = 0;
- mString = str;
- return NO_ERROR;
+ if (! buf) {
+ return NO_MEMORY;
}
+
+ char* str = (char*)buf->data();
+ str[size] = 0;
+ mString = str;
}
-
- return NO_MEMORY;
+
+ return NO_ERROR;
}
ssize_t String8::find(const char* other, size_t start) const
diff --git a/location/java/android/location/LocationManager.java b/location/java/android/location/LocationManager.java
index 7d07e4b..9ceda7e 100644
--- a/location/java/android/location/LocationManager.java
+++ b/location/java/android/location/LocationManager.java
@@ -424,8 +424,7 @@
* {@link LocationListener#onLocationChanged} method will be called for
* each location update
*
- * @throws IllegalArgumentException if provider is null or doesn't exist
- * @throws IllegalArgumentException if listener is null
+ * @throws IllegalArgumentException if provider or listener is null
* @throws RuntimeException if the calling thread has no Looper
* @throws SecurityException if no suitable permission is present for the provider.
*/
@@ -977,7 +976,7 @@
* @return true if the provider is enabled
*
* @throws SecurityException if no suitable permission is present for the provider.
- * @throws IllegalArgumentException if provider is null or doesn't exist
+ * @throws IllegalArgumentException if provider is null
*/
public boolean isProviderEnabled(String provider) {
if (provider == null) {
diff --git a/media/libeffects/Android.mk b/media/libeffects/Android.mk
deleted file mode 100644
index fc4ceb6..0000000
--- a/media/libeffects/Android.mk
+++ /dev/null
@@ -1,127 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-#
-TEST_EFFECT_LIBRARIES := true
-
-# Effect factory library
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- EffectsFactory.c
-
-LOCAL_SHARED_LIBRARIES := \
- libcutils
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)
-LOCAL_MODULE:= libeffects
-
-ifeq ($(TARGET_OS)-$(TARGET_SIMULATOR),linux-true)
-LOCAL_LDLIBS += -ldl
-endif
-
-ifneq ($(TARGET_SIMULATOR),true)
-LOCAL_SHARED_LIBRARIES += libdl
-endif
-
-LOCAL_C_INCLUDES := \
-
-include $(BUILD_SHARED_LIBRARY)
-
-
-ifeq ($(TEST_EFFECT_LIBRARIES),true)
-# Test Reverb library
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- EffectReverb.c.arm \
- EffectsMath.c.arm
-LOCAL_CFLAGS+= -O2
-
-LOCAL_SHARED_LIBRARIES := \
- libcutils
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/soundfx
-LOCAL_MODULE:= libreverb
-
-ifeq ($(TARGET_OS)-$(TARGET_SIMULATOR),linux-true)
-LOCAL_LDLIBS += -ldl
-endif
-
-ifneq ($(TARGET_SIMULATOR),true)
-LOCAL_SHARED_LIBRARIES += libdl
-endif
-
-LOCAL_C_INCLUDES := \
- $(call include-path-for, graphics corecg)
-
-LOCAL_PRELINK_MODULE := false
-
-include $(BUILD_SHARED_LIBRARY)
-
-# Test Equalizer library
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- EffectsMath.c.arm \
- EffectEqualizer.cpp \
- AudioBiquadFilter.cpp.arm \
- AudioCoefInterpolator.cpp.arm \
- AudioPeakingFilter.cpp.arm \
- AudioShelvingFilter.cpp.arm \
- AudioEqualizer.cpp.arm
-
-LOCAL_CFLAGS+= -O2
-
-LOCAL_SHARED_LIBRARIES := \
- libcutils
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/soundfx
-LOCAL_MODULE:= libequalizer
-
-ifeq ($(TARGET_OS)-$(TARGET_SIMULATOR),linux-true)
-LOCAL_LDLIBS += -ldl
-endif
-
-ifneq ($(TARGET_SIMULATOR),true)
-LOCAL_SHARED_LIBRARIES += libdl
-endif
-
-LOCAL_C_INCLUDES := \
- $(call include-path-for, graphics corecg) \
- system/media/opensles/include
-
-LOCAL_PRELINK_MODULE := false
-
-include $(BUILD_SHARED_LIBRARY)
-
-endif
-
-
-# Visualizer library
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- EffectVisualizer.cpp
-
-LOCAL_CFLAGS+= -O2
-
-LOCAL_SHARED_LIBRARIES := \
- libcutils
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/soundfx
-LOCAL_MODULE:= libvisualizer
-
-ifeq ($(TARGET_OS)-$(TARGET_SIMULATOR),linux-true)
-LOCAL_LDLIBS += -ldl
-endif
-
-ifneq ($(TARGET_SIMULATOR),true)
-LOCAL_SHARED_LIBRARIES += libdl
-endif
-
-LOCAL_C_INCLUDES := \
- $(call include-path-for, graphics corecg)
-
-LOCAL_PRELINK_MODULE := false
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/media/libeffects/factory/Android.mk b/media/libeffects/factory/Android.mk
new file mode 100644
index 0000000..20f58e5
--- /dev/null
+++ b/media/libeffects/factory/Android.mk
@@ -0,0 +1,25 @@
+LOCAL_PATH:= $(call my-dir)
+
+# Effect factory library
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= \
+ EffectsFactory.c
+
+LOCAL_SHARED_LIBRARIES := \
+ libcutils
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)
+LOCAL_MODULE:= libeffects
+
+ifeq ($(TARGET_OS)-$(TARGET_SIMULATOR),linux-true)
+LOCAL_LDLIBS += -ldl
+endif
+
+ifneq ($(TARGET_SIMULATOR),true)
+LOCAL_SHARED_LIBRARIES += libdl
+endif
+
+LOCAL_C_INCLUDES := \
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/media/libeffects/EffectsFactory.c b/media/libeffects/factory/EffectsFactory.c
similarity index 99%
rename from media/libeffects/EffectsFactory.c
rename to media/libeffects/factory/EffectsFactory.c
index edd6184..0be280c 100644
--- a/media/libeffects/EffectsFactory.c
+++ b/media/libeffects/factory/EffectsFactory.c
@@ -31,7 +31,7 @@
static list_elem_t *gCurEffect; // current effect in enumeration process
static uint32_t gCurEffectIdx; // current effect index in enumeration process
-static const char * const gEffectLibPath = "/system/lib/soundfx"; // path to built-in effect libraries
+const char * const gEffectLibPath = "/system/lib/soundfx"; // path to built-in effect libraries
static int gInitDone; // true is global initialization has been preformed
static int gNextLibId; // used by loadLibrary() to allocate unique library handles
static int gCanQueryEffect; // indicates that call to EffectQueryEffect() is valid, i.e. that the list of effects
diff --git a/media/libeffects/EffectsFactory.h b/media/libeffects/factory/EffectsFactory.h
similarity index 100%
rename from media/libeffects/EffectsFactory.h
rename to media/libeffects/factory/EffectsFactory.h
diff --git a/media/libeffects/lvm/lib/Android.mk b/media/libeffects/lvm/lib/Android.mk
new file mode 100644
index 0000000..a944212
--- /dev/null
+++ b/media/libeffects/lvm/lib/Android.mk
@@ -0,0 +1,124 @@
+LOCAL_PATH:= $(call my-dir)
+
+# Music bundle
+
+include $(CLEAR_VARS)
+
+LOCAL_ARM_MODE := arm
+
+LOCAL_SRC_FILES:= \
+ StereoWidening/src/LVCS_BypassMix.c \
+ StereoWidening/src/LVCS_Control.c \
+ StereoWidening/src/LVCS_Equaliser.c \
+ StereoWidening/src/LVCS_Init.c \
+ StereoWidening/src/LVCS_Process.c \
+ StereoWidening/src/LVCS_ReverbGenerator.c \
+ StereoWidening/src/LVCS_StereoEnhancer.c \
+ StereoWidening/src/LVCS_Tables.c \
+ Bass/src/LVDBE_Control.c \
+ Bass/src/LVDBE_Init.c \
+ Bass/src/LVDBE_Process.c \
+ Bass/src/LVDBE_Tables.c \
+ Bundle/src/LVM_API_Specials.c \
+ Bundle/src/LVM_Buffers.c \
+ Bundle/src/LVM_Init.c \
+ Bundle/src/LVM_Process.c \
+ Bundle/src/LVM_Tables.c \
+ Bundle/src/LVM_Control.c \
+ SpectrumAnalyzer/src/LVPSA_Control.c \
+ SpectrumAnalyzer/src/LVPSA_Init.c \
+ SpectrumAnalyzer/src/LVPSA_Memory.c \
+ SpectrumAnalyzer/src/LVPSA_Process.c \
+ SpectrumAnalyzer/src/LVPSA_QPD_Init.c \
+ SpectrumAnalyzer/src/LVPSA_QPD_Process.c \
+ SpectrumAnalyzer/src/LVPSA_Tables.c \
+ Eq/src/LVEQNB_CalcCoef.c \
+ Eq/src/LVEQNB_Control.c \
+ Eq/src/LVEQNB_Init.c \
+ Eq/src/LVEQNB_Process.c \
+ Eq/src/LVEQNB_Tables.c \
+ Common/src/InstAlloc.c \
+ Common/src/DC_2I_D16_TRC_WRA_01.c \
+ Common/src/DC_2I_D16_TRC_WRA_01_Init.c \
+ Common/src/FO_2I_D16F32C15_LShx_TRC_WRA_01.c \
+ Common/src/FO_2I_D16F32Css_LShx_TRC_WRA_01_Init.c \
+ Common/src/FO_1I_D16F16C15_TRC_WRA_01.c \
+ Common/src/FO_1I_D16F16Css_TRC_WRA_01_Init.c \
+ Common/src/BP_1I_D16F32C30_TRC_WRA_01.c \
+ Common/src/BP_1I_D16F16C14_TRC_WRA_01.c \
+ Common/src/BP_1I_D32F32C30_TRC_WRA_02.c \
+ Common/src/BP_1I_D16F16Css_TRC_WRA_01_Init.c \
+ Common/src/BP_1I_D16F32Cll_TRC_WRA_01_Init.c \
+ Common/src/BP_1I_D32F32Cll_TRC_WRA_02_Init.c \
+ Common/src/BQ_2I_D32F32Cll_TRC_WRA_01_Init.c \
+ Common/src/BQ_2I_D32F32C30_TRC_WRA_01.c \
+ Common/src/BQ_2I_D16F32C15_TRC_WRA_01.c \
+ Common/src/BQ_2I_D16F32C14_TRC_WRA_01.c \
+ Common/src/BQ_2I_D16F32C13_TRC_WRA_01.c \
+ Common/src/BQ_2I_D16F32Css_TRC_WRA_01_init.c \
+ Common/src/BQ_2I_D16F16C15_TRC_WRA_01.c \
+ Common/src/BQ_2I_D16F16C14_TRC_WRA_01.c \
+ Common/src/BQ_2I_D16F16Css_TRC_WRA_01_Init.c \
+ Common/src/BQ_1I_D16F16C15_TRC_WRA_01.c \
+ Common/src/BQ_1I_D16F16Css_TRC_WRA_01_Init.c \
+ Common/src/BQ_1I_D16F32C14_TRC_WRA_01.c \
+ Common/src/BQ_1I_D16F32Css_TRC_WRA_01_init.c \
+ Common/src/PK_2I_D32F32C30G11_TRC_WRA_01.c \
+ Common/src/PK_2I_D32F32C14G11_TRC_WRA_01.c \
+ Common/src/PK_2I_D32F32CssGss_TRC_WRA_01_Init.c \
+ Common/src/PK_2I_D32F32CllGss_TRC_WRA_01_Init.c \
+ Common/src/Int16LShiftToInt32_16x32.c \
+ Common/src/From2iToMono_16.c \
+ Common/src/Copy_16.c \
+ Common/src/MonoTo2I_16.c \
+ Common/src/LoadConst_16.c \
+ Common/src/dB_to_Lin32.c \
+ Common/src/Shift_Sat_v16xv16.c \
+ Common/src/Abs_32.c \
+ Common/src/Int32RShiftToInt16_Sat_32x16.c \
+ Common/src/From2iToMono_32.c \
+ Common/src/mult3s_16x16.c \
+ Common/src/NonLinComp_D16.c \
+ Common/src/DelayMix_16x16.c \
+ Common/src/MSTo2i_Sat_16x16.c \
+ Common/src/From2iToMS_16x16.c \
+ Common/src/Mac3s_Sat_16x16.c \
+ Common/src/Add2_Sat_16x16.c \
+ Common/src/LVC_MixSoft_1St_2i_D16C31_SAT.c \
+ Common/src/LVC_MixSoft_1St_D16C31_SAT.c \
+ Common/src/LVC_Mixer_VarSlope_SetTimeConstant.c \
+ Common/src/LVC_Mixer_SetTimeConstant.c \
+ Common/src/LVC_Mixer_SetTarget.c \
+ Common/src/LVC_Mixer_GetTarget.c \
+ Common/src/LVC_Mixer_Init.c \
+ Common/src/LVC_Core_MixHard_1St_2i_D16C31_SAT.c \
+ Common/src/LVC_Core_MixSoft_1St_2i_D16C31_WRA.c \
+ Common/src/LVC_Core_MixInSoft_D16C31_SAT.c \
+ Common/src/LVC_Mixer_GetCurrent.c \
+ Common/src/LVC_MixSoft_2St_D16C31_SAT.c \
+ Common/src/LVC_Core_MixSoft_1St_D16C31_WRA.c \
+ Common/src/LVC_Core_MixHard_2St_D16C31_SAT.c \
+ Common/src/LVC_MixInSoft_D16C31_SAT.c \
+ Common/src/AGC_MIX_VOL_2St1Mon_D32_WRA.c \
+ Common/src/LVM_Timer.c \
+ Common/src/LVM_Timer_Init.c
+
+LOCAL_MODULE:= libmusicbundle
+
+LOCAL_PRELINK_MODULE := false
+
+LOCAL_C_INCLUDES += \
+ $(LOCAL_PATH)/Eq/lib \
+ $(LOCAL_PATH)/Eq/src \
+ $(LOCAL_PATH)/Bass/lib \
+ $(LOCAL_PATH)/Bass/src \
+ $(LOCAL_PATH)/Common/lib \
+ $(LOCAL_PATH)/Common/src \
+ $(LOCAL_PATH)/Bundle/lib \
+ $(LOCAL_PATH)/Bundle/src \
+ $(LOCAL_PATH)/SpectrumAnalyzer/lib \
+ $(LOCAL_PATH)/SpectrumAnalyzer/src \
+ $(LOCAL_PATH)/StereoWidening/src \
+ $(LOCAL_PATH)/StereoWidening/lib
+
+include $(BUILD_STATIC_LIBRARY)
diff --git a/media/libeffects/lvm/lib/Bass/lib/LVDBE.h b/media/libeffects/lvm/lib/Bass/lib/LVDBE.h
new file mode 100755
index 0000000..48731df
--- /dev/null
+++ b/media/libeffects/lvm/lib/Bass/lib/LVDBE.h
@@ -0,0 +1,472 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/****************************************************************************************
+
+ $Author: nxp007753 $
+ $Revision: 1081 $
+ $Date: 2010-07-05 11:48:44 +0200 (Mon, 05 Jul 2010) $
+
+*****************************************************************************************/
+
+/****************************************************************************************/
+/* */
+/* Header file for the application layer interface of Dynamic Bass Enhancement */
+/* module. */
+/* */
+/* This files includes all definitions, types, structures and function */
+/* prototypes required by the calling layer. All other types, structures and */
+/* functions are private. */
+/* */
+/****************************************************************************************/
+/* */
+/* Note: 1 */
+/* ======= */
+/* The algorithm can execute either with separate input and output buffers or with */
+/* a common buffer, i.e. the data is processed in-place. */
+/* */
+/****************************************************************************************/
+/* */
+/* Note: 2 */
+/* ======= */
+/* The Dynamic Bass Enhancement algorithm always processes data as stereo input. Mono*/
+/* format data is not supported. The data is interleaved as follows: */
+/* */
+/* Byte Offset Stereo Input Mono-In-Stereo Input */
+/* =========== ============ ==================== */
+/* 0 Left Sample #1 Mono Sample #1 */
+/* 2 Right Sample #1 Mono Sample #1 */
+/* 4 Left Sample #2 Mono Sample #2 */
+/* 6 Right Sample #2 Mono Sample #2 */
+/* . . . */
+/* . . . */
+/* */
+/* Mono format data is not supported, the calling routine must convert a Mono stream */
+/* in to Mono-In-Stereo format. */
+/* */
+/****************************************************************************************/
+
+#ifndef __LVDBE_H__
+#define __LVDBE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/****************************************************************************************/
+/* */
+/* Includes */
+/* */
+/****************************************************************************************/
+
+#include "LVM_Types.h"
+
+
+/****************************************************************************************/
+/* */
+/* Definitions */
+/* */
+/****************************************************************************************/
+
+/* Memory table*/
+#define LVDBE_NR_MEMORY_REGIONS 4 /* Number of memory regions */
+
+/* Bass Enhancement effect level */
+#define LVDBE_EFFECT_03DB 3 /* Effect defines for backwards compatibility */
+#define LVDBE_EFFECT_06DB 6
+#define LVDBE_EFFECT_09DB 9
+#define LVDBE_EFFECT_12DB 12
+#define LVDBE_EFFECT_15DB 15
+
+
+/****************************************************************************************/
+/* */
+/* Types */
+/* */
+/****************************************************************************************/
+
+/* Instance handle */
+typedef void *LVDBE_Handle_t;
+
+
+/* Operating modes */
+typedef enum
+{
+ LVDBE_OFF = 0,
+ LVDBE_ON = 1,
+ LVDBE_MODE_MAX = LVM_MAXINT_32
+} LVDBE_Mode_en;
+
+
+/* High pass filter */
+typedef enum
+{
+ LVDBE_HPF_OFF = 0,
+ LVDBE_HPF_ON = 1,
+ LVDBE_HPF_MAX = LVM_MAXINT_32
+} LVDBE_FilterSelect_en;
+
+
+/* Volume control */
+typedef enum
+{
+ LVDBE_VOLUME_OFF = 0,
+ LVDBE_VOLUME_ON = 1,
+ LVDBE_VOLUME_MAX = LVM_MAXINT_32
+} LVDBE_Volume_en;
+
+
+/* Memory Types */
+typedef enum
+{
+ LVDBE_PERSISTENT = 0,
+ LVDBE_PERSISTENT_DATA = 1,
+ LVDBE_PERSISTENT_COEF = 2,
+ LVDBE_SCRATCH = 3,
+ LVDBE_MEMORY_MAX = LVM_MAXINT_32
+
+} LVDBE_MemoryTypes_en;
+
+
+/* Function return status */
+typedef enum
+{
+ LVDBE_SUCCESS = 0, /* Successful return from a routine */
+ LVDBE_ALIGNMENTERROR = 1, /* Memory alignment error */
+ LVDBE_NULLADDRESS = 2, /* NULL allocation address */
+ LVDBE_TOOMANYSAMPLES = 3, /* Maximum block size exceeded */
+ LVDBE_SIZEERROR = 4, /* Incorrect structure size */
+ LVDBE_STATUS_MAX = LVM_MAXINT_32
+} LVDBE_ReturnStatus_en;
+
+
+/****************************************************************************************/
+/* */
+/* Linked enumerated type and capability definitions */
+/* */
+/* The capability definitions are used to define the required capabilities at */
+/* initialisation, these are added together to give the capability word. The */
+/* enumerated type is used to select the mode through a control function at run time. */
+/* */
+/* The capability definition is related to the enumerated type value by the equation: */
+/* */
+/* Capability_value = 2^Enumerated_value */
+/* */
+/* For example, a module could be configurd at initialisation to support two sample */
+/* rates only by calling the init function with the value: */
+/* Capabilities.SampleRate = LVDBE_CAP_32000 + LVCS_DBE_44100; */
+/* */
+/* and at run time it would be passed the value LVDBE_FS_32000 through the control */
+/* function to select operation at 32kHz */
+/* */
+/****************************************************************************************/
+
+/*
+ * Bass Enhancement centre frequency
+ */
+#define LVDBE_CAP_CENTRE_55Hz 1
+#define LVDBE_CAP_CENTRE_66Hz 2
+#define LVDBE_CAP_CENTRE_78Hz 4
+#define LVDBE_CAP_CENTRE_90Hz 8
+
+typedef enum
+{
+ LVDBE_CENTRE_55HZ = 0,
+ LVDBE_CENTRE_66HZ = 1,
+ LVDBE_CENTRE_78HZ = 2,
+ LVDBE_CENTRE_90HZ = 3,
+ LVDBE_CENTRE_MAX = LVM_MAXINT_32
+} LVDBE_CentreFreq_en;
+
+
+/*
+ * Supported sample rates in samples per second
+ */
+#define LVDBE_CAP_FS_8000 1
+#define LVDBE_CAP_FS_11025 2
+#define LVDBE_CAP_FS_12000 4
+#define LVDBE_CAP_FS_16000 8
+#define LVDBE_CAP_FS_22050 16
+#define LVDBE_CAP_FS_24000 32
+#define LVDBE_CAP_FS_32000 64
+#define LVDBE_CAP_FS_44100 128
+#define LVDBE_CAP_FS_48000 256
+
+typedef enum
+{
+ LVDBE_FS_8000 = 0,
+ LVDBE_FS_11025 = 1,
+ LVDBE_FS_12000 = 2,
+ LVDBE_FS_16000 = 3,
+ LVDBE_FS_22050 = 4,
+ LVDBE_FS_24000 = 5,
+ LVDBE_FS_32000 = 6,
+ LVDBE_FS_44100 = 7,
+ LVDBE_FS_48000 = 8,
+ LVDBE_FS_MAX = LVM_MAXINT_32
+} LVDBE_Fs_en;
+
+
+/****************************************************************************************/
+/* */
+/* Structures */
+/* */
+/****************************************************************************************/
+
+/* Memory region definition */
+typedef struct
+{
+ LVM_UINT32 Size; /* Region size in bytes */
+ LVM_UINT16 Alignment; /* Region alignment in bytes */
+ LVDBE_MemoryTypes_en Type; /* Region type */
+ void *pBaseAddress; /* Pointer to the region base address */
+} LVDBE_MemoryRegion_t;
+
+
+/* Memory table containing the region definitions */
+typedef struct
+{
+ LVDBE_MemoryRegion_t Region[LVDBE_NR_MEMORY_REGIONS]; /* One definition for each region */
+} LVDBE_MemTab_t;
+
+
+/* Parameter structure */
+typedef struct
+{
+ LVDBE_Mode_en OperatingMode;
+ LVDBE_Fs_en SampleRate;
+ LVM_INT16 EffectLevel;
+ LVDBE_CentreFreq_en CentreFrequency;
+ LVDBE_FilterSelect_en HPFSelect;
+ LVDBE_Volume_en VolumeControl;
+ LVM_INT16 VolumedB;
+ LVM_INT16 HeadroomdB;
+
+} LVDBE_Params_t;
+
+
+/* Capability structure */
+typedef struct
+{
+ LVM_UINT16 SampleRate; /* Sampling rate capabilities */
+ LVM_UINT16 CentreFrequency; /* Centre frequency capabilities */
+ LVM_UINT16 MaxBlockSize; /* Maximum block size in sample pairs */
+} LVDBE_Capabilities_t;
+
+
+/****************************************************************************************/
+/* */
+/* Function Prototypes */
+/* */
+/****************************************************************************************/
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVDBE_Memory */
+/* */
+/* DESCRIPTION: */
+/* This function is used for memory allocation and free. It can be called in */
+/* two ways: */
+/* */
+/* hInstance = NULL Returns the memory requirements */
+/* hInstance = Instance handle Returns the memory requirements and */
+/* allocated base addresses for the instance */
+/* */
+/* When this function is called for memory allocation (hInstance=NULL) the memory */
+/* base address pointers are NULL on return. */
+/* */
+/* When the function is called for free (hInstance = Instance Handle) the memory */
+/* table returns the allocated memory and base addresses used during initialisation. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance Handle */
+/* pMemoryTable Pointer to an empty memory definition table */
+/* pCapabilities Pointer to the default capabilites */
+/* */
+/* RETURNS: */
+/* LVDBE_SUCCESS Succeeded */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVDBE_Process function */
+/* */
+/****************************************************************************************/
+
+LVDBE_ReturnStatus_en LVDBE_Memory(LVDBE_Handle_t hInstance,
+ LVDBE_MemTab_t *pMemoryTable,
+ LVDBE_Capabilities_t *pCapabilities);
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVDBE_Init */
+/* */
+/* DESCRIPTION: */
+/* Create and initialisation function for the Bass Enhancement module */
+/* */
+/* This function can be used to create an algorithm instance by calling with */
+/* hInstance set to NULL. In this case the algorithm returns the new instance */
+/* handle. */
+/* */
+/* This function can be used to force a full re-initialisation of the algorithm */
+/* by calling with hInstance = Instance Handle. In this case the memory table */
+/* should be correct for the instance, this can be ensured by calling the function */
+/* LVDBE_Memory before calling this function. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* pMemoryTable Pointer to the memory definition table */
+/* pCapabilities Pointer to the initialisation capabilities */
+/* */
+/* RETURNS: */
+/* LVDBE_SUCCESS Initialisation succeeded */
+/* LVDBE_ALIGNMENTERROR Instance or scratch memory on incorrect alignment */
+/* LVDBE_NULLADDRESS One or more memory has a NULL pointer */
+/* */
+/* NOTES: */
+/* 1. The instance handle is the pointer to the base address of the first memory */
+/* region. */
+/* 2. This function must not be interrupted by the LVDBE_Process function */
+/* */
+/****************************************************************************************/
+
+LVDBE_ReturnStatus_en LVDBE_Init(LVDBE_Handle_t *phInstance,
+ LVDBE_MemTab_t *pMemoryTable,
+ LVDBE_Capabilities_t *pCapabilities);
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVDBE_GetParameters */
+/* */
+/* DESCRIPTION: */
+/* Request the Bass Enhancement parameters. The current parameter set is returned */
+/* via the parameter pointer. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* pParams Pointer to an empty parameter structure */
+/* */
+/* RETURNS: */
+/* LVDBE_SUCCESS Always succeeds */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVDBE_Process function */
+/* */
+/****************************************************************************************/
+
+LVDBE_ReturnStatus_en LVDBE_GetParameters(LVDBE_Handle_t hInstance,
+ LVDBE_Params_t *pParams);
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVDBE_GetCapabilities */
+/* */
+/* DESCRIPTION: */
+/* Request the Dynamic Bass Enhancement capabilities. The initial capabilities are */
+/* returned via the pointer. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* pCapabilities Pointer to an empty capabilitiy structure */
+/* */
+/* RETURNS: */
+/* LVDBE_Success Always succeeds */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVDBE_Process function */
+/* */
+/****************************************************************************************/
+
+LVDBE_ReturnStatus_en LVDBE_GetCapabilities(LVDBE_Handle_t hInstance,
+ LVDBE_Capabilities_t *pCapabilities);
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVDBE_Control */
+/* */
+/* DESCRIPTION: */
+/* Sets or changes the Bass Enhancement parameters. Changing the parameters while the */
+/* module is processing signals may have the following side effects: */
+/* */
+/* General parameters: */
+/* =================== */
+/* OperatingMode: Changing the mode of operation may cause a change in volume */
+/* level. */
+/* */
+/* SampleRate: Changing the sample rate may cause pops and clicks. */
+/* */
+/* EffectLevel: Changing the effect level setting will have no side effects */
+/* */
+/* CentreFrequency: Changing the centre frequency may cause pops and clicks */
+/* */
+/* HPFSelect: Selecting/de-selecting the high pass filter may cause pops and */
+/* clicks */
+/* */
+/* VolumedB Changing the volume setting will have no side effects */
+/* */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* pParams Pointer to a parameter structure */
+/* */
+/* RETURNS: */
+/* LVDBE_SUCCESS Always succeeds */
+/* */
+/* NOTES: */
+/* 1. This function must not be interrupted by the LVDBE_Process function */
+/* */
+/****************************************************************************************/
+
+LVDBE_ReturnStatus_en LVDBE_Control(LVDBE_Handle_t hInstance,
+ LVDBE_Params_t *pParams);
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVDBE_Process */
+/* */
+/* DESCRIPTION: */
+/* Process function for the Bass Enhancement module. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* pInData Pointer to the input data */
+/* pOutData Pointer to the output data */
+/* NumSamples Number of samples in the input buffer */
+/* */
+/* RETURNS: */
+/* LVDBE_SUCCESS Succeeded */
+/* LVDBE_TOOMANYSAMPLES NumSamples was larger than the maximum block size */
+/* */
+/* NOTES: */
+/* */
+/****************************************************************************************/
+
+LVDBE_ReturnStatus_en LVDBE_Process(LVDBE_Handle_t hInstance,
+ const LVM_INT16 *pInData,
+ LVM_INT16 *pOutData,
+ LVM_UINT16 NumSamples);
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __LVDBE_H__ */
diff --git a/media/libeffects/lvm/lib/Bass/src/LVDBE_Coeffs.h b/media/libeffects/lvm/lib/Bass/src/LVDBE_Coeffs.h
new file mode 100755
index 0000000..94a7869
--- /dev/null
+++ b/media/libeffects/lvm/lib/Bass/src/LVDBE_Coeffs.h
@@ -0,0 +1,518 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef __LVDBE_COEFFS_H__
+#define __LVDBE_COEFFS_H__
+
+
+/************************************************************************************/
+/* */
+/* General */
+/* */
+/************************************************************************************/
+
+#define LVDBE_SCALESHIFT 10 /* As a power of 2 */
+
+
+/************************************************************************************/
+/* */
+/* High Pass Filter coefficients */
+/* */
+/************************************************************************************/
+
+ /* Coefficients for centre frequency 55Hz */
+#define HPF_Fs8000_Fc55_A0 1029556328 /* Floating point value 0.958849 */
+#define HPF_Fs8000_Fc55_A1 -2059112655 /* Floating point value -1.917698 */
+#define HPF_Fs8000_Fc55_A2 1029556328 /* Floating point value 0.958849 */
+#define HPF_Fs8000_Fc55_B1 -2081986375 /* Floating point value -1.939001 */
+#define HPF_Fs8000_Fc55_B2 1010183914 /* Floating point value 0.940807 */
+#define HPF_Fs11025_Fc55_A0 1038210831 /* Floating point value 0.966909 */
+#define HPF_Fs11025_Fc55_A1 -2076421662 /* Floating point value -1.933818 */
+#define HPF_Fs11025_Fc55_A2 1038210831 /* Floating point value 0.966909 */
+#define HPF_Fs11025_Fc55_B1 -2099950710 /* Floating point value -1.955732 */
+#define HPF_Fs11025_Fc55_B2 1027238450 /* Floating point value 0.956690 */
+#define HPF_Fs12000_Fc55_A0 1040079943 /* Floating point value 0.968650 */
+#define HPF_Fs12000_Fc55_A1 -2080159885 /* Floating point value -1.937300 */
+#define HPF_Fs12000_Fc55_A2 1040079943 /* Floating point value 0.968650 */
+#define HPF_Fs12000_Fc55_B1 -2103811702 /* Floating point value -1.959327 */
+#define HPF_Fs12000_Fc55_B2 1030940477 /* Floating point value 0.960138 */
+#define HPF_Fs16000_Fc55_A0 1045381988 /* Floating point value 0.973588 */
+#define HPF_Fs16000_Fc55_A1 -2090763976 /* Floating point value -1.947176 */
+#define HPF_Fs16000_Fc55_A2 1045381988 /* Floating point value 0.973588 */
+#define HPF_Fs16000_Fc55_B1 -2114727793 /* Floating point value -1.969494 */
+#define HPF_Fs16000_Fc55_B2 1041478147 /* Floating point value 0.969952 */
+#define HPF_Fs22050_Fc55_A0 1049766523 /* Floating point value 0.977671 */
+#define HPF_Fs22050_Fc55_A1 -2099533046 /* Floating point value -1.955343 */
+#define HPF_Fs22050_Fc55_A2 1049766523 /* Floating point value 0.977671 */
+#define HPF_Fs22050_Fc55_B1 -2123714381 /* Floating point value -1.977863 */
+#define HPF_Fs22050_Fc55_B2 1050232780 /* Floating point value 0.978105 */
+#define HPF_Fs24000_Fc55_A0 1050711051 /* Floating point value 0.978551 */
+#define HPF_Fs24000_Fc55_A1 -2101422103 /* Floating point value -1.957102 */
+#define HPF_Fs24000_Fc55_A2 1050711051 /* Floating point value 0.978551 */
+#define HPF_Fs24000_Fc55_B1 -2125645498 /* Floating point value -1.979662 */
+#define HPF_Fs24000_Fc55_B2 1052123526 /* Floating point value 0.979866 */
+#define HPF_Fs32000_Fc55_A0 1053385759 /* Floating point value 0.981042 */
+#define HPF_Fs32000_Fc55_A1 -2106771519 /* Floating point value -1.962084 */
+#define HPF_Fs32000_Fc55_A2 1053385759 /* Floating point value 0.981042 */
+#define HPF_Fs32000_Fc55_B1 -2131104794 /* Floating point value -1.984746 */
+#define HPF_Fs32000_Fc55_B2 1057486949 /* Floating point value 0.984861 */
+#define HPF_Fs44100_Fc55_A0 1055592498 /* Floating point value 0.983097 */
+#define HPF_Fs44100_Fc55_A1 -2111184995 /* Floating point value -1.966194 */
+#define HPF_Fs44100_Fc55_A2 1055592498 /* Floating point value 0.983097 */
+#define HPF_Fs44100_Fc55_B1 -2135598658 /* Floating point value -1.988931 */
+#define HPF_Fs44100_Fc55_B2 1061922249 /* Floating point value 0.988992 */
+#define HPF_Fs48000_Fc55_A0 1056067276 /* Floating point value 0.983539 */
+#define HPF_Fs48000_Fc55_A1 -2112134551 /* Floating point value -1.967079 */
+#define HPF_Fs48000_Fc55_A2 1056067276 /* Floating point value 0.983539 */
+#define HPF_Fs48000_Fc55_B1 -2136564296 /* Floating point value -1.989831 */
+#define HPF_Fs48000_Fc55_B2 1062877714 /* Floating point value 0.989882 */
+
+ /* Coefficients for centre frequency 66Hz */
+#define HPF_Fs8000_Fc66_A0 1023293271 /* Floating point value 0.953016 */
+#define HPF_Fs8000_Fc66_A1 -2046586542 /* Floating point value -1.906032 */
+#define HPF_Fs8000_Fc66_A2 1023293271 /* Floating point value 0.953016 */
+#define HPF_Fs8000_Fc66_B1 -2068896860 /* Floating point value -1.926810 */
+#define HPF_Fs8000_Fc66_B2 997931110 /* Floating point value 0.929396 */
+#define HPF_Fs11025_Fc66_A0 1033624228 /* Floating point value 0.962638 */
+#define HPF_Fs11025_Fc66_A1 -2067248455 /* Floating point value -1.925275 */
+#define HPF_Fs11025_Fc66_A2 1033624228 /* Floating point value 0.962638 */
+#define HPF_Fs11025_Fc66_B1 -2090448000 /* Floating point value -1.946881 */
+#define HPF_Fs11025_Fc66_B2 1018182305 /* Floating point value 0.948256 */
+#define HPF_Fs12000_Fc66_A0 1035857662 /* Floating point value 0.964718 */
+#define HPF_Fs12000_Fc66_A1 -2071715325 /* Floating point value -1.929435 */
+#define HPF_Fs12000_Fc66_A2 1035857662 /* Floating point value 0.964718 */
+#define HPF_Fs12000_Fc66_B1 -2095080333 /* Floating point value -1.951196 */
+#define HPF_Fs12000_Fc66_B2 1022587158 /* Floating point value 0.952359 */
+#define HPF_Fs16000_Fc66_A0 1042197528 /* Floating point value 0.970622 */
+#define HPF_Fs16000_Fc66_A1 -2084395056 /* Floating point value -1.941244 */
+#define HPF_Fs16000_Fc66_A2 1042197528 /* Floating point value 0.970622 */
+#define HPF_Fs16000_Fc66_B1 -2108177912 /* Floating point value -1.963394 */
+#define HPF_Fs16000_Fc66_B2 1035142690 /* Floating point value 0.964052 */
+#define HPF_Fs22050_Fc66_A0 1047445145 /* Floating point value 0.975509 */
+#define HPF_Fs22050_Fc66_A1 -2094890289 /* Floating point value -1.951019 */
+#define HPF_Fs22050_Fc66_A2 1047445145 /* Floating point value 0.975509 */
+#define HPF_Fs22050_Fc66_B1 -2118961025 /* Floating point value -1.973436 */
+#define HPF_Fs22050_Fc66_B2 1045593102 /* Floating point value 0.973784 */
+#define HPF_Fs24000_Fc66_A0 1048576175 /* Floating point value 0.976563 */
+#define HPF_Fs24000_Fc66_A1 -2097152349 /* Floating point value -1.953125 */
+#define HPF_Fs24000_Fc66_A2 1048576175 /* Floating point value 0.976563 */
+#define HPF_Fs24000_Fc66_B1 -2121278255 /* Floating point value -1.975594 */
+#define HPF_Fs24000_Fc66_B2 1047852379 /* Floating point value 0.975889 */
+#define HPF_Fs32000_Fc66_A0 1051780119 /* Floating point value 0.979547 */
+#define HPF_Fs32000_Fc66_A1 -2103560237 /* Floating point value -1.959093 */
+#define HPF_Fs32000_Fc66_A2 1051780119 /* Floating point value 0.979547 */
+#define HPF_Fs32000_Fc66_B1 -2127829187 /* Floating point value -1.981695 */
+#define HPF_Fs32000_Fc66_B2 1054265623 /* Floating point value 0.981861 */
+#define HPF_Fs44100_Fc66_A0 1054424722 /* Floating point value 0.982010 */
+#define HPF_Fs44100_Fc66_A1 -2108849444 /* Floating point value -1.964019 */
+#define HPF_Fs44100_Fc66_A2 1054424722 /* Floating point value 0.982010 */
+#define HPF_Fs44100_Fc66_B1 -2133221723 /* Floating point value -1.986718 */
+#define HPF_Fs44100_Fc66_B2 1059573993 /* Floating point value 0.986805 */
+#define HPF_Fs48000_Fc66_A0 1054993851 /* Floating point value 0.982540 */
+#define HPF_Fs48000_Fc66_A1 -2109987702 /* Floating point value -1.965079 */
+#define HPF_Fs48000_Fc66_A2 1054993851 /* Floating point value 0.982540 */
+#define HPF_Fs48000_Fc66_B1 -2134380475 /* Floating point value -1.987797 */
+#define HPF_Fs48000_Fc66_B2 1060718118 /* Floating point value 0.987871 */
+
+ /* Coefficients for centre frequency 78Hz */
+#define HPF_Fs8000_Fc78_A0 1016504203 /* Floating point value 0.946693 */
+#define HPF_Fs8000_Fc78_A1 -2033008405 /* Floating point value -1.893387 */
+#define HPF_Fs8000_Fc78_A2 1016504203 /* Floating point value 0.946693 */
+#define HPF_Fs8000_Fc78_B1 -2054623390 /* Floating point value -1.913517 */
+#define HPF_Fs8000_Fc78_B2 984733853 /* Floating point value 0.917105 */
+#define HPF_Fs11025_Fc78_A0 1028643741 /* Floating point value 0.957999 */
+#define HPF_Fs11025_Fc78_A1 -2057287482 /* Floating point value -1.915998 */
+#define HPF_Fs11025_Fc78_A2 1028643741 /* Floating point value 0.957999 */
+#define HPF_Fs11025_Fc78_B1 -2080083769 /* Floating point value -1.937229 */
+#define HPF_Fs11025_Fc78_B2 1008393904 /* Floating point value 0.939140 */
+#define HPF_Fs12000_Fc78_A0 1031271067 /* Floating point value 0.960446 */
+#define HPF_Fs12000_Fc78_A1 -2062542133 /* Floating point value -1.920892 */
+#define HPF_Fs12000_Fc78_A2 1031271067 /* Floating point value 0.960446 */
+#define HPF_Fs12000_Fc78_B1 -2085557048 /* Floating point value -1.942326 */
+#define HPF_Fs12000_Fc78_B2 1013551620 /* Floating point value 0.943944 */
+#define HPF_Fs16000_Fc78_A0 1038734628 /* Floating point value 0.967397 */
+#define HPF_Fs16000_Fc78_A1 -2077469256 /* Floating point value -1.934794 */
+#define HPF_Fs16000_Fc78_A2 1038734628 /* Floating point value 0.967397 */
+#define HPF_Fs16000_Fc78_B1 -2101033380 /* Floating point value -1.956740 */
+#define HPF_Fs16000_Fc78_B2 1028275228 /* Floating point value 0.957656 */
+#define HPF_Fs22050_Fc78_A0 1044918584 /* Floating point value 0.973156 */
+#define HPF_Fs22050_Fc78_A1 -2089837169 /* Floating point value -1.946313 */
+#define HPF_Fs22050_Fc78_A2 1044918584 /* Floating point value 0.973156 */
+#define HPF_Fs22050_Fc78_B1 -2113775854 /* Floating point value -1.968607 */
+#define HPF_Fs22050_Fc78_B2 1040555007 /* Floating point value 0.969092 */
+#define HPF_Fs24000_Fc78_A0 1046252164 /* Floating point value 0.974398 */
+#define HPF_Fs24000_Fc78_A1 -2092504328 /* Floating point value -1.948797 */
+#define HPF_Fs24000_Fc78_A2 1046252164 /* Floating point value 0.974398 */
+#define HPF_Fs24000_Fc78_B1 -2116514229 /* Floating point value -1.971157 */
+#define HPF_Fs24000_Fc78_B2 1043212719 /* Floating point value 0.971568 */
+#define HPF_Fs32000_Fc78_A0 1050031301 /* Floating point value 0.977918 */
+#define HPF_Fs32000_Fc78_A1 -2100062603 /* Floating point value -1.955836 */
+#define HPF_Fs32000_Fc78_A2 1050031301 /* Floating point value 0.977918 */
+#define HPF_Fs32000_Fc78_B1 -2124255900 /* Floating point value -1.978367 */
+#define HPF_Fs32000_Fc78_B2 1050762639 /* Floating point value 0.978599 */
+#define HPF_Fs44100_Fc78_A0 1053152258 /* Floating point value 0.980824 */
+#define HPF_Fs44100_Fc78_A1 -2106304516 /* Floating point value -1.961649 */
+#define HPF_Fs44100_Fc78_A2 1053152258 /* Floating point value 0.980824 */
+#define HPF_Fs44100_Fc78_B1 -2130628742 /* Floating point value -1.984303 */
+#define HPF_Fs44100_Fc78_B2 1057018180 /* Floating point value 0.984425 */
+#define HPF_Fs48000_Fc78_A0 1053824087 /* Floating point value 0.981450 */
+#define HPF_Fs48000_Fc78_A1 -2107648173 /* Floating point value -1.962900 */
+#define HPF_Fs48000_Fc78_A2 1053824087 /* Floating point value 0.981450 */
+#define HPF_Fs48000_Fc78_B1 -2131998154 /* Floating point value -1.985578 */
+#define HPF_Fs48000_Fc78_B2 1058367200 /* Floating point value 0.985681 */
+
+ /* Coefficients for centre frequency 90Hz */
+#define HPF_Fs8000_Fc90_A0 1009760053 /* Floating point value 0.940412 */
+#define HPF_Fs8000_Fc90_A1 -2019520105 /* Floating point value -1.880825 */
+#define HPF_Fs8000_Fc90_A2 1009760053 /* Floating point value 0.940412 */
+#define HPF_Fs8000_Fc90_B1 -2040357139 /* Floating point value -1.900231 */
+#define HPF_Fs8000_Fc90_B2 971711129 /* Floating point value 0.904977 */
+#define HPF_Fs11025_Fc90_A0 1023687217 /* Floating point value 0.953383 */
+#define HPF_Fs11025_Fc90_A1 -2047374434 /* Floating point value -1.906766 */
+#define HPF_Fs11025_Fc90_A2 1023687217 /* Floating point value 0.953383 */
+#define HPF_Fs11025_Fc90_B1 -2069722397 /* Floating point value -1.927579 */
+#define HPF_Fs11025_Fc90_B2 998699604 /* Floating point value 0.930111 */
+#define HPF_Fs12000_Fc90_A0 1026704754 /* Floating point value 0.956193 */
+#define HPF_Fs12000_Fc90_A1 -2053409508 /* Floating point value -1.912387 */
+#define HPF_Fs12000_Fc90_A2 1026704754 /* Floating point value 0.956193 */
+#define HPF_Fs12000_Fc90_B1 -2076035996 /* Floating point value -1.933459 */
+#define HPF_Fs12000_Fc90_B2 1004595918 /* Floating point value 0.935603 */
+#define HPF_Fs16000_Fc90_A0 1035283225 /* Floating point value 0.964183 */
+#define HPF_Fs16000_Fc90_A1 -2070566451 /* Floating point value -1.928365 */
+#define HPF_Fs16000_Fc90_A2 1035283225 /* Floating point value 0.964183 */
+#define HPF_Fs16000_Fc90_B1 -2093889811 /* Floating point value -1.950087 */
+#define HPF_Fs16000_Fc90_B2 1021453326 /* Floating point value 0.951303 */
+#define HPF_Fs22050_Fc90_A0 1042398116 /* Floating point value 0.970809 */
+#define HPF_Fs22050_Fc90_A1 -2084796232 /* Floating point value -1.941618 */
+#define HPF_Fs22050_Fc90_A2 1042398116 /* Floating point value 0.970809 */
+#define HPF_Fs22050_Fc90_B1 -2108591057 /* Floating point value -1.963778 */
+#define HPF_Fs22050_Fc90_B2 1035541188 /* Floating point value 0.964423 */
+#define HPF_Fs24000_Fc90_A0 1043933302 /* Floating point value 0.972239 */
+#define HPF_Fs24000_Fc90_A1 -2087866604 /* Floating point value -1.944477 */
+#define HPF_Fs24000_Fc90_A2 1043933302 /* Floating point value 0.972239 */
+#define HPF_Fs24000_Fc90_B1 -2111750495 /* Floating point value -1.966721 */
+#define HPF_Fs24000_Fc90_B2 1038593601 /* Floating point value 0.967266 */
+#define HPF_Fs32000_Fc90_A0 1048285391 /* Floating point value 0.976292 */
+#define HPF_Fs32000_Fc90_A1 -2096570783 /* Floating point value -1.952584 */
+#define HPF_Fs32000_Fc90_A2 1048285391 /* Floating point value 0.976292 */
+#define HPF_Fs32000_Fc90_B1 -2120682737 /* Floating point value -1.975040 */
+#define HPF_Fs32000_Fc90_B2 1047271295 /* Floating point value 0.975347 */
+#define HPF_Fs44100_Fc90_A0 1051881330 /* Floating point value 0.979641 */
+#define HPF_Fs44100_Fc90_A1 -2103762660 /* Floating point value -1.959282 */
+#define HPF_Fs44100_Fc90_A2 1051881330 /* Floating point value 0.979641 */
+#define HPF_Fs44100_Fc90_B1 -2128035809 /* Floating point value -1.981888 */
+#define HPF_Fs44100_Fc90_B2 1054468533 /* Floating point value 0.982050 */
+#define HPF_Fs48000_Fc90_A0 1052655619 /* Floating point value 0.980362 */
+#define HPF_Fs48000_Fc90_A1 -2105311238 /* Floating point value -1.960724 */
+#define HPF_Fs48000_Fc90_A2 1052655619 /* Floating point value 0.980362 */
+#define HPF_Fs48000_Fc90_B1 -2129615871 /* Floating point value -1.983359 */
+#define HPF_Fs48000_Fc90_B2 1056021492 /* Floating point value 0.983497 */
+
+
+/************************************************************************************/
+/* */
+/* Band Pass Filter coefficients */
+/* */
+/************************************************************************************/
+
+ /* Coefficients for centre frequency 55Hz */
+#define BPF_Fs8000_Fc55_A0 9875247 /* Floating point value 0.009197 */
+#define BPF_Fs8000_Fc55_A1 0 /* Floating point value 0.000000 */
+#define BPF_Fs8000_Fc55_A2 -9875247 /* Floating point value -0.009197 */
+#define BPF_Fs8000_Fc55_B1 -2125519830 /* Floating point value -1.979545 */
+#define BPF_Fs8000_Fc55_B2 1053762629 /* Floating point value 0.981393 */
+#define BPF_Fs11025_Fc55_A0 7183952 /* Floating point value 0.006691 */
+#define BPF_Fs11025_Fc55_A1 0 /* Floating point value 0.000000 */
+#define BPF_Fs11025_Fc55_A2 -7183952 /* Floating point value -0.006691 */
+#define BPF_Fs11025_Fc55_B1 -2131901658 /* Floating point value -1.985488 */
+#define BPF_Fs11025_Fc55_B2 1059207548 /* Floating point value 0.986464 */
+#define BPF_Fs12000_Fc55_A0 6603871 /* Floating point value 0.006150 */
+#define BPF_Fs12000_Fc55_A1 0 /* Floating point value 0.000000 */
+#define BPF_Fs12000_Fc55_A2 -6603871 /* Floating point value -0.006150 */
+#define BPF_Fs12000_Fc55_B1 -2133238092 /* Floating point value -1.986733 */
+#define BPF_Fs12000_Fc55_B2 1060381143 /* Floating point value 0.987557 */
+#define BPF_Fs16000_Fc55_A0 4960591 /* Floating point value 0.004620 */
+#define BPF_Fs16000_Fc55_A1 0 /* Floating point value 0.000000 */
+#define BPF_Fs16000_Fc55_A2 -4960591 /* Floating point value -0.004620 */
+#define BPF_Fs16000_Fc55_B1 -2136949052 /* Floating point value -1.990189 */
+#define BPF_Fs16000_Fc55_B2 1063705760 /* Floating point value 0.990653 */
+#define BPF_Fs22050_Fc55_A0 3604131 /* Floating point value 0.003357 */
+#define BPF_Fs22050_Fc55_A1 0 /* Floating point value 0.000000 */
+#define BPF_Fs22050_Fc55_A2 -3604131 /* Floating point value -0.003357 */
+#define BPF_Fs22050_Fc55_B1 -2139929085 /* Floating point value -1.992964 */
+#define BPF_Fs22050_Fc55_B2 1066450095 /* Floating point value 0.993209 */
+#define BPF_Fs24000_Fc55_A0 3312207 /* Floating point value 0.003085 */
+#define BPF_Fs24000_Fc55_A1 0 /* Floating point value 0.000000 */
+#define BPF_Fs24000_Fc55_A2 -3312207 /* Floating point value -0.003085 */
+#define BPF_Fs24000_Fc55_B1 -2140560606 /* Floating point value -1.993552 */
+#define BPF_Fs24000_Fc55_B2 1067040703 /* Floating point value 0.993759 */
+#define BPF_Fs32000_Fc55_A0 2486091 /* Floating point value 0.002315 */
+#define BPF_Fs32000_Fc55_A1 0 /* Floating point value 0.000000 */
+#define BPF_Fs32000_Fc55_A2 -2486091 /* Floating point value -0.002315 */
+#define BPF_Fs32000_Fc55_B1 -2142328962 /* Floating point value -1.995199 */
+#define BPF_Fs32000_Fc55_B2 1068712067 /* Floating point value 0.995316 */
+#define BPF_Fs44100_Fc55_A0 1805125 /* Floating point value 0.001681 */
+#define BPF_Fs44100_Fc55_A1 0 /* Floating point value 0.000000 */
+#define BPF_Fs44100_Fc55_A2 -1805125 /* Floating point value -0.001681 */
+#define BPF_Fs44100_Fc55_B1 -2143765772 /* Floating point value -1.996537 */
+#define BPF_Fs44100_Fc55_B2 1070089770 /* Floating point value 0.996599 */
+#define BPF_Fs48000_Fc55_A0 1658687 /* Floating point value 0.001545 */
+#define BPF_Fs48000_Fc55_A1 0 /* Floating point value 0.000000 */
+#define BPF_Fs48000_Fc55_A2 -1658687 /* Floating point value -0.001545 */
+#define BPF_Fs48000_Fc55_B1 -2144072292 /* Floating point value -1.996823 */
+#define BPF_Fs48000_Fc55_B2 1070386036 /* Floating point value 0.996875 */
+
+ /* Coefficients for centre frequency 66Hz */
+#define BPF_Fs8000_Fc66_A0 13580189 /* Floating point value 0.012648 */
+#define BPF_Fs8000_Fc66_A1 0 /* Floating point value 0.000000 */
+#define BPF_Fs8000_Fc66_A2 -13580189 /* Floating point value -0.012648 */
+#define BPF_Fs8000_Fc66_B1 -2117161175 /* Floating point value -1.971760 */
+#define BPF_Fs8000_Fc66_B2 1046266945 /* Floating point value 0.974412 */
+#define BPF_Fs11025_Fc66_A0 9888559 /* Floating point value 0.009209 */
+#define BPF_Fs11025_Fc66_A1 0 /* Floating point value 0.000000 */
+#define BPF_Fs11025_Fc66_A2 -9888559 /* Floating point value -0.009209 */
+#define BPF_Fs11025_Fc66_B1 -2125972738 /* Floating point value -1.979966 */
+#define BPF_Fs11025_Fc66_B2 1053735698 /* Floating point value 0.981368 */
+#define BPF_Fs12000_Fc66_A0 9091954 /* Floating point value 0.008468 */
+#define BPF_Fs12000_Fc66_A1 0 /* Floating point value 0.000000 */
+#define BPF_Fs12000_Fc66_A2 -9091954 /* Floating point value -0.008468 */
+#define BPF_Fs12000_Fc66_B1 -2127818004 /* Floating point value -1.981685 */
+#define BPF_Fs12000_Fc66_B2 1055347356 /* Floating point value 0.982869 */
+#define BPF_Fs16000_Fc66_A0 6833525 /* Floating point value 0.006364 */
+#define BPF_Fs16000_Fc66_A1 0 /* Floating point value 0.000000 */
+#define BPF_Fs16000_Fc66_A2 -6833525 /* Floating point value -0.006364 */
+#define BPF_Fs16000_Fc66_B1 -2132941739 /* Floating point value -1.986457 */
+#define BPF_Fs16000_Fc66_B2 1059916517 /* Floating point value 0.987124 */
+#define BPF_Fs22050_Fc66_A0 4967309 /* Floating point value 0.004626 */
+#define BPF_Fs22050_Fc66_A1 0 /* Floating point value 0.000000 */
+#define BPF_Fs22050_Fc66_A2 -4967309 /* Floating point value -0.004626 */
+#define BPF_Fs22050_Fc66_B1 -2137056003 /* Floating point value -1.990288 */
+#define BPF_Fs22050_Fc66_B2 1063692170 /* Floating point value 0.990641 */
+#define BPF_Fs24000_Fc66_A0 4565445 /* Floating point value 0.004252 */
+#define BPF_Fs24000_Fc66_A1 0 /* Floating point value 0.000000 */
+#define BPF_Fs24000_Fc66_A2 -4565445 /* Floating point value -0.004252 */
+#define BPF_Fs24000_Fc66_B1 -2137927842 /* Floating point value -1.991100 */
+#define BPF_Fs24000_Fc66_B2 1064505202 /* Floating point value 0.991398 */
+#define BPF_Fs32000_Fc66_A0 3427761 /* Floating point value 0.003192 */
+#define BPF_Fs32000_Fc66_A1 0 /* Floating point value 0.000000 */
+#define BPF_Fs32000_Fc66_A2 -3427761 /* Floating point value -0.003192 */
+#define BPF_Fs32000_Fc66_B1 -2140369007 /* Floating point value -1.993374 */
+#define BPF_Fs32000_Fc66_B2 1066806920 /* Floating point value 0.993541 */
+#define BPF_Fs44100_Fc66_A0 2489466 /* Floating point value 0.002318 */
+#define BPF_Fs44100_Fc66_A1 0 /* Floating point value 0.000000 */
+#define BPF_Fs44100_Fc66_A2 -2489466 /* Floating point value -0.002318 */
+#define BPF_Fs44100_Fc66_B1 -2142352342 /* Floating point value -1.995221 */
+#define BPF_Fs44100_Fc66_B2 1068705240 /* Floating point value 0.995309 */
+#define BPF_Fs48000_Fc66_A0 2287632 /* Floating point value 0.002131 */
+#define BPF_Fs48000_Fc66_A1 0 /* Floating point value 0.000000 */
+#define BPF_Fs48000_Fc66_A2 -2287632 /* Floating point value -0.002131 */
+#define BPF_Fs48000_Fc66_B1 -2142775436 /* Floating point value -1.995615 */
+#define BPF_Fs48000_Fc66_B2 1069113581 /* Floating point value 0.995690 */
+
+ /* Coefficients for centre frequency 78Hz */
+#define BPF_Fs8000_Fc78_A0 19941180 /* Floating point value 0.018572 */
+#define BPF_Fs8000_Fc78_A1 0 /* Floating point value 0.000000 */
+#define BPF_Fs8000_Fc78_A2 -19941180 /* Floating point value -0.018572 */
+#define BPF_Fs8000_Fc78_B1 -2103186749 /* Floating point value -1.958745 */
+#define BPF_Fs8000_Fc78_B2 1033397648 /* Floating point value 0.962427 */
+#define BPF_Fs11025_Fc78_A0 14543934 /* Floating point value 0.013545 */
+#define BPF_Fs11025_Fc78_A1 0 /* Floating point value 0.000000 */
+#define BPF_Fs11025_Fc78_A2 -14543934 /* Floating point value -0.013545 */
+#define BPF_Fs11025_Fc78_B1 -2115966638 /* Floating point value -1.970647 */
+#define BPF_Fs11025_Fc78_B2 1044317135 /* Floating point value 0.972596 */
+#define BPF_Fs12000_Fc78_A0 13376999 /* Floating point value 0.012458 */
+#define BPF_Fs12000_Fc78_A1 0 /* Floating point value 0.000000 */
+#define BPF_Fs12000_Fc78_A2 -13376999 /* Floating point value -0.012458 */
+#define BPF_Fs12000_Fc78_B1 -2118651708 /* Floating point value -1.973148 */
+#define BPF_Fs12000_Fc78_B2 1046678029 /* Floating point value 0.974795 */
+#define BPF_Fs16000_Fc78_A0 10064222 /* Floating point value 0.009373 */
+#define BPF_Fs16000_Fc78_A1 0 /* Floating point value 0.000000 */
+#define BPF_Fs16000_Fc78_A2 -10064222 /* Floating point value -0.009373 */
+#define BPF_Fs16000_Fc78_B1 -2126124342 /* Floating point value -1.980108 */
+#define BPF_Fs16000_Fc78_B2 1053380304 /* Floating point value 0.981037 */
+#define BPF_Fs22050_Fc78_A0 7321780 /* Floating point value 0.006819 */
+#define BPF_Fs22050_Fc78_A1 0 /* Floating point value 0.000000 */
+#define BPF_Fs22050_Fc78_A2 -7321780 /* Floating point value -0.006819 */
+#define BPF_Fs22050_Fc78_B1 -2132143771 /* Floating point value -1.985714 */
+#define BPF_Fs22050_Fc78_B2 1058928700 /* Floating point value 0.986204 */
+#define BPF_Fs24000_Fc78_A0 6730640 /* Floating point value 0.006268 */
+#define BPF_Fs24000_Fc78_A1 0 /* Floating point value 0.000000 */
+#define BPF_Fs24000_Fc78_A2 -6730640 /* Floating point value -0.006268 */
+#define BPF_Fs24000_Fc78_B1 -2133421607 /* Floating point value -1.986904 */
+#define BPF_Fs24000_Fc78_B2 1060124669 /* Floating point value 0.987318 */
+#define BPF_Fs32000_Fc78_A0 5055965 /* Floating point value 0.004709 */
+#define BPF_Fs32000_Fc78_A1 0 /* Floating point value 0.000000 */
+#define BPF_Fs32000_Fc78_A2 -5055965 /* Floating point value -0.004709 */
+#define BPF_Fs32000_Fc78_B1 -2137003977 /* Floating point value -1.990240 */
+#define BPF_Fs32000_Fc78_B2 1063512802 /* Floating point value 0.990473 */
+#define BPF_Fs44100_Fc78_A0 3673516 /* Floating point value 0.003421 */
+#define BPF_Fs44100_Fc78_A1 0 /* Floating point value 0.000000 */
+#define BPF_Fs44100_Fc78_A2 -3673516 /* Floating point value -0.003421 */
+#define BPF_Fs44100_Fc78_B1 -2139919394 /* Floating point value -1.992955 */
+#define BPF_Fs44100_Fc78_B2 1066309718 /* Floating point value 0.993078 */
+#define BPF_Fs48000_Fc78_A0 3375990 /* Floating point value 0.003144 */
+#define BPF_Fs48000_Fc78_A1 0 /* Floating point value 0.000000 */
+#define BPF_Fs48000_Fc78_A2 -3375990 /* Floating point value -0.003144 */
+#define BPF_Fs48000_Fc78_B1 -2140541906 /* Floating point value -1.993535 */
+#define BPF_Fs48000_Fc78_B2 1066911660 /* Floating point value 0.993639 */
+
+ /* Coefficients for centre frequency 90Hz */
+#define BPF_Fs8000_Fc90_A0 24438548 /* Floating point value 0.022760 */
+#define BPF_Fs8000_Fc90_A1 0 /* Floating point value 0.000000 */
+#define BPF_Fs8000_Fc90_A2 -24438548 /* Floating point value -0.022760 */
+#define BPF_Fs8000_Fc90_B1 -2092801347 /* Floating point value -1.949073 */
+#define BPF_Fs8000_Fc90_B2 1024298757 /* Floating point value 0.953953 */
+#define BPF_Fs11025_Fc90_A0 17844385 /* Floating point value 0.016619 */
+#define BPF_Fs11025_Fc90_A1 0 /* Floating point value 0.000000 */
+#define BPF_Fs11025_Fc90_A2 -17844385 /* Floating point value -0.016619 */
+#define BPF_Fs11025_Fc90_B1 -2108604921 /* Floating point value -1.963791 */
+#define BPF_Fs11025_Fc90_B2 1037639797 /* Floating point value 0.966377 */
+#define BPF_Fs12000_Fc90_A0 16416707 /* Floating point value 0.015289 */
+#define BPF_Fs12000_Fc90_A1 0 /* Floating point value 0.000000 */
+#define BPF_Fs12000_Fc90_A2 -16416707 /* Floating point value -0.015289 */
+#define BPF_Fs12000_Fc90_B1 -2111922936 /* Floating point value -1.966882 */
+#define BPF_Fs12000_Fc90_B2 1040528216 /* Floating point value 0.969067 */
+#define BPF_Fs16000_Fc90_A0 12359883 /* Floating point value 0.011511 */
+#define BPF_Fs16000_Fc90_A1 0 /* Floating point value 0.000000 */
+#define BPF_Fs16000_Fc90_A2 -12359883 /* Floating point value -0.011511 */
+#define BPF_Fs16000_Fc90_B1 -2121152162 /* Floating point value -1.975477 */
+#define BPF_Fs16000_Fc90_B2 1048735817 /* Floating point value 0.976711 */
+#define BPF_Fs22050_Fc90_A0 8997173 /* Floating point value 0.008379 */
+#define BPF_Fs22050_Fc90_A1 0 /* Floating point value 0.000000 */
+#define BPF_Fs22050_Fc90_A2 -8997173 /* Floating point value -0.008379 */
+#define BPF_Fs22050_Fc90_B1 -2128580762 /* Floating point value -1.982395 */
+#define BPF_Fs22050_Fc90_B2 1055539113 /* Floating point value 0.983047 */
+#define BPF_Fs24000_Fc90_A0 8271818 /* Floating point value 0.007704 */
+#define BPF_Fs24000_Fc90_A1 0 /* Floating point value 0.000000 */
+#define BPF_Fs24000_Fc90_A2 -8271818 /* Floating point value -0.007704 */
+#define BPF_Fs24000_Fc90_B1 -2130157013 /* Floating point value -1.983863 */
+#define BPF_Fs24000_Fc90_B2 1057006621 /* Floating point value 0.984414 */
+#define BPF_Fs32000_Fc90_A0 6215918 /* Floating point value 0.005789 */
+#define BPF_Fs32000_Fc90_A1 0 /* Floating point value 0.000000 */
+#define BPF_Fs32000_Fc90_A2 -6215918 /* Floating point value -0.005789 */
+#define BPF_Fs32000_Fc90_B1 -2134574521 /* Floating point value -1.987977 */
+#define BPF_Fs32000_Fc90_B2 1061166033 /* Floating point value 0.988288 */
+#define BPF_Fs44100_Fc90_A0 4517651 /* Floating point value 0.004207 */
+#define BPF_Fs44100_Fc90_A1 0 /* Floating point value 0.000000 */
+#define BPF_Fs44100_Fc90_A2 -4517651 /* Floating point value -0.004207 */
+#define BPF_Fs44100_Fc90_B1 -2138167926 /* Floating point value -1.991324 */
+#define BPF_Fs44100_Fc90_B2 1064601898 /* Floating point value 0.991488 */
+#define BPF_Fs48000_Fc90_A0 4152024 /* Floating point value 0.003867 */
+#define BPF_Fs48000_Fc90_A1 0 /* Floating point value 0.000000 */
+#define BPF_Fs48000_Fc90_A2 -4152024 /* Floating point value -0.003867 */
+#define BPF_Fs48000_Fc90_B1 -2138935002 /* Floating point value -1.992038 */
+#define BPF_Fs48000_Fc90_B2 1065341620 /* Floating point value 0.992177 */
+
+
+/************************************************************************************/
+/* */
+/* Automatic Gain Control time constants and gain settings */
+/* */
+/************************************************************************************/
+
+/* AGC Time constants */
+#define AGC_ATTACK_Fs8000 27571 /* Floating point value 0.841395 */
+#define AGC_ATTACK_Fs11025 28909 /* Floating point value 0.882223 */
+#define AGC_ATTACK_Fs12000 29205 /* Floating point value 0.891251 */
+#define AGC_ATTACK_Fs16000 30057 /* Floating point value 0.917276 */
+#define AGC_ATTACK_Fs22050 30778 /* Floating point value 0.939267 */
+#define AGC_ATTACK_Fs24000 30935 /* Floating point value 0.944061 */
+#define AGC_ATTACK_Fs32000 31383 /* Floating point value 0.957745 */
+#define AGC_ATTACK_Fs44100 31757 /* Floating point value 0.969158 */
+#define AGC_ATTACK_Fs48000 31838 /* Floating point value 0.971628 */
+#define DECAY_SHIFT 10 /* As a power of 2 */
+#define AGC_DECAY_Fs8000 44 /* Floating point value 0.000042 */
+#define AGC_DECAY_Fs11025 32 /* Floating point value 0.000030 */
+#define AGC_DECAY_Fs12000 29 /* Floating point value 0.000028 */
+#define AGC_DECAY_Fs16000 22 /* Floating point value 0.000021 */
+#define AGC_DECAY_Fs22050 16 /* Floating point value 0.000015 */
+#define AGC_DECAY_Fs24000 15 /* Floating point value 0.000014 */
+#define AGC_DECAY_Fs32000 11 /* Floating point value 0.000010 */
+#define AGC_DECAY_Fs44100 8 /* Floating point value 0.000008 */
+#define AGC_DECAY_Fs48000 7 /* Floating point value 0.000007 */
+
+/* AGC Gain settings */
+#define AGC_GAIN_SCALE 31 /* As a power of 2 */
+#define AGC_GAIN_SHIFT 4 /* As a power of 2 */
+#define AGC_TARGETLEVEL 33170337 /* Floating point value -0.100000dB */
+#define AGC_HPFGAIN_0dB 110739704 /* Floating point value 0.412538 */
+#define AGC_GAIN_0dB 0 /* Floating point value 0.000000 */
+#define AGC_HPFGAIN_1dB 157006071 /* Floating point value 0.584893 */
+#define AGC_GAIN_1dB 32754079 /* Floating point value 0.122018 */
+#define AGC_HPFGAIN_2dB 208917788 /* Floating point value 0.778279 */
+#define AGC_GAIN_2dB 69504761 /* Floating point value 0.258925 */
+#define AGC_HPFGAIN_3dB 267163693 /* Floating point value 0.995262 */
+#define AGC_GAIN_3dB 110739704 /* Floating point value 0.412538 */
+#define AGC_HPFGAIN_4dB 332516674 /* Floating point value 1.238721 */
+#define AGC_GAIN_4dB 157006071 /* Floating point value 0.584893 */
+#define AGC_HPFGAIN_5dB 405843924 /* Floating point value 1.511886 */
+#define AGC_GAIN_5dB 208917788 /* Floating point value 0.778279 */
+#define AGC_HPFGAIN_6dB 488118451 /* Floating point value 1.818383 */
+#define AGC_GAIN_6dB 267163693 /* Floating point value 0.995262 */
+#define AGC_HPFGAIN_7dB 580431990 /* Floating point value 2.162278 */
+#define AGC_GAIN_7dB 332516674 /* Floating point value 1.238721 */
+#define AGC_HPFGAIN_8dB 684009483 /* Floating point value 2.548134 */
+#define AGC_GAIN_8dB 405843924 /* Floating point value 1.511886 */
+#define AGC_HPFGAIN_9dB 800225343 /* Floating point value 2.981072 */
+#define AGC_GAIN_9dB 488118451 /* Floating point value 1.818383 */
+#define AGC_HPFGAIN_10dB 930621681 /* Floating point value 3.466836 */
+#define AGC_GAIN_10dB 580431990 /* Floating point value 2.162278 */
+#define AGC_HPFGAIN_11dB 1076928780 /* Floating point value 4.011872 */
+#define AGC_GAIN_11dB 684009483 /* Floating point value 2.548134 */
+#define AGC_HPFGAIN_12dB 1241088045 /* Floating point value 4.623413 */
+#define AGC_GAIN_12dB 800225343 /* Floating point value 2.981072 */
+#define AGC_HPFGAIN_13dB 1425277769 /* Floating point value 5.309573 */
+#define AGC_GAIN_13dB 930621681 /* Floating point value 3.466836 */
+#define AGC_HPFGAIN_14dB 1631942039 /* Floating point value 6.079458 */
+#define AGC_GAIN_14dB 1076928780 /* Floating point value 4.011872 */
+#define AGC_HPFGAIN_15dB 1863823163 /* Floating point value 6.943282 */
+#define AGC_GAIN_15dB 1241088045 /* Floating point value 4.623413 */
+
+
+/************************************************************************************/
+/* */
+/* Volume control */
+/* */
+/************************************************************************************/
+
+/* Volume control gain */
+#define VOLUME_MAX 0 /* In dBs */
+#define VOLUME_SHIFT 0 /* In dBs */
+
+/* Volume control time constants */
+#define VOL_TC_SHIFT 21 /* As a power of 2 */
+#define VOL_TC_Fs8000 25889 /* Floating point value 0.024690 */
+#define VOL_TC_Fs11025 18850 /* Floating point value 0.017977 */
+#define VOL_TC_Fs12000 17331 /* Floating point value 0.016529 */
+#define VOL_TC_Fs16000 13026 /* Floating point value 0.012422 */
+#define VOL_TC_Fs22050 9468 /* Floating point value 0.009029 */
+#define VOL_TC_Fs24000 8702 /* Floating point value 0.008299 */
+#define VOL_TC_Fs32000 6533 /* Floating point value 0.006231 */
+#define VOL_TC_Fs44100 4745 /* Floating point value 0.004525 */
+#define VOL_TC_Fs48000 4360 /* Floating point value 0.004158 */
+#define MIX_TC_Fs8000 29365 /* Floating point value 0.896151 */
+#define MIX_TC_Fs11025 30230 /* Floating point value 0.922548 */
+#define MIX_TC_Fs12000 30422 /* Floating point value 0.928415 */
+#define MIX_TC_Fs16000 30978 /* Floating point value 0.945387 */
+#define MIX_TC_Fs22050 31451 /* Floating point value 0.959804 */
+#define MIX_TC_Fs24000 31554 /* Floating point value 0.962956 */
+#define MIX_TC_Fs32000 31850 /* Floating point value 0.971973 */
+#define MIX_TC_Fs44100 32097 /* Floating point value 0.979515 */
+#define MIX_TC_Fs48000 32150 /* Floating point value 0.981150 */
+
+
+#endif
diff --git a/media/libeffects/lvm/lib/Bass/src/LVDBE_Control.c b/media/libeffects/lvm/lib/Bass/src/LVDBE_Control.c
new file mode 100755
index 0000000..e66513f
--- /dev/null
+++ b/media/libeffects/lvm/lib/Bass/src/LVDBE_Control.c
@@ -0,0 +1,377 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/****************************************************************************************
+
+ $Author: nxp007753 $
+ $Revision: 1223 $
+ $Date: 2010-07-15 14:27:01 +0200 (Thu, 15 Jul 2010) $
+
+*****************************************************************************************/
+
+/****************************************************************************************/
+/* */
+/* Includes */
+/* */
+/****************************************************************************************/
+
+#include "LVDBE.h"
+#include "LVDBE_Private.h"
+#include "VectorArithmetic.h"
+#include "LVDBE_Coeffs.h"
+#include "LVDBE_Tables.h"
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVDBE_GetParameters */
+/* */
+/* DESCRIPTION: */
+/* Request the Dynamic Bass Enhancement parameters. The current parameter set is */
+/* returned via the parameter pointer. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* pParams Pointer to an empty parameter structure */
+/* */
+/* RETURNS: */
+/* LVDBE_SUCCESS Always succeeds */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVDBE_Process function */
+/* */
+/****************************************************************************************/
+
+LVDBE_ReturnStatus_en LVDBE_GetParameters(LVDBE_Handle_t hInstance,
+ LVDBE_Params_t *pParams)
+{
+
+ LVDBE_Instance_t *pInstance =(LVDBE_Instance_t *)hInstance;
+
+ *pParams = pInstance->Params;
+
+ return(LVDBE_SUCCESS);
+}
+
+
+/************************************************************************************/
+/* */
+/* FUNCTION: LVDBE_GetCapabilities */
+/* */
+/* DESCRIPTION: Dynamic Bass Enhnacement capabilities. The current capabilities are */
+/* returned via the pointer. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* pCapabilities Pointer to an empty capability structure */
+/* */
+/* RETURNS: */
+/* LVDBE_Success Always succeeds */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVDBE_Process function */
+/* */
+/************************************************************************************/
+
+LVDBE_ReturnStatus_en LVDBE_GetCapabilities(LVDBE_Handle_t hInstance,
+ LVDBE_Capabilities_t *pCapabilities)
+{
+
+ LVDBE_Instance_t *pInstance =(LVDBE_Instance_t *)hInstance;
+
+ *pCapabilities = pInstance->Capabilities;
+
+ return(LVDBE_SUCCESS);
+}
+
+
+/************************************************************************************/
+/* */
+/* FUNCTION: LVDBE_SetFilters */
+/* */
+/* DESCRIPTION: */
+/* Sets the filter coefficients and clears the data history */
+/* */
+/* PARAMETERS: */
+/* pInstance Pointer to the instance */
+/* pParams Initialisation parameters */
+/* */
+/************************************************************************************/
+
+void LVDBE_SetFilters(LVDBE_Instance_t *pInstance,
+ LVDBE_Params_t *pParams)
+{
+
+ /*
+ * Calculate the table offsets
+ */
+ LVM_UINT16 Offset = (LVM_UINT16)((LVM_UINT16)pParams->SampleRate + (LVM_UINT16)(pParams->CentreFrequency * (1+LVDBE_FS_48000)));
+
+
+ /*
+ * Setup the high pass filter
+ */
+ LoadConst_16(0, /* Clear the history, value 0 */
+ (LVM_INT16 *)&pInstance->pData->HPFTaps, /* Destination */
+ sizeof(pInstance->pData->HPFTaps)/sizeof(LVM_INT16)); /* Number of words */
+ BQ_2I_D32F32Cll_TRC_WRA_01_Init(&pInstance->pCoef->HPFInstance, /* Initialise the filter */
+ &pInstance->pData->HPFTaps,
+ (BQ_C32_Coefs_t *)&LVDBE_HPF_Table[Offset]);
+
+
+ /*
+ * Setup the band pass filter
+ */
+ LoadConst_16(0, /* Clear the history, value 0 */
+ (LVM_INT16 *)&pInstance->pData->BPFTaps, /* Destination */
+ sizeof(pInstance->pData->BPFTaps)/sizeof(LVM_INT16)); /* Number of words */
+ BP_1I_D32F32Cll_TRC_WRA_02_Init(&pInstance->pCoef->BPFInstance, /* Initialise the filter */
+ &pInstance->pData->BPFTaps,
+ (BP_C32_Coefs_t *)&LVDBE_BPF_Table[Offset]);
+
+}
+
+
+
+/************************************************************************************/
+/* */
+/* FUNCTION: LVDBE_SetAGC */
+/* */
+/* DESCRIPTION: */
+/* Sets the AGC gain level and attack and decay times constants. */
+/* */
+/* PARAMETERS: */
+/* pInstance Pointer to the instance */
+/* pParams Initialisation parameters */
+/* */
+/************************************************************************************/
+
+void LVDBE_SetAGC(LVDBE_Instance_t *pInstance,
+ LVDBE_Params_t *pParams)
+{
+
+ /*
+ * Get the attack and decay time constants
+ */
+ pInstance->pData->AGCInstance.AGC_Attack = LVDBE_AGC_ATTACK_Table[(LVM_UINT16)pParams->SampleRate]; /* Attack multiplier */
+ pInstance->pData->AGCInstance.AGC_Decay = LVDBE_AGC_DECAY_Table[(LVM_UINT16)pParams->SampleRate]; /* Decay multipler */
+
+
+ /*
+ * Get the boost gain
+ */
+ if (pParams->HPFSelect == LVDBE_HPF_ON)
+ {
+ pInstance->pData->AGCInstance.AGC_MaxGain = LVDBE_AGC_HPFGAIN_Table[(LVM_UINT16)pParams->EffectLevel]; /* High pass filter on */
+ }
+ else
+ {
+ pInstance->pData->AGCInstance.AGC_MaxGain = LVDBE_AGC_GAIN_Table[(LVM_UINT16)pParams->EffectLevel]; /* High pass filter off */
+ }
+ pInstance->pData->AGCInstance.AGC_GainShift = AGC_GAIN_SHIFT;
+ pInstance->pData->AGCInstance.AGC_Target = AGC_TARGETLEVEL;
+
+}
+
+
+/************************************************************************************/
+/* */
+/* FUNCTION: LVDBE_SetVolume */
+/* */
+/* DESCRIPTION: */
+/* Converts the input volume demand from dBs to linear. */
+/* */
+/* PARAMETERS: */
+/* pInstance Pointer to the instance */
+/* pParams Initialisation parameters */
+/* */
+/* NOTES: */
+/* 1. The volume should have the following settings: */
+/* */
+/* DBE Vol Control Volume setting */
+/* === =========== =================== */
+/* Off Off HeadroomdB */
+/* Off On VolumedB+HeadroomdB */
+/* On Off HeadroomdB */
+/* On On VolumedB+HeadroomdB */
+/* */
+/************************************************************************************/
+
+void LVDBE_SetVolume(LVDBE_Instance_t *pInstance,
+ LVDBE_Params_t *pParams)
+{
+
+ LVM_UINT16 dBShifts; /* 6dB shifts */
+ LVM_UINT16 dBOffset; /* Table offset */
+ LVM_INT16 Volume = 0; /* Required volume in dBs */
+
+ /*
+ * Apply the volume if enabled
+ */
+ if (pParams->VolumeControl == LVDBE_VOLUME_ON)
+ {
+ /*
+ * Limit the gain to the maximum allowed
+ */
+ if (pParams->VolumedB > VOLUME_MAX)
+ {
+ Volume = VOLUME_MAX;
+ }
+ else
+ {
+ Volume = pParams->VolumedB;
+ }
+ }
+
+
+ /*
+ * Calculate the required gain and shifts
+ */
+ dBOffset = (LVM_UINT16)(6 + Volume % 6); /* Get the dBs 0-5 */
+ dBShifts = (LVM_UINT16)(Volume / -6); /* Get the 6dB shifts */
+
+
+ /*
+ * When DBE is enabled use AGC volume
+ */
+ pInstance->pData->AGCInstance.Target = ((LVM_INT32)LVDBE_VolumeTable[dBOffset] << 16);
+ pInstance->pData->AGCInstance.Target = pInstance->pData->AGCInstance.Target >> dBShifts;
+
+ pInstance->pData->AGCInstance.VolumeTC = LVDBE_VolumeTCTable[(LVM_UINT16)pParams->SampleRate]; /* Volume update time constant */
+ pInstance->pData->AGCInstance.VolumeShift = VOLUME_SHIFT+1;
+
+ /*
+ * When DBE is disabled use the bypass volume control
+ */
+ if(dBShifts > 0)
+ {
+ LVC_Mixer_SetTarget(&pInstance->pData->BypassVolume.MixerStream[0],(((LVM_INT32)LVDBE_VolumeTable[dBOffset]) >> dBShifts));
+ }
+ else
+ {
+ LVC_Mixer_SetTarget(&pInstance->pData->BypassVolume.MixerStream[0],(LVM_INT32)LVDBE_VolumeTable[dBOffset]);
+ }
+
+ pInstance->pData->BypassVolume.MixerStream[0].CallbackSet = 1;
+ LVC_Mixer_VarSlope_SetTimeConstant(&pInstance->pData->BypassVolume.MixerStream[0],
+ LVDBE_MIXER_TC,
+ (LVM_Fs_en)pInstance->Params.SampleRate,
+ 2);
+}
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVDBE_Control */
+/* */
+/* DESCRIPTION: */
+/* Sets or changes the Bass Enhancement parameters. Changing the parameters while the */
+/* module is processing signals may have the following side effects: */
+/* */
+/* General parameters: */
+/* =================== */
+/* OperatingMode: Changing the mode of operation may cause a change in volume */
+/* level or cause pops and clicks. */
+/* */
+/* SampleRate: Changing the sample rate may cause pops and clicks. */
+/* */
+/* EffectLevel: Changing the effect level may cause pops and clicks */
+/* */
+/* CentreFrequency: Changing the centre frequency may cause pops and clicks */
+/* */
+/* HPFSelect: Selecting/de-selecting the high pass filter may cause pops and */
+/* clicks */
+/* */
+/* VolumedB Changing the volume setting will have no side effects */
+/* */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* pParams Pointer to a parameter structure */
+/* */
+/* RETURNS: */
+/* LVDBE_SUCCESS Always succeeds */
+/* */
+/* NOTES: */
+/* 1. This function must not be interrupted by the LVDBE_Process function */
+/* */
+/****************************************************************************************/
+
+LVDBE_ReturnStatus_en LVDBE_Control(LVDBE_Handle_t hInstance,
+ LVDBE_Params_t *pParams)
+{
+
+ LVDBE_Instance_t *pInstance =(LVDBE_Instance_t *)hInstance;
+
+
+ /*
+ * Update the filters
+ */
+ if ((pInstance->Params.SampleRate != pParams->SampleRate) ||
+ (pInstance->Params.CentreFrequency != pParams->CentreFrequency))
+ {
+ LVDBE_SetFilters(pInstance, /* Instance pointer */
+ pParams); /* New parameters */
+ }
+
+
+ /*
+ * Update the AGC is the effect level has changed
+ */
+ if ((pInstance->Params.SampleRate != pParams->SampleRate) ||
+ (pInstance->Params.EffectLevel != pParams->EffectLevel) ||
+ (pInstance->Params.HPFSelect != pParams->HPFSelect))
+ {
+ LVDBE_SetAGC(pInstance, /* Instance pointer */
+ pParams); /* New parameters */
+ }
+
+
+ /*
+ * Update the Volume if the volume demand has changed
+ */
+ if ((pInstance->Params.VolumedB != pParams->VolumedB) ||
+ (pInstance->Params.SampleRate != pParams->SampleRate) ||
+ (pInstance->Params.HeadroomdB != pParams->HeadroomdB) ||
+ (pInstance->Params.VolumeControl != pParams->VolumeControl))
+ {
+ LVDBE_SetVolume(pInstance, /* Instance pointer */
+ pParams); /* New parameters */
+ }
+
+ if (pInstance->Params.OperatingMode==LVDBE_ON && pParams->OperatingMode==LVDBE_OFF)
+ {
+ LVDBE_Params_t Params = *pParams; /* make local copy of params */
+ Params.EffectLevel = 0; /* zero effect level before switching off module*/
+ pInstance->bTransitionOnToOff = LVM_TRUE; /* Set the CallBack */
+ LVDBE_SetAGC(pInstance, /* Instance pointer */
+ &Params); /* New parameters */
+ }
+ if (pInstance->Params.OperatingMode==LVDBE_OFF && pParams->OperatingMode==LVDBE_ON)
+ {
+ pInstance->bTransitionOnToOff = LVM_FALSE; /* Set the CallBack */
+ LVDBE_SetAGC(pInstance, /* Instance pointer */
+ pParams); /* New parameters */
+ }
+
+ /*
+ * Update the instance parameters
+ */
+ pInstance->Params = *pParams;
+
+
+ return(LVDBE_SUCCESS);
+}
diff --git a/media/libeffects/lvm/lib/Bass/src/LVDBE_Init.c b/media/libeffects/lvm/lib/Bass/src/LVDBE_Init.c
new file mode 100755
index 0000000..75869c7
--- /dev/null
+++ b/media/libeffects/lvm/lib/Bass/src/LVDBE_Init.c
@@ -0,0 +1,267 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/****************************************************************************************
+
+ $Author: nxp007753 $
+ $Revision: 1081 $
+ $Date: 2010-07-05 11:48:44 +0200 (Mon, 05 Jul 2010) $
+
+*****************************************************************************************/
+
+/****************************************************************************************/
+/* */
+/* Includes */
+/* */
+/****************************************************************************************/
+
+#include "LVDBE.h"
+#include "LVDBE_Private.h"
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVDBE_Memory */
+/* */
+/* DESCRIPTION: */
+/* This function is used for memory allocation and free. It can be called in */
+/* two ways: */
+/* */
+/* hInstance = NULL Returns the memory requirements */
+/* hInstance = Instance handle Returns the memory requirements and */
+/* allocated base addresses for the instance */
+/* */
+/* When this function is called for memory allocation (hInstance=NULL) the memory */
+/* base address pointers are NULL on return. */
+/* */
+/* When the function is called for free (hInstance = Instance Handle) the memory */
+/* table returns the allocated memory and base addresses used during initialisation. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance Handle */
+/* pMemoryTable Pointer to an empty memory definition table */
+/* pCapabilities Pointer to the instance capabilities */
+/* */
+/* RETURNS: */
+/* LVDBE_SUCCESS Succeeded */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVDBE_Process function */
+/* */
+/****************************************************************************************/
+
+LVDBE_ReturnStatus_en LVDBE_Memory(LVDBE_Handle_t hInstance,
+ LVDBE_MemTab_t *pMemoryTable,
+ LVDBE_Capabilities_t *pCapabilities)
+{
+
+ LVM_UINT32 ScratchSize;
+ LVDBE_Instance_t *pInstance = (LVDBE_Instance_t *)hInstance;
+
+
+ /*
+ * Fill in the memory table
+ */
+ if (hInstance == LVM_NULL)
+ {
+ /*
+ * Instance memory
+ */
+ pMemoryTable->Region[LVDBE_MEMREGION_INSTANCE].Size = sizeof(LVDBE_Instance_t);
+ pMemoryTable->Region[LVDBE_MEMREGION_INSTANCE].Alignment = LVDBE_INSTANCE_ALIGN;
+ pMemoryTable->Region[LVDBE_MEMREGION_INSTANCE].Type = LVDBE_PERSISTENT;
+ pMemoryTable->Region[LVDBE_MEMREGION_INSTANCE].pBaseAddress = LVM_NULL;
+
+ /*
+ * Data memory
+ */
+ pMemoryTable->Region[LVDBE_MEMREGION_PERSISTENT_DATA].Size = sizeof(LVDBE_Data_t);
+ pMemoryTable->Region[LVDBE_MEMREGION_PERSISTENT_DATA].Alignment = LVDBE_PERSISTENT_DATA_ALIGN;
+ pMemoryTable->Region[LVDBE_MEMREGION_PERSISTENT_DATA].Type = LVDBE_PERSISTENT_DATA;
+ pMemoryTable->Region[LVDBE_MEMREGION_PERSISTENT_DATA].pBaseAddress = LVM_NULL;
+
+ /*
+ * Coef memory
+ */
+ pMemoryTable->Region[LVDBE_MEMREGION_PERSISTENT_COEF].Size = sizeof(LVDBE_Coef_t);
+ pMemoryTable->Region[LVDBE_MEMREGION_PERSISTENT_COEF].Alignment = LVDBE_PERSISTENT_COEF_ALIGN;
+ pMemoryTable->Region[LVDBE_MEMREGION_PERSISTENT_COEF].Type = LVDBE_PERSISTENT_COEF;
+ pMemoryTable->Region[LVDBE_MEMREGION_PERSISTENT_COEF].pBaseAddress = LVM_NULL;
+
+ /*
+ * Scratch memory
+ */
+ ScratchSize = (LVM_UINT32)(LVDBE_SCRATCHBUFFERS_INPLACE*sizeof(LVM_INT16)*pCapabilities->MaxBlockSize);
+ pMemoryTable->Region[LVDBE_MEMREGION_SCRATCH].Size = ScratchSize;
+ pMemoryTable->Region[LVDBE_MEMREGION_SCRATCH].Alignment = LVDBE_SCRATCH_ALIGN;
+ pMemoryTable->Region[LVDBE_MEMREGION_SCRATCH].Type = LVDBE_SCRATCH;
+ pMemoryTable->Region[LVDBE_MEMREGION_SCRATCH].pBaseAddress = LVM_NULL;
+ }
+ else
+ {
+ /* Read back memory allocation table */
+ *pMemoryTable = pInstance->MemoryTable;
+ }
+
+ return(LVDBE_SUCCESS);
+}
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVDBE_Init */
+/* */
+/* DESCRIPTION: */
+/* Create and initialisation function for the Dynamic Bass Enhancement module */
+/* */
+/* This function can be used to create an algorithm instance by calling with */
+/* hInstance set to NULL. In this case the algorithm returns the new instance */
+/* handle. */
+/* */
+/* This function can be used to force a full re-initialisation of the algorithm */
+/* by calling with hInstance = Instance Handle. In this case the memory table */
+/* should be correct for the instance, this can be ensured by calling the function */
+/* DBE_Memory before calling this function. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* pMemoryTable Pointer to the memory definition table */
+/* pCapabilities Pointer to the instance capabilities */
+/* */
+/* RETURNS: */
+/* LVDBE_SUCCESS Initialisation succeeded */
+/* LVDBE_ALIGNMENTERROR Instance or scratch memory on incorrect alignment */
+/* LVDBE_NULLADDRESS Instance or scratch memory has a NULL pointer */
+/* */
+/* NOTES: */
+/* 1. The instance handle is the pointer to the base address of the first memory */
+/* region. */
+/* 2. This function must not be interrupted by the LVDBE_Process function */
+/* */
+/****************************************************************************************/
+
+LVDBE_ReturnStatus_en LVDBE_Init(LVDBE_Handle_t *phInstance,
+ LVDBE_MemTab_t *pMemoryTable,
+ LVDBE_Capabilities_t *pCapabilities)
+{
+
+ LVDBE_Instance_t *pInstance;
+ LVMixer3_1St_st *pMixer_Instance;
+ LVM_INT16 i;
+ LVM_INT32 MixGain;
+
+
+ /*
+ * Set the instance handle if not already initialised
+ */
+ if (*phInstance == LVM_NULL)
+ {
+ *phInstance = (LVDBE_Handle_t)pMemoryTable->Region[LVDBE_MEMREGION_INSTANCE].pBaseAddress;
+ }
+ pInstance =(LVDBE_Instance_t *)*phInstance;
+
+
+ /*
+ * Check the memory table for NULL pointers and incorrectly aligned data
+ */
+ for (i=0; i<LVDBE_NR_MEMORY_REGIONS; i++)
+ {
+ if (pMemoryTable->Region[i].Size!=0)
+ {
+ if (pMemoryTable->Region[i].pBaseAddress==LVM_NULL)
+ {
+ return(LVDBE_NULLADDRESS);
+ }
+ if (((LVM_UINT32)pMemoryTable->Region[i].pBaseAddress % pMemoryTable->Region[i].Alignment)!=0){
+ return(LVDBE_ALIGNMENTERROR);
+ }
+ }
+ }
+
+
+ /*
+ * Save the memory table in the instance structure
+ */
+ pInstance->Capabilities = *pCapabilities;
+
+
+ /*
+ * Save the memory table in the instance structure
+ */
+ pInstance->MemoryTable = *pMemoryTable;
+
+
+ /*
+ * Set the default instance parameters
+ */
+ pInstance->Params.CentreFrequency = LVDBE_CENTRE_55HZ;
+ pInstance->Params.EffectLevel = 0;
+ pInstance->Params.HeadroomdB = 0;
+ pInstance->Params.HPFSelect = LVDBE_HPF_OFF;
+ pInstance->Params.OperatingMode = LVDBE_OFF;
+ pInstance->Params.SampleRate = LVDBE_FS_8000;
+ pInstance->Params.VolumeControl = LVDBE_VOLUME_OFF;
+ pInstance->Params.VolumedB = 0;
+
+
+ /*
+ * Set pointer to data and coef memory
+ */
+ pInstance->pData = pMemoryTable->Region[LVDBE_MEMREGION_PERSISTENT_DATA].pBaseAddress;
+ pInstance->pCoef = pMemoryTable->Region[LVDBE_MEMREGION_PERSISTENT_COEF].pBaseAddress;
+
+
+ /*
+ * Initialise the filters
+ */
+ LVDBE_SetFilters(pInstance, /* Set the filter taps and coefficients */
+ &pInstance->Params);
+
+
+ /*
+ * Initialise the AGC
+ */
+ LVDBE_SetAGC(pInstance, /* Set the AGC gain */
+ &pInstance->Params);
+ pInstance->pData->AGCInstance.AGC_Gain = pInstance->pData->AGCInstance.AGC_MaxGain; /* Default to the bass boost setting */
+
+
+ /*
+ * Initialise the volume
+ */
+ LVDBE_SetVolume(pInstance, /* Set the Volume */
+ &pInstance->Params);
+
+ pInstance->pData->AGCInstance.Volume = pInstance->pData->AGCInstance.Target; /* Initialise as the target */
+
+ pMixer_Instance = &pInstance->pData->BypassVolume;
+ MixGain = LVC_Mixer_GetTarget(&pMixer_Instance->MixerStream[0]);
+ LVC_Mixer_Init(&pMixer_Instance->MixerStream[0],MixGain,MixGain);
+
+ /* Configure the mixer process path */
+ pMixer_Instance->MixerStream[0].CallbackParam = 0;
+ pMixer_Instance->MixerStream[0].pCallbackHandle = LVM_NULL;
+ pMixer_Instance->MixerStream[0].pCallBack = LVM_NULL;
+ pMixer_Instance->MixerStream[0].CallbackSet = 0;
+
+ /*
+ * Initialise the clicks minimisation variable
+ */
+ pInstance->bTransitionOnToOff = LVM_FALSE;
+
+ return(LVDBE_SUCCESS);
+}
+
diff --git a/media/libeffects/lvm/lib/Bass/src/LVDBE_Private.h b/media/libeffects/lvm/lib/Bass/src/LVDBE_Private.h
new file mode 100755
index 0000000..3e09cf4
--- /dev/null
+++ b/media/libeffects/lvm/lib/Bass/src/LVDBE_Private.h
@@ -0,0 +1,148 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/****************************************************************************************
+
+ $Author: nxp007753 $
+ $Revision: 1081 $
+ $Date: 2010-07-05 11:48:44 +0200 (Mon, 05 Jul 2010) $
+
+*****************************************************************************************/
+
+/****************************************************************************************/
+/* */
+/* Header file for the private layer interface of Dynamic Bass Enhancement module */
+/* */
+/* This files includes all definitions, types, structures and function */
+/* prototypes required by the execution layer. */
+/* */
+/****************************************************************************************/
+
+#ifndef __LVDBE_PRIVATE_H__
+#define __LVDBE_PRIVATE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/****************************************************************************************/
+/* */
+/* Includes */
+/* */
+/****************************************************************************************/
+
+#include "LVDBE.h" /* Calling or Application layer definitions */
+#include "BIQUAD.h"
+#include "LVC_Mixer.h"
+#include "AGC.h"
+
+
+/****************************************************************************************/
+/* */
+/* Defines */
+/* */
+/****************************************************************************************/
+
+/* General */
+#define LVDBE_INVALID 0xFFFF /* Invalid init parameter */
+
+/* Memory */
+#define LVDBE_MEMREGION_INSTANCE 0 /* Offset to the instance memory region */
+#define LVDBE_MEMREGION_PERSISTENT_DATA 1 /* Offset to persistent data memory region */
+#define LVDBE_MEMREGION_PERSISTENT_COEF 2 /* Offset to persistent coefficient region */
+#define LVDBE_MEMREGION_SCRATCH 3 /* Offset to data scratch memory region */
+
+#define LVDBE_INSTANCE_ALIGN 4 /* 32-bit alignment for structures */
+#define LVDBE_PERSISTENT_DATA_ALIGN 4 /* 32-bit alignment for data */
+#define LVDBE_PERSISTENT_COEF_ALIGN 4 /* 32-bit alignment for coef */
+#define LVDBE_SCRATCH_ALIGN 4 /* 32-bit alignment for long data */
+
+#define LVDBE_SCRATCHBUFFERS_INPLACE 4 /* Number of buffers required for inplace processing */
+
+#define LVDBE_MIXER_TC 5 /* Mixer time */
+
+/****************************************************************************************/
+/* */
+/* Structures */
+/* */
+/****************************************************************************************/
+
+/* Data structure */
+typedef struct
+{
+ /* AGC parameters */
+ AGC_MIX_VOL_2St1Mon_D32_t AGCInstance; /* AGC instance parameters */
+
+ /* Process variables */
+ Biquad_2I_Order2_Taps_t HPFTaps; /* High pass filter taps */
+ Biquad_1I_Order2_Taps_t BPFTaps; /* Band pass filter taps */
+ LVMixer3_1St_st BypassVolume; /* Bypass volume scaler */
+
+} LVDBE_Data_t;
+
+/* Coefs structure */
+typedef struct
+{
+ /* Process variables */
+ Biquad_Instance_t HPFInstance; /* High pass filter instance */
+ Biquad_Instance_t BPFInstance; /* Band pass filter instance */
+
+} LVDBE_Coef_t;
+
+/* Instance structure */
+typedef struct
+{
+ /* Public parameters */
+ LVDBE_MemTab_t MemoryTable; /* Instance memory allocation table */
+ LVDBE_Params_t Params; /* Instance parameters */
+ LVDBE_Capabilities_t Capabilities; /* Instance capabilities */
+
+ /* Data and coefficient pointers */
+ LVDBE_Data_t *pData; /* Instance data */
+ LVDBE_Coef_t *pCoef; /* Instance coefficients */
+
+ LVM_INT32 bTransitionOnToOff;
+
+} LVDBE_Instance_t;
+
+
+/****************************************************************************************/
+/* */
+/* Function prototypes */
+/* */
+/****************************************************************************************/
+
+void LVDBE_SetAGC(LVDBE_Instance_t *pInstance,
+ LVDBE_Params_t *pParams);
+
+
+void LVDBE_SetVolume(LVDBE_Instance_t *pInstance,
+ LVDBE_Params_t *pParams);
+
+
+void LVDBE_SetFilters(LVDBE_Instance_t *pInstance,
+ LVDBE_Params_t *pParams);
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __LVDBE_PRIVATE_H__ */
+
+
diff --git a/media/libeffects/lvm/lib/Bass/src/LVDBE_Process.c b/media/libeffects/lvm/lib/Bass/src/LVDBE_Process.c
new file mode 100755
index 0000000..35eec07
--- /dev/null
+++ b/media/libeffects/lvm/lib/Bass/src/LVDBE_Process.c
@@ -0,0 +1,205 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/****************************************************************************************
+
+ $Author: nxp007753 $
+ $Revision: 1081 $
+ $Date: 2010-07-05 11:48:44 +0200 (Mon, 05 Jul 2010) $
+
+*****************************************************************************************/
+
+/****************************************************************************************/
+/* */
+/* Includes */
+/* */
+/****************************************************************************************/
+
+#include "LVDBE.h"
+#include "LVDBE_Private.h"
+#include "VectorArithmetic.h"
+#include "AGC.h"
+#include "LVDBE_Coeffs.h" /* Filter coefficients */
+
+
+/********************************************************************************************/
+/* */
+/* FUNCTION: LVDBE_Process */
+/* */
+/* DESCRIPTION: */
+/* Process function for the Bass Enhancement module. */
+/* */
+/* Data can be processed in two formats, stereo or mono-in-stereo. Data in mono */
+/* format is not supported, the calling routine must convert the mono stream to */
+/* mono-in-stereo. */
+/* ___________ */
+/* ________ | | ________ */
+/* | | _____ |------------------------->| | | | */
+/* | 16-bit | | | | ________ | | | 32-bit | */
+/* -+-->| to |-->| HPF |--| | | _____ | AGC Mixer |-->| to |--| */
+/* | | 32-bit | |_____| | | Stereo | | | | | | 16-bit | | */
+/* | |________| |-->| to |-->| BPF |-->| | |________| 0 */
+/* | | Mono | |_____| |___________| \--> */
+/* | |________| */
+/* | _________ 0 */
+/* | | | | */
+/* |----------------------------------------------------| Volume |-----------------| */
+/* | Control | */
+/* |_________| */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* pInData Pointer to the input data */
+/* pOutData Pointer to the output data */
+/* NumSamples Number of samples in the input buffer */
+/* */
+/* RETURNS: */
+/* LVDBE_SUCCESS Succeeded */
+/* LVDBE_TOOMANYSAMPLES NumSamples was larger than the maximum block size */
+/* */
+/* NOTES: */
+/* 1. The input and output data must be 32-bit format. The input is scaled by a shift */
+/* when converting from 16-bit format, this scaling allows for internal headroom in the */
+/* bass enhancement algorithm. */
+/* 2. For a 16-bit implementation the converstion to 32-bit is removed and replaced with */
+/* the headroom loss. This headroom loss is compensated in the volume control so the */
+/* overall end to end gain is odB. */
+/* */
+/********************************************************************************************/
+
+LVDBE_ReturnStatus_en LVDBE_Process(LVDBE_Handle_t hInstance,
+ const LVM_INT16 *pInData,
+ LVM_INT16 *pOutData,
+ LVM_UINT16 NumSamples)
+{
+
+ LVDBE_Instance_t *pInstance =(LVDBE_Instance_t *)hInstance;
+ LVM_INT32 *pScratch = (LVM_INT32 *)pInstance->MemoryTable.Region[LVDBE_MEMREGION_SCRATCH].pBaseAddress;
+ LVM_INT32 *pMono = (LVM_INT32 *)pOutData;
+ LVM_INT16 *pInput = (LVM_INT16 *)pInData;
+
+
+ /*
+ * Check the number of samples is not too large
+ */
+ if (NumSamples > pInstance->Capabilities.MaxBlockSize)
+ {
+ return(LVDBE_TOOMANYSAMPLES);
+ }
+
+ /*
+ * Check if the algorithm is enabled
+ */
+ if ((pInstance->Params.OperatingMode != LVDBE_OFF) ||
+ (pInstance->bTransitionOnToOff == LVM_TRUE))
+ {
+
+ /*
+ * Convert 16-bit samples to 32-bit and scale
+ * (For a 16-bit implementation apply headroom loss here)
+ */
+ Int16LShiftToInt32_16x32(pInput, /* Source 16-bit data */
+ pScratch, /* Destination 32-bit data */
+ (LVM_INT16)(2*NumSamples), /* Left and right */
+ LVDBE_SCALESHIFT); /* Shift scale */
+
+
+ /*
+ * Apply the high pass filter if selected
+ */
+ if (pInstance->Params.HPFSelect == LVDBE_HPF_ON)
+ {
+ BQ_2I_D32F32C30_TRC_WRA_01(&pInstance->pCoef->HPFInstance, /* Filter instance */
+ (LVM_INT32 *)pScratch, /* Source */
+ (LVM_INT32 *)pScratch, /* Destination */
+ (LVM_INT16)NumSamples); /* Number of samples */
+ }
+
+
+ /*
+ * Create the mono stream
+ */
+ From2iToMono_32(pScratch, /* Stereo source */
+ pMono, /* Mono destination */
+ (LVM_INT16)NumSamples); /* Number of samples */
+
+
+ /*
+ * Apply the band pass filter
+ */
+ BP_1I_D32F32C30_TRC_WRA_02(&pInstance->pCoef->BPFInstance, /* Filter instance */
+ (LVM_INT32 *)pMono, /* Source */
+ (LVM_INT32 *)pMono, /* Destination */
+ (LVM_INT16)NumSamples); /* Number of samples */
+
+
+ /*
+ * Apply the AGC and mix
+ */
+ AGC_MIX_VOL_2St1Mon_D32_WRA(&pInstance->pData->AGCInstance, /* Instance pointer */
+ pScratch, /* Stereo source */
+ pMono, /* Mono band pass source */
+ pScratch, /* Stereo destination */
+ NumSamples); /* Number of samples */
+
+ if(pInstance->bTransitionOnToOff == LVM_TRUE)
+ {
+ if ((pInstance->pData->AGCInstance.AGC_Gain == pInstance->pData->AGCInstance.AGC_Target)&&
+ (pInstance->pData->AGCInstance.AGC_Gain == 0))
+ {
+ pInstance->bTransitionOnToOff = LVM_FALSE;
+ }
+ }
+
+
+
+ /*
+ * Convert 32-bit samples to 16-bit and saturate
+ * (Not required for 16-bit implemenations)
+ */
+ Int32RShiftToInt16_Sat_32x16(pScratch, /* Source 32-bit data */
+ pOutData, /* Destination 16-bit data */
+ (LVM_INT16)(2*NumSamples), /* Left and right */
+ LVDBE_SCALESHIFT); /* Shift scale */
+
+ }
+ else
+ {
+
+ /*
+ * The algorithm is disabled but volume management is required to compensate for
+ * headroom and volume (if enabled)
+ */
+ LVC_MixSoft_1St_D16C31_SAT(&pInstance->pData->BypassVolume,
+ pInData,
+ pOutData,
+ (LVM_INT16)(2*NumSamples)); /* Left and right */
+
+ }
+
+ return(LVDBE_SUCCESS);
+}
+
+
+
+
+
+
+
+
+
+
diff --git a/media/libeffects/lvm/lib/Bass/src/LVDBE_Tables.c b/media/libeffects/lvm/lib/Bass/src/LVDBE_Tables.c
new file mode 100755
index 0000000..da8ca5a
--- /dev/null
+++ b/media/libeffects/lvm/lib/Bass/src/LVDBE_Tables.c
@@ -0,0 +1,463 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+/************************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1009 $
+ $Date: 2010-06-28 14:14:15 +0200 (Mon, 28 Jun 2010) $
+
+*************************************************************************************/
+
+
+/************************************************************************************/
+/* */
+/* Includes */
+/* */
+/************************************************************************************/
+
+#include "LVDBE.h"
+#include "LVDBE_Coeffs.h" /* Filter coefficients */
+#include "BIQUAD.h"
+
+
+/************************************************************************************/
+/* */
+/* Coefficients constant table */
+/* */
+/************************************************************************************/
+
+/*
+ * High Pass Filter Coefficient table
+ */
+const BQ_C32_Coefs_t LVDBE_HPF_Table[] = {
+ /* Coefficients for 55Hz centre frequency */
+ {HPF_Fs8000_Fc55_A2, /* 8kS/s coefficients */
+ HPF_Fs8000_Fc55_A1,
+ HPF_Fs8000_Fc55_A0,
+ -HPF_Fs8000_Fc55_B2,
+ -HPF_Fs8000_Fc55_B1},
+ {HPF_Fs11025_Fc55_A2, /* 11kS/s coefficients */
+ HPF_Fs11025_Fc55_A1,
+ HPF_Fs11025_Fc55_A0,
+ -HPF_Fs11025_Fc55_B2,
+ -HPF_Fs11025_Fc55_B1},
+ {HPF_Fs12000_Fc55_A2, /* 12kS/s coefficients */
+ HPF_Fs12000_Fc55_A1,
+ HPF_Fs12000_Fc55_A0,
+ -HPF_Fs12000_Fc55_B2,
+ -HPF_Fs12000_Fc55_B1},
+ {HPF_Fs16000_Fc55_A2, /* 16kS/s coefficients */
+ HPF_Fs16000_Fc55_A1,
+ HPF_Fs16000_Fc55_A0,
+ -HPF_Fs16000_Fc55_B2,
+ -HPF_Fs16000_Fc55_B1},
+ {HPF_Fs22050_Fc55_A2, /* 22kS/s coefficients */
+ HPF_Fs22050_Fc55_A1,
+ HPF_Fs22050_Fc55_A0,
+ -HPF_Fs22050_Fc55_B2,
+ -HPF_Fs22050_Fc55_B1},
+ {HPF_Fs24000_Fc55_A2, /* 24kS/s coefficients */
+ HPF_Fs24000_Fc55_A1,
+ HPF_Fs24000_Fc55_A0,
+ -HPF_Fs24000_Fc55_B2,
+ -HPF_Fs24000_Fc55_B1},
+ {HPF_Fs32000_Fc55_A2, /* 32kS/s coefficients */
+ HPF_Fs32000_Fc55_A1,
+ HPF_Fs32000_Fc55_A0,
+ -HPF_Fs32000_Fc55_B2,
+ -HPF_Fs32000_Fc55_B1},
+ {HPF_Fs44100_Fc55_A2, /* 44kS/s coefficients */
+ HPF_Fs44100_Fc55_A1,
+ HPF_Fs44100_Fc55_A0,
+ -HPF_Fs44100_Fc55_B2,
+ -HPF_Fs44100_Fc55_B1},
+ {HPF_Fs48000_Fc55_A2, /* 48kS/s coefficients */
+ HPF_Fs48000_Fc55_A1,
+ HPF_Fs48000_Fc55_A0,
+ -HPF_Fs48000_Fc55_B2,
+ -HPF_Fs48000_Fc55_B1},
+
+ /* Coefficients for 66Hz centre frequency */
+ {HPF_Fs8000_Fc66_A2, /* 8kS/s coefficients */
+ HPF_Fs8000_Fc66_A1,
+ HPF_Fs8000_Fc66_A0,
+ -HPF_Fs8000_Fc66_B2,
+ -HPF_Fs8000_Fc66_B1},
+ {HPF_Fs11025_Fc66_A2, /* 11kS/s coefficients */
+ HPF_Fs11025_Fc66_A1,
+ HPF_Fs11025_Fc66_A0,
+ -HPF_Fs11025_Fc66_B2,
+ -HPF_Fs11025_Fc66_B1},
+ {HPF_Fs12000_Fc66_A2, /* 12kS/s coefficients */
+ HPF_Fs12000_Fc66_A1,
+ HPF_Fs12000_Fc66_A0,
+ -HPF_Fs12000_Fc66_B2,
+ -HPF_Fs12000_Fc66_B1},
+ {HPF_Fs16000_Fc66_A2, /* 16kS/s coefficients */
+ HPF_Fs16000_Fc66_A1,
+ HPF_Fs16000_Fc66_A0,
+ -HPF_Fs16000_Fc66_B2,
+ -HPF_Fs16000_Fc66_B1},
+ {HPF_Fs22050_Fc66_A2, /* 22kS/s coefficients */
+ HPF_Fs22050_Fc66_A1,
+ HPF_Fs22050_Fc66_A0,
+ -HPF_Fs22050_Fc66_B2,
+ -HPF_Fs22050_Fc66_B1},
+ {HPF_Fs24000_Fc66_A2, /* 24kS/s coefficients */
+ HPF_Fs24000_Fc66_A1,
+ HPF_Fs24000_Fc66_A0,
+ -HPF_Fs24000_Fc66_B2,
+ -HPF_Fs24000_Fc66_B1},
+ {HPF_Fs32000_Fc66_A2, /* 32kS/s coefficients */
+ HPF_Fs32000_Fc66_A1,
+ HPF_Fs32000_Fc66_A0,
+ -HPF_Fs32000_Fc66_B2,
+ -HPF_Fs32000_Fc66_B1},
+ {HPF_Fs44100_Fc66_A2, /* 44kS/s coefficients */
+ HPF_Fs44100_Fc66_A1,
+ HPF_Fs44100_Fc66_A0,
+ -HPF_Fs44100_Fc66_B2,
+ -HPF_Fs44100_Fc66_B1},
+ {HPF_Fs48000_Fc66_A2, /* 48kS/s coefficients */
+ HPF_Fs48000_Fc66_A1,
+ HPF_Fs48000_Fc66_A0,
+ -HPF_Fs48000_Fc66_B2,
+ -HPF_Fs48000_Fc66_B1},
+
+ /* Coefficients for 78Hz centre frequency */
+ {HPF_Fs8000_Fc78_A2, /* 8kS/s coefficients */
+ HPF_Fs8000_Fc78_A1,
+ HPF_Fs8000_Fc78_A0,
+ -HPF_Fs8000_Fc78_B2,
+ -HPF_Fs8000_Fc78_B1},
+ {HPF_Fs11025_Fc78_A2, /* 11kS/s coefficients */
+ HPF_Fs11025_Fc78_A1,
+ HPF_Fs11025_Fc78_A0,
+ -HPF_Fs11025_Fc78_B2,
+ -HPF_Fs11025_Fc78_B1},
+ {HPF_Fs12000_Fc78_A2, /* 12kS/s coefficients */
+ HPF_Fs12000_Fc78_A1,
+ HPF_Fs12000_Fc78_A0,
+ -HPF_Fs12000_Fc78_B2,
+ -HPF_Fs12000_Fc78_B1},
+ {HPF_Fs16000_Fc78_A2, /* 16kS/s coefficients */
+ HPF_Fs16000_Fc78_A1,
+ HPF_Fs16000_Fc78_A0,
+ -HPF_Fs16000_Fc78_B2,
+ -HPF_Fs16000_Fc78_B1},
+ {HPF_Fs22050_Fc78_A2, /* 22kS/s coefficients */
+ HPF_Fs22050_Fc78_A1,
+ HPF_Fs22050_Fc78_A0,
+ -HPF_Fs22050_Fc78_B2,
+ -HPF_Fs22050_Fc78_B1},
+ {HPF_Fs24000_Fc78_A2, /* 24kS/s coefficients */
+ HPF_Fs24000_Fc78_A1,
+ HPF_Fs24000_Fc78_A0,
+ -HPF_Fs24000_Fc78_B2,
+ -HPF_Fs24000_Fc78_B1},
+ {HPF_Fs32000_Fc78_A2, /* 32kS/s coefficients */
+ HPF_Fs32000_Fc78_A1,
+ HPF_Fs32000_Fc78_A0,
+ -HPF_Fs32000_Fc78_B2,
+ -HPF_Fs32000_Fc78_B1},
+ {HPF_Fs44100_Fc78_A2, /* 44kS/s coefficients */
+ HPF_Fs44100_Fc78_A1,
+ HPF_Fs44100_Fc78_A0,
+ -HPF_Fs44100_Fc78_B2,
+ -HPF_Fs44100_Fc78_B1},
+ {HPF_Fs48000_Fc78_A2, /* 48kS/s coefficients */
+ HPF_Fs48000_Fc78_A1,
+ HPF_Fs48000_Fc78_A0,
+ -HPF_Fs48000_Fc78_B2,
+ -HPF_Fs48000_Fc78_B1},
+
+ /* Coefficients for 90Hz centre frequency */
+ {HPF_Fs8000_Fc90_A2, /* 8kS/s coefficients */
+ HPF_Fs8000_Fc90_A1,
+ HPF_Fs8000_Fc90_A0,
+ -HPF_Fs8000_Fc90_B2,
+ -HPF_Fs8000_Fc90_B1},
+ {HPF_Fs11025_Fc90_A2, /* 11kS/s coefficients */
+ HPF_Fs11025_Fc90_A1,
+ HPF_Fs11025_Fc90_A0,
+ -HPF_Fs11025_Fc90_B2,
+ -HPF_Fs11025_Fc90_B1},
+ {HPF_Fs12000_Fc90_A2, /* 12kS/s coefficients */
+ HPF_Fs12000_Fc90_A1,
+ HPF_Fs12000_Fc90_A0,
+ -HPF_Fs12000_Fc90_B2,
+ -HPF_Fs12000_Fc90_B1},
+ {HPF_Fs16000_Fc90_A2, /* 16kS/s coefficients */
+ HPF_Fs16000_Fc90_A1,
+ HPF_Fs16000_Fc90_A0,
+ -HPF_Fs16000_Fc90_B2,
+ -HPF_Fs16000_Fc90_B1},
+ {HPF_Fs22050_Fc90_A2, /* 22kS/s coefficients */
+ HPF_Fs22050_Fc90_A1,
+ HPF_Fs22050_Fc90_A0,
+ -HPF_Fs22050_Fc90_B2,
+ -HPF_Fs22050_Fc90_B1},
+ {HPF_Fs24000_Fc90_A2, /* 24kS/s coefficients */
+ HPF_Fs24000_Fc90_A1,
+ HPF_Fs24000_Fc90_A0,
+ -HPF_Fs24000_Fc90_B2,
+ -HPF_Fs24000_Fc90_B1},
+ {HPF_Fs32000_Fc90_A2, /* 32kS/s coefficients */
+ HPF_Fs32000_Fc90_A1,
+ HPF_Fs32000_Fc90_A0,
+ -HPF_Fs32000_Fc90_B2,
+ -HPF_Fs32000_Fc90_B1},
+ {HPF_Fs44100_Fc90_A2, /* 44kS/s coefficients */
+ HPF_Fs44100_Fc90_A1,
+ HPF_Fs44100_Fc90_A0,
+ -HPF_Fs44100_Fc90_B2,
+ -HPF_Fs44100_Fc90_B1},
+ {HPF_Fs48000_Fc90_A2, /* 48kS/s coefficients */
+ HPF_Fs48000_Fc90_A1,
+ HPF_Fs48000_Fc90_A0,
+ -HPF_Fs48000_Fc90_B2,
+ -HPF_Fs48000_Fc90_B1}};
+
+/*
+ * Band Pass Filter coefficient table
+ */
+const BP_C32_Coefs_t LVDBE_BPF_Table[] = {
+ /* Coefficients for 55Hz centre frequency */
+ {BPF_Fs8000_Fc55_A0, /* 8kS/s coefficients */
+ -BPF_Fs8000_Fc55_B2,
+ -BPF_Fs8000_Fc55_B1},
+ {BPF_Fs11025_Fc55_A0, /* 11kS/s coefficients */
+ -BPF_Fs11025_Fc55_B2,
+ -BPF_Fs11025_Fc55_B1},
+ {BPF_Fs12000_Fc55_A0, /* 12kS/s coefficients */
+ -BPF_Fs12000_Fc55_B2,
+ -BPF_Fs12000_Fc55_B1},
+ {BPF_Fs16000_Fc55_A0, /* 16kS/s coefficients */
+ -BPF_Fs16000_Fc55_B2,
+ -BPF_Fs16000_Fc55_B1},
+ {BPF_Fs22050_Fc55_A0, /* 22kS/s coefficients */
+ -BPF_Fs22050_Fc55_B2,
+ -BPF_Fs22050_Fc55_B1},
+ {BPF_Fs24000_Fc55_A0, /* 24kS/s coefficients */
+ -BPF_Fs24000_Fc55_B2,
+ -BPF_Fs24000_Fc55_B1},
+ {BPF_Fs32000_Fc55_A0, /* 32kS/s coefficients */
+ -BPF_Fs32000_Fc55_B2,
+ -BPF_Fs32000_Fc55_B1},
+ {BPF_Fs44100_Fc55_A0, /* 44kS/s coefficients */
+ -BPF_Fs44100_Fc55_B2,
+ -BPF_Fs44100_Fc55_B1},
+ {BPF_Fs48000_Fc55_A0, /* 48kS/s coefficients */
+ -BPF_Fs48000_Fc55_B2,
+ -BPF_Fs48000_Fc55_B1},
+
+ /* Coefficients for 66Hz centre frequency */
+ {BPF_Fs8000_Fc66_A0, /* 8kS/s coefficients */
+ -BPF_Fs8000_Fc66_B2,
+ -BPF_Fs8000_Fc66_B1},
+ {BPF_Fs11025_Fc66_A0, /* 11kS/s coefficients */
+ -BPF_Fs11025_Fc66_B2,
+ -BPF_Fs11025_Fc66_B1},
+ {BPF_Fs12000_Fc66_A0, /* 12kS/s coefficients */
+ -BPF_Fs12000_Fc66_B2,
+ -BPF_Fs12000_Fc66_B1},
+ {BPF_Fs16000_Fc66_A0, /* 16kS/s coefficients */
+ -BPF_Fs16000_Fc66_B2,
+ -BPF_Fs16000_Fc66_B1},
+ {BPF_Fs22050_Fc66_A0, /* 22kS/s coefficients */
+ -BPF_Fs22050_Fc66_B2,
+ -BPF_Fs22050_Fc66_B1},
+ {BPF_Fs24000_Fc66_A0, /* 24kS/s coefficients */
+ -BPF_Fs24000_Fc66_B2,
+ -BPF_Fs24000_Fc66_B1},
+ {BPF_Fs32000_Fc66_A0, /* 32kS/s coefficients */
+ -BPF_Fs32000_Fc66_B2,
+ -BPF_Fs32000_Fc66_B1},
+ {BPF_Fs44100_Fc66_A0, /* 44kS/s coefficients */
+ -BPF_Fs44100_Fc66_B2,
+ -BPF_Fs44100_Fc66_B1},
+ {BPF_Fs48000_Fc66_A0, /* 48kS/s coefficients */
+ -BPF_Fs48000_Fc66_B2,
+ -BPF_Fs48000_Fc66_B1},
+
+ /* Coefficients for 78Hz centre frequency */
+ {BPF_Fs8000_Fc78_A0, /* 8kS/s coefficients */
+ -BPF_Fs8000_Fc78_B2,
+ -BPF_Fs8000_Fc78_B1},
+ {BPF_Fs11025_Fc78_A0, /* 11kS/s coefficients */
+ -BPF_Fs11025_Fc78_B2,
+ -BPF_Fs11025_Fc78_B1},
+ {BPF_Fs12000_Fc78_A0, /* 12kS/s coefficients */
+ -BPF_Fs12000_Fc78_B2,
+ -BPF_Fs12000_Fc78_B1},
+ {BPF_Fs16000_Fc78_A0, /* 16kS/s coefficients */
+ -BPF_Fs16000_Fc78_B2,
+ -BPF_Fs16000_Fc78_B1},
+ {BPF_Fs22050_Fc78_A0, /* 22kS/s coefficients */
+ -BPF_Fs22050_Fc78_B2,
+ -BPF_Fs22050_Fc78_B1},
+ {BPF_Fs24000_Fc78_A0, /* 24kS/s coefficients */
+ -BPF_Fs24000_Fc78_B2,
+ -BPF_Fs24000_Fc78_B1},
+ {BPF_Fs32000_Fc78_A0, /* 32kS/s coefficients */
+ -BPF_Fs32000_Fc78_B2,
+ -BPF_Fs32000_Fc78_B1},
+ {BPF_Fs44100_Fc78_A0, /* 44kS/s coefficients */
+ -BPF_Fs44100_Fc78_B2,
+ -BPF_Fs44100_Fc78_B1},
+ {BPF_Fs48000_Fc78_A0, /* 48kS/s coefficients */
+ -BPF_Fs48000_Fc78_B2,
+ -BPF_Fs48000_Fc78_B1},
+
+ /* Coefficients for 90Hz centre frequency */
+ {BPF_Fs8000_Fc90_A0, /* 8kS/s coefficients */
+ -BPF_Fs8000_Fc90_B2,
+ -BPF_Fs8000_Fc90_B1},
+ {BPF_Fs11025_Fc90_A0, /* 11kS/s coefficients */
+ -BPF_Fs11025_Fc90_B2,
+ -BPF_Fs11025_Fc90_B1},
+ {BPF_Fs12000_Fc90_A0, /* 12kS/s coefficients */
+ -BPF_Fs12000_Fc90_B2,
+ -BPF_Fs12000_Fc90_B1},
+ {BPF_Fs16000_Fc90_A0, /* 16kS/s coefficients */
+ -BPF_Fs16000_Fc90_B2,
+ -BPF_Fs16000_Fc90_B1},
+ {BPF_Fs22050_Fc90_A0, /* 22kS/s coefficients */
+ -BPF_Fs22050_Fc90_B2,
+ -BPF_Fs22050_Fc90_B1},
+ {BPF_Fs24000_Fc90_A0, /* 24kS/s coefficients */
+ -BPF_Fs24000_Fc90_B2,
+ -BPF_Fs24000_Fc90_B1},
+ {BPF_Fs32000_Fc90_A0, /* 32kS/s coefficients */
+ -BPF_Fs32000_Fc90_B2,
+ -BPF_Fs32000_Fc90_B1},
+ {BPF_Fs44100_Fc90_A0, /* 44kS/s coefficients */
+ -BPF_Fs44100_Fc90_B2,
+ -BPF_Fs44100_Fc90_B1},
+ {BPF_Fs48000_Fc90_A0, /* 48kS/s coefficients */
+ -BPF_Fs48000_Fc90_B2,
+ -BPF_Fs48000_Fc90_B1}};
+
+
+/************************************************************************************/
+/* */
+/* AGC constant tables */
+/* */
+/************************************************************************************/
+
+/* Attack time (signal too large) */
+const LVM_INT16 LVDBE_AGC_ATTACK_Table[] = {
+ AGC_ATTACK_Fs8000,
+ AGC_ATTACK_Fs11025,
+ AGC_ATTACK_Fs12000,
+ AGC_ATTACK_Fs16000,
+ AGC_ATTACK_Fs22050,
+ AGC_ATTACK_Fs24000,
+ AGC_ATTACK_Fs32000,
+ AGC_ATTACK_Fs44100,
+ AGC_ATTACK_Fs48000};
+
+/* Decay time (signal too small) */
+const LVM_INT16 LVDBE_AGC_DECAY_Table[] = {
+ AGC_DECAY_Fs8000,
+ AGC_DECAY_Fs11025,
+ AGC_DECAY_Fs12000,
+ AGC_DECAY_Fs16000,
+ AGC_DECAY_Fs22050,
+ AGC_DECAY_Fs24000,
+ AGC_DECAY_Fs32000,
+ AGC_DECAY_Fs44100,
+ AGC_DECAY_Fs48000};
+
+/* Gain for use without the high pass filter */
+const LVM_INT32 LVDBE_AGC_GAIN_Table[] = {
+ AGC_GAIN_0dB,
+ AGC_GAIN_1dB,
+ AGC_GAIN_2dB,
+ AGC_GAIN_3dB,
+ AGC_GAIN_4dB,
+ AGC_GAIN_5dB,
+ AGC_GAIN_6dB,
+ AGC_GAIN_7dB,
+ AGC_GAIN_8dB,
+ AGC_GAIN_9dB,
+ AGC_GAIN_10dB,
+ AGC_GAIN_11dB,
+ AGC_GAIN_12dB,
+ AGC_GAIN_13dB,
+ AGC_GAIN_14dB,
+ AGC_GAIN_15dB};
+
+/* Gain for use with the high pass filter */
+const LVM_INT32 LVDBE_AGC_HPFGAIN_Table[] = {
+ AGC_HPFGAIN_0dB,
+ AGC_HPFGAIN_1dB,
+ AGC_HPFGAIN_2dB,
+ AGC_HPFGAIN_3dB,
+ AGC_HPFGAIN_4dB,
+ AGC_HPFGAIN_5dB,
+ AGC_HPFGAIN_6dB,
+ AGC_HPFGAIN_7dB,
+ AGC_HPFGAIN_8dB,
+ AGC_HPFGAIN_9dB,
+ AGC_HPFGAIN_10dB,
+ AGC_HPFGAIN_11dB,
+ AGC_HPFGAIN_12dB,
+ AGC_HPFGAIN_13dB,
+ AGC_HPFGAIN_14dB,
+ AGC_HPFGAIN_15dB};
+
+
+/************************************************************************************/
+/* */
+/* Volume control gain and time constant tables */
+/* */
+/************************************************************************************/
+
+/* dB to linear conversion table */
+const LVM_INT16 LVDBE_VolumeTable[] = {
+ 0x4000, /* -6dB */
+ 0x47FB, /* -5dB */
+ 0x50C3, /* -4dB */
+ 0x5A9E, /* -3dB */
+ 0x65AD, /* -2dB */
+ 0x7215, /* -1dB */
+ 0x7FFF}; /* 0dB */
+
+const LVM_INT16 LVDBE_VolumeTCTable[] = {
+ VOL_TC_Fs8000,
+ VOL_TC_Fs11025,
+ VOL_TC_Fs12000,
+ VOL_TC_Fs16000,
+ VOL_TC_Fs22050,
+ VOL_TC_Fs24000,
+ VOL_TC_Fs32000,
+ VOL_TC_Fs44100,
+ VOL_TC_Fs48000};
+
+const LVM_INT16 LVDBE_MixerTCTable[] = {
+ MIX_TC_Fs8000,
+ MIX_TC_Fs11025,
+ MIX_TC_Fs12000,
+ MIX_TC_Fs16000,
+ MIX_TC_Fs22050,
+ MIX_TC_Fs24000,
+ MIX_TC_Fs32000,
+ MIX_TC_Fs44100,
+ MIX_TC_Fs48000};
+
+
diff --git a/media/libeffects/lvm/lib/Bass/src/LVDBE_Tables.h b/media/libeffects/lvm/lib/Bass/src/LVDBE_Tables.h
new file mode 100755
index 0000000..4cb6d21
--- /dev/null
+++ b/media/libeffects/lvm/lib/Bass/src/LVDBE_Tables.h
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1009 $
+ $Date: 2010-06-28 14:14:15 +0200 (Mon, 28 Jun 2010) $
+
+*************************************************************************************/
+
+
+/************************************************************************************/
+/* */
+/* Includes */
+/* */
+/************************************************************************************/
+#ifndef __LVBDE_TABLES_H__
+#define __LVBDE_TABLES_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#include "BIQUAD.h"
+#include "LVM_Types.h"
+
+/************************************************************************************/
+/* */
+/* Coefficients constant table */
+/* */
+/************************************************************************************/
+
+/*
+ * High Pass Filter Coefficient table
+ */
+extern const BQ_C32_Coefs_t LVDBE_HPF_Table[];
+
+/*
+ * Band Pass Filter coefficient table
+ */
+extern const BP_C32_Coefs_t LVDBE_BPF_Table[];
+
+/************************************************************************************/
+/* */
+/* AGC constant tables */
+/* */
+/************************************************************************************/
+
+/* Attack time (signal too large) */
+extern const LVM_INT16 LVDBE_AGC_ATTACK_Table[];
+
+/* Decay time (signal too small) */
+extern const LVM_INT16 LVDBE_AGC_DECAY_Table[];
+
+/* Gain for use without the high pass filter */
+extern const LVM_INT32 LVDBE_AGC_GAIN_Table[];
+
+/* Gain for use with the high pass filter */
+extern const LVM_INT32 LVDBE_AGC_HPFGAIN_Table[];
+
+/************************************************************************************/
+/* */
+/* Volume control gain and time constant tables */
+/* */
+/************************************************************************************/
+
+/* dB to linear conversion table */
+extern const LVM_INT16 LVDBE_VolumeTable[];
+
+extern const LVM_INT16 LVDBE_VolumeTCTable[];
+
+extern const LVM_INT16 LVDBE_MixerTCTable[];
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __LVBDE_TABLES_H__ */
diff --git a/media/libeffects/lvm/lib/Bundle/lib/LVM.h b/media/libeffects/lvm/lib/Bundle/lib/LVM.h
new file mode 100755
index 0000000..d472182
--- /dev/null
+++ b/media/libeffects/lvm/lib/Bundle/lib/LVM.h
@@ -0,0 +1,637 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/*****************************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1002 $
+ $Date: 2010-06-28 13:40:09 +0200 (Mon, 28 Jun 2010) $
+
+*****************************************************************************************/
+
+/****************************************************************************************/
+/* */
+/* Header file for the application layer interface of Concert Sound, Bass Enhancement, */
+/* Equalizer, Power Spectrum Analyzer, Trebble Enhancement and volume management */
+/* bundle. */
+/* */
+/* This files includes all definitions, types, structures and function */
+/* prototypes required by the calling layer. All other types, structures and */
+/* functions are private. */
+/* */
+/****************************************************************************************/
+/* */
+/* Note: 1 */
+/* ======= */
+/* The algorithm can execute either with separate input and output buffers or with */
+/* a common buffer, i.e. the data is processed in-place. */
+/* */
+/****************************************************************************************/
+/* */
+/* Note: 2 */
+/* ======= */
+/* Three data formats are support Stereo,Mono-In-Stereo and Mono. The data is */
+/* interleaved as follows: */
+/* */
+/* Byte Offset Stereo Input Mono-In-Stereo Input Mono Input */
+/* =========== ============ ==================== ============== */
+/* 0 Left Sample #1 Mono Sample #1 Mono Sample #1 */
+/* 2 Right Sample #1 Mono Sample #1 Mono Sample #2 */
+/* 4 Left Sample #2 Mono Sample #2 Mono Sample #3 */
+/* 6 Right Sample #2 Mono Sample #2 Mono Sample #4 */
+/* . . . . */
+/* . . . . */
+/* */
+/****************************************************************************************/
+
+#ifndef __LVM_H__
+#define __LVM_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/****************************************************************************************/
+/* */
+/* Includes */
+/* */
+/****************************************************************************************/
+
+#include "LVM_Types.h"
+
+
+/****************************************************************************************/
+/* */
+/* Definitions */
+/* */
+/****************************************************************************************/
+
+/* Memory table*/
+#define LVM_NR_MEMORY_REGIONS 4 /* Number of memory regions */
+
+/* Concert Sound effect level presets */
+#define LVM_CS_EFFECT_NONE 0 /* 0% effect, minimum value */
+#define LVM_CS_EFFECT_LOW 16384 /* 50% effect */
+#define LVM_CS_EFFECT_MED 24576 /* 75% effect */
+#define LVM_CS_EFFECT_HIGH 32767 /* 100% effect, maximum value */
+
+/* Treble enhancement */
+#define LVM_TE_LOW_MIPS 32767
+
+/* Bass enhancement effect level presets */
+#define LVM_BE_0DB 0 /* 0dB boost, no effect */
+#define LVM_BE_3DB 3 /* +3dB boost */
+#define LVM_BE_6DB 6 /* +6dB boost */
+#define LVM_BE_9DB 9 /* +9dB boost */
+#define LVM_BE_12DB 12 /* +12dB boost */
+#define LVM_BE_15DB 15 /* +15dB boost */
+
+/* N-Band Equalizer */
+#define LVM_EQ_NBANDS 5 /* Number of bands for equalizer */
+
+/* Headroom management */
+#define LVM_HEADROOM_MAX_NBANDS 5
+
+/****************************************************************************************/
+/* */
+/* Types */
+/* */
+/****************************************************************************************/
+
+/* Instance handle */
+typedef void *LVM_Handle_t;
+
+
+/* Status return values */
+typedef enum
+{
+ LVM_SUCCESS = 0, /* Successful return from a routine */
+ LVM_ALIGNMENTERROR = 1, /* Memory alignment error */
+ LVM_NULLADDRESS = 2, /* NULL allocation address */
+ LVM_OUTOFRANGE = 3, /* Out of range control parameter */
+ LVM_INVALIDNUMSAMPLES = 4, /* Invalid number of samples */
+ LVM_WRONGAUDIOTIME = 5, /* Wrong time value for audio time*/
+ LVM_ALGORITHMDISABLED = 6, /* Algorithm is disabled*/
+ LVM_ALGORITHMPSA = 7, /* Algorithm PSA returns an error */
+ LVM_RETURNSTATUS_DUMMY = LVM_MAXENUM
+} LVM_ReturnStatus_en;
+
+
+/* Buffer Management mode */
+typedef enum
+{
+ LVM_MANAGED_BUFFERS = 0,
+ LVM_UNMANAGED_BUFFERS = 1,
+ LVM_BUFFERS_DUMMY = LVM_MAXENUM
+} LVM_BufferMode_en;
+
+/* Output device type */
+typedef enum
+{
+ LVM_HEADPHONES = 0,
+ LVM_EX_HEADPHONES = 1,
+ LVM_SPEAKERTYPE_MAX = LVM_MAXENUM
+} LVM_OutputDeviceType_en;
+
+/* Virtualizer mode selection*/
+typedef enum
+{
+ LVM_CONCERTSOUND = 0,
+ LVM_VIRTUALIZERTYPE_DUMMY = LVM_MAXENUM
+} LVM_VirtualizerType_en;
+
+/* N-Band Equaliser operating mode */
+typedef enum
+{
+ LVM_EQNB_OFF = 0,
+ LVM_EQNB_ON = 1,
+ LVM_EQNB_DUMMY = LVM_MAXENUM
+} LVM_EQNB_Mode_en;
+
+/* Bass Enhancement operating mode */
+typedef enum
+{
+ LVM_BE_OFF = 0,
+ LVM_BE_ON = 1,
+ LVM_BE_DUMMY = LVM_MAXENUM
+} LVM_BE_Mode_en;
+
+/* Bass Enhancement centre frequency selection control */
+typedef enum
+{
+ LVM_BE_CENTRE_55Hz = 0,
+ LVM_BE_CENTRE_66Hz = 1,
+ LVM_BE_CENTRE_78Hz = 2,
+ LVM_BE_CENTRE_90Hz = 3,
+ LVM_BE_CENTRE_DUMMY = LVM_MAXENUM
+} LVM_BE_CentreFreq_en;
+
+/* Bass Enhancement HPF selection control */
+typedef enum
+{
+ LVM_BE_HPF_OFF = 0,
+ LVM_BE_HPF_ON = 1,
+ LVM_BE_HPF_DUMMY = LVM_MAXENUM
+} LVM_BE_FilterSelect_en;
+
+/* Volume Control operating mode */
+typedef enum
+{
+ LVM_VC_OFF = 0,
+ LVM_VC_ON = 1,
+ LVM_VC_DUMMY = LVM_MAXENUM
+} LVM_VC_Mode_en;
+
+/* Treble Enhancement operating mode */
+typedef enum
+{
+ LVM_TE_OFF = 0,
+ LVM_TE_ON = 1,
+ LVM_TE_DUMMY = LVM_MAXENUM
+} LVM_TE_Mode_en;
+
+/* Headroom management operating mode */
+typedef enum
+{
+ LVM_HEADROOM_OFF = 0,
+ LVM_HEADROOM_ON = 1,
+ LVM_Headroom_DUMMY = LVM_MAXENUM
+} LVM_Headroom_Mode_en;
+
+typedef enum
+{
+ LVM_PSA_SPEED_SLOW, /* Peak decaying at slow speed */
+ LVM_PSA_SPEED_MEDIUM, /* Peak decaying at medium speed */
+ LVM_PSA_SPEED_FAST, /* Peak decaying at fast speed */
+ LVM_PSA_SPEED_DUMMY = LVM_MAXENUM
+} LVM_PSA_DecaySpeed_en;
+
+typedef enum
+{
+ LVM_PSA_OFF = 0,
+ LVM_PSA_ON = 1,
+ LVM_PSA_DUMMY = LVM_MAXENUM
+} LVM_PSA_Mode_en;
+
+/* Version information */
+typedef struct
+{
+ LVM_CHAR *pVersionNumber; /* Pointer to the version number in the format X.YY.ZZ */
+ LVM_CHAR *pPlatform; /* Pointer to the library platform type */
+} LVM_VersionInfo_st;
+
+
+/****************************************************************************************/
+/* */
+/* Structures */
+/* */
+/****************************************************************************************/
+
+/* Memory table containing the region definitions */
+typedef struct
+{
+ LVM_MemoryRegion_st Region[LVM_NR_MEMORY_REGIONS]; /* One definition for each region */
+} LVM_MemTab_t;
+
+/* N-Band equaliser band definition */
+typedef struct
+{
+ LVM_INT16 Gain; /* Band gain in dB */
+ LVM_UINT16 Frequency; /* Band centre frequency in Hz */
+ LVM_UINT16 QFactor; /* Band quality factor (x100) */
+} LVM_EQNB_BandDef_t;
+
+
+/* Headroom band definition */
+typedef struct
+{
+ LVM_UINT16 Limit_Low; /* Low frequency limit of the band in Hertz */
+ LVM_UINT16 Limit_High; /* High frequency limit of the band in Hertz */
+ LVM_INT16 Headroom_Offset; /* Headroom = biggest band gain - Headroom_Offset */
+} LVM_HeadroomBandDef_t;
+
+
+/* Control Parameter structure */
+typedef struct
+{
+ /* General parameters */
+ LVM_Mode_en OperatingMode; /* Bundle operating mode On/Bypass */
+ LVM_Fs_en SampleRate; /* Sample rate */
+ LVM_Format_en SourceFormat; /* Input data format */
+ LVM_OutputDeviceType_en SpeakerType; /* Output device type */
+
+ /* Concert Sound Virtualizer parameters*/
+ LVM_Mode_en VirtualizerOperatingMode; /* Virtualizer operating mode On/Off */
+ LVM_VirtualizerType_en VirtualizerType; /* Virtualizer type: ConcertSound */
+ LVM_UINT16 VirtualizerReverbLevel; /* Virtualizer reverb level in % */
+ LVM_INT16 CS_EffectLevel; /* Concert Sound effect level */
+
+ /* N-Band Equaliser parameters */
+ LVM_EQNB_Mode_en EQNB_OperatingMode; /* N-Band Equaliser operating mode */
+ LVM_UINT16 EQNB_NBands; /* Number of bands */
+ LVM_EQNB_BandDef_t *pEQNB_BandDefinition; /* Pointer to equaliser definitions */
+
+ /* Bass Enhancement parameters */
+ LVM_BE_Mode_en BE_OperatingMode; /* Bass Enhancement operating mode */
+ LVM_INT16 BE_EffectLevel; /* Bass Enhancement effect level */
+ LVM_BE_CentreFreq_en BE_CentreFreq; /* Bass Enhancement centre frequency */
+ LVM_BE_FilterSelect_en BE_HPF; /* Bass Enhancement high pass filter selector */
+
+ /* Volume Control parameters */
+ LVM_INT16 VC_EffectLevel; /* Volume Control setting in dBs */
+ LVM_INT16 VC_Balance; /* Left Right Balance control in dB (-96 to 96 dB), -ve values reduce
+ Right channel while +ve value reduces Left channel*/
+
+ /* Treble Enhancement parameters */
+ LVM_TE_Mode_en TE_OperatingMode; /* Treble Enhancement On/Off */
+ LVM_INT16 TE_EffectLevel; /* Treble Enhancement gain dBs */
+
+ /* Spectrum Analyzer parameters Control */
+ LVM_PSA_Mode_en PSA_Enable;
+ LVM_PSA_DecaySpeed_en PSA_PeakDecayRate; /* Peak value decay rate*/
+
+} LVM_ControlParams_t;
+
+
+/* Instance Parameter structure */
+typedef struct
+{
+ /* General */
+ LVM_BufferMode_en BufferMode; /* Buffer management mode */
+ LVM_UINT16 MaxBlockSize; /* Maximum processing block size */
+
+ /* N-Band Equaliser */
+ LVM_UINT16 EQNB_NumBands; /* Maximum number of equaliser bands */
+
+ /* PSA */
+ LVM_PSA_Mode_en PSA_Included; /* Controls the instance memory allocation for PSA: ON/OFF */
+} LVM_InstParams_t;
+
+/* Headroom management parameter structure */
+typedef struct
+{
+ LVM_Headroom_Mode_en Headroom_OperatingMode; /* Headroom Control On/Off */
+ LVM_HeadroomBandDef_t *pHeadroomDefinition; /* Pointer to headroom bands definition */
+ LVM_UINT16 NHeadroomBands; /* Number of headroom bands */
+
+} LVM_HeadroomParams_t;
+
+/****************************************************************************************/
+/* */
+/* Function Prototypes */
+/* */
+/****************************************************************************************/
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_GetVersionInfo */
+/* */
+/* DESCRIPTION: */
+/* This function is used to retrieve information about the library's version. */
+/* */
+/* PARAMETERS: */
+/* pVersion Pointer to an empty version info structure */
+/* */
+/* RETURNS: */
+/* LVM_SUCCESS Succeeded */
+/* LVM_NULLADDRESS when pVersion is NULL */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVM_Process function */
+/* */
+/****************************************************************************************/
+LVM_ReturnStatus_en LVM_GetVersionInfo(LVM_VersionInfo_st *pVersion);
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_GetMemoryTable */
+/* */
+/* DESCRIPTION: */
+/* This function is used for memory allocation and free. It can be called in */
+/* two ways: */
+/* */
+/* hInstance = NULL Returns the memory requirements */
+/* hInstance = Instance handle Returns the memory requirements and */
+/* allocated base addresses for the instance */
+/* */
+/* When this function is called for memory allocation (hInstance=NULL) the memory */
+/* base address pointers are NULL on return. */
+/* */
+/* When the function is called for free (hInstance = Instance Handle) the memory */
+/* table returns the allocated memory and base addresses used during initialisation. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance Handle */
+/* pMemoryTable Pointer to an empty memory definition table */
+/* pInstParams Pointer to the instance parameters */
+/* */
+/* RETURNS: */
+/* LVM_SUCCESS Succeeded */
+/* LVM_NULLADDRESS When one of pMemoryTable or pInstParams is NULL */
+/* LVM_OUTOFRANGE When any of the Instance parameters are out of range */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVM_Process function */
+/* */
+/****************************************************************************************/
+LVM_ReturnStatus_en LVM_GetMemoryTable(LVM_Handle_t hInstance,
+ LVM_MemTab_t *pMemoryTable,
+ LVM_InstParams_t *pInstParams);
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_GetInstanceHandle */
+/* */
+/* DESCRIPTION: */
+/* This function is used to create a bundle instance. It returns the created instance */
+/* handle through phInstance. All parameters are set to their default, inactive state. */
+/* */
+/* PARAMETERS: */
+/* phInstance pointer to the instance handle */
+/* pMemoryTable Pointer to the memory definition table */
+/* pInstParams Pointer to the instance parameters */
+/* */
+/* RETURNS: */
+/* LVM_SUCCESS Initialisation succeeded */
+/* LVM_NULLADDRESS One or more memory has a NULL pointer */
+/* LVM_OUTOFRANGE When any of the Instance parameters are out of range */
+/* */
+/* NOTES: */
+/* 1. This function must not be interrupted by the LVM_Process function */
+/* */
+/****************************************************************************************/
+LVM_ReturnStatus_en LVM_GetInstanceHandle(LVM_Handle_t *phInstance,
+ LVM_MemTab_t *pMemoryTable,
+ LVM_InstParams_t *pInstParams);
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_ClearAudioBuffers */
+/* */
+/* DESCRIPTION: */
+/* This function is used to clear the internal audio buffers of the bundle. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* */
+/* RETURNS: */
+/* LVM_SUCCESS Initialisation succeeded */
+/* LVM_NULLADDRESS Instance memory has a NULL pointer */
+/* */
+/* NOTES: */
+/* 1. This function must not be interrupted by the LVM_Process function */
+/* */
+/****************************************************************************************/
+LVM_ReturnStatus_en LVM_ClearAudioBuffers(LVM_Handle_t hInstance);
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_GetControlParameters */
+/* */
+/* DESCRIPTION: */
+/* Request the LifeVibes module parameters. The current parameter set is returned */
+/* via the parameter pointer. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* pParams Pointer to an empty parameter structure */
+/* */
+/* RETURNS: */
+/* LVM_SUCCESS Succeeded */
+/* LVM_NULLADDRESS when any of hInstance or pParams is NULL */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVM_Process function */
+/* */
+/****************************************************************************************/
+LVM_ReturnStatus_en LVM_GetControlParameters(LVM_Handle_t hInstance,
+ LVM_ControlParams_t *pParams);
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_SetControlParameters */
+/* */
+/* DESCRIPTION: */
+/* Sets or changes the LifeVibes module parameters. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* pParams Pointer to a parameter structure */
+/* */
+/* RETURNS: */
+/* LVM_SUCCESS Succeeded */
+/* LVM_NULLADDRESS When hInstance, pParams or any control pointers are NULL */
+/* LVM_OUTOFRANGE When any of the control parameters are out of range */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVM_Process function */
+/* */
+/****************************************************************************************/
+LVM_ReturnStatus_en LVM_SetControlParameters(LVM_Handle_t hInstance,
+ LVM_ControlParams_t *pParams);
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_Process */
+/* */
+/* DESCRIPTION: */
+/* Process function for the LifeVibes module. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* pInData Pointer to the input data */
+/* pOutData Pointer to the output data */
+/* NumSamples Number of samples in the input buffer */
+/* AudioTime Audio Time of the current input data in milli-seconds */
+/* */
+/* RETURNS: */
+/* LVM_SUCCESS Succeeded */
+/* LVM_INVALIDNUMSAMPLES When the NumSamples is not a valied multiple in unmanaged */
+/* buffer mode */
+/* LVM_ALIGNMENTERROR When either the input our output buffers are not 32-bit */
+/* aligned in unmanaged mode */
+/* LVM_NULLADDRESS When one of hInstance, pInData or pOutData is NULL */
+/* */
+/* NOTES: */
+/* 1. The input and output buffers must be 32-bit aligned */
+/* 2. Number of samples is defined as follows: */
+/* MONO the number of samples in the block */
+/* MONOINSTEREO the number of sample pairs in the block */
+/* STEREO the number of sample pairs in the block */
+/* */
+/****************************************************************************************/
+LVM_ReturnStatus_en LVM_Process(LVM_Handle_t hInstance,
+ const LVM_INT16 *pInData,
+ LVM_INT16 *pOutData,
+ LVM_UINT16 NumSamples,
+ LVM_UINT32 AudioTime);
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_SetHeadroomParams */
+/* */
+/* DESCRIPTION: */
+/* This function is used to set the automatic headroom management parameters. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance Handle */
+/* pHeadroomParams Pointer to headroom parameter structure */
+/* */
+/* RETURNS: */
+/* LVM_NULLADDRESS When hInstance or pHeadroomParams is NULL */
+/* LVM_SUCCESS Succeeded */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVM_Process function */
+/* */
+/****************************************************************************************/
+LVM_ReturnStatus_en LVM_SetHeadroomParams( LVM_Handle_t hInstance,
+ LVM_HeadroomParams_t *pHeadroomParams);
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_GetHeadroomParams */
+/* */
+/* DESCRIPTION: */
+/* This function is used to get the automatic headroom management parameters. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance Handle */
+/* pHeadroomParams Pointer to headroom parameter structure (output) */
+/* */
+/* RETURNS: */
+/* LVM_SUCCESS Succeeded */
+/* LVM_NULLADDRESS When hInstance or pHeadroomParams are NULL */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVM_Process function */
+/* */
+/****************************************************************************************/
+LVM_ReturnStatus_en LVM_GetHeadroomParams( LVM_Handle_t hInstance,
+ LVM_HeadroomParams_t *pHeadroomParams);
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_GetSpectrum */
+/* */
+/* DESCRIPTION: */
+/* This function is used to retrieve Spectral information at a given Audio time */
+/* for display usage */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance Handle */
+/* pCurrentPeaks Pointer to location where currents peaks are to be saved */
+/* pPastPeaks Pointer to location where past peaks are to be saved */
+/* pCentreFreqs Pointer to location where centre frequency of each band is */
+/* to be saved */
+/* AudioTime Audio time at which the spectral information is needed */
+/* */
+/* RETURNS: */
+/* LVM_SUCCESS Succeeded */
+/* LVM_NULLADDRESS If any of input addresses are NULL */
+/* LVM_WRONGAUDIOTIME Failure due to audio time error */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVM_Process function */
+/* */
+/****************************************************************************************/
+LVM_ReturnStatus_en LVM_GetSpectrum( LVM_Handle_t hInstance,
+ LVM_UINT8 *pCurrentPeaks,
+ LVM_UINT8 *pPastPeaks,
+ LVM_INT32 AudioTime);
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_SetVolumeNoSmoothing */
+/* */
+/* DESCRIPTION: */
+/* This function is used to set output volume without any smoothing */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance Handle */
+/* pParams Control Parameters, only volume value is used here */
+/* */
+/* RETURNS: */
+/* LVM_SUCCESS Succeeded */
+/* LVM_NULLADDRESS If any of input addresses are NULL */
+/* LVM_OUTOFRANGE When any of the control parameters are out of range */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVM_Process function */
+/* */
+/****************************************************************************************/
+LVM_ReturnStatus_en LVM_SetVolumeNoSmoothing( LVM_Handle_t hInstance,
+ LVM_ControlParams_t *pParams);
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __LVM_H__ */
+
diff --git a/media/libeffects/lvm/lib/Bundle/src/LVM_API_Specials.c b/media/libeffects/lvm/lib/Bundle/src/LVM_API_Specials.c
new file mode 100755
index 0000000..2f6fa4c
--- /dev/null
+++ b/media/libeffects/lvm/lib/Bundle/src/LVM_API_Specials.c
@@ -0,0 +1,158 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/****************************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1002 $
+ $Date: 2010-06-28 13:40:09 +0200 (Mon, 28 Jun 2010) $
+
+*****************************************************************************************/
+
+
+/****************************************************************************************/
+/* */
+/* Includes */
+/* */
+/****************************************************************************************/
+
+#include "LVM_Private.h"
+#include "LVM_Tables.h"
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_GetSpectrum */
+/* */
+/* DESCRIPTION: */
+/* This function is used to retrieve Spectral information at a given Audio time */
+/* for display usage */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance Handle */
+/* pCurrentPeaks Pointer to location where currents peaks are to be saved */
+/* pPastPeaks Pointer to location where past peaks are to be saved */
+/* AudioTime Audio time at which the spectral information is needed */
+/* */
+/* RETURNS: */
+/* LVM_SUCCESS Succeeded */
+/* LVM_NULLADDRESS If any of input addresses are NULL */
+/* LVM_WRONGAUDIOTIME Failure due to audio time error */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVM_Process function */
+/* */
+/****************************************************************************************/
+LVM_ReturnStatus_en LVM_GetSpectrum(
+ LVM_Handle_t hInstance,
+ LVM_UINT8 *pCurrentPeaks,
+ LVM_UINT8 *pPastPeaks,
+ LVM_INT32 AudioTime
+ )
+{
+ LVM_Instance_t *pInstance = (LVM_Instance_t *)hInstance;
+
+ pLVPSA_Handle_t *hPSAInstance;
+ LVPSA_RETURN LVPSA_Status;
+
+
+ if(pInstance == LVM_NULL)
+ {
+ return LVM_NULLADDRESS;
+ }
+
+ /*If PSA is not included at the time of instance creation, return without any processing*/
+ if(pInstance->InstParams.PSA_Included!=LVM_PSA_ON)
+ {
+ return LVM_SUCCESS;
+ }
+
+ hPSAInstance = pInstance->hPSAInstance;
+
+ if((pCurrentPeaks == LVM_NULL) ||
+ (pPastPeaks == LVM_NULL))
+ {
+ return LVM_NULLADDRESS;
+ }
+
+
+ /*
+ * Update new parameters if necessary
+ */
+ if (pInstance->ControlPending == LVM_TRUE)
+ {
+ LVM_ApplyNewSettings(hInstance);
+ }
+
+ /* If PSA module is disabled, do nothing */
+ if(pInstance->Params.PSA_Enable==LVM_PSA_OFF)
+ {
+ return LVM_ALGORITHMDISABLED;
+ }
+
+ LVPSA_Status = LVPSA_GetSpectrum(hPSAInstance,
+ (LVPSA_Time) (AudioTime),
+ (LVM_UINT8*) pCurrentPeaks,
+ (LVM_UINT8*) pPastPeaks );
+
+ if(LVPSA_Status != LVPSA_OK)
+ {
+ if(LVPSA_Status == LVPSA_ERROR_WRONGTIME)
+ {
+ return (LVM_ReturnStatus_en) LVM_WRONGAUDIOTIME;
+ }
+ else
+ {
+ return (LVM_ReturnStatus_en) LVM_NULLADDRESS;
+ }
+ }
+
+ return(LVM_SUCCESS);
+}
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_SetVolumeNoSmoothing */
+/* */
+/* DESCRIPTION: */
+/* This function is used to set output volume without any smoothing */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance Handle */
+/* pParams Control Parameters, only volume value is used here */
+/* */
+/* RETURNS: */
+/* LVM_SUCCESS Succeeded */
+/* LVM_NULLADDRESS If any of input addresses are NULL */
+/* LVM_OUTOFRANGE When any of the control parameters are out of range */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVM_Process function */
+/* */
+/****************************************************************************************/
+LVM_ReturnStatus_en LVM_SetVolumeNoSmoothing( LVM_Handle_t hInstance,
+ LVM_ControlParams_t *pParams)
+{
+ LVM_Instance_t *pInstance =(LVM_Instance_t *)hInstance;
+ LVM_ReturnStatus_en Error;
+
+ /*Apply new controls*/
+ Error = LVM_SetControlParameters(hInstance,pParams);
+ pInstance->NoSmoothVolume = LVM_TRUE;
+ return Error;
+}
+
diff --git a/media/libeffects/lvm/lib/Bundle/src/LVM_Buffers.c b/media/libeffects/lvm/lib/Bundle/src/LVM_Buffers.c
new file mode 100755
index 0000000..41785a3
--- /dev/null
+++ b/media/libeffects/lvm/lib/Bundle/src/LVM_Buffers.c
@@ -0,0 +1,878 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+
+/****************************************************************************************
+
+ $Author: nxp007753 $
+ $Revision: 1082 $
+ $Date: 2010-07-05 12:44:39 +0200 (Mon, 05 Jul 2010) $
+
+*****************************************************************************************/
+
+/****************************************************************************************/
+/* */
+/* Includes */
+/* */
+/****************************************************************************************/
+
+#include "LVM_Private.h"
+#include "VectorArithmetic.h"
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_BufferManagedIn */
+/* */
+/* DESCRIPTION: */
+/* Full buffer management allowing the user to provide input and output buffers on */
+/* any alignment and with any number of samples. The alignment is corrected within */
+/* the buffer management and the samples are grouped in to blocks of the correct size */
+/* before processing. */
+/* */
+/* PARAMETERS: */
+/* hInstance - Instance handle */
+/* pInData - Pointer to the input data stream */
+/* *pToProcess - Pointer to pointer to the start of data processing */
+/* *pProcessed - Pointer to pointer to the destination of the processed data */
+/* pNumSamples - Pointer to the number of samples to process */
+/* */
+/* RETURNS: */
+/* None */
+/* */
+/* NOTES: */
+/* */
+/****************************************************************************************/
+
+void LVM_BufferManagedIn(LVM_Handle_t hInstance,
+ const LVM_INT16 *pInData,
+ LVM_INT16 **pToProcess,
+ LVM_INT16 **pProcessed,
+ LVM_UINT16 *pNumSamples)
+{
+
+ LVM_INT16 SampleCount; /* Number of samples to be processed this call */
+ LVM_INT16 NumSamples; /* Number of samples in scratch buffer */
+ LVM_INT16 *pStart;
+ LVM_Instance_t *pInstance = (LVM_Instance_t *)hInstance;
+ LVM_Buffer_t *pBuffer;
+ LVM_INT16 *pDest;
+ LVM_INT16 NumChannels =2;
+
+
+ /*
+ * Set the processing address pointers
+ */
+ pBuffer = pInstance->pBufferManagement;
+ pDest = pBuffer->pScratch;
+ *pToProcess = pBuffer->pScratch;
+ *pProcessed = pBuffer->pScratch;
+
+ /*
+ * Check if it is the first call of a block
+ */
+ if (pInstance->SamplesToProcess == 0)
+ {
+ /*
+ * First call for a new block of samples
+ */
+ pInstance->SamplesToProcess = (LVM_INT16)(*pNumSamples + pBuffer->InDelaySamples);
+ pInstance->pInputSamples = (LVM_INT16 *)pInData;
+ pBuffer->BufferState = LVM_FIRSTCALL;
+ }
+ pStart = pInstance->pInputSamples; /* Pointer to the input samples */
+ pBuffer->SamplesToOutput = 0; /* Samples to output is same as number read for inplace processing */
+
+
+ /*
+ * Calculate the number of samples to process this call and update the buffer state
+ */
+ if (pInstance->SamplesToProcess > pInstance->InternalBlockSize)
+ {
+ /*
+ * Process the maximum bock size of samples.
+ */
+ SampleCount = pInstance->InternalBlockSize;
+ NumSamples = pInstance->InternalBlockSize;
+ }
+ else
+ {
+ /*
+ * Last call for the block, so calculate how many frames and samples to process
+ */
+ LVM_INT16 NumFrames;
+
+ NumSamples = pInstance->SamplesToProcess;
+ NumFrames = (LVM_INT16)(NumSamples >> MIN_INTERNAL_BLOCKSHIFT);
+ SampleCount = (LVM_INT16)(NumFrames << MIN_INTERNAL_BLOCKSHIFT);
+
+ /*
+ * Update the buffer state
+ */
+ if (pBuffer->BufferState == LVM_FIRSTCALL)
+ {
+ pBuffer->BufferState = LVM_FIRSTLASTCALL;
+ }
+ else
+ {
+ pBuffer->BufferState = LVM_LASTCALL;
+ }
+ }
+ *pNumSamples = (LVM_UINT16)SampleCount; /* Set the number of samples to process this call */
+
+
+ /*
+ * Copy samples from the delay buffer as required
+ */
+ if (((pBuffer->BufferState == LVM_FIRSTCALL) ||
+ (pBuffer->BufferState == LVM_FIRSTLASTCALL)) &&
+ (pBuffer->InDelaySamples != 0))
+ {
+ Copy_16(&pBuffer->InDelayBuffer[0], /* Source */
+ pDest, /* Destination */
+ (LVM_INT16)(NumChannels*pBuffer->InDelaySamples)); /* Number of delay samples, left and right */
+ NumSamples = (LVM_INT16)(NumSamples - pBuffer->InDelaySamples); /* Update sample count */
+ pDest += NumChannels * pBuffer->InDelaySamples; /* Update the destination pointer */
+ }
+
+
+ /*
+ * Copy the rest of the samples for this call from the input buffer
+ */
+ if (NumSamples > 0)
+ {
+ Copy_16(pStart, /* Source */
+ pDest, /* Destination */
+ (LVM_INT16)(NumChannels*NumSamples)); /* Number of input samples */
+ pStart += NumChannels * NumSamples; /* Update the input pointer */
+
+ /*
+ * Update the input data pointer and samples to output
+ */
+ pBuffer->SamplesToOutput = (LVM_INT16)(pBuffer->SamplesToOutput + NumSamples); /* Update samples to output */
+ }
+
+
+ /*
+ * Update the sample count and input pointer
+ */
+ pInstance->SamplesToProcess = (LVM_INT16)(pInstance->SamplesToProcess - SampleCount); /* Update the count of samples */
+ pInstance->pInputSamples = pStart; /* Update input sample pointer */
+
+
+ /*
+ * Save samples to the delay buffer if any left unprocessed
+ */
+ if ((pBuffer->BufferState == LVM_FIRSTLASTCALL) ||
+ (pBuffer->BufferState == LVM_LASTCALL))
+ {
+ NumSamples = pInstance->SamplesToProcess;
+ pStart = pBuffer->pScratch; /* Start of the buffer */
+ pStart += NumChannels*SampleCount; /* Offset by the number of processed samples */
+ if (NumSamples != 0)
+ {
+ Copy_16(pStart, /* Source */
+ &pBuffer->InDelayBuffer[0], /* Destination */
+ (LVM_INT16)(NumChannels*NumSamples)); /* Number of input samples */
+ }
+
+
+ /*
+ * Update the delay sample count
+ */
+ pBuffer->InDelaySamples = NumSamples; /* Number of delay sample pairs */
+ pInstance->SamplesToProcess = 0; /* All Samples used */
+ }
+}
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_BufferUnmanagedIn */
+/* */
+/* DESCRIPTION: */
+/* This mode is selected by the user code and disables the buffer management with the */
+/* exception of the maximum block size processing. The user must ensure that the */
+/* input and output buffers are 32-bit aligned and also that the number of samples to */
+/* process is a correct multiple of samples. */
+/* */
+/* PARAMETERS: */
+/* hInstance - Instance handle */
+/* *pToProcess - Pointer to the start of data processing */
+/* *pProcessed - Pointer to the destination of the processed data */
+/* pNumSamples - Pointer to the number of samples to process */
+/* */
+/* RETURNS: */
+/* None */
+/* */
+/* NOTES: */
+/* */
+/****************************************************************************************/
+
+void LVM_BufferUnmanagedIn(LVM_Handle_t hInstance,
+ LVM_INT16 **pToProcess,
+ LVM_INT16 **pProcessed,
+ LVM_UINT16 *pNumSamples)
+{
+
+ LVM_Instance_t *pInstance = (LVM_Instance_t *)hInstance;
+
+
+ /*
+ * Check if this is the first call of a block
+ */
+ if (pInstance->SamplesToProcess == 0)
+ {
+ pInstance->SamplesToProcess = (LVM_INT16)*pNumSamples; /* Get the number of samples on first call */
+ pInstance->pInputSamples = *pToProcess; /* Get the I/O pointers */
+ pInstance->pOutputSamples = *pProcessed;
+
+
+ /*
+ * Set te block size to process
+ */
+ if (pInstance->SamplesToProcess > pInstance->InternalBlockSize)
+ {
+ *pNumSamples = (LVM_UINT16)pInstance->InternalBlockSize;
+ }
+ else
+ {
+ *pNumSamples = (LVM_UINT16)pInstance->SamplesToProcess;
+ }
+ }
+
+ /*
+ * Set the process pointers
+ */
+ *pToProcess = pInstance->pInputSamples;
+ *pProcessed = pInstance->pOutputSamples;
+}
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_BufferOptimisedIn */
+/* */
+/* DESCRIPTION: */
+/* Optimised buffer management for the case where the data is outplace processing, */
+/* the output data is 32-bit aligned and there are sufficient samples to allow some */
+/* processing directly in the output buffer. This saves one data copy per sample */
+/* compared with the unoptimsed version. */
+/* */
+/* PARAMETERS: */
+/* hInstance - Instance handle */
+/* pInData - Pointer to the input data stream */
+/* *pToProcess - Pointer to the start of data processing */
+/* *pProcessed - Pointer to the destination of the processed data */
+/* pNumSamples - Pointer to the number of samples to process */
+/* */
+/* RETURNS: */
+/* None */
+/* */
+/* NOTES: */
+/* */
+/****************************************************************************************/
+
+void LVM_BufferOptimisedIn(LVM_Handle_t hInstance,
+ const LVM_INT16 *pInData,
+ LVM_INT16 **pToProcess,
+ LVM_INT16 **pProcessed,
+ LVM_UINT16 *pNumSamples)
+{
+
+ LVM_Instance_t *pInstance = (LVM_Instance_t *)hInstance;
+ LVM_Buffer_t *pBuffer = pInstance->pBufferManagement;
+ LVM_INT16 *pDest;
+ LVM_INT16 SampleCount;
+ LVM_INT16 NumSamples;
+ LVM_INT16 NumFrames;
+
+ /*
+ * Check if it is the first call for this block
+ */
+ if (pInstance->SamplesToProcess == 0)
+ {
+ /*
+ * First call for a new block of samples
+ */
+ pBuffer->BufferState = LVM_FIRSTCALL;
+ pInstance->pInputSamples = (LVM_INT16 *)pInData;
+ pInstance->SamplesToProcess = (LVM_INT16)*pNumSamples;
+ pBuffer->SamplesToOutput = (LVM_INT16)*pNumSamples;
+ pDest = *pProcessed; /* The start of the output buffer */
+
+
+ /*
+ * Copy the already processed samples to the output buffer
+ */
+ if (pBuffer->OutDelaySamples != 0)
+ {
+ Copy_16(&pBuffer->OutDelayBuffer[0], /* Source */
+ pDest, /* Detsination */
+ (LVM_INT16)(2*pBuffer->OutDelaySamples)); /* Number of delay samples */
+ pDest += 2 * pBuffer->OutDelaySamples; /* Update the output pointer */
+ pBuffer->SamplesToOutput = (LVM_INT16)(pBuffer->SamplesToOutput - pBuffer->OutDelaySamples); /* Update the numbr of samples to output */
+ }
+ *pToProcess = pDest; /* Set the address to start processing */
+ *pProcessed = pDest; /* Process in the output buffer, now inplace */
+
+ /*
+ * Copy the input delay buffer (unprocessed) samples to the output buffer
+ */
+ if (pBuffer->InDelaySamples != 0)
+ {
+ Copy_16(&pBuffer->InDelayBuffer[0], /* Source */
+ pDest, /* Destination */
+ (LVM_INT16)(2*pBuffer->InDelaySamples)); /* Number of delay samples */
+ pDest += 2 * pBuffer->InDelaySamples; /* Update the output pointer */
+ }
+
+
+ /*
+ * Calculate how many input samples to process and copy
+ */
+ NumSamples = (LVM_INT16)(*pNumSamples - pBuffer->OutDelaySamples); /* Number that will fit in the output buffer */
+ if (NumSamples >= pInstance->InternalBlockSize)
+ {
+ NumSamples = pInstance->InternalBlockSize;
+ }
+ NumFrames = (LVM_INT16)(NumSamples >> MIN_INTERNAL_BLOCKSHIFT);
+ SampleCount = (LVM_INT16)(NumFrames << MIN_INTERNAL_BLOCKSHIFT);
+ *pNumSamples = (LVM_UINT16)SampleCount; /* The number of samples to process */
+ pBuffer->SamplesToOutput = (LVM_INT16)(pBuffer->SamplesToOutput - SampleCount); /* Update the number of samples to output */
+ SampleCount = (LVM_INT16)(SampleCount - pBuffer->InDelaySamples); /* The number of samples to copy from the input */
+
+
+ /*
+ * Copy samples from the input buffer and update counts and pointers
+ */
+ Copy_16(pInstance->pInputSamples, /* Source */
+ pDest, /* Destination */
+ (LVM_INT16)(2*SampleCount)); /* Number of input samples */
+ pInstance->pInputSamples += 2 * SampleCount; /* Update the input pointer */
+ pInstance->pOutputSamples = pDest + (2 * SampleCount); /* Update the output pointer */
+ pInstance->SamplesToProcess = (LVM_INT16)(pInstance->SamplesToProcess - SampleCount); /* Samples left in the input buffer */
+ }
+ else
+ {
+ /*
+ * Second or subsequent call in optimised mode
+ */
+ if (pBuffer->SamplesToOutput >= MIN_INTERNAL_BLOCKSIZE)
+ {
+ /*
+ * More samples can be processed directly in the output buffer
+ */
+ *pToProcess = pInstance->pOutputSamples; /* Set the address to start processing */
+ *pProcessed = pInstance->pOutputSamples; /* Process in the output buffer, now inplace */
+ NumSamples = pBuffer->SamplesToOutput; /* Number that will fit in the output buffer */
+ if (NumSamples >= pInstance->InternalBlockSize)
+ {
+ NumSamples = pInstance->InternalBlockSize;
+ }
+ NumFrames = (LVM_INT16)(NumSamples >> MIN_INTERNAL_BLOCKSHIFT);
+ SampleCount = (LVM_INT16)(NumFrames << MIN_INTERNAL_BLOCKSHIFT);
+ *pNumSamples = (LVM_UINT16)SampleCount; /* The number of samples to process */
+
+
+ /*
+ * Copy samples from the input buffer and update counts and pointers
+ */
+ Copy_16(pInstance->pInputSamples, /* Source */
+ pInstance->pOutputSamples, /* Destination */
+ (LVM_INT16)(2*SampleCount)); /* Number of input samples */
+ pInstance->pInputSamples += 2 * SampleCount; /* Update the input pointer */
+ pInstance->pOutputSamples += 2 * SampleCount; /* Update the output pointer */
+ pInstance->SamplesToProcess = (LVM_INT16)(pInstance->SamplesToProcess - SampleCount); /* Samples left in the input buffer */
+ pBuffer->SamplesToOutput = (LVM_INT16)(pBuffer->SamplesToOutput - SampleCount); /* Number that will fit in the output buffer */
+ }
+ else
+ {
+ /*
+ * The remaining samples can not be processed in the output buffer
+ */
+ pBuffer->BufferState = LVM_LASTCALL; /* Indicate this is the last bock to process */
+ *pToProcess = pBuffer->pScratch; /* Set the address to start processing */
+ *pProcessed = pBuffer->pScratch; /* Process in the output buffer, now inplace */
+ NumSamples = pInstance->SamplesToProcess; /* Number left to be processed */
+ NumFrames = (LVM_INT16)(NumSamples >> MIN_INTERNAL_BLOCKSHIFT);
+ SampleCount = (LVM_INT16)(NumFrames << MIN_INTERNAL_BLOCKSHIFT);
+ *pNumSamples = (LVM_UINT16)SampleCount; /* The number of samples to process */
+
+
+ /*
+ * Copy samples from the input buffer and update counts and pointers
+ */
+ Copy_16(pInstance->pInputSamples, /* Source */
+ pBuffer->pScratch, /* Destination */
+ (LVM_INT16)(2*SampleCount)); /* Number of input samples */
+ pInstance->pInputSamples += 2 * SampleCount; /* Update the input pointer */
+ pInstance->SamplesToProcess = (LVM_INT16)(pInstance->SamplesToProcess - SampleCount); /* Samples left in the input buffer */
+ }
+ }
+}
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_BufferIn */
+/* */
+/* DESCRIPTION: */
+/* This function manages the data input, it has the following features: */
+/* - Accepts data in 16-bit aligned memory */
+/* - Copies the data to 32-bit aligned memory */
+/* - Converts Mono inputs to Mono-in-Stereo */
+/* - Accepts any number of samples as input, except 0 */
+/* - Breaks the input sample stream in to blocks of the configured frame size or */
+/* multiples of the frame size */
+/* - Limits the processing block size to the maximum block size. */
+/* - Works with inplace or outplace processing automatically */
+/* */
+/* To manage the data the function has a number of operating states: */
+/* LVM_FIRSTCALL - The first call for this block of input samples */
+/* LVM_MAXBLOCKCALL - The current block is the maximum size. Only used for the */
+/* second and subsequent blocks. */
+/* LVM_LASTCALL - The last call for this block of input samples */
+/* LVM_FIRSTLASTCALL - This is the first and last call for this block of input*/
+/* samples, this occurs when the number of samples to */
+/* process is less than the maximum block size. */
+/* */
+/* The function uses an internal delay buffer the size of the minimum frame, this is */
+/* used to temporarily hold samples when the number of samples to process is not a */
+/* multiple of the frame size. */
+/* */
+/* To ensure correct operation with inplace buffering the number of samples to output*/
+/* per call is calculated in this function and is set to the number of samples read */
+/* from the input buffer. */
+/* */
+/* The total number of samples to process is stored when the function is called for */
+/* the first time. The value is overwritten by the size of the block to be processed */
+/* in each call so the size of the processing blocks can be controlled. The number of */
+/* samples actually processed for each block of input samples is always a multiple of*/
+/* the frame size so for any particular block of input samples the actual number of */
+/* processed samples may not match the number of input samples, sometime it will be */
+/* sometimes less. The average is the same and the difference is never more than the */
+/* frame size. */
+/* */
+/* PARAMETERS: */
+/* hInstance - Instance handle */
+/* pInData - Pointer to the input data stream */
+/* *pToProcess - Pointer to the start of data processing */
+/* *pProcessed - Pointer to the destination of the processed data */
+/* pNumSamples - Pointer to the number of samples to process */
+/* */
+/* RETURNS: */
+/* None */
+/* */
+/* NOTES: */
+/* */
+/****************************************************************************************/
+
+void LVM_BufferIn(LVM_Handle_t hInstance,
+ const LVM_INT16 *pInData,
+ LVM_INT16 **pToProcess,
+ LVM_INT16 **pProcessed,
+ LVM_UINT16 *pNumSamples)
+{
+
+ LVM_Instance_t *pInstance = (LVM_Instance_t *)hInstance;
+
+
+ /*
+ * Check which mode, managed or unmanaged
+ */
+ if (pInstance->InstParams.BufferMode == LVM_MANAGED_BUFFERS)
+ {
+ LVM_BufferManagedIn(hInstance,
+ pInData,
+ pToProcess,
+ pProcessed,
+ pNumSamples);
+ }
+ else
+ {
+ LVM_BufferUnmanagedIn(hInstance,
+ pToProcess,
+ pProcessed,
+ pNumSamples);
+ }
+}
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_BufferManagedOut */
+/* */
+/* DESCRIPTION: */
+/* Full buffer management output. This works in conjunction with the managed input */
+/* routine and ensures the correct number of samples are always output to the output */
+/* buffer. */
+/* */
+/* PARAMETERS: */
+/* hInstance - Instance handle */
+/* pOutData - Pointer to the output data stream */
+/* pNumSamples - Pointer to the number of samples to process */
+/* */
+/* RETURNS: */
+/* None */
+/* */
+/* NOTES: */
+/* */
+/****************************************************************************************/
+
+void LVM_BufferManagedOut(LVM_Handle_t hInstance,
+ LVM_INT16 *pOutData,
+ LVM_UINT16 *pNumSamples)
+{
+
+ LVM_Instance_t *pInstance = (LVM_Instance_t *)hInstance;
+ LVM_Buffer_t *pBuffer = pInstance->pBufferManagement;
+ LVM_INT16 SampleCount = (LVM_INT16)*pNumSamples;
+ LVM_INT16 NumSamples;
+ LVM_INT16 *pStart;
+ LVM_INT16 *pDest;
+
+
+ /*
+ * Set the pointers
+ */
+ NumSamples = pBuffer->SamplesToOutput;
+ pStart = pBuffer->pScratch;
+
+
+ /*
+ * check if it is the first call of a block
+ */
+ if ((pBuffer->BufferState == LVM_FIRSTCALL) ||
+ (pBuffer->BufferState == LVM_FIRSTLASTCALL))
+ {
+ /* First call for a new block */
+ pInstance->pOutputSamples = pOutData; /* Initialise the destination */
+ }
+ pDest = pInstance->pOutputSamples; /* Set the output address */
+
+
+ /*
+ * If the number of samples is non-zero then there are still samples to send to
+ * the output buffer
+ */
+ if ((NumSamples != 0) &&
+ (pBuffer->OutDelaySamples != 0))
+ {
+ /*
+ * Copy the delayed output buffer samples to the output
+ */
+ if (pBuffer->OutDelaySamples <= NumSamples)
+ {
+ /*
+ * Copy all output delay samples to the output
+ */
+ Copy_16(&pBuffer->OutDelayBuffer[0], /* Source */
+ pDest, /* Detsination */
+ (LVM_INT16)(2*pBuffer->OutDelaySamples)); /* Number of delay samples */
+
+ /*
+ * Update the pointer and sample counts
+ */
+ pDest += 2*pBuffer->OutDelaySamples; /* Output sample pointer */
+ NumSamples = (LVM_INT16)(NumSamples - pBuffer->OutDelaySamples); /* Samples left to send */
+ pBuffer->OutDelaySamples = 0; /* No samples left in the buffer */
+
+ }
+ else
+ {
+ /*
+ * Copy only some of the ouput delay samples to the output
+ */
+ Copy_16(&pBuffer->OutDelayBuffer[0], /* Source */
+ pDest, /* Detsination */
+ (LVM_INT16)(2*NumSamples)); /* Number of delay samples */
+
+ /*
+ * Update the pointer and sample counts
+ */
+ pDest += 2*NumSamples; /* Output sample pointer */
+ pBuffer->OutDelaySamples = (LVM_INT16)(pBuffer->OutDelaySamples - NumSamples); /* No samples left in the buffer */
+
+
+ /*
+ * Realign the delay buffer data to avoid using circular buffer management
+ */
+ Copy_16(&pBuffer->OutDelayBuffer[2*NumSamples], /* Source */
+ &pBuffer->OutDelayBuffer[0], /* Destination */
+ (LVM_INT16)(2*pBuffer->OutDelaySamples)); /* Number of samples to move */
+ NumSamples = 0; /* Samples left to send */
+ }
+ }
+
+
+ /*
+ * Copy the processed results to the output
+ */
+ if ((NumSamples != 0) &&
+ (SampleCount != 0))
+ {
+ if (SampleCount <= NumSamples)
+ {
+ /*
+ * Copy all processed samples to the output
+ */
+ Copy_16(pStart, /* Source */
+ pDest, /* Detsination */
+ (LVM_INT16)(2*SampleCount)); /* Number of processed samples */
+
+ /*
+ * Update the pointer and sample counts
+ */
+ pDest += 2 * SampleCount; /* Output sample pointer */
+ NumSamples = (LVM_INT16)(NumSamples - SampleCount); /* Samples left to send */
+ SampleCount = 0; /* No samples left in the buffer */
+ }
+ else
+ {
+ /*
+ * Copy only some processed samples to the output
+ */
+ Copy_16(pStart, /* Source */
+ pDest, /* Destination */
+ (LVM_INT16)(2*NumSamples)); /* Number of processed samples */
+
+
+ /*
+ * Update the pointers and sample counts
+ */
+ pStart += 2 * NumSamples; /* Processed sample pointer */
+ pDest += 2 * NumSamples; /* Output sample pointer */
+ SampleCount = (LVM_INT16)(SampleCount - NumSamples); /* Processed samples left */
+ NumSamples = 0; /* Clear the sample count */
+ }
+ }
+
+
+ /*
+ * Copy the remaining processed data to the output delay buffer
+ */
+ if (SampleCount != 0)
+ {
+ Copy_16(pStart, /* Source */
+ &pBuffer->OutDelayBuffer[2*pBuffer->OutDelaySamples], /* Destination */
+ (LVM_INT16)(2*SampleCount)); /* Number of processed samples */
+ pBuffer->OutDelaySamples = (LVM_INT16)(pBuffer->OutDelaySamples + SampleCount); /* Update the buffer count */
+ }
+
+
+ /*
+ * pointers, counts and set default buffer processing
+ */
+ pBuffer->SamplesToOutput = NumSamples; /* Samples left to send */
+ pInstance->pOutputSamples = pDest; /* Output sample pointer */
+ pBuffer->BufferState = LVM_MAXBLOCKCALL; /* Set for the default call block size */
+ *pNumSamples = (LVM_UINT16)pInstance->SamplesToProcess; /* This will terminate the loop when all samples processed */
+}
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_BufferUnmanagedOut */
+/* */
+/* DESCRIPTION: */
+/* This works in conjunction with the unmanaged input routine and updates the number */
+/* of samples left to be processed and adjusts the buffer pointers. */
+/* */
+/* PARAMETERS: */
+/* hInstance - Instance handle */
+/* pNumSamples - Pointer to the number of samples to process */
+/* */
+/* RETURNS: */
+/* None */
+/* */
+/* NOTES: */
+/* */
+/****************************************************************************************/
+
+void LVM_BufferUnmanagedOut(LVM_Handle_t hInstance,
+ LVM_UINT16 *pNumSamples)
+{
+
+ LVM_Instance_t *pInstance = (LVM_Instance_t *)hInstance;
+ LVM_INT16 NumChannels =2;
+
+
+ /*
+ * Update sample counts
+ */
+ pInstance->pInputSamples += (LVM_INT16)(*pNumSamples * NumChannels); /* Update the I/O pointers */
+ pInstance->pOutputSamples += (LVM_INT16)(*pNumSamples * 2);
+ pInstance->SamplesToProcess = (LVM_INT16)(pInstance->SamplesToProcess - *pNumSamples); /* Update the sample count */
+
+ /*
+ * Set te block size to process
+ */
+ if (pInstance->SamplesToProcess > pInstance->InternalBlockSize)
+ {
+ *pNumSamples = (LVM_UINT16)pInstance->InternalBlockSize;
+ }
+ else
+ {
+ *pNumSamples = (LVM_UINT16)pInstance->SamplesToProcess;
+ }
+}
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_BufferOptimisedOut */
+/* */
+/* DESCRIPTION: */
+/* This works in conjunction with the optimised input routine and copies the last few */
+/* processed and unprocessed samples to their respective buffers. */
+/* */
+/* PARAMETERS: */
+/* hInstance - Instance handle */
+/* pNumSamples - Pointer to the number of samples to process */
+/* */
+/* RETURNS: */
+/* None */
+/* */
+/* NOTES: */
+/* */
+/****************************************************************************************/
+
+void LVM_BufferOptimisedOut(LVM_Handle_t hInstance,
+ LVM_UINT16 *pNumSamples)
+{
+
+ LVM_Instance_t *pInstance = (LVM_Instance_t *)hInstance;
+ LVM_Buffer_t *pBuffer = pInstance->pBufferManagement;
+
+ /*
+ * Check if it is the last block to process
+ */
+ if (pBuffer->BufferState == LVM_LASTCALL)
+ {
+ LVM_INT16 *pSrc = pBuffer->pScratch;
+
+ /*
+ * Copy the unprocessed samples to the input delay buffer
+ */
+ if (pInstance->SamplesToProcess != 0)
+ {
+ Copy_16(pInstance->pInputSamples, /* Source */
+ &pBuffer->InDelayBuffer[0], /* Destination */
+ (LVM_INT16)(2*pInstance->SamplesToProcess)); /* Number of input samples */
+ pBuffer->InDelaySamples = pInstance->SamplesToProcess;
+ pInstance->SamplesToProcess = 0;
+ }
+ else
+ {
+ pBuffer->InDelaySamples = 0;
+ }
+
+
+ /*
+ * Fill the last empty spaces in the output buffer
+ */
+ if (pBuffer->SamplesToOutput != 0)
+ {
+ Copy_16(pSrc, /* Source */
+ pInstance->pOutputSamples, /* Destination */
+ (LVM_INT16)(2*pBuffer->SamplesToOutput)); /* Number of input samples */
+ *pNumSamples = (LVM_UINT16)(*pNumSamples - pBuffer->SamplesToOutput);
+ pSrc += 2 * pBuffer->SamplesToOutput; /* Update scratch pointer */
+ pBuffer->SamplesToOutput = 0; /* No more samples in this block */
+ }
+
+
+ /*
+ * Save any remaining processed samples in the output delay buffer
+ */
+ if (*pNumSamples != 0)
+ {
+ Copy_16(pSrc, /* Source */
+ &pBuffer->OutDelayBuffer[0], /* Destination */
+ (LVM_INT16)(2**pNumSamples)); /* Number of input samples */
+
+ pBuffer->OutDelaySamples = (LVM_INT16)*pNumSamples;
+
+ *pNumSamples = 0; /* No more samples in this block */
+ }
+ else
+ {
+ pBuffer->OutDelaySamples = 0;
+ }
+ }
+}
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_BufferOut */
+/* */
+/* DESCRIPTION: */
+/* This function manages the data output, it has the following features: */
+/* - Output data to 16-bit aligned memory */
+/* - Reads data from 32-bit aligned memory */
+/* - Reads data only in blocks of frame size or multiples of frame size */
+/* - Writes the same number of samples as the LVM_BufferIn function reads */
+/* - Works with inplace or outplace processing automatically */
+/* */
+/* To manage the data the function has a number of operating states: */
+/* LVM_FIRSTCALL - The first call for this block of input samples */
+/* LVM_FIRSTLASTCALL - This is the first and last call for this block of input*/
+/* samples, this occurs when the number of samples to */
+/* process is less than the maximum block size. */
+/* */
+/* The function uses an internal delay buffer the size of the minimum frame, this is */
+/* used to temporarily hold samples when the number of samples to write is not a */
+/* multiple of the frame size. */
+/* */
+/* To ensure correct operation with inplace buffering the number of samples to output*/
+/* per call is always the same as the number of samples read from the input buffer. */
+/* */
+/* PARAMETERS: */
+/* hInstance - Instance handle */
+/* pOutData - Pointer to the output data stream */
+/* pNumSamples - Pointer to the number of samples to process */
+/* */
+/* RETURNS: */
+/* None */
+/* */
+/* NOTES: */
+/* */
+/****************************************************************************************/
+
+void LVM_BufferOut(LVM_Handle_t hInstance,
+ LVM_INT16 *pOutData,
+ LVM_UINT16 *pNumSamples)
+{
+
+ LVM_Instance_t *pInstance = (LVM_Instance_t *)hInstance;
+
+
+ /*
+ * Check which mode, managed or unmanaged
+ */
+ if (pInstance->InstParams.BufferMode == LVM_MANAGED_BUFFERS)
+ {
+ LVM_BufferManagedOut(hInstance,
+ pOutData,
+ pNumSamples);
+ }
+ else
+ {
+ LVM_BufferUnmanagedOut(hInstance,
+ pNumSamples);
+ }
+}
+
diff --git a/media/libeffects/lvm/lib/Bundle/src/LVM_Coeffs.h b/media/libeffects/lvm/lib/Bundle/src/LVM_Coeffs.h
new file mode 100755
index 0000000..f578db9
--- /dev/null
+++ b/media/libeffects/lvm/lib/Bundle/src/LVM_Coeffs.h
@@ -0,0 +1,573 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef __LVM_COEFFS_H__
+#define __LVM_COEFFS_H__
+
+
+/************************************************************************************/
+/* */
+/* High Pass Shelving Filter coefficients */
+/* */
+/************************************************************************************/
+
+#define TrebleBoostCorner 8000
+#define TrebleBoostMinRate 4
+#define TrebleBoostSteps 15
+
+
+/* Coefficients for sample rate 22050Hz */
+ /* Gain = 1.000000 dB */
+#define HPF_Fs22050_Gain1_A0 5383 /* Floating point value 0.164291 */
+#define HPF_Fs22050_Gain1_A1 16859 /* Floating point value 0.514492 */
+#define HPF_Fs22050_Gain1_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain1_B1 12125 /* Floating point value 0.370033 */
+#define HPF_Fs22050_Gain1_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain1_Shift 1 /* Shift value */
+ /* Gain = 2.000000 dB */
+#define HPF_Fs22050_Gain2_A0 4683 /* Floating point value 0.142925 */
+#define HPF_Fs22050_Gain2_A1 17559 /* Floating point value 0.535858 */
+#define HPF_Fs22050_Gain2_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain2_B1 12125 /* Floating point value 0.370033 */
+#define HPF_Fs22050_Gain2_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain2_Shift 1 /* Shift value */
+ /* Gain = 3.000000 dB */
+#define HPF_Fs22050_Gain3_A0 3898 /* Floating point value 0.118953 */
+#define HPF_Fs22050_Gain3_A1 18345 /* Floating point value 0.559830 */
+#define HPF_Fs22050_Gain3_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain3_B1 12125 /* Floating point value 0.370033 */
+#define HPF_Fs22050_Gain3_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain3_Shift 1 /* Shift value */
+ /* Gain = 4.000000 dB */
+#define HPF_Fs22050_Gain4_A0 3016 /* Floating point value 0.092055 */
+#define HPF_Fs22050_Gain4_A1 19226 /* Floating point value 0.586728 */
+#define HPF_Fs22050_Gain4_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain4_B1 12125 /* Floating point value 0.370033 */
+#define HPF_Fs22050_Gain4_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain4_Shift 1 /* Shift value */
+ /* Gain = 5.000000 dB */
+#define HPF_Fs22050_Gain5_A0 2028 /* Floating point value 0.061876 */
+#define HPF_Fs22050_Gain5_A1 20215 /* Floating point value 0.616907 */
+#define HPF_Fs22050_Gain5_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain5_B1 12125 /* Floating point value 0.370033 */
+#define HPF_Fs22050_Gain5_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain5_Shift 1 /* Shift value */
+ /* Gain = 6.000000 dB */
+#define HPF_Fs22050_Gain6_A0 918 /* Floating point value 0.028013 */
+#define HPF_Fs22050_Gain6_A1 21324 /* Floating point value 0.650770 */
+#define HPF_Fs22050_Gain6_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain6_B1 12125 /* Floating point value 0.370033 */
+#define HPF_Fs22050_Gain6_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain6_Shift 1 /* Shift value */
+ /* Gain = 7.000000 dB */
+#define HPF_Fs22050_Gain7_A0 -164 /* Floating point value -0.005002 */
+#define HPF_Fs22050_Gain7_A1 11311 /* Floating point value 0.345199 */
+#define HPF_Fs22050_Gain7_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain7_B1 12125 /* Floating point value 0.370033 */
+#define HPF_Fs22050_Gain7_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain7_Shift 2 /* Shift value */
+ /* Gain = 8.000000 dB */
+#define HPF_Fs22050_Gain8_A0 -864 /* Floating point value -0.026368 */
+#define HPF_Fs22050_Gain8_A1 12012 /* Floating point value 0.366565 */
+#define HPF_Fs22050_Gain8_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain8_B1 12125 /* Floating point value 0.370033 */
+#define HPF_Fs22050_Gain8_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain8_Shift 2 /* Shift value */
+ /* Gain = 9.000000 dB */
+#define HPF_Fs22050_Gain9_A0 -1650 /* Floating point value -0.050340 */
+#define HPF_Fs22050_Gain9_A1 12797 /* Floating point value 0.390537 */
+#define HPF_Fs22050_Gain9_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain9_B1 12125 /* Floating point value 0.370033 */
+#define HPF_Fs22050_Gain9_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain9_Shift 2 /* Shift value */
+ /* Gain = 10.000000 dB */
+#define HPF_Fs22050_Gain10_A0 -2531 /* Floating point value -0.077238 */
+#define HPF_Fs22050_Gain10_A1 13679 /* Floating point value 0.417435 */
+#define HPF_Fs22050_Gain10_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain10_B1 12125 /* Floating point value 0.370033 */
+#define HPF_Fs22050_Gain10_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain10_Shift 2 /* Shift value */
+ /* Gain = 11.000000 dB */
+#define HPF_Fs22050_Gain11_A0 -3520 /* Floating point value -0.107417 */
+#define HPF_Fs22050_Gain11_A1 14667 /* Floating point value 0.447615 */
+#define HPF_Fs22050_Gain11_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain11_B1 12125 /* Floating point value 0.370033 */
+#define HPF_Fs22050_Gain11_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain11_Shift 2 /* Shift value */
+ /* Gain = 12.000000 dB */
+#define HPF_Fs22050_Gain12_A0 -4629 /* Floating point value -0.141279 */
+#define HPF_Fs22050_Gain12_A1 15777 /* Floating point value 0.481477 */
+#define HPF_Fs22050_Gain12_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain12_B1 12125 /* Floating point value 0.370033 */
+#define HPF_Fs22050_Gain12_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain12_Shift 2 /* Shift value */
+ /* Gain = 13.000000 dB */
+#define HPF_Fs22050_Gain13_A0 -2944 /* Floating point value -0.089849 */
+#define HPF_Fs22050_Gain13_A1 8531 /* Floating point value 0.260352 */
+#define HPF_Fs22050_Gain13_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain13_B1 12125 /* Floating point value 0.370033 */
+#define HPF_Fs22050_Gain13_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain13_Shift 3 /* Shift value */
+ /* Gain = 14.000000 dB */
+#define HPF_Fs22050_Gain14_A0 -3644 /* Floating point value -0.111215 */
+#define HPF_Fs22050_Gain14_A1 9231 /* Floating point value 0.281718 */
+#define HPF_Fs22050_Gain14_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain14_B1 12125 /* Floating point value 0.370033 */
+#define HPF_Fs22050_Gain14_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain14_Shift 3 /* Shift value */
+ /* Gain = 15.000000 dB */
+#define HPF_Fs22050_Gain15_A0 -4430 /* Floating point value -0.135187 */
+#define HPF_Fs22050_Gain15_A1 10017 /* Floating point value 0.305690 */
+#define HPF_Fs22050_Gain15_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain15_B1 12125 /* Floating point value 0.370033 */
+#define HPF_Fs22050_Gain15_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain15_Shift 3 /* Shift value */
+
+
+/* Coefficients for sample rate 24000Hz */
+ /* Gain = 1.000000 dB */
+#define HPF_Fs24000_Gain1_A0 3625 /* Floating point value 0.110628 */
+#define HPF_Fs24000_Gain1_A1 16960 /* Floating point value 0.517578 */
+#define HPF_Fs24000_Gain1_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain1_B1 8780 /* Floating point value 0.267949 */
+#define HPF_Fs24000_Gain1_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain1_Shift 1 /* Shift value */
+ /* Gain = 2.000000 dB */
+#define HPF_Fs24000_Gain2_A0 2811 /* Floating point value 0.085800 */
+#define HPF_Fs24000_Gain2_A1 17774 /* Floating point value 0.542406 */
+#define HPF_Fs24000_Gain2_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain2_B1 8780 /* Floating point value 0.267949 */
+#define HPF_Fs24000_Gain2_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain2_Shift 1 /* Shift value */
+ /* Gain = 3.000000 dB */
+#define HPF_Fs24000_Gain3_A0 1899 /* Floating point value 0.057943 */
+#define HPF_Fs24000_Gain3_A1 18686 /* Floating point value 0.570263 */
+#define HPF_Fs24000_Gain3_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain3_B1 8780 /* Floating point value 0.267949 */
+#define HPF_Fs24000_Gain3_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain3_Shift 1 /* Shift value */
+ /* Gain = 4.000000 dB */
+#define HPF_Fs24000_Gain4_A0 874 /* Floating point value 0.026687 */
+#define HPF_Fs24000_Gain4_A1 19711 /* Floating point value 0.601519 */
+#define HPF_Fs24000_Gain4_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain4_B1 8780 /* Floating point value 0.267949 */
+#define HPF_Fs24000_Gain4_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain4_Shift 1 /* Shift value */
+ /* Gain = 5.000000 dB */
+#define HPF_Fs24000_Gain5_A0 -275 /* Floating point value -0.008383 */
+#define HPF_Fs24000_Gain5_A1 20860 /* Floating point value 0.636589 */
+#define HPF_Fs24000_Gain5_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain5_B1 8780 /* Floating point value 0.267949 */
+#define HPF_Fs24000_Gain5_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain5_Shift 1 /* Shift value */
+ /* Gain = 6.000000 dB */
+#define HPF_Fs24000_Gain6_A0 -1564 /* Floating point value -0.047733 */
+#define HPF_Fs24000_Gain6_A1 22149 /* Floating point value 0.675938 */
+#define HPF_Fs24000_Gain6_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain6_B1 8780 /* Floating point value 0.267949 */
+#define HPF_Fs24000_Gain6_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain6_Shift 1 /* Shift value */
+ /* Gain = 7.000000 dB */
+#define HPF_Fs24000_Gain7_A0 -1509 /* Floating point value -0.046051 */
+#define HPF_Fs24000_Gain7_A1 11826 /* Floating point value 0.360899 */
+#define HPF_Fs24000_Gain7_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain7_B1 8780 /* Floating point value 0.267949 */
+#define HPF_Fs24000_Gain7_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain7_Shift 2 /* Shift value */
+ /* Gain = 8.000000 dB */
+#define HPF_Fs24000_Gain8_A0 -2323 /* Floating point value -0.070878 */
+#define HPF_Fs24000_Gain8_A1 12640 /* Floating point value 0.385727 */
+#define HPF_Fs24000_Gain8_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain8_B1 8780 /* Floating point value 0.267949 */
+#define HPF_Fs24000_Gain8_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain8_Shift 2 /* Shift value */
+ /* Gain = 9.000000 dB */
+#define HPF_Fs24000_Gain9_A0 -3235 /* Floating point value -0.098736 */
+#define HPF_Fs24000_Gain9_A1 13552 /* Floating point value 0.413584 */
+#define HPF_Fs24000_Gain9_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain9_B1 8780 /* Floating point value 0.267949 */
+#define HPF_Fs24000_Gain9_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain9_Shift 2 /* Shift value */
+ /* Gain = 10.000000 dB */
+#define HPF_Fs24000_Gain10_A0 -4260 /* Floating point value -0.129992 */
+#define HPF_Fs24000_Gain10_A1 14577 /* Floating point value 0.444841 */
+#define HPF_Fs24000_Gain10_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain10_B1 8780 /* Floating point value 0.267949 */
+#define HPF_Fs24000_Gain10_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain10_Shift 2 /* Shift value */
+ /* Gain = 11.000000 dB */
+#define HPF_Fs24000_Gain11_A0 -5409 /* Floating point value -0.165062 */
+#define HPF_Fs24000_Gain11_A1 15726 /* Floating point value 0.479911 */
+#define HPF_Fs24000_Gain11_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain11_B1 8780 /* Floating point value 0.267949 */
+#define HPF_Fs24000_Gain11_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain11_Shift 2 /* Shift value */
+ /* Gain = 12.000000 dB */
+#define HPF_Fs24000_Gain12_A0 -6698 /* Floating point value -0.204411 */
+#define HPF_Fs24000_Gain12_A1 17015 /* Floating point value 0.519260 */
+#define HPF_Fs24000_Gain12_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain12_B1 8780 /* Floating point value 0.267949 */
+#define HPF_Fs24000_Gain12_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain12_Shift 2 /* Shift value */
+ /* Gain = 13.000000 dB */
+#define HPF_Fs24000_Gain13_A0 -4082 /* Floating point value -0.124576 */
+#define HPF_Fs24000_Gain13_A1 9253 /* Floating point value 0.282374 */
+#define HPF_Fs24000_Gain13_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain13_B1 8780 /* Floating point value 0.267949 */
+#define HPF_Fs24000_Gain13_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain13_Shift 3 /* Shift value */
+ /* Gain = 14.000000 dB */
+#define HPF_Fs24000_Gain14_A0 -4896 /* Floating point value -0.149404 */
+#define HPF_Fs24000_Gain14_A1 10066 /* Floating point value 0.307202 */
+#define HPF_Fs24000_Gain14_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain14_B1 8780 /* Floating point value 0.267949 */
+#define HPF_Fs24000_Gain14_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain14_Shift 3 /* Shift value */
+ /* Gain = 15.000000 dB */
+#define HPF_Fs24000_Gain15_A0 -5808 /* Floating point value -0.177261 */
+#define HPF_Fs24000_Gain15_A1 10979 /* Floating point value 0.335059 */
+#define HPF_Fs24000_Gain15_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain15_B1 8780 /* Floating point value 0.267949 */
+#define HPF_Fs24000_Gain15_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain15_Shift 3 /* Shift value */
+
+
+/* Coefficients for sample rate 32000Hz */
+ /* Gain = 1.000000 dB */
+#define HPF_Fs32000_Gain1_A0 17225 /* Floating point value 0.525677 */
+#define HPF_Fs32000_Gain1_A1 -990 /* Floating point value -0.030227 */
+#define HPF_Fs32000_Gain1_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain1_B1 0 /* Floating point value -0.000000 */
+#define HPF_Fs32000_Gain1_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain1_Shift 1 /* Shift value */
+ /* Gain = 2.000000 dB */
+#define HPF_Fs32000_Gain2_A0 18337 /* Floating point value 0.559593 */
+#define HPF_Fs32000_Gain2_A1 -2102 /* Floating point value -0.064142 */
+#define HPF_Fs32000_Gain2_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain2_B1 0 /* Floating point value -0.000000 */
+#define HPF_Fs32000_Gain2_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain2_Shift 1 /* Shift value */
+ /* Gain = 3.000000 dB */
+#define HPF_Fs32000_Gain3_A0 19584 /* Floating point value 0.597646 */
+#define HPF_Fs32000_Gain3_A1 -3349 /* Floating point value -0.102196 */
+#define HPF_Fs32000_Gain3_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain3_B1 0 /* Floating point value -0.000000 */
+#define HPF_Fs32000_Gain3_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain3_Shift 1 /* Shift value */
+ /* Gain = 4.000000 dB */
+#define HPF_Fs32000_Gain4_A0 20983 /* Floating point value 0.640343 */
+#define HPF_Fs32000_Gain4_A1 -4748 /* Floating point value -0.144893 */
+#define HPF_Fs32000_Gain4_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain4_B1 0 /* Floating point value -0.000000 */
+#define HPF_Fs32000_Gain4_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain4_Shift 1 /* Shift value */
+ /* Gain = 5.000000 dB */
+#define HPF_Fs32000_Gain5_A0 22553 /* Floating point value 0.688250 */
+#define HPF_Fs32000_Gain5_A1 -6318 /* Floating point value -0.192799 */
+#define HPF_Fs32000_Gain5_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain5_B1 0 /* Floating point value -0.000000 */
+#define HPF_Fs32000_Gain5_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain5_Shift 1 /* Shift value */
+ /* Gain = 6.000000 dB */
+#define HPF_Fs32000_Gain6_A0 24314 /* Floating point value 0.742002 */
+#define HPF_Fs32000_Gain6_A1 -8079 /* Floating point value -0.246551 */
+#define HPF_Fs32000_Gain6_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain6_B1 0 /* Floating point value -0.000000 */
+#define HPF_Fs32000_Gain6_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain6_Shift 1 /* Shift value */
+ /* Gain = 7.000000 dB */
+#define HPF_Fs32000_Gain7_A0 13176 /* Floating point value 0.402109 */
+#define HPF_Fs32000_Gain7_A1 -5040 /* Floating point value -0.153795 */
+#define HPF_Fs32000_Gain7_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain7_B1 0 /* Floating point value -0.000000 */
+#define HPF_Fs32000_Gain7_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain7_Shift 2 /* Shift value */
+ /* Gain = 8.000000 dB */
+#define HPF_Fs32000_Gain8_A0 14288 /* Floating point value 0.436024 */
+#define HPF_Fs32000_Gain8_A1 -6151 /* Floating point value -0.187711 */
+#define HPF_Fs32000_Gain8_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain8_B1 0 /* Floating point value -0.000000 */
+#define HPF_Fs32000_Gain8_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain8_Shift 2 /* Shift value */
+ /* Gain = 9.000000 dB */
+#define HPF_Fs32000_Gain9_A0 15535 /* Floating point value 0.474078 */
+#define HPF_Fs32000_Gain9_A1 -7398 /* Floating point value -0.225764 */
+#define HPF_Fs32000_Gain9_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain9_B1 0 /* Floating point value -0.000000 */
+#define HPF_Fs32000_Gain9_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain9_Shift 2 /* Shift value */
+ /* Gain = 10.000000 dB */
+#define HPF_Fs32000_Gain10_A0 16934 /* Floating point value 0.516774 */
+#define HPF_Fs32000_Gain10_A1 -8797 /* Floating point value -0.268461 */
+#define HPF_Fs32000_Gain10_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain10_B1 0 /* Floating point value -0.000000 */
+#define HPF_Fs32000_Gain10_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain10_Shift 2 /* Shift value */
+ /* Gain = 11.000000 dB */
+#define HPF_Fs32000_Gain11_A0 18503 /* Floating point value 0.564681 */
+#define HPF_Fs32000_Gain11_A1 -10367 /* Floating point value -0.316368 */
+#define HPF_Fs32000_Gain11_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain11_B1 0 /* Floating point value -0.000000 */
+#define HPF_Fs32000_Gain11_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain11_Shift 2 /* Shift value */
+ /* Gain = 12.000000 dB */
+#define HPF_Fs32000_Gain12_A0 20265 /* Floating point value 0.618433 */
+#define HPF_Fs32000_Gain12_A1 -12128 /* Floating point value -0.370120 */
+#define HPF_Fs32000_Gain12_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain12_B1 0 /* Floating point value -0.000000 */
+#define HPF_Fs32000_Gain12_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain12_Shift 2 /* Shift value */
+ /* Gain = 13.000000 dB */
+#define HPF_Fs32000_Gain13_A0 11147 /* Floating point value 0.340178 */
+#define HPF_Fs32000_Gain13_A1 -7069 /* Floating point value -0.215726 */
+#define HPF_Fs32000_Gain13_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain13_B1 0 /* Floating point value -0.000000 */
+#define HPF_Fs32000_Gain13_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain13_Shift 3 /* Shift value */
+ /* Gain = 14.000000 dB */
+#define HPF_Fs32000_Gain14_A0 12258 /* Floating point value 0.374093 */
+#define HPF_Fs32000_Gain14_A1 -8180 /* Floating point value -0.249642 */
+#define HPF_Fs32000_Gain14_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain14_B1 0 /* Floating point value -0.000000 */
+#define HPF_Fs32000_Gain14_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain14_Shift 3 /* Shift value */
+ /* Gain = 15.000000 dB */
+#define HPF_Fs32000_Gain15_A0 13505 /* Floating point value 0.412147 */
+#define HPF_Fs32000_Gain15_A1 -9427 /* Floating point value -0.287695 */
+#define HPF_Fs32000_Gain15_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain15_B1 0 /* Floating point value -0.000000 */
+#define HPF_Fs32000_Gain15_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain15_Shift 3 /* Shift value */
+
+
+/* Coefficients for sample rate 44100Hz */
+ /* Gain = 1.000000 dB */
+#define HPF_Fs44100_Gain1_A0 17442 /* Floating point value 0.532294 */
+#define HPF_Fs44100_Gain1_A1 -4761 /* Floating point value -0.145294 */
+#define HPF_Fs44100_Gain1_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain1_B1 -7173 /* Floating point value -0.218894 */
+#define HPF_Fs44100_Gain1_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain1_Shift 1 /* Shift value */
+ /* Gain = 2.000000 dB */
+#define HPF_Fs44100_Gain2_A0 18797 /* Floating point value 0.573633 */
+#define HPF_Fs44100_Gain2_A1 -6116 /* Floating point value -0.186634 */
+#define HPF_Fs44100_Gain2_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain2_B1 -7173 /* Floating point value -0.218894 */
+#define HPF_Fs44100_Gain2_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain2_Shift 1 /* Shift value */
+ /* Gain = 3.000000 dB */
+#define HPF_Fs44100_Gain3_A0 20317 /* Floating point value 0.620016 */
+#define HPF_Fs44100_Gain3_A1 -7635 /* Floating point value -0.233017 */
+#define HPF_Fs44100_Gain3_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain3_B1 -7173 /* Floating point value -0.218894 */
+#define HPF_Fs44100_Gain3_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain3_Shift 1 /* Shift value */
+ /* Gain = 4.000000 dB */
+#define HPF_Fs44100_Gain4_A0 22022 /* Floating point value 0.672059 */
+#define HPF_Fs44100_Gain4_A1 -9341 /* Floating point value -0.285060 */
+#define HPF_Fs44100_Gain4_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain4_B1 -7173 /* Floating point value -0.218894 */
+#define HPF_Fs44100_Gain4_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain4_Shift 1 /* Shift value */
+ /* Gain = 5.000000 dB */
+#define HPF_Fs44100_Gain5_A0 23935 /* Floating point value 0.730452 */
+#define HPF_Fs44100_Gain5_A1 -11254 /* Floating point value -0.343453 */
+#define HPF_Fs44100_Gain5_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain5_B1 -7173 /* Floating point value -0.218894 */
+#define HPF_Fs44100_Gain5_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain5_Shift 1 /* Shift value */
+ /* Gain = 6.000000 dB */
+#define HPF_Fs44100_Gain6_A0 26082 /* Floating point value 0.795970 */
+#define HPF_Fs44100_Gain6_A1 -13401 /* Floating point value -0.408971 */
+#define HPF_Fs44100_Gain6_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain6_B1 -7173 /* Floating point value -0.218894 */
+#define HPF_Fs44100_Gain6_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain6_Shift 1 /* Shift value */
+ /* Gain = 7.000000 dB */
+#define HPF_Fs44100_Gain7_A0 14279 /* Floating point value 0.435774 */
+#define HPF_Fs44100_Gain7_A1 -7924 /* Floating point value -0.241815 */
+#define HPF_Fs44100_Gain7_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain7_B1 -7173 /* Floating point value -0.218894 */
+#define HPF_Fs44100_Gain7_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain7_Shift 2 /* Shift value */
+ /* Gain = 8.000000 dB */
+#define HPF_Fs44100_Gain8_A0 15634 /* Floating point value 0.477113 */
+#define HPF_Fs44100_Gain8_A1 -9278 /* Floating point value -0.283154 */
+#define HPF_Fs44100_Gain8_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain8_B1 -7173 /* Floating point value -0.218894 */
+#define HPF_Fs44100_Gain8_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain8_Shift 2 /* Shift value */
+ /* Gain = 9.000000 dB */
+#define HPF_Fs44100_Gain9_A0 17154 /* Floating point value 0.523496 */
+#define HPF_Fs44100_Gain9_A1 -10798 /* Floating point value -0.329537 */
+#define HPF_Fs44100_Gain9_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain9_B1 -7173 /* Floating point value -0.218894 */
+#define HPF_Fs44100_Gain9_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain9_Shift 2 /* Shift value */
+ /* Gain = 10.000000 dB */
+#define HPF_Fs44100_Gain10_A0 18859 /* Floating point value 0.575539 */
+#define HPF_Fs44100_Gain10_A1 -12504 /* Floating point value -0.381580 */
+#define HPF_Fs44100_Gain10_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain10_B1 -7173 /* Floating point value -0.218894 */
+#define HPF_Fs44100_Gain10_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain10_Shift 2 /* Shift value */
+ /* Gain = 11.000000 dB */
+#define HPF_Fs44100_Gain11_A0 20773 /* Floating point value 0.633932 */
+#define HPF_Fs44100_Gain11_A1 -14417 /* Floating point value -0.439973 */
+#define HPF_Fs44100_Gain11_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain11_B1 -7173 /* Floating point value -0.218894 */
+#define HPF_Fs44100_Gain11_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain11_Shift 2 /* Shift value */
+ /* Gain = 12.000000 dB */
+#define HPF_Fs44100_Gain12_A0 22920 /* Floating point value 0.699450 */
+#define HPF_Fs44100_Gain12_A1 -16564 /* Floating point value -0.505491 */
+#define HPF_Fs44100_Gain12_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain12_B1 -7173 /* Floating point value -0.218894 */
+#define HPF_Fs44100_Gain12_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain12_Shift 2 /* Shift value */
+ /* Gain = 13.000000 dB */
+#define HPF_Fs44100_Gain13_A0 12694 /* Floating point value 0.387399 */
+#define HPF_Fs44100_Gain13_A1 -9509 /* Floating point value -0.290189 */
+#define HPF_Fs44100_Gain13_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain13_B1 -7173 /* Floating point value -0.218894 */
+#define HPF_Fs44100_Gain13_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain13_Shift 3 /* Shift value */
+ /* Gain = 14.000000 dB */
+#define HPF_Fs44100_Gain14_A0 14049 /* Floating point value 0.428738 */
+#define HPF_Fs44100_Gain14_A1 -10864 /* Floating point value -0.331528 */
+#define HPF_Fs44100_Gain14_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain14_B1 -7173 /* Floating point value -0.218894 */
+#define HPF_Fs44100_Gain14_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain14_Shift 3 /* Shift value */
+ /* Gain = 15.000000 dB */
+#define HPF_Fs44100_Gain15_A0 15569 /* Floating point value 0.475121 */
+#define HPF_Fs44100_Gain15_A1 -12383 /* Floating point value -0.377912 */
+#define HPF_Fs44100_Gain15_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain15_B1 -7173 /* Floating point value -0.218894 */
+#define HPF_Fs44100_Gain15_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain15_Shift 3 /* Shift value */
+
+
+/* Coefficients for sample rate 48000Hz */
+ /* Gain = 1.000000 dB */
+#define HPF_Fs48000_Gain1_A0 17491 /* Floating point value 0.533777 */
+#define HPF_Fs48000_Gain1_A1 -5606 /* Floating point value -0.171082 */
+#define HPF_Fs48000_Gain1_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain1_B1 -8780 /* Floating point value -0.267949 */
+#define HPF_Fs48000_Gain1_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain1_Shift 1 /* Shift value */
+ /* Gain = 2.000000 dB */
+#define HPF_Fs48000_Gain2_A0 18900 /* Floating point value 0.576779 */
+#define HPF_Fs48000_Gain2_A1 -7015 /* Floating point value -0.214085 */
+#define HPF_Fs48000_Gain2_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain2_B1 -8780 /* Floating point value -0.267949 */
+#define HPF_Fs48000_Gain2_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain2_Shift 1 /* Shift value */
+ /* Gain = 3.000000 dB */
+#define HPF_Fs48000_Gain3_A0 20481 /* Floating point value 0.625029 */
+#define HPF_Fs48000_Gain3_A1 -8596 /* Floating point value -0.262335 */
+#define HPF_Fs48000_Gain3_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain3_B1 -8780 /* Floating point value -0.267949 */
+#define HPF_Fs48000_Gain3_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain3_Shift 1 /* Shift value */
+ /* Gain = 4.000000 dB */
+#define HPF_Fs48000_Gain4_A0 22255 /* Floating point value 0.679167 */
+#define HPF_Fs48000_Gain4_A1 -10370 /* Floating point value -0.316472 */
+#define HPF_Fs48000_Gain4_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain4_B1 -8780 /* Floating point value -0.267949 */
+#define HPF_Fs48000_Gain4_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain4_Shift 1 /* Shift value */
+ /* Gain = 5.000000 dB */
+#define HPF_Fs48000_Gain5_A0 24245 /* Floating point value 0.739910 */
+#define HPF_Fs48000_Gain5_A1 -12361 /* Floating point value -0.377215 */
+#define HPF_Fs48000_Gain5_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain5_B1 -8780 /* Floating point value -0.267949 */
+#define HPF_Fs48000_Gain5_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain5_Shift 1 /* Shift value */
+ /* Gain = 6.000000 dB */
+#define HPF_Fs48000_Gain6_A0 26479 /* Floating point value 0.808065 */
+#define HPF_Fs48000_Gain6_A1 -14594 /* Floating point value -0.445370 */
+#define HPF_Fs48000_Gain6_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain6_B1 -8780 /* Floating point value -0.267949 */
+#define HPF_Fs48000_Gain6_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain6_Shift 1 /* Shift value */
+ /* Gain = 7.000000 dB */
+#define HPF_Fs48000_Gain7_A0 14527 /* Floating point value 0.443318 */
+#define HPF_Fs48000_Gain7_A1 -8570 /* Floating point value -0.261540 */
+#define HPF_Fs48000_Gain7_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain7_B1 -8780 /* Floating point value -0.267949 */
+#define HPF_Fs48000_Gain7_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain7_Shift 2 /* Shift value */
+ /* Gain = 8.000000 dB */
+#define HPF_Fs48000_Gain8_A0 15936 /* Floating point value 0.486321 */
+#define HPF_Fs48000_Gain8_A1 -9979 /* Floating point value -0.304543 */
+#define HPF_Fs48000_Gain8_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain8_B1 -8780 /* Floating point value -0.267949 */
+#define HPF_Fs48000_Gain8_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain8_Shift 2 /* Shift value */
+ /* Gain = 9.000000 dB */
+#define HPF_Fs48000_Gain9_A0 17517 /* Floating point value 0.534571 */
+#define HPF_Fs48000_Gain9_A1 -11560 /* Floating point value -0.352793 */
+#define HPF_Fs48000_Gain9_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain9_B1 -8780 /* Floating point value -0.267949 */
+#define HPF_Fs48000_Gain9_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain9_Shift 2 /* Shift value */
+ /* Gain = 10.000000 dB */
+#define HPF_Fs48000_Gain10_A0 19291 /* Floating point value 0.588708 */
+#define HPF_Fs48000_Gain10_A1 -13334 /* Floating point value -0.406930 */
+#define HPF_Fs48000_Gain10_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain10_B1 -8780 /* Floating point value -0.267949 */
+#define HPF_Fs48000_Gain10_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain10_Shift 2 /* Shift value */
+ /* Gain = 11.000000 dB */
+#define HPF_Fs48000_Gain11_A0 21281 /* Floating point value 0.649452 */
+#define HPF_Fs48000_Gain11_A1 -15325 /* Floating point value -0.467674 */
+#define HPF_Fs48000_Gain11_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain11_B1 -8780 /* Floating point value -0.267949 */
+#define HPF_Fs48000_Gain11_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain11_Shift 2 /* Shift value */
+ /* Gain = 12.000000 dB */
+#define HPF_Fs48000_Gain12_A0 23515 /* Floating point value 0.717607 */
+#define HPF_Fs48000_Gain12_A1 -17558 /* Floating point value -0.535829 */
+#define HPF_Fs48000_Gain12_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain12_B1 -8780 /* Floating point value -0.267949 */
+#define HPF_Fs48000_Gain12_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain12_Shift 2 /* Shift value */
+ /* Gain = 13.000000 dB */
+#define HPF_Fs48000_Gain13_A0 13041 /* Floating point value 0.397982 */
+#define HPF_Fs48000_Gain13_A1 -10056 /* Floating point value -0.306877 */
+#define HPF_Fs48000_Gain13_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain13_B1 -8780 /* Floating point value -0.267949 */
+#define HPF_Fs48000_Gain13_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain13_Shift 3 /* Shift value */
+ /* Gain = 14.000000 dB */
+#define HPF_Fs48000_Gain14_A0 14450 /* Floating point value 0.440984 */
+#define HPF_Fs48000_Gain14_A1 -11465 /* Floating point value -0.349880 */
+#define HPF_Fs48000_Gain14_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain14_B1 -8780 /* Floating point value -0.267949 */
+#define HPF_Fs48000_Gain14_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain14_Shift 3 /* Shift value */
+ /* Gain = 15.000000 dB */
+#define HPF_Fs48000_Gain15_A0 16031 /* Floating point value 0.489234 */
+#define HPF_Fs48000_Gain15_A1 -13046 /* Floating point value -0.398130 */
+#define HPF_Fs48000_Gain15_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain15_B1 -8780 /* Floating point value -0.267949 */
+#define HPF_Fs48000_Gain15_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain15_Shift 3 /* Shift value */
+
+
+#endif
diff --git a/media/libeffects/lvm/lib/Bundle/src/LVM_Control.c b/media/libeffects/lvm/lib/Bundle/src/LVM_Control.c
new file mode 100755
index 0000000..4667feb
--- /dev/null
+++ b/media/libeffects/lvm/lib/Bundle/src/LVM_Control.c
@@ -0,0 +1,1032 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/****************************************************************************************
+
+ $Author: nxp007753 $
+ $Revision: 1255 $
+ $Date: 2010-07-16 17:07:29 +0200 (Fri, 16 Jul 2010) $
+
+*****************************************************************************************/
+
+
+/****************************************************************************************/
+/* */
+/* Includes */
+/* */
+/****************************************************************************************/
+
+#include "VectorArithmetic.h"
+#include "ScalarArithmetic.h"
+#include "LVM_Coeffs.h"
+#include "LVM_Tables.h"
+#include "LVM_Private.h"
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_SetControlParameters */
+/* */
+/* DESCRIPTION: */
+/* Sets or changes the LifeVibes module parameters. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* pParams Pointer to a parameter structure */
+/* */
+/* RETURNS: */
+/* LVM_SUCCESS Succeeded */
+/* LVM_NULLADDRESS When hInstance, pParams or any control pointers are NULL */
+/* LVM_OUTOFRANGE When any of the control parameters are out of range */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVM_Process function */
+/* */
+/****************************************************************************************/
+
+LVM_ReturnStatus_en LVM_SetControlParameters(LVM_Handle_t hInstance,
+ LVM_ControlParams_t *pParams)
+{
+ LVM_Instance_t *pInstance =(LVM_Instance_t *)hInstance;
+
+
+ if ((pParams == LVM_NULL) || (hInstance == LVM_NULL))
+ {
+ return (LVM_NULLADDRESS);
+ }
+
+ pInstance->NewParams = *pParams;
+
+ if(
+ /* General parameters */
+ ((pParams->OperatingMode != LVM_MODE_OFF) && (pParams->OperatingMode != LVM_MODE_ON)) ||
+ ((pParams->SampleRate != LVM_FS_8000) && (pParams->SampleRate != LVM_FS_11025) && (pParams->SampleRate != LVM_FS_12000) &&
+ (pParams->SampleRate != LVM_FS_16000) && (pParams->SampleRate != LVM_FS_22050) && (pParams->SampleRate != LVM_FS_24000) &&
+ (pParams->SampleRate != LVM_FS_32000) && (pParams->SampleRate != LVM_FS_44100) && (pParams->SampleRate != LVM_FS_48000)) ||
+ ((pParams->SourceFormat != LVM_STEREO) && (pParams->SourceFormat != LVM_MONOINSTEREO) && (pParams->SourceFormat != LVM_MONO)) ||
+ (pParams->SpeakerType > LVM_EX_HEADPHONES))
+ {
+ return (LVM_OUTOFRANGE);
+ }
+
+ /*
+ * Cinema Sound parameters
+ */
+ if((pParams->VirtualizerOperatingMode != LVM_MODE_OFF) && (pParams->VirtualizerOperatingMode != LVM_MODE_ON))
+ {
+ return (LVM_OUTOFRANGE);
+ }
+
+ if(pParams->VirtualizerType != LVM_CONCERTSOUND)
+ {
+ return (LVM_OUTOFRANGE);
+ }
+
+ if(pParams->VirtualizerReverbLevel > LVM_VIRTUALIZER_MAX_REVERB_LEVEL)
+ {
+ return (LVM_OUTOFRANGE);
+ }
+
+ if(pParams->CS_EffectLevel < LVM_CS_MIN_EFFECT_LEVEL)
+ {
+ return (LVM_OUTOFRANGE);
+ }
+
+ /*
+ * N-Band Equalizer
+ */
+ if(pParams->EQNB_NBands > pInstance->InstParams.EQNB_NumBands)
+ {
+ return (LVM_OUTOFRANGE);
+ }
+
+ /* Definition pointer */
+ if ((pParams->pEQNB_BandDefinition == LVM_NULL) &&
+ (pParams->EQNB_NBands != 0))
+ {
+ return (LVM_NULLADDRESS);
+ }
+
+ /*
+ * Copy the filter definitions for the Equaliser
+ */
+ {
+ LVM_INT16 i;
+
+ if (pParams->EQNB_NBands != 0)
+ {
+ for (i=0; i<pParams->EQNB_NBands; i++)
+ {
+ pInstance->pEQNB_BandDefs[i] = pParams->pEQNB_BandDefinition[i];
+ }
+ pInstance->NewParams.pEQNB_BandDefinition = pInstance->pEQNB_BandDefs;
+ }
+ }
+ if( /* N-Band Equaliser parameters */
+ ((pParams->EQNB_OperatingMode != LVM_EQNB_OFF) && (pParams->EQNB_OperatingMode != LVM_EQNB_ON)) ||
+ (pParams->EQNB_NBands > pInstance->InstParams.EQNB_NumBands))
+ {
+ return (LVM_OUTOFRANGE);
+ }
+ /* Band parameters*/
+ {
+ LVM_INT16 i;
+ for(i = 0; i < pParams->EQNB_NBands; i++)
+ {
+ if(((pParams->pEQNB_BandDefinition[i].Frequency < LVM_EQNB_MIN_BAND_FREQ) ||
+ (pParams->pEQNB_BandDefinition[i].Frequency > LVM_EQNB_MAX_BAND_FREQ)) ||
+ ((pParams->pEQNB_BandDefinition[i].Gain < LVM_EQNB_MIN_BAND_GAIN) ||
+ (pParams->pEQNB_BandDefinition[i].Gain > LVM_EQNB_MAX_BAND_GAIN)) ||
+ ((pParams->pEQNB_BandDefinition[i].QFactor < LVM_EQNB_MIN_QFACTOR) ||
+ (pParams->pEQNB_BandDefinition[i].QFactor > LVM_EQNB_MAX_QFACTOR)))
+ {
+ return (LVM_OUTOFRANGE);
+ }
+ }
+ }
+
+ /*
+ * Bass Enhancement parameters
+ */
+ if(((pParams->BE_OperatingMode != LVM_BE_OFF) && (pParams->BE_OperatingMode != LVM_BE_ON)) ||
+ ((pParams->BE_EffectLevel < LVM_BE_MIN_EFFECTLEVEL ) || (pParams->BE_EffectLevel > LVM_BE_MAX_EFFECTLEVEL ))||
+ ((pParams->BE_CentreFreq != LVM_BE_CENTRE_55Hz) && (pParams->BE_CentreFreq != LVM_BE_CENTRE_66Hz) &&
+ (pParams->BE_CentreFreq != LVM_BE_CENTRE_78Hz) && (pParams->BE_CentreFreq != LVM_BE_CENTRE_90Hz)) ||
+ ((pParams->BE_HPF != LVM_BE_HPF_OFF) && (pParams->BE_HPF != LVM_BE_HPF_ON)))
+ {
+ return (LVM_OUTOFRANGE);
+ }
+
+ /*
+ * Volume Control parameters
+ */
+ if((pParams->VC_EffectLevel < LVM_VC_MIN_EFFECTLEVEL ) || (pParams->VC_EffectLevel > LVM_VC_MAX_EFFECTLEVEL ))
+ {
+ return (LVM_OUTOFRANGE);
+ }
+ if((pParams->VC_Balance < LVM_VC_BALANCE_MIN ) || (pParams->VC_Balance > LVM_VC_BALANCE_MAX ))
+ {
+ return (LVM_OUTOFRANGE);
+ }
+
+ /*
+ * PSA parameters
+ */
+ if( (pParams->PSA_PeakDecayRate > LVPSA_SPEED_HIGH) ||
+ (pParams->PSA_Enable > LVM_PSA_ON))
+ {
+ return (LVM_OUTOFRANGE);
+ }
+
+
+ /*
+ * Set the flag to indicate there are new parameters to use
+ *
+ * Protect the copy of the new parameters from interrupts to avoid possible problems
+ * with loss control parameters. This problem can occur if this control function is called more
+ * than once before a call to the process function. If the process function interrupts
+ * the copy to NewParams then one frame may have mixed parameters, some old and some new.
+ */
+ pInstance->ControlPending = LVM_TRUE;
+ pInstance->NoSmoothVolume = LVM_FALSE;
+
+ return(LVM_SUCCESS);
+}
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_GetControlParameters */
+/* */
+/* DESCRIPTION: */
+/* Request the LifeVibes module parameters. The current parameter set is returned */
+/* via the parameter pointer. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* pParams Pointer to an empty parameter structure */
+/* */
+/* RETURNS: */
+/* LVM_SUCCESS Succeeded */
+/* LVM_NULLADDRESS when any of hInstance or pParams is NULL */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVM_Process function */
+/* */
+/****************************************************************************************/
+
+LVM_ReturnStatus_en LVM_GetControlParameters(LVM_Handle_t hInstance,
+ LVM_ControlParams_t *pParams)
+{
+ LVM_Instance_t *pInstance =(LVM_Instance_t *)hInstance;
+
+
+ /*
+ * Check pointer
+ */
+ if ((pParams == LVM_NULL) || (hInstance == LVM_NULL))
+ {
+ return (LVM_NULLADDRESS);
+ }
+ *pParams = pInstance->NewParams;
+
+ /*
+ * Copy the filter definitions for the Equaliser
+ */
+ {
+ LVM_INT16 i;
+
+ if (pInstance->NewParams.EQNB_NBands != 0)
+ for (i=0; i<pInstance->NewParams.EQNB_NBands; i++)
+ {
+ pInstance->pEQNB_UserDefs[i] = pInstance->pEQNB_BandDefs[i];
+ }
+ pParams->pEQNB_BandDefinition = pInstance->pEQNB_UserDefs;
+ }
+
+ return(LVM_SUCCESS);
+}
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_SetTrebleBoost */
+/* */
+/* DESCRIPTION: */
+/* Enable the treble boost when the settings are appropriate, i.e. non-zero gain */
+/* and the sample rate is high enough for the effect to be heard. */
+/* */
+/* PARAMETERS: */
+/* pInstance Pointer to the instance structure */
+/* pParams Pointer to the parameters to use */
+/* */
+/****************************************************************************************/
+void LVM_SetTrebleBoost(LVM_Instance_t *pInstance,
+ LVM_ControlParams_t *pParams)
+{
+ extern FO_C16_LShx_Coefs_t LVM_TrebleBoostCoefs[];
+ LVM_INT16 Offset;
+ LVM_INT16 EffectLevel = 0;
+
+ /*
+ * Load the coefficients
+ */
+ if ((pParams->TE_OperatingMode == LVM_TE_ON) &&
+ (pParams->SampleRate >= TrebleBoostMinRate) &&
+ (pParams->OperatingMode == LVM_MODE_ON) &&
+ (pParams->TE_EffectLevel > 0))
+ {
+ if((pParams->TE_EffectLevel == LVM_TE_LOW_MIPS) &&
+ ((pParams->SpeakerType == LVM_HEADPHONES)||
+ (pParams->SpeakerType == LVM_EX_HEADPHONES)))
+ {
+ pInstance->TE_Active = LVM_FALSE;
+ }
+ else
+ {
+ EffectLevel = pParams->TE_EffectLevel;
+ pInstance->TE_Active = LVM_TRUE;
+ }
+
+ if(pInstance->TE_Active == LVM_TRUE)
+ {
+ /*
+ * Load the coefficients and enabled the treble boost
+ */
+ Offset = (LVM_INT16)(EffectLevel - 1 + TrebleBoostSteps * (pParams->SampleRate - TrebleBoostMinRate));
+ FO_2I_D16F32Css_LShx_TRC_WRA_01_Init(&pInstance->pTE_State->TrebleBoost_State,
+ &pInstance->pTE_Taps->TrebleBoost_Taps,
+ &LVM_TrebleBoostCoefs[Offset]);
+
+ /*
+ * Clear the taps
+ */
+ LoadConst_16((LVM_INT16)0, /* Value */
+ (LVM_INT16 *)&pInstance->pTE_Taps->TrebleBoost_Taps, /* Destination */
+ (LVM_UINT16)(sizeof(pInstance->pTE_Taps->TrebleBoost_Taps)/sizeof(LVM_INT16))); /* Number of words */
+ }
+ }
+ else
+ {
+ /*
+ * Disable the treble boost
+ */
+ pInstance->TE_Active = LVM_FALSE;
+ }
+
+ return;
+}
+
+
+/************************************************************************************/
+/* */
+/* FUNCTION: LVM_SetVolume */
+/* */
+/* DESCRIPTION: */
+/* Converts the input volume demand from dBs to linear. */
+/* */
+/* PARAMETERS: */
+/* pInstance Pointer to the instance */
+/* pParams Initialisation parameters */
+/* */
+/************************************************************************************/
+void LVM_SetVolume(LVM_Instance_t *pInstance,
+ LVM_ControlParams_t *pParams)
+{
+
+ LVM_UINT16 dBShifts; /* 6dB shifts */
+ LVM_UINT16 dBOffset; /* Table offset */
+ LVM_INT16 Volume = 0; /* Required volume in dBs */
+
+ /*
+ * Limit the gain to the maximum allowed
+ */
+ if (pParams->VC_EffectLevel > 0)
+ {
+ Volume = 0;
+ }
+ else
+ {
+ Volume = pParams->VC_EffectLevel;
+ }
+
+ /* Compensate this volume in PSA plot */
+ if(Volume > -60) /* Limit volume loss to PSA Limits*/
+ pInstance->PSA_GainOffset=(LVM_INT16)(-Volume);/* Loss is compensated by Gain*/
+ else
+ pInstance->PSA_GainOffset=(LVM_INT16)60;/* Loss is compensated by Gain*/
+
+ pInstance->VC_AVLFixedVolume = 0;
+
+ /*
+ * Set volume control and AVL volumes according to headroom and volume user setting
+ */
+ if(pParams->OperatingMode == LVM_MODE_ON)
+ {
+ /* Default Situation with no AVL and no RS */
+ if(pParams->EQNB_OperatingMode == LVM_EQNB_ON)
+ {
+ if(Volume > -pInstance->Headroom)
+ Volume = (LVM_INT16)-pInstance->Headroom;
+ }
+ }
+
+ /*
+ * Activate volume control if necessary
+ */
+ pInstance->VC_Active = LVM_TRUE;
+ if (Volume != 0)
+ {
+ pInstance->VC_VolumedB = Volume;
+ }
+ else
+ {
+ pInstance->VC_VolumedB = 0;
+ }
+
+ /*
+ * Calculate the required gain and shifts
+ */
+ dBOffset = (LVM_UINT16)((-Volume) % 6); /* Get the dBs 0-5 */
+ dBShifts = (LVM_UINT16)(Volume / -6); /* Get the 6dB shifts */
+
+
+ /*
+ * Set the parameters
+ */
+ if(dBShifts == 0)
+ {
+ LVC_Mixer_SetTarget(&pInstance->VC_Volume.MixerStream[0],
+ (LVM_INT32)LVM_VolumeTable[dBOffset]);
+ }
+ else
+ {
+ LVC_Mixer_SetTarget(&pInstance->VC_Volume.MixerStream[0],
+ (((LVM_INT32)LVM_VolumeTable[dBOffset])>>dBShifts));
+ }
+ pInstance->VC_Volume.MixerStream[0].CallbackSet = 1;
+ if(pInstance->NoSmoothVolume == LVM_TRUE)
+ {
+ LVC_Mixer_SetTimeConstant(&pInstance->VC_Volume.MixerStream[0],0,pInstance->Params.SampleRate,2);
+ }
+ else
+ {
+ LVC_Mixer_VarSlope_SetTimeConstant(&pInstance->VC_Volume.MixerStream[0],LVM_VC_MIXER_TIME,pInstance->Params.SampleRate,2);
+ }
+}
+
+
+/************************************************************************************/
+/* */
+/* FUNCTION: LVM_SetHeadroom */
+/* */
+/* DESCRIPTION: */
+/* Find suitable headroom based on EQ settings. */
+/* */
+/* PARAMETERS: */
+/* pInstance Pointer to the instance */
+/* pParams Initialisation parameters */
+/* */
+/* RETURNS: */
+/* void Nothing */
+/* */
+/* NOTES: */
+/* */
+/************************************************************************************/
+void LVM_SetHeadroom(LVM_Instance_t *pInstance,
+ LVM_ControlParams_t *pParams)
+{
+ LVM_INT16 ii, jj;
+ LVM_INT16 Headroom = 0;
+ LVM_INT16 MaxGain = 0;
+
+
+ if ((pParams->EQNB_OperatingMode == LVEQNB_ON) && (pInstance->HeadroomParams.Headroom_OperatingMode == LVM_HEADROOM_ON))
+ {
+ /* Find typical headroom value */
+ for(jj = 0; jj < pInstance->HeadroomParams.NHeadroomBands; jj++)
+ {
+ MaxGain = 0;
+ for( ii = 0; ii < pParams->EQNB_NBands; ii++)
+ {
+ if((pParams->pEQNB_BandDefinition[ii].Frequency >= pInstance->HeadroomParams.pHeadroomDefinition[jj].Limit_Low) &&
+ (pParams->pEQNB_BandDefinition[ii].Frequency <= pInstance->HeadroomParams.pHeadroomDefinition[jj].Limit_High))
+ {
+ if(pParams->pEQNB_BandDefinition[ii].Gain > MaxGain)
+ {
+ MaxGain = pParams->pEQNB_BandDefinition[ii].Gain;
+ }
+ }
+ }
+
+ if((MaxGain - pInstance->HeadroomParams.pHeadroomDefinition[jj].Headroom_Offset) > Headroom){
+ Headroom = (LVM_INT16)(MaxGain - pInstance->HeadroomParams.pHeadroomDefinition[jj].Headroom_Offset);
+ }
+ }
+
+ /* Saturate */
+ if(Headroom < 0)
+ Headroom = 0;
+ }
+ pInstance->Headroom = (LVM_UINT16)Headroom ;
+
+}
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_ApplyNewSettings */
+/* */
+/* DESCRIPTION: */
+/* Applies changes to parametres. This function makes no assumptions about what */
+/* each module needs for initialisation and hence passes all parameters to all the */
+/* the modules in turn. */
+/* */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* */
+/* RETURNS: */
+/* LVM_Success Succeeded */
+/* */
+/****************************************************************************************/
+
+LVM_ReturnStatus_en LVM_ApplyNewSettings(LVM_Handle_t hInstance)
+{
+ LVM_Instance_t *pInstance =(LVM_Instance_t *)hInstance;
+ LVM_ControlParams_t LocalParams;
+ LVM_INT16 Count = 5;
+
+
+ /*
+ * Copy the new parameters but make sure they didn't change while copying
+ */
+ do
+ {
+ pInstance->ControlPending = LVM_FALSE;
+ LocalParams = pInstance->NewParams;
+ pInstance->HeadroomParams = pInstance->NewHeadroomParams;
+ Count--;
+ } while ((pInstance->ControlPending != LVM_FALSE) &&
+ (Count > 0));
+
+ /* Clear all internal data if format change*/
+ if(LocalParams.SourceFormat != pInstance->Params.SourceFormat)
+ {
+ LVM_ClearAudioBuffers(pInstance);
+ pInstance->ControlPending = LVM_FALSE;
+ }
+
+ /*
+ * Update the treble boost if required
+ */
+ if ((pInstance->Params.SampleRate != LocalParams.SampleRate) ||
+ (pInstance->Params.TE_EffectLevel != LocalParams.TE_EffectLevel) ||
+ (pInstance->Params.TE_OperatingMode != LocalParams.TE_OperatingMode) ||
+ (pInstance->Params.OperatingMode != LocalParams.OperatingMode) ||
+ (pInstance->Params.SpeakerType != LocalParams.SpeakerType))
+ {
+ LVM_SetTrebleBoost(pInstance,
+ &LocalParams);
+ }
+
+ /*
+ * Update the headroom if required
+ */
+ LVM_SetHeadroom(pInstance, /* Instance pointer */
+ &LocalParams); /* New parameters */
+
+ /*
+ * Update the volume if required
+ */
+ {
+ LVM_SetVolume(pInstance, /* Instance pointer */
+ &LocalParams); /* New parameters */
+ }
+ /* Apply balance changes*/
+ if(pInstance->Params.VC_Balance != LocalParams.VC_Balance)
+ {
+ /* Configure Mixer module for gradual changes to volume*/
+ if(LocalParams.VC_Balance < 0)
+ {
+ LVM_INT32 Target;
+ /* Drop in right channel volume*/
+ Target = LVM_MAXINT_16;
+ LVC_Mixer_SetTarget(&pInstance->VC_BalanceMix.MixerStream[0],Target);
+ LVC_Mixer_VarSlope_SetTimeConstant(&pInstance->VC_BalanceMix.MixerStream[0],LVM_VC_MIXER_TIME,LocalParams.SampleRate,1);
+
+ Target = dB_to_Lin32((LVM_INT16)(LocalParams.VC_Balance<<4));
+ LVC_Mixer_SetTarget(&pInstance->VC_BalanceMix.MixerStream[1],Target);
+ LVC_Mixer_VarSlope_SetTimeConstant(&pInstance->VC_BalanceMix.MixerStream[1],LVM_VC_MIXER_TIME,LocalParams.SampleRate,1);
+ }
+ else if(LocalParams.VC_Balance >0)
+ {
+ LVM_INT32 Target;
+ /* Drop in left channel volume*/
+ Target = dB_to_Lin32((LVM_INT16)((-LocalParams.VC_Balance)<<4));
+ LVC_Mixer_SetTarget(&pInstance->VC_BalanceMix.MixerStream[0],Target);
+ LVC_Mixer_VarSlope_SetTimeConstant(&pInstance->VC_BalanceMix.MixerStream[0],LVM_VC_MIXER_TIME,LocalParams.SampleRate,1);
+
+ Target = LVM_MAXINT_16;
+ LVC_Mixer_SetTarget(&pInstance->VC_BalanceMix.MixerStream[1],Target);
+ LVC_Mixer_VarSlope_SetTimeConstant(&pInstance->VC_BalanceMix.MixerStream[1],LVM_VC_MIXER_TIME,LocalParams.SampleRate,1);
+ }
+ else
+ {
+ LVM_INT32 Target;
+ /* No drop*/
+ Target = LVM_MAXINT_16;
+ LVC_Mixer_SetTarget(&pInstance->VC_BalanceMix.MixerStream[0],Target);
+ LVC_Mixer_VarSlope_SetTimeConstant(&pInstance->VC_BalanceMix.MixerStream[0],LVM_VC_MIXER_TIME,LocalParams.SampleRate,1);
+
+ LVC_Mixer_SetTarget(&pInstance->VC_BalanceMix.MixerStream[1],Target);
+ LVC_Mixer_VarSlope_SetTimeConstant(&pInstance->VC_BalanceMix.MixerStream[1],LVM_VC_MIXER_TIME,LocalParams.SampleRate,1);
+ }
+ }
+ /*
+ * Update the bass enhancement
+ */
+ {
+ LVDBE_ReturnStatus_en DBE_Status;
+ LVDBE_Params_t DBE_Params;
+ LVDBE_Handle_t *hDBEInstance = pInstance->hDBEInstance;
+
+
+ /*
+ * Set the new parameters
+ */
+ if(LocalParams.OperatingMode == LVM_MODE_OFF)
+ {
+ DBE_Params.OperatingMode = LVDBE_OFF;
+ }
+ else
+ {
+ DBE_Params.OperatingMode = (LVDBE_Mode_en)LocalParams.BE_OperatingMode;
+ }
+ DBE_Params.SampleRate = (LVDBE_Fs_en)LocalParams.SampleRate;
+ DBE_Params.EffectLevel = LocalParams.BE_EffectLevel;
+ DBE_Params.CentreFrequency = (LVDBE_CentreFreq_en)LocalParams.BE_CentreFreq;
+ DBE_Params.HPFSelect = (LVDBE_FilterSelect_en)LocalParams.BE_HPF;
+ DBE_Params.HeadroomdB = 0;
+ DBE_Params.VolumeControl = LVDBE_VOLUME_OFF;
+ DBE_Params.VolumedB = 0;
+
+ /*
+ * Make the changes
+ */
+ DBE_Status = LVDBE_Control(hDBEInstance,
+ &DBE_Params);
+
+
+ /*
+ * Quit if the changes were not accepted
+ */
+ if (DBE_Status != LVDBE_SUCCESS)
+ {
+ return((LVM_ReturnStatus_en)DBE_Status);
+ }
+
+
+ /*
+ * Set the control flag
+ */
+ pInstance->DBE_Active = LVM_TRUE;
+ }
+
+ /*
+ * Update the N-Band Equaliser
+ */
+ {
+ LVEQNB_ReturnStatus_en EQNB_Status;
+ LVEQNB_Params_t EQNB_Params;
+ LVEQNB_Handle_t *hEQNBInstance = pInstance->hEQNBInstance;
+
+
+ /*
+ * Set the new parameters
+ */
+
+ if(LocalParams.OperatingMode == LVM_MODE_OFF)
+ {
+ EQNB_Params.OperatingMode = LVEQNB_BYPASS;
+ }
+ else
+ {
+ EQNB_Params.OperatingMode = (LVEQNB_Mode_en)LocalParams.EQNB_OperatingMode;
+ }
+
+ EQNB_Params.SampleRate = (LVEQNB_Fs_en)LocalParams.SampleRate;
+ EQNB_Params.NBands = LocalParams.EQNB_NBands;
+ EQNB_Params.pBandDefinition = (LVEQNB_BandDef_t *)LocalParams.pEQNB_BandDefinition;
+ if (LocalParams.SourceFormat == LVM_STEREO) /* Mono format not supported */
+ {
+ EQNB_Params.SourceFormat = LVEQNB_STEREO;
+ }
+ else
+ {
+ EQNB_Params.SourceFormat = LVEQNB_MONOINSTEREO; /* Force to Mono-in-Stereo mode */
+ }
+
+
+ /*
+ * Set the control flag
+ */
+ if ((LocalParams.OperatingMode == LVM_MODE_ON) &&
+ (LocalParams.EQNB_OperatingMode == LVM_EQNB_ON))
+ {
+ pInstance->EQNB_Active = LVM_TRUE;
+ }
+ else
+ {
+ EQNB_Params.OperatingMode = LVEQNB_BYPASS;
+ }
+
+ /*
+ * Make the changes
+ */
+ EQNB_Status = LVEQNB_Control(hEQNBInstance,
+ &EQNB_Params);
+
+
+ /*
+ * Quit if the changes were not accepted
+ */
+ if (EQNB_Status != LVEQNB_SUCCESS)
+ {
+ return((LVM_ReturnStatus_en)EQNB_Status);
+ }
+
+ }
+
+
+ /*
+ * Update concert sound
+ */
+ {
+ LVCS_ReturnStatus_en CS_Status;
+ LVCS_Params_t CS_Params;
+ LVCS_Handle_t *hCSInstance = pInstance->hCSInstance;
+ LVM_Mode_en CompressorMode=LVM_MODE_ON;
+
+ /*
+ * Set the new parameters
+ */
+ if(LocalParams.VirtualizerOperatingMode == LVM_MODE_ON)
+ {
+ CS_Params.OperatingMode = LVCS_ON;
+ }
+ else
+ {
+ CS_Params.OperatingMode = LVCS_OFF;
+ }
+
+ if((LocalParams.TE_OperatingMode == LVM_TE_ON) && (LocalParams.TE_EffectLevel == LVM_TE_LOW_MIPS))
+ {
+ CS_Params.SpeakerType = LVCS_EX_HEADPHONES;
+ }
+ else
+ {
+ CS_Params.SpeakerType = LVCS_HEADPHONES;
+ }
+
+ if (LocalParams.SourceFormat == LVM_STEREO) /* Mono format not supported */
+ {
+ CS_Params.SourceFormat = LVCS_STEREO;
+ }
+ else
+ {
+ CS_Params.SourceFormat = LVCS_MONOINSTEREO; /* Force to Mono-in-Stereo mode */
+ }
+ CS_Params.SampleRate = LocalParams.SampleRate;
+ CS_Params.ReverbLevel = LocalParams.VirtualizerReverbLevel;
+ CS_Params.EffectLevel = LocalParams.CS_EffectLevel;
+
+
+ /*
+ * Set the control flag
+ */
+ if ((LocalParams.OperatingMode == LVM_MODE_ON) &&
+ (LocalParams.VirtualizerOperatingMode != LVCS_OFF))
+ {
+ pInstance->CS_Active = LVM_TRUE;
+ }
+ else
+ {
+ CS_Params.OperatingMode = LVCS_OFF;
+ }
+
+ CS_Params.CompressorMode=CompressorMode;
+
+ /*
+ * Make the changes
+ */
+ CS_Status = LVCS_Control(hCSInstance,
+ &CS_Params);
+
+
+ /*
+ * Quit if the changes were not accepted
+ */
+ if (CS_Status != LVCS_SUCCESS)
+ {
+ return((LVM_ReturnStatus_en)CS_Status);
+ }
+
+ }
+
+ /*
+ * Update the Power Spectrum Analyser
+ */
+ {
+ LVPSA_RETURN PSA_Status;
+ LVPSA_ControlParams_t PSA_Params;
+ pLVPSA_Handle_t *hPSAInstance = pInstance->hPSAInstance;
+
+
+ /*
+ * Set the new parameters
+ */
+ PSA_Params.Fs = LocalParams.SampleRate;
+ PSA_Params.LevelDetectionSpeed = (LVPSA_LevelDetectSpeed_en)LocalParams.PSA_PeakDecayRate;
+
+ /*
+ * Make the changes
+ */
+ if(pInstance->InstParams.PSA_Included==LVM_PSA_ON)
+ {
+ PSA_Status = LVPSA_Control(hPSAInstance,
+ &PSA_Params);
+
+ if (PSA_Status != LVPSA_OK)
+ {
+ return((LVM_ReturnStatus_en)PSA_Status);
+ }
+
+ /*
+ * Apply new settings
+ */
+ PSA_Status = LVPSA_ApplyNewSettings ((LVPSA_InstancePr_t*)hPSAInstance);
+ if(PSA_Status != LVPSA_OK)
+ {
+ return((LVM_ReturnStatus_en)PSA_Status);
+ }
+ }
+ }
+
+ /*
+ * Update the parameters and clear the flag
+ */
+ pInstance->Params = LocalParams;
+
+
+ return(LVM_SUCCESS);
+}
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_SetHeadroomParams */
+/* */
+/* DESCRIPTION: */
+/* This function is used to set the automatiuc headroom management parameters. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance Handle */
+/* pHeadroomParams Pointer to headroom parameter structure */
+/* */
+/* RETURNS: */
+/* LVM_Success Succeeded */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVM_Process function */
+/* */
+/****************************************************************************************/
+
+LVM_ReturnStatus_en LVM_SetHeadroomParams(LVM_Handle_t hInstance,
+ LVM_HeadroomParams_t *pHeadroomParams)
+{
+ LVM_Instance_t *pInstance =(LVM_Instance_t *)hInstance;
+ LVM_UINT16 ii, NBands;
+
+ /* Check for NULL pointers */
+ if ((hInstance == LVM_NULL) || (pHeadroomParams == LVM_NULL))
+ {
+ return (LVM_NULLADDRESS);
+ }
+ if ((pHeadroomParams->NHeadroomBands != 0) && (pHeadroomParams->pHeadroomDefinition == LVM_NULL))
+ {
+ return (LVM_NULLADDRESS);
+ }
+
+ /* Consider only the LVM_HEADROOM_MAX_NBANDS first bands*/
+ if (pHeadroomParams->NHeadroomBands > LVM_HEADROOM_MAX_NBANDS)
+ {
+ NBands = LVM_HEADROOM_MAX_NBANDS;
+ }
+ else
+ {
+ NBands = pHeadroomParams->NHeadroomBands;
+ }
+ pInstance->NewHeadroomParams.NHeadroomBands = NBands;
+
+ /* Copy settings in memory */
+ for(ii = 0; ii < NBands; ii++)
+ {
+ pInstance->pHeadroom_BandDefs[ii] = pHeadroomParams->pHeadroomDefinition[ii];
+ }
+
+ pInstance->NewHeadroomParams.pHeadroomDefinition = pInstance->pHeadroom_BandDefs;
+ pInstance->NewHeadroomParams.Headroom_OperatingMode = pHeadroomParams->Headroom_OperatingMode;
+ pInstance->ControlPending = LVM_TRUE;
+
+ return(LVM_SUCCESS);
+}
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_GetHeadroomParams */
+/* */
+/* DESCRIPTION: */
+/* This function is used to get the automatic headroom management parameters. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance Handle */
+/* pHeadroomParams Pointer to headroom parameter structure (output) */
+/* */
+/* RETURNS: */
+/* LVM_SUCCESS Succeeded */
+/* LVM_NULLADDRESS When hInstance or pHeadroomParams are NULL */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVM_Process function */
+/* */
+/****************************************************************************************/
+
+LVM_ReturnStatus_en LVM_GetHeadroomParams(LVM_Handle_t hInstance,
+ LVM_HeadroomParams_t *pHeadroomParams)
+{
+ LVM_Instance_t *pInstance =(LVM_Instance_t *)hInstance;
+ LVM_UINT16 ii;
+
+ /* Check for NULL pointers */
+ if ((hInstance == LVM_NULL) || (pHeadroomParams == LVM_NULL))
+ {
+ return (LVM_NULLADDRESS);
+ }
+
+ pHeadroomParams->NHeadroomBands = pInstance->NewHeadroomParams.NHeadroomBands;
+
+
+ /* Copy settings in memory */
+ for(ii = 0; ii < pInstance->NewHeadroomParams.NHeadroomBands; ii++)
+ {
+ pInstance->pHeadroom_UserDefs[ii] = pInstance->pHeadroom_BandDefs[ii];
+ }
+
+
+ pHeadroomParams->pHeadroomDefinition = pInstance->pHeadroom_UserDefs;
+ pHeadroomParams->Headroom_OperatingMode = pInstance->NewHeadroomParams.Headroom_OperatingMode;
+ return(LVM_SUCCESS);
+}
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_AlgoCallBack */
+/* */
+/* DESCRIPTION: */
+/* This is the callback function of the algorithm. */
+/* */
+/* PARAMETERS: */
+/* pBundleHandle Pointer to the Instance Handle */
+/* pData Pointer to the data */
+/* callbackId ID of the callback */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVM_Process function */
+/* */
+/****************************************************************************************/
+LVM_INT32 LVM_AlgoCallBack( void *pBundleHandle,
+ void *pData,
+ LVM_INT16 callbackId)
+{
+ LVM_Instance_t *pInstance =(LVM_Instance_t *)pBundleHandle;
+
+ (void) pData;
+
+ switch(callbackId & 0xFF00){
+ case ALGORITHM_CS_ID:
+ switch(callbackId & 0x00FF)
+ {
+ case LVCS_EVENT_ALGOFF:
+ pInstance->CS_Active = LVM_FALSE;
+ break;
+ default:
+ break;
+ }
+ break;
+ case ALGORITHM_EQNB_ID:
+ switch(callbackId & 0x00FF)
+ {
+ case LVEQNB_EVENT_ALGOFF:
+ pInstance->EQNB_Active = LVM_FALSE;
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_VCCallBack */
+/* */
+/* DESCRIPTION: */
+/* This is the callback function of the Volume control. */
+/* */
+/* PARAMETERS: */
+/* pBundleHandle Pointer to the Instance Handle */
+/* pGeneralPurpose Pointer to the data */
+/* CallBackParam ID of the callback */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVM_Process function */
+/* */
+/****************************************************************************************/
+LVM_INT32 LVM_VCCallBack(void* pBundleHandle,
+ void* pGeneralPurpose,
+ short CallBackParam)
+{
+ LVM_Instance_t *pInstance =(LVM_Instance_t *)pBundleHandle;
+ LVM_INT32 Target;
+
+ (void) pGeneralPurpose;
+ (void) CallBackParam;
+
+ /* When volume mixer has reached 0 dB target then stop it to avoid
+ unnecessary processing. */
+ Target = LVC_Mixer_GetTarget(&pInstance->VC_Volume.MixerStream[0]);
+
+ if(Target == 0x7FFF)
+ {
+ pInstance->VC_Active = LVM_FALSE;
+ }
+ return 1;
+}
diff --git a/media/libeffects/lvm/lib/Bundle/src/LVM_Init.c b/media/libeffects/lvm/lib/Bundle/src/LVM_Init.c
new file mode 100755
index 0000000..7ac5685
--- /dev/null
+++ b/media/libeffects/lvm/lib/Bundle/src/LVM_Init.c
@@ -0,0 +1,1003 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************************
+
+ $Author: nxp007753 $
+ $Revision: 1255 $
+ $Date: 2010-07-16 17:07:29 +0200 (Fri, 16 Jul 2010) $
+
+*************************************************************************************/
+
+/************************************************************************************/
+/* */
+/* Includes */
+/* */
+/************************************************************************************/
+
+#include "LVM_Private.h"
+#include "LVM_Tables.h"
+#include "VectorArithmetic.h"
+#include "InstAlloc.h"
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_GetMemoryTable */
+/* */
+/* DESCRIPTION: */
+/* This function is used for memory allocation and free. It can be called in */
+/* two ways: */
+/* */
+/* hInstance = NULL Returns the memory requirements */
+/* hInstance = Instance handle Returns the memory requirements and */
+/* allocated base addresses for the instance */
+/* */
+/* When this function is called for memory allocation (hInstance=NULL) the memory */
+/* base address pointers are NULL on return. */
+/* */
+/* When the function is called for free (hInstance = Instance Handle) the memory */
+/* table returns the allocated memory and base addresses used during initialisation. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance Handle */
+/* pMemoryTable Pointer to an empty memory definition table */
+/* pCapabilities Pointer to the default capabilities */
+/* */
+/* RETURNS: */
+/* LVM_SUCCESS Succeeded */
+/* LVM_NULLADDRESS When one of pMemoryTable or pInstParams is NULL */
+/* LVM_OUTOFRANGE When any of the Instance parameters are out of range */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVM_Process function */
+/* 2. The scratch memory is the largest required by any of the sub-modules plus any */
+/* additional scratch requirements of the bundle */
+/* */
+/****************************************************************************************/
+
+LVM_ReturnStatus_en LVM_GetMemoryTable(LVM_Handle_t hInstance,
+ LVM_MemTab_t *pMemoryTable,
+ LVM_InstParams_t *pInstParams)
+{
+
+ LVM_Instance_t *pInstance = (LVM_Instance_t *)hInstance;
+ LVM_UINT32 AlgScratchSize;
+ LVM_UINT32 BundleScratchSize;
+ LVM_UINT16 InternalBlockSize;
+ INST_ALLOC AllocMem[LVM_NR_MEMORY_REGIONS];
+ LVM_INT16 i;
+
+
+ /*
+ * Check parameters
+ */
+ if(pMemoryTable == LVM_NULL)
+ {
+ return LVM_NULLADDRESS;
+ }
+
+
+ /*
+ * Return memory table if the instance has already been created
+ */
+ if (hInstance != LVM_NULL)
+ {
+ /* Read back memory allocation table */
+ *pMemoryTable = pInstance->MemoryTable;
+ return(LVM_SUCCESS);
+ }
+
+ if(pInstParams == LVM_NULL)
+ {
+ return LVM_NULLADDRESS;
+ }
+
+ /*
+ * Power Spectrum Analyser
+ */
+ if(pInstParams->PSA_Included > LVM_PSA_ON)
+ {
+ return (LVM_OUTOFRANGE);
+ }
+
+ /*
+ * Check the instance parameters
+ */
+ if( (pInstParams->BufferMode != LVM_MANAGED_BUFFERS) && (pInstParams->BufferMode != LVM_UNMANAGED_BUFFERS) )
+ {
+ return (LVM_OUTOFRANGE);
+ }
+
+ /* N-Band Equalizer */
+ if( pInstParams->EQNB_NumBands > 32 )
+ {
+ return (LVM_OUTOFRANGE);
+ }
+
+ if(pInstParams->BufferMode == LVM_MANAGED_BUFFERS)
+ {
+ if( (pInstParams->MaxBlockSize < LVM_MIN_MAXBLOCKSIZE ) || (pInstParams->MaxBlockSize > LVM_MANAGED_MAX_MAXBLOCKSIZE ) )
+ {
+ return (LVM_OUTOFRANGE);
+ }
+ }
+ else
+ {
+ if( (pInstParams->MaxBlockSize < LVM_MIN_MAXBLOCKSIZE ) || (pInstParams->MaxBlockSize > LVM_UNMANAGED_MAX_MAXBLOCKSIZE) )
+ {
+ return (LVM_OUTOFRANGE);
+ }
+ }
+
+ /*
+ * Initialise the AllocMem structures
+ */
+ for (i=0; i<LVM_NR_MEMORY_REGIONS; i++)
+ {
+ InstAlloc_Init(&AllocMem[i], LVM_NULL);
+ }
+ InternalBlockSize = (LVM_UINT16)((pInstParams->MaxBlockSize) & MIN_INTERNAL_BLOCKMASK); /* Force to a multiple of MIN_INTERNAL_BLOCKSIZE */
+
+ if (InternalBlockSize < MIN_INTERNAL_BLOCKSIZE)
+ {
+ InternalBlockSize = MIN_INTERNAL_BLOCKSIZE;
+ }
+
+ /* Maximum Internal Black Size should not be more than MAX_INTERNAL_BLOCKSIZE*/
+ if(InternalBlockSize > MAX_INTERNAL_BLOCKSIZE)
+ {
+ InternalBlockSize = MAX_INTERNAL_BLOCKSIZE;
+ }
+
+ /*
+ * Bundle requirements
+ */
+ InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_SLOW_DATA],
+ sizeof(LVM_Instance_t));
+
+
+ /*
+ * Set the algorithm and bundle scratch requirements
+ */
+ AlgScratchSize = 0;
+ if (pInstParams->BufferMode == LVM_MANAGED_BUFFERS)
+ {
+ BundleScratchSize = 6 * (MIN_INTERNAL_BLOCKSIZE + InternalBlockSize) * sizeof(LVM_INT16);
+ InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_TEMPORARY_FAST], /* Scratch buffer */
+ BundleScratchSize);
+ InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_SLOW_DATA],
+ sizeof(LVM_Buffer_t));
+ }
+
+ /*
+ * Treble Enhancement requirements
+ */
+ InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA],
+ sizeof(LVM_TE_Data_t));
+ InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_COEF],
+ sizeof(LVM_TE_Coefs_t));
+
+ /*
+ * N-Band Equalizer requirements
+ */
+ InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA], /* Local storage */
+ (pInstParams->EQNB_NumBands * sizeof(LVM_EQNB_BandDef_t)));
+ InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA], /* User storage */
+ (pInstParams->EQNB_NumBands * sizeof(LVM_EQNB_BandDef_t)));
+
+ /*
+ * Concert Sound requirements
+ */
+ {
+ LVCS_MemTab_t CS_MemTab;
+ LVCS_Capabilities_t CS_Capabilities;
+
+ /*
+ * Set the capabilities
+ */
+ CS_Capabilities.MaxBlockSize = InternalBlockSize;
+
+ /*
+ * Get the memory requirements
+ */
+ LVCS_Memory(LVM_NULL,
+ &CS_MemTab,
+ &CS_Capabilities);
+
+ /*
+ * Update the memory allocation structures
+ */
+ InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA],
+ CS_MemTab.Region[LVM_MEMREGION_PERSISTENT_FAST_DATA].Size);
+ InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_COEF],
+ CS_MemTab.Region[LVM_MEMREGION_PERSISTENT_FAST_COEF].Size);
+ if (CS_MemTab.Region[LVM_MEMREGION_TEMPORARY_FAST].Size > AlgScratchSize) AlgScratchSize = CS_MemTab.Region[LVM_MEMREGION_TEMPORARY_FAST].Size;
+
+ }
+
+
+ /*
+ * Dynamic Bass Enhancement requirements
+ */
+ {
+ LVDBE_MemTab_t DBE_MemTab;
+ LVDBE_Capabilities_t DBE_Capabilities;
+
+ /*
+ * Set the capabilities
+ */
+ DBE_Capabilities.SampleRate = LVDBE_CAP_FS_8000 | LVDBE_CAP_FS_11025 | LVDBE_CAP_FS_12000 | LVDBE_CAP_FS_16000 | LVDBE_CAP_FS_22050 | LVDBE_CAP_FS_24000 | LVDBE_CAP_FS_32000 | LVDBE_CAP_FS_44100 | LVDBE_CAP_FS_48000;
+ DBE_Capabilities.CentreFrequency = LVDBE_CAP_CENTRE_55Hz | LVDBE_CAP_CENTRE_55Hz | LVDBE_CAP_CENTRE_66Hz | LVDBE_CAP_CENTRE_78Hz | LVDBE_CAP_CENTRE_90Hz;
+ DBE_Capabilities.MaxBlockSize = InternalBlockSize;
+
+ /*
+ * Get the memory requirements
+ */
+ LVDBE_Memory(LVM_NULL,
+ &DBE_MemTab,
+
+ &DBE_Capabilities);
+ /*
+ * Update the bundle table
+ */
+ InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA],
+ DBE_MemTab.Region[LVM_MEMREGION_PERSISTENT_FAST_DATA].Size);
+ InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_COEF],
+ DBE_MemTab.Region[LVM_MEMREGION_PERSISTENT_FAST_COEF].Size);
+ if (DBE_MemTab.Region[LVM_MEMREGION_TEMPORARY_FAST].Size > AlgScratchSize) AlgScratchSize = DBE_MemTab.Region[LVM_MEMREGION_TEMPORARY_FAST].Size;
+
+ }
+
+
+ /*
+ * N-Band equaliser requirements
+ */
+ {
+ LVEQNB_MemTab_t EQNB_MemTab; /* For N-Band Equaliser */
+ LVEQNB_Capabilities_t EQNB_Capabilities;
+
+ /*
+ * Set the capabilities
+ */
+ EQNB_Capabilities.SampleRate = LVEQNB_CAP_FS_8000 | LVEQNB_CAP_FS_11025 | LVEQNB_CAP_FS_12000 | LVEQNB_CAP_FS_16000 | LVEQNB_CAP_FS_22050 | LVEQNB_CAP_FS_24000 | LVEQNB_CAP_FS_32000 | LVEQNB_CAP_FS_44100 | LVEQNB_CAP_FS_48000;
+ EQNB_Capabilities.SourceFormat = LVEQNB_CAP_STEREO | LVEQNB_CAP_MONOINSTEREO;
+ EQNB_Capabilities.MaxBlockSize = InternalBlockSize;
+ EQNB_Capabilities.MaxBands = pInstParams->EQNB_NumBands;
+
+ /*
+ * Get the memory requirements
+ */
+ LVEQNB_Memory(LVM_NULL,
+ &EQNB_MemTab,
+ &EQNB_Capabilities);
+
+ /*
+ * Update the bundle table
+ */
+ InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA],
+ EQNB_MemTab.Region[LVM_MEMREGION_PERSISTENT_FAST_DATA].Size);
+ InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_COEF],
+ EQNB_MemTab.Region[LVM_MEMREGION_PERSISTENT_FAST_COEF].Size);
+ if (EQNB_MemTab.Region[LVM_MEMREGION_TEMPORARY_FAST].Size > AlgScratchSize) AlgScratchSize = EQNB_MemTab.Region[LVM_MEMREGION_TEMPORARY_FAST].Size;
+
+ }
+
+ /*
+ * Headroom management memory allocation
+ */
+ InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA],
+ (LVM_HEADROOM_MAX_NBANDS * sizeof(LVM_HeadroomBandDef_t)));
+ InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA],
+ (LVM_HEADROOM_MAX_NBANDS * sizeof(LVM_HeadroomBandDef_t)));
+
+
+ /*
+ * Spectrum Analyzer memory requirements
+ */
+ {
+ pLVPSA_Handle_t hPSAInst = LVM_NULL;
+ LVPSA_MemTab_t PSA_MemTab;
+ LVPSA_InitParams_t PSA_InitParams;
+ LVPSA_FilterParam_t FiltersParams[9];
+ LVPSA_RETURN PSA_Status;
+
+ if(pInstParams->PSA_Included == LVM_PSA_ON)
+ {
+ PSA_InitParams.SpectralDataBufferDuration = (LVM_UINT16) 500;
+ PSA_InitParams.MaxInputBlockSize = (LVM_UINT16) 1000;
+ PSA_InitParams.nBands = (LVM_UINT16) 9;
+
+ PSA_InitParams.pFiltersParams = &FiltersParams[0];
+ for(i = 0; i < PSA_InitParams.nBands; i++)
+ {
+ FiltersParams[i].CenterFrequency = (LVM_UINT16) 1000;
+ FiltersParams[i].QFactor = (LVM_UINT16) 25;
+ FiltersParams[i].PostGain = (LVM_INT16) 0;
+ }
+
+ /*
+ * Get the memory requirements
+ */
+ PSA_Status = LVPSA_Memory (hPSAInst,
+ &PSA_MemTab,
+ &PSA_InitParams);
+
+ if (PSA_Status != LVPSA_OK)
+ {
+ return((LVM_ReturnStatus_en) LVM_ALGORITHMPSA);
+ }
+
+ /*
+ * Update the bundle table
+ */
+ /* Slow Data */
+ InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_SLOW_DATA],
+ PSA_MemTab.Region[LVM_PERSISTENT_SLOW_DATA].Size);
+
+ /* Fast Data */
+ InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA],
+ PSA_MemTab.Region[LVM_PERSISTENT_FAST_DATA].Size);
+
+ /* Fast Coef */
+ InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_COEF],
+ PSA_MemTab.Region[LVM_PERSISTENT_FAST_COEF].Size);
+
+ /* Fast Temporary */
+ InstAlloc_AddMember(&AllocMem[LVM_TEMPORARY_FAST],
+ MAX_INTERNAL_BLOCKSIZE * sizeof(LVM_INT16));
+
+ if (PSA_MemTab.Region[LVM_TEMPORARY_FAST].Size > AlgScratchSize)
+ {
+ AlgScratchSize = PSA_MemTab.Region[LVM_TEMPORARY_FAST].Size;
+ }
+ }
+ }
+
+ /*
+ * Return the memory table
+ */
+ pMemoryTable->Region[LVM_MEMREGION_PERSISTENT_SLOW_DATA].Size = InstAlloc_GetTotal(&AllocMem[LVM_MEMREGION_PERSISTENT_SLOW_DATA]);
+ pMemoryTable->Region[LVM_MEMREGION_PERSISTENT_SLOW_DATA].Type = LVM_PERSISTENT_SLOW_DATA;
+ pMemoryTable->Region[LVM_MEMREGION_PERSISTENT_SLOW_DATA].pBaseAddress = LVM_NULL;
+
+ pMemoryTable->Region[LVM_MEMREGION_PERSISTENT_FAST_DATA].Size = InstAlloc_GetTotal(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA]);
+ pMemoryTable->Region[LVM_MEMREGION_PERSISTENT_FAST_DATA].Type = LVM_PERSISTENT_FAST_DATA;
+ pMemoryTable->Region[LVM_MEMREGION_PERSISTENT_FAST_DATA].pBaseAddress = LVM_NULL;
+ if (pMemoryTable->Region[LVM_MEMREGION_PERSISTENT_FAST_DATA].Size < 4)
+ {
+ pMemoryTable->Region[LVM_MEMREGION_PERSISTENT_FAST_DATA].Size = 0;
+ }
+
+ pMemoryTable->Region[LVM_MEMREGION_PERSISTENT_FAST_COEF].Size = InstAlloc_GetTotal(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_COEF]);
+ pMemoryTable->Region[LVM_MEMREGION_PERSISTENT_FAST_COEF].Type = LVM_PERSISTENT_FAST_COEF;
+ pMemoryTable->Region[LVM_MEMREGION_PERSISTENT_FAST_COEF].pBaseAddress = LVM_NULL;
+ if (pMemoryTable->Region[LVM_MEMREGION_PERSISTENT_FAST_COEF].Size < 4)
+ {
+ pMemoryTable->Region[LVM_MEMREGION_PERSISTENT_FAST_COEF].Size = 0;
+ }
+
+ InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_TEMPORARY_FAST],
+ AlgScratchSize);
+ pMemoryTable->Region[LVM_MEMREGION_TEMPORARY_FAST].Size = InstAlloc_GetTotal(&AllocMem[LVM_MEMREGION_TEMPORARY_FAST]);
+ pMemoryTable->Region[LVM_MEMREGION_TEMPORARY_FAST].Type = LVM_TEMPORARY_FAST;
+ pMemoryTable->Region[LVM_MEMREGION_TEMPORARY_FAST].pBaseAddress = LVM_NULL;
+ if (pMemoryTable->Region[LVM_MEMREGION_TEMPORARY_FAST].Size < 4)
+ {
+ pMemoryTable->Region[LVM_MEMREGION_TEMPORARY_FAST].Size = 0;
+ }
+
+ return(LVM_SUCCESS);
+
+}
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_GetInstanceHandle */
+/* */
+/* DESCRIPTION: */
+/* This function is used to create a bundle instance. It returns the created instance */
+/* handle through phInstance. All parameters are set to their default, inactive state. */
+/* */
+/* PARAMETERS: */
+/* phInstance pointer to the instance handle */
+/* pMemoryTable Pointer to the memory definition table */
+/* pInstParams Pointer to the initialisation capabilities */
+/* */
+/* RETURNS: */
+/* LVM_SUCCESS Initialisation succeeded */
+/* LVM_OUTOFRANGE When any of the Instance parameters are out of range */
+/* LVM_NULLADDRESS When one of phInstance, pMemoryTable or pInstParams are NULL*/
+/* */
+/* NOTES: */
+/* 1. This function must not be interrupted by the LVM_Process function */
+/* */
+/****************************************************************************************/
+
+LVM_ReturnStatus_en LVM_GetInstanceHandle(LVM_Handle_t *phInstance,
+ LVM_MemTab_t *pMemoryTable,
+ LVM_InstParams_t *pInstParams)
+{
+
+ LVM_ReturnStatus_en Status = LVM_SUCCESS;
+ LVM_Instance_t *pInstance;
+ INST_ALLOC AllocMem[LVM_NR_MEMORY_REGIONS];
+ LVM_INT16 i;
+ LVM_UINT16 InternalBlockSize;
+ LVM_INT32 BundleScratchSize;
+
+
+ /*
+ * Check valid points have been given
+ */
+ if ((phInstance == LVM_NULL) || (pMemoryTable == LVM_NULL) || (pInstParams == LVM_NULL))
+ {
+ return (LVM_NULLADDRESS);
+ }
+
+ /*
+ * Check the memory table for NULL pointers
+ */
+ for (i=0; i<LVM_NR_MEMORY_REGIONS; i++)
+ {
+ if ((pMemoryTable->Region[i].Size != 0) &&
+ (pMemoryTable->Region[i].pBaseAddress==LVM_NULL))
+ {
+ return(LVM_NULLADDRESS);
+ }
+ }
+
+ /*
+ * Check the instance parameters
+ */
+ if( (pInstParams->BufferMode != LVM_MANAGED_BUFFERS) && (pInstParams->BufferMode != LVM_UNMANAGED_BUFFERS) )
+ {
+ return (LVM_OUTOFRANGE);
+ }
+
+ if( pInstParams->EQNB_NumBands > 32 )
+ {
+ return (LVM_OUTOFRANGE);
+ }
+
+ if(pInstParams->BufferMode == LVM_MANAGED_BUFFERS)
+ {
+ if( (pInstParams->MaxBlockSize < LVM_MIN_MAXBLOCKSIZE ) || (pInstParams->MaxBlockSize > LVM_MANAGED_MAX_MAXBLOCKSIZE ) )
+ {
+ return (LVM_OUTOFRANGE);
+ }
+ }
+ else
+ {
+ if( (pInstParams->MaxBlockSize < LVM_MIN_MAXBLOCKSIZE ) || (pInstParams->MaxBlockSize > LVM_UNMANAGED_MAX_MAXBLOCKSIZE) )
+ {
+ return (LVM_OUTOFRANGE);
+ }
+ }
+
+ if(pInstParams->PSA_Included > LVM_PSA_ON)
+ {
+ return (LVM_OUTOFRANGE);
+ }
+
+ /*
+ * Initialise the AllocMem structures
+ */
+ for (i=0; i<LVM_NR_MEMORY_REGIONS; i++)
+ {
+ InstAlloc_Init(&AllocMem[i],
+ pMemoryTable->Region[i].pBaseAddress);
+ }
+
+
+ /*
+ * Set the instance handle
+ */
+ *phInstance = (LVM_Handle_t)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_SLOW_DATA],
+ sizeof(LVM_Instance_t));
+ pInstance =(LVM_Instance_t *)*phInstance;
+
+
+ /*
+ * Save the memory table, parameters and capabilities
+ */
+ pInstance->MemoryTable = *pMemoryTable;
+ pInstance->InstParams = *pInstParams;
+
+
+ /*
+ * Set the bundle scratch memory and initialse the buffer management
+ */
+ InternalBlockSize = (LVM_UINT16)((pInstParams->MaxBlockSize) & MIN_INTERNAL_BLOCKMASK); /* Force to a multiple of MIN_INTERNAL_BLOCKSIZE */
+ if (InternalBlockSize < MIN_INTERNAL_BLOCKSIZE)
+ {
+ InternalBlockSize = MIN_INTERNAL_BLOCKSIZE;
+ }
+
+ /* Maximum Internal Black Size should not be more than MAX_INTERNAL_BLOCKSIZE*/
+ if(InternalBlockSize > MAX_INTERNAL_BLOCKSIZE)
+ {
+ InternalBlockSize = MAX_INTERNAL_BLOCKSIZE;
+ }
+ pInstance->InternalBlockSize = (LVM_INT16)InternalBlockSize;
+
+
+ /*
+ * Common settings for managed and unmanaged buffers
+ */
+ pInstance->SamplesToProcess = 0; /* No samples left to process */
+ if (pInstParams->BufferMode == LVM_MANAGED_BUFFERS)
+ {
+ /*
+ * Managed buffers required
+ */
+ pInstance->pBufferManagement = InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_SLOW_DATA],
+ sizeof(LVM_Buffer_t));
+ BundleScratchSize = (LVM_INT32)(6 * (MIN_INTERNAL_BLOCKSIZE + InternalBlockSize) * sizeof(LVM_INT16));
+ pInstance->pBufferManagement->pScratch = InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_TEMPORARY_FAST], /* Scratch 1 buffer */
+ (LVM_UINT32)BundleScratchSize);
+
+ LoadConst_16(0, /* Clear the input delay buffer */
+ (LVM_INT16 *)&pInstance->pBufferManagement->InDelayBuffer,
+ (LVM_INT16)(2 * MIN_INTERNAL_BLOCKSIZE));
+ pInstance->pBufferManagement->InDelaySamples = MIN_INTERNAL_BLOCKSIZE; /* Set the number of delay samples */
+ pInstance->pBufferManagement->OutDelaySamples = 0; /* No samples in the output buffer */
+ pInstance->pBufferManagement->BufferState = LVM_FIRSTCALL; /* Set the state ready for the first call */
+ }
+
+
+ /*
+ * Set default parameters
+ */
+ pInstance->Params.OperatingMode = LVM_MODE_OFF;
+ pInstance->Params.SampleRate = LVM_FS_8000;
+ pInstance->Params.SourceFormat = LVM_MONO;
+ pInstance->Params.SpeakerType = LVM_HEADPHONES;
+ pInstance->Params.VC_EffectLevel = 0;
+ pInstance->Params.VC_Balance = 0;
+
+ /*
+ * Set callback
+ */
+ pInstance->CallBack = LVM_AlgoCallBack;
+
+
+ /*
+ * DC removal filter
+ */
+ DC_2I_D16_TRC_WRA_01_Init(&pInstance->DC_RemovalInstance);
+
+
+ /*
+ * Treble Enhancement
+ */
+ pInstance->pTE_Taps = (LVM_TE_Data_t *)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA],
+ sizeof(LVM_TE_Data_t));
+
+ pInstance->pTE_State = (LVM_TE_Coefs_t *)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_COEF],
+ sizeof(LVM_TE_Coefs_t));
+ pInstance->Params.TE_OperatingMode = LVM_TE_OFF;
+ pInstance->Params.TE_EffectLevel = 0;
+ pInstance->TE_Active = LVM_FALSE;
+
+
+ /*
+ * Set the volume control and initialise Current to Target
+ */
+ pInstance->VC_Volume.MixerStream[0].CallbackParam = 0;
+ pInstance->VC_Volume.MixerStream[0].CallbackSet = 0;
+ pInstance->VC_Volume.MixerStream[0].pCallbackHandle = pInstance;
+ pInstance->VC_Volume.MixerStream[0].pCallBack = LVM_VCCallBack;
+
+ /* In managed buffering, start with low signal level as delay in buffer management causes a click*/
+ if (pInstParams->BufferMode == LVM_MANAGED_BUFFERS)
+ {
+ LVC_Mixer_Init(&pInstance->VC_Volume.MixerStream[0],0,0);
+ }
+ else
+ {
+ LVC_Mixer_Init(&pInstance->VC_Volume.MixerStream[0],LVM_MAXINT_16,LVM_MAXINT_16);
+ }
+
+ LVC_Mixer_SetTimeConstant(&pInstance->VC_Volume.MixerStream[0],0,LVM_FS_8000,2);
+
+ pInstance->VC_VolumedB = 0;
+ pInstance->VC_AVLFixedVolume = 0;
+ pInstance->VC_Active = LVM_FALSE;
+
+ pInstance->VC_BalanceMix.MixerStream[0].CallbackParam = 0;
+ pInstance->VC_BalanceMix.MixerStream[0].CallbackSet = 0;
+ pInstance->VC_BalanceMix.MixerStream[0].pCallbackHandle = pInstance;
+ pInstance->VC_BalanceMix.MixerStream[0].pCallBack = LVM_VCCallBack;
+ LVC_Mixer_Init(&pInstance->VC_BalanceMix.MixerStream[0],LVM_MAXINT_16,LVM_MAXINT_16);
+ LVC_Mixer_VarSlope_SetTimeConstant(&pInstance->VC_BalanceMix.MixerStream[0],LVM_VC_MIXER_TIME,LVM_FS_8000,2);
+
+ pInstance->VC_BalanceMix.MixerStream[1].CallbackParam = 0;
+ pInstance->VC_BalanceMix.MixerStream[1].CallbackSet = 0;
+ pInstance->VC_BalanceMix.MixerStream[1].pCallbackHandle = pInstance;
+ pInstance->VC_BalanceMix.MixerStream[1].pCallBack = LVM_VCCallBack;
+ LVC_Mixer_Init(&pInstance->VC_BalanceMix.MixerStream[1],LVM_MAXINT_16,LVM_MAXINT_16);
+ LVC_Mixer_VarSlope_SetTimeConstant(&pInstance->VC_BalanceMix.MixerStream[1],LVM_VC_MIXER_TIME,LVM_FS_8000,2);
+ /*
+ * Set the default EQNB pre-gain and pointer to the band definitions
+ */
+ pInstance->pEQNB_BandDefs = InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA],
+ (pInstParams->EQNB_NumBands * sizeof(LVM_EQNB_BandDef_t)));
+ pInstance->pEQNB_UserDefs = InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA],
+ (pInstParams->EQNB_NumBands * sizeof(LVM_EQNB_BandDef_t)));
+
+
+ /*
+ * Initialise the Concert Sound module
+ */
+ {
+ LVCS_Handle_t hCSInstance; /* Instance handle */
+ LVCS_MemTab_t CS_MemTab; /* Memory table */
+ LVCS_Capabilities_t CS_Capabilities; /* Initial capabilities */
+ LVCS_ReturnStatus_en LVCS_Status; /* Function call status */
+
+ /*
+ * Set default parameters
+ */
+ pInstance->Params.VirtualizerReverbLevel = 100;
+ pInstance->Params.VirtualizerType = LVM_CONCERTSOUND;
+ pInstance->Params.VirtualizerOperatingMode = LVM_MODE_OFF;
+ pInstance->CS_Active = LVM_FALSE;
+
+ /*
+ * Set the initialisation capabilities
+ */
+ CS_Capabilities.MaxBlockSize = (LVM_UINT16)InternalBlockSize;
+ CS_Capabilities.CallBack = pInstance->CallBack;
+ CS_Capabilities.pBundleInstance = (void*)pInstance;
+
+
+ /*
+ * Get the memory requirements and then set the address pointers, forcing alignment
+ */
+ LVCS_Status = LVCS_Memory(LVM_NULL, /* Get the memory requirements */
+ &CS_MemTab,
+ &CS_Capabilities);
+ CS_MemTab.Region[LVCS_MEMREGION_PERSISTENT_SLOW_DATA].pBaseAddress = &pInstance->CS_Instance;
+ CS_MemTab.Region[LVCS_MEMREGION_PERSISTENT_FAST_DATA].pBaseAddress = (void *)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA],
+ CS_MemTab.Region[LVCS_MEMREGION_PERSISTENT_FAST_DATA].Size);
+ CS_MemTab.Region[LVCS_MEMREGION_PERSISTENT_FAST_COEF].pBaseAddress = (void *)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_COEF],
+ CS_MemTab.Region[LVCS_MEMREGION_PERSISTENT_FAST_COEF].Size);
+ CS_MemTab.Region[LVCS_MEMREGION_TEMPORARY_FAST].pBaseAddress = (void *)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_TEMPORARY_FAST],
+ 0);
+
+ /*
+ * Initialise the Concert Sound instance and save the instance handle
+ */
+ hCSInstance = LVM_NULL; /* Set to NULL to return handle */
+ LVCS_Status = LVCS_Init(&hCSInstance, /* Initiailse */
+ &CS_MemTab,
+ &CS_Capabilities);
+ if (LVCS_Status != LVCS_SUCCESS) return((LVM_ReturnStatus_en)LVCS_Status);
+ pInstance->hCSInstance = hCSInstance; /* Save the instance handle */
+
+ }
+
+ /*
+ * Initialise the Bass Enhancement module
+ */
+ {
+ LVDBE_Handle_t hDBEInstance; /* Instance handle */
+ LVDBE_MemTab_t DBE_MemTab; /* Memory table */
+ LVDBE_Capabilities_t DBE_Capabilities; /* Initial capabilities */
+ LVDBE_ReturnStatus_en LVDBE_Status; /* Function call status */
+
+
+ /*
+ * Set the initialisation parameters
+ */
+ pInstance->Params.BE_OperatingMode = LVM_BE_OFF;
+ pInstance->Params.BE_CentreFreq = LVM_BE_CENTRE_55Hz;
+ pInstance->Params.BE_EffectLevel = 0;
+ pInstance->Params.BE_HPF = LVM_BE_HPF_OFF;
+
+ pInstance->DBE_Active = LVM_FALSE;
+
+
+
+ /*
+ * Set the initialisation capabilities
+ */
+ DBE_Capabilities.SampleRate = LVDBE_CAP_FS_8000 | LVDBE_CAP_FS_11025 | LVDBE_CAP_FS_12000 | LVDBE_CAP_FS_16000 | LVDBE_CAP_FS_22050 | LVDBE_CAP_FS_24000 | LVDBE_CAP_FS_32000 | LVDBE_CAP_FS_44100 | LVDBE_CAP_FS_48000;
+ DBE_Capabilities.CentreFrequency = LVDBE_CAP_CENTRE_55Hz | LVDBE_CAP_CENTRE_55Hz | LVDBE_CAP_CENTRE_66Hz | LVDBE_CAP_CENTRE_78Hz | LVDBE_CAP_CENTRE_90Hz;
+ DBE_Capabilities.MaxBlockSize = (LVM_UINT16)InternalBlockSize;
+
+
+ /*
+ * Get the memory requirements and then set the address pointers
+ */
+ LVDBE_Status = LVDBE_Memory(LVM_NULL, /* Get the memory requirements */
+ &DBE_MemTab,
+ &DBE_Capabilities);
+ DBE_MemTab.Region[LVDBE_MEMREGION_INSTANCE].pBaseAddress = &pInstance->DBE_Instance;
+ DBE_MemTab.Region[LVDBE_MEMREGION_PERSISTENT_DATA].pBaseAddress = (void *)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA],
+ DBE_MemTab.Region[LVDBE_MEMREGION_PERSISTENT_DATA].Size);
+ DBE_MemTab.Region[LVDBE_MEMREGION_PERSISTENT_COEF].pBaseAddress = (void *)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_COEF],
+ DBE_MemTab.Region[LVDBE_MEMREGION_PERSISTENT_COEF].Size);
+ DBE_MemTab.Region[LVDBE_MEMREGION_SCRATCH].pBaseAddress = (void *)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_TEMPORARY_FAST],
+ 0);
+
+
+ /*
+ * Initialise the Dynamic Bass Enhancement instance and save the instance handle
+ */
+ hDBEInstance = LVM_NULL; /* Set to NULL to return handle */
+ LVDBE_Status = LVDBE_Init(&hDBEInstance, /* Initiailse */
+ &DBE_MemTab,
+ &DBE_Capabilities);
+ if (LVDBE_Status != LVDBE_SUCCESS) return((LVM_ReturnStatus_en)LVDBE_Status);
+ pInstance->hDBEInstance = hDBEInstance; /* Save the instance handle */
+ }
+
+
+ /*
+ * Initialise the N-Band Equaliser module
+ */
+ {
+ LVEQNB_Handle_t hEQNBInstance; /* Instance handle */
+ LVEQNB_MemTab_t EQNB_MemTab; /* Memory table */
+ LVEQNB_Capabilities_t EQNB_Capabilities; /* Initial capabilities */
+ LVEQNB_ReturnStatus_en LVEQNB_Status; /* Function call status */
+
+
+ /*
+ * Set the initialisation parameters
+ */
+ pInstance->Params.EQNB_OperatingMode = LVM_EQNB_OFF;
+ pInstance->Params.EQNB_NBands = 0;
+ pInstance->Params.pEQNB_BandDefinition = LVM_NULL;
+ pInstance->EQNB_Active = LVM_FALSE;
+
+
+ /*
+ * Set the initialisation capabilities
+ */
+ EQNB_Capabilities.SampleRate = LVEQNB_CAP_FS_8000 | LVEQNB_CAP_FS_11025 | LVEQNB_CAP_FS_12000 | LVEQNB_CAP_FS_16000 | LVEQNB_CAP_FS_22050 | LVEQNB_CAP_FS_24000 | LVEQNB_CAP_FS_32000 | LVEQNB_CAP_FS_44100 | LVEQNB_CAP_FS_48000;
+ EQNB_Capabilities.MaxBlockSize = (LVM_UINT16)InternalBlockSize;
+ EQNB_Capabilities.MaxBands = pInstParams->EQNB_NumBands;
+ EQNB_Capabilities.SourceFormat = LVEQNB_CAP_STEREO | LVEQNB_CAP_MONOINSTEREO;
+ EQNB_Capabilities.CallBack = pInstance->CallBack;
+ EQNB_Capabilities.pBundleInstance = (void*)pInstance;
+
+
+ /*
+ * Get the memory requirements and then set the address pointers, forcing alignment
+ */
+ LVEQNB_Status = LVEQNB_Memory(LVM_NULL, /* Get the memory requirements */
+ &EQNB_MemTab,
+ &EQNB_Capabilities);
+ EQNB_MemTab.Region[LVEQNB_MEMREGION_INSTANCE].pBaseAddress = &pInstance->EQNB_Instance;
+ EQNB_MemTab.Region[LVEQNB_MEMREGION_PERSISTENT_DATA].pBaseAddress = (void *)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA],
+ EQNB_MemTab.Region[LVEQNB_MEMREGION_PERSISTENT_DATA].Size);
+ EQNB_MemTab.Region[LVEQNB_MEMREGION_PERSISTENT_COEF].pBaseAddress = (void *)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_COEF],
+ EQNB_MemTab.Region[LVEQNB_MEMREGION_PERSISTENT_COEF].Size);
+ EQNB_MemTab.Region[LVEQNB_MEMREGION_SCRATCH].pBaseAddress = (void *)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_TEMPORARY_FAST],
+ 0);
+
+
+ /*
+ * Initialise the Dynamic Bass Enhancement instance and save the instance handle
+ */
+ hEQNBInstance = LVM_NULL; /* Set to NULL to return handle */
+ LVEQNB_Status = LVEQNB_Init(&hEQNBInstance, /* Initiailse */
+ &EQNB_MemTab,
+ &EQNB_Capabilities);
+ if (LVEQNB_Status != LVEQNB_SUCCESS) return((LVM_ReturnStatus_en)LVEQNB_Status);
+ pInstance->hEQNBInstance = hEQNBInstance; /* Save the instance handle */
+ }
+
+ /*
+ * Headroom management memory allocation
+ */
+ {
+ pInstance->pHeadroom_BandDefs = InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA],
+ (LVM_HEADROOM_MAX_NBANDS * sizeof(LVM_HeadroomBandDef_t)));
+ pInstance->pHeadroom_UserDefs = InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA],
+ (LVM_HEADROOM_MAX_NBANDS * sizeof(LVM_HeadroomBandDef_t)));
+
+ /* Headroom management parameters initialisation */
+ pInstance->NewHeadroomParams.NHeadroomBands = 2;
+ pInstance->NewHeadroomParams.pHeadroomDefinition = pInstance->pHeadroom_BandDefs;
+ pInstance->NewHeadroomParams.pHeadroomDefinition[0].Limit_Low = 20;
+ pInstance->NewHeadroomParams.pHeadroomDefinition[0].Limit_High = 4999;
+ pInstance->NewHeadroomParams.pHeadroomDefinition[0].Headroom_Offset = 3;
+ pInstance->NewHeadroomParams.pHeadroomDefinition[1].Limit_Low = 5000;
+ pInstance->NewHeadroomParams.pHeadroomDefinition[1].Limit_High = 24000;
+ pInstance->NewHeadroomParams.pHeadroomDefinition[1].Headroom_Offset = 4;
+ pInstance->NewHeadroomParams.Headroom_OperatingMode = LVM_HEADROOM_ON;
+
+ pInstance->Headroom =0;
+ }
+
+
+ /*
+ * Initialise the PSA module
+ */
+ {
+ pLVPSA_Handle_t hPSAInstance = LVM_NULL; /* Instance handle */
+ LVPSA_MemTab_t PSA_MemTab;
+ LVPSA_RETURN PSA_Status; /* Function call status */
+ LVPSA_FilterParam_t FiltersParams[9];
+
+ if(pInstParams->PSA_Included==LVM_PSA_ON)
+ {
+ pInstance->PSA_InitParams.SpectralDataBufferDuration = (LVM_UINT16) 500;
+ pInstance->PSA_InitParams.MaxInputBlockSize = (LVM_UINT16) 2048;
+ pInstance->PSA_InitParams.nBands = (LVM_UINT16) 9;
+ pInstance->PSA_InitParams.pFiltersParams = &FiltersParams[0];
+ for(i = 0; i < pInstance->PSA_InitParams.nBands; i++)
+ {
+ FiltersParams[i].CenterFrequency = (LVM_UINT16) 1000;
+ FiltersParams[i].QFactor = (LVM_UINT16) 100;
+ FiltersParams[i].PostGain = (LVM_INT16) 0;
+ }
+
+ /*Get the memory requirements and then set the address pointers*/
+ PSA_Status = LVPSA_Memory (hPSAInstance,
+ &PSA_MemTab,
+ &pInstance->PSA_InitParams);
+
+ if (PSA_Status != LVPSA_OK)
+ {
+ return((LVM_ReturnStatus_en) LVM_ALGORITHMPSA);
+ }
+
+ /* Slow Data */
+ PSA_MemTab.Region[LVM_PERSISTENT_SLOW_DATA].pBaseAddress = (void *)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_SLOW_DATA],
+ PSA_MemTab.Region[LVM_PERSISTENT_SLOW_DATA].Size);
+
+
+ /* Fast Data */
+ PSA_MemTab.Region[LVM_PERSISTENT_FAST_DATA].pBaseAddress = (void *)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA],
+ PSA_MemTab.Region[LVM_PERSISTENT_FAST_DATA].Size);
+
+
+ /* Fast Coef */
+ PSA_MemTab.Region[LVM_PERSISTENT_FAST_COEF].pBaseAddress = (void *)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_COEF],
+ PSA_MemTab.Region[LVM_PERSISTENT_FAST_COEF].Size);
+
+ /* Fast Temporary */
+ pInstance->pPSAInput = InstAlloc_AddMember(&AllocMem[LVM_TEMPORARY_FAST],
+ (LVM_UINT32) MAX_INTERNAL_BLOCKSIZE * sizeof(LVM_INT16));
+
+ PSA_MemTab.Region[LVM_TEMPORARY_FAST].pBaseAddress = (void *)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_TEMPORARY_FAST],0);
+
+
+ /*Initialise PSA instance and save the instance handle*/
+ pInstance->PSA_ControlParams.Fs = LVM_FS_48000;
+ pInstance->PSA_ControlParams.LevelDetectionSpeed = LVPSA_SPEED_MEDIUM;
+ PSA_Status = LVPSA_Init (&hPSAInstance,
+ &pInstance->PSA_InitParams,
+ &pInstance->PSA_ControlParams,
+ &PSA_MemTab);
+
+ if (PSA_Status != LVPSA_OK)
+ {
+ return((LVM_ReturnStatus_en) LVM_ALGORITHMPSA);
+ }
+
+ pInstance->hPSAInstance = hPSAInstance; /* Save the instance handle */
+ pInstance->PSA_GainOffset = 0;
+ }
+ else
+ {
+ pInstance->hPSAInstance = LVM_NULL;
+ }
+
+ /*
+ * Set the initialisation parameters.
+ */
+ pInstance->Params.PSA_PeakDecayRate = LVM_PSA_SPEED_MEDIUM;
+ pInstance->Params.PSA_Enable = LVM_PSA_OFF;
+ }
+
+ /*
+ * Copy the initial parameters to the new parameters for correct readback of
+ * the settings.
+ */
+ pInstance->NewParams = pInstance->Params;
+
+
+ /*
+ * Create configuration number
+ */
+ pInstance->ConfigurationNumber = 0x00000000;
+ pInstance->ConfigurationNumber += LVM_CS_MASK;
+ pInstance->ConfigurationNumber += LVM_EQNB_MASK;
+ pInstance->ConfigurationNumber += LVM_DBE_MASK;
+ pInstance->ConfigurationNumber += LVM_VC_MASK;
+ pInstance->ConfigurationNumber += LVM_PSA_MASK;
+
+ if(((pInstance->ConfigurationNumber & LVM_CS_MASK)!=0) ||
+ ((pInstance->ConfigurationNumber & LVM_DBE_MASK)!=0) ||
+ ((pInstance->ConfigurationNumber & LVM_EQNB_MASK)!=0)||
+ ((pInstance->ConfigurationNumber & LVM_TE_MASK)!=0) ||
+ ((pInstance->ConfigurationNumber & LVM_VC_MASK)!=0))
+ {
+ pInstance->BlickSizeMultiple = 4;
+ }
+ else
+ {
+ pInstance->BlickSizeMultiple = 1;
+ }
+
+ return(Status);
+}
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_ClearAudioBuffers */
+/* */
+/* DESCRIPTION: */
+/* This function is used to clear the internal audio buffers of the bundle. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* */
+/* RETURNS: */
+/* LVM_SUCCESS Initialisation succeeded */
+/* LVM_NULLADDRESS Instance or scratch memory has a NULL pointer */
+/* */
+/* NOTES: */
+/* 1. This function must not be interrupted by the LVM_Process function */
+/* */
+/****************************************************************************************/
+
+LVM_ReturnStatus_en LVM_ClearAudioBuffers(LVM_Handle_t hInstance)
+{
+ LVM_MemTab_t MemTab; /* Memory table */
+ LVM_InstParams_t InstParams; /* Instance parameters */
+ LVM_ControlParams_t Params; /* Control Parameters */
+ LVM_Instance_t *pInstance = (LVM_Instance_t *)hInstance; /* Pointer to Instance */
+
+
+ if(hInstance == LVM_NULL){
+ return LVM_NULLADDRESS;
+ }
+
+ /* Save the control parameters */ /* coverity[unchecked_value] */ /* Do not check return value internal function calls */
+ LVM_GetControlParameters(hInstance, &Params);
+
+ /* Retrieve allocated buffers in memtab */
+ LVM_GetMemoryTable(hInstance, &MemTab, LVM_NULL);
+
+ /* Save the instance parameters */
+ InstParams = pInstance->InstParams;
+
+ /* Call LVM_GetInstanceHandle to re-initialise the bundle */
+ LVM_GetInstanceHandle( &hInstance,
+ &MemTab,
+ &InstParams);
+
+ /* Restore control parameters */ /* coverity[unchecked_value] */ /* Do not check return value internal function calls */
+ LVM_SetControlParameters(hInstance, &Params);
+
+ /* DC removal filter */
+ DC_2I_D16_TRC_WRA_01_Init(&pInstance->DC_RemovalInstance);
+
+
+ return LVM_SUCCESS;
+}
+
+
+
diff --git a/media/libeffects/lvm/lib/Bundle/src/LVM_Private.h b/media/libeffects/lvm/lib/Bundle/src/LVM_Private.h
new file mode 100755
index 0000000..f70e473
--- /dev/null
+++ b/media/libeffects/lvm/lib/Bundle/src/LVM_Private.h
@@ -0,0 +1,292 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/**********************************************************************************
+
+ $Author: nxp007753 $
+ $Revision: 1082 $
+ $Date: 2010-07-05 12:44:39 +0200 (Mon, 05 Jul 2010) $
+
+***********************************************************************************/
+
+/************************************************************************************/
+/* */
+/* Header file for the private layer interface of concert sound bundle */
+/* */
+/* This files includes all definitions, types, structures and function */
+/* prototypes required by the execution layer. */
+/* */
+/************************************************************************************/
+
+#ifndef __LVM_PRIVATE_H__
+#define __LVM_PRIVATE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/************************************************************************************/
+/* */
+/* Includes */
+/* */
+/************************************************************************************/
+
+#include "LVM.h" /* LifeVibes */
+#include "LVM_Common.h" /* LifeVibes common */
+#include "BIQUAD.h" /* Biquad library */
+#include "LVC_Mixer.h" /* Mixer library */
+#include "LVCS_Private.h" /* Concert Sound */
+#include "LVDBE_Private.h" /* Dynamic Bass Enhancement */
+#include "LVEQNB_Private.h" /* N-Band equaliser */
+#include "LVPSA_Private.h" /* Parametric Spectrum Analyzer */
+
+
+/************************************************************************************/
+/* */
+/* Defines */
+/* */
+/************************************************************************************/
+
+/* General */
+#define LVM_INVALID 0xFFFF /* Invalid init parameter */
+
+/* Memory */
+#define LVM_INSTANCE_ALIGN 4 /* 32-bit for structures */
+#define LVM_FIRSTCALL 0 /* First call to the buffer */
+#define LVM_MAXBLOCKCALL 1 /* Maximum block size calls to the buffer */
+#define LVM_LASTCALL 2 /* Last call to the buffer */
+#define LVM_FIRSTLASTCALL 3 /* Single call for small number of samples */
+
+/* Block Size */
+#define LVM_MIN_MAXBLOCKSIZE 16 /* Minimum MaxBlockSize Limit*/
+#define LVM_MANAGED_MAX_MAXBLOCKSIZE 8191 /* Maximum MaxBlockSzie Limit for Managed Buffer Mode*/
+#define LVM_UNMANAGED_MAX_MAXBLOCKSIZE 4096 /* Maximum MaxBlockSzie Limit for Unmanaged Buffer Mode */
+
+#define MAX_INTERNAL_BLOCKSIZE 8128 /* Maximum multiple of 64 below 8191*/
+
+#define MIN_INTERNAL_BLOCKSIZE 16 /* Minimum internal block size */
+#define MIN_INTERNAL_BLOCKSHIFT 4 /* Minimum internal block size as a power of 2 */
+#define MIN_INTERNAL_BLOCKMASK 0xFFF0 /* Minimum internal block size mask */
+
+#define LVM_PSA_DYNAMICRANGE 60 /* Spectral Dynamic range: used for offseting output*/
+#define LVM_PSA_BARHEIGHT 127 /* Spectral Bar Height*/
+
+#define LVM_TE_MIN_EFFECTLEVEL 0 /*TE Minimum EffectLevel*/
+#define LVM_TE_MAX_EFFECTLEVEL 15 /*TE Maximum Effect level*/
+
+#define LVM_VC_MIN_EFFECTLEVEL -96 /*VC Minimum EffectLevel*/
+#define LVM_VC_MAX_EFFECTLEVEL 0 /*VC Maximum Effect level*/
+
+#define LVM_BE_MIN_EFFECTLEVEL 0 /*BE Minimum EffectLevel*/
+#define LVM_BE_MAX_EFFECTLEVEL 15 /*BE Maximum Effect level*/
+
+#define LVM_EQNB_MIN_BAND_FREQ 20 /*EQNB Minimum Band Frequency*/
+#define LVM_EQNB_MAX_BAND_FREQ 24000 /*EQNB Maximum Band Frequency*/
+#define LVM_EQNB_MIN_BAND_GAIN -15 /*EQNB Minimum Band Frequency*/
+#define LVM_EQNB_MAX_BAND_GAIN 15 /*EQNB Maximum Band Frequency*/
+#define LVM_EQNB_MIN_QFACTOR 25 /*EQNB Minimum Q Factor*/
+#define LVM_EQNB_MAX_QFACTOR 1200 /*EQNB Maximum Q Factor*/
+#define LVM_EQNB_MIN_LPF_FREQ 1000 /*EQNB Minimum Low Pass Corner frequency*/
+#define LVM_EQNB_MIN_HPF_FREQ 20 /*EQNB Minimum High Pass Corner frequency*/
+#define LVM_EQNB_MAX_HPF_FREQ 1000 /*EQNB Maximum High Pass Corner frequency*/
+
+#define LVM_CS_MIN_EFFECT_LEVEL 0 /*CS Minimum Effect Level*/
+#define LVM_CS_MAX_REVERB_LEVEL 100 /*CS Maximum Reverb Level*/
+#define LVM_VIRTUALIZER_MAX_REVERB_LEVEL 100 /*Vitrualizer Maximum Reverb Level*/
+
+#define LVM_VC_MIXER_TIME 100 /*VC mixer time*/
+#define LVM_VC_BALANCE_MAX 96 /*VC balance max value*/
+#define LVM_VC_BALANCE_MIN -96 /*VC balance min value*/
+
+/* Algorithm masks */
+#define LVM_CS_MASK 1
+#define LVM_EQNB_MASK 2
+#define LVM_DBE_MASK 4
+#define LVM_VC_MASK 16
+#define LVM_TE_MASK 32
+#define LVM_PSA_MASK 2048
+
+
+/************************************************************************************/
+/* */
+/* Structures */
+/* */
+/************************************************************************************/
+
+/* Memory region definition */
+typedef struct
+{
+ LVM_UINT32 Size; /* Region size in bytes */
+ LVM_UINT16 Alignment; /* Byte alignment */
+ LVM_MemoryTypes_en Type; /* Region type */
+ void *pBaseAddress; /* Pointer to the region base address */
+} LVM_IntMemoryRegion_t;
+
+
+/* Memory table containing the region definitions */
+typedef struct
+{
+ LVM_IntMemoryRegion_t Region[LVM_NR_MEMORY_REGIONS]; /* One definition for each region */
+} LVM_IntMemTab_t;
+
+
+/* Buffer Management */
+typedef struct
+{
+ LVM_INT16 *pScratch; /* Bundle scratch buffer */
+
+ LVM_INT16 BufferState; /* Buffer status */
+ LVM_INT16 InDelayBuffer[6*MIN_INTERNAL_BLOCKSIZE]; /* Input buffer delay line, left and right */
+ LVM_INT16 InDelaySamples; /* Number of samples in the input delay buffer */
+
+ LVM_INT16 OutDelayBuffer[2*MIN_INTERNAL_BLOCKSIZE]; /* Output buffer delay line */
+ LVM_INT16 OutDelaySamples; /* Number of samples in the output delay buffer, left and right */
+ LVM_INT16 SamplesToOutput; /* Samples to write to the output */
+} LVM_Buffer_t;
+
+
+/* Filter taps */
+typedef struct
+{
+ Biquad_2I_Order1_Taps_t TrebleBoost_Taps; /* Treble boost Taps */
+} LVM_TE_Data_t;
+
+
+/* Coefficients */
+typedef struct
+{
+ Biquad_Instance_t TrebleBoost_State; /* State for the treble boost filter */
+} LVM_TE_Coefs_t;
+
+
+typedef struct
+{
+ /* Public parameters */
+ LVM_MemTab_t MemoryTable; /* Instance memory allocation table */
+ LVM_ControlParams_t Params; /* Control parameters */
+ LVM_InstParams_t InstParams; /* Instance parameters */
+
+ /* Private parameters */
+ LVM_UINT16 ControlPending; /* Control flag to indicate update pending */
+ LVM_ControlParams_t NewParams; /* New control parameters pending update */
+
+ /* Buffer control */
+ LVM_INT16 InternalBlockSize; /* Maximum internal block size */
+ LVM_Buffer_t *pBufferManagement; /* Buffer management variables */
+ LVM_INT16 SamplesToProcess; /* Input samples left to process */
+ LVM_INT16 *pInputSamples; /* External input sample pointer */
+ LVM_INT16 *pOutputSamples; /* External output sample pointer */
+
+ /* Configuration number */
+ LVM_INT32 ConfigurationNumber;
+ LVM_INT32 BlickSizeMultiple;
+
+ /* DC removal */
+ Biquad_Instance_t DC_RemovalInstance; /* DC removal filter instance */
+
+ /* Concert Sound */
+ LVCS_Handle_t hCSInstance; /* Concert Sound instance handle */
+ LVCS_Instance_t CS_Instance; /* Concert Sound instance */
+ LVM_INT16 CS_Active; /* Control flag */
+
+ /* Equalizer */
+ LVEQNB_Handle_t hEQNBInstance; /* N-Band Equaliser instance handle */
+ LVEQNB_Instance_t EQNB_Instance; /* N-Band Equaliser instance */
+ LVM_EQNB_BandDef_t *pEQNB_BandDefs; /* Local storage for new definitions */
+ LVM_EQNB_BandDef_t *pEQNB_UserDefs; /* Local storage for the user's definitions */
+ LVM_INT16 EQNB_Active; /* Control flag */
+
+ /* Dynamic Bass Enhancement */
+ LVDBE_Handle_t hDBEInstance; /* Dynamic Bass Enhancement instance handle */
+ LVDBE_Instance_t DBE_Instance; /* Dynamic Bass Enhancement instance */
+ LVM_INT16 DBE_Active; /* Control flag */
+
+ /* Volume Control */
+ LVMixer3_1St_st VC_Volume; /* Volume scaler */
+ LVMixer3_2St_st VC_BalanceMix; /* VC balance mixer */
+ LVM_INT16 VC_VolumedB; /* Gain in dB */
+ LVM_INT16 VC_Active; /* Control flag */
+ LVM_INT16 VC_AVLFixedVolume; /* AVL fixed volume */
+
+ /* Treble Enhancement */
+ LVM_TE_Data_t *pTE_Taps; /* Treble boost Taps */
+ LVM_TE_Coefs_t *pTE_State; /* State for the treble boost filter */
+ LVM_INT16 TE_Active; /* Control flag */
+
+ /* Headroom */
+ LVM_HeadroomParams_t NewHeadroomParams; /* New headroom parameters pending update */
+ LVM_HeadroomParams_t HeadroomParams; /* Headroom parameters */
+ LVM_HeadroomBandDef_t *pHeadroom_BandDefs; /* Local storage for new definitions */
+ LVM_HeadroomBandDef_t *pHeadroom_UserDefs; /* Local storage for the user's definitions */
+ LVM_UINT16 Headroom; /* Value of the current headroom */
+
+ /* Spectrum Analyzer */
+ pLVPSA_Handle_t hPSAInstance; /* Spectrum Analyzer instance handle */
+ LVPSA_InstancePr_t PSA_Instance; /* Spectrum Analyzer instance */
+ LVPSA_InitParams_t PSA_InitParams; /* Spectrum Analyzer initialization parameters */
+ LVPSA_ControlParams_t PSA_ControlParams; /* Spectrum Analyzer control parameters */
+ LVM_INT16 PSA_GainOffset; /* Tone control flag */
+ LVM_Callback CallBack;
+ LVM_INT16 *pPSAInput; /* PSA input pointer */
+
+ LVM_INT16 NoSmoothVolume; /* Enable or disable smooth volume changes*/
+
+} LVM_Instance_t;
+
+
+/************************************************************************************/
+/* */
+/* Function Prototypes */
+/* */
+/************************************************************************************/
+
+LVM_ReturnStatus_en LVM_ApplyNewSettings(LVM_Handle_t hInstance);
+
+void LVM_SetTrebleBoost( LVM_Instance_t *pInstance,
+ LVM_ControlParams_t *pParams);
+
+void LVM_SetVolume( LVM_Instance_t *pInstance,
+ LVM_ControlParams_t *pParams);
+
+LVM_INT32 LVM_VCCallBack(void* pBundleHandle,
+ void* pGeneralPurpose,
+ short CallBackParam);
+
+void LVM_SetHeadroom( LVM_Instance_t *pInstance,
+ LVM_ControlParams_t *pParams);
+
+void LVM_BufferIn( LVM_Handle_t hInstance,
+ const LVM_INT16 *pInData,
+ LVM_INT16 **pToProcess,
+ LVM_INT16 **pProcessed,
+ LVM_UINT16 *pNumSamples);
+
+void LVM_BufferOut( LVM_Handle_t hInstance,
+ LVM_INT16 *pOutData,
+ LVM_UINT16 *pNumSamples);
+
+LVM_INT32 LVM_AlgoCallBack( void *pBundleHandle,
+ void *pData,
+ LVM_INT16 callbackId);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __LVM_PRIVATE_H__ */
+
diff --git a/media/libeffects/lvm/lib/Bundle/src/LVM_Process.c b/media/libeffects/lvm/lib/Bundle/src/LVM_Process.c
new file mode 100755
index 0000000..bad9450
--- /dev/null
+++ b/media/libeffects/lvm/lib/Bundle/src/LVM_Process.c
@@ -0,0 +1,283 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/****************************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1002 $
+ $Date: 2010-06-28 13:40:09 +0200 (Mon, 28 Jun 2010) $
+
+*****************************************************************************************/
+
+
+/****************************************************************************************/
+/* */
+/* Includes */
+/* */
+/****************************************************************************************/
+
+#include "LVM_Private.h"
+#include "VectorArithmetic.h"
+#include "LVM_Coeffs.h"
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_Process */
+/* */
+/* DESCRIPTION: */
+/* Process function for the LifeVibes module. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* pInData Pointer to the input data */
+/* pOutData Pointer to the output data */
+/* NumSamples Number of samples in the input buffer */
+/* AudioTime Audio Time of the current input buffer in ms */
+/* */
+/* RETURNS: */
+/* LVM_SUCCESS Succeeded */
+/* LVM_INVALIDNUMSAMPLES When the NumSamples is not a valied multiple in unmanaged */
+/* buffer mode */
+/* LVM_ALIGNMENTERROR When either the input our output buffers are not 32-bit */
+/* aligned in unmanaged mode */
+/* LVM_NULLADDRESS When one of hInstance, pInData or pOutData is NULL */
+/* */
+/* NOTES: */
+/* */
+/****************************************************************************************/
+
+LVM_ReturnStatus_en LVM_Process(LVM_Handle_t hInstance,
+ const LVM_INT16 *pInData,
+ LVM_INT16 *pOutData,
+ LVM_UINT16 NumSamples,
+ LVM_UINT32 AudioTime)
+{
+
+ LVM_Instance_t *pInstance = (LVM_Instance_t *)hInstance;
+ LVM_UINT16 SampleCount = NumSamples;
+ LVM_INT16 *pInput = (LVM_INT16 *)pInData;
+ LVM_INT16 *pToProcess = (LVM_INT16 *)pInData;
+ LVM_INT16 *pProcessed = pOutData;
+ LVM_ReturnStatus_en Status;
+
+ /*
+ * Check if the number of samples is zero
+ */
+ if (NumSamples == 0)
+ {
+ return(LVM_SUCCESS);
+ }
+
+
+ /*
+ * Check valid points have been given
+ */
+ if ((hInstance == LVM_NULL) || (pInData == LVM_NULL) || (pOutData == LVM_NULL))
+ {
+ return (LVM_NULLADDRESS);
+ }
+
+ /*
+ * For unmanaged mode only
+ */
+ if(pInstance->InstParams.BufferMode == LVM_UNMANAGED_BUFFERS)
+ {
+ /*
+ * Check if the number of samples is a good multiple (unmanaged mode only)
+ */
+ if((NumSamples % pInstance->BlickSizeMultiple) != 0)
+ {
+ return(LVM_INVALIDNUMSAMPLES);
+ }
+
+ /*
+ * Check the buffer alignment
+ */
+ if((((LVM_UINT32)pInData % 4) != 0) || (((LVM_UINT32)pOutData % 4) != 0))
+ {
+ return(LVM_ALIGNMENTERROR);
+ }
+ }
+
+
+ /*
+ * Update new parameters if necessary
+ */
+ if (pInstance->ControlPending == LVM_TRUE)
+ {
+ Status = LVM_ApplyNewSettings(hInstance);
+
+ if(Status != LVM_SUCCESS)
+ {
+ return Status;
+ }
+ }
+
+
+ /*
+ * Convert from Mono if necessary
+ */
+ if (pInstance->Params.SourceFormat == LVM_MONO)
+ {
+ MonoTo2I_16(pInData, /* Source */
+ pOutData, /* Destination */
+ (LVM_INT16)NumSamples); /* Number of input samples */
+ pInput = pOutData;
+ pToProcess = pOutData;
+ }
+
+
+ /*
+ * Process the data with managed buffers
+ */
+ while (SampleCount != 0)
+ {
+ /*
+ * Manage the input buffer and frame processing
+ */
+ LVM_BufferIn(hInstance,
+ pInput,
+ &pToProcess,
+ &pProcessed,
+ &SampleCount);
+
+ /*
+ * Only process data when SampleCount is none zero, a zero count can occur when
+ * the BufferIn routine is working in managed mode.
+ */
+ if (SampleCount != 0)
+ {
+
+ /*
+ * Apply ConcertSound if required
+ */
+ if (pInstance->CS_Active == LVM_TRUE)
+ {
+ (void)LVCS_Process(pInstance->hCSInstance, /* Concert Sound instance handle */
+ pToProcess,
+ pProcessed,
+ SampleCount);
+ pToProcess = pProcessed;
+ }
+
+ /*
+ * Apply volume if required
+ */
+ if (pInstance->VC_Active!=0)
+ {
+ LVC_MixSoft_1St_D16C31_SAT(&pInstance->VC_Volume,
+ pToProcess,
+ pProcessed,
+ (LVM_INT16)(2*SampleCount)); /* Left and right*/
+ pToProcess = pProcessed;
+ }
+
+ /*
+ * Call N-Band equaliser if enabled
+ */
+ if (pInstance->EQNB_Active == LVM_TRUE)
+ {
+ LVEQNB_Process(pInstance->hEQNBInstance, /* N-Band equaliser instance handle */
+ pToProcess,
+ pProcessed,
+ SampleCount);
+ pToProcess = pProcessed;
+ }
+
+ /*
+ * Call bass enhancement if enabled
+ */
+ if (pInstance->DBE_Active == LVM_TRUE)
+ {
+ LVDBE_Process(pInstance->hDBEInstance, /* Dynamic Bass Enhancement instance handle */
+ pToProcess,
+ pProcessed,
+ SampleCount);
+ pToProcess = pProcessed;
+ }
+
+ /*
+ * Bypass mode or everything off, so copy the input to the output
+ */
+ if (pToProcess != pProcessed)
+ {
+ Copy_16(pToProcess, /* Source */
+ pProcessed, /* Destination */
+ (LVM_INT16)(2*SampleCount)); /* Left and right */
+ }
+
+ /*
+ * Apply treble boost if required
+ */
+ if (pInstance->TE_Active == LVM_TRUE)
+ {
+ /*
+ * Apply the filter
+ */
+ FO_2I_D16F32C15_LShx_TRC_WRA_01(&pInstance->pTE_State->TrebleBoost_State,
+ pProcessed,
+ pProcessed,
+ (LVM_INT16)SampleCount);
+
+ }
+
+ /*
+ * Volume balance
+ */
+ LVC_MixSoft_1St_2i_D16C31_SAT(&pInstance->VC_BalanceMix,
+ pProcessed,
+ pProcessed,
+ SampleCount);
+
+ /*
+ * Perform Parametric Spectum Analysis
+ */
+ if ((pInstance->Params.PSA_Enable == LVM_PSA_ON)&&(pInstance->InstParams.PSA_Included==LVM_PSA_ON))
+ {
+ From2iToMono_16(pProcessed,
+ pInstance->pPSAInput,
+ (LVM_INT16) (SampleCount));
+
+ LVPSA_Process(pInstance->hPSAInstance,
+ pInstance->pPSAInput,
+ (LVM_UINT16) (SampleCount),
+ AudioTime);
+ }
+
+
+ /*
+ * DC removal
+ */
+ DC_2I_D16_TRC_WRA_01(&pInstance->DC_RemovalInstance,
+ pProcessed,
+ pProcessed,
+ (LVM_INT16)SampleCount);
+
+
+ }
+
+ /*
+ * Manage the output buffer
+ */
+ LVM_BufferOut(hInstance,
+ pOutData,
+ &SampleCount);
+
+ }
+
+ return(LVM_SUCCESS);
+}
diff --git a/media/libeffects/lvm/lib/Bundle/src/LVM_Tables.c b/media/libeffects/lvm/lib/Bundle/src/LVM_Tables.c
new file mode 100755
index 0000000..cb33541
--- /dev/null
+++ b/media/libeffects/lvm/lib/Bundle/src/LVM_Tables.c
@@ -0,0 +1,397 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1002 $
+ $Date: 2010-06-28 13:40:09 +0200 (Mon, 28 Jun 2010) $
+
+*************************************************************************************/
+
+/************************************************************************************/
+/* */
+/* Includes */
+/* */
+/************************************************************************************/
+
+#include "LVM_Tables.h"
+#include "LVM_Coeffs.h"
+
+/************************************************************************************/
+/* */
+/* Treble Boost Filter Coefficients */
+/* */
+/************************************************************************************/
+
+FO_C16_LShx_Coefs_t LVM_TrebleBoostCoefs[] = {
+
+ /* 22kHz sampling rate */
+ {HPF_Fs22050_Gain1_A1, /* Gain setting 1 */
+ HPF_Fs22050_Gain1_A0,
+ -HPF_Fs22050_Gain1_B1,
+ HPF_Fs22050_Gain1_Shift},
+ {HPF_Fs22050_Gain2_A1, /* Gain setting 2 */
+ HPF_Fs22050_Gain2_A0,
+ -HPF_Fs22050_Gain2_B1,
+ HPF_Fs22050_Gain2_Shift},
+ {HPF_Fs22050_Gain3_A1, /* Gain setting 3 */
+ HPF_Fs22050_Gain3_A0,
+ -HPF_Fs22050_Gain3_B1,
+ HPF_Fs22050_Gain3_Shift},
+ {HPF_Fs22050_Gain4_A1, /* Gain setting 4 */
+ HPF_Fs22050_Gain4_A0,
+ -HPF_Fs22050_Gain4_B1,
+ HPF_Fs22050_Gain4_Shift},
+ {HPF_Fs22050_Gain5_A1, /* Gain setting 5 */
+ HPF_Fs22050_Gain5_A0,
+ -HPF_Fs22050_Gain5_B1,
+ HPF_Fs22050_Gain5_Shift},
+ {HPF_Fs22050_Gain6_A1, /* Gain setting 6 */
+ HPF_Fs22050_Gain6_A0,
+ -HPF_Fs22050_Gain6_B1,
+ HPF_Fs22050_Gain6_Shift},
+ {HPF_Fs22050_Gain7_A1, /* Gain setting 7 */
+ HPF_Fs22050_Gain7_A0,
+ -HPF_Fs22050_Gain7_B1,
+ HPF_Fs22050_Gain7_Shift},
+ {HPF_Fs22050_Gain8_A1, /* Gain setting 8 */
+ HPF_Fs22050_Gain8_A0,
+ -HPF_Fs22050_Gain8_B1,
+ HPF_Fs22050_Gain8_Shift},
+ {HPF_Fs22050_Gain9_A1, /* Gain setting 9 */
+ HPF_Fs22050_Gain9_A0,
+ -HPF_Fs22050_Gain9_B1,
+ HPF_Fs22050_Gain9_Shift},
+ {HPF_Fs22050_Gain10_A1, /* Gain setting 10 */
+ HPF_Fs22050_Gain10_A0,
+ -HPF_Fs22050_Gain10_B1,
+ HPF_Fs22050_Gain10_Shift},
+ {HPF_Fs22050_Gain11_A1, /* Gain setting 11 */
+ HPF_Fs22050_Gain11_A0,
+ -HPF_Fs22050_Gain11_B1,
+ HPF_Fs22050_Gain11_Shift},
+ {HPF_Fs22050_Gain12_A1, /* Gain setting 12 */
+ HPF_Fs22050_Gain12_A0,
+ -HPF_Fs22050_Gain12_B1,
+ HPF_Fs22050_Gain12_Shift},
+ {HPF_Fs22050_Gain13_A1, /* Gain setting 13 */
+ HPF_Fs22050_Gain13_A0,
+ -HPF_Fs22050_Gain13_B1,
+ HPF_Fs22050_Gain13_Shift},
+ {HPF_Fs22050_Gain14_A1, /* Gain setting 14 */
+ HPF_Fs22050_Gain14_A0,
+ -HPF_Fs22050_Gain14_B1,
+ HPF_Fs22050_Gain14_Shift},
+ {HPF_Fs22050_Gain15_A1, /* Gain setting 15 */
+ HPF_Fs22050_Gain15_A0,
+ -HPF_Fs22050_Gain15_B1,
+ HPF_Fs22050_Gain15_Shift},
+
+ /* 24kHz sampling rate */
+ {HPF_Fs24000_Gain1_A1, /* Gain setting 1 */
+ HPF_Fs24000_Gain1_A0,
+ -HPF_Fs24000_Gain1_B1,
+ HPF_Fs24000_Gain1_Shift},
+ {HPF_Fs24000_Gain2_A1, /* Gain setting 2 */
+ HPF_Fs24000_Gain2_A0,
+ -HPF_Fs24000_Gain2_B1,
+ HPF_Fs24000_Gain2_Shift},
+ {HPF_Fs24000_Gain3_A1, /* Gain setting 3 */
+ HPF_Fs24000_Gain3_A0,
+ -HPF_Fs24000_Gain3_B1,
+ HPF_Fs24000_Gain3_Shift},
+ {HPF_Fs24000_Gain4_A1, /* Gain setting 4 */
+ HPF_Fs24000_Gain4_A0,
+ -HPF_Fs24000_Gain4_B1,
+ HPF_Fs24000_Gain4_Shift},
+ {HPF_Fs24000_Gain5_A1, /* Gain setting 5 */
+ HPF_Fs24000_Gain5_A0,
+ -HPF_Fs24000_Gain5_B1,
+ HPF_Fs24000_Gain5_Shift},
+ {HPF_Fs24000_Gain6_A1, /* Gain setting 6 */
+ HPF_Fs24000_Gain6_A0,
+ -HPF_Fs24000_Gain6_B1,
+ HPF_Fs24000_Gain6_Shift},
+ {HPF_Fs24000_Gain7_A1, /* Gain setting 7 */
+ HPF_Fs24000_Gain7_A0,
+ -HPF_Fs24000_Gain7_B1,
+ HPF_Fs24000_Gain7_Shift},
+ {HPF_Fs24000_Gain8_A1, /* Gain setting 8 */
+ HPF_Fs24000_Gain8_A0,
+ -HPF_Fs24000_Gain8_B1,
+ HPF_Fs24000_Gain8_Shift},
+ {HPF_Fs24000_Gain9_A1, /* Gain setting 9 */
+ HPF_Fs24000_Gain9_A0,
+ -HPF_Fs24000_Gain9_B1,
+ HPF_Fs24000_Gain9_Shift},
+ {HPF_Fs24000_Gain10_A1, /* Gain setting 10 */
+ HPF_Fs24000_Gain10_A0,
+ -HPF_Fs24000_Gain10_B1,
+ HPF_Fs24000_Gain10_Shift},
+ {HPF_Fs24000_Gain11_A1, /* Gain setting 11 */
+ HPF_Fs24000_Gain11_A0,
+ -HPF_Fs24000_Gain11_B1,
+ HPF_Fs24000_Gain11_Shift},
+ {HPF_Fs24000_Gain12_A1, /* Gain setting 12 */
+ HPF_Fs24000_Gain12_A0,
+ -HPF_Fs24000_Gain12_B1,
+ HPF_Fs24000_Gain12_Shift},
+ {HPF_Fs24000_Gain13_A1, /* Gain setting 13 */
+ HPF_Fs24000_Gain13_A0,
+ -HPF_Fs24000_Gain13_B1,
+ HPF_Fs24000_Gain13_Shift},
+ {HPF_Fs24000_Gain14_A1, /* Gain setting 14 */
+ HPF_Fs24000_Gain14_A0,
+ -HPF_Fs24000_Gain14_B1,
+ HPF_Fs24000_Gain14_Shift},
+ {HPF_Fs24000_Gain15_A1, /* Gain setting 15 */
+ HPF_Fs24000_Gain15_A0,
+ -HPF_Fs24000_Gain15_B1,
+ HPF_Fs24000_Gain15_Shift},
+
+ /* 32kHz sampling rate */
+ {HPF_Fs32000_Gain1_A1, /* Gain setting 1 */
+ HPF_Fs32000_Gain1_A0,
+ -HPF_Fs32000_Gain1_B1,
+ HPF_Fs32000_Gain1_Shift},
+ {HPF_Fs32000_Gain2_A1, /* Gain setting 2 */
+ HPF_Fs32000_Gain2_A0,
+ -HPF_Fs32000_Gain2_B1,
+ HPF_Fs32000_Gain2_Shift},
+ {HPF_Fs32000_Gain3_A1, /* Gain setting 3 */
+ HPF_Fs32000_Gain3_A0,
+ -HPF_Fs32000_Gain3_B1,
+ HPF_Fs32000_Gain3_Shift},
+ {HPF_Fs32000_Gain4_A1, /* Gain setting 4 */
+ HPF_Fs32000_Gain4_A0,
+ -HPF_Fs32000_Gain4_B1,
+ HPF_Fs32000_Gain4_Shift},
+ {HPF_Fs32000_Gain5_A1, /* Gain setting 5 */
+ HPF_Fs32000_Gain5_A0,
+ -HPF_Fs32000_Gain5_B1,
+ HPF_Fs32000_Gain5_Shift},
+ {HPF_Fs32000_Gain6_A1, /* Gain setting 6 */
+ HPF_Fs32000_Gain6_A0,
+ -HPF_Fs32000_Gain6_B1,
+ HPF_Fs32000_Gain6_Shift},
+ {HPF_Fs32000_Gain7_A1, /* Gain setting 7 */
+ HPF_Fs32000_Gain7_A0,
+ -HPF_Fs32000_Gain7_B1,
+ HPF_Fs32000_Gain7_Shift},
+ {HPF_Fs32000_Gain8_A1, /* Gain setting 8 */
+ HPF_Fs32000_Gain8_A0,
+ -HPF_Fs32000_Gain8_B1,
+ HPF_Fs32000_Gain8_Shift},
+ {HPF_Fs32000_Gain9_A1, /* Gain setting 9 */
+ HPF_Fs32000_Gain9_A0,
+ -HPF_Fs32000_Gain9_B1,
+ HPF_Fs32000_Gain9_Shift},
+ {HPF_Fs32000_Gain10_A1, /* Gain setting 10 */
+ HPF_Fs32000_Gain10_A0,
+ -HPF_Fs32000_Gain10_B1,
+ HPF_Fs32000_Gain10_Shift},
+ {HPF_Fs32000_Gain11_A1, /* Gain setting 11 */
+ HPF_Fs32000_Gain11_A0,
+ -HPF_Fs32000_Gain11_B1,
+ HPF_Fs32000_Gain11_Shift},
+ {HPF_Fs32000_Gain12_A1, /* Gain setting 12 */
+ HPF_Fs32000_Gain12_A0,
+ -HPF_Fs32000_Gain12_B1,
+ HPF_Fs32000_Gain12_Shift},
+ {HPF_Fs32000_Gain13_A1, /* Gain setting 13 */
+ HPF_Fs32000_Gain13_A0,
+ -HPF_Fs32000_Gain13_B1,
+ HPF_Fs32000_Gain13_Shift},
+ {HPF_Fs32000_Gain14_A1, /* Gain setting 14 */
+ HPF_Fs32000_Gain14_A0,
+ -HPF_Fs32000_Gain14_B1,
+ HPF_Fs32000_Gain14_Shift},
+ {HPF_Fs32000_Gain15_A1, /* Gain setting 15 */
+ HPF_Fs32000_Gain15_A0,
+ -HPF_Fs32000_Gain15_B1,
+ HPF_Fs32000_Gain15_Shift},
+
+ /* 44kHz sampling rate */
+ {HPF_Fs44100_Gain1_A1, /* Gain setting 1 */
+ HPF_Fs44100_Gain1_A0,
+ -HPF_Fs44100_Gain1_B1,
+ HPF_Fs44100_Gain1_Shift},
+ {HPF_Fs44100_Gain2_A1, /* Gain setting 2 */
+ HPF_Fs44100_Gain2_A0,
+ -HPF_Fs44100_Gain2_B1,
+ HPF_Fs44100_Gain2_Shift},
+ {HPF_Fs44100_Gain3_A1, /* Gain setting 3 */
+ HPF_Fs44100_Gain3_A0,
+ -HPF_Fs44100_Gain3_B1,
+ HPF_Fs44100_Gain3_Shift},
+ {HPF_Fs44100_Gain4_A1, /* Gain setting 4 */
+ HPF_Fs44100_Gain4_A0,
+ -HPF_Fs44100_Gain4_B1,
+ HPF_Fs44100_Gain4_Shift},
+ {HPF_Fs44100_Gain5_A1, /* Gain setting 5 */
+ HPF_Fs44100_Gain5_A0,
+ -HPF_Fs44100_Gain5_B1,
+ HPF_Fs44100_Gain5_Shift},
+ {HPF_Fs44100_Gain6_A1, /* Gain setting 6 */
+ HPF_Fs44100_Gain6_A0,
+ -HPF_Fs44100_Gain6_B1,
+ HPF_Fs44100_Gain6_Shift},
+ {HPF_Fs44100_Gain7_A1, /* Gain setting 7 */
+ HPF_Fs44100_Gain7_A0,
+ -HPF_Fs44100_Gain7_B1,
+ HPF_Fs44100_Gain7_Shift},
+ {HPF_Fs44100_Gain8_A1, /* Gain setting 8 */
+ HPF_Fs44100_Gain8_A0,
+ -HPF_Fs44100_Gain8_B1,
+ HPF_Fs44100_Gain8_Shift},
+ {HPF_Fs44100_Gain9_A1, /* Gain setting 9 */
+ HPF_Fs44100_Gain9_A0,
+ -HPF_Fs44100_Gain9_B1,
+ HPF_Fs44100_Gain9_Shift},
+ {HPF_Fs44100_Gain10_A1, /* Gain setting 10 */
+ HPF_Fs44100_Gain10_A0,
+ -HPF_Fs44100_Gain10_B1,
+ HPF_Fs44100_Gain10_Shift},
+ {HPF_Fs44100_Gain11_A1, /* Gain setting 11 */
+ HPF_Fs44100_Gain11_A0,
+ -HPF_Fs44100_Gain11_B1,
+ HPF_Fs44100_Gain11_Shift},
+ {HPF_Fs44100_Gain12_A1, /* Gain setting 12 */
+ HPF_Fs44100_Gain12_A0,
+ -HPF_Fs44100_Gain12_B1,
+ HPF_Fs44100_Gain12_Shift},
+ {HPF_Fs44100_Gain13_A1, /* Gain setting 13 */
+ HPF_Fs44100_Gain13_A0,
+ -HPF_Fs44100_Gain13_B1,
+ HPF_Fs44100_Gain13_Shift},
+ {HPF_Fs44100_Gain14_A1, /* Gain setting 14 */
+ HPF_Fs44100_Gain14_A0,
+ -HPF_Fs44100_Gain14_B1,
+ HPF_Fs44100_Gain14_Shift},
+ {HPF_Fs44100_Gain15_A1, /* Gain setting 15 */
+ HPF_Fs44100_Gain15_A0,
+ -HPF_Fs44100_Gain15_B1,
+ HPF_Fs44100_Gain15_Shift},
+
+ /* 48kHz sampling rate */
+ {HPF_Fs48000_Gain1_A1, /* Gain setting 1 */
+ HPF_Fs48000_Gain1_A0,
+ -HPF_Fs48000_Gain1_B1,
+ HPF_Fs48000_Gain1_Shift},
+ {HPF_Fs48000_Gain2_A1, /* Gain setting 2 */
+ HPF_Fs48000_Gain2_A0,
+ -HPF_Fs48000_Gain2_B1,
+ HPF_Fs48000_Gain2_Shift},
+ {HPF_Fs48000_Gain3_A1, /* Gain setting 3 */
+ HPF_Fs48000_Gain3_A0,
+ -HPF_Fs48000_Gain3_B1,
+ HPF_Fs48000_Gain3_Shift},
+ {HPF_Fs48000_Gain4_A1, /* Gain setting 4 */
+ HPF_Fs48000_Gain4_A0,
+ -HPF_Fs48000_Gain4_B1,
+ HPF_Fs48000_Gain4_Shift},
+ {HPF_Fs48000_Gain5_A1, /* Gain setting 5 */
+ HPF_Fs48000_Gain5_A0,
+ -HPF_Fs48000_Gain5_B1,
+ HPF_Fs48000_Gain5_Shift},
+ {HPF_Fs48000_Gain6_A1, /* Gain setting 6 */
+ HPF_Fs48000_Gain6_A0,
+ -HPF_Fs48000_Gain6_B1,
+ HPF_Fs48000_Gain6_Shift},
+ {HPF_Fs48000_Gain7_A1, /* Gain setting 7 */
+ HPF_Fs48000_Gain7_A0,
+ -HPF_Fs48000_Gain7_B1,
+ HPF_Fs48000_Gain7_Shift},
+ {HPF_Fs48000_Gain8_A1, /* Gain setting 8 */
+ HPF_Fs48000_Gain8_A0,
+ -HPF_Fs48000_Gain8_B1,
+ HPF_Fs48000_Gain8_Shift},
+ {HPF_Fs48000_Gain9_A1, /* Gain setting 9 */
+ HPF_Fs48000_Gain9_A0,
+ -HPF_Fs48000_Gain9_B1,
+ HPF_Fs48000_Gain9_Shift},
+ {HPF_Fs48000_Gain10_A1, /* Gain setting 10 */
+ HPF_Fs48000_Gain10_A0,
+ -HPF_Fs48000_Gain10_B1,
+ HPF_Fs48000_Gain10_Shift},
+ {HPF_Fs48000_Gain11_A1, /* Gain setting 11 */
+ HPF_Fs48000_Gain11_A0,
+ -HPF_Fs48000_Gain11_B1,
+ HPF_Fs48000_Gain11_Shift},
+ {HPF_Fs48000_Gain12_A1, /* Gain setting 12 */
+ HPF_Fs48000_Gain12_A0,
+ -HPF_Fs48000_Gain12_B1,
+ HPF_Fs48000_Gain12_Shift},
+ {HPF_Fs48000_Gain13_A1, /* Gain setting 13 */
+ HPF_Fs48000_Gain13_A0,
+ -HPF_Fs48000_Gain13_B1,
+ HPF_Fs48000_Gain13_Shift},
+ {HPF_Fs48000_Gain14_A1, /* Gain setting 14 */
+ HPF_Fs48000_Gain14_A0,
+ -HPF_Fs48000_Gain14_B1,
+ HPF_Fs48000_Gain14_Shift},
+ {HPF_Fs48000_Gain15_A1, /* Gain setting 15 */
+ HPF_Fs48000_Gain15_A0,
+ -HPF_Fs48000_Gain15_B1,
+ HPF_Fs48000_Gain15_Shift}};
+
+
+/************************************************************************************/
+/* */
+/* Volume control gain and time constant tables */
+/* */
+/************************************************************************************/
+
+/* dB to linear conversion table */
+const LVM_INT16 LVM_VolumeTable[] = {
+ 0x7FFF, /* 0dB */
+ 0x7215, /* -1dB */
+ 0x65AD, /* -2dB */
+ 0x5A9E, /* -3dB */
+ 0x50C3, /* -4dB */
+ 0x47FB, /* -5dB */
+ 0x4000}; /* -6dB */
+
+/************************************************************************************/
+/* */
+/* Volume mixer time constants (100ms) */
+/* */
+/************************************************************************************/
+
+#define LVM_MIX_TC_Fs8000 32580 /* Floating point value 0.994262695 */
+#define LVM_MIX_TC_Fs11025 32632 /* Floating point value 0.995849609 */
+#define LVM_MIX_TC_Fs12000 32643 /* Floating point value 0.996185303 */
+#define LVM_MIX_TC_Fs16000 32674 /* Floating point value 0.997131348 */
+#define LVM_MIX_TC_Fs22050 32700 /* Floating point value 0.997924805 */
+#define LVM_MIX_TC_Fs24000 32705 /* Floating point value 0.998077393 */
+#define LVM_MIX_TC_Fs32000 32721 /* Floating point value 0.998565674 */
+#define LVM_MIX_TC_Fs44100 32734 /* Floating point value 0.998962402 */
+#define LVM_MIX_TC_Fs48000 32737 /* Floating point value 0.999053955 */
+
+
+const LVM_INT16 LVM_MixerTCTable[] = {
+ LVM_MIX_TC_Fs8000,
+ LVM_MIX_TC_Fs11025,
+ LVM_MIX_TC_Fs12000,
+ LVM_MIX_TC_Fs16000,
+ LVM_MIX_TC_Fs22050,
+ LVM_MIX_TC_Fs24000,
+ LVM_MIX_TC_Fs32000,
+ LVM_MIX_TC_Fs44100,
+ LVM_MIX_TC_Fs48000};
+
diff --git a/media/libeffects/lvm/lib/Bundle/src/LVM_Tables.h b/media/libeffects/lvm/lib/Bundle/src/LVM_Tables.h
new file mode 100755
index 0000000..574f641
--- /dev/null
+++ b/media/libeffects/lvm/lib/Bundle/src/LVM_Tables.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1002 $
+ $Date: 2010-06-28 13:40:09 +0200 (Mon, 28 Jun 2010) $
+
+*************************************************************************************/
+
+#ifndef __LVM_TABLES_H__
+#define __LVM_TABLES_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/************************************************************************************/
+/* */
+/* Includes */
+/* */
+/************************************************************************************/
+
+#include "BIQUAD.h"
+#include "LVM_Types.h"
+
+/************************************************************************************/
+/* */
+/* Treble Boost Filter Coefficients */
+/* */
+/************************************************************************************/
+
+extern FO_C16_LShx_Coefs_t LVM_TrebleBoostCoefs[];
+
+
+/************************************************************************************/
+/* */
+/* Volume control gain and time constant tables */
+/* */
+/************************************************************************************/
+
+extern const LVM_INT16 LVM_VolumeTable[];
+extern const LVM_INT16 LVM_MixerTCTable[];
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __LVM_TABLES_H__ */
+
+
diff --git a/media/libeffects/lvm/lib/Common/lib/AGC.h b/media/libeffects/lvm/lib/Common/lib/AGC.h
new file mode 100755
index 0000000..980a8e3
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/lib/AGC.h
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/**********************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1000 $
+ $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $
+
+***********************************************************************************/
+
+#ifndef __AGC_H__
+#define __AGC_H__
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**********************************************************************************/
+/* */
+/* Includes */
+/* */
+/**********************************************************************************/
+
+#include "LVM_Types.h"
+
+
+/**********************************************************************************/
+/* */
+/* Types */
+/* */
+/**********************************************************************************/
+
+typedef struct
+{
+ LVM_INT32 AGC_Gain; /* The current AGC gain */
+ LVM_INT32 AGC_MaxGain; /* The maximum AGC gain */
+ LVM_INT32 Volume; /* The current volume setting */
+ LVM_INT32 Target; /* The target volume setting */
+ LVM_INT32 AGC_Target; /* AGC target level */
+ LVM_INT16 AGC_Attack; /* AGC attack scaler */
+ LVM_INT16 AGC_Decay; /* AGC decay scaler */
+ LVM_INT16 AGC_GainShift; /* The gain shift */
+ LVM_INT16 VolumeShift; /* Volume shift scaling */
+ LVM_INT16 VolumeTC; /* Volume update time constant */
+
+} AGC_MIX_VOL_2St1Mon_D32_t;
+
+
+/**********************************************************************************/
+/* */
+/* Function Prototypes */
+/* */
+/**********************************************************************************/
+
+void AGC_MIX_VOL_2St1Mon_D32_WRA(AGC_MIX_VOL_2St1Mon_D32_t *pInstance, /* Instance pointer */
+ const LVM_INT32 *pStSrc, /* Stereo source */
+ const LVM_INT32 *pMonoSrc, /* Mono source */
+ LVM_INT32 *pDst, /* Stereo destination */
+ LVM_UINT16 n); /* Number of samples */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __AGC_H__ */
+
+
+
+
+
+
+
+
+
+
diff --git a/media/libeffects/lvm/lib/Common/lib/BIQUAD.h b/media/libeffects/lvm/lib/Common/lib/BIQUAD.h
new file mode 100755
index 0000000..08e5a6f
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/lib/BIQUAD.h
@@ -0,0 +1,341 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/**********************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 722 $
+ $Date: 2010-06-10 15:12:34 +0200 (Thu, 10 Jun 2010) $
+
+***********************************************************************************/
+
+#ifndef _BIQUAD_H_
+#define _BIQUAD_H_
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#include "LVM_Types.h"
+/**********************************************************************************
+ INSTANCE MEMORY TYPE DEFINITION
+***********************************************************************************/
+
+typedef struct
+{
+ LVM_INT32 Storage[6];
+
+} Biquad_Instance_t;
+
+
+/**********************************************************************************
+ COEFFICIENT TYPE DEFINITIONS
+***********************************************************************************/
+
+/*** Biquad coefficients **********************************************************/
+typedef struct
+{
+ LVM_INT16 A2; /* a2 */
+ LVM_INT16 A1; /* a1 */
+ LVM_INT16 A0; /* a0 */
+ LVM_INT16 B2; /* -b2! */
+ LVM_INT16 B1; /* -b1! */
+} BQ_C16_Coefs_t;
+
+typedef struct
+{
+ LVM_INT32 A2; /* a2 */
+ LVM_INT32 A1; /* a1 */
+ LVM_INT32 A0; /* a0 */
+ LVM_INT32 B2; /* -b2! */
+ LVM_INT32 B1; /* -b1! */
+} BQ_C32_Coefs_t;
+
+/*** First order coefficients *****************************************************/
+typedef struct
+{
+ LVM_INT16 A1; /* a1 */
+ LVM_INT16 A0; /* a0 */
+ LVM_INT16 B1; /* -b1! */
+} FO_C16_Coefs_t;
+
+typedef struct
+{
+ LVM_INT32 A1; /* a1 */
+ LVM_INT32 A0; /* a0 */
+ LVM_INT32 B1; /* -b1! */
+} FO_C32_Coefs_t;
+
+/*** First order coefficients with Shift*****************************************************/
+typedef struct
+{
+ LVM_INT16 A1; /* a1 */
+ LVM_INT16 A0; /* a0 */
+ LVM_INT16 B1; /* -b1! */
+ LVM_INT16 Shift; /* Shift */
+} FO_C16_LShx_Coefs_t;
+
+/*** Band pass coefficients *******************************************************/
+typedef struct
+{
+ LVM_INT16 A0; /* a0 */
+ LVM_INT16 B2; /* -b2! */
+ LVM_INT16 B1; /* -b1! */
+} BP_C16_Coefs_t;
+
+typedef struct
+{
+ LVM_INT32 A0; /* a0 */
+ LVM_INT32 B2; /* -b2! */
+ LVM_INT32 B1; /* -b1! */
+} BP_C32_Coefs_t;
+
+/*** Peaking coefficients *********************************************************/
+typedef struct
+{
+ LVM_INT16 A0; /* a0 */
+ LVM_INT16 B2; /* -b2! */
+ LVM_INT16 B1; /* -b1! */
+ LVM_INT16 G; /* Gain */
+} PK_C16_Coefs_t;
+
+typedef struct
+{
+ LVM_INT32 A0; /* a0 */
+ LVM_INT32 B2; /* -b2! */
+ LVM_INT32 B1; /* -b1! */
+ LVM_INT16 G; /* Gain */
+} PK_C32_Coefs_t;
+
+
+/**********************************************************************************
+ TAPS TYPE DEFINITIONS
+***********************************************************************************/
+
+/*** Types used for first order and shelving filter *******************************/
+
+typedef struct
+{
+ LVM_INT32 Storage[ (1*2) ]; /* One channel, two taps of size LVM_INT32 */
+} Biquad_1I_Order1_Taps_t;
+
+typedef struct
+{
+ LVM_INT32 Storage[ (2*2) ]; /* Two channels, two taps of size LVM_INT32 */
+} Biquad_2I_Order1_Taps_t;
+
+
+/*** Types used for biquad, band pass and peaking filter **************************/
+
+typedef struct
+{
+ LVM_INT32 Storage[ (1*4) ]; /* One channel, four taps of size LVM_INT32 */
+} Biquad_1I_Order2_Taps_t;
+
+typedef struct
+{
+ LVM_INT32 Storage[ (2*4) ]; /* Two channels, four taps of size LVM_INT32 */
+} Biquad_2I_Order2_Taps_t;
+
+/* The names of the functions are changed to satisfy QAC rules: Name should be Unique withing 16 characters*/
+#define BQ_2I_D32F32Cll_TRC_WRA_01_Init Init_BQ_2I_D32F32Cll_TRC_WRA_01
+#define BP_1I_D32F32C30_TRC_WRA_02 TWO_BP_1I_D32F32C30_TRC_WRA_02
+
+/**********************************************************************************
+ FUNCTION PROTOTYPES: BIQUAD FILTERS
+***********************************************************************************/
+
+/*** 16 bit data path *************************************************************/
+
+void BQ_2I_D16F32Css_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance,
+ Biquad_2I_Order2_Taps_t *pTaps,
+ BQ_C16_Coefs_t *pCoef);
+
+void BQ_2I_D16F32C15_TRC_WRA_01 ( Biquad_Instance_t *pInstance,
+ LVM_INT16 *pDataIn,
+ LVM_INT16 *pDataOut,
+ LVM_INT16 NrSamples);
+
+void BQ_2I_D16F32C14_TRC_WRA_01 ( Biquad_Instance_t *pInstance,
+ LVM_INT16 *pDataIn,
+ LVM_INT16 *pDataOut,
+ LVM_INT16 NrSamples);
+
+void BQ_2I_D16F32C13_TRC_WRA_01 ( Biquad_Instance_t *pInstance,
+ LVM_INT16 *pDataIn,
+ LVM_INT16 *pDataOut,
+ LVM_INT16 NrSamples);
+
+void BQ_2I_D16F16Css_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance,
+ Biquad_2I_Order2_Taps_t *pTaps,
+ BQ_C16_Coefs_t *pCoef);
+
+void BQ_2I_D16F16C15_TRC_WRA_01( Biquad_Instance_t *pInstance,
+ LVM_INT16 *pDataIn,
+ LVM_INT16 *pDataOut,
+ LVM_INT16 NrSamples);
+
+void BQ_2I_D16F16C14_TRC_WRA_01( Biquad_Instance_t *pInstance,
+ LVM_INT16 *pDataIn,
+ LVM_INT16 *pDataOut,
+ LVM_INT16 NrSamples);
+
+void BQ_1I_D16F16Css_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance,
+ Biquad_1I_Order2_Taps_t *pTaps,
+ BQ_C16_Coefs_t *pCoef);
+
+void BQ_1I_D16F16C15_TRC_WRA_01( Biquad_Instance_t *pInstance,
+ LVM_INT16 *pDataIn,
+ LVM_INT16 *pDataOut,
+ LVM_INT16 NrSamples);
+
+void BQ_1I_D16F32Css_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance,
+ Biquad_1I_Order2_Taps_t *pTaps,
+ BQ_C16_Coefs_t *pCoef);
+
+void BQ_1I_D16F32C14_TRC_WRA_01 ( Biquad_Instance_t *pInstance,
+ LVM_INT16 *pDataIn,
+ LVM_INT16 *pDataOut,
+ LVM_INT16 NrSamples);
+
+/*** 32 bit data path *************************************************************/
+
+void BQ_2I_D32F32Cll_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance,
+ Biquad_2I_Order2_Taps_t *pTaps,
+ BQ_C32_Coefs_t *pCoef);
+
+void BQ_2I_D32F32C30_TRC_WRA_01 ( Biquad_Instance_t *pInstance,
+ LVM_INT32 *pDataIn,
+ LVM_INT32 *pDataOut,
+ LVM_INT16 NrSamples);
+
+/**********************************************************************************
+ FUNCTION PROTOTYPES: FIRST ORDER FILTERS
+***********************************************************************************/
+
+/*** 16 bit data path *************************************************************/
+
+void FO_1I_D16F16Css_TRC_WRA_01_Init( Biquad_Instance_t *pInstance,
+ Biquad_1I_Order1_Taps_t *pTaps,
+ FO_C16_Coefs_t *pCoef);
+
+void FO_1I_D16F16C15_TRC_WRA_01( Biquad_Instance_t *pInstance,
+ LVM_INT16 *pDataIn,
+ LVM_INT16 *pDataOut,
+ LVM_INT16 NrSamples);
+
+void FO_2I_D16F32Css_LShx_TRC_WRA_01_Init(Biquad_Instance_t *pInstance,
+ Biquad_2I_Order1_Taps_t *pTaps,
+ FO_C16_LShx_Coefs_t *pCoef);
+
+void FO_2I_D16F32C15_LShx_TRC_WRA_01(Biquad_Instance_t *pInstance,
+ LVM_INT16 *pDataIn,
+ LVM_INT16 *pDataOut,
+ LVM_INT16 NrSamples);
+
+/*** 32 bit data path *************************************************************/
+
+void FO_1I_D32F32Cll_TRC_WRA_01_Init( Biquad_Instance_t *pInstance,
+ Biquad_1I_Order1_Taps_t *pTaps,
+ FO_C32_Coefs_t *pCoef);
+
+void FO_1I_D32F32C31_TRC_WRA_01( Biquad_Instance_t *pInstance,
+ LVM_INT32 *pDataIn,
+ LVM_INT32 *pDataOut,
+ LVM_INT16 NrSamples);
+
+/**********************************************************************************
+ FUNCTION PROTOTYPES: BAND PASS FILTERS
+***********************************************************************************/
+
+/*** 16 bit data path *************************************************************/
+
+void BP_1I_D16F16Css_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance,
+ Biquad_1I_Order2_Taps_t *pTaps,
+ BP_C16_Coefs_t *pCoef);
+
+void BP_1I_D16F16C14_TRC_WRA_01 ( Biquad_Instance_t *pInstance,
+ LVM_INT16 *pDataIn,
+ LVM_INT16 *pDataOut,
+ LVM_INT16 NrSamples);
+
+void BP_1I_D16F32Cll_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance,
+ Biquad_1I_Order2_Taps_t *pTaps,
+ BP_C32_Coefs_t *pCoef);
+
+void BP_1I_D16F32C30_TRC_WRA_01 ( Biquad_Instance_t *pInstance,
+ LVM_INT16 *pDataIn,
+ LVM_INT16 *pDataOut,
+ LVM_INT16 NrSamples);
+
+
+/*** 32 bit data path *************************************************************/
+
+void BP_1I_D32F32Cll_TRC_WRA_02_Init ( Biquad_Instance_t *pInstance,
+ Biquad_1I_Order2_Taps_t *pTaps,
+ BP_C32_Coefs_t *pCoef);
+
+void BP_1I_D32F32C30_TRC_WRA_02( Biquad_Instance_t *pInstance,
+ LVM_INT32 *pDataIn,
+ LVM_INT32 *pDataOut,
+ LVM_INT16 NrSamples);
+
+
+/*** 32 bit data path STEREO ******************************************************/
+
+void PK_2I_D32F32CllGss_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance,
+ Biquad_2I_Order2_Taps_t *pTaps,
+ PK_C32_Coefs_t *pCoef);
+
+void PK_2I_D32F32C30G11_TRC_WRA_01 ( Biquad_Instance_t *pInstance,
+ LVM_INT32 *pDataIn,
+ LVM_INT32 *pDataOut,
+ LVM_INT16 NrSamples);
+
+void PK_2I_D32F32CssGss_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance,
+ Biquad_2I_Order2_Taps_t *pTaps,
+ PK_C16_Coefs_t *pCoef);
+
+void PK_2I_D32F32C14G11_TRC_WRA_01 ( Biquad_Instance_t *pInstance,
+ LVM_INT32 *pDataIn,
+ LVM_INT32 *pDataOut,
+ LVM_INT16 NrSamples);
+
+
+/**********************************************************************************
+ FUNCTION PROTOTYPES: DC REMOVAL FILTERS
+***********************************************************************************/
+
+/*** 16 bit data path STEREO ******************************************************/
+
+void DC_2I_D16_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance);
+
+void DC_2I_D16_TRC_WRA_01 ( Biquad_Instance_t *pInstance,
+ LVM_INT16 *pDataIn,
+ LVM_INT16 *pDataOut,
+ LVM_INT16 NrSamples);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+/**********************************************************************************/
+
+#endif /** _BIQUAD_H_ **/
+
diff --git a/media/libeffects/lvm/lib/Common/lib/CompLim.h b/media/libeffects/lvm/lib/Common/lib/CompLim.h
new file mode 100755
index 0000000..df9b583
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/lib/CompLim.h
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/**********************************************************************************
+
+ $Author: nxp27078 $
+ $Revision: 672 $
+ $Date: 2010-06-08 19:39:38 +0200 (Tue, 08 Jun 2010) $
+
+***********************************************************************************/
+
+#ifndef _COMP_LIM_H
+#define _COMP_LIM_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/************************************************************************************/
+/* */
+/* Includes */
+/* */
+/************************************************************************************/
+
+#include "LVM_Types.h"
+
+
+/************************************************************************************/
+/* */
+/* Structures */
+/* */
+/************************************************************************************/
+
+typedef struct /* Compressor state */
+{
+ /* Normaliser */
+ LVM_INT16 Norm_Attack; /* Attack time constant of the Normaliser integrator */
+ LVM_INT16 Norm_Decay; /* Decay time constant of the Normaliser integrator */
+ LVM_INT32 NormInt; /* Normaliser integrator current value */
+ LVM_INT16 Shift; /* Shift gain */
+ LVM_INT16 Threshold; /* Target threshold */
+
+ /* Compressor */
+ LVM_INT16 Comp_Atten; /* Attenuation applied before soft knee compressor */
+ LVM_INT16 Comp_Attack_S; /* Attack time constant of the slow integrator */
+ LVM_INT16 Comp_Decay_S; /* Decay time constant of slow the integrator */
+ LVM_INT16 Comp_Attack_F; /* Attack time constant of fast the integrator */
+ LVM_INT16 Comp_Decay_F; /* Decay time constant of fast the integrator */
+ LVM_INT16 SoftClipGain; /* Soft clip gain control */
+ LVM_INT32 CompIntSlow; /* Compressor slow integrator current value */
+ LVM_INT32 CompIntFast; /* Compressor fast integrator current value */
+
+
+} CompLim_Instance_t;
+
+
+/************************************************************************************/
+/* */
+/* Function Prototypes */
+/* */
+/************************************************************************************/
+
+void NonLinComp_D16(LVM_INT16 Gain,
+ LVM_INT16 *pSterBfIn,
+ LVM_INT16 *pSterBfOut,
+ LVM_INT32 BlockLength);
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* #ifndef _COMP_LIM_H */
+
+
+
diff --git a/media/libeffects/lvm/lib/Common/lib/Filter.h b/media/libeffects/lvm/lib/Common/lib/Filter.h
new file mode 100755
index 0000000..93ccbcb
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/lib/Filter.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 771 $*/
+/* $Date: 2010-06-14 10:41:36 +0200 (Mon, 14 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+#ifndef _FILTER_H_
+#define _FILTER_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**********************************************************************************
+ INCLUDES
+***********************************************************************************/
+#include "LVM_Types.h"
+#include "BIQUAD.h"
+
+
+/**********************************************************************************
+ DEFINES
+***********************************************************************************/
+#define FILTER_LOSS 32730 /* -0.01dB loss to avoid wrapping due to band ripple */
+
+/**********************************************************************************
+ FUNCTION PROTOTYPES
+***********************************************************************************/
+
+LVM_INT32 LVM_Polynomial(LVM_UINT16 N,
+ LVM_INT32 *pCoefficients,
+ LVM_INT32 X);
+
+LVM_INT32 LVM_Power10( LVM_INT32 X);
+
+LVM_INT32 LVM_FO_LPF( LVM_INT32 w,
+ FO_C32_Coefs_t *pCoeffs);
+
+LVM_INT32 LVM_FO_HPF( LVM_INT32 w,
+ FO_C32_Coefs_t *pCoeffs);
+
+LVM_INT32 LVM_GetOmega(LVM_UINT16 Fc,
+ LVM_Fs_en SampleRate);
+
+/**********************************************************************************/
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /** _FILTER_H_ **/
+
diff --git a/media/libeffects/lvm/lib/Common/lib/InstAlloc.h b/media/libeffects/lvm/lib/Common/lib/InstAlloc.h
new file mode 100755
index 0000000..31409bf
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/lib/InstAlloc.h
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+#ifndef __INSTALLOC_H__
+#define __INSTALLOC_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#include "LVM_Types.h"
+/*######################################################################################*/
+/* Type declarations */
+/*######################################################################################*/
+typedef struct
+{
+ LVM_UINT32 TotalSize; /* Accumulative total memory size */
+ LVM_UINT32 pNextMember; /* Pointer to the next instance member to be allocated */
+} INST_ALLOC;
+
+
+/*######################################################################################*/
+/* Function prototypes */
+/*######################################################################################*/
+
+/****************************************************************************************
+ * Name : InstAlloc_Init()
+ * Input : pms - Pointer to the INST_ALLOC instance
+ StartAddr - Base address of the instance memory
+ * Returns : Error code
+ * Description : Initializes the instance distribution and memory size calculation function
+ * Remarks :
+ ****************************************************************************************/
+
+void InstAlloc_Init( INST_ALLOC *pms, void *StartAddr );
+
+
+/****************************************************************************************
+ * Name : InstAlloc_AddMember()
+ * Input : pms - Pointer to the INST_ALLOC instance
+ Size - The size in bytes of the new added member
+ * Returns : A pointer to the new added member
+ * Description : Allocates space for a new member in the instance memory and returns
+ a pointer to this new member. The start address of all members will
+ be 32 bit alligned.
+ * Remarks :
+ ****************************************************************************************/
+
+void* InstAlloc_AddMember( INST_ALLOC *pms, LVM_UINT32 Size );
+
+/****************************************************************************************
+ * Name : InstAlloc_GetTotal()
+ * Input : pms - Pointer to the INST_ALLOC instance
+ * Returns : The instance memory size
+ * Description : This functions returns the calculated instance memory size
+ * Remarks :
+ ****************************************************************************************/
+
+LVM_UINT32 InstAlloc_GetTotal( INST_ALLOC *pms);
+
+void* InstAlloc_AddMemberAllRet( INST_ALLOC *pms,
+ LVM_UINT32 Size[],
+ void **ptr);
+
+void* InstAlloc_AddMemberAll( INST_ALLOC *pms,
+ LVM_UINT32 Size[],
+ LVM_MemoryTable_st *pMemoryTable);
+
+void InstAlloc_InitAll( INST_ALLOC *pms,
+ LVM_MemoryTable_st *pMemoryTable);
+
+void InstAlloc_InitAll_NULL( INST_ALLOC *pms);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __JBS_INSTALLOC_H__ */
diff --git a/media/libeffects/lvm/lib/Common/lib/LVM_Common.h b/media/libeffects/lvm/lib/Common/lib/LVM_Common.h
new file mode 100755
index 0000000..f0f893d
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/lib/LVM_Common.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/*****************************************************************************************
+
+ $Author: nxp27078 $
+ $Revision: 672 $
+ $Date: 2010-06-08 19:39:38 +0200 (Tue, 08 Jun 2010) $
+
+*****************************************************************************************/
+
+/****************************************************************************************/
+/* */
+/* Header file for the common definitions used within the bundle and its algorithms. */
+/* */
+/* This files includes all definitions, types, structures and function prototypes. */
+/* */
+/****************************************************************************************/
+
+
+#ifndef __LVM_COMMON_H__
+#define __LVM_COMMON_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/****************************************************************************************/
+/* */
+/* Includes */
+/* */
+/****************************************************************************************/
+#include "LVM_Types.h"
+
+
+/****************************************************************************************/
+/* */
+/* Definitions */
+/* */
+/****************************************************************************************/
+/* Algorithm identification */
+#define ALGORITHM_NONE_ID 0x0000
+#define ALGORITHM_CS_ID 0x0100
+#define ALGORITHM_EQNB_ID 0x0200
+#define ALGORITHM_DBE_ID 0x0300
+#define ALGORITHM_VC_ID 0x0500
+#define ALGORITHM_TE_ID 0x0600
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __LVM_COMMON_H__ */
+
diff --git a/media/libeffects/lvm/lib/Common/lib/LVM_Macros.h b/media/libeffects/lvm/lib/Common/lib/LVM_Macros.h
new file mode 100755
index 0000000..8bd363d
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/lib/LVM_Macros.h
@@ -0,0 +1,130 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/**********************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1000 $
+ $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $
+
+***********************************************************************************/
+
+#ifndef _LVM_MACROS_H_
+#define _LVM_MACROS_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**********************************************************************************
+ MUL32x32INTO32(A,B,C,ShiftR)
+ C = (A * B) >> ShiftR
+
+ A, B and C are all 32 bit SIGNED numbers and ShiftR can vary from 0 to 64
+
+ The user has to take care that C does not overflow. The result in case
+ of overflow is undefined.
+
+***********************************************************************************/
+#ifndef MUL32x32INTO32
+#define MUL32x32INTO32(A,B,C,ShiftR) \
+ {LVM_INT32 MUL32x32INTO32_temp,MUL32x32INTO32_temp2,MUL32x32INTO32_mask,MUL32x32INTO32_HH,MUL32x32INTO32_HL,MUL32x32INTO32_LH,MUL32x32INTO32_LL;\
+ LVM_INT32 shiftValue;\
+ shiftValue = (ShiftR);\
+ MUL32x32INTO32_mask=0x0000FFFF;\
+ MUL32x32INTO32_HH= ((LVM_INT32)((LVM_INT16)((A)>>16))*((LVM_INT16)((B)>>16)) );\
+ MUL32x32INTO32_HL= ((LVM_INT32)((B)&MUL32x32INTO32_mask)*((LVM_INT16)((A)>>16))) ;\
+ MUL32x32INTO32_LH= ((LVM_INT32)((A)&MUL32x32INTO32_mask)*((LVM_INT16)((B)>>16)));\
+ MUL32x32INTO32_LL= (LVM_INT32)((A)&MUL32x32INTO32_mask)*(LVM_INT32)((B)&MUL32x32INTO32_mask);\
+ MUL32x32INTO32_temp= (LVM_INT32)(MUL32x32INTO32_HL&MUL32x32INTO32_mask)+(LVM_INT32)(MUL32x32INTO32_LH&MUL32x32INTO32_mask)+(LVM_INT32)((MUL32x32INTO32_LL>>16)&MUL32x32INTO32_mask);\
+ MUL32x32INTO32_HH= MUL32x32INTO32_HH+(LVM_INT32)(MUL32x32INTO32_HL>>16)+(LVM_INT32)(MUL32x32INTO32_LH>>16)+(LVM_INT32)(MUL32x32INTO32_temp>>16);\
+ MUL32x32INTO32_LL=MUL32x32INTO32_LL+(LVM_INT32)(MUL32x32INTO32_HL<<16)+(LVM_INT32)(MUL32x32INTO32_LH<<16);\
+ if(shiftValue<32)\
+ {\
+ MUL32x32INTO32_HH=MUL32x32INTO32_HH<<(32-shiftValue);\
+ MUL32x32INTO32_mask=((LVM_INT32)1<<(32-shiftValue))-1;\
+ MUL32x32INTO32_LL=(MUL32x32INTO32_LL>>shiftValue)&MUL32x32INTO32_mask;\
+ MUL32x32INTO32_temp2=MUL32x32INTO32_HH|MUL32x32INTO32_LL;\
+ }\
+ else\
+ {\
+ MUL32x32INTO32_temp2=(LVM_INT32)MUL32x32INTO32_HH>>(shiftValue-32);\
+ }\
+ (C) = MUL32x32INTO32_temp2;\
+ }
+#endif
+
+/**********************************************************************************
+ MUL32x16INTO32(A,B,C,ShiftR)
+ C = (A * B) >> ShiftR
+
+ A and C are 32 bit SIGNED numbers. B is a 16 bit SIGNED number.
+ ShiftR can vary from 0 to 48
+
+ The user has to take care that C does not overflow. The result in case
+ of overflow is undefined.
+
+***********************************************************************************/
+#ifndef MUL32x16INTO32
+#define MUL32x16INTO32(A,B,C,ShiftR) \
+ {LVM_INT32 MUL32x16INTO32_mask,MUL32x16INTO32_HH,MUL32x16INTO32_LL;\
+ LVM_INT32 shiftValue;\
+ shiftValue = (ShiftR);\
+ MUL32x16INTO32_mask=0x0000FFFF;\
+ MUL32x16INTO32_HH= ((LVM_INT32)(B)*((LVM_INT16)((A)>>16)));\
+ MUL32x16INTO32_LL= ((LVM_INT32)((A)&MUL32x16INTO32_mask)*(B));\
+ if(shiftValue<16)\
+ {\
+ MUL32x16INTO32_HH=(LVM_INT32)((LVM_UINT32)MUL32x16INTO32_HH<<(16-shiftValue));\
+ (C)=MUL32x16INTO32_HH+(LVM_INT32)(MUL32x16INTO32_LL>>shiftValue);\
+ }\
+ else if(shiftValue<32) {\
+ MUL32x16INTO32_HH=(LVM_INT32)(MUL32x16INTO32_HH>>(shiftValue-16));\
+ (C)=MUL32x16INTO32_HH+(LVM_INT32)(MUL32x16INTO32_LL>>shiftValue);\
+ }\
+ else {\
+ (C)=MUL32x16INTO32_HH>>(shiftValue-16);}\
+ }
+#endif
+
+/**********************************************************************************
+ ADD2_SAT_32x32(A,B,C)
+ C = SAT(A + B)
+
+ A,B and C are 32 bit SIGNED numbers.
+***********************************************************************************/
+#ifndef ADD2_SAT_32x32
+#define ADD2_SAT_32x32(A,B,C) \
+ {(C)=(A)+(B);\
+ if ((((C) ^ (A)) & ((C) ^ (B))) >> 31)\
+ {\
+ if((A)<0)\
+ (C)=0x80000000l;\
+ else\
+ (C)=0x7FFFFFFFl;\
+ }\
+ }
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _LVM_MACROS_H_ */
+
+/*** End of file ******************************************************************/
diff --git a/media/libeffects/lvm/lib/Common/lib/LVM_Timer.h b/media/libeffects/lvm/lib/Common/lib/LVM_Timer.h
new file mode 100755
index 0000000..22a16d6
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/lib/LVM_Timer.h
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef __LVM_TIMER_H__
+#define __LVM_TIMER_H__
+/************************************************************************/
+/* */
+/* Project:: My Project */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+#include "LVM_Types.h"
+
+/****************************************************************************************/
+/* */
+/* Header file for the LVM_Timer library */
+/* */
+/* Functionality: */
+/* The timer will count down a number of ms, based on the number of samples it */
+/* sees and the curent sampling rate. When the timer expires, a registered */
+/* callback function will be called. */
+/* The maximal number of sampless that can be called by the timer is 2^32, which */
+/* corresponds to 24.8 hours at a sampling rate of 48 kHz */
+/* The timer currently does not suport changes in sampling rate while timing. */
+/****************************************************************************************/
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/****************************************************************************************/
+/* TYPE DEFINITIONS */
+/****************************************************************************************/
+
+typedef struct
+{
+ LVM_INT32 Storage[6];
+
+} LVM_Timer_Instance_t;
+
+typedef struct
+{
+ LVM_INT32 SamplingRate;
+ LVM_INT16 TimeInMs;
+ LVM_INT32 CallBackParam;
+ void *pCallBackParams;
+ void *pCallbackInstance;
+ void (*pCallBack)(void*,void*,LVM_INT32);
+
+} LVM_Timer_Params_t;
+
+/****************************************************************************************/
+/* FUNCTION PROTOTYPES */
+/****************************************************************************************/
+
+void LVM_Timer_Init ( LVM_Timer_Instance_t *pInstance,
+ LVM_Timer_Params_t *pParams );
+
+
+void LVM_Timer ( LVM_Timer_Instance_t *pInstance,
+ LVM_INT16 BlockSize );
+
+
+/****************************************************************************************/
+/* END OF HEADER */
+/****************************************************************************************/
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __LVM_TIMER_H__ */
diff --git a/media/libeffects/lvm/lib/Common/lib/LVM_Types.h b/media/libeffects/lvm/lib/Common/lib/LVM_Types.h
new file mode 100755
index 0000000..e4649ba
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/lib/LVM_Types.h
@@ -0,0 +1,195 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/****************************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1000 $
+ $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $
+
+*****************************************************************************************/
+
+/****************************************************************************************/
+/* */
+/* Header file defining the standard LifeVibes types for use in the application layer */
+/* interface of all LifeVibes modules */
+/* */
+/****************************************************************************************/
+
+#ifndef LVM_TYPES_H
+#define LVM_TYPES_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/****************************************************************************************/
+/* */
+/* definitions */
+/* */
+/****************************************************************************************/
+
+#define LVM_NULL 0 /* NULL pointer */
+
+#define LVM_TRUE 1 /* Booleans */
+#define LVM_FALSE 0
+
+#define LVM_MAXINT_8 127 /* Maximum positive integer size */
+#define LVM_MAXINT_16 32767
+#define LVM_MAXINT_32 2147483647
+#define LVM_MAXENUM 2147483647
+
+#define LVM_MODULEID_MASK 0xFF00 /* Mask to extract the calling module ID from callbackId */
+#define LVM_EVENTID_MASK 0x00FF /* Mask to extract the callback event from callbackId */
+
+/* Memory table*/
+#define LVM_MEMREGION_PERSISTENT_SLOW_DATA 0 /* Offset to the instance memory region */
+#define LVM_MEMREGION_PERSISTENT_FAST_DATA 1 /* Offset to the persistent data memory region */
+#define LVM_MEMREGION_PERSISTENT_FAST_COEF 2 /* Offset to the persistent coefficient memory region */
+#define LVM_MEMREGION_TEMPORARY_FAST 3 /* Offset to temporary memory region */
+
+#define LVM_NR_MEMORY_REGIONS 4 /* Number of memory regions */
+
+/* Memory partition type */
+#define LVM_MEM_PARTITION0 0 /* 1st memory partition */
+#define LVM_MEM_PARTITION1 1 /* 2nd memory partition */
+#define LVM_MEM_PARTITION2 2 /* 3rd memory partition */
+#define LVM_MEM_PARTITION3 3 /* 4th memory partition */
+
+/* Use type */
+#define LVM_MEM_PERSISTENT 0 /* Persistent memory type */
+#define LVM_MEM_SCRATCH 4 /* Scratch memory type */
+
+/* Access type */
+#define LVM_MEM_INTERNAL 0 /* Internal (fast) access memory */
+#define LVM_MEM_EXTERNAL 8 /* External (slow) access memory */
+
+/* Platform specific */
+#define LVM_PERSISTENT LVM_MEM_PARTITION0+LVM_MEM_PERSISTENT+LVM_MEM_INTERNAL
+#define LVM_PERSISTENT_DATA LVM_MEM_PARTITION1+LVM_MEM_PERSISTENT+LVM_MEM_INTERNAL
+#define LVM_PERSISTENT_COEF LVM_MEM_PARTITION2+LVM_MEM_PERSISTENT+LVM_MEM_INTERNAL
+#define LVM_SCRATCH LVM_MEM_PARTITION3+LVM_MEM_SCRATCH+LVM_MEM_INTERNAL
+
+/****************************************************************************************/
+/* */
+/* Basic types */
+/* */
+/****************************************************************************************/
+
+typedef char LVM_CHAR; /* ASCII character */
+
+typedef char LVM_INT8; /* Signed 8-bit word */
+typedef unsigned char LVM_UINT8; /* Unsigned 8-bit word */
+
+typedef short LVM_INT16; /* Signed 16-bit word */
+typedef unsigned short LVM_UINT16; /* Unsigned 16-bit word */
+
+typedef long LVM_INT32; /* Signed 32-bit word */
+typedef unsigned long LVM_UINT32; /* Unsigned 32-bit word */
+
+
+/****************************************************************************************/
+/* */
+/* Standard Enumerated types */
+/* */
+/****************************************************************************************/
+
+/* Operating mode */
+typedef enum
+{
+ LVM_MODE_OFF = 0,
+ LVM_MODE_ON = 1,
+ LVM_MODE_DUMMY = LVM_MAXENUM
+} LVM_Mode_en;
+
+
+/* Format */
+typedef enum
+{
+ LVM_STEREO = 0,
+ LVM_MONOINSTEREO = 1,
+ LVM_MONO = 2,
+ LVM_SOURCE_DUMMY = LVM_MAXENUM
+} LVM_Format_en;
+
+
+/* LVM sampling rates */
+typedef enum
+{
+ LVM_FS_8000 = 0,
+ LVM_FS_11025 = 1,
+ LVM_FS_12000 = 2,
+ LVM_FS_16000 = 3,
+ LVM_FS_22050 = 4,
+ LVM_FS_24000 = 5,
+ LVM_FS_32000 = 6,
+ LVM_FS_44100 = 7,
+ LVM_FS_48000 = 8,
+ LVM_FS_INVALID = LVM_MAXENUM-1,
+ LVM_FS_DUMMY = LVM_MAXENUM
+} LVM_Fs_en;
+
+
+/* Memory Types */
+typedef enum
+{
+ LVM_PERSISTENT_SLOW_DATA = LVM_MEMREGION_PERSISTENT_SLOW_DATA,
+ LVM_PERSISTENT_FAST_DATA = LVM_MEMREGION_PERSISTENT_FAST_DATA,
+ LVM_PERSISTENT_FAST_COEF = LVM_MEMREGION_PERSISTENT_FAST_COEF,
+ LVM_TEMPORARY_FAST = LVM_MEMREGION_TEMPORARY_FAST,
+ LVM_MEMORYTYPE_DUMMY = LVM_MAXENUM
+} LVM_MemoryTypes_en;
+
+
+/* Memory region definition */
+typedef struct
+{
+ LVM_UINT32 Size; /* Region size in bytes */
+ LVM_MemoryTypes_en Type; /* Region type */
+ void *pBaseAddress; /* Pointer to the region base address */
+} LVM_MemoryRegion_st;
+
+
+/* Memory table containing the region definitions */
+typedef struct
+{
+ LVM_MemoryRegion_st Region[LVM_NR_MEMORY_REGIONS]; /* One definition for each region */
+} LVM_MemoryTable_st;
+
+
+/****************************************************************************************/
+/* */
+/* Standard Function Prototypes */
+/* */
+/****************************************************************************************/
+typedef LVM_INT32 (*LVM_Callback)(void *pCallbackData, /* Pointer to the callback data structure */
+ void *pGeneralPurpose, /* General purpose pointer (e.g. to a data structure needed in the callback) */
+ LVM_INT16 GeneralPurpose ); /* General purpose variable (e.g. to be used as callback ID) */
+
+
+/****************************************************************************************/
+/* */
+/* End of file */
+/* */
+/****************************************************************************************/
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* LVM_TYPES_H */
diff --git a/media/libeffects/lvm/lib/Common/lib/Mixer.h b/media/libeffects/lvm/lib/Common/lib/Mixer.h
new file mode 100755
index 0000000..d741980
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/lib/Mixer.h
@@ -0,0 +1,135 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/**********************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1000 $
+ $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $
+
+***********************************************************************************/
+
+#ifndef __MIXER_H__
+#define __MIXER_H__
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+#include "LVM_Types.h"
+
+/**********************************************************************************
+ INSTANCE MEMORY TYPE DEFINITION
+***********************************************************************************/
+
+typedef struct
+{
+ LVM_INT32 Alpha; /* Time constant. Set by calling application. Can be changed at any time */
+ LVM_INT32 Target; /* Target value. Set by calling application. Can be changed at any time */
+ LVM_INT32 Current; /* Current value. Set by the mixer function. */
+ LVM_INT16 CallbackSet; /* Boolean. Should be set by calling application each time the target value is updated */
+ LVM_INT16 CallbackParam; /* Parameter that will be used in the calback function */
+ void *pCallbackHandle; /* Pointer to the instance of the callback function */
+ void *pGeneralPurpose; /* Pointer for general purpose usage */
+ LVM_Callback pCallBack; /* Pointer to the callback function */
+} Mix_1St_Cll_t;
+
+typedef struct
+{
+ LVM_INT32 Alpha1;
+ LVM_INT32 Target1;
+ LVM_INT32 Current1;
+ LVM_INT16 CallbackSet1;
+ LVM_INT16 CallbackParam1;
+ void *pCallbackHandle1;
+ void *pGeneralPurpose1;
+ LVM_Callback pCallBack1;
+
+ LVM_INT32 Alpha2; /* Warning the address of this location is passed as a pointer to Mix_1St_Cll_t in some functions */
+ LVM_INT32 Target2;
+ LVM_INT32 Current2;
+ LVM_INT16 CallbackSet2;
+ LVM_INT16 CallbackParam2;
+ void *pCallbackHandle2;
+ void *pGeneralPurpose2;
+ LVM_Callback pCallBack2;
+
+} Mix_2St_Cll_t;
+
+
+/*** General functions ************************************************************/
+
+LVM_UINT32 LVM_Mixer_TimeConstant(LVM_UINT32 tc,
+ LVM_UINT16 Fs,
+ LVM_UINT16 NumChannels);
+
+
+void MixSoft_1St_D32C31_WRA( Mix_1St_Cll_t *pInstance,
+ const LVM_INT32 *src,
+ LVM_INT32 *dst,
+ LVM_INT16 n);
+
+void MixSoft_2St_D32C31_SAT( Mix_2St_Cll_t *pInstance,
+ const LVM_INT32 *src1,
+ const LVM_INT32 *src2,
+ LVM_INT32 *dst,
+ LVM_INT16 n);
+
+void MixInSoft_D32C31_SAT( Mix_1St_Cll_t *pInstance,
+ const LVM_INT32 *src,
+ LVM_INT32 *dst,
+ LVM_INT16 n);
+
+/**********************************************************************************
+ FUNCTION PROTOTYPES (LOW LEVEL SUBFUNCTIONS)
+***********************************************************************************/
+
+void Core_MixSoft_1St_D32C31_WRA( Mix_1St_Cll_t *pInstance,
+ const LVM_INT32 *src,
+ LVM_INT32 *dst,
+ LVM_INT16 n);
+
+void Core_MixHard_2St_D32C31_SAT( Mix_2St_Cll_t *pInstance,
+ const LVM_INT32 *src1,
+ const LVM_INT32 *src2,
+ LVM_INT32 *dst,
+ LVM_INT16 n);
+
+void Core_MixInSoft_D32C31_SAT( Mix_1St_Cll_t *pInstance,
+ const LVM_INT32 *src,
+ LVM_INT32 *dst,
+ LVM_INT16 n);
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+/**********************************************************************************/
+
+#endif /* __MIXER_H__ */
+
+
+
+
+
+
+
+
+
+
diff --git a/media/libeffects/lvm/lib/Common/lib/ScalarArithmetic.h b/media/libeffects/lvm/lib/Common/lib/ScalarArithmetic.h
new file mode 100755
index 0000000..c66e201
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/lib/ScalarArithmetic.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+#ifndef __SCALARARITHMETIC_H__
+#define __SCALARARITHMETIC_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/*######################################################################################*/
+/* Include files */
+/*######################################################################################*/
+
+#include "LVM_Types.h"
+
+/*######################################################################################*/
+/* Extern function prototypes */
+/*######################################################################################*/
+
+/* Absolute value including the corner case for the extreme negative value */
+LVM_INT32 Abs_32(LVM_INT32 input);
+
+/****************************************************************************************
+ * Name : dB_to_Lin32()
+ * Input : Signed 16-bit integer
+ * MSB (16) = sign bit
+ * (15->05) = integer part
+ * (04->01) = decimal part
+ * Output : Signed 32-bit integer
+ * MSB (32) = sign bit
+ * (31->16) = integer part
+ * (15->01) = decimal part
+ * Returns : Lin value format 1.16.15
+ ****************************************************************************************/
+
+LVM_INT32 dB_to_Lin32(LVM_INT16 db_fix);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __SCALARARITHMETIC_H__ */
+
+
diff --git a/media/libeffects/lvm/lib/Common/lib/VectorArithmetic.h b/media/libeffects/lvm/lib/Common/lib/VectorArithmetic.h
new file mode 100755
index 0000000..290a996
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/lib/VectorArithmetic.h
@@ -0,0 +1,189 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/**********************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 853 $
+ $Date: 2010-06-16 15:10:28 +0200 (Wed, 16 Jun 2010) $
+
+***********************************************************************************/
+
+#ifndef _VECTOR_ARITHMETIC_H_
+#define _VECTOR_ARITHMETIC_H_
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#include "LVM_Types.h"
+
+/**********************************************************************************
+ VARIOUS FUNCTIONS
+***********************************************************************************/
+
+void LoadConst_16( const LVM_INT16 val,
+ LVM_INT16 *dst,
+ LVM_INT16 n );
+
+void LoadConst_32( const LVM_INT32 val,
+ LVM_INT32 *dst,
+ LVM_INT16 n );
+
+void Copy_16( const LVM_INT16 *src,
+ LVM_INT16 *dst,
+ LVM_INT16 n );
+
+/*********************************************************************************
+ * note: In Mult3s_16x16() saturation of result is not taken care when *
+ * overflow occurs. *
+ * For example when *src = 0x8000, val = *0x8000 *
+ * The function gives the output as 0x8000 instead of 0x7fff *
+ * This is the only case which will give wrong result. *
+ * For more information refer to Vector_Arithmetic.doc in /doc folder *
+ *********************************************************************************/
+void Mult3s_16x16( const LVM_INT16 *src,
+ const LVM_INT16 val,
+ LVM_INT16 *dst,
+ LVM_INT16 n);
+
+/*********************************************************************************
+ * note: In Mult3s_32x16() saturation of result is not taken care when *
+ * overflow occurs. *
+ * For example when *src = 0x8000000, val = *0x8000 *
+ * The function gives the output as 0x8000000 instead of 0x7fffffff *
+ * This is the only extreme condition which is giving unexpected result *
+ * For more information refer to Vector_Arithmetic.doc in /doc folder *
+ *********************************************************************************/
+void Mult3s_32x16( const LVM_INT32 *src,
+ const LVM_INT16 val,
+ LVM_INT32 *dst,
+ LVM_INT16 n);
+
+void DelayMix_16x16( const LVM_INT16 *src,
+ LVM_INT16 *delay,
+ LVM_INT16 size,
+ LVM_INT16 *dst,
+ LVM_INT16 *pOffset,
+ LVM_INT16 n);
+
+void DelayWrite_32( const LVM_INT32 *src, /* Source 1, to be delayed */
+ LVM_INT32 *delay, /* Delay buffer */
+ LVM_UINT16 size, /* Delay size */
+ LVM_UINT16 *pOffset, /* Delay offset */
+ LVM_INT16 n);
+
+void Add2_Sat_16x16( const LVM_INT16 *src,
+ LVM_INT16 *dst,
+ LVM_INT16 n );
+
+void Add2_Sat_32x32( const LVM_INT32 *src,
+ LVM_INT32 *dst,
+ LVM_INT16 n );
+
+void Mac3s_Sat_16x16( const LVM_INT16 *src,
+ const LVM_INT16 val,
+ LVM_INT16 *dst,
+ LVM_INT16 n);
+
+void Mac3s_Sat_32x16( const LVM_INT32 *src,
+ const LVM_INT16 val,
+ LVM_INT32 *dst,
+ LVM_INT16 n);
+
+void DelayAllPass_Sat_32x16To32( LVM_INT32 *delay, /* Delay buffer */
+ LVM_UINT16 size, /* Delay size */
+ LVM_INT16 coeff, /* All pass filter coefficient */
+ LVM_UINT16 DelayOffset, /* Simple delay offset */
+ LVM_UINT16 *pAllPassOffset, /* All pass filter delay offset */
+ LVM_INT32 *dst, /* Source/destination */
+ LVM_INT16 n);
+
+/**********************************************************************************
+ SHIFT FUNCTIONS
+***********************************************************************************/
+
+void Shift_Sat_v16xv16 ( const LVM_INT16 val,
+ const LVM_INT16 *src,
+ LVM_INT16 *dst,
+ LVM_INT16 n);
+
+void Shift_Sat_v32xv32 ( const LVM_INT16 val,
+ const LVM_INT32 *src,
+ LVM_INT32 *dst,
+ LVM_INT16 n);
+
+/**********************************************************************************
+ AUDIO FORMAT CONVERSION FUNCTIONS
+***********************************************************************************/
+
+void MonoTo2I_16( const LVM_INT16 *src,
+ LVM_INT16 *dst,
+ LVM_INT16 n);
+
+void MonoTo2I_32( const LVM_INT32 *src,
+ LVM_INT32 *dst,
+ LVM_INT16 n);
+
+void From2iToMono_32( const LVM_INT32 *src,
+ LVM_INT32 *dst,
+ LVM_INT16 n);
+
+void MSTo2i_Sat_16x16( const LVM_INT16 *srcM,
+ const LVM_INT16 *srcS,
+ LVM_INT16 *dst,
+ LVM_INT16 n );
+
+void From2iToMS_16x16( const LVM_INT16 *src,
+ LVM_INT16 *dstM,
+ LVM_INT16 *dstS,
+ LVM_INT16 n );
+
+void From2iToMono_16( const LVM_INT16 *src,
+ LVM_INT16 *dst,
+ LVM_INT16 n);
+
+void JoinTo2i_32x32( const LVM_INT32 *srcL,
+ const LVM_INT32 *srcR,
+ LVM_INT32 *dst,
+ LVM_INT16 n );
+
+/**********************************************************************************
+ DATA TYPE CONVERSION FUNCTIONS
+***********************************************************************************/
+
+void Int16LShiftToInt32_16x32(const LVM_INT16 *src,
+ LVM_INT32 *dst,
+ LVM_INT16 n,
+ LVM_INT16 shift );
+
+void Int32RShiftToInt16_Sat_32x16(const LVM_INT32 *src,
+ LVM_INT16 *dst,
+ LVM_INT16 n,
+ LVM_INT16 shift );
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+/**********************************************************************************/
+
+#endif /* _VECTOR_ARITHMETIC_H_ */
+
+/**********************************************************************************/
diff --git a/media/libeffects/lvm/lib/Common/src/AGC_MIX_VOL_2St1Mon_D32_WRA.c b/media/libeffects/lvm/lib/Common/src/AGC_MIX_VOL_2St1Mon_D32_WRA.c
new file mode 100755
index 0000000..40e0dbf
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/AGC_MIX_VOL_2St1Mon_D32_WRA.c
@@ -0,0 +1,204 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/****************************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1070 $
+ $Date: 2010-07-02 11:22:18 +0200 (Fri, 02 Jul 2010) $
+
+*****************************************************************************************/
+
+/****************************************************************************************/
+/* */
+/* Includes */
+/* */
+/****************************************************************************************/
+
+#include "AGC.h"
+#include "ScalarArithmetic.h"
+
+
+/****************************************************************************************/
+/* */
+/* Defines */
+/* */
+/****************************************************************************************/
+
+#define VOL_TC_SHIFT 21 /* As a power of 2 */
+#define DECAY_SHIFT 10 /* As a power of 2 */
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: AGC_MIX_VOL_2St1Mon_D32_WRA */
+/* */
+/* DESCRIPTION: */
+/* Apply AGC and mix signals */
+/* */
+/* */
+/* StSrc ------------------| */
+/* | */
+/* ______ _|_ ________ */
+/* | | | | | | */
+/* MonoSrc -->| AGC |---->| + |----->| Volume |------------------------------+---> */
+/* | Gain | |___| | Gain | | */
+/* |______| |________| | */
+/* /|\ __________ ________ | */
+/* | | | | | | */
+/* |-------------------------------| AGC Gain |<--| Peak |<--| */
+/* | Update | | Detect | */
+/* |__________| |________| */
+/* */
+/* */
+/* PARAMETERS: */
+/* pInstance Instance pointer */
+/* pStereoIn Stereo source */
+/* pMonoIn Mono band pass source */
+/* pStereoOut Stereo destination */
+/* */
+/* RETURNS: */
+/* Void */
+/* */
+/* NOTES: */
+/* */
+/****************************************************************************************/
+
+void AGC_MIX_VOL_2St1Mon_D32_WRA(AGC_MIX_VOL_2St1Mon_D32_t *pInstance, /* Instance pointer */
+ const LVM_INT32 *pStSrc, /* Stereo source */
+ const LVM_INT32 *pMonoSrc, /* Mono source */
+ LVM_INT32 *pDst, /* Stereo destination */
+ LVM_UINT16 NumSamples) /* Number of samples */
+{
+
+ /*
+ * General variables
+ */
+ LVM_UINT16 i; /* Sample index */
+ LVM_INT32 Left; /* Left sample */
+ LVM_INT32 Right; /* Right sample */
+ LVM_INT32 Mono; /* Mono sample */
+ LVM_INT32 AbsPeak; /* Absolute peak signal */
+ LVM_INT32 HighWord; /* High word in intermediate calculations */
+ LVM_INT32 LowWord; /* Low word in intermediate calculations */
+ LVM_INT16 AGC_Mult; /* Short AGC gain */
+ LVM_INT16 Vol_Mult; /* Short volume */
+
+
+ /*
+ * Instance control variables
+ */
+ LVM_INT32 AGC_Gain = pInstance->AGC_Gain; /* Get the current AGC gain */
+ LVM_INT32 AGC_MaxGain = pInstance->AGC_MaxGain; /* Get maximum AGC gain */
+ LVM_INT16 AGC_GainShift = pInstance->AGC_GainShift; /* Get the AGC shift */
+ LVM_INT16 AGC_Attack = pInstance->AGC_Attack; /* Attack scaler */
+ LVM_INT16 AGC_Decay = pInstance->AGC_Decay; /* Decay scaler */
+ LVM_INT32 AGC_Target = pInstance->AGC_Target; /* Get the target level */
+ LVM_INT32 Vol_Current = pInstance->Volume; /* Actual volume setting */
+ LVM_INT32 Vol_Target = pInstance->Target; /* Target volume setting */
+ LVM_INT16 Vol_Shift = pInstance->VolumeShift; /* Volume shift scaling */
+ LVM_INT16 Vol_TC = pInstance->VolumeTC; /* Time constant */
+
+
+ /*
+ * Process on a sample by sample basis
+ */
+ for (i=0;i<NumSamples;i++) /* For each sample */
+ {
+
+ /*
+ * Get the short scalers
+ */
+ AGC_Mult = (LVM_INT16)(AGC_Gain >> 16); /* Get the short AGC gain */
+ Vol_Mult = (LVM_INT16)(Vol_Current >> 16); /* Get the short volume gain */
+
+
+ /*
+ * Get the input samples
+ */
+ Left = *pStSrc++; /* Get the left sample */
+ Right = *pStSrc++; /* Get the right sample */
+ Mono = *pMonoSrc++; /* Get the mono sample */
+
+
+ /*
+ * Apply the AGC gain to the mono input and mix with the stereo signal
+ */
+ HighWord = (AGC_Mult * (Mono >> 16)); /* signed long (Mono) by unsigned short (AGC_Mult) multiply */
+ LowWord = (AGC_Mult * (Mono & 0xffff));
+ Mono = (HighWord + (LowWord >> 16)) << (AGC_GainShift);
+ Left += Mono; /* Mix in the mono signal */
+ Right += Mono;
+
+
+ /*
+ * Apply the volume and write to the output stream
+ */
+ HighWord = (Vol_Mult * (Left >> 16)); /* signed long (Left) by unsigned short (Vol_Mult) multiply */
+ LowWord = (Vol_Mult * (Left & 0xffff));
+ Left = (HighWord + (LowWord >> 16)) << (Vol_Shift);
+ HighWord = (Vol_Mult * (Right >> 16)); /* signed long (Right) by unsigned short (Vol_Mult) multiply */
+ LowWord = (Vol_Mult * (Right & 0xffff));
+ Right = (HighWord + (LowWord >> 16)) << (Vol_Shift);
+ *pDst++ = Left; /* Save the results */
+ *pDst++ = Right;
+
+
+ /*
+ * Update the AGC gain
+ */
+ AbsPeak = (Abs_32(Left)>Abs_32(Right)) ? Abs_32(Left) : Abs_32(Right); /* Get the absolute peak */
+ if (AbsPeak > AGC_Target)
+ {
+ /*
+ * The signal is too large so decrease the gain
+ */
+ HighWord = (AGC_Attack * (AGC_Gain >> 16)); /* signed long (AGC_Gain) by unsigned short (AGC_Attack) multiply */
+ LowWord = (AGC_Attack * (AGC_Gain & 0xffff));
+ AGC_Gain = (HighWord + (LowWord >> 16)) << 1;
+ }
+ else
+ {
+ /*
+ * The signal is too small so increase the gain
+ */
+ if (AGC_Gain > AGC_MaxGain)
+ {
+ AGC_Gain -= (AGC_Decay << DECAY_SHIFT);
+ }
+ else
+ {
+ AGC_Gain += (AGC_Decay << DECAY_SHIFT);
+ }
+ }
+
+ /*
+ * Update the gain
+ */
+ Vol_Current += Vol_TC * ((Vol_Target - Vol_Current) >> VOL_TC_SHIFT);
+ }
+
+
+ /*
+ * Update the parameters
+ */
+ pInstance->Volume = Vol_Current; /* Actual volume setting */
+ pInstance->AGC_Gain = AGC_Gain;
+
+ return;
+}
+
diff --git a/media/libeffects/lvm/lib/Common/src/Abs_32.c b/media/libeffects/lvm/lib/Common/src/Abs_32.c
new file mode 100755
index 0000000..635315d
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/Abs_32.c
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+/*######################################################################################*/
+/* Include files */
+/*######################################################################################*/
+
+#include "ScalarArithmetic.h"
+
+/****************************************************************************************
+ * Name : Abs_32()
+ * Input : Signed 32-bit integer
+ * Output :
+ * Returns : Absolute value
+ * Description : Absolute value with maximum negative value corner case
+ * Remarks :
+ ****************************************************************************************/
+
+LVM_INT32 Abs_32(LVM_INT32 input)
+{
+ if(input < 0)
+ {
+ if (input == (LVM_INT32)(0x80000000U))
+ {
+ /* The corner case, so set to the maximum positive value */
+ input=(LVM_INT32) 0x7fffffff;
+ }
+ else
+ {
+ /* Negative input, so invert */
+ input = (LVM_INT32)(-input);
+ }
+ }
+ return input;
+}
+
diff --git a/media/libeffects/lvm/lib/Common/src/Add2_Sat_16x16.c b/media/libeffects/lvm/lib/Common/src/Add2_Sat_16x16.c
new file mode 100755
index 0000000..18026c5
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/Add2_Sat_16x16.c
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/**********************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1000 $
+ $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $
+
+***********************************************************************************/
+
+/**********************************************************************************
+ INCLUDE FILES
+***********************************************************************************/
+
+#include "VectorArithmetic.h"
+
+/**********************************************************************************
+ FUNCTION ADD2_SAT_16X16
+***********************************************************************************/
+
+void Add2_Sat_16x16( const LVM_INT16 *src,
+ LVM_INT16 *dst,
+ LVM_INT16 n )
+{
+ LVM_INT32 Temp;
+ LVM_INT16 ii;
+ for (ii = n; ii != 0; ii--)
+ {
+ Temp = ((LVM_INT32) *src) + ((LVM_INT32) *dst);
+ src++;
+
+ if (Temp > 0x00007FFF)
+ {
+ *dst = 0x7FFF;
+ }
+ else if (Temp < -0x00008000)
+ {
+ *dst = - 0x8000;
+ }
+ else
+ {
+ *dst = (LVM_INT16)Temp;
+ }
+ dst++;
+ }
+ return;
+}
+
+/**********************************************************************************/
diff --git a/media/libeffects/lvm/lib/Common/src/Add2_Sat_32x32.c b/media/libeffects/lvm/lib/Common/src/Add2_Sat_32x32.c
new file mode 100755
index 0000000..96fc7e6
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/Add2_Sat_32x32.c
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+/**********************************************************************************
+ INCLUDE FILES
+***********************************************************************************/
+
+#include "VectorArithmetic.h"
+
+
+/**********************************************************************************
+ FUNCTION ADD2_SAT_32X32
+***********************************************************************************/
+
+void Add2_Sat_32x32( const LVM_INT32 *src,
+ LVM_INT32 *dst,
+ LVM_INT16 n )
+{
+ LVM_INT32 a,b,c;
+ LVM_INT16 ii;
+ for (ii = n; ii != 0; ii--)
+ {
+ a=*src;
+ src++;
+
+ b=*dst;
+ c=a+b;
+ if ((((c ^ a) & (c ^ b)) >> 31)!=0) /* overflow / underflow */
+ {
+ if(a<0)
+ {
+ c=0x80000000l;
+ }
+ else
+ {
+ c=0x7FFFFFFFl;
+ }
+ }
+
+ *dst = c;
+ dst++;
+ }
+ return;
+}
+
+/**********************************************************************************/
diff --git a/media/libeffects/lvm/lib/Common/src/BP_1I_D16F16C14_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/BP_1I_D16F16C14_TRC_WRA_01.c
new file mode 100755
index 0000000..76d8e42
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/BP_1I_D16F16C14_TRC_WRA_01.c
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+#include "BIQUAD.h"
+#include "BP_1I_D16F16Css_TRC_WRA_01_Private.h"
+#include "LVM_Macros.h"
+
+
+/**************************************************************************
+ ASSUMPTIONS:
+ COEFS-
+ pBiquadState->coefs[0] is A0,
+ pBiquadState->coefs[1] is -B2,
+ pBiquadState->coefs[2] is -B1, these are in Q14 format
+
+ DELAYS-
+ pBiquadState->pDelays[0] is x(n-1)L in Q0 format
+ pBiquadState->pDelays[1] is x(n-2)L in Q0 format
+ pBiquadState->pDelays[2] is y(n-1)L in Q0 format
+ pBiquadState->pDelays[3] is y(n-2)L in Q0 format
+***************************************************************************/
+
+void BP_1I_D16F16C14_TRC_WRA_01 ( Biquad_Instance_t *pInstance,
+ LVM_INT16 *pDataIn,
+ LVM_INT16 *pDataOut,
+ LVM_INT16 NrSamples)
+
+
+ {
+ LVM_INT32 ynL;
+ LVM_INT16 ii;
+ PFilter_State pBiquadState = (PFilter_State) pInstance;
+
+ for (ii = NrSamples; ii != 0; ii--)
+ {
+
+
+ /**************************************************************************
+ PROCESSING OF THE LEFT CHANNEL
+ ***************************************************************************/
+ // ynL= (A0 (Q14) * (x(n)L (Q0) - x(n-2)L (Q0) ) ) in Q14
+ ynL=(LVM_INT32)pBiquadState->coefs[0]* ((*pDataIn)-pBiquadState->pDelays[1]);
+
+ // ynL+= ((-B2 (Q14) * y(n-2)L (Q0) ) ) in Q14
+ ynL+=(LVM_INT32)pBiquadState->coefs[1]*pBiquadState->pDelays[3];
+
+ // ynL+= ((-B1 (Q30) * y(n-1)L (Q0) ) ) in Q14
+ ynL+=(LVM_INT32)pBiquadState->coefs[2]*pBiquadState->pDelays[2];
+
+ ynL=(LVM_INT16)(ynL>>14); // ynL in Q0
+ /**************************************************************************
+ UPDATING THE DELAYS
+ ***************************************************************************/
+ pBiquadState->pDelays[3]=pBiquadState->pDelays[2]; // y(n-2)L=y(n-1)L
+ pBiquadState->pDelays[1]=pBiquadState->pDelays[0]; // x(n-2)L=x(n-1)L
+ pBiquadState->pDelays[2]=ynL; // Update y(n-1)L in Q0
+ pBiquadState->pDelays[0]=(*pDataIn++); // Update x(n-1)L in Q0
+
+ /**************************************************************************
+ WRITING THE OUTPUT
+ ***************************************************************************/
+ *pDataOut++=(LVM_INT16)ynL; // Write Left output in Q0
+
+ }
+
+ }
+
diff --git a/media/libeffects/lvm/lib/Common/src/BP_1I_D16F16Css_TRC_WRA_01_Init.c b/media/libeffects/lvm/lib/Common/src/BP_1I_D16F16Css_TRC_WRA_01_Init.c
new file mode 100755
index 0000000..9338eb2
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/BP_1I_D16F16Css_TRC_WRA_01_Init.c
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/* */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/*-------------------------------------------------------------------------*/
+#include "BIQUAD.h"
+#include "BP_1I_D16F16Css_TRC_WRA_01_Private.h"
+
+
+/*-------------------------------------------------------------------------*/
+/* FUNCTION: */
+/* BP_1I_D16F16Css_TRC_WRA_01_Init */
+/* */
+/* DESCRIPTION: */
+/* These functions initializes a BIQUAD filter defined as a cascade of */
+/* biquadratic Filter Sections. */
+/* */
+/* PARAMETERS: */
+/* pInstance - output, returns the pointer to the State Variable */
+/* This state pointer must be passed to any subsequent */
+/* call to "Biquad" functions. */
+/* pTaps - input, pointer to the taps memory */
+/* pCoef - input, pointer to the coefficient structure */
+/* N - M coefficient factor of QM.N */
+/* RETURNS: */
+/* void return code */
+/*-------------------------------------------------------------------------*/
+void BP_1I_D16F16Css_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance,
+ Biquad_1I_Order2_Taps_t *pTaps,
+ BP_C16_Coefs_t *pCoef)
+{
+ PFilter_State pBiquadState = (PFilter_State) pInstance;
+ pBiquadState->pDelays =(LVM_INT32 *) pTaps;
+
+ pBiquadState->coefs[0]=pCoef->A0;
+ pBiquadState->coefs[1]=pCoef->B2;
+ pBiquadState->coefs[2]=pCoef->B1;
+ }
+/*-------------------------------------------------------------------------*/
+/* End Of File: BP_1I_D16F16Css_TRC_WRA_01_Init.c */
+
diff --git a/media/libeffects/lvm/lib/Common/src/BP_1I_D16F16Css_TRC_WRA_01_Private.h b/media/libeffects/lvm/lib/Common/src/BP_1I_D16F16Css_TRC_WRA_01_Private.h
new file mode 100755
index 0000000..2a0d7d5
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/BP_1I_D16F16Css_TRC_WRA_01_Private.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+#ifndef _BP_1I_D16F16CSS_TRC_WRA_01_PRIVATE_H_
+#define _BP_1I_D16F16CSS_TRC_WRA_01_PRIVATE_H_
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+/* The internal state variables are implemented in a (for the user) hidden structure */
+/* In this (private) file, the internal structure is declared fro private use. */
+typedef struct _Filter_State_
+{
+ LVM_INT32 * pDelays; /* pointer to the delayed samples (data of 32 bits) */
+ LVM_INT32 coefs[3]; /* pointer to the filter coefficients */
+}Filter_State;
+
+typedef Filter_State * PFilter_State ;
+
+#endif /*_BP_1I_D16F16CSS_TRC_WRA_01_PRIVATE_H_*/
diff --git a/media/libeffects/lvm/lib/Common/src/BP_1I_D16F32C30_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/BP_1I_D16F32C30_TRC_WRA_01.c
new file mode 100755
index 0000000..f52d3db
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/BP_1I_D16F32C30_TRC_WRA_01.c
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+#include "BIQUAD.h"
+#include "BP_1I_D16F32Cll_TRC_WRA_01_Private.h"
+#include "LVM_Macros.h"
+
+
+/**************************************************************************
+ ASSUMPTIONS:
+ COEFS-
+ pBiquadState->coefs[0] is A0,
+ pBiquadState->coefs[1] is -B2,
+ pBiquadState->coefs[2] is -B1, these are in Q30 format
+
+ DELAYS-
+ pBiquadState->pDelays[0] is x(n-1)L in Q0 format
+ pBiquadState->pDelays[1] is x(n-2)L in Q0 format
+ pBiquadState->pDelays[2] is y(n-1)L in Q16 format
+ pBiquadState->pDelays[3] is y(n-2)L in Q16 format
+***************************************************************************/
+
+void BP_1I_D16F32C30_TRC_WRA_01 ( Biquad_Instance_t *pInstance,
+ LVM_INT16 *pDataIn,
+ LVM_INT16 *pDataOut,
+ LVM_INT16 NrSamples)
+
+
+ {
+ LVM_INT32 ynL,templ;
+ LVM_INT16 ii;
+ PFilter_State pBiquadState = (PFilter_State) pInstance;
+
+ for (ii = NrSamples; ii != 0; ii--)
+ {
+
+
+ /**************************************************************************
+ PROCESSING OF THE LEFT CHANNEL
+ ***************************************************************************/
+ // ynL= (A0 (Q30) * (x(n)L (Q0) - x(n-2)L (Q0) ) >>14) in Q16
+ templ= (LVM_INT32) *pDataIn-pBiquadState->pDelays[1];
+ MUL32x32INTO32(pBiquadState->coefs[0],templ,ynL,14)
+
+ // ynL+= ((-B2 (Q30) * y(n-2)L (Q16) ) >>30) in Q16
+ MUL32x32INTO32(pBiquadState->coefs[1],pBiquadState->pDelays[3],templ,30)
+ ynL+=templ;
+
+ // ynL+= ((-B1 (Q30) * y(n-1)L (Q16) ) >>30) in Q16
+ MUL32x32INTO32(pBiquadState->coefs[2],pBiquadState->pDelays[2],templ,30)
+ ynL+=templ;
+
+ /**************************************************************************
+ UPDATING THE DELAYS
+ ***************************************************************************/
+ pBiquadState->pDelays[3]=pBiquadState->pDelays[2]; // y(n-2)L=y(n-1)L
+ pBiquadState->pDelays[1]=pBiquadState->pDelays[0]; // x(n-2)L=x(n-1)L
+ pBiquadState->pDelays[2]=ynL; // Update y(n-1)L in Q16
+ pBiquadState->pDelays[0]=(*pDataIn++); // Update x(n-1)L in Q0
+
+ /**************************************************************************
+ WRITING THE OUTPUT
+ ***************************************************************************/
+ *pDataOut++=(LVM_INT16)(ynL>>16); // Write Left output in Q0
+
+ }
+
+ }
+
diff --git a/media/libeffects/lvm/lib/Common/src/BP_1I_D16F32Cll_TRC_WRA_01_Init.c b/media/libeffects/lvm/lib/Common/src/BP_1I_D16F32Cll_TRC_WRA_01_Init.c
new file mode 100755
index 0000000..c560085
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/BP_1I_D16F32Cll_TRC_WRA_01_Init.c
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/* */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/*-------------------------------------------------------------------------*/
+#include "BIQUAD.h"
+#include "BP_1I_D16F32Cll_TRC_WRA_01_Private.h"
+
+
+/*-------------------------------------------------------------------------*/
+/* FUNCTION: */
+/* BP_1I_D16F32Cll_TRC_WRA_01_Init */
+/* */
+/* DESCRIPTION: */
+/* These functions initializes a Band pass filter (BIQUAD) */
+/* biquadratic Filter Sections. */
+/* */
+/* PARAMETERS: */
+/* pInstance - output, returns the pointer to the State Variable */
+/* This state pointer must be passed to any subsequent */
+/* call to "Biquad" functions. */
+/* pTaps - input, pointer to the taps memory */
+/* pCoef - input, pointer to the coefficient structure */
+/* N - M coefficient factor of QM.N */
+/* */
+/* The coefficients are modified in the init() function such that lower */
+/* half word is right shifted by one and most significant bit of the lower */
+/* word is made to be zero. */
+/* */
+/* Reason: For MIPS effciency,we are using DSP 32*16 multiplication */
+/* instruction. But we have 32*32 multiplication. This can be realized by two 32*16 */
+/* multiplication. But 16th bit in the 32 bit word is not a sign bit. So this is done */
+/* by putting 16th bit to zero and lossing one bit precision by division of lower */
+/* half word by 2. */
+/* RETURNS: */
+/* void return code */
+/*-------------------------------------------------------------------------*/
+void BP_1I_D16F32Cll_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance,
+ Biquad_1I_Order2_Taps_t *pTaps,
+ BP_C32_Coefs_t *pCoef)
+{
+ PFilter_State pBiquadState = (PFilter_State) pInstance;
+ pBiquadState->pDelays =(LVM_INT32 *) pTaps;
+
+ pBiquadState->coefs[0] = pCoef->A0;
+ pBiquadState->coefs[1] = pCoef->B2;
+ pBiquadState->coefs[2] = pCoef->B1;
+}
+/*-------------------------------------------------------------------------*/
+/* End Of File: BP_1I_D16F32Cll_TRC_WRA_01_Init.c */
+
diff --git a/media/libeffects/lvm/lib/Common/src/BP_1I_D16F32Cll_TRC_WRA_01_Private.h b/media/libeffects/lvm/lib/Common/src/BP_1I_D16F32Cll_TRC_WRA_01_Private.h
new file mode 100755
index 0000000..76777f6e
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/BP_1I_D16F32Cll_TRC_WRA_01_Private.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+#ifndef _BP_1I_D16F32CLL_TRC_WRA_01_PRIVATE_H_
+#define _BP_1I_D16F32CLL_TRC_WRA_01_PRIVATE_H_
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+/* The internal state variables are implemented in a (for the user) hidden structure */
+/* In this (private) file, the internal structure is declared fro private use. */
+typedef struct _Filter_State_
+{
+ LVM_INT32 * pDelays; /* pointer to the delayed samples (data of 32 bits) */
+ LVM_INT32 coefs[3]; /* pointer to the filter coefficients */
+}Filter_State;
+
+typedef Filter_State * PFilter_State ;
+
+#endif /*_BP_1I_D16F32CLL_TRC_WRA_01_PRIVATE_H_*/
diff --git a/media/libeffects/lvm/lib/Common/src/BP_1I_D32F32C30_TRC_WRA_02.c b/media/libeffects/lvm/lib/Common/src/BP_1I_D32F32C30_TRC_WRA_02.c
new file mode 100755
index 0000000..2b3555f
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/BP_1I_D32F32C30_TRC_WRA_02.c
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+#include "BIQUAD.h"
+#include "BP_1I_D32F32Cll_TRC_WRA_02_Private.h"
+#include "LVM_Macros.h"
+
+
+/**************************************************************************
+ ASSUMPTIONS:
+ COEFS-
+ pBiquadState->coefs[0] is A0,
+ pBiquadState->coefs[1] is -B2,
+ pBiquadState->coefs[2] is -B1, these are in Q30 format
+
+ DELAYS-
+ pBiquadState->pDelays[0] is x(n-1)L in Q0 format
+ pBiquadState->pDelays[1] is x(n-2)L in Q0 format
+ pBiquadState->pDelays[2] is y(n-1)L in Q0 format
+ pBiquadState->pDelays[3] is y(n-2)L in Q0 format
+***************************************************************************/
+
+void BP_1I_D32F32C30_TRC_WRA_02 ( Biquad_Instance_t *pInstance,
+ LVM_INT32 *pDataIn,
+ LVM_INT32 *pDataOut,
+ LVM_INT16 NrSamples)
+ {
+ LVM_INT32 ynL,templ;
+ LVM_INT16 ii;
+ PFilter_State pBiquadState = (PFilter_State) pInstance;
+
+ for (ii = NrSamples; ii != 0; ii--)
+ {
+
+
+ /**************************************************************************
+ PROCESSING OF THE LEFT CHANNEL
+ ***************************************************************************/
+ // ynL= (A0 (Q30) * (x(n)L (Q0) - x(n-2)L (Q0) ) >>30) in Q0
+ templ=(*pDataIn)-pBiquadState->pDelays[1];
+ MUL32x32INTO32(pBiquadState->coefs[0],templ,ynL,30)
+
+ // ynL+= ((-B2 (Q30) * y(n-2)L (Q0) ) >>30) in Q0
+ MUL32x32INTO32(pBiquadState->coefs[1],pBiquadState->pDelays[3],templ,30)
+ ynL+=templ;
+
+ // ynL+= ((-B1 (Q30) * y(n-1)L (Q0) ) >>30) in Q0
+ MUL32x32INTO32(pBiquadState->coefs[2],pBiquadState->pDelays[2],templ,30)
+ ynL+=templ;
+
+ /**************************************************************************
+ UPDATING THE DELAYS
+ ***************************************************************************/
+ pBiquadState->pDelays[3]=pBiquadState->pDelays[2]; // y(n-2)L=y(n-1)L
+ pBiquadState->pDelays[1]=pBiquadState->pDelays[0]; // x(n-2)L=x(n-1)L
+ pBiquadState->pDelays[2]=ynL; // Update y(n-1)L in Q0
+ pBiquadState->pDelays[0]=(*pDataIn++); // Update x(n-1)L in Q0
+
+ /**************************************************************************
+ WRITING THE OUTPUT
+ ***************************************************************************/
+ *pDataOut++=ynL; // Write Left output in Q0
+
+ }
+
+ }
+
diff --git a/media/libeffects/lvm/lib/Common/src/BP_1I_D32F32Cll_TRC_WRA_02_Init.c b/media/libeffects/lvm/lib/Common/src/BP_1I_D32F32Cll_TRC_WRA_02_Init.c
new file mode 100755
index 0000000..f3f4571
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/BP_1I_D32F32Cll_TRC_WRA_02_Init.c
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/* */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/*-------------------------------------------------------------------------*/
+#include "BIQUAD.h"
+#include "BP_1I_D32F32Cll_TRC_WRA_02_Private.h"
+
+/*-------------------------------------------------------------------------*/
+/* FUNCTION: */
+/* BP_1I_D32F32Cll_TRC_WRA_02_Init */
+/* */
+/* DESCRIPTION: */
+/* These functions initializes a BIQUAD filter defined as a cascade of */
+/* biquadratic Filter Sections. */
+/* */
+/* PARAMETERS: */
+/* pInstance - output, returns the pointer to the State Variable */
+/* This state pointer must be passed to any subsequent */
+/* call to "Biquad" functions. */
+/* pTaps - input, pointer to the taps memory */
+/* pCoef - input, pointer to the coefficient structure */
+/* N - M coefficient factor of QM.N */
+/* RETURNS: */
+/* void return code */
+/*-------------------------------------------------------------------------*/
+void BP_1I_D32F32Cll_TRC_WRA_02_Init ( Biquad_Instance_t *pInstance,
+ Biquad_1I_Order2_Taps_t *pTaps,
+ BP_C32_Coefs_t *pCoef)
+{
+ PFilter_State pBiquadState = (PFilter_State) pInstance;
+ pBiquadState->pDelays =(LVM_INT32 *) pTaps;
+
+ pBiquadState->coefs[0]=pCoef->A0;
+
+ pBiquadState->coefs[1]=pCoef->B2;
+
+ pBiquadState->coefs[2]=pCoef->B1;
+}
+/*-------------------------------------------------------------------------*/
+/* End Of File: BP_1I_D32F32Cll_TRC_WRA_02_Init.c */
+
diff --git a/media/libeffects/lvm/lib/Common/src/BP_1I_D32F32Cll_TRC_WRA_02_Private.h b/media/libeffects/lvm/lib/Common/src/BP_1I_D32F32Cll_TRC_WRA_02_Private.h
new file mode 100755
index 0000000..8884537
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/BP_1I_D32F32Cll_TRC_WRA_02_Private.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+#ifndef _BP_1I_D32F32CLL_TRC_WRA_02_PRIVATE_H_
+#define _BP_1I_D32F32CLL_TRC_WRA_02_PRIVATE_H_
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+/* The internal state variables are implemented in a (for the user) hidden structure */
+/* In this (private) file, the internal structure is declared fro private use. */
+typedef struct _Filter_State_
+{
+ LVM_INT32 * pDelays; /* pointer to the delayed samples (data of 32 bits) */
+ LVM_INT32 coefs[3]; /* pointer to the filter coefficients */
+}Filter_State;
+
+typedef Filter_State * PFilter_State ;
+
+#endif /*_BP_1I_D32F32CLL_TRC_WRA_02_PRIVATE_H_*/
diff --git a/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F16C15_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F16C15_TRC_WRA_01.c
new file mode 100755
index 0000000..00e3b52
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F16C15_TRC_WRA_01.c
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+#include "BIQUAD.h"
+#include "BQ_1I_D16F16Css_TRC_WRA_01_Private.h"
+#include "LVM_Macros.h"
+
+/**************************************************************************
+ ASSUMPTIONS:
+ COEFS-
+ pBiquadState->coefs[0] is A2, pBiquadState->coefs[1] is A1
+ pBiquadState->coefs[2] is A0, pBiquadState->coefs[3] is -B2
+ pBiquadState->coefs[4] is -B1, these are in Q15 format
+
+ DELAYS-
+ pBiquadState->pDelays[0] is x(n-1)L in Q0 format
+ pBiquadState->pDelays[1] is x(n-2)L in Q0 format
+ pBiquadState->pDelays[2] is y(n-1)L in Q0 format
+ pBiquadState->pDelays[3] is y(n-2)L in Q0 format
+***************************************************************************/
+
+void BQ_1I_D16F16C15_TRC_WRA_01 ( Biquad_Instance_t *pInstance,
+ LVM_INT16 *pDataIn,
+ LVM_INT16 *pDataOut,
+ LVM_INT16 NrSamples)
+ {
+ LVM_INT32 ynL;
+ LVM_INT16 ii;
+ PFilter_State pBiquadState = (PFilter_State) pInstance;
+
+ for (ii = NrSamples; ii != 0; ii--)
+ {
+
+
+ /**************************************************************************
+ PROCESSING OF THE LEFT CHANNEL
+ ***************************************************************************/
+ // ynL=A2 (Q15) * x(n-2)L (Q0) in Q15
+ ynL=(LVM_INT32)pBiquadState->coefs[0]* pBiquadState->pDelays[1];
+
+ // ynL+=A1 (Q15) * x(n-1)L (Q0) in Q15
+ ynL+=(LVM_INT32)pBiquadState->coefs[1]* pBiquadState->pDelays[0];
+
+ // ynL+=A0 (Q15) * x(n)L (Q0) in Q15
+ ynL+=(LVM_INT32)pBiquadState->coefs[2]* (*pDataIn);
+
+ // ynL+= (-B2 (Q15) * y(n-2)L (Q0) ) in Q15
+ ynL+=(LVM_INT32)pBiquadState->coefs[3]*pBiquadState->pDelays[3];
+
+ // ynL+= (-B1 (Q15) * y(n-1)L (Q0) ) in Q15
+ ynL+=(LVM_INT32)pBiquadState->coefs[4]*pBiquadState->pDelays[2];
+
+ ynL=ynL>>15; // ynL in Q0 format
+ /**************************************************************************
+ UPDATING THE DELAYS
+ ***************************************************************************/
+ pBiquadState->pDelays[3]=pBiquadState->pDelays[2]; // y(n-2)L=y(n-1)L
+ pBiquadState->pDelays[1]=pBiquadState->pDelays[0]; // x(n-2)L=x(n-1)L
+ pBiquadState->pDelays[2]=ynL; // Update y(n-1)L in Q0
+ pBiquadState->pDelays[0]=(*pDataIn++); // Update x(n-1)L in Q0
+
+ /**************************************************************************
+ WRITING THE OUTPUT
+ ***************************************************************************/
+ *pDataOut++=(LVM_INT16)ynL; // Write Left output in Q0
+
+
+ }
+
+ }
+
diff --git a/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F16Css_TRC_WRA_01_Init.c b/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F16Css_TRC_WRA_01_Init.c
new file mode 100755
index 0000000..3fedc45
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F16Css_TRC_WRA_01_Init.c
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/* */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/*-------------------------------------------------------------------------*/
+#include "BIQUAD.h"
+#include "BQ_1I_D16F16Css_TRC_WRA_01_Private.h"
+
+/*-------------------------------------------------------------------------*/
+/* FUNCTION: */
+/* BQ_1I_D16F16Css_TRC_WRA_01_Init */
+/* */
+/* DESCRIPTION: */
+/* These functions initializes a BIQUAD filter defined as a cascade of */
+/* biquadratic Filter Sections. */
+/* */
+/* PARAMETERS: */
+/* pInstance - output, returns the pointer to the State Variable */
+/* This state pointer must be passed to any subsequent */
+/* call to "Biquad" functions. */
+/* pTaps - input, pointer to the taps memory */
+/* pCoef - input, pointer to the coefficient structure */
+/* N - M coefficient factor of QM.N */
+/* RETURNS: */
+/* void return code */
+/*-------------------------------------------------------------------------*/
+void BQ_1I_D16F16Css_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance,
+ Biquad_1I_Order2_Taps_t *pTaps,
+ BQ_C16_Coefs_t *pCoef)
+{
+ LVM_INT16 temp;
+ PFilter_State pBiquadState = (PFilter_State) pInstance;
+ pBiquadState->pDelays =(LVM_INT32 *) pTaps ;
+
+ temp=pCoef->A2;
+ pBiquadState->coefs[0]=temp;
+ temp=pCoef->A1;
+ pBiquadState->coefs[1]=temp;
+ temp=pCoef->A0;
+ pBiquadState->coefs[2]=temp;
+ temp=pCoef->B2;
+ pBiquadState->coefs[3]=temp;
+ temp=pCoef->B1;
+ pBiquadState->coefs[4]=temp;
+}
+/*-------------------------------------------------------------------------*/
+/* End Of File: BQ_1I_D16F16Css_TRC_WRA_01_Init.c */
+
diff --git a/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F16Css_TRC_WRA_01_Private.h b/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F16Css_TRC_WRA_01_Private.h
new file mode 100755
index 0000000..18dacd3
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F16Css_TRC_WRA_01_Private.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+#ifndef _BQ_1I_D16F16CSS_TRC_WRA_01_PRIVATE_H_
+#define _BQ_1I_D16F16CSS_TRC_WRA_01_PRIVATE_H_
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+/* The internal state variables are implemented in a (for the user) hidden structure */
+/* In this (private) file, the internal structure is declared fro private use. */
+typedef struct _Filter_State_
+{
+ LVM_INT32 * pDelays; /* pointer to the delayed samples (data of 32 bits) */
+ LVM_INT16 coefs[5]; /* pointer to the filter coefficients */
+}Filter_State;
+
+typedef Filter_State * PFilter_State ;
+
+#endif /*_BQ_1I_D16F16CSS_TRC_WRA_01_PRIVATE_H_ */
diff --git a/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F32C14_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F32C14_TRC_WRA_01.c
new file mode 100755
index 0000000..cdff1d9
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F32C14_TRC_WRA_01.c
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+#include "BIQUAD.h"
+#include "BQ_1I_D16F32Css_TRC_WRA_01_Private.h"
+#include "LVM_Macros.h"
+
+/**************************************************************************
+ ASSUMPTIONS:
+ COEFS-
+ pBiquadState->coefs[0] is A2, pBiquadState->coefs[1] is A1
+ pBiquadState->coefs[2] is A0, pBiquadState->coefs[3] is -B2
+ pBiquadState->coefs[4] is -B1, these are in Q14 format
+
+ DELAYS-
+ pBiquadState->pDelays[0] is x(n-1)L in Q0 format
+ pBiquadState->pDelays[1] is x(n-2)L in Q0 format
+ pBiquadState->pDelays[2] is y(n-1)L in Q16 format
+ pBiquadState->pDelays[3] is y(n-2)L in Q16 format
+***************************************************************************/
+
+void BQ_1I_D16F32C14_TRC_WRA_01 ( Biquad_Instance_t *pInstance,
+ LVM_INT16 *pDataIn,
+ LVM_INT16 *pDataOut,
+ LVM_INT16 NrSamples)
+ {
+ LVM_INT32 ynL,templ;
+ LVM_INT16 ii;
+ PFilter_State pBiquadState = (PFilter_State) pInstance;
+
+ for (ii = NrSamples; ii != 0; ii--)
+ {
+
+
+ /**************************************************************************
+ PROCESSING OF THE LEFT CHANNEL
+ ***************************************************************************/
+ // ynL=A2 (Q14) * x(n-2)L (Q0) in Q14
+ ynL=(LVM_INT32)pBiquadState->coefs[0]* pBiquadState->pDelays[1];
+
+ // ynL+=A1 (Q14) * x(n-1)L (Q0) in Q14
+ ynL+=(LVM_INT32)pBiquadState->coefs[1]* pBiquadState->pDelays[0];
+
+ // ynL+=A0 (Q14) * x(n)L (Q0) in Q14
+ ynL+=(LVM_INT32)pBiquadState->coefs[2]* (*pDataIn);
+
+ // ynL+= ( (-B2 (Q14) * y(n-2)L (Q16) )>>16) in Q14
+ MUL32x16INTO32(pBiquadState->pDelays[3],pBiquadState->coefs[3],templ,16)
+ ynL+=templ;
+
+ // ynL+= ( (-B1 (Q14) * y(n-1)L (Q16) )>>16) in Q14
+ MUL32x16INTO32(pBiquadState->pDelays[2],pBiquadState->coefs[4],templ,16)
+ ynL+=templ;
+
+ /**************************************************************************
+ UPDATING THE DELAYS
+ ***************************************************************************/
+ pBiquadState->pDelays[3]=pBiquadState->pDelays[2]; // y(n-2)L=y(n-1)L
+ pBiquadState->pDelays[1]=pBiquadState->pDelays[0]; // x(n-2)L=x(n-1)L
+ pBiquadState->pDelays[2]=ynL<<2; // Update y(n-1)L in Q16
+ pBiquadState->pDelays[0]=(*pDataIn++); // Update x(n-1)L in Q0
+
+ /**************************************************************************
+ WRITING THE OUTPUT
+ ***************************************************************************/
+ *pDataOut++=(LVM_INT16)(ynL>>14); // Write Left output in Q0
+
+ }
+ }
+
diff --git a/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F32Css_TRC_WRA_01_Private.h b/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F32Css_TRC_WRA_01_Private.h
new file mode 100755
index 0000000..bc88847
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F32Css_TRC_WRA_01_Private.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+#ifndef _BQ_1I_D16F32CSS_TRC_WRA_01_PRIVATE_H_
+#define _BQ_1I_D16F32CSS_TRC_WRA_01_PRIVATE_H_
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+/* The internal state variables are implemented in a (for the user) hidden structure */
+/* In this (private) file, the internal structure is declared fro private use. */
+typedef struct _Filter_State_
+{
+ LVM_INT32 * pDelays; /* pointer to the delayed samples (data of 32 bits) */
+ LVM_INT16 coefs[5]; /* pointer to the filter coefficients */
+}Filter_State;
+
+typedef Filter_State * PFilter_State ;
+
+#endif /*_BQ_1I_D16F32CSS_TRC_WRA_01_PRIVATE_H_*/
diff --git a/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F32Css_TRC_WRA_01_init.c b/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F32Css_TRC_WRA_01_init.c
new file mode 100755
index 0000000..520c969
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F32Css_TRC_WRA_01_init.c
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/* */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/*-------------------------------------------------------------------------*/
+#include "BIQUAD.h"
+#include "BQ_1I_D16F32Css_TRC_WRA_01_Private.h"
+
+
+/*-------------------------------------------------------------------------*/
+/* FUNCTION: */
+/* BQ_1I_D16F32Css_TRC_WRA_01_Init */
+/* */
+/* DESCRIPTION: */
+/* These functions initializes a BIQUAD filter defined as a cascade of */
+/* biquadratic Filter Sections. */
+/* */
+/* PARAMETERS: */
+/* pInstance - output, returns the pointer to the State Variable */
+/* This state pointer must be passed to any subsequent */
+/* call to "Biquad" functions. */
+/* pTaps - input, pointer to the taps memory */
+/* pCoef - input, pointer to the coefficient structure */
+/* N - M coefficient factor of QM.N */
+/* RETURNS: */
+/* void return code */
+/*-------------------------------------------------------------------------*/
+void BQ_1I_D16F32Css_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance,
+ Biquad_1I_Order2_Taps_t *pTaps,
+ BQ_C16_Coefs_t *pCoef)
+{
+ LVM_INT16 temp;
+ PFilter_State pBiquadState = (PFilter_State) pInstance;
+ pBiquadState->pDelays =(LVM_INT32 *) pTaps ;
+
+ temp=pCoef->A2;
+ pBiquadState->coefs[0]=temp;
+ temp=pCoef->A1;
+ pBiquadState->coefs[1]=temp;
+ temp=pCoef->A0;
+ pBiquadState->coefs[2]=temp;
+ temp=pCoef->B2;
+ pBiquadState->coefs[3]=temp;
+ temp=pCoef->B1;
+ pBiquadState->coefs[4]=temp;
+}
+/*-------------------------------------------------------------------------*/
+/* End Of File: BQ_1I_D16F32Css_TRC_WRA_01_Init */
+
diff --git a/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F16C14_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F16C14_TRC_WRA_01.c
new file mode 100755
index 0000000..c267a90
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F16C14_TRC_WRA_01.c
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+#include "BIQUAD.h"
+#include "BQ_2I_D16F16Css_TRC_WRA_01_Private.h"
+#include "LVM_Macros.h"
+
+
+/**************************************************************************
+ ASSUMPTIONS:
+ COEFS-
+ pBiquadState->coefs[0] is A2, pBiquadState->coefs[1] is A1
+ pBiquadState->coefs[2] is A0, pBiquadState->coefs[3] is -B2
+ pBiquadState->coefs[4] is -B1, these are in Q14 format
+
+ DELAYS-
+ pBiquadState->pDelays[0] is x(n-1)L in Q0 format
+ pBiquadState->pDelays[1] is x(n-1)R in Q0 format
+ pBiquadState->pDelays[2] is x(n-2)L in Q0 format
+ pBiquadState->pDelays[3] is x(n-2)R in Q0 format
+ pBiquadState->pDelays[4] is y(n-1)L in Q0 format
+ pBiquadState->pDelays[5] is y(n-1)R in Q0 format
+ pBiquadState->pDelays[6] is y(n-2)L in Q0 format
+ pBiquadState->pDelays[7] is y(n-2)R in Q0 format
+***************************************************************************/
+
+void BQ_2I_D16F16C14_TRC_WRA_01 ( Biquad_Instance_t *pInstance,
+ LVM_INT16 *pDataIn,
+ LVM_INT16 *pDataOut,
+ LVM_INT16 NrSamples)
+ {
+ LVM_INT32 ynL,ynR;
+ LVM_INT16 ii;
+ PFilter_State pBiquadState = (PFilter_State) pInstance;
+
+ for (ii = NrSamples; ii != 0; ii--)
+ {
+
+ /**************************************************************************
+ PROCESSING OF THE LEFT CHANNEL
+ ***************************************************************************/
+ // ynL=A2 (Q14) * x(n-2)L (Q0) in Q14
+ ynL=(LVM_INT32)pBiquadState->coefs[0]* pBiquadState->pDelays[2];
+
+ // ynL+=A1 (Q14) * x(n-1)L (Q0) in Q14
+ ynL+=(LVM_INT32)pBiquadState->coefs[1]* pBiquadState->pDelays[0];
+
+ // ynL+=A0 (Q14) * x(n)L (Q0) in Q14
+ ynL+=(LVM_INT32)pBiquadState->coefs[2]* (*pDataIn);
+
+ // ynL+= ( -B2 (Q14) * y(n-2)L (Q0) ) in Q14
+ ynL+=(LVM_INT32)pBiquadState->coefs[3]*pBiquadState->pDelays[6];
+
+ // ynL+=( -B1 (Q14) * y(n-1)L (Q0) ) in Q14
+ ynL+=(LVM_INT32)pBiquadState->coefs[4]*pBiquadState->pDelays[4];
+
+ ynL=ynL>>14; // ynL in Q0 format
+
+ /**************************************************************************
+ PROCESSING OF THE RIGHT CHANNEL
+ ***************************************************************************/
+ // ynR=A2 (Q14) * x(n-2)R (Q0) in Q14
+ ynR=(LVM_INT32)pBiquadState->coefs[0]*pBiquadState->pDelays[3];
+
+ // ynR+=A1 (Q14) * x(n-1)R (Q0) in Q14
+ ynR+=(LVM_INT32)pBiquadState->coefs[1]*pBiquadState->pDelays[1];
+
+ // ynR+=A0 (Q14) * x(n)R (Q0) in Q14
+ ynR+=(LVM_INT32)pBiquadState->coefs[2]*(*(pDataIn+1));
+
+ // ynR+= ( -B2 (Q14) * y(n-2)R (Q0) ) in Q14
+ ynR+=(LVM_INT32)pBiquadState->coefs[3]*pBiquadState->pDelays[7];
+
+ // ynR+=( -B1 (Q14) * y(n-1)R (Q0) ) in Q14
+ ynR+=(LVM_INT32)pBiquadState->coefs[4]*pBiquadState->pDelays[5];
+
+ ynR=ynR>>14; // ynL in Q0 format
+ /**************************************************************************
+ UPDATING THE DELAYS
+ ***************************************************************************/
+ pBiquadState->pDelays[7]=pBiquadState->pDelays[5]; // y(n-2)R=y(n-1)R
+ pBiquadState->pDelays[6]=pBiquadState->pDelays[4]; // y(n-2)L=y(n-1)L
+ pBiquadState->pDelays[3]=pBiquadState->pDelays[1]; // x(n-2)R=x(n-1)R
+ pBiquadState->pDelays[2]=pBiquadState->pDelays[0]; // x(n-2)L=x(n-1)L
+ pBiquadState->pDelays[5]=ynR; // Update y(n-1)R in Q0
+ pBiquadState->pDelays[4]=ynL; // Update y(n-1)L in Q0
+ pBiquadState->pDelays[0]=(*pDataIn++); // Update x(n-1)L in Q0
+ pBiquadState->pDelays[1]=(*pDataIn++); // Update x(n-1)R in Q0
+
+ /**************************************************************************
+ WRITING THE OUTPUT
+ ***************************************************************************/
+ *pDataOut++=(LVM_INT16)ynL; // Write Left output in Q0
+ *pDataOut++=(LVM_INT16)ynR; // Write Right ouput in Q0
+
+
+ }
+
+ }
+
diff --git a/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F16C15_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F16C15_TRC_WRA_01.c
new file mode 100755
index 0000000..ded2bb3
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F16C15_TRC_WRA_01.c
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+#include "BIQUAD.h"
+#include "BQ_2I_D16F16Css_TRC_WRA_01_Private.h"
+#include "LVM_Macros.h"
+
+
+/**************************************************************************
+ ASSUMPTIONS:
+ COEFS-
+ pBiquadState->coefs[0] is A2, pBiquadState->coefs[1] is A1
+ pBiquadState->coefs[2] is A0, pBiquadState->coefs[3] is -B2
+ pBiquadState->coefs[4] is -B1, these are in Q15 format
+
+ DELAYS-
+ pBiquadState->pDelays[0] is x(n-1)L in Q0 format
+ pBiquadState->pDelays[1] is x(n-1)R in Q0 format
+ pBiquadState->pDelays[2] is x(n-2)L in Q0 format
+ pBiquadState->pDelays[3] is x(n-2)R in Q0 format
+ pBiquadState->pDelays[4] is y(n-1)L in Q0 format
+ pBiquadState->pDelays[5] is y(n-1)R in Q0 format
+ pBiquadState->pDelays[6] is y(n-2)L in Q0 format
+ pBiquadState->pDelays[7] is y(n-2)R in Q0 format
+***************************************************************************/
+
+void BQ_2I_D16F16C15_TRC_WRA_01 ( Biquad_Instance_t *pInstance,
+ LVM_INT16 *pDataIn,
+ LVM_INT16 *pDataOut,
+ LVM_INT16 NrSamples)
+ {
+ LVM_INT32 ynL,ynR;
+ LVM_INT16 ii;
+ PFilter_State pBiquadState = (PFilter_State) pInstance;
+
+ for (ii = NrSamples; ii != 0; ii--)
+ {
+
+
+ /**************************************************************************
+ PROCESSING OF THE LEFT CHANNEL
+ ***************************************************************************/
+ // ynL=A2 (Q15) * x(n-2)L (Q0) in Q15
+ ynL=(LVM_INT32)pBiquadState->coefs[0]* pBiquadState->pDelays[2];
+
+ // ynL+=A1 (Q15) * x(n-1)L (Q0) in Q15
+ ynL+=(LVM_INT32)pBiquadState->coefs[1]* pBiquadState->pDelays[0];
+
+ // ynL+=A0 (Q15) * x(n)L (Q0) in Q15
+ ynL+=(LVM_INT32)pBiquadState->coefs[2]* (*pDataIn);
+
+ // ynL+= ( -B2 (Q15) * y(n-2)L (Q0) ) in Q15
+ ynL+=(LVM_INT32)pBiquadState->coefs[3]*pBiquadState->pDelays[6];
+
+ // ynL+=( -B1 (Q15) * y(n-1)L (Q0) ) in Q15
+ ynL+=(LVM_INT32)pBiquadState->coefs[4]*pBiquadState->pDelays[4];
+
+ ynL=ynL>>15; // ynL in Q0 format
+
+ /**************************************************************************
+ PROCESSING OF THE RIGHT CHANNEL
+ ***************************************************************************/
+ // ynR=A2 (Q15) * x(n-2)R (Q0) in Q15
+ ynR=(LVM_INT32)pBiquadState->coefs[0]*pBiquadState->pDelays[3];
+
+ // ynR+=A1 (Q15) * x(n-1)R (Q0) in Q15
+ ynR+=(LVM_INT32)pBiquadState->coefs[1]*pBiquadState->pDelays[1];
+
+ // ynR+=A0 (Q15) * x(n)R (Q0) in Q15
+ ynR+=(LVM_INT32)pBiquadState->coefs[2]*(*(pDataIn+1));
+
+ // ynR+= ( -B2 (Q15) * y(n-2)R (Q0) ) in Q15
+ ynR+=(LVM_INT32)pBiquadState->coefs[3]*pBiquadState->pDelays[7];
+
+ // ynR+=( -B1 (Q15) * y(n-1)R (Q0) ) in Q15
+ ynR+=(LVM_INT32)pBiquadState->coefs[4]*pBiquadState->pDelays[5];
+
+ ynR=ynR>>15; // ynL in Q0 format
+ /**************************************************************************
+ UPDATING THE DELAYS
+ ***************************************************************************/
+ pBiquadState->pDelays[7]=pBiquadState->pDelays[5]; // y(n-2)R=y(n-1)R
+ pBiquadState->pDelays[6]=pBiquadState->pDelays[4]; // y(n-2)L=y(n-1)L
+ pBiquadState->pDelays[3]=pBiquadState->pDelays[1]; // x(n-2)R=x(n-1)R
+ pBiquadState->pDelays[2]=pBiquadState->pDelays[0]; // x(n-2)L=x(n-1)L
+ pBiquadState->pDelays[5]=ynR; // Update y(n-1)R in Q0
+ pBiquadState->pDelays[4]=ynL; // Update y(n-1)L in Q0
+ pBiquadState->pDelays[0]=(*pDataIn++); // Update x(n-1)L in Q0
+ pBiquadState->pDelays[1]=(*pDataIn++); // Update x(n-1)R in Q0
+
+ /**************************************************************************
+ WRITING THE OUTPUT
+ ***************************************************************************/
+ *pDataOut++=(LVM_INT16)ynL; // Write Left output in Q0
+ *pDataOut++=(LVM_INT16)ynR; // Write Right ouput in Q0
+
+ }
+
+ }
+
diff --git a/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F16Css_TRC_WRA_01_Init.c b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F16Css_TRC_WRA_01_Init.c
new file mode 100755
index 0000000..b0cd1b9
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F16Css_TRC_WRA_01_Init.c
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/* */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/*-------------------------------------------------------------------------*/
+#include "BIQUAD.h"
+#include "BQ_2I_D16F16Css_TRC_WRA_01_Private.h"
+
+
+/*-------------------------------------------------------------------------*/
+/* FUNCTION: */
+/* BQ_2I_D16F16Css_TRC_WRA_01_Init */
+/* */
+/* DESCRIPTION: */
+/* These functions initializes a BIQUAD filter defined as a cascade of */
+/* biquadratic Filter Sections. */
+/* */
+/* PARAMETERS: */
+/* pInstance - output, returns the pointer to the State Variable */
+/* This state pointer must be passed to any subsequent */
+/* call to "Biquad" functions. */
+/* pTaps - input, pointer to the taps memory */
+/* pCoef - input, pointer to the coefficient structure */
+/* N - M coefficient factor of QM.N */
+/* RETURNS: */
+/* void return code */
+/*-------------------------------------------------------------------------*/
+void BQ_2I_D16F16Css_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance,
+ Biquad_2I_Order2_Taps_t *pTaps,
+ BQ_C16_Coefs_t *pCoef)
+{
+ LVM_INT16 temp;
+ PFilter_State pBiquadState = (PFilter_State) pInstance;
+ pBiquadState->pDelays =(LVM_INT32 *) pTaps ;
+
+ temp=pCoef->A2;
+ pBiquadState->coefs[0]=temp;
+ temp=pCoef->A1;
+ pBiquadState->coefs[1]=temp;
+ temp=pCoef->A0;
+ pBiquadState->coefs[2]=temp;
+ temp=pCoef->B2;
+ pBiquadState->coefs[3]=temp;
+ temp=pCoef->B1;
+ pBiquadState->coefs[4]=temp;
+}
+/*-------------------------------------------------------------------------*/
+/* End Of File: BQ_2I_D16F16Css_TRC_WRA_01_Init.c */
+
diff --git a/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F16Css_TRC_WRA_01_Private.h b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F16Css_TRC_WRA_01_Private.h
new file mode 100755
index 0000000..bcb0093
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F16Css_TRC_WRA_01_Private.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef _BQ_2I_D16F16CSS_TRC_WRA_01_PRIVATE_H_
+#define _BQ_2I_D16F16CSS_TRC_WRA_01_PRIVATE_H_
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+/* The internal state variables are implemented in a (for the user) hidden structure */
+/* In this (private) file, the internal structure is declared fro private use. */
+typedef struct _Filter_State_
+{
+ LVM_INT32 * pDelays; /* pointer to the delayed samples (data of 32 bits) */
+ LVM_INT16 coefs[5]; /* pointer to the filter coefficients */
+}Filter_State;
+
+typedef Filter_State * PFilter_State ;
+
+#endif /* _BQ_2I_D16F16CSS_TRC_WRA_01_PRIVATE_H_ */
diff --git a/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32C13_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32C13_TRC_WRA_01.c
new file mode 100755
index 0000000..ae743f2
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32C13_TRC_WRA_01.c
@@ -0,0 +1,127 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+#include "BIQUAD.h"
+#include "BQ_2I_D16F32Css_TRC_WRA_01_Private.h"
+#include "LVM_Macros.h"
+
+
+/**************************************************************************
+ ASSUMPTIONS:
+ COEFS-
+ pBiquadState->coefs[0] is A2, pBiquadState->coefs[1] is A1
+ pBiquadState->coefs[2] is A0, pBiquadState->coefs[3] is -B2
+ pBiquadState->coefs[4] is -B1, these are in Q13 format
+
+ DELAYS-
+ pBiquadState->pDelays[0] is x(n-1)L in Q0 format
+ pBiquadState->pDelays[1] is x(n-1)R in Q0 format
+ pBiquadState->pDelays[2] is x(n-2)L in Q0 format
+ pBiquadState->pDelays[3] is x(n-2)R in Q0 format
+ pBiquadState->pDelays[4] is y(n-1)L in Q16 format
+ pBiquadState->pDelays[5] is y(n-1)R in Q16 format
+ pBiquadState->pDelays[6] is y(n-2)L in Q16 format
+ pBiquadState->pDelays[7] is y(n-2)R in Q16 format
+***************************************************************************/
+
+void BQ_2I_D16F32C13_TRC_WRA_01 ( Biquad_Instance_t *pInstance,
+ LVM_INT16 *pDataIn,
+ LVM_INT16 *pDataOut,
+ LVM_INT16 NrSamples)
+ {
+ LVM_INT32 ynL,ynR,templ;
+ LVM_INT16 ii;
+ PFilter_State pBiquadState = (PFilter_State) pInstance;
+
+ for (ii = NrSamples; ii != 0; ii--)
+ {
+
+
+ /**************************************************************************
+ PROCESSING OF THE LEFT CHANNEL
+ ***************************************************************************/
+ /* ynL=A2 (Q13) * x(n-2)L (Q0) in Q13*/
+ ynL=(LVM_INT32)pBiquadState->coefs[0]* pBiquadState->pDelays[2];
+
+ /* ynL+=A1 (Q13) * x(n-1)L (Q0) in Q13*/
+ ynL+=(LVM_INT32)pBiquadState->coefs[1]* pBiquadState->pDelays[0];
+
+ /* ynL+=A0 (Q13) * x(n)L (Q0) in Q13*/
+ ynL+=(LVM_INT32)pBiquadState->coefs[2]* (*pDataIn);
+
+ /* ynL+= ( (-B2 (Q13) * y(n-2)L (Q16) )>>16) in Q13 */
+ MUL32x16INTO32(pBiquadState->pDelays[6],pBiquadState->coefs[3],templ,16)
+ ynL+=templ;
+
+ /* ynL+=( (-B1 (Q13) * y(n-1)L (Q16) )>>16) in Q13 */
+ MUL32x16INTO32(pBiquadState->pDelays[4],pBiquadState->coefs[4],templ,16)
+ ynL+=templ;
+
+ /**************************************************************************
+ PROCESSING OF THE RIGHT CHANNEL
+ ***************************************************************************/
+ /* ynR=A2 (Q13) * x(n-2)R (Q0) in Q13*/
+ ynR=(LVM_INT32)pBiquadState->coefs[0]*pBiquadState->pDelays[3];
+
+ /* ynR+=A1 (Q13) * x(n-1)R (Q0) in Q13*/
+ ynR+=(LVM_INT32)pBiquadState->coefs[1]*pBiquadState->pDelays[1];
+
+ /* ynR+=A0 (Q13) * x(n)R (Q0) in Q13*/
+ ynR+=(LVM_INT32)pBiquadState->coefs[2]*(*(pDataIn+1));
+
+ /* ynR+= ( (-B2 (Q13) * y(n-2)R (Q16) )>>16) in Q13*/
+ MUL32x16INTO32(pBiquadState->pDelays[7],pBiquadState->coefs[3],templ,16)
+ ynR+=templ;
+
+ /* ynR+=( (-B1 (Q13) * y(n-1)R (Q16) )>>16) in Q13 */
+ MUL32x16INTO32(pBiquadState->pDelays[5],pBiquadState->coefs[4],templ,16)
+ ynR+=templ;
+
+ /**************************************************************************
+ UPDATING THE DELAYS
+ ***************************************************************************/
+ pBiquadState->pDelays[7]=pBiquadState->pDelays[5]; /* y(n-2)R=y(n-1)R*/
+ pBiquadState->pDelays[6]=pBiquadState->pDelays[4]; /* y(n-2)L=y(n-1)L*/
+ pBiquadState->pDelays[3]=pBiquadState->pDelays[1]; /* x(n-2)R=x(n-1)R*/
+ pBiquadState->pDelays[2]=pBiquadState->pDelays[0]; /* x(n-2)L=x(n-1)L*/
+ pBiquadState->pDelays[5]=ynR<<3; /* Update y(n-1)R in Q16*/
+ pBiquadState->pDelays[4]=ynL<<3; /* Update y(n-1)L in Q16*/
+ pBiquadState->pDelays[0]=(*pDataIn); /* Update x(n-1)L in Q0*/
+ pDataIn++;
+ pBiquadState->pDelays[1]=(*pDataIn); /* Update x(n-1)R in Q0*/
+ pDataIn++;
+
+ /**************************************************************************
+ WRITING THE OUTPUT
+ ***************************************************************************/
+ *pDataOut=(LVM_INT16)(ynL>>13); /* Write Left output in Q0*/
+ pDataOut++;
+ *pDataOut=(LVM_INT16)(ynR>>13); /* Write Right ouput in Q0*/
+ pDataOut++;
+ }
+
+ }
+
diff --git a/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32C14_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32C14_TRC_WRA_01.c
new file mode 100755
index 0000000..a0ca2cc
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32C14_TRC_WRA_01.c
@@ -0,0 +1,126 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+#include "BIQUAD.h"
+#include "BQ_2I_D16F32Css_TRC_WRA_01_Private.h"
+#include "LVM_Macros.h"
+
+/**************************************************************************
+ ASSUMPTIONS:
+ COEFS-
+ pBiquadState->coefs[0] is A2, pBiquadState->coefs[1] is A1
+ pBiquadState->coefs[2] is A0, pBiquadState->coefs[3] is -B2
+ pBiquadState->coefs[4] is -B1, these are in Q14 format
+
+ DELAYS-
+ pBiquadState->pDelays[0] is x(n-1)L in Q0 format
+ pBiquadState->pDelays[1] is x(n-1)R in Q0 format
+ pBiquadState->pDelays[2] is x(n-2)L in Q0 format
+ pBiquadState->pDelays[3] is x(n-2)R in Q0 format
+ pBiquadState->pDelays[4] is y(n-1)L in Q16 format
+ pBiquadState->pDelays[5] is y(n-1)R in Q16 format
+ pBiquadState->pDelays[6] is y(n-2)L in Q16 format
+ pBiquadState->pDelays[7] is y(n-2)R in Q16 format
+***************************************************************************/
+
+void BQ_2I_D16F32C14_TRC_WRA_01 ( Biquad_Instance_t *pInstance,
+ LVM_INT16 *pDataIn,
+ LVM_INT16 *pDataOut,
+ LVM_INT16 NrSamples)
+ {
+ LVM_INT32 ynL,ynR,templ;
+ LVM_INT16 ii;
+ PFilter_State pBiquadState = (PFilter_State) pInstance;
+
+ for (ii = NrSamples; ii != 0; ii--)
+ {
+
+
+ /**************************************************************************
+ PROCESSING OF THE LEFT CHANNEL
+ ***************************************************************************/
+ /* ynL=A2 (Q14) * x(n-2)L (Q0) in Q14*/
+ ynL=(LVM_INT32)pBiquadState->coefs[0]* pBiquadState->pDelays[2];
+
+ /* ynL+=A1 (Q14) * x(n-1)L (Q0) in Q14*/
+ ynL+=(LVM_INT32)pBiquadState->coefs[1]* pBiquadState->pDelays[0];
+
+ /* ynL+=A0 (Q14) * x(n)L (Q0) in Q14*/
+ ynL+=(LVM_INT32)pBiquadState->coefs[2]* (*pDataIn);
+
+ /* ynL+= ( (-B2 (Q14) * y(n-2)L (Q16) )>>16) in Q14 */
+ MUL32x16INTO32(pBiquadState->pDelays[6],pBiquadState->coefs[3],templ,16)
+ ynL+=templ;
+
+ /* ynL+=( (-B1 (Q14) * y(n-1)L (Q16) )>>16) in Q14 */
+ MUL32x16INTO32(pBiquadState->pDelays[4],pBiquadState->coefs[4],templ,16)
+ ynL+=templ;
+
+ /**************************************************************************
+ PROCESSING OF THE RIGHT CHANNEL
+ ***************************************************************************/
+ /* ynR=A2 (Q14) * x(n-2)R (Q0) in Q14*/
+ ynR=(LVM_INT32)pBiquadState->coefs[0]*pBiquadState->pDelays[3];
+
+ /* ynR+=A1 (Q14) * x(n-1)R (Q0) in Q14*/
+ ynR+=(LVM_INT32)pBiquadState->coefs[1]*pBiquadState->pDelays[1];
+
+ /* ynR+=A0 (Q14) * x(n)R (Q0) in Q14*/
+ ynR+=(LVM_INT32)pBiquadState->coefs[2]*(*(pDataIn+1));
+
+ /* ynR+= ( (-B2 (Q14) * y(n-2)R (Q16) )>>16) in Q14*/
+ MUL32x16INTO32(pBiquadState->pDelays[7],pBiquadState->coefs[3],templ,16)
+ ynR+=templ;
+
+ /* ynR+=( (-B1 (Q14) * y(n-1)R (Q16) )>>16) in Q14 */
+ MUL32x16INTO32(pBiquadState->pDelays[5],pBiquadState->coefs[4],templ,16)
+ ynR+=templ;
+
+ /**************************************************************************
+ UPDATING THE DELAYS
+ ***************************************************************************/
+ pBiquadState->pDelays[7]=pBiquadState->pDelays[5]; /* y(n-2)R=y(n-1)R*/
+ pBiquadState->pDelays[6]=pBiquadState->pDelays[4]; /* y(n-2)L=y(n-1)L*/
+ pBiquadState->pDelays[3]=pBiquadState->pDelays[1]; /* x(n-2)R=x(n-1)R*/
+ pBiquadState->pDelays[2]=pBiquadState->pDelays[0]; /* x(n-2)L=x(n-1)L*/
+ pBiquadState->pDelays[5]=ynR<<2; /* Update y(n-1)R in Q16*/
+ pBiquadState->pDelays[4]=ynL<<2; /* Update y(n-1)L in Q16*/
+ pBiquadState->pDelays[0]=(*pDataIn); /* Update x(n-1)L in Q0*/
+ pDataIn++;
+ pBiquadState->pDelays[1]=(*pDataIn); /* Update x(n-1)R in Q0*/
+ pDataIn++;
+
+ /**************************************************************************
+ WRITING THE OUTPUT
+ ***************************************************************************/
+ *pDataOut=(LVM_INT16)(ynL>>14); /* Write Left output in Q0*/
+ pDataOut++;
+ *pDataOut=(LVM_INT16)(ynR>>14); /* Write Right ouput in Q0*/
+ pDataOut++;
+ }
+
+ }
+
diff --git a/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32C15_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32C15_TRC_WRA_01.c
new file mode 100755
index 0000000..f1ab815
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32C15_TRC_WRA_01.c
@@ -0,0 +1,126 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+#include "BIQUAD.h"
+#include "BQ_2I_D16F32Css_TRC_WRA_01_Private.h"
+#include "LVM_Macros.h"
+
+/**************************************************************************
+ ASSUMPTIONS:
+ COEFS-
+ pBiquadState->coefs[0] is A2, pBiquadState->coefs[1] is A1
+ pBiquadState->coefs[2] is A0, pBiquadState->coefs[3] is -B2
+ pBiquadState->coefs[4] is -B1, these are in Q15 format
+
+ DELAYS-
+ pBiquadState->pDelays[0] is x(n-1)L in Q0 format
+ pBiquadState->pDelays[1] is x(n-1)R in Q0 format
+ pBiquadState->pDelays[2] is x(n-2)L in Q0 format
+ pBiquadState->pDelays[3] is x(n-2)R in Q0 format
+ pBiquadState->pDelays[4] is y(n-1)L in Q16 format
+ pBiquadState->pDelays[5] is y(n-1)R in Q16 format
+ pBiquadState->pDelays[6] is y(n-2)L in Q16 format
+ pBiquadState->pDelays[7] is y(n-2)R in Q16 format
+***************************************************************************/
+
+void BQ_2I_D16F32C15_TRC_WRA_01 ( Biquad_Instance_t *pInstance,
+ LVM_INT16 *pDataIn,
+ LVM_INT16 *pDataOut,
+ LVM_INT16 NrSamples)
+ {
+ LVM_INT32 ynL,ynR,templ;
+ LVM_INT16 ii;
+ PFilter_State pBiquadState = (PFilter_State) pInstance;
+
+ for (ii = NrSamples; ii != 0; ii--)
+ {
+
+
+ /**************************************************************************
+ PROCESSING OF THE LEFT CHANNEL
+ ***************************************************************************/
+ /* ynL=A2 (Q15) * x(n-2)L (Q0) in Q15*/
+ ynL=(LVM_INT32)pBiquadState->coefs[0]* pBiquadState->pDelays[2];
+
+ /* ynL+=A1 (Q15) * x(n-1)L (Q0) in Q15*/
+ ynL+=(LVM_INT32)pBiquadState->coefs[1]* pBiquadState->pDelays[0];
+
+ /* ynL+=A0 (Q15) * x(n)L (Q0) in Q15*/
+ ynL+=(LVM_INT32)pBiquadState->coefs[2]* (*pDataIn);
+
+ /* ynL+= ( (-B2 (Q15) * y(n-2)L (Q16) )>>16) in Q15 */
+ MUL32x16INTO32(pBiquadState->pDelays[6],pBiquadState->coefs[3],templ,16)
+ ynL+=templ;
+
+ /* ynL+=( (-B1 (Q15) * y(n-1)L (Q16) )>>16) in Q15 */
+ MUL32x16INTO32(pBiquadState->pDelays[4],pBiquadState->coefs[4],templ,16)
+ ynL+=templ;
+
+ /**************************************************************************
+ PROCESSING OF THE RIGHT CHANNEL
+ ***************************************************************************/
+ /* ynR=A2 (Q15) * x(n-2)R (Q0) in Q15*/
+ ynR=(LVM_INT32)pBiquadState->coefs[0]*pBiquadState->pDelays[3];
+
+ /* ynR+=A1 (Q15) * x(n-1)R (Q0) in Q15*/
+ ynR+=(LVM_INT32)pBiquadState->coefs[1]*pBiquadState->pDelays[1];
+
+ /* ynR+=A0 (Q15) * x(n)R (Q0) in Q15*/
+ ynR+=(LVM_INT32)pBiquadState->coefs[2]*(*(pDataIn+1));
+
+ /* ynR+= ( (-B2 (Q15) * y(n-2)R (Q16) )>>16) in Q15 */
+ MUL32x16INTO32(pBiquadState->pDelays[7],pBiquadState->coefs[3],templ,16)
+ ynR+=templ;
+
+ /* ynR+=( (-B1 (Q15) * y(n-1)R (Q16) )>>16) in Q15 */
+ MUL32x16INTO32(pBiquadState->pDelays[5],pBiquadState->coefs[4],templ,16)
+ ynR+=templ;
+
+ /**************************************************************************
+ UPDATING THE DELAYS
+ ***************************************************************************/
+ pBiquadState->pDelays[7]=pBiquadState->pDelays[5]; /* y(n-2)R=y(n-1)R*/
+ pBiquadState->pDelays[6]=pBiquadState->pDelays[4]; /* y(n-2)L=y(n-1)L*/
+ pBiquadState->pDelays[3]=pBiquadState->pDelays[1]; /* x(n-2)R=x(n-1)R*/
+ pBiquadState->pDelays[2]=pBiquadState->pDelays[0]; /* x(n-2)L=x(n-1)L*/
+ pBiquadState->pDelays[5]=ynR<<1; /* Update y(n-1)R in Q16*/
+ pBiquadState->pDelays[4]=ynL<<1; /* Update y(n-1)L in Q16*/
+ pBiquadState->pDelays[0]=(*pDataIn); /* Update x(n-1)L in Q0*/
+ pDataIn++;
+ pBiquadState->pDelays[1]=(*pDataIn); /* Update x(n-1)R in Q0*/
+ pDataIn++;
+
+ /**************************************************************************
+ WRITING THE OUTPUT
+ ***************************************************************************/
+ *pDataOut=(LVM_INT16)(ynL>>15); /* Write Left output in Q0*/
+ pDataOut++;
+ *pDataOut=(LVM_INT16)(ynR>>15); /* Write Right ouput in Q0*/
+ pDataOut++;
+ }
+
+ }
+
diff --git a/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32Css_TRC_WRA_01_Private.h b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32Css_TRC_WRA_01_Private.h
new file mode 100755
index 0000000..3cbb58b
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32Css_TRC_WRA_01_Private.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef _BQ_2I_D16F32CSS_TRC_WRA_01_PRIVATE_H_
+#define _BQ_2I_D16F32CSS_TRC_WRA_01_PRIVATE_H_
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+/* The internal state variables are implemented in a (for the user) hidden structure */
+/* In this (private) file, the internal structure is declared fro private use. */
+typedef struct _Filter_State_
+{
+ LVM_INT32 * pDelays; /* pointer to the delayed samples (data of 32 bits) */
+ LVM_INT16 coefs[5]; /* pointer to the filter coefficients */
+}Filter_State;
+
+typedef Filter_State * PFilter_State ;
+
+#endif /* _BQ_2I_D16F32CSS_TRC_WRA_01_PRIVATE_H_ */
diff --git a/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32Css_TRC_WRA_01_init.c b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32Css_TRC_WRA_01_init.c
new file mode 100755
index 0000000..0c6b33e
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32Css_TRC_WRA_01_init.c
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+#include "BIQUAD.h"
+#include "BQ_2I_D16F32Css_TRC_WRA_01_Private.h"
+
+
+/*-------------------------------------------------------------------------*/
+/* FUNCTION: */
+/* BQ_2I_D16F32Css_TRC_WRA_01_Init */
+/* */
+/* DESCRIPTION: */
+/* These functions initializes a BIQUAD filter defined as a cascade of */
+/* biquadratic Filter Sections. */
+/* */
+/* PARAMETERS: */
+/* pInstance - output, returns the pointer to the State Variable */
+/* This state pointer must be passed to any subsequent */
+/* call to "Biquad" functions. */
+/* pTaps - input, pointer to the taps memory */
+/* pCoef - input, pointer to the coefficient structure */
+/* N - M coefficient factor of QM.N */
+/* RETURNS: */
+/* void return code */
+/*-------------------------------------------------------------------------*/
+void BQ_2I_D16F32Css_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance,
+ Biquad_2I_Order2_Taps_t *pTaps,
+ BQ_C16_Coefs_t *pCoef)
+{
+ LVM_INT16 temp;
+ PFilter_State pBiquadState = (PFilter_State) pInstance;
+ pBiquadState->pDelays =(LVM_INT32 *) pTaps ;
+
+ temp=pCoef->A2;
+ pBiquadState->coefs[0]=temp;
+ temp=pCoef->A1;
+ pBiquadState->coefs[1]=temp;
+ temp=pCoef->A0;
+ pBiquadState->coefs[2]=temp;
+ temp=pCoef->B2;
+ pBiquadState->coefs[3]=temp;
+ temp=pCoef->B1;
+ pBiquadState->coefs[4]=temp;
+}
+/*-------------------------------------------------------------------------*/
+/* End Of File: BQ_2I_D16F32Css_TRC_WRA_01_Init */
+
diff --git a/media/libeffects/lvm/lib/Common/src/BQ_2I_D32F32C30_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/BQ_2I_D32F32C30_TRC_WRA_01.c
new file mode 100755
index 0000000..51278cf
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/BQ_2I_D32F32C30_TRC_WRA_01.c
@@ -0,0 +1,135 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+#include "BIQUAD.h"
+#include "BQ_2I_D32F32Cll_TRC_WRA_01_Private.h"
+#include "LVM_Macros.h"
+
+/**************************************************************************
+ ASSUMPTIONS:
+ COEFS-
+ pBiquadState->coefs[0] is A2, pBiquadState->coefs[1] is A1
+ pBiquadState->coefs[2] is A0, pBiquadState->coefs[3] is -B2
+ pBiquadState->coefs[4] is -B1, these are in Q30 format
+
+ DELAYS-
+ pBiquadState->pDelays[0] is x(n-1)L in Q0 format
+ pBiquadState->pDelays[1] is x(n-1)R in Q0 format
+ pBiquadState->pDelays[2] is x(n-2)L in Q0 format
+ pBiquadState->pDelays[3] is x(n-2)R in Q0 format
+ pBiquadState->pDelays[4] is y(n-1)L in Q0 format
+ pBiquadState->pDelays[5] is y(n-1)R in Q0 format
+ pBiquadState->pDelays[6] is y(n-2)L in Q0 format
+ pBiquadState->pDelays[7] is y(n-2)R in Q0 format
+***************************************************************************/
+
+void BQ_2I_D32F32C30_TRC_WRA_01 ( Biquad_Instance_t *pInstance,
+ LVM_INT32 *pDataIn,
+ LVM_INT32 *pDataOut,
+ LVM_INT16 NrSamples)
+
+
+ {
+ LVM_INT32 ynL,ynR,templ,tempd;
+ LVM_INT16 ii;
+ PFilter_State pBiquadState = (PFilter_State) pInstance;
+
+ for (ii = NrSamples; ii != 0; ii--)
+ {
+
+
+ /**************************************************************************
+ PROCESSING OF THE LEFT CHANNEL
+ ***************************************************************************/
+ /* ynL= ( A2 (Q30) * x(n-2)L (Q0) ) >>30 in Q0*/
+ MUL32x32INTO32(pBiquadState->coefs[0],pBiquadState->pDelays[2],ynL,30)
+
+ /* ynL+= ( A1 (Q30) * x(n-1)L (Q0) ) >> 30 in Q0*/
+ MUL32x32INTO32(pBiquadState->coefs[1],pBiquadState->pDelays[0],templ,30)
+ ynL+=templ;
+
+ /* ynL+= ( A0 (Q30) * x(n)L (Q0) ) >> 30 in Q0*/
+ MUL32x32INTO32(pBiquadState->coefs[2],*pDataIn,templ,30)
+ ynL+=templ;
+
+ /* ynL+= (-B2 (Q30) * y(n-2)L (Q0) ) >> 30 in Q0*/
+ MUL32x32INTO32(pBiquadState->coefs[3],pBiquadState->pDelays[6],templ,30)
+ ynL+=templ;
+
+ /* ynL+= (-B1 (Q30) * y(n-1)L (Q0) ) >> 30 in Q0 */
+ MUL32x32INTO32(pBiquadState->coefs[4],pBiquadState->pDelays[4],templ,30)
+ ynL+=templ;
+
+ /**************************************************************************
+ PROCESSING OF THE RIGHT CHANNEL
+ ***************************************************************************/
+ /* ynR= ( A2 (Q30) * x(n-2)R (Q0) ) >> 30 in Q0*/
+ MUL32x32INTO32(pBiquadState->coefs[0],pBiquadState->pDelays[3],ynR,30)
+
+ /* ynR+= ( A1 (Q30) * x(n-1)R (Q0) ) >> 30 in Q0*/
+ MUL32x32INTO32(pBiquadState->coefs[1],pBiquadState->pDelays[1],templ,30)
+ ynR+=templ;
+
+ /* ynR+= ( A0 (Q30) * x(n)R (Q0) ) >> 30 in Q0*/
+ tempd=*(pDataIn+1);
+ MUL32x32INTO32(pBiquadState->coefs[2],tempd,templ,30)
+ ynR+=templ;
+
+ /* ynR+= (-B2 (Q30) * y(n-2)R (Q0) ) >> 30 in Q0*/
+ MUL32x32INTO32(pBiquadState->coefs[3],pBiquadState->pDelays[7],templ,30)
+ ynR+=templ;
+
+ /* ynR+= (-B1 (Q30) * y(n-1)R (Q0) ) >> 30 in Q0 */
+ MUL32x32INTO32(pBiquadState->coefs[4],pBiquadState->pDelays[5],templ,30)
+ ynR+=templ;
+
+ /**************************************************************************
+ UPDATING THE DELAYS
+ ***************************************************************************/
+ pBiquadState->pDelays[7]=pBiquadState->pDelays[5]; /* y(n-2)R=y(n-1)R*/
+ pBiquadState->pDelays[6]=pBiquadState->pDelays[4]; /* y(n-2)L=y(n-1)L*/
+ pBiquadState->pDelays[3]=pBiquadState->pDelays[1]; /* x(n-2)R=x(n-1)R*/
+ pBiquadState->pDelays[2]=pBiquadState->pDelays[0]; /* x(n-2)L=x(n-1)L*/
+ pBiquadState->pDelays[5]=(LVM_INT32)ynR; /* Update y(n-1)R in Q0*/
+ pBiquadState->pDelays[4]=(LVM_INT32)ynL; /* Update y(n-1)L in Q0*/
+ pBiquadState->pDelays[0]=(*pDataIn); /* Update x(n-1)L in Q0*/
+ pDataIn++;
+ pBiquadState->pDelays[1]=(*pDataIn); /* Update x(n-1)R in Q0*/
+ pDataIn++;
+
+ /**************************************************************************
+ WRITING THE OUTPUT
+ ***************************************************************************/
+ *pDataOut=(LVM_INT32)ynL; /* Write Left output in Q0*/
+ pDataOut++;
+ *pDataOut=(LVM_INT32)ynR; /* Write Right ouput in Q0*/
+ pDataOut++;
+
+
+ }
+
+ }
+
diff --git a/media/libeffects/lvm/lib/Common/src/BQ_2I_D32F32Cll_TRC_WRA_01_Init.c b/media/libeffects/lvm/lib/Common/src/BQ_2I_D32F32Cll_TRC_WRA_01_Init.c
new file mode 100755
index 0000000..7c460d3
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/BQ_2I_D32F32Cll_TRC_WRA_01_Init.c
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/* */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/*-------------------------------------------------------------------------*/
+#include "BIQUAD.h"
+#include "BQ_2I_D32F32Cll_TRC_WRA_01_Private.h"
+
+/*-------------------------------------------------------------------------*/
+/* FUNCTION: */
+/* BQ_2I_D32F32Cll_TRC_WRA_01_Init */
+/* */
+/* DESCRIPTION: */
+/* These functions initializes a BIQUAD filter defined as a cascade of */
+/* biquadratic Filter Sections. */
+/* */
+/* PARAMETERS: */
+/* pInstance - output, returns the pointer to the State Variable */
+/* This state pointer must be passed to any subsequent */
+/* call to "Biquad" functions. */
+/* pTaps - input, pointer to the taps memory */
+/* pCoef - input, pointer to the coefficient structure */
+/* N - M coefficient factor of QM.N */
+/* RETURNS: */
+/* void return code */
+/*-------------------------------------------------------------------------*/
+void BQ_2I_D32F32Cll_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance,
+ Biquad_2I_Order2_Taps_t *pTaps,
+ BQ_C32_Coefs_t *pCoef)
+{
+ LVM_INT32 temp;
+ PFilter_State pBiquadState = (PFilter_State) pInstance;
+ pBiquadState->pDelays =(LVM_INT32 *) pTaps ;
+
+ temp=pCoef->A2;
+ pBiquadState->coefs[0]=temp;
+ temp=pCoef->A1;
+ pBiquadState->coefs[1]=temp;
+ temp=pCoef->A0;
+ pBiquadState->coefs[2]=temp;
+ temp=pCoef->B2;
+ pBiquadState->coefs[3]=temp;
+ temp=pCoef->B1;
+ pBiquadState->coefs[4]=temp;
+}
+/*-------------------------------------------------------------------------*/
+/* End Of File: BQ_2I_D32F32C32_TRC_WRA_01_Init.c */
+
diff --git a/media/libeffects/lvm/lib/Common/src/BQ_2I_D32F32Cll_TRC_WRA_01_Private.h b/media/libeffects/lvm/lib/Common/src/BQ_2I_D32F32Cll_TRC_WRA_01_Private.h
new file mode 100755
index 0000000..fb4f2dd
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/BQ_2I_D32F32Cll_TRC_WRA_01_Private.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef _BQ_2I_D32F32CLL_TRC_WRA_01_PRIVATE_H_
+#define _BQ_2I_D32F32CLL_TRC_WRA_01_PRIVATE_H_
+
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+/* The internal state variables are implemented in a (for the user) hidden structure */
+/* In this (private) file, the internal structure is declared fro private use. */
+typedef struct _Filter_State_
+{
+ LVM_INT32 * pDelays; /* pointer to the delayed samples (data of 32 bits) */
+ LVM_INT32 coefs[5]; /* pointer to the filter coefficients */
+}Filter_State;
+
+typedef Filter_State * PFilter_State ;
+
+#endif /* _BQ_2I_D32F32CLL_TRC_WRA_01_PRIVATE_H_*/
diff --git a/media/libeffects/lvm/lib/Common/src/CompLim_private.h b/media/libeffects/lvm/lib/Common/src/CompLim_private.h
new file mode 100755
index 0000000..07a8833
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/CompLim_private.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/**********************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1000 $
+ $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $
+
+***********************************************************************************/
+
+#ifndef _COMP_LIM_PRIVATE_
+#define _COMP_LIM_PRIVATE_
+
+/**********************************************************************************
+ INCLUDE FILES
+***********************************************************************************/
+
+#include "CompLim.h"
+
+/**********************************************************************************
+ DEFINITIONS
+***********************************************************************************/
+
+#define FS_48K 48000
+
+#define INTEGER_16 0xFFFF /* 65535*/
+#define INTEGER_15 0x7FFF /* 32767*/
+
+#define GAIN_6DB 1
+#define GAIN_12DB 2
+#define GAIN_18DB 3
+#define GAIN_24DB 4
+
+#endif /* #ifndef _COMP_LIM_PRIVATE_ */
+
+/*** End of file ******************************************************************/
+
diff --git a/media/libeffects/lvm/lib/Common/src/Copy_16.c b/media/libeffects/lvm/lib/Common/src/Copy_16.c
new file mode 100755
index 0000000..6ee1ff6
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/Copy_16.c
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/**********************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1000 $
+ $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $
+
+***********************************************************************************/
+
+/**********************************************************************************
+ INCLUDE FILES
+***********************************************************************************/
+
+#include "VectorArithmetic.h"
+
+/**********************************************************************************
+ FUNCTION COPY_16
+***********************************************************************************/
+
+void Copy_16( const LVM_INT16 *src,
+ LVM_INT16 *dst,
+ LVM_INT16 n )
+{
+ LVM_INT16 ii;
+
+ if (src > dst)
+ {
+ for (ii = n; ii != 0; ii--)
+ {
+ *dst = *src;
+ dst++;
+ src++;
+ }
+ }
+ else
+ {
+ src += n - 1;
+ dst += n - 1;
+ for (ii = n; ii != 0; ii--)
+ {
+ *dst = *src;
+ dst--;
+ src--;
+ }
+ }
+
+ return;
+}
+
+/**********************************************************************************/
diff --git a/media/libeffects/lvm/lib/Common/src/Core_MixHard_2St_D32C31_SAT.c b/media/libeffects/lvm/lib/Common/src/Core_MixHard_2St_D32C31_SAT.c
new file mode 100755
index 0000000..adac24f
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/Core_MixHard_2St_D32C31_SAT.c
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+/**********************************************************************************
+ INCLUDE FILES
+***********************************************************************************/
+
+#include "Mixer_private.h"
+#include "LVM_Macros.h"
+
+/**********************************************************************************
+ FUNCTION CORE_MIXHARD_2ST_D32C31_SAT
+***********************************************************************************/
+
+void Core_MixHard_2St_D32C31_SAT( Mix_2St_Cll_t *pInstance,
+ const LVM_INT32 *src1,
+ const LVM_INT32 *src2,
+ LVM_INT32 *dst,
+ LVM_INT16 n)
+{
+ LVM_INT32 Temp1,Temp2,Temp3;
+ LVM_INT16 ii;
+ LVM_INT16 Current1Short;
+ LVM_INT16 Current2Short;
+
+ Current1Short = (LVM_INT16)(pInstance->Current1 >> 16);
+ Current2Short = (LVM_INT16)(pInstance->Current2 >> 16);
+
+ for (ii = n; ii != 0; ii--){
+ Temp1=*src1++;
+ MUL32x16INTO32(Temp1,Current1Short,Temp3,15)
+ Temp2=*src2++;
+ MUL32x16INTO32(Temp2,Current2Short,Temp1,15)
+ Temp2=(Temp1>>1)+(Temp3>>1);
+ if (Temp2 > 0x3FFFFFFF)
+ Temp2 = 0x7FFFFFFF;
+ else if (Temp2 < - 0x40000000)
+ Temp2 = 0x80000000;
+ else
+ Temp2=(Temp2<<1);
+ *dst++ = Temp2;
+ }
+}
+
+
+/**********************************************************************************/
diff --git a/media/libeffects/lvm/lib/Common/src/Core_MixInSoft_D32C31_SAT.c b/media/libeffects/lvm/lib/Common/src/Core_MixInSoft_D32C31_SAT.c
new file mode 100755
index 0000000..d557f6e
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/Core_MixInSoft_D32C31_SAT.c
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+/**********************************************************************************
+ INCLUDE FILES
+***********************************************************************************/
+
+#include "Mixer_private.h"
+#include "LVM_Macros.h"
+
+/**********************************************************************************
+ FUNCTION CORE_MIXSOFT_1ST_D32C31_WRA
+***********************************************************************************/
+
+void Core_MixInSoft_D32C31_SAT( Mix_1St_Cll_t *pInstance,
+ const LVM_INT32 *src,
+ LVM_INT32 *dst,
+ LVM_INT16 n)
+{
+ LVM_INT32 Temp1,Temp2,Temp3;
+ LVM_INT16 OutLoop;
+ LVM_INT16 InLoop;
+ LVM_INT32 TargetTimesOneMinAlpha;
+ LVM_INT32 CurrentTimesAlpha;
+ LVM_INT16 ii,jj;
+ LVM_INT16 CurrentShort;
+
+ InLoop = (LVM_INT16)(n >> 2); /* Process per 4 samples */
+ OutLoop = (LVM_INT16)(n - (InLoop << 2));
+
+ MUL32x32INTO32((0x7FFFFFFF-pInstance->Alpha),pInstance->Target,TargetTimesOneMinAlpha,31); /* Q31 * Q0 in Q0 */
+ if (pInstance->Target >= pInstance->Current){
+ TargetTimesOneMinAlpha +=2; /* Ceil*/
+ }
+
+ if (OutLoop){
+ MUL32x32INTO32(pInstance->Current,pInstance->Alpha,CurrentTimesAlpha,31); /* Q0 * Q31 in Q0 */
+ pInstance->Current = TargetTimesOneMinAlpha + CurrentTimesAlpha; /* Q0 + Q0 into Q0*/
+ CurrentShort = (LVM_INT16)(pInstance->Current>>16); /* From Q31 to Q15*/
+
+ for (ii = OutLoop; ii != 0; ii--){
+ Temp1=*src++;
+ Temp2=*dst;
+ MUL32x16INTO32(Temp1,CurrentShort,Temp3,15)
+ Temp1=(Temp2>>1)+(Temp3>>1);
+
+ if (Temp1 > 0x3FFFFFFF)
+ Temp1 = 0x7FFFFFFF;
+ else if (Temp1 < - 0x40000000)
+ Temp1 = 0x80000000;
+ else
+ Temp1=(Temp1<<1);
+ *dst++ = Temp1;
+ }
+ }
+
+ for (ii = InLoop; ii != 0; ii--){
+ MUL32x32INTO32(pInstance->Current,pInstance->Alpha,CurrentTimesAlpha,31); /* Q0 * Q31 in Q0 */
+ pInstance->Current = TargetTimesOneMinAlpha + CurrentTimesAlpha; /* Q0 + Q0 into Q0*/
+ CurrentShort = (LVM_INT16)(pInstance->Current>>16); /* From Q31 to Q15*/
+
+ for (jj = 4; jj!=0 ; jj--){
+ Temp1=*src++;
+ Temp2=*dst;
+ MUL32x16INTO32(Temp1,CurrentShort,Temp3,15)
+ Temp1=(Temp2>>1)+(Temp3>>1);
+
+ if (Temp1 > 0x3FFFFFFF)
+ Temp1 = 0x7FFFFFFF;
+ else if (Temp1 < - 0x40000000)
+ Temp1 = 0x80000000;
+ else
+ Temp1=(Temp1<<1);
+ *dst++ = Temp1;
+ }
+ }
+}
+
+
+/**********************************************************************************/
diff --git a/media/libeffects/lvm/lib/Common/src/Core_MixSoft_1St_D32C31_WRA.c b/media/libeffects/lvm/lib/Common/src/Core_MixSoft_1St_D32C31_WRA.c
new file mode 100755
index 0000000..7b4e66db8
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/Core_MixSoft_1St_D32C31_WRA.c
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+/**********************************************************************************
+ INCLUDE FILES
+***********************************************************************************/
+
+#include "Mixer_private.h"
+#include "LVM_Macros.h"
+
+/**********************************************************************************
+ FUNCTION CORE_MIXSOFT_1ST_D32C31_WRA
+***********************************************************************************/
+
+void Core_MixSoft_1St_D32C31_WRA( Mix_1St_Cll_t *pInstance,
+ const LVM_INT32 *src,
+ LVM_INT32 *dst,
+ LVM_INT16 n)
+{
+ LVM_INT32 Temp1,Temp2;
+ LVM_INT16 OutLoop;
+ LVM_INT16 InLoop;
+ LVM_INT32 TargetTimesOneMinAlpha;
+ LVM_INT32 CurrentTimesAlpha;
+ LVM_INT16 CurrentShort;
+ LVM_INT16 ii;
+
+ InLoop = (LVM_INT16)(n >> 2); /* Process per 4 samples */
+ OutLoop = (LVM_INT16)(n - (InLoop << 2));
+
+ MUL32x32INTO32((0x7FFFFFFF-pInstance->Alpha),pInstance->Target,TargetTimesOneMinAlpha,31) /* Q31 * Q31 in Q31 */
+ if (pInstance->Target >= pInstance->Current)
+ {
+ TargetTimesOneMinAlpha +=2; /* Ceil*/
+ }
+
+ if (OutLoop!=0)
+ {
+ MUL32x32INTO32(pInstance->Current,pInstance->Alpha,CurrentTimesAlpha,31) /* Q31 * Q31 in Q31 */
+ pInstance->Current = TargetTimesOneMinAlpha + CurrentTimesAlpha; /* Q31 + Q31 into Q31*/
+ CurrentShort = (LVM_INT16)(pInstance->Current>>16); /* From Q31 to Q15*/
+
+ for (ii = OutLoop; ii != 0; ii--)
+ {
+ Temp1=*src;
+ src++;
+
+ MUL32x16INTO32(Temp1,CurrentShort,Temp2,15)
+ *dst = Temp2;
+ dst++;
+ }
+ }
+
+ for (ii = InLoop; ii != 0; ii--)
+ {
+ MUL32x32INTO32(pInstance->Current,pInstance->Alpha,CurrentTimesAlpha,31) /* Q31 * Q31 in Q31 */
+ pInstance->Current = TargetTimesOneMinAlpha + CurrentTimesAlpha; /* Q31 + Q31 into Q31*/
+ CurrentShort = (LVM_INT16)(pInstance->Current>>16); /* From Q31 to Q15*/
+ Temp1=*src;
+ src++;
+
+ MUL32x16INTO32(Temp1,CurrentShort,Temp2,15)
+ *dst = Temp2;
+ dst++;
+
+ Temp1=*src;
+ src++;
+
+ MUL32x16INTO32(Temp1,CurrentShort,Temp2,15)
+ *dst = Temp2;
+ dst++;
+
+ Temp1=*src;
+ src++;
+
+ MUL32x16INTO32(Temp1,CurrentShort,Temp2,15)
+ *dst = Temp2;
+ dst++;
+
+ Temp1=*src;
+ src++;
+ MUL32x16INTO32(Temp1,CurrentShort,Temp2,15)
+ *dst = Temp2;
+ dst++;
+ }
+}
+
+
+/**********************************************************************************/
diff --git a/media/libeffects/lvm/lib/Common/src/DC_2I_D16_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/DC_2I_D16_TRC_WRA_01.c
new file mode 100755
index 0000000..187fe68
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/DC_2I_D16_TRC_WRA_01.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+#include "BIQUAD.h"
+#include "DC_2I_D16_TRC_WRA_01_Private.h"
+#include "LVM_Macros.h"
+
+void DC_2I_D16_TRC_WRA_01( Biquad_Instance_t *pInstance,
+ LVM_INT16 *pDataIn,
+ LVM_INT16 *pDataOut,
+ LVM_INT16 NrSamples)
+ {
+ LVM_INT32 LeftDC,RightDC;
+ LVM_INT32 Diff;
+ LVM_INT32 j;
+ PFilter_State pBiquadState = (PFilter_State) pInstance;
+
+ LeftDC = pBiquadState->LeftDC;
+ RightDC = pBiquadState->RightDC;
+ for(j=NrSamples-1;j>=0;j--)
+ {
+ /* Subtract DC an saturate */
+ Diff=*(pDataIn++)-(LeftDC>>16);
+ if (Diff > 32767) {
+ Diff = 32767; }
+ else if (Diff < -32768) {
+ Diff = -32768; }
+ *(pDataOut++)=(LVM_INT16)Diff;
+ if (Diff < 0) {
+ LeftDC -= DC_D16_STEP; }
+ else {
+ LeftDC += DC_D16_STEP; }
+
+
+ /* Subtract DC an saturate */
+ Diff=*(pDataIn++)-(RightDC>>16);
+ if (Diff > 32767) {
+ Diff = 32767; }
+ else if (Diff < -32768) {
+ Diff = -32768; }
+ *(pDataOut++)=(LVM_INT16)Diff;
+ if (Diff < 0) {
+ RightDC -= DC_D16_STEP; }
+ else {
+ RightDC += DC_D16_STEP; }
+
+ }
+ pBiquadState->LeftDC = LeftDC;
+ pBiquadState->RightDC = RightDC;
+
+
+ }
+
diff --git a/media/libeffects/lvm/lib/Common/src/DC_2I_D16_TRC_WRA_01_Init.c b/media/libeffects/lvm/lib/Common/src/DC_2I_D16_TRC_WRA_01_Init.c
new file mode 100755
index 0000000..292641b
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/DC_2I_D16_TRC_WRA_01_Init.c
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+#include "BIQUAD.h"
+#include "DC_2I_D16_TRC_WRA_01_Private.h"
+
+void DC_2I_D16_TRC_WRA_01_Init(Biquad_Instance_t *pInstance)
+{
+ PFilter_State pBiquadState = (PFilter_State) pInstance;
+ pBiquadState->LeftDC = 0;
+ pBiquadState->RightDC = 0;
+}
+
diff --git a/media/libeffects/lvm/lib/Common/src/DC_2I_D16_TRC_WRA_01_Private.h b/media/libeffects/lvm/lib/Common/src/DC_2I_D16_TRC_WRA_01_Private.h
new file mode 100755
index 0000000..2514a77
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/DC_2I_D16_TRC_WRA_01_Private.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef _DC_2I_D16_TRC_WRA_01_PRIVATE_H_
+#define _DC_2I_D16_TRC_WRA_01_PRIVATE_H_
+
+#define DC_D16_STEP 0x200;
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+
+/* The internal state variables are implemented in a (for the user) hidden structure */
+/* In this (private) file, the internal structure is declared fro private use.*/
+typedef struct _Filter_State_
+{
+ LVM_INT32 LeftDC; /* LeftDC */
+ LVM_INT32 RightDC; /* RightDC */
+}Filter_State;
+
+typedef Filter_State * PFilter_State ;
+
+#endif /* _DC_2I_D16_TRC_WRA_01_PRIVATE_H_ */
diff --git a/media/libeffects/lvm/lib/Common/src/DelayAllPass_Sat_32x16To32.c b/media/libeffects/lvm/lib/Common/src/DelayAllPass_Sat_32x16To32.c
new file mode 100755
index 0000000..cda72ac
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/DelayAllPass_Sat_32x16To32.c
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+/**********************************************************************************
+ INCLUDE FILES
+***********************************************************************************/
+
+#include "LVM_Types.h"
+#include "LVM_Macros.h"
+#include "VectorArithmetic.h"
+
+/**********************************************************************************
+ FUNCTION DelayAllPass_32x32
+***********************************************************************************/
+
+void DelayAllPass_Sat_32x16To32( LVM_INT32 *delay, /* Delay buffer */
+ LVM_UINT16 size, /* Delay size */
+ LVM_INT16 coeff, /* All pass filter coefficient */
+ LVM_UINT16 DelayOffset, /* Simple delay offset */
+ LVM_UINT16 *pAllPassOffset, /* All pass filter delay offset */
+ LVM_INT32 *dst, /* Source/destination */
+ LVM_INT16 n) /* Number of samples */
+{
+ LVM_INT16 i;
+ LVM_UINT16 AllPassOffset = *pAllPassOffset;
+ LVM_INT32 temp;
+ LVM_INT32 a,b,c;
+
+ for (i = 0; i < n; i++)
+ {
+
+ MUL32x16INTO32(delay[AllPassOffset], coeff, temp, 15)
+ a = temp;
+ b = delay[DelayOffset];
+ DelayOffset++;
+
+ c = a + b;
+ if ((((c ^ a) & (c ^ b)) >> 31) != 0) /* overflow / underflow */
+ {
+ if(a < 0)
+ {
+ c = 0x80000000l;
+ }
+ else
+ {
+ c = 0x7FFFFFFFl;
+ }
+ }
+ *dst = c;
+ dst++;
+
+
+ MUL32x16INTO32(c, -coeff, temp, 15)
+ a = temp;
+ b = delay[AllPassOffset];
+ c = a + b;
+ if ((((c ^ a) & (c ^ b)) >> 31)!=0) /* overflow / underflow */
+ {
+ if(a < 0)
+ {
+ c = 0x80000000l;
+ }
+ else
+ {
+ c = 0x7FFFFFFFl;
+ }
+ }
+ delay[AllPassOffset] = c;
+ AllPassOffset++;
+
+ /* Make the delay buffer a circular buffer */
+ if (DelayOffset >= size)
+ {
+ DelayOffset = 0;
+ }
+
+ if (AllPassOffset >= size)
+ {
+ AllPassOffset = 0;
+ }
+ }
+
+ /* Update the offset */
+ *pAllPassOffset = AllPassOffset;
+
+ return;
+}
+
+/**********************************************************************************/
+
diff --git a/media/libeffects/lvm/lib/Common/src/DelayMix_16x16.c b/media/libeffects/lvm/lib/Common/src/DelayMix_16x16.c
new file mode 100755
index 0000000..ee41701
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/DelayMix_16x16.c
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/**********************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1000 $
+ $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $
+
+***********************************************************************************/
+
+/**********************************************************************************
+ INCLUDE FILES
+***********************************************************************************/
+
+#include "VectorArithmetic.h"
+
+/**********************************************************************************
+ FUNCTION DelayMix_16x16
+***********************************************************************************/
+
+void DelayMix_16x16(const LVM_INT16 *src, /* Source 1, to be delayed */
+ LVM_INT16 *delay, /* Delay buffer */
+ LVM_INT16 size, /* Delay size */
+ LVM_INT16 *dst, /* Source/destination */
+ LVM_INT16 *pOffset, /* Delay offset */
+ LVM_INT16 n) /* Number of stereo samples */
+{
+ LVM_INT16 i;
+ LVM_INT16 Offset = *pOffset;
+ LVM_INT16 temp;
+
+ for (i=0; i<n; i++)
+ {
+ /* Left channel */
+ temp = (LVM_INT16)((LVM_UINT32)((LVM_INT32)(*dst) + (LVM_INT32)delay[Offset]) >> 1);
+ *dst = temp;
+ dst++;
+
+ delay[Offset] = *src;
+ Offset++;
+ src++;
+
+
+ /* Right channel */
+ temp = (LVM_INT16)((LVM_UINT32)((LVM_INT32)(*dst) - (LVM_INT32)delay[Offset]) >> 1);
+ *dst = temp;
+ dst++;
+
+ delay[Offset] = *src;
+ Offset++;
+ src++;
+
+ /* Make the reverb delay buffer a circular buffer */
+ if (Offset >= size)
+ {
+ Offset = 0;
+ }
+ }
+
+ /* Update the offset */
+ *pOffset = Offset;
+
+ return;
+}
+
+/**********************************************************************************/
diff --git a/media/libeffects/lvm/lib/Common/src/DelayWrite_32.c b/media/libeffects/lvm/lib/Common/src/DelayWrite_32.c
new file mode 100755
index 0000000..0ae4c42e
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/DelayWrite_32.c
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+/**********************************************************************************
+ INCLUDE FILES
+***********************************************************************************/
+
+#include "VectorArithmetic.h"
+
+/**********************************************************************************
+ FUNCTION DelayMix_16x16
+***********************************************************************************/
+
+void DelayWrite_32(const LVM_INT32 *src, /* Source 1, to be delayed */
+ LVM_INT32 *delay, /* Delay buffer */
+ LVM_UINT16 size, /* Delay size */
+ LVM_UINT16 *pOffset, /* Delay offset */
+ LVM_INT16 n) /* Number of samples */
+{
+ LVM_INT16 i;
+ LVM_INT16 Offset = (LVM_INT16)*pOffset;
+
+ for (i=0; i<n; i++)
+ {
+ delay[Offset] = *src;
+ Offset++;
+ src++;
+
+ /* Make the delay buffer a circular buffer */
+ if (Offset >= size)
+ {
+ Offset = 0;
+ }
+ }
+
+ /* Update the offset */
+ *pOffset = (LVM_UINT16)Offset;
+
+ return;
+}
+
+/**********************************************************************************/
+
diff --git a/media/libeffects/lvm/lib/Common/src/FO_1I_D16F16C15_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/FO_1I_D16F16C15_TRC_WRA_01.c
new file mode 100755
index 0000000..831a115
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/FO_1I_D16F16C15_TRC_WRA_01.c
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+#include "BIQUAD.h"
+#include "FO_1I_D16F16Css_TRC_WRA_01_Private.h"
+#include "LVM_Macros.h"
+
+/**************************************************************************
+ ASSUMPTIONS:
+ COEFS-
+ pBiquadState->coefs[0] is A1,
+ pBiquadState->coefs[1] is A0,
+ pBiquadState->coefs[2] is -B1, these are in Q15 format
+
+ DELAYS-
+ pBiquadState->pDelays[0] is x(n-1)L in Q0 format
+ pBiquadState->pDelays[1] is y(n-1)L in Q0 format
+***************************************************************************/
+
+void FO_1I_D16F16C15_TRC_WRA_01( Biquad_Instance_t *pInstance,
+ LVM_INT16 *pDataIn,
+ LVM_INT16 *pDataOut,
+ LVM_INT16 NrSamples)
+ {
+ LVM_INT32 ynL;
+ LVM_INT16 ii;
+ PFilter_State pBiquadState = (PFilter_State) pInstance;
+
+ for (ii = NrSamples; ii != 0; ii--)
+ {
+
+ /**************************************************************************
+ PROCESSING OF THE LEFT CHANNEL
+ ***************************************************************************/
+ // ynL=A1 (Q15) * x(n-1)L (Q0) in Q15
+ ynL=(LVM_INT32)pBiquadState->coefs[0]* pBiquadState->pDelays[0];
+
+ // ynL+=A0 (Q15) * x(n)L (Q0) in Q15
+ ynL+=(LVM_INT32)pBiquadState->coefs[1]* (*pDataIn);
+
+ // ynL+= (-B1 (Q15) * y(n-1)L (Q0) ) in Q15
+ ynL+=(LVM_INT32)pBiquadState->coefs[2]*pBiquadState->pDelays[1];
+
+
+ ynL=(LVM_INT16)(ynL>>15); // ynL in Q0 format
+ /**************************************************************************
+ UPDATING THE DELAYS
+ ***************************************************************************/
+ pBiquadState->pDelays[1]=ynL; // Update y(n-1)L in Q0
+ pBiquadState->pDelays[0]=(*pDataIn++); // Update x(n-1)L in Q0
+
+ /**************************************************************************
+ WRITING THE OUTPUT
+ ***************************************************************************/
+ *pDataOut++=(LVM_INT16)ynL; // Write Left output in Q0
+
+ }
+
+ }
+
diff --git a/media/libeffects/lvm/lib/Common/src/FO_1I_D16F16Css_TRC_WRA_01_Init.c b/media/libeffects/lvm/lib/Common/src/FO_1I_D16F16Css_TRC_WRA_01_Init.c
new file mode 100755
index 0000000..4675084
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/FO_1I_D16F16Css_TRC_WRA_01_Init.c
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/* */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/*-------------------------------------------------------------------------*/
+#include "BIQUAD.h"
+#include "FO_1I_D16F16Css_TRC_WRA_01_Private.h"
+
+
+/*-------------------------------------------------------------------------*/
+/* FUNCTION: */
+/* FO_1I_D16F16Css_TRC_WRA_01_Init */
+/* */
+/* DESCRIPTION: */
+/* These functions initializes a BIQUAD filter defined as a cascade of */
+/* biquadratic Filter Sections. */
+/* */
+/* PARAMETERS: */
+/* pInstance - output, returns the pointer to the State Variable */
+/* This state pointer must be passed to any subsequent */
+/* call to "Biquad" functions. */
+/* pTaps - input, pointer to the taps memory */
+/* pCoef - input, pointer to the coefficient structure */
+/* N - M coefficient factor of QM.N */
+/* RETURNS: */
+/* void return code */
+/*-------------------------------------------------------------------------*/
+void FO_1I_D16F16Css_TRC_WRA_01_Init( Biquad_Instance_t *pInstance,
+ Biquad_1I_Order1_Taps_t *pTaps,
+ FO_C16_Coefs_t *pCoef)
+{
+ LVM_INT16 temp;
+ PFilter_State pBiquadState = (PFilter_State) pInstance;
+ pBiquadState->pDelays =(LVM_INT32 *) pTaps;
+
+ temp=pCoef->A1;
+ pBiquadState->coefs[0]=temp;
+ temp=pCoef->A0;
+ pBiquadState->coefs[1]=temp;
+ temp=pCoef->B1;
+ pBiquadState->coefs[2]=temp;
+}
+/*------------------------------------------------*/
+/* End Of File: FO_1I_D16F16Css_TRC_WRA_01_Init.c */
+
diff --git a/media/libeffects/lvm/lib/Common/src/FO_1I_D16F16Css_TRC_WRA_01_Private.h b/media/libeffects/lvm/lib/Common/src/FO_1I_D16F16Css_TRC_WRA_01_Private.h
new file mode 100755
index 0000000..e1a818c4
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/FO_1I_D16F16Css_TRC_WRA_01_Private.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef _FO_1I_D16F16CSS_TRC_WRA_01_PRIVATE_H_
+#define _FO_1I_D16F16CSS_TRC_WRA_01_PRIVATE_H_
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ */
+/* */
+/************************************************************************/
+
+/* The internal state variables are implemented in a (for the user) hidden structure */
+/* In this (private) file, the internal structure is declared fro private use. */
+typedef struct _Filter_State_
+{
+ LVM_INT32* pDelays; /* pointer to the delayed samples (data of 32 bits) */
+ LVM_INT16 coefs[3]; /* pointer to the filter coefficients */
+}Filter_State;
+
+typedef Filter_State * PFilter_State ;
+
+#endif /* _FO_1I_D16F16CSS_TRC_WRA_01_PRIVATE_H_ */
diff --git a/media/libeffects/lvm/lib/Common/src/FO_1I_D32F32C31_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/FO_1I_D32F32C31_TRC_WRA_01.c
new file mode 100755
index 0000000..9bdc5b4
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/FO_1I_D32F32C31_TRC_WRA_01.c
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+#include "BIQUAD.h"
+#include "FO_1I_D32F32Cll_TRC_WRA_01_Private.h"
+#include "LVM_Macros.h"
+
+
+/**************************************************************************
+ ASSUMPTIONS:
+ COEFS-
+ pBiquadState->coefs[0] is A1,
+ pBiquadState->coefs[1] is A0,
+ pBiquadState->coefs[2] is -B1, these are in Q31 format
+
+ DELAYS-
+ pBiquadState->pDelays[0] is x(n-1)L in Q0 format
+ pBiquadState->pDelays[1] is y(n-1)L in Q0 format
+***************************************************************************/
+
+void FO_1I_D32F32C31_TRC_WRA_01( Biquad_Instance_t *pInstance,
+ LVM_INT32 *pDataIn,
+ LVM_INT32 *pDataOut,
+ LVM_INT16 NrSamples)
+ {
+ LVM_INT32 ynL,templ;
+ LVM_INT16 ii;
+ PFilter_State pBiquadState = (PFilter_State) pInstance;
+
+ for (ii = NrSamples; ii != 0; ii--)
+ {
+
+ /**************************************************************************
+ PROCESSING OF THE LEFT CHANNEL
+ ***************************************************************************/
+ // ynL=A1 (Q31) * x(n-1)L (Q0) >>31 in Q0
+ MUL32x32INTO32(pBiquadState->coefs[0],pBiquadState->pDelays[0],ynL,31)
+
+ // ynL+=A0 (Q31) * x(n)L (Q0) >> 31 in Q0
+ MUL32x32INTO32(pBiquadState->coefs[1],*pDataIn,templ,31)
+ ynL+=templ;
+
+ // ynL+= (-B1 (Q31) * y(n-1)L (Q0) ) >> 31 in Q0
+ MUL32x32INTO32(pBiquadState->coefs[2],pBiquadState->pDelays[1],templ,31)
+ ynL+=templ;
+
+ /**************************************************************************
+ UPDATING THE DELAYS
+ ***************************************************************************/
+ pBiquadState->pDelays[1]=ynL; // Update y(n-1)L in Q0
+ pBiquadState->pDelays[0]=(*pDataIn++); // Update x(n-1)L in Q0
+
+ /**************************************************************************
+ WRITING THE OUTPUT
+ ***************************************************************************/
+ *pDataOut++=(LVM_INT32)ynL; // Write Left output in Q0
+ }
+
+ }
+
diff --git a/media/libeffects/lvm/lib/Common/src/FO_1I_D32F32Cll_TRC_WRA_01_Init.c b/media/libeffects/lvm/lib/Common/src/FO_1I_D32F32Cll_TRC_WRA_01_Init.c
new file mode 100755
index 0000000..eea0b64
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/FO_1I_D32F32Cll_TRC_WRA_01_Init.c
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+#include "BIQUAD.h"
+#include "FO_1I_D32F32Cll_TRC_WRA_01_Private.h"
+
+
+/*-------------------------------------------------------------------------*/
+/* FUNCTION: */
+/* FO_1I_D32F32Cll_TRC_WRA_01_Init */
+/* */
+/* DESCRIPTION: */
+/* These functions initializes a BIQUAD filter defined as a cascade of */
+/* biquadratic Filter Sections. */
+/* */
+/* PARAMETERS: */
+/* pInstance - output, returns the pointer to the State Variable */
+/* This state pointer must be passed to any subsequent */
+/* call to "Biquad" functions. */
+/* pTaps - input, pointer to the taps memory */
+/* pCoef - input, pointer to the coefficient structure */
+/* N - M coefficient factor of QM.N */
+/* RETURNS: */
+/* void return code */
+/*-------------------------------------------------------------------------*/
+void FO_1I_D32F32Cll_TRC_WRA_01_Init( Biquad_Instance_t *pInstance,
+ Biquad_1I_Order1_Taps_t *pTaps,
+ FO_C32_Coefs_t *pCoef)
+{
+ LVM_INT32 temp;
+ PFilter_State pBiquadState = (PFilter_State) pInstance;
+ pBiquadState->pDelays = (LVM_INT32 *) pTaps;
+
+ temp=pCoef->A1;
+ pBiquadState->coefs[0]=temp;
+ temp=pCoef->A0;
+ pBiquadState->coefs[1]=temp;
+ temp=pCoef->B1;
+ pBiquadState->coefs[2]=temp;
+}
+/*------------------------------------------------*/
+/* End Of File: FO_1I_D32F32Cll_TRC_WRA_01_Init.c */
+
diff --git a/media/libeffects/lvm/lib/Common/src/FO_1I_D32F32Cll_TRC_WRA_01_Private.h b/media/libeffects/lvm/lib/Common/src/FO_1I_D32F32Cll_TRC_WRA_01_Private.h
new file mode 100755
index 0000000..9329150
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/FO_1I_D32F32Cll_TRC_WRA_01_Private.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+#ifndef _FO_1I_D32F32CLL_TRC_WRA_01_PRIVATE_H_
+#define _FO_1I_D32F32CLL_TRC_WRA_01_PRIVATE_H_
+
+
+/* The internal state variables are implemented in a (for the user) hidden structure */
+/* In this (private) file, the internal structure is declared fro private use. */
+typedef struct _Filter_State_
+{
+ LVM_INT32 * pDelays; /* pointer to the delayed samples (data of 32 bits) */
+ LVM_INT32 coefs[3]; /* pointer to the filter coefficients */
+}Filter_State;
+
+typedef Filter_State * PFilter_State ;
+
+#endif /* _FO_1I_D32F32CLL_TRC_WRA_01_PRIVATE_H_ */
diff --git a/media/libeffects/lvm/lib/Common/src/FO_2I_D16F32C15_LShx_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/FO_2I_D16F32C15_LShx_TRC_WRA_01.c
new file mode 100755
index 0000000..4b219a2
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/FO_2I_D16F32C15_LShx_TRC_WRA_01.c
@@ -0,0 +1,137 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+#include "BIQUAD.h"
+#include "FO_2I_D16F32Css_LShx_TRC_WRA_01_Private.h"
+#include "LVM_Macros.h"
+
+/**************************************************************************
+ASSUMPTIONS:
+COEFS-
+pBiquadState->coefs[0] is A1,
+pBiquadState->coefs[1] is A0,
+pBiquadState->coefs[2] is -B1, these are in Q15 format
+pBiquadState->Shift is Shift value
+DELAYS-
+pBiquadState->pDelays[0] is x(n-1)L in Q15 format
+pBiquadState->pDelays[1] is y(n-1)L in Q30 format
+pBiquadState->pDelays[2] is x(n-1)R in Q15 format
+pBiquadState->pDelays[3] is y(n-1)R in Q30 format
+***************************************************************************/
+
+void FO_2I_D16F32C15_LShx_TRC_WRA_01(Biquad_Instance_t *pInstance,
+ LVM_INT16 *pDataIn,
+ LVM_INT16 *pDataOut,
+ LVM_INT16 NrSamples)
+ {
+ LVM_INT32 ynL,ynR;
+ LVM_INT32 Temp;
+ LVM_INT32 NegSatValue;
+ LVM_INT16 ii;
+ LVM_INT16 Shift;
+ PFilter_State pBiquadState = (PFilter_State) pInstance;
+
+ NegSatValue = LVM_MAXINT_16 +1;
+ NegSatValue = -NegSatValue;
+
+ Shift = pBiquadState->Shift;
+
+
+ for (ii = NrSamples; ii != 0; ii--)
+ {
+
+ /**************************************************************************
+ PROCESSING OF THE LEFT CHANNEL
+ ***************************************************************************/
+
+ // ynL =A1 (Q15) * x(n-1)L (Q15) in Q30
+ ynL=(LVM_INT32)pBiquadState->coefs[0]* pBiquadState->pDelays[0];
+ // ynR =A1 (Q15) * x(n-1)R (Q15) in Q30
+ ynR=(LVM_INT32)pBiquadState->coefs[0]* pBiquadState->pDelays[2];
+
+
+ // ynL+=A0 (Q15) * x(n)L (Q15) in Q30
+ ynL+=(LVM_INT32)pBiquadState->coefs[1]* (*pDataIn);
+ // ynR+=A0 (Q15) * x(n)L (Q15) in Q30
+ ynR+=(LVM_INT32)pBiquadState->coefs[1]* (*(pDataIn+1));
+
+
+ // ynL += (-B1 (Q15) * y(n-1)L (Q30) ) in Q30
+ MUL32x16INTO32(pBiquadState->pDelays[1],pBiquadState->coefs[2],Temp,15);
+ ynL +=Temp;
+ // ynR += (-B1 (Q15) * y(n-1)R (Q30) ) in Q30
+ MUL32x16INTO32(pBiquadState->pDelays[3],pBiquadState->coefs[2],Temp,15);
+ ynR +=Temp;
+
+
+ /**************************************************************************
+ UPDATING THE DELAYS
+ ***************************************************************************/
+ pBiquadState->pDelays[1]=ynL; // Update y(n-1)L in Q30
+ pBiquadState->pDelays[0]=(*pDataIn++); // Update x(n-1)L in Q15
+
+ pBiquadState->pDelays[3]=ynR; // Update y(n-1)R in Q30
+ pBiquadState->pDelays[2]=(*pDataIn++); // Update x(n-1)R in Q15
+
+ /**************************************************************************
+ WRITING THE OUTPUT
+ ***************************************************************************/
+ /*Apply shift: Instead of left shift on 16-bit result, right shift of (15-shift) is applied
+ for better SNR*/
+ ynL = ynL>>(15-Shift);
+ ynR = ynR>>(15-Shift);
+
+ /*Saturate results*/
+ if(ynL > LVM_MAXINT_16)
+ {
+ ynL = LVM_MAXINT_16;
+ }
+ else
+ {
+ if(ynL < NegSatValue)
+ {
+ ynL = NegSatValue;
+ }
+ }
+
+ if(ynR > LVM_MAXINT_16)
+ {
+ ynR = LVM_MAXINT_16;
+ }
+ else
+ {
+ if(ynR < NegSatValue)
+ {
+ ynR = NegSatValue;
+ }
+ }
+
+ *pDataOut++=(LVM_INT16)ynL;
+ *pDataOut++=(LVM_INT16)ynR;
+ }
+
+ }
+
diff --git a/media/libeffects/lvm/lib/Common/src/FO_2I_D16F32Css_LShx_TRC_WRA_01_Init.c b/media/libeffects/lvm/lib/Common/src/FO_2I_D16F32Css_LShx_TRC_WRA_01_Init.c
new file mode 100755
index 0000000..7f212f5
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/FO_2I_D16F32Css_LShx_TRC_WRA_01_Init.c
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/* */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/*-------------------------------------------------------------------------*/
+#include "BIQUAD.h"
+#include "FO_2I_D16F32Css_LShx_TRC_WRA_01_Private.h"
+
+/*-------------------------------------------------------------------------*/
+/* FUNCTION: */
+/* FO_2I_D16F32Css_LShx_TRC_WRA_01_Init */
+/* */
+/* DESCRIPTION: */
+/* These functions initializes a BIQUAD filter defined as a cascade of */
+/* biquadratic Filter Sections. */
+/* */
+/* PARAMETERS: */
+/* pInstance - output, returns the pointer to the State Variable */
+/* This state pointer must be passed to any subsequent */
+/* call to "Biquad" functions. */
+/* pTaps - input, pointer to the taps memory */
+/* pCoef - input, pointer to the coefficient structure */
+/* N - M coefficient factor of QM.N */
+/* RETURNS: */
+/* void return code */
+/*-------------------------------------------------------------------------*/
+void FO_2I_D16F32Css_LShx_TRC_WRA_01_Init(Biquad_Instance_t *pInstance,
+ Biquad_2I_Order1_Taps_t *pTaps,
+ FO_C16_LShx_Coefs_t *pCoef)
+{
+ LVM_INT16 temp;
+ PFilter_State pBiquadState = (PFilter_State) pInstance;
+ pBiquadState->pDelays =(LVM_INT32 *) pTaps ;
+
+ temp=pCoef->A1;
+ pBiquadState->coefs[0]=temp;
+ temp=pCoef->A0;
+ pBiquadState->coefs[1]=temp;
+ temp=pCoef->B1;
+ pBiquadState->coefs[2]=temp;
+
+ temp=pCoef->Shift;
+ pBiquadState->Shift = temp;
+}
+/*-------------------------------------------------------------------------*/
+/* End Of File: FO_2I_D16F32Css_LShx_TRC_WRA_01_Init.c */
+
diff --git a/media/libeffects/lvm/lib/Common/src/FO_2I_D16F32Css_LShx_TRC_WRA_01_Private.h b/media/libeffects/lvm/lib/Common/src/FO_2I_D16F32Css_LShx_TRC_WRA_01_Private.h
new file mode 100755
index 0000000..6a4564a
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/FO_2I_D16F32Css_LShx_TRC_WRA_01_Private.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef _FO_2I_D16F32CSS_LSHX_TRC_WRA_01_PRIVATE_H_
+#define _FO_2I_D16F32CSS_LSHX_TRC_WRA_01_PRIVATE_H_
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+/* The internal state variables are implemented in a (for the user) hidden structure */
+/* In this (private) file, the internal structure is declared fro private use. */
+typedef struct _Filter_State_
+{
+ LVM_INT32 *pDelays; /* pointer to the delayed samples (data of 32 bits) */
+ LVM_INT16 coefs[3]; /* pointer to the filter coefficients */
+ LVM_INT16 Shift; /* Shift value*/
+}Filter_State;
+
+typedef Filter_State * PFilter_State ;
+
+#endif /* _FO_2I_D16F32CSS_LSHX_TRC_WRA_01_PRIVATE_H_ */
diff --git a/media/libeffects/lvm/lib/Common/src/Filters.h b/media/libeffects/lvm/lib/Common/src/Filters.h
new file mode 100755
index 0000000..a274f32
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/Filters.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1001 $
+ $Date: 2010-06-28 13:23:02 +0200 (Mon, 28 Jun 2010) $
+
+*************************************************************************************/
+
+#ifndef FILTERS_H
+#define FILTERS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#include "LVM_Types.h"
+
+/************************************************************************************/
+/* */
+/* Structures */
+/* */
+/************************************************************************************/
+
+/*
+ * Biquad with coefficients A0, A1, A2, B1 and B2 coefficients
+ */
+/* Single precision (16-bit) Biquad section coefficients */
+typedef struct
+{
+ LVM_INT16 A0;
+ LVM_INT16 A1;
+ LVM_INT16 A2;
+ LVM_INT16 B1;
+ LVM_INT16 B2;
+ LVM_UINT16 Scale;
+} BiquadA012B12CoefsSP_t;
+
+
+/*
+ * Biquad with coefficients A0, A1 and B1 coefficients
+ */
+/* Single precision (16-bit) Biquad section coefficients */
+typedef struct
+{
+ LVM_INT16 A0;
+ LVM_INT16 A1;
+ LVM_INT16 B1;
+ LVM_UINT16 Scale;
+} BiquadA01B1CoefsSP_t;
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* FILTERS_H */
+
diff --git a/media/libeffects/lvm/lib/Common/src/From2iToMS_16x16.c b/media/libeffects/lvm/lib/Common/src/From2iToMS_16x16.c
new file mode 100755
index 0000000..fb00768
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/From2iToMS_16x16.c
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/**********************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1000 $
+ $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $
+
+***********************************************************************************/
+
+/**********************************************************************************
+ INCLUDE FILES
+***********************************************************************************/
+
+#include "VectorArithmetic.h"
+
+/**********************************************************************************
+ FUNCTION From2iToMS_16x16
+***********************************************************************************/
+
+void From2iToMS_16x16( const LVM_INT16 *src,
+ LVM_INT16 *dstM,
+ LVM_INT16 *dstS,
+ LVM_INT16 n )
+{
+ LVM_INT32 temp1,left,right;
+ LVM_INT16 ii;
+ for (ii = n; ii != 0; ii--)
+ {
+ left = (LVM_INT32)*src;
+ src++;
+
+ right = (LVM_INT32)*src;
+ src++;
+
+ /* Compute M signal*/
+ temp1 = (left+right)>>1;
+ *dstM = (LVM_INT16)temp1;
+ dstM++;
+
+ /* Compute S signal*/
+ temp1 = (left-right)>>1;
+ *dstS = (LVM_INT16)temp1;
+ dstS++;
+ }
+
+ return;
+}
+
+/**********************************************************************************/
diff --git a/media/libeffects/lvm/lib/Common/src/From2iToMono_16.c b/media/libeffects/lvm/lib/Common/src/From2iToMono_16.c
new file mode 100755
index 0000000..0ebb4ae
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/From2iToMono_16.c
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/**********************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1000 $
+ $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $
+
+***********************************************************************************/
+
+/**********************************************************************************
+ INCLUDE FILES
+***********************************************************************************/
+
+#include "VectorArithmetic.h"
+
+/**********************************************************************************
+ FUNCTION From2iToMono_16
+***********************************************************************************/
+
+void From2iToMono_16( const LVM_INT16 *src,
+ LVM_INT16 *dst,
+ LVM_INT16 n)
+{
+ LVM_INT16 ii;
+ LVM_INT32 Temp;
+ for (ii = n; ii != 0; ii--)
+ {
+ Temp = (LVM_INT32)*src;
+ src++;
+
+ Temp += (LVM_INT32)*src;
+ src++;
+
+ *dst = (LVM_INT16)(Temp >>1);
+ dst++;
+ }
+
+ return;
+}
+
+/**********************************************************************************/
diff --git a/media/libeffects/lvm/lib/Common/src/From2iToMono_32.c b/media/libeffects/lvm/lib/Common/src/From2iToMono_32.c
new file mode 100755
index 0000000..5181368
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/From2iToMono_32.c
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/**********************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1000 $
+ $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $
+
+***********************************************************************************/
+
+/**********************************************************************************
+ INCLUDE FILES
+***********************************************************************************/
+
+#include "VectorArithmetic.h"
+
+/**********************************************************************************
+ FUNCTION From2iToMono_32
+***********************************************************************************/
+
+void From2iToMono_32( const LVM_INT32 *src,
+ LVM_INT32 *dst,
+ LVM_INT16 n)
+{
+ LVM_INT16 ii;
+ LVM_INT32 Temp;
+
+ for (ii = n; ii != 0; ii--)
+ {
+ Temp = (*src>>1);
+ src++;
+
+ Temp +=(*src>>1);
+ src++;
+
+ *dst = Temp;
+ dst++;
+ }
+
+ return;
+}
+
+/**********************************************************************************/
diff --git a/media/libeffects/lvm/lib/Common/src/InstAlloc.c b/media/libeffects/lvm/lib/Common/src/InstAlloc.c
new file mode 100755
index 0000000..ff900e0
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/InstAlloc.c
@@ -0,0 +1,194 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+#include "InstAlloc.h"
+
+/****************************************************************************************
+ * Name : InstAlloc_Init()
+ * Input : pms - Pointer to the INST_ALLOC instance
+ StartAddr - Base address of the instance memory
+ * Returns : Error code
+ * Description : Initializes the instance distribution and memory size calculation function
+ * Remarks :
+ ****************************************************************************************/
+
+void InstAlloc_Init( INST_ALLOC *pms,
+ void *StartAddr )
+{
+ pms->TotalSize = 3;
+ pms->pNextMember = (LVM_UINT32)(((LVM_UINT32)StartAddr + 3) & 0xFFFFFFFC);/* This code will fail if the platform address space is more than 32-bits*/
+}
+
+
+/****************************************************************************************
+ * Name : InstAlloc_AddMember()
+ * Input : pms - Pointer to the INST_ALLOC instance
+ Size - The size in bytes of the new added member
+ * Returns : A pointer to the new added member
+ * Description : Allocates space for a new member in the instance memory and returns
+ a pointer to this new member. The start address of all members will
+ be 32 bit alligned.
+ * Remarks :
+ ****************************************************************************************/
+
+void* InstAlloc_AddMember( INST_ALLOC *pms,
+ LVM_UINT32 Size )
+{
+ void *NewMemberAddress; /* Variable to temporarily store the return value */
+ NewMemberAddress = (void*)pms->pNextMember;
+
+ Size = ((Size + 3) & 0xFFFFFFFC); /* Ceil the size to a multiple of four */
+
+ pms->TotalSize += Size;
+ pms->pNextMember += Size;
+
+ return(NewMemberAddress);
+}
+
+
+/****************************************************************************************
+ * Name : InstAlloc_GetTotal()
+ * Input : pms - Pointer to the INST_ALLOC instance
+ * Returns : The instance memory size
+ * Description : This functions returns the calculated instance memory size
+ * Remarks :
+ ****************************************************************************************/
+
+LVM_UINT32 InstAlloc_GetTotal( INST_ALLOC *pms)
+{
+ if (pms->TotalSize > 3)
+ {
+ return(pms->TotalSize);
+ }
+ else
+ {
+ return 0; /* No memory added */
+ }
+}
+
+
+void InstAlloc_InitAll( INST_ALLOC *pms,
+ LVM_MemoryTable_st *pMemoryTable)
+{
+ LVM_UINT32 StartAddr;
+
+ StartAddr = (LVM_UINT32)pMemoryTable->Region[LVM_PERSISTENT_SLOW_DATA].pBaseAddress;
+
+ pms[0].TotalSize = 3;
+ pms[0].pNextMember = (LVM_UINT32)(((LVM_UINT32)StartAddr + 3) & 0xFFFFFFFC);
+
+
+ StartAddr = (LVM_UINT32)pMemoryTable->Region[LVM_PERSISTENT_FAST_DATA].pBaseAddress;
+
+ pms[1].TotalSize = 3;
+ pms[1].pNextMember = (LVM_UINT32)(((LVM_UINT32)StartAddr + 3) & 0xFFFFFFFC);
+
+
+ StartAddr = (LVM_UINT32)pMemoryTable->Region[LVM_PERSISTENT_FAST_COEF].pBaseAddress;
+
+ pms[2].TotalSize = 3;
+ pms[2].pNextMember = (LVM_UINT32)(((LVM_UINT32)StartAddr + 3) & 0xFFFFFFFC);
+
+
+ StartAddr = (LVM_UINT32)pMemoryTable->Region[LVM_TEMPORARY_FAST].pBaseAddress;
+
+ pms[3].TotalSize = 3;
+ pms[3].pNextMember = (LVM_UINT32)(((LVM_UINT32)StartAddr + 3) & 0xFFFFFFFC);
+
+}
+
+/****************************************************************************************
+ * Name : InstAlloc_InitAll_NULL()
+ * Input : pms - Pointer to array of four INST_ALLOC instances
+ * Returns : Nothing
+ * Description : This function reserves Size of 3 bytes for all memory regions and
+ * intializes pNextMember for all regions to 0
+ * Remarks :
+ ****************************************************************************************/
+
+void InstAlloc_InitAll_NULL( INST_ALLOC *pms)
+{
+ pms[0].TotalSize = 3;
+ pms[0].pNextMember = 0;
+
+
+ pms[1].TotalSize = 3;
+ pms[1].pNextMember = 0;
+
+ pms[2].TotalSize = 3;
+ pms[2].pNextMember = 0;
+
+ pms[3].TotalSize = 3;
+ pms[3].pNextMember = 0;
+
+}
+
+
+void* InstAlloc_AddMemberAll( INST_ALLOC *pms,
+ LVM_UINT32 Size[],
+ LVM_MemoryTable_st *pMemoryTable)
+{
+ void *NewMemberAddress; /* Variable to temporarily store the return value */
+
+ /* coverity[returned_pointer] Ignore coverity warning that ptr is not used */
+ NewMemberAddress = InstAlloc_AddMember(&pms[LVM_PERSISTENT_SLOW_DATA], Size[LVM_PERSISTENT_SLOW_DATA]);
+
+ pMemoryTable->Region[LVM_PERSISTENT_SLOW_DATA].Size = InstAlloc_GetTotal(&pms[LVM_PERSISTENT_SLOW_DATA]);
+ pMemoryTable->Region[LVM_PERSISTENT_SLOW_DATA].Type = LVM_PERSISTENT_SLOW_DATA;
+ pMemoryTable->Region[LVM_PERSISTENT_SLOW_DATA].pBaseAddress = LVM_NULL;
+
+ NewMemberAddress = InstAlloc_AddMember(&pms[LVM_PERSISTENT_FAST_DATA], Size[LVM_PERSISTENT_FAST_DATA]);
+
+ pMemoryTable->Region[LVM_PERSISTENT_FAST_DATA].Size = InstAlloc_GetTotal(&pms[LVM_PERSISTENT_FAST_DATA]);
+ pMemoryTable->Region[LVM_PERSISTENT_FAST_DATA].Type = LVM_PERSISTENT_FAST_DATA;
+ pMemoryTable->Region[LVM_PERSISTENT_FAST_DATA].pBaseAddress = LVM_NULL;
+
+ NewMemberAddress = InstAlloc_AddMember(&pms[LVM_PERSISTENT_FAST_COEF], Size[LVM_PERSISTENT_FAST_COEF]);
+
+ pMemoryTable->Region[LVM_PERSISTENT_FAST_COEF].Size = InstAlloc_GetTotal(&pms[LVM_PERSISTENT_FAST_COEF]);
+ pMemoryTable->Region[LVM_PERSISTENT_FAST_COEF].Type = LVM_PERSISTENT_FAST_COEF;
+ pMemoryTable->Region[LVM_PERSISTENT_FAST_COEF].pBaseAddress = LVM_NULL;
+
+ NewMemberAddress = InstAlloc_AddMember(&pms[LVM_TEMPORARY_FAST], Size[LVM_TEMPORARY_FAST]);
+
+ pMemoryTable->Region[LVM_TEMPORARY_FAST].Size = InstAlloc_GetTotal(&pms[LVM_TEMPORARY_FAST]);
+ pMemoryTable->Region[LVM_TEMPORARY_FAST].Type = LVM_TEMPORARY_FAST;
+ pMemoryTable->Region[LVM_TEMPORARY_FAST].pBaseAddress = LVM_NULL;
+
+ return(NewMemberAddress);
+}
+
+
+void* InstAlloc_AddMemberAllRet( INST_ALLOC *pms,
+ LVM_UINT32 Size[],
+ void **ptr)
+{
+ ptr[0] = InstAlloc_AddMember(&pms[LVM_PERSISTENT_SLOW_DATA], Size[LVM_PERSISTENT_SLOW_DATA]);
+ ptr[1] = InstAlloc_AddMember(&pms[LVM_PERSISTENT_FAST_DATA], Size[LVM_PERSISTENT_FAST_DATA]);
+ ptr[2] = InstAlloc_AddMember(&pms[LVM_PERSISTENT_FAST_COEF], Size[LVM_PERSISTENT_FAST_COEF]);
+ ptr[3] = InstAlloc_AddMember(&pms[LVM_TEMPORARY_FAST], Size[LVM_TEMPORARY_FAST]);
+
+ return (ptr[0]);
+}
diff --git a/media/libeffects/lvm/lib/Common/src/Int16LShiftToInt32_16x32.c b/media/libeffects/lvm/lib/Common/src/Int16LShiftToInt32_16x32.c
new file mode 100755
index 0000000..e6be756
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/Int16LShiftToInt32_16x32.c
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/**********************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1000 $
+ $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $
+
+***********************************************************************************/
+
+/**********************************************************************************
+ INCLUDE FILES
+***********************************************************************************/
+
+#include "VectorArithmetic.h"
+
+/**********************************************************************************
+ FUNCTION INT16LSHIFTTOINT32_16X32
+***********************************************************************************/
+
+void Int16LShiftToInt32_16x32(const LVM_INT16 *src,
+ LVM_INT32 *dst,
+ LVM_INT16 n,
+ LVM_INT16 shift )
+{
+ LVM_INT16 ii;
+
+ src += n-1;
+ dst += n-1;
+
+ for (ii = n; ii != 0; ii--)
+ {
+ *dst = ( ((LVM_INT32)*src) << shift);
+ src--;
+ dst--;
+ }
+
+ return;
+}
+
+/**********************************************************************************/
diff --git a/media/libeffects/lvm/lib/Common/src/Int32RShiftToInt16_Sat_32x16.c b/media/libeffects/lvm/lib/Common/src/Int32RShiftToInt16_Sat_32x16.c
new file mode 100755
index 0000000..b21eef5
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/Int32RShiftToInt16_Sat_32x16.c
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/**********************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1000 $
+ $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $
+
+***********************************************************************************/
+
+/**********************************************************************************
+ INCLUDE FILES
+***********************************************************************************/
+
+#include "VectorArithmetic.h"
+
+/**********************************************************************************
+ FUNCTION INT32RSHIFTTOINT16_SAT_32X16
+***********************************************************************************/
+
+void Int32RShiftToInt16_Sat_32x16(const LVM_INT32 *src,
+ LVM_INT16 *dst,
+ LVM_INT16 n,
+ LVM_INT16 shift )
+{
+ LVM_INT32 temp;
+ LVM_INT16 ii;
+
+ for (ii = n; ii != 0; ii--)
+ {
+ temp = *src >> shift;
+ src++;
+
+ if (temp > 0x00007FFF)
+ {
+ *dst = 0x7FFF;
+ }
+ else if (temp < -0x00008000)
+ {
+ *dst = - 0x8000;
+ }
+ else
+ {
+ *dst = (LVM_INT16)temp;
+ }
+
+ dst++;
+ }
+
+ return;
+}
+
+/**********************************************************************************/
diff --git a/media/libeffects/lvm/lib/Common/src/JoinTo2i_32x32.c b/media/libeffects/lvm/lib/Common/src/JoinTo2i_32x32.c
new file mode 100755
index 0000000..e04f1c3
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/JoinTo2i_32x32.c
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+/**********************************************************************************
+ INCLUDE FILES
+***********************************************************************************/
+
+#include "VectorArithmetic.h"
+
+/**********************************************************************************
+ FUNCTION JoinTo2i_32x32
+***********************************************************************************/
+
+void JoinTo2i_32x32( const LVM_INT32 *srcL,
+ const LVM_INT32 *srcR,
+ LVM_INT32 *dst,
+ LVM_INT16 n )
+{
+ LVM_INT16 ii;
+
+ srcL += n-1;
+ srcR += n-1;
+ dst += ((2*n)-1);
+
+ for (ii = n; ii != 0; ii--)
+ {
+ *dst = *srcR;
+ dst--;
+ srcR--;
+
+ *dst = *srcL;
+ dst--;
+ srcL--;
+ }
+
+ return;
+}
+
+/**********************************************************************************/
+
diff --git a/media/libeffects/lvm/lib/Common/src/LVC_Core_MixHard_1St_2i_D16C31_SAT.c b/media/libeffects/lvm/lib/Common/src/LVC_Core_MixHard_1St_2i_D16C31_SAT.c
new file mode 100755
index 0000000..c1d2b2c
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/LVC_Core_MixHard_1St_2i_D16C31_SAT.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/**********************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1000 $
+ $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $
+
+***********************************************************************************/
+
+/**********************************************************************************
+ INCLUDE FILES
+***********************************************************************************/
+
+#include "LVC_Mixer_Private.h"
+#include "LVM_Macros.h"
+#include "ScalarArithmetic.h"
+
+
+/**********************************************************************************
+ FUNCTION LVC_Core_MixHard_1St_2i_D16C31_SAT
+***********************************************************************************/
+
+void LVC_Core_MixHard_1St_2i_D16C31_SAT( LVMixer3_st *ptrInstance1,
+ LVMixer3_st *ptrInstance2,
+ const LVM_INT16 *src,
+ LVM_INT16 *dst,
+ LVM_INT16 n)
+{
+ LVM_INT32 Temp;
+ LVM_INT16 ii;
+ LVM_INT16 Current1Short;
+ LVM_INT16 Current2Short;
+ Mix_Private_st *pInstance1=(Mix_Private_st *)(ptrInstance1->PrivateParams);
+ Mix_Private_st *pInstance2=(Mix_Private_st *)(ptrInstance2->PrivateParams);
+
+
+ Current1Short = (LVM_INT16)(pInstance1->Current >> 16);
+ Current2Short = (LVM_INT16)(pInstance2->Current >> 16);
+
+ for (ii = n; ii != 0; ii--)
+ {
+ Temp = ((LVM_INT32)*(src++) * (LVM_INT32)Current1Short)>>15;
+ if (Temp > 0x00007FFF)
+ *dst++ = 0x7FFF;
+ else if (Temp < -0x00008000)
+ *dst++ = - 0x8000;
+ else
+ *dst++ = (LVM_INT16)Temp;
+
+ Temp = ((LVM_INT32)*(src++) * (LVM_INT32)Current2Short)>>15;
+ if (Temp > 0x00007FFF)
+ *dst++ = 0x7FFF;
+ else if (Temp < -0x00008000)
+ *dst++ = - 0x8000;
+ else
+ *dst++ = (LVM_INT16)Temp;
+ }
+
+
+}
+/**********************************************************************************/
diff --git a/media/libeffects/lvm/lib/Common/src/LVC_Core_MixHard_2St_D16C31_SAT.c b/media/libeffects/lvm/lib/Common/src/LVC_Core_MixHard_2St_D16C31_SAT.c
new file mode 100755
index 0000000..2bb212c
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/LVC_Core_MixHard_2St_D16C31_SAT.c
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/**********************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1000 $
+ $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $
+
+***********************************************************************************/
+
+/**********************************************************************************
+ INCLUDE FILES
+***********************************************************************************/
+
+#include "LVC_Mixer_Private.h"
+
+/**********************************************************************************
+ FUNCTION LVCore_MIXHARD_2ST_D16C31_SAT
+***********************************************************************************/
+
+void LVC_Core_MixHard_2St_D16C31_SAT( LVMixer3_st *ptrInstance1,
+ LVMixer3_st *ptrInstance2,
+ const LVM_INT16 *src1,
+ const LVM_INT16 *src2,
+ LVM_INT16 *dst,
+ LVM_INT16 n)
+{
+ LVM_INT32 Temp;
+ LVM_INT16 ii;
+ LVM_INT16 Current1Short;
+ LVM_INT16 Current2Short;
+ Mix_Private_st *pInstance1=(Mix_Private_st *)(ptrInstance1->PrivateParams);
+ Mix_Private_st *pInstance2=(Mix_Private_st *)(ptrInstance2->PrivateParams);
+
+
+ Current1Short = (LVM_INT16)(pInstance1->Current >> 16);
+ Current2Short = (LVM_INT16)(pInstance2->Current >> 16);
+
+ for (ii = n; ii != 0; ii--){
+ Temp = (((LVM_INT32)*(src1++) * (LVM_INT32)Current1Short)>>15) +
+ (((LVM_INT32)*(src2++) * (LVM_INT32)Current2Short)>>15);
+ if (Temp > 0x00007FFF)
+ *dst++ = 0x7FFF;
+ else if (Temp < -0x00008000)
+ *dst++ = - 0x8000;
+ else
+ *dst++ = (LVM_INT16)Temp;
+ }
+}
+
+
+/**********************************************************************************/
diff --git a/media/libeffects/lvm/lib/Common/src/LVC_Core_MixInSoft_D16C31_SAT.c b/media/libeffects/lvm/lib/Common/src/LVC_Core_MixInSoft_D16C31_SAT.c
new file mode 100755
index 0000000..0408f42
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/LVC_Core_MixInSoft_D16C31_SAT.c
@@ -0,0 +1,136 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/**********************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1000 $
+ $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $
+
+***********************************************************************************/
+
+/**********************************************************************************
+ INCLUDE FILES
+***********************************************************************************/
+
+#include "LVC_Mixer_Private.h"
+#include "LVM_Macros.h"
+
+/**********************************************************************************
+ FUNCTION LVCore_MIXSOFT_1ST_D16C31_WRA
+***********************************************************************************/
+
+void LVC_Core_MixInSoft_D16C31_SAT( LVMixer3_st *ptrInstance,
+ const LVM_INT16 *src,
+ LVM_INT16 *dst,
+ LVM_INT16 n)
+{
+
+ LVM_INT16 OutLoop;
+ LVM_INT16 InLoop;
+ LVM_INT16 CurrentShort;
+ LVM_INT32 ii,jj;
+ Mix_Private_st *pInstance=(Mix_Private_st *)(ptrInstance->PrivateParams);
+ LVM_INT32 Delta=pInstance->Delta;
+ LVM_INT32 Current=pInstance->Current;
+ LVM_INT32 Target=pInstance->Target;
+ LVM_INT32 Temp;
+
+ InLoop = (LVM_INT16)(n >> 2); /* Process per 4 samples */
+ OutLoop = (LVM_INT16)(n - (InLoop << 2));
+
+ if(Current<Target){
+ if (OutLoop){
+ ADD2_SAT_32x32(Current,Delta,Temp); /* Q31 + Q31 into Q31*/
+ Current=Temp;
+ if (Current > Target)
+ Current = Target;
+
+ CurrentShort = (LVM_INT16)(Current>>16); /* From Q31 to Q15*/
+
+ for (ii = OutLoop; ii != 0; ii--){
+ Temp = ((LVM_INT32)*dst) + (((LVM_INT32)*(src++) * CurrentShort)>>15); /* Q15 + Q15*Q15>>15 into Q15 */
+ if (Temp > 0x00007FFF)
+ *dst++ = 0x7FFF;
+ else if (Temp < -0x00008000)
+ *dst++ = - 0x8000;
+ else
+ *dst++ = (LVM_INT16)Temp;
+ }
+ }
+
+ for (ii = InLoop; ii != 0; ii--){
+ ADD2_SAT_32x32(Current,Delta,Temp); /* Q31 + Q31 into Q31*/
+ Current=Temp;
+ if (Current > Target)
+ Current = Target;
+
+ CurrentShort = (LVM_INT16)(Current>>16); /* From Q31 to Q15*/
+
+ for (jj = 4; jj!=0 ; jj--){
+ Temp = ((LVM_INT32)*dst) + (((LVM_INT32)*(src++) * CurrentShort)>>15); /* Q15 + Q15*Q15>>15 into Q15 */
+ if (Temp > 0x00007FFF)
+ *dst++ = 0x7FFF;
+ else if (Temp < -0x00008000)
+ *dst++ = - 0x8000;
+ else
+ *dst++ = (LVM_INT16)Temp;
+ }
+ }
+ }
+ else{
+ if (OutLoop){
+ Current -= Delta; /* Q31 + Q31 into Q31*/
+ if (Current < Target)
+ Current = Target;
+
+ CurrentShort = (LVM_INT16)(Current>>16); /* From Q31 to Q15*/
+
+ for (ii = OutLoop; ii != 0; ii--){
+ Temp = ((LVM_INT32)*dst) + (((LVM_INT32)*(src++) * CurrentShort)>>15); /* Q15 + Q15*Q15>>15 into Q15 */
+ if (Temp > 0x00007FFF)
+ *dst++ = 0x7FFF;
+ else if (Temp < -0x00008000)
+ *dst++ = - 0x8000;
+ else
+ *dst++ = (LVM_INT16)Temp;
+ }
+ }
+
+ for (ii = InLoop; ii != 0; ii--){
+ Current -= Delta; /* Q31 + Q31 into Q31*/
+ if (Current < Target)
+ Current = Target;
+
+ CurrentShort = (LVM_INT16)(Current>>16); /* From Q31 to Q15*/
+
+ for (jj = 4; jj!=0 ; jj--){
+ Temp = ((LVM_INT32)*dst) + (((LVM_INT32)*(src++) * CurrentShort)>>15); /* Q15 + Q15*Q15>>15 into Q15 */
+ if (Temp > 0x00007FFF)
+ *dst++ = 0x7FFF;
+ else if (Temp < -0x00008000)
+ *dst++ = - 0x8000;
+ else
+ *dst++ = (LVM_INT16)Temp;
+ }
+ }
+ }
+ pInstance->Current=Current;
+}
+
+
+/**********************************************************************************/
diff --git a/media/libeffects/lvm/lib/Common/src/LVC_Core_MixSoft_1St_2i_D16C31_WRA.c b/media/libeffects/lvm/lib/Common/src/LVC_Core_MixSoft_1St_2i_D16C31_WRA.c
new file mode 100755
index 0000000..2847d47
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/LVC_Core_MixSoft_1St_2i_D16C31_WRA.c
@@ -0,0 +1,151 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/**********************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1000 $
+ $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $
+
+***********************************************************************************/
+
+/**********************************************************************************
+ INCLUDE FILES
+***********************************************************************************/
+
+#include "LVC_Mixer_Private.h"
+#include "ScalarArithmetic.h"
+#include "LVM_Macros.h"
+
+/**********************************************************************************
+ FUNCTION LVC_Core_MixSoft_1St_2i_D16C31_WRA
+***********************************************************************************/
+
+void LVC_Core_MixSoft_1St_2i_D16C31_WRA( LVMixer3_st *ptrInstance1,
+ LVMixer3_st *ptrInstance2,
+ const LVM_INT16 *src,
+ LVM_INT16 *dst,
+ LVM_INT16 n)
+{
+ LVM_INT16 OutLoop;
+ LVM_INT16 InLoop;
+ LVM_INT16 CurrentShortL;
+ LVM_INT16 CurrentShortR;
+ LVM_INT32 ii;
+ Mix_Private_st *pInstanceL=(Mix_Private_st *)(ptrInstance1->PrivateParams);
+ Mix_Private_st *pInstanceR=(Mix_Private_st *)(ptrInstance2->PrivateParams);
+
+ LVM_INT32 DeltaL=pInstanceL->Delta;
+ LVM_INT32 CurrentL=pInstanceL->Current;
+ LVM_INT32 TargetL=pInstanceL->Target;
+
+ LVM_INT32 DeltaR=pInstanceR->Delta;
+ LVM_INT32 CurrentR=pInstanceR->Current;
+ LVM_INT32 TargetR=pInstanceR->Target;
+
+ LVM_INT32 Temp;
+
+ InLoop = (LVM_INT16)(n >> 2); /* Process per 4 samples */
+ OutLoop = (LVM_INT16)(n - (InLoop << 2));
+
+ if (OutLoop)
+ {
+ if(CurrentL<TargetL)
+ {
+ ADD2_SAT_32x32(CurrentL,DeltaL,Temp); /* Q31 + Q31 into Q31*/
+ CurrentL=Temp;
+ if (CurrentL > TargetL)
+ CurrentL = TargetL;
+ }
+ else
+ {
+ CurrentL -= DeltaL; /* Q31 + Q31 into Q31*/
+ if (CurrentL < TargetL)
+ CurrentL = TargetL;
+ }
+
+ if(CurrentR<TargetR)
+ {
+ ADD2_SAT_32x32(CurrentR,DeltaR,Temp); /* Q31 + Q31 into Q31*/
+ CurrentR=Temp;
+ if (CurrentR > TargetR)
+ CurrentR = TargetR;
+ }
+ else
+ {
+ CurrentR -= DeltaR; /* Q31 + Q31 into Q31*/
+ if (CurrentR < TargetR)
+ CurrentR = TargetR;
+ }
+
+ CurrentShortL = (LVM_INT16)(CurrentL>>16); /* From Q31 to Q15*/
+ CurrentShortR = (LVM_INT16)(CurrentR>>16); /* From Q31 to Q15*/
+
+ for (ii = OutLoop*2; ii != 0; ii-=2)
+ {
+ *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShortL)>>15); /* Q15*Q15>>15 into Q15 */
+ *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShortR)>>15); /* Q15*Q15>>15 into Q15 */
+ }
+ }
+
+ for (ii = InLoop*2; ii != 0; ii-=2)
+ {
+ if(CurrentL<TargetL)
+ {
+ ADD2_SAT_32x32(CurrentL,DeltaL,Temp); /* Q31 + Q31 into Q31*/
+ CurrentL=Temp;
+ if (CurrentL > TargetL)
+ CurrentL = TargetL;
+ }
+ else
+ {
+ CurrentL -= DeltaL; /* Q31 + Q31 into Q31*/
+ if (CurrentL < TargetL)
+ CurrentL = TargetL;
+ }
+
+ if(CurrentR<TargetR)
+ {
+ ADD2_SAT_32x32(CurrentR,DeltaR,Temp); /* Q31 + Q31 into Q31*/
+ CurrentR=Temp;
+ if (CurrentR > TargetR)
+ CurrentR = TargetR;
+ }
+ else
+ {
+ CurrentR -= DeltaR; /* Q31 + Q31 into Q31*/
+ if (CurrentR < TargetR)
+ CurrentR = TargetR;
+ }
+
+ CurrentShortL = (LVM_INT16)(CurrentL>>16); /* From Q31 to Q15*/
+ CurrentShortR = (LVM_INT16)(CurrentR>>16); /* From Q31 to Q15*/
+
+ *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShortL)>>15); /* Q15*Q15>>15 into Q15 */
+ *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShortR)>>15); /* Q15*Q15>>15 into Q15 */
+ *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShortL)>>15);
+ *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShortR)>>15);
+ *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShortL)>>15);
+ *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShortR)>>15);
+ *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShortL)>>15);
+ *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShortR)>>15);
+ }
+ pInstanceL->Current=CurrentL;
+ pInstanceR->Current=CurrentR;
+
+}
+/**********************************************************************************/
diff --git a/media/libeffects/lvm/lib/Common/src/LVC_Core_MixSoft_1St_D16C31_WRA.c b/media/libeffects/lvm/lib/Common/src/LVC_Core_MixSoft_1St_D16C31_WRA.c
new file mode 100755
index 0000000..78f0122
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/LVC_Core_MixSoft_1St_D16C31_WRA.c
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/**********************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1000 $
+ $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $
+
+***********************************************************************************/
+
+/**********************************************************************************
+ INCLUDE FILES
+***********************************************************************************/
+
+#include "LVC_Mixer_Private.h"
+#include "LVM_Macros.h"
+#include "ScalarArithmetic.h"
+
+/**********************************************************************************
+ FUNCTION LVCore_MIXSOFT_1ST_D16C31_WRA
+***********************************************************************************/
+
+void LVC_Core_MixSoft_1St_D16C31_WRA( LVMixer3_st *ptrInstance,
+ const LVM_INT16 *src,
+ LVM_INT16 *dst,
+ LVM_INT16 n)
+{
+ LVM_INT16 OutLoop;
+ LVM_INT16 InLoop;
+ LVM_INT16 CurrentShort;
+ LVM_INT32 ii;
+ Mix_Private_st *pInstance=(Mix_Private_st *)(ptrInstance->PrivateParams);
+ LVM_INT32 Delta=pInstance->Delta;
+ LVM_INT32 Current=pInstance->Current;
+ LVM_INT32 Target=pInstance->Target;
+ LVM_INT32 Temp;
+
+ InLoop = (LVM_INT16)(n >> 2); /* Process per 4 samples */
+ OutLoop = (LVM_INT16)(n - (InLoop << 2));
+
+ if(Current<Target){
+ if (OutLoop){
+ ADD2_SAT_32x32(Current,Delta,Temp); /* Q31 + Q31 into Q31*/
+ Current=Temp;
+ if (Current > Target)
+ Current = Target;
+
+ CurrentShort = (LVM_INT16)(Current>>16); /* From Q31 to Q15*/
+
+ for (ii = OutLoop; ii != 0; ii--){
+ *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShort)>>15); /* Q15*Q15>>15 into Q15 */
+ }
+ }
+
+ for (ii = InLoop; ii != 0; ii--){
+ ADD2_SAT_32x32(Current,Delta,Temp); /* Q31 + Q31 into Q31*/
+ Current=Temp;
+ if (Current > Target)
+ Current = Target;
+
+ CurrentShort = (LVM_INT16)(Current>>16); /* From Q31 to Q15*/
+
+ *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShort)>>15); /* Q15*Q15>>15 into Q15 */
+ *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShort)>>15);
+ *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShort)>>15);
+ *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShort)>>15);
+ }
+ }
+ else{
+ if (OutLoop){
+ Current -= Delta; /* Q31 + Q31 into Q31*/
+ if (Current < Target)
+ Current = Target;
+
+ CurrentShort = (LVM_INT16)(Current>>16); /* From Q31 to Q15*/
+
+ for (ii = OutLoop; ii != 0; ii--){
+ *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShort)>>15); /* Q15*Q15>>15 into Q15 */
+ }
+ }
+
+ for (ii = InLoop; ii != 0; ii--){
+ Current -= Delta; /* Q31 + Q31 into Q31*/
+ if (Current < Target)
+ Current = Target;
+
+ CurrentShort = (LVM_INT16)(Current>>16); /* From Q31 to Q15*/
+
+ *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShort)>>15); /* Q15*Q15>>15 into Q15 */
+ *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShort)>>15);
+ *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShort)>>15);
+ *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShort)>>15);
+ }
+ }
+ pInstance->Current=Current;
+}
+
+
+/**********************************************************************************/
diff --git a/media/libeffects/lvm/lib/Common/src/LVC_MixInSoft_D16C31_SAT.c b/media/libeffects/lvm/lib/Common/src/LVC_MixInSoft_D16C31_SAT.c
new file mode 100755
index 0000000..52be129
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/LVC_MixInSoft_D16C31_SAT.c
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/**********************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1000 $
+ $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $
+
+***********************************************************************************/
+
+/**********************************************************************************
+ INCLUDE FILES
+***********************************************************************************/
+
+#include "LVC_Mixer_Private.h"
+#include "VectorArithmetic.h"
+#include "ScalarArithmetic.h"
+
+/**********************************************************************************
+ DEFINITIONS
+***********************************************************************************/
+
+#define TRUE 1
+#define FALSE 0
+
+/**********************************************************************************
+ FUNCTION MIXINSOFT_D16C31_SAT
+***********************************************************************************/
+
+void LVC_MixInSoft_D16C31_SAT( LVMixer3_1St_st *ptrInstance,
+ LVM_INT16 *src,
+ LVM_INT16 *dst,
+ LVM_INT16 n)
+{
+ char HardMixing = TRUE;
+ LVM_INT32 TargetGain;
+ Mix_Private_st *pInstance=(Mix_Private_st *)(ptrInstance->MixerStream[0].PrivateParams);
+
+ if(n<=0) return;
+
+ /******************************************************************************
+ SOFT MIXING
+ *******************************************************************************/
+ if (pInstance->Current != pInstance->Target)
+ {
+ if(pInstance->Delta == 0x7FFFFFFF){
+ pInstance->Current = pInstance->Target;
+ TargetGain=pInstance->Target>>(16-pInstance->Shift); // TargetGain in Q16.15 format
+ LVC_Mixer_SetTarget(&(ptrInstance->MixerStream[0]),TargetGain);
+ }else if (Abs_32(pInstance->Current-pInstance->Target) < pInstance->Delta){
+ pInstance->Current = pInstance->Target; /* Difference is not significant anymore. Make them equal. */
+ TargetGain=pInstance->Target>>(16-pInstance->Shift); // TargetGain in Q16.15 format
+ LVC_Mixer_SetTarget(&(ptrInstance->MixerStream[0]),TargetGain);
+ }else{
+ /* Soft mixing has to be applied */
+ HardMixing = FALSE;
+ if(pInstance->Shift!=0){
+ Shift_Sat_v16xv16 ((LVM_INT16)pInstance->Shift,src,src,n);
+ LVC_Core_MixInSoft_D16C31_SAT( &(ptrInstance->MixerStream[0]), src, dst, n);
+ }
+ else
+ LVC_Core_MixInSoft_D16C31_SAT( &(ptrInstance->MixerStream[0]), src, dst, n);
+ }
+ }
+
+ /******************************************************************************
+ HARD MIXING
+ *******************************************************************************/
+
+ if (HardMixing){
+ if (pInstance->Target != 0){ /* Nothing to do in case Target = 0 */
+ if ((pInstance->Target>>16) == 0x7FFF){
+ if(pInstance->Shift!=0)
+ Shift_Sat_v16xv16 ((LVM_INT16)pInstance->Shift,src,src,n);
+ Add2_Sat_16x16( src, dst, n );
+ }
+ else{
+ if(pInstance->Shift!=0)
+ Shift_Sat_v16xv16 ((LVM_INT16)pInstance->Shift,src,src,n);
+ Mac3s_Sat_16x16(src,(LVM_INT16)(pInstance->Target>>16),dst,n);
+ pInstance->Current = pInstance->Target; /* In case the LVCore function would have changed the Current value */
+ }
+ }
+ }
+
+
+ /******************************************************************************
+ CALL BACK
+ *******************************************************************************/
+
+ if (ptrInstance->MixerStream[0].CallbackSet){
+ if (Abs_32(pInstance->Current-pInstance->Target) < pInstance->Delta){
+ pInstance->Current = pInstance->Target; /* Difference is not significant anymore. Make them equal. */
+ TargetGain=pInstance->Target>>(16-pInstance->Shift); // TargetGain in Q16.15 format
+ LVC_Mixer_SetTarget(ptrInstance->MixerStream,TargetGain);
+ ptrInstance->MixerStream[0].CallbackSet = FALSE;
+ if (ptrInstance->MixerStream[0].pCallBack != 0){
+ (*ptrInstance->MixerStream[0].pCallBack) ( ptrInstance->MixerStream[0].pCallbackHandle, ptrInstance->MixerStream[0].pGeneralPurpose,ptrInstance->MixerStream[0].CallbackParam );
+ }
+ }
+ }
+
+}
+
+/**********************************************************************************/
diff --git a/media/libeffects/lvm/lib/Common/src/LVC_MixSoft_1St_2i_D16C31_SAT.c b/media/libeffects/lvm/lib/Common/src/LVC_MixSoft_1St_2i_D16C31_SAT.c
new file mode 100755
index 0000000..d832e06
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/LVC_MixSoft_1St_2i_D16C31_SAT.c
@@ -0,0 +1,160 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/**********************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1000 $
+ $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $
+
+***********************************************************************************/
+
+/**********************************************************************************
+ INCLUDE FILES
+***********************************************************************************/
+
+#include "LVC_Mixer_Private.h"
+#include "VectorArithmetic.h"
+#include "ScalarArithmetic.h"
+
+/**********************************************************************************
+ DEFINITIONS
+***********************************************************************************/
+
+#define TRUE 1
+#define FALSE 0
+
+/**********************************************************************************
+ FUNCTION LVC_MixSoft_1St_2i_D16C31_SAT
+***********************************************************************************/
+
+void LVC_MixSoft_1St_2i_D16C31_SAT( LVMixer3_2St_st *ptrInstance,
+ const LVM_INT16 *src,
+ LVM_INT16 *dst,
+ LVM_INT16 n)
+{
+ char HardMixing = TRUE;
+ LVM_INT32 TargetGain;
+ Mix_Private_st *pInstance1=(Mix_Private_st *)(ptrInstance->MixerStream[0].PrivateParams);
+ Mix_Private_st *pInstance2=(Mix_Private_st *)(ptrInstance->MixerStream[1].PrivateParams);
+
+ if(n<=0) return;
+
+ /******************************************************************************
+ SOFT MIXING
+ *******************************************************************************/
+ if ((pInstance1->Current != pInstance1->Target)||(pInstance2->Current != pInstance2->Target))
+ {
+ if(pInstance1->Delta == 0x7FFFFFFF)
+ {
+ pInstance1->Current = pInstance1->Target;
+ TargetGain=pInstance1->Target>>16; // TargetGain in Q16.15 format, no integer part
+ LVC_Mixer_SetTarget(&(ptrInstance->MixerStream[0]),TargetGain);
+ }
+ else if (Abs_32(pInstance1->Current-pInstance1->Target) < pInstance1->Delta)
+ {
+ pInstance1->Current = pInstance1->Target; /* Difference is not significant anymore. Make them equal. */
+ TargetGain=pInstance1->Target>>16; // TargetGain in Q16.15 format, no integer part
+ LVC_Mixer_SetTarget(&(ptrInstance->MixerStream[0]),TargetGain);
+ }
+ else
+ {
+ /* Soft mixing has to be applied */
+ HardMixing = FALSE;
+ }
+
+ if(HardMixing == TRUE)
+ {
+ if(pInstance2->Delta == 0x7FFFFFFF)
+ {
+ pInstance2->Current = pInstance2->Target;
+ TargetGain=pInstance2->Target>>16; // TargetGain in Q16.15 format, no integer part
+ LVC_Mixer_SetTarget(&(ptrInstance->MixerStream[1]),TargetGain);
+ }
+ else if (Abs_32(pInstance2->Current-pInstance2->Target) < pInstance2->Delta)
+ {
+ pInstance2->Current = pInstance2->Target; /* Difference is not significant anymore. Make them equal. */
+ TargetGain=pInstance2->Target>>16; // TargetGain in Q16.15 format, no integer part
+ LVC_Mixer_SetTarget(&(ptrInstance->MixerStream[1]),TargetGain);
+ }
+ else
+ {
+ /* Soft mixing has to be applied */
+ HardMixing = FALSE;
+ }
+ }
+
+ if(HardMixing == FALSE)
+ {
+ LVC_Core_MixSoft_1St_2i_D16C31_WRA( &(ptrInstance->MixerStream[0]),&(ptrInstance->MixerStream[1]), src, dst, n);
+ }
+ }
+
+ /******************************************************************************
+ HARD MIXING
+ *******************************************************************************/
+
+ if (HardMixing)
+ {
+ if (((pInstance1->Target>>16) == 0x7FFF)&&((pInstance2->Target>>16) == 0x7FFF))
+ {
+ if(src!=dst)
+ {
+ Copy_16(src, dst, n);
+ }
+ }
+ else
+ {
+ LVC_Core_MixHard_1St_2i_D16C31_SAT(&(ptrInstance->MixerStream[0]),&(ptrInstance->MixerStream[1]), src, dst, n);
+ }
+ }
+
+ /******************************************************************************
+ CALL BACK
+ *******************************************************************************/
+
+ if (ptrInstance->MixerStream[0].CallbackSet)
+ {
+ if (Abs_32(pInstance1->Current-pInstance1->Target) < pInstance1->Delta)
+ {
+ pInstance1->Current = pInstance1->Target; /* Difference is not significant anymore. Make them equal. */
+ TargetGain=pInstance1->Target>>(16-pInstance1->Shift); // TargetGain in Q16.15 format
+ LVC_Mixer_SetTarget(&ptrInstance->MixerStream[0],TargetGain);
+ ptrInstance->MixerStream[0].CallbackSet = FALSE;
+ if (ptrInstance->MixerStream[0].pCallBack != 0)
+ {
+ (*ptrInstance->MixerStream[0].pCallBack) ( ptrInstance->MixerStream[0].pCallbackHandle, ptrInstance->MixerStream[0].pGeneralPurpose,ptrInstance->MixerStream[0].CallbackParam );
+ }
+ }
+ }
+ if (ptrInstance->MixerStream[1].CallbackSet)
+ {
+ if (Abs_32(pInstance2->Current-pInstance2->Target) < pInstance2->Delta)
+ {
+ pInstance2->Current = pInstance2->Target; /* Difference is not significant anymore. Make them equal. */
+ TargetGain=pInstance2->Target>>(16-pInstance2->Shift); // TargetGain in Q16.15 format
+ LVC_Mixer_SetTarget(&ptrInstance->MixerStream[1],TargetGain);
+ ptrInstance->MixerStream[1].CallbackSet = FALSE;
+ if (ptrInstance->MixerStream[1].pCallBack != 0)
+ {
+ (*ptrInstance->MixerStream[1].pCallBack) ( ptrInstance->MixerStream[1].pCallbackHandle, ptrInstance->MixerStream[1].pGeneralPurpose,ptrInstance->MixerStream[1].CallbackParam );
+ }
+ }
+ }
+}
+
+/**********************************************************************************/
diff --git a/media/libeffects/lvm/lib/Common/src/LVC_MixSoft_1St_D16C31_SAT.c b/media/libeffects/lvm/lib/Common/src/LVC_MixSoft_1St_D16C31_SAT.c
new file mode 100755
index 0000000..cfb1239
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/LVC_MixSoft_1St_D16C31_SAT.c
@@ -0,0 +1,119 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/**********************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1000 $
+ $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $
+
+***********************************************************************************/
+
+/**********************************************************************************
+ INCLUDE FILES
+***********************************************************************************/
+
+#include "LVC_Mixer_Private.h"
+#include "VectorArithmetic.h"
+#include "ScalarArithmetic.h"
+
+/**********************************************************************************
+ DEFINITIONS
+***********************************************************************************/
+
+#define TRUE 1
+#define FALSE 0
+
+/**********************************************************************************
+ FUNCTION LVMixer3_MIXSOFT_1ST_D16C31_SAT
+***********************************************************************************/
+
+void LVC_MixSoft_1St_D16C31_SAT( LVMixer3_1St_st *ptrInstance,
+ const LVM_INT16 *src,
+ LVM_INT16 *dst,
+ LVM_INT16 n)
+{
+ char HardMixing = TRUE;
+ LVM_INT32 TargetGain;
+ Mix_Private_st *pInstance=(Mix_Private_st *)(ptrInstance->MixerStream[0].PrivateParams);
+
+ if(n<=0) return;
+
+ /******************************************************************************
+ SOFT MIXING
+ *******************************************************************************/
+ if (pInstance->Current != pInstance->Target)
+ {
+ if(pInstance->Delta == 0x7FFFFFFF){
+ pInstance->Current = pInstance->Target;
+ TargetGain=pInstance->Target>>(16-pInstance->Shift); // TargetGain in Q16.15 format
+ LVC_Mixer_SetTarget(&(ptrInstance->MixerStream[0]),TargetGain);
+ }else if (Abs_32(pInstance->Current-pInstance->Target) < pInstance->Delta){
+ pInstance->Current = pInstance->Target; /* Difference is not significant anymore. Make them equal. */
+ TargetGain=pInstance->Target>>(16-pInstance->Shift); // TargetGain in Q16.15 format
+ LVC_Mixer_SetTarget(&(ptrInstance->MixerStream[0]),TargetGain);
+ }else{
+ /* Soft mixing has to be applied */
+ HardMixing = FALSE;
+ if(pInstance->Shift!=0){
+ Shift_Sat_v16xv16 ((LVM_INT16)pInstance->Shift,src,dst,n);
+ LVC_Core_MixSoft_1St_D16C31_WRA( &(ptrInstance->MixerStream[0]), dst, dst, n);
+ }
+ else
+ LVC_Core_MixSoft_1St_D16C31_WRA( &(ptrInstance->MixerStream[0]), src, dst, n);
+ }
+ }
+
+ /******************************************************************************
+ HARD MIXING
+ *******************************************************************************/
+
+ if (HardMixing){
+ if (pInstance->Target == 0)
+ LoadConst_16(0, dst, n);
+ else if(pInstance->Shift!=0){
+ Shift_Sat_v16xv16 ((LVM_INT16)pInstance->Shift,src,dst,n);
+ if ((pInstance->Target>>16) != 0x7FFF)
+ Mult3s_16x16( dst, (LVM_INT16)(pInstance->Target>>16), dst, n );
+ }
+ else {
+ if ((pInstance->Target>>16) != 0x7FFF)
+ Mult3s_16x16( src, (LVM_INT16)(pInstance->Target>>16), dst, n );
+ else if(src!=dst)
+ Copy_16(src, dst, n);
+ }
+
+ }
+
+ /******************************************************************************
+ CALL BACK
+ *******************************************************************************/
+
+ if (ptrInstance->MixerStream[0].CallbackSet){
+ if (Abs_32(pInstance->Current-pInstance->Target) < pInstance->Delta){
+ pInstance->Current = pInstance->Target; /* Difference is not significant anymore. Make them equal. */
+ TargetGain=pInstance->Target>>(16-pInstance->Shift); // TargetGain in Q16.15 format
+ LVC_Mixer_SetTarget(ptrInstance->MixerStream,TargetGain);
+ ptrInstance->MixerStream[0].CallbackSet = FALSE;
+ if (ptrInstance->MixerStream[0].pCallBack != 0){
+ (*ptrInstance->MixerStream[0].pCallBack) ( ptrInstance->MixerStream[0].pCallbackHandle, ptrInstance->MixerStream[0].pGeneralPurpose,ptrInstance->MixerStream[0].CallbackParam );
+ }
+ }
+ }
+}
+
+/**********************************************************************************/
diff --git a/media/libeffects/lvm/lib/Common/src/LVC_MixSoft_2St_D16C31_SAT.c b/media/libeffects/lvm/lib/Common/src/LVC_MixSoft_2St_D16C31_SAT.c
new file mode 100755
index 0000000..6184736
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/LVC_MixSoft_2St_D16C31_SAT.c
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/**********************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1000 $
+ $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $
+
+***********************************************************************************/
+
+/**********************************************************************************
+ INCLUDE FILES
+***********************************************************************************/
+
+#include "LVC_Mixer_Private.h"
+#include "VectorArithmetic.h"
+
+/**********************************************************************************
+ FUNCTION LVC_MixSoft_2St_D16C31_SAT.c
+***********************************************************************************/
+
+void LVC_MixSoft_2St_D16C31_SAT( LVMixer3_2St_st *ptrInstance,
+ const LVM_INT16 *src1,
+ LVM_INT16 *src2,
+ LVM_INT16 *dst,
+ LVM_INT16 n)
+{
+ Mix_Private_st *pInstance1=(Mix_Private_st *)(ptrInstance->MixerStream[0].PrivateParams);
+ Mix_Private_st *pInstance2=(Mix_Private_st *)(ptrInstance->MixerStream[1].PrivateParams);
+
+ if(n<=0) return;
+
+ /******************************************************************************
+ SOFT MIXING
+ *******************************************************************************/
+ if ((pInstance1->Current == pInstance1->Target)&&(pInstance1->Current == 0)){
+ LVC_MixSoft_1St_D16C31_SAT( (LVMixer3_1St_st *)(&ptrInstance->MixerStream[1]), src2, dst, n);
+ }
+ else if ((pInstance2->Current == pInstance2->Target)&&(pInstance2->Current == 0)){
+ LVC_MixSoft_1St_D16C31_SAT( (LVMixer3_1St_st *)(&ptrInstance->MixerStream[0]), src1, dst, n);
+ }
+ else if ((pInstance1->Current != pInstance1->Target) || (pInstance2->Current != pInstance2->Target))
+ {
+ LVC_MixSoft_1St_D16C31_SAT((LVMixer3_1St_st *)(&ptrInstance->MixerStream[0]), src1, dst, n);
+ LVC_MixInSoft_D16C31_SAT( (LVMixer3_1St_st *)(&ptrInstance->MixerStream[1]), src2, dst, n);
+ }
+ else{
+ /******************************************************************************
+ HARD MIXING
+ *******************************************************************************/
+ if(pInstance2->Shift!=0)
+ Shift_Sat_v16xv16 ((LVM_INT16)pInstance2->Shift,src2,src2,n);
+ if(pInstance1->Shift!=0)
+ {
+ Shift_Sat_v16xv16 ((LVM_INT16)pInstance1->Shift,src1,dst,n);
+ LVC_Core_MixHard_2St_D16C31_SAT( &ptrInstance->MixerStream[0], &ptrInstance->MixerStream[1], dst, src2, dst, n);
+ }
+ else
+ LVC_Core_MixHard_2St_D16C31_SAT( &ptrInstance->MixerStream[0], &ptrInstance->MixerStream[1], src1, src2, dst, n);
+ }
+}
+
+/**********************************************************************************/
diff --git a/media/libeffects/lvm/lib/Common/src/LVC_Mixer.h b/media/libeffects/lvm/lib/Common/src/LVC_Mixer.h
new file mode 100755
index 0000000..3b32e21
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/LVC_Mixer.h
@@ -0,0 +1,144 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/**********************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1000 $
+ $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $
+
+***********************************************************************************/
+
+#ifndef __LVC_MIXER_H__
+#define __LVC_MIXER_H__
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+#include "LVM_Types.h"
+
+/**********************************************************************************
+ INSTANCE MEMORY TYPE DEFINITION
+***********************************************************************************/
+
+/* LVMixer3_st structure stores Instance parameters for one audio stream */
+typedef struct
+{
+ LVM_INT32 PrivateParams[4]; /* Private Instance params for Audio Stream */
+ LVM_INT16 CallbackSet; /* Boolean. Should be set by calling application each time the target value is updated */
+ LVM_INT16 CallbackParam; /* Parameter that will be used in the calback function */
+ void *pCallbackHandle; /* Pointer to the instance of the callback function */
+ void *pGeneralPurpose; /* Pointer for general purpose usage */
+ LVM_Callback pCallBack; /* Pointer to the callback function */
+} LVMixer3_st;
+
+typedef struct
+{
+ LVMixer3_st MixerStream[1]; /* Instance Params for one Audio Stream */
+} LVMixer3_1St_st;
+
+typedef struct
+{
+ LVMixer3_st MixerStream[2]; /* Instance Params for two Audio Streams */
+} LVMixer3_2St_st;
+
+typedef struct
+{
+ LVMixer3_st MixerStream[3]; /* Instance Params for three Audio Streams */
+} LVMixer3_3St_st;
+
+/**********************************************************************************
+ FUNCTION PROTOTYPES (HIGH LEVEL FUNCTIONS)
+***********************************************************************************/
+
+/* Function names should be unique within first 16 characters */
+#define LVMixer3_MixSoft_1St_D16C31_SAT LVMixer3_1St_D16C31_SAT_MixSoft
+#define LVMixer3_MixInSoft_D16C31_SAT LVMixer3_D16C31_SAT_MixInSoft
+#define LVMixer3_MixSoft_2St_D16C31_SAT LVMixer3_2St_D16C31_SAT_MixSoft
+#define LVMixer3_MixSoft_3St_D16C31_SAT LVMixer3_3St_D16C31_SAT_MixSoft
+
+
+/*** General functions ************************************************************/
+
+/**********************************************************************************/
+/* This time constant calculation function assumes the mixer will be called with */
+/* large block sizes. When the block size is small, especially if less than 4, */
+/* then the calculation will give an incorrect value for alpha, see the mixer */
+/* documentation for further details. */
+/* ********************************************************************************/
+void LVC_Mixer_SetTarget( LVMixer3_st *pStream,
+ LVM_INT32 TargetGain);
+
+LVM_INT32 LVC_Mixer_GetTarget( LVMixer3_st *pStream);
+
+LVM_INT32 LVC_Mixer_GetCurrent( LVMixer3_st *pStream);
+
+void LVC_Mixer_Init( LVMixer3_st *pStream,
+ LVM_INT32 TargetGain,
+ LVM_INT32 CurrentGain);
+
+void LVC_Mixer_SetTimeConstant( LVMixer3_st *pStream,
+ LVM_INT32 Tc_millisec,
+ LVM_Fs_en Fs,
+ LVM_INT16 NumChannels);
+
+void LVC_Mixer_VarSlope_SetTimeConstant( LVMixer3_st *pStream,
+ LVM_INT32 Tc_millisec,
+ LVM_Fs_en Fs,
+ LVM_INT16 NumChannels);
+
+/*** 16 bit functions *************************************************************/
+
+void LVC_MixSoft_1St_D16C31_SAT( LVMixer3_1St_st *pInstance,
+ const LVM_INT16 *src,
+ LVM_INT16 *dst,
+ LVM_INT16 n);
+
+void LVC_MixInSoft_D16C31_SAT( LVMixer3_1St_st *pInstance,
+ LVM_INT16 *src,
+ LVM_INT16 *dst,
+ LVM_INT16 n);
+
+void LVC_MixSoft_2St_D16C31_SAT( LVMixer3_2St_st *pInstance,
+ const LVM_INT16 *src1,
+ LVM_INT16 *src2,
+ LVM_INT16 *dst, /* dst cannot be equal to src2 */
+ LVM_INT16 n);
+
+/**********************************************************************************/
+/* For applying different gains to Left and right chennals */
+/* MixerStream[0] applies to Left channel */
+/* MixerStream[1] applies to Right channel */
+/* Gain values should not be more that 1.0 */
+/**********************************************************************************/
+void LVC_MixSoft_1St_2i_D16C31_SAT( LVMixer3_2St_st *pInstance,
+ const LVM_INT16 *src,
+ LVM_INT16 *dst, /* dst can be equal to src */
+ LVM_INT16 n); /* Number of stereo samples */
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+/**********************************************************************************/
+
+#endif //#ifndef __LVC_MIXER_H__
+
diff --git a/media/libeffects/lvm/lib/Common/src/LVC_Mixer_GetCurrent.c b/media/libeffects/lvm/lib/Common/src/LVC_Mixer_GetCurrent.c
new file mode 100755
index 0000000..09658ba
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/LVC_Mixer_GetCurrent.c
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 839 $*/
+/* $Date: 2010-06-16 14:15:52 +0200 (Wed, 16 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+#include "LVM_Types.h"
+#include "LVM_Macros.h"
+#include "LVC_Mixer_Private.h"
+
+
+/************************************************************************/
+/* FUNCTION: */
+/* LVMixer3_GetCurrent */
+/* */
+/* DESCRIPTION: */
+/* This function returns the CurrentGain in Q16.15 format */
+/* */
+/* RETURNS: */
+/* CurrentGain - CurrentGain value in Q 16.15 format */
+/* */
+/************************************************************************/
+
+LVM_INT32 LVC_Mixer_GetCurrent( LVMixer3_st *pStream)
+{
+ LVM_INT32 CurrentGain;
+ Mix_Private_st *pInstance=(Mix_Private_st *)pStream->PrivateParams;
+ CurrentGain=pInstance->Current>>(16-pInstance->Shift); // CurrentGain in Q16.15 format
+ return CurrentGain;
+}
diff --git a/media/libeffects/lvm/lib/Common/src/LVC_Mixer_GetTarget.c b/media/libeffects/lvm/lib/Common/src/LVC_Mixer_GetTarget.c
new file mode 100755
index 0000000..ed2cf94
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/LVC_Mixer_GetTarget.c
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 839 $*/
+/* $Date: 2010-06-16 14:15:52 +0200 (Wed, 16 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+#include "LVM_Types.h"
+#include "LVM_Macros.h"
+#include "LVC_Mixer_Private.h"
+
+/************************************************************************/
+/* FUNCTION: */
+/* LVMixer3_GetTarget */
+/* */
+/* DESCRIPTION: */
+/* This function returns the TargetGain in Q16.15 format */
+/* */
+/* RETURNS: */
+/* TargetGain - TargetGain value in Q 16.15 format */
+/* */
+/************************************************************************/
+
+LVM_INT32 LVC_Mixer_GetTarget( LVMixer3_st *pStream)
+{
+ LVM_INT32 TargetGain;
+ Mix_Private_st *pInstance=(Mix_Private_st *)pStream->PrivateParams;
+
+ TargetGain=pInstance->Target>>(16-pInstance->Shift); // TargetGain in Q16.15 format
+
+ return TargetGain;
+}
diff --git a/media/libeffects/lvm/lib/Common/src/LVC_Mixer_Init.c b/media/libeffects/lvm/lib/Common/src/LVC_Mixer_Init.c
new file mode 100755
index 0000000..c61e468
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/LVC_Mixer_Init.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+#include "LVM_Types.h"
+#include "LVM_Macros.h"
+#include "LVC_Mixer_Private.h"
+
+/************************************************************************/
+/* FUNCTION: */
+/* LVMixer3_Init */
+/* */
+/* DESCRIPTION: */
+/* This intialization function intializes the private instance */
+/* paramters for a given Audio Stream based on TargetGain and */
+/* CurrentGain */
+/* This function caclulates the "Shift" required to provide the */
+/* integer part of TargetGain and fractional gain values "Target" and */
+/* "Current" based on maximum(TargetGain,CurrentGain) */
+/* E.g. CurrentGain=1.9 and TargetGain=2.5 then based on */
+/* MaxGain of 2.5, Shift = 2, Current=1.9/4=0.475, Target=2.5/4=0.625 */
+/* Therefore integer gain of 4 is provided by Left Shift of 2 and */
+/* fraction gain is provided through Current=0.475 and Target=0.625 */
+/* PARAMETERS: */
+/* pStream - ptr to Instance Parameter Structure LVMixer3_st for an*/
+/* Audio Stream */
+/* TargetGain - TargetGain value in Q 16.15 format */
+/* CurrentGain - CurrentGain value in Q 16.15 format */
+/* */
+/* RETURNS: */
+/* void */
+/* */
+/************************************************************************/
+
+void LVC_Mixer_Init( LVMixer3_st *pStream,
+ LVM_INT32 TargetGain,
+ LVM_INT32 CurrentGain)
+{
+ LVM_INT16 Shift=0;
+ LVM_INT32 MaxGain=TargetGain; // MaxGain is in Q16.15 format
+ Mix_Private_st *pInstance=(Mix_Private_st *)pStream->PrivateParams;
+ if(CurrentGain>MaxGain)
+ MaxGain=CurrentGain; // MaxGain=max(CurrentGain,TargetGain)
+
+ MaxGain=MaxGain>>15; // MaxGain in Q31.0 format i.e Integer part only
+ while(MaxGain>0){ // Update Shift required to provide integer gain
+ Shift++;
+ MaxGain=MaxGain>>1;
+ }
+ pInstance->Target=TargetGain<<(16-Shift); // Update fractional gain Target
+ pInstance->Current=CurrentGain<<(16-Shift); // Update fractional gain Current
+ pInstance->Shift=Shift; // Update Shift
+}
+
diff --git a/media/libeffects/lvm/lib/Common/src/LVC_Mixer_Private.h b/media/libeffects/lvm/lib/Common/src/LVC_Mixer_Private.h
new file mode 100755
index 0000000..d61d670
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/LVC_Mixer_Private.h
@@ -0,0 +1,136 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/**********************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1000 $
+ $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $
+
+***********************************************************************************/
+
+#ifndef __LVC_MIXER_PRIVATE_H__
+#define __LVC_MIXER_PRIVATE_H__
+
+/**********************************************************************************
+ INCLUDE FILES
+***********************************************************************************/
+
+#include "LVC_Mixer.h"
+#include "VectorArithmetic.h"
+
+/* Instance parameter structure */
+typedef struct
+{
+ /* General */
+ LVM_INT32 Target; /* 32 bit number specifying fractional value of Target Gain */
+ LVM_INT32 Current; /* 32 bit number specifying fractional valude of Current Gain */
+ LVM_INT32 Shift; /* Left Shift for Integer part of Gain */
+ LVM_INT32 Delta; /* 32 bit number specifying the fractional value of Delta Gain */
+} Mix_Private_st;
+
+
+
+/**********************************************************************************
+ DEFINITIONS
+***********************************************************************************/
+#define LVCore_MixInSoft_D32C31_SAT LVCore_InSoft_D32C31_SAT
+#define LVCore_MixSoft_1St_D32C31_WRA LVCore_Soft_1St_D32C31_WRA
+#define LVCore_MixHard_2St_D32C31_SAT LVCore_Hard_2St_D32C31_SAT
+
+/**********************************************************************************
+ FUNCTION PROTOTYPES (LOW LEVEL SUBFUNCTIONS)
+***********************************************************************************/
+
+/*** 16 bit functions *************************************************************/
+
+void LVC_Core_MixInSoft_D16C31_SAT( LVMixer3_st *pInstance,
+ const LVM_INT16 *src,
+ LVM_INT16 *dst,
+ LVM_INT16 n);
+
+void LVC_Core_MixSoft_1St_D16C31_WRA( LVMixer3_st *pInstance,
+ const LVM_INT16 *src,
+ LVM_INT16 *dst,
+ LVM_INT16 n);
+
+void LVC_Core_MixHard_2St_D16C31_SAT( LVMixer3_st *pInstance1,
+ LVMixer3_st *pInstance2,
+ const LVM_INT16 *src1,
+ const LVM_INT16 *src2,
+ LVM_INT16 *dst,
+ LVM_INT16 n);
+
+/**********************************************************************************/
+/* For applying different gains to Left and right chennals */
+/* ptrInstance1 applies to Left channel */
+/* ptrInstance2 applies to Right channel */
+/* Gain values should not be more that 1.0 */
+/**********************************************************************************/
+
+void LVC_Core_MixSoft_1St_2i_D16C31_WRA( LVMixer3_st *ptrInstance1,
+ LVMixer3_st *ptrInstance2,
+ const LVM_INT16 *src,
+ LVM_INT16 *dst, /* dst can be equal to src */
+ LVM_INT16 n); /* Number of stereo samples */
+
+/**********************************************************************************/
+/* For applying different gains to Left and right chennals */
+/* ptrInstance1 applies to Left channel */
+/* ptrInstance2 applies to Right channel */
+/* Gain values should not be more that 1.0 */
+/**********************************************************************************/
+void LVC_Core_MixHard_1St_2i_D16C31_SAT( LVMixer3_st *ptrInstance1,
+ LVMixer3_st *ptrInstance2,
+ const LVM_INT16 *src,
+ LVM_INT16 *dst, /* dst can be equal to src */
+ LVM_INT16 n); /* Number of stereo samples */
+
+
+
+/*** 32 bit functions *************************************************************/
+
+void LVC_Core_MixInSoft_D32C31_SAT( LVMixer3_st *pInstance,
+ const LVM_INT32 *src,
+ LVM_INT32 *dst,
+ LVM_INT16 n);
+
+void LVC_Core_MixSoft_1St_D32C31_WRA( LVMixer3_st *pInstance,
+ const LVM_INT32 *src,
+ LVM_INT32 *dst,
+ LVM_INT16 n);
+
+void LVC_Core_MixHard_2St_D32C31_SAT( LVMixer3_st *pInstance1,
+ LVMixer3_st *pInstance2,
+ const LVM_INT32 *src1,
+ const LVM_INT32 *src2,
+ LVM_INT32 *dst,
+ LVM_INT16 n);
+
+/**********************************************************************************/
+
+#endif //#ifndef __LVC_MIXER_PRIVATE_H__
+
+
+
+
+
+
+
+
+
+
diff --git a/media/libeffects/lvm/lib/Common/src/LVC_Mixer_SetTarget.c b/media/libeffects/lvm/lib/Common/src/LVC_Mixer_SetTarget.c
new file mode 100755
index 0000000..4d3fe0c
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/LVC_Mixer_SetTarget.c
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+#include "LVM_Types.h"
+#include "LVM_Macros.h"
+#include "LVC_Mixer_Private.h"
+
+/************************************************************************/
+/* FUNCTION: */
+/* LVMixer3_SetTarget */
+/* */
+/* DESCRIPTION: */
+/* This function updates the private instance parameters: Shift,Target,*/
+/* Current for a given Audio Stream based on new value of TargetGain */
+/* */
+/* This function caclulates the "Shift" required to provide the */
+/* integer part of TargetGain and fractional gain values "Target" and */
+/* "Current" based on maximum(TargetGain,CurrentGain) */
+/* E.g. CurrentGain=1.9 and TargetGain=2.5 then based on */
+/* MaxGain of 2.5, Shift = 2, Current=1.9/4=0.475, Target=2.5/4=0.625 */
+/* Therefore integer gain of 4 is provided by Left Shift of 2 and */
+/* fraction gain is provided through Current=0.475 and Target=0.625 */
+/* PARAMETERS: */
+/* pStream - ptr to Instance Parameter Structure LVMixer3_st */
+/* for an Audio Stream */
+/* TargetGain - TargetGain value in Q 16.15 format */
+/* */
+/* RETURNS: */
+/* void */
+/* */
+/************************************************************************/
+
+void LVC_Mixer_SetTarget(LVMixer3_st *pStream,
+ LVM_INT32 TargetGain)
+{
+ LVM_INT32 Shift=0;
+ LVM_INT32 CurrentGain;
+ LVM_INT32 MaxGain=TargetGain; // MaxGain is in Q16.15 format
+ Mix_Private_st *pInstance=(Mix_Private_st *)pStream->PrivateParams;
+ CurrentGain=pInstance->Current>>(16-pInstance->Shift); // CurrentGain in Q16.15 format
+ if(CurrentGain>MaxGain)
+ MaxGain=CurrentGain; // MaxGain=max(CurrentGain,TargetGain)
+
+ MaxGain=MaxGain>>15; // MaxGain in Q31.0 format i.e Integer part only
+ while(MaxGain>0){ // Update Shift required to provide integer gain
+ Shift++;
+ MaxGain=MaxGain>>1;
+ }
+ pInstance->Target=TargetGain<<(16-Shift); // Update fractional gain Target
+ pInstance->Current=CurrentGain<<(16-Shift); // Update fractional gain Current
+ pInstance->Shift=Shift; // Update Shift
+}
diff --git a/media/libeffects/lvm/lib/Common/src/LVC_Mixer_SetTimeConstant.c b/media/libeffects/lvm/lib/Common/src/LVC_Mixer_SetTimeConstant.c
new file mode 100755
index 0000000..df0fd37
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/LVC_Mixer_SetTimeConstant.c
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+#include "LVM_Types.h"
+#include "LVM_Macros.h"
+#include "LVC_Mixer_Private.h"
+
+/************************************************************************/
+/* FUNCTION: */
+/* LVMixer3_SetTimeConstant */
+/* */
+/* DESCRIPTION: */
+/* This function calculates the step change for fractional gain for a */
+/* given time constant, sample rate and num channels */
+/* Delta=(2147483647*4*1000)/(NumChannels*SampleRate*Tc_millisec) */
+/* in Q 0.31 format */
+/* */
+/* PARAMETERS: */
+/* pStream - ptr to Instance Parameter Structure LVMixer3_st for an*/
+/* Audio Stream */
+/* Tc_millisec - TimeConstant i.e time required in milli second to */
+/* go from linear fractional gain of 0 to 0.99999999 */
+/* Fs - LVM_Fs_en enumerator for Sampling Frequency */
+/* NumChannels - Number of channels in Audio Stream 1=Mono, 2=Stereo */
+/* */
+/* UPDATES: */
+/* Delta - the step change for fractional gain per 4 samples */
+/* in Q0.31 format for a given Time Constant, */
+/* Sample Rate and NumChannels */
+/* RETURNS: */
+/* void */
+/************************************************************************/
+
+void LVC_Mixer_SetTimeConstant(LVMixer3_st *pStream,
+ LVM_INT32 Tc_millisec,
+ LVM_Fs_en Fs,
+ LVM_INT16 NumChannels)
+{
+ LVM_INT32 DeltaTable[9]={1073741824,
+ 779132389,
+ 715827882,
+ 536870912,
+ 389566194,
+ 357913941,
+ 268435456,
+ 194783097,
+ 178956971};
+ Mix_Private_st *pInstance=(Mix_Private_st *)pStream->PrivateParams;
+ LVM_INT32 Delta=DeltaTable[Fs];
+ Delta=Delta>>(NumChannels-1);
+
+ if(Tc_millisec==0)
+ Delta=0x7FFFFFFF;
+ else
+ Delta=Delta/Tc_millisec;
+
+ if(Delta==0)
+ Delta=1; // If Time Constant is so large that Delta is 0, assign minimum value to Delta
+
+ pInstance->Delta=Delta; // Delta=(2147483647*4*1000)/(NumChannels*SampleRate*Tc_millisec) in Q 0.31 format
+}
diff --git a/media/libeffects/lvm/lib/Common/src/LVC_Mixer_VarSlope_SetTimeConstant.c b/media/libeffects/lvm/lib/Common/src/LVC_Mixer_VarSlope_SetTimeConstant.c
new file mode 100755
index 0000000..420af9a
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/LVC_Mixer_VarSlope_SetTimeConstant.c
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+#include "LVM_Types.h"
+#include "LVM_Macros.h"
+#include "LVC_Mixer_Private.h"
+
+
+/************************************************************************/
+/* FUNCTION: */
+/* LVMixer3_VarSlope_SetTimeConstant */
+/* */
+/* DESCRIPTION: */
+/* This function calculates the step change for fractional gain for a */
+/* given time constant, sample rate and num channels */
+/* Delta=(2147483647*4*1000)/(NumChannels*SampleRate*Tc_millisec) */
+/* in Q 0.31 format */
+/* */
+/* PARAMETERS: */
+/* pStream - ptr to Instance Parameter Structure LVMixer3_st for an*/
+/* Audio Stream */
+/* Tc_millisec - TimeConstant i.e time required in milli second to */
+/* go from linear fractional gain of 0 to 0.99999999 */
+/* Fs - LVM_Fs_en enumerator for Sampling Frequency */
+/* NumChannels - Number of channels in Audio Stream 1=Mono, 2=Stereo */
+/* */
+/* UPDATES: */
+/* Delta - the step change for fractional gain per 4 samples */
+/* in Q0.31 format for a given Time Constant, */
+/* Sample Rate and NumChannels */
+/* RETURNS: */
+/* void */
+/************************************************************************/
+
+void LVC_Mixer_VarSlope_SetTimeConstant( LVMixer3_st *pStream,
+ LVM_INT32 Tc_millisec,
+ LVM_Fs_en Fs,
+ LVM_INT16 NumChannels)
+{
+ LVM_INT32 DeltaTable[9]={1073741824,
+ 779132389,
+ 715827882,
+ 536870912,
+ 389566194,
+ 357913941,
+ 268435456,
+ 194783097,
+ 178956971};
+ Mix_Private_st *pInstance=(Mix_Private_st *)pStream->PrivateParams;
+ LVM_INT32 Delta=DeltaTable[Fs];
+
+ LVM_INT32 Current;
+ LVM_INT32 Target;
+
+ Delta=Delta>>(NumChannels-1);
+
+ /* Get gain values */
+ Current = LVC_Mixer_GetCurrent( pStream );
+ Target = LVC_Mixer_GetTarget( pStream );
+
+ if (Current != Target)
+ {
+ Tc_millisec = Tc_millisec * 32767 / (Current - Target);
+ if (Tc_millisec<0) Tc_millisec = -Tc_millisec;
+
+ if(Tc_millisec==0)
+ Delta=0x7FFFFFFF;
+ else
+ Delta=Delta/Tc_millisec;
+
+ if(Delta==0)
+ Delta=1; // If Time Constant is so large that Delta is 0, assign minimum value to Delta
+ }
+ else
+ {
+ Delta =1; // Minimum value for proper call-backs (setting it to zero has some problems, to be corrected)
+ }
+
+
+ pInstance->Delta=Delta; // Delta=(2147483647*4*1000)/(NumChannels*SampleRate*Tc_millisec) in Q 0.31 format
+}
diff --git a/media/libeffects/lvm/lib/Common/src/LVM_FO_HPF.c b/media/libeffects/lvm/lib/Common/src/LVM_FO_HPF.c
new file mode 100755
index 0000000..37c199e
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/LVM_FO_HPF.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: nxp27078 $*/
+/* $Revision: 762 $*/
+/* $Date: 2010-06-11 14:50:33 +0200 (vr, 11 jun 2010) $*/
+/* */
+/************************************************************************/
+
+#include "LVM_Types.h"
+#include "LVM_Macros.h"
+#include "ScalarArithmetic.h"
+#include "BIQUAD.h"
+#include "Filter.h"
+
+
+/*-------------------------------------------------------------------------*/
+/* FUNCTION: */
+/* void LVM_FO_LPF( LVM_INT32 w , */
+/* FO_C32_Coefs_t *pCoeffs); */
+/* */
+/* */
+/* DESCRIPTION: */
+/* This function calculates the coefficient of first order low pass */
+/* filter. It uses the equations: */
+/* */
+/* B1 = (tan(w/2) - 1 ) / (tan(w/2) + 1 ) */
+/* A0 = (1 - B1) / 2 */
+/* A1 = A0 */
+/* */
+/* The value of B1 is then calculated directly from the value w by a */
+/* polynomial expansion using a 9th order polynomial. It uses the */
+/* following table of 32-bit integer polynomial coefficients: */
+/* */
+/* Coefficient Value */
+/* A0 -8388571 */
+/* A1 33547744 */
+/* A2 -66816791 */
+/* A3 173375308 */
+/* A4 -388437573 */
+/* A5 752975383 */
+/* A6 -1103016663 */
+/* A7 1121848567 */
+/* A8 -688078159 */
+/* A9 194669577 */
+/* A10 8 */
+/* */
+/* Y = (A0 + A1*X + A2*X2 + A3*X3 + Â….. + AN*xN) << AN+1 */
+/* */
+/* */
+/* PARAMETERS: */
+/* */
+/* w Sample rate in radians, where: */
+/* w = 2 * Pi * Fc / Fs */
+/* Fc is the corner frequency in Hz */
+/* Fs is the sample rate in Hz */
+/* w is in Q2.29 format and data range is [0 Pi] */
+/* pCoeffs Points to the filter coefficients calculated here */
+/* in Q1.30 format */
+/* RETURNS: */
+/* */
+/*-------------------------------------------------------------------------*/
+
+LVM_INT32 LVM_FO_HPF( LVM_INT32 w,
+ FO_C32_Coefs_t *pCoeffs)
+{
+ LVM_INT32 Y,Coefficients[13]={ -8388571,
+ 33547744,
+ -66816791,
+ 173375308,
+ -388437573,
+ 752975383,
+ -1103016663,
+ 1121848567,
+ -688078159,
+ 194669577,
+ 8,
+ 0,
+ 0};
+ Y=LVM_Polynomial( (LVM_UINT16)9,
+ Coefficients,
+ w);
+ pCoeffs->B1=-Y; /* Store -B1 in filter structure instead of B1!*/
+ /* A0=(1-B1)/2= B1/2 - 0.5*/
+ Y=Y>>1; /* A0=Y=B1/2*/
+ Y=Y-0x40000000; /* A0=Y=(B1/2 - 0.5)*/
+ MUL32x16INTO32(Y, FILTER_LOSS ,pCoeffs->A0 ,15) /* Apply loss to avoid overflow*/
+ pCoeffs->A1=-pCoeffs->A0; /* Store A1=-A0*/
+
+ return 1;
+}
+
diff --git a/media/libeffects/lvm/lib/Common/src/LVM_FO_LPF.c b/media/libeffects/lvm/lib/Common/src/LVM_FO_LPF.c
new file mode 100755
index 0000000..6c73d59
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/LVM_FO_LPF.c
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: nxp27078 $*/
+/* $Revision: 762 $*/
+/* $Date: 2010-06-11 14:50:33 +0200 (vr, 11 jun 2010) $*/
+/* */
+/************************************************************************/
+
+#include "LVM_Types.h"
+#include "LVM_Macros.h"
+#include "ScalarArithmetic.h"
+#include "BIQUAD.h"
+#include "Filter.h"
+
+
+/*-------------------------------------------------------------------------*/
+/* FUNCTION: */
+/* void LVM_FO_LPF( LVM_INT32 w , */
+/* FO_C32_Coefs_t *pCoeffs); */
+/* */
+/* */
+/* DESCRIPTION: */
+/* This function calculates the coefficient of first order low pass */
+/* filter. It uses the equations: */
+/* */
+/* B1 = (tan(w/2) - 1 ) / (tan(w/2) + 1 ) */
+/* A0 = (1 + B1) / 2 */
+/* A1 = A0 */
+/* */
+/* The value of B1 is then calculated directly from the value w by a */
+/* polynomial expansion using a 9th order polynomial. It uses the */
+/* following table of 32-bit integer polynomial coefficients: */
+/* */
+/* Coefficient Value */
+/* A0 -8388571 */
+/* A1 33547744 */
+/* A2 -66816791 */
+/* A3 173375308 */
+/* A4 -388437573 */
+/* A5 752975383 */
+/* A6 -1103016663 */
+/* A7 1121848567 */
+/* A8 -688078159 */
+/* A9 194669577 */
+/* A10 8 */
+/* */
+/* Y = (A0 + A1*X + A2*X2 + A3*X3 + Â….. + AN*xN) << AN+1 */
+/* */
+/* */
+/* PARAMETERS: */
+/* */
+/* w Sample rate in radians, where: */
+/* w = 2 * Pi * Fc / Fs */
+/* Fc is the corner frequency in Hz */
+/* Fs is the sample rate in Hz */
+/* w is in Q2.29 format and data range is [0 Pi] */
+/* pCoeffs Points to the filter coefficients calculated here */
+/* in Q1.30 format */
+/* RETURNS: */
+/* */
+/*-------------------------------------------------------------------------*/
+
+LVM_INT32 LVM_FO_LPF( LVM_INT32 w,
+ FO_C32_Coefs_t *pCoeffs)
+{
+ LVM_INT32 Y,Coefficients[13]={ -8388571,
+ 33547744,
+ -66816791,
+ 173375308,
+ -388437573,
+ 752975383,
+ -1103016663,
+ 1121848567,
+ -688078159,
+ 194669577,
+ 8};
+ Y=LVM_Polynomial( (LVM_UINT16)9,
+ Coefficients,
+ w);
+ pCoeffs->B1=-Y; // Store -B1 in filter structure instead of B1!
+ // A0=(1+B1)/2= B1/2 + 0.5
+ Y=Y>>1; // A0=Y=B1/2
+ Y=Y+0x40000000; // A0=Y=(B1/2 + 0.5)
+ MUL32x16INTO32(Y, FILTER_LOSS ,pCoeffs->A0 ,15) // Apply loss to avoid overflow
+ pCoeffs->A1=pCoeffs->A0;
+ return 1;
+}
+
diff --git a/media/libeffects/lvm/lib/Common/src/LVM_GetOmega.c b/media/libeffects/lvm/lib/Common/src/LVM_GetOmega.c
new file mode 100755
index 0000000..1cc10db
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/LVM_GetOmega.c
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: nxp27078 $*/
+/* $Revision: 762 $*/
+/* $Date: 2010-06-11 14:50:33 +0200 (vr, 11 jun 2010) $*/
+/* */
+/************************************************************************/
+
+#include "LVM_Types.h"
+#include "Filter.h"
+#include "LVM_Macros.h"
+
+/************************************************************************************/
+/* */
+/* Defines and Tables for 2*Pi/Fs */
+/* */
+/************************************************************************************/
+
+#define LVVDL_2PiBy_8000 1727108826 /* In Q41 format */
+#define LVVDL_2PiBy_11025 1253230894 /* In Q41 format */
+#define LVVDL_2PiBy_12000 1151405884 /* In Q41 format */
+
+#define LVVDL_2PiByFs_SHIFT1 12 /* Qformat shift for 8kHz, 11.025kHz and 12kHz i.e. 12=41-29 */
+#define LVVDL_2PiByFs_SHIFT2 13 /* Qformat shift for 16kHz, 22.050kHz and 24kHz i.e. 13=42-29 */
+#define LVVDL_2PiByFs_SHIFT3 14 /* Qformat shift for 32kHz, 44.1kHz and 48kHz i.e. 14=43-29 */
+
+const LVM_INT32 LVVDL_2PiOnFsTable[] = {LVVDL_2PiBy_8000 , /* 8kHz in Q41, 16kHz in Q42, 32kHz in Q43 */
+ LVVDL_2PiBy_11025, /* 11025 Hz in Q41, 22050Hz in Q42, 44100 Hz in Q43*/
+ LVVDL_2PiBy_12000}; /* 12kHz in Q41, 24kHz in Q42, 48kHz in Q43 */
+
+
+const LVM_INT32 LVVDL_2PiOnFsShiftTable[]={LVVDL_2PiByFs_SHIFT1 , /* 8kHz, 11025Hz, 12kHz */
+ LVVDL_2PiByFs_SHIFT2, /* 16kHz, 22050Hz, 24kHz*/
+ LVVDL_2PiByFs_SHIFT3}; /* 32kHz, 44100Hz, 48kHz */
+
+/*-------------------------------------------------------------------------*/
+/* FUNCTION: */
+/* LVM_GetOmega */
+/* */
+/* LVM_INT32 LVM_GetOmega(LVM_UINT16 Fc, */
+/* LVM_Fs_en Fs) */
+/* */
+/* DESCRIPTION: */
+/* This function calculates the value of w using Fc and Fs */
+/* */
+/* PARAMETERS: */
+/* */
+/* LVM_UINT16 Fc The corner frequency in Hz Q16.0 format */
+/* LVM_Fs_en Fs The SampleRate */
+/* RETURNS: */
+/* w=2*pi*Fc/Fs in Q2.29 format */
+/*-------------------------------------------------------------------------*/
+
+LVM_INT32 LVM_GetOmega(LVM_UINT16 Fc,
+ LVM_Fs_en Fs)
+{
+ LVM_INT32 w;
+ MUL32x32INTO32((LVM_INT32)Fc,LVVDL_2PiOnFsTable[Fs%3],w,LVVDL_2PiOnFsShiftTable[Fs/3])
+ return w;
+}
+
diff --git a/media/libeffects/lvm/lib/Common/src/LVM_Mixer_FilterCoeffs.h b/media/libeffects/lvm/lib/Common/src/LVM_Mixer_FilterCoeffs.h
new file mode 100755
index 0000000..00235e0d
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/LVM_Mixer_FilterCoeffs.h
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+/************************************************************************************/
+/* */
+/* Mixer library tables */
+/* */
+/* Coefficients and table values for the mixer library, generated by the Matlab */
+/* Script: Mixer_GenerateCoeffs.m */
+/* */
+/************************************************************************************/
+
+#ifndef __LVM_MIXER_FILTER_COEFFS_H__
+#define __LVM_MIXER_FILTER_COEFFS_H__
+
+
+/************************************************************************************/
+/* */
+/* Alpha Time Constant table */
+/* */
+/************************************************************************************/
+
+#define Alpha_TableSize 50 /* The number of table entires */
+#define ALPHA_0 2147480769 /* Floating point Alpha = 0.999999 */
+#define ALPHA_1 2147479577 /* Floating point Alpha = 0.999998 */
+#define ALPHA_2 2147477892 /* Floating point Alpha = 0.999997 */
+#define ALPHA_3 2147475510 /* Floating point Alpha = 0.999996 */
+#define ALPHA_4 2147472141 /* Floating point Alpha = 0.999995 */
+#define ALPHA_5 2147467377 /* Floating point Alpha = 0.999992 */
+#define ALPHA_6 2147460642 /* Floating point Alpha = 0.999989 */
+#define ALPHA_7 2147451118 /* Floating point Alpha = 0.999985 */
+#define ALPHA_8 2147437651 /* Floating point Alpha = 0.999979 */
+#define ALPHA_9 2147418608 /* Floating point Alpha = 0.999970 */
+#define ALPHA_10 2147391683 /* Floating point Alpha = 0.999957 */
+#define ALPHA_11 2147353611 /* Floating point Alpha = 0.999939 */
+#define ALPHA_12 2147299779 /* Floating point Alpha = 0.999914 */
+#define ALPHA_13 2147223662 /* Floating point Alpha = 0.999879 */
+#define ALPHA_14 2147116037 /* Floating point Alpha = 0.999829 */
+#define ALPHA_15 2146963865 /* Floating point Alpha = 0.999758 */
+#define ALPHA_16 2146748712 /* Floating point Alpha = 0.999658 */
+#define ALPHA_17 2146444522 /* Floating point Alpha = 0.999516 */
+#define ALPHA_18 2146014472 /* Floating point Alpha = 0.999316 */
+#define ALPHA_19 2145406527 /* Floating point Alpha = 0.999033 */
+#define ALPHA_20 2144547188 /* Floating point Alpha = 0.998633 */
+#define ALPHA_21 2143332669 /* Floating point Alpha = 0.998067 */
+#define ALPHA_22 2141616514 /* Floating point Alpha = 0.997268 */
+#define ALPHA_23 2139192215 /* Floating point Alpha = 0.996139 */
+#define ALPHA_24 2135768939 /* Floating point Alpha = 0.994545 */
+#define ALPHA_25 2130937774 /* Floating point Alpha = 0.992295 */
+#define ALPHA_26 2124125153 /* Floating point Alpha = 0.989123 */
+#define ALPHA_27 2114529263 /* Floating point Alpha = 0.984654 */
+#define ALPHA_28 2101034612 /* Floating point Alpha = 0.978370 */
+#define ALPHA_29 2082100030 /* Floating point Alpha = 0.969553 */
+#define ALPHA_30 2055617398 /* Floating point Alpha = 0.957221 */
+#define ALPHA_31 2018744824 /* Floating point Alpha = 0.940051 */
+#define ALPHA_32 1967733015 /* Floating point Alpha = 0.916297 */
+#define ALPHA_33 1897794587 /* Floating point Alpha = 0.883729 */
+#define ALPHA_34 1803123234 /* Floating point Alpha = 0.839645 */
+#define ALPHA_35 1677262220 /* Floating point Alpha = 0.781036 */
+#define ALPHA_36 1514142675 /* Floating point Alpha = 0.705078 */
+#define ALPHA_37 1310197875 /* Floating point Alpha = 0.610108 */
+#define ALPHA_38 1067813480 /* Floating point Alpha = 0.497239 */
+#define ALPHA_39 799601371 /* Floating point Alpha = 0.372343 */
+#define ALPHA_40 531183049 /* Floating point Alpha = 0.247351 */
+#define ALPHA_41 297904007 /* Floating point Alpha = 0.138722 */
+#define ALPHA_42 131499768 /* Floating point Alpha = 0.061234 */
+#define ALPHA_43 41375282 /* Floating point Alpha = 0.019267 */
+#define ALPHA_44 8065899 /* Floating point Alpha = 0.003756 */
+#define ALPHA_45 799076 /* Floating point Alpha = 0.000372 */
+#define ALPHA_46 30398 /* Floating point Alpha = 0.000014 */
+#define ALPHA_47 299 /* Floating point Alpha = 0.000000 */
+#define ALPHA_48 0 /* Floating point Alpha = 0.000000 */
+#define ALPHA_49 0 /* Floating point Alpha = 0.000000 */
+#define ALPHA_50 0 /* Floating point Alpha = 0.000000 */
+
+
+#endif
diff --git a/media/libeffects/lvm/lib/Common/src/LVM_Mixer_TimeConstant.c b/media/libeffects/lvm/lib/Common/src/LVM_Mixer_TimeConstant.c
new file mode 100755
index 0000000..db6975a
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/LVM_Mixer_TimeConstant.c
@@ -0,0 +1,165 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+#include "LVM_Types.h"
+#include "LVM_Macros.h"
+#include "Mixer.h"
+#include "LVM_Mixer_FilterCoeffs.h"
+
+
+/************************************************************************/
+/* FUNCTION: */
+/* LVM_Mix_GetTimeConstant */
+/* */
+/* DESCRIPTION: */
+/* This function calculates the filter coefficient using the following */
+/* equation: */
+/* Alpha = exp(ln(0.1)/ (tc * Update + 1.0)) */
+/* */
+/* This is to be used with the follow first order filter, called at a */
+/* rate of Update times a second. tc is the required time constant in */
+/* units of 100us. */
+/* */
+/* Output(n) = Alpha * Output(n-1) + (1 - Alpha) * Target(n) */
+/* */
+/* The function assumes the block size is large, i.e. the update rate */
+/* is approximately a fixed, and correct factor of the value of Fs */
+/* given in the call. This is especially not true when the block size */
+/* is very small, see the mixer documentation for further details. */
+/* */
+/* The function does not support all possible combinations of input */
+/* values: */
+/* */
+/* 1. NumChannels is limited to the values 1 (Mono) and 2 (Stereo) */
+/* 2. The product tc * Fs is limited approximately to the range */
+/* 8 < (tc * Fs) < 2^35 */
+/* */
+/* PARAMETERS: */
+/* tc - the time constant in 100us steps, i.e. 10 = 1ms */
+/* Fs - the filter update rate in Hz */
+/* NumChannels - Number of channels 1=Mono, 2=Stereo */
+/* */
+/* RETURNS: */
+/* Alpha - the filter coefficient Q31 format */
+/* */
+/************************************************************************/
+
+LVM_UINT32 LVM_Mixer_TimeConstant(LVM_UINT32 tc,
+ LVM_UINT16 Fs,
+ LVM_UINT16 NumChannels)
+{
+
+ LVM_UINT32 Product;
+ LVM_INT16 Interpolate;
+ LVM_UINT16 Shift;
+ LVM_INT32 Diff;
+ LVM_UINT32 Table[] = {ALPHA_0, /* Log spaced look-up table */
+ ALPHA_1,
+ ALPHA_2,
+ ALPHA_3,
+ ALPHA_4,
+ ALPHA_5,
+ ALPHA_6,
+ ALPHA_7,
+ ALPHA_8,
+ ALPHA_9,
+ ALPHA_10,
+ ALPHA_11,
+ ALPHA_12,
+ ALPHA_13,
+ ALPHA_14,
+ ALPHA_15,
+ ALPHA_16,
+ ALPHA_17,
+ ALPHA_18,
+ ALPHA_19,
+ ALPHA_20,
+ ALPHA_21,
+ ALPHA_22,
+ ALPHA_23,
+ ALPHA_24,
+ ALPHA_25,
+ ALPHA_26,
+ ALPHA_27,
+ ALPHA_28,
+ ALPHA_29,
+ ALPHA_30,
+ ALPHA_31,
+ ALPHA_32,
+ ALPHA_33,
+ ALPHA_34,
+ ALPHA_35,
+ ALPHA_36,
+ ALPHA_37,
+ ALPHA_38,
+ ALPHA_39,
+ ALPHA_40,
+ ALPHA_41,
+ ALPHA_42,
+ ALPHA_43,
+ ALPHA_44,
+ ALPHA_45,
+ ALPHA_46,
+ ALPHA_47,
+ ALPHA_48,
+ ALPHA_49,
+ ALPHA_50};
+
+
+ /* Calculate the product of the time constant and the sample rate */
+ Product = ((tc >> 16) * (LVM_UINT32)Fs) << 13; /* Stereo value */
+ Product = Product + (((tc & 0x0000FFFF) * (LVM_UINT32)Fs) >> 3);
+
+ if (NumChannels == 1)
+ {
+ Product = Product >> 1; /* Mono value */
+ }
+
+ /* Normalize to get the table index and interpolation factor */
+ for (Shift=0; Shift<((Alpha_TableSize-1)/2); Shift++)
+ {
+ if ((Product & 0x80000000)!=0)
+ {
+ break;
+ }
+
+ Product = Product << 1;
+ }
+ Shift = (LVM_UINT16)((Shift << 1));
+
+ if ((Product & 0x40000000)==0)
+ {
+ Shift++;
+ }
+
+ Interpolate = (LVM_INT16)((Product >> 15) & 0x00007FFF);
+
+ Diff = (LVM_INT32)(Table[Shift] - Table[Shift+1]);
+ MUL32x16INTO32(Diff,Interpolate,Diff,15)
+ Product = Table[Shift+1] + (LVM_UINT32)Diff;
+
+ return Product;
+}
diff --git a/media/libeffects/lvm/lib/Common/src/LVM_Polynomial.c b/media/libeffects/lvm/lib/Common/src/LVM_Polynomial.c
new file mode 100755
index 0000000..b8cf4b4
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/LVM_Polynomial.c
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+#include "LVM_Types.h"
+#include "LVM_Macros.h"
+#include "ScalarArithmetic.h"
+
+/*-------------------------------------------------------------------------*/
+/* FUNCTION: */
+/* LVM_Polynomial */
+/* */
+/* DESCRIPTION: */
+/* This function performs polynomial expansion */
+/* Y = (A0 + A1*X + A2*X2 + A3*X3 + Â….. + AN*xN) << AN+1 */
+/* */
+/* LVM_INT32 LVM_Polynomial(LVM_UINT16 N, */
+/* LVM_INT32 *pCoefficients, */
+/* LVM_INT32 X) */
+/* */
+/* PARAMETERS: */
+/* */
+/* N is the polynomial order */
+/* pCoefficients is the ptr to polynomial coefficients A0,A1.. in Q.31 */
+/* X is the input variable */
+/* */
+/* RETURNS: */
+/* The result of the polynomial expansion in Q1.31 format */
+/*-------------------------------------------------------------------------*/
+
+LVM_INT32 LVM_Polynomial(LVM_UINT16 N,
+ LVM_INT32 *pCoefficients,
+ LVM_INT32 X)
+{
+ LVM_INT32 i;
+ LVM_INT32 Y,A,XTemp,Temp,sign;
+
+ Y=*pCoefficients; /* Y=A0*/
+ pCoefficients++;
+
+ if((LVM_UINT32)X==0x80000000)
+ {
+ Temp=-1;
+ sign=Temp;
+ for(i=1;i<=N;i++)
+ {
+ Y+=((*pCoefficients)*sign);
+ pCoefficients++;
+ sign*=Temp;
+ }
+
+
+ }
+ else
+ {
+ XTemp=X;
+ for(i=N-1;i>=0;i--)
+ {
+ A=*pCoefficients;
+ pCoefficients++;
+
+ MUL32x32INTO32(A,XTemp,Temp,31)
+ Y+=Temp;
+
+ MUL32x32INTO32(XTemp,X,Temp,31)
+ XTemp=Temp;
+ }
+ }
+ A=*pCoefficients;
+ pCoefficients++;
+
+ if(A<0)
+ {
+ A=Abs_32(A);
+ Y=Y>>A;
+ }
+ else
+ {
+ Y = Y<<A;
+ }
+ return Y;
+}
+
diff --git a/media/libeffects/lvm/lib/Common/src/LVM_Power10.c b/media/libeffects/lvm/lib/Common/src/LVM_Power10.c
new file mode 100755
index 0000000..9a3f632
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/LVM_Power10.c
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+#include "LVM_Types.h"
+#include "LVM_Macros.h"
+#include "ScalarArithmetic.h"
+#include "Filter.h"
+
+
+/*-------------------------------------------------------------------------*/
+/* FUNCTION: */
+/* LVM_Power10 */
+/* */
+/* DESCRIPTION: */
+/* This function calculates 10X using an 11th order polynomial. It uses */
+/* the following table of 32-bit integer polynomial coefficients: */
+/* */
+/* Coefficient Value */
+/* A0 67102543 */
+/* A1 309032995 */
+/* A2 712096127 */
+/* A3 1092797331 */
+/* A4 1251625137 */
+/* A5 1154649460 */
+/* A6 915654800 */
+/* A7 597883683 */
+/* A8 284378230 */
+/* A9 150262097 */
+/* A10 124894471 */
+/* A11 50477244 */
+/* A12 -2 */
+/* */
+/* Y = (A0 + A1*X + A2*X2 + A3*X3 + Â….. + AN*xN) << AN+1 */
+/* */
+/* */
+/* PARAMETERS: */
+/* */
+/* X is the input variable in Q2.30 format */
+/* */
+/* RETURNS: */
+/* The result of the 10x expansion in Q8.24 format */
+/*-------------------------------------------------------------------------*/
+
+LVM_INT32 LVM_Power10(LVM_INT32 X)
+{
+ LVM_INT32 Y,Coefficients[13]={ 16775636,
+ 77258249,
+ 178024032,
+ 273199333,
+ 312906284,
+ 288662365,
+ 228913700,
+ 149470921,
+ 71094558,
+ 37565524,
+ 31223618,
+ 12619311,
+ 0};
+ Y=LVM_Polynomial((LVM_UINT16)11,
+ Coefficients,
+ X);
+ return Y;
+}
+
diff --git a/media/libeffects/lvm/lib/Common/src/LVM_Timer.c b/media/libeffects/lvm/lib/Common/src/LVM_Timer.c
new file mode 100755
index 0000000..d49aadc
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/LVM_Timer.c
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: My Project */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+/****************************************************************************************/
+/* INCLUDE FILES */
+/****************************************************************************************/
+
+#include "LVM_Timer.h"
+#include "LVM_Timer_Private.h"
+
+/****************************************************************************************/
+/* TIMER FUNCTION */
+/****************************************************************************************/
+
+void LVM_Timer ( LVM_Timer_Instance_t *pInstance,
+ LVM_INT16 BlockSize ){
+
+ LVM_Timer_Instance_Private_t *pInstancePr;
+ pInstancePr = (LVM_Timer_Instance_Private_t *)pInstance;
+
+ if (pInstancePr->TimerArmed){
+ pInstancePr->RemainingTimeInSamples -= BlockSize;
+ if (pInstancePr->RemainingTimeInSamples <= 0){
+ pInstancePr->TimerArmed = 0;
+ (*pInstancePr->pCallBack) ( pInstancePr->pCallbackInstance,
+ pInstancePr->pCallBackParams,
+ pInstancePr->CallBackParam );
+ }
+ }
+}
+
+/****************************************************************************************/
+/* END OF FILE */
+/****************************************************************************************/
diff --git a/media/libeffects/lvm/lib/Common/src/LVM_Timer_Init.c b/media/libeffects/lvm/lib/Common/src/LVM_Timer_Init.c
new file mode 100755
index 0000000..e473038
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/LVM_Timer_Init.c
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: My Project */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+/****************************************************************************************/
+/* INCLUDE FILES */
+/****************************************************************************************/
+
+#include "LVM_Timer.h"
+#include "LVM_Timer_Private.h"
+#include "LVM_Macros.h"
+
+/****************************************************************************************/
+/* DEFINITIONS */
+/****************************************************************************************/
+
+#define OneOverThousandInQ24 16777
+
+/****************************************************************************************/
+/* INIT FUNCTION */
+/****************************************************************************************/
+
+void LVM_Timer_Init ( LVM_Timer_Instance_t *pInstance,
+ LVM_Timer_Params_t *pParams ){
+
+ LVM_Timer_Instance_Private_t *pInstancePr;
+ pInstancePr = (LVM_Timer_Instance_Private_t *)pInstance;
+
+ pInstancePr->CallBackParam = pParams->CallBackParam;
+ pInstancePr->pCallBackParams = pParams->pCallBackParams;
+ pInstancePr->pCallbackInstance = pParams->pCallbackInstance;
+ pInstancePr->pCallBack = pParams->pCallBack;
+ pInstancePr->TimerArmed = 1;
+
+ MUL32x16INTO32(pParams->SamplingRate,OneOverThousandInQ24,pInstancePr->RemainingTimeInSamples,16); /* (Q0 * Q24) >>16 into Q8*/
+ MUL32x16INTO32(pInstancePr->RemainingTimeInSamples,pParams->TimeInMs,pInstancePr->RemainingTimeInSamples,8); /* (Q8 * Q0) >>8 into Q0*/
+}
+
+/****************************************************************************************/
+/* END OF FILE */
+/****************************************************************************************/
diff --git a/media/libeffects/lvm/lib/Common/src/LVM_Timer_Private.h b/media/libeffects/lvm/lib/Common/src/LVM_Timer_Private.h
new file mode 100755
index 0000000..04d5af6
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/LVM_Timer_Private.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: My Project */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+#ifndef LVM_TIMER_PRIVATE_H
+#define LVM_TIMER_PRIVATE_H
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+#include "LVM_Types.h"
+
+/****************************************************************************************/
+/* TYPE DEFINITIONS */
+/****************************************************************************************/
+
+typedef struct
+{
+ LVM_INT32 RemainingTimeInSamples;
+ LVM_INT32 CallBackParam;
+ LVM_INT32 *pCallBackParams;
+ void *pCallbackInstance;
+ void (*pCallBack)(void*,void*,LVM_INT32);
+ LVM_INT16 TimerArmed; /* Boolean, true between init and callback */
+
+} LVM_Timer_Instance_Private_t;
+
+/****************************************************************************************/
+/* END OF HEADER */
+/****************************************************************************************/
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* LVM_TIMER_PRIVATE_H */
diff --git a/media/libeffects/lvm/lib/Common/src/LoadConst_16.c b/media/libeffects/lvm/lib/Common/src/LoadConst_16.c
new file mode 100755
index 0000000..bc2735f
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/LoadConst_16.c
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/**********************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1000 $
+ $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $
+
+***********************************************************************************/
+
+/**********************************************************************************
+ INCLUDE FILES
+***********************************************************************************/
+
+#include "VectorArithmetic.h"
+
+/**********************************************************************************
+ FUNCTION LoadConst_16
+***********************************************************************************/
+
+void LoadConst_16(const LVM_INT16 val,
+ LVM_INT16 *dst,
+ LVM_INT16 n )
+{
+ LVM_INT16 ii;
+
+ for (ii = n; ii != 0; ii--)
+ {
+ *dst = val;
+ dst++;
+ }
+
+ return;
+}
+
+/**********************************************************************************/
diff --git a/media/libeffects/lvm/lib/Common/src/LoadConst_32.c b/media/libeffects/lvm/lib/Common/src/LoadConst_32.c
new file mode 100755
index 0000000..19d5d4e
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/LoadConst_32.c
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+/**********************************************************************************
+ INCLUDE FILES
+***********************************************************************************/
+
+#include "VectorArithmetic.h"
+
+/**********************************************************************************
+ FUNCTION LoadConst_32
+***********************************************************************************/
+
+void LoadConst_32(const LVM_INT32 val,
+ LVM_INT32 *dst,
+ LVM_INT16 n )
+{
+ LVM_INT16 ii;
+
+ for (ii = n; ii != 0; ii--)
+ {
+ *dst = val;
+ dst++;
+ }
+
+ return;
+}
+
+/**********************************************************************************/
diff --git a/media/libeffects/lvm/lib/Common/src/MSTo2i_Sat_16x16.c b/media/libeffects/lvm/lib/Common/src/MSTo2i_Sat_16x16.c
new file mode 100755
index 0000000..1949f3c
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/MSTo2i_Sat_16x16.c
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/**********************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1000 $
+ $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $
+
+***********************************************************************************/
+
+/**********************************************************************************
+ INCLUDE FILES
+***********************************************************************************/
+
+#include "VectorArithmetic.h"
+
+/**********************************************************************************
+ FUNCTION MSTO2I_SAT_16X16
+***********************************************************************************/
+
+void MSTo2i_Sat_16x16(const LVM_INT16 *srcM,
+ const LVM_INT16 *srcS,
+ LVM_INT16 *dst,
+ LVM_INT16 n )
+{
+ LVM_INT32 temp,mVal,sVal;
+ LVM_INT16 ii;
+
+
+ for (ii = n; ii != 0; ii--)
+ {
+ mVal=(LVM_INT32)*srcM;
+ srcM++;
+
+ sVal=(LVM_INT32)*srcS;
+ srcS++;
+
+ temp = mVal + sVal;
+
+ if (temp > 0x00007FFF)
+ {
+ *dst = 0x7FFF;
+ }
+ else if (temp < -0x00008000)
+ {
+ *dst = - 0x8000;
+ }
+ else
+ {
+ *dst = (LVM_INT16)temp;
+ }
+ dst++;
+
+ temp = mVal - sVal;
+
+ if (temp > 0x00007FFF)
+ {
+ *dst = 0x7FFF;
+ }
+ else if (temp < -0x00008000)
+ {
+ *dst = - 0x8000;
+ }
+ else
+ {
+ *dst = (LVM_INT16)temp;
+ }
+ dst++;
+ }
+
+ return;
+}
+/**********************************************************************************/
diff --git a/media/libeffects/lvm/lib/Common/src/Mac3s_Sat_16x16.c b/media/libeffects/lvm/lib/Common/src/Mac3s_Sat_16x16.c
new file mode 100755
index 0000000..ef04ae8
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/Mac3s_Sat_16x16.c
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/**********************************************************************************
+
+ %created_by: sra % (CM/S)
+ %name: Mac3s_Sat_16x16.c % (CM/S)
+ %version: 1 % (CM/S)
+ %date_created: Fri Nov 13 12:07:13 2009 % (CM/S)
+
+***********************************************************************************/
+
+/**********************************************************************************
+ INCLUDE FILES
+***********************************************************************************/
+
+#include "VectorArithmetic.h"
+#include "LVM_Macros.h"
+
+/**********************************************************************************
+ FUNCTION Mac3S_16X16
+***********************************************************************************/
+
+void Mac3s_Sat_16x16( const LVM_INT16 *src,
+ const LVM_INT16 val,
+ LVM_INT16 *dst,
+ LVM_INT16 n)
+{
+ LVM_INT16 ii;
+ LVM_INT16 srcval;
+ LVM_INT32 Temp,dInVal;
+
+
+ for (ii = n; ii != 0; ii--)
+ {
+ srcval=*src;
+ src++;
+
+ Temp = (srcval *val)>>15;
+
+ dInVal = (LVM_INT32)*dst;
+
+ Temp = Temp + dInVal;
+
+ if (Temp > 0x00007FFF)
+ {
+ *dst = 0x7FFF;
+ }
+ else if (Temp < -0x00008000)
+ {
+ *dst = - 0x8000;
+ }
+ else
+ {
+ *dst = (LVM_INT16)Temp;
+ }
+
+ dst++;
+ }
+
+ return;
+}
+
+/**********************************************************************************/
+
+
+
diff --git a/media/libeffects/lvm/lib/Common/src/Mac3s_Sat_32x16.c b/media/libeffects/lvm/lib/Common/src/Mac3s_Sat_32x16.c
new file mode 100755
index 0000000..746a273
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/Mac3s_Sat_32x16.c
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+/**********************************************************************************
+ INCLUDE FILES
+***********************************************************************************/
+
+#include "VectorArithmetic.h"
+#include "LVM_Macros.h"
+
+/**********************************************************************************
+ FUNCTION MAC3S_16X16
+***********************************************************************************/
+
+void Mac3s_Sat_32x16( const LVM_INT32 *src,
+ const LVM_INT16 val,
+ LVM_INT32 *dst,
+ LVM_INT16 n)
+{
+ LVM_INT16 ii;
+ LVM_INT32 srcval,temp, dInVal, dOutVal;
+
+
+ for (ii = n; ii != 0; ii--)
+ {
+ srcval=*src;
+ src++;
+
+ MUL32x16INTO32(srcval,val,temp,15)
+
+ dInVal = *dst;
+ dOutVal = temp + dInVal;
+
+
+ if ((((dOutVal ^ temp) & (dOutVal ^ dInVal)) >> 31)!=0) /* overflow / underflow */
+ {
+ if(temp<0)
+ {
+ dOutVal=0x80000000l;
+ }
+ else
+ {
+ dOutVal=0x7FFFFFFFl;
+ }
+ }
+
+ *dst = dOutVal;
+ dst++;
+ }
+
+ return;
+}
+
+/**********************************************************************************/
+
+
+
diff --git a/media/libeffects/lvm/lib/Common/src/MixInSoft_D32C31_SAT.c b/media/libeffects/lvm/lib/Common/src/MixInSoft_D32C31_SAT.c
new file mode 100755
index 0000000..36de6c1
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/MixInSoft_D32C31_SAT.c
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+/**********************************************************************************
+ INCLUDE FILES
+***********************************************************************************/
+
+#include "Mixer_private.h"
+#include "VectorArithmetic.h"
+
+/**********************************************************************************
+ DEFINITIONS
+***********************************************************************************/
+
+#define TRUE 1
+#define FALSE 0
+
+/**********************************************************************************
+ FUNCTION MIXINSOFT_D32C31_SAT
+***********************************************************************************/
+
+void MixInSoft_D32C31_SAT( Mix_1St_Cll_t *pInstance,
+ const LVM_INT32 *src,
+ LVM_INT32 *dst,
+ LVM_INT16 n)
+{
+ char HardMixing = TRUE;
+
+ if(n<=0) return;
+
+ /******************************************************************************
+ SOFT MIXING
+ *******************************************************************************/
+ if (pInstance->Current != pInstance->Target)
+ {
+ if(pInstance->Alpha == 0){
+ pInstance->Current = pInstance->Target;
+ }else if ((pInstance->Current-pInstance->Target <POINT_ZERO_ONE_DB)&&
+ (pInstance->Current-pInstance->Target > -POINT_ZERO_ONE_DB)){
+ pInstance->Current = pInstance->Target; /* Difference is not significant anymore. Make them equal. */
+ }else{
+ /* Soft mixing has to be applied */
+ HardMixing = FALSE;
+ Core_MixInSoft_D32C31_SAT( pInstance, src, dst, n);
+ }
+ }
+
+ /******************************************************************************
+ HARD MIXING
+ *******************************************************************************/
+
+ if (HardMixing){
+ if (pInstance->Target != 0){ /* Nothing to do in case Target = 0 */
+ if ((pInstance->Target>>16) == 0x7FFF)
+ Add2_Sat_32x32( src, dst, n );
+ else{
+ Core_MixInSoft_D32C31_SAT( pInstance, src, dst, n);
+ pInstance->Current = pInstance->Target; /* In case the core function would have changed the Current value */
+ }
+ }
+ }
+
+ /******************************************************************************
+ CALL BACK
+ *******************************************************************************/
+ /* Call back before the hard mixing, because in this case, hard mixing makes
+ use of the core soft mix function which can change the Current value! */
+
+ if (pInstance->CallbackSet){
+ if ((pInstance->Current-pInstance->Target <POINT_ZERO_ONE_DB)&&
+ (pInstance->Current-pInstance->Target > -POINT_ZERO_ONE_DB)){
+ pInstance->Current = pInstance->Target; /* Difference is not significant anymore. Make them equal. */
+ pInstance->CallbackSet = FALSE;
+ if (pInstance->pCallBack != 0){
+ (*pInstance->pCallBack) ( pInstance->pCallbackHandle, pInstance->pGeneralPurpose,pInstance->CallbackParam );
+ }
+ }
+ }
+}
+
+/**********************************************************************************/
diff --git a/media/libeffects/lvm/lib/Common/src/MixSoft_1St_D32C31_WRA.c b/media/libeffects/lvm/lib/Common/src/MixSoft_1St_D32C31_WRA.c
new file mode 100755
index 0000000..5cf1a29
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/MixSoft_1St_D32C31_WRA.c
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+/**********************************************************************************
+ INCLUDE FILES
+***********************************************************************************/
+
+#include "Mixer_private.h"
+#include "VectorArithmetic.h"
+
+/**********************************************************************************
+ DEFINITIONS
+***********************************************************************************/
+
+#define TRUE 1
+#define FALSE 0
+
+
+
+/**********************************************************************************
+ FUNCTION MIXSOFT_1ST_D32C31_WRA
+***********************************************************************************/
+
+void MixSoft_1St_D32C31_WRA( Mix_1St_Cll_t *pInstance,
+ const LVM_INT32 *src,
+ LVM_INT32 *dst,
+ LVM_INT16 n)
+{
+ char HardMixing = TRUE;
+
+ if(n<=0) return;
+
+ /******************************************************************************
+ SOFT MIXING
+ *******************************************************************************/
+ if (pInstance->Current != pInstance->Target)
+ {
+ if(pInstance->Alpha == 0){
+ pInstance->Current = pInstance->Target;
+ }else if ((pInstance->Current-pInstance->Target <POINT_ZERO_ONE_DB)&&
+ (pInstance->Current-pInstance->Target > -POINT_ZERO_ONE_DB)){
+ pInstance->Current = pInstance->Target; /* Difference is not significant anymore. Make them equal. */
+ }else{
+ /* Soft mixing has to be applied */
+ HardMixing = FALSE;
+ Core_MixSoft_1St_D32C31_WRA( pInstance, src, dst, n);
+ }
+ }
+
+ /******************************************************************************
+ HARD MIXING
+ *******************************************************************************/
+
+ if (HardMixing){
+ if (pInstance->Target == 0)
+ LoadConst_32(0, dst, n);
+ else if ((pInstance->Target>>16) == 0x7FFF){
+ if (src != dst)
+ Copy_16((LVM_INT16*)src, (LVM_INT16*)dst, (LVM_INT16)(n * 2));
+ }
+ else
+ Mult3s_32x16( src, (LVM_INT16)(pInstance->Current>>16), dst, n );
+ }
+
+ /******************************************************************************
+ CALL BACK
+ *******************************************************************************/
+
+ if (pInstance->CallbackSet){
+ if ((pInstance->Current-pInstance->Target <POINT_ZERO_ONE_DB)&&
+ (pInstance->Current-pInstance->Target > -POINT_ZERO_ONE_DB)){
+ pInstance->Current = pInstance->Target; /* Difference is not significant anymore. Make them equal. */
+ pInstance->CallbackSet = FALSE;
+ if (pInstance->pCallBack != 0){
+ (*pInstance->pCallBack) ( pInstance->pCallbackHandle, pInstance->pGeneralPurpose,pInstance->CallbackParam );
+ }
+ }
+ }
+}
+
+/**********************************************************************************/
diff --git a/media/libeffects/lvm/lib/Common/src/MixSoft_2St_D32C31_SAT.c b/media/libeffects/lvm/lib/Common/src/MixSoft_2St_D32C31_SAT.c
new file mode 100755
index 0000000..b03f0ba
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/MixSoft_2St_D32C31_SAT.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+/**********************************************************************************
+ INCLUDE FILES
+***********************************************************************************/
+
+#include "Mixer_private.h"
+#include "VectorArithmetic.h"
+
+
+/**********************************************************************************
+ FUNCTION MIXSOFT_2ST_D32C31_SAT
+***********************************************************************************/
+
+void MixSoft_2St_D32C31_SAT( Mix_2St_Cll_t *pInstance,
+ const LVM_INT32 *src1,
+ const LVM_INT32 *src2,
+ LVM_INT32 *dst,
+ LVM_INT16 n)
+{
+
+ if(n<=0) return;
+
+ /******************************************************************************
+ SOFT MIXING
+ *******************************************************************************/
+ if ((pInstance->Current1 != pInstance->Target1) || (pInstance->Current2 != pInstance->Target2))
+ {
+ MixSoft_1St_D32C31_WRA( (Mix_1St_Cll_t*) pInstance, src1, dst, n);
+ MixInSoft_D32C31_SAT( (Mix_1St_Cll_t*) &pInstance->Alpha2, src2, dst, n);
+ }
+
+ /******************************************************************************
+ HARD MIXING
+ *******************************************************************************/
+
+ else
+ {
+ if (pInstance->Current1 == 0)
+ MixSoft_1St_D32C31_WRA( (Mix_1St_Cll_t*) &pInstance->Alpha2, src2, dst, n);
+ else if (pInstance->Current2 == 0)
+ MixSoft_1St_D32C31_WRA( (Mix_1St_Cll_t*) pInstance, src1, dst, n);
+ else
+ Core_MixHard_2St_D32C31_SAT( pInstance, src1, src2, dst, n);
+ }
+}
+
+/**********************************************************************************/
diff --git a/media/libeffects/lvm/lib/Common/src/Mixer_private.h b/media/libeffects/lvm/lib/Common/src/Mixer_private.h
new file mode 100755
index 0000000..d012548
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/Mixer_private.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/**********************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1000 $
+ $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $
+
+***********************************************************************************/
+
+#ifndef __MIXER_PRIVATE_H__
+#define __MIXER_PRIVATE_H__
+
+/**********************************************************************************
+ INCLUDE FILES
+***********************************************************************************/
+
+#include "Mixer.h"
+
+#define POINT_ZERO_ONE_DB 2473805 /* 0.01 dB on a full scale signal = (10^(0.01/20) -1) * 2^31 */
+
+/**********************************************************************************
+ DEFINITIONS
+***********************************************************************************/
+
+/**********************************************************************************/
+
+#endif //#ifndef __MIXER_PRIVATE_H__
+
diff --git a/media/libeffects/lvm/lib/Common/src/MonoTo2I_16.c b/media/libeffects/lvm/lib/Common/src/MonoTo2I_16.c
new file mode 100755
index 0000000..b053e556
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/MonoTo2I_16.c
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/**********************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1000 $
+ $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $
+
+***********************************************************************************/
+
+/**********************************************************************************
+ INCLUDE FILES
+***********************************************************************************/
+
+#include "VectorArithmetic.h"
+
+/**********************************************************************************
+ FUNCTION MonoTo2I_16
+***********************************************************************************/
+
+void MonoTo2I_16( const LVM_INT16 *src,
+ LVM_INT16 *dst,
+ LVM_INT16 n)
+{
+ LVM_INT16 ii;
+ src += (n-1);
+ dst += ((n*2)-1);
+
+ for (ii = n; ii != 0; ii--)
+ {
+ *dst = *src;
+ dst--;
+
+ *dst = *src;
+ dst--;
+ src--;
+ }
+
+ return;
+}
+
+/**********************************************************************************/
diff --git a/media/libeffects/lvm/lib/Common/src/MonoTo2I_32.c b/media/libeffects/lvm/lib/Common/src/MonoTo2I_32.c
new file mode 100755
index 0000000..e8164bb
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/MonoTo2I_32.c
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+/**********************************************************************************
+ INCLUDE FILES
+***********************************************************************************/
+
+#include "VectorArithmetic.h"
+
+/**********************************************************************************
+ FUNCTION MonoTo2I_32
+***********************************************************************************/
+
+void MonoTo2I_32( const LVM_INT32 *src,
+ LVM_INT32 *dst,
+ LVM_INT16 n)
+{
+ LVM_INT16 ii;
+ src += (n-1);
+ dst += ((n*2)-1);
+
+ for (ii = n; ii != 0; ii--)
+ {
+ *dst = *src;
+ dst--;
+
+ *dst = *src;
+ dst--;
+ src--;
+ }
+
+ return;
+}
+
+/**********************************************************************************/
diff --git a/media/libeffects/lvm/lib/Common/src/Mult3s_32x16.c b/media/libeffects/lvm/lib/Common/src/Mult3s_32x16.c
new file mode 100755
index 0000000..ee83524
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/Mult3s_32x16.c
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+/**********************************************************************************
+ INCLUDE FILES
+***********************************************************************************/
+
+#include "VectorArithmetic.h"
+#include "LVM_Macros.h"
+
+/**********************************************************************************
+FUNCTION MULT3S_16X16
+***********************************************************************************/
+
+void Mult3s_32x16( const LVM_INT32 *src,
+ const LVM_INT16 val,
+ LVM_INT32 *dst,
+ LVM_INT16 n)
+{
+ LVM_INT16 ii;
+ LVM_INT32 srcval,temp;
+
+ for (ii = n; ii != 0; ii--)
+ {
+ srcval=*src;
+ src++;
+
+ MUL32x16INTO32(srcval,val,temp,15)
+
+ *dst = temp;
+ dst++;
+ }
+
+ return;
+}
+
+/**********************************************************************************/
diff --git a/media/libeffects/lvm/lib/Common/src/NonLinComp_D16.c b/media/libeffects/lvm/lib/Common/src/NonLinComp_D16.c
new file mode 100755
index 0000000..1428777
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/NonLinComp_D16.c
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/**********************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1000 $
+ $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $
+
+***********************************************************************************/
+
+/****************************************************************************************/
+/* */
+/* Includes */
+/* */
+/****************************************************************************************/
+
+#include "CompLim_private.h"
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: NonLinComp_D16 */
+/* */
+/* DESCRIPTION: */
+/* Non-linear compression by companding. The function works on a sample by sample */
+/* basis by increasing the level near the zero crossing. This gives a ttrade-off */
+/* between THD and compression. It uses the equation: */
+/* */
+/* Output = Input + K * (Input - Input^2) if Input > 0 */
+/* = Input + K * (Input + Input^2) if Input <= 0 */
+/* */
+/* The value of K controls the amount of compression and as a side effect the amount */
+/* distortion introduced. The amount of compression is signal dependent and the values */
+/* given below are approximate. */
+/* */
+/* Gain (fractional) Gain (integer) Compression Pk-Pk THD */
+/* 1.0 32767 +6dB 16dB */
+/* 0.78 25559 +5dB 19dB */
+/* 0.6 19661 +4dB 21dB */
+/* 0.41 13435 +3dB 24dB */
+/* 0.26 8520 +2dB 28dB */
+/* 0.12 3932 +1dB 34dB */
+/* 0.0 0 +0dB 98dB */
+/* */
+/* PARAMETERS: */
+/* Gain - compression control parameter */
+/* pDataIn - pointer to the input data buffer */
+/* pDataOut - pointer to the output data buffer */
+/* BlockLength - number of samples to process */
+/* */
+/* RETURNS: */
+/* None */
+/* */
+/* NOTES: */
+/* */
+/****************************************************************************************/
+
+void NonLinComp_D16(LVM_INT16 Gain,
+ LVM_INT16 *pDataIn,
+ LVM_INT16 *pDataOut,
+ LVM_INT32 BlockLength)
+{
+
+ LVM_INT16 Sample; /* Input samples */
+ LVM_INT32 SampleNo; /* Sample index */
+ LVM_INT16 Temp;
+
+
+ /*
+ * Process a block of samples
+ */
+ for(SampleNo = 0; SampleNo<BlockLength; SampleNo++)
+ {
+
+ /*
+ * Read the input
+ */
+ Sample = *pDataIn;
+ pDataIn++;
+
+
+ /*
+ * Apply the compander, this compresses the signal at the expense of
+ * harmonic distortion. The amount of compression is control by the
+ * gain factor
+ */
+ if ((LVM_INT32)Sample != -32768)
+ {
+ Temp = (LVM_INT16)((Sample * Sample) >> 15);
+ if(Sample >0)
+ {
+ Sample = (LVM_INT16)(Sample + ((Gain * (Sample - Temp)) >> 15));
+ }
+ else
+ {
+ Sample = (LVM_INT16)(Sample + ((Gain * (Sample + Temp)) >> 15));
+ }
+ }
+
+
+ /*
+ * Save the output
+ */
+ *pDataOut = Sample;
+ pDataOut++;
+
+
+ }
+
+}
+
diff --git a/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32C14G11_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32C14G11_TRC_WRA_01.c
new file mode 100755
index 0000000..06cfe88
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32C14G11_TRC_WRA_01.c
@@ -0,0 +1,130 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+#include "BIQUAD.h"
+#include "PK_2I_D32F32CssGss_TRC_WRA_01_Private.h"
+#include "LVM_Macros.h"
+
+/**************************************************************************
+ ASSUMPTIONS:
+ COEFS-
+ pBiquadState->coefs[0] is A0,
+ pBiquadState->coefs[1] is -B2,
+ pBiquadState->coefs[2] is -B1, these are in Q14 format
+ pBiquadState->coefs[3] is Gain, in Q11 format
+
+
+ DELAYS-
+ pBiquadState->pDelays[0] is x(n-1)L in Q0 format
+ pBiquadState->pDelays[1] is x(n-1)R in Q0 format
+ pBiquadState->pDelays[2] is x(n-2)L in Q0 format
+ pBiquadState->pDelays[3] is x(n-2)R in Q0 format
+ pBiquadState->pDelays[4] is y(n-1)L in Q0 format
+ pBiquadState->pDelays[5] is y(n-1)R in Q0 format
+ pBiquadState->pDelays[6] is y(n-2)L in Q0 format
+ pBiquadState->pDelays[7] is y(n-2)R in Q0 format
+***************************************************************************/
+void PK_2I_D32F32C14G11_TRC_WRA_01 ( Biquad_Instance_t *pInstance,
+ LVM_INT32 *pDataIn,
+ LVM_INT32 *pDataOut,
+ LVM_INT16 NrSamples)
+ {
+ LVM_INT32 ynL,ynR,ynLO,ynRO,templ;
+ LVM_INT16 ii;
+ PFilter_State pBiquadState = (PFilter_State) pInstance;
+
+ for (ii = NrSamples; ii != 0; ii--)
+ {
+
+
+ /**************************************************************************
+ PROCESSING OF THE LEFT CHANNEL
+ ***************************************************************************/
+ /* ynL= (A0 (Q14) * (x(n)L (Q0) - x(n-2)L (Q0) ) >>14) in Q0*/
+ templ=(*pDataIn)-pBiquadState->pDelays[2];
+ MUL32x16INTO32(templ,pBiquadState->coefs[0],ynL,14)
+
+ /* ynL+= ((-B2 (Q14) * y(n-2)L (Q0) ) >>14) in Q0*/
+ MUL32x16INTO32(pBiquadState->pDelays[6],pBiquadState->coefs[1],templ,14)
+ ynL+=templ;
+
+ /* ynL+= ((-B1 (Q14) * y(n-1)L (Q0) ) >>14) in Q0 */
+ MUL32x16INTO32(pBiquadState->pDelays[4],pBiquadState->coefs[2],templ,14)
+ ynL+=templ;
+
+ /* ynLO= ((Gain (Q11) * ynL (Q0))>>11) in Q0*/
+ MUL32x16INTO32(ynL,pBiquadState->coefs[3],ynLO,11)
+
+ /* ynLO=( ynLO(Q0) + x(n)L (Q0) ) in Q0*/
+ ynLO+= (*pDataIn);
+
+ /**************************************************************************
+ PROCESSING OF THE RIGHT CHANNEL
+ ***************************************************************************/
+ /* ynR= (A0 (Q14) * (x(n)R (Q0) - x(n-2)R (Q0) ) >>14) in Q0*/
+ templ=(*(pDataIn+1))-pBiquadState->pDelays[3];
+ MUL32x16INTO32(templ,pBiquadState->coefs[0],ynR,14)
+
+ /* ynR+= ((-B2 (Q14) * y(n-2)R (Q0) ) >>14) in Q0*/
+ MUL32x16INTO32(pBiquadState->pDelays[7],pBiquadState->coefs[1],templ,14)
+ ynR+=templ;
+
+ /* ynR+= ((-B1 (Q14) * y(n-1)R (Q0) ) >>14) in Q0 */
+ MUL32x16INTO32(pBiquadState->pDelays[5],pBiquadState->coefs[2],templ,14)
+ ynR+=templ;
+
+ /* ynRO= ((Gain (Q11) * ynR (Q0))>>11) in Q0*/
+ MUL32x16INTO32(ynR,pBiquadState->coefs[3],ynRO,11)
+
+ /* ynRO=( ynRO(Q0) + x(n)R (Q0) ) in Q0*/
+ ynRO+= (*(pDataIn+1));
+
+ /**************************************************************************
+ UPDATING THE DELAYS
+ ***************************************************************************/
+ pBiquadState->pDelays[7]=pBiquadState->pDelays[5]; /* y(n-2)R=y(n-1)R*/
+ pBiquadState->pDelays[6]=pBiquadState->pDelays[4]; /* y(n-2)L=y(n-1)L*/
+ pBiquadState->pDelays[3]=pBiquadState->pDelays[1]; /* x(n-2)R=x(n-1)R*/
+ pBiquadState->pDelays[2]=pBiquadState->pDelays[0]; /* x(n-2)L=x(n-1)L*/
+ pBiquadState->pDelays[5]=ynR; /* Update y(n-1)R in Q0*/
+ pBiquadState->pDelays[4]=ynL; /* Update y(n-1)L in Q0*/
+ pBiquadState->pDelays[0]=(*pDataIn); /* Update x(n-1)L in Q0*/
+ pDataIn++;
+ pBiquadState->pDelays[1]=(*pDataIn); /* Update x(n-1)R in Q0*/
+ pDataIn++;
+
+ /**************************************************************************
+ WRITING THE OUTPUT
+ ***************************************************************************/
+ *pDataOut=ynLO; /* Write Left output in Q0*/
+ pDataOut++;
+ *pDataOut=ynRO; /* Write Right ouput in Q0*/
+ pDataOut++;
+
+ }
+
+ }
+
diff --git a/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32C30G11_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32C30G11_TRC_WRA_01.c
new file mode 100755
index 0000000..5b78f62
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32C30G11_TRC_WRA_01.c
@@ -0,0 +1,128 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+#include "BIQUAD.h"
+#include "PK_2I_D32F32CllGss_TRC_WRA_01_Private.h"
+#include "LVM_Macros.h"
+
+/**************************************************************************
+ ASSUMPTIONS:
+ COEFS-
+ pBiquadState->coefs[0] is A0,
+ pBiquadState->coefs[1] is -B2,
+ pBiquadState->coefs[2] is -B1, these are in Q30 format
+ pBiquadState->coefs[3] is Gain, in Q11 format
+
+
+ DELAYS-
+ pBiquadState->pDelays[0] is x(n-1)L in Q0 format
+ pBiquadState->pDelays[1] is x(n-1)R in Q0 format
+ pBiquadState->pDelays[2] is x(n-2)L in Q0 format
+ pBiquadState->pDelays[3] is x(n-2)R in Q0 format
+ pBiquadState->pDelays[4] is y(n-1)L in Q0 format
+ pBiquadState->pDelays[5] is y(n-1)R in Q0 format
+ pBiquadState->pDelays[6] is y(n-2)L in Q0 format
+ pBiquadState->pDelays[7] is y(n-2)R in Q0 format
+***************************************************************************/
+void PK_2I_D32F32C30G11_TRC_WRA_01 ( Biquad_Instance_t *pInstance,
+ LVM_INT32 *pDataIn,
+ LVM_INT32 *pDataOut,
+ LVM_INT16 NrSamples)
+ {
+ LVM_INT32 ynL,ynR,ynLO,ynRO,templ;
+ LVM_INT16 ii;
+ PFilter_State pBiquadState = (PFilter_State) pInstance;
+
+ for (ii = NrSamples; ii != 0; ii--)
+ {
+
+
+ /**************************************************************************
+ PROCESSING OF THE LEFT CHANNEL
+ ***************************************************************************/
+ /* ynL= (A0 (Q30) * (x(n)L (Q0) - x(n-2)L (Q0) ) >>30) in Q0*/
+ templ=(*pDataIn)-pBiquadState->pDelays[2];
+ MUL32x32INTO32(templ,pBiquadState->coefs[0],ynL,30)
+
+ /* ynL+= ((-B2 (Q30) * y(n-2)L (Q0) ) >>30) in Q0*/
+ MUL32x32INTO32(pBiquadState->pDelays[6],pBiquadState->coefs[1],templ,30)
+ ynL+=templ;
+
+ /* ynL+= ((-B1 (Q30) * y(n-1)L (Q0) ) >>30) in Q0 */
+ MUL32x32INTO32(pBiquadState->pDelays[4],pBiquadState->coefs[2],templ,30)
+ ynL+=templ;
+
+ /* ynLO= ((Gain (Q11) * ynL (Q0))>>11) in Q0*/
+ MUL32x16INTO32(ynL,pBiquadState->coefs[3],ynLO,11)
+ /* ynLO=( ynLO(Q0) + x(n)L (Q0) ) in Q0*/
+ ynLO+= (*pDataIn);
+
+ /**************************************************************************
+ PROCESSING OF THE RIGHT CHANNEL
+ ***************************************************************************/
+ /* ynR= (A0 (Q30) * (x(n)R (Q0) - x(n-2)R (Q0) ) >>30) in Q0*/
+ templ=(*(pDataIn+1))-pBiquadState->pDelays[3];
+ MUL32x32INTO32(templ,pBiquadState->coefs[0],ynR,30)
+
+ /* ynR+= ((-B2 (Q30) * y(n-2)R (Q0) ) >>30) in Q0*/
+ MUL32x32INTO32(pBiquadState->pDelays[7],pBiquadState->coefs[1],templ,30)
+ ynR+=templ;
+
+ /* ynR+= ((-B1 (Q30) * y(n-1)R (Q0) ) >>30) in Q0 */
+ MUL32x32INTO32(pBiquadState->pDelays[5],pBiquadState->coefs[2],templ,30)
+ ynR+=templ;
+
+ /* ynRO= ((Gain (Q11) * ynR (Q0))>>11) in Q0*/
+ MUL32x16INTO32(ynR,pBiquadState->coefs[3],ynRO,11)
+
+ /* ynRO=( ynRO(Q0) + x(n)R (Q0) ) in Q0*/
+ ynRO+= (*(pDataIn+1));
+
+ /**************************************************************************
+ UPDATING THE DELAYS
+ ***************************************************************************/
+ pBiquadState->pDelays[7]=pBiquadState->pDelays[5]; /* y(n-2)R=y(n-1)R*/
+ pBiquadState->pDelays[6]=pBiquadState->pDelays[4]; /* y(n-2)L=y(n-1)L*/
+ pBiquadState->pDelays[3]=pBiquadState->pDelays[1]; /* x(n-2)R=x(n-1)R*/
+ pBiquadState->pDelays[2]=pBiquadState->pDelays[0]; /* x(n-2)L=x(n-1)L*/
+ pBiquadState->pDelays[5]=ynR; /* Update y(n-1)R in Q0*/
+ pBiquadState->pDelays[4]=ynL; /* Update y(n-1)L in Q0*/
+ pBiquadState->pDelays[0]=(*pDataIn); /* Update x(n-1)L in Q0*/
+ pDataIn++;
+ pBiquadState->pDelays[1]=(*pDataIn); /* Update x(n-1)R in Q0*/
+ pDataIn++;
+
+ /**************************************************************************
+ WRITING THE OUTPUT
+ ***************************************************************************/
+ *pDataOut=ynLO; /* Write Left output in Q0*/
+ pDataOut++;
+ *pDataOut=ynRO; /* Write Right ouput in Q0*/
+ pDataOut++;
+ }
+
+ }
+
diff --git a/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32CllGss_TRC_WRA_01_Init.c b/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32CllGss_TRC_WRA_01_Init.c
new file mode 100755
index 0000000..e7bcd0c
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32CllGss_TRC_WRA_01_Init.c
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+#include "BIQUAD.h"
+#include "PK_2I_D32F32CllGss_TRC_WRA_01_Private.h"
+
+
+void PK_2I_D32F32CllGss_TRC_WRA_01_Init(Biquad_Instance_t *pInstance,
+ Biquad_2I_Order2_Taps_t *pTaps,
+ PK_C32_Coefs_t *pCoef)
+{
+ PFilter_State pBiquadState = (PFilter_State) pInstance;
+ pBiquadState->pDelays =(LVM_INT32 *) pTaps;
+
+ pBiquadState->coefs[0]=pCoef->A0;
+
+ pBiquadState->coefs[1]=pCoef->B2;
+
+ pBiquadState->coefs[2]=pCoef->B1;
+
+ pBiquadState->coefs[3]=pCoef->G;
+
+}
+
diff --git a/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32CllGss_TRC_WRA_01_Private.h b/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32CllGss_TRC_WRA_01_Private.h
new file mode 100755
index 0000000..741f504
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32CllGss_TRC_WRA_01_Private.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef _PK_2I_D32F32CLLGSS_TRC_WRA_01_PRIVATE_H_
+#define _PK_2I_D32F32CLLGSS_TRC_WRA_01_PRIVATE_H_
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+/* The internal state variables are implemented in a (for the user) hidden structure */
+/* In this (private) file, the internal structure is declared fro private use. */
+typedef struct _Filter_State_
+{
+ LVM_INT32 * pDelays; /* pointer to the delayed samples (data of 32 bits) */
+ LVM_INT32 coefs[5]; /* pointer to the filter coefficients */
+}Filter_State;
+
+typedef Filter_State * PFilter_State ;
+
+#endif /* _PK_2I_D32F32CLLGSS_TRC_WRA_01_PRIVATE_H_ */
diff --git a/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32CssGss_TRC_WRA_01_Init.c b/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32CssGss_TRC_WRA_01_Init.c
new file mode 100755
index 0000000..f02305e
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32CssGss_TRC_WRA_01_Init.c
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+#include "BIQUAD.h"
+#include "PK_2I_D32F32CssGss_TRC_WRA_01_Private.h"
+
+void PK_2I_D32F32CssGss_TRC_WRA_01_Init(Biquad_Instance_t *pInstance,
+ Biquad_2I_Order2_Taps_t *pTaps,
+ PK_C16_Coefs_t *pCoef)
+{
+ PFilter_State pBiquadState = (PFilter_State) pInstance;
+ pBiquadState->pDelays =(LVM_INT32 *) pTaps;
+
+ pBiquadState->coefs[0]=pCoef->A0;
+
+ pBiquadState->coefs[1]=pCoef->B2;
+
+ pBiquadState->coefs[2]=pCoef->B1;
+
+ pBiquadState->coefs[3]=pCoef->G;
+
+}
+
diff --git a/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32CssGss_TRC_WRA_01_Private.h b/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32CssGss_TRC_WRA_01_Private.h
new file mode 100755
index 0000000..ca31669
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32CssGss_TRC_WRA_01_Private.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef _PK_2I_D32F32CSSGSS_TRC_WRA_01_PRIVATE_H_
+#define _PK_2I_D32F32CSSGSS_TRC_WRA_01_PRIVATE_H_
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+
+/* The internal state variables are implemented in a (for the user) hidden structure */
+/* In this (private) file, the internal structure is declared fro private use. */
+typedef struct _Filter_State_
+{
+ LVM_INT32 * pDelays; /* pointer to the delayed samples (data of 32 bits) */
+ LVM_INT32 coefs[5]; /* pointer to the filter coefficients */
+}Filter_State;
+
+typedef Filter_State * PFilter_State ;
+
+#endif /* _PK_2I_D32F32CSSGSS_TRC_WRA_01_PRIVATE_H_ */
diff --git a/media/libeffects/lvm/lib/Common/src/Shift_Sat_v16xv16.c b/media/libeffects/lvm/lib/Common/src/Shift_Sat_v16xv16.c
new file mode 100755
index 0000000..e449a7f
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/Shift_Sat_v16xv16.c
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/**********************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1000 $
+ $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $
+
+***********************************************************************************/
+
+/**********************************************************************************
+ INCLUDE FILES
+***********************************************************************************/
+
+#include "VectorArithmetic.h"
+
+/**********************************************************************************
+ FUNCTION Shift_Sat_v16xv16
+***********************************************************************************/
+
+void Shift_Sat_v16xv16 (const LVM_INT16 val,
+ const LVM_INT16 *src,
+ LVM_INT16 *dst,
+ LVM_INT16 n)
+{
+ LVM_INT32 temp;
+ LVM_INT32 ii;
+ LVM_INT16 RShift;
+ if(val>0)
+ {
+ for (ii = n; ii != 0; ii--)
+ {
+ temp = (LVM_INT32)*src;
+ src++;
+
+ temp = temp << val;
+
+ if (temp > 0x00007FFF)
+ {
+ *dst = 0x7FFF;
+ }
+ else if (temp < -0x00008000)
+ {
+ *dst = - 0x8000;
+ }
+ else
+ {
+ *dst = (LVM_INT16)temp;
+ }
+ dst++;
+ }
+ }
+ else if(val<0)
+ {
+ RShift=(LVM_INT16)(-val);
+
+ for (ii = n; ii != 0; ii--)
+ {
+ *dst = (LVM_INT16)(*src >> RShift);
+ dst++;
+ src++;
+ }
+ }
+ else
+ {
+ if(src!=dst)
+ {
+ Copy_16(src,dst,n);
+ }
+ }
+ return;
+}
+
+/**********************************************************************************/
diff --git a/media/libeffects/lvm/lib/Common/src/Shift_Sat_v32xv32.c b/media/libeffects/lvm/lib/Common/src/Shift_Sat_v32xv32.c
new file mode 100755
index 0000000..0ab98ea
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/Shift_Sat_v32xv32.c
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: */
+/* $Author: beq07716 $*/
+/* $Revision: 1000 $*/
+/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+/**********************************************************************************
+ INCLUDE FILES
+***********************************************************************************/
+
+#include "VectorArithmetic.h"
+
+/**********************************************************************************
+ FUNCTION Shift_Sat_v32xv32
+***********************************************************************************/
+
+void Shift_Sat_v32xv32 (const LVM_INT16 val,
+ const LVM_INT32 *src,
+ LVM_INT32 *dst,
+ LVM_INT16 n)
+{
+ LVM_INT32 ii;
+ LVM_INT16 RShift;
+
+ if(val>0)
+ {
+ LVM_INT32 a,b;
+
+ for (ii = n; ii != 0; ii--)
+ {
+ a=*src;
+ src++;
+
+ b=(a<<val);
+
+ if( (b>>val) != a ) /* if overflow occured, right shift will show difference*/
+ {
+ if(a<0)
+ {
+ b=0x80000000l;
+ }
+ else
+ {
+ b=0x7FFFFFFFl;
+ }
+ }
+
+ *dst = b;
+ dst++;
+ }
+ }
+ else if(val<0)
+ {
+ RShift=(LVM_INT16)(-val);
+ for (ii = n; ii != 0; ii--)
+ {
+ *dst = (*src >> RShift);
+ dst++;
+ src++;
+ }
+ }
+ else
+ {
+ if(src!=dst)
+ {
+ Copy_16((LVM_INT16 *)src,(LVM_INT16 *)dst,(LVM_INT16)(n<<1));
+ }
+ }
+ return;
+}
+
+/**********************************************************************************/
diff --git a/media/libeffects/lvm/lib/Common/src/dB_to_Lin32.c b/media/libeffects/lvm/lib/Common/src/dB_to_Lin32.c
new file mode 100755
index 0000000..ac0343f
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/dB_to_Lin32.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* %created_by: sra % (CM/S)*/
+/* %name: dB_to_Lin32.c % (CM/S)*/
+/* %version: 2 % (CM/S)*/
+/* %date_created: Wed Jun 18 11:27:46 2008 % (CM/S)*/
+/* */
+/************************************************************************/
+
+/*######################################################################################*/
+/* Include files */
+/*######################################################################################*/
+
+#include "ScalarArithmetic.h"
+
+
+/****************************************************************************************
+ * Name : dB_to_Lin32()
+ * Input : Signed 16-bit integer
+ * MSB (16) = sign bit
+ * (15->05) = integer part
+ * (04->01) = decimal part
+ * Output : Signed 32-bit integer
+ * MSB (32) = sign bit
+ * (31->16) = integer part
+ * (15->01) = decimal part
+ * Returns : Lin value format 1.16.15
+ * Description :
+ * Remarks : Makes an approximation to the conversion by counting the number
+ * of 6dB steps for use as shifts and then interpolates with a remainder
+ * with the equation:
+ *
+ * Correction = (Remainder / 1.5029) - (Remainder^2 / 6)
+ *
+ * The two coefficients are scaled from 0x40000000 in 96 steps and calculated
+ * as follows:
+ *
+ * FIRST_COEF = 0x80000000 / (96 * 1.5029)
+ * SECOND_COEF = 0x80000000 / (96^2 * 6)
+ *
+ ****************************************************************************************/
+
+#define FOUR_OVER_SIX 21846 /* (4 / 6) * 2^15 */
+#define SIX_DB 96 /* 6 * 16 or 6dB in Q11.4 format */
+#define FIRST_COEF_NEG 14884305
+#define FIRST_COEF_POS 7442152 /* FIRST_COEF_NEG / 2 */
+#define SECOND_COEF 38836
+#define MAX_VALUE 1536 /* 96 * 16 */
+
+LVM_INT32 dB_to_Lin32(LVM_INT16 db_fix)
+{
+ LVM_INT32 Lin_val_32;
+ LVM_INT16 Shift;
+ LVM_INT32 Remain;
+
+
+ /*
+ * Check sign of the input
+ */
+ if (db_fix<0)
+ {
+ if (db_fix > -MAX_VALUE)
+ {
+ Shift = (LVM_INT16)((((LVM_UINT32)(-db_fix) >> 4) * FOUR_OVER_SIX) >> 17); /* Number of 6dB steps in Q11.4 format */
+ Remain = -db_fix - (Shift * SIX_DB);
+ Remain = (0x7FFFFFFF - (Remain * FIRST_COEF_NEG)) + (Remain * Remain * SECOND_COEF);
+ Lin_val_32 = (LVM_INT32)((LVM_UINT32)Remain >> (16 + Shift));
+ }
+ else
+ {
+ Lin_val_32 = 0;
+ }
+ }
+ else
+ {
+ if (db_fix < MAX_VALUE)
+ {
+ Shift = (LVM_INT16)((((LVM_UINT32)db_fix >> 4) * FOUR_OVER_SIX) >> 17); /* Number of 6dB steps in Q11.4 format */
+ Remain = db_fix - (Shift * SIX_DB);
+ Remain = 0x3FFFFFFF + (Remain * FIRST_COEF_POS) + (Remain * Remain * SECOND_COEF);
+ Lin_val_32 = (LVM_INT32)((LVM_UINT32)Remain >> (15 - Shift));
+ }
+ else
+ {
+ Lin_val_32 = 0x7FFFFFFF;
+ }
+ }
+
+
+ return Lin_val_32; /* format 1.16.15 */
+}
+
diff --git a/media/libeffects/lvm/lib/Common/src/mult3s_16x16.c b/media/libeffects/lvm/lib/Common/src/mult3s_16x16.c
new file mode 100755
index 0000000..b500979
--- /dev/null
+++ b/media/libeffects/lvm/lib/Common/src/mult3s_16x16.c
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/**********************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1000 $
+ $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $
+
+***********************************************************************************/
+
+/**********************************************************************************
+ INCLUDE FILES
+***********************************************************************************/
+
+#include "VectorArithmetic.h"
+
+/**********************************************************************************
+ FUNCTION MULT3S_16X16
+***********************************************************************************/
+
+void Mult3s_16x16( const LVM_INT16 *src,
+ const LVM_INT16 val,
+ LVM_INT16 *dst,
+ LVM_INT16 n)
+{
+ LVM_INT16 ii;
+ LVM_INT32 temp;
+
+ for (ii = n; ii != 0; ii--)
+ {
+ temp = (LVM_INT32)(*src) * (LVM_INT32)val;
+ src++;
+
+ *dst = (LVM_INT16)(temp >> 15);
+ dst++;
+ }
+
+ return;
+}
+
+/**********************************************************************************/
diff --git a/media/libeffects/lvm/lib/Eq/lib/LVEQNB.h b/media/libeffects/lvm/lib/Eq/lib/LVEQNB.h
new file mode 100755
index 0000000..7ba583f
--- /dev/null
+++ b/media/libeffects/lvm/lib/Eq/lib/LVEQNB.h
@@ -0,0 +1,484 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/**********************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1005 $
+ $Date: 2010-06-28 13:58:28 +0200 (Mon, 28 Jun 2010) $
+
+***********************************************************************************/
+
+/****************************************************************************************/
+/* */
+/* Header file for the application layer interface of the N-Band equaliser. */
+/* */
+/* This files includes all definitions, types, structures and function */
+/* prototypes required by the calling layer. All other types, structures and */
+/* functions are private. */
+/* */
+/****************************************************************************************/
+/* */
+/* Note: 1 */
+/* ======= */
+/* The algorithm can execute either with separate input and output buffers or with */
+/* a common buffer, i.e. the data is processed in-place. */
+/* */
+/****************************************************************************************/
+/* */
+/* Note: 2 */
+/* ======= */
+/* Two data formats are support Stereo and Mono-In-Stereo. The data is interleaved as */
+/* follows: */
+/* Byte Offset Stereo Input Mono-In-Stereo Input */
+/* =========== ============ ==================== */
+/* 0 Left Sample #1 Mono Sample #1 */
+/* 2 Right Sample #1 Mono Sample #1 */
+/* 4 Left Sample #2 Mono Sample #2 */
+/* 6 Right Sample #2 Mono Sample #2 */
+/* . . . */
+/* . . . */
+/* */
+/* Mono format data is not supported, the calling routine must convert a Mono stream */
+/* in to Mono-In-Stereo format. */
+/* */
+/****************************************************************************************/
+/* */
+/* Note: 3 */
+/* ======= */
+/* The format of the data in the filter band definition structure is as follows: */
+/* */
+/* Gain is in integer dB, range -15dB to +15dB inclusive */
+/* Frequency is the centre frequency in Hz, range DC to Nyquist */
+/* QFactor is the Q multiplied by 100, range 0.25 (25) to 12 (1200) */
+/* */
+/* Example: */
+/* Gain = 7 7dB gain */
+/* Frequency = 2467 Centre frequency = 2.467kHz */
+/* QFactor = 1089 Q = 10.89 */
+/* */
+/* The equaliser filters are passed as a pointer to and array of filter band */
+/* definitions structures. There must be one filter definition for each band. */
+/* */
+/****************************************************************************************/
+
+
+#ifndef __LVEQNB_H__
+#define __LVEQNB_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/****************************************************************************************/
+/* */
+/* Includes */
+/* */
+/****************************************************************************************/
+
+#include "LVM_Types.h"
+#include "LVM_Common.h"
+
+/****************************************************************************************/
+/* */
+/* Definitions */
+/* */
+/****************************************************************************************/
+
+/* Memory table */
+#define LVEQNB_MEMREGION_INSTANCE 0 /* Offset to the instance memory region */
+#define LVEQNB_MEMREGION_PERSISTENT_DATA 1 /* Offset to persistent data memory region */
+#define LVEQNB_MEMREGION_PERSISTENT_COEF 2 /* Offset to persistent coefficient region */
+#define LVEQNB_MEMREGION_SCRATCH 3 /* Offset to data scratch memory region */
+#define LVEQNB_NR_MEMORY_REGIONS 4 /* Number of memory regions */
+
+/* Callback events */
+#define LVEQNB_EVENT_NONE 0x0000 /* Not a valid event */
+#define LVEQNB_EVENT_ALGOFF 0x0001 /* EQNB has completed switch off */
+
+/****************************************************************************************/
+/* */
+/* Types */
+/* */
+/****************************************************************************************/
+
+/* Instance handle */
+typedef void *LVEQNB_Handle_t;
+
+
+/* Operating modes */
+typedef enum
+{
+ LVEQNB_BYPASS = 0,
+ LVEQNB_ON = 1,
+ LVEQNB_MODE_MAX = LVM_MAXINT_32
+} LVEQNB_Mode_en;
+
+
+/* Filter mode control */
+typedef enum
+{
+ LVEQNB_FILTER_OFF = 0,
+ LVEQNB_FILTER_ON = 1,
+ LVEQNB_FILTER_DUMMY = LVM_MAXINT_32
+} LVEQNB_FilterMode_en;
+
+
+/* Memory Types */
+typedef enum
+{
+ LVEQNB_PERSISTENT = 0,
+ LVEQNB_PERSISTENT_DATA = 1,
+ LVEQNB_PERSISTENT_COEF = 2,
+ LVEQNB_SCRATCH = 3,
+ LVEQNB_MEMORY_MAX = LVM_MAXINT_32
+} LVEQNB_MemoryTypes_en;
+
+
+/* Function return status */
+typedef enum
+{
+ LVEQNB_SUCCESS = 0, /* Successful return from a routine */
+ LVEQNB_ALIGNMENTERROR = 1, /* Memory alignment error */
+ LVEQNB_NULLADDRESS = 2, /* NULL allocation address */
+ LVEQNB_TOOMANYSAMPLES = 3, /* Maximum block size exceeded */
+ LVEQNB_STATUS_MAX = LVM_MAXINT_32
+} LVEQNB_ReturnStatus_en;
+
+
+/****************************************************************************************/
+/* */
+/* Linked enumerated type and capability definitions */
+/* */
+/* The capability definitions are used to define the required capabilities at */
+/* initialisation, these are added together to give the capability word. The */
+/* enumerated type is used to select the mode through a control function at run time. */
+/* */
+/* The capability definition is related to the enumerated type value by the equation: */
+/* */
+/* Capability_value = 2^Enumerated_value */
+/* */
+/* For example, a module could be configurd at initialisation to support two sample */
+/* rates only by calling the init function with the value: */
+/* Capabilities.SampleRate = LVEQNB_CAP_32000 + LVEQNB_CAP_44100; */
+/* */
+/* and at run time it would be passed the value LVEQNB_FS_32000 through the control */
+/* function to select operation at 32kHz */
+/* */
+/****************************************************************************************/
+
+/*
+ * Supported source data formats
+ */
+#define LVEQNB_CAP_STEREO 1
+#define LVEQNB_CAP_MONOINSTEREO 2
+
+typedef enum
+{
+ LVEQNB_STEREO = 0,
+ LVEQNB_MONOINSTEREO = 1,
+ LVEQNB_SOURCE_MAX = LVM_MAXINT_32
+} LVEQNB_SourceFormat_en;
+
+
+/*
+ * Supported sample rates in samples per second
+ */
+#define LVEQNB_CAP_FS_8000 1
+#define LVEQNB_CAP_FS_11025 2
+#define LVEQNB_CAP_FS_12000 4
+#define LVEQNB_CAP_FS_16000 8
+#define LVEQNB_CAP_FS_22050 16
+#define LVEQNB_CAP_FS_24000 32
+#define LVEQNB_CAP_FS_32000 64
+#define LVEQNB_CAP_FS_44100 128
+#define LVEQNB_CAP_FS_48000 256
+
+typedef enum
+{
+ LVEQNB_FS_8000 = 0,
+ LVEQNB_FS_11025 = 1,
+ LVEQNB_FS_12000 = 2,
+ LVEQNB_FS_16000 = 3,
+ LVEQNB_FS_22050 = 4,
+ LVEQNB_FS_24000 = 5,
+ LVEQNB_FS_32000 = 6,
+ LVEQNB_FS_44100 = 7,
+ LVEQNB_FS_48000 = 8,
+ LVEQNB_FS_MAX = LVM_MAXINT_32
+} LVEQNB_Fs_en;
+
+
+/****************************************************************************************/
+/* */
+/* Structures */
+/* */
+/****************************************************************************************/
+
+/* Memory region definition */
+typedef struct
+{
+ LVM_UINT32 Size; /* Region size in bytes */
+ LVM_UINT16 Alignment; /* Region alignment in bytes */
+ LVEQNB_MemoryTypes_en Type; /* Region type */
+ void *pBaseAddress; /* Pointer to the region base address */
+} LVEQNB_MemoryRegion_t;
+
+
+/* Memory table containing the region definitions */
+typedef struct
+{
+ LVEQNB_MemoryRegion_t Region[LVEQNB_NR_MEMORY_REGIONS]; /* One definition for each region */
+} LVEQNB_MemTab_t;
+
+
+/* Equaliser band definition */
+typedef struct
+{
+ LVM_INT16 Gain; /* Band gain in dB */
+ LVM_UINT16 Frequency; /* Band centre frequency in Hz */
+ LVM_UINT16 QFactor; /* Band quality factor */
+} LVEQNB_BandDef_t;
+
+
+/* Parameter structure */
+typedef struct
+{
+ /* General parameters */
+ LVEQNB_Mode_en OperatingMode;
+ LVEQNB_Fs_en SampleRate;
+ LVEQNB_SourceFormat_en SourceFormat;
+
+ /* Equaliser parameters */
+ LVM_UINT16 NBands; /* Number of bands */
+ LVEQNB_BandDef_t *pBandDefinition; /* Pointer to equaliser definitions */
+
+} LVEQNB_Params_t;
+
+
+/* Capability structure */
+typedef struct
+{
+ /* General parameters */
+ LVM_UINT16 SampleRate;
+ LVM_UINT16 SourceFormat;
+ LVM_UINT16 MaxBlockSize;
+ LVM_UINT16 MaxBands;
+
+ /* Callback parameters */
+ LVM_Callback CallBack; /* Bundle callback */
+ void *pBundleInstance; /* Bundle instance handle */
+
+} LVEQNB_Capabilities_t;
+
+
+/****************************************************************************************/
+/* */
+/* Function Prototypes */
+/* */
+/****************************************************************************************/
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVEQNB_Memory */
+/* */
+/* DESCRIPTION: */
+/* This function is used for memory allocation and free. It can be called in */
+/* two ways: */
+/* */
+/* hInstance = NULL Returns the memory requirements */
+/* hInstance = Instance handle Returns the memory requirements and */
+/* allocated base addresses for the instance */
+/* */
+/* When this function is called for memory allocation (hInstance=NULL) the memory */
+/* base address pointers are NULL on return. */
+/* */
+/* When the function is called for free (hInstance = Instance Handle) the memory */
+/* table returns the allocated memory and base addresses used during initialisation. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance Handle */
+/* pMemoryTable Pointer to an empty memory definition table */
+/* pCapabilities Pointer to the default capabilities */
+/* */
+/* RETURNS: */
+/* LVEQNB_SUCCESS Succeeded */
+/* LVEQNB_NULLADDRESS When any of pMemoryTable and pCapabilities is NULL address */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVEQNB_Process function */
+/* */
+/****************************************************************************************/
+
+LVEQNB_ReturnStatus_en LVEQNB_Memory(LVEQNB_Handle_t hInstance,
+ LVEQNB_MemTab_t *pMemoryTable,
+ LVEQNB_Capabilities_t *pCapabilities);
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVEQNB_Init */
+/* */
+/* DESCRIPTION: */
+/* Create and initialisation function for the N-Band equalliser module */
+/* */
+/* This function can be used to create an algorithm instance by calling with */
+/* hInstance set to NULL. In this case the algorithm returns the new instance */
+/* handle. */
+/* */
+/* This function can be used to force a full re-initialisation of the algorithm */
+/* by calling with hInstance = Instance Handle. In this case the memory table */
+/* should be correct for the instance, this can be ensured by calling the function */
+/* LVEQNB_Memory before calling this function. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* pMemoryTable Pointer to the memory definition table */
+/* pCapabilities Pointer to the initialisation capabilities */
+/* */
+/* RETURNS: */
+/* LVEQNB_SUCCESS Initialisation succeeded */
+/* LVEQNB_NULLADDRESS When pCapabilities or pMemoryTableis or phInstance are NULL */
+/* LVEQNB_NULLADDRESS One or more of the memory regions has a NULL base address */
+/* pointer for a memory region with a non-zero size. */
+/* */
+/* */
+/* NOTES: */
+/* 1. The instance handle is the pointer to the base address of the first memory */
+/* region. */
+/* 2. This function must not be interrupted by the LVEQNB_Process function */
+/* */
+/****************************************************************************************/
+
+LVEQNB_ReturnStatus_en LVEQNB_Init(LVEQNB_Handle_t *phInstance,
+ LVEQNB_MemTab_t *pMemoryTable,
+ LVEQNB_Capabilities_t *pCapabilities);
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVEQNB_GetParameters */
+/* */
+/* DESCRIPTION: */
+/* Request the equaliser module parameters. The current parameter set is returned */
+/* via the parameter pointer. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* pParams Pointer to an empty parameter structure */
+/* */
+/* RETURNS: */
+/* LVEQNB_SUCCESS Succeeds */
+/* LVEQNB_NULLADDRESS Instance or pParams is NULL pointer */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVEQNB_Process function */
+/* */
+/****************************************************************************************/
+
+LVEQNB_ReturnStatus_en LVEQNB_GetParameters(LVEQNB_Handle_t hInstance,
+ LVEQNB_Params_t *pParams);
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVEQNB_GetCapabilities */
+/* */
+/* DESCRIPTION: */
+/* Request the equaliser module capabilities. The capabilities set is returned */
+/* via the pointer. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* pCapabilities Pointer to an empty capability structure */
+/* */
+/* RETURNS: */
+/* LVEQNB_SUCCESS Succeeds */
+/* LVEQNB_NULLADDRESS hInstance or pCapabilities is NULL */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVEQNB_Process function */
+/* */
+/****************************************************************************************/
+
+LVEQNB_ReturnStatus_en LVEQNB_GetCapabilities(LVEQNB_Handle_t hInstance,
+ LVEQNB_Capabilities_t *pCapabilities);
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVEQNB_Control */
+/* */
+/* DESCRIPTION: */
+/* Sets or changes the equaliser module parameters. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* pParams Pointer to a parameter structure */
+/* */
+/* RETURNS: */
+/* LVEQNB_SUCCESS Succeeded */
+/* LVEQNB_NULLADDRESS Instance or pParams is NULL pointer */
+/* LVEQNB_NULLADDRESS NULL address for the equaliser filter definitions and the */
+/* number of bands is non-zero */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVEQNB_Process function */
+/* */
+/****************************************************************************************/
+
+LVEQNB_ReturnStatus_en LVEQNB_Control(LVEQNB_Handle_t hInstance,
+ LVEQNB_Params_t *pParams);
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVEQNB_Process */
+/* */
+/* DESCRIPTION: */
+/* Process function for the LifeVibes module. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* pInData Pointer to the input data */
+/* pOutData Pointer to the output data */
+/* NumSamples Number of samples in the input buffer */
+/* */
+/* RETURNS: */
+/* LVEQNB_SUCCESS Succeeded */
+/* LVEQNB_NULLADDRESS When hInstance, pInData or pOutData are NULL */
+/* LVEQNB_ALIGNMENTERROR When pInData or pOutData are not 32-bit aligned */
+/* LVEQNB_TOOMANYSAMPLES NumSamples was larger than the maximum block size */
+/* */
+/* NOTES: */
+/* */
+/****************************************************************************************/
+
+LVEQNB_ReturnStatus_en LVEQNB_Process(LVEQNB_Handle_t hInstance,
+ const LVM_INT16 *pInData,
+ LVM_INT16 *pOutData,
+ LVM_UINT16 NumSamples);
+
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __LVEQNB__ */
+
diff --git a/media/libeffects/lvm/lib/Eq/src/LVEQNB_CalcCoef.c b/media/libeffects/lvm/lib/Eq/src/LVEQNB_CalcCoef.c
new file mode 100755
index 0000000..4881049
--- /dev/null
+++ b/media/libeffects/lvm/lib/Eq/src/LVEQNB_CalcCoef.c
@@ -0,0 +1,306 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/**********************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1005 $
+ $Date: 2010-06-28 13:58:28 +0200 (Mon, 28 Jun 2010) $
+
+***********************************************************************************/
+
+/****************************************************************************************/
+/* */
+/* Includes */
+/* */
+/****************************************************************************************/
+
+#include "LVEQNB_Private.h"
+
+
+/****************************************************************************************/
+/* */
+/* Defines */
+/* */
+/****************************************************************************************/
+
+#define PI 3.14159265358979
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVEQNB_DoublePrecCoefs */
+/* */
+/* DESCRIPTION: */
+/* Calculate double precision coefficients for a peaking filter */
+/* */
+/* PARAMETERS: */
+/* Fs Sampling frequency index */
+/* pFilterDefinition Pointer to the filter definition */
+/* pCoefficients Pointer to the coefficients */
+/* */
+/* RETURNS: */
+/* LVEQNB_SUCCESS Always succeeds */
+/* */
+/* NOTES: */
+/* 1. The equations used are as follows: */
+/* */
+/* G = 10^(GaindB/20) - 1 */
+/* t0 = 2 * Pi * Fc / Fs */
+/* D = 1 if GaindB >= 0 */
+/* D = 1 / (1 + G) if GaindB < 0 */
+/* */
+/* b2 = -0.5 * (2Q - D * t0) / (2Q + D * t0) */
+/* b1 = (0.5 - b2) * (1 - coserr(t0)) */
+/* a0 = (0.5 + b2) / 2 */
+/* */
+/* Where: */
+/* GaindB is the gain in dBs, range -15dB to +15dB */
+/* Fc is the centre frequency, DC to Fs/50 */
+/* Fs is the sample frequency, 8000 to 48000 in descrete steps */
+/* Q is the Q factor, 0.25 to 12 (represented by 25 to 1200) */
+/* */
+/* 2. The double precision coefficients are only used when fc is less than fs/85, so */
+/* the cosine of t0 is always close to 1.0. Instead of calculating the cosine */
+/* itself the difference from the value 1.0 is calculated, this can be done with */
+/* lower precision maths. */
+/* */
+/* 3. The value of the B2 coefficient is only calculated as a single precision value, */
+/* small errors in this value have a combined effect on the Q and Gain but not the */
+/* the frequency of the filter. */
+/* */
+/****************************************************************************************/
+
+
+LVEQNB_ReturnStatus_en LVEQNB_DoublePrecCoefs(LVM_UINT16 Fs,
+ LVEQNB_BandDef_t *pFilterDefinition,
+ PK_C32_Coefs_t *pCoefficients)
+{
+
+ extern LVM_INT16 LVEQNB_GainTable[];
+ extern LVM_INT16 LVEQNB_TwoPiOnFsTable[];
+ extern LVM_INT16 LVEQNB_DTable[];
+ extern LVM_INT16 LVEQNB_DPCosCoef[];
+
+ /*
+ * Get the filter definition
+ */
+ LVM_INT16 Gain = pFilterDefinition->Gain;
+ LVM_UINT16 Frequency = pFilterDefinition->Frequency;
+ LVM_UINT16 QFactor = pFilterDefinition->QFactor;
+
+ /*
+ * Intermediate variables and temporary values
+ */
+ LVM_INT32 T0;
+ LVM_INT16 D;
+ LVM_INT32 A0;
+ LVM_INT32 B1;
+ LVM_INT32 B2;
+ LVM_INT32 Dt0;
+ LVM_INT32 B2_Den;
+ LVM_INT32 B2_Num;
+ LVM_INT32 CosErr;
+ LVM_INT16 coef;
+ LVM_INT32 factor;
+ LVM_INT16 t0;
+ LVM_INT16 i;
+
+ /*
+ * Calculating the intermediate values
+ */
+ T0 = (LVM_INT32)Frequency * LVEQNB_TwoPiOnFsTable[Fs]; /* T0 = 2 * Pi * Fc / Fs */
+ if (Gain >= 0)
+ {
+ D = LVEQNB_DTable[15]; /* D = 1 if GaindB >= 0 */
+ }
+ else
+ {
+ D = LVEQNB_DTable[Gain+15]; /* D = 1 / (1 + G) if GaindB < 0 */
+ }
+
+ /*
+ * Calculate the B2 coefficient
+ */
+ Dt0 = D * (T0 >> 10);
+ B2_Den = ((LVM_INT32)QFactor << 19) + (Dt0 >> 2);
+ B2_Num = (Dt0 >> 3) - ((LVM_INT32)QFactor << 18);
+ B2 = (B2_Num / (B2_Den >> 16)) << 15;
+
+ /*
+ * Calculate the cosine error by a polynomial expansion using the equation:
+ *
+ * CosErr += coef(n) * t0^n For n = 0 to 4
+ */
+ T0 = (T0 >> 6) * 0x7f53; /* Scale to 1.0 in 16-bit for range 0 to fs/50 */
+ t0 = (LVM_INT16)(T0 >> 16);
+ factor = 0x7fff; /* Initialise to 1.0 for the a0 coefficient */
+ CosErr = 0; /* Initialise the error to zero */
+ for (i=1; i<5; i++)
+ {
+ coef = LVEQNB_DPCosCoef[i]; /* Get the nth coefficient */
+ CosErr += (factor * coef) >> 5; /* The nth partial sum */
+ factor = (factor * t0) >> 15; /* Calculate t0^n */
+ }
+ CosErr = CosErr << (LVEQNB_DPCosCoef[0]); /* Correct the scaling */
+
+ /*
+ * Calculate the B1 and A0 coefficients
+ */
+ B1 = (0x40000000 - B2); /* B1 = (0.5 - b2/2) */
+ A0 = ((B1 >> 16) * (CosErr >> 10)) >> 6; /* Temporary storage for (0.5 - b2/2) * coserr(t0) */
+ B1 -= A0; /* B1 = (0.5 - b2/2) * (1 - coserr(t0)) */
+ A0 = (0x40000000 + B2) >> 1; /* A0 = (0.5 + b2) */
+
+ /*
+ * Write coeff into the data structure
+ */
+ pCoefficients->A0 = A0;
+ pCoefficients->B1 = B1;
+ pCoefficients->B2 = B2;
+ pCoefficients->G = LVEQNB_GainTable[Gain+15];
+
+ return(LVEQNB_SUCCESS);
+
+}
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVEQNB_SinglePrecCoefs */
+/* */
+/* DESCRIPTION: */
+/* Calculate single precision coefficients for a peaking filter */
+/* */
+/* PARAMETERS: */
+/* Fs Sampling frequency index */
+/* pFilterDefinition Pointer to the filter definition */
+/* pCoefficients Pointer to the coefficients */
+/* */
+/* RETURNS: */
+/* LVEQNB_SUCCESS Always succeeds */
+/* */
+/* NOTES: */
+/* 1. The equations used are as follows: */
+/* */
+/* G = 10^(GaindB/20) - 1 */
+/* t0 = 2 * Pi * Fc / Fs */
+/* D = 1 if GaindB >= 0 */
+/* D = 1 / (1 + G) if GaindB < 0 */
+/* */
+/* b2 = -0.5 * (2Q - D * t0) / (2Q + D * t0) */
+/* b1 = (0.5 - b2) * cos(t0) */
+/* a0 = (0.5 + b2) / 2 */
+/* */
+/* Where: */
+/* GaindB is the gain in dBs, range -15dB to +15dB */
+/* Fc is the centre frequency, DC to Nyquist */
+/* Fs is the sample frequency, 8000 to 48000 in descrete steps */
+/* Q is the Q factor, 0.25 to 12 */
+/* */
+/****************************************************************************************/
+
+
+LVEQNB_ReturnStatus_en LVEQNB_SinglePrecCoefs(LVM_UINT16 Fs,
+ LVEQNB_BandDef_t *pFilterDefinition,
+ PK_C16_Coefs_t *pCoefficients)
+{
+
+ extern LVM_INT16 LVEQNB_GainTable[];
+ extern LVM_INT16 LVEQNB_TwoPiOnFsTable[];
+ extern LVM_INT16 LVEQNB_DTable[];
+ extern LVM_INT16 LVEQNB_CosCoef[];
+
+
+ /*
+ * Get the filter definition
+ */
+ LVM_INT16 Gain = pFilterDefinition->Gain;
+ LVM_UINT16 Frequency = pFilterDefinition->Frequency;
+ LVM_UINT16 QFactor = pFilterDefinition->QFactor;
+
+
+ /*
+ * Intermediate variables and temporary values
+ */
+ LVM_INT32 T0;
+ LVM_INT16 D;
+ LVM_INT32 A0;
+ LVM_INT32 B1;
+ LVM_INT32 B2;
+ LVM_INT32 Dt0;
+ LVM_INT32 B2_Den;
+ LVM_INT32 B2_Num;
+ LVM_INT32 COS_T0;
+ LVM_INT16 coef;
+ LVM_INT32 factor;
+ LVM_INT16 t0;
+ LVM_INT16 i;
+
+ /*
+ * Calculating the intermediate values
+ */
+ T0 = (LVM_INT32)Frequency * LVEQNB_TwoPiOnFsTable[Fs]; /* T0 = 2 * Pi * Fc / Fs */
+ if (Gain >= 0)
+ {
+ D = LVEQNB_DTable[15]; /* D = 1 if GaindB >= 0 */
+ }
+ else
+ {
+ D = LVEQNB_DTable[Gain+15]; /* D = 1 / (1 + G) if GaindB < 0 */
+ }
+
+ /*
+ * Calculate the B2 coefficient
+ */
+ Dt0 = D * (T0 >> 10);
+ B2_Den = ((LVM_INT32)QFactor << 19) + (Dt0 >> 2);
+ B2_Num = (Dt0 >> 3) - ((LVM_INT32)QFactor << 18);
+ B2 = (B2_Num / (B2_Den >> 16)) << 15;
+
+ /*
+ * Calculate the cosine by a polynomial expansion using the equation:
+ *
+ * Cos += coef(n) * t0^n For n = 0 to 6
+ */
+ T0 = (T0 >> 10) * 20859; /* Scale to 1.0 in 16-bit for range 0 to fs/2 */
+ t0 = (LVM_INT16)(T0 >> 16);
+ factor = 0x7fff; /* Initialise to 1.0 for the a0 coefficient */
+ COS_T0 = 0; /* Initialise the error to zero */
+ for (i=1; i<7; i++)
+ {
+ coef = LVEQNB_CosCoef[i]; /* Get the nth coefficient */
+ COS_T0 += (factor * coef) >> 5; /* The nth partial sum */
+ factor = (factor * t0) >> 15; /* Calculate t0^n */
+ }
+ COS_T0 = COS_T0 << (LVEQNB_CosCoef[0]+6); /* Correct the scaling */
+
+
+ B1 = ((0x40000000 - B2) >> 16) * (COS_T0 >> 16); /* B1 = (0.5 - b2/2) * cos(t0) */
+ A0 = (0x40000000 + B2) >> 1; /* A0 = (0.5 + b2/2) */
+
+ /*
+ * Write coeff into the data structure
+ */
+ pCoefficients->A0 = (LVM_INT16)(A0>>16);
+ pCoefficients->B1 = (LVM_INT16)(B1>>15);
+ pCoefficients->B2 = (LVM_INT16)(B2>>16);
+ pCoefficients->G = LVEQNB_GainTable[Gain+15];
+
+
+ return(LVEQNB_SUCCESS);
+
+}
diff --git a/media/libeffects/lvm/lib/Eq/src/LVEQNB_Coeffs.h b/media/libeffects/lvm/lib/Eq/src/LVEQNB_Coeffs.h
new file mode 100755
index 0000000..87d7145
--- /dev/null
+++ b/media/libeffects/lvm/lib/Eq/src/LVEQNB_Coeffs.h
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+
+#ifndef __LVEQNB_COEFFS_H__
+#define __LVEQNB_COEFFS_H__
+
+
+/************************************************************************************/
+/* */
+/* Gain table for (10^(Gain/20) - 1) */
+/* */
+/************************************************************************************/
+
+#define LVEQNB_GAINSHIFT 11 /* As a power of 2 */
+#define LVEQNB_Gain_Neg15_dB -1684 /* Floating point value -0.822172 */
+#define LVEQNB_Gain_Neg14_dB -1639 /* Floating point value -0.800474 */
+#define LVEQNB_Gain_Neg13_dB -1590 /* Floating point value -0.776128 */
+#define LVEQNB_Gain_Neg12_dB -1534 /* Floating point value -0.748811 */
+#define LVEQNB_Gain_Neg11_dB -1471 /* Floating point value -0.718162 */
+#define LVEQNB_Gain_Neg10_dB -1400 /* Floating point value -0.683772 */
+#define LVEQNB_Gain_Neg9_dB -1321 /* Floating point value -0.645187 */
+#define LVEQNB_Gain_Neg8_dB -1233 /* Floating point value -0.601893 */
+#define LVEQNB_Gain_Neg7_dB -1133 /* Floating point value -0.553316 */
+#define LVEQNB_Gain_Neg6_dB -1022 /* Floating point value -0.498813 */
+#define LVEQNB_Gain_Neg5_dB -896 /* Floating point value -0.437659 */
+#define LVEQNB_Gain_Neg4_dB -756 /* Floating point value -0.369043 */
+#define LVEQNB_Gain_Neg3_dB -598 /* Floating point value -0.292054 */
+#define LVEQNB_Gain_Neg2_dB -421 /* Floating point value -0.205672 */
+#define LVEQNB_Gain_Neg1_dB -223 /* Floating point value -0.108749 */
+#define LVEQNB_Gain_0_dB 0 /* Floating point value 0.000000 */
+#define LVEQNB_Gain_1_dB 250 /* Floating point value 0.122018 */
+#define LVEQNB_Gain_2_dB 530 /* Floating point value 0.258925 */
+#define LVEQNB_Gain_3_dB 845 /* Floating point value 0.412538 */
+#define LVEQNB_Gain_4_dB 1198 /* Floating point value 0.584893 */
+#define LVEQNB_Gain_5_dB 1594 /* Floating point value 0.778279 */
+#define LVEQNB_Gain_6_dB 2038 /* Floating point value 0.995262 */
+#define LVEQNB_Gain_7_dB 2537 /* Floating point value 1.238721 */
+#define LVEQNB_Gain_8_dB 3096 /* Floating point value 1.511886 */
+#define LVEQNB_Gain_9_dB 3724 /* Floating point value 1.818383 */
+#define LVEQNB_Gain_10_dB 4428 /* Floating point value 2.162278 */
+#define LVEQNB_Gain_11_dB 5219 /* Floating point value 2.548134 */
+#define LVEQNB_Gain_12_dB 6105 /* Floating point value 2.981072 */
+#define LVEQNB_Gain_13_dB 7100 /* Floating point value 3.466836 */
+#define LVEQNB_Gain_14_dB 8216 /* Floating point value 4.011872 */
+#define LVEQNB_Gain_15_dB 9469 /* Floating point value 4.623413 */
+
+
+/************************************************************************************/
+/* */
+/* Frequency table for 2*Pi/Fs */
+/* */
+/************************************************************************************/
+
+#define LVEQNB_FREQSHIFT 25 /* As a power of 2 */
+#define LVEQNB_2PiOn_8000 26354 /* Floating point value 0.000785 */
+#define LVEQNB_2PiOn_11025 19123 /* Floating point value 0.000570 */
+#define LVEQNB_2PiOn_12000 17569 /* Floating point value 0.000524 */
+#define LVEQNB_2PiOn_16000 13177 /* Floating point value 0.000393 */
+#define LVEQNB_2PiOn_22050 9561 /* Floating point value 0.000285 */
+#define LVEQNB_2PiOn_24000 8785 /* Floating point value 0.000262 */
+#define LVEQNB_2PiOn_32000 6588 /* Floating point value 0.000196 */
+#define LVEQNB_2PiOn_44100 4781 /* Floating point value 0.000142 */
+#define LVEQNB_2PiOn_48000 4392 /* Floating point value 0.000131 */
+
+
+/************************************************************************************/
+/* */
+/* 50D table for 50 / ( 1 + Gain ) */
+/* */
+/************************************************************************************/
+
+#define LVEQNB_100DSHIFT 5 /* As a power of 2 */
+#define LVEQNB_100D_Neg15_dB 17995 /* Floating point value 5.623413 */
+#define LVEQNB_100D_Neg14_dB 16038 /* Floating point value 5.011872 */
+#define LVEQNB_100D_Neg13_dB 14294 /* Floating point value 4.466836 */
+#define LVEQNB_100D_Neg12_dB 12739 /* Floating point value 3.981072 */
+#define LVEQNB_100D_Neg11_dB 11354 /* Floating point value 3.548134 */
+#define LVEQNB_100D_Neg10_dB 10119 /* Floating point value 3.162278 */
+#define LVEQNB_100D_Neg9_dB 9019 /* Floating point value 2.818383 */
+#define LVEQNB_100D_Neg8_dB 8038 /* Floating point value 2.511886 */
+#define LVEQNB_100D_Neg7_dB 7164 /* Floating point value 2.238721 */
+#define LVEQNB_100D_Neg6_dB 6385 /* Floating point value 1.995262 */
+#define LVEQNB_100D_Neg5_dB 5690 /* Floating point value 1.778279 */
+#define LVEQNB_100D_Neg4_dB 5072 /* Floating point value 1.584893 */
+#define LVEQNB_100D_Neg3_dB 4520 /* Floating point value 1.412538 */
+#define LVEQNB_100D_Neg2_dB 4029 /* Floating point value 1.258925 */
+#define LVEQNB_100D_Neg1_dB 3590 /* Floating point value 1.122018 */
+#define LVEQNB_100D_0_dB 3200 /* Floating point value 1.000000 */
+
+
+#endif
diff --git a/media/libeffects/lvm/lib/Eq/src/LVEQNB_Control.c b/media/libeffects/lvm/lib/Eq/src/LVEQNB_Control.c
new file mode 100755
index 0000000..88f6fb0
--- /dev/null
+++ b/media/libeffects/lvm/lib/Eq/src/LVEQNB_Control.c
@@ -0,0 +1,501 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/**********************************************************************************
+
+ $Author: nxp007753 $
+ $Revision: 1223 $
+ $Date: 2010-07-15 14:27:01 +0200 (Thu, 15 Jul 2010) $
+
+***********************************************************************************/
+
+/****************************************************************************************/
+/* */
+/* Includes */
+/* */
+/****************************************************************************************/
+
+#include "LVEQNB.h"
+#include "LVEQNB_Private.h"
+#include "VectorArithmetic.h"
+#include "BIQUAD.h"
+
+
+/****************************************************************************************/
+/* */
+/* Defines */
+/* */
+/****************************************************************************************/
+
+#define LOW_FREQ 298 /* 32768/110 for low test frequency */
+#define HIGH_FREQ 386 /* 32768/85 for high test frequency */
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVEQNB_GetParameters */
+/* */
+/* DESCRIPTION: */
+/* Request the N-Band equaliser parameters. The current parameter set is returned via */
+/* the parameter pointer. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* pParams Pointer to an empty parameter structure */
+/* */
+/* RETURNS: */
+/* LVEQNB_SUCCESS Succeeds */
+/* LVEQNB_NULLADDRESS Instance or pParams is NULL pointer */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVEQNB_Process function */
+/* */
+/****************************************************************************************/
+
+LVEQNB_ReturnStatus_en LVEQNB_GetParameters(LVEQNB_Handle_t hInstance,
+ LVEQNB_Params_t *pParams)
+{
+
+ LVEQNB_Instance_t *pInstance =(LVEQNB_Instance_t *)hInstance;
+
+ /*
+ * Check for error conditions
+ */
+ if((hInstance == LVM_NULL) || (pParams == LVM_NULL))
+ {
+ return LVEQNB_NULLADDRESS;
+ }
+
+ *pParams = pInstance->Params;
+
+ return(LVEQNB_SUCCESS);
+}
+
+
+/************************************************************************************/
+/* */
+/* FUNCTION: LVEQNB_GetCapabilities */
+/* */
+/* DESCRIPTION: */
+/* Get the N-Band equaliser capabilities. The current capabilities are returned */
+/* via the pointer. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* pCapabilities Pointer to an empty capability structure */
+/* */
+/* RETURNS: */
+/* LVEQNB_Success Succeeds */
+/* LVEQNB_NULLADDRESS hInstance or pCapabilities is NULL */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVEQNB_Process function */
+/* */
+/************************************************************************************/
+
+LVEQNB_ReturnStatus_en LVEQNB_GetCapabilities(LVEQNB_Handle_t hInstance,
+ LVEQNB_Capabilities_t *pCapabilities)
+{
+
+ LVEQNB_Instance_t *pInstance =(LVEQNB_Instance_t *)hInstance;
+
+ if((hInstance == LVM_NULL) || (pCapabilities == LVM_NULL))
+ {
+ return LVEQNB_NULLADDRESS;
+ }
+
+ *pCapabilities = pInstance->Capabilities;
+
+ return(LVEQNB_SUCCESS);
+}
+
+
+/************************************************************************************/
+/* */
+/* FUNCTION: LVEQNB_SetFilters */
+/* */
+/* DESCRIPTION: */
+/* Sets the filter type based on the definition. */
+/* */
+/* PARAMETERS: */
+/* pInstance Pointer to the instance */
+/* pParams Initialisation parameters */
+/* */
+/* RETURNS: */
+/* void Nothing */
+/* */
+/* NOTES: */
+/* 1. To select the biquad type the follow rules are applied: */
+/* Double precision if (fc <= fs/110) */
+/* Double precision if (fs/110 < fc < fs/85) & (Q>3) */
+/* Single precision otherwise */
+/* */
+/************************************************************************************/
+
+void LVEQNB_SetFilters(LVEQNB_Instance_t *pInstance,
+ LVEQNB_Params_t *pParams)
+{
+
+ extern const LVM_UINT16 LVEQNB_SampleRateTab[]; /* Sample rate table */
+ LVM_UINT16 i; /* Filter band index */
+ LVM_UINT32 fs = (LVM_UINT32)LVEQNB_SampleRateTab[(LVM_UINT16)pParams->SampleRate]; /* Sample rate */
+ LVM_UINT32 fc; /* Filter centre frequency */
+ LVM_INT16 QFactor; /* Filter Q factor */
+
+
+ pInstance->NBands = pParams->NBands;
+
+ for (i=0; i<pParams->NBands; i++)
+ {
+ /*
+ * Get the filter settings
+ */
+ fc = (LVM_UINT32)pParams->pBandDefinition[i].Frequency; /* Get the band centre frequency */
+ QFactor = (LVM_INT16)pParams->pBandDefinition[i].QFactor; /* Get the band Q factor */
+
+
+ /*
+ * For each filter set the type of biquad required
+ */
+ pInstance->pBiquadType[i] = LVEQNB_SinglePrecision; /* Default to single precision */
+ if ((fc << 15) <= (LOW_FREQ * fs))
+ {
+ /*
+ * fc <= fs/110
+ */
+ pInstance->pBiquadType[i] = LVEQNB_DoublePrecision;
+ }
+ else if (((fc << 15) <= (HIGH_FREQ * fs)) && (QFactor > 300))
+ {
+ /*
+ * (fs/110 < fc < fs/85) & (Q>3)
+ */
+ pInstance->pBiquadType[i] = LVEQNB_DoublePrecision;
+ }
+
+
+ /*
+ * Check for out of range frequencies
+ */
+ if (fc > (fs >> 1))
+ {
+ pInstance->pBiquadType[i] = LVEQNB_OutOfRange;
+ }
+
+
+ /*
+ * Copy the filter definition to persistant memory
+ */
+ pInstance->pBandDefinitions[i] = pParams->pBandDefinition[i];
+
+ }
+}
+
+
+/************************************************************************************/
+/* */
+/* FUNCTION: LVEQNB_SetCoefficients */
+/* */
+/* DESCRIPTION: */
+/* Sets the filter coefficients. This uses the type to select single or double */
+/* precision coefficients. */
+/* */
+/* PARAMETERS: */
+/* pInstance Pointer to the instance */
+/* pParams Initialisation parameters */
+/* */
+/************************************************************************************/
+
+void LVEQNB_SetCoefficients(LVEQNB_Instance_t *pInstance)
+{
+
+ LVM_UINT16 i; /* Filter band index */
+ LVEQNB_BiquadType_en BiquadType; /* Filter biquad type */
+
+
+ /*
+ * Set the coefficients for each band by the init function
+ */
+ for (i=0; i<pInstance->Params.NBands; i++)
+ {
+
+ /*
+ * Check band type for correct initialisation method and recalculate the coefficients
+ */
+ BiquadType = pInstance->pBiquadType[i];
+ switch (BiquadType)
+ {
+ case LVEQNB_DoublePrecision:
+ {
+ PK_C32_Coefs_t Coefficients;
+
+ /*
+ * Calculate the double precision coefficients
+ */
+ LVEQNB_DoublePrecCoefs((LVM_UINT16)pInstance->Params.SampleRate,
+ &pInstance->pBandDefinitions[i],
+ &Coefficients);
+
+ /*
+ * Set the coefficients
+ */
+ PK_2I_D32F32CllGss_TRC_WRA_01_Init(&pInstance->pEQNB_FilterState[i],
+ &pInstance->pEQNB_Taps[i],
+ &Coefficients);
+ break;
+ }
+
+ case LVEQNB_SinglePrecision:
+ {
+ PK_C16_Coefs_t Coefficients;
+
+ /*
+ * Calculate the single precision coefficients
+ */
+ LVEQNB_SinglePrecCoefs((LVM_UINT16)pInstance->Params.SampleRate,
+ &pInstance->pBandDefinitions[i],
+ &Coefficients);
+
+ /*
+ * Set the coefficients
+ */
+ PK_2I_D32F32CssGss_TRC_WRA_01_Init(&pInstance->pEQNB_FilterState[i],
+ &pInstance->pEQNB_Taps[i],
+ &Coefficients);
+ break;
+ }
+ default:
+ break;
+ }
+ }
+
+}
+
+
+/************************************************************************************/
+/* */
+/* FUNCTION: LVEQNB_ClearFilterHistory */
+/* */
+/* DESCRIPTION: */
+/* Clears the filter data history */
+/* */
+/* PARAMETERS: */
+/* pInstance Pointer to the instance */
+/* */
+/************************************************************************************/
+
+void LVEQNB_ClearFilterHistory(LVEQNB_Instance_t *pInstance)
+{
+ LVM_INT16 *pTapAddress;
+ LVM_INT16 NumTaps;
+
+
+ pTapAddress = (LVM_INT16 *)pInstance->pEQNB_Taps;
+ NumTaps = (LVM_INT16)((pInstance->Capabilities.MaxBands * sizeof(Biquad_2I_Order2_Taps_t))/sizeof(LVM_INT16));
+
+ if (NumTaps != 0)
+ {
+ LoadConst_16(0, /* Clear the history, value 0 */
+ pTapAddress, /* Destination */
+ NumTaps); /* Number of words */
+ }
+}
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVEQNB_Control */
+/* */
+/* DESCRIPTION: */
+/* Sets or changes the LifeVibes module parameters. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* pParams Pointer to a parameter structure */
+/* */
+/* RETURNS: */
+/* LVEQNB_Success Always succeeds */
+/* LVEQNB_NULLADDRESS Instance or pParams is NULL pointer */
+/* LVEQNB_NULLADDRESS NULL address for the equaliser filter definitions and the */
+/* number of bands is non-zero */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVEQNB_Process function */
+/* */
+/****************************************************************************************/
+
+LVEQNB_ReturnStatus_en LVEQNB_Control(LVEQNB_Handle_t hInstance,
+ LVEQNB_Params_t *pParams)
+{
+
+ LVEQNB_Instance_t *pInstance = (LVEQNB_Instance_t *)hInstance;
+ LVM_INT16 bChange = LVM_FALSE;
+ LVM_INT16 i = 0;
+ LVEQNB_Mode_en OperatingModeSave ;
+
+ /*
+ * Check for error conditions
+ */
+ if((hInstance == LVM_NULL) || (pParams == LVM_NULL))
+ {
+ return LVEQNB_NULLADDRESS;
+ }
+
+ if((pParams->NBands !=0) && (pParams->pBandDefinition==LVM_NULL))
+ {
+ return LVEQNB_NULLADDRESS;
+ }
+
+ OperatingModeSave = pInstance->Params.OperatingMode;
+
+ /* Set the alpha factor of the mixer */
+ if (pParams->SampleRate != pInstance->Params.SampleRate)
+ {
+ LVC_Mixer_VarSlope_SetTimeConstant(&pInstance->BypassMixer.MixerStream[0],LVEQNB_BYPASS_MIXER_TC,(LVM_Fs_en)pParams->SampleRate,2);
+ LVC_Mixer_VarSlope_SetTimeConstant(&pInstance->BypassMixer.MixerStream[1],LVEQNB_BYPASS_MIXER_TC,(LVM_Fs_en)pParams->SampleRate,2);
+ }
+
+
+ if( (pInstance->Params.NBands != pParams->NBands ) ||
+ (pInstance->Params.OperatingMode != pParams->OperatingMode ) ||
+ (pInstance->Params.pBandDefinition != pParams->pBandDefinition ) ||
+ (pInstance->Params.SampleRate != pParams->SampleRate ) ||
+ (pInstance->Params.SourceFormat != pParams->SourceFormat ))
+ {
+
+ bChange = LVM_TRUE;
+ }
+ else
+ {
+ for(i = 0; i < pParams->NBands; i++)
+ {
+
+ if((pInstance->pBandDefinitions[i].Frequency != pParams->pBandDefinition[i].Frequency )||
+ (pInstance->pBandDefinitions[i].Gain != pParams->pBandDefinition[i].Gain )||
+ (pInstance->pBandDefinitions[i].QFactor != pParams->pBandDefinition[i].QFactor ))
+ {
+
+ bChange = LVM_TRUE;
+ }
+ }
+ }
+
+
+ if(bChange){
+
+ /*
+ * If the sample rate has changed clear the history
+ */
+ if (pInstance->Params.SampleRate != pParams->SampleRate)
+ {
+ LVEQNB_ClearFilterHistory(pInstance); /* Clear the history */
+ }
+
+ /*
+ * Update the instance parameters
+ */
+ pInstance->Params = *pParams;
+
+
+ /*
+ * Reset the filters except if the algo is switched off
+ */
+ if(pParams->OperatingMode != LVEQNB_BYPASS){
+ /*
+ * Reset the filters as all parameters could have changed
+ */
+ LVEQNB_SetFilters(pInstance, /* Instance pointer */
+ pParams); /* New parameters */
+
+ /*
+ * Update the filters
+ */
+ LVEQNB_SetCoefficients(pInstance); /* Instance pointer */
+ }
+
+ if(pParams->OperatingMode != OperatingModeSave)
+ {
+ if(pParams->OperatingMode == LVEQNB_ON)
+ {
+ LVC_Mixer_SetTarget(&pInstance->BypassMixer.MixerStream[0],LVM_MAXINT_16);
+ LVC_Mixer_SetTarget(&pInstance->BypassMixer.MixerStream[1],0);
+
+ pInstance->BypassMixer.MixerStream[0].CallbackSet = 1;
+ pInstance->BypassMixer.MixerStream[1].CallbackSet = 1;
+ }
+ else
+ {
+ /* Stay on the ON operating mode until the transition is done */
+ pInstance->Params.OperatingMode = LVEQNB_ON;
+
+ LVC_Mixer_SetTarget(&pInstance->BypassMixer.MixerStream[0],0);
+ LVC_Mixer_SetTarget(&pInstance->BypassMixer.MixerStream[1],LVM_MAXINT_16);
+ pInstance->BypassMixer.MixerStream[0].CallbackSet = 1;
+ pInstance->BypassMixer.MixerStream[1].CallbackSet = 1;
+ }
+ LVC_Mixer_VarSlope_SetTimeConstant(&pInstance->BypassMixer.MixerStream[0],LVEQNB_BYPASS_MIXER_TC,(LVM_Fs_en)pParams->SampleRate,2);
+ LVC_Mixer_VarSlope_SetTimeConstant(&pInstance->BypassMixer.MixerStream[1],LVEQNB_BYPASS_MIXER_TC,(LVM_Fs_en)pParams->SampleRate,2);
+
+ pInstance->bInOperatingModeTransition = LVM_TRUE;
+ }
+
+ }
+ return(LVEQNB_SUCCESS);
+}
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVEQNB_BypassMixerCallBack */
+/* */
+/* DESCRIPTION: */
+/* CallBack function of the mixer */
+/* transition */
+/* */
+/****************************************************************************************/
+LVM_INT32 LVEQNB_BypassMixerCallBack (void* hInstance,
+ void *pGeneralPurpose,
+ LVM_INT16 CallbackParam)
+{
+ LVEQNB_Instance_t *pInstance =(LVEQNB_Instance_t *)hInstance;
+ LVM_Callback CallBack = pInstance->Capabilities.CallBack;
+
+ (void) pGeneralPurpose;
+
+ /*
+ * Send an ALGOFF event if the ON->OFF switch transition is finished
+ */
+ if((LVC_Mixer_GetTarget(&pInstance->BypassMixer.MixerStream[0]) == 0x00000000) &&
+ (CallbackParam == 0)){
+ pInstance->Params.OperatingMode = LVEQNB_BYPASS;
+ if (CallBack != LVM_NULL){
+ CallBack(pInstance->Capabilities.pBundleInstance, LVM_NULL, ALGORITHM_EQNB_ID|LVEQNB_EVENT_ALGOFF);
+ }
+ }
+
+ /*
+ * Exit transition state
+ */
+ pInstance->bInOperatingModeTransition = LVM_FALSE;
+
+ return 1;
+}
+
+
+
+
+
+
diff --git a/media/libeffects/lvm/lib/Eq/src/LVEQNB_Init.c b/media/libeffects/lvm/lib/Eq/src/LVEQNB_Init.c
new file mode 100755
index 0000000..a29fe05
--- /dev/null
+++ b/media/libeffects/lvm/lib/Eq/src/LVEQNB_Init.c
@@ -0,0 +1,329 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/**********************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1005 $
+ $Date: 2010-06-28 13:58:28 +0200 (Mon, 28 Jun 2010) $
+
+***********************************************************************************/
+
+
+/****************************************************************************************/
+/* */
+/* Includes */
+/* */
+/****************************************************************************************/
+
+#include "LVEQNB.h"
+#include "LVEQNB_Private.h"
+#include "InstAlloc.h"
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVEQNB_Memory */
+/* */
+/* DESCRIPTION: */
+/* This function is used for memory allocation and free. It can be called in */
+/* two ways: */
+/* */
+/* hInstance = NULL Returns the memory requirements */
+/* hInstance = Instance handle Returns the memory requirements and */
+/* allocated base addresses for the instance */
+/* */
+/* When this function is called for memory allocation (hInstance=NULL) the memory */
+/* base address pointers are NULL on return. */
+/* */
+/* When the function is called for free (hInstance = Instance Handle) the memory */
+/* table returns the allocated memory and base addresses used during initialisation. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance Handle */
+/* pMemoryTable Pointer to an empty memory definition table */
+/* pCapabilities Pointer to the instance capabilities */
+/* */
+/* RETURNS: */
+/* LVEQNB_SUCCESS Succeeded */
+/* LVEQNB_NULLADDRESS When any of pMemoryTable and pCapabilities is NULL address */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVEQNB_Process function */
+/* */
+/****************************************************************************************/
+
+LVEQNB_ReturnStatus_en LVEQNB_Memory(LVEQNB_Handle_t hInstance,
+ LVEQNB_MemTab_t *pMemoryTable,
+ LVEQNB_Capabilities_t *pCapabilities)
+{
+
+ INST_ALLOC AllocMem;
+ LVEQNB_Instance_t *pInstance = (LVEQNB_Instance_t *)hInstance;
+
+
+ if((pMemoryTable == LVM_NULL)|| (pCapabilities == LVM_NULL))
+ {
+ return LVEQNB_NULLADDRESS;
+ }
+
+
+ /*
+ * Fill in the memory table
+ */
+ if (hInstance == LVM_NULL)
+ {
+ /*
+ * Instance memory
+ */
+ InstAlloc_Init(&AllocMem,
+ LVM_NULL);
+ InstAlloc_AddMember(&AllocMem, /* Low pass filter */
+ sizeof(LVEQNB_Instance_t));
+ pMemoryTable->Region[LVEQNB_MEMREGION_INSTANCE].Size = InstAlloc_GetTotal(&AllocMem);
+ pMemoryTable->Region[LVEQNB_MEMREGION_INSTANCE].Alignment = LVEQNB_INSTANCE_ALIGN;
+ pMemoryTable->Region[LVEQNB_MEMREGION_INSTANCE].Type = LVEQNB_PERSISTENT;
+ pMemoryTable->Region[LVEQNB_MEMREGION_INSTANCE].pBaseAddress = LVM_NULL;
+
+
+ /*
+ * Persistant data memory
+ */
+ InstAlloc_Init(&AllocMem,
+ LVM_NULL);
+ InstAlloc_AddMember(&AllocMem, /* Low pass filter */
+ sizeof(Biquad_2I_Order2_Taps_t));
+ InstAlloc_AddMember(&AllocMem, /* High pass filter */
+ sizeof(Biquad_2I_Order2_Taps_t));
+ InstAlloc_AddMember(&AllocMem,
+ (pCapabilities->MaxBands * sizeof(Biquad_2I_Order2_Taps_t))); /* Equaliser Biquad Taps */
+ InstAlloc_AddMember(&AllocMem,
+ (pCapabilities->MaxBands * sizeof(LVEQNB_BandDef_t))); /* Filter definitions */
+ InstAlloc_AddMember(&AllocMem,
+ (pCapabilities->MaxBands * sizeof(LVEQNB_BiquadType_en))); /* Biquad types */
+ pMemoryTable->Region[LVEQNB_MEMREGION_PERSISTENT_DATA].Size = InstAlloc_GetTotal(&AllocMem);
+ pMemoryTable->Region[LVEQNB_MEMREGION_PERSISTENT_DATA].Alignment = LVEQNB_DATA_ALIGN;
+ pMemoryTable->Region[LVEQNB_MEMREGION_PERSISTENT_DATA].Type = LVEQNB_PERSISTENT_DATA;
+ pMemoryTable->Region[LVEQNB_MEMREGION_PERSISTENT_DATA].pBaseAddress = LVM_NULL;
+
+ /*
+ * Persistant coefficient memory
+ */
+ InstAlloc_Init(&AllocMem,
+ LVM_NULL);
+ InstAlloc_AddMember(&AllocMem, /* Low pass filter */
+ sizeof(Biquad_Instance_t));
+ InstAlloc_AddMember(&AllocMem, /* High pass filter */
+ sizeof(Biquad_Instance_t));
+ InstAlloc_AddMember(&AllocMem,
+ pCapabilities->MaxBands * sizeof(Biquad_Instance_t)); /* Equaliser Biquad Instance */
+ pMemoryTable->Region[LVEQNB_MEMREGION_PERSISTENT_COEF].Size = InstAlloc_GetTotal(&AllocMem);
+ pMemoryTable->Region[LVEQNB_MEMREGION_PERSISTENT_COEF].Alignment = LVEQNB_COEF_ALIGN;
+ pMemoryTable->Region[LVEQNB_MEMREGION_PERSISTENT_COEF].Type = LVEQNB_PERSISTENT_COEF;
+ pMemoryTable->Region[LVEQNB_MEMREGION_PERSISTENT_COEF].pBaseAddress = LVM_NULL;
+
+ /*
+ * Scratch memory
+ */
+ InstAlloc_Init(&AllocMem,
+ LVM_NULL);
+ InstAlloc_AddMember(&AllocMem, /* Low pass filter */
+ LVEQNB_SCRATCHBUFFERS*sizeof(LVM_INT16)*pCapabilities->MaxBlockSize);
+ pMemoryTable->Region[LVEQNB_MEMREGION_SCRATCH].Size = InstAlloc_GetTotal(&AllocMem);
+ pMemoryTable->Region[LVEQNB_MEMREGION_SCRATCH].Alignment = LVEQNB_SCRATCH_ALIGN;
+ pMemoryTable->Region[LVEQNB_MEMREGION_SCRATCH].Type = LVEQNB_SCRATCH;
+ pMemoryTable->Region[LVEQNB_MEMREGION_SCRATCH].pBaseAddress = LVM_NULL;
+ }
+ else
+ {
+ /* Read back memory allocation table */
+ *pMemoryTable = pInstance->MemoryTable;
+ }
+
+ return(LVEQNB_SUCCESS);
+}
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVEQNB_Init */
+/* */
+/* DESCRIPTION: */
+/* Create and initialisation function for the N-Band equaliser module */
+/* */
+/* This function can be used to create an algorithm instance by calling with */
+/* hInstance set to NULL. In this case the algorithm returns the new instance */
+/* handle. */
+/* */
+/* This function can be used to force a full re-initialisation of the algorithm */
+/* by calling with hInstance = Instance Handle. In this case the memory table */
+/* should be correct for the instance, this can be ensured by calling the function */
+/* DBE_Memory before calling this function. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* pMemoryTable Pointer to the memory definition table */
+/* pCapabilities Pointer to the instance capabilities */
+/* */
+/* RETURNS: */
+/* LVEQNB_SUCCESS Initialisation succeeded */
+/* LVEQNB_NULLADDRESS When pCapabilities or pMemoryTableis or phInstance are NULL */
+/* LVEQNB_NULLADDRESS One or more of the memory regions has a NULL base address */
+/* pointer for a memory region with a non-zero size. */
+/* */
+/* NOTES: */
+/* 1. The instance handle is the pointer to the base address of the first memory */
+/* region. */
+/* 2. This function must not be interrupted by the LVEQNB_Process function */
+/* */
+/****************************************************************************************/
+
+LVEQNB_ReturnStatus_en LVEQNB_Init(LVEQNB_Handle_t *phInstance,
+ LVEQNB_MemTab_t *pMemoryTable,
+ LVEQNB_Capabilities_t *pCapabilities)
+{
+
+ LVEQNB_Instance_t *pInstance;
+ LVM_UINT32 MemSize;
+ INST_ALLOC AllocMem;
+ LVM_INT32 i;
+
+ /*
+ * Check for NULL pointers
+ */
+ if((phInstance == LVM_NULL) || (pMemoryTable == LVM_NULL) || (pCapabilities == LVM_NULL))
+ {
+ return LVEQNB_NULLADDRESS;
+ }
+
+ /*
+ * Check the memory table for NULL pointers
+ */
+ for (i = 0; i < LVEQNB_NR_MEMORY_REGIONS; i++)
+ {
+ if (pMemoryTable->Region[i].Size!=0)
+ {
+ if (pMemoryTable->Region[i].pBaseAddress==LVM_NULL)
+ {
+ return(LVEQNB_NULLADDRESS);
+ }
+ }
+ }
+
+ /*
+ * Set the instance handle if not already initialised
+ */
+
+ InstAlloc_Init(&AllocMem, pMemoryTable->Region[LVEQNB_MEMREGION_INSTANCE].pBaseAddress);
+
+ if (*phInstance == LVM_NULL)
+ {
+ *phInstance = InstAlloc_AddMember(&AllocMem, sizeof(LVEQNB_Instance_t));
+ }
+ pInstance =(LVEQNB_Instance_t *)*phInstance;
+
+
+
+ /*
+ * Save the memory table in the instance structure
+ */
+ pInstance->Capabilities = *pCapabilities;
+
+
+ /*
+ * Save the memory table in the instance structure and
+ * set the structure pointers
+ */
+ pInstance->MemoryTable = *pMemoryTable;
+
+ /*
+ * Allocate coefficient memory
+ */
+ InstAlloc_Init(&AllocMem,
+ pMemoryTable->Region[LVEQNB_MEMREGION_PERSISTENT_COEF].pBaseAddress);
+
+ pInstance->pEQNB_FilterState = InstAlloc_AddMember(&AllocMem,
+ pCapabilities->MaxBands * sizeof(Biquad_Instance_t)); /* Equaliser Biquad Instance */
+
+
+
+ /*
+ * Allocate data memory
+ */
+ InstAlloc_Init(&AllocMem,
+ pMemoryTable->Region[LVEQNB_MEMREGION_PERSISTENT_DATA].pBaseAddress);
+
+ MemSize = (pCapabilities->MaxBands * sizeof(Biquad_2I_Order2_Taps_t));
+ pInstance->pEQNB_Taps = (Biquad_2I_Order2_Taps_t *)InstAlloc_AddMember(&AllocMem,
+ MemSize);
+ MemSize = (pCapabilities->MaxBands * sizeof(LVEQNB_BandDef_t));
+ pInstance->pBandDefinitions = (LVEQNB_BandDef_t *)InstAlloc_AddMember(&AllocMem,
+ MemSize);
+ MemSize = (pCapabilities->MaxBands * sizeof(LVEQNB_BiquadType_en));
+ pInstance->pBiquadType = (LVEQNB_BiquadType_en *)InstAlloc_AddMember(&AllocMem,
+ MemSize);
+
+
+ /*
+ * Internally map, structure and allign scratch memory
+ */
+ InstAlloc_Init(&AllocMem,
+ pMemoryTable->Region[LVEQNB_MEMREGION_SCRATCH].pBaseAddress);
+
+ pInstance->pFastTemporary = (LVM_INT16 *)InstAlloc_AddMember(&AllocMem,
+ sizeof(LVM_INT16));
+
+ /*
+ * Update the instance parameters
+ */
+ pInstance->Params.NBands = 0;
+ pInstance->Params.OperatingMode = LVEQNB_BYPASS;
+ pInstance->Params.pBandDefinition = LVM_NULL;
+ pInstance->Params.SampleRate = LVEQNB_FS_8000;
+ pInstance->Params.SourceFormat = LVEQNB_STEREO;
+
+ /*
+ * Initialise the filters
+ */
+ LVEQNB_SetFilters(pInstance, /* Set the filter types */
+ &pInstance->Params);
+
+ LVEQNB_SetCoefficients(pInstance); /* Set the filter coefficients */
+
+ LVEQNB_ClearFilterHistory(pInstance); /* Clear the filter history */
+
+ /*
+ * Initialise the bypass variables
+ */
+ pInstance->BypassMixer.MixerStream[0].CallbackSet = 0;
+ pInstance->BypassMixer.MixerStream[0].CallbackParam = 0;
+ pInstance->BypassMixer.MixerStream[0].pCallbackHandle = (void*)pInstance;
+ pInstance->BypassMixer.MixerStream[0].pCallBack = LVEQNB_BypassMixerCallBack;
+ LVC_Mixer_Init(&pInstance->BypassMixer.MixerStream[0],0,0);
+ LVC_Mixer_SetTimeConstant(&pInstance->BypassMixer.MixerStream[0],0,LVM_FS_8000,2);
+
+ pInstance->BypassMixer.MixerStream[1].CallbackSet = 1;
+ pInstance->BypassMixer.MixerStream[1].CallbackParam = 0;
+ pInstance->BypassMixer.MixerStream[1].pCallbackHandle = LVM_NULL;
+ pInstance->BypassMixer.MixerStream[1].pCallBack = LVM_NULL;
+ LVC_Mixer_Init(&pInstance->BypassMixer.MixerStream[1],0,LVM_MAXINT_16);
+ LVC_Mixer_SetTimeConstant(&pInstance->BypassMixer.MixerStream[1],0,LVM_FS_8000,2);
+
+ pInstance->bInOperatingModeTransition = LVM_FALSE;
+
+ return(LVEQNB_SUCCESS);
+}
+
diff --git a/media/libeffects/lvm/lib/Eq/src/LVEQNB_Private.h b/media/libeffects/lvm/lib/Eq/src/LVEQNB_Private.h
new file mode 100755
index 0000000..0ae84af
--- /dev/null
+++ b/media/libeffects/lvm/lib/Eq/src/LVEQNB_Private.h
@@ -0,0 +1,141 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/**********************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1005 $
+ $Date: 2010-06-28 13:58:28 +0200 (Mon, 28 Jun 2010) $
+
+***********************************************************************************/
+
+#ifndef __LVEQNB_PRIVATE_H__
+#define __LVEQNB_PRIVATE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/****************************************************************************************/
+/* */
+/* Includes */
+/* */
+/****************************************************************************************/
+
+#include "LVEQNB.h" /* Calling or Application layer definitions */
+#include "BIQUAD.h"
+#include "LVC_Mixer.h"
+
+/****************************************************************************************/
+/* */
+/* Defines */
+/* */
+/****************************************************************************************/
+
+/* General */
+#define LVEQNB_INVALID 0xFFFF /* Invalid init parameter */
+
+/* Memory */
+#define LVEQNB_INSTANCE_ALIGN 4 /* 32-bit alignment for instance structures */
+#define LVEQNB_DATA_ALIGN 4 /* 32-bit alignment for structures */
+#define LVEQNB_COEF_ALIGN 4 /* 32-bit alignment for long words */
+#define LVEQNB_SCRATCHBUFFERS 4 /* Number of buffers required for inplace processing */
+#define LVEQNB_SCRATCH_ALIGN 4 /* 32-bit alignment for long data */
+
+#define LVEQNB_BYPASS_MIXER_TC 100 /* Bypass Mixer TC */
+
+/****************************************************************************************/
+/* */
+/* Types */
+/* */
+/****************************************************************************************/
+
+/* Filter biquad types */
+typedef enum
+{
+ LVEQNB_SinglePrecision = 0,
+ LVEQNB_DoublePrecision = 1,
+ LVEQNB_OutOfRange = 2,
+ LVEQNB_BIQUADTYPE_MAX = LVM_MAXINT_32
+} LVEQNB_BiquadType_en;
+
+
+/****************************************************************************************/
+/* */
+/* Structures */
+/* */
+/****************************************************************************************/
+
+
+
+/* Instance structure */
+typedef struct
+{
+ /* Public parameters */
+ LVEQNB_MemTab_t MemoryTable; /* Instance memory allocation table */
+ LVEQNB_Params_t Params; /* Instance parameters */
+ LVEQNB_Capabilities_t Capabilities; /* Instance capabilities */
+
+ /* Aligned memory pointers */
+ LVM_INT16 *pFastTemporary; /* Fast temporary data base address */
+
+ /* Process variables */
+ Biquad_2I_Order2_Taps_t *pEQNB_Taps; /* Equaliser Taps */
+ Biquad_Instance_t *pEQNB_FilterState; /* State for each filter band */
+
+ /* Filter definitions and call back */
+ LVM_UINT16 NBands; /* Number of bands */
+ LVEQNB_BandDef_t *pBandDefinitions; /* Filter band definitions */
+ LVEQNB_BiquadType_en *pBiquadType; /* Filter biquad types */
+
+ /* Bypass variable */
+ LVMixer3_2St_st BypassMixer; /* Bypass mixer used in transitions */
+ LVM_INT16 bInOperatingModeTransition; /* Operating mode transition flag */
+
+} LVEQNB_Instance_t;
+
+
+/****************************************************************************************/
+/* */
+/* Function prototypes */
+/* */
+/****************************************************************************************/
+
+void LVEQNB_SetFilters(LVEQNB_Instance_t *pInstance,
+ LVEQNB_Params_t *pParams);
+
+void LVEQNB_SetCoefficients(LVEQNB_Instance_t *pInstance);
+
+void LVEQNB_ClearFilterHistory(LVEQNB_Instance_t *pInstance);
+
+LVEQNB_ReturnStatus_en LVEQNB_SinglePrecCoefs(LVM_UINT16 Fs,
+ LVEQNB_BandDef_t *pFilterDefinition,
+ PK_C16_Coefs_t *pCoefficients);
+
+LVEQNB_ReturnStatus_en LVEQNB_DoublePrecCoefs(LVM_UINT16 Fs,
+ LVEQNB_BandDef_t *pFilterDefinition,
+ PK_C32_Coefs_t *pCoefficients);
+
+LVM_INT32 LVEQNB_BypassMixerCallBack (void* hInstance, void *pGeneralPurpose, LVM_INT16 CallbackParam);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __LVEQNB_PRIVATE_H__ */
+
diff --git a/media/libeffects/lvm/lib/Eq/src/LVEQNB_Process.c b/media/libeffects/lvm/lib/Eq/src/LVEQNB_Process.c
new file mode 100755
index 0000000..e29e881
--- /dev/null
+++ b/media/libeffects/lvm/lib/Eq/src/LVEQNB_Process.c
@@ -0,0 +1,208 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/**********************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1005 $
+ $Date: 2010-06-28 13:58:28 +0200 (Mon, 28 Jun 2010) $
+
+***********************************************************************************/
+
+/****************************************************************************************/
+/* */
+/* Includes */
+/* */
+/****************************************************************************************/
+
+#include "LVEQNB.h"
+#include "LVEQNB_Private.h"
+#include "VectorArithmetic.h"
+#include "BIQUAD.h"
+
+
+/****************************************************************************************/
+/* */
+/* Defines */
+/* */
+/****************************************************************************************/
+
+#define SHIFT 13
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVEQNB_Process */
+/* */
+/* DESCRIPTION: */
+/* Process function for the N-Band Equaliser module. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* pInData Pointer to the input data */
+/* pOutData Pointer to the output data */
+/* NumSamples Number of samples in the input buffer */
+/* */
+/* RETURNS: */
+/* LVEQNB_SUCCESS Succeeded */
+/* LVEQNB_NULLADDRESS When hInstance, pInData or pOutData are NULL */
+/* LVEQNB_ALIGNMENTERROR When pInData or pOutData are not 32-bit aligned */
+/* LVEQNB_TOOMANYSAMPLES NumSamples was larger than the maximum block size */
+/* */
+/* NOTES: */
+/* */
+/****************************************************************************************/
+
+LVEQNB_ReturnStatus_en LVEQNB_Process(LVEQNB_Handle_t hInstance,
+ const LVM_INT16 *pInData,
+ LVM_INT16 *pOutData,
+ LVM_UINT16 NumSamples)
+{
+
+ LVM_UINT16 i;
+ Biquad_Instance_t *pBiquad;
+ LVEQNB_Instance_t *pInstance = (LVEQNB_Instance_t *)hInstance;
+ LVM_INT32 *pScratch;
+
+
+ /* Check for NULL pointers */
+ if((hInstance == LVM_NULL) || (pInData == LVM_NULL) || (pOutData == LVM_NULL))
+ {
+ return LVEQNB_NULLADDRESS;
+ }
+
+ /* Check if the input and output data buffers are 32-bit aligned */
+ if ((((LVM_INT32)pInData % 4) != 0) || (((LVM_INT32)pOutData % 4) != 0))
+ {
+ return LVEQNB_ALIGNMENTERROR;
+ }
+
+ pScratch = (LVM_INT32 *)pInstance->pFastTemporary;
+
+ /*
+ * Check the number of samples is not too large
+ */
+ if (NumSamples > pInstance->Capabilities.MaxBlockSize)
+ {
+ return(LVEQNB_TOOMANYSAMPLES);
+ }
+
+ if (pInstance->Params.OperatingMode == LVEQNB_ON)
+ {
+ /*
+ * Convert from 16-bit to 32-bit
+ */
+ Int16LShiftToInt32_16x32((LVM_INT16 *)pInData, /* Source */
+ pScratch, /* Destination */
+ (LVM_INT16)(2*NumSamples), /* Left and Right */
+ SHIFT); /* Scaling shift */
+
+ /*
+ * For each section execte the filter unless the gain is 0dB
+ */
+ if (pInstance->NBands != 0)
+ {
+ for (i=0; i<pInstance->NBands; i++)
+ {
+ /*
+ * Check if band is non-zero dB gain
+ */
+ if (pInstance->pBandDefinitions[i].Gain != 0)
+ {
+ /*
+ * Get the address of the biquad instance
+ */
+ pBiquad = &pInstance->pEQNB_FilterState[i];
+
+
+ /*
+ * Select single or double precision as required
+ */
+ switch (pInstance->pBiquadType[i])
+ {
+ case LVEQNB_SinglePrecision:
+ {
+ PK_2I_D32F32C14G11_TRC_WRA_01(pBiquad,
+ (LVM_INT32 *)pScratch,
+ (LVM_INT32 *)pScratch,
+ (LVM_INT16)NumSamples);
+ break;
+ }
+
+ case LVEQNB_DoublePrecision:
+ {
+ PK_2I_D32F32C30G11_TRC_WRA_01(pBiquad,
+ (LVM_INT32 *)pScratch,
+ (LVM_INT32 *)pScratch,
+ (LVM_INT16)NumSamples);
+ break;
+ }
+ default:
+ break;
+ }
+ }
+ }
+ }
+
+
+ if(pInstance->bInOperatingModeTransition == LVM_TRUE){
+ /*
+ * Convert from 32-bit to 16- bit and saturate
+ */
+ Int32RShiftToInt16_Sat_32x16(pScratch, /* Source */
+ (LVM_INT16 *)pScratch, /* Destination */
+ (LVM_INT16)(2*NumSamples), /* Left and Right */
+ SHIFT); /* Scaling shift */
+
+ LVC_MixSoft_2St_D16C31_SAT(&pInstance->BypassMixer,
+ (LVM_INT16 *)pScratch,
+ (LVM_INT16 *)pInData,
+ (LVM_INT16 *)pScratch,
+ (LVM_INT16)(2*NumSamples));
+
+ Copy_16((LVM_INT16*)pScratch, /* Source */
+ pOutData, /* Destination */
+ (LVM_INT16)(2*NumSamples)); /* Left and Right samples */
+ }
+ else{
+
+ /*
+ * Convert from 32-bit to 16- bit and saturate
+ */
+ Int32RShiftToInt16_Sat_32x16(pScratch, /* Source */
+ pOutData, /* Destination */
+ (LVM_INT16 )(2*NumSamples), /* Left and Right */
+ SHIFT); /* Scaling shift */
+ }
+ }
+ else
+ {
+ /*
+ * Mode is OFF so copy the data if necessary
+ */
+ if (pInData != pOutData)
+ {
+ Copy_16(pInData, /* Source */
+ pOutData, /* Destination */
+ (LVM_INT16)(2*NumSamples)); /* Left and Right samples */
+ }
+ }
+
+
+
+ return(LVEQNB_SUCCESS);
+
+}
diff --git a/media/libeffects/lvm/lib/Eq/src/LVEQNB_Tables.c b/media/libeffects/lvm/lib/Eq/src/LVEQNB_Tables.c
new file mode 100755
index 0000000..33c07da
--- /dev/null
+++ b/media/libeffects/lvm/lib/Eq/src/LVEQNB_Tables.c
@@ -0,0 +1,203 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1005 $
+ $Date: 2010-06-28 13:58:28 +0200 (Mon, 28 Jun 2010) $
+
+*************************************************************************************/
+
+
+/************************************************************************************/
+/* */
+/* Includes */
+/* */
+/************************************************************************************/
+
+#include "LVEQNB.h"
+#include "LVEQNB_Coeffs.h"
+
+
+/************************************************************************************/
+/* */
+/* Sample rate table */
+/* */
+/************************************************************************************/
+
+/*
+ * Sample rate table for converting between the enumerated type and the actual
+ * frequency
+ */
+const LVM_UINT16 LVEQNB_SampleRateTab[] = {8000, /* 8kS/s */
+ 11025,
+ 12000,
+ 16000,
+ 22050,
+ 24000,
+ 32000,
+ 44100,
+ 48000}; /* 48kS/s */
+
+
+/************************************************************************************/
+/* */
+/* Coefficient calculation tables */
+/* */
+/************************************************************************************/
+
+/*
+ * Table for 2 * Pi / Fs
+ */
+const LVM_INT16 LVEQNB_TwoPiOnFsTable[] = {LVEQNB_2PiOn_8000, /* 8kS/s */
+ LVEQNB_2PiOn_11025,
+ LVEQNB_2PiOn_12000,
+ LVEQNB_2PiOn_16000,
+ LVEQNB_2PiOn_22050,
+ LVEQNB_2PiOn_24000,
+ LVEQNB_2PiOn_32000,
+ LVEQNB_2PiOn_44100,
+ LVEQNB_2PiOn_48000}; /* 48kS/s */
+
+/*
+ * Gain table
+ */
+const LVM_INT16 LVEQNB_GainTable[] = {LVEQNB_Gain_Neg15_dB, /* -15dB gain */
+ LVEQNB_Gain_Neg14_dB,
+ LVEQNB_Gain_Neg13_dB,
+ LVEQNB_Gain_Neg12_dB,
+ LVEQNB_Gain_Neg11_dB,
+ LVEQNB_Gain_Neg10_dB,
+ LVEQNB_Gain_Neg9_dB,
+ LVEQNB_Gain_Neg8_dB,
+ LVEQNB_Gain_Neg7_dB,
+ LVEQNB_Gain_Neg6_dB,
+ LVEQNB_Gain_Neg5_dB,
+ LVEQNB_Gain_Neg4_dB,
+ LVEQNB_Gain_Neg3_dB,
+ LVEQNB_Gain_Neg2_dB,
+ LVEQNB_Gain_Neg1_dB,
+ LVEQNB_Gain_0_dB, /* 0dB gain */
+ LVEQNB_Gain_1_dB,
+ LVEQNB_Gain_2_dB,
+ LVEQNB_Gain_3_dB,
+ LVEQNB_Gain_4_dB,
+ LVEQNB_Gain_5_dB,
+ LVEQNB_Gain_6_dB,
+ LVEQNB_Gain_7_dB,
+ LVEQNB_Gain_8_dB,
+ LVEQNB_Gain_9_dB,
+ LVEQNB_Gain_10_dB,
+ LVEQNB_Gain_11_dB,
+ LVEQNB_Gain_12_dB,
+ LVEQNB_Gain_13_dB,
+ LVEQNB_Gain_14_dB,
+ LVEQNB_Gain_15_dB}; /* +15dB gain */
+
+
+/*
+ * D table for 100 / (Gain + 1)
+ */
+const LVM_INT16 LVEQNB_DTable[] = {LVEQNB_100D_Neg15_dB, /* -15dB gain */
+ LVEQNB_100D_Neg14_dB,
+ LVEQNB_100D_Neg13_dB,
+ LVEQNB_100D_Neg12_dB,
+ LVEQNB_100D_Neg11_dB,
+ LVEQNB_100D_Neg10_dB,
+ LVEQNB_100D_Neg9_dB,
+ LVEQNB_100D_Neg8_dB,
+ LVEQNB_100D_Neg7_dB,
+ LVEQNB_100D_Neg6_dB,
+ LVEQNB_100D_Neg5_dB,
+ LVEQNB_100D_Neg4_dB,
+ LVEQNB_100D_Neg3_dB,
+ LVEQNB_100D_Neg2_dB,
+ LVEQNB_100D_Neg1_dB,
+ LVEQNB_100D_0_dB}; /* 0dB gain */
+
+
+/************************************************************************************/
+/* */
+/* Filter polynomial coefficients */
+/* */
+/************************************************************************************/
+
+/*
+ * Coefficients for calculating the cosine with the equation:
+ *
+ * Cos(x) = (2^Shifts)*(a0 + a1*x + a2*x^2 + a3*x^3 + a4*x^4 + a5*x^5)
+ *
+ * These coefficients expect the input, x, to be in the range 0 to 32768 respresenting
+ * a range of 0 to Pi. The output is in the range 32767 to -32768 representing the range
+ * +1.0 to -1.0
+ */
+const LVM_INT16 LVEQNB_CosCoef[] = {3, /* Shifts */
+ 4096, /* a0 */
+ -36, /* a1 */
+ -19725, /* a2 */
+ -2671, /* a3 */
+ 23730, /* a4 */
+ -9490}; /* a5 */
+
+/*
+ * Coefficients for calculating the cosine error with the equation:
+ *
+ * CosErr(x) = (2^Shifts)*(a0 + a1*x + a2*x^2 + a3*x^3)
+ *
+ * These coefficients expect the input, x, to be in the range 0 to 32768 respresenting
+ * a range of 0 to Pi/25. The output is in the range 0 to 32767 representing the range
+ * 0.0 to 0.0078852986
+ *
+ * This is used to give a double precision cosine over the range 0 to Pi/25 using the
+ * the equation:
+ *
+ * Cos(x) = 1.0 - CosErr(x)
+ */
+const LVM_INT16 LVEQNB_DPCosCoef[] = {1, /* Shifts */
+ 0, /* a0 */
+ -6, /* a1 */
+ 16586, /* a2 */
+ -44}; /* a3 */
+
+/************************************************************************************/
+/* */
+/* Bypass mixer time constants (100ms) */
+/* */
+/************************************************************************************/
+
+#define LVEQNB_MIX_TC_Fs8000 32580 /* Floating point value 0.994262695 */
+#define LVEQNB_MIX_TC_Fs11025 32632 /* Floating point value 0.995849609 */
+#define LVEQNB_MIX_TC_Fs12000 32643 /* Floating point value 0.996185303 */
+#define LVEQNB_MIX_TC_Fs16000 32674 /* Floating point value 0.997131348 */
+#define LVEQNB_MIX_TC_Fs22050 32700 /* Floating point value 0.997924805 */
+#define LVEQNB_MIX_TC_Fs24000 32705 /* Floating point value 0.998077393 */
+#define LVEQNB_MIX_TC_Fs32000 32721 /* Floating point value 0.998565674 */
+#define LVEQNB_MIX_TC_Fs44100 32734 /* Floating point value 0.998962402 */
+#define LVEQNB_MIX_TC_Fs48000 32737 /* Floating point value 0.999053955 */
+
+
+const LVM_INT16 LVEQNB_MixerTCTable[] = {
+ LVEQNB_MIX_TC_Fs8000,
+ LVEQNB_MIX_TC_Fs11025,
+ LVEQNB_MIX_TC_Fs12000,
+ LVEQNB_MIX_TC_Fs16000,
+ LVEQNB_MIX_TC_Fs22050,
+ LVEQNB_MIX_TC_Fs24000,
+ LVEQNB_MIX_TC_Fs32000,
+ LVEQNB_MIX_TC_Fs44100,
+ LVEQNB_MIX_TC_Fs48000};
diff --git a/media/libeffects/lvm/lib/SpectrumAnalyzer/lib/LVPSA.h b/media/libeffects/lvm/lib/SpectrumAnalyzer/lib/LVPSA.h
new file mode 100755
index 0000000..b9903b2
--- /dev/null
+++ b/media/libeffects/lvm/lib/SpectrumAnalyzer/lib/LVPSA.h
@@ -0,0 +1,298 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: PSA_01_ARMC_01 */
+/* $Author: beq07716 $*/
+/* $Revision: 1006 $*/
+/* $Date: 2010-06-28 14:01:47 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+#ifndef _LVPSA_H_
+#define _LVPSA_H_
+
+
+#include "LVM_Types.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/****************************************************************************************/
+/* */
+/* CONSTANTS DEFINITIONS */
+/* */
+/****************************************************************************************/
+
+/* Memory table*/
+#define LVPSA_NR_MEMORY_REGIONS 4 /* Number of memory regions */
+
+/****************************************************************************************/
+/* */
+/* TYPES DEFINITIONS */
+/* */
+/****************************************************************************************/
+/* Memory Types */
+typedef enum
+{
+ LVPSA_PERSISTENT = LVM_PERSISTENT,
+ LVPSA_PERSISTENT_DATA = LVM_PERSISTENT_DATA,
+ LVPSA_PERSISTENT_COEF = LVM_PERSISTENT_COEF,
+ LVPSA_SCRATCH = LVM_SCRATCH,
+ LVPSA_MEMORY_DUMMY = LVM_MAXINT_32 /* Force 32 bits enum, don't use it! */
+} LVPSA_MemoryTypes_en;
+
+/* Level detection speed control parameters */
+typedef enum
+{
+ LVPSA_SPEED_LOW, /* Low speed level detection */
+ LVPSA_SPEED_MEDIUM, /* Medium speed level detection */
+ LVPSA_SPEED_HIGH, /* High speed level detection */
+ LVPSA_SPEED_DUMMY = LVM_MAXINT_32 /* Force 32 bits enum, don't use it! */
+} LVPSA_LevelDetectSpeed_en;
+
+/* Filter control parameters */
+typedef struct
+{
+ LVM_UINT16 CenterFrequency; /* Center frequency of the band-pass filter (in Hz) */
+ LVM_UINT16 QFactor; /* Quality factor of the filter (in 1/100) */
+ LVM_INT16 PostGain; /* Postgain to apply after the filtering (in dB Q16.0) */
+
+} LVPSA_FilterParam_t;
+
+/* LVPSA initialization parameters */
+typedef struct
+{
+ LVM_UINT16 SpectralDataBufferDuration; /* Spectral data buffer duration in time (ms in Q16.0) */
+ LVM_UINT16 MaxInputBlockSize; /* Maximum expected input block size (in samples) */
+ LVM_UINT16 nBands; /* Number of bands of the SA */
+ LVPSA_FilterParam_t *pFiltersParams; /* Points to nBands filter param structures for filters settings */
+
+} LVPSA_InitParams_t, *pLVPSA_InitParams_t;
+
+/* LVPSA control parameters */
+typedef struct
+{
+ LVM_Fs_en Fs; /* Input sampling rate */
+ LVPSA_LevelDetectSpeed_en LevelDetectionSpeed; /* Level detection speed */
+
+} LVPSA_ControlParams_t, *pLVPSA_ControlParams_t;
+
+/* Memory region definition */
+typedef struct
+{
+ LVM_UINT32 Size; /* Region size in bytes */
+ LVPSA_MemoryTypes_en Type; /* Region type */
+ void *pBaseAddress; /* Pointer to the region base address */
+} LVPSA_MemoryRegion_t;
+
+/* Memory table containing the region definitions */
+typedef struct
+{
+ LVPSA_MemoryRegion_t Region[LVPSA_NR_MEMORY_REGIONS];/* One definition for each region */
+} LVPSA_MemTab_t;
+
+/* Audio time type */
+typedef LVM_INT32 LVPSA_Time;
+
+/* Module instance Handle */
+typedef void *pLVPSA_Handle_t;
+
+/* LVPSA return codes */
+typedef enum
+{
+ LVPSA_OK, /* The function ran without any problem */
+ LVPSA_ERROR_INVALIDPARAM, /* A parameter is incorrect */
+ LVPSA_ERROR_WRONGTIME, /* An incorrect AudioTime is used */
+ LVPSA_ERROR_NULLADDRESS, /* A pointer has a NULL value */
+ LVPSA_RETURN_DUMMY = LVM_MAXINT_32 /* Force 32 bits enum, don't use it! */
+} LVPSA_RETURN;
+
+
+
+/*********************************************************************************************************************************
+ FUNCTIONS PROTOTYPE
+**********************************************************************************************************************************/
+/*********************************************************************************************************************************/
+/* */
+/* FUNCTION: LVPSA_Memory */
+/* */
+/* DESCRIPTION: */
+/* This function is used for memory allocation and free. It can be called in */
+/* two ways: */
+/* */
+/* hInstance = NULL Returns the memory requirements */
+/* hInstance = Instance handle Returns the memory requirements and */
+/* allocated base addresses for the instance */
+/* */
+/* When this function is called for memory allocation (hInstance=NULL) the memory */
+/* base address pointers are NULL on return. */
+/* */
+/* When the function is called for free (hInstance = Instance Handle) the memory */
+/* table returns the allocated memory and base addresses used during initialisation. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance Handle */
+/* pMemoryTable Pointer to an empty memory definition table */
+/* pInitParams Pointer to the instance init parameters */
+/* */
+/* RETURNS: */
+/* LVPSA_OK Succeeds */
+/* otherwise Error due to bad parameters */
+/* */
+/*********************************************************************************************************************************/
+LVPSA_RETURN LVPSA_Memory ( pLVPSA_Handle_t hInstance,
+ LVPSA_MemTab_t *pMemoryTable,
+ LVPSA_InitParams_t *pInitParams );
+
+/*********************************************************************************************************************************/
+/* */
+/* FUNCTION: LVPSA_Init */
+/* */
+/* DESCRIPTION: */
+/* Initializes the LVPSA module. */
+/* */
+/* */
+/* PARAMETERS: */
+/* phInstance Pointer to the instance Handle */
+/* pInitParams Pointer to the instance init parameters */
+/* pControlParams Pointer to the instance control parameters */
+/* pMemoryTable Pointer to the memory definition table */
+/* */
+/* */
+/* RETURNS: */
+/* LVPSA_OK Succeeds */
+/* otherwise Error due to bad parameters */
+/* */
+/*********************************************************************************************************************************/
+LVPSA_RETURN LVPSA_Init ( pLVPSA_Handle_t *phInstance,
+ LVPSA_InitParams_t *pInitParams,
+ LVPSA_ControlParams_t *pControlParams,
+ LVPSA_MemTab_t *pMemoryTable );
+
+/*********************************************************************************************************************************/
+/* */
+/* FUNCTION: LVPSA_Control */
+/* */
+/* DESCRIPTION: */
+/* Controls the LVPSA module. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance Handle */
+/* pNewParams Pointer to the instance new control parameters */
+/* */
+/* RETURNS: */
+/* LVPSA_OK Succeeds */
+/* otherwise Error due to bad parameters */
+/* */
+/*********************************************************************************************************************************/
+LVPSA_RETURN LVPSA_Control ( pLVPSA_Handle_t hInstance,
+ LVPSA_ControlParams_t *pNewParams );
+
+/*********************************************************************************************************************************/
+/* */
+/* FUNCTION: LVPSA_Process */
+/* */
+/* DESCRIPTION: */
+/* The process calculates the levels of the frequency bands. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance Handle */
+/* pLVPSA_InputSamples Pointer to the input samples buffer */
+/* InputBlockSize Number of mono samples to process */
+/* AudioTime Playback time of the first input sample */
+/* */
+/* */
+/* RETURNS: */
+/* LVPSA_OK Succeeds */
+/* otherwise Error due to bad parameters */
+/* */
+/*********************************************************************************************************************************/
+LVPSA_RETURN LVPSA_Process ( pLVPSA_Handle_t hInstance,
+ LVM_INT16 *pLVPSA_InputSamples,
+ LVM_UINT16 InputBlockSize,
+ LVPSA_Time AudioTime );
+
+/*********************************************************************************************************************************/
+/* */
+/* FUNCTION: LVPSA_GetSpectrum */
+/* */
+/* DESCRIPTION: */
+/* This function is used for memory allocation and free. */
+/* */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance Handle */
+/* GetSpectrumAudioTime Time to retrieve the values at */
+/* pCurrentValues Pointer to an empty buffer : Current level values output */
+/* pPeakValues Pointer to an empty buffer : Peak level values output */
+/* */
+/* */
+/* RETURNS: */
+/* LVPSA_OK Succeeds */
+/* otherwise Error due to bad parameters */
+/* */
+/*********************************************************************************************************************************/
+LVPSA_RETURN LVPSA_GetSpectrum ( pLVPSA_Handle_t hInstance,
+ LVPSA_Time GetSpectrumAudioTime,
+ LVM_UINT8 *pCurrentValues,
+ LVM_UINT8 *pPeakValues );
+
+/*********************************************************************************************************************************/
+/* */
+/* FUNCTION: LVPSA_GetControlParams */
+/* */
+/* DESCRIPTION: */
+/* Get the current control parameters of the LVPSA module. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance Handle */
+/* pParams Pointer to an empty control parameters structure */
+/* RETURNS: */
+/* LVPSA_OK Succeeds */
+/* otherwise Error due to bad parameters */
+/* */
+/*********************************************************************************************************************************/
+LVPSA_RETURN LVPSA_GetControlParams ( pLVPSA_Handle_t hInstance,
+ LVPSA_ControlParams_t *pParams );
+
+/*********************************************************************************************************************************/
+/* */
+/* FUNCTION: LVPSA_GetInitParams */
+/* */
+/* DESCRIPTION: */
+/* Get the initialization parameters of the LVPSA module. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance Handle */
+/* pParams Pointer to an empty init parameters structure */
+/* RETURNS: */
+/* LVPSA_OK Succeeds */
+/* otherwise Error due to bad parameters */
+/* */
+/*********************************************************************************************************************************/
+LVPSA_RETURN LVPSA_GetInitParams ( pLVPSA_Handle_t hInstance,
+ LVPSA_InitParams_t *pParams );
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _LVPSA_H */
diff --git a/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Control.c b/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Control.c
new file mode 100755
index 0000000..1be8ff0
--- /dev/null
+++ b/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Control.c
@@ -0,0 +1,715 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: PSA_01_ARMC_01 */
+/* $Author: beq07716 $*/
+/* $Revision: 1006 $*/
+/* $Date: 2010-06-28 14:01:47 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+#include "LVPSA.h"
+#include "LVPSA_Private.h"
+#include "VectorArithmetic.h"
+
+#define LOW_FREQ 298 /* 32768/110 for low test frequency */
+#define HIGH_FREQ 386 /* 32768/85 for high test frequency */
+
+LVPSA_RETURN LVPSA_SetBPFiltersType ( LVPSA_InstancePr_t *pInst,
+ LVPSA_ControlParams_t *pParams );
+
+LVPSA_RETURN LVPSA_SetQPFCoefficients( LVPSA_InstancePr_t *pInst,
+ LVPSA_ControlParams_t *pParams );
+
+LVPSA_RETURN LVPSA_BPSinglePrecCoefs( LVM_UINT16 Fs,
+ LVPSA_FilterParam_t *pFilterParams,
+ BP_C16_Coefs_t *pCoefficients);
+
+LVPSA_RETURN LVPSA_BPDoublePrecCoefs( LVM_UINT16 Fs,
+ LVPSA_FilterParam_t *pFilterParams,
+ BP_C32_Coefs_t *pCoefficients);
+
+LVPSA_RETURN LVPSA_BPDoublePrecCoefs( LVM_UINT16 Fs,
+ LVPSA_FilterParam_t *pFilterParams,
+ BP_C32_Coefs_t *pCoefficients);
+
+LVPSA_RETURN LVPSA_SetBPFCoefficients( LVPSA_InstancePr_t *pInst,
+ LVPSA_ControlParams_t *pParams );
+
+LVPSA_RETURN LVPSA_ClearFilterHistory( LVPSA_InstancePr_t *pInst);
+
+
+
+
+/************************************************************************************/
+/* */
+/* FUNCTION: LVPSA_Control */
+/* */
+/* DESCRIPTION: */
+/* Give some new control parameters to the module. */
+/* */
+/* PARAMETERS: */
+/* hInstance Pointer to the instance */
+/* NewParams Structure that contains the new parameters */
+/* */
+/* RETURNS: */
+/* LVPSA_OK Succeeds */
+/* otherwise Error due to bad parameters */
+/* */
+/************************************************************************************/
+LVPSA_RETURN LVPSA_Control ( pLVPSA_Handle_t hInstance,
+ LVPSA_ControlParams_t *pNewParams )
+{
+
+ LVPSA_InstancePr_t *pLVPSA_Inst = (LVPSA_InstancePr_t*)hInstance;
+
+ if((hInstance == LVM_NULL) || (pNewParams == LVM_NULL))
+ {
+ return(LVPSA_ERROR_NULLADDRESS);
+ }
+ if(pNewParams->Fs >= LVPSA_NR_SUPPORTED_RATE)
+ {
+ return(LVPSA_ERROR_INVALIDPARAM);
+ }
+ if(pNewParams->LevelDetectionSpeed >= LVPSA_NR_SUPPORTED_SPEED)
+ {
+ return(LVPSA_ERROR_INVALIDPARAM);
+ }
+
+ pLVPSA_Inst->NewParams = *pNewParams;
+ pLVPSA_Inst->bControlPending = LVM_TRUE;
+
+ return(LVPSA_OK);
+}
+
+/************************************************************************************/
+/* */
+/* FUNCTION: LVPSA_GetControlParams */
+/* */
+/* DESCRIPTION: */
+/* Get the current control parameters of the module */
+/* */
+/* PARAMETERS: */
+/* hInstance Pointer to the instance */
+/* pParams Pointer to an empty control structure */
+/* RETURNS: */
+/* LVPSA_OK Succeeds */
+/* otherwise Error due to bad parameters */
+/* */
+/************************************************************************************/
+LVPSA_RETURN LVPSA_GetControlParams ( pLVPSA_Handle_t hInstance,
+ LVPSA_ControlParams_t *pParams )
+{
+ LVPSA_InstancePr_t *pLVPSA_Inst = (LVPSA_InstancePr_t*)hInstance;
+
+ if((hInstance == LVM_NULL) || (pParams == LVM_NULL))
+ {
+ return(LVPSA_ERROR_NULLADDRESS);
+ }
+
+ pParams->Fs = pLVPSA_Inst->CurrentParams.Fs;
+ pParams->LevelDetectionSpeed = pLVPSA_Inst->CurrentParams.LevelDetectionSpeed;
+
+ return(LVPSA_OK);
+}
+
+
+/************************************************************************************/
+/* */
+/* FUNCTION: LVPSA_GetInitParams */
+/* */
+/* DESCRIPTION: */
+/* Get the initialization parameters of the module */
+/* */
+/* PARAMETERS: */
+/* hInstance Pointer to the instance */
+/* pParams Pointer to an empty control structure */
+/* RETURNS: */
+/* LVPSA_OK Succeeds */
+/* otherwise Error due to bad parameters */
+/* */
+/************************************************************************************/
+LVPSA_RETURN LVPSA_GetInitParams ( pLVPSA_Handle_t hInstance,
+ LVPSA_InitParams_t *pParams )
+{
+ LVPSA_InstancePr_t *pLVPSA_Inst = (LVPSA_InstancePr_t*)hInstance;
+
+ if((hInstance == LVM_NULL) || (pParams == LVM_NULL))
+ {
+ return(LVPSA_ERROR_NULLADDRESS);
+ }
+
+ pParams->SpectralDataBufferDuration = pLVPSA_Inst->SpectralDataBufferDuration;
+ pParams->MaxInputBlockSize = pLVPSA_Inst->MaxInputBlockSize;
+ pParams->nBands = pLVPSA_Inst->nBands;
+ pParams->pFiltersParams = pLVPSA_Inst->pFiltersParams;
+
+ return(LVPSA_OK);
+}
+
+
+/************************************************************************************/
+/* */
+/* FUNCTION: LVPSA_ApplyNewSettings */
+/* */
+/* DESCRIPTION: */
+/* Reinitialize some parameters and changes filters' coefficients if */
+/* some control parameters have changed. */
+/* */
+/* PARAMETERS: */
+/* pInst Pointer to the instance */
+/* */
+/* RETURNS: */
+/* LVPSA_OK Succeeds */
+/* otherwise Error due to bad parameters */
+/* */
+/* NOTES: */
+/* */
+/************************************************************************************/
+LVPSA_RETURN LVPSA_ApplyNewSettings (LVPSA_InstancePr_t *pInst)
+{
+ LVM_UINT16 ii;
+ LVM_UINT16 Freq;
+ LVPSA_ControlParams_t Params;
+ extern LVM_INT16 LVPSA_nSamplesBufferUpdate[];
+ extern LVM_UINT16 LVPSA_SampleRateTab[];
+ extern LVM_UINT16 LVPSA_DownSamplingFactor[];
+
+
+ if(pInst == 0)
+ {
+ return(LVPSA_ERROR_NULLADDRESS);
+ }
+
+ Params = pInst->NewParams;
+
+ /* Modifies filters types and coefficients, clear the taps and
+ re-initializes parameters if sample frequency has changed */
+ if(Params.Fs != pInst->CurrentParams.Fs)
+ {
+ pInst->CurrentParams.Fs = Params.Fs;
+
+ /* Initialize the center freqeuncies as a function of the sample rate */
+ Freq = (LVM_UINT16) ((LVPSA_SampleRateTab[pInst->CurrentParams.Fs]>>1) / (pInst->nBands + 1));
+ for(ii = pInst->nBands; ii > 0; ii--)
+ {
+ pInst->pFiltersParams[ii-1].CenterFrequency = (LVM_UINT16) (Freq * ii);
+ }
+
+ /* Count the number of relevant filters. If the center frequency of the filter is
+ bigger than the nyquist frequency, then the filter is not relevant and doesn't
+ need to be used */
+ for(ii = pInst->nBands; ii > 0; ii--)
+ {
+ if(pInst->pFiltersParams[ii-1].CenterFrequency < (LVPSA_SampleRateTab[pInst->CurrentParams.Fs]>>1))
+ {
+ pInst->nRelevantFilters = ii;
+ break;
+ }
+ }
+ LVPSA_SetBPFiltersType(pInst, &Params);
+ LVPSA_SetBPFCoefficients(pInst, &Params);
+ LVPSA_SetQPFCoefficients(pInst, &Params);
+ LVPSA_ClearFilterHistory(pInst);
+ pInst->nSamplesBufferUpdate = (LVM_UINT16)LVPSA_nSamplesBufferUpdate[Params.Fs];
+ pInst->BufferUpdateSamplesCount = 0;
+ pInst->DownSamplingFactor = LVPSA_DownSamplingFactor[Params.Fs];
+ pInst->DownSamplingCount = 0;
+ for(ii = 0; ii < (pInst->nBands * pInst->SpectralDataBufferLength); ii++)
+ {
+ pInst->pSpectralDataBufferStart[ii] = 0;
+ }
+ for(ii = 0; ii < pInst->nBands; ii++)
+ {
+ pInst->pPreviousPeaks[ii] = 0;
+ }
+ }
+ else
+ {
+ if(Params.LevelDetectionSpeed != pInst->CurrentParams.LevelDetectionSpeed)
+ {
+ LVPSA_SetQPFCoefficients(pInst, &Params);
+ }
+ }
+
+ pInst->CurrentParams = pInst->NewParams;
+
+ return (LVPSA_OK);
+}
+/************************************************************************************/
+/* */
+/* FUNCTION: LVPSA_SetBPFiltersType */
+/* */
+/* DESCRIPTION: */
+/* Sets the filter type based on the BPFilterType. */
+/* */
+/* PARAMETERS: */
+/* pInst Pointer to the instance */
+/* pParams Poniter to conrol parameters */
+/* */
+/* RETURNS: */
+/* LVPSA_OK Always succeeds */
+/* */
+/* NOTES: */
+/* 1. To select the biquad type the follow rules are applied: */
+/* Double precision if (fc <= fs/110) */
+/* Double precision if (fs/110 < fc < fs/85) & (Q>3) */
+/* Single precision otherwise */
+/* */
+/************************************************************************************/
+LVPSA_RETURN LVPSA_SetBPFiltersType ( LVPSA_InstancePr_t *pInst,
+ LVPSA_ControlParams_t *pParams )
+{
+
+ extern LVM_UINT16 LVPSA_SampleRateTab[]; /* Sample rate table */
+ LVM_UINT16 ii; /* Filter band index */
+ LVM_UINT32 fs = (LVM_UINT32)LVPSA_SampleRateTab[(LVM_UINT16)pParams->Fs]; /* Sample rate */
+ LVM_UINT32 fc; /* Filter centre frequency */
+ LVM_INT16 QFactor; /* Filter Q factor */
+
+ for (ii = 0; ii < pInst->nRelevantFilters; ii++)
+ {
+ /*
+ * Get the filter settings
+ */
+ fc = (LVM_UINT32)pInst->pFiltersParams[ii].CenterFrequency; /* Get the band centre frequency */
+ QFactor =(LVM_INT16) pInst->pFiltersParams[ii].QFactor; /* Get the band Q factor */
+
+
+ /*
+ * For each filter set the type of biquad required
+ */
+ pInst->pBPFiltersPrecision[ii] = LVPSA_SimplePrecisionFilter; /* Default to single precision */
+ if ((LOW_FREQ * fs) >= (fc << 15))
+ {
+ /*
+ * fc <= fs/110
+ */
+ pInst->pBPFiltersPrecision[ii] = LVPSA_DoublePrecisionFilter;
+ }
+ else
+ {
+ if (((LOW_FREQ * fs) < (fc << 15)) && ((fc << 15) < (HIGH_FREQ * fs)) && (QFactor > 300))
+ {
+ /*
+ * (fs/110 < fc < fs/85) & (Q>3)
+ */
+ pInst->pBPFiltersPrecision[ii] = LVPSA_DoublePrecisionFilter;
+ }
+ }
+ }
+
+ return(LVPSA_OK);
+}
+
+/************************************************************************************/
+/* */
+/* FUNCTION: LVPSA_SetBPFCoefficients */
+/* */
+/* DESCRIPTION: */
+/* Sets the band pass filter coefficients. This uses the type to select */
+/* single or double precision coefficients. */
+/* */
+/* PARAMETERS: */
+/* pInst Pointer to the instance */
+/* Params Initialisation parameters */
+/* */
+/* RETURNS: */
+/* LVPSA_OK Always succeeds */
+/* */
+/* NOTES: */
+/* */
+/************************************************************************************/
+LVPSA_RETURN LVPSA_SetBPFCoefficients( LVPSA_InstancePr_t *pInst,
+ LVPSA_ControlParams_t *pParams)
+{
+
+ LVM_UINT16 ii;
+
+ /*
+ * Set the coefficients for each band by the init function
+ */
+ for (ii = 0; ii < pInst->nRelevantFilters; ii++)
+ {
+ switch (pInst->pBPFiltersPrecision[ii])
+ {
+ case LVPSA_DoublePrecisionFilter:
+ {
+ BP_C32_Coefs_t Coefficients;
+
+ /*
+ * Calculate the double precision coefficients
+ */
+ LVPSA_BPDoublePrecCoefs((LVM_UINT16)pParams->Fs,
+ &pInst->pFiltersParams[ii],
+ &Coefficients);
+
+ /*
+ * Set the coefficients
+ */
+ BP_1I_D16F32Cll_TRC_WRA_01_Init ( &pInst->pBP_Instances[ii],
+ &pInst->pBP_Taps[ii],
+ &Coefficients);
+ break;
+ }
+
+ case LVPSA_SimplePrecisionFilter:
+ {
+ BP_C16_Coefs_t Coefficients;
+
+ /*
+ * Calculate the single precision coefficients
+ */
+ LVPSA_BPSinglePrecCoefs((LVM_UINT16)pParams->Fs,
+ &pInst->pFiltersParams[ii],
+ &Coefficients);
+
+ /*
+ * Set the coefficients
+ */
+ BP_1I_D16F16Css_TRC_WRA_01_Init ( &pInst->pBP_Instances[ii],
+ &pInst->pBP_Taps[ii],
+ &Coefficients);
+ break;
+ }
+ }
+ }
+
+ return(LVPSA_OK);
+}
+
+
+/************************************************************************************/
+/* */
+/* FUNCTION: LVPSA_SetQPFCoefficients */
+/* */
+/* DESCRIPTION: */
+/* Sets the quasi peak filters coefficients. This uses the chosen */
+/* LevelDetectionSpeed from the control parameters. */
+/* */
+/* PARAMETERS: */
+/* pInst Pointer to the instance */
+/* Params Control parameters */
+/* */
+/* RETURNS: */
+/* LVPSA_OK Always succeeds */
+/* */
+/* NOTES: */
+/* */
+/************************************************************************************/
+LVPSA_RETURN LVPSA_SetQPFCoefficients( LVPSA_InstancePr_t *pInst,
+ LVPSA_ControlParams_t *pParams )
+{
+ LVM_UINT16 ii;
+ LVM_Fs_en Fs = pParams->Fs;
+ QPD_C32_Coefs *pCoefficients;
+ extern QPD_C32_Coefs LVPSA_QPD_Coefs[];
+
+
+ pCoefficients = &LVPSA_QPD_Coefs[(pParams->LevelDetectionSpeed * LVPSA_NR_SUPPORTED_RATE) + Fs];
+
+
+ for (ii = 0; ii < pInst->nRelevantFilters; ii++)
+ {
+ LVPSA_QPD_Init (&pInst->pQPD_States[ii],
+ &pInst->pQPD_Taps[ii],
+ pCoefficients );
+ }
+
+ return(LVPSA_OK);
+
+}
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVPSA_BPSinglePrecCoefs */
+/* */
+/* DESCRIPTION: */
+/* Calculate single precision coefficients for a band pass filter */
+/* */
+/* PARAMETERS: */
+/* Fs Sampling frequency index */
+/* pFilterParams Pointer to the filter definition */
+/* pCoefficients Pointer to the coefficients */
+/* */
+/* RETURNS: */
+/* LVPSA_OK Always succeeds */
+/* */
+/* NOTES: */
+/* 1. The equations used are as follows: */
+/* */
+/* t0 = 2 * Pi * Fc / Fs */
+/* */
+/* b2 = -0.5 * (2Q - t0) / (2Q + t0) */
+/* b1 = (0.5 - b2) * cos(t0) */
+/* a0 = (0.5 + b2) / 2 */
+/* */
+/* Where: */
+/* Fc is the centre frequency, DC to Nyquist */
+/* Fs is the sample frequency, 8000 to 48000 in descrete steps */
+/* Q is the Q factor, 0.25 to 12 */
+/* */
+/* 2. This function is entirely based on the LVEQNB_SinglePrecCoefs function */
+/* of the n bands equalizer (LVEQNB */
+/* */
+/****************************************************************************************/
+LVPSA_RETURN LVPSA_BPSinglePrecCoefs( LVM_UINT16 Fs,
+ LVPSA_FilterParam_t *pFilterParams,
+ BP_C16_Coefs_t *pCoefficients)
+{
+
+ extern LVM_INT16 LVPSA_TwoPiOnFsTable[];
+ extern LVM_INT16 LVPSA_CosCoef[];
+
+
+ /*
+ * Intermediate variables and temporary values
+ */
+ LVM_INT32 T0;
+ LVM_INT16 D;
+ LVM_INT32 A0;
+ LVM_INT32 B1;
+ LVM_INT32 B2;
+ LVM_INT32 Dt0;
+ LVM_INT32 B2_Den;
+ LVM_INT32 B2_Num;
+ LVM_INT32 COS_T0;
+ LVM_INT16 coef;
+ LVM_INT32 factor;
+ LVM_INT16 t0;
+ LVM_INT16 i;
+
+
+ /*
+ * Get the filter definition
+ */
+ LVM_UINT16 Frequency = pFilterParams->CenterFrequency;
+ LVM_UINT16 QFactor = pFilterParams->QFactor;
+
+
+ /*
+ * Calculating the intermediate values
+ */
+ T0 = (LVM_INT32)Frequency * LVPSA_TwoPiOnFsTable[Fs]; /* T0 = 2 * Pi * Fc / Fs */
+ D = 3200; /* Floating point value 1.000000 (1*100*2^5) */
+ /* Force D = 1 : the function was originally used for a peaking filter.
+ The D parameter do not exist for a BandPass filter coefficients */
+
+ /*
+ * Calculate the B2 coefficient
+ */
+ Dt0 = D * (T0 >> 10);
+ B2_Den = (LVM_INT32)(((LVM_UINT32)QFactor << 19) + (LVM_UINT32)(Dt0 >> 2));
+ B2_Num = (LVM_INT32)((LVM_UINT32)(Dt0 >> 3) - ((LVM_UINT32)QFactor << 18));
+ B2 = (B2_Num / (B2_Den >> 16)) << 15;
+
+ /*
+ * Calculate the cosine by a polynomial expansion using the equation:
+ *
+ * Cos += coef(n) * t0^n For n = 0 to 6
+ */
+ T0 = (T0 >> 10) * 20859; /* Scale to 1.0 in 16-bit for range 0 to fs/2 */
+ t0 = (LVM_INT16)(T0 >> 16);
+ factor = 0x7fff; /* Initialise to 1.0 for the a0 coefficient */
+ COS_T0 = 0; /* Initialise the error to zero */
+ for (i=1; i<7; i++)
+ {
+ coef = LVPSA_CosCoef[i]; /* Get the nth coefficient */
+ COS_T0 += (factor * coef) >> 5; /* The nth partial sum */
+ factor = (factor * t0) >> 15; /* Calculate t0^n */
+ }
+ COS_T0 = COS_T0 << (LVPSA_CosCoef[0]+6); /* Correct the scaling */
+
+
+ B1 = ((0x40000000 - B2) >> 16) * (COS_T0 >> 16); /* B1 = (0.5 - b2) * cos(t0) */
+ A0 = (0x40000000 + B2) >> 1; /* A0 = (0.5 + b2) / 2 */
+
+ /*
+ * Write coeff into the data structure
+ */
+ pCoefficients->A0 = (LVM_INT16)(A0>>16);
+ pCoefficients->B1 = (LVM_INT16)(B1>>15);
+ pCoefficients->B2 = (LVM_INT16)(B2>>16);
+
+
+ return(LVPSA_OK);
+}
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVPSA_BPDoublePrecCoefs */
+/* */
+/* DESCRIPTION: */
+/* Calculate double precision coefficients for a band pass filter */
+/* */
+/* PARAMETERS: */
+/* Fs Sampling frequency index */
+/* pFilterParams Pointer to the filter definition */
+/* pCoefficients Pointer to the coefficients */
+/* */
+/* RETURNS: */
+/* LVPSA_OK Always succeeds */
+/* */
+/* NOTES: */
+/* 1. The equations used are as follows: */
+/* */
+/* t0 = 2 * Pi * Fc / Fs */
+/* */
+/* b2 = -0.5 * (2Q - t0) / (2Q + t0) */
+/* b1 = (0.5 - b2) * (1 - coserr(t0)) */
+/* a0 = (0.5 + b2) / 2 */
+/* */
+/* Where: */
+/* Fc is the centre frequency, DC to Fs/50 */
+/* Fs is the sample frequency, 8000 to 48000 in descrete steps */
+/* Q is the Q factor, 0.25 to 12 (represented by 25 to 1200) */
+/* */
+/* 2. The double precision coefficients are only used when fc is less than fs/85, so */
+/* the cosine of t0 is always close to 1.0. Instead of calculating the cosine */
+/* itself the difference from the value 1.0 is calculated, this can be done with */
+/* lower precision maths. */
+/* */
+/* 3. The value of the B2 coefficient is only calculated as a single precision value, */
+/* small errors in this value have a combined effect on the Q and Gain but not the */
+/* the frequency of the filter. */
+/* */
+/* 4. This function is entirely based on the LVEQNB_DoublePrecCoefs function */
+/* of the n bands equalizer (LVEQNB */
+/* */
+/****************************************************************************************/
+LVPSA_RETURN LVPSA_BPDoublePrecCoefs( LVM_UINT16 Fs,
+ LVPSA_FilterParam_t *pFilterParams,
+ BP_C32_Coefs_t *pCoefficients)
+{
+
+ extern LVM_INT16 LVPSA_TwoPiOnFsTable[];
+ extern LVM_INT16 LVPSA_DPCosCoef[];
+
+ /*
+ * Intermediate variables and temporary values
+ */
+ LVM_INT32 T0;
+ LVM_INT16 D;
+ LVM_INT32 A0;
+ LVM_INT32 B1;
+ LVM_INT32 B2;
+ LVM_INT32 Dt0;
+ LVM_INT32 B2_Den;
+ LVM_INT32 B2_Num;
+ LVM_INT32 CosErr;
+ LVM_INT16 coef;
+ LVM_INT32 factor;
+ LVM_INT16 t0;
+ LVM_INT16 i;
+
+ /*
+ * Get the filter definition
+ */
+ LVM_UINT16 Frequency = pFilterParams->CenterFrequency;
+ LVM_UINT16 QFactor = pFilterParams->QFactor;
+
+
+ /*
+ * Calculating the intermediate values
+ */
+ T0 = (LVM_INT32)Frequency * LVPSA_TwoPiOnFsTable[Fs]; /* T0 = 2 * Pi * Fc / Fs */
+ D = 3200; /* Floating point value 1.000000 (1*100*2^5) */
+ /* Force D = 1 : the function was originally used for a peaking filter.
+ The D parameter do not exist for a BandPass filter coefficients */
+
+ /*
+ * Calculate the B2 coefficient
+ */
+ Dt0 = D * (T0 >> 10);
+ B2_Den = (LVM_INT32)(((LVM_UINT32)QFactor << 19) + (LVM_UINT32)(Dt0 >> 2));
+ B2_Num = (LVM_INT32)((LVM_UINT32)(Dt0 >> 3) - ((LVM_UINT32)QFactor << 18));
+ B2 = (B2_Num / (B2_Den >> 16)) << 15;
+
+ /*
+ * Calculate the cosine error by a polynomial expansion using the equation:
+ *
+ * CosErr += coef(n) * t0^n For n = 0 to 4
+ */
+ T0 = (T0 >> 6) * 0x7f53; /* Scale to 1.0 in 16-bit for range 0 to fs/50 */
+ t0 = (LVM_INT16)(T0 >> 16);
+ factor = 0x7fff; /* Initialise to 1.0 for the a0 coefficient */
+ CosErr = 0; /* Initialise the error to zero */
+ for (i=1; i<5; i++)
+ {
+ coef = LVPSA_DPCosCoef[i]; /* Get the nth coefficient */
+ CosErr += (factor * coef) >> 5; /* The nth partial sum */
+ factor = (factor * t0) >> 15; /* Calculate t0^n */
+ }
+ CosErr = CosErr << (LVPSA_DPCosCoef[0]); /* Correct the scaling */
+
+ /*
+ * Calculate the B1 and A0 coefficients
+ */
+ B1 = (0x40000000 - B2); /* B1 = (0.5 - b2) */
+ A0 = ((B1 >> 16) * (CosErr >> 10)) >> 6; /* Temporary storage for (0.5 - b2) * coserr(t0) */
+ B1 -= A0; /* B1 = (0.5 - b2) * (1 - coserr(t0)) */
+ A0 = (0x40000000 + B2) >> 1; /* A0 = (0.5 + b2) / 2 */
+
+ /*
+ * Write coeff into the data structure
+ */
+ pCoefficients->A0 = A0;
+ pCoefficients->B1 = B1;
+ pCoefficients->B2 = B2;
+
+ return(LVPSA_OK);
+}
+
+/************************************************************************************/
+/* */
+/* FUNCTION: LVPSA_ClearFilterHistory */
+/* */
+/* DESCRIPTION: */
+/* Clears the filters' data history */
+/* */
+/* PARAMETERS: */
+/* pInst Pointer to the instance */
+/* */
+/* RETURNS: */
+/* LVPSA_OK Always succeeds */
+/* */
+/* NOTES: */
+/* */
+/************************************************************************************/
+LVPSA_RETURN LVPSA_ClearFilterHistory(LVPSA_InstancePr_t *pInst)
+{
+ LVM_INT8 *pTapAddress;
+ LVM_UINT32 i;
+
+ /* Band Pass filters taps */
+ pTapAddress = (LVM_INT8 *)pInst->pBP_Taps;
+ for(i = 0; i < pInst->nBands * sizeof(Biquad_1I_Order2_Taps_t); i++)
+ {
+ pTapAddress[i] = 0;
+ }
+
+ /* Quasi-peak filters taps */
+ pTapAddress = (LVM_INT8 *)pInst->pQPD_Taps;
+ for(i = 0; i < pInst->nBands * sizeof(QPD_Taps_t); i++)
+ {
+ pTapAddress[i] = 0;
+ }
+
+ return(LVPSA_OK);
+}
+
diff --git a/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Init.c b/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Init.c
new file mode 100755
index 0000000..ab45678
--- /dev/null
+++ b/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Init.c
@@ -0,0 +1,197 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: PSA_01_ARMC_01 */
+/* $Author: beq07716 $*/
+/* $Revision: 1006 $*/
+/* $Date: 2010-06-28 14:01:47 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+#include "LVPSA.h"
+#include "LVPSA_Private.h"
+#include "InstAlloc.h"
+
+/************************************************************************************/
+/* */
+/* FUNCTION: LVPSA_Init */
+/* */
+/* DESCRIPTION: */
+/* Initialize the LVPSA module */
+/* */
+/* */
+/* PARAMETERS: */
+/* phInstance Pointer to pointer to the instance */
+/* InitParams Init parameters structure */
+/* ControlParams Control parameters structure */
+/* pMemoryTable Memory table that contains memory areas definition */
+/* */
+/* */
+/* RETURNS: */
+/* LVPSA_OK Succeeds */
+/* otherwise Error due to bad parameters */
+/* */
+/************************************************************************************/
+LVPSA_RETURN LVPSA_Init ( pLVPSA_Handle_t *phInstance,
+ LVPSA_InitParams_t *pInitParams,
+ LVPSA_ControlParams_t *pControlParams,
+ LVPSA_MemTab_t *pMemoryTable )
+{
+ LVPSA_InstancePr_t *pLVPSA_Inst;
+ LVPSA_RETURN errorCode = LVPSA_OK;
+ LVM_UINT32 ii;
+ extern LVM_INT16 LVPSA_GainTable[];
+ LVM_UINT32 BufferLength = 0;
+
+ /* Ints_Alloc instances, needed for memory alignment management */
+ INST_ALLOC Instance;
+ INST_ALLOC Scratch;
+ INST_ALLOC Data;
+ INST_ALLOC Coef;
+
+ /* Check parameters */
+ if((phInstance == LVM_NULL) || (pInitParams == LVM_NULL) || (pControlParams == LVM_NULL) || (pMemoryTable == LVM_NULL))
+ {
+ return(LVPSA_ERROR_NULLADDRESS);
+ }
+ if( (pInitParams->SpectralDataBufferDuration > LVPSA_MAXBUFFERDURATION) ||
+ (pInitParams->SpectralDataBufferDuration == 0) ||
+ (pInitParams->MaxInputBlockSize > LVPSA_MAXINPUTBLOCKSIZE) ||
+ (pInitParams->MaxInputBlockSize == 0) ||
+ (pInitParams->nBands < LVPSA_NBANDSMIN) ||
+ (pInitParams->nBands > LVPSA_NBANDSMAX) ||
+ (pInitParams->pFiltersParams == 0))
+ {
+ return(LVPSA_ERROR_INVALIDPARAM);
+ }
+ for(ii = 0; ii < pInitParams->nBands; ii++)
+ {
+ if((pInitParams->pFiltersParams[ii].CenterFrequency > LVPSA_MAXCENTERFREQ) ||
+ (pInitParams->pFiltersParams[ii].PostGain > LVPSA_MAXPOSTGAIN) ||
+ (pInitParams->pFiltersParams[ii].PostGain < LVPSA_MINPOSTGAIN) ||
+ (pInitParams->pFiltersParams[ii].QFactor < LVPSA_MINQFACTOR) ||
+ (pInitParams->pFiltersParams[ii].QFactor > LVPSA_MAXQFACTOR))
+ {
+ return(LVPSA_ERROR_INVALIDPARAM);
+ }
+ }
+
+
+ /*Inst_Alloc instances initialization */
+ InstAlloc_Init( &Instance , pMemoryTable->Region[LVPSA_MEMREGION_INSTANCE].pBaseAddress);
+ InstAlloc_Init( &Scratch , pMemoryTable->Region[LVPSA_MEMREGION_SCRATCH].pBaseAddress);
+ InstAlloc_Init( &Data , pMemoryTable->Region[LVPSA_MEMREGION_PERSISTENT_DATA].pBaseAddress);
+ InstAlloc_Init( &Coef , pMemoryTable->Region[LVPSA_MEMREGION_PERSISTENT_COEF].pBaseAddress);
+
+
+ /* Set the instance handle if not already initialised */
+ if (*phInstance == LVM_NULL)
+ {
+ *phInstance = InstAlloc_AddMember( &Instance, sizeof(LVPSA_InstancePr_t) );
+ }
+ pLVPSA_Inst =(LVPSA_InstancePr_t*)*phInstance;
+
+
+ /* Check the memory table for NULL pointers */
+ for (ii = 0; ii < LVPSA_NR_MEMORY_REGIONS; ii++)
+ {
+ if (pMemoryTable->Region[ii].Size!=0)
+ {
+ if (pMemoryTable->Region[ii].pBaseAddress==LVM_NULL)
+ {
+ return(LVPSA_ERROR_NULLADDRESS);
+ }
+ pLVPSA_Inst->MemoryTable.Region[ii] = pMemoryTable->Region[ii];
+ }
+ }
+
+ /* Initialize module's internal parameters */
+ pLVPSA_Inst->bControlPending = LVM_FALSE;
+ pLVPSA_Inst->nBands = pInitParams->nBands;
+ pLVPSA_Inst->MaxInputBlockSize = pInitParams->MaxInputBlockSize;
+ pLVPSA_Inst->SpectralDataBufferDuration = pInitParams->SpectralDataBufferDuration;
+ pLVPSA_Inst->CurrentParams.Fs = LVM_FS_DUMMY;
+ pLVPSA_Inst->CurrentParams.LevelDetectionSpeed = LVPSA_SPEED_DUMMY;
+
+ { /* for avoiding QAC warnings */
+ LVM_INT32 SDBD=(LVM_INT32)pLVPSA_Inst->SpectralDataBufferDuration;
+ LVM_INT32 IRTI=(LVM_INT32)LVPSA_InternalRefreshTimeInv;
+ LVM_INT32 BL;
+
+ MUL32x32INTO32(SDBD,IRTI,BL,LVPSA_InternalRefreshTimeShift)
+
+ BufferLength=(LVM_UINT32)BL;
+ }
+
+ if((BufferLength * LVPSA_InternalRefreshTime) != pLVPSA_Inst->SpectralDataBufferDuration)
+ {
+ pLVPSA_Inst->SpectralDataBufferLength = BufferLength + 1;
+ }
+ else
+ {
+ pLVPSA_Inst->SpectralDataBufferLength = BufferLength;
+ }
+
+
+ /* Assign the pointers */
+
+ pLVPSA_Inst->pPostGains = InstAlloc_AddMember( &Instance, pInitParams->nBands * sizeof(LVM_UINT16) );
+ pLVPSA_Inst->pFiltersParams = InstAlloc_AddMember( &Instance, pInitParams->nBands * sizeof(LVPSA_FilterParam_t) );
+ pLVPSA_Inst->pSpectralDataBufferStart = InstAlloc_AddMember( &Instance, pInitParams->nBands * pLVPSA_Inst->SpectralDataBufferLength * sizeof(LVM_UINT8) );
+ pLVPSA_Inst->pPreviousPeaks = InstAlloc_AddMember( &Instance, pInitParams->nBands * sizeof(LVM_UINT8) );
+ pLVPSA_Inst->pBPFiltersPrecision = InstAlloc_AddMember( &Instance, pInitParams->nBands * sizeof(LVPSA_BPFilterPrecision_en) );
+
+ pLVPSA_Inst->pBP_Instances = InstAlloc_AddMember( &Coef, pInitParams->nBands * sizeof(Biquad_Instance_t) );
+ pLVPSA_Inst->pQPD_States = InstAlloc_AddMember( &Coef, pInitParams->nBands * sizeof(QPD_State_t) );
+
+ pLVPSA_Inst->pBP_Taps = InstAlloc_AddMember( &Data, pInitParams->nBands * sizeof(Biquad_1I_Order2_Taps_t) );
+ pLVPSA_Inst->pQPD_Taps = InstAlloc_AddMember( &Data, pInitParams->nBands * sizeof(QPD_Taps_t) );
+
+
+ /* Copy filters parameters in the private instance */
+ for(ii = 0; ii < pLVPSA_Inst->nBands; ii++)
+ {
+ pLVPSA_Inst->pFiltersParams[ii] = pInitParams->pFiltersParams[ii];
+ }
+
+ /* Set Post filters gains*/
+ for(ii = 0; ii < pLVPSA_Inst->nBands; ii++)
+ {
+ pLVPSA_Inst->pPostGains[ii] =(LVM_UINT16) LVPSA_GainTable[pInitParams->pFiltersParams[ii].PostGain + 15];
+ }
+ pLVPSA_Inst->pSpectralDataBufferWritePointer = pLVPSA_Inst->pSpectralDataBufferStart;
+
+
+ /* Initialize control dependant internal parameters */
+ errorCode = LVPSA_Control (*phInstance, pControlParams);
+
+ if(errorCode!=0)
+ {
+ return errorCode;
+ }
+
+ errorCode = LVPSA_ApplyNewSettings (pLVPSA_Inst);
+
+ if(errorCode!=0)
+ {
+ return errorCode;
+ }
+
+ return(errorCode);
+}
+
diff --git a/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Memory.c b/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Memory.c
new file mode 100755
index 0000000..059cb4e
--- /dev/null
+++ b/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Memory.c
@@ -0,0 +1,177 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: PSA_01_ARMC_01 */
+/* $Author: beq07716 $*/
+/* $Revision: 1006 $*/
+/* $Date: 2010-06-28 14:01:47 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+#include "LVPSA.h"
+#include "LVPSA_Private.h"
+#include "InstAlloc.h"
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVEQNB_Memory */
+/* */
+/* DESCRIPTION: */
+/* This function is used for memory allocation and free. It can be called in */
+/* two ways: */
+/* */
+/* hInstance = NULL Returns the memory requirements */
+/* hInstance = Instance handle Returns the memory requirements and */
+/* allocated base addresses for the instance */
+/* */
+/* When this function is called for memory allocation (hInstance=NULL) the memory */
+/* base address pointers are NULL on return. */
+/* */
+/* When the function is called for free (hInstance = Instance Handle) the memory */
+/* table returns the allocated memory and base addresses used during initialisation. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance Handle */
+/* pMemoryTable Pointer to an empty memory definition table */
+/* InitParams Pointer to the instance init parameters */
+/* */
+/* RETURNS: */
+/* LVPSA_OK Succeeds */
+/* otherwise Error due to bad parameters */
+/* */
+/****************************************************************************************/
+LVPSA_RETURN LVPSA_Memory ( pLVPSA_Handle_t hInstance,
+ LVPSA_MemTab_t *pMemoryTable,
+ LVPSA_InitParams_t *pInitParams )
+{
+ LVM_UINT32 ii;
+ LVM_UINT32 BufferLength;
+ INST_ALLOC Instance;
+ INST_ALLOC Scratch;
+ INST_ALLOC Data;
+ INST_ALLOC Coef;
+ LVPSA_InstancePr_t *pLVPSA_Inst = (LVPSA_InstancePr_t*)hInstance;
+
+
+ InstAlloc_Init( &Instance , LVM_NULL);
+ InstAlloc_Init( &Scratch , LVM_NULL);
+ InstAlloc_Init( &Data , LVM_NULL);
+ InstAlloc_Init( &Coef , LVM_NULL);
+
+
+ if((pMemoryTable == LVM_NULL) || (pInitParams == LVM_NULL))
+ {
+ return(LVPSA_ERROR_NULLADDRESS);
+ }
+
+
+ /*
+ * Fill in the memory table
+ */
+ if (hInstance == LVM_NULL)
+ {
+
+ /* Check init parameter */
+ if( (pInitParams->SpectralDataBufferDuration > LVPSA_MAXBUFFERDURATION) ||
+ (pInitParams->SpectralDataBufferDuration == 0) ||
+ (pInitParams->MaxInputBlockSize > LVPSA_MAXINPUTBLOCKSIZE) ||
+ (pInitParams->MaxInputBlockSize == 0) ||
+ (pInitParams->nBands < LVPSA_NBANDSMIN) ||
+ (pInitParams->nBands > LVPSA_NBANDSMAX) ||
+ (pInitParams->pFiltersParams == 0))
+ {
+ return(LVPSA_ERROR_INVALIDPARAM);
+ }
+ for(ii = 0; ii < pInitParams->nBands; ii++)
+ {
+ if((pInitParams->pFiltersParams[ii].CenterFrequency > LVPSA_MAXCENTERFREQ) ||
+ (pInitParams->pFiltersParams[ii].PostGain > LVPSA_MAXPOSTGAIN) ||
+ (pInitParams->pFiltersParams[ii].PostGain < LVPSA_MINPOSTGAIN) ||
+ (pInitParams->pFiltersParams[ii].QFactor < LVPSA_MINQFACTOR) ||
+ (pInitParams->pFiltersParams[ii].QFactor > LVPSA_MAXQFACTOR))
+ {
+ return(LVPSA_ERROR_INVALIDPARAM);
+ }
+ }
+
+ /*
+ * Instance memory
+ */
+
+ InstAlloc_AddMember( &Instance, sizeof(LVPSA_InstancePr_t) );
+ InstAlloc_AddMember( &Instance, pInitParams->nBands * sizeof(LVM_UINT16) );
+ InstAlloc_AddMember( &Instance, pInitParams->nBands * sizeof(LVPSA_FilterParam_t) );
+
+ {
+ /* for avoiding QAC warnings as MUL32x32INTO32 works on LVM_INT32 only*/
+ LVM_INT32 SDBD=(LVM_INT32)pInitParams->SpectralDataBufferDuration;
+ LVM_INT32 IRTI=(LVM_INT32)LVPSA_InternalRefreshTimeInv;
+ LVM_INT32 BL;
+
+ MUL32x32INTO32(SDBD,IRTI,BL,LVPSA_InternalRefreshTimeShift)
+ BufferLength=(LVM_UINT32)BL;
+ }
+
+
+ if((BufferLength * LVPSA_InternalRefreshTime) != pInitParams->SpectralDataBufferDuration)
+ {
+ BufferLength++;
+ }
+ InstAlloc_AddMember( &Instance, pInitParams->nBands * BufferLength * sizeof(LVM_UINT8) );
+ InstAlloc_AddMember( &Instance, pInitParams->nBands * sizeof(LVM_UINT8) );
+ InstAlloc_AddMember( &Instance, pInitParams->nBands * sizeof(LVPSA_BPFilterPrecision_en) );
+ pMemoryTable->Region[LVPSA_MEMREGION_INSTANCE].Size = InstAlloc_GetTotal(&Instance);
+ pMemoryTable->Region[LVPSA_MEMREGION_INSTANCE].Type = LVPSA_PERSISTENT;
+ pMemoryTable->Region[LVPSA_MEMREGION_INSTANCE].pBaseAddress = LVM_NULL;
+
+ /*
+ * Scratch memory
+ */
+ InstAlloc_AddMember( &Scratch, 2 * pInitParams->MaxInputBlockSize * sizeof(LVM_INT16) );
+ pMemoryTable->Region[LVPSA_MEMREGION_SCRATCH].Size = InstAlloc_GetTotal(&Scratch);
+ pMemoryTable->Region[LVPSA_MEMREGION_SCRATCH].Type = LVPSA_SCRATCH;
+ pMemoryTable->Region[LVPSA_MEMREGION_SCRATCH].pBaseAddress = LVM_NULL;
+
+ /*
+ * Persistent coefficients memory
+ */
+ InstAlloc_AddMember( &Coef, pInitParams->nBands * sizeof(Biquad_Instance_t) );
+ InstAlloc_AddMember( &Coef, pInitParams->nBands * sizeof(QPD_State_t) );
+ pMemoryTable->Region[LVPSA_MEMREGION_PERSISTENT_COEF].Size = InstAlloc_GetTotal(&Coef);
+ pMemoryTable->Region[LVPSA_MEMREGION_PERSISTENT_COEF].Type = LVPSA_PERSISTENT_COEF;
+ pMemoryTable->Region[LVPSA_MEMREGION_PERSISTENT_COEF].pBaseAddress = LVM_NULL;
+
+ /*
+ * Persistent data memory
+ */
+ InstAlloc_AddMember( &Data, pInitParams->nBands * sizeof(Biquad_1I_Order2_Taps_t) );
+ InstAlloc_AddMember( &Data, pInitParams->nBands * sizeof(QPD_Taps_t) );
+ pMemoryTable->Region[LVPSA_MEMREGION_PERSISTENT_DATA].Size = InstAlloc_GetTotal(&Data);
+ pMemoryTable->Region[LVPSA_MEMREGION_PERSISTENT_DATA].Type = LVPSA_PERSISTENT_DATA;
+ pMemoryTable->Region[LVPSA_MEMREGION_PERSISTENT_DATA].pBaseAddress = LVM_NULL;
+
+ }
+ else
+ {
+ /* Read back memory allocation table */
+ *pMemoryTable = pLVPSA_Inst->MemoryTable;
+ }
+
+ return(LVPSA_OK);
+}
+
diff --git a/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Private.h b/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Private.h
new file mode 100755
index 0000000..eb9fa8f
--- /dev/null
+++ b/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Private.h
@@ -0,0 +1,159 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: PSA_01_ARMC_01 */
+/* $Author: beq07716 $*/
+/* $Revision: 1006 $*/
+/* $Date: 2010-06-28 14:01:47 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+#ifndef _LVPSA_PRIVATE_H_
+#define _LVPSA_PRIVATE_H_
+
+#include "LVPSA.h"
+#include "BIQUAD.h"
+#include "LVPSA_QPD.h"
+#include "LVM_Macros.h"
+
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**********************************************************************************
+ CONSTANT DEFINITIONS
+***********************************************************************************/
+
+/* Memory */
+#define LVPSA_INSTANCE_ALIGN 4 /* 32-bit alignment for structures */
+#define LVPSA_SCRATCH_ALIGN 4 /* 32-bit alignment for long data */
+#define LVPSA_COEF_ALIGN 4 /* 32-bit alignment for long words */
+#define LVPSA_DATA_ALIGN 4 /* 32-bit alignment for long data */
+
+#define LVPSA_MEMREGION_INSTANCE 0 /* Offset to instance memory region in memory table */
+#define LVPSA_MEMREGION_PERSISTENT_COEF 1 /* Offset to persistent coefficients memory region in memory table */
+#define LVPSA_MEMREGION_PERSISTENT_DATA 2 /* Offset to persistent taps memory region in memory table */
+#define LVPSA_MEMREGION_SCRATCH 3 /* Offset to scratch memory region in memory table */
+
+#define LVPSA_NR_SUPPORTED_RATE 9 /* From 8000Hz to 48000Hz */
+#define LVPSA_NR_SUPPORTED_SPEED 3 /* LOW, MEDIUM, HIGH */
+
+#define LVPSA_MAXBUFFERDURATION 4000 /* Maximum length in ms of the levels buffer */
+#define LVPSA_MAXINPUTBLOCKSIZE 5000 /* Maximum length in mono samples of the block to process */
+#define LVPSA_NBANDSMIN 1 /* Minimum number of frequency band */
+#define LVPSA_NBANDSMAX 30 /* Maximum number of frequency band */
+#define LVPSA_MAXCENTERFREQ 20000 /* Maximum possible center frequency */
+#define LVPSA_MINPOSTGAIN -15 /* Minimum possible post gain */
+#define LVPSA_MAXPOSTGAIN 15 /* Maximum possible post gain */
+#define LVPSA_MINQFACTOR 25 /* Minimum possible Q factor */
+#define LVPSA_MAXQFACTOR 1200 /* Maximum possible Q factor */
+
+#define LVPSA_MAXLEVELDECAYFACTOR 0x4111 /* Decay factor for the maximum values calculation */
+#define LVPSA_MAXLEVELDECAYSHIFT 14 /* Decay shift for the maximum values calculation */
+
+#define LVPSA_MAXUNSIGNEDCHAR 0xFF
+
+#define LVPSA_FsInvertShift 31
+#define LVPSA_GAINSHIFT 11
+#define LVPSA_FREQSHIFT 25
+
+/**********************************************************************************
+ TYPES DEFINITIONS
+***********************************************************************************/
+
+#define LVPSA_InternalRefreshTime 0x0014 /* 20 ms (50Hz) in Q16.0 */
+#define LVPSA_InternalRefreshTimeInv 0x0666 /* 1/20ms left shifted by 15 */
+#define LVPSA_InternalRefreshTimeShift 15
+
+
+/* Precision of the filter */
+typedef enum
+{
+ LVPSA_SimplePrecisionFilter, /* Simple precision */
+ LVPSA_DoublePrecisionFilter /* Double precision */
+} LVPSA_BPFilterPrecision_en;
+
+typedef struct
+{
+ LVM_CHAR bControlPending; /* Flag incating a change of the control parameters */
+ LVM_UINT16 nBands; /* Number of bands of the spectrum analyzer */
+ LVM_UINT16 MaxInputBlockSize; /* Maximum input data buffer size */
+
+ LVPSA_ControlParams_t CurrentParams; /* Current control parameters of the module */
+ LVPSA_ControlParams_t NewParams; /* New control parameters given by the user */
+ LVPSA_MemTab_t MemoryTable;
+
+ LVPSA_BPFilterPrecision_en *pBPFiltersPrecision; /* Points a nBands elements array that contains the filter precision for each band */
+ Biquad_Instance_t *pBP_Instances; /* Points a nBands elements array that contains the band pass filter instance for each band */
+ Biquad_1I_Order2_Taps_t *pBP_Taps; /* Points a nBands elements array that contains the band pass filter taps for each band */
+ QPD_State_t *pQPD_States; /* Points a nBands elements array that contains the QPD filter instance for each band */
+ QPD_Taps_t *pQPD_Taps; /* Points a nBands elements array that contains the QPD filter taps for each band */
+ LVM_UINT16 *pPostGains; /* Points a nBands elements array that contains the post-filter gains for each band */
+
+ LVPSA_FilterParam_t *pFiltersParams; /* Copy of the filters parameters from the input parameters */
+
+
+ LVM_UINT16 nSamplesBufferUpdate; /* Number of samples to make 20ms */
+ LVM_INT32 BufferUpdateSamplesCount; /* Counter used to know when to put a new value in the buffer */
+ LVM_UINT16 nRelevantFilters; /* Number of relevent filters depending on sampling frequency and bands center frequency */
+ LVM_UINT16 LocalSamplesCount; /* Counter used to update the SpectralDataBufferAudioTime */
+
+ LVM_UINT16 DownSamplingFactor; /* Down sampling factor depending on the sampling frequency */
+ LVM_UINT16 DownSamplingCount; /* Counter used for the downsampling handling */
+
+ LVM_UINT16 SpectralDataBufferDuration; /* Length of the buffer in time (ms) defined by the application */
+ LVM_UINT8 *pSpectralDataBufferStart; /* Starting address of the buffer */
+ LVM_UINT8 *pSpectralDataBufferWritePointer; /* Current position of the writting pointer of the buffer */
+ LVPSA_Time SpectralDataBufferAudioTime; /* AudioTime at which the last value save occured in the buffer */
+ LVM_UINT32 SpectralDataBufferLength; /* Number of spectrum data value that the buffer can contain (per band)
+ = SpectralDataBufferDuration/20ms */
+
+ LVM_UINT8 *pPreviousPeaks; /* Points to a nBands elements array that contains the previous peak value of the level
+ detection. Those values are decremented after each call to the GetSpectrum function */
+
+}LVPSA_InstancePr_t, *pLVPSA_InstancePr_t;
+
+
+
+/**********************************************************************************
+ FUNCTIONS PROTOTYPE
+***********************************************************************************/
+/************************************************************************************/
+/* */
+/* FUNCTION: LVPSA_ApplyNewSettings */
+/* */
+/* DESCRIPTION: */
+/* Reinitialize some parameters and changes filters' coefficients if */
+/* some control parameters have changed. */
+/* */
+/* PARAMETERS: */
+/* pInst Pointer to the instance */
+/* */
+/* RETURNS: */
+/* LVPSA_OK Always succeeds */
+/* */
+/************************************************************************************/
+LVPSA_RETURN LVPSA_ApplyNewSettings (LVPSA_InstancePr_t *pInst);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _LVPSA_PRIVATE_H */
diff --git a/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Process.c b/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Process.c
new file mode 100755
index 0000000..d88a751
--- /dev/null
+++ b/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Process.c
@@ -0,0 +1,260 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: PSA_01_ARMC_01 */
+/* $Author: beq07716 $*/
+/* $Revision: 1006 $*/
+/* $Date: 2010-06-28 14:01:47 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+#include "LVPSA.h"
+#include "LVPSA_Private.h"
+#include "LVM_Macros.h"
+#include "VectorArithmetic.h"
+
+#define LVM_MININT_32 0x80000000
+
+
+/************************************************************************************/
+/* */
+/* FUNCTION: LVPSA_Process */
+/* */
+/* DESCRIPTION: */
+/* The process applies band pass filters to the signal. Each output */
+/* feeds a quasi peak filter for level detection. */
+/* */
+/* PARAMETERS: */
+/* hInstance Pointer to the instance */
+/* pLVPSA_InputSamples Pointer to the input samples buffer */
+/* InputBlockSize Number of mono samples to process */
+/* AudioTime Playback time of the input samples */
+/* */
+/* */
+/* RETURNS: */
+/* LVPSA_OK Succeeds */
+/* otherwise Error due to bad parameters */
+/* */
+/************************************************************************************/
+LVPSA_RETURN LVPSA_Process ( pLVPSA_Handle_t hInstance,
+ LVM_INT16 *pLVPSA_InputSamples,
+ LVM_UINT16 InputBlockSize,
+ LVPSA_Time AudioTime )
+
+{
+ LVPSA_InstancePr_t *pLVPSA_Inst = (LVPSA_InstancePr_t*)hInstance;
+ LVM_INT16 *pScratch;
+ LVM_INT16 ii;
+ LVM_INT32 AudioTimeInc;
+ extern LVM_UINT32 LVPSA_SampleRateInvTab[];
+ LVM_UINT8 *pWrite_Save; /* Position of the write pointer at the beginning of the process */
+
+ /******************************************************************************
+ CHECK PARAMETERS
+ *******************************************************************************/
+ if(hInstance == LVM_NULL || pLVPSA_InputSamples == LVM_NULL)
+ {
+ return(LVPSA_ERROR_NULLADDRESS);
+ }
+ if(InputBlockSize == 0 || InputBlockSize > pLVPSA_Inst->MaxInputBlockSize)
+ {
+ return(LVPSA_ERROR_INVALIDPARAM);
+ }
+
+ pScratch = (LVM_INT16*)pLVPSA_Inst->MemoryTable.Region[LVPSA_MEMREGION_SCRATCH].pBaseAddress;
+ pWrite_Save = pLVPSA_Inst->pSpectralDataBufferWritePointer;
+
+ /******************************************************************************
+ APPLY NEW SETTINGS IF NEEDED
+ *******************************************************************************/
+ if (pLVPSA_Inst->bControlPending == LVM_TRUE)
+ {
+ pLVPSA_Inst->bControlPending = 0;
+ LVPSA_ApplyNewSettings( pLVPSA_Inst);
+ }
+
+ /******************************************************************************
+ PROCESS SAMPLES
+ *******************************************************************************/
+ /* Put samples in range [-0.5;0.5[ for BP filters (see Biquads documentation) */
+ Copy_16( pLVPSA_InputSamples,pScratch,(LVM_INT16)InputBlockSize);
+ Shift_Sat_v16xv16(-1,pScratch,pScratch,(LVM_INT16)InputBlockSize);
+
+ for (ii = 0; ii < pLVPSA_Inst->nRelevantFilters; ii++)
+ {
+ switch(pLVPSA_Inst->pBPFiltersPrecision[ii])
+ {
+ case LVPSA_SimplePrecisionFilter:
+ BP_1I_D16F16C14_TRC_WRA_01 ( &pLVPSA_Inst->pBP_Instances[ii],
+ pScratch,
+ pScratch + InputBlockSize,
+ (LVM_INT16)InputBlockSize);
+ break;
+
+ case LVPSA_DoublePrecisionFilter:
+ BP_1I_D16F32C30_TRC_WRA_01 ( &pLVPSA_Inst->pBP_Instances[ii],
+ pScratch,
+ pScratch + InputBlockSize,
+ (LVM_INT16)InputBlockSize);
+ break;
+ default:
+ break;
+ }
+
+
+ LVPSA_QPD_Process ( pLVPSA_Inst,
+ pScratch + InputBlockSize,
+ (LVM_INT16)InputBlockSize,
+ ii);
+ }
+
+ /******************************************************************************
+ UPDATE SpectralDataBufferAudioTime
+ *******************************************************************************/
+
+ if(pLVPSA_Inst->pSpectralDataBufferWritePointer != pWrite_Save)
+ {
+ MUL32x32INTO32((AudioTime + (LVM_INT32)((LVM_INT32)pLVPSA_Inst->LocalSamplesCount*1000)),
+ (LVM_INT32)LVPSA_SampleRateInvTab[pLVPSA_Inst->CurrentParams.Fs],
+ AudioTimeInc,
+ LVPSA_FsInvertShift)
+ pLVPSA_Inst->SpectralDataBufferAudioTime = AudioTime + AudioTimeInc;
+ }
+
+ return(LVPSA_OK);
+}
+
+
+/************************************************************************************/
+/* */
+/* FUNCTION: LVPSA_GetSpectrum */
+/* */
+/* DESCRIPTION: */
+/* Gets the levels values at a certain point in time */
+/* */
+/* */
+/* PARAMETERS: */
+/* hInstance Pointer to the instance */
+/* GetSpectrumAudioTime Retrieve the values at this time */
+/* pCurrentValues Pointer to a buffer that will contain levels' values */
+/* pMaxValues Pointer to a buffer that will contain max levels' values */
+/* */
+/* */
+/* RETURNS: */
+/* LVPSA_OK Succeeds */
+/* otherwise Error due to bad parameters */
+/* */
+/************************************************************************************/
+LVPSA_RETURN LVPSA_GetSpectrum ( pLVPSA_Handle_t hInstance,
+ LVPSA_Time GetSpectrumAudioTime,
+ LVM_UINT8 *pCurrentValues,
+ LVM_UINT8 *pPeakValues )
+
+{
+
+ LVPSA_InstancePr_t *pLVPSA_Inst = (LVPSA_InstancePr_t*)hInstance;
+ LVM_INT32 StatusDelta, ii;
+ LVM_UINT8 *pRead;
+
+ if(hInstance == LVM_NULL || pCurrentValues == LVM_NULL || pPeakValues == LVM_NULL)
+ {
+ return(LVPSA_ERROR_NULLADDRESS);
+ }
+
+
+ /* First find the place where to look in the status buffer */
+ if(GetSpectrumAudioTime <= pLVPSA_Inst->SpectralDataBufferAudioTime)
+ {
+ MUL32x32INTO32((pLVPSA_Inst->SpectralDataBufferAudioTime - GetSpectrumAudioTime),LVPSA_InternalRefreshTimeInv,StatusDelta,LVPSA_InternalRefreshTimeShift);
+ if((StatusDelta * LVPSA_InternalRefreshTime) != (pLVPSA_Inst->SpectralDataBufferAudioTime - GetSpectrumAudioTime))
+ {
+ StatusDelta += 1;
+ }
+ }
+ else
+ {
+ /* This part handles the wrap around */
+ MUL32x32INTO32(((pLVPSA_Inst->SpectralDataBufferAudioTime - (LVM_INT32)LVM_MININT_32) + ((LVM_INT32)LVM_MAXINT_32 - GetSpectrumAudioTime)),LVPSA_InternalRefreshTimeInv,StatusDelta,LVPSA_InternalRefreshTimeShift)
+ if(((LVM_INT32)(StatusDelta * LVPSA_InternalRefreshTime)) != ((LVM_INT32)((pLVPSA_Inst->SpectralDataBufferAudioTime - (LVM_INT32)LVM_MININT_32) + ((LVM_INT32)LVM_MAXINT_32 - GetSpectrumAudioTime))))
+ {
+ StatusDelta += 1;
+ }
+ }
+ /* Check whether the desired level is not too "old" (see 2.10 in LVPSA_DesignNotes.doc)*/
+ if(
+ ((GetSpectrumAudioTime < pLVPSA_Inst->SpectralDataBufferAudioTime)&&
+ ((GetSpectrumAudioTime<0)&&(pLVPSA_Inst->SpectralDataBufferAudioTime>0))&&
+ (((LVM_INT32)(-GetSpectrumAudioTime + pLVPSA_Inst->SpectralDataBufferAudioTime))>LVM_MAXINT_32))||
+
+ ((GetSpectrumAudioTime > pLVPSA_Inst->SpectralDataBufferAudioTime)&&
+ (((GetSpectrumAudioTime>=0)&&(pLVPSA_Inst->SpectralDataBufferAudioTime>=0))||
+ ((GetSpectrumAudioTime<=0)&&(pLVPSA_Inst->SpectralDataBufferAudioTime<=0))||
+ (((GetSpectrumAudioTime>=0)&&(pLVPSA_Inst->SpectralDataBufferAudioTime<=0))&&
+ (((LVM_INT32)(GetSpectrumAudioTime - pLVPSA_Inst->SpectralDataBufferAudioTime))<LVM_MAXINT_32))))||
+
+ (StatusDelta > (LVM_INT32)pLVPSA_Inst->SpectralDataBufferLength) ||
+ (!StatusDelta))
+ {
+ for(ii = 0; ii < pLVPSA_Inst->nBands; ii++)
+ {
+ pCurrentValues[ii] = 0;
+ pPeakValues[ii] = 0;
+ }
+ return(LVPSA_OK);
+ }
+ /* Set the reading pointer */
+ if((LVM_INT32)(StatusDelta * pLVPSA_Inst->nBands) > (pLVPSA_Inst->pSpectralDataBufferWritePointer - pLVPSA_Inst->pSpectralDataBufferStart))
+ {
+ pRead = pLVPSA_Inst->pSpectralDataBufferWritePointer + (pLVPSA_Inst->SpectralDataBufferLength - (LVM_UINT32)StatusDelta) * pLVPSA_Inst->nBands;
+ }
+ else
+ {
+ pRead = pLVPSA_Inst->pSpectralDataBufferWritePointer - StatusDelta * pLVPSA_Inst->nBands;
+ }
+
+
+ /* Read the status buffer and fill the output buffers */
+ for(ii = 0; ii < pLVPSA_Inst->nBands; ii++)
+ {
+ pCurrentValues[ii] = pRead[ii];
+ if(pLVPSA_Inst->pPreviousPeaks[ii] <= pRead[ii])
+ {
+ pLVPSA_Inst->pPreviousPeaks[ii] = pRead[ii];
+ }
+ else if(pLVPSA_Inst->pPreviousPeaks[ii] != 0)
+ {
+ LVM_INT32 temp;
+ /*Re-compute max values for decay */
+ temp = (LVM_INT32)(LVPSA_MAXUNSIGNEDCHAR - pLVPSA_Inst->pPreviousPeaks[ii]);
+ temp = ((temp * LVPSA_MAXLEVELDECAYFACTOR)>>LVPSA_MAXLEVELDECAYSHIFT);
+ /* If the gain has no effect, "help" the value to increase */
+ if(temp == (LVPSA_MAXUNSIGNEDCHAR - pLVPSA_Inst->pPreviousPeaks[ii]))
+ {
+ temp += 1;
+ }
+ /* Saturate */
+ temp = (temp > LVPSA_MAXUNSIGNEDCHAR) ? LVPSA_MAXUNSIGNEDCHAR : temp;
+ /* Store new max level */
+ pLVPSA_Inst->pPreviousPeaks[ii] = (LVM_UINT8)(LVPSA_MAXUNSIGNEDCHAR - temp);
+ }
+
+ pPeakValues[ii] = pLVPSA_Inst->pPreviousPeaks[ii];
+ }
+
+ return(LVPSA_OK);
+}
diff --git a/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_QPD.h b/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_QPD.h
new file mode 100755
index 0000000..641357e
--- /dev/null
+++ b/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_QPD.h
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: PSA_01_ARMC_01 */
+/* $Author: beq07716 $*/
+/* $Revision: 1006 $*/
+/* $Date: 2010-06-28 14:01:47 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+#ifndef _LVPSA_QPD_H_
+#define _LVPSA_QPD_H_
+
+#include "LVM_Types.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+typedef struct
+{
+ LVM_INT32 *pDelay; /* pointer to the delayed samples (data of 32 bits) */
+ LVM_INT32 Coefs[2]; /* pointer to the filter coefficients */
+}QPD_State_t, *pQPD_State_t;
+
+typedef struct
+{
+ LVM_INT32 KP; /*should store a0*/
+ LVM_INT32 KM; /*should store b2*/
+
+} QPD_C32_Coefs, *PQPD_C32_Coefs;
+
+typedef struct
+{
+ LVM_INT32 Storage[1];
+
+} QPD_Taps_t, *pQPD_Taps_t;
+
+/************************************************************************************/
+/* */
+/* FUNCTION: LVPSA_QPD_Process */
+/* */
+/* DESCRIPTION: */
+/* Apply downsampling, post gain, quasi peak filtering and write the levels values */
+/* in the buffer every 20 ms. */
+/* */
+/* PARAMETERS: */
+/* */
+/* RETURNS: void */
+/* */
+/************************************************************************************/
+void LVPSA_QPD_Process ( void *hInstance,
+ LVM_INT16 *pInSamps,
+ LVM_INT16 numSamples,
+ LVM_INT16 BandIndex);
+
+/************************************************************************************/
+/* */
+/* FUNCTION: LVPSA_QPD_Init */
+/* */
+/* DESCRIPTION: */
+/* Initialize a quasi peak filter instance. */
+/* */
+/* PARAMETERS: */
+/* pInstance Pointer to the instance */
+/* pTaps Pointer to the filter's taps */
+/* pCoef Pointer to the filter's coefficients */
+/* */
+/* RETURNS: void */
+/* */
+/************************************************************************************/
+void LVPSA_QPD_Init ( QPD_State_t *pInstance,
+ QPD_Taps_t *pTaps,
+ QPD_C32_Coefs *pCoef );
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif
+
diff --git a/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_QPD_Init.c b/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_QPD_Init.c
new file mode 100755
index 0000000..37abe40
--- /dev/null
+++ b/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_QPD_Init.c
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: PSA_01_ARMC_01 */
+/* $Author: beq07716 $*/
+/* $Revision: 1006 $*/
+/* $Date: 2010-06-28 14:01:47 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+#include "LVPSA_QPD.h"
+
+/************************************************************************************/
+/* */
+/* FUNCTION: LVPSA_QPD_Init */
+/* */
+/* DESCRIPTION: */
+/* Initialize a quasi peak filter instance. */
+/* */
+/* PARAMETERS: */
+/* pQPD_State Pointer to the filter state */
+/* pTaps Pointer to the filter's taps */
+/* pCoef Pointer to the filter's coefficients */
+/* */
+/* RETURNS: void */
+/* */
+/************************************************************************************/
+void LVPSA_QPD_Init ( pQPD_State_t pQPD_State,
+ QPD_Taps_t *pTaps,
+ QPD_C32_Coefs *pCoef )
+{
+ pQPD_State->pDelay = pTaps->Storage;
+ pQPD_State->Coefs[0] = pCoef->KP;
+ pQPD_State->Coefs[1] = pCoef->KM;
+}
diff --git a/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_QPD_Process.c b/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_QPD_Process.c
new file mode 100755
index 0000000..7087475
--- /dev/null
+++ b/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_QPD_Process.c
@@ -0,0 +1,220 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: PSA_01_ARMC_01 */
+/* $Author: beq07716 $*/
+/* $Revision: 1006 $*/
+/* $Date: 2010-06-28 14:01:47 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+#include "LVPSA_QPD.h"
+#include "LVPSA_Private.h"
+
+/************************************************************************************/
+/* */
+/* FUNCTION: LVPSA_QPD_WritePeak */
+/* */
+/* DESCRIPTION: */
+/* Write a level value in the buffer in the corresponding band. */
+/* */
+/* PARAMETERS: */
+/* pInst Pointer to the LVPSA instance */
+/* ppWrite Pointer to pointer to the buffer */
+/* CallNumber Number of the band the value should be written in */
+/* Value Value to write in the buffer */
+/* */
+/* RETURNS: void */
+/* */
+/************************************************************************************/
+void LVPSA_QPD_WritePeak( pLVPSA_InstancePr_t pLVPSA_Inst,
+ LVM_UINT8 **ppWrite,
+ LVM_INT16 BandIndex,
+ LVM_INT16 Value );
+
+
+
+/************************************************************************************/
+/* */
+/* FUNCTION: LVPSA_QPD_Process */
+/* */
+/* DESCRIPTION: */
+/* Apply downsampling, post gain, quasi peak filtering and write the levels values */
+/* in the buffer every 20 ms. */
+/* */
+/* PARAMETERS: */
+/* */
+/* RETURNS: void */
+/* */
+/************************************************************************************/
+void LVPSA_QPD_Process ( void *hInstance,
+ LVM_INT16 *pInSamps,
+ LVM_INT16 numSamples,
+ LVM_INT16 BandIndex)
+{
+
+ /******************************************************************************
+ PARAMETERS
+ *******************************************************************************/
+ LVPSA_InstancePr_t *pLVPSA_Inst = (LVPSA_InstancePr_t*)hInstance;
+ QPD_State_t *pQPDState = (QPD_State_t*)&pLVPSA_Inst->pQPD_States[BandIndex];
+
+ /* Pointer to taps */
+ LVM_INT32* pDelay = pQPDState->pDelay;
+
+ /* Parameters needed during quasi peak calculations */
+ LVM_INT32 X0;
+ LVM_INT32 temp,temp2;
+ LVM_INT32 accu;
+ LVM_INT16 Xg0;
+ LVM_INT16 D0;
+ LVM_INT16 V0 = (LVM_INT16)(*pDelay);
+
+ /* Filter's coef */
+ LVM_INT32 Kp = pQPDState->Coefs[0];
+ LVM_INT32 Km = pQPDState->Coefs[1];
+
+ LVM_INT16 ii = numSamples;
+
+ LVM_UINT8 *pWrite = pLVPSA_Inst->pSpectralDataBufferWritePointer;
+ LVM_INT32 BufferUpdateSamplesCount = pLVPSA_Inst->BufferUpdateSamplesCount;
+ LVM_UINT16 DownSamplingFactor = pLVPSA_Inst->DownSamplingFactor;
+
+ /******************************************************************************
+ INITIALIZATION
+ *******************************************************************************/
+ /* Correct the pointer to take the first down sampled signal sample */
+ pInSamps += pLVPSA_Inst->DownSamplingCount;
+ /* Correct also the number of samples */
+ ii = (LVM_INT16)(ii - (LVM_INT16)pLVPSA_Inst->DownSamplingCount);
+
+ while (ii > 0)
+ {
+ /* Apply post gain */
+ X0 = ((*pInSamps) * pLVPSA_Inst->pPostGains[BandIndex]) >> (LVPSA_GAINSHIFT-1); /* - 1 to compensate scaling in process function*/
+ pInSamps = pInSamps + DownSamplingFactor;
+
+ /* Saturate and take absolute value */
+ if(X0 < 0)
+ X0 = -X0;
+ if (X0 > 0x7FFF)
+ Xg0 = 0x7FFF;
+ else
+ Xg0 = (LVM_INT16)(X0);
+
+
+ /* Quasi peak filter calculation */
+ D0 = (LVM_INT16)(Xg0 - V0);
+
+ temp2 = (LVM_INT32)D0;
+ MUL32x32INTO32(temp2,Kp,accu,31);
+
+ D0 = (LVM_INT16)(D0>>1);
+ if (D0 < 0){
+ D0 = (LVM_INT16)(-D0);
+ }
+
+ temp2 = (LVM_INT32)D0;
+ MUL32x32INTO32((LVM_INT32)D0,Km,temp,31);
+ accu +=temp + Xg0;
+
+ if (accu > 0x7FFF)
+ accu = 0x7FFF;
+ else if(accu < 0)
+ accu = 0x0000;
+
+ V0 = (LVM_INT16)accu;
+
+ if(((pLVPSA_Inst->nSamplesBufferUpdate - BufferUpdateSamplesCount) < DownSamplingFactor))
+ {
+ LVPSA_QPD_WritePeak( pLVPSA_Inst,
+ &pWrite,
+ BandIndex,
+ V0);
+ BufferUpdateSamplesCount -= pLVPSA_Inst->nSamplesBufferUpdate;
+ pLVPSA_Inst->LocalSamplesCount = (LVM_UINT16)(numSamples - ii);
+ }
+ BufferUpdateSamplesCount+=DownSamplingFactor;
+
+ ii = (LVM_INT16)(ii-DownSamplingFactor);
+
+ }
+
+ /* Store last taps in memory */
+ *pDelay = (LVM_INT32)(V0);
+
+ /* If this is the last call to the function after last band processing,
+ update the parameters. */
+ if(BandIndex == (pLVPSA_Inst->nRelevantFilters-1))
+ {
+ pLVPSA_Inst->pSpectralDataBufferWritePointer = pWrite;
+ /* Adjustment for 11025Hz input, 220,5 is normally
+ the exact number of samples for 20ms.*/
+ if((pLVPSA_Inst->pSpectralDataBufferWritePointer != pWrite)&&(pLVPSA_Inst->CurrentParams.Fs == LVM_FS_11025))
+ {
+ if(pLVPSA_Inst->nSamplesBufferUpdate == 220)
+ {
+ pLVPSA_Inst->nSamplesBufferUpdate = 221;
+ }
+ else
+ {
+ pLVPSA_Inst->nSamplesBufferUpdate = 220;
+ }
+ }
+ pLVPSA_Inst->pSpectralDataBufferWritePointer = pWrite;
+ pLVPSA_Inst->BufferUpdateSamplesCount = BufferUpdateSamplesCount;
+ pLVPSA_Inst->DownSamplingCount = (LVM_UINT16)(-ii);
+ }
+}
+
+/************************************************************************************/
+/* */
+/* FUNCTION: LVPSA_QPD_WritePeak */
+/* */
+/* DESCRIPTION: */
+/* Write a level value in the spectrum data buffer in the corresponding band. */
+/* */
+/* PARAMETERS: */
+/* pLVPSA_Inst Pointer to the LVPSA instance */
+/* ppWrite Pointer to pointer to the buffer */
+/* CallNumber Number of the band the value should be written in */
+/* Value Value to write in the spectrum data buffer */
+/* */
+/* RETURNS: void */
+/* */
+/************************************************************************************/
+void LVPSA_QPD_WritePeak( pLVPSA_InstancePr_t pLVPSA_Inst,
+ LVM_UINT8 **ppWrite,
+ LVM_INT16 BandIndex,
+ LVM_INT16 Value )
+{
+ LVM_UINT8 *pWrite = *ppWrite;
+
+
+ /* Write the value and update the write pointer */
+ *(pWrite + BandIndex) = (LVM_UINT8)(Value>>7);
+ pWrite += pLVPSA_Inst->nBands;
+ if (pWrite == (pLVPSA_Inst->pSpectralDataBufferStart + pLVPSA_Inst->nBands * pLVPSA_Inst->SpectralDataBufferLength))
+ {
+ pWrite = pLVPSA_Inst->pSpectralDataBufferStart;
+ }
+
+ *ppWrite = pWrite;
+
+}
+
diff --git a/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Tables.c b/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Tables.c
new file mode 100755
index 0000000..f4a35c5
--- /dev/null
+++ b/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Tables.c
@@ -0,0 +1,250 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************/
+/* */
+/* Project:: PSA_01_ARMC_01 */
+/* $Author: beq07716 $*/
+/* $Revision: 1006 $*/
+/* $Date: 2010-06-28 14:01:47 +0200 (Mon, 28 Jun 2010) $*/
+/* */
+/************************************************************************/
+
+
+/************************************************************************************/
+/* */
+/* Includes */
+/* */
+/************************************************************************************/
+
+#include "LVPSA.h"
+#include "LVPSA_QPD.h"
+/************************************************************************************/
+/* */
+/* Sample rate table */
+/* */
+/************************************************************************************/
+
+/*
+ * Sample rate table for converting between the enumerated type and the actual
+ * frequency
+ */
+const LVM_UINT16 LVPSA_SampleRateTab[] = { 8000, /* 8kS/s */
+ 11025,
+ 12000,
+ 16000,
+ 22050,
+ 24000,
+ 32000,
+ 44100,
+ 48000}; /* 48kS/s */
+
+/************************************************************************************/
+/* */
+/* Sample rate inverse table */
+/* */
+/************************************************************************************/
+
+/*
+ * Sample rate table for converting between the enumerated type and the actual
+ * frequency
+ */
+const LVM_UINT32 LVPSA_SampleRateInvTab[] = { 268435, /* 8kS/s */
+ 194783,
+ 178957,
+ 134218,
+ 97391,
+ 89478,
+ 67109,
+ 48696,
+ 44739}; /* 48kS/s */
+
+
+
+/************************************************************************************/
+/* */
+/* Number of samples in 20ms */
+/* */
+/************************************************************************************/
+
+/*
+ * Table for converting between the enumerated type and the number of samples
+ * during 20ms
+ */
+const LVM_UINT16 LVPSA_nSamplesBufferUpdate[] = { 160, /* 8kS/s */
+ 220,
+ 240,
+ 320,
+ 441,
+ 480,
+ 640,
+ 882,
+ 960}; /* 48kS/s */
+/************************************************************************************/
+/* */
+/* Down sampling factors */
+/* */
+/************************************************************************************/
+
+/*
+ * Table for converting between the enumerated type and the down sampling factor
+ */
+const LVM_UINT16 LVPSA_DownSamplingFactor[] = { 5, /* 8000 S/s */
+ 7, /* 11025 S/s */
+ 8, /* 12000 S/s */
+ 10, /* 16000 S/s */
+ 15, /* 22050 S/s */
+ 16, /* 24000 S/s */
+ 21, /* 32000 S/s */
+ 30, /* 44100 S/s */
+ 32}; /* 48000 S/s */
+
+
+/************************************************************************************/
+/* */
+/* Coefficient calculation tables */
+/* */
+/************************************************************************************/
+
+/*
+ * Table for 2 * Pi / Fs
+ */
+const LVM_INT16 LVPSA_TwoPiOnFsTable[] = { 26354, /* 8kS/s */
+ 19123,
+ 17569,
+ 13177,
+ 9561,
+ 8785,
+ 6588,
+ 4781,
+ 4392}; /* 48kS/s */
+
+/*
+ * Gain table
+ */
+const LVM_INT16 LVPSA_GainTable[] = { 364, /* -15dB gain */
+ 408,
+ 458,
+ 514,
+ 577,
+ 647,
+ 726,
+ 815,
+ 914,
+ 1026,
+ 1151,
+ 1292,
+ 1449,
+ 1626,
+ 1825,
+ 2048, /* 0dB gain */
+ 2297,
+ 2578,
+ 2892,
+ 3245,
+ 3641,
+ 4096,
+ 4584,
+ 5144,
+ 5772,
+ 6476,
+ 7266,
+ 8153,
+ 9148,
+ 10264,
+ 11576}; /* +15dB gain */
+
+/************************************************************************************/
+/* */
+/* Cosone polynomial coefficients */
+/* */
+/************************************************************************************/
+
+/*
+ * Coefficients for calculating the cosine with the equation:
+ *
+ * Cos(x) = (2^Shifts)*(a0 + a1*x + a2*x^2 + a3*x^3 + a4*x^4 + a5*x^5)
+ *
+ * These coefficients expect the input, x, to be in the range 0 to 32768 respresenting
+ * a range of 0 to Pi. The output is in the range 32767 to -32768 representing the range
+ * +1.0 to -1.0
+ */
+const LVM_INT16 LVPSA_CosCoef[] = { 3, /* Shifts */
+ 4096, /* a0 */
+ -36, /* a1 */
+ -19725, /* a2 */
+ -2671, /* a3 */
+ 23730, /* a4 */
+ -9490}; /* a5 */
+
+/*
+ * Coefficients for calculating the cosine error with the equation:
+ *
+ * CosErr(x) = (2^Shifts)*(a0 + a1*x + a2*x^2 + a3*x^3)
+ *
+ * These coefficients expect the input, x, to be in the range 0 to 32768 respresenting
+ * a range of 0 to Pi/25. The output is in the range 0 to 32767 representing the range
+ * 0.0 to 0.0078852986
+ *
+ * This is used to give a double precision cosine over the range 0 to Pi/25 using the
+ * the equation:
+ *
+ * Cos(x) = 1.0 - CosErr(x)
+ */
+const LVM_INT16 LVPSA_DPCosCoef[] = { 1, /* Shifts */
+ 0, /* a0 */
+ -6, /* a1 */
+ 16586, /* a2 */
+ -44}; /* a3 */
+
+/************************************************************************************/
+/* */
+/* Quasi peak filter coefficients table */
+/* */
+/************************************************************************************/
+const QPD_C32_Coefs LVPSA_QPD_Coefs[] = {
+
+ {0x80CEFD2B,0x00CB9B17}, /* 8kS/s */ /* LVPSA_SPEED_LOW */
+ {0x80D242E7,0x00CED11D},
+ {0x80DCBAF5,0x00D91679},
+ {0x80CEFD2B,0x00CB9B17},
+ {0x80E13739,0x00DD7CD3},
+ {0x80DCBAF5,0x00D91679},
+ {0x80D94BAF,0x00D5B7E7},
+ {0x80E13739,0x00DD7CD3},
+ {0x80DCBAF5,0x00D91679}, /* 48kS/s */
+
+ {0x8587513D,0x055C22CF}, /* 8kS/s */ /* LVPSA_SPEED_MEDIUM */
+ {0x859D2967,0x0570F007},
+ {0x85E2EFAC,0x05B34D79},
+ {0x8587513D,0x055C22CF},
+ {0x8600C7B9,0x05CFA6CF},
+ {0x85E2EFAC,0x05B34D79},
+ {0x85CC1018,0x059D8F69},
+ {0x8600C7B9,0x05CFA6CF},//{0x8600C7B9,0x05CFA6CF},
+ {0x85E2EFAC,0x05B34D79}, /* 48kS/s */
+
+ {0xA115EA7A,0x1CDB3F5C}, /* 8kS/s */ /* LVPSA_SPEED_HIGH */
+ {0xA18475F0,0x1D2C83A2},
+ {0xA2E1E950,0x1E2A532E},
+ {0xA115EA7A,0x1CDB3F5C},
+ {0xA375B2C6,0x1E943BBC},
+ {0xA2E1E950,0x1E2A532E},
+ {0xA26FF6BD,0x1DD81530},
+ {0xA375B2C6,0x1E943BBC},
+ {0xA2E1E950,0x1E2A532E}}; /* 48kS/s */
+
diff --git a/media/libeffects/lvm/lib/StereoWidening/lib/LVCS.h b/media/libeffects/lvm/lib/StereoWidening/lib/LVCS.h
new file mode 100755
index 0000000..1ab45cc
--- /dev/null
+++ b/media/libeffects/lvm/lib/StereoWidening/lib/LVCS.h
@@ -0,0 +1,396 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/****************************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1001 $
+ $Date: 2010-06-28 13:23:02 +0200 (Mon, 28 Jun 2010) $
+
+*****************************************************************************************/
+
+/****************************************************************************************/
+/* */
+/* Header file for the application layer interface of Concert Sound and Concert */
+/* Sound EX. */
+/* */
+/* This files includes all definitions, types, structures and function */
+/* prototypes required by the calling layer. All other types, structures and */
+/* functions are private. */
+/* */
+/****************************************************************************************/
+/* */
+/* Note: 1 */
+/* ======= */
+/* The algorithm can execute either with separate input and output buffers or with */
+/* a common buffer, i.e. the data is processed in-place. If the buffers are the */
+/* same then the MIPs will be slightly higher and an extra stereo scratch buffer is */
+/* required. */
+/* */
+/****************************************************************************************/
+/* */
+/* Note: 2 */
+/* ======= */
+/* Two data formats are support Stereo and Mono-In-Stereo. The data is interleaved as */
+/* follows: */
+/* Byte Offset Stereo Input Mono-In-Stereo Input */
+/* =========== ============ ==================== */
+/* 0 Left Sample #1 Mono Sample #1 */
+/* 2 Right Sample #1 Mono Sample #1 */
+/* 4 Left Sample #2 Mono Sample #2 */
+/* 6 Right Sample #2 Mono Sample #2 */
+/* . . . */
+/* . . . */
+/* */
+/* Mono format data is not supported, the calling routine must convert a Mono stream */
+/* in to Mono-In-Stereo format. */
+/* */
+/****************************************************************************************/
+
+#ifndef LVCS_H
+#define LVCS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/****************************************************************************************/
+/* */
+/* Includes */
+/* */
+/****************************************************************************************/
+
+#include "LVM_Types.h"
+#include "LVM_Common.h"
+
+
+/****************************************************************************************/
+/* */
+/* Definitions */
+/* */
+/****************************************************************************************/
+
+/* Memory table */
+#define LVCS_MEMREGION_PERSISTENT_SLOW_DATA 0 /* Offset to the instance memory region */
+#define LVCS_MEMREGION_PERSISTENT_FAST_DATA 1 /* Offset to the persistent data memory region */
+#define LVCS_MEMREGION_PERSISTENT_FAST_COEF 2 /* Offset to the persistent coefficient memory region */
+#define LVCS_MEMREGION_TEMPORARY_FAST 3 /* Offset to temporary memory region */
+#define LVCS_NR_MEMORY_REGIONS 4 /* Number of memory regions */
+
+/* Effect Level */
+#define LVCS_EFFECT_LOW 16384 /* Effect scaling 50% */
+#define LVCS_EFFECT_MEDIUM 24576 /* Effect scaling 75% */
+#define LVCS_EFFECT_HIGH 32767 /* Effect Scaling 100% */
+
+/* Callback events */
+#define LVCS_EVENT_NONE 0x0000 /* Not a valid event */
+#define LVCS_EVENT_ALGOFF 0x0001 /* CS has completed switch off */
+
+
+/****************************************************************************************/
+/* */
+/* Types */
+/* */
+/****************************************************************************************/
+
+/* Instance handle */
+typedef void *LVCS_Handle_t;
+
+
+/* Operating modes */
+typedef enum
+{
+ LVCS_OFF = 0,
+ LVCS_ON = 15,
+ LVCS_MAX = LVM_MAXENUM
+} LVCS_Modes_en;
+
+
+/* Memory Types */
+typedef enum
+{
+ LVCS_SCRATCH = 0,
+ LVCS_DATA = 1,
+ LVCS_COEFFICIENT = 2,
+ LVCS_PERSISTENT = 3,
+ LVCS_MEMORYTYPE_MAX = LVM_MAXENUM
+} LVCS_MemoryTypes_en;
+
+
+/* Function return status */
+typedef enum
+{
+ LVCS_SUCCESS = 0, /* Successful return from a routine */
+ LVCS_ALIGNMENTERROR = 1, /* Memory alignment error */
+ LVCS_NULLADDRESS = 2, /* NULL allocation address */
+ LVCS_TOOMANYSAMPLES = 3, /* Maximum block size exceeded */
+ LVCS_INVALIDBUFFER = 4, /* Invalid buffer processing request */
+ LVCS_STATUSMAX = LVM_MAXENUM
+} LVCS_ReturnStatus_en;
+
+
+/*
+ * Source data formats
+ */
+typedef enum
+{
+ LVCS_STEREO = 0,
+ LVCS_MONOINSTEREO = 1,
+ LVCS_SOURCEMAX = LVM_MAXENUM
+} LVCS_SourceFormat_en;
+
+
+/*
+ * Supported output devices
+ */
+typedef enum
+{
+ LVCS_HEADPHONES = 0,
+ LVCS_EX_HEADPHONES = 1,
+ LVCS_SPEAKERTYPE_MAX = LVM_MAXENUM
+} LVCS_SpeakerType_en;
+
+/*
+ * Speaker Coefficients Table
+ */
+typedef struct
+{
+ void *pTable1;
+ void *pTable2;
+ void *pTable3;
+ void *pTable4;
+ void *pTable5;
+ void *pTable6;
+ void *pTable7;
+ void *pTable8;
+} LVCS_CSMS_Coef_Tables_t;
+
+
+/****************************************************************************************/
+/* */
+/* Structures */
+/* */
+/****************************************************************************************/
+
+/* Memory region definition */
+typedef struct
+{
+ LVM_UINT32 Size; /* Region size in bytes */
+ LVCS_MemoryTypes_en Type; /* Region type */
+ void *pBaseAddress; /* Pointer to the region base address */
+} LVCS_MemoryRegion_t;
+
+
+/* Memory table containing the region definitions */
+typedef struct
+{
+ LVCS_MemoryRegion_t Region[LVCS_NR_MEMORY_REGIONS]; /* One definition for each region */
+} LVCS_MemTab_t;
+
+
+/* Concert Sound parameter structure */
+typedef struct
+{
+ LVCS_Modes_en OperatingMode; /* Algorithm mode */
+ LVCS_SpeakerType_en SpeakerType; /* Output device type */
+ LVCS_SourceFormat_en SourceFormat; /* Source data format */
+ LVM_Mode_en CompressorMode; /* Non-Linear Compressor Mode */
+ LVM_Fs_en SampleRate; /* Sampling rate */
+ LVM_INT16 EffectLevel; /* Effect level */
+ LVM_UINT16 ReverbLevel; /* Reverb level in % */
+} LVCS_Params_t;
+
+
+/* Concert Sound Capability structure */
+typedef struct
+{
+ /* General parameters */
+ LVM_UINT16 MaxBlockSize; /* Maximum block size in sample pairs */
+
+ /* Callback parameters */
+ LVM_Callback CallBack; /* Bundle callback */
+ void *pBundleInstance; /* Bundle instance handle */
+
+} LVCS_Capabilities_t;
+
+
+/****************************************************************************************/
+/* */
+/* Function Prototypes */
+/* */
+/****************************************************************************************/
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVCS_Memory */
+/* */
+/* DESCRIPTION: */
+/* This function is used for memory allocation and free. It can be called in */
+/* two ways: */
+/* */
+/* hInstance = NULL Returns the memory requirements */
+/* hInstance = Instance handle Returns the memory requirements and */
+/* allocated base addresses for the instance */
+/* */
+/* When this function is called for memory allocation (hInstance=NULL) it is */
+/* passed the default capabilities, of these only the buffer processing setting is */
+/* used. */
+/* */
+/* When called for memory allocation the memory base address pointers are NULL on */
+/* return. */
+/* */
+/* When the function is called for free (hInstance = Instance Handle) the */
+/* capabilities are ignored and the memory table returns the allocated memory and */
+/* base addresses used during initialisation. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance Handle */
+/* pMemoryTable Pointer to an empty memory definition table */
+/* pCapabilities Pointer to the default capabilites */
+/* */
+/* RETURNS: */
+/* LVCS_Success Succeeded */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVCS_Process function */
+/* */
+/****************************************************************************************/
+
+LVCS_ReturnStatus_en LVCS_Memory(LVCS_Handle_t hInstance,
+ LVCS_MemTab_t *pMemoryTable,
+ LVCS_Capabilities_t *pCapabilities);
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVCS_Init */
+/* */
+/* DESCRIPTION: */
+/* Create and initialisation function for the Concert Sound module */
+/* */
+/* This function can be used to create an algorithm instance by calling with */
+/* hInstance set to NULL. In this case the algorithm returns the new instance */
+/* handle. */
+/* */
+/* This function can be used to force a full re-initialisation of the algorithm */
+/* by calling with hInstance = Instance Handle. In this case the memory table */
+/* should be correct for the instance, this can be ensured by calling the function */
+/* LVCS_Memory before calling this function. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* pMemoryTable Pointer to the memory definition table */
+/* pCapabilities Pointer to the initialisation capabilities */
+/* */
+/* RETURNS: */
+/* LVCS_Success Initialisation succeeded */
+/* LVCS_AlignmentError Instance or scratch memory on incorrect alignment */
+/* LVCS_NullAddress Instance or scratch memory has a NULL pointer */
+/* */
+/* NOTES: */
+/* 1. The instance handle is the pointer to the base address of the first memory */
+/* region. */
+/* 2. This function must not be interrupted by the LVCS_Process function */
+/* */
+/****************************************************************************************/
+
+LVCS_ReturnStatus_en LVCS_Init(LVCS_Handle_t *phInstance,
+ LVCS_MemTab_t *pMemoryTable,
+ LVCS_Capabilities_t *pCapabilities);
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVCS_GetParameters */
+/* */
+/* DESCRIPTION: */
+/* Request the Concert Sound parameters. The current parameter set is returned */
+/* via the parameter pointer. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* pParams Pointer to an empty parameter structure */
+/* */
+/* RETURNS: */
+/* LVCS_Success Always succeeds */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVCS_Process function */
+/* */
+/****************************************************************************************/
+
+LVCS_ReturnStatus_en LVCS_GetParameters(LVCS_Handle_t hInstance,
+ LVCS_Params_t *pParams);
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVCS_Control */
+/* */
+/* DESCRIPTION: */
+/* Sets or changes the Concert Sound parameters. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* pParams Pointer to a parameter structure */
+/* */
+/* RETURNS: */
+/* LVCS_Success Succeeded */
+/* */
+/* NOTES: */
+/* 1. This function must not be interrupted by the LVCS_Process function */
+/* */
+/****************************************************************************************/
+
+LVCS_ReturnStatus_en LVCS_Control(LVCS_Handle_t hInstance,
+ LVCS_Params_t *pParams);
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVCS_Process */
+/* */
+/* DESCRIPTION: */
+/* Process function for the Concert Sound module. The implementation supports two */
+/* variants of the algorithm, one for headphones and one for mobile speakers. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* pInData Pointer to the input data */
+/* pOutData Pointer to the output data */
+/* NumSamples Number of samples in the input buffer */
+/* */
+/* RETURNS: */
+/* LVCS_Success Succeeded */
+/* LVCS_TooManySamples NumSamples was larger than the maximum block size */
+/* */
+/* NOTES: */
+/* */
+/****************************************************************************************/
+
+LVCS_ReturnStatus_en LVCS_Process(LVCS_Handle_t hInstance,
+ const LVM_INT16 *pInData,
+ LVM_INT16 *pOutData,
+ LVM_UINT16 NumSamples);
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* LVCS_H */
diff --git a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_BypassMix.c b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_BypassMix.c
new file mode 100755
index 0000000..2a83e89
--- /dev/null
+++ b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_BypassMix.c
@@ -0,0 +1,303 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************************
+
+ $Author: nxp007753 $
+ $Revision: 1246 $
+ $Date: 2010-07-16 11:07:10 +0200 (Fri, 16 Jul 2010) $
+
+*************************************************************************************/
+
+/************************************************************************************/
+/* */
+/* Includes */
+/* */
+/************************************************************************************/
+
+#include "LVCS.h"
+#include "LVCS_Private.h"
+#include "LVCS_BypassMix.h"
+#include "VectorArithmetic.h"
+#include "LVCS_Tables.h"
+
+/****************************************************************************************/
+/* */
+/* Function Prototypes */
+/* */
+/****************************************************************************************/
+LVM_INT32 LVCS_MixerCallback( LVCS_Handle_t hInstance,
+ void *pGeneralPurpose,
+ LVM_INT16 CallbackParam);
+
+/************************************************************************************/
+/* */
+/* FUNCTION: LVCS_BypassMixInit */
+/* */
+/* DESCRIPTION: */
+/* Initialises the bypass mixer module */
+/* */
+/* The overall gain of the processed path is set by the gains in the individual */
+/* processing blocks and by the effect level gain. */
+/* */
+/* The unprocessed path must have matching gain for the processed path to ensure */
+/* as they are mixed together the correct effect is achieved, this is the value */
+/* UnprocLoss. */
+/* */
+/* The overall gain is corrected by a combination of a shift with saturation and a */
+/* linear scaler, loss. The loss ensures the sum in the mixer does not saturate */
+/* and also corrects for any excess gain in the shift. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance Handle */
+/* pParams Initialisation parameters */
+/* */
+/* RETURNS: */
+/* LVCS_Success Always succeeds */
+/* */
+/* NOTES: */
+/* */
+/************************************************************************************/
+
+LVCS_ReturnStatus_en LVCS_BypassMixInit(LVCS_Handle_t hInstance,
+ LVCS_Params_t *pParams)
+{
+
+ LVM_UINT16 Offset;
+ LVM_UINT32 Gain;
+ LVCS_Instance_t *pInstance = (LVCS_Instance_t *)hInstance;
+ LVCS_BypassMix_t *pConfig = (LVCS_BypassMix_t *)&pInstance->BypassMix;
+ const Gain_t *pOutputGainTable;
+ LVM_INT32 Current;
+
+
+ /*
+ * Set the transition gain
+ */
+ if ((pParams->OperatingMode == LVCS_ON) &&
+ (pInstance->bTimerDone == LVM_TRUE)
+ && (LVC_Mixer_GetTarget(&pInstance->MSBypassMixer.MixerStream[1]) != 0x7FFF) /* this indicates an off->on transtion */
+ )
+ {
+ pInstance->TransitionGain = pParams->EffectLevel;
+ }
+ else
+ {
+ /* Select no effect level */
+ pInstance->TransitionGain = 0;
+ }
+
+ /*
+ * Calculate the output gain table offset
+ */
+ Offset = (LVM_UINT16)(pParams->SpeakerType + (pParams->SourceFormat*(1+LVCS_EX_HEADPHONES)));
+ pOutputGainTable = (Gain_t*)&LVCS_OutputGainTable[0];
+
+ /*
+ * Setup the mixer gain for the processed path
+ */
+ Gain = (LVM_UINT32)(pOutputGainTable[Offset].Loss * pInstance->TransitionGain);
+
+ pConfig->Mixer_Instance.MixerStream[0].CallbackParam = 0;
+ pConfig->Mixer_Instance.MixerStream[0].pCallbackHandle = LVM_NULL;
+ pConfig->Mixer_Instance.MixerStream[0].pCallBack = LVM_NULL;
+ pConfig->Mixer_Instance.MixerStream[0].CallbackSet=1;
+ Current = LVC_Mixer_GetCurrent(&pConfig->Mixer_Instance.MixerStream[0]);
+ LVC_Mixer_Init(&pConfig->Mixer_Instance.MixerStream[0],(LVM_INT32)(Gain >> 15),Current);
+ LVC_Mixer_VarSlope_SetTimeConstant(&pConfig->Mixer_Instance.MixerStream[0],LVCS_BYPASS_MIXER_TC,pParams->SampleRate,2);
+ /*
+ * Setup the mixer gain for the unprocessed path
+ */
+ Gain = (LVM_UINT32)(pOutputGainTable[Offset].Loss * (0x7FFF - pInstance->TransitionGain));
+ Gain = (LVM_UINT32)pOutputGainTable[Offset].UnprocLoss * (Gain >> 15);
+ Current = LVC_Mixer_GetCurrent(&pConfig->Mixer_Instance.MixerStream[1]);
+ LVC_Mixer_Init(&pConfig->Mixer_Instance.MixerStream[1],(LVM_INT32)(Gain >> 15),Current);
+ LVC_Mixer_VarSlope_SetTimeConstant(&pConfig->Mixer_Instance.MixerStream[1],LVCS_BYPASS_MIXER_TC,pParams->SampleRate,2);
+ pConfig->Mixer_Instance.MixerStream[1].CallbackParam = 0;
+ pConfig->Mixer_Instance.MixerStream[1].pCallbackHandle = hInstance;
+ pConfig->Mixer_Instance.MixerStream[1].CallbackSet=1;
+ pConfig->Mixer_Instance.MixerStream[1].pCallBack = LVCS_MixerCallback;
+
+ /*
+ * Setup the output gain shift
+ */
+ pConfig->Output_Shift = pOutputGainTable[Offset].Shift;
+
+
+ /*
+ * Correct gain for the effect level
+ */
+ {
+
+ LVM_INT16 GainCorrect;
+ LVM_INT32 Gain1;
+ LVM_INT32 Gain2;
+
+ Gain1 = LVC_Mixer_GetTarget(&pConfig->Mixer_Instance.MixerStream[0]);
+ Gain2 = LVC_Mixer_GetTarget(&pConfig->Mixer_Instance.MixerStream[1]);
+ /*
+ * Calculate the gain correction
+ */
+ if (pInstance->Params.CompressorMode == LVM_MODE_ON)
+ {
+ GainCorrect = (LVM_INT16)( pInstance->VolCorrect.GainMin
+ - (((LVM_INT32)pInstance->VolCorrect.GainMin * (LVM_INT32)pInstance->TransitionGain) >> 15)
+ + (((LVM_INT32)pInstance->VolCorrect.GainFull * (LVM_INT32)pInstance->TransitionGain) >> 15) );
+
+ /*
+ * Apply the gain correction and shift, note the result is in Q3.13 format
+ */
+ Gain1 = (Gain1 * GainCorrect) << 4;
+ Gain2 = (Gain2 * GainCorrect) << 4;
+ }
+ else
+ {
+ Gain1 = Gain1 << 16;
+ Gain2 = Gain2 << 16;
+ }
+
+
+
+ /*
+ * Set the gain values
+ */
+ pConfig->Output_Shift = pConfig->Output_Shift;
+ LVC_Mixer_SetTarget(&pConfig->Mixer_Instance.MixerStream[0],Gain1>>16);
+ LVC_Mixer_VarSlope_SetTimeConstant(&pConfig->Mixer_Instance.MixerStream[0],LVCS_BYPASS_MIXER_TC,pParams->SampleRate,2);
+ LVC_Mixer_SetTarget(&pConfig->Mixer_Instance.MixerStream[1],Gain2>>16);
+ LVC_Mixer_VarSlope_SetTimeConstant(&pConfig->Mixer_Instance.MixerStream[1],LVCS_BYPASS_MIXER_TC,pParams->SampleRate,2);
+ }
+
+ return(LVCS_SUCCESS);
+
+}
+
+/************************************************************************************/
+/* */
+/* FUNCTION: LVCS_BypassMixer */
+/* */
+/* DESCRIPTION: */
+/* Apply Bypass Mix. */
+/* */
+/* This mixes the processed and unprocessed data streams together to correct the */
+/* overall system gain and allow progressive control of the Concert Sound effect. */
+/* */
+/* When the bypass mixer is enabled the output is the processed signal only and */
+/* without gain correction. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance Handle */
+/* pProcessed Pointer to the processed data */
+/* pUnprocessed Pointer to the unprocessed data */
+/* pOutData Pointer to the output data */
+/* NumSamples Number of samples to process */
+/* */
+/* RETURNS: */
+/* LVCS_Success Always succeeds */
+/* */
+/* NOTES: */
+/* */
+/************************************************************************************/
+
+LVCS_ReturnStatus_en LVCS_BypassMixer(LVCS_Handle_t hInstance,
+ const LVM_INT16 *pProcessed,
+ const LVM_INT16 *pUnprocessed,
+ LVM_INT16 *pOutData,
+ LVM_UINT16 NumSamples)
+{
+
+ LVCS_Instance_t *pInstance = (LVCS_Instance_t *)hInstance;
+ LVCS_BypassMix_t *pConfig = (LVCS_BypassMix_t *)&pInstance->BypassMix;
+
+ /*
+ * Check if the bypass mixer is enabled
+ */
+ if ((pInstance->Params.OperatingMode & LVCS_BYPASSMIXSWITCH) != 0)
+ {
+ /*
+ * Apply the bypass mix
+ */
+ LVC_MixSoft_2St_D16C31_SAT(&pConfig->Mixer_Instance,
+ pProcessed,
+ (LVM_INT16 *) pUnprocessed,
+ pOutData,
+ (LVM_INT16)(2*NumSamples));
+
+ /*
+ * Apply output gain correction shift
+ */
+ Shift_Sat_v16xv16 ((LVM_INT16)pConfig->Output_Shift,
+ (LVM_INT16*)pOutData,
+ (LVM_INT16*)pOutData,
+ (LVM_INT16)(2*NumSamples)); /* Left and right*/
+ }
+
+ return(LVCS_SUCCESS);
+}
+
+
+/************************************************************************************/
+/* */
+/* FUNCTION: LVCS_MixerCallback */
+/* */
+/************************************************************************************/
+LVM_INT32 LVCS_MixerCallback(LVCS_Handle_t hInstance,
+ void *pGeneralPurpose,
+ LVM_INT16 CallbackParam)
+{
+ LVCS_Instance_t *pInstance = (LVCS_Instance_t *)hInstance;
+ LVM_INT32 Target1;
+
+ Target1 = LVC_Mixer_GetTarget(&pInstance->MSBypassMixer.MixerStream[0]);
+ (void)pGeneralPurpose;
+
+ /*
+ * Off transition has completed in Headphone mode
+ */
+ if ((pInstance->OutputDevice == LVCS_HEADPHONE) &&
+ (pInstance->bInOperatingModeTransition) &&
+ (Target1 == 0x0000)&& /* this indicates an on->off transition */
+ (CallbackParam == 0))
+ {
+ /* Set operating mode to OFF */
+ pInstance->Params.OperatingMode = LVCS_OFF;
+
+ /* Exit transition state */
+ pInstance->bInOperatingModeTransition = LVM_FALSE;
+
+ /* Signal to the bundle */
+ if((*pInstance->Capabilities.CallBack) != LVM_NULL){
+ (*pInstance->Capabilities.CallBack)(pInstance->Capabilities.pBundleInstance,
+ LVM_NULL,
+ (ALGORITHM_CS_ID | LVCS_EVENT_ALGOFF));
+ }
+ }
+
+
+ if ((pInstance->OutputDevice == LVCS_HEADPHONE) &&
+ (Target1 == 1) &&
+ (pInstance->bTimerDone == LVM_TRUE)){
+
+ /* Exit transition state */
+ pInstance->bInOperatingModeTransition = LVM_FALSE;
+ }
+
+ return 1;
+}
+
+
+
diff --git a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_BypassMix.h b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_BypassMix.h
new file mode 100755
index 0000000..79dff41
--- /dev/null
+++ b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_BypassMix.h
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1001 $
+ $Date: 2010-06-28 13:23:02 +0200 (Mon, 28 Jun 2010) $
+
+*************************************************************************************/
+
+#ifndef __LVCS_BYPASSMIX_H__
+#define __LVCS_BYPASSMIX_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/************************************************************************************/
+/* */
+/* Includes */
+/* */
+/************************************************************************************/
+
+#include "LVC_Mixer.h"
+
+
+/************************************************************************************/
+/* */
+/* Structures */
+/* */
+/************************************************************************************/
+
+/* Bypass mixer structure */
+typedef struct
+{
+ /* Mixer settings */
+ LVMixer3_2St_st Mixer_Instance; /* Mixer instance */
+ LVM_UINT16 Output_Shift; /* Correcting gain output shift */
+
+} LVCS_BypassMix_t;
+
+
+/* Output gain type */
+typedef struct
+{
+ /* Output gain settings, Gain = (Loss/32768) * 2^Shift */
+ LVM_UINT16 Shift; /* Left shifts required */
+ LVM_UINT16 Loss; /* Loss required */
+ LVM_UINT16 UnprocLoss; /* Unprocessed path loss */
+} Gain_t;
+
+
+/************************************************************************************/
+/* */
+/* Function prototypes */
+/* */
+/************************************************************************************/
+
+LVCS_ReturnStatus_en LVCS_BypassMixInit(LVCS_Handle_t hInstance,
+ LVCS_Params_t *pParams);
+
+
+LVCS_ReturnStatus_en LVCS_BypassMixer(LVCS_Handle_t hInstance,
+ const LVM_INT16 *pProcessed,
+ const LVM_INT16 *unProcessed,
+ LVM_INT16 *pOutData,
+ LVM_UINT16 NumSamples);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* BYPASSMIX_H */
diff --git a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Control.c b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Control.c
new file mode 100755
index 0000000..5dfca256
--- /dev/null
+++ b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Control.c
@@ -0,0 +1,273 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************************
+
+ $Author: nxp007753 $
+ $Revision: 1246 $
+ $Date: 2010-07-16 11:07:10 +0200 (Fri, 16 Jul 2010) $
+
+*************************************************************************************/
+
+/************************************************************************************/
+/* */
+/* Includes */
+/* */
+/************************************************************************************/
+
+#include "LVCS.h"
+#include "LVCS_Private.h"
+#include "LVCS_Tables.h"
+
+/************************************************************************************/
+/* */
+/* FUNCTION: LVCS_GetParameters */
+/* */
+/* DESCRIPTION: */
+/* Request the Concert Sound parameters. The current parameter set is returned */
+/* via the parameter pointer. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* pParams Pointer to an empty parameter structure */
+/* */
+/* RETURNS: */
+/* LVCS_Success Always succeeds */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVCS_Process function */
+/* */
+/************************************************************************************/
+
+LVCS_ReturnStatus_en LVCS_GetParameters(LVCS_Handle_t hInstance,
+ LVCS_Params_t *pParams)
+{
+
+ LVCS_Instance_t *pInstance =(LVCS_Instance_t *)hInstance;
+
+ *pParams = pInstance->Params;
+
+ return(LVCS_SUCCESS);
+}
+
+
+/************************************************************************************/
+/* */
+/* FUNCTION: LVCS_Control */
+/* */
+/* DESCRIPTION: */
+/* Sets or changes the Concert Sound parameters. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* pParams Pointer to a parameter structure */
+/* */
+/* RETURNS: */
+/* LVCS_Success Succeeded */
+/* */
+/* NOTES: */
+/* 1. This function must not be interrupted by the LVCS_Process function */
+/* */
+/************************************************************************************/
+
+LVCS_ReturnStatus_en LVCS_Control(LVCS_Handle_t hInstance,
+ LVCS_Params_t *pParams)
+{
+ LVM_INT16 Offset;
+ LVCS_Instance_t *pInstance =(LVCS_Instance_t *)hInstance;
+ LVCS_ReturnStatus_en err;
+ LVCS_Modes_en OperatingModeSave = pInstance->Params.OperatingMode;
+
+ if (pParams->SampleRate != pInstance->Params.SampleRate)
+ {
+ LVC_Mixer_VarSlope_SetTimeConstant(&pInstance->MSBypassMixer.MixerStream[0],LVCS_BYPASS_MIXER_TC,pParams->SampleRate,2);
+
+ LVC_Mixer_VarSlope_SetTimeConstant(&pInstance->MSBypassMixer.MixerStream[1],LVCS_BYPASS_MIXER_TC,pParams->SampleRate,2);
+ pInstance->TimerParams.SamplingRate = LVCS_SampleRateTable[pParams->SampleRate];
+ }
+
+ /*
+ * If the reverb level has changed
+ */
+ if(pInstance->Params.ReverbLevel != pParams->ReverbLevel)
+ {
+ err=LVCS_ReverbGeneratorInit(hInstance,pParams);
+ }
+
+ /*
+ * If the sample rate or speaker has changed then perform a full re-initialisation
+ */
+ if ((pInstance->Params.SampleRate != pParams->SampleRate) ||
+ (pInstance->Params.SpeakerType != pParams->SpeakerType))
+ {
+ const LVCS_VolCorrect_t *pLVCS_VolCorrectTable;
+
+ /*
+ * Output device
+ */
+ pInstance->OutputDevice = LVCS_HEADPHONE;
+
+ /*
+ * Get the volume correction parameters
+ */
+ /* Use internal coefficient table */
+ pLVCS_VolCorrectTable = (LVCS_VolCorrect_t*)&LVCS_VolCorrectTable[0];
+ Offset = (LVM_INT16)(pParams->SpeakerType + pParams->SourceFormat*(1+LVCS_EX_HEADPHONES));
+
+ pInstance->VolCorrect = pLVCS_VolCorrectTable[Offset];
+
+ err=LVCS_SEnhancerInit(hInstance,
+ pParams);
+
+ err=LVCS_ReverbGeneratorInit(hInstance,
+ pParams);
+
+ err=LVCS_EqualiserInit(hInstance,
+ pParams);
+
+ err=LVCS_BypassMixInit(hInstance,
+ pParams);
+
+ }
+
+
+ /*
+ * Check if the effect level or source format has changed
+ */
+ else if ((pInstance->Params.EffectLevel != pParams->EffectLevel) ||
+ (pInstance->Params.SourceFormat != pParams->SourceFormat))
+ {
+ const LVCS_VolCorrect_t *pLVCS_VolCorrectTable;
+
+ /*
+ * Get the volume correction parameters
+ */
+ /* Use internal coefficient table */
+ pLVCS_VolCorrectTable = (LVCS_VolCorrect_t*)&LVCS_VolCorrectTable[0];
+ Offset = (LVM_INT16)(pParams->SpeakerType + pParams->SourceFormat*(1+LVCS_EX_HEADPHONES));
+
+ pInstance->VolCorrect = pLVCS_VolCorrectTable[Offset];
+
+ /* Update the effect level and alpha-mixer gains */
+ err=LVCS_BypassMixInit(hInstance,
+ pParams);
+
+ if(err != LVCS_SUCCESS)
+ {
+ return err;
+ }
+ }
+ else
+ {
+ pInstance->Params = *pParams;
+ }
+
+ /*
+ * Update the instance parameters
+ */
+ pInstance->Params = *pParams;
+
+ /* Stay on the current operating mode until the transition is done */
+ if((pParams->OperatingMode != OperatingModeSave) ||
+ (pInstance->bInOperatingModeTransition == LVM_TRUE)){
+
+ /* Set the reverb delay timeout */
+ if(pInstance->bInOperatingModeTransition != LVM_TRUE){
+ pInstance->bTimerDone = LVM_FALSE;
+ pInstance->TimerParams.TimeInMs = (LVM_INT16)(((pInstance->Reverberation.DelaySize << 2)/pInstance->TimerParams.SamplingRate) + 1);
+ LVM_Timer_Init ( &pInstance->TimerInstance,
+ &pInstance->TimerParams);
+ }
+
+ /* Update the effect level and alpha-mixer gains */
+ err=LVCS_BypassMixInit(hInstance,
+ pParams);
+
+ /* Change transition bypass mixer settings if needed depending on transition type */
+ if(pParams->OperatingMode != LVCS_OFF){
+ LVM_INT32 Current1;
+ LVM_INT32 Current2;
+
+ Current1 = LVC_Mixer_GetCurrent(&pInstance->MSBypassMixer.MixerStream[0]);
+ Current2 = LVC_Mixer_GetCurrent(&pInstance->MSBypassMixer.MixerStream[1]);
+
+ if(pInstance->bInOperatingModeTransition != LVM_TRUE)
+ {
+ Current1 = 0x00000000;
+ Current2 = LVM_MAXINT_16;
+ }
+ pInstance->MSBypassMixer.MixerStream[0].CallbackSet = 1;
+ pInstance->MSBypassMixer.MixerStream[1].CallbackSet = 1;
+
+ LVC_Mixer_Init(&pInstance->MSBypassMixer.MixerStream[0],LVM_MAXINT_16,Current1);
+ LVC_Mixer_Init(&pInstance->MSBypassMixer.MixerStream[1],0,Current2);
+ }
+ else
+ {
+ LVM_INT32 Current1;
+ LVM_INT32 Current2;
+
+ Current1 = LVC_Mixer_GetCurrent(&pInstance->MSBypassMixer.MixerStream[0]);
+ Current2 = LVC_Mixer_GetCurrent(&pInstance->MSBypassMixer.MixerStream[1]);
+
+ if(pInstance->bInOperatingModeTransition != LVM_TRUE)
+ {
+ Current1 = LVM_MAXINT_16;
+ Current2 = 0x00000000;
+ }
+ pInstance->MSBypassMixer.MixerStream[0].CallbackSet = 1;
+ pInstance->MSBypassMixer.MixerStream[1].CallbackSet = 1;
+ pInstance->Params.OperatingMode = OperatingModeSave;
+ LVC_Mixer_Init(&pInstance->MSBypassMixer.MixerStream[0],0x00000000,Current1);
+ LVC_Mixer_Init(&pInstance->MSBypassMixer.MixerStream[1],LVM_MAXINT_16,Current2);
+ }
+ LVC_Mixer_SetTimeConstant(&pInstance->MSBypassMixer.MixerStream[0],LVCS_BYPASS_MIXER_TC,pParams->SampleRate,2);
+ LVC_Mixer_SetTimeConstant(&pInstance->MSBypassMixer.MixerStream[1],LVCS_BYPASS_MIXER_TC,pParams->SampleRate,2);
+
+
+ /* Set transition flag */
+ pInstance->bInOperatingModeTransition = LVM_TRUE;
+ }
+
+ return(LVCS_SUCCESS);
+}
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVCS_TimerCallBack */
+/* */
+/* DESCRIPTION: */
+/* CallBack function of the Timer. */
+/* */
+/****************************************************************************************/
+void LVCS_TimerCallBack (void* hInstance, void* pCallBackParams, LVM_INT32 CallbackParam)
+{
+ LVCS_Instance_t *pInstance = (LVCS_Instance_t *)hInstance;
+
+ /* Avoid warnings because pCallBackParams and CallbackParam are not used*/
+ if((pCallBackParams != LVM_NULL) || (CallbackParam != 0)){
+ pCallBackParams = hInstance;
+ CallbackParam = 0;
+ return;
+ }
+
+ pInstance->bTimerDone = LVM_TRUE;
+
+
+ return;
+}
+
diff --git a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Equaliser.c b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Equaliser.c
new file mode 100755
index 0000000..ca615b0
--- /dev/null
+++ b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Equaliser.c
@@ -0,0 +1,167 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1001 $
+ $Date: 2010-06-28 13:23:02 +0200 (Mon, 28 Jun 2010) $
+
+*************************************************************************************/
+
+/************************************************************************************/
+/* */
+/* Includes */
+/* */
+/************************************************************************************/
+
+#include "LVCS.h"
+#include "LVCS_Private.h"
+#include "LVCS_Equaliser.h"
+#include "BIQUAD.h"
+#include "VectorArithmetic.h"
+#include "LVCS_Tables.h"
+
+/************************************************************************************/
+/* */
+/* FUNCTION: LVCS_EqualiserInit */
+/* */
+/* DESCRIPTION: */
+/* Initialises the equaliser module */
+/* */
+/* The function selects the coefficients for the filters and clears the data */
+/* history. It is also used for re-initialisation when one of the system control */
+/* parameters changes but will only change the coefficients and clear the history */
+/* if the sample rate or speaker type has changed. */
+/* */
+/* To avoid excessive testing during the sample processing the biquad type is */
+/* set as a callback function in the init routine. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance Handle */
+/* pParams Initialisation parameters */
+/* */
+/* RETURNS: */
+/* LVCS_Success Always succeeds */
+/* */
+/* NOTES: */
+/* */
+/************************************************************************************/
+
+LVCS_ReturnStatus_en LVCS_EqualiserInit(LVCS_Handle_t hInstance,
+ LVCS_Params_t *pParams)
+{
+
+ LVM_UINT16 Offset;
+ LVCS_Instance_t *pInstance = (LVCS_Instance_t *)hInstance;
+ LVCS_Equaliser_t *pConfig = (LVCS_Equaliser_t *)&pInstance->Equaliser;
+ LVCS_Data_t *pData = (LVCS_Data_t *)pInstance->MemoryTable.Region[LVCS_MEMREGION_PERSISTENT_FAST_DATA].pBaseAddress;
+ LVCS_Coefficient_t *pCoefficients = (LVCS_Coefficient_t *)pInstance->MemoryTable.Region[LVCS_MEMREGION_PERSISTENT_FAST_COEF].pBaseAddress;
+ BQ_C16_Coefs_t Coeffs;
+ const BiquadA012B12CoefsSP_t *pEqualiserCoefTable;
+
+ /*
+ * If the sample rate changes re-initialise the filters
+ */
+ if ((pInstance->Params.SampleRate != pParams->SampleRate) ||
+ (pInstance->Params.SpeakerType != pParams->SpeakerType))
+ {
+ /*
+ * Setup the filter coefficients and clear the history
+ */
+ Offset = (LVM_UINT16)(pParams->SampleRate + (pParams->SpeakerType * (1+LVM_FS_48000)));
+ pEqualiserCoefTable = (BiquadA012B12CoefsSP_t*)&LVCS_EqualiserCoefTable[0];
+
+ /* Left and right filters */
+ /* Convert incoming coefficients to the required format/ordering */
+ Coeffs.A0 = (LVM_INT16) pEqualiserCoefTable[Offset].A0;
+ Coeffs.A1 = (LVM_INT16) pEqualiserCoefTable[Offset].A1;
+ Coeffs.A2 = (LVM_INT16) pEqualiserCoefTable[Offset].A2;
+ Coeffs.B1 = (LVM_INT16)-pEqualiserCoefTable[Offset].B1;
+ Coeffs.B2 = (LVM_INT16)-pEqualiserCoefTable[Offset].B2;
+
+ LoadConst_16((LVM_INT16)0, /* Value */
+ (LVM_INT16 *)&pData->EqualiserBiquadTaps, /* Destination */
+ (LVM_UINT16)(sizeof(pData->EqualiserBiquadTaps)/sizeof(LVM_INT16))); /* Number of words */
+
+ BQ_2I_D16F32Css_TRC_WRA_01_Init(&pCoefficients->EqualiserBiquadInstance,
+ &pData->EqualiserBiquadTaps,
+ &Coeffs);
+
+ /* Callbacks */
+ switch(pEqualiserCoefTable[Offset].Scale)
+ {
+ case 13:
+ pConfig->pBiquadCallBack = BQ_2I_D16F32C13_TRC_WRA_01;
+ break;
+ case 14:
+ pConfig->pBiquadCallBack = BQ_2I_D16F32C14_TRC_WRA_01;
+ break;
+ case 15:
+ pConfig->pBiquadCallBack = BQ_2I_D16F32C15_TRC_WRA_01;
+ break;
+ }
+ }
+
+ return(LVCS_SUCCESS);
+}
+
+/************************************************************************************/
+/* */
+/* FUNCTION: LVCS_Equaliser */
+/* */
+/* DESCRIPTION: */
+/* Apply the equaliser filter. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance Handle */
+/* pInputOutput Pointer to the input/output buffer */
+/* NumSamples The number of samples to process */
+/* */
+/* RETURNS: */
+/* LVCS_Success Always succeeds */
+/* */
+/* NOTES: */
+/* 1. Always processes in place. */
+/* */
+/************************************************************************************/
+
+LVCS_ReturnStatus_en LVCS_Equaliser(LVCS_Handle_t hInstance,
+ LVM_INT16 *pInputOutput,
+ LVM_UINT16 NumSamples)
+{
+
+ LVCS_Instance_t *pInstance = (LVCS_Instance_t *)hInstance;
+ LVCS_Equaliser_t *pConfig = (LVCS_Equaliser_t *)&pInstance->Equaliser;
+ LVCS_Coefficient_t *pCoefficients = (LVCS_Coefficient_t *)pInstance->MemoryTable.Region[LVCS_MEMREGION_PERSISTENT_FAST_COEF].pBaseAddress;
+
+
+ /*
+ * Check if the equaliser is required
+ */
+ if ((pInstance->Params.OperatingMode & LVCS_EQUALISERSWITCH) != 0)
+ {
+ /* Apply filter to the left and right channels */
+ (pConfig->pBiquadCallBack)((Biquad_Instance_t*)&pCoefficients->EqualiserBiquadInstance,
+ (LVM_INT16 *)pInputOutput,
+ (LVM_INT16 *)pInputOutput,
+ (LVM_INT16)NumSamples);
+ }
+
+ return(LVCS_SUCCESS);
+}
+
diff --git a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Equaliser.h b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Equaliser.h
new file mode 100755
index 0000000..10b02cc
--- /dev/null
+++ b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Equaliser.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1001 $
+ $Date: 2010-06-28 13:23:02 +0200 (Mon, 28 Jun 2010) $
+
+*************************************************************************************/
+
+#ifndef __LVCS_EQUALISER_H__
+#define __LVCS_EQUALISER_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/************************************************************************************/
+/* */
+/* Structures */
+/* */
+/************************************************************************************/
+
+/* Equaliser structure */
+typedef struct
+{
+ void (*pBiquadCallBack) (Biquad_Instance_t*, LVM_INT16*, LVM_INT16*, LVM_INT16);
+
+} LVCS_Equaliser_t;
+
+
+/************************************************************************************/
+/* */
+/* Function prototypes */
+/* */
+/************************************************************************************/
+
+LVCS_ReturnStatus_en LVCS_EqualiserInit(LVCS_Handle_t hInstance,
+ LVCS_Params_t *pParams);
+
+LVCS_ReturnStatus_en LVCS_Equaliser(LVCS_Handle_t hInstance,
+ LVM_INT16 *pInputOutput,
+ LVM_UINT16 NumSamples);
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* EQUALISER_H */
diff --git a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Headphone_Coeffs.h b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Headphone_Coeffs.h
new file mode 100755
index 0000000..1d55281
--- /dev/null
+++ b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Headphone_Coeffs.h
@@ -0,0 +1,398 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef __LVCS_HEADPHONE_COEFFS_H__
+#define __LVCS_HEADPHONE_COEFFS_H__
+
+
+/************************************************************************************/
+/* */
+/* The Stereo Enhancer */
+/* */
+/************************************************************************************/
+
+/* Stereo Enhancer coefficients for 8000 Hz sample rate, scaled with 0.161258 */
+#define CS_MIDDLE_8000_A0 7462 /* Floating point value 0.227720 */
+#define CS_MIDDLE_8000_A1 -7049 /* Floating point value -0.215125 */
+#define CS_MIDDLE_8000_A2 0 /* Floating point value 0.000000 */
+#define CS_MIDDLE_8000_B1 -30209 /* Floating point value -0.921899 */
+#define CS_MIDDLE_8000_B2 0 /* Floating point value 0.000000 */
+#define CS_MIDDLE_8000_SCALE 15
+#define CS_SIDE_8000_A0 20036 /* Floating point value 0.611441 */
+#define CS_SIDE_8000_A1 -12463 /* Floating point value -0.380344 */
+#define CS_SIDE_8000_A2 -7573 /* Floating point value -0.231097 */
+#define CS_SIDE_8000_B1 -20397 /* Floating point value -0.622470 */
+#define CS_SIDE_8000_B2 -4285 /* Floating point value -0.130759 */
+#define CS_SIDE_8000_SCALE 15
+
+/* Stereo Enhancer coefficients for 11025Hz sample rate, scaled with 0.162943 */
+#define CS_MIDDLE_11025_A0 7564 /* Floating point value 0.230838 */
+#define CS_MIDDLE_11025_A1 -7260 /* Floating point value -0.221559 */
+#define CS_MIDDLE_11025_A2 0 /* Floating point value 0.000000 */
+#define CS_MIDDLE_11025_B1 -30902 /* Floating point value -0.943056 */
+#define CS_MIDDLE_11025_B2 0 /* Floating point value 0.000000 */
+#define CS_MIDDLE_11025_SCALE 15
+#define CS_SIDE_11025_A0 18264 /* Floating point value 0.557372 */
+#define CS_SIDE_11025_A1 -12828 /* Floating point value -0.391490 */
+#define CS_SIDE_11025_A2 -5436 /* Floating point value -0.165881 */
+#define CS_SIDE_11025_B1 -28856 /* Floating point value -0.880608 */
+#define CS_SIDE_11025_B2 1062 /* Floating point value 0.032397 */
+#define CS_SIDE_11025_SCALE 15
+
+/* Stereo Enhancer coefficients for 12000Hz sample rate, scaled with 0.162191 */
+#define CS_MIDDLE_12000_A0 7534 /* Floating point value 0.229932 */
+#define CS_MIDDLE_12000_A1 -7256 /* Floating point value -0.221436 */
+#define CS_MIDDLE_12000_A2 0 /* Floating point value 0.000000 */
+#define CS_MIDDLE_12000_B1 -31051 /* Floating point value -0.947616 */
+#define CS_MIDDLE_12000_B2 0 /* Floating point value 0.000000 */
+#define CS_MIDDLE_12000_SCALE 15
+#define CS_SIDE_12000_A0 18298 /* Floating point value 0.558398 */
+#define CS_SIDE_12000_A1 -12852 /* Floating point value -0.392211 */
+#define CS_SIDE_12000_A2 -5446 /* Floating point value -0.166187 */
+#define CS_SIDE_12000_B1 -29247 /* Floating point value -0.892550 */
+#define CS_SIDE_12000_B2 1077 /* Floating point value 0.032856 */
+#define CS_SIDE_12000_SCALE 15
+
+/* Stereo Enhancer coefficients for 16000Hz sample rate, scaled with 0.162371 */
+#define CS_MIDDLE_16000_A0 7558 /* Floating point value 0.230638 */
+#define CS_MIDDLE_16000_A1 -7348 /* Floating point value -0.224232 */
+#define CS_MIDDLE_16000_A2 0 /* Floating point value 0.000000 */
+#define CS_MIDDLE_16000_B1 -31475 /* Floating point value -0.960550 */
+#define CS_MIDDLE_16000_B2 0 /* Floating point value 0.000000 */
+#define CS_MIDDLE_16000_SCALE 15
+#define CS_SIDE_16000_A0 8187 /* Floating point value 0.499695 */
+#define CS_SIDE_16000_A1 -5825 /* Floating point value -0.355543 */
+#define CS_SIDE_16000_A2 -2362 /* Floating point value -0.144152 */
+#define CS_SIDE_16000_B1 -17216 /* Floating point value -1.050788 */
+#define CS_SIDE_16000_B2 2361 /* Floating point value 0.144104 */
+#define CS_SIDE_16000_SCALE 14
+
+/* Stereo Enhancer coefficients for 22050Hz sample rate, scaled with 0.160781 */
+#define CS_MIDDLE_22050_A0 7496 /* Floating point value 0.228749 */
+#define CS_MIDDLE_22050_A1 -7344 /* Floating point value -0.224128 */
+#define CS_MIDDLE_22050_A2 0 /* Floating point value 0.000000 */
+#define CS_MIDDLE_22050_B1 -31826 /* Floating point value -0.971262 */
+#define CS_MIDDLE_22050_B2 0 /* Floating point value 0.000000 */
+#define CS_MIDDLE_22050_SCALE 15
+#define CS_SIDE_22050_A0 7211 /* Floating point value 0.440112 */
+#define CS_SIDE_22050_A1 -4278 /* Floating point value -0.261096 */
+#define CS_SIDE_22050_A2 -2933 /* Floating point value -0.179016 */
+#define CS_SIDE_22050_B1 -18297 /* Floating point value -1.116786 */
+#define CS_SIDE_22050_B2 2990 /* Floating point value 0.182507 */
+#define CS_SIDE_22050_SCALE 14
+
+/* Stereo Enhancer coefficients for 24000Hz sample rate, scaled with 0.161882 */
+#define CS_MIDDLE_24000_A0 7550 /* Floating point value 0.230395 */
+#define CS_MIDDLE_24000_A1 -7409 /* Floating point value -0.226117 */
+#define CS_MIDDLE_24000_A2 0 /* Floating point value 0.000000 */
+#define CS_MIDDLE_24000_B1 -31902 /* Floating point value -0.973573 */
+#define CS_MIDDLE_24000_B2 0 /* Floating point value 0.000000 */
+#define CS_MIDDLE_24000_SCALE 15
+#define CS_SIDE_24000_A0 6796 /* Floating point value 0.414770 */
+#define CS_SIDE_24000_A1 -4705 /* Floating point value -0.287182 */
+#define CS_SIDE_24000_A2 -2090 /* Floating point value -0.127588 */
+#define CS_SIDE_24000_B1 -20147 /* Floating point value -1.229648 */
+#define CS_SIDE_24000_B2 4623 /* Floating point value 0.282177 */
+#define CS_SIDE_24000_SCALE 14
+
+/* Stereo Enhancer coefficients for 32000Hz sample rate, scaled with 0.160322 */
+#define CS_MIDDLE_32000_A0 7484 /* Floating point value 0.228400 */
+#define CS_MIDDLE_32000_A1 -7380 /* Floating point value -0.225214 */
+#define CS_MIDDLE_32000_A2 0 /* Floating point value 0.000000 */
+#define CS_MIDDLE_32000_B1 -32117 /* Floating point value -0.980126 */
+#define CS_MIDDLE_32000_B2 0 /* Floating point value 0.000000 */
+#define CS_MIDDLE_32000_SCALE 15
+#define CS_SIDE_32000_A0 5973 /* Floating point value 0.364579 */
+#define CS_SIDE_32000_A1 -3397 /* Floating point value -0.207355 */
+#define CS_SIDE_32000_A2 -2576 /* Floating point value -0.157224 */
+#define CS_SIDE_32000_B1 -20877 /* Floating point value -1.274231 */
+#define CS_SIDE_32000_B2 5120 /* Floating point value 0.312495 */
+#define CS_SIDE_32000_SCALE 14
+
+/* Stereo Enhancer coefficients for 44100Hz sample rate, scaled with 0.163834 */
+#define CS_MIDDLE_44100_A0 7654 /* Floating point value 0.233593 */
+#define CS_MIDDLE_44100_A1 -7577 /* Floating point value -0.231225 */
+#define CS_MIDDLE_44100_A2 0 /* Floating point value 0.000000 */
+#define CS_MIDDLE_44100_B1 -32294 /* Floating point value -0.985545 */
+#define CS_MIDDLE_44100_B2 0 /* Floating point value 0.000000 */
+#define CS_MIDDLE_44100_SCALE 15
+#define CS_SIDE_44100_A0 4662 /* Floating point value 0.284573 */
+#define CS_SIDE_44100_A1 -4242 /* Floating point value -0.258910 */
+#define CS_SIDE_44100_A2 -420 /* Floating point value -0.025662 */
+#define CS_SIDE_44100_B1 -25760 /* Floating point value -1.572248 */
+#define CS_SIDE_44100_B2 9640 /* Floating point value 0.588399 */
+#define CS_SIDE_44100_SCALE 14
+
+/* Stereo Enhancer coefficients for 48000Hz sample rate, scaled with 0.164402 */
+#define CS_MIDDLE_48000_A0 7682 /* Floating point value 0.234445 */
+#define CS_MIDDLE_48000_A1 -7611 /* Floating point value -0.232261 */
+#define CS_MIDDLE_48000_A2 0 /* Floating point value 0.000000 */
+#define CS_MIDDLE_48000_B1 -32333 /* Floating point value -0.986713 */
+#define CS_MIDDLE_48000_B2 0 /* Floating point value 0.000000 */
+#define CS_MIDDLE_48000_SCALE 15
+#define CS_SIDE_48000_A0 4466 /* Floating point value 0.272606 */
+#define CS_SIDE_48000_A1 -4374 /* Floating point value -0.266952 */
+#define CS_SIDE_48000_A2 -93 /* Floating point value -0.005654 */
+#define CS_SIDE_48000_B1 -26495 /* Floating point value -1.617141 */
+#define CS_SIDE_48000_B2 10329 /* Floating point value 0.630405 */
+#define CS_SIDE_48000_SCALE 14
+
+
+/************************************************************************************/
+/* */
+/* The Reverb Unit */
+/* */
+/************************************************************************************/
+
+/* Reverb delay settings in samples */
+#define LVCS_STEREODELAY_CS_8KHZ 93 /* Sample rate 8kS/s */
+#define LVCS_STEREODELAY_CS_11KHZ 128 /* Sample rate 11kS/s */
+#define LVCS_STEREODELAY_CS_12KHZ 139 /* Sample rate 12kS/s */
+#define LVCS_STEREODELAY_CS_16KHZ 186 /* Sample rate 16kS/s */
+#define LVCS_STEREODELAY_CS_22KHZ 256 /* Sample rate 22kS/s */
+#define LVCS_STEREODELAY_CS_24KHZ 279 /* Sample rate 24kS/s */
+#define LVCS_STEREODELAY_CS_32KHZ 372 /* Sample rate 32kS/s */
+#define LVCS_STEREODELAY_CS_44KHZ 512 /* Sample rate 44kS/s */
+#define LVCS_STEREODELAY_CS_48KHZ 512 /* Sample rate 48kS/s */
+
+/* Reverb coefficients for 8000 Hz sample rate, scaled with 1.038030 */
+#define CS_REVERB_8000_A0 21865 /* Floating point value 0.667271 */
+#define CS_REVERB_8000_A1 -21865 /* Floating point value -0.667271 */
+#define CS_REVERB_8000_A2 0 /* Floating point value 0.000000 */
+#define CS_REVERB_8000_B1 -21895 /* Floating point value -0.668179 */
+#define CS_REVERB_8000_B2 0 /* Floating point value 0.000000 */
+#define CS_REVERB_8000_SCALE 15
+
+/* Reverb coefficients for 11025Hz sample rate, scaled with 1.038030 */
+#define CS_REVERB_11025_A0 22926 /* Floating point value 0.699638 */
+#define CS_REVERB_11025_A1 -22926 /* Floating point value -0.699638 */
+#define CS_REVERB_11025_A2 0 /* Floating point value 0.000000 */
+#define CS_REVERB_11025_B1 -24546 /* Floating point value -0.749096 */
+#define CS_REVERB_11025_B2 0 /* Floating point value 0.000000 */
+#define CS_REVERB_11025_SCALE 15
+
+/* Reverb coefficients for 12000Hz sample rate, scaled with 1.038030 */
+#define CS_REVERB_12000_A0 23165 /* Floating point value 0.706931 */
+#define CS_REVERB_12000_A1 -23165 /* Floating point value -0.706931 */
+#define CS_REVERB_12000_A2 0 /* Floating point value 0.000000 */
+#define CS_REVERB_12000_B1 -25144 /* Floating point value -0.767327 */
+#define CS_REVERB_12000_B2 0 /* Floating point value 0.000000 */
+#define CS_REVERB_12000_SCALE 15
+
+/* Reverb coefficients for 16000Hz sample rate, scaled with 1.038030 */
+#define CS_REVERB_16000_A0 23864 /* Floating point value 0.728272 */
+#define CS_REVERB_16000_A1 -23864 /* Floating point value -0.728272 */
+#define CS_REVERB_16000_A2 0 /* Floating point value 0.000000 */
+#define CS_REVERB_16000_B1 -26892 /* Floating point value -0.820679 */
+#define CS_REVERB_16000_B2 0 /* Floating point value 0.000000 */
+#define CS_REVERB_16000_SCALE 15
+
+/* Reverb coefficients for 22050Hz sample rate, scaled with 1.038030 */
+#define CS_REVERB_22050_A0 16921 /* Floating point value 0.516396 */
+#define CS_REVERB_22050_A1 0 /* Floating point value 0.000000 */
+#define CS_REVERB_22050_A2 -16921 /* Floating point value -0.516396 */
+#define CS_REVERB_22050_B1 -16991 /* Floating point value -0.518512 */
+#define CS_REVERB_22050_B2 -9535 /* Floating point value -0.290990 */
+#define CS_REVERB_22050_SCALE 15
+
+/* Reverb coefficients for 24000Hz sample rate, scaled with 1.038030 */
+#define CS_REVERB_24000_A0 15714 /* Floating point value 0.479565 */
+#define CS_REVERB_24000_A1 0 /* Floating point value 0.000000 */
+#define CS_REVERB_24000_A2 -15714 /* Floating point value -0.479565 */
+#define CS_REVERB_24000_B1 -20898 /* Floating point value -0.637745 */
+#define CS_REVERB_24000_B2 -6518 /* Floating point value -0.198912 */
+#define CS_REVERB_24000_SCALE 15
+
+/* Reverb coefficients for 32000Hz sample rate, scaled with 1.038030 */
+#define CS_REVERB_32000_A0 12463 /* Floating point value 0.380349 */
+#define CS_REVERB_32000_A1 0 /* Floating point value 0.000000 */
+#define CS_REVERB_32000_A2 -12463 /* Floating point value -0.380349 */
+#define CS_REVERB_32000_B1 -31158 /* Floating point value -0.950873 */
+#define CS_REVERB_32000_B2 1610 /* Floating point value 0.049127 */
+#define CS_REVERB_32000_SCALE 15
+
+/* Reverb coefficients for 44100Hz sample rate, scaled with 1.038030 */
+#define CS_REVERB_44100_A0 4872 /* Floating point value 0.297389 */
+#define CS_REVERB_44100_A1 0 /* Floating point value 0.000000 */
+#define CS_REVERB_44100_A2 -4872 /* Floating point value -0.297389 */
+#define CS_REVERB_44100_B1 -19668 /* Floating point value -1.200423 */
+#define CS_REVERB_44100_B2 4203 /* Floating point value 0.256529 */
+#define CS_REVERB_44100_SCALE 14
+
+/* Reverb coefficients for 48000Hz sample rate, scaled with 1.038030 */
+#define CS_REVERB_48000_A0 4566 /* Floating point value 0.278661 */
+#define CS_REVERB_48000_A1 0 /* Floating point value 0.000000 */
+#define CS_REVERB_48000_A2 -4566 /* Floating point value -0.278661 */
+#define CS_REVERB_48000_B1 -20562 /* Floating point value -1.254993 */
+#define CS_REVERB_48000_B2 4970 /* Floating point value 0.303347 */
+#define CS_REVERB_48000_SCALE 14
+
+/* Reverb Gain Settings */
+#define LVCS_HEADPHONE_DELAYGAIN 0.800000 /* Algorithm delay path gain */
+#define LVCS_HEADPHONE_OUTPUTGAIN 1.000000 /* Algorithm output gain */
+#define LVCS_HEADPHONE_PROCGAIN 18403 /* Processed path gain */
+#define LVCS_HEADPHONE_UNPROCGAIN 18403 /* Unprocessed path gain */
+#define LVCS_HEADPHONE_GAINCORRECT 1.009343 /* Delay mixer gain correction */
+
+
+/************************************************************************************/
+/* */
+/* The Equaliser */
+/* */
+/************************************************************************************/
+
+/* Equaliser coefficients for 8000 Hz sample rate, CS scaled with 1.038497 and CSEX scaled with 0.775480 */
+#define CS_EQUALISER_8000_A0 20698 /* Floating point value 1.263312 */
+#define CS_EQUALISER_8000_A1 -9859 /* Floating point value -0.601748 */
+#define CS_EQUALISER_8000_A2 -4599 /* Floating point value -0.280681 */
+#define CS_EQUALISER_8000_B1 -7797 /* Floating point value -0.475865 */
+#define CS_EQUALISER_8000_B2 -6687 /* Floating point value -0.408154 */
+#define CS_EQUALISER_8000_SCALE 14
+#define CSEX_EQUALISER_8000_A0 30912 /* Floating point value 0.943357 */
+#define CSEX_EQUALISER_8000_A1 -14724 /* Floating point value -0.449345 */
+#define CSEX_EQUALISER_8000_A2 -6868 /* Floating point value -0.209594 */
+#define CSEX_EQUALISER_8000_B1 -15593 /* Floating point value -0.475865 */
+#define CSEX_EQUALISER_8000_B2 -13374 /* Floating point value -0.408154 */
+#define CSEX_EQUALISER_8000_SCALE 15
+
+/* Equaliser coefficients for 11025Hz sample rate, CS scaled with 1.027761 and CSEX scaled with 0.767463 */
+#define CS_EQUALISER_11025_A0 18041 /* Floating point value 1.101145 */
+#define CS_EQUALISER_11025_A1 2278 /* Floating point value 0.139020 */
+#define CS_EQUALISER_11025_A2 -14163 /* Floating point value -0.864423 */
+#define CS_EQUALISER_11025_B1 402 /* Floating point value 0.024541 */
+#define CS_EQUALISER_11025_B2 -14892 /* Floating point value -0.908930 */
+#define CS_EQUALISER_11025_SCALE 14
+#define CSEX_EQUALISER_11025_A0 31983 /* Floating point value 0.976058 */
+#define CSEX_EQUALISER_11025_A1 -22784 /* Floating point value -0.695326 */
+#define CSEX_EQUALISER_11025_A2 -2976 /* Floating point value -0.090809 */
+#define CSEX_EQUALISER_11025_B1 -20008 /* Floating point value -0.610594 */
+#define CSEX_EQUALISER_11025_B2 -10196 /* Floating point value -0.311149 */
+#define CSEX_EQUALISER_11025_SCALE 15
+
+/* Equaliser coefficients for 12000Hz sample rate, CS scaled with 1.032521 and CSEX scaled with 0.771017 */
+#define CS_EQUALISER_12000_A0 20917 /* Floating point value 1.276661 */
+#define CS_EQUALISER_12000_A1 -16671 /* Floating point value -1.017519 */
+#define CS_EQUALISER_12000_A2 -723 /* Floating point value -0.044128 */
+#define CS_EQUALISER_12000_B1 -11954 /* Floating point value -0.729616 */
+#define CS_EQUALISER_12000_B2 -3351 /* Floating point value -0.204532 */
+#define CS_EQUALISER_12000_SCALE 14
+#define CSEX_EQUALISER_12000_A0 16500 /* Floating point value 1.007095 */
+#define CSEX_EQUALISER_12000_A1 -14285 /* Floating point value -0.871912 */
+#define CSEX_EQUALISER_12000_A2 381 /* Floating point value 0.023232 */
+#define CSEX_EQUALISER_12000_B1 -12220 /* Floating point value -0.745857 */
+#define CSEX_EQUALISER_12000_B2 -3099 /* Floating point value -0.189171 */
+#define CSEX_EQUALISER_12000_SCALE 14
+
+/* Equaliser coefficients for 16000Hz sample rate, CS scaled with 1.031378 and CSEX scaled with 0.770164 */
+#define CS_EQUALISER_16000_A0 20998 /* Floating point value 1.281629 */
+#define CS_EQUALISER_16000_A1 -17627 /* Floating point value -1.075872 */
+#define CS_EQUALISER_16000_A2 -678 /* Floating point value -0.041365 */
+#define CS_EQUALISER_16000_B1 -11882 /* Floating point value -0.725239 */
+#define CS_EQUALISER_16000_B2 -3676 /* Floating point value -0.224358 */
+#define CS_EQUALISER_16000_SCALE 14
+#define CSEX_EQUALISER_16000_A0 17713 /* Floating point value 1.081091 */
+#define CSEX_EQUALISER_16000_A1 -14208 /* Floating point value -0.867183 */
+#define CSEX_EQUALISER_16000_A2 -1151 /* Floating point value -0.070247 */
+#define CSEX_EQUALISER_16000_B1 -8440 /* Floating point value -0.515121 */
+#define CSEX_EQUALISER_16000_B2 -6978 /* Floating point value -0.425893 */
+#define CSEX_EQUALISER_16000_SCALE 14
+
+/* Equaliser coefficients for 22050Hz sample rate, CS scaled with 1.041576 and CSEX scaled with 0.777779 */
+#define CS_EQUALISER_22050_A0 22751 /* Floating point value 1.388605 */
+#define CS_EQUALISER_22050_A1 -21394 /* Floating point value -1.305799 */
+#define CS_EQUALISER_22050_A2 654 /* Floating point value 0.039922 */
+#define CS_EQUALISER_22050_B1 -11788 /* Floating point value -0.719494 */
+#define CS_EQUALISER_22050_B2 -3985 /* Floating point value -0.243245 */
+#define CS_EQUALISER_22050_SCALE 14
+#define CSEX_EQUALISER_22050_A0 20855 /* Floating point value 1.272910 */
+#define CSEX_EQUALISER_22050_A1 -21971 /* Floating point value -1.341014 */
+#define CSEX_EQUALISER_22050_A2 2744 /* Floating point value 0.167462 */
+#define CSEX_EQUALISER_22050_B1 -10063 /* Floating point value -0.614219 */
+#define CSEX_EQUALISER_22050_B2 -5659 /* Floating point value -0.345384 */
+#define CSEX_EQUALISER_22050_SCALE 14
+
+/* Equaliser coefficients for 24000Hz sample rate, CS scaled with 1.034495 and CSEX scaled with 0.772491 */
+#define CS_EQUALISER_24000_A0 23099 /* Floating point value 1.409832 */
+#define CS_EQUALISER_24000_A1 -23863 /* Floating point value -1.456506 */
+#define CS_EQUALISER_24000_A2 2481 /* Floating point value 0.151410 */
+#define CS_EQUALISER_24000_B1 -13176 /* Floating point value -0.804201 */
+#define CS_EQUALISER_24000_B2 -2683 /* Floating point value -0.163783 */
+#define CS_EQUALISER_24000_SCALE 14
+#define CSEX_EQUALISER_24000_A0 21286 /* Floating point value 1.299198 */
+#define CSEX_EQUALISER_24000_A1 -23797 /* Floating point value -1.452447 */
+#define CSEX_EQUALISER_24000_A2 3940 /* Floating point value 0.240489 */
+#define CSEX_EQUALISER_24000_B1 -10966 /* Floating point value -0.669303 */
+#define CSEX_EQUALISER_24000_B2 -4833 /* Floating point value -0.294984 */
+#define CSEX_EQUALISER_24000_SCALE 14
+
+/* Equaliser coefficients for 32000Hz sample rate, CS scaled with 1.044559 and CSEX scaled with 0.780006 */
+#define CS_EQUALISER_32000_A0 25575 /* Floating point value 1.560988 */
+#define CS_EQUALISER_32000_A1 -30765 /* Floating point value -1.877724 */
+#define CS_EQUALISER_32000_A2 6386 /* Floating point value 0.389741 */
+#define CS_EQUALISER_32000_B1 -14867 /* Floating point value -0.907410 */
+#define CS_EQUALISER_32000_B2 -1155 /* Floating point value -0.070489 */
+#define CS_EQUALISER_32000_SCALE 14
+#define CSEX_EQUALISER_32000_A0 14623 /* Floating point value 1.785049 */
+#define CSEX_EQUALISER_32000_A1 -18297 /* Floating point value -2.233497 */
+#define CSEX_EQUALISER_32000_A2 4313 /* Floating point value 0.526431 */
+#define CSEX_EQUALISER_32000_B1 -3653 /* Floating point value -0.445939 */
+#define CSEX_EQUALISER_32000_B2 -4280 /* Floating point value -0.522446 */
+#define CSEX_EQUALISER_32000_SCALE 13
+
+/* Equaliser coefficients for 44100Hz sample rate, CS scaled with 1.022170 and CSEX scaled with 0.763288 */
+#define CS_EQUALISER_44100_A0 13304 /* Floating point value 1.623993 */
+#define CS_EQUALISER_44100_A1 -18602 /* Floating point value -2.270743 */
+#define CS_EQUALISER_44100_A2 5643 /* Floating point value 0.688829 */
+#define CS_EQUALISER_44100_B1 -9152 /* Floating point value -1.117190 */
+#define CS_EQUALISER_44100_B2 1067 /* Floating point value 0.130208 */
+#define CS_EQUALISER_44100_SCALE 13
+#define CSEX_EQUALISER_44100_A0 16616 /* Floating point value 2.028315 */
+#define CSEX_EQUALISER_44100_A1 -23613 /* Floating point value -2.882459 */
+#define CSEX_EQUALISER_44100_A2 7410 /* Floating point value 0.904535 */
+#define CSEX_EQUALISER_44100_B1 -4860 /* Floating point value -0.593308 */
+#define CSEX_EQUALISER_44100_B2 -3161 /* Floating point value -0.385816 */
+#define CSEX_EQUALISER_44100_SCALE 13
+
+/* Equaliser coefficients for 48000Hz sample rate, CS scaled with 1.018635 and CSEX scaled with 0.760648 */
+#define CS_EQUALISER_48000_A0 13445 /* Floating point value 1.641177 */
+#define CS_EQUALISER_48000_A1 -19372 /* Floating point value -2.364687 */
+#define CS_EQUALISER_48000_A2 6225 /* Floating point value 0.759910 */
+#define CS_EQUALISER_48000_B1 -9558 /* Floating point value -1.166774 */
+#define CS_EQUALISER_48000_B2 1459 /* Floating point value 0.178074 */
+#define CS_EQUALISER_48000_SCALE 13
+#define CSEX_EQUALISER_48000_A0 17200 /* Floating point value 2.099655 */
+#define CSEX_EQUALISER_48000_A1 -25110 /* Floating point value -3.065220 */
+#define CSEX_EQUALISER_48000_A2 8277 /* Floating point value 1.010417 */
+#define CSEX_EQUALISER_48000_B1 -5194 /* Floating point value -0.634021 */
+#define CSEX_EQUALISER_48000_B2 -2845 /* Floating point value -0.347332 */
+#define CSEX_EQUALISER_48000_SCALE 13
+
+
+/************************************************************************************/
+/* */
+/* The Output Gain Correction */
+/* */
+/************************************************************************************/
+
+#define LVCS_HEADPHONE_SHIFT 2 /* Output Shift */
+#define LVCS_HEADPHONE_SHIFTLOSS 27779 /* Output Shift loss */
+#define LVCS_HEADPHONE_GAIN 6840 /* Unprocessed path gain */
+#define LVCS_EX_HEADPHONE_SHIFT 3 /* EX Output Shift */
+#define LVCS_EX_HEADPHONE_SHIFTLOSS 18600 /* EX Output Shift loss */
+#define LVCS_EX_HEADPHONE_GAIN 5108 /* EX Unprocessed path gain */
+
+#endif
diff --git a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Init.c b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Init.c
new file mode 100755
index 0000000..4aa95d3
--- /dev/null
+++ b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Init.c
@@ -0,0 +1,233 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1001 $
+ $Date: 2010-06-28 13:23:02 +0200 (Mon, 28 Jun 2010) $
+
+*************************************************************************************/
+
+/************************************************************************************/
+/* */
+/* Includes */
+/* */
+/************************************************************************************/
+
+#include "LVCS.h"
+#include "LVCS_Private.h"
+#include "LVCS_Tables.h"
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVCS_Memory */
+/* */
+/* DESCRIPTION: */
+/* This function is used for memory allocation and free. It can be called in */
+/* two ways: */
+/* */
+/* hInstance = NULL Returns the memory requirements */
+/* hInstance = Instance handle Returns the memory requirements and */
+/* allocated base addresses for the instance */
+/* */
+/* When this function is called for memory allocation (hInstance=NULL) it is */
+/* passed the default capabilities. */
+/* */
+/* When called for memory allocation the memory base address pointers are NULL on */
+/* return. */
+/* */
+/* When the function is called for free (hInstance = Instance Handle) the */
+/* capabilities are ignored and the memory table returns the allocated memory and */
+/* base addresses used during initialisation. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance Handle */
+/* pMemoryTable Pointer to an empty memory definition table */
+/* pCapabilities Pointer to the default capabilites */
+/* */
+/* RETURNS: */
+/* LVCS_Success Succeeded */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVCS_Process function */
+/* */
+/****************************************************************************************/
+
+LVCS_ReturnStatus_en LVCS_Memory(LVCS_Handle_t hInstance,
+ LVCS_MemTab_t *pMemoryTable,
+ LVCS_Capabilities_t *pCapabilities)
+{
+
+ LVM_UINT32 ScratchSize;
+ LVCS_Instance_t *pInstance = (LVCS_Instance_t *)hInstance;
+
+
+ /*
+ * Fill in the memory table
+ */
+ if (hInstance == LVM_NULL)
+ {
+ /*
+ * Instance memory
+ */
+ pMemoryTable->Region[LVCS_MEMREGION_PERSISTENT_SLOW_DATA].Size = (LVM_UINT32)sizeof(LVCS_Instance_t);
+ pMemoryTable->Region[LVCS_MEMREGION_PERSISTENT_SLOW_DATA].Type = LVCS_PERSISTENT;
+ pMemoryTable->Region[LVCS_MEMREGION_PERSISTENT_SLOW_DATA].pBaseAddress = LVM_NULL;
+
+ /*
+ * Data memory
+ */
+ pMemoryTable->Region[LVCS_MEMREGION_PERSISTENT_FAST_DATA].Size = (LVM_UINT32)sizeof(LVCS_Data_t);
+ pMemoryTable->Region[LVCS_MEMREGION_PERSISTENT_FAST_DATA].Type = LVCS_DATA;
+ pMemoryTable->Region[LVCS_MEMREGION_PERSISTENT_FAST_DATA].pBaseAddress = LVM_NULL;
+
+ /*
+ * Coefficient memory
+ */
+ pMemoryTable->Region[LVCS_MEMREGION_PERSISTENT_FAST_COEF].Size = (LVM_UINT32)sizeof(LVCS_Coefficient_t);
+ pMemoryTable->Region[LVCS_MEMREGION_PERSISTENT_FAST_COEF].Type = LVCS_COEFFICIENT;
+ pMemoryTable->Region[LVCS_MEMREGION_PERSISTENT_FAST_COEF].pBaseAddress = LVM_NULL;
+
+ /*
+ * Scratch memory
+ */
+ ScratchSize = (LVM_UINT32)(LVCS_SCRATCHBUFFERS*sizeof(LVM_INT16)*pCapabilities->MaxBlockSize); /* Inplace processing */
+ pMemoryTable->Region[LVCS_MEMREGION_TEMPORARY_FAST].Size = ScratchSize;
+ pMemoryTable->Region[LVCS_MEMREGION_TEMPORARY_FAST].Type = LVCS_SCRATCH;
+ pMemoryTable->Region[LVCS_MEMREGION_TEMPORARY_FAST].pBaseAddress = LVM_NULL;
+ }
+ else
+ {
+ /* Read back memory allocation table */
+ *pMemoryTable = pInstance->MemoryTable;
+ }
+
+ return(LVCS_SUCCESS);
+}
+
+
+/************************************************************************************/
+/* */
+/* FUNCTION: LVCS_Init */
+/* */
+/* DESCRIPTION: */
+/* Create and initialisation function for the Concert Sound module */
+/* */
+/* This function can be used to create an algorithm instance by calling with */
+/* hInstance set to LVM_NULL. In this case the algorithm returns the new instance */
+/* handle. */
+/* */
+/* This function can be used to force a full re-initialisation of the algorithm */
+/* by calling with hInstance = Instance Handle. In this case the memory table */
+/* should be correct for the instance, this can be ensured by calling the function */
+/* LVCS_Memory before calling this function. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* pMemoryTable Pointer to the memory definition table */
+/* pCapabilities Pointer to the capabilities structure */
+/* */
+/* RETURNS: */
+/* LVCS_Success Initialisation succeeded */
+/* */
+/* NOTES: */
+/* 1. The instance handle is the pointer to the base address of the first memory */
+/* region. */
+/* 2. This function must not be interrupted by the LVCS_Process function */
+/* 3. This function must be called with the same capabilities as used for the */
+/* call to the memory function */
+/* */
+/************************************************************************************/
+
+LVCS_ReturnStatus_en LVCS_Init(LVCS_Handle_t *phInstance,
+ LVCS_MemTab_t *pMemoryTable,
+ LVCS_Capabilities_t *pCapabilities)
+{
+
+ LVM_INT16 Offset;
+ LVCS_Instance_t *pInstance;
+ LVCS_VolCorrect_t *pLVCS_VolCorrectTable;
+
+
+ /*
+ * Set the instance handle if not already initialised
+ */
+ if (*phInstance == LVM_NULL)
+ {
+ *phInstance = (LVCS_Handle_t)pMemoryTable->Region[LVCS_MEMREGION_PERSISTENT_SLOW_DATA].pBaseAddress;
+ }
+ pInstance =(LVCS_Instance_t *)*phInstance;
+
+
+ /*
+ * Save the capabilities in the instance structure
+ */
+ pInstance->Capabilities = *pCapabilities;
+
+ /*
+ * Save the memory table in the instance structure
+ */
+ pInstance->MemoryTable = *pMemoryTable;
+
+
+ /*
+ * Set all initial parameters to invalid to force a full initialisation
+ */
+ pInstance->Params.OperatingMode = LVCS_OFF;
+ pInstance->Params.SpeakerType = LVCS_SPEAKERTYPE_MAX;
+ pInstance->OutputDevice = LVCS_HEADPHONE;
+ pInstance->Params.SourceFormat = LVCS_SOURCEMAX;
+ pInstance->Params.CompressorMode = LVM_MODE_OFF;
+ pInstance->Params.SampleRate = LVM_FS_INVALID;
+ pInstance->Params.EffectLevel = 0;
+ pInstance->Params.ReverbLevel = (LVM_UINT16)0x8000;
+ pLVCS_VolCorrectTable = (LVCS_VolCorrect_t*)&LVCS_VolCorrectTable[0];
+ Offset = (LVM_INT16)(pInstance->Params.SpeakerType + (pInstance->Params.SourceFormat*(1+LVCS_EX_HEADPHONES)));
+ pInstance->VolCorrect = pLVCS_VolCorrectTable[Offset];
+ pInstance->TransitionGain = 0;
+ LVC_Mixer_Init(&pInstance->BypassMix.Mixer_Instance.MixerStream[0],0,0);
+ LVC_Mixer_Init(&pInstance->BypassMix.Mixer_Instance.MixerStream[1],0,0);
+
+ /*
+ * Initialise the bypass variables
+ */
+ pInstance->MSBypassMixer.MixerStream[0].CallbackParam = 0;
+ pInstance->MSBypassMixer.MixerStream[0].pCallbackHandle = LVM_NULL;
+ pInstance->MSBypassMixer.MixerStream[0].pCallBack = LVM_NULL;
+ pInstance->MSBypassMixer.MixerStream[0].CallbackSet = 0;
+ LVC_Mixer_Init(&pInstance->MSBypassMixer.MixerStream[0],0,0);
+ LVC_Mixer_SetTimeConstant(&pInstance->MSBypassMixer.MixerStream[0],0,LVM_FS_44100,2);
+
+
+ pInstance->MSBypassMixer.MixerStream[1].CallbackParam = 0;
+ pInstance->MSBypassMixer.MixerStream[1].pCallbackHandle = LVM_NULL;
+ pInstance->MSBypassMixer.MixerStream[1].pCallBack = LVM_NULL;
+ pInstance->MSBypassMixer.MixerStream[1].CallbackSet = 0;
+ LVC_Mixer_Init(&pInstance->MSBypassMixer.MixerStream[1],0,0);
+ LVC_Mixer_SetTimeConstant(&pInstance->MSBypassMixer.MixerStream[1],0,LVM_FS_44100,2);
+
+ pInstance->bInOperatingModeTransition = LVM_FALSE;
+ pInstance->bTimerDone = LVM_FALSE;
+ pInstance->TimerParams.CallBackParam = 0;
+ pInstance->TimerParams.pCallBack = LVCS_TimerCallBack;
+ pInstance->TimerParams.pCallbackInstance = pInstance;
+ pInstance->TimerParams.pCallBackParams = LVM_NULL;
+
+ return(LVCS_SUCCESS);
+}
+
diff --git a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Private.h b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Private.h
new file mode 100755
index 0000000..be30829
--- /dev/null
+++ b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Private.h
@@ -0,0 +1,171 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1001 $
+ $Date: 2010-06-28 13:23:02 +0200 (Mon, 28 Jun 2010) $
+
+*************************************************************************************/
+
+/************************************************************************************/
+/* */
+/* Header file for the private layer interface of concert sound. */
+/* */
+/* This files includes all definitions, types, structures and function */
+/* prototypes required by the execution layer. */
+/* */
+/************************************************************************************/
+
+#ifndef __LVCS_PRIVATE_H__
+#define __LVCS_PRIVATE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/************************************************************************************/
+/* */
+/* Includes */
+/* */
+/************************************************************************************/
+
+#include "LVCS.h" /* Calling or Application layer definitions */
+#include "LVCS_StereoEnhancer.h" /* Stereo enhancer module definitions */
+#include "LVCS_ReverbGenerator.h" /* Reverberation module definitions */
+#include "LVCS_Equaliser.h" /* Equaliser module definitions */
+#include "LVCS_BypassMix.h" /* Bypass Mixer module definitions */
+#include "LVM_Timer.h"
+
+
+/************************************************************************************/
+/* */
+/* Defines */
+/* */
+/************************************************************************************/
+
+/* Configuration switch controls */
+#define LVCS_STEREOENHANCESWITCH 0x0001 /* Stereo enhancement enable control */
+#define LVCS_REVERBSWITCH 0x0002 /* Reverberation enable control */
+#define LVCS_EQUALISERSWITCH 0x0004 /* Equaliser enable control */
+#define LVCS_BYPASSMIXSWITCH 0x0008 /* Bypass mixer enable control */
+
+/* Memory */
+#define LVCS_SCRATCHBUFFERS 6 /* Number of buffers required for inplace processing */
+
+/* General */
+#define LVCS_INVALID 0xFFFF /* Invalid init parameter */
+#define LVCS_BYPASS_MIXER_TC 100 /* Bypass mixer time */
+
+/* Access to external coefficients table */
+#define LVCS_NR_OF_FS 9
+#define LVCS_NR_OF_CHAN_CFG 2
+
+
+/************************************************************************************/
+/* */
+/* Types */
+/* */
+/************************************************************************************/
+
+typedef LVM_UINT16 LVCS_Configuration_t; /* Internal algorithm configuration */
+
+typedef enum
+{
+ LVCS_HEADPHONE = 0,
+ LVCS_DEVICE_MAX = LVM_MAXENUM
+} LVCS_OutputDevice_en;
+
+
+/************************************************************************************/
+/* */
+/* Structures */
+/* */
+/************************************************************************************/
+
+/* Volume correction structure */
+typedef struct
+{
+ LVM_INT16 CompFull; /* Post CS compression 100% effect */
+ LVM_INT16 CompMin; /* Post CS compression 0% effect */
+ LVM_INT16 GainFull; /* CS gain correct 100% effect */
+ LVM_INT16 GainMin; /* CS gain correct 0% effect */
+} LVCS_VolCorrect_t;
+
+/* Instance structure */
+typedef struct
+{
+ /* Public parameters */
+ LVCS_MemTab_t MemoryTable; /* Instance memory allocation table */
+ LVCS_Params_t Params; /* Instance parameters */
+ LVCS_Capabilities_t Capabilities; /* Initialisation capabilities */
+
+ /* Private parameters */
+ LVCS_OutputDevice_en OutputDevice; /* Selected output device type */
+ LVCS_VolCorrect_t VolCorrect; /* Volume correction settings */
+ LVM_INT16 TransitionGain; /* Transition gain */
+
+ /* Sub-block configurations */
+ LVCS_StereoEnhancer_t StereoEnhancer; /* Stereo enhancer configuration */
+ LVCS_ReverbGenerator_t Reverberation; /* Reverberation configuration */
+ LVCS_Equaliser_t Equaliser; /* Equaliser configuration */
+ LVCS_BypassMix_t BypassMix; /* Bypass mixer configuration */
+
+ /* Bypass variable */
+ LVMixer3_2St_st MSBypassMixer; /* Bypass mixer used in transitions in MS mode */
+ LVM_INT16 bInOperatingModeTransition; /* Operating mode transition flag */
+ LVM_INT16 bTimerDone; /* Timer completion flag */
+ LVM_Timer_Params_t TimerParams; /* Timer parameters */
+ LVM_Timer_Instance_t TimerInstance; /* Timer instance */
+
+} LVCS_Instance_t;
+
+/* Coefficient Structure */
+typedef struct
+{
+ Biquad_Instance_t EqualiserBiquadInstance;
+ Biquad_Instance_t ReverbBiquadInstance;
+ Biquad_Instance_t SEBiquadInstanceMid;
+ Biquad_Instance_t SEBiquadInstanceSide;
+
+} LVCS_Coefficient_t;
+
+/* Data Structure */
+typedef struct
+{
+ Biquad_2I_Order2_Taps_t EqualiserBiquadTaps;
+ Biquad_2I_Order2_Taps_t ReverbBiquadTaps;
+ Biquad_1I_Order1_Taps_t SEBiquadTapsMid;
+ Biquad_1I_Order2_Taps_t SEBiquadTapsSide;
+
+} LVCS_Data_t;
+
+
+void LVCS_TimerCallBack ( void* hInstance,
+ void* pCallBackParams,
+ LVM_INT32 CallbackParam);
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* PRIVATE_H */
+
+
diff --git a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Process.c b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Process.c
new file mode 100755
index 0000000..999b8bb
--- /dev/null
+++ b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Process.c
@@ -0,0 +1,271 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1001 $
+ $Date: 2010-06-28 13:23:02 +0200 (Mon, 28 Jun 2010) $
+
+*************************************************************************************/
+
+
+/************************************************************************************/
+/* */
+/* Includes */
+/* */
+/************************************************************************************/
+
+#include "LVCS.h"
+#include "LVCS_Private.h"
+#include "VectorArithmetic.h"
+#include "CompLim.h"
+
+/************************************************************************************/
+/* */
+/* FUNCTION: LVCS_Process_CS */
+/* */
+/* DESCRIPTION: */
+/* Process function for the Concert Sound module based on the following block */
+/* diagram: */
+/* _________ ________ _____ _______ ___ ______ */
+/* | | | | | | | | | | | | */
+/* ----->| Stereo |->| Reverb |->| Equ |->| Alpha |-->| + |-| Gain |----> */
+/* | | Enhance | |________| |_____| |_______| |___| |______| */
+/* | |_________| | */
+/* | ___________ | */
+/* | | | | */
+/* |------------------------------->| 1 - Alpha |-----| */
+/* |___________| */
+/* */
+/* The Stereo Enhancer, Reverb and Equaliser blocks are each configured to have */
+/* their gain to give a near peak to peak output (-0.1dBFS) with a worst case */
+/* input signal. The gains of these blocks are re-combined in the Alpha mixer and */
+/* the gain block folloing the sum. */
+/* */
+/* The processing uses the output buffer for data storage after each processing */
+/* block. When processing is inplace a copy of the input signal is made in scratch */
+/* memory for the 1-Alpha path. */
+/* */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* pInData Pointer to the input data */
+/* pOutData Pointer to the output data */
+/* NumSamples Number of samples in the input buffer */
+/* */
+/* RETURNS: */
+/* LVCS_Success Succeeded */
+/* */
+/* NOTES: */
+/* */
+/************************************************************************************/
+
+LVCS_ReturnStatus_en LVCS_Process_CS(LVCS_Handle_t hInstance,
+ const LVM_INT16 *pInData,
+ LVM_INT16 *pOutData,
+ LVM_UINT16 NumSamples)
+{
+ const LVM_INT16 *pInput;
+ LVCS_Instance_t *pInstance = (LVCS_Instance_t *)hInstance;
+ LVM_INT16 *pScratch = (LVM_INT16 *)pInstance->MemoryTable.Region[LVCS_MEMREGION_TEMPORARY_FAST].pBaseAddress;
+ LVCS_ReturnStatus_en err;
+
+ /*
+ * Check if the processing is inplace
+ */
+ if (pInData == pOutData)
+ {
+ /* Processing inplace */
+ pInput = pScratch + (2*NumSamples);
+ Copy_16((LVM_INT16 *)pInData, /* Source */
+ (LVM_INT16 *)pInput, /* Destination */
+ (LVM_INT16)(2*NumSamples)); /* Left and right */
+ }
+ else
+ {
+ /* Processing outplace */
+ pInput = pInData;
+ }
+
+ /*
+ * Call the stereo enhancer
+ */
+ err=LVCS_StereoEnhancer(hInstance, /* Instance handle */
+ pInData, /* Pointer to the input data */
+ pOutData, /* Pointer to the output data */
+ NumSamples); /* Number of samples to process */
+
+ /*
+ * Call the reverb generator
+ */
+ err=LVCS_ReverbGenerator(hInstance, /* Instance handle */
+ pOutData, /* Pointer to the input data */
+ pOutData, /* Pointer to the output data */
+ NumSamples); /* Number of samples to process */
+
+ /*
+ * Call the equaliser
+ */
+ err=LVCS_Equaliser(hInstance, /* Instance handle */
+ pOutData, /* Pointer to the input data */
+ NumSamples); /* Number of samples to process */
+
+ /*
+ * Call the bypass mixer
+ */
+ err=LVCS_BypassMixer(hInstance, /* Instance handle */
+ pOutData, /* Pointer to the processed data */
+ pInput, /* Pointer to the input (unprocessed) data */
+ pOutData, /* Pointer to the output data */
+ NumSamples); /* Number of samples to process */
+
+ if(err !=LVCS_SUCCESS)
+ {
+ return err;
+ }
+
+ return(LVCS_SUCCESS);
+}
+
+/************************************************************************************/
+/* */
+/* FUNCTION: LVCS_Process */
+/* */
+/* DESCRIPTION: */
+/* Process function for the Concert Sound module. The implementation supports two */
+/* variants of the algorithm, one for headphones and one for mobile speakers. */
+/* */
+/* Data can be processed in two formats, stereo or mono-in-stereo. Data in mono */
+/* format is not supported, the calling routine must convert the mono stream to */
+/* mono-in-stereo. */
+/* */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* pInData Pointer to the input data */
+/* pOutData Pointer to the output data */
+/* NumSamples Number of samples in the input buffer */
+/* */
+/* RETURNS: */
+/* LVCS_Success Succeeded */
+/* LVCS_TooManySamples NumSamples was larger than the maximum block size */
+/* */
+/* NOTES: */
+/* */
+/************************************************************************************/
+
+LVCS_ReturnStatus_en LVCS_Process(LVCS_Handle_t hInstance,
+ const LVM_INT16 *pInData,
+ LVM_INT16 *pOutData,
+ LVM_UINT16 NumSamples)
+{
+
+ LVCS_Instance_t *pInstance =(LVCS_Instance_t *)hInstance;
+ LVCS_ReturnStatus_en err;
+
+ /*
+ * Check the number of samples is not too large
+ */
+ if (NumSamples > pInstance->Capabilities.MaxBlockSize)
+ {
+ return(LVCS_TOOMANYSAMPLES);
+ }
+
+ /*
+ * Check if the algorithm is enabled
+ */
+ if (pInstance->Params.OperatingMode != LVCS_OFF)
+ {
+ /*
+ * Call CS process function
+ */
+ err=LVCS_Process_CS(hInstance,
+ pInData,
+ pOutData,
+ NumSamples);
+
+ /*
+ * Compress to reduce expansion effect of Concert Sound and correct volume
+ * differences for difference settings. Not applied in test modes
+ */
+ if ((pInstance->Params.OperatingMode == LVCS_ON)&&(pInstance->Params.CompressorMode == LVM_MODE_ON))
+ {
+ LVM_INT16 Gain = pInstance->VolCorrect.CompMin;
+ LVM_INT32 Current1;
+
+ Current1 = LVC_Mixer_GetCurrent(&pInstance->BypassMix.Mixer_Instance.MixerStream[0]);
+ Gain = (LVM_INT16)( pInstance->VolCorrect.CompMin
+ - (((LVM_INT32)pInstance->VolCorrect.CompMin * (Current1)) >> 15)
+ + (((LVM_INT32)pInstance->VolCorrect.CompFull * (Current1)) >> 15) );
+
+ NonLinComp_D16(Gain, /* Compressor gain setting */
+ pOutData,
+ pOutData,
+ (LVM_INT32)(2*NumSamples));
+ }
+
+
+ if(pInstance->bInOperatingModeTransition == LVM_TRUE){
+
+ /*
+ * Re-init bypass mix when timer has completed
+ */
+ if ((pInstance->bTimerDone == LVM_TRUE) &&
+ (pInstance->BypassMix.Mixer_Instance.MixerStream[1].CallbackSet == 0))
+ {
+ err=LVCS_BypassMixInit(hInstance,
+ &pInstance->Params);
+
+ if(err != LVCS_SUCCESS)
+ {
+ return err;
+ }
+
+ }
+ else{
+ LVM_Timer ( &pInstance->TimerInstance,
+ (LVM_INT16)NumSamples);
+ }
+ }
+ }
+ else
+ {
+ if (pInData != pOutData)
+ {
+ /*
+ * The algorithm is disabled so just copy the data
+ */
+ Copy_16((LVM_INT16 *)pInData, /* Source */
+ (LVM_INT16 *)pOutData, /* Destination */
+ (LVM_INT16)(2*NumSamples)); /* Left and right */
+ }
+ }
+
+
+ return(LVCS_SUCCESS);
+}
+
+
+
+
+
+
+
+
+
+
diff --git a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_ReverbGenerator.c b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_ReverbGenerator.c
new file mode 100755
index 0000000..2efef84
--- /dev/null
+++ b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_ReverbGenerator.c
@@ -0,0 +1,272 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1001 $
+ $Date: 2010-06-28 13:23:02 +0200 (Mon, 28 Jun 2010) $
+
+*************************************************************************************/
+
+/************************************************************************************/
+/* */
+/* Includes */
+/* */
+/************************************************************************************/
+
+#include "LVCS.h"
+#include "LVCS_Private.h"
+#include "LVCS_ReverbGenerator.h"
+#include "LVC_Mixer.h"
+#include "VectorArithmetic.h"
+#include "BIQUAD.h"
+#include "LVCS_Tables.h"
+
+/************************************************************************************/
+/* */
+/* FUNCTION: LVCS_ReverbGeneratorInit */
+/* */
+/* DESCRIPTION: */
+/* Initialises the reverb module. The delay buffer size is configured for the */
+/* sample rate and the speaker type. */
+/* */
+/* The routine may also be called for re-initialisation, i.e. when one of the */
+/* control parameters has changed. In this case the delay and filters are only */
+/* re-initialised if one of the following two conditions is met: */
+/* - the sample rate has changed */
+/* - the speaker type changes to/from the mobile speaker */
+/* */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance Handle */
+/* pParams Pointer to the inialisation parameters */
+/* */
+/* RETURNS: */
+/* LVCS_Success Always succeeds */
+/* */
+/* NOTES: */
+/* 1. In the delay settings 'Samples' is the number of samples to the end of the */
+/* buffer. */
+/* 2. The numerator coefficients of the filter are negated to cause an inversion. */
+/* */
+/************************************************************************************/
+
+LVCS_ReturnStatus_en LVCS_ReverbGeneratorInit(LVCS_Handle_t hInstance,
+ LVCS_Params_t *pParams)
+{
+
+ LVM_UINT16 Delay;
+ LVM_UINT16 Offset;
+ LVCS_Instance_t *pInstance = (LVCS_Instance_t *)hInstance;
+ LVCS_ReverbGenerator_t *pConfig = (LVCS_ReverbGenerator_t *)&pInstance->Reverberation;
+ LVCS_Data_t *pData = (LVCS_Data_t *)pInstance->MemoryTable.Region[LVCS_MEMREGION_PERSISTENT_FAST_DATA].pBaseAddress;
+ LVCS_Coefficient_t *pCoefficients = (LVCS_Coefficient_t *)pInstance->MemoryTable.Region[LVCS_MEMREGION_PERSISTENT_FAST_COEF].pBaseAddress;
+ BQ_C16_Coefs_t Coeffs;
+ const BiquadA012B12CoefsSP_t *pReverbCoefTable;
+
+ /*
+ * Initialise the delay and filters if:
+ * - the sample rate has changed
+ * - the speaker type has changed to or from the mobile speaker
+ */
+ if(pInstance->Params.SampleRate != pParams->SampleRate ) /* Sample rate change test */
+
+ {
+ /*
+ * Setup the delay
+ */
+ Delay = (LVM_UINT16)LVCS_StereoDelayCS[(LVM_UINT16)pParams->SampleRate];
+
+
+ pConfig->DelaySize = (LVM_INT16)(2 * Delay);
+ pConfig->DelayOffset = 0;
+ LoadConst_16(0, /* Value */
+ (LVM_INT16 *)&pConfig->StereoSamples[0], /* Destination */
+ (LVM_UINT16)(sizeof(pConfig->StereoSamples)/sizeof(LVM_INT16))); /* Number of words */
+
+ /*
+ * Setup the filters
+ */
+ Offset = (LVM_UINT16)pParams->SampleRate;
+ pReverbCoefTable = (BiquadA012B12CoefsSP_t*)&LVCS_ReverbCoefTable[0];
+
+ /* Convert incoming coefficients to the required format/ordering */
+ Coeffs.A0 = (LVM_INT16)pReverbCoefTable[Offset].A0;
+ Coeffs.A1 = (LVM_INT16)pReverbCoefTable[Offset].A1;
+ Coeffs.A2 = (LVM_INT16)pReverbCoefTable[Offset].A2;
+ Coeffs.B1 = (LVM_INT16)-pReverbCoefTable[Offset].B1;
+ Coeffs.B2 = (LVM_INT16)-pReverbCoefTable[Offset].B2;
+
+ LoadConst_16(0, /* Value */
+ (LVM_INT16 *)&pData->ReverbBiquadTaps, /* Destination */
+ (LVM_UINT16)(sizeof(pData->ReverbBiquadTaps)/sizeof(LVM_INT16))); /* Number of words */
+
+ BQ_2I_D16F16Css_TRC_WRA_01_Init(&pCoefficients->ReverbBiquadInstance,
+ &pData->ReverbBiquadTaps,
+ &Coeffs);
+
+ /* Callbacks */
+ switch(pReverbCoefTable[Offset].Scale)
+ {
+ case 14:
+ pConfig->pBiquadCallBack = BQ_2I_D16F16C14_TRC_WRA_01;
+ break;
+ case 15:
+ pConfig->pBiquadCallBack = BQ_2I_D16F16C15_TRC_WRA_01;
+ break;
+ }
+
+
+ /*
+ * Setup the mixer
+ */
+ pConfig->ProcGain = (LVM_UINT16)(HEADPHONEGAINPROC);
+ pConfig->UnprocGain = (LVM_UINT16)(HEADPHONEGAINUNPROC);
+ }
+
+ if(pInstance->Params.ReverbLevel != pParams->ReverbLevel)
+ {
+ LVM_INT32 ReverbPercentage=83886; // 1 Percent Reverb i.e 1/100 in Q 23 format
+ ReverbPercentage*=pParams->ReverbLevel; // Actual Reverb Level in Q 23 format
+ pConfig->ReverbLevel=(LVM_INT16)(ReverbPercentage>>8); // Reverb Level in Q 15 format
+ }
+
+ return(LVCS_SUCCESS);
+}
+
+/************************************************************************************/
+/* */
+/* FUNCTION: LVCS_Reverb */
+/* */
+/* DESCRIPTION: */
+/* Create reverb using the block of input samples based on the following block */
+/* diagram: */
+/* ________ ________ */
+/* | | | | */
+/* _____ _______ | |----------->| | ______ ___ */
+/* | | | | | Stereo | | L & R | | | | | */
+/* -->| LPF |-->| Delay |-->| to | ____ | to |-->| Gain |-->| + |--> */
+/* | |_____| |_______| | L & R | | | | Stereo | |______| |___| */
+/* | | |-->| -1 |-->| | | */
+/* | |________| |____| |________| | */
+/* | | */
+/* |-----------------------------------------------------------------------| */
+/* */
+/* The input buffer is broken in to sub-blocks of the size of the delay or less. */
+/* This allows the delay buffer to be treated as a circular buffer but processed */
+/* as a linear buffer. */
+/* */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance Handle */
+/* pInData Pointer to the input buffer */
+/* pOutData Pointer to the output buffer */
+/* NumSamples Number of samples to process */
+/* */
+/* RETURNS: */
+/* LVCS_Success Always succeeds */
+/* */
+/* NOTES: */
+/* 1. Process in blocks of samples the size of the delay where possible, if not */
+/* the number of samples left over */
+/* 2. The Gain is combined with the LPF and incorporated in to the coefficients */
+/* */
+/************************************************************************************/
+
+LVCS_ReturnStatus_en LVCS_ReverbGenerator(LVCS_Handle_t hInstance,
+ const LVM_INT16 *pInData,
+ LVM_INT16 *pOutData,
+ LVM_UINT16 NumSamples)
+{
+
+ LVCS_Instance_t *pInstance = (LVCS_Instance_t *)hInstance;
+ LVCS_ReverbGenerator_t *pConfig = (LVCS_ReverbGenerator_t *)&pInstance->Reverberation;
+ LVCS_Coefficient_t *pCoefficients = (LVCS_Coefficient_t *)pInstance->MemoryTable.Region[LVCS_MEMREGION_PERSISTENT_FAST_COEF].pBaseAddress;
+ LVM_INT16 *pScratch = (LVM_INT16 *)pInstance->MemoryTable.Region[LVCS_MEMREGION_TEMPORARY_FAST].pBaseAddress;
+
+
+ /*
+ * Copy the data to the output in outplace processing
+ */
+ if (pInData != pOutData)
+ {
+ /*
+ * Reverb not required so just copy the data
+ */
+ Copy_16((LVM_INT16 *)pInData, /* Source */
+ (LVM_INT16 *)pOutData, /* Destination */
+ (LVM_INT16)(2*NumSamples)); /* Left and right */
+ }
+
+
+ /*
+ * Check if the reverb is required
+ */
+ if (((pInstance->Params.SpeakerType == LVCS_HEADPHONE) || /* Disable when CS4MS in stereo mode */
+ (pInstance->Params.SpeakerType == LVCS_EX_HEADPHONES) ||
+ (pInstance->Params.SourceFormat != LVCS_STEREO)) &&
+ ((pInstance->Params.OperatingMode & LVCS_REVERBSWITCH) !=0)) /* For validation testing */
+ {
+ /********************************************************************************/
+ /* */
+ /* Copy the input data to scratch memory and filter it */
+ /* */
+ /********************************************************************************/
+
+ /*
+ * Copy the input data to the scratch memory
+ */
+ Copy_16((LVM_INT16 *)pInData, /* Source */
+ (LVM_INT16 *)pScratch, /* Destination */
+ (LVM_INT16)(2*NumSamples)); /* Left and right */
+
+
+ /*
+ * Filter the data
+ */
+ (pConfig->pBiquadCallBack)((Biquad_Instance_t*)&pCoefficients->ReverbBiquadInstance,
+ (LVM_INT16 *)pScratch,
+ (LVM_INT16 *)pScratch,
+ (LVM_INT16)NumSamples);
+
+ Mult3s_16x16( (LVM_INT16 *)pScratch,
+ pConfig->ReverbLevel,
+ (LVM_INT16 *)pScratch,
+ (LVM_INT16)(2*NumSamples));
+
+
+ /*
+ * Apply the delay mix
+ */
+ DelayMix_16x16((LVM_INT16 *)pScratch,
+ &pConfig->StereoSamples[0],
+ pConfig->DelaySize,
+ pOutData,
+ &pConfig->DelayOffset,
+ (LVM_INT16)NumSamples);
+
+
+ }
+
+ return(LVCS_SUCCESS);
+}
+
+
+
+
+
diff --git a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_ReverbGenerator.h b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_ReverbGenerator.h
new file mode 100755
index 0000000..1164bce
--- /dev/null
+++ b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_ReverbGenerator.h
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1001 $
+ $Date: 2010-06-28 13:23:02 +0200 (Mon, 28 Jun 2010) $
+
+*************************************************************************************/
+
+#ifndef __LVCS_REVERBGENERATOR_H__
+#define __LVCS_REVERBGENERATOR_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/************************************************************************************/
+/* */
+/* Includes */
+/* */
+/************************************************************************************/
+
+#include "LVC_Mixer.h"
+
+
+/************************************************************************************/
+/* */
+/* Defines */
+/* */
+/************************************************************************************/
+
+#define HEADPHONEGAINPROC LVCS_HEADPHONE_PROCGAIN
+#define HEADPHONEGAINUNPROC LVCS_HEADPHONE_UNPROCGAIN
+
+
+/************************************************************************************/
+/* */
+/* Structures */
+/* */
+/************************************************************************************/
+
+
+/* Reverberation module structure */
+typedef struct
+{
+
+ /* Stereo delay */
+ LVM_INT16 DelaySize;
+ LVM_INT16 DelayOffset;
+ LVM_INT16 ProcGain;
+ LVM_INT16 UnprocGain;
+ LVM_INT16 StereoSamples[2*LVCS_STEREODELAY_CS_48KHZ];
+
+ /* Reverb Level */
+ LVM_INT16 ReverbLevel;
+
+ /* Filter */
+ void (*pBiquadCallBack) (Biquad_Instance_t*, LVM_INT16*, LVM_INT16*, LVM_INT16);
+
+} LVCS_ReverbGenerator_t;
+
+
+/************************************************************************************/
+/* */
+/* Function prototypes */
+/* */
+/************************************************************************************/
+
+LVCS_ReturnStatus_en LVCS_ReverbGeneratorInit(LVCS_Handle_t hInstance,
+ LVCS_Params_t *pParams);
+
+LVCS_ReturnStatus_en LVCS_ReverbGenerator(LVCS_Handle_t hInstance,
+ const LVM_INT16 *pInput,
+ LVM_INT16 *pOutput,
+ LVM_UINT16 NumSamples);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* REVERB_H */
diff --git a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_StereoEnhancer.c b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_StereoEnhancer.c
new file mode 100755
index 0000000..4ff4716
--- /dev/null
+++ b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_StereoEnhancer.c
@@ -0,0 +1,266 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1001 $
+ $Date: 2010-06-28 13:23:02 +0200 (Mon, 28 Jun 2010) $
+
+*************************************************************************************/
+
+/************************************************************************************/
+/* */
+/* Includes */
+/* */
+/************************************************************************************/
+
+#include "LVCS.h"
+#include "LVCS_Private.h"
+#include "LVCS_StereoEnhancer.h"
+#include "VectorArithmetic.h"
+#include "LVCS_Tables.h"
+
+/************************************************************************************/
+/* */
+/* FUNCTION: LVCS_StereoEnhanceInit */
+/* */
+/* DESCRIPTION: */
+/* Initialises the stereo enhancement module based on the sample rate. */
+/* */
+/* The function selects the coefficients for the filters and clears the data */
+/* history. It is also used for re-initialisation when one of the system control */
+/* parameters changes but will only change the coefficients and clear the history */
+/* if the sample rate or speaker type has changed. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance Handle */
+/* pParams Initialisation parameters */
+/* */
+/* RETURNS: */
+/* LVCS_Success Always succeeds */
+/* */
+/* NOTES: */
+/* */
+/************************************************************************************/
+
+LVCS_ReturnStatus_en LVCS_SEnhancerInit(LVCS_Handle_t hInstance,
+ LVCS_Params_t *pParams)
+{
+
+ LVM_UINT16 Offset;
+ LVCS_Instance_t *pInstance = (LVCS_Instance_t *)hInstance;
+ LVCS_StereoEnhancer_t *pConfig = (LVCS_StereoEnhancer_t *)&pInstance->StereoEnhancer;
+ LVCS_Data_t *pData = (LVCS_Data_t *)pInstance->MemoryTable.Region[LVCS_MEMREGION_PERSISTENT_FAST_DATA].pBaseAddress;
+ LVCS_Coefficient_t *pCoefficient = (LVCS_Coefficient_t *)pInstance->MemoryTable.Region[LVCS_MEMREGION_PERSISTENT_FAST_COEF].pBaseAddress;
+ FO_C16_Coefs_t CoeffsMid;
+ BQ_C16_Coefs_t CoeffsSide;
+ const BiquadA012B12CoefsSP_t *pSESideCoefs;
+
+ /*
+ * If the sample rate or speaker type has changed update the filters
+ */
+ if ((pInstance->Params.SampleRate != pParams->SampleRate) ||
+ (pInstance->Params.SpeakerType != pParams->SpeakerType))
+ {
+ /*
+ * Set the filter coefficients based on the sample rate
+ */
+ /* Mid filter */
+ Offset = (LVM_UINT16)pParams->SampleRate;
+
+ /* Convert incoming coefficients to the required format/ordering */
+ CoeffsMid.A0 = (LVM_INT16) LVCS_SEMidCoefTable[Offset].A0;
+ CoeffsMid.A1 = (LVM_INT16) LVCS_SEMidCoefTable[Offset].A1;
+ CoeffsMid.B1 = (LVM_INT16)-LVCS_SEMidCoefTable[Offset].B1;
+
+ /* Clear the taps */
+ LoadConst_16(0, /* Value */
+ (LVM_INT16 *)&pData->SEBiquadTapsMid, /* Destination */
+ (LVM_UINT16)(sizeof(pData->SEBiquadTapsMid)/sizeof(LVM_UINT16))); /* Number of words */
+
+ FO_1I_D16F16Css_TRC_WRA_01_Init(&pCoefficient->SEBiquadInstanceMid,
+ &pData->SEBiquadTapsMid,
+ &CoeffsMid);
+
+ /* Callbacks */
+ if(LVCS_SEMidCoefTable[Offset].Scale==15)
+ {
+ pConfig->pBiquadCallBack_Mid = FO_1I_D16F16C15_TRC_WRA_01;
+ }
+
+ Offset = (LVM_UINT16)(pParams->SampleRate);
+ pSESideCoefs = (BiquadA012B12CoefsSP_t*)&LVCS_SESideCoefTable[0];
+
+ /* Side filter */
+ /* Convert incoming coefficients to the required format/ordering */
+ CoeffsSide.A0 = (LVM_INT16) pSESideCoefs[Offset].A0;
+ CoeffsSide.A1 = (LVM_INT16) pSESideCoefs[Offset].A1;
+ CoeffsSide.A2 = (LVM_INT16) pSESideCoefs[Offset].A2;
+ CoeffsSide.B1 = (LVM_INT16)-pSESideCoefs[Offset].B1;
+ CoeffsSide.B2 = (LVM_INT16)-pSESideCoefs[Offset].B2;
+
+ /* Clear the taps */
+ LoadConst_16(0, /* Value */
+ (LVM_INT16 *)&pData->SEBiquadTapsSide, /* Destination */
+ (LVM_UINT16)(sizeof(pData->SEBiquadTapsSide)/sizeof(LVM_UINT16))); /* Number of words */
+
+
+ /* Callbacks */
+ switch(pSESideCoefs[Offset].Scale)
+ {
+ case 14:
+ BQ_1I_D16F32Css_TRC_WRA_01_Init(&pCoefficient->SEBiquadInstanceSide,
+ &pData->SEBiquadTapsSide,
+ &CoeffsSide);
+
+ pConfig->pBiquadCallBack_Side = BQ_1I_D16F32C14_TRC_WRA_01;
+ break;
+ case 15:
+ BQ_1I_D16F16Css_TRC_WRA_01_Init(&pCoefficient->SEBiquadInstanceSide,
+ &pData->SEBiquadTapsSide,
+ &CoeffsSide);
+
+ pConfig->pBiquadCallBack_Side = BQ_1I_D16F16C15_TRC_WRA_01;
+ break;
+ }
+
+ }
+
+
+ return(LVCS_SUCCESS);
+}
+
+/************************************************************************************/
+/* */
+/* FUNCTION: LVCS_StereoEnhance */
+/* */
+/* DESCRIPTION: */
+/* Enhance the stereo image in the input samples based on the following block */
+/* diagram: */
+/* */
+/* ________ */
+/* ________ | | ________ */
+/* | | Middle | Treble | | | */
+/* | |---------->| Boost |-------->| | */
+/* | Stereo | |________| | M & S | */
+/* -->| to | ________ | to |--> */
+/* | M & S | Side | | | Stereo | */
+/* | |---------->| Side |-------->| | */
+/* |________| | Boost | |________| */
+/* |________| */
+/* */
+/* */
+/* If the input signal is a mono signal there will be no side signal and hence */
+/* the side filter will not be run. In mobile speaker mode the middle filter is */
+/* not required and the Trebble boost filter is replaced by a simple gain block. */
+/* */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance Handle */
+/* pInData Pointer to the input data */
+/* pOutData Pointer to the output data */
+/* NumSamples Number of samples to process */
+/* */
+/* RETURNS: */
+/* LVCS_Success Always succeeds */
+/* */
+/* NOTES: */
+/* 1. The side filter is not used in Mobile Speaker mode */
+/* */
+/************************************************************************************/
+
+LVCS_ReturnStatus_en LVCS_StereoEnhancer(LVCS_Handle_t hInstance,
+ const LVM_INT16 *pInData,
+ LVM_INT16 *pOutData,
+ LVM_UINT16 NumSamples)
+{
+
+ LVCS_Instance_t *pInstance = (LVCS_Instance_t *)hInstance;
+ LVCS_StereoEnhancer_t *pConfig = (LVCS_StereoEnhancer_t *)&pInstance->StereoEnhancer;
+ LVCS_Coefficient_t *pCoefficient = (LVCS_Coefficient_t *)pInstance->MemoryTable.Region[LVCS_MEMREGION_PERSISTENT_FAST_COEF].pBaseAddress;
+ LVM_INT16 *pScratch = (LVM_INT16 *)pInstance->MemoryTable.Region[LVCS_MEMREGION_TEMPORARY_FAST].pBaseAddress;
+
+ /*
+ * Check if the Stereo Enhancer is enabled
+ */
+ if ((pInstance->Params.OperatingMode & LVCS_STEREOENHANCESWITCH) != 0)
+ {
+ /*
+ * Convert from stereo to middle and side
+ */
+ From2iToMS_16x16(pInData,
+ pScratch,
+ pScratch+NumSamples,
+ (LVM_INT16)NumSamples);
+
+ /*
+ * Apply filter to the middle signal
+ */
+ if (pInstance->OutputDevice == LVCS_HEADPHONE)
+ {
+ (pConfig->pBiquadCallBack_Mid)((Biquad_Instance_t*)&pCoefficient->SEBiquadInstanceMid,
+ (LVM_INT16 *)pScratch,
+ (LVM_INT16 *)pScratch,
+ (LVM_INT16)NumSamples);
+ }
+ else
+ {
+ Mult3s_16x16(pScratch, /* Source */
+ (LVM_INT16)pConfig->MidGain, /* Gain */
+ pScratch, /* Destination */
+ (LVM_INT16)NumSamples); /* Number of samples */
+ }
+
+ /*
+ * Apply the filter the side signal only in stereo mode for headphones
+ * and in all modes for mobile speakers
+ */
+ if (pInstance->Params.SourceFormat == LVCS_STEREO)
+ {
+ (pConfig->pBiquadCallBack_Side)((Biquad_Instance_t*)&pCoefficient->SEBiquadInstanceSide,
+ (LVM_INT16 *)(pScratch + NumSamples),
+ (LVM_INT16 *)(pScratch + NumSamples),
+ (LVM_INT16)NumSamples);
+ }
+
+ /*
+ * Convert from middle and side to stereo
+ */
+ MSTo2i_Sat_16x16(pScratch,
+ pScratch+NumSamples,
+ pOutData,
+ (LVM_INT16)NumSamples);
+
+ }
+ else
+ {
+ /*
+ * The stereo enhancer is disabled so just copy the data
+ */
+ Copy_16((LVM_INT16 *)pInData, /* Source */
+ (LVM_INT16 *)pOutData, /* Destination */
+ (LVM_INT16)(2*NumSamples)); /* Left and right */
+
+ }
+
+ return(LVCS_SUCCESS);
+}
+
+
+
+
diff --git a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_StereoEnhancer.h b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_StereoEnhancer.h
new file mode 100755
index 0000000..c3f6296
--- /dev/null
+++ b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_StereoEnhancer.h
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1001 $
+ $Date: 2010-06-28 13:23:02 +0200 (Mon, 28 Jun 2010) $
+
+*************************************************************************************/
+
+#ifndef __LVCS_STEREOENHANCER_H__
+#define __LVCS_STEREOENHANCER_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/************************************************************************************/
+/* */
+/* Includes */
+/* */
+/************************************************************************************/
+
+#include "Filters.h" /* Filter definitions */
+#include "LVCS_Headphone_Coeffs.h" /* Headphone coefficients */
+#include "BIQUAD.h"
+
+
+/************************************************************************************/
+/* */
+/* Structures */
+/* */
+/************************************************************************************/
+
+/* Stereo enhancer structure */
+typedef struct
+{
+ /*
+ * Middle filter
+ */
+ void (*pBiquadCallBack_Mid)(Biquad_Instance_t*, LVM_INT16*, LVM_INT16*, LVM_INT16);
+
+ /*
+ * Side filter
+ */
+ void (*pBiquadCallBack_Side)(Biquad_Instance_t*, LVM_INT16*, LVM_INT16*, LVM_INT16);
+
+ LVM_UINT16 MidGain; /* Middle gain in mobile speaker mode */
+
+} LVCS_StereoEnhancer_t;
+
+
+/************************************************************************************/
+/* */
+/* Function prototypes */
+/* */
+/************************************************************************************/
+
+LVCS_ReturnStatus_en LVCS_SEnhancerInit(LVCS_Handle_t hInstance,
+ LVCS_Params_t *pParams);
+
+LVCS_ReturnStatus_en LVCS_StereoEnhancer(LVCS_Handle_t hInstance,
+ const LVM_INT16 *pInData,
+ LVM_INT16 *pOutData,
+ LVM_UINT16 NumSamples);
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* STEREOENHANCE_H */
diff --git a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Tables.c b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Tables.c
new file mode 100755
index 0000000..ad4eb1e
--- /dev/null
+++ b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Tables.c
@@ -0,0 +1,456 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1001 $
+ $Date: 2010-06-28 13:23:02 +0200 (Mon, 28 Jun 2010) $
+
+*************************************************************************************/
+
+
+/************************************************************************************/
+/* */
+/* Includes */
+/* */
+/************************************************************************************/
+
+#include "LVCS_Private.h"
+#include "Filters.h" /* Filter definitions */
+#include "BIQUAD.h" /* Biquad definitions */
+#include "LVCS_Headphone_Coeffs.h" /* Headphone coefficients */
+
+
+/************************************************************************************/
+/* */
+/* Stereo Enhancer coefficient constant tables */
+/* */
+/************************************************************************************/
+
+/* Coefficient table for the middle filter */
+const BiquadA01B1CoefsSP_t LVCS_SEMidCoefTable[] = {
+ {CS_MIDDLE_8000_A0, /* 8kS/s coefficients */
+ CS_MIDDLE_8000_A1,
+ CS_MIDDLE_8000_B1,
+ (LVM_UINT16 )CS_MIDDLE_8000_SCALE},
+ {CS_MIDDLE_11025_A0, /* 11kS/s coefficients */
+ CS_MIDDLE_11025_A1,
+ CS_MIDDLE_11025_B1,
+ (LVM_UINT16 )CS_MIDDLE_11025_SCALE},
+ {CS_MIDDLE_12000_A0, /* 12kS/s coefficients */
+ CS_MIDDLE_12000_A1,
+ CS_MIDDLE_12000_B1,
+ (LVM_UINT16 )CS_MIDDLE_12000_SCALE},
+ {CS_MIDDLE_16000_A0, /* 16kS/s coefficients */
+ CS_MIDDLE_16000_A1,
+ CS_MIDDLE_16000_B1,
+ (LVM_UINT16 )CS_MIDDLE_16000_SCALE},
+ {CS_MIDDLE_22050_A0, /* 22kS/s coefficients */
+ CS_MIDDLE_22050_A1,
+ CS_MIDDLE_22050_B1,
+ (LVM_UINT16 )CS_MIDDLE_22050_SCALE},
+ {CS_MIDDLE_24000_A0, /* 24kS/s coefficients */
+ CS_MIDDLE_24000_A1,
+ CS_MIDDLE_24000_B1,
+ (LVM_UINT16 )CS_MIDDLE_24000_SCALE},
+ {CS_MIDDLE_32000_A0, /* 32kS/s coefficients */
+ CS_MIDDLE_32000_A1,
+ CS_MIDDLE_32000_B1,
+ (LVM_UINT16 )CS_MIDDLE_32000_SCALE},
+ {CS_MIDDLE_44100_A0, /* 44kS/s coefficients */
+ CS_MIDDLE_44100_A1,
+ CS_MIDDLE_44100_B1,
+ (LVM_UINT16 )CS_MIDDLE_44100_SCALE},
+ {CS_MIDDLE_48000_A0, /* 48kS/s coefficients */
+ CS_MIDDLE_48000_A1,
+ CS_MIDDLE_48000_B1,
+ (LVM_UINT16 )CS_MIDDLE_48000_SCALE}};
+
+/* Coefficient table for the side filter */
+const BiquadA012B12CoefsSP_t LVCS_SESideCoefTable[] = {
+ /* Headphone Side coefficients */
+ {CS_SIDE_8000_A0, /* 8kS/s coefficients */
+ CS_SIDE_8000_A1,
+ CS_SIDE_8000_A2,
+ CS_SIDE_8000_B1,
+ CS_SIDE_8000_B2,
+ (LVM_UINT16 )CS_SIDE_8000_SCALE},
+ {CS_SIDE_11025_A0, /* 11kS/s coefficients */
+ CS_SIDE_11025_A1,
+ CS_SIDE_11025_A2,
+ CS_SIDE_11025_B1,
+ CS_SIDE_11025_B2,
+ (LVM_UINT16 )CS_SIDE_11025_SCALE},
+ {CS_SIDE_12000_A0, /* 12kS/s coefficients */
+ CS_SIDE_12000_A1,
+ CS_SIDE_12000_A2,
+ CS_SIDE_12000_B1,
+ CS_SIDE_12000_B2,
+ (LVM_UINT16 )CS_SIDE_12000_SCALE},
+ {CS_SIDE_16000_A0, /* 16kS/s coefficients */
+ CS_SIDE_16000_A1,
+ CS_SIDE_16000_A2,
+ CS_SIDE_16000_B1,
+ CS_SIDE_16000_B2,
+ (LVM_UINT16 )CS_SIDE_16000_SCALE},
+ {CS_SIDE_22050_A0, /* 22kS/s coefficients */
+ CS_SIDE_22050_A1,
+ CS_SIDE_22050_A2,
+ CS_SIDE_22050_B1,
+ CS_SIDE_22050_B2,
+ (LVM_UINT16 )CS_SIDE_22050_SCALE},
+ {CS_SIDE_24000_A0, /* 24kS/s coefficients */
+ CS_SIDE_24000_A1,
+ CS_SIDE_24000_A2,
+ CS_SIDE_24000_B1,
+ CS_SIDE_24000_B2,
+ (LVM_UINT16 )CS_SIDE_24000_SCALE},
+ {CS_SIDE_32000_A0, /* 32kS/s coefficients */
+ CS_SIDE_32000_A1,
+ CS_SIDE_32000_A2,
+ CS_SIDE_32000_B1,
+ CS_SIDE_32000_B2,
+ (LVM_UINT16 )CS_SIDE_32000_SCALE},
+ {CS_SIDE_44100_A0, /* 44kS/s coefficients */
+ CS_SIDE_44100_A1,
+ CS_SIDE_44100_A2,
+ CS_SIDE_44100_B1,
+ CS_SIDE_44100_B2,
+ (LVM_UINT16 )CS_SIDE_44100_SCALE},
+ {CS_SIDE_48000_A0, /* 48kS/s coefficients */
+ CS_SIDE_48000_A1,
+ CS_SIDE_48000_A2,
+ CS_SIDE_48000_B1,
+ CS_SIDE_48000_B2,
+ (LVM_UINT16 )CS_SIDE_48000_SCALE}
+};
+
+
+/************************************************************************************/
+/* */
+/* Equaliser coefficient constant tables */
+/* */
+/************************************************************************************/
+
+const BiquadA012B12CoefsSP_t LVCS_EqualiserCoefTable[] = {
+ /* Headphone coefficients */
+ {CS_EQUALISER_8000_A0, /* 8kS/s coefficients */
+ CS_EQUALISER_8000_A1,
+ CS_EQUALISER_8000_A2,
+ CS_EQUALISER_8000_B1,
+ CS_EQUALISER_8000_B2,
+ (LVM_UINT16 )CS_EQUALISER_8000_SCALE},
+ {CS_EQUALISER_11025_A0, /* 11kS/s coefficients */
+ CS_EQUALISER_11025_A1,
+ CS_EQUALISER_11025_A2,
+ CS_EQUALISER_11025_B1,
+ CS_EQUALISER_11025_B2,
+ (LVM_UINT16 )CS_EQUALISER_11025_SCALE},
+ {CS_EQUALISER_12000_A0, /* 12kS/s coefficients */
+ CS_EQUALISER_12000_A1,
+ CS_EQUALISER_12000_A2,
+ CS_EQUALISER_12000_B1,
+ CS_EQUALISER_12000_B2,
+ (LVM_UINT16 )CS_EQUALISER_12000_SCALE},
+ {CS_EQUALISER_16000_A0, /* 16kS/s coefficients */
+ CS_EQUALISER_16000_A1,
+ CS_EQUALISER_16000_A2,
+ CS_EQUALISER_16000_B1,
+ CS_EQUALISER_16000_B2,
+ (LVM_UINT16 )CS_EQUALISER_16000_SCALE},
+ {CS_EQUALISER_22050_A0, /* 22kS/s coefficients */
+ CS_EQUALISER_22050_A1,
+ CS_EQUALISER_22050_A2,
+ CS_EQUALISER_22050_B1,
+ CS_EQUALISER_22050_B2,
+ (LVM_UINT16 )CS_EQUALISER_22050_SCALE},
+ {CS_EQUALISER_24000_A0, /* 24kS/s coefficients */
+ CS_EQUALISER_24000_A1,
+ CS_EQUALISER_24000_A2,
+ CS_EQUALISER_24000_B1,
+ CS_EQUALISER_24000_B2,
+ (LVM_UINT16 )CS_EQUALISER_24000_SCALE},
+ {CS_EQUALISER_32000_A0, /* 32kS/s coefficients */
+ CS_EQUALISER_32000_A1,
+ CS_EQUALISER_32000_A2,
+ CS_EQUALISER_32000_B1,
+ CS_EQUALISER_32000_B2,
+ (LVM_UINT16 )CS_EQUALISER_32000_SCALE},
+ {CS_EQUALISER_44100_A0, /* 44kS/s coefficients */
+ CS_EQUALISER_44100_A1,
+ CS_EQUALISER_44100_A2,
+ CS_EQUALISER_44100_B1,
+ CS_EQUALISER_44100_B2,
+ (LVM_UINT16 )CS_EQUALISER_44100_SCALE},
+ {CS_EQUALISER_48000_A0, /* 48kS/s coefficients */
+ CS_EQUALISER_48000_A1,
+ CS_EQUALISER_48000_A2,
+ CS_EQUALISER_48000_B1,
+ CS_EQUALISER_48000_B2,
+ (LVM_UINT16 )CS_EQUALISER_48000_SCALE},
+
+ /* Concert Sound EX Headphone coefficients */
+ {CSEX_EQUALISER_8000_A0, /* 8kS/s coefficients */
+ CSEX_EQUALISER_8000_A1,
+ CSEX_EQUALISER_8000_A2,
+ CSEX_EQUALISER_8000_B1,
+ CSEX_EQUALISER_8000_B2,
+ (LVM_UINT16 )CSEX_EQUALISER_8000_SCALE},
+ {CSEX_EQUALISER_11025_A0, /* 11kS/s coefficients */
+ CSEX_EQUALISER_11025_A1,
+ CSEX_EQUALISER_11025_A2,
+ CSEX_EQUALISER_11025_B1,
+ CSEX_EQUALISER_11025_B2,
+ (LVM_UINT16 )CSEX_EQUALISER_11025_SCALE},
+ {CSEX_EQUALISER_12000_A0, /* 12kS/s coefficients */
+ CSEX_EQUALISER_12000_A1,
+ CSEX_EQUALISER_12000_A2,
+ CSEX_EQUALISER_12000_B1,
+ CSEX_EQUALISER_12000_B2,
+ (LVM_UINT16 )CSEX_EQUALISER_12000_SCALE},
+ {CSEX_EQUALISER_16000_A0, /* 16kS/s coefficients */
+ CSEX_EQUALISER_16000_A1,
+ CSEX_EQUALISER_16000_A2,
+ CSEX_EQUALISER_16000_B1,
+ CSEX_EQUALISER_16000_B2,
+ (LVM_UINT16 )CSEX_EQUALISER_16000_SCALE},
+ {CSEX_EQUALISER_22050_A0, /* 22kS/s coefficients */
+ CSEX_EQUALISER_22050_A1,
+ CSEX_EQUALISER_22050_A2,
+ CSEX_EQUALISER_22050_B1,
+ CSEX_EQUALISER_22050_B2,
+ (LVM_UINT16 )CSEX_EQUALISER_22050_SCALE},
+ {CSEX_EQUALISER_24000_A0, /* 24kS/s coefficients */
+ CSEX_EQUALISER_24000_A1,
+ CSEX_EQUALISER_24000_A2,
+ CSEX_EQUALISER_24000_B1,
+ CSEX_EQUALISER_24000_B2,
+ (LVM_UINT16 )CSEX_EQUALISER_24000_SCALE},
+ {CSEX_EQUALISER_32000_A0, /* 32kS/s coefficients */
+ CSEX_EQUALISER_32000_A1,
+ CSEX_EQUALISER_32000_A2,
+ CSEX_EQUALISER_32000_B1,
+ CSEX_EQUALISER_32000_B2,
+ (LVM_UINT16 )CSEX_EQUALISER_32000_SCALE},
+ {CSEX_EQUALISER_44100_A0, /* 44kS/s coefficients */
+ CSEX_EQUALISER_44100_A1,
+ CSEX_EQUALISER_44100_A2,
+ CSEX_EQUALISER_44100_B1,
+ CSEX_EQUALISER_44100_B2,
+ (LVM_UINT16 )CSEX_EQUALISER_44100_SCALE},
+ {CSEX_EQUALISER_48000_A0, /* 48kS/s coefficients */
+ CSEX_EQUALISER_48000_A1,
+ CSEX_EQUALISER_48000_A2,
+ CSEX_EQUALISER_48000_B1,
+ CSEX_EQUALISER_48000_B2,
+ (LVM_UINT16 )CSEX_EQUALISER_48000_SCALE}
+};
+
+
+/************************************************************************************/
+/* */
+/* Reverb delay constant tables */
+/* */
+/************************************************************************************/
+
+/* Stereo delay table for Concert Sound */
+const LVM_UINT16 LVCS_StereoDelayCS[] = {
+ LVCS_STEREODELAY_CS_8KHZ,
+ LVCS_STEREODELAY_CS_11KHZ,
+ LVCS_STEREODELAY_CS_12KHZ,
+ LVCS_STEREODELAY_CS_16KHZ,
+ LVCS_STEREODELAY_CS_22KHZ,
+ LVCS_STEREODELAY_CS_24KHZ,
+ LVCS_STEREODELAY_CS_32KHZ,
+ LVCS_STEREODELAY_CS_44KHZ,
+ LVCS_STEREODELAY_CS_48KHZ};
+
+/************************************************************************************/
+/* */
+/* Reverb coefficients constant table */
+/* */
+/************************************************************************************/
+
+const BiquadA012B12CoefsSP_t LVCS_ReverbCoefTable[] = {
+ /* Headphone coefficients */
+ {CS_REVERB_8000_A0, /* 8kS/s coefficients */
+ CS_REVERB_8000_A1,
+ CS_REVERB_8000_A2,
+ CS_REVERB_8000_B1,
+ CS_REVERB_8000_B2,
+ (LVM_UINT16 )CS_REVERB_8000_SCALE},
+ {CS_REVERB_11025_A0, /* 11kS/s coefficients */
+ CS_REVERB_11025_A1,
+ CS_REVERB_11025_A2,
+ CS_REVERB_11025_B1,
+ CS_REVERB_11025_B2,
+ (LVM_UINT16 )CS_REVERB_11025_SCALE},
+ {CS_REVERB_12000_A0, /* 12kS/s coefficients */
+ CS_REVERB_12000_A1,
+ CS_REVERB_12000_A2,
+ CS_REVERB_12000_B1,
+ CS_REVERB_12000_B2,
+ (LVM_UINT16 )CS_REVERB_12000_SCALE},
+ {CS_REVERB_16000_A0, /* 16kS/s coefficients */
+ CS_REVERB_16000_A1,
+ CS_REVERB_16000_A2,
+ CS_REVERB_16000_B1,
+ CS_REVERB_16000_B2,
+ (LVM_UINT16 )CS_REVERB_16000_SCALE},
+ {CS_REVERB_22050_A0, /* 22kS/s coefficients */
+ CS_REVERB_22050_A1,
+ CS_REVERB_22050_A2,
+ CS_REVERB_22050_B1,
+ CS_REVERB_22050_B2,
+ (LVM_UINT16 )CS_REVERB_22050_SCALE},
+ {CS_REVERB_24000_A0, /* 24kS/s coefficients */
+ CS_REVERB_24000_A1,
+ CS_REVERB_24000_A2,
+ CS_REVERB_24000_B1,
+ CS_REVERB_24000_B2,
+ (LVM_UINT16 )CS_REVERB_24000_SCALE},
+ {CS_REVERB_32000_A0, /* 32kS/s coefficients */
+ CS_REVERB_32000_A1,
+ CS_REVERB_32000_A2,
+ CS_REVERB_32000_B1,
+ CS_REVERB_32000_B2,
+ (LVM_UINT16 )CS_REVERB_32000_SCALE},
+ {CS_REVERB_44100_A0, /* 44kS/s coefficients */
+ CS_REVERB_44100_A1,
+ CS_REVERB_44100_A2,
+ CS_REVERB_44100_B1,
+ CS_REVERB_44100_B2,
+ (LVM_UINT16 )CS_REVERB_44100_SCALE},
+ {CS_REVERB_48000_A0, /* 48kS/s coefficients */
+ CS_REVERB_48000_A1,
+ CS_REVERB_48000_A2,
+ CS_REVERB_48000_B1,
+ CS_REVERB_48000_B2,
+ (LVM_UINT16 )CS_REVERB_48000_SCALE}
+};
+
+
+/************************************************************************************/
+/* */
+/* Bypass mixer constant tables */
+/* */
+/************************************************************************************/
+
+const Gain_t LVCS_OutputGainTable[] = {
+ {LVCS_HEADPHONE_SHIFT, /* Headphone, stereo mode */
+ LVCS_HEADPHONE_SHIFTLOSS,
+ LVCS_HEADPHONE_GAIN},
+ {LVCS_EX_HEADPHONE_SHIFT, /* EX Headphone, stereo mode */
+ LVCS_EX_HEADPHONE_SHIFTLOSS,
+ LVCS_EX_HEADPHONE_GAIN},
+ {LVCS_HEADPHONE_SHIFT, /* Headphone, mono mode */
+ LVCS_HEADPHONE_SHIFTLOSS,
+ LVCS_HEADPHONE_GAIN},
+ {LVCS_EX_HEADPHONE_SHIFT, /* EX Headphone, mono mode */
+ LVCS_EX_HEADPHONE_SHIFTLOSS,
+ LVCS_EX_HEADPHONE_GAIN}
+};
+
+
+/************************************************************************************/
+/* */
+/* Volume correction table */
+/* */
+/* Coefficient order: */
+/* Compression 100% effect */
+/* Compression 0% effect */
+/* Gain 100% effect */
+/* Gain 0% effect */
+/* */
+/* The Compression gain is represented by a Q1.15 number to give a range of 0dB */
+/* to +6dB, E.g.: */
+/* 0 is 0dB compression (no effect) */
+/* 5461 is 1dB compression gain */
+/* 10923 is 2dB compression gain */
+/* 32767 is 6dB compression gain */
+/* */
+/* The Gain is represented as a Q3.13 number to give a range of +8 to -infinity */
+/* E.g.: */
+/* 0 is -infinity */
+/* 32767 is +18dB (x8) gain */
+/* 4096 is 0dB gain */
+/* 1024 is -12dB gain */
+/* */
+/************************************************************************************/
+const LVCS_VolCorrect_t LVCS_VolCorrectTable[] = {
+ {14200, /* Headphone, stereo mode */
+ 0,
+ 4096,
+ 5786},
+ {14200, /* EX Headphone, stereo mode */
+ 0,
+ 4096,
+ 5786},
+ {32767, /* Headphone, mono mode */
+ 0,
+ 4096,
+ 5786},
+ {32767, /* EX Headphone, mono mode */
+ 0,
+ 4096,
+ 5786}
+};
+
+/************************************************************************************/
+/* */
+/* Mixer time constants, 100ms */
+/* */
+/************************************************************************************/
+
+#define LVCS_VOL_TC_Fs8000 32580 /* Floating point value 0.994262695 */
+#define LVCS_VOL_TC_Fs11025 32632 /* Floating point value 0.995849609 */
+#define LVCS_VOL_TC_Fs12000 32643 /* Floating point value 0.996185303 */
+#define LVCS_VOL_TC_Fs16000 32674 /* Floating point value 0.997131348 */
+#define LVCS_VOL_TC_Fs22050 32700 /* Floating point value 0.997924805 */
+#define LVCS_VOL_TC_Fs24000 32705 /* Floating point value 0.998077393 */
+#define LVCS_VOL_TC_Fs32000 32721 /* Floating point value 0.998565674 */
+#define LVCS_VOL_TC_Fs44100 32734 /* Floating point value 0.998962402 */
+#define LVCS_VOL_TC_Fs48000 32737 /* Floating point value 0.999053955 */
+
+
+const LVM_INT16 LVCS_VolumeTCTable[9] = {LVCS_VOL_TC_Fs8000,
+ LVCS_VOL_TC_Fs11025,
+ LVCS_VOL_TC_Fs12000,
+ LVCS_VOL_TC_Fs16000,
+ LVCS_VOL_TC_Fs22050,
+ LVCS_VOL_TC_Fs24000,
+ LVCS_VOL_TC_Fs32000,
+ LVCS_VOL_TC_Fs44100,
+ LVCS_VOL_TC_Fs48000};
+
+/************************************************************************************/
+/* */
+/* Sample rate table */
+/* */
+/************************************************************************************/
+
+const LVM_INT32 LVCS_SampleRateTable[9] = {8000,
+ 11025,
+ 12000,
+ 16000,
+ 22050,
+ 24000,
+ 32000,
+ 44100,
+ 48000};
+
diff --git a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Tables.h b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Tables.h
new file mode 100755
index 0000000..72d6855
--- /dev/null
+++ b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Tables.h
@@ -0,0 +1,159 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 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.
+ */
+
+/************************************************************************************
+
+ $Author: nxp27078 $
+ $Revision: 672 $
+ $Date: 2010-06-08 19:39:38 +0200 (Tue, 08 Jun 2010) $
+
+*************************************************************************************/
+#ifndef __LVCS_TABLES_H__
+#define __LVCS_TABLES_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/************************************************************************************/
+/* */
+/* Includes */
+/* */
+/************************************************************************************/
+
+#include "BIQUAD.h" /* Biquad definitions */
+
+/************************************************************************************/
+/* */
+/* Stereo Enhancer coefficient constant tables */
+/* */
+/************************************************************************************/
+
+/* Coefficient table for the middle filter */
+extern const BiquadA01B1CoefsSP_t LVCS_SEMidCoefTable[];
+
+/* Coefficient table for the side filter */
+extern const BiquadA012B12CoefsSP_t LVCS_SESideCoefTable[];
+
+/************************************************************************************/
+/* */
+/* Equaliser coefficient constant tables */
+/* */
+/************************************************************************************/
+
+extern const BiquadA012B12CoefsSP_t LVCS_EqualiserCoefTable[];
+
+/************************************************************************************/
+/* */
+/* Reverb delay constant tables */
+/* */
+/************************************************************************************/
+
+/* Stereo delay table for Concert Sound */
+extern const LVM_UINT16 LVCS_StereoDelayCS[];
+
+/************************************************************************************/
+/* */
+/* Reverb coefficients constant table */
+/* */
+/************************************************************************************/
+
+extern const BiquadA012B12CoefsSP_t LVCS_ReverbCoefTable[];
+
+/************************************************************************************/
+/* */
+/* Bypass mixer constant tables */
+/* */
+/************************************************************************************/
+
+extern const Gain_t LVCS_OutputGainTable[];
+
+/************************************************************************************/
+/* */
+/* Volume correction table */
+/* */
+/* Coefficient order: */
+/* Compression 100% effect */
+/* Compression 0% effect */
+/* Gain 100% effect */
+/* Gain 0% effect */
+/* */
+/* The Compression gain is represented by a Q1.15 number to give a range of 0dB */
+/* to +6dB, E.g.: */
+/* 0 is 0dB compression (no effect) */
+/* 5461 is 1dB compression gain */
+/* 10923 is 2dB compression gain */
+/* 32767 is 6dB compression gain */
+/* */
+/* The Gain is represented as a Q3.13 number to give a range of +8 to -infinity */
+/* E.g.: */
+/* 0 is -infinity */
+/* 32767 is +18dB (x8) gain */
+/* 4096 is 0dB gain */
+/* 1024 is -12dB gain */
+/* */
+/************************************************************************************/
+
+extern const LVCS_VolCorrect_t LVCS_VolCorrectTable[];
+extern const LVM_INT16 LVCS_VolumeTCTable[];
+
+
+/************************************************************************************/
+/* */
+/* Sample rates */
+/* */
+/************************************************************************************/
+
+extern LVM_INT32 LVCS_SampleRateTable[];
+
+
+/*Speaker coeffient tables*/
+extern LVM_UINT16 LVCS_MS_Small_SEMiddleGainTable[];
+extern BiquadA012B12CoefsSP_t LVCS_MS_Small_SESideCoefTable[];
+extern BiquadA012B12CoefsSP_t LVCS_MS_Small_EqualiserCoefTable[];
+extern BiquadA012B12CoefsSP_t LVCS_MS_Small_ReverbCoefTable[] ;
+extern LVM_UINT16 LVCS_MS_Small_StereoDelayCS4MS[];
+extern Gain_t LVCS_MS_Small_OutputGainTable[];
+extern LVCS_VolCorrect_t LVCS_MS_Small_VolCorrectTable[];
+extern LVM_UINT16 LVCS_MS_Small_ReverbGainTable[];
+
+extern LVM_UINT16 LVCS_MS_Medium_SEMiddleGainTable[];
+extern BiquadA012B12CoefsSP_t LVCS_MS_Medium_SESideCoefTable[];
+extern BiquadA012B12CoefsSP_t LVCS_MS_Medium_EqualiserCoefTable[];
+extern BiquadA012B12CoefsSP_t LVCS_MS_Medium_ReverbCoefTable[] ;
+extern LVM_UINT16 LVCS_MS_Medium_StereoDelayCS4MS[];
+extern Gain_t LVCS_MS_Medium_OutputGainTable[];
+extern LVCS_VolCorrect_t LVCS_MS_Medium_VolCorrectTable[];
+extern LVM_UINT16 LVCS_MS_Medium_ReverbGainTable[];
+
+extern LVM_UINT16 LVCS_MS_Large_SEMiddleGainTable[];
+extern BiquadA012B12CoefsSP_t LVCS_MS_Large_SESideCoefTable[];
+extern BiquadA012B12CoefsSP_t LVCS_MS_Large_EqualiserCoefTable[];
+extern BiquadA012B12CoefsSP_t LVCS_MS_Large_ReverbCoefTable[] ;
+extern LVM_UINT16 LVCS_MS_Large_StereoDelayCS4MS[];
+extern Gain_t LVCS_MS_Large_OutputGainTable[];
+extern LVCS_VolCorrect_t LVCS_MS_Large_VolCorrectTable[];
+extern LVM_UINT16 LVCS_MS_Large_ReverbGainTable[];
+
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __LVCS_TABLES_H__ */
+
diff --git a/media/libeffects/lvm/wrapper/Android.mk b/media/libeffects/lvm/wrapper/Android.mk
new file mode 100644
index 0000000..4ebc443
--- /dev/null
+++ b/media/libeffects/lvm/wrapper/Android.mk
@@ -0,0 +1,30 @@
+LOCAL_PATH:= $(call my-dir)
+
+# music bundle wrapper
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_ARM_MODE := arm
+
+LOCAL_SRC_FILES:= \
+ Bundle/EffectBundle.cpp
+
+LOCAL_MODULE:= libbundlewrapper
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/soundfx
+
+LOCAL_PRELINK_MODULE := false
+
+LOCAL_STATIC_LIBRARIES += libmusicbundle
+
+LOCAL_SHARED_LIBRARIES := \
+ libcutils \
+ libdl
+
+LOCAL_C_INCLUDES += \
+ $(LOCAL_PATH)/Bundle \
+ $(LOCAL_PATH)/../lib/Common/lib/ \
+ $(LOCAL_PATH)/../lib/Bundle/lib/
+
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
new file mode 100644
index 0000000..9e39e79
--- /dev/null
+++ b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
@@ -0,0 +1,2609 @@
+/*
+ * Copyright (C) 2010-2010 NXP Software
+ * Copyright (C) 2009 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.
+ */
+
+#define LOG_TAG "Bundle"
+#define ARRAY_SIZE(array) (sizeof array / sizeof array[0])
+#define LVM_BUNDLE // Include all the bundle code
+//#define LOG_NDEBUG 0
+
+#include <cutils/log.h>
+#include <assert.h>
+#include <stdlib.h>
+#include <string.h>
+#include <new>
+#include <EffectBundle.h>
+
+#ifdef LVM_BUNDLE
+#define LVM_MAX_SESSIONS 32
+#define MAX_NUM_BANDS 5
+#define MAX_CALL_SIZE 256
+#endif /* end LVM_BUNDLE */
+
+
+int framecountag = 0;
+// effect_interface_t interface implementation for bass boost
+extern "C" const struct effect_interface_s gLvmEffectInterface;
+
+#define LVM_ERROR_CHECK(LvmStatus, callingFunc, calledFunc){\
+ if (LvmStatus == LVM_NULLADDRESS){\
+ LOGV("\tLVM_ERROR : Parameter error - "\
+ "null pointer returned by %s in %s\n\n\n\n", callingFunc, calledFunc);\
+ }\
+ if (LvmStatus == LVM_ALIGNMENTERROR){\
+ LOGV("\tLVM_ERROR : Parameter error - "\
+ "bad alignment returned by %s in %s\n\n\n\n", callingFunc, calledFunc);\
+ }\
+ if (LvmStatus == LVM_INVALIDNUMSAMPLES){\
+ LOGV("\tLVM_ERROR : Parameter error - "\
+ "bad number of samples returned by %s in %s\n\n\n\n", callingFunc, calledFunc);\
+ }\
+ if (LvmStatus == LVM_OUTOFRANGE){\
+ LOGV("\tLVM_ERROR : Parameter error - "\
+ "out of range returned by %s in %s\n", callingFunc, calledFunc);\
+ }\
+ }
+
+
+
+
+
+// Namespaces
+namespace android {
+namespace {
+
+/* local functions */
+#define CHECK_ARG(cond) { \
+ if (!(cond)) { \
+ LOGV("\tLVM_ERROR : Invalid argument: "#cond); \
+ return -EINVAL; \
+ } \
+}
+
+int LvmInitFlag = LVM_FALSE;
+SessionContext GlobalSessionMemory[32];
+
+// NXP SW BassBoost UUID
+const effect_descriptor_t gBassBoostDescriptor = {
+ {0x0634f220, 0xddd4, 0x11db, 0xa0fc, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b }},
+ {0x8631f300, 0x72e2, 0x11df, 0xb57e, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, // uuid
+ EFFECT_API_VERSION,
+ (EFFECT_FLAG_TYPE_INSERT | EFFECT_FLAG_INSERT_LAST),
+ 0, // TODO
+ 1,
+ "Dynamic Bass Boost",
+ "NXP Software Ltd.",
+};
+
+// NXP SW Virtualizer UUID
+const effect_descriptor_t gVirtualizerDescriptor = {
+ {0x37cc2c00, 0xdddd, 0x11db, 0x8577, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, // Virtualizer ID
+ {0x1d4033c0, 0x8557, 0x11df, 0x9f2d, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, // NXP SW UUID gen july 01 2010
+ EFFECT_API_VERSION,
+ (EFFECT_FLAG_TYPE_INSERT | EFFECT_FLAG_INSERT_LAST),
+ 0, // TODO
+ 1,
+ "Virtualizer",
+ "NXP Software Ltd.",
+};
+
+// NXP SW Equalizer UUID
+const effect_descriptor_t gEqualizerDescriptor = {
+ {0x0bed4300, 0xddd6, 0x11db, 0x8f34, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, // type
+ {0xce772f20, 0x847d, 0x11df, 0xbb17, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, // uuid Eq NXP
+ EFFECT_API_VERSION,
+ (EFFECT_FLAG_TYPE_INSERT | EFFECT_FLAG_INSERT_LAST),
+ 0, // TODO
+ 1,
+ "Equalizer",
+ "NXP Software Ltd.",
+};
+
+// NXP SW Volume UUID
+const effect_descriptor_t gVolumeDescriptor = {
+ {0x09e8ede0, 0xddde, 0x11db, 0xb4f6, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b }},
+ //{0x8631f300, 0x72e2, 0x11df, 0xb57e, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b }}, // uuid
+ {0x119341a0, 0x8469, 0x11df, 0x81f9, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b }}, //uuid VOL NXP
+ EFFECT_API_VERSION,
+ (EFFECT_FLAG_TYPE_INSERT | EFFECT_FLAG_INSERT_LAST),
+ 0, // TODO
+ 1,
+ "Volume",
+ "NXP Software Ltd.",
+};
+
+//--- local function prototypes
+void LvmGlobalBundle_init (void);
+int LvmBundle_init (EffectContext *pContext);
+int LvmEffect_enable (EffectContext *pContext);
+int LvmEffect_disable (EffectContext *pContext);
+void LvmEffect_free (EffectContext *pContext);
+int Effect_configure (EffectContext *pContext, effect_config_t *pConfig);
+int BassBoost_setParameter (EffectContext *pContext, int32_t *pParam, void *pValue);
+int BassBoost_getParameter (EffectContext *pContext,
+ int32_t *pParam,
+ size_t *pValueSize,
+ void *pValue);
+int Virtualizer_setParameter (EffectContext *pContext, int32_t *pParam, void *pValue);
+int Virtualizer_getParameter (EffectContext *pContext,
+ int32_t *pParam,
+ size_t *pValueSize,
+ void *pValue);
+int Equalizer_setParameter (EffectContext *pContext, int32_t *pParam, void *pValue);
+int Equalizer_getParameter (EffectContext *pContext,
+ int32_t *pParam,
+ size_t *pValueSize,
+ void *pValue);
+int Volume_setParameter (EffectContext *pContext, int32_t *pParam, void *pValue);
+int Volume_getParameter (EffectContext *pContext,
+ int32_t *pParam,
+ size_t *pValueSize,
+ void *pValue);
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/* Effect Library Interface Implementation */
+extern "C" int EffectQueryNumberEffects(uint32_t *pNumEffects){
+ LOGV("\n\tEffectQueryNumberEffects start");
+ *pNumEffects = 4;
+ LOGV("\tEffectQueryNumberEffects creating %d effects", *pNumEffects);
+ LOGV("\tEffectQueryNumberEffects end\n");
+ return 0;
+} /* end EffectQueryNumberEffects */
+
+
+extern "C" int EffectQueryEffect(uint32_t index, effect_descriptor_t *pDescriptor){
+ LOGV("\n\tEffectQueryEffect start");
+ LOGV("\tEffectQueryEffect processing index %d", index);
+
+ if (pDescriptor == NULL){
+ LOGV("\tLVM_ERROR : EffectQueryEffect was passed NULL pointer");
+ return -EINVAL;
+ }
+ if (index > 3){
+ LOGV("\tLVM_ERROR : EffectQueryEffect index out of range %d", index);
+ return -ENOENT;
+ }
+ if(index == LVM_BASS_BOOST){
+ LOGV("\tEffectQueryEffect processing LVM_BASS_BOOST");
+ memcpy(pDescriptor, &gBassBoostDescriptor, sizeof(effect_descriptor_t));
+ }else if(index == LVM_VIRTUALIZER){
+ LOGV("\tEffectQueryEffect processing LVM_VIRTUALIZER");
+ memcpy(pDescriptor, &gVirtualizerDescriptor, sizeof(effect_descriptor_t));
+ } else if(index == LVM_EQUALIZER){
+ LOGV("\tEffectQueryEffect processing LVM_EQUALIZER");
+ memcpy(pDescriptor, &gEqualizerDescriptor, sizeof(effect_descriptor_t));
+ } else if(index == LVM_VOLUME){
+ LOGV("\tEffectQueryEffect processing LVM_VOLUME");
+ memcpy(pDescriptor, &gVolumeDescriptor, sizeof(effect_descriptor_t));
+ }
+ LOGV("\tEffectQueryEffect end\n");
+ return 0;
+} /* end EffectQueryEffect */
+
+
+extern "C" int EffectCreate(effect_uuid_t *uuid,
+ int32_t sessionId,
+ int32_t ioId,
+ effect_interface_t *pInterface){
+ int ret;
+ int i;
+ EffectContext *pContext = new EffectContext;
+
+ LOGV("\n\tEffectCreate start session %d", sessionId);
+
+ if (pInterface == NULL || uuid == NULL){
+ LOGV("\tLVM_ERROR : EffectCreate() called with NULL pointer");
+ return -EINVAL;
+ }
+
+ if((sessionId < 0)||(sessionId >= LVM_MAX_SESSIONS)){
+ LOGV("\tLVM_ERROR : EffectCreate sessionId is less than 0");
+ return -EINVAL;
+ }
+
+ if(LvmInitFlag == LVM_FALSE){
+ LvmInitFlag = LVM_TRUE;
+ LOGV("\tEffectCreate - Initializing all global memory");
+ LvmGlobalBundle_init();
+ }
+
+ // If this is the first create in this session
+ if(GlobalSessionMemory[sessionId].bBundledEffectsEnabled == LVM_FALSE){
+ LOGV("\tEffectCreate - This is the first effect in current session %d", sessionId);
+ LOGV("\tEffectCreate - Setting up Bundled Effects Instance for session %d", sessionId);
+ GlobalSessionMemory[sessionId].bBundledEffectsEnabled = LVM_TRUE;
+ GlobalSessionMemory[sessionId].pBundledContext = new BundledEffectContext;
+
+ pContext->pBundledContext = GlobalSessionMemory[sessionId].pBundledContext;
+ pContext->pBundledContext->SessionNo = sessionId;
+ pContext->pBundledContext->hInstance = NULL;
+ pContext->pBundledContext->bVolumeEnabled = LVM_FALSE;
+ pContext->pBundledContext->bEqualizerEnabled = LVM_FALSE;
+ pContext->pBundledContext->bBassEnabled = LVM_FALSE;
+ pContext->pBundledContext->bVirtualizerEnabled = LVM_FALSE;
+ pContext->pBundledContext->NumberEffectsEnabled = 0;
+ pContext->pBundledContext->NumberEffectsCalled = 0;
+
+ /* Saved strength is used to return the exact strength that was used in the set to the get
+ * because we map the original strength range of 0:1000 to 1:15, and this will avoid
+ * quantisation like effect when returning
+ */
+ pContext->pBundledContext->BassStrengthSaved = 0;
+ pContext->pBundledContext->VirtStrengthSaved = 0;
+ pContext->pBundledContext->CurPreset = PRESET_CUSTOM;
+ pContext->pBundledContext->levelSaved = 0;
+ pContext->pBundledContext->bMuteEnabled = LVM_FALSE;
+
+ LOGV("\tEffectCreate - Calling LvmBundle_init");
+ ret = LvmBundle_init(pContext);
+
+ if (ret < 0){
+ LOGV("\tLVM_ERROR : EffectCreate() Bundle init failed");
+ delete pContext->pBundledContext;
+ delete pContext;
+ return ret;
+ }
+ }
+ else{
+ pContext->pBundledContext = GlobalSessionMemory[sessionId].pBundledContext;
+ }
+
+ LOGV("\tEffectCreate - pBundledContext is %p", pContext->pBundledContext);
+
+ // Create each Effect
+ if (memcmp(uuid, &gBassBoostDescriptor.uuid, sizeof(effect_uuid_t)) == 0){
+ // Create Bass Boost
+ LOGV("\tEffectCreate - Effect to be created is LVM_BASS_BOOST");
+ GlobalSessionMemory[sessionId].bBassInstantiated = LVM_TRUE;
+
+ pContext->itfe = &gLvmEffectInterface;
+ pContext->EffectType = LVM_BASS_BOOST;
+ } else if (memcmp(uuid, &gVirtualizerDescriptor.uuid, sizeof(effect_uuid_t)) == 0){
+ // Create Virtualizer
+ LOGV("\tEffectCreate - Effect to be created is LVM_VIRTUALIZER");
+ GlobalSessionMemory[sessionId].bVirtualizerInstantiated = LVM_TRUE;
+
+ pContext->itfe = &gLvmEffectInterface;
+ pContext->EffectType = LVM_VIRTUALIZER;
+ } else if (memcmp(uuid, &gEqualizerDescriptor.uuid, sizeof(effect_uuid_t)) == 0){
+ // Create Equalizer
+ LOGV("\tEffectCreate - Effect to be created is LVM_EQUALIZER");
+ GlobalSessionMemory[sessionId].bEqualizerInstantiated = LVM_TRUE;
+
+ pContext->itfe = &gLvmEffectInterface;
+ pContext->EffectType = LVM_EQUALIZER;
+ } else if (memcmp(uuid, &gVolumeDescriptor.uuid, sizeof(effect_uuid_t)) == 0){
+ // Create Volume
+ LOGV("\tEffectCreate - Effect to be created is LVM_VOLUME");
+ GlobalSessionMemory[sessionId].bVolumeInstantiated = LVM_TRUE;
+
+ pContext->itfe = &gLvmEffectInterface;
+ pContext->EffectType = LVM_VOLUME;
+ }
+ else{
+ LOGV("\tLVM_ERROR : EffectCreate() invalid UUID");
+ return -EINVAL;
+ }
+
+ *pInterface = (effect_interface_t)pContext;
+ LOGV("\tEffectCreate end..\n\n");
+ return 0;
+} /* end EffectCreate */
+
+
+
+extern "C" int EffectRelease(effect_interface_t interface){
+ LOGV("\n\tEffectRelease start %p", interface);
+ EffectContext * pContext = (EffectContext *)interface;
+
+ if (pContext == NULL){
+ LOGV("\tLVM_ERROR : EffectRelease called with NULL pointer");
+ return -EINVAL;
+ }
+
+ // Clear the instantiated flag for the effect
+ if(pContext->EffectType == LVM_BASS_BOOST) {
+ LOGV("\tEffectRelease LVM_BASS_BOOST Clearing global intstantiated flag");
+ GlobalSessionMemory[pContext->pBundledContext->SessionNo].bBassInstantiated = LVM_FALSE;
+ } else if(pContext->EffectType == LVM_VIRTUALIZER) {
+ LOGV("\tEffectRelease LVM_VIRTUALIZER Clearing global intstantiated flag");
+ GlobalSessionMemory[pContext->pBundledContext->SessionNo].bVirtualizerInstantiated = LVM_FALSE;
+ } else if(pContext->EffectType == LVM_EQUALIZER) {
+ LOGV("\tEffectRelease LVM_EQUALIZER Clearing global intstantiated flag");
+ GlobalSessionMemory[pContext->pBundledContext->SessionNo].bEqualizerInstantiated = LVM_FALSE;
+ } else if(pContext->EffectType == LVM_VOLUME) {
+ LOGV("\tEffectRelease LVM_VOLUME Clearing global intstantiated flag");
+ GlobalSessionMemory[pContext->pBundledContext->SessionNo].bVolumeInstantiated = LVM_FALSE;
+ } else {
+ LOGV("\tLVM_ERROR : EffectRelease : Unsupported effect\n\n\n\n\n\n\n");
+ }
+
+ // if all effects are no longer instantiaed free the lvm memory and delete BundledEffectContext
+ if((GlobalSessionMemory[pContext->pBundledContext->SessionNo].bBassInstantiated == LVM_FALSE)&&
+ (GlobalSessionMemory[pContext->pBundledContext->SessionNo].bVolumeInstantiated == LVM_FALSE)&&
+ (GlobalSessionMemory[pContext->pBundledContext->SessionNo].bEqualizerInstantiated == LVM_FALSE)&&
+ (GlobalSessionMemory[pContext->pBundledContext->SessionNo].bVirtualizerInstantiated == LVM_FALSE))
+ {
+ LOGV("\tEffectRelease: All effects are no longer instantiated\n");
+ GlobalSessionMemory[pContext->pBundledContext->SessionNo].bBundledEffectsEnabled = LVM_FALSE;
+ GlobalSessionMemory[pContext->pBundledContext->SessionNo].pBundledContext = LVM_NULL;
+ LOGV("\tEffectRelease: Freeing LVM Bundle memory\n");
+ LvmEffect_free(pContext);
+ LOGV("\tEffectRelease: Deleting LVM Bundle context\n");
+ delete pContext->pBundledContext;
+ }
+
+ // free the effect context for current effect
+ delete pContext;
+
+ LOGV("\tEffectRelease end\n");
+ return 0;
+
+} /* end EffectRelease */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+void LvmGlobalBundle_init(){
+ LOGV("\tLvmGlobalBundle_init start");
+ for(int i=0; i<LVM_MAX_SESSIONS; i++){
+ GlobalSessionMemory[i].bBundledEffectsEnabled = LVM_FALSE;
+ GlobalSessionMemory[i].bVolumeInstantiated = LVM_FALSE;
+ GlobalSessionMemory[i].bEqualizerInstantiated = LVM_FALSE;
+ GlobalSessionMemory[i].bBassInstantiated = LVM_FALSE;
+ GlobalSessionMemory[i].bVirtualizerInstantiated = LVM_FALSE;
+ GlobalSessionMemory[i].pBundledContext = LVM_NULL;
+ }
+ return;
+}
+//----------------------------------------------------------------------------
+// LvmBundle_init()
+//----------------------------------------------------------------------------
+// Purpose: Initialize engine with default configuration, creates instance
+// with all effects disabled.
+//
+// Inputs:
+// pContext: effect engine context
+//
+// Outputs:
+//
+//----------------------------------------------------------------------------
+
+int LvmBundle_init(EffectContext *pContext){
+ int status;
+
+ LOGV("\tLvmBundle_init start");
+
+ pContext->config.inputCfg.accessMode = EFFECT_BUFFER_ACCESS_READ;
+ pContext->config.inputCfg.channels = CHANNEL_STEREO;
+ pContext->config.inputCfg.format = SAMPLE_FORMAT_PCM_S15;
+ pContext->config.inputCfg.samplingRate = 44100;
+ pContext->config.inputCfg.bufferProvider.getBuffer = NULL;
+ pContext->config.inputCfg.bufferProvider.releaseBuffer = NULL;
+ pContext->config.inputCfg.bufferProvider.cookie = NULL;
+ pContext->config.inputCfg.mask = EFFECT_CONFIG_ALL;
+ pContext->config.outputCfg.accessMode = EFFECT_BUFFER_ACCESS_ACCUMULATE;
+ pContext->config.outputCfg.channels = CHANNEL_STEREO;
+ pContext->config.outputCfg.format = SAMPLE_FORMAT_PCM_S15;
+ pContext->config.outputCfg.samplingRate = 44100;
+ pContext->config.outputCfg.bufferProvider.getBuffer = NULL;
+ pContext->config.outputCfg.bufferProvider.releaseBuffer = NULL;
+ pContext->config.outputCfg.bufferProvider.cookie = NULL;
+ pContext->config.outputCfg.mask = EFFECT_CONFIG_ALL;
+
+ CHECK_ARG(pContext != NULL);
+
+ if (pContext->pBundledContext->hInstance != NULL){
+ LOGV("\tLvmBundle_init pContext->pBassBoost != NULL "
+ "-> Calling pContext->pBassBoost->free()");
+
+ LvmEffect_free(pContext);
+
+ LOGV("\tLvmBundle_init pContext->pBassBoost != NULL "
+ "-> Called pContext->pBassBoost->free()");
+ }
+
+ #ifdef LVM_BUNDLE
+ LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */
+ LVM_ControlParams_t params; /* Control Parameters */
+ LVM_InstParams_t InstParams; /* Instance parameters */
+ LVM_EQNB_BandDef_t BandDefs[MAX_NUM_BANDS]; /* Equaliser band definitions */
+ LVM_HeadroomParams_t HeadroomParams; /* Headroom parameters */
+ LVM_HeadroomBandDef_t HeadroomBandDef[LVM_HEADROOM_MAX_NBANDS];
+ LVM_MemTab_t MemTab; /* Memory allocation table */
+ bool bMallocFailure = LVM_FALSE;
+
+ /* Set the capabilities */
+ InstParams.BufferMode = LVM_MANAGED_BUFFERS;
+ InstParams.MaxBlockSize = MAX_CALL_SIZE;
+ InstParams.EQNB_NumBands = MAX_NUM_BANDS;
+ InstParams.PSA_Included = LVM_PSA_ON;
+
+ /* Allocate memory, forcing alignment */
+ LvmStatus = LVM_GetMemoryTable(LVM_NULL,
+ &MemTab,
+ &InstParams);
+
+ LVM_ERROR_CHECK(LvmStatus, "LVM_GetMemoryTable", "LvmBundle_init")
+ if(LvmStatus != LVM_SUCCESS) return -EINVAL;
+
+ LOGV("\tCreateInstance Succesfully called LVM_GetMemoryTable\n");
+
+ /* Allocate memory */
+ for (int i=0; i<LVM_NR_MEMORY_REGIONS; i++){
+ if (MemTab.Region[i].Size != 0){
+ MemTab.Region[i].pBaseAddress = malloc(MemTab.Region[i].Size);
+
+ if (MemTab.Region[i].pBaseAddress == LVM_NULL){
+ LOGV("\tLVM_ERROR : CreateInstance Failed to allocate %ld bytes for region %u\n",
+ MemTab.Region[i].Size, i );
+ bMallocFailure = LVM_TRUE;
+ }else{
+ LOGV("\tCreateInstance allocated %ld bytes for region %u at %p\n",
+ MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress);
+ }
+ }
+ }
+
+ /* If one or more of the memory regions failed to allocate, free the regions that were
+ * succesfully allocated and return with an error
+ */
+ if(bMallocFailure == LVM_TRUE){
+ for (int i=0; i<LVM_NR_MEMORY_REGIONS; i++){
+ if (MemTab.Region[i].pBaseAddress == LVM_NULL){
+ LOGV("\tLVM_ERROR : CreateInstance Failed to allocate %ld bytes for region %u - Not freeing\n",
+ MemTab.Region[i].Size, i );
+ }else{
+ LOGV("\tLVM_ERROR : CreateInstance Failed: but allocated %ld bytes for region %u at %p- free\n",
+ MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress);
+ free(MemTab.Region[i].pBaseAddress);
+ }
+ }
+ return -EINVAL;
+ }
+ LOGV("\tCreateInstance Succesfully malloc'd memory\n");
+
+ /* Initialise */
+ pContext->pBundledContext->hInstance = LVM_NULL; /* Initialise to NULL */
+
+ LvmStatus = LVM_GetInstanceHandle(&pContext->pBundledContext->hInstance,/* Init sets the instance handle */
+ &MemTab,
+ &InstParams);
+
+ LVM_ERROR_CHECK(LvmStatus, "LVM_GetInstanceHandle", "LvmBundle_init")
+ if(LvmStatus != LVM_SUCCESS) return -EINVAL;
+
+ LOGV("\tCreateInstance Succesfully called LVM_GetInstanceHandle\n");
+
+ /* Set the initial process parameters */
+ /* General parameters */
+ params.OperatingMode = LVM_MODE_ON;
+ params.SampleRate = LVM_FS_44100;
+ params.SourceFormat = LVM_STEREO;
+ params.SpeakerType = LVM_HEADPHONES;
+
+ /* Concert Sound parameters */
+ params.VirtualizerOperatingMode = LVM_MODE_OFF;
+ params.VirtualizerType = LVM_CONCERTSOUND;
+ params.VirtualizerReverbLevel = 100;
+ params.CS_EffectLevel = LVM_CS_EFFECT_HIGH;
+
+ /* N-Band Equaliser parameters */
+ params.EQNB_OperatingMode = LVM_EQNB_OFF;
+ params.EQNB_NBands = FIVEBAND_NUMBANDS;
+ params.pEQNB_BandDefinition = &BandDefs[0];
+ for (int i=0; i<FIVEBAND_NUMBANDS; i++)
+ {
+ BandDefs[i].Frequency = EQNB_5BandPresetsFrequencies[i];
+ BandDefs[i].QFactor = EQNB_5BandPresetsQFactors[i];
+ BandDefs[i].Gain = EQNB_5BandNormalPresets[i];
+ }
+
+ /* Volume Control parameters */
+ params.VC_EffectLevel = 0;
+ params.VC_Balance = 0;
+
+ /* Treble Enhancement parameters */
+ params.TE_OperatingMode = LVM_TE_OFF;
+ params.TE_EffectLevel = 0;
+
+ /* PSA Control parameters */
+ params.PSA_Enable = LVM_PSA_OFF;
+ params.PSA_PeakDecayRate = (LVM_PSA_DecaySpeed_en)0;
+
+ /* Bass Enhancement parameters */
+ params.BE_OperatingMode = LVM_BE_OFF;
+ params.BE_EffectLevel = 0;
+ params.BE_CentreFreq = LVM_BE_CENTRE_90Hz;
+ params.BE_HPF = LVM_BE_HPF_ON;
+
+ /* PSA Control parameters */
+ params.PSA_Enable = LVM_PSA_OFF;
+ params.PSA_PeakDecayRate = LVM_PSA_SPEED_MEDIUM;
+
+ LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, /* Activate the initial settings */
+ ¶ms);
+
+ LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "LvmBundle_init")
+ if(LvmStatus != LVM_SUCCESS) return -EINVAL;
+
+ LOGV("\tCreateInstance Succesfully called LVM_SetControlParameters\n");
+
+ /* Set the headroom parameters */
+ HeadroomBandDef[0].Limit_Low = 20;
+ HeadroomBandDef[0].Limit_High = 4999;
+ HeadroomBandDef[0].Headroom_Offset = 3;
+ HeadroomBandDef[1].Limit_Low = 5000;
+ HeadroomBandDef[1].Limit_High = 24000;
+ HeadroomBandDef[1].Headroom_Offset = 4;
+ HeadroomParams.pHeadroomDefinition = &HeadroomBandDef[0];
+ HeadroomParams.Headroom_OperatingMode = LVM_HEADROOM_ON;
+ HeadroomParams.NHeadroomBands = 2;
+
+ LvmStatus = LVM_SetHeadroomParams(pContext->pBundledContext->hInstance,
+ &HeadroomParams);
+
+ LVM_ERROR_CHECK(LvmStatus, "LVM_SetHeadroomParams", "LvmBundle_init")
+ if(LvmStatus != LVM_SUCCESS) return -EINVAL;
+
+ LOGV("\tCreateInstance Succesfully called LVM_SetHeadroomParams\n");
+ #endif /* end LVM_BUNDLE */
+
+ LOGV("\tLvmBundle_init End");
+ return 0;
+} /* end LvmBundle_init */
+
+
+
+//----------------------------------------------------------------------------
+// LvmBundle_process()
+//----------------------------------------------------------------------------
+// Purpose:
+// Apply LVM Bundle effects
+//
+// Inputs:
+// pIn: pointer to stereo 16 bit input data
+// pOut: pointer to stereo 16 bit output data
+// frameCount: Frames to process
+// pContext: effect engine context
+// strength strength to be applied
+//
+// Outputs:
+// pOut: pointer to updated stereo 16 bit output data
+//
+//----------------------------------------------------------------------------
+
+int LvmBundle_process(LVM_INT16 *pIn,
+ LVM_INT16 *pOut,
+ int frameCount,
+ EffectContext *pContext){
+
+ LVM_ControlParams_t ActiveParams; /* Current control Parameters */
+ LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */
+
+
+ #ifdef LVM_BUNDLE
+ LVM_INT16 *pOutTmp;
+ if (pContext->config.outputCfg.accessMode == EFFECT_BUFFER_ACCESS_WRITE){
+ //LOGV("\tprocess: mBehavior is EFFECT_BUFFER_ACCESS_WRITE %d\n",
+ // pContext->config.outputCfg.accessMode);
+ pOutTmp = pOut;
+ }else if (pContext->config.outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE){
+ //LOGV("\tprocess: mBehavior is EFFECT_BUFFER_ACCESS_ACCUMULATE %d\n",
+ // pContext->config.outputCfg.accessMode);
+ pOutTmp = (LVM_INT16 *)malloc(frameCount * sizeof(LVM_INT16) * 2);
+ if(pOutTmp == NULL){
+ LOGV("\tLVM_ERROR : LvmBundle_process failed to allocate memory for EFFECT_BUFFER_ACCESS_ACCUMULATE mode");
+ return -EINVAL;
+ }
+ }else{
+ LOGV("LVM_ERROR : LvmBundle_process invalid access mode");
+ return -EINVAL;
+ }
+
+ /* Process the samples */
+ LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, /* Get the current settings */
+ &ActiveParams);
+
+ LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "LvmEffect_enable")
+ if(LvmStatus != LVM_SUCCESS) return -EINVAL;
+ LOGV("\t%d %d %d\n",ActiveParams.BE_OperatingMode, ActiveParams.VirtualizerOperatingMode, ActiveParams.EQNB_OperatingMode);
+
+
+ LvmStatus = LVM_Process(pContext->pBundledContext->hInstance, /* Instance handle */
+ pIn, /* Input buffer */
+ pOutTmp, /* Output buffer */
+ (LVM_UINT16)frameCount, /* Number of samples to read */
+ 0); /* Audo Time */
+ LVM_ERROR_CHECK(LvmStatus, "LVM_Process", "LvmBundle_process")
+ if(LvmStatus != LVM_SUCCESS) return -EINVAL;
+
+ if (pContext->config.outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE){
+ for (int i=0; i<frameCount*2; i++){
+ pOut[i] += pOutTmp[i];
+ }
+ free(pOutTmp);
+ }
+ #else
+ memcpy(pOut, pIn, frameCount*sizeof(LVM_INT16)*2); // 2 is for stereo input
+ #endif /* end LVM_BUNDLE */
+ return 0;
+} /* end LvmBundle_process */
+
+//----------------------------------------------------------------------------
+// LvmEffect_enable()
+//----------------------------------------------------------------------------
+// Purpose: Enable the effect in the bundle
+//
+// Inputs:
+// pContext: effect engine context
+//
+// Outputs:
+//
+//----------------------------------------------------------------------------
+
+int LvmEffect_enable(EffectContext *pContext){
+ LOGV("\tLvmEffect_enable start");
+
+ #ifdef LVM_BUNDLE
+ LVM_ControlParams_t ActiveParams; /* Current control Parameters */
+ LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */
+
+ LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, /* Get the current settings */
+ &ActiveParams);
+
+ LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "LvmEffect_enable")
+ if(LvmStatus != LVM_SUCCESS) return -EINVAL;
+ LOGV("\tLvmEffect_enable Succesfully called LVM_GetControlParameters\n");
+
+ if(pContext->EffectType == LVM_BASS_BOOST) {
+ LOGV("\tLvmEffect_enable : Enabling LVM_BASS_BOOST");
+ ActiveParams.BE_OperatingMode = LVM_BE_ON;
+ }
+ if(pContext->EffectType == LVM_VIRTUALIZER) {
+ LOGV("\tLvmEffect_enable : Enabling LVM_VIRTUALIZER");
+ ActiveParams.VirtualizerOperatingMode = LVM_MODE_ON;
+ }
+ if(pContext->EffectType == LVM_EQUALIZER) {
+ LOGV("\tLvmEffect_enable : Enabling LVM_EQUALIZER");
+ ActiveParams.EQNB_OperatingMode = LVM_EQNB_ON;
+ }
+ if(pContext->EffectType == LVM_VOLUME) {
+ LOGV("\tLvmEffect_enable : Enabling LVM_VOLUME");
+ }
+
+ LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
+ LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "LvmEffect_enable")
+ if(LvmStatus != LVM_SUCCESS) return -EINVAL;
+ LOGV("\tLvmEffect_enable Succesfully called LVM_SetControlParameters\n");
+ #endif /* end LVM_BUNDLE */
+
+ LOGV("\tLvmEffect_enable end");
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+// LvmEffect_disable()
+//----------------------------------------------------------------------------
+// Purpose: Disable the effect in the bundle
+//
+// Inputs:
+// pContext: effect engine context
+//
+// Outputs:
+//
+//----------------------------------------------------------------------------
+
+int LvmEffect_disable(EffectContext *pContext){
+ LOGV("\tLvmEffect_disable start");
+
+ #ifdef LVM_BUNDLE
+ LVM_ControlParams_t ActiveParams; /* Current control Parameters */
+ LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */
+
+ LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, /* Get the current settings */
+ &ActiveParams);
+
+ LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "LvmEffect_disable")
+ if(LvmStatus != LVM_SUCCESS) return -EINVAL;
+ LOGV("\tLvmEffect_disable Succesfully called LVM_GetControlParameters\n");
+
+ if(pContext->EffectType == LVM_BASS_BOOST) {
+ LOGV("\tLvmEffect_disable : Disabling LVM_BASS_BOOST");
+ ActiveParams.BE_OperatingMode = LVM_BE_OFF;
+ }
+ if(pContext->EffectType == LVM_VIRTUALIZER) {
+ LOGV("\tLvmEffect_enable : Enabling LVM_VIRTUALIZER");
+ ActiveParams.VirtualizerOperatingMode = LVM_MODE_OFF;
+ }
+ if(pContext->EffectType == LVM_EQUALIZER) {
+ LOGV("\tLvmEffect_enable : Enabling LVM_EQUALIZER");
+ ActiveParams.EQNB_OperatingMode = LVM_EQNB_OFF;
+ }
+ if(pContext->EffectType == LVM_VOLUME) {
+ LOGV("\tLvmEffect_enable : Enabling LVM_VOLUME");
+ }
+
+ LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
+ LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "LvmEffect_disable")
+ if(LvmStatus != LVM_SUCCESS) return -EINVAL;
+ LOGV("\tLvmEffect_enable Succesfully called LVM_SetControlParameters\n");
+ #endif /* end LVM_BUNDLE */
+
+ LOGV("\tLvmEffect_enable end");
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+// LvmEffect_free()
+//----------------------------------------------------------------------------
+// Purpose: Free all memory associated with the Bundle.
+//
+// Inputs:
+// pContext: effect engine context
+//
+// Outputs:
+//
+//----------------------------------------------------------------------------
+
+void LvmEffect_free(EffectContext *pContext){
+ #ifdef LVM_BUNDLE
+ LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */
+ LVM_ControlParams_t params; /* Control Parameters */
+ LVM_MemTab_t MemTab;
+
+ /* Free the algorithm memory */
+ LvmStatus = LVM_GetMemoryTable(pContext->pBundledContext->hInstance,
+ &MemTab,
+ LVM_NULL);
+
+ LVM_ERROR_CHECK(LvmStatus, "LVM_GetMemoryTable", "LvmEffect_free")
+
+ for (int i=0; i<LVM_NR_MEMORY_REGIONS; i++){
+ if (MemTab.Region[i].Size != 0){
+ if (MemTab.Region[i].pBaseAddress != NULL){
+ LOGV("\tfree() - START freeing %ld bytes for region %u at %p\n",
+ MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress);
+
+ free(MemTab.Region[i].pBaseAddress);
+
+ LOGV("\tfree() - END freeing %ld bytes for region %u at %p\n",
+ MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress);
+ }else{
+ LOGV("\tLVM_ERROR : free() - trying to free with NULL pointer %ld bytes "
+ "for region %u at %p ERROR\n",
+ MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress);
+ }
+ }
+ }
+ #endif /* end LVM_BUNDLE */
+} /* end LvmEffect_free */
+
+//----------------------------------------------------------------------------
+// Effect_configure()
+//----------------------------------------------------------------------------
+// Purpose: Set input and output audio configuration.
+//
+// Inputs:
+// pContext: effect engine context
+// pConfig: pointer to effect_config_t structure holding input and output
+// configuration parameters
+//
+// Outputs:
+//
+//----------------------------------------------------------------------------
+
+int Effect_configure(EffectContext *pContext, effect_config_t *pConfig){
+ LOGV("\tEffect_configure start");
+
+ CHECK_ARG(pContext != NULL);
+ CHECK_ARG(pConfig != NULL);
+
+ CHECK_ARG(pConfig->inputCfg.samplingRate == pConfig->outputCfg.samplingRate);
+ CHECK_ARG(pConfig->inputCfg.channels == pConfig->outputCfg.channels);
+ CHECK_ARG(pConfig->inputCfg.format == pConfig->outputCfg.format);
+ CHECK_ARG(pConfig->inputCfg.channels == CHANNEL_STEREO);
+ CHECK_ARG(pConfig->outputCfg.accessMode == EFFECT_BUFFER_ACCESS_WRITE
+ || pConfig->outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE);
+ CHECK_ARG(pConfig->inputCfg.format == SAMPLE_FORMAT_PCM_S15);
+
+ LOGV("\tEffect_configure calling memcpy");
+ memcpy(&pContext->config, pConfig, sizeof(effect_config_t));
+ LOGV("\tEffect_configure End");
+ return 0;
+} /* end Effect_configure */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+//----------------------------------------------------------------------------
+// BassGetStrength()
+//----------------------------------------------------------------------------
+// Purpose:
+// get the effect strength currently being used, what is actually returned is the strengh that was
+// previously used in the set, this is because the app uses a strength in the range 0-1000 while
+// the bassboost uses 1-15, so to avoid a quantisation the original set value is used. However the
+// actual used value is checked to make sure it corresponds to the one being returned
+//
+// Inputs:
+// pContext: effect engine context
+//
+//----------------------------------------------------------------------------
+
+uint32_t BassGetStrength(EffectContext *pContext){
+ LOGV("\tBassGetStrength() (0-1000) -> %d\n", pContext->pBundledContext->BassStrengthSaved);
+
+ #ifdef LVM_BUNDLE
+ LVM_ControlParams_t ActiveParams; /* Current control Parameters */
+ LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */
+
+ LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, /* Get the current settings */
+ &ActiveParams);
+
+ LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "BassGetStrength")
+ if(LvmStatus != LVM_SUCCESS) return -EINVAL;
+
+ LOGV("\tBassGetStrength Succesfully returned from LVM_GetControlParameters\n");
+
+ /* Check that the strength returned matches the strength that was set earlier */
+ if(ActiveParams.BE_EffectLevel != (LVM_INT16)((15*pContext->pBundledContext->BassStrengthSaved)/1000)){
+ LOGV("\tLVM_ERROR : BassGetStrength module strength does not match savedStrength %d %d\n",
+ ActiveParams.BE_EffectLevel, pContext->pBundledContext->BassStrengthSaved);
+ return -EINVAL;
+ }
+
+ LOGV("\tBassGetStrength() (0-15) -> %d\n", ActiveParams.BE_EffectLevel );
+ #endif /* end LVM_BUNDLE */
+
+ LOGV("\tBassGetStrength() (saved) -> %d\n", pContext->pBundledContext->BassStrengthSaved );
+ return pContext->pBundledContext->BassStrengthSaved;
+} /* end BassGetStrength */
+
+//----------------------------------------------------------------------------
+// BassSetStrength()
+//----------------------------------------------------------------------------
+// Purpose:
+// Apply the strength to the BassBosst. Must first be converted from the range 0-1000 to 1-15
+//
+// Inputs:
+// pContext: effect engine context
+// strength strength to be applied
+//
+//----------------------------------------------------------------------------
+
+void BassSetStrength(EffectContext *pContext, uint32_t strength){
+ LOGV("\tBassSetStrength(%d)", strength);
+
+ pContext->pBundledContext->BassStrengthSaved = (int)strength;
+
+ #ifdef LVM_BUNDLE
+ LVM_ControlParams_t ActiveParams; /* Current control Parameters */
+ LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */
+
+ /* Get the current settings */
+ LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance,
+ &ActiveParams);
+
+ LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "BassSetStrength")
+ LOGV("\tsetStrength Succesfully returned from LVM_GetControlParameters\n");
+
+ /* Bass Enhancement parameters */
+// ActiveParams.BE_OperatingMode = LVM_BE_ON;
+ ActiveParams.BE_EffectLevel = (LVM_INT16)((15*strength)/1000);
+ ActiveParams.BE_CentreFreq = LVM_BE_CENTRE_90Hz;
+
+ LOGV("\tBassSetStrength() (0-15) -> %d\n", ActiveParams.BE_EffectLevel );
+
+ /* Activate the initial settings */
+ LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
+
+ LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "BassSetStrength")
+ LOGV("\tBassSetStrength Succesfully called LVM_SetControlParameters\n");
+ #endif /* end LVM_BUNDLE */
+} /* end BassSetStrength */
+
+//----------------------------------------------------------------------------
+// VirtualizerGetStrength()
+//----------------------------------------------------------------------------
+// Purpose:
+// get the effect strength currently being used, what is actually returned is the strengh that was
+// previously used in the set, this is because the app uses a strength in the range 0-1000 while
+// the Virtualizer uses 1-100, so to avoid a quantisation the original set value is used. However the
+// actual used value is checked to make sure it corresponds to the one being returned
+//
+// Inputs:
+// pContext: effect engine context
+//
+//----------------------------------------------------------------------------
+
+uint32_t VirtualizerGetStrength(EffectContext *pContext){
+ LOGV("\tVirtualizerGetStrength() (0-1000) -> %d\n", pContext->pBundledContext->VirtStrengthSaved );
+
+ #ifdef LVM_BUNDLE
+ LVM_ControlParams_t ActiveParams; /* Current control Parameters */
+ LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */
+
+ LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
+
+ LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VirtualizerGetStrength")
+ if(LvmStatus != LVM_SUCCESS) return -EINVAL;
+
+ LOGV("\tVirtualizerGetStrength Succesfully returned from LVM_GetControlParameters\n");
+ LOGV("\tVirtualizerGetStrength() (0-100) -> %d\n", ActiveParams.VirtualizerReverbLevel*10);
+ #endif /* end LVM_BUNDLE */
+
+ return ActiveParams.VirtualizerReverbLevel*10;
+} /* end getStrength */
+
+//----------------------------------------------------------------------------
+// VirtualizerSetStrength()
+//----------------------------------------------------------------------------
+// Purpose:
+// Apply the strength to the Virtualizer. Must first be converted from the range 0-1000 to 1-15
+//
+// Inputs:
+// pContext: effect engine context
+// strength strength to be applied
+//
+//----------------------------------------------------------------------------
+
+void VirtualizerSetStrength(EffectContext *pContext, uint32_t strength){
+ LOGV("\tVirtualizerSetStrength(%d)", strength);
+
+ pContext->pBundledContext->VirtStrengthSaved = (int)strength;
+
+ #ifdef LVM_BUNDLE
+ LVM_ControlParams_t ActiveParams; /* Current control Parameters */
+ LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */
+
+ /* Get the current settings */
+ LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance,&ActiveParams);
+
+ LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VirtualizerSetStrength")
+ LOGV("\tVirtualizerSetStrength Succesfully returned from LVM_GetControlParameters\n");
+
+ /* Virtualizer parameters */
+ ActiveParams.VirtualizerReverbLevel = (LVM_INT16)(strength/10);
+
+ LOGV("\tVirtualizerSetStrength() (0-1000) -> %d\n", strength );
+ LOGV("\tVirtualizerSetStrength() (0- 100) -> %d\n", ActiveParams.VirtualizerReverbLevel );
+
+ /* Activate the initial settings */
+ LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
+ LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "VirtualizerSetStrength")
+ LOGV("\tVirtualizerSetStrength Succesfully called LVM_SetControlParameters\n");
+ #endif /* end LVM_BUNDLE */
+} /* end setStrength */
+
+//----------------------------------------------------------------------------
+// EqualizerGetBandLevel()
+//----------------------------------------------------------------------------
+// Purpose: Retrieve the gain currently being used for the band passed in
+//
+// Inputs:
+// band: band number
+// pContext: effect engine context
+//
+// Outputs:
+//
+//----------------------------------------------------------------------------
+int32_t EqualizerGetBandLevel(EffectContext *pContext, int32_t band){
+
+ int32_t Gain =0;
+
+ #ifdef LVM_BUNDLE
+ LVM_ControlParams_t ActiveParams; /* Current control Parameters */
+ LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */
+ LVM_EQNB_BandDef_t *BandDef;
+
+ LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, /* Get the current settings */
+ &ActiveParams);
+
+ LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "getBandLevel")
+
+ BandDef = ActiveParams.pEQNB_BandDefinition;
+ Gain = (int32_t)BandDef[band].Gain*100; // Convert to millibels
+
+ LOGV("\tgetBandLevel() -> %d\n", Gain );
+ LOGV("\tgetBandLevel Succesfully returned from LVM_GetControlParameters\n");
+ #endif /* end LVM_BUNDLE */
+
+ return Gain;
+}
+
+//----------------------------------------------------------------------------
+// EqualizerSetBandLevel()
+//----------------------------------------------------------------------------
+// Purpose:
+// Sets gain value for the given band.
+//
+// Inputs:
+// band: band number
+// Gain: Gain to be applied in millibels
+// pContext: effect engine context
+//
+// Outputs:
+//
+//---------------------------------------------------------------------------
+void EqualizerSetBandLevel(EffectContext *pContext, int band, int Gain){
+ int gainRounded;
+ if(Gain > 0){
+ gainRounded = (int)((Gain+50)/100);
+ }else{
+ gainRounded = (int)((Gain-50)/100);
+ }
+ LOGV("\tsetBandLevel(%d)->(%d)", Gain, gainRounded);
+
+ #ifdef LVM_BUNDLE
+ LVM_ControlParams_t ActiveParams; /* Current control Parameters */
+ LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */
+ LVM_EQNB_BandDef_t *BandDef;
+
+ /* Get the current settings */
+ LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
+ LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "setBandLevel")
+ LOGV("\tsetBandLevel Succesfully returned from LVM_GetControlParameters\n");
+ LOGV("\tsetBandLevel() just Got -> %d\n", ActiveParams.pEQNB_BandDefinition[band].Gain);
+
+ /* Set local EQ parameters */
+ BandDef = ActiveParams.pEQNB_BandDefinition;
+ ActiveParams.pEQNB_BandDefinition[band].Gain = gainRounded;
+
+ /* Activate the initial settings */
+ LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
+ LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "setBandLevel")
+ LOGV("\tsetBandLevel() just Set -> %d\n", ActiveParams.pEQNB_BandDefinition[band].Gain);
+
+ /* Get the current settings to check they were applied ok, might not work as process not called*/
+ LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
+ LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "setBandLevel")
+ LOGV("\tLVM_ERROR : remove this test setBandLevel Succesfully returned from LVM_GetControlParameters\n");
+ LOGV("\tsetBandLevel() just Got -> %d\n", ActiveParams.pEQNB_BandDefinition[band].Gain);
+ LOGV("\tsetBandLevel Succesfully called LVM_SetControlParameters\n");
+ #endif /* end LVM_BUNDLE */
+
+ pContext->pBundledContext->CurPreset = PRESET_CUSTOM;
+ return;
+}
+//----------------------------------------------------------------------------
+// EqualizerGetCentreFrequency()
+//----------------------------------------------------------------------------
+// Purpose: Retrieve the frequency being used for the band passed in
+//
+// Inputs:
+// band: band number
+// pContext: effect engine context
+//
+// Outputs:
+//
+//----------------------------------------------------------------------------
+int32_t EqualizerGetCentreFrequency(EffectContext *pContext, int32_t band){
+ int32_t Frequency =0;
+
+ #ifdef LVM_BUNDLE
+ LVM_ControlParams_t ActiveParams; /* Current control Parameters */
+ LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */
+ LVM_EQNB_BandDef_t *BandDef;
+
+ LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, /* Get the current settings */
+ &ActiveParams);
+
+ LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "getCentreFrequency")
+
+ BandDef = ActiveParams.pEQNB_BandDefinition;
+ Frequency = (int32_t)BandDef[band].Frequency*1000; // Convert to millibels
+
+ LOGV("\tgetCentreFrequency() -> %d\n", Frequency );
+ LOGV("\tgetCentreFrequency Succesfully returned from LVM_GetControlParameters\n");
+ #endif /* end LVM_BUNDLE */
+
+ return Frequency;
+}
+
+//----------------------------------------------------------------------------
+// EqualizerGetBandFreqRange(
+//----------------------------------------------------------------------------
+// Purpose:
+//
+// Gets lower and upper boundaries of a band.
+// For the high shelf, the low bound is the band frequency and the high
+// bound is Nyquist.
+// For the peaking filters, they are the gain[dB]/2 points.
+//
+// Inputs:
+// band: band number
+// pContext: effect engine context
+//
+// Outputs:
+// pLow: lower band range
+// pLow: upper band range
+//----------------------------------------------------------------------------
+int32_t EqualizerGetBandFreqRange(EffectContext *pContext, int32_t band, uint32_t *pLow, uint32_t *pHi){
+ *pLow = bandFreqRange[band][0];
+ *pHi = bandFreqRange[band][1];
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+// EqualizerGetBand(
+//----------------------------------------------------------------------------
+// Purpose:
+//
+// Returns the band with the maximum influence on a given frequency.
+// Result is unaffected by whether EQ is enabled or not, or by whether
+// changes have been committed or not.
+//
+// Inputs:
+// targetFreq The target frequency, in millihertz.
+// pContext: effect engine context
+//
+// Outputs:
+// pLow: lower band range
+// pLow: upper band range
+//----------------------------------------------------------------------------
+int32_t EqualizerGetBand(EffectContext *pContext, uint32_t targetFreq){
+ int band = 0;
+
+ if(targetFreq < bandFreqRange[0][0]){
+ return -EINVAL;
+ }else if(targetFreq == bandFreqRange[0][0]){
+ return 0;
+ }
+ for(int i=0; i<FIVEBAND_NUMBANDS;i++){
+ if((targetFreq > bandFreqRange[i][0])&&(targetFreq <= bandFreqRange[i][1])){
+ band = i;
+ }
+ }
+ return band;
+}
+
+//----------------------------------------------------------------------------
+// EqualizerGetPreset(
+//----------------------------------------------------------------------------
+// Purpose:
+//
+// Gets the currently set preset ID.
+// Will return PRESET_CUSTOM in case the EQ parameters have been modified
+// manually since a preset was set.
+//
+// Inputs:
+// pContext: effect engine context
+//
+//----------------------------------------------------------------------------
+int32_t EqualizerGetPreset(EffectContext *pContext){
+ return pContext->pBundledContext->CurPreset;
+}
+
+//----------------------------------------------------------------------------
+// EqualizerSetPreset(
+//----------------------------------------------------------------------------
+// Purpose:
+//
+// Sets the current preset by ID.
+// All the band parameters will be overridden.
+//
+// Inputs:
+// pContext: effect engine context
+// preset The preset ID.
+//
+//----------------------------------------------------------------------------
+void EqualizerSetPreset(EffectContext *pContext, int preset){
+
+ LOGV("\tsetPreset(%d)", preset);
+ pContext->pBundledContext->CurPreset = preset;
+
+ #ifdef LVM_BUNDLE
+ LVM_ControlParams_t ActiveParams; /* Current control Parameters */
+ LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */
+
+ /* Get the current settings */
+ LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
+ LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "setPreset")
+ LOGV("\tsetPreset Succesfully returned from LVM_GetControlParameters\n");
+
+ //ActiveParams.pEQNB_BandDefinition = &BandDefs[0];
+ for (int i=0; i<FIVEBAND_NUMBANDS; i++)
+ {
+ ActiveParams.pEQNB_BandDefinition[i].Frequency = EQNB_5BandPresetsFrequencies[i];
+ ActiveParams.pEQNB_BandDefinition[i].QFactor = EQNB_5BandPresetsQFactors[i];
+ ActiveParams.pEQNB_BandDefinition[i].Gain
+ = EQNB_5BandNormalPresets[i + preset * FIVEBAND_NUMBANDS];
+ }
+ /* Activate the new settings */
+ LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
+ LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "setPreset")
+ LOGV("\tsetPreset Succesfully called LVM_SetControlParameters\n");
+ #endif /* end LVM_BUNDLE */
+
+ return;
+}
+int32_t EqualizerGetNumPresets(){
+ return 10;
+}
+
+//----------------------------------------------------------------------------
+// EqualizerGetPresetName(
+//----------------------------------------------------------------------------
+// Purpose:
+// Gets a human-readable name for a preset ID. Will return "Custom" if
+// PRESET_CUSTOM is passed.
+//
+// Inputs:
+// preset The preset ID. Must be less than number of presets.
+//
+//-------------------------------------------------------------------------
+const char * EqualizerGetPresetName(int32_t preset){
+ LOGV("\tEqualizerGetPresetName start(%d)", preset);
+ if (preset == PRESET_CUSTOM) {
+ return "Custom";
+ } else {
+ return gEqualizerPresets[preset].name;
+ }
+ LOGV("\tEqualizerGetPresetName end(%d)", preset);
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+// VolumeSetVolumeLevel()
+//----------------------------------------------------------------------------
+// Purpose:
+//
+// Inputs:
+// pContext: effect engine context
+// level level to be applied
+//
+//----------------------------------------------------------------------------
+
+int VolumeSetVolumeLevel(EffectContext *pContext, int16_t level){
+ LOGV("\tVolumeSetVolumeLevel start(%d)", level);
+
+ #ifdef LVM_BUNDLE
+ LVM_ControlParams_t ActiveParams; /* Current control Parameters */
+ LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */
+
+ /* Get the current settings */
+ LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
+ LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeSetVolumeLevel")
+ if(LvmStatus != LVM_SUCCESS) return -EINVAL;
+ LOGV("\tVolumeSetVolumeLevel Succesfully returned from LVM_GetControlParameters\n");
+
+ /* Volume parameters */
+ ActiveParams.VC_EffectLevel = (LVM_INT16)(level/100);
+ LOGV("\tVolumeSetVolumeLevel() (-96dB -> 0dB) -> %d\n", ActiveParams.VC_EffectLevel );
+
+ /* Activate the initial settings */
+ LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
+ LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "VolumeSetVolumeLevel")
+ if(LvmStatus != LVM_SUCCESS) return -EINVAL;
+
+ LOGV("\tVolumeSetVolumeLevel Succesfully called LVM_SetControlParameters\n");
+ LOGV("\tVolumeSetVolumeLevel end");
+ #endif /* end LVM_BUNDLE */
+ return 0;
+} /* end setVolumeLevel */
+
+//----------------------------------------------------------------------------
+// VolumeGetVolumeLevel()
+//----------------------------------------------------------------------------
+// Purpose:
+//
+// Inputs:
+// pContext: effect engine context
+//
+//----------------------------------------------------------------------------
+
+int VolumeGetVolumeLevel(EffectContext *pContext, int16_t *level){
+
+ LOGV("\tVolumeGetVolumeLevel start");
+ #ifdef LVM_BUNDLE
+ LVM_ControlParams_t ActiveParams; /* Current control Parameters */
+ LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */
+
+ LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
+ LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeGetVolumeLevel")
+ if(LvmStatus != LVM_SUCCESS) return -EINVAL;
+
+ LOGV("\tVolumeGetVolumeLevel() (-96dB -> 0dB) -> %d\n", ActiveParams.VC_EffectLevel );
+ LOGV("\tVolumeGetVolumeLevel Succesfully returned from LVM_GetControlParameters\n");
+ #endif /* end LVM_BUNDLE */
+
+ *level = ActiveParams.VC_EffectLevel*100; // Convert dB to millibels
+ LOGV("\tVolumeGetVolumeLevel end");
+ return 0;
+} /* end VolumeGetVolumeLevel */
+
+//----------------------------------------------------------------------------
+// VolumeSetMute()
+//----------------------------------------------------------------------------
+// Purpose:
+//
+// Inputs:
+// pContext: effect engine context
+// mute: enable/disable flag
+//
+//----------------------------------------------------------------------------
+
+int32_t VolumeSetMute(EffectContext *pContext, uint32_t mute){
+ LOGV("\tVolumeSetMute start()");
+
+ pContext->pBundledContext->bMuteEnabled = mute;
+
+ #ifdef LVM_BUNDLE
+ LVM_ControlParams_t ActiveParams; /* Current control Parameters */
+ LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */
+
+ /* Get the current settings */
+ LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
+ LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeSetMute")
+ if(LvmStatus != LVM_SUCCESS) return -EINVAL;
+
+ LOGV("\tVolumeSetMute Succesfully returned from LVM_GetControlParameters\n");
+ LOGV("\tVolumeSetMute() to %d, level was %d\n", mute, ActiveParams.BE_EffectLevel );
+
+ /* Set appropriate volume level */
+ if(pContext->pBundledContext->bMuteEnabled == LVM_TRUE){
+ pContext->pBundledContext->levelSaved = ActiveParams.VC_EffectLevel;
+ ActiveParams.VC_EffectLevel = -96;
+ }else{
+ ActiveParams.VC_EffectLevel = pContext->pBundledContext->levelSaved;
+ }
+
+ /* Activate the initial settings */
+ LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
+ LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "VolumeSetMute")
+ if(LvmStatus != LVM_SUCCESS) return -EINVAL;
+
+ LOGV("\tVolumeSetMute Succesfully called LVM_SetControlParameters\n");
+ #endif /* end LVM_BUNDLE */
+ LOGV("\tVolumeSetMute start()");
+ return 0;
+} /* end setMute */
+
+//----------------------------------------------------------------------------
+// VolumeSetMute()
+//----------------------------------------------------------------------------
+// Purpose:
+//
+// Inputs:
+// pContext: effect engine context
+//
+// Ourputs:
+// mute: enable/disable flag
+//----------------------------------------------------------------------------
+
+int32_t VolumeGetMute(EffectContext *pContext, uint32_t *mute){
+ LOGV("\tVolumeGetMute start");
+ if((pContext->pBundledContext->bMuteEnabled == LVM_FALSE)||(pContext->pBundledContext->bMuteEnabled == LVM_TRUE)){
+ *mute = pContext->pBundledContext->bMuteEnabled;
+ return 0;
+ }else{
+ LOGV("\tLVM_ERROR : VolumeGetMute read an invalid value from context %d", pContext->pBundledContext->bMuteEnabled);
+ return -EINVAL;
+ }
+ LOGV("\tVolumeGetMute start");
+} /* end getMute */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+//----------------------------------------------------------------------------
+// BassBoost_getParameter()
+//----------------------------------------------------------------------------
+// Purpose:
+// Get a BassBoost parameter
+//
+// Inputs:
+// pBassBoost - handle to instance data
+// pParam - pointer to parameter
+// pValue - pointer to variable to hold retrieved value
+// pValueSize - pointer to value size: maximum size as input
+//
+// Outputs:
+// *pValue updated with parameter value
+// *pValueSize updated with actual value size
+//
+//
+// Side Effects:
+//
+//----------------------------------------------------------------------------
+
+int BassBoost_getParameter(EffectContext *pContext,
+ int32_t *pParam,
+ size_t *pValueSize,
+ void *pValue){
+ int status = 0;
+ int32_t param = *pParam++;
+ int32_t param2;
+ char *name;
+
+ LOGV("\tBassBoost_getParameter start");
+
+ switch (param){
+ case BASSBOOST_PARAM_STRENGTH_SUP:
+ //if (*pValueSize != sizeof(uint32_t)){
+ // LOGV("\tLVM_ERROR : BassBoost_getParameter() invalid pValueSize1 %d", *pValueSize);
+ // return -EINVAL;
+ //}
+ //*pValueSize = sizeof(uint32_t);
+ //break;
+ case BASSBOOST_PARAM_STRENGTH:
+ if (*pValueSize != sizeof(int16_t)){
+ LOGV("\tLVM_ERROR : BassBoost_getParameter() invalid pValueSize2 %d", *pValueSize);
+ return -EINVAL;
+ }
+ *pValueSize = sizeof(int16_t);
+ break;
+
+ default:
+ LOGV("\tLVM_ERROR : BassBoost_getParameter() invalid param %d", param);
+ return -EINVAL;
+ }
+
+ switch (param){
+ case BASSBOOST_PARAM_STRENGTH_SUP:
+ *(uint32_t *)pValue = 1;
+
+ LOGV("\tBassBoost_getParameter() BASSBOOST_PARAM_STRENGTH_SUP Value is %d",
+ *(uint32_t *)pValue);
+ break;
+
+ case BASSBOOST_PARAM_STRENGTH:
+ *(int16_t *)pValue = BassGetStrength(pContext);
+
+ LOGV("\tBassBoost_getParameter() BASSBOOST_PARAM_STRENGTH Value is %d",
+ *(int16_t *)pValue);
+ break;
+
+ default:
+ LOGV("\tLVM_ERROR : BassBoost_getParameter() invalid param %d", param);
+ status = -EINVAL;
+ break;
+ }
+
+ LOGV("\tBassBoost_getParameter end");
+ return status;
+} /* end BassBoost_getParameter */
+
+
+//----------------------------------------------------------------------------
+// BassBoost_setParameter()
+//----------------------------------------------------------------------------
+// Purpose:
+// Set a BassBoost parameter
+//
+// Inputs:
+// pBassBoost - handle to instance data
+// pParam - pointer to parameter
+// pValue - pointer to value
+//
+// Outputs:
+//
+//----------------------------------------------------------------------------
+
+int BassBoost_setParameter (EffectContext *pContext, int32_t *pParam, void *pValue){
+ int status = 0;
+ int16_t strength;
+
+ LOGV("\tBassBoost_setParameter start");
+
+ switch (*pParam){
+ case BASSBOOST_PARAM_STRENGTH:
+ strength = *(int16_t *)pValue;
+ LOGV("\tBassBoost_setParameter() BASSBOOST_PARAM_STRENGTH value is %d", strength);
+ LOGV("\tBassBoost_setParameter() Calling pBassBoost->BassSetStrength");
+ BassSetStrength(pContext, (int32_t)strength);
+ LOGV("\tBassBoost_setParameter() Called pBassBoost->BassSetStrength");
+ break;
+ default:
+ LOGV("\tLVM_ERROR : BassBoost_setParameter() invalid param %d", *pParam);
+ break;
+ }
+
+ LOGV("\tBassBoost_setParameter end");
+ return status;
+} /* end BassBoost_setParameter */
+
+//----------------------------------------------------------------------------
+// Virtualizer_getParameter()
+//----------------------------------------------------------------------------
+// Purpose:
+// Get a Virtualizer parameter
+//
+// Inputs:
+// pVirtualizer - handle to instance data
+// pParam - pointer to parameter
+// pValue - pointer to variable to hold retrieved value
+// pValueSize - pointer to value size: maximum size as input
+//
+// Outputs:
+// *pValue updated with parameter value
+// *pValueSize updated with actual value size
+//
+//
+// Side Effects:
+//
+//----------------------------------------------------------------------------
+
+int Virtualizer_getParameter(EffectContext *pContext,
+ int32_t *pParam,
+ size_t *pValueSize,
+ void *pValue){
+ int status = 0;
+ int32_t param = *pParam++;
+ int32_t param2;
+ char *name;
+
+ LOGV("\tVirtualizer_getParameter start");
+
+ switch (param){
+ case VIRTUALIZER_PARAM_STRENGTH_SUP:
+ //if (*pValueSize != sizeof(uint32_t)){
+ // LOGV("\tLVM_ERROR : Virtualizer_getParameter() invalid pValueSize1 %d", *pValueSize);
+ // return -EINVAL;
+ //}
+ //*pValueSize = sizeof(uint32_t);
+ //break;
+ case VIRTUALIZER_PARAM_STRENGTH:
+ if (*pValueSize != sizeof(int16_t)){
+ LOGV("\tLVM_ERROR : Virtualizer_getParameter() invalid pValueSize2 %d", *pValueSize);
+ return -EINVAL;
+ }
+ *pValueSize = sizeof(int16_t);
+ break;
+
+ default:
+ LOGV("\tLVM_ERROR : Virtualizer_getParameter() invalid param %d", param);
+ return -EINVAL;
+ }
+
+ switch (param){
+ case VIRTUALIZER_PARAM_STRENGTH_SUP:
+ *(uint32_t *)pValue = 1;
+
+ LOGV("\tVirtualizer_getParameter() VIRTUALIZER_PARAM_STRENGTH_SUP Value is %d",
+ *(uint32_t *)pValue);
+ break;
+
+ case VIRTUALIZER_PARAM_STRENGTH:
+ *(int16_t *)pValue = VirtualizerGetStrength(pContext);
+
+ LOGV("\tVirtualizer_getParameter() VIRTUALIZER_PARAM_STRENGTH Value is %d",
+ *(int16_t *)pValue);
+ break;
+
+ default:
+ LOGV("\tLVM_ERROR : Virtualizer_getParameter() invalid param %d", param);
+ status = -EINVAL;
+ break;
+ }
+
+ LOGV("\tVirtualizer_getParameter end");
+ return status;
+} /* end Virtualizer_getParameter */
+
+
+//----------------------------------------------------------------------------
+// Virtualizer_setParameter()
+//----------------------------------------------------------------------------
+// Purpose:
+// Set a Virtualizer parameter
+//
+// Inputs:
+// pVirtualizer - handle to instance data
+// pParam - pointer to parameter
+// pValue - pointer to value
+//
+// Outputs:
+//
+//----------------------------------------------------------------------------
+
+int Virtualizer_setParameter (EffectContext *pContext, int32_t *pParam, void *pValue){
+ int status = 0;
+ int16_t strength;
+
+ LOGV("\tVirtualizer_setParameter start");
+
+ switch (*pParam){
+ case VIRTUALIZER_PARAM_STRENGTH:
+ strength = *(int16_t *)pValue;
+ LOGV("\tVirtualizer_setParameter() VIRTUALIZER_PARAM_STRENGTH value is %d", strength);
+ LOGV("\tVirtualizer_setParameter() Calling pVirtualizer->setStrength");
+ VirtualizerSetStrength(pContext, (int32_t)strength);
+ LOGV("\tVirtualizer_setParameter() Called pVirtualizer->setStrength");
+ break;
+ default:
+ LOGV("\tLVM_ERROR : Virtualizer_setParameter() invalid param %d", *pParam);
+ break;
+ }
+
+ LOGV("\tVirtualizer_setParameter end");
+ return status;
+} /* end Virtualizer_setParameter */
+
+//----------------------------------------------------------------------------
+// Equalizer_getParameter()
+//----------------------------------------------------------------------------
+// Purpose:
+// Get a Equalizer parameter
+//
+// Inputs:
+// pEqualizer - handle to instance data
+// pParam - pointer to parameter
+// pValue - pointer to variable to hold retrieved value
+// pValueSize - pointer to value size: maximum size as input
+//
+// Outputs:
+// *pValue updated with parameter value
+// *pValueSize updated with actual value size
+//
+//
+// Side Effects:
+//
+//----------------------------------------------------------------------------
+int Equalizer_getParameter(EffectContext *pContext,
+ int32_t *pParam,
+ size_t *pValueSize,
+ void *pValue){
+ int status = 0;
+ int bMute = 0;
+ int32_t param = *pParam++;
+ int32_t param2;
+ char *name;
+
+ LOGV("\tEqualizer_getParameter start");
+
+ switch (param) {
+ case EQ_PARAM_NUM_BANDS:
+ case EQ_PARAM_CUR_PRESET:
+ case EQ_PARAM_GET_NUM_OF_PRESETS:
+ if (*pValueSize < sizeof(int16_t)) {
+ LOGV("\tLVM_ERROR : Equalizer_getParameter() invalid pValueSize 1 %d", *pValueSize);
+ return -EINVAL;
+ }
+ *pValueSize = sizeof(int16_t);
+ break;
+
+ case EQ_PARAM_LEVEL_RANGE:
+ case EQ_PARAM_BAND_FREQ_RANGE:
+ if (*pValueSize < 2 * sizeof(int32_t)) {
+ LOGV("\tLVM_ERROR : Equalizer_getParameter() invalid pValueSize 2 %d", *pValueSize);
+ return -EINVAL;
+ }
+ *pValueSize = 2 * sizeof(int32_t);
+ break;
+ case EQ_PARAM_BAND_LEVEL:
+ case EQ_PARAM_GET_BAND:
+ case EQ_PARAM_CENTER_FREQ:
+ if (*pValueSize < sizeof(int32_t)) {
+ LOGV("\tLVM_ERROR : Equalizer_getParameter() invalid pValueSize 1 %d", *pValueSize);
+ return -EINVAL;
+ }
+ *pValueSize = sizeof(int32_t);
+ break;
+
+ case EQ_PARAM_GET_PRESET_NAME:
+ break;
+
+ default:
+ LOGV("\tLVM_ERROR : Equalizer_getParameter unknown param %d", param);
+ return -EINVAL;
+ }
+
+ switch (param) {
+ case EQ_PARAM_NUM_BANDS:
+ *(int16_t *)pValue = FIVEBAND_NUMBANDS;
+ LOGV("\tEqualizer_getParameter() EQ_PARAM_NUM_BANDS %d", *(int16_t *)pValue);
+ break;
+
+ case EQ_PARAM_LEVEL_RANGE:
+ *(int32_t *)pValue = -1500;
+ *((int32_t *)pValue + 1) = 1500;
+ LOGV("\tEqualizer_getParameter() EQ_PARAM_LEVEL_RANGE min %d, max %d", *(int32_t *)pValue, *((int32_t *)pValue + 1));
+ break;
+
+ case EQ_PARAM_BAND_LEVEL:
+ param2 = *pParam;
+ if (param2 >= FIVEBAND_NUMBANDS) {
+ status = -EINVAL;
+ break;
+ }
+ *(int32_t *)pValue = EqualizerGetBandLevel(pContext, param2);
+ LOGV("\tEqualizer_getParameter() EQ_PARAM_BAND_LEVEL band %d, level %d", param2, *(int32_t *)pValue);
+ break;
+
+ case EQ_PARAM_CENTER_FREQ:
+ param2 = *pParam;
+ if (param2 >= FIVEBAND_NUMBANDS) {
+ status = -EINVAL;
+ break;
+ }
+ *(int32_t *)pValue = EqualizerGetCentreFrequency(pContext, param2);
+ LOGV("\tEqualizer_getParameter() EQ_PARAM_CENTER_FREQ band %d, frequency %d", param2, *(int32_t *)pValue);
+ break;
+
+ case EQ_PARAM_BAND_FREQ_RANGE:
+ param2 = *pParam;
+ if (param2 >= FIVEBAND_NUMBANDS) {
+ status = -EINVAL;
+ break;
+ }
+ EqualizerGetBandFreqRange(pContext, param2, (uint32_t *)pValue, ((uint32_t *)pValue + 1));
+ LOGV("\tEqualizer_getParameter() EQ_PARAM_BAND_FREQ_RANGE band %d, min %d, max %d", param2, *(int32_t *)pValue, *((int32_t *)pValue + 1));
+ break;
+
+ case EQ_PARAM_GET_BAND:
+ param2 = *pParam;
+ *(int32_t *)pValue = EqualizerGetBand(pContext, param2);
+ LOGV("\tEqualizer_getParameter() EQ_PARAM_GET_BAND frequency %d, band %d", param2, *(int32_t *)pValue);
+ break;
+
+ case EQ_PARAM_CUR_PRESET:
+ *(int16_t *)pValue = EqualizerGetPreset(pContext);
+ LOGV("\tEqualizer_getParameter() EQ_PARAM_CUR_PRESET %d", *(int32_t *)pValue);
+ break;
+
+ case EQ_PARAM_GET_NUM_OF_PRESETS:
+ *(int16_t *)pValue = EqualizerGetNumPresets();
+ LOGV("\tEqualizer_getParameter() EQ_PARAM_GET_NUM_OF_PRESETS %d", *(int16_t *)pValue);
+ break;
+
+ case EQ_PARAM_GET_PRESET_NAME:
+ param2 = *pParam;
+ if (param2 >= EqualizerGetNumPresets()) {
+ //if (param2 >= 20) { // AGO FIX
+ status = -EINVAL;
+ break;
+ }
+ name = (char *)pValue;
+ strncpy(name, EqualizerGetPresetName(param2), *pValueSize - 1);
+ name[*pValueSize - 1] = 0;
+ *pValueSize = strlen(name) + 1;
+ LOGV("\tEqualizer_getParameter() EQ_PARAM_GET_PRESET_NAME preset %d, name %s len %d", param2, gEqualizerPresets[param2].name, *pValueSize);
+ break;
+
+ default:
+ LOGV("\tLVM_ERROR : Equalizer_getParameter() invalid param %d", param);
+ status = -EINVAL;
+ break;
+ }
+
+ LOGV("\tEqualizer_getParameter end");
+ return status;
+} /* end Equalizer_getParameter */
+
+//----------------------------------------------------------------------------
+// Equalizer_setParameter()
+//----------------------------------------------------------------------------
+// Purpose:
+// Set a Equalizer parameter
+//
+// Inputs:
+// pEqualizer - handle to instance data
+// pParam - pointer to parameter
+// pValue - pointer to value
+//
+// Outputs:
+//
+//----------------------------------------------------------------------------
+int Equalizer_setParameter (EffectContext *pContext, int32_t *pParam, void *pValue){
+ int status = 0;
+ int32_t preset;
+ int32_t band;
+ int32_t level;
+ int32_t param = *pParam++;
+
+ LOGV("\tEqualizer_setParameter start");
+ switch (param) {
+ case EQ_PARAM_CUR_PRESET:
+ preset = *(int16_t *)pValue;
+
+ LOGV("\tEqualizer_setParameter() EQ_PARAM_CUR_PRESET %d", preset);
+ if ((preset >= EqualizerGetNumPresets())||(preset < 0)) {
+ status = -EINVAL;
+ break;
+ }
+ EqualizerSetPreset(pContext, preset);
+ break;
+ case EQ_PARAM_BAND_LEVEL:
+ band = *pParam;
+ level = *(int32_t *)pValue;
+ LOGV("\tEqualizer_setParameter() EQ_PARAM_BAND_LEVEL band %d, level %d", band, level);
+ if (band >= FIVEBAND_NUMBANDS) {
+ status = -EINVAL;
+ break;
+ }
+ EqualizerSetBandLevel(pContext, band, level);
+ break;
+ default:
+ LOGV("\tLVM_ERROR : setParameter() invalid param %d", param);
+ break;
+ }
+
+ LOGV("\tEqualizer_setParameter end");
+ return status;
+} /* end Equalizer_setParameter */
+
+//----------------------------------------------------------------------------
+// Volume_getParameter()
+//----------------------------------------------------------------------------
+// Purpose:
+// Get a Volume parameter
+//
+// Inputs:
+// pVolume - handle to instance data
+// pParam - pointer to parameter
+// pValue - pointer to variable to hold retrieved value
+// pValueSize - pointer to value size: maximum size as input
+//
+// Outputs:
+// *pValue updated with parameter value
+// *pValueSize updated with actual value size
+//
+//
+// Side Effects:
+//
+//----------------------------------------------------------------------------
+
+int Volume_getParameter(EffectContext *pContext,
+ int32_t *pParam,
+ size_t *pValueSize,
+ void *pValue){
+ int status = 0;
+ int bMute = 0;
+ int32_t param = *pParam++;
+ int32_t param2;
+ char *name;
+
+ LOGV("\tVolume_getParameter start");
+
+ switch (param){
+ case VOLUME_PARAM_LEVEL:
+ case VOLUME_PARAM_MAXLEVEL:
+ case VOLUME_PARAM_STEREOPOSITION:
+ if (*pValueSize < sizeof(int16_t)){
+ LOGV("\tLVM_ERROR : Volume_getParameter() invalid pValueSize 1 %d", *pValueSize);
+ return -EINVAL;
+ }
+ *pValueSize = sizeof(int16_t);
+ break;
+
+ case VOLUME_PARAM_MUTE:
+ case VOLUME_PARAM_ENABLESTEREOPOSITION:
+ if (*pValueSize < sizeof(int32_t)){
+ LOGV("\tLVM_ERROR : Volume_getParameter() invalid pValueSize 2 %d", *pValueSize);
+ return -EINVAL;
+ }
+ *pValueSize = sizeof(int32_t);
+ break;
+
+ default:
+ LOGV("\tLVM_ERROR : EVolume_getParameter unknown param %d", param);
+ return -EINVAL;
+ }
+
+ switch (param){
+ case VOLUME_PARAM_LEVEL:
+ status = VolumeGetVolumeLevel(pContext, (int16_t *)(pValue));
+ LOGV("\tVolume_getParameter() VOLUME_PARAM_LEVEL Value is %d",
+ *(int16_t *)pValue);
+ break;
+
+ case VOLUME_PARAM_MAXLEVEL:
+ *(int16_t *)pValue = 0;
+ LOGV("\tVolume_getParameter() VOLUME_PARAM_MAXLEVEL Value is %d",
+ *(int16_t *)pValue);
+ break;
+
+ case VOLUME_PARAM_STEREOPOSITION:
+ *(int16_t *)pValue = 0;
+ LOGV("\tVolume_getParameter() VOLUME_PARAM_STEREOPOSITION Value is %d",
+ *(int16_t *)pValue);
+ break;
+
+ case VOLUME_PARAM_MUTE:
+ status = VolumeGetMute(pContext, (uint32_t *)pValue);
+ LOGV("\tVolume_getParameter() VOLUME_PARAM_MUTE Value is %d",
+ *(uint32_t *)pValue);
+ break;
+
+ case VOLUME_PARAM_ENABLESTEREOPOSITION:
+ *(int32_t *)pValue = 0;
+ LOGV("\tVolume_getParameter() VOLUME_PARAM_ENABLESTEREOPOSITION Value is %d",
+ *(uint32_t *)pValue);
+ break;
+
+ default:
+ LOGV("\tLVM_ERROR : Volume_getParameter() invalid param %d", param);
+ status = -EINVAL;
+ break;
+ }
+
+ LOGV("\tVolume_getParameter end");
+ return status;
+} /* end Volume_getParameter */
+
+
+//----------------------------------------------------------------------------
+// Volume_setParameter()
+//----------------------------------------------------------------------------
+// Purpose:
+// Set a Volume parameter
+//
+// Inputs:
+// pVolume - handle to instance data
+// pParam - pointer to parameter
+// pValue - pointer to value
+//
+// Outputs:
+//
+//----------------------------------------------------------------------------
+
+int Volume_setParameter (EffectContext *pContext, int32_t *pParam, void *pValue){
+ int status = 0;
+ int16_t level;
+ uint32_t mute;
+
+ LOGV("\tVolume_setParameter start");
+
+ switch (*pParam){
+ case VOLUME_PARAM_LEVEL:
+ level = *(int16_t *)pValue;
+ LOGV("\tVolume_setParameter() VOLUME_PARAM_LEVEL value is %d", level);
+ LOGV("\tVolume_setParameter() Calling pVolume->setVolumeLevel");
+ status = VolumeSetVolumeLevel(pContext, (int16_t)level);
+ LOGV("\tVolume_setParameter() Called pVolume->setVolumeLevel");
+ break;
+
+ case VOLUME_PARAM_MUTE:
+ mute = *(uint32_t *)pValue;
+ LOGV("\tVolume_setParameter() Calling pVolume->setMute, mute is %d", mute);
+ LOGV("\tVolume_setParameter() Calling pVolume->setMute");
+ status = VolumeSetMute(pContext, mute);
+ LOGV("\tVolume_setParameter() Called pVolume->setMute");
+ break;
+
+ case VOLUME_PARAM_ENABLESTEREOPOSITION:
+ LOGV("\tVolume_setParameter() VOLUME_PARAM_ENABLESTEREOPOSITION called");
+ break;
+
+ case VOLUME_PARAM_STEREOPOSITION:
+ LOGV("\tVolume_setParameter() VOLUME_PARAM_STEREOPOSITION called");
+ break;
+
+ default:
+ LOGV("\tLVM_ERROR : Volume_setParameter() invalid param %d", *pParam);
+ break;
+ }
+
+ LOGV("\tVolume_setParameter end");
+ return status;
+} /* end Volume_setParameter */
+} // namespace
+} // namespace
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/* Effect Control Interface Implementation: Process */
+extern "C" int Effect_process(effect_interface_t self,
+ audio_buffer_t *inBuffer,
+ audio_buffer_t *outBuffer){
+ EffectContext * pContext = (EffectContext *) self;
+ int status = 0;
+
+ //LOGV("\tIn Effect_process");
+
+ if (pContext == NULL){
+ LOGV("\tLVM_ERROR : Effect_process() ERROR pContext == NULL");
+ return -EINVAL;
+ }
+ if (inBuffer == NULL || inBuffer->raw == NULL ||
+ outBuffer == NULL || outBuffer->raw == NULL ||
+ inBuffer->frameCount != outBuffer->frameCount){
+ LOGV("\tLVM_ERROR : Effect_process() ERROR NULL INPUT POINTER OR FRAME COUNT IS WRONG");
+ return -EINVAL;
+ }
+
+ if ((pContext->pBundledContext->bBassEnabled == LVM_FALSE)&&(pContext->EffectType == LVM_BASS_BOOST)){
+ LOGV("\tLVM_ERROR : Effect_process() ERROR LVM_BASS_BOOST Effect is not enabled");
+ return -ENODATA;
+ }
+ if ((pContext->pBundledContext->bVolumeEnabled == LVM_FALSE)&&(pContext->EffectType == LVM_VOLUME)){
+ LOGV("\tLVM_ERROR : Effect_process() ERROR LVM_VOLUME Effect is not enabled");
+ return -ENODATA;
+ }
+ if ((pContext->pBundledContext->bEqualizerEnabled == LVM_FALSE)&&(pContext->EffectType == LVM_EQUALIZER)){
+ LOGV("\tLVM_ERROR : Effect_process() ERROR LVM_EQUALIZER Effect is not enabled");
+ return -ENODATA;
+ }
+ if ((pContext->pBundledContext->bVirtualizerEnabled == LVM_FALSE)&&(pContext->EffectType == LVM_VIRTUALIZER)){
+ LOGV("\tLVM_ERROR : Effect_process() ERROR LVM_VIRTUALIZER Effect is not enabled");
+ return -ENODATA;
+ }
+
+ pContext->pBundledContext->NumberEffectsCalled++;
+
+ if(pContext->pBundledContext->NumberEffectsCalled == pContext->pBundledContext->NumberEffectsEnabled){
+ LOGV("\tEffect_process() Calling process with %d frames, %d effects enabled, %d called: Effect %d", outBuffer->frameCount, pContext->pBundledContext->NumberEffectsEnabled, pContext->pBundledContext->NumberEffectsCalled, pContext->EffectType);
+ pContext->pBundledContext->NumberEffectsCalled = 0;
+ /* Process all the available frames, block processing is handled internalLY by the LVM bundle */
+ status = android::LvmBundle_process( (LVM_INT16 *)inBuffer->raw,
+ (LVM_INT16 *)outBuffer->raw,
+ outBuffer->frameCount,
+ pContext);
+ //LOGV("\tEffect_process() Called process with %d frames, %d effects enabled, %d called: Effect %d", outBuffer->frameCount, pContext->pBundledContext->NumberEffectsEnabled, pContext->pBundledContext->NumberEffectsCalled, pContext->EffectType);
+ }else{
+ LOGV("\tEffect_process() Not Calling process with %d frames, %d effects enabled, %d called: Effect %d", outBuffer->frameCount, pContext->pBundledContext->NumberEffectsEnabled, pContext->pBundledContext->NumberEffectsCalled, pContext->EffectType);
+ memcpy(outBuffer->raw, inBuffer->raw, outBuffer->frameCount*sizeof(LVM_INT16)*2); // 2 is for stereo input
+ }
+ return status;
+} /* end Effect_process */
+
+/* Effect Control Interface Implementation: Command */
+extern "C" int Effect_command(effect_interface_t self,
+ int cmdCode,
+ int cmdSize,
+ void *pCmdData,
+ int *replySize,
+ void *pReplyData){
+ EffectContext * pContext = (EffectContext *) self;
+ int retsize;
+ int status = 0;
+
+ LOGV("\t\nEffect_command start");
+
+ if(pContext->EffectType == LVM_BASS_BOOST){
+ LOGV("\tEffect_command setting command for LVM_BASS_BOOST");
+ }
+ if(pContext->EffectType == LVM_VIRTUALIZER){
+ LOGV("\tEffect_command setting command for LVM_VIRTUALIZER");
+ }
+ if(pContext->EffectType == LVM_EQUALIZER){
+ LOGV("\tEffect_command setting command for LVM_EQUALIZER");
+ }
+ if(pContext->EffectType == LVM_VOLUME){
+ LOGV("\tEffect_command setting command for LVM_VOLUME");
+ }
+
+ if (pContext == NULL){
+ LOGV("\tLVM_ERROR : Effect_command ERROR pContext == NULL");
+ return -EINVAL;
+ }
+
+ LOGV("\tEffect_command INPUTS are: command %d cmdSize %d",cmdCode, cmdSize);
+
+ // Incase we disable an effect, next time process is called the number of effect called could be greater
+ pContext->pBundledContext->NumberEffectsCalled = 0;
+
+ LOGV("\tEffect_command NumberEffectsCalled = %d, NumberEffectsEnabled = %d", pContext->pBundledContext->NumberEffectsCalled, pContext->pBundledContext->NumberEffectsEnabled);
+
+ switch (cmdCode){
+ case EFFECT_CMD_INIT:
+ LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_INIT start");
+ if(pContext->EffectType == LVM_BASS_BOOST){
+ LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_INIT for LVM_BASS_BOOST");
+
+ if (pReplyData == NULL || *replySize != sizeof(int)){
+ LOGV("\tLVM_ERROR : BassBoost_command cmdCode Case: "
+ "EFFECT_CMD_INIT: ERROR");
+ return -EINVAL;
+ }
+
+ android::BassSetStrength(pContext, 0);
+ }
+ if(pContext->EffectType == LVM_VIRTUALIZER){
+ LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_INIT for LVM_VIRTUALIZER");
+
+ if (pReplyData == NULL || *replySize != sizeof(int)){
+ LOGV("\tLVM_ERROR : Virtualizer_command cmdCode Case: "
+ "EFFECT_CMD_INIT: ERROR");
+ return -EINVAL;
+ }
+
+ android::VirtualizerSetStrength(pContext, 0);
+ }
+ if(pContext->EffectType == LVM_EQUALIZER){
+ LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_INIT for LVM_EQUALIZER");
+
+ if (pReplyData == NULL || *replySize != sizeof(int)){
+ LOGV("\tLVM_ERROR : Equalizer_command cmdCode Case: "
+ "EFFECT_CMD_INIT: ERROR");
+ return -EINVAL;
+ }
+
+ android::EqualizerSetPreset(pContext, 0);
+ }
+ if(pContext->EffectType == LVM_VOLUME){
+ LOGV("\tEffect_command cmdCode Case: "
+ "EFFECT_CMD_INIT start");
+
+ if (pReplyData == NULL || *replySize != sizeof(int)){
+ LOGV("\tLVM_ERROR : Volume_command cmdCode Case: "
+ "EFFECT_CMD_INIT: ERROR");
+ return -EINVAL;
+ }
+
+ status = android::VolumeSetVolumeLevel(pContext, 0);
+ if(status == -EINVAL){
+ return -EINVAL;
+ }
+ }
+ break;
+
+ case EFFECT_CMD_CONFIGURE:
+ LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_CONFIGURE start");
+ if (pCmdData == NULL||
+ cmdSize != sizeof(effect_config_t)||
+ pReplyData == NULL||
+ *replySize != sizeof(int)){
+ LOGV("\tLVM_ERROR : Effect_command cmdCode Case: "
+ "EFFECT_CMD_CONFIGURE: ERROR");
+ return -EINVAL;
+ }
+ *(int *) pReplyData = android::Effect_configure(pContext, (effect_config_t *) pCmdData);
+ LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_CONFIGURE end");
+ break;
+
+ case EFFECT_CMD_RESET:
+ LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_RESET start");
+ android::Effect_configure(pContext, &pContext->config);
+ LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_RESET end");
+ break;
+
+ case EFFECT_CMD_GET_PARAM:{
+ LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_GET_PARAM start");
+
+ if(pContext->EffectType == LVM_BASS_BOOST){
+ if (pCmdData == NULL || cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) ||
+ pReplyData == NULL ||*replySize < (int) (sizeof(effect_param_t) + sizeof(int32_t))){
+ LOGV("\tLVM_ERROR : BassBoost_command cmdCode Case: "
+ "EFFECT_CMD_GET_PARAM: ERROR");
+ return -EINVAL;
+ }
+ effect_param_t *p = (effect_param_t *)pCmdData;
+
+ memcpy(pReplyData, pCmdData, sizeof(effect_param_t) + p->psize);
+
+ p = (effect_param_t *)pReplyData;
+
+ int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t);
+
+ p->status = android::BassBoost_getParameter(pContext,
+ (int32_t *)p->data,
+ (size_t *)&p->vsize,
+ p->data + voffset);
+
+ *replySize = sizeof(effect_param_t) + voffset + p->vsize;
+
+ LOGV("\tBassBoost_command EFFECT_CMD_GET_PARAM "
+ "*pCmdData %d, *replySize %d, *pReplyData %d ",
+ *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)),
+ *replySize,
+ *(int16_t *)((char *)pReplyData + sizeof(effect_param_t) + voffset));
+ }
+
+ if(pContext->EffectType == LVM_VIRTUALIZER){
+ if (pCmdData == NULL || cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) ||
+ pReplyData == NULL ||*replySize < (int) (sizeof(effect_param_t) + sizeof(int32_t))){
+ LOGV("\tLVM_ERROR : Virtualizer_command cmdCode Case: "
+ "EFFECT_CMD_GET_PARAM: ERROR");
+ return -EINVAL;
+ }
+ effect_param_t *p = (effect_param_t *)pCmdData;
+
+ memcpy(pReplyData, pCmdData, sizeof(effect_param_t) + p->psize);
+
+ p = (effect_param_t *)pReplyData;
+
+ int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t);
+
+ p->status = android::Virtualizer_getParameter(pContext,
+ (int32_t *)p->data,
+ (size_t *)&p->vsize,
+ p->data + voffset);
+
+ *replySize = sizeof(effect_param_t) + voffset + p->vsize;
+
+ LOGV("\tVirtualizer_command EFFECT_CMD_GET_PARAM "
+ "*pCmdData %d, *replySize %d, *pReplyData %d ",
+ *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)),
+ *replySize,
+ *(int16_t *)((char *)pReplyData + sizeof(effect_param_t) + voffset));
+ }
+ if(pContext->EffectType == LVM_EQUALIZER){
+ LOGV("\tEqualizer_command cmdCode Case: "
+ "EFFECT_CMD_GET_PARAM start");
+ if (pCmdData == NULL || cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) ||
+ pReplyData == NULL || *replySize < (int) (sizeof(effect_param_t) + sizeof(int32_t))) {
+ LOGV("\tLVM_ERROR : Equalizer_command cmdCode Case: "
+ "EFFECT_CMD_GET_PARAM");
+ return -EINVAL;
+ }
+ effect_param_t *p = (effect_param_t *)pCmdData;
+
+ memcpy(pReplyData, pCmdData, sizeof(effect_param_t) + p->psize);
+
+ p = (effect_param_t *)pReplyData;
+
+ int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t);
+
+ p->status = android::Equalizer_getParameter(pContext, (int32_t *)p->data, &p->vsize,
+ p->data + voffset);
+
+ *replySize = sizeof(effect_param_t) + voffset + p->vsize;
+
+ LOGV("\tEqualizer_command EFFECT_CMD_GET_PARAM *pCmdData %d, *replySize %d, *pReplyData %08x %08x",
+ *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), *replySize,
+ *(int32_t *)((char *)pReplyData + sizeof(effect_param_t) + voffset),
+ *(int32_t *)((char *)pReplyData + sizeof(effect_param_t) + voffset + sizeof(int32_t)));
+ }
+ if(pContext->EffectType == LVM_VOLUME){
+ LOGV("\tVolume_command cmdCode Case: "
+ "EFFECT_CMD_GET_PARAM start");
+ if (pCmdData == NULL || cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) ||
+ pReplyData == NULL ||*replySize < (int) (sizeof(effect_param_t) + sizeof(int32_t))){
+ LOGV("\tLVM_ERROR : Volume_command cmdCode Case: "
+ "EFFECT_CMD_GET_PARAM: ERROR");
+ return -EINVAL;
+ }
+ effect_param_t *p = (effect_param_t *)pCmdData;
+
+ memcpy(pReplyData, pCmdData, sizeof(effect_param_t) + p->psize);
+
+ p = (effect_param_t *)pReplyData;
+
+ int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t);
+
+ p->status = android::Volume_getParameter(pContext,
+ (int32_t *)p->data,
+ (size_t *)&p->vsize,
+ p->data + voffset);
+
+ *replySize = sizeof(effect_param_t) + voffset + p->vsize;
+
+ LOGV("\tVolume_command EFFECT_CMD_GET_PARAM "
+ "*pCmdData %d, *replySize %d, *pReplyData %d ",
+ *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)),
+ *replySize,
+ *(int16_t *)((char *)pReplyData + sizeof(effect_param_t) + voffset));
+ }
+ LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_GET_PARAM end");
+ } break;
+ case EFFECT_CMD_SET_PARAM:{
+ LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_PARAM start");
+ if(pContext->EffectType == LVM_BASS_BOOST){
+ LOGV("\tBassBoost_command EFFECT_CMD_SET_PARAM param %d, *replySize %d, value %d ",
+ *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)),
+ *replySize,
+ *(int16_t *)((char *)pCmdData + sizeof(effect_param_t) + sizeof(int32_t)));
+
+ if ( pCmdData == NULL||
+ cmdSize != (int)(sizeof(effect_param_t) + sizeof(int32_t) + sizeof(int16_t))||
+ pReplyData == NULL||
+ *replySize != sizeof(int32_t)){
+ LOGV("\tLVM_ERROR : BassBoost_command cmdCode Case: "
+ "EFFECT_CMD_SET_PARAM: ERROR");
+ return -EINVAL;
+ }
+ effect_param_t *p = (effect_param_t *) pCmdData;
+
+ if (p->psize != sizeof(int32_t)){
+ LOGV("\tLVM_ERROR : BassBoost_command cmdCode Case: "
+ "EFFECT_CMD_SET_PARAM: ERROR, psize is not sizeof(int32_t)");
+ return -EINVAL;
+ }
+
+ LOGV("\tnBassBoost_command cmdSize is %d\n"
+ "\tsizeof(effect_param_t) is %d\n"
+ "\tp->psize is %d\n"
+ "\tp->vsize is %d"
+ "\n",
+ cmdSize, sizeof(effect_param_t), p->psize, p->vsize );
+
+ *(int *)pReplyData = android::BassBoost_setParameter(pContext,
+ (int32_t *)p->data,
+ p->data + p->psize);
+ }
+ if(pContext->EffectType == LVM_VIRTUALIZER){
+ LOGV("\tVirtualizer_command EFFECT_CMD_SET_PARAM param %d, *replySize %d, value %d ",
+ *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)),
+ *replySize,
+ *(int16_t *)((char *)pCmdData + sizeof(effect_param_t) + sizeof(int32_t)));
+
+ if ( pCmdData == NULL||
+ cmdSize != (int)(sizeof(effect_param_t) + sizeof(int32_t) + sizeof(int16_t))||
+ pReplyData == NULL||
+ *replySize != sizeof(int32_t)){
+ LOGV("\tLVM_ERROR : Virtualizer_command cmdCode Case: "
+ "EFFECT_CMD_SET_PARAM: ERROR");
+ return -EINVAL;
+ }
+ effect_param_t *p = (effect_param_t *) pCmdData;
+
+ if (p->psize != sizeof(int32_t)){
+ LOGV("\tLVM_ERROR : Virtualizer_command cmdCode Case: "
+ "EFFECT_CMD_SET_PARAM: ERROR, psize is not sizeof(int32_t)");
+ return -EINVAL;
+ }
+
+ LOGV("\tnVirtualizer_command cmdSize is %d\n"
+ "\tsizeof(effect_param_t) is %d\n"
+ "\tp->psize is %d\n"
+ "\tp->vsize is %d"
+ "\n",
+ cmdSize, sizeof(effect_param_t), p->psize, p->vsize );
+
+ *(int *)pReplyData = android::Virtualizer_setParameter(pContext,
+ (int32_t *)p->data,
+ p->data + p->psize);
+ }
+ if(pContext->EffectType == LVM_EQUALIZER){
+ LOGV("\tEqualizer_command cmdCode Case: "
+ "EFFECT_CMD_SET_PARAM start");
+ LOGV("\tEqualizer_command EFFECT_CMD_SET_PARAM param %d, *replySize %d, value %d ",
+ *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)),
+ *replySize,
+ *(int16_t *)((char *)pCmdData + sizeof(effect_param_t) + sizeof(int32_t)));
+
+ if (pCmdData == NULL || cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) ||
+ pReplyData == NULL || *replySize != sizeof(int32_t)) {
+ LOGV("\tLVM_ERROR : Equalizer_command cmdCode Case: "
+ "EFFECT_CMD_SET_PARAM: ERROR");
+ return -EINVAL;
+ }
+ effect_param_t *p = (effect_param_t *) pCmdData;
+
+ *(int *)pReplyData = android::Equalizer_setParameter(pContext,
+ (int32_t *)p->data,
+ p->data + p->psize);
+ }
+ if(pContext->EffectType == LVM_VOLUME){
+ LOGV("\tVolume_command cmdCode Case: "
+ "EFFECT_CMD_SET_PARAM start");
+ LOGV("\tVolume_command EFFECT_CMD_SET_PARAM param %d, *replySize %d, value %d ",
+ *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)),
+ *replySize,
+ *(int16_t *)((char *)pCmdData + sizeof(effect_param_t) + sizeof(int32_t)));
+
+ if ( pCmdData == NULL||
+ cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t))||
+ pReplyData == NULL||
+ *replySize != sizeof(int32_t)){
+ LOGV("\tLVM_ERROR : Volume_command cmdCode Case: "
+ "EFFECT_CMD_SET_PARAM: ERROR");
+ return -EINVAL;
+ }
+ effect_param_t *p = (effect_param_t *) pCmdData;
+
+ *(int *)pReplyData = android::Volume_setParameter(pContext,
+ (int32_t *)p->data,
+ p->data + p->psize);
+ }
+ LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_PARAM end");
+ } break;
+
+ case EFFECT_CMD_ENABLE:
+ LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_ENABLE start");
+ if (pReplyData == NULL || *replySize != sizeof(int)){
+ LOGV("\tLVM_ERROR : Effect_command cmdCode Case: EFFECT_CMD_ENABLE: ERROR");
+ return -EINVAL;
+ }
+ switch (pContext->EffectType){
+ case LVM_BASS_BOOST:
+ if(pContext->pBundledContext->bBassEnabled == LVM_TRUE){
+ LOGV("\tLVM_ERROR : BassBoost_command cmdCode Case: "
+ "EFFECT_CMD_ENABLE: ERROR-Effect is already enabled");
+ return -EINVAL;
+ }
+ pContext->pBundledContext->bBassEnabled = LVM_TRUE;
+ LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_ENABLE LVM_BASS_BOOST enabled");
+ break;
+ case LVM_EQUALIZER:
+ if(pContext->pBundledContext->bEqualizerEnabled == LVM_TRUE){
+ LOGV("\tLVM_ERROR : Equalizer_command cmdCode Case: "
+ "EFFECT_CMD_ENABLE: ERROR-Effect is already enabled");
+ return -EINVAL;
+ }
+ pContext->pBundledContext->bEqualizerEnabled = LVM_TRUE;
+ LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_ENABLE LVM_EQUALIZER enabled");
+ break;
+ case LVM_VIRTUALIZER:
+ if(pContext->pBundledContext->bVirtualizerEnabled == LVM_TRUE){
+ LOGV("\tLVM_ERROR : Virtualizer_command cmdCode Case: "
+ "EFFECT_CMD_ENABLE: ERROR-Effect is already enabled");
+ return -EINVAL;
+ }
+ pContext->pBundledContext->bVirtualizerEnabled = LVM_TRUE;
+ LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_ENABLE LVM_VIRTUALIZER enabled");
+ break;
+ case LVM_VOLUME:
+ if(pContext->pBundledContext->bVolumeEnabled == LVM_TRUE){
+ LOGV("\tLVM_ERROR : Volume_command cmdCode Case: "
+ "EFFECT_CMD_ENABLE: ERROR-Effect is already enabled");
+ return -EINVAL;
+ }
+ pContext->pBundledContext->bVolumeEnabled = LVM_TRUE;
+ LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_ENABLE LVM_VOLUME enabled");
+ break;
+ default:
+ LOGV("\tLVM_ERROR : Effect_command cmdCode Case: "
+ "EFFECT_CMD_ENABLE: ERROR, invalid Effect Type");
+ return -EINVAL;
+ }
+ *(int *)pReplyData = 0;
+ pContext->pBundledContext->NumberEffectsEnabled++;
+ android::LvmEffect_enable(pContext);
+ LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_ENABLE NumberEffectsEnabled = %d", pContext->pBundledContext->NumberEffectsEnabled);
+ LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_ENABLE end");
+ break;
+
+ case EFFECT_CMD_DISABLE:
+ LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_DISABLE start");
+ if (pReplyData == NULL || *replySize != sizeof(int)){
+ LOGV("\tLVM_ERROR : Effect_command cmdCode Case: EFFECT_CMD_DISABLE: ERROR");
+ return -EINVAL;
+ }
+ switch (pContext->EffectType){
+ case LVM_BASS_BOOST:
+ if(pContext->pBundledContext->bBassEnabled == LVM_FALSE){
+ LOGV("\tLVM_ERROR : BassBoost_command cmdCode Case: "
+ "EFFECT_CMD_DISABLE: ERROR-Effect is not yet enabled");
+ return -EINVAL;
+ }
+ pContext->pBundledContext->bBassEnabled = LVM_FALSE;
+ LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_DISABLE LVM_BASS_BOOST disabled");
+ break;
+ case LVM_EQUALIZER:
+ if(pContext->pBundledContext->bEqualizerEnabled == LVM_FALSE){
+ LOGV("\tLVM_ERROR : Equalizer_command cmdCode Case: "
+ "EFFECT_CMD_DISABLE: ERROR-Effect is not yet enabled");
+ return -EINVAL;
+ }
+ pContext->pBundledContext->bEqualizerEnabled = LVM_FALSE;
+ LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_DISABLE LVM_EQUALIZER disabled");
+ break;
+ case LVM_VIRTUALIZER:
+ if(pContext->pBundledContext->bVirtualizerEnabled == LVM_FALSE){
+ LOGV("\tLVM_ERROR : Virtualizer_command cmdCode Case: "
+ "EFFECT_CMD_DISABLE: ERROR-Effect is not yet enabled");
+ return -EINVAL;
+ }
+ pContext->pBundledContext->bVirtualizerEnabled = LVM_FALSE;
+ LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_DISABLE LVM_VIRTUALIZER disabled");
+ break;
+ case LVM_VOLUME:
+ if(pContext->pBundledContext->bVolumeEnabled == LVM_FALSE){
+ LOGV("\tLVM_ERROR : Volume_command cmdCode Case: "
+ "EFFECT_CMD_DISABLE: ERROR-Effect is not yet enabled");
+ return -EINVAL;
+ }
+ pContext->pBundledContext->bVolumeEnabled = LVM_FALSE;
+ LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_DISABLE LVM_VOLUME disabled");
+ break;
+ break;
+ default:
+ LOGV("\tLVM_ERROR : Effect_command cmdCode Case: "
+ "EFFECT_CMD_DISABLE: ERROR, invalid Effect Type");
+ return -EINVAL;
+ }
+ *(int *)pReplyData = 0;
+ pContext->pBundledContext->NumberEffectsEnabled--;
+ android::LvmEffect_disable(pContext);
+ LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_DISABLE NumberEffectsEnabled = %d", pContext->pBundledContext->NumberEffectsEnabled);
+ LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_DISABLE end");
+ break;
+
+ case EFFECT_CMD_SET_DEVICE:
+ case EFFECT_CMD_SET_VOLUME:
+// case EFFECT_CMD_SET_AUDIO_MODE:// AGO add this
+ LOGV("\tEffect_command cmdCode Case: "
+ "EFFECT_CMD_SET_DEVICE/EFFECT_CMD_SET_VOLUME/EFFECT_CMD_SET_AUDIO_MODE start");
+ break;
+
+ default:
+ LOGV("\tLVM_ERROR : Effect_command cmdCode Case: DEFAULT start %d ERROR",cmdCode);
+ return -EINVAL;
+ }
+
+ LOGV("\tEffect_command end...\n\n");
+ return 0;
+} /* end Effect_command */
+
+// effect_interface_t interface implementation for effect
+const struct effect_interface_s gLvmEffectInterface = {
+ Effect_process,
+ Effect_command
+}; /* end gLvmEffectInterface */
+
+
diff --git a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.h b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.h
new file mode 100644
index 0000000..6818dd6
--- /dev/null
+++ b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.h
@@ -0,0 +1,193 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef ANDROID_EFFECTBUNDLE_H_
+#define ANDROID_EFFECTBUNDLE_H_
+
+#include <media/EffectApi.h>
+#include <LVM.h>
+
+#if __cplusplus
+extern "C" {
+#endif
+
+#define FIVEBAND_NUMBANDS 5
+#define MAX_NUM_BANDS 5
+#define MAX_CALL_SIZE 256
+
+//TODO: this should be included from each effect API include
+static const effect_uuid_t SL_IID_BASSBOOST_ = { 0x0634f220, 0xddd4, 0x11db, 0xa0fc, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } };
+const effect_uuid_t * const SL_IID_BASSBOOST = &SL_IID_BASSBOOST_;
+
+static const effect_uuid_t SL_IID_EQUALIZER_ = { 0x0bed4300, 0xddd6, 0x11db, 0x8f34, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } };
+const effect_uuid_t * const SL_IID_EQUALIZER = &SL_IID_EQUALIZER_;
+
+static const effect_uuid_t SL_IID_VIRTUALIZER_ = { 0x37cc2c00, 0xdddd, 0x11db, 0x8577, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } }; // updated mon 28th june 2010
+const effect_uuid_t * const SL_IID_VIRTUALIZER = &SL_IID_VIRTUALIZER_;
+
+static const effect_uuid_t SL_IID_VOLUME_ = { 0x09e8ede0, 0xddde, 0x11db, 0xb4f6, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } }; // updated mon 28th june 2010
+const effect_uuid_t * const SL_IID_VOLUME = &SL_IID_VOLUME_;
+
+typedef enum
+{
+ LVM_BASS_BOOST,
+ LVM_VIRTUALIZER,
+ LVM_EQUALIZER,
+ LVM_VOLUME
+} lvm_effect_en;
+
+// Preset configuration.
+struct PresetConfig {
+ // Human-readable name.
+ const char * name;
+ // An array of size nBands where each element is a configuration for the
+ // corresponding band.
+ //const BandConfig * bandConfigs;
+};
+
+/* BundledEffectContext : One per session */
+struct BundledEffectContext{
+ LVM_Handle_t hInstance; /* Instance handle */
+ int SessionNo; /* Current session number */
+ bool bVolumeEnabled; /* Flag for Volume */
+ bool bEqualizerEnabled; /* Flag for EQ */
+ bool bBassEnabled; /* Flag for Bass */
+ bool bVirtualizerEnabled; /* Flag for Virtualizer */
+ int NumberEffectsEnabled; /* Effects in this session */
+ int NumberEffectsCalled; /* Effects called so far */
+ // Saved parameters for each effect */
+ // Bass Boost
+ int BassStrengthSaved; /* Conversion between Get/Set */
+ // Equalizer
+ int CurPreset; /* Current preset being used */
+ // Virtualzer
+ int VirtStrengthSaved; /* Conversion between Get/Set */
+ // Volume
+ int levelSaved; /* for when mute is set, level must be saved */
+ bool bMuteEnabled; /* Must store as mute = -96dB level */
+};
+
+/* SessionContext : One session */
+struct SessionContext{
+ bool bBundledEffectsEnabled;
+ bool bVolumeInstantiated;
+ bool bEqualizerInstantiated;
+ bool bBassInstantiated;
+ bool bVirtualizerInstantiated;
+ BundledEffectContext *pBundledContext;
+};
+
+struct EffectContext{
+ const struct effect_interface_s *itfe;
+ effect_config_t config;
+ lvm_effect_en EffectType;
+ BundledEffectContext *pBundledContext;
+};
+
+//TODO: this should be included from each effect API include
+/* enumerated parameter settings for BassBoost effect */
+typedef enum
+{
+ BASSBOOST_PARAM_STRENGTH_SUP, // type SLboolean = typedef SLuint32
+ BASSBOOST_PARAM_STRENGTH // type SLpermille = typedef SLuint16
+} t_bassboost_params;
+
+/* enumerated parameter settings for Virtualizer effect */
+typedef enum
+{
+ VIRTUALIZER_PARAM_STRENGTH_SUP, // type SLboolean = typedef SLuint32
+ VIRTUALIZER_PARAM_STRENGTH // type SLpermille = typedef SLuint16
+} t_virtualizer_params;
+
+/* enumerated parameter settings for Equalizer effect */
+typedef enum
+{
+ EQ_PARAM_NUM_BANDS, // Gets the number of frequency bands that the equalizer supports.
+ EQ_PARAM_LEVEL_RANGE, // Returns the minimum and maximum band levels supported.
+ EQ_PARAM_BAND_LEVEL, // Gets/Sets the gain set for the given equalizer band.
+ EQ_PARAM_CENTER_FREQ, // Gets the center frequency of the given band.
+ EQ_PARAM_BAND_FREQ_RANGE, // Gets the frequency range of the given frequency band.
+ EQ_PARAM_GET_BAND, // Gets the band that has the most effect on the given frequency.
+ EQ_PARAM_CUR_PRESET, // Gets/Sets the current preset.
+ EQ_PARAM_GET_NUM_OF_PRESETS, // Gets the total number of presets the equalizer supports.
+ EQ_PARAM_GET_PRESET_NAME // Gets the preset name based on the index.
+} t_equalizer_params;
+
+/* enumerated parameter settings for Volume effect */
+typedef enum
+{
+ VOLUME_PARAM_LEVEL, // type SLmillibel = typedef SLuint16 (set & get)
+ VOLUME_PARAM_MAXLEVEL, // type SLmillibel = typedef SLuint16 (get)
+ VOLUME_PARAM_MUTE, // type SLboolean = typedef SLuint32 (set & get)
+ VOLUME_PARAM_ENABLESTEREOPOSITION, // type SLboolean = typedef SLuint32 (set & get)
+ VOLUME_PARAM_STEREOPOSITION, // type SLpermille = typedef SLuint16 (set & get)
+} t_volume_params;
+
+static const int PRESET_CUSTOM = -1;
+
+static const uint32_t bandFreqRange[FIVEBAND_NUMBANDS][2] = {
+ {30000, 120000},
+ {12000, 460000},
+ {46000, 1800000},
+ {180000, 7000000},
+ {700000, 1}
+ };
+
+static const LVM_UINT16 EQNB_5BandPresetsFrequencies[] = {
+ 60, /* Frequencies in Hz */
+ 230,
+ 910,
+ 3600,
+ 14000};
+
+static const LVM_UINT16 EQNB_5BandPresetsQFactors[] = {
+ 96, /* Q factor multiplied by 100 */
+ 96,
+ 96,
+ 96,
+ 96};
+
+static const LVM_INT16 EQNB_5BandNormalPresets[] = {
+ 3, 0, 0, 0, 3, /* Normal Preset */
+ 8, 5, -3, 5, 6, /* Classical Preset */
+ 15, -6, 7, 13, 10, /* Dance Preset */
+ 0, 0, 0, 0, 0, /* Flat Preset */
+ 6, -2, -2, 6, -3, /* Folk Preset */
+ 8, -8, 13, -1, -4, /* Heavy Metal Preset */
+ 10, 6, -4, 5, 8, /* Hip Hop Preset */
+ 8, 5, -4, 5, 9, /* Jazz Preset */
+ -6, 4, 9, 4, -5, /* Pop Preset */
+ 10, 6, -1, 8, 10}; /* Rock Preset */
+
+static const PresetConfig gEqualizerPresets[] = {
+ {"Normal"},
+ {"Classical"},
+ {"Dance"},
+ {"Flat"},
+ {"Folk"},
+ {"Heavy Metal"},
+ {"Hip Hop"},
+ {"Jazz"},
+ {"Pop"},
+ {"Rock"}
+ };
+
+#if __cplusplus
+} // extern "C"
+#endif
+
+
+#endif /*ANDROID_EFFECTBUNDLE_H_*/
diff --git a/media/libeffects/testlibs/Android.mk_ b/media/libeffects/testlibs/Android.mk_
new file mode 100644
index 0000000..9ba71ed
--- /dev/null
+++ b/media/libeffects/testlibs/Android.mk_
@@ -0,0 +1,66 @@
+LOCAL_PATH:= $(call my-dir)
+
+# Test Reverb library
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= \
+ EffectReverb.c.arm \
+ EffectsMath.c.arm
+LOCAL_CFLAGS+= -O2
+
+LOCAL_SHARED_LIBRARIES := \
+ libcutils
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/soundfx
+LOCAL_MODULE:= libreverbtest
+
+ifeq ($(TARGET_OS)-$(TARGET_SIMULATOR),linux-true)
+LOCAL_LDLIBS += -ldl
+endif
+
+ifneq ($(TARGET_SIMULATOR),true)
+LOCAL_SHARED_LIBRARIES += libdl
+endif
+
+LOCAL_C_INCLUDES := \
+ $(call include-path-for, graphics corecg)
+
+LOCAL_PRELINK_MODULE := false
+
+include $(BUILD_SHARED_LIBRARY)
+
+# Test Equalizer library
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= \
+ EffectsMath.c.arm \
+ EffectEqualizer.cpp \
+ AudioBiquadFilter.cpp.arm \
+ AudioCoefInterpolator.cpp.arm \
+ AudioPeakingFilter.cpp.arm \
+ AudioShelvingFilter.cpp.arm \
+ AudioEqualizer.cpp.arm
+
+LOCAL_CFLAGS+= -O2
+
+LOCAL_SHARED_LIBRARIES := \
+ libcutils
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/soundfx
+LOCAL_MODULE:= libequalizertest
+
+ifeq ($(TARGET_OS)-$(TARGET_SIMULATOR),linux-true)
+LOCAL_LDLIBS += -ldl
+endif
+
+ifneq ($(TARGET_SIMULATOR),true)
+LOCAL_SHARED_LIBRARIES += libdl
+endif
+
+LOCAL_C_INCLUDES := \
+ $(call include-path-for, graphics corecg)
+
+LOCAL_PRELINK_MODULE := false
+
+include $(BUILD_SHARED_LIBRARY)
+
diff --git a/media/libeffects/AudioBiquadFilter.cpp b/media/libeffects/testlibs/AudioBiquadFilter.cpp
similarity index 100%
rename from media/libeffects/AudioBiquadFilter.cpp
rename to media/libeffects/testlibs/AudioBiquadFilter.cpp
diff --git a/media/libeffects/AudioBiquadFilter.h b/media/libeffects/testlibs/AudioBiquadFilter.h
similarity index 100%
rename from media/libeffects/AudioBiquadFilter.h
rename to media/libeffects/testlibs/AudioBiquadFilter.h
diff --git a/media/libeffects/AudioCoefInterpolator.cpp b/media/libeffects/testlibs/AudioCoefInterpolator.cpp
similarity index 100%
rename from media/libeffects/AudioCoefInterpolator.cpp
rename to media/libeffects/testlibs/AudioCoefInterpolator.cpp
diff --git a/media/libeffects/AudioCoefInterpolator.h b/media/libeffects/testlibs/AudioCoefInterpolator.h
similarity index 100%
rename from media/libeffects/AudioCoefInterpolator.h
rename to media/libeffects/testlibs/AudioCoefInterpolator.h
diff --git a/media/libeffects/AudioCommon.h b/media/libeffects/testlibs/AudioCommon.h
similarity index 100%
rename from media/libeffects/AudioCommon.h
rename to media/libeffects/testlibs/AudioCommon.h
diff --git a/media/libeffects/AudioEqualizer.cpp b/media/libeffects/testlibs/AudioEqualizer.cpp
similarity index 100%
rename from media/libeffects/AudioEqualizer.cpp
rename to media/libeffects/testlibs/AudioEqualizer.cpp
diff --git a/media/libeffects/AudioEqualizer.h b/media/libeffects/testlibs/AudioEqualizer.h
similarity index 100%
rename from media/libeffects/AudioEqualizer.h
rename to media/libeffects/testlibs/AudioEqualizer.h
diff --git a/media/libeffects/AudioFormatAdapter.h b/media/libeffects/testlibs/AudioFormatAdapter.h
similarity index 100%
rename from media/libeffects/AudioFormatAdapter.h
rename to media/libeffects/testlibs/AudioFormatAdapter.h
diff --git a/media/libeffects/AudioHighShelfFilterCoef.inl b/media/libeffects/testlibs/AudioHighShelfFilterCoef.inl
similarity index 100%
rename from media/libeffects/AudioHighShelfFilterCoef.inl
rename to media/libeffects/testlibs/AudioHighShelfFilterCoef.inl
diff --git a/media/libeffects/AudioLowShelfFilterCoef.inl b/media/libeffects/testlibs/AudioLowShelfFilterCoef.inl
similarity index 100%
rename from media/libeffects/AudioLowShelfFilterCoef.inl
rename to media/libeffects/testlibs/AudioLowShelfFilterCoef.inl
diff --git a/media/libeffects/AudioPeakingFilter.cpp b/media/libeffects/testlibs/AudioPeakingFilter.cpp
similarity index 100%
rename from media/libeffects/AudioPeakingFilter.cpp
rename to media/libeffects/testlibs/AudioPeakingFilter.cpp
diff --git a/media/libeffects/AudioPeakingFilter.h b/media/libeffects/testlibs/AudioPeakingFilter.h
similarity index 100%
rename from media/libeffects/AudioPeakingFilter.h
rename to media/libeffects/testlibs/AudioPeakingFilter.h
diff --git a/media/libeffects/AudioPeakingFilterCoef.inl b/media/libeffects/testlibs/AudioPeakingFilterCoef.inl
similarity index 100%
rename from media/libeffects/AudioPeakingFilterCoef.inl
rename to media/libeffects/testlibs/AudioPeakingFilterCoef.inl
diff --git a/media/libeffects/AudioShelvingFilter.cpp b/media/libeffects/testlibs/AudioShelvingFilter.cpp
similarity index 100%
rename from media/libeffects/AudioShelvingFilter.cpp
rename to media/libeffects/testlibs/AudioShelvingFilter.cpp
diff --git a/media/libeffects/AudioShelvingFilter.h b/media/libeffects/testlibs/AudioShelvingFilter.h
similarity index 100%
rename from media/libeffects/AudioShelvingFilter.h
rename to media/libeffects/testlibs/AudioShelvingFilter.h
diff --git a/media/libeffects/EffectEqualizer.cpp b/media/libeffects/testlibs/EffectEqualizer.cpp
similarity index 99%
rename from media/libeffects/EffectEqualizer.cpp
rename to media/libeffects/testlibs/EffectEqualizer.cpp
index af0c411..0eb2bdf 100644
--- a/media/libeffects/EffectEqualizer.cpp
+++ b/media/libeffects/testlibs/EffectEqualizer.cpp
@@ -16,7 +16,8 @@
#define LOG_TAG "Equalizer"
#define ARRAY_SIZE(array) (sizeof array / sizeof array[0])
-//#define LOG_NDEBUG 0
+//
+#define LOG_NDEBUG 0
#include <cutils/log.h>
#include <assert.h>
#include <stdlib.h>
diff --git a/media/libeffects/EffectReverb.c b/media/libeffects/testlibs/EffectReverb.c
similarity index 100%
rename from media/libeffects/EffectReverb.c
rename to media/libeffects/testlibs/EffectReverb.c
diff --git a/media/libeffects/EffectReverb.h b/media/libeffects/testlibs/EffectReverb.h
similarity index 100%
rename from media/libeffects/EffectReverb.h
rename to media/libeffects/testlibs/EffectReverb.h
diff --git a/media/libeffects/EffectsMath.c b/media/libeffects/testlibs/EffectsMath.c
similarity index 100%
rename from media/libeffects/EffectsMath.c
rename to media/libeffects/testlibs/EffectsMath.c
diff --git a/media/libeffects/EffectsMath.h b/media/libeffects/testlibs/EffectsMath.h
similarity index 100%
rename from media/libeffects/EffectsMath.h
rename to media/libeffects/testlibs/EffectsMath.h
diff --git a/media/libeffects/visualizer/Android.mk b/media/libeffects/visualizer/Android.mk
new file mode 100644
index 0000000..82cd925
--- /dev/null
+++ b/media/libeffects/visualizer/Android.mk
@@ -0,0 +1,30 @@
+LOCAL_PATH:= $(call my-dir)
+
+# Visualizer library
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= \
+ EffectVisualizer.cpp
+
+LOCAL_CFLAGS+= -O2
+
+LOCAL_SHARED_LIBRARIES := \
+ libcutils
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/soundfx
+LOCAL_MODULE:= libvisualizer
+
+ifeq ($(TARGET_OS)-$(TARGET_SIMULATOR),linux-true)
+LOCAL_LDLIBS += -ldlS
+endif
+
+ifneq ($(TARGET_SIMULATOR),true)
+LOCAL_SHARED_LIBRARIES += libdl
+endif
+
+LOCAL_C_INCLUDES := \
+ $(call include-path-for, graphics corecg)
+
+LOCAL_PRELINK_MODULE := false
+
+include $(BUILD_SHARED_LIBRARY)
\ No newline at end of file
diff --git a/media/libeffects/EffectVisualizer.cpp b/media/libeffects/visualizer/EffectVisualizer.cpp
similarity index 99%
rename from media/libeffects/EffectVisualizer.cpp
rename to media/libeffects/visualizer/EffectVisualizer.cpp
index bcda06e..ec13557 100644
--- a/media/libeffects/EffectVisualizer.cpp
+++ b/media/libeffects/visualizer/EffectVisualizer.cpp
@@ -230,9 +230,6 @@
if (pContext == NULL) {
return -EINVAL;
}
- if (pContext->mState != VISUALIZER_STATE_ACTIVE) {
- return -ENODATA;
- }
if (inBuffer == NULL || inBuffer->raw == NULL ||
outBuffer == NULL || outBuffer->raw == NULL ||
@@ -269,6 +266,9 @@
memcpy(outBuffer->raw, inBuffer->raw, outBuffer->frameCount * 2 * sizeof(int16_t));
}
}
+ if (pContext->mState != VISUALIZER_STATE_ACTIVE) {
+ return -ENODATA;
+ }
return 0;
} // end Visualizer_process
diff --git a/media/libmedia/AudioSystem.cpp b/media/libmedia/AudioSystem.cpp
index c77f551..7e3b743 100644
--- a/media/libmedia/AudioSystem.cpp
+++ b/media/libmedia/AudioSystem.cpp
@@ -590,18 +590,22 @@
return output;
}
-status_t AudioSystem::startOutput(audio_io_handle_t output, AudioSystem::stream_type stream)
+status_t AudioSystem::startOutput(audio_io_handle_t output,
+ AudioSystem::stream_type stream,
+ int session)
{
const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
if (aps == 0) return PERMISSION_DENIED;
- return aps->startOutput(output, stream);
+ return aps->startOutput(output, stream, session);
}
-status_t AudioSystem::stopOutput(audio_io_handle_t output, AudioSystem::stream_type stream)
+status_t AudioSystem::stopOutput(audio_io_handle_t output,
+ AudioSystem::stream_type stream,
+ int session)
{
const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
if (aps == 0) return PERMISSION_DENIED;
- return aps->stopOutput(output, stream);
+ return aps->stopOutput(output, stream, session);
}
void AudioSystem::releaseOutput(audio_io_handle_t output)
@@ -666,6 +670,38 @@
return aps->getStreamVolumeIndex(stream, index);
}
+uint32_t AudioSystem::getStrategyForStream(AudioSystem::stream_type stream)
+{
+ const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
+ if (aps == 0) return 0;
+ return aps->getStrategyForStream(stream);
+}
+
+audio_io_handle_t AudioSystem::getOutputForEffect(effect_descriptor_t *desc)
+{
+ const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
+ if (aps == 0) return PERMISSION_DENIED;
+ return aps->getOutputForEffect(desc);
+}
+
+status_t AudioSystem::registerEffect(effect_descriptor_t *desc,
+ audio_io_handle_t output,
+ uint32_t strategy,
+ int session,
+ int id)
+{
+ const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
+ if (aps == 0) return PERMISSION_DENIED;
+ return aps->registerEffect(desc, output, strategy, session, id);
+}
+
+status_t AudioSystem::unregisterEffect(int id)
+{
+ const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
+ if (aps == 0) return PERMISSION_DENIED;
+ return aps->unregisterEffect(id);
+}
+
// ---------------------------------------------------------------------------
void AudioSystem::AudioPolicyServiceClient::binderDied(const wp<IBinder>& who) {
diff --git a/media/libmedia/IAudioFlinger.cpp b/media/libmedia/IAudioFlinger.cpp
index 7d6a5d3..3a89e25 100644
--- a/media/libmedia/IAudioFlinger.cpp
+++ b/media/libmedia/IAudioFlinger.cpp
@@ -69,7 +69,8 @@
QUERY_NUM_EFFECTS,
QUERY_EFFECT,
GET_EFFECT_DESCRIPTOR,
- CREATE_EFFECT
+ CREATE_EFFECT,
+ MOVE_EFFECTS
};
class BpAudioFlinger : public BpInterface<IAudioFlinger>
@@ -676,6 +677,17 @@
return effect;
}
+
+ virtual status_t moveEffects(int session, int srcOutput, int dstOutput)
+ {
+ Parcel data, reply;
+ data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
+ data.writeInt32(session);
+ data.writeInt32(srcOutput);
+ data.writeInt32(dstOutput);
+ remote()->transact(MOVE_EFFECTS, data, &reply);
+ return reply.readInt32();
+ }
};
IMPLEMENT_META_INTERFACE(AudioFlinger, "android.media.IAudioFlinger");
@@ -1024,6 +1036,14 @@
reply->write(&desc, sizeof(effect_descriptor_t));
return NO_ERROR;
} break;
+ case MOVE_EFFECTS: {
+ CHECK_INTERFACE(IAudioFlinger, data, reply);
+ int session = data.readInt32();
+ int srcOutput = data.readInt32();
+ int dstOutput = data.readInt32();
+ reply->writeInt32(moveEffects(session, srcOutput, dstOutput));
+ return NO_ERROR;
+ } break;
default:
return BBinder::onTransact(code, data, reply, flags);
}
diff --git a/media/libmedia/IAudioPolicyService.cpp b/media/libmedia/IAudioPolicyService.cpp
index 18dd173..950c213 100644
--- a/media/libmedia/IAudioPolicyService.cpp
+++ b/media/libmedia/IAudioPolicyService.cpp
@@ -44,7 +44,11 @@
RELEASE_INPUT,
INIT_STREAM_VOLUME,
SET_STREAM_VOLUME,
- GET_STREAM_VOLUME
+ GET_STREAM_VOLUME,
+ GET_STRATEGY_FOR_STREAM,
+ GET_OUTPUT_FOR_EFFECT,
+ REGISTER_EFFECT,
+ UNREGISTER_EFFECT
};
class BpAudioPolicyService : public BpInterface<IAudioPolicyService>
@@ -137,22 +141,28 @@
return static_cast <audio_io_handle_t> (reply.readInt32());
}
- virtual status_t startOutput(audio_io_handle_t output, AudioSystem::stream_type stream)
+ virtual status_t startOutput(audio_io_handle_t output,
+ AudioSystem::stream_type stream,
+ int session)
{
Parcel data, reply;
data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
data.writeInt32(output);
data.writeInt32(stream);
+ data.writeInt32(session);
remote()->transact(START_OUTPUT, data, &reply);
return static_cast <status_t> (reply.readInt32());
}
- virtual status_t stopOutput(audio_io_handle_t output, AudioSystem::stream_type stream)
+ virtual status_t stopOutput(audio_io_handle_t output,
+ AudioSystem::stream_type stream,
+ int session)
{
Parcel data, reply;
data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
data.writeInt32(output);
data.writeInt32(stream);
+ data.writeInt32(session);
remote()->transact(STOP_OUTPUT, data, &reply);
return static_cast <status_t> (reply.readInt32());
}
@@ -242,6 +252,51 @@
if (index) *index = lIndex;
return static_cast <status_t> (reply.readInt32());
}
+
+ virtual uint32_t getStrategyForStream(AudioSystem::stream_type stream)
+ {
+ Parcel data, reply;
+ data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
+ data.writeInt32(static_cast <uint32_t>(stream));
+ remote()->transact(GET_STRATEGY_FOR_STREAM, data, &reply);
+ return reply.readInt32();
+ }
+
+ virtual audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc)
+ {
+ Parcel data, reply;
+ data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
+ data.write(desc, sizeof(effect_descriptor_t));
+ remote()->transact(GET_OUTPUT_FOR_EFFECT, data, &reply);
+ return static_cast <audio_io_handle_t> (reply.readInt32());
+ }
+
+ virtual status_t registerEffect(effect_descriptor_t *desc,
+ audio_io_handle_t output,
+ uint32_t strategy,
+ int session,
+ int id)
+ {
+ Parcel data, reply;
+ data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
+ data.write(desc, sizeof(effect_descriptor_t));
+ data.writeInt32(output);
+ data.writeInt32(strategy);
+ data.writeInt32(session);
+ data.writeInt32(id);
+ remote()->transact(REGISTER_EFFECT, data, &reply);
+ return static_cast <status_t> (reply.readInt32());
+ }
+
+ virtual status_t unregisterEffect(int id)
+ {
+ Parcel data, reply;
+ data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
+ data.writeInt32(id);
+ remote()->transact(UNREGISTER_EFFECT, data, &reply);
+ return static_cast <status_t> (reply.readInt32());
+ }
+
};
IMPLEMENT_META_INTERFACE(AudioPolicyService, "android.media.IAudioPolicyService");
@@ -255,18 +310,24 @@
switch(code) {
case SET_DEVICE_CONNECTION_STATE: {
CHECK_INTERFACE(IAudioPolicyService, data, reply);
- AudioSystem::audio_devices device = static_cast <AudioSystem::audio_devices>(data.readInt32());
- AudioSystem::device_connection_state state = static_cast <AudioSystem::device_connection_state>(data.readInt32());
+ AudioSystem::audio_devices device =
+ static_cast <AudioSystem::audio_devices>(data.readInt32());
+ AudioSystem::device_connection_state state =
+ static_cast <AudioSystem::device_connection_state>(data.readInt32());
const char *device_address = data.readCString();
- reply->writeInt32(static_cast <uint32_t>(setDeviceConnectionState(device, state, device_address)));
+ reply->writeInt32(static_cast<uint32_t> (setDeviceConnectionState(device,
+ state,
+ device_address)));
return NO_ERROR;
} break;
case GET_DEVICE_CONNECTION_STATE: {
CHECK_INTERFACE(IAudioPolicyService, data, reply);
- AudioSystem::audio_devices device = static_cast <AudioSystem::audio_devices>(data.readInt32());
+ AudioSystem::audio_devices device =
+ static_cast<AudioSystem::audio_devices> (data.readInt32());
const char *device_address = data.readCString();
- reply->writeInt32(static_cast <uint32_t>(getDeviceConnectionState(device, device_address)));
+ reply->writeInt32(static_cast<uint32_t> (getDeviceConnectionState(device,
+ device_address)));
return NO_ERROR;
} break;
@@ -287,7 +348,8 @@
case SET_FORCE_USE: {
CHECK_INTERFACE(IAudioPolicyService, data, reply);
AudioSystem::force_use usage = static_cast <AudioSystem::force_use>(data.readInt32());
- AudioSystem::forced_config config = static_cast <AudioSystem::forced_config>(data.readInt32());
+ AudioSystem::forced_config config =
+ static_cast <AudioSystem::forced_config>(data.readInt32());
reply->writeInt32(static_cast <uint32_t>(setForceUse(usage, config)));
return NO_ERROR;
} break;
@@ -301,11 +363,13 @@
case GET_OUTPUT: {
CHECK_INTERFACE(IAudioPolicyService, data, reply);
- AudioSystem::stream_type stream = static_cast <AudioSystem::stream_type>(data.readInt32());
+ AudioSystem::stream_type stream =
+ static_cast <AudioSystem::stream_type>(data.readInt32());
uint32_t samplingRate = data.readInt32();
uint32_t format = data.readInt32();
uint32_t channels = data.readInt32();
- AudioSystem::output_flags flags = static_cast <AudioSystem::output_flags>(data.readInt32());
+ AudioSystem::output_flags flags =
+ static_cast <AudioSystem::output_flags>(data.readInt32());
audio_io_handle_t output = getOutput(stream,
samplingRate,
@@ -320,7 +384,10 @@
CHECK_INTERFACE(IAudioPolicyService, data, reply);
audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32());
uint32_t stream = data.readInt32();
- reply->writeInt32(static_cast <uint32_t>(startOutput(output, (AudioSystem::stream_type)stream)));
+ int session = data.readInt32();
+ reply->writeInt32(static_cast <uint32_t>(startOutput(output,
+ (AudioSystem::stream_type)stream,
+ session)));
return NO_ERROR;
} break;
@@ -328,7 +395,10 @@
CHECK_INTERFACE(IAudioPolicyService, data, reply);
audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32());
uint32_t stream = data.readInt32();
- reply->writeInt32(static_cast <uint32_t>(stopOutput(output, (AudioSystem::stream_type)stream)));
+ int session = data.readInt32();
+ reply->writeInt32(static_cast <uint32_t>(stopOutput(output,
+ (AudioSystem::stream_type)stream,
+ session)));
return NO_ERROR;
} break;
@@ -345,7 +415,8 @@
uint32_t samplingRate = data.readInt32();
uint32_t format = data.readInt32();
uint32_t channels = data.readInt32();
- AudioSystem::audio_in_acoustics acoustics = static_cast <AudioSystem::audio_in_acoustics>(data.readInt32());
+ AudioSystem::audio_in_acoustics acoustics =
+ static_cast <AudioSystem::audio_in_acoustics>(data.readInt32());
audio_io_handle_t input = getInput(inputSource,
samplingRate,
format,
@@ -378,7 +449,8 @@
case INIT_STREAM_VOLUME: {
CHECK_INTERFACE(IAudioPolicyService, data, reply);
- AudioSystem::stream_type stream = static_cast <AudioSystem::stream_type>(data.readInt32());
+ AudioSystem::stream_type stream =
+ static_cast <AudioSystem::stream_type>(data.readInt32());
int indexMin = data.readInt32();
int indexMax = data.readInt32();
reply->writeInt32(static_cast <uint32_t>(initStreamVolume(stream, indexMin,indexMax)));
@@ -387,7 +459,8 @@
case SET_STREAM_VOLUME: {
CHECK_INTERFACE(IAudioPolicyService, data, reply);
- AudioSystem::stream_type stream = static_cast <AudioSystem::stream_type>(data.readInt32());
+ AudioSystem::stream_type stream =
+ static_cast <AudioSystem::stream_type>(data.readInt32());
int index = data.readInt32();
reply->writeInt32(static_cast <uint32_t>(setStreamVolumeIndex(stream, index)));
return NO_ERROR;
@@ -395,7 +468,8 @@
case GET_STREAM_VOLUME: {
CHECK_INTERFACE(IAudioPolicyService, data, reply);
- AudioSystem::stream_type stream = static_cast <AudioSystem::stream_type>(data.readInt32());
+ AudioSystem::stream_type stream =
+ static_cast <AudioSystem::stream_type>(data.readInt32());
int index;
status_t status = getStreamVolumeIndex(stream, &index);
reply->writeInt32(index);
@@ -403,6 +477,46 @@
return NO_ERROR;
} break;
+ case GET_STRATEGY_FOR_STREAM: {
+ CHECK_INTERFACE(IAudioPolicyService, data, reply);
+ AudioSystem::stream_type stream =
+ static_cast <AudioSystem::stream_type>(data.readInt32());
+ reply->writeInt32(getStrategyForStream(stream));
+ return NO_ERROR;
+ } break;
+
+ case GET_OUTPUT_FOR_EFFECT: {
+ CHECK_INTERFACE(IAudioPolicyService, data, reply);
+ effect_descriptor_t desc;
+ data.read(&desc, sizeof(effect_descriptor_t));
+ audio_io_handle_t output = getOutputForEffect(&desc);
+ reply->writeInt32(static_cast <int>(output));
+ return NO_ERROR;
+ } break;
+
+ case REGISTER_EFFECT: {
+ CHECK_INTERFACE(IAudioPolicyService, data, reply);
+ effect_descriptor_t desc;
+ data.read(&desc, sizeof(effect_descriptor_t));
+ audio_io_handle_t output = data.readInt32();
+ uint32_t strategy = data.readInt32();
+ int session = data.readInt32();
+ int id = data.readInt32();
+ reply->writeInt32(static_cast <int32_t>(registerEffect(&desc,
+ output,
+ strategy,
+ session,
+ id)));
+ return NO_ERROR;
+ } break;
+
+ case UNREGISTER_EFFECT: {
+ CHECK_INTERFACE(IAudioPolicyService, data, reply);
+ int id = data.readInt32();
+ reply->writeInt32(static_cast <int32_t>(unregisterEffect(id)));
+ return NO_ERROR;
+ } break;
+
default:
return BBinder::onTransact(code, data, reply, flags);
}
diff --git a/media/libstagefright/AudioPlayer.cpp b/media/libstagefright/AudioPlayer.cpp
index b79ba13..b7bde6b 100644
--- a/media/libstagefright/AudioPlayer.cpp
+++ b/media/libstagefright/AudioPlayer.cpp
@@ -41,6 +41,9 @@
mReachedEOS(false),
mFinalStatus(OK),
mStarted(false),
+ mIsFirstBuffer(false),
+ mFirstBufferResult(OK),
+ mFirstBuffer(NULL),
mAudioSink(audioSink) {
}
@@ -68,6 +71,24 @@
}
}
+ // We allow an optional INFO_FORMAT_CHANGED at the very beginning
+ // of playback, if there is one, getFormat below will retrieve the
+ // updated format, if there isn't, we'll stash away the valid buffer
+ // of data to be used on the first audio callback.
+
+ CHECK(mFirstBuffer == NULL);
+
+ mFirstBufferResult = mSource->read(&mFirstBuffer);
+ if (mFirstBufferResult == INFO_FORMAT_CHANGED) {
+ LOGV("INFO_FORMAT_CHANGED!!!");
+
+ CHECK(mFirstBuffer == NULL);
+ mFirstBufferResult = OK;
+ mIsFirstBuffer = false;
+ } else {
+ mIsFirstBuffer = true;
+ }
+
sp<MetaData> format = mSource->getFormat();
const char *mime;
bool success = format->findCString(kKeyMIMEType, &mime);
@@ -87,6 +108,11 @@
DEFAULT_AUDIOSINK_BUFFERCOUNT,
&AudioPlayer::AudioSinkCallback, this);
if (err != OK) {
+ if (mFirstBuffer != NULL) {
+ mFirstBuffer->release();
+ mFirstBuffer = NULL;
+ }
+
if (!sourceAlreadyStarted) {
mSource->stop();
}
@@ -110,6 +136,11 @@
delete mAudioTrack;
mAudioTrack = NULL;
+ if (mFirstBuffer != NULL) {
+ mFirstBuffer->release();
+ mFirstBuffer = NULL;
+ }
+
if (!sourceAlreadyStarted) {
mSource->stop();
}
@@ -163,6 +194,12 @@
// Make sure to release any buffer we hold onto so that the
// source is able to stop().
+
+ if (mFirstBuffer != NULL) {
+ mFirstBuffer->release();
+ mFirstBuffer = NULL;
+ }
+
if (mInputBuffer != NULL) {
LOGV("AudioPlayer releasing input buffer.");
@@ -247,6 +284,14 @@
Mutex::Autolock autoLock(mLock);
if (mSeeking) {
+ if (mIsFirstBuffer) {
+ if (mFirstBuffer != NULL) {
+ mFirstBuffer->release();
+ mFirstBuffer = NULL;
+ }
+ mIsFirstBuffer = false;
+ }
+
options.setSeekTo(mSeekTimeUs);
if (mInputBuffer != NULL) {
@@ -259,7 +304,17 @@
}
if (mInputBuffer == NULL) {
- status_t err = mSource->read(&mInputBuffer, &options);
+ status_t err;
+
+ if (mIsFirstBuffer) {
+ mInputBuffer = mFirstBuffer;
+ mFirstBuffer = NULL;
+ err = mFirstBufferResult;
+
+ mIsFirstBuffer = false;
+ } else {
+ err = mSource->read(&mInputBuffer, &options);
+ }
CHECK((err == OK && mInputBuffer != NULL)
|| (err != OK && mInputBuffer == NULL));
diff --git a/media/libstagefright/codecs/aacdec/AACDecoder.cpp b/media/libstagefright/codecs/aacdec/AACDecoder.cpp
index f3b281f..8ae1135 100644
--- a/media/libstagefright/codecs/aacdec/AACDecoder.cpp
+++ b/media/libstagefright/codecs/aacdec/AACDecoder.cpp
@@ -99,15 +99,6 @@
!= MP4AUDEC_SUCCESS) {
return ERROR_UNSUPPORTED;
}
-
- // Check on the sampling rate to see whether it is changed.
- int32_t sampleRate;
- CHECK(mMeta->findInt32(kKeySampleRate, &sampleRate));
- if (mConfig->samplingRate != sampleRate) {
- mMeta->setInt32(kKeySampleRate, mConfig->samplingRate);
- LOGW("Sample rate was %d, but now is %d",
- sampleRate, mConfig->samplingRate);
- }
}
return OK;
}
@@ -215,6 +206,19 @@
Int decoderErr = PVMP4AudioDecodeFrame(mConfig, mDecoderBuf);
+ // Check on the sampling rate to see whether it is changed.
+ int32_t sampleRate;
+ CHECK(mMeta->findInt32(kKeySampleRate, &sampleRate));
+ if (mConfig->samplingRate != sampleRate) {
+ mMeta->setInt32(kKeySampleRate, mConfig->samplingRate);
+ LOGW("Sample rate was %d, but now is %d",
+ sampleRate, mConfig->samplingRate);
+ buffer->release();
+ mInputBuffer->release();
+ mInputBuffer = NULL;
+ return INFO_FORMAT_CHANGED;
+ }
+
size_t numOutBytes =
mConfig->frameLength * sizeof(int16_t) * mConfig->desiredChannels;
if (mConfig->aacPlusUpsamplingFactor == 2) {
diff --git a/media/libstagefright/codecs/m4v_h263/enc/src/mp4def.h b/media/libstagefright/codecs/m4v_h263/enc/src/mp4def.h
index df1aa8b..0d5a3e8 100644
--- a/media/libstagefright/codecs/m4v_h263/enc/src/mp4def.h
+++ b/media/libstagefright/codecs/m4v_h263/enc/src/mp4def.h
@@ -18,6 +18,7 @@
#ifndef _PVDECDEF_H_
#define _PVDECDEF_H_
+#include <stdint.h> // for uint8_t, etc
#include <stdlib.h>
#include <string.h>
diff --git a/native/android/Android.mk b/native/android/Android.mk
index 2fe0679..950a1e9 100644
--- a/native/android/Android.mk
+++ b/native/android/Android.mk
@@ -6,6 +6,7 @@
# our source files
#
LOCAL_SRC_FILES:= \
+ asset_manager.cpp \
input.cpp \
looper.cpp \
native_activity.cpp \
diff --git a/native/android/asset_manager.cpp b/native/android/asset_manager.cpp
new file mode 100644
index 0000000..36c381e
--- /dev/null
+++ b/native/android/asset_manager.cpp
@@ -0,0 +1,210 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#define LOG_TAG "NAsset"
+#include <utils/Log.h>
+
+#include <android/asset_manager.h>
+#include <utils/AssetManager.h>
+#include <utils/AssetDir.h>
+#include <utils/Asset.h>
+#include <utils/threads.h>
+
+#include "jni.h"
+#include "JNIHelp.h"
+
+using namespace android;
+
+// -------------------- Backing implementation of the public API --------------------
+
+// AAssetManager is actually a secret typedef for an empty base class of AssetManager,
+// but AAssetDir and AAsset are actual wrappers for isolation.
+
+// -----
+struct AAssetDir {
+ AssetDir* mAssetDir;
+ size_t mCurFileIndex;
+ String8 mCachedFileName;
+
+ AAssetDir(AssetDir* dir) : mAssetDir(dir), mCurFileIndex(0) { }
+ ~AAssetDir() { delete mAssetDir; }
+};
+
+
+// -----
+struct AAsset {
+ Asset* mAsset;
+
+ AAsset(Asset* asset) : mAsset(asset) { }
+ ~AAsset() { delete mAsset; }
+};
+
+// -------------------- Public native C API --------------------
+
+/**
+ * Supporting information
+ */
+
+static struct assetmanager_offsets_t
+{
+ jfieldID mObject;
+} gAssetManagerOffsets;
+
+static volatile bool gJNIConfigured = false;
+static Mutex gMutex;
+
+/**
+ * Asset Manager functionality
+ */
+AAssetManager* AAssetManager_fromJava(JNIEnv* env, jobject assetManager)
+{
+ {
+ Mutex::Autolock _l(gMutex);
+
+ if (gJNIConfigured == false) {
+ jclass amClass = env->FindClass("android/content/res/AssetManager");
+ gAssetManagerOffsets.mObject = env->GetFieldID(amClass, "mObject", "I");
+ gJNIConfigured = true;
+ }
+ }
+
+ return (AAssetManager*) env->GetIntField(assetManager, gAssetManagerOffsets.mObject);
+}
+
+AAsset* AAssetManager_open(AAssetManager* amgr, const char* filename, int mode)
+{
+ Asset::AccessMode amMode;
+ switch (mode) {
+ case AASSET_MODE_UNKNOWN:
+ amMode = Asset::ACCESS_UNKNOWN;
+ break;
+ case AASSET_MODE_RANDOM:
+ amMode = Asset::ACCESS_RANDOM;
+ break;
+ case AASSET_MODE_STREAMING:
+ amMode = Asset::ACCESS_STREAMING;
+ break;
+ case AASSET_MODE_BUFFER:
+ amMode = Asset::ACCESS_BUFFER;
+ break;
+ default:
+ return NULL;
+ }
+
+ AssetManager* mgr = static_cast<AssetManager*>(amgr);
+ Asset* asset = mgr->open(filename, amMode);
+ if (asset == NULL) {
+ return NULL;
+ }
+
+ return new AAsset(asset);
+}
+
+AAssetDir* AAssetManager_openDir(AAssetManager* amgr, const char* dirName)
+{
+ AssetManager* mgr = static_cast<AssetManager*>(amgr);
+ return new AAssetDir(mgr->openDir(dirName));
+}
+
+/**
+ * AssetDir functionality
+ */
+
+const char* AAssetDir_getNextFileName(AAssetDir* assetDir)
+{
+ const char* returnName = NULL;
+ size_t index = assetDir->mCurFileIndex;
+ const size_t max = assetDir->mAssetDir->getFileCount();
+
+ // Find the next regular file; explicitly don't report directories even if the
+ // underlying implementation changes to report them. At that point we can add
+ // a more general iterator to this native interface set if appropriate.
+ while ((index < max) && (assetDir->mAssetDir->getFileType(index) != kFileTypeRegular)) {
+ index++;
+ }
+
+ // still in bounds? then the one at 'index' is the next to be reported; generate
+ // the string to return and advance the iterator for next time.
+ if (index < max) {
+ assetDir->mCachedFileName = assetDir->mAssetDir->getFileName(index);
+ returnName = assetDir->mCachedFileName.string();
+ index++;
+ }
+
+ assetDir->mCurFileIndex = index;
+ return returnName;
+}
+
+void AAssetDir_rewind(AAssetDir* assetDir)
+{
+ assetDir->mCurFileIndex = 0;
+}
+
+const char* AAssetDir_getFileName(AAssetDir* assetDir, int index)
+{
+ assetDir->mCachedFileName = assetDir->mAssetDir->getFileName(index);
+ return assetDir->mCachedFileName.string();
+}
+
+void AAssetDir_close(AAssetDir* assetDir)
+{
+ delete assetDir;
+}
+
+/**
+ * Asset functionality
+ */
+
+int AAsset_read(AAsset* asset, void* buf, size_t count)
+{
+ return asset->mAsset->read(buf, (size_t)count);
+}
+
+off_t AAsset_seek(AAsset* asset, off_t offset, int whence)
+{
+ return asset->mAsset->seek(offset, whence);
+}
+
+void AAsset_close(AAsset* asset)
+{
+ asset->mAsset->close();
+ delete asset;
+}
+
+const void* AAsset_getBuffer(AAsset* asset)
+{
+ return asset->mAsset->getBuffer(false);
+}
+
+off_t AAsset_getLength(AAsset* asset)
+{
+ return asset->mAsset->getLength();
+}
+
+off_t AAsset_getRemainingLength(AAsset* asset)
+{
+ return asset->mAsset->getRemainingLength();
+}
+
+int AAsset_openFileDescriptor(AAsset* asset, off_t* outStart, off_t* outLength)
+{
+ return asset->mAsset->openFileDescriptor(outStart, outLength);
+}
+
+int AAsset_isAllocated(AAsset* asset)
+{
+ return asset->mAsset->isAllocated() ? 1 : 0;
+}
diff --git a/native/android/input.cpp b/native/android/input.cpp
index a4dde51..59bf711 100644
--- a/native/android/input.cpp
+++ b/native/android/input.cpp
@@ -38,8 +38,8 @@
return static_cast<const InputEvent*>(event)->getDeviceId();
}
-int32_t AInputEvent_getNature(const AInputEvent* event) {
- return static_cast<const InputEvent*>(event)->getNature();
+int32_t AInputEvent_getSource(const AInputEvent* event) {
+ return static_cast<const InputEvent*>(event)->getSource();
}
int32_t AKeyEvent_getAction(const AInputEvent* key_event) {
@@ -69,6 +69,7 @@
return static_cast<const KeyEvent*>(key_event)->getDownTime();
}
+
int64_t AKeyEvent_getEventTime(const AInputEvent* key_event) {
return static_cast<const KeyEvent*>(key_event)->getEventTime();
}
@@ -141,6 +142,26 @@
return static_cast<const MotionEvent*>(motion_event)->getSize(pointer_index);
}
+float AMotionEvent_getTouchMajor(const AInputEvent* motion_event, size_t pointer_index) {
+ return static_cast<const MotionEvent*>(motion_event)->getTouchMajor(pointer_index);
+}
+
+float AMotionEvent_getTouchMinor(const AInputEvent* motion_event, size_t pointer_index) {
+ return static_cast<const MotionEvent*>(motion_event)->getTouchMinor(pointer_index);
+}
+
+float AMotionEvent_getToolMajor(const AInputEvent* motion_event, size_t pointer_index) {
+ return static_cast<const MotionEvent*>(motion_event)->getToolMajor(pointer_index);
+}
+
+float AMotionEvent_getToolMinor(const AInputEvent* motion_event, size_t pointer_index) {
+ return static_cast<const MotionEvent*>(motion_event)->getToolMinor(pointer_index);
+}
+
+float AMotionEvent_getOrientation(const AInputEvent* motion_event, size_t pointer_index) {
+ return static_cast<const MotionEvent*>(motion_event)->getOrientation(pointer_index);
+}
+
size_t AMotionEvent_getHistorySize(const AInputEvent* motion_event) {
return static_cast<const MotionEvent*>(motion_event)->getHistorySize();
}
@@ -187,6 +208,37 @@
pointer_index, history_index);
}
+float AMotionEvent_getHistoricalTouchMajor(AInputEvent* motion_event, size_t pointer_index,
+ size_t history_index) {
+ return static_cast<const MotionEvent*>(motion_event)->getHistoricalTouchMajor(
+ pointer_index, history_index);
+}
+
+float AMotionEvent_getHistoricalTouchMinor(AInputEvent* motion_event, size_t pointer_index,
+ size_t history_index) {
+ return static_cast<const MotionEvent*>(motion_event)->getHistoricalTouchMinor(
+ pointer_index, history_index);
+}
+
+float AMotionEvent_getHistoricalToolMajor(AInputEvent* motion_event, size_t pointer_index,
+ size_t history_index) {
+ return static_cast<const MotionEvent*>(motion_event)->getHistoricalToolMajor(
+ pointer_index, history_index);
+}
+
+float AMotionEvent_getHistoricalToolMinor(AInputEvent* motion_event, size_t pointer_index,
+ size_t history_index) {
+ return static_cast<const MotionEvent*>(motion_event)->getHistoricalToolMinor(
+ pointer_index, history_index);
+}
+
+float AMotionEvent_getHistoricalOrientation(AInputEvent* motion_event, size_t pointer_index,
+ size_t history_index) {
+ return static_cast<const MotionEvent*>(motion_event)->getHistoricalOrientation(
+ pointer_index, history_index);
+}
+
+
void AInputQueue_attachLooper(AInputQueue* queue, ALooper* looper,
ALooper_callbackFunc* callback, void* data) {
queue->attachLooper(looper, callback, data);
@@ -196,7 +248,7 @@
queue->detachLooper();
}
-int AInputQueue_hasEvents(AInputQueue* queue) {
+int32_t AInputQueue_hasEvents(AInputQueue* queue) {
return queue->hasEvents();
}
@@ -204,6 +256,10 @@
return queue->getEvent(outEvent);
}
+int32_t AInputQueue_preDispatchEvent(AInputQueue* queue, AInputEvent* event) {
+ return queue->preDispatchEvent(event) ? 1 : 0;
+}
+
void AInputQueue_finishEvent(AInputQueue* queue, AInputEvent* event, int handled) {
queue->finishEvent(event, handled != 0);
}
diff --git a/native/include/android/asset_manager.h b/native/include/android/asset_manager.h
new file mode 100644
index 0000000..89989f8
--- /dev/null
+++ b/native/include/android/asset_manager.h
@@ -0,0 +1,148 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+
+#ifndef ANDROID_ASSET_MANAGER_H
+#define ANDROID_ASSET_MANAGER_H
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct AAssetManager;
+typedef struct AAssetManager AAssetManager;
+
+struct AAssetDir;
+typedef struct AAssetDir AAssetDir;
+
+struct AAsset;
+typedef struct AAsset AAsset;
+
+/* Available modes for opening assets */
+enum {
+ AASSET_MODE_UNKNOWN = 0,
+ AASSET_MODE_RANDOM = 1,
+ AASSET_MODE_STREAMING = 2,
+ AASSET_MODE_BUFFER = 3
+};
+
+
+/**
+ * Given a Dalvik AssetManager object, obtain the corresponding native AAssetManager
+ * object. Note that the caller is responsible for obtaining and holding a VM reference
+ * to the jobject to prevent its being garbage collected while the native object is
+ * in use.
+ */
+AAssetManager* AAssetManager_fromJava(JNIEnv* env, jobject assetManager);
+
+/**
+ * Open the named directory within the asset hierarchy. The directory can then
+ * be inspected with the AAssetDir functions. To open the top-level directory,
+ * pass in "" as the dirName.
+ *
+ * The object returned here should be freed by calling AAssetDir_close().
+ */
+AAssetDir* AAssetManager_openDir(AAssetManager* mgr, const char* dirName);
+
+/**
+ * Open an asset.
+ *
+ * The object returned here should be freed by calling AAsset_close().
+ */
+AAsset* AAssetManager_open(AAssetManager* mgr, const char* filename, int mode);
+
+/**
+ * Iterate over the files in an asset directory. A NULL string is returned
+ * when all the file names have been returned.
+ *
+ * The returned file name is suitable for passing to AAssetManager_open().
+ *
+ * The string returned here is owned by the AssetDir implementation and is not
+ * guaranteed to remain valid if any other calls are made on this AAssetDir
+ * instance.
+ */
+const char* AAssetDir_getNextFileName(AAssetDir* assetDir);
+
+/**
+ * Reset the iteration state of AAssetDir_getNextFileName() to the beginning.
+ */
+void AAssetDir_rewind(AAssetDir* assetDir);
+
+/**
+ * Close an opened AAssetDir, freeing any related resources.
+ */
+void AAssetDir_close(AAssetDir* assetDir);
+
+/**
+ * Attempt to read 'count' bytes of data from the current offset.
+ *
+ * Returns the number of bytes read, zero on EOF, or < 0 on error.
+ */
+int AAsset_read(AAsset* asset, void* buf, size_t count);
+
+/**
+ * Seek to the specified offset within the asset data. 'whence' uses the
+ * same constants as lseek()/fseek().
+ *
+ * Returns the new position on success, or (off_t) -1 on error.
+ */
+off_t AAsset_seek(AAsset* asset, off_t offset, int whence);
+
+/**
+ * Close the asset, freeing all associated resources.
+ */
+void AAsset_close(AAsset* asset);
+
+/**
+ * Get a pointer to a buffer holding the entire contents of the assset.
+ *
+ * Returns NULL on failure.
+ */
+const void* AAsset_getBuffer(AAsset* asset);
+
+/**
+ * Report the total size of the asset data.
+ */
+off_t AAsset_getLength(AAsset* asset);
+
+/**
+ * Report the total amount of asset data that can be read from the current position.
+ */
+off_t AAsset_getRemainingLength(AAsset* asset);
+
+/**
+ * Open a new file descriptor that can be used to read the asset data.
+ *
+ * Returns < 0 if direct fd access is not possible (for example, if the asset is
+ * compressed).
+ */
+int AAsset_openFileDescriptor(AAsset* asset, off_t* outStart, off_t* outLength);
+
+/**
+ * Returns whether this asset's internal buffer is allocated in ordinary RAM (i.e. not
+ * mmapped).
+ */
+int AAsset_isAllocated(AAsset* asset);
+
+
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif // ANDROID_ASSET_MANAGER_H
diff --git a/native/include/android/input.h b/native/include/android/input.h
index 25dd68e..0b8c7e4 100644
--- a/native/include/android/input.h
+++ b/native/include/android/input.h
@@ -49,49 +49,21 @@
#endif
/*
- * Input device classes.
- */
-enum {
- /* The input device is a keyboard. */
- INPUT_DEVICE_CLASS_KEYBOARD = 0x00000001,
-
- /* The input device is an alpha-numeric keyboard (not just a dial pad). */
- INPUT_DEVICE_CLASS_ALPHAKEY = 0x00000002,
-
- /* The input device is a touchscreen (either single-touch or multi-touch). */
- INPUT_DEVICE_CLASS_TOUCHSCREEN = 0x00000004,
-
- /* The input device is a trackball. */
- INPUT_DEVICE_CLASS_TRACKBALL = 0x00000008,
-
- /* The input device is a multi-touch touchscreen. */
- INPUT_DEVICE_CLASS_TOUCHSCREEN_MT= 0x00000010,
-
- /* The input device is a directional pad. */
- INPUT_DEVICE_CLASS_DPAD = 0x00000020,
-
- /* The input device is a gamepad (implies keyboard). */
- INPUT_DEVICE_CLASS_GAMEPAD = 0x00000040
-};
-
-/*
* Key states (may be returned by queries about the current state of a
* particular key code, scan code or switch).
- *
- * XXX should we call this BUTTON_STATE_XXX?
*/
enum {
/* The key state is unknown or the requested key itself is not supported. */
- KEY_STATE_UNKNOWN = -1,
+ AKEY_STATE_UNKNOWN = -1,
/* The key is up. */
- KEY_STATE_UP = 0,
+ AKEY_STATE_UP = 0,
/* The key is down. */
- KEY_STATE_DOWN = 1,
+ AKEY_STATE_DOWN = 1,
/* The key is down but is a virtual key press that is being emulated by the system. */
- KEY_STATE_VIRTUAL = 2
+ AKEY_STATE_VIRTUAL = 2
};
/*
@@ -99,28 +71,28 @@
*/
enum {
/* No meta keys are pressed. */
- META_NONE = 0,
+ AMETA_NONE = 0,
/* This mask is used to check whether one of the ALT meta keys is pressed. */
- META_ALT_ON = 0x02,
+ AMETA_ALT_ON = 0x02,
/* This mask is used to check whether the left ALT meta key is pressed. */
- META_ALT_LEFT_ON = 0x10,
+ AMETA_ALT_LEFT_ON = 0x10,
/* This mask is used to check whether the right ALT meta key is pressed. */
- META_ALT_RIGHT_ON = 0x20,
+ AMETA_ALT_RIGHT_ON = 0x20,
/* This mask is used to check whether one of the SHIFT meta keys is pressed. */
- META_SHIFT_ON = 0x01,
+ AMETA_SHIFT_ON = 0x01,
/* This mask is used to check whether the left SHIFT meta key is pressed. */
- META_SHIFT_LEFT_ON = 0x40,
+ AMETA_SHIFT_LEFT_ON = 0x40,
/* This mask is used to check whether the right SHIFT meta key is pressed. */
- META_SHIFT_RIGHT_ON = 0x80,
+ AMETA_SHIFT_RIGHT_ON = 0x80,
/* This mask is used to check whether the SYM meta key is pressed. */
- META_SYM_ON = 0x04
+ AMETA_SYM_ON = 0x04
};
/*
@@ -137,10 +109,10 @@
*/
enum {
/* Indicates that the input event is a key event. */
- INPUT_EVENT_TYPE_KEY = 1,
+ AINPUT_EVENT_TYPE_KEY = 1,
/* Indicates that the input event is a motion event. */
- INPUT_EVENT_TYPE_MOTION = 2
+ AINPUT_EVENT_TYPE_MOTION = 2
};
/*
@@ -148,16 +120,16 @@
*/
enum {
/* The key has been pressed down. */
- KEY_EVENT_ACTION_DOWN = 0,
+ AKEY_EVENT_ACTION_DOWN = 0,
/* The key has been released. */
- KEY_EVENT_ACTION_UP = 1,
+ AKEY_EVENT_ACTION_UP = 1,
/* Multiple duplicate key events have occurred in a row, or a complex string is
* being delivered. The repeat_count property of the key event contains the number
* of times the given key code should be executed.
*/
- KEY_EVENT_ACTION_MULTIPLE = 2
+ AKEY_EVENT_ACTION_MULTIPLE = 2
};
/*
@@ -165,25 +137,25 @@
*/
enum {
/* This mask is set if the device woke because of this key event. */
- KEY_EVENT_FLAG_WOKE_HERE = 0x1,
+ AKEY_EVENT_FLAG_WOKE_HERE = 0x1,
/* This mask is set if the key event was generated by a software keyboard. */
- KEY_EVENT_FLAG_SOFT_KEYBOARD = 0x2,
+ AKEY_EVENT_FLAG_SOFT_KEYBOARD = 0x2,
/* This mask is set if we don't want the key event to cause us to leave touch mode. */
- KEY_EVENT_FLAG_KEEP_TOUCH_MODE = 0x4,
+ AKEY_EVENT_FLAG_KEEP_TOUCH_MODE = 0x4,
/* This mask is set if an event was known to come from a trusted part
* of the system. That is, the event is known to come from the user,
* and could not have been spoofed by a third party component. */
- KEY_EVENT_FLAG_FROM_SYSTEM = 0x8,
+ AKEY_EVENT_FLAG_FROM_SYSTEM = 0x8,
/* This mask is used for compatibility, to identify enter keys that are
* coming from an IME whose enter key has been auto-labelled "next" or
* "done". This allows TextView to dispatch these as normal enter keys
* for old applications, but still do the appropriate action when
* receiving them. */
- KEY_EVENT_FLAG_EDITOR_ACTION = 0x10,
+ AKEY_EVENT_FLAG_EDITOR_ACTION = 0x10,
/* When associated with up key events, this indicates that the key press
* has been canceled. Typically this is used with virtual touch screen
@@ -193,26 +165,26 @@
* key. Note that for this to work, the application can not perform an
* action for a key until it receives an up or the long press timeout has
* expired. */
- KEY_EVENT_FLAG_CANCELED = 0x20,
+ AKEY_EVENT_FLAG_CANCELED = 0x20,
/* This key event was generated by a virtual (on-screen) hard key area.
* Typically this is an area of the touchscreen, outside of the regular
* display, dedicated to "hardware" buttons. */
- KEY_EVENT_FLAG_VIRTUAL_HARD_KEY = 0x40,
+ AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY = 0x40,
/* This flag is set for the first key repeat that occurs after the
* long press timeout. */
- KEY_EVENT_FLAG_LONG_PRESS = 0x80,
+ AKEY_EVENT_FLAG_LONG_PRESS = 0x80,
- /* Set when a key event has KEY_EVENT_FLAG_CANCELED set because a long
+ /* Set when a key event has AKEY_EVENT_FLAG_CANCELED set because a long
* press action was executed while it was down. */
- KEY_EVENT_FLAG_CANCELED_LONG_PRESS = 0x100,
+ AKEY_EVENT_FLAG_CANCELED_LONG_PRESS = 0x100,
- /* Set for KEY_EVENT_ACTION_UP when this event's key code is still being
+ /* Set for AKEY_EVENT_ACTION_UP when this event's key code is still being
* tracked from its initial down. That is, somebody requested that tracking
* started on the key down and a long press has not caused
* the tracking to be canceled. */
- KEY_EVENT_FLAG_TRACKING = 0x200
+ AKEY_EVENT_FLAG_TRACKING = 0x200
};
/*
@@ -220,57 +192,57 @@
*/
/* Bit shift for the action bits holding the pointer index as
- * defined by MOTION_EVENT_ACTION_POINTER_INDEX_MASK.
+ * defined by AMOTION_EVENT_ACTION_POINTER_INDEX_MASK.
*/
-#define MOTION_EVENT_ACTION_POINTER_INDEX_SHIFT 8
+#define AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT 8
enum {
/* Bit mask of the parts of the action code that are the action itself.
*/
- MOTION_EVENT_ACTION_MASK = 0xff,
+ AMOTION_EVENT_ACTION_MASK = 0xff,
/* Bits in the action code that represent a pointer index, used with
- * MOTION_EVENT_ACTION_POINTER_DOWN and MOTION_EVENT_ACTION_POINTER_UP. Shifting
- * down by MOTION_EVENT_ACTION_POINTER_INDEX_SHIFT provides the actual pointer
+ * AMOTION_EVENT_ACTION_POINTER_DOWN and AMOTION_EVENT_ACTION_POINTER_UP. Shifting
+ * down by AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT provides the actual pointer
* index where the data for the pointer going up or down can be found.
*/
- MOTION_EVENT_ACTION_POINTER_INDEX_MASK = 0xff00,
+ AMOTION_EVENT_ACTION_POINTER_INDEX_MASK = 0xff00,
/* A pressed gesture has started, the motion contains the initial starting location.
*/
- MOTION_EVENT_ACTION_DOWN = 0,
+ AMOTION_EVENT_ACTION_DOWN = 0,
/* A pressed gesture has finished, the motion contains the final release location
* as well as any intermediate points since the last down or move event.
*/
- MOTION_EVENT_ACTION_UP = 1,
+ AMOTION_EVENT_ACTION_UP = 1,
- /* A change has happened during a press gesture (between MOTION_EVENT_ACTION_DOWN and
- * MOTION_EVENT_ACTION_UP). The motion contains the most recent point, as well as
+ /* A change has happened during a press gesture (between AMOTION_EVENT_ACTION_DOWN and
+ * AMOTION_EVENT_ACTION_UP). The motion contains the most recent point, as well as
* any intermediate points since the last down or move event.
*/
- MOTION_EVENT_ACTION_MOVE = 2,
+ AMOTION_EVENT_ACTION_MOVE = 2,
/* The current gesture has been aborted.
* You will not receive any more points in it. You should treat this as
* an up event, but not perform any action that you normally would.
*/
- MOTION_EVENT_ACTION_CANCEL = 3,
+ AMOTION_EVENT_ACTION_CANCEL = 3,
/* A movement has happened outside of the normal bounds of the UI element.
* This does not provide a full gesture, but only the initial location of the movement/touch.
*/
- MOTION_EVENT_ACTION_OUTSIDE = 4,
+ AMOTION_EVENT_ACTION_OUTSIDE = 4,
/* A non-primary pointer has gone down.
- * The bits in MOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed.
+ * The bits in AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed.
*/
- MOTION_EVENT_ACTION_POINTER_DOWN = 5,
+ AMOTION_EVENT_ACTION_POINTER_DOWN = 5,
/* A non-primary pointer has gone up.
- * The bits in MOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed.
+ * The bits in AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed.
*/
- MOTION_EVENT_ACTION_POINTER_UP = 6
+ AMOTION_EVENT_ACTION_POINTER_UP = 6
};
/*
@@ -278,39 +250,50 @@
*/
enum {
/* No edges intersected */
- MOTION_EVENT_EDGE_FLAG_NONE = 0,
+ AMOTION_EVENT_EDGE_FLAG_NONE = 0,
/* Flag indicating the motion event intersected the top edge of the screen. */
- MOTION_EVENT_EDGE_FLAG_TOP = 0x01,
+ AMOTION_EVENT_EDGE_FLAG_TOP = 0x01,
/* Flag indicating the motion event intersected the bottom edge of the screen. */
- MOTION_EVENT_EDGE_FLAG_BOTTOM = 0x02,
+ AMOTION_EVENT_EDGE_FLAG_BOTTOM = 0x02,
/* Flag indicating the motion event intersected the left edge of the screen. */
- MOTION_EVENT_EDGE_FLAG_LEFT = 0x04,
+ AMOTION_EVENT_EDGE_FLAG_LEFT = 0x04,
/* Flag indicating the motion event intersected the right edge of the screen. */
- MOTION_EVENT_EDGE_FLAG_RIGHT = 0x08
+ AMOTION_EVENT_EDGE_FLAG_RIGHT = 0x08
};
/*
- * Specifies the logical nature of an input event.
- * For example, the nature distinguishes between motion events that represent touches and
- * those that represent trackball moves.
+ * Input sources.
*
- * XXX This concept is tentative. Another idea would be to associate events with logical
- * controllers rather than physical devices. The interpretation of an event would
- * be made with respect to the nature of the controller that is considered the logical
- * source of an event. The decoupling is beneficial since multiple physical (and virtual)
- * devices could be responsible for producing events that would be associated with
- * various logical controllers. For example, the hard keyboard, on screen keyboard,
- * and peripheral keyboard could be mapped onto a single logical "keyboard" controller
- * (or treated independently, if desired).
+ * The appropriate interpretation for an input event depends on its source.
+ * Refer to the documentation on android.view.InputDevice for more details about input sources
+ * and their correct interpretation.
*/
enum {
- INPUT_EVENT_NATURE_KEY = 1,
- INPUT_EVENT_NATURE_TOUCH = 2,
- INPUT_EVENT_NATURE_TRACKBALL = 3
+ AINPUT_SOURCE_CLASS_MASK = 0x000000ff,
+
+ AINPUT_SOURCE_CLASS_BUTTON = 0x00000001,
+ AINPUT_SOURCE_CLASS_POINTER = 0x00000002,
+ AINPUT_SOURCE_CLASS_NAVIGATION = 0x00000004,
+ AINPUT_SOURCE_CLASS_POSITION = 0x00000008,
+ AINPUT_SOURCE_CLASS_JOYSTICK = 0x00000010,
+};
+
+enum {
+ AINPUT_SOURCE_UNKNOWN = 0x00000000,
+
+ AINPUT_SOURCE_KEYBOARD = 0x00000100 | AINPUT_SOURCE_CLASS_BUTTON,
+ AINPUT_SOURCE_DPAD = 0x00000200 | AINPUT_SOURCE_CLASS_BUTTON,
+ AINPUT_SOURCE_GAMEPAD = 0x00000400 | AINPUT_SOURCE_CLASS_BUTTON,
+ AINPUT_SOURCE_TOUCHSCREEN = 0x00001000 | AINPUT_SOURCE_CLASS_POINTER,
+ AINPUT_SOURCE_MOUSE = 0x00002000 | AINPUT_SOURCE_CLASS_POINTER,
+ AINPUT_SOURCE_TRACKBALL = 0x00010000 | AINPUT_SOURCE_CLASS_NAVIGATION,
+ AINPUT_SOURCE_TOUCHPAD = 0x00100000 | AINPUT_SOURCE_CLASS_POSITION,
+ AINPUT_SOURCE_JOYSTICK_LEFT = 0x01000000 | AINPUT_SOURCE_CLASS_JOYSTICK,
+ AINPUT_SOURCE_JOYSTICK_RIGHT = 0x02000000 | AINPUT_SOURCE_CLASS_JOYSTICK,
};
/*
@@ -337,8 +320,8 @@
*/
int32_t AInputEvent_getDeviceId(const AInputEvent* event);
-/* Get the input event nature. */
-int32_t AInputEvent_getNature(const AInputEvent* event);
+/* Get the input event source. */
+int32_t AInputEvent_getSource(const AInputEvent* event);
/*** Accessors for key events only. ***/
@@ -466,11 +449,41 @@
* determine fat touch events. */
float AMotionEvent_getSize(const AInputEvent* motion_event, size_t pointer_index);
+/* Get the current length of the major axis of an ellipse that describes the touch area
+ * at the point of contact for the given pointer index. */
+float AMotionEvent_getTouchMajor(const AInputEvent* motion_event, size_t pointer_index);
+
+/* Get the current length of the minor axis of an ellipse that describes the touch area
+ * at the point of contact for the given pointer index. */
+float AMotionEvent_getTouchMinor(const AInputEvent* motion_event, size_t pointer_index);
+
+/* Get the current length of the major axis of an ellipse that describes the size
+ * of the approaching tool for the given pointer index.
+ * The tool area represents the estimated size of the finger or pen that is
+ * touching the device independent of its actual touch area at the point of contact. */
+float AMotionEvent_getToolMajor(const AInputEvent* motion_event, size_t pointer_index);
+
+/* Get the current length of the minor axis of an ellipse that describes the size
+ * of the approaching tool for the given pointer index.
+ * The tool area represents the estimated size of the finger or pen that is
+ * touching the device independent of its actual touch area at the point of contact. */
+float AMotionEvent_getToolMinor(const AInputEvent* motion_event, size_t pointer_index);
+
+/* Get the current orientation of the touch area and tool area in radians clockwise from
+ * vertical for the given pointer index.
+ * An angle of 0 degrees indicates that the major axis of contact is oriented
+ * upwards, is perfectly circular or is of unknown orientation. A positive angle
+ * indicates that the major axis of contact is oriented to the right. A negative angle
+ * indicates that the major axis of contact is oriented to the left.
+ * The full range is from -PI/4 radians (finger pointing fully left) to PI/4 radians
+ * (finger pointing fully right). */
+float AMotionEvent_getOrientation(const AInputEvent* motion_event, size_t pointer_index);
+
/* Get the number of historical points in this event. These are movements that
* have occurred between this event and the previous event. This only applies
- * to MOTION_EVENT_ACTION_MOVE events -- all other actions will have a size of 0.
+ * to AMOTION_EVENT_ACTION_MOVE events -- all other actions will have a size of 0.
* Historical samples are indexed from oldest to newest. */
-size_t AMotionEvent_get_history_size(const AInputEvent* motion_event);
+size_t AMotionEvent_getHistorySize(const AInputEvent* motion_event);
/* Get the time that a historical movement occurred between this event and
* the previous event, in the java.lang.System.nanoTime() time base. */
@@ -527,6 +540,47 @@
float AMotionEvent_getHistoricalSize(AInputEvent* motion_event, size_t pointer_index,
size_t history_index);
+/* Get the historical length of the major axis of an ellipse that describes the touch area
+ * at the point of contact for the given pointer index that
+ * occurred between this event and the previous motion event. */
+float AMotionEvent_getHistoricalTouchMajor(const AInputEvent* motion_event, size_t pointer_index,
+ size_t history_index);
+
+/* Get the historical length of the minor axis of an ellipse that describes the touch area
+ * at the point of contact for the given pointer index that
+ * occurred between this event and the previous motion event. */
+float AMotionEvent_getHistoricalTouchMinor(const AInputEvent* motion_event, size_t pointer_index,
+ size_t history_index);
+
+/* Get the historical length of the major axis of an ellipse that describes the size
+ * of the approaching tool for the given pointer index that
+ * occurred between this event and the previous motion event.
+ * The tool area represents the estimated size of the finger or pen that is
+ * touching the device independent of its actual touch area at the point of contact. */
+float AMotionEvent_getHistoricalToolMajor(const AInputEvent* motion_event, size_t pointer_index,
+ size_t history_index);
+
+/* Get the historical length of the minor axis of an ellipse that describes the size
+ * of the approaching tool for the given pointer index that
+ * occurred between this event and the previous motion event.
+ * The tool area represents the estimated size of the finger or pen that is
+ * touching the device independent of its actual touch area at the point of contact. */
+float AMotionEvent_getHistoricalToolMinor(const AInputEvent* motion_event, size_t pointer_index,
+ size_t history_index);
+
+/* Get the historical orientation of the touch area and tool area in radians clockwise from
+ * vertical for the given pointer index that
+ * occurred between this event and the previous motion event.
+ * An angle of 0 degrees indicates that the major axis of contact is oriented
+ * upwards, is perfectly circular or is of unknown orientation. A positive angle
+ * indicates that the major axis of contact is oriented to the right. A negative angle
+ * indicates that the major axis of contact is oriented to the left.
+ * The full range is from -PI/4 radians (finger pointing fully left) to PI/4 radians
+ * (finger pointing fully right). */
+float AMotionEvent_getHistoricalOrientation(const AInputEvent* motion_event, size_t pointer_index,
+ size_t history_index);
+
+
/*
* Input queue
*
@@ -553,7 +607,7 @@
* input queue. Returns 1 if the queue has events; 0 if
* it does not have events; and a negative value if there is an error.
*/
-int AInputQueue_hasEvents(AInputQueue* queue);
+int32_t AInputQueue_hasEvents(AInputQueue* queue);
/*
* Returns the next available event from the queue. Returns a negative
@@ -562,6 +616,16 @@
int32_t AInputQueue_getEvent(AInputQueue* queue, AInputEvent** outEvent);
/*
+ * Sends the key for standard pre-dispatching -- that is, possibly deliver
+ * it to the current IME to be consumed before the app. Returns 0 if it
+ * was not pre-dispatched, meaning you can process it right now. If non-zero
+ * is returned, you must abandon the current event processing and allow the
+ * event to appear again in the event queue (if it does not get consumed during
+ * pre-dispatching).
+ */
+int32_t AInputQueue_preDispatchEvent(AInputQueue* queue, AInputEvent* event);
+
+/*
* Report that dispatching has finished with the given event.
* This must be called after receiving an event with AInputQueue_get_event().
*/
diff --git a/native/include/android/native_activity.h b/native/include/android/native_activity.h
index ea6f05f..ee4204d 100644
--- a/native/include/android/native_activity.h
+++ b/native/include/android/native_activity.h
@@ -23,6 +23,7 @@
#include <jni.h>
+#include <android/asset_manager.h>
#include <android/input.h>
#include <android/native_window.h>
@@ -84,6 +85,12 @@
* state.
*/
void* instance;
+
+ /**
+ * Pointer to the Asset Manager instance for the application. The application
+ * uses this to access binary assets bundled inside its own .apk file.
+ */
+ AAssetManager* assetManager;
} ANativeActivity;
/**
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index 771d885..b88e69d 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -63,6 +63,8 @@
// ----------------------------------------------------------------------------
+extern const char * const gEffectLibPath;
+
namespace android {
static const char* kDeadlockedString = "AudioFlinger may be deadlocked\n";
@@ -127,8 +129,7 @@
AudioFlinger::AudioFlinger()
: BnAudioFlinger(),
- mAudioHardware(0), mMasterVolume(1.0f), mMasterMute(false), mNextUniqueId(1),
- mTotalEffectsCpuLoad(0), mTotalEffectsMemory(0)
+ mAudioHardware(0), mMasterVolume(1.0f), mMasterMute(false), mNextUniqueId(1)
{
mHardwareStatus = AUDIO_HW_IDLE;
@@ -321,13 +322,19 @@
mClients.add(pid, client);
}
- // If no audio session id is provided, create one here
- // TODO: enforce same stream type for all tracks in same audio session?
- // TODO: prevent same audio session on different output threads
LOGV("createTrack() sessionId: %d", (sessionId == NULL) ? -2 : *sessionId);
- if (sessionId != NULL && *sessionId != 0) {
+ if (sessionId != NULL && *sessionId != AudioSystem::SESSION_OUTPUT_MIX) {
+ // prevent same audio session on different output threads
+ for (size_t i = 0; i < mPlaybackThreads.size(); i++) {
+ if (mPlaybackThreads.keyAt(i) != output &&
+ mPlaybackThreads.valueAt(i)->hasAudioSession(*sessionId)) {
+ lStatus = BAD_VALUE;
+ goto Exit;
+ }
+ }
lSessionId = *sessionId;
} else {
+ // if no audio session id is provided, create one here
lSessionId = nextUniqueId();
if (sessionId != NULL) {
*sessionId = lSessionId;
@@ -1141,6 +1148,23 @@
{ // scope for mLock
Mutex::Autolock _l(mLock);
+
+ // all tracks in same audio session must share the same routing strategy otherwise
+ // conflicts will happen when tracks are moved from one output to another by audio policy
+ // manager
+ uint32_t strategy =
+ AudioSystem::getStrategyForStream((AudioSystem::stream_type)streamType);
+ for (size_t i = 0; i < mTracks.size(); ++i) {
+ sp<Track> t = mTracks[i];
+ if (t != 0) {
+ if (sessionId == t->sessionId() &&
+ strategy != AudioSystem::getStrategyForStream((AudioSystem::stream_type)t->type())) {
+ lStatus = BAD_VALUE;
+ goto Exit;
+ }
+ }
+ }
+
track = new Track(this, client, streamType, sampleRate, format,
channelCount, frameCount, sharedBuffer, sessionId);
if (track->getCblk() == NULL || track->name() < 0) {
@@ -1153,6 +1177,7 @@
if (chain != 0) {
LOGV("createTrack_l() setting main buffer %p", chain->inBuffer());
track->setMainBuffer(chain->inBuffer());
+ chain->setStrategy(AudioSystem::getStrategyForStream((AudioSystem::stream_type)track->type()));
}
}
lStatus = NO_ERROR;
@@ -1344,7 +1369,16 @@
mMixBuffer = new int16_t[mFrameCount * 2];
memset(mMixBuffer, 0, mFrameCount * 2 * sizeof(int16_t));
- //TODO handle effects reconfig
+ // force reconfiguration of effect chains and engines to take new buffer size and audio
+ // parameters into account
+ // Note that mLock is not held when readOutputParameters() is called from the constructor
+ // but in this case nothing is done below as no audio sessions have effect yet so it doesn't
+ // matter.
+ // create a copy of mEffectChains as calling moveEffectChain_l() can reorder some effect chains
+ Vector< sp<EffectChain> > effectChains = mEffectChains;
+ for (size_t i = 0; i < effectChains.size(); i ++) {
+ mAudioFlinger->moveEffectChain_l(effectChains[i]->sessionId(), this, this);
+ }
}
status_t AudioFlinger::PlaybackThread::getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames)
@@ -1369,7 +1403,8 @@
for (size_t i = 0; i < mTracks.size(); ++i) {
sp<Track> track = mTracks[i];
- if (sessionId == track->sessionId()) {
+ if (sessionId == track->sessionId() &&
+ !(track->mCblk->flags & CBLK_INVALID_MSK)) {
return true;
}
}
@@ -1377,6 +1412,23 @@
return false;
}
+uint32_t AudioFlinger::PlaybackThread::getStrategyForSession_l(int sessionId)
+{
+ // session AudioSystem::SESSION_OUTPUT_MIX is placed in same strategy as MUSIC stream so that
+ // it is moved to correct output by audio policy manager when A2DP is connected or disconnected
+ if (sessionId == AudioSystem::SESSION_OUTPUT_MIX) {
+ return AudioSystem::getStrategyForStream(AudioSystem::MUSIC);
+ }
+ for (size_t i = 0; i < mTracks.size(); i++) {
+ sp<Track> track = mTracks[i];
+ if (sessionId == track->sessionId() &&
+ !(track->mCblk->flags & CBLK_INVALID_MSK)) {
+ return AudioSystem::getStrategyForStream((AudioSystem::stream_type) track->type());
+ }
+ }
+ return AudioSystem::getStrategyForStream(AudioSystem::MUSIC);
+}
+
sp<AudioFlinger::EffectChain> AudioFlinger::PlaybackThread::getEffectChain(int sessionId)
{
Mutex::Autolock _l(mLock);
@@ -1402,7 +1454,7 @@
Mutex::Autolock _l(mLock);
size_t size = mEffectChains.size();
for (size_t i = 0; i < size; i++) {
- mEffectChains[i]->setMode(mode);
+ mEffectChains[i]->setMode_l(mode);
}
}
@@ -1503,8 +1555,7 @@
// prevent any changes in effect chain list and in each effect chain
// during mixing and effect process as the audio buffers could be deleted
// or modified if an effect is created or deleted
- effectChains = mEffectChains;
- lockEffectChains_l();
+ lockEffectChains_l(effectChains);
}
if (LIKELY(mixerStatus == MIXER_TRACKS_READY)) {
@@ -1540,7 +1591,7 @@
effectChains[i]->process_l();
}
// enable changes in effect chain
- unlockEffectChains();
+ unlockEffectChains(effectChains);
#ifdef LVMX
int audioOutputType = LifeVibes::getMixerType(mId, mType);
if (LifeVibes::audioOutputTypeIsLifeVibes(audioOutputType)) {
@@ -1571,7 +1622,7 @@
mStandby = false;
} else {
// enable changes in effect chain
- unlockEffectChains();
+ unlockEffectChains(effectChains);
usleep(sleepTime);
}
@@ -1625,10 +1676,10 @@
}
#endif
// Delegate master volume control to effect in output mix effect chain if needed
- sp<EffectChain> chain = getEffectChain_l(0);
+ sp<EffectChain> chain = getEffectChain_l(AudioSystem::SESSION_OUTPUT_MIX);
if (chain != 0) {
uint32_t v = (uint32_t)(masterVolume * (1 << 24));
- chain->setVolume(&v, &v);
+ chain->setVolume_l(&v, &v);
masterVolume = (float)((v + (1 << 23)) >> 24);
chain.clear();
}
@@ -1706,7 +1757,7 @@
uint32_t vr = (uint32_t)(v * cblk->volume[1]) << 12;
// Delegate volume control to effect in track effect chain if needed
- if (chain != 0 && chain->setVolume(&vl, &vr)) {
+ if (chain != 0 && chain->setVolume_l(&vl, &vr)) {
// Do not ramp volume is volume is controlled by effect
param = AudioMixer::VOLUME;
}
@@ -1814,8 +1865,10 @@
void AudioFlinger::MixerThread::invalidateTracks(int streamType)
{
- LOGV ("MixerThread::invalidateTracks() mixer %p, streamType %d, mTracks.size %d", this, streamType, mTracks.size());
+ LOGV ("MixerThread::invalidateTracks() mixer %p, streamType %d, mTracks.size %d",
+ this, streamType, mTracks.size());
Mutex::Autolock _l(mLock);
+
size_t size = mTracks.size();
for (size_t i = 0; i < size; i++) {
sp<Track> t = mTracks[i];
@@ -1885,7 +1938,7 @@
// aware of attached audio device.
mDevice = (uint32_t)value;
for (size_t i = 0; i < mEffectChains.size(); i++) {
- mEffectChains[i]->setDevice(mDevice);
+ mEffectChains[i]->setDevice_l(mDevice);
}
}
@@ -2070,7 +2123,6 @@
// hardware resources as soon as possible
nsecs_t standbyDelay = microseconds(activeSleepTime*2);
-
while (!exitPending())
{
bool rampVolume;
@@ -2198,7 +2250,7 @@
// there is one, the track is connected to it
if (!effectChains.isEmpty()) {
// Do not ramp volume is volume is controlled by effect
- if(effectChains[0]->setVolume(&vl, &vr)) {
+ if(effectChains[0]->setVolume_l(&vl, &vr)) {
rampVolume = false;
}
}
@@ -2246,7 +2298,8 @@
if (UNLIKELY(trackToRemove != 0)) {
mActiveTracks.remove(trackToRemove);
if (!effectChains.isEmpty()) {
- LOGV("stopping track on chain %p for session Id: %d", effectChains[0].get(), trackToRemove->sessionId());
+ LOGV("stopping track on chain %p for session Id: %d", effectChains[0].get(),
+ trackToRemove->sessionId());
effectChains[0]->stopTrack();
}
if (trackToRemove->isTerminated()) {
@@ -2255,7 +2308,7 @@
}
}
- lockEffectChains_l();
+ lockEffectChains_l(effectChains);
}
if (LIKELY(mixerStatus == MIXER_TRACKS_READY)) {
@@ -2301,7 +2354,7 @@
for (size_t i = 0; i < effectChains.size(); i ++) {
effectChains[i]->process_l();
}
- unlockEffectChains();
+ unlockEffectChains(effectChains);
mLastWriteTime = systemTime();
mInWrite = true;
@@ -2312,7 +2365,7 @@
mInWrite = false;
mStandby = false;
} else {
- unlockEffectChains();
+ unlockEffectChains(effectChains);
usleep(sleepTime);
}
@@ -2505,8 +2558,7 @@
// prevent any changes in effect chain list and in each effect chain
// during mixing and effect process as the audio buffers could be deleted
// or modified if an effect is created or deleted
- effectChains = mEffectChains;
- lockEffectChains_l();
+ lockEffectChains_l(effectChains);
}
if (LIKELY(mixerStatus == MIXER_TRACKS_READY)) {
@@ -2547,7 +2599,7 @@
effectChains[i]->process_l();
}
// enable changes in effect chain
- unlockEffectChains();
+ unlockEffectChains(effectChains);
standbyTime = systemTime() + kStandbyTimeInNsecs;
for (size_t i = 0; i < outputTracks.size(); i++) {
@@ -2557,7 +2609,7 @@
mBytesWritten += mixBufferSize;
} else {
// enable changes in effect chain
- unlockEffectChains();
+ unlockEffectChains(effectChains);
usleep(sleepTime);
}
@@ -2859,7 +2911,9 @@
if (thread != 0) {
if (!isOutputTrack()) {
if (mState == ACTIVE || mState == RESUMING) {
- AudioSystem::stopOutput(thread->id(), (AudioSystem::stream_type)mStreamType);
+ AudioSystem::stopOutput(thread->id(),
+ (AudioSystem::stream_type)mStreamType,
+ mSessionId);
}
AudioSystem::releaseOutput(thread->id());
}
@@ -2948,7 +3002,8 @@
status_t AudioFlinger::PlaybackThread::Track::start()
{
status_t status = NO_ERROR;
- LOGV("start(%d), calling thread %d", mName, IPCThreadState::self()->getCallingPid());
+ LOGV("start(%d), calling thread %d session %d",
+ mName, IPCThreadState::self()->getCallingPid(), mSessionId);
sp<ThreadBase> thread = mThread.promote();
if (thread != 0) {
Mutex::Autolock _l(thread->mLock);
@@ -2965,7 +3020,9 @@
if (!isOutputTrack() && state != ACTIVE && state != RESUMING) {
thread->mLock.unlock();
- status = AudioSystem::startOutput(thread->id(), (AudioSystem::stream_type)mStreamType);
+ status = AudioSystem::startOutput(thread->id(),
+ (AudioSystem::stream_type)mStreamType,
+ mSessionId);
thread->mLock.lock();
}
if (status == NO_ERROR) {
@@ -2998,7 +3055,9 @@
}
if (!isOutputTrack() && (state == ACTIVE || state == RESUMING)) {
thread->mLock.unlock();
- AudioSystem::stopOutput(thread->id(), (AudioSystem::stream_type)mStreamType);
+ AudioSystem::stopOutput(thread->id(),
+ (AudioSystem::stream_type)mStreamType,
+ mSessionId);
thread->mLock.lock();
}
}
@@ -3015,7 +3074,9 @@
LOGV("ACTIVE/RESUMING => PAUSING (%d) on thread %p", mName, thread.get());
if (!isOutputTrack()) {
thread->mLock.unlock();
- AudioSystem::stopOutput(thread->id(), (AudioSystem::stream_type)mStreamType);
+ AudioSystem::stopOutput(thread->id(),
+ (AudioSystem::stream_type)mStreamType,
+ mSessionId);
thread->mLock.lock();
}
}
@@ -3584,7 +3645,7 @@
}
// If no audio session id is provided, create one here
- if (sessionId != NULL && *sessionId != 0) {
+ if (sessionId != NULL && *sessionId != AudioSystem::SESSION_OUTPUT_MIX) {
lSessionId = *sessionId;
} else {
lSessionId = nextUniqueId();
@@ -4415,8 +4476,8 @@
thread->type() != PlaybackThread::DIRECT) {
MixerThread *srcThread = (MixerThread *)thread;
srcThread->invalidateTracks(stream);
- }
}
+ }
return NO_ERROR;
}
@@ -4471,12 +4532,26 @@
status_t AudioFlinger::loadEffectLibrary(const char *libPath, int *handle)
{
+ // check calling permissions
+ if (!settingsAllowed()) {
+ return PERMISSION_DENIED;
+ }
+ // only allow libraries loaded from /system/lib/soundfx for now
+ if (strncmp(gEffectLibPath, libPath, strlen(gEffectLibPath)) != 0) {
+ return PERMISSION_DENIED;
+ }
+
Mutex::Autolock _l(mLock);
return EffectLoadLibrary(libPath, handle);
}
status_t AudioFlinger::unloadEffectLibrary(int handle)
{
+ // check calling permissions
+ if (!settingsAllowed()) {
+ return PERMISSION_DENIED;
+ }
+
Mutex::Autolock _l(mLock);
return EffectUnloadLibrary(handle);
}
@@ -4521,7 +4596,8 @@
sp<Client> client;
wp<Client> wclient;
- LOGV("createEffect pid %d, client %p, priority %d, sessionId %d, output %d", pid, effectClient.get(), priority, sessionId, output);
+ LOGV("createEffect pid %d, client %p, priority %d, sessionId %d, output %d",
+ pid, effectClient.get(), priority, sessionId, output);
if (pDesc == NULL) {
lStatus = BAD_VALUE;
@@ -4576,7 +4652,7 @@
// an auxiliary version of this effect type is available
found = true;
memcpy(&d, &desc, sizeof(effect_descriptor_t));
- if (sessionId != 0 ||
+ if (sessionId != AudioSystem::SESSION_OUTPUT_MIX ||
(desc.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_AUXILIARY) {
break;
}
@@ -4589,22 +4665,23 @@
}
// For same effect type, chose auxiliary version over insert version if
// connect to output mix (Compliance to OpenSL ES)
- if (sessionId == 0 &&
+ if (sessionId == AudioSystem::SESSION_OUTPUT_MIX &&
(d.flags & EFFECT_FLAG_TYPE_MASK) != EFFECT_FLAG_TYPE_AUXILIARY) {
memcpy(&desc, &d, sizeof(effect_descriptor_t));
}
}
// Do not allow auxiliary effects on a session different from 0 (output mix)
- if (sessionId != 0 &&
+ if (sessionId != AudioSystem::SESSION_OUTPUT_MIX &&
(desc.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_AUXILIARY) {
lStatus = INVALID_OPERATION;
goto Exit;
}
- // Session -1 is reserved for output stage effects that can only be created
- // by audio policy manager (running in same process)
- if (sessionId == -1 && getpid() != IPCThreadState::self()->getCallingPid()) {
+ // Session AudioSystem::SESSION_OUTPUT_STAGE is reserved for output stage effects
+ // that can only be created by audio policy manager (running in same process)
+ if (sessionId == AudioSystem::SESSION_OUTPUT_STAGE &&
+ getpid() != IPCThreadState::self()->getCallingPid()) {
lStatus = INVALID_OPERATION;
goto Exit;
}
@@ -4616,13 +4693,14 @@
// output threads.
// TODO: allow attachment of effect to inputs
if (output == 0) {
- if (sessionId <= 0) {
- // default to first output
- // TODO: define criteria to choose output when not specified. Or
- // receive output from audio policy manager
- if (mPlaybackThreads.size() != 0) {
- output = mPlaybackThreads.keyAt(0);
- }
+ if (sessionId == AudioSystem::SESSION_OUTPUT_STAGE) {
+ // output must be specified by AudioPolicyManager when using session
+ // AudioSystem::SESSION_OUTPUT_STAGE
+ lStatus = BAD_VALUE;
+ goto Exit;
+ } else if (sessionId == AudioSystem::SESSION_OUTPUT_MIX) {
+ output = AudioSystem::getOutputForEffect(&desc);
+ LOGV("createEffect() got output %d for effect %s", output, desc.name);
} else {
// look for the thread where the specified audio session is present
for (size_t i = 0; i < mPlaybackThreads.size(); i++) {
@@ -4635,7 +4713,7 @@
}
PlaybackThread *thread = checkPlaybackThread_l(output);
if (thread == NULL) {
- LOGE("unknown output thread");
+ LOGE("createEffect() unknown output thread");
lStatus = BAD_VALUE;
goto Exit;
}
@@ -4650,7 +4728,8 @@
}
// create effect on selected output trhead
- handle = thread->createEffect_l(client, effectClient, priority, sessionId, &desc, enabled, &lStatus);
+ handle = thread->createEffect_l(client, effectClient, priority, sessionId,
+ &desc, enabled, &lStatus);
if (handle != 0 && id != NULL) {
*id = handle->id();
}
@@ -4663,31 +4742,64 @@
return handle;
}
-status_t AudioFlinger::registerEffectResource_l(effect_descriptor_t *desc) {
- if (mTotalEffectsCpuLoad + desc->cpuLoad > MAX_EFFECTS_CPU_LOAD) {
- LOGW("registerEffectResource() CPU Load limit exceeded for Fx %s, CPU %f MIPS",
- desc->name, (float)desc->cpuLoad/10);
- return INVALID_OPERATION;
+status_t AudioFlinger::moveEffects(int session, int srcOutput, int dstOutput)
+{
+ LOGV("moveEffects() session %d, srcOutput %d, dstOutput %d",
+ session, srcOutput, dstOutput);
+ Mutex::Autolock _l(mLock);
+ if (srcOutput == dstOutput) {
+ LOGW("moveEffects() same dst and src outputs %d", dstOutput);
+ return NO_ERROR;
}
- if (mTotalEffectsMemory + desc->memoryUsage > MAX_EFFECTS_MEMORY) {
- LOGW("registerEffectResource() memory limit exceeded for Fx %s, Memory %d KB",
- desc->name, desc->memoryUsage);
- return INVALID_OPERATION;
+ PlaybackThread *srcThread = checkPlaybackThread_l(srcOutput);
+ if (srcThread == NULL) {
+ LOGW("moveEffects() bad srcOutput %d", srcOutput);
+ return BAD_VALUE;
}
- mTotalEffectsCpuLoad += desc->cpuLoad;
- mTotalEffectsMemory += desc->memoryUsage;
- LOGV("registerEffectResource_l() effect %s, CPU %d, memory %d",
- desc->name, desc->cpuLoad, desc->memoryUsage);
- LOGV(" total CPU %d, total memory %d", mTotalEffectsCpuLoad, mTotalEffectsMemory);
+ PlaybackThread *dstThread = checkPlaybackThread_l(dstOutput);
+ if (dstThread == NULL) {
+ LOGW("moveEffects() bad dstOutput %d", dstOutput);
+ return BAD_VALUE;
+ }
+
+ Mutex::Autolock _dl(dstThread->mLock);
+ Mutex::Autolock _sl(srcThread->mLock);
+ moveEffectChain_l(session, srcThread, dstThread);
+
return NO_ERROR;
}
-void AudioFlinger::unregisterEffectResource_l(effect_descriptor_t *desc) {
- mTotalEffectsCpuLoad -= desc->cpuLoad;
- mTotalEffectsMemory -= desc->memoryUsage;
- LOGV("unregisterEffectResource_l() effect %s, CPU %d, memory %d",
- desc->name, desc->cpuLoad, desc->memoryUsage);
- LOGV(" total CPU %d, total memory %d", mTotalEffectsCpuLoad, mTotalEffectsMemory);
+// moveEffectChain_l mustbe called with both srcThread and dstThread mLocks held
+status_t AudioFlinger::moveEffectChain_l(int session,
+ AudioFlinger::PlaybackThread *srcThread,
+ AudioFlinger::PlaybackThread *dstThread)
+{
+ LOGV("moveEffectChain_l() session %d from thread %p to thread %p",
+ session, srcThread, dstThread);
+
+ sp<EffectChain> chain = srcThread->getEffectChain_l(session);
+ if (chain == 0) {
+ LOGW("moveEffectChain_l() effect chain for session %d not on source thread %p",
+ session, srcThread);
+ return INVALID_OPERATION;
+ }
+
+ // remove chain first. This is usefull only if reconfiguring effect chain on same output thread,
+ // so that a new chain is created with correct parameters when first effect is added. This is
+ // otherwise unecessary as removeEffect_l() will remove the chain when last effect is
+ // removed.
+ srcThread->removeEffectChain_l(chain);
+
+ // transfer all effects one by one so that new effect chain is created on new thread with
+ // correct buffer sizes and audio parameters and effect engines reconfigured accordingly
+ sp<EffectModule> effect = chain->getEffectFromId_l(0);
+ while (effect != 0) {
+ srcThread->removeEffect_l(effect);
+ dstThread->addEffect_l(effect);
+ effect = chain->getEffectFromId_l(0);
+ }
+
+ return NO_ERROR;
}
// PlaybackThread::createEffect_l() must be called with AudioFlinger::mLock held
@@ -4706,6 +4818,7 @@
status_t lStatus;
sp<Track> track;
sp<EffectChain> chain;
+ bool chainCreated = false;
bool effectCreated = false;
bool effectRegistered = false;
@@ -4717,16 +4830,18 @@
// Do not allow auxiliary effect on session other than 0
if ((desc->flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_AUXILIARY &&
- sessionId != 0) {
- LOGW("createEffect_l() Cannot add auxiliary effect %s to session %d", desc->name, sessionId);
+ sessionId != AudioSystem::SESSION_OUTPUT_MIX) {
+ LOGW("createEffect_l() Cannot add auxiliary effect %s to session %d",
+ desc->name, sessionId);
lStatus = BAD_VALUE;
goto Exit;
}
// Do not allow effects with session ID 0 on direct output or duplicating threads
// TODO: add rule for hw accelerated effects on direct outputs with non PCM format
- if (sessionId == 0 && mType != MIXER) {
- LOGW("createEffect_l() Cannot add auxiliary effect %s to session %d", desc->name, sessionId);
+ if (sessionId == AudioSystem::SESSION_OUTPUT_MIX && mType != MIXER) {
+ LOGW("createEffect_l() Cannot add auxiliary effect %s to session %d",
+ desc->name, sessionId);
lStatus = BAD_VALUE;
goto Exit;
}
@@ -4743,26 +4858,29 @@
LOGV("createEffect_l() new effect chain for session %d", sessionId);
chain = new EffectChain(this, sessionId);
addEffectChain_l(chain);
+ chain->setStrategy(getStrategyForSession_l(sessionId));
+ chainCreated = true;
} else {
- effect = chain->getEffectFromDesc(desc);
+ effect = chain->getEffectFromDesc_l(desc);
}
LOGV("createEffect_l() got effect %p on chain %p", effect == 0 ? 0 : effect.get(), chain.get());
if (effect == 0) {
+ int id = mAudioFlinger->nextUniqueId();
// Check CPU and memory usage
- lStatus = mAudioFlinger->registerEffectResource_l(desc);
+ lStatus = AudioSystem::registerEffect(desc, mId, chain->strategy(), sessionId, id);
if (lStatus != NO_ERROR) {
goto Exit;
}
effectRegistered = true;
// create a new effect module if none present in the chain
- effect = new EffectModule(this, chain, desc, mAudioFlinger->nextUniqueId(), sessionId);
+ effect = new EffectModule(this, chain, desc, id, sessionId);
lStatus = effect->status();
if (lStatus != NO_ERROR) {
goto Exit;
}
- lStatus = chain->addEffect(effect);
+ lStatus = chain->addEffect_l(effect);
if (lStatus != NO_ERROR) {
goto Exit;
}
@@ -4781,13 +4899,15 @@
Exit:
if (lStatus != NO_ERROR && lStatus != ALREADY_EXISTS) {
+ Mutex::Autolock _l(mLock);
if (effectCreated) {
- if (chain->removeEffect(effect) == 0) {
- removeEffectChain_l(chain);
- }
+ chain->removeEffect_l(effect);
}
if (effectRegistered) {
- mAudioFlinger->unregisterEffectResource_l(desc);
+ AudioSystem::unregisterEffect(effect->id());
+ }
+ if (chainCreated) {
+ removeEffectChain_l(chain);
}
handle.clear();
}
@@ -4798,26 +4918,71 @@
return handle;
}
-void AudioFlinger::PlaybackThread::disconnectEffect(const sp< EffectModule>& effect,
- const wp<EffectHandle>& handle) {
+// PlaybackThread::addEffect_l() must be called with AudioFlinger::mLock and
+// PlaybackThread::mLock held
+status_t AudioFlinger::PlaybackThread::addEffect_l(const sp<EffectModule>& effect)
+{
+ // check for existing effect chain with the requested audio session
+ int sessionId = effect->sessionId();
+ sp<EffectChain> chain = getEffectChain_l(sessionId);
+ bool chainCreated = false;
+
+ if (chain == 0) {
+ // create a new chain for this session
+ LOGV("addEffect_l() new effect chain for session %d", sessionId);
+ chain = new EffectChain(this, sessionId);
+ addEffectChain_l(chain);
+ chain->setStrategy(getStrategyForSession_l(sessionId));
+ chainCreated = true;
+ }
+ LOGV("addEffect_l() %p chain %p effect %p", this, chain.get(), effect.get());
+
+ if (chain->getEffectFromId_l(effect->id()) != 0) {
+ LOGW("addEffect_l() %p effect %s already present in chain %p",
+ this, effect->desc().name, chain.get());
+ return BAD_VALUE;
+ }
+
+ status_t status = chain->addEffect_l(effect);
+ if (status != NO_ERROR) {
+ if (chainCreated) {
+ removeEffectChain_l(chain);
+ }
+ return status;
+ }
+
+ effect->setDevice(mDevice);
+ effect->setMode(mAudioFlinger->getMode());
+ return NO_ERROR;
+}
+
+void AudioFlinger::PlaybackThread::removeEffect_l(const sp<EffectModule>& effect) {
+
+ LOGV("removeEffect_l() %p effect %p", this, effect.get());
effect_descriptor_t desc = effect->desc();
+ if ((desc.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_AUXILIARY) {
+ detachAuxEffect_l(effect->id());
+ }
+
+ sp<EffectChain> chain = effect->chain().promote();
+ if (chain != 0) {
+ // remove effect chain if removing last effect
+ if (chain->removeEffect_l(effect) == 0) {
+ removeEffectChain_l(chain);
+ }
+ } else {
+ LOGW("removeEffect_l() %p cannot promote chain for effect %p", this, effect.get());
+ }
+}
+
+void AudioFlinger::PlaybackThread::disconnectEffect(const sp<EffectModule>& effect,
+ const wp<EffectHandle>& handle) {
Mutex::Autolock _l(mLock);
+ LOGV("disconnectEffect() %p effect %p", this, effect.get());
// delete the effect module if removing last handle on it
if (effect->removeHandle(handle) == 0) {
- if ((desc.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_AUXILIARY) {
- detachAuxEffect_l(effect->id());
- }
- sp<EffectChain> chain = effect->chain().promote();
- if (chain != 0) {
- // remove effect chain if remove last effect
- if (chain->removeEffect(effect) == 0) {
- removeEffectChain_l(chain);
- }
- }
- mLock.unlock();
- mAudioFlinger->mLock.lock();
- mAudioFlinger->unregisterEffectResource_l(&desc);
- mAudioFlinger->mLock.unlock();
+ removeEffect_l(effect);
+ AudioSystem::unregisterEffect(effect->id());
}
}
@@ -4861,13 +5026,16 @@
chain->setInBuffer(buffer, ownsBuffer);
chain->setOutBuffer(mMixBuffer);
- // Effect chain for session -1 is inserted at end of effect chains list
- // in order to be processed last as it contains output stage effects
- // Effect chain for session 0 is inserted before session -1 to be processed
+ // Effect chain for session AudioSystem::SESSION_OUTPUT_STAGE is inserted at end of effect
+ // chains list in order to be processed last as it contains output stage effects
+ // Effect chain for session AudioSystem::SESSION_OUTPUT_MIX is inserted before
+ // session AudioSystem::SESSION_OUTPUT_STAGE to be processed
// after track specific effects and before output stage
- // Effect chain for session other than 0 is inserted at beginning of effect
- // chains list to be processed before output mix effects. Relative order between
- // sessions other than 0 is not important
+ // It is therefore mandatory that AudioSystem::SESSION_OUTPUT_MIX == 0 and
+ // that AudioSystem::SESSION_OUTPUT_STAGE < AudioSystem::SESSION_OUTPUT_MIX
+ // Effect chain for other sessions are inserted at beginning of effect
+ // chains list to be processed before output mix effects. Relative order between other
+ // sessions is not important
size_t size = mEffectChains.size();
size_t i = 0;
for (i = 0; i < size; i++) {
@@ -4894,52 +5062,58 @@
track->setMainBuffer(mMixBuffer);
}
}
+ break;
}
}
return mEffectChains.size();
}
-void AudioFlinger::PlaybackThread::lockEffectChains_l()
+void AudioFlinger::PlaybackThread::lockEffectChains_l(
+ Vector<sp <AudioFlinger::EffectChain> >& effectChains)
{
+ effectChains = mEffectChains;
for (size_t i = 0; i < mEffectChains.size(); i++) {
mEffectChains[i]->lock();
}
}
-void AudioFlinger::PlaybackThread::unlockEffectChains()
+void AudioFlinger::PlaybackThread::unlockEffectChains(
+ Vector<sp <AudioFlinger::EffectChain> >& effectChains)
{
- Mutex::Autolock _l(mLock);
- for (size_t i = 0; i < mEffectChains.size(); i++) {
- mEffectChains[i]->unlock();
+ for (size_t i = 0; i < effectChains.size(); i++) {
+ effectChains[i]->unlock();
}
}
+
sp<AudioFlinger::EffectModule> AudioFlinger::PlaybackThread::getEffect_l(int sessionId, int effectId)
{
sp<EffectModule> effect;
sp<EffectChain> chain = getEffectChain_l(sessionId);
if (chain != 0) {
- effect = chain->getEffectFromId(effectId);
+ effect = chain->getEffectFromId_l(effectId);
}
return effect;
}
-status_t AudioFlinger::PlaybackThread::attachAuxEffect(const sp<AudioFlinger::PlaybackThread::Track> track, int EffectId)
+status_t AudioFlinger::PlaybackThread::attachAuxEffect(
+ const sp<AudioFlinger::PlaybackThread::Track> track, int EffectId)
{
Mutex::Autolock _l(mLock);
return attachAuxEffect_l(track, EffectId);
}
-status_t AudioFlinger::PlaybackThread::attachAuxEffect_l(const sp<AudioFlinger::PlaybackThread::Track> track, int EffectId)
+status_t AudioFlinger::PlaybackThread::attachAuxEffect_l(
+ const sp<AudioFlinger::PlaybackThread::Track> track, int EffectId)
{
status_t status = NO_ERROR;
if (EffectId == 0) {
track->setAuxBuffer(0, NULL);
} else {
- // Auxiliary effects are always in audio session 0
- sp<EffectModule> effect = getEffect_l(0, EffectId);
+ // Auxiliary effects are always in audio session AudioSystem::SESSION_OUTPUT_MIX
+ sp<EffectModule> effect = getEffect_l(AudioSystem::SESSION_OUTPUT_MIX, EffectId);
if (effect != 0) {
if ((effect->desc().flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_AUXILIARY) {
track->setAuxBuffer(EffectId, (int32_t *)effect->inBuffer());
@@ -5135,7 +5309,7 @@
if ((mDescriptor.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_AUXILIARY) {
AudioMixer::ditherAndClamp(mConfig.inputCfg.buffer.s32,
mConfig.inputCfg.buffer.s32,
- mConfig.inputCfg.buffer.frameCount);
+ mConfig.inputCfg.buffer.frameCount/2);
}
// do the actual processing in the effect engine
@@ -5212,7 +5386,8 @@
mConfig.outputCfg.bufferProvider.releaseBuffer = NULL;
mConfig.inputCfg.accessMode = EFFECT_BUFFER_ACCESS_READ;
// Insert effect:
- // - in session 0 or -1, always overwrites output buffer: input buffer == output buffer
+ // - in session AudioSystem::SESSION_OUTPUT_MIX or AudioSystem::SESSION_OUTPUT_STAGE,
+ // always overwrites output buffer: input buffer == output buffer
// - in other sessions:
// last effect in the chain accumulates in output buffer: input buffer != output buffer
// other effect: overwrites output buffer: input buffer == output buffer
@@ -5229,6 +5404,9 @@
mConfig.inputCfg.buffer.frameCount = thread->frameCount();
mConfig.outputCfg.buffer.frameCount = mConfig.inputCfg.buffer.frameCount;
+ LOGV("configure() %p thread %p buffer %p framecount %d",
+ this, thread.get(), mConfig.inputCfg.buffer.raw, mConfig.inputCfg.buffer.frameCount);
+
status_t cmdStatus;
int size = sizeof(int);
status_t status = (*mEffectInterface)->command(mEffectInterface, EFFECT_CMD_CONFIGURE, sizeof(effect_config_t), &mConfig, &size, &cmdStatus);
@@ -5365,7 +5543,9 @@
// Send volume indication if EFFECT_FLAG_VOLUME_IND is set and read back altered volume
// if controller flag is set (Note that controller == TRUE => EFFECT_FLAG_VOLUME_CTRL set)
- if ((mDescriptor.flags & EFFECT_FLAG_VOLUME_MASK) & (EFFECT_FLAG_VOLUME_CTRL|EFFECT_FLAG_VOLUME_IND)) {
+ if ((mState >= ACTIVE) &&
+ ((mDescriptor.flags & EFFECT_FLAG_VOLUME_MASK) == EFFECT_FLAG_VOLUME_CTRL ||
+ (mDescriptor.flags & EFFECT_FLAG_VOLUME_MASK) == EFFECT_FLAG_VOLUME_IND)) {
status_t cmdStatus;
uint32_t volume[2];
uint32_t *pVolume = NULL;
@@ -5745,9 +5925,11 @@
AudioFlinger::EffectChain::EffectChain(const wp<ThreadBase>& wThread,
int sessionId)
- : mThread(wThread), mSessionId(sessionId), mVolumeCtrlIdx(-1), mActiveTrackCnt(0), mOwnInBuffer(false)
+ : mThread(wThread), mSessionId(sessionId), mActiveTrackCnt(0), mOwnInBuffer(false),
+ mVolumeCtrlIdx(-1), mLeftVolume(0), mRightVolume(0),
+ mNewLeftVolume(0), mNewRightVolume(0)
{
-
+ mStrategy = AudioSystem::getStrategyForStream(AudioSystem::MUSIC);
}
AudioFlinger::EffectChain::~EffectChain()
@@ -5758,7 +5940,8 @@
}
-sp<AudioFlinger::EffectModule> AudioFlinger::EffectChain::getEffectFromDesc(effect_descriptor_t *descriptor)
+// getEffectFromDesc_l() must be called with PlaybackThread::mLock held
+sp<AudioFlinger::EffectModule> AudioFlinger::EffectChain::getEffectFromDesc_l(effect_descriptor_t *descriptor)
{
sp<EffectModule> effect;
size_t size = mEffects.size();
@@ -5772,13 +5955,15 @@
return effect;
}
-sp<AudioFlinger::EffectModule> AudioFlinger::EffectChain::getEffectFromId(int id)
+// getEffectFromId_l() must be called with PlaybackThread::mLock held
+sp<AudioFlinger::EffectModule> AudioFlinger::EffectChain::getEffectFromId_l(int id)
{
sp<EffectModule> effect;
size_t size = mEffects.size();
for (size_t i = 0; i < size; i++) {
- if (mEffects[i]->id() == id) {
+ // by convention, return first effect if id provided is 0 (0 is never a valid id)
+ if (id == 0 || mEffects[i]->id() == id) {
effect = mEffects[i];
break;
}
@@ -5807,21 +5992,25 @@
}
}
-status_t AudioFlinger::EffectChain::addEffect(sp<EffectModule>& effect)
+// addEffect_l() must be called with PlaybackThread::mLock held
+status_t AudioFlinger::EffectChain::addEffect_l(const sp<EffectModule>& effect)
{
effect_descriptor_t desc = effect->desc();
uint32_t insertPref = desc.flags & EFFECT_FLAG_INSERT_MASK;
Mutex::Autolock _l(mLock);
+ effect->setChain(this);
+ sp<ThreadBase> thread = mThread.promote();
+ if (thread == 0) {
+ return NO_INIT;
+ }
+ effect->setThread(thread);
if ((desc.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_AUXILIARY) {
// Auxiliary effects are inserted at the beginning of mEffects vector as
// they are processed first and accumulated in chain input buffer
mEffects.insertAt(effect, 0);
- sp<ThreadBase> thread = mThread.promote();
- if (thread == 0) {
- return NO_INIT;
- }
+
// the input buffer for auxiliary effect contains mono samples in
// 32 bit format. This is to avoid saturation in AudoMixer
// accumulation stage. Saturation is done in EffectModule::process() before
@@ -5860,7 +6049,7 @@
// check invalid effect chaining combinations
if (insertPref == EFFECT_FLAG_INSERT_EXCLUSIVE ||
iPref == EFFECT_FLAG_INSERT_EXCLUSIVE) {
- LOGW("addEffect() could not insert effect %s: exclusive conflict with %s", desc.name, d.name);
+ LOGW("addEffect_l() could not insert effect %s: exclusive conflict with %s", desc.name, d.name);
return INVALID_OPERATION;
}
// remember position of first insert effect and by default
@@ -5910,22 +6099,17 @@
effect->setOutBuffer(mInBuffer);
}
mEffects.insertAt(effect, idx_insert);
- // Always give volume control to last effect in chain with volume control capability
- if (((desc.flags & EFFECT_FLAG_VOLUME_MASK) & EFFECT_FLAG_VOLUME_CTRL) &&
- mVolumeCtrlIdx < idx_insert) {
- mVolumeCtrlIdx = idx_insert;
- }
- LOGV("addEffect() effect %p, added in chain %p at rank %d", effect.get(), this, idx_insert);
+ LOGV("addEffect_l() effect %p, added in chain %p at rank %d", effect.get(), this, idx_insert);
}
effect->configure();
return NO_ERROR;
}
-size_t AudioFlinger::EffectChain::removeEffect(const sp<EffectModule>& effect)
+// removeEffect_l() must be called with PlaybackThread::mLock held
+size_t AudioFlinger::EffectChain::removeEffect_l(const sp<EffectModule>& effect)
{
Mutex::Autolock _l(mLock);
-
int size = (int)mEffects.size();
int i;
uint32_t type = effect->desc().flags & EFFECT_FLAG_TYPE_MASK;
@@ -5941,26 +6125,16 @@
}
}
mEffects.removeAt(i);
- LOGV("removeEffect() effect %p, removed from chain %p at rank %d", effect.get(), this, i);
+ LOGV("removeEffect_l() effect %p, removed from chain %p at rank %d", effect.get(), this, i);
break;
}
}
- // Return volume control to last effect in chain with volume control capability
- if (mVolumeCtrlIdx == i) {
- size = (int)mEffects.size();
- for (i = size; i > 0; i--) {
- if ((mEffects[i - 1]->desc().flags & EFFECT_FLAG_VOLUME_MASK) & EFFECT_FLAG_VOLUME_CTRL) {
- break;
- }
- }
- // mVolumeCtrlIdx reset to -1 if no effect found with volume control flag set
- mVolumeCtrlIdx = i - 1;
- }
return mEffects.size();
}
-void AudioFlinger::EffectChain::setDevice(uint32_t device)
+// setDevice_l() must be called with PlaybackThread::mLock held
+void AudioFlinger::EffectChain::setDevice_l(uint32_t device)
{
size_t size = mEffects.size();
for (size_t i = 0; i < size; i++) {
@@ -5968,7 +6142,8 @@
}
}
-void AudioFlinger::EffectChain::setMode(uint32_t mode)
+// setMode_l() must be called with PlaybackThread::mLock held
+void AudioFlinger::EffectChain::setMode_l(uint32_t mode)
{
size_t size = mEffects.size();
for (size_t i = 0; i < size; i++) {
@@ -5976,27 +6151,56 @@
}
}
-bool AudioFlinger::EffectChain::setVolume(uint32_t *left, uint32_t *right)
+// setVolume_l() must be called with PlaybackThread::mLock held
+bool AudioFlinger::EffectChain::setVolume_l(uint32_t *left, uint32_t *right)
{
uint32_t newLeft = *left;
uint32_t newRight = *right;
bool hasControl = false;
+ int ctrlIdx = -1;
+ size_t size = mEffects.size();
- // first get volume update from volume controller
- if (mVolumeCtrlIdx >= 0) {
- mEffects[mVolumeCtrlIdx]->setVolume(&newLeft, &newRight, true);
+ // first update volume controller
+ for (size_t i = size; i > 0; i--) {
+ if ((mEffects[i - 1]->state() >= EffectModule::ACTIVE) &&
+ (mEffects[i - 1]->desc().flags & EFFECT_FLAG_VOLUME_MASK) == EFFECT_FLAG_VOLUME_CTRL) {
+ ctrlIdx = i - 1;
+ hasControl = true;
+ break;
+ }
+ }
+
+ if (ctrlIdx == mVolumeCtrlIdx && *left == mLeftVolume && *right == mRightVolume) {
+ if (hasControl) {
+ *left = mNewLeftVolume;
+ *right = mNewRightVolume;
+ }
+ return hasControl;
+ }
+
+ if (mVolumeCtrlIdx != -1) {
hasControl = true;
}
+ mVolumeCtrlIdx = ctrlIdx;
+ mLeftVolume = newLeft;
+ mRightVolume = newRight;
+
+ // second get volume update from volume controller
+ if (ctrlIdx >= 0) {
+ mEffects[ctrlIdx]->setVolume(&newLeft, &newRight, true);
+ mNewLeftVolume = newLeft;
+ mNewRightVolume = newRight;
+ }
// then indicate volume to all other effects in chain.
// Pass altered volume to effects before volume controller
// and requested volume to effects after controller
uint32_t lVol = newLeft;
uint32_t rVol = newRight;
- size_t size = mEffects.size();
+
for (size_t i = 0; i < size; i++) {
- if ((int)i == mVolumeCtrlIdx) continue;
- // this also works for mVolumeCtrlIdx == -1 when there is no volume controller
- if ((int)i > mVolumeCtrlIdx) {
+ if ((int)i == ctrlIdx) continue;
+ // this also works for ctrlIdx == -1 when there is no volume controller
+ if ((int)i > ctrlIdx) {
lVol = *left;
rVol = *right;
}
@@ -6008,16 +6212,6 @@
return hasControl;
}
-sp<AudioFlinger::EffectModule> AudioFlinger::EffectChain::getVolumeController()
-{
- sp<EffectModule> effect;
- if (mVolumeCtrlIdx >= 0) {
- effect = mEffects[mVolumeCtrlIdx];
- }
- return effect;
-}
-
-
status_t AudioFlinger::EffectChain::dump(int fd, const Vector<String16>& args)
{
const size_t SIZE = 256;
@@ -6033,12 +6227,11 @@
result.append("\tCould not lock mutex:\n");
}
- result.append("\tNum fx In buffer Out buffer Vol ctrl Active tracks:\n");
- snprintf(buffer, SIZE, "\t%02d 0x%08x 0x%08x %02d %d\n",
+ result.append("\tNum fx In buffer Out buffer Active tracks:\n");
+ snprintf(buffer, SIZE, "\t%02d 0x%08x 0x%08x %d\n",
mEffects.size(),
(uint32_t)mInBuffer,
(uint32_t)mOutBuffer,
- (mVolumeCtrlIdx == -1) ? 0 : mEffects[mVolumeCtrlIdx]->id(),
mActiveTrackCnt);
result.append(buffer);
write(fd, result.string(), result.size());
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index 7013d76..a8c9a92 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -168,8 +168,7 @@
int *id,
int *enabled);
- status_t registerEffectResource_l(effect_descriptor_t *desc);
- void unregisterEffectResource_l(effect_descriptor_t *desc);
+ virtual status_t moveEffects(int session, int srcOutput, int dstOutput);
enum hardware_call_state {
AUDIO_HW_IDLE = 0,
@@ -619,15 +618,22 @@
sp<EffectChain> getEffectChain_l(int sessionId);
status_t addEffectChain_l(const sp<EffectChain>& chain);
size_t removeEffectChain_l(const sp<EffectChain>& chain);
- void lockEffectChains_l();
- void unlockEffectChains();
+ void lockEffectChains_l(Vector<sp <EffectChain> >& effectChains);
+ void unlockEffectChains(Vector<sp <EffectChain> >& effectChains);
sp<AudioFlinger::EffectModule> getEffect_l(int sessionId, int effectId);
void detachAuxEffect_l(int effectId);
- status_t attachAuxEffect(const sp<AudioFlinger::PlaybackThread::Track> track, int EffectId);
- status_t attachAuxEffect_l(const sp<AudioFlinger::PlaybackThread::Track> track, int EffectId);
+ status_t attachAuxEffect(const sp<AudioFlinger::PlaybackThread::Track> track,
+ int EffectId);
+ status_t attachAuxEffect_l(const sp<AudioFlinger::PlaybackThread::Track> track,
+ int EffectId);
void setMode(uint32_t mode);
+ status_t addEffect_l(const sp< EffectModule>& effect);
+ void removeEffect_l(const sp< EffectModule>& effect);
+
+ uint32_t getStrategyForSession_l(int sessionId);
+
struct stream_type_t {
stream_type_t()
: volume(1.0f),
@@ -690,7 +696,10 @@
class MixerThread : public PlaybackThread {
public:
- MixerThread (const sp<AudioFlinger>& audioFlinger, AudioStreamOut* output, int id, uint32_t device);
+ MixerThread (const sp<AudioFlinger>& audioFlinger,
+ AudioStreamOut* output,
+ int id,
+ uint32_t device);
virtual ~MixerThread();
// Thread virtuals
@@ -701,7 +710,8 @@
virtual status_t dumpInternals(int fd, const Vector<String16>& args);
protected:
- uint32_t prepareTracks_l(const SortedVector< wp<Track> >& activeTracks, Vector< sp<Track> > *tracksToRemove);
+ uint32_t prepareTracks_l(const SortedVector< wp<Track> >& activeTracks,
+ Vector< sp<Track> > *tracksToRemove);
virtual int getTrackName_l();
virtual void deleteTrackName_l(int name);
virtual uint32_t activeSleepTimeUs();
@@ -764,6 +774,9 @@
void audioConfigChanged_l(int event, int ioHandle, void *param2);
int nextUniqueId();
+ status_t moveEffectChain_l(int session,
+ AudioFlinger::PlaybackThread *srcThread,
+ AudioFlinger::PlaybackThread *dstThread);
friend class AudioBuffer;
@@ -931,6 +944,9 @@
uint32_t status() {
return mStatus;
}
+ int sessionId() {
+ return mSessionId;
+ }
status_t setEnabled(bool enabled);
bool isEnabled();
@@ -938,6 +954,8 @@
int16_t *inBuffer() { return mConfig.inputCfg.buffer.s16; }
void setOutBuffer(int16_t *buffer) { mConfig.outputCfg.buffer.s16 = buffer; }
int16_t *outBuffer() { return mConfig.outputCfg.buffer.s16; }
+ void setChain(const wp<EffectChain>& chain) { mChain = chain; }
+ void setThread(const wp<ThreadBase>& thread) { mThread = thread; }
status_t addHandle(sp<EffectHandle>& handle);
void disconnect(const wp<EffectHandle>& handle);
@@ -1061,19 +1079,18 @@
mLock.unlock();
}
- status_t addEffect(sp<EffectModule>& handle);
- size_t removeEffect(const sp<EffectModule>& handle);
+ status_t addEffect_l(const sp<EffectModule>& handle);
+ size_t removeEffect_l(const sp<EffectModule>& handle);
int sessionId() {
return mSessionId;
}
- sp<EffectModule> getEffectFromDesc(effect_descriptor_t *descriptor);
- sp<EffectModule> getEffectFromId(int id);
- sp<EffectModule> getVolumeController();
- bool setVolume(uint32_t *left, uint32_t *right);
- void setDevice(uint32_t device);
- void setMode(uint32_t mode);
+ sp<EffectModule> getEffectFromDesc_l(effect_descriptor_t *descriptor);
+ sp<EffectModule> getEffectFromId_l(int id);
+ bool setVolume_l(uint32_t *left, uint32_t *right);
+ void setDevice_l(uint32_t device);
+ void setMode_l(uint32_t mode);
void setInBuffer(int16_t *buffer, bool ownsBuffer = false) {
mInBuffer = buffer;
@@ -1093,6 +1110,10 @@
void stopTrack() {mActiveTrackCnt--;}
int activeTracks() { return mActiveTrackCnt;}
+ uint32_t strategy() { return mStrategy; }
+ void setStrategy(uint32_t strategy)
+ { mStrategy = strategy; }
+
status_t dump(int fd, const Vector<String16>& args);
protected:
@@ -1106,9 +1127,14 @@
int mSessionId; // audio session ID
int16_t *mInBuffer; // chain input buffer
int16_t *mOutBuffer; // chain output buffer
- int mVolumeCtrlIdx; // index of insert effect having control over volume
int mActiveTrackCnt; // number of active tracks connected
bool mOwnInBuffer; // true if the chain owns its input buffer
+ int mVolumeCtrlIdx; // index of insert effect having control over volume
+ uint32_t mLeftVolume; // previous volume on left channel
+ uint32_t mRightVolume; // previous volume on right channel
+ uint32_t mNewLeftVolume; // new volume on left channel
+ uint32_t mNewRightVolume; // new volume on right channel
+ uint32_t mStrategy; // strategy for this effect chain
};
friend class RecordThread;
@@ -1138,12 +1164,6 @@
#endif
uint32_t mMode;
- // Maximum CPU load allocated to audio effects in 0.1 MIPS (ARMv5TE, 0 WS memory) units
- static const uint32_t MAX_EFFECTS_CPU_LOAD = 1000;
- // Maximum memory allocated to audio effects in KB
- static const uint32_t MAX_EFFECTS_MEMORY = 512;
- uint32_t mTotalEffectsCpuLoad; // current CPU load used by effects
- uint32_t mTotalEffectsMemory; // current memory used by effects
};
// ----------------------------------------------------------------------------
diff --git a/services/audioflinger/AudioPolicyManagerBase.cpp b/services/audioflinger/AudioPolicyManagerBase.cpp
index 381a958..1d87c0d 100644
--- a/services/audioflinger/AudioPolicyManagerBase.cpp
+++ b/services/audioflinger/AudioPolicyManagerBase.cpp
@@ -538,9 +538,11 @@
return output;
}
-status_t AudioPolicyManagerBase::startOutput(audio_io_handle_t output, AudioSystem::stream_type stream)
+status_t AudioPolicyManagerBase::startOutput(audio_io_handle_t output,
+ AudioSystem::stream_type stream,
+ int session)
{
- LOGV("startOutput() output %d, stream %d", output, stream);
+ LOGV("startOutput() output %d, stream %d, session %d", output, stream, session);
ssize_t index = mOutputs.indexOfKey(output);
if (index < 0) {
LOGW("startOutput() unknow output %d", output);
@@ -574,9 +576,11 @@
return NO_ERROR;
}
-status_t AudioPolicyManagerBase::stopOutput(audio_io_handle_t output, AudioSystem::stream_type stream)
+status_t AudioPolicyManagerBase::stopOutput(audio_io_handle_t output,
+ AudioSystem::stream_type stream,
+ int session)
{
- LOGV("stopOutput() output %d, stream %d", output, stream);
+ LOGV("stopOutput() output %d, stream %d, session %d", output, stream, session);
ssize_t index = mOutputs.indexOfKey(output);
if (index < 0) {
LOGW("stopOutput() unknow output %d", output);
@@ -602,8 +606,12 @@
setOutputDevice(output, getNewDevice(output));
#ifdef WITH_A2DP
- if (mA2dpOutput != 0 && !a2dpUsedForSonification() && strategy == STRATEGY_SONIFICATION) {
- setStrategyMute(STRATEGY_MEDIA, false, mA2dpOutput, mOutputs.valueFor(mHardwareOutput)->mLatency*2);
+ if (mA2dpOutput != 0 && !a2dpUsedForSonification() &&
+ strategy == STRATEGY_SONIFICATION) {
+ setStrategyMute(STRATEGY_MEDIA,
+ false,
+ mA2dpOutput,
+ mOutputs.valueFor(mHardwareOutput)->mLatency*2);
}
#endif
if (output != mHardwareOutput) {
@@ -826,6 +834,85 @@
return NO_ERROR;
}
+audio_io_handle_t AudioPolicyManagerBase::getOutputForEffect(effect_descriptor_t *desc)
+{
+ LOGV("getOutputForEffect()");
+ // apply simple rule where global effects are attached to the same output as MUSIC streams
+ return getOutput(AudioSystem::MUSIC);
+}
+
+status_t AudioPolicyManagerBase::registerEffect(effect_descriptor_t *desc,
+ audio_io_handle_t output,
+ uint32_t strategy,
+ int session,
+ int id)
+{
+ ssize_t index = mOutputs.indexOfKey(output);
+ if (index < 0) {
+ LOGW("registerEffect() unknown output %d", output);
+ return INVALID_OPERATION;
+ }
+
+ if (mTotalEffectsCpuLoad + desc->cpuLoad > getMaxEffectsCpuLoad()) {
+ LOGW("registerEffect() CPU Load limit exceeded for Fx %s, CPU %f MIPS",
+ desc->name, (float)desc->cpuLoad/10);
+ return INVALID_OPERATION;
+ }
+ if (mTotalEffectsMemory + desc->memoryUsage > getMaxEffectsMemory()) {
+ LOGW("registerEffect() memory limit exceeded for Fx %s, Memory %d KB",
+ desc->name, desc->memoryUsage);
+ return INVALID_OPERATION;
+ }
+ mTotalEffectsCpuLoad += desc->cpuLoad;
+ mTotalEffectsMemory += desc->memoryUsage;
+ LOGV("registerEffect() effect %s, output %d, strategy %d session %d id %d",
+ desc->name, output, strategy, session, id);
+
+ LOGV("registerEffect() CPU %d, memory %d", desc->cpuLoad, desc->memoryUsage);
+ LOGV(" total CPU %d, total memory %d", mTotalEffectsCpuLoad, mTotalEffectsMemory);
+
+ EffectDescriptor *pDesc = new EffectDescriptor();
+ memcpy (&pDesc->mDesc, desc, sizeof(effect_descriptor_t));
+ pDesc->mOutput = output;
+ pDesc->mStrategy = (routing_strategy)strategy;
+ pDesc->mSession = session;
+ mEffects.add(id, pDesc);
+
+ return NO_ERROR;
+}
+
+status_t AudioPolicyManagerBase::unregisterEffect(int id)
+{
+ ssize_t index = mEffects.indexOfKey(id);
+ if (index < 0) {
+ LOGW("unregisterEffect() unknown effect ID %d", id);
+ return INVALID_OPERATION;
+ }
+
+ EffectDescriptor *pDesc = mEffects.valueAt(index);
+
+ if (mTotalEffectsCpuLoad < pDesc->mDesc.cpuLoad) {
+ LOGW("unregisterEffect() CPU load %d too high for total %d",
+ pDesc->mDesc.cpuLoad, mTotalEffectsCpuLoad);
+ pDesc->mDesc.cpuLoad = mTotalEffectsCpuLoad;
+ }
+ mTotalEffectsCpuLoad -= pDesc->mDesc.cpuLoad;
+ if (mTotalEffectsMemory < pDesc->mDesc.memoryUsage) {
+ LOGW("unregisterEffect() memory %d too big for total %d",
+ pDesc->mDesc.memoryUsage, mTotalEffectsMemory);
+ pDesc->mDesc.memoryUsage = mTotalEffectsMemory;
+ }
+ mTotalEffectsMemory -= pDesc->mDesc.memoryUsage;
+ LOGV("unregisterEffect() effect %s, ID %d, CPU %d, memory %d",
+ pDesc->mDesc.name, id, pDesc->mDesc.cpuLoad, pDesc->mDesc.memoryUsage);
+ LOGV(" total CPU %d, total memory %d", mTotalEffectsCpuLoad, mTotalEffectsMemory);
+
+ mEffects.removeItem(id);
+ delete pDesc;
+
+ return NO_ERROR;
+}
+
status_t AudioPolicyManagerBase::dump(int fd)
{
const size_t SIZE = 256;
@@ -890,6 +977,19 @@
write(fd, buffer, strlen(buffer));
}
+ snprintf(buffer, SIZE, "\nTotal Effects CPU: %f MIPS, Total Effects memory: %d KB\n",
+ (float)mTotalEffectsCpuLoad/10, mTotalEffectsMemory);
+ write(fd, buffer, strlen(buffer));
+
+ snprintf(buffer, SIZE, "Registered effects:\n");
+ write(fd, buffer, strlen(buffer));
+ for (size_t i = 0; i < mEffects.size(); i++) {
+ snprintf(buffer, SIZE, "- Effect %d dump:\n", mEffects.keyAt(i));
+ write(fd, buffer, strlen(buffer));
+ mEffects.valueAt(i)->dump(fd);
+ }
+
+
return NO_ERROR;
}
@@ -902,7 +1002,8 @@
#ifdef AUDIO_POLICY_TEST
Thread(false),
#endif //AUDIO_POLICY_TEST
- mPhoneState(AudioSystem::MODE_NORMAL), mRingerMode(0), mMusicStopTime(0), mLimitRingtoneVolume(false)
+ mPhoneState(AudioSystem::MODE_NORMAL), mRingerMode(0), mMusicStopTime(0),
+ mLimitRingtoneVolume(false), mTotalEffectsCpuLoad(0), mTotalEffectsMemory(0)
{
mpClientInterface = clientInterface;
@@ -938,6 +1039,7 @@
} else {
addOutput(mHardwareOutput, outputDesc);
setOutputDevice(mHardwareOutput, (uint32_t)AudioSystem::DEVICE_OUT_SPEAKER, true);
+ //TODO: configure audio effect output stage here
}
updateDeviceForStrategy();
@@ -1152,6 +1254,9 @@
if (mA2dpOutput) {
// add A2DP output descriptor
addOutput(mA2dpOutput, outputDesc);
+
+ //TODO: configure audio effect output stage here
+
// set initial stream volume for A2DP device
applyStreamVolumes(mA2dpOutput, device);
if (a2dpUsedForSonification()) {
@@ -1269,6 +1374,7 @@
AudioParameter param;
param.add(String8("closing"), String8("true"));
mpClientInterface->setParameters(mA2dpOutput, param.toString());
+
mpClientInterface->closeOutput(mA2dpOutput);
delete mOutputs.valueFor(mA2dpOutput);
mOutputs.removeItem(mA2dpOutput);
@@ -1282,48 +1388,54 @@
uint32_t curDevice = getDeviceForStrategy(strategy, false);
bool a2dpWasUsed = AudioSystem::isA2dpDevice((AudioSystem::audio_devices)(prevDevice & ~AudioSystem::DEVICE_OUT_SPEAKER));
bool a2dpIsUsed = AudioSystem::isA2dpDevice((AudioSystem::audio_devices)(curDevice & ~AudioSystem::DEVICE_OUT_SPEAKER));
- AudioOutputDescriptor *hwOutputDesc = mOutputs.valueFor(mHardwareOutput);
- AudioOutputDescriptor *a2dpOutputDesc;
+ audio_io_handle_t srcOutput = 0;
+ audio_io_handle_t dstOutput = 0;
if (a2dpWasUsed && !a2dpIsUsed) {
bool dupUsed = a2dpUsedForSonification() && a2dpWasUsed && (AudioSystem::popCount(prevDevice) == 2);
-
+ dstOutput = mHardwareOutput;
if (dupUsed) {
- LOGV("checkOutputForStrategy() moving strategy %d to duplicated", strategy);
- a2dpOutputDesc = mOutputs.valueFor(mDuplicatedOutput);
+ LOGV("checkOutputForStrategy() moving strategy %d from duplicated", strategy);
+ srcOutput = mDuplicatedOutput;
} else {
- LOGV("checkOutputForStrategy() moving strategy %d to a2dp", strategy);
- a2dpOutputDesc = mOutputs.valueFor(mA2dpOutput);
+ LOGV("checkOutputForStrategy() moving strategy %d from a2dp", strategy);
+ srcOutput = mA2dpOutput;
}
- for (int i = 0; i < (int)AudioSystem::NUM_STREAM_TYPES; i++) {
- if (getStrategy((AudioSystem::stream_type)i) == strategy) {
- mpClientInterface->setStreamOutput((AudioSystem::stream_type)i, mHardwareOutput);
- }
- }
// do not change newDevice if it was already set before this call by a previous call to
// getNewDevice() or checkOutputForStrategy() for a strategy with higher priority
- if (newDevice == 0 && hwOutputDesc->isUsedByStrategy(strategy)) {
+ if (newDevice == 0 && mOutputs.valueFor(mHardwareOutput)->isUsedByStrategy(strategy)) {
newDevice = getDeviceForStrategy(strategy, false);
}
}
if (a2dpIsUsed && !a2dpWasUsed) {
bool dupUsed = a2dpUsedForSonification() && a2dpIsUsed && (AudioSystem::popCount(curDevice) == 2);
- audio_io_handle_t a2dpOutput;
-
+ srcOutput = mHardwareOutput;
if (dupUsed) {
- LOGV("checkOutputForStrategy() moving strategy %d from duplicated", strategy);
- a2dpOutputDesc = mOutputs.valueFor(mDuplicatedOutput);
- a2dpOutput = mDuplicatedOutput;
+ LOGV("checkOutputForStrategy() moving strategy %d to duplicated", strategy);
+ dstOutput = mDuplicatedOutput;
} else {
- LOGV("checkOutputForStrategy() moving strategy %d from a2dp", strategy);
- a2dpOutputDesc = mOutputs.valueFor(mA2dpOutput);
- a2dpOutput = mA2dpOutput;
+ LOGV("checkOutputForStrategy() moving strategy %d to a2dp", strategy);
+ dstOutput = mA2dpOutput;
}
+ }
+ if (srcOutput != 0 && dstOutput != 0) {
+ // Move effects associated to this strategy from previous output to new output
+ for (size_t i = 0; i < mEffects.size(); i++) {
+ EffectDescriptor *desc = mEffects.valueAt(i);
+ if (desc->mSession != AudioSystem::SESSION_OUTPUT_STAGE &&
+ desc->mStrategy == strategy &&
+ desc->mOutput == srcOutput) {
+ LOGV("checkOutputForStrategy() moving effect %d to output %d", mEffects.keyAt(i), dstOutput);
+ mpClientInterface->moveEffects(desc->mSession, srcOutput, dstOutput);
+ desc->mOutput = dstOutput;
+ }
+ }
+ // Move tracks associated to this strategy from previous output to new output
for (int i = 0; i < (int)AudioSystem::NUM_STREAM_TYPES; i++) {
if (getStrategy((AudioSystem::stream_type)i) == strategy) {
- mpClientInterface->setStreamOutput((AudioSystem::stream_type)i, a2dpOutput);
+ mpClientInterface->setStreamOutput((AudioSystem::stream_type)i, dstOutput);
}
}
}
@@ -1371,8 +1483,12 @@
return device;
}
-AudioPolicyManagerBase::routing_strategy AudioPolicyManagerBase::getStrategy(AudioSystem::stream_type stream)
-{
+uint32_t AudioPolicyManagerBase::getStrategyForStream(AudioSystem::stream_type stream) {
+ return (uint32_t)getStrategy(stream);
+}
+
+AudioPolicyManagerBase::routing_strategy AudioPolicyManagerBase::getStrategy(
+ AudioSystem::stream_type stream) {
// stream to strategy mapping
switch (stream) {
case AudioSystem::VOICE_CALL:
@@ -1836,6 +1952,16 @@
(format !=0 && !AudioSystem::isLinearPCM(format)));
}
+uint32_t AudioPolicyManagerBase::getMaxEffectsCpuLoad()
+{
+ return MAX_EFFECTS_CPU_LOAD;
+}
+
+uint32_t AudioPolicyManagerBase::getMaxEffectsMemory()
+{
+ return MAX_EFFECTS_MEMORY;
+}
+
// --- AudioOutputDescriptor class implementation
AudioPolicyManagerBase::AudioOutputDescriptor::AudioOutputDescriptor()
@@ -1969,5 +2095,27 @@
mCanBeMuted);
}
+// --- EffectDescriptor class implementation
+
+status_t AudioPolicyManagerBase::EffectDescriptor::dump(int fd)
+{
+ const size_t SIZE = 256;
+ char buffer[SIZE];
+ String8 result;
+
+ snprintf(buffer, SIZE, " Output: %d\n", mOutput);
+ result.append(buffer);
+ snprintf(buffer, SIZE, " Strategy: %d\n", mStrategy);
+ result.append(buffer);
+ snprintf(buffer, SIZE, " Session: %d\n", mSession);
+ result.append(buffer);
+ snprintf(buffer, SIZE, " Name: %s\n", mDesc.name);
+ result.append(buffer);
+ write(fd, result.string(), result.size());
+
+ return NO_ERROR;
+}
+
+
}; // namespace android
diff --git a/services/audioflinger/AudioPolicyService.cpp b/services/audioflinger/AudioPolicyService.cpp
index bb3905c..f24e08e 100644
--- a/services/audioflinger/AudioPolicyService.cpp
+++ b/services/audioflinger/AudioPolicyService.cpp
@@ -119,7 +119,8 @@
if (!AudioSystem::isOutputDevice(device) && !AudioSystem::isInputDevice(device)) {
return BAD_VALUE;
}
- if (state != AudioSystem::DEVICE_STATE_AVAILABLE && state != AudioSystem::DEVICE_STATE_UNAVAILABLE) {
+ if (state != AudioSystem::DEVICE_STATE_AVAILABLE &&
+ state != AudioSystem::DEVICE_STATE_UNAVAILABLE) {
return BAD_VALUE;
}
@@ -128,8 +129,9 @@
return mpPolicyManager->setDeviceConnectionState(device, state, device_address);
}
-AudioSystem::device_connection_state AudioPolicyService::getDeviceConnectionState(AudioSystem::audio_devices device,
- const char *device_address)
+AudioSystem::device_connection_state AudioPolicyService::getDeviceConnectionState(
+ AudioSystem::audio_devices device,
+ const char *device_address)
{
if (mpPolicyManager == NULL) {
return AudioSystem::DEVICE_STATE_UNAVAILABLE;
@@ -175,7 +177,8 @@
return NO_ERROR;
}
-status_t AudioPolicyService::setForceUse(AudioSystem::force_use usage, AudioSystem::forced_config config)
+status_t AudioPolicyService::setForceUse(AudioSystem::force_use usage,
+ AudioSystem::forced_config config)
{
if (mpPolicyManager == NULL) {
return NO_INIT;
@@ -223,24 +226,28 @@
return mpPolicyManager->getOutput(stream, samplingRate, format, channels, flags);
}
-status_t AudioPolicyService::startOutput(audio_io_handle_t output, AudioSystem::stream_type stream)
+status_t AudioPolicyService::startOutput(audio_io_handle_t output,
+ AudioSystem::stream_type stream,
+ int session)
{
if (mpPolicyManager == NULL) {
return NO_INIT;
}
LOGV("startOutput() tid %d", gettid());
Mutex::Autolock _l(mLock);
- return mpPolicyManager->startOutput(output, stream);
+ return mpPolicyManager->startOutput(output, stream, session);
}
-status_t AudioPolicyService::stopOutput(audio_io_handle_t output, AudioSystem::stream_type stream)
+status_t AudioPolicyService::stopOutput(audio_io_handle_t output,
+ AudioSystem::stream_type stream,
+ int session)
{
if (mpPolicyManager == NULL) {
return NO_INIT;
}
LOGV("stopOutput() tid %d", gettid());
Mutex::Autolock _l(mLock);
- return mpPolicyManager->stopOutput(output, stream);
+ return mpPolicyManager->stopOutput(output, stream, session);
}
void AudioPolicyService::releaseOutput(audio_io_handle_t output)
@@ -339,8 +346,46 @@
return mpPolicyManager->getStreamVolumeIndex(stream, index);
}
+uint32_t AudioPolicyService::getStrategyForStream(AudioSystem::stream_type stream)
+{
+ if (mpPolicyManager == NULL) {
+ return 0;
+ }
+ return mpPolicyManager->getStrategyForStream(stream);
+}
+
+audio_io_handle_t AudioPolicyService::getOutputForEffect(effect_descriptor_t *desc)
+{
+ if (mpPolicyManager == NULL) {
+ return NO_INIT;
+ }
+ Mutex::Autolock _l(mLock);
+ return mpPolicyManager->getOutputForEffect(desc);
+}
+
+status_t AudioPolicyService::registerEffect(effect_descriptor_t *desc,
+ audio_io_handle_t output,
+ uint32_t strategy,
+ int session,
+ int id)
+{
+ if (mpPolicyManager == NULL) {
+ return NO_INIT;
+ }
+ return mpPolicyManager->registerEffect(desc, output, strategy, session, id);
+}
+
+status_t AudioPolicyService::unregisterEffect(int id)
+{
+ if (mpPolicyManager == NULL) {
+ return NO_INIT;
+ }
+ return mpPolicyManager->unregisterEffect(id);
+}
+
void AudioPolicyService::binderDied(const wp<IBinder>& who) {
- LOGW("binderDied() %p, tid %d, calling tid %d", who.unsafe_get(), gettid(), IPCThreadState::self()->getCallingPid());
+ LOGW("binderDied() %p, tid %d, calling tid %d", who.unsafe_get(), gettid(),
+ IPCThreadState::self()->getCallingPid());
}
static bool tryLock(Mutex& mutex)
@@ -447,10 +492,16 @@
return 0;
}
- return af->openOutput(pDevices, pSamplingRate, (uint32_t *)pFormat, pChannels, pLatencyMs, flags);
+ return af->openOutput(pDevices,
+ pSamplingRate,
+ (uint32_t *)pFormat,
+ pChannels,
+ pLatencyMs,
+ flags);
}
-audio_io_handle_t AudioPolicyService::openDuplicateOutput(audio_io_handle_t output1, audio_io_handle_t output2)
+audio_io_handle_t AudioPolicyService::openDuplicateOutput(audio_io_handle_t output1,
+ audio_io_handle_t output2)
{
sp<IAudioFlinger> af = AudioSystem::get_audio_flinger();
if (af == 0) {
@@ -514,12 +565,16 @@
return af->closeInput(input);
}
-status_t AudioPolicyService::setStreamVolume(AudioSystem::stream_type stream, float volume, audio_io_handle_t output, int delayMs)
+status_t AudioPolicyService::setStreamVolume(AudioSystem::stream_type stream,
+ float volume,
+ audio_io_handle_t output,
+ int delayMs)
{
return mAudioCommandThread->volumeCommand((int)stream, volume, (int)output, delayMs);
}
-status_t AudioPolicyService::setStreamOutput(AudioSystem::stream_type stream, audio_io_handle_t output)
+status_t AudioPolicyService::setStreamOutput(AudioSystem::stream_type stream,
+ audio_io_handle_t output)
{
sp<IAudioFlinger> af = AudioSystem::get_audio_flinger();
if (af == 0) return PERMISSION_DENIED;
@@ -527,8 +582,18 @@
return af->setStreamOutput(stream, output);
}
+status_t AudioPolicyService::moveEffects(int session, audio_io_handle_t srcOutput,
+ audio_io_handle_t dstOutput)
+{
+ sp<IAudioFlinger> af = AudioSystem::get_audio_flinger();
+ if (af == 0) return PERMISSION_DENIED;
-void AudioPolicyService::setParameters(audio_io_handle_t ioHandle, const String8& keyValuePairs, int delayMs)
+ return af->moveEffects(session, (int)srcOutput, (int)dstOutput);
+}
+
+void AudioPolicyService::setParameters(audio_io_handle_t ioHandle,
+ const String8& keyValuePairs,
+ int delayMs)
{
mAudioCommandThread->parametersCommand((int)ioHandle, keyValuePairs, delayMs);
}
@@ -539,7 +604,8 @@
return result;
}
-status_t AudioPolicyService::startTone(ToneGenerator::tone_type tone, AudioSystem::stream_type stream)
+status_t AudioPolicyService::startTone(ToneGenerator::tone_type tone,
+ AudioSystem::stream_type stream)
{
mTonePlaybackThread->startToneCommand(tone, stream);
return NO_ERROR;
@@ -623,8 +689,11 @@
}break;
case SET_VOLUME: {
VolumeData *data = (VolumeData *)command->mParam;
- LOGV("AudioCommandThread() processing set volume stream %d, volume %f, output %d", data->mStream, data->mVolume, data->mIO);
- command->mStatus = AudioSystem::setStreamVolume(data->mStream, data->mVolume, data->mIO);
+ LOGV("AudioCommandThread() processing set volume stream %d, \
+ volume %f, output %d", data->mStream, data->mVolume, data->mIO);
+ command->mStatus = AudioSystem::setStreamVolume(data->mStream,
+ data->mVolume,
+ data->mIO);
if (command->mWaitStatus) {
command->mCond.signal();
mWaitWorkCV.wait(mLock);
@@ -633,7 +702,8 @@
}break;
case SET_PARAMETERS: {
ParametersData *data = (ParametersData *)command->mParam;
- LOGV("AudioCommandThread() processing set parameters string %s, io %d", data->mKeyValuePairs.string(), data->mIO);
+ LOGV("AudioCommandThread() processing set parameters string %s, io %d",
+ data->mKeyValuePairs.string(), data->mIO);
command->mStatus = AudioSystem::setParameters(data->mIO, data->mKeyValuePairs);
if (command->mWaitStatus) {
command->mCond.signal();
@@ -643,7 +713,8 @@
}break;
case SET_VOICE_VOLUME: {
VoiceVolumeData *data = (VoiceVolumeData *)command->mParam;
- LOGV("AudioCommandThread() processing set voice volume volume %f", data->mVolume);
+ LOGV("AudioCommandThread() processing set voice volume volume %f",
+ data->mVolume);
command->mStatus = AudioSystem::setVoiceVolume(data->mVolume);
if (command->mWaitStatus) {
command->mCond.signal();
@@ -734,7 +805,10 @@
mWaitWorkCV.signal();
}
-status_t AudioPolicyService::AudioCommandThread::volumeCommand(int stream, float volume, int output, int delayMs)
+status_t AudioPolicyService::AudioCommandThread::volumeCommand(int stream,
+ float volume,
+ int output,
+ int delayMs)
{
status_t status = NO_ERROR;
@@ -752,7 +826,8 @@
}
Mutex::Autolock _l(mLock);
insertCommand_l(command, delayMs);
- LOGV("AudioCommandThread() adding set volume stream %d, volume %f, output %d", stream, volume, output);
+ LOGV("AudioCommandThread() adding set volume stream %d, volume %f, output %d",
+ stream, volume, output);
mWaitWorkCV.signal();
if (command->mWaitStatus) {
command->mCond.wait(mLock);
@@ -762,7 +837,9 @@
return status;
}
-status_t AudioPolicyService::AudioCommandThread::parametersCommand(int ioHandle, const String8& keyValuePairs, int delayMs)
+status_t AudioPolicyService::AudioCommandThread::parametersCommand(int ioHandle,
+ const String8& keyValuePairs,
+ int delayMs)
{
status_t status = NO_ERROR;
@@ -779,7 +856,8 @@
}
Mutex::Autolock _l(mLock);
insertCommand_l(command, delayMs);
- LOGV("AudioCommandThread() adding set parameter string %s, io %d ,delay %d", keyValuePairs.string(), ioHandle, delayMs);
+ LOGV("AudioCommandThread() adding set parameter string %s, io %d ,delay %d",
+ keyValuePairs.string(), ioHandle, delayMs);
mWaitWorkCV.signal();
if (command->mWaitStatus) {
command->mCond.wait(mLock);
@@ -840,7 +918,8 @@
ParametersData *data = (ParametersData *)command->mParam;
ParametersData *data2 = (ParametersData *)command2->mParam;
if (data->mIO != data2->mIO) break;
- LOGV("Comparing parameter command %s to new command %s", data2->mKeyValuePairs.string(), data->mKeyValuePairs.string());
+ LOGV("Comparing parameter command %s to new command %s",
+ data2->mKeyValuePairs.string(), data->mKeyValuePairs.string());
AudioParameter param = AudioParameter(data->mKeyValuePairs);
AudioParameter param2 = AudioParameter(data2->mKeyValuePairs);
for (size_t j = 0; j < param.size(); j++) {
@@ -872,7 +951,8 @@
VolumeData *data2 = (VolumeData *)command2->mParam;
if (data->mIO != data2->mIO) break;
if (data->mStream != data2->mStream) break;
- LOGV("Filtering out volume command on output %d for stream %d", data->mIO, data->mStream);
+ LOGV("Filtering out volume command on output %d for stream %d",
+ data->mIO, data->mStream);
removedCommands.add(command2);
} break;
case START_TONE:
@@ -896,7 +976,8 @@
removedCommands.clear();
// insert command at the right place according to its time stamp
- LOGV("inserting command: %d at index %d, num commands %d", command->mCommand, (int)i+1, mAudioCommands.size());
+ LOGV("inserting command: %d at index %d, num commands %d",
+ command->mCommand, (int)i+1, mAudioCommands.size());
mAudioCommands.insertAt(command, i + 1);
}
diff --git a/services/audioflinger/AudioPolicyService.h b/services/audioflinger/AudioPolicyService.h
index a13d0bd..558f455 100644
--- a/services/audioflinger/AudioPolicyService.h
+++ b/services/audioflinger/AudioPolicyService.h
@@ -28,7 +28,8 @@
// ----------------------------------------------------------------------------
-class AudioPolicyService: public BnAudioPolicyService, public AudioPolicyClientInterface, public IBinder::DeathRecipient
+class AudioPolicyService: public BnAudioPolicyService, public AudioPolicyClientInterface,
+ public IBinder::DeathRecipient
{
public:
@@ -43,8 +44,9 @@
virtual status_t setDeviceConnectionState(AudioSystem::audio_devices device,
AudioSystem::device_connection_state state,
const char *device_address);
- virtual AudioSystem::device_connection_state getDeviceConnectionState(AudioSystem::audio_devices device,
- const char *device_address);
+ virtual AudioSystem::device_connection_state getDeviceConnectionState(
+ AudioSystem::audio_devices device,
+ const char *device_address);
virtual status_t setPhoneState(int state);
virtual status_t setRingerMode(uint32_t mode, uint32_t mask);
virtual status_t setForceUse(AudioSystem::force_use usage, AudioSystem::forced_config config);
@@ -53,15 +55,21 @@
uint32_t samplingRate = 0,
uint32_t format = AudioSystem::FORMAT_DEFAULT,
uint32_t channels = 0,
- AudioSystem::output_flags flags = AudioSystem::OUTPUT_FLAG_INDIRECT);
- virtual status_t startOutput(audio_io_handle_t output, AudioSystem::stream_type stream);
- virtual status_t stopOutput(audio_io_handle_t output, AudioSystem::stream_type stream);
+ AudioSystem::output_flags flags =
+ AudioSystem::OUTPUT_FLAG_INDIRECT);
+ virtual status_t startOutput(audio_io_handle_t output,
+ AudioSystem::stream_type stream,
+ int session = 0);
+ virtual status_t stopOutput(audio_io_handle_t output,
+ AudioSystem::stream_type stream,
+ int session = 0);
virtual void releaseOutput(audio_io_handle_t output);
virtual audio_io_handle_t getInput(int inputSource,
uint32_t samplingRate = 0,
uint32_t format = AudioSystem::FORMAT_DEFAULT,
uint32_t channels = 0,
- AudioSystem::audio_in_acoustics acoustics = (AudioSystem::audio_in_acoustics)0);
+ AudioSystem::audio_in_acoustics acoustics =
+ (AudioSystem::audio_in_acoustics)0);
virtual status_t startInput(audio_io_handle_t input);
virtual status_t stopInput(audio_io_handle_t input);
virtual void releaseInput(audio_io_handle_t input);
@@ -71,6 +79,16 @@
virtual status_t setStreamVolumeIndex(AudioSystem::stream_type stream, int index);
virtual status_t getStreamVolumeIndex(AudioSystem::stream_type stream, int *index);
+ virtual uint32_t getStrategyForStream(AudioSystem::stream_type stream);
+
+ virtual audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc);
+ virtual status_t registerEffect(effect_descriptor_t *desc,
+ audio_io_handle_t output,
+ uint32_t strategy,
+ int session,
+ int id);
+ virtual status_t unregisterEffect(int id);
+
virtual status_t onTransact(
uint32_t code,
const Parcel& data,
@@ -89,7 +107,8 @@
uint32_t *pChannels,
uint32_t *pLatencyMs,
AudioSystem::output_flags flags);
- virtual audio_io_handle_t openDuplicateOutput(audio_io_handle_t output1, audio_io_handle_t output2);
+ virtual audio_io_handle_t openDuplicateOutput(audio_io_handle_t output1,
+ audio_io_handle_t output2);
virtual status_t closeOutput(audio_io_handle_t output);
virtual status_t suspendOutput(audio_io_handle_t output);
virtual status_t restoreOutput(audio_io_handle_t output);
@@ -99,13 +118,21 @@
uint32_t *pChannels,
uint32_t acoustics);
virtual status_t closeInput(audio_io_handle_t input);
- virtual status_t setStreamVolume(AudioSystem::stream_type stream, float volume, audio_io_handle_t output, int delayMs = 0);
+ virtual status_t setStreamVolume(AudioSystem::stream_type stream,
+ float volume,
+ audio_io_handle_t output,
+ int delayMs = 0);
virtual status_t setStreamOutput(AudioSystem::stream_type stream, audio_io_handle_t output);
- virtual void setParameters(audio_io_handle_t ioHandle, const String8& keyValuePairs, int delayMs = 0);
+ virtual void setParameters(audio_io_handle_t ioHandle,
+ const String8& keyValuePairs,
+ int delayMs = 0);
virtual String8 getParameters(audio_io_handle_t ioHandle, const String8& keys);
virtual status_t startTone(ToneGenerator::tone_type tone, AudioSystem::stream_type stream);
virtual status_t stopTone();
virtual status_t setVoiceVolume(float volume, int delayMs = 0);
+ virtual status_t moveEffects(int session,
+ audio_io_handle_t srcOutput,
+ audio_io_handle_t dstOutput);
private:
AudioPolicyService();
diff --git a/services/java/com/android/server/InputManager.java b/services/java/com/android/server/InputManager.java
index cdae27c..b4f46ab 100644
--- a/services/java/com/android/server/InputManager.java
+++ b/services/java/com/android/server/InputManager.java
@@ -56,8 +56,6 @@
private final Callbacks mCallbacks;
private final Context mContext;
private final WindowManagerService mWindowManagerService;
- private final PowerManager mPowerManager;
- private final PowerManagerService mPowerManagerService;
private int mTouchScreenConfig;
private int mKeyboardConfig;
@@ -77,14 +75,15 @@
private static native boolean nativeHasKeys(int[] keyCodes, boolean[] keyExists);
private static native void nativeRegisterInputChannel(InputChannel inputChannel);
private static native void nativeUnregisterInputChannel(InputChannel inputChannel);
- private static native int nativeInjectKeyEvent(KeyEvent event, int nature,
+ private static native int nativeInjectKeyEvent(KeyEvent event,
int injectorPid, int injectorUid, boolean sync, int timeoutMillis);
- private static native int nativeInjectMotionEvent(MotionEvent event, int nature,
+ private static native int nativeInjectMotionEvent(MotionEvent event,
int injectorPid, int injectorUid, boolean sync, int timeoutMillis);
private static native void nativeSetInputWindows(InputWindow[] windows);
private static native void nativeSetInputDispatchMode(boolean enabled, boolean frozen);
private static native void nativeSetFocusedApplication(InputApplication application);
private static native void nativePreemptInputDispatch();
+ private static native String nativeDump();
// Device class as defined by EventHub.
private static final int CLASS_KEYBOARD = 0x00000001;
@@ -100,14 +99,9 @@
static final int INPUT_EVENT_INJECTION_FAILED = 2;
static final int INPUT_EVENT_INJECTION_TIMED_OUT = 3;
- public InputManager(Context context,
- WindowManagerService windowManagerService,
- PowerManager powerManager,
- PowerManagerService powerManagerService) {
+ public InputManager(Context context, WindowManagerService windowManagerService) {
this.mContext = context;
this.mWindowManagerService = windowManagerService;
- this.mPowerManager = powerManager;
- this.mPowerManagerService = powerManagerService;
this.mCallbacks = new Callbacks();
@@ -229,14 +223,13 @@
* to be dispatched before it can determine whether input event injection will be
* permitted based on the current input focus.
* @param event The event to inject.
- * @param nature The nature of the event.
* @param injectorPid The pid of the injecting application.
* @param injectorUid The uid of the injecting application.
* @param sync If true, waits for the event to be completed before returning.
* @param timeoutMillis The injection timeout in milliseconds.
* @return One of the INPUT_EVENT_INJECTION_XXX constants.
*/
- public int injectKeyEvent(KeyEvent event, int nature, int injectorPid, int injectorUid,
+ public int injectKeyEvent(KeyEvent event, int injectorPid, int injectorUid,
boolean sync, int timeoutMillis) {
if (event == null) {
throw new IllegalArgumentException("event must not be null");
@@ -248,7 +241,7 @@
throw new IllegalArgumentException("timeoutMillis must be positive");
}
- return nativeInjectKeyEvent(event, nature, injectorPid, injectorUid,
+ return nativeInjectKeyEvent(event, injectorPid, injectorUid,
sync, timeoutMillis);
}
@@ -258,7 +251,6 @@
* to be dispatched before it can determine whether input event injection will be
* permitted based on the current input focus.
* @param event The event to inject.
- * @param nature The nature of the event.
* @param sync If true, waits for the event to be completed before returning.
* @param injectorPid The pid of the injecting application.
* @param injectorUid The uid of the injecting application.
@@ -266,7 +258,7 @@
* @param timeoutMillis The injection timeout in milliseconds.
* @return One of the INPUT_EVENT_INJECTION_XXX constants.
*/
- public int injectMotionEvent(MotionEvent event, int nature, int injectorPid, int injectorUid,
+ public int injectMotionEvent(MotionEvent event, int injectorPid, int injectorUid,
boolean sync, int timeoutMillis) {
if (event == null) {
throw new IllegalArgumentException("event must not be null");
@@ -278,7 +270,7 @@
throw new IllegalArgumentException("timeoutMillis must be positive");
}
- return nativeInjectMotionEvent(event, nature, injectorPid, injectorUid,
+ return nativeInjectMotionEvent(event, injectorPid, injectorUid,
sync, timeoutMillis);
}
@@ -299,7 +291,10 @@
}
public void dump(PrintWriter pw) {
- // TODO
+ String dumpStr = nativeDump();
+ if (dumpStr != null) {
+ pw.println(dumpStr);
+ }
}
private static final class VirtualKeyDefinition {
diff --git a/services/java/com/android/server/LocationManagerService.java b/services/java/com/android/server/LocationManagerService.java
index 8519e2c..3bcf427 100644
--- a/services/java/com/android/server/LocationManagerService.java
+++ b/services/java/com/android/server/LocationManagerService.java
@@ -1613,8 +1613,6 @@
}
} catch (SecurityException se) {
throw se;
- } catch (IllegalArgumentException iae) {
- throw iae;
} catch (Exception e) {
Slog.e(TAG, "isProviderEnabled got exception:", e);
return false;
@@ -1638,7 +1636,7 @@
LocationProviderInterface p = mProvidersByName.get(provider);
if (p == null) {
- throw new IllegalArgumentException("provider=" + provider);
+ return false;
}
return isAllowedBySettingsLocked(provider);
}
@@ -1650,8 +1648,6 @@
}
} catch (SecurityException se) {
throw se;
- } catch (IllegalArgumentException iae) {
- throw iae;
} catch (Exception e) {
Slog.e(TAG, "getLastKnownLocation got exception:", e);
return null;
@@ -1663,7 +1659,7 @@
LocationProviderInterface p = mProvidersByName.get(provider);
if (p == null) {
- throw new IllegalArgumentException("provider=" + provider);
+ return null;
}
if (!isAllowedBySettingsLocked(provider)) {
diff --git a/services/java/com/android/server/MountService.java b/services/java/com/android/server/MountService.java
index 6c2f1b2..d7b92ec 100644
--- a/services/java/com/android/server/MountService.java
+++ b/services/java/com/android/server/MountService.java
@@ -23,11 +23,14 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
+import android.content.res.ObbInfo;
+import android.content.res.ObbScanner;
import android.net.Uri;
import android.os.storage.IMountService;
import android.os.storage.IMountServiceListener;
import android.os.storage.IMountShutdownObserver;
import android.os.storage.StorageResultCode;
+import android.os.Binder;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
@@ -53,7 +56,8 @@
private static final boolean LOCAL_LOGD = false;
private static final boolean DEBUG_UNMOUNT = false;
private static final boolean DEBUG_EVENTS = false;
-
+ private static final boolean DEBUG_OBB = true;
+
private static final String TAG = "MountService";
/*
@@ -130,6 +134,12 @@
*/
final private HashSet<String> mAsecMountSet = new HashSet<String>();
+ /**
+ * Private hash of currently mounted filesystem images.
+ */
+ final private HashSet<String> mObbMountSet = new HashSet<String>();
+
+ // Handler messages
private static final int H_UNMOUNT_PM_UPDATE = 1;
private static final int H_UNMOUNT_PM_DONE = 2;
private static final int H_UNMOUNT_MS = 3;
@@ -287,7 +297,7 @@
Slog.w(TAG, "Waiting too long for mReady!");
}
}
-
+
private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
@@ -344,7 +354,7 @@
MountServiceBinderListener(IMountServiceListener listener) {
mListener = listener;
-
+
}
public void binderDied() {
@@ -1327,5 +1337,145 @@
public void finishMediaUpdate() {
mHandler.sendEmptyMessage(H_UNMOUNT_PM_DONE);
}
+
+ private boolean isCallerOwnerOfPackage(String packageName) {
+ final int callerUid = Binder.getCallingUid();
+ return isUidOwnerOfPackage(packageName, callerUid);
+ }
+
+ private boolean isUidOwnerOfPackage(String packageName, int callerUid) {
+ if (packageName == null) {
+ return false;
+ }
+
+ final int packageUid = mPms.getPackageUid(packageName);
+
+ if (DEBUG_OBB) {
+ Slog.d(TAG, "packageName = " + packageName + ", packageUid = " +
+ packageUid + ", callerUid = " + callerUid);
+ }
+
+ return callerUid == packageUid;
+ }
+
+ public String getMountedObbPath(String filename) {
+ waitForReady();
+ warnOnNotMounted();
+
+ // XXX replace with call to IMediaContainerService
+ ObbInfo obbInfo = ObbScanner.getObbInfo(filename);
+ if (!isCallerOwnerOfPackage(obbInfo.packageName)) {
+ throw new IllegalArgumentException("Caller package does not match OBB file");
+ }
+
+ try {
+ ArrayList<String> rsp = mConnector.doCommand(String.format("obb path %s", filename));
+ String []tok = rsp.get(0).split(" ");
+ int code = Integer.parseInt(tok[0]);
+ if (code != VoldResponseCode.AsecPathResult) {
+ throw new IllegalStateException(String.format("Unexpected response code %d", code));
+ }
+ return tok[1];
+ } catch (NativeDaemonConnectorException e) {
+ int code = e.getCode();
+ if (code == VoldResponseCode.OpFailedStorageNotFound) {
+ throw new IllegalArgumentException(String.format("OBB '%s' not found", filename));
+ } else {
+ throw new IllegalStateException(String.format("Unexpected response code %d", code));
+ }
+ }
+ }
+
+ public boolean isObbMounted(String filename) {
+ waitForReady();
+ warnOnNotMounted();
+
+ // XXX replace with call to IMediaContainerService
+ ObbInfo obbInfo = ObbScanner.getObbInfo(filename);
+ if (!isCallerOwnerOfPackage(obbInfo.packageName)) {
+ throw new IllegalArgumentException("Caller package does not match OBB file");
+ }
+
+ synchronized (mObbMountSet) {
+ return mObbMountSet.contains(filename);
+ }
+ }
+
+ public int mountObb(String filename, String key) {
+ waitForReady();
+ warnOnNotMounted();
+
+ synchronized (mObbMountSet) {
+ if (mObbMountSet.contains(filename)) {
+ return StorageResultCode.OperationFailedStorageMounted;
+ }
+ }
+
+ final int callerUid = Binder.getCallingUid();
+
+ // XXX replace with call to IMediaContainerService
+ ObbInfo obbInfo = ObbScanner.getObbInfo(filename);
+ if (!isUidOwnerOfPackage(obbInfo.packageName, callerUid)) {
+ throw new IllegalArgumentException("Caller package does not match OBB file");
+ }
+
+ if (key == null) {
+ key = "none";
+ }
+
+ int rc = StorageResultCode.OperationSucceeded;
+ String cmd = String.format("obb mount %s %s %d", filename, key, callerUid);
+ try {
+ mConnector.doCommand(cmd);
+ } catch (NativeDaemonConnectorException e) {
+ int code = e.getCode();
+ if (code != VoldResponseCode.OpFailedStorageBusy) {
+ rc = StorageResultCode.OperationFailedInternalError;
+ }
+ }
+
+ if (rc == StorageResultCode.OperationSucceeded) {
+ synchronized (mObbMountSet) {
+ mObbMountSet.add(filename);
+ }
+ }
+ return rc;
+ }
+
+ public int unmountObb(String filename, boolean force) {
+ waitForReady();
+ warnOnNotMounted();
+
+ ObbInfo obbInfo = ObbScanner.getObbInfo(filename);
+ if (!isCallerOwnerOfPackage(obbInfo.packageName)) {
+ throw new IllegalArgumentException("Caller package does not match OBB file");
+ }
+
+ synchronized (mObbMountSet) {
+ if (!mObbMountSet.contains(filename)) {
+ return StorageResultCode.OperationFailedStorageNotMounted;
+ }
+ }
+
+ int rc = StorageResultCode.OperationSucceeded;
+ String cmd = String.format("obb unmount %s%s", filename, (force ? " force" : ""));
+ try {
+ mConnector.doCommand(cmd);
+ } catch (NativeDaemonConnectorException e) {
+ int code = e.getCode();
+ if (code == VoldResponseCode.OpFailedStorageBusy) {
+ rc = StorageResultCode.OperationFailedStorageBusy;
+ } else {
+ rc = StorageResultCode.OperationFailedInternalError;
+ }
+ }
+
+ if (rc == StorageResultCode.OperationSucceeded) {
+ synchronized (mObbMountSet) {
+ mObbMountSet.remove(filename);
+ }
+ }
+ return rc;
+ }
}
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java
index c6e5cd24..2e28afb 100644
--- a/services/java/com/android/server/WindowManagerService.java
+++ b/services/java/com/android/server/WindowManagerService.java
@@ -102,6 +102,7 @@
import android.view.IWindowManager;
import android.view.IWindowSession;
import android.view.InputChannel;
+import android.view.InputDevice;
import android.view.InputQueue;
import android.view.KeyEvent;
import android.view.MotionEvent;
@@ -331,7 +332,7 @@
/**
* Z-ordered (bottom-most first) list of all Window objects.
*/
- final ArrayList mWindows = new ArrayList();
+ final ArrayList<WindowState> mWindows = new ArrayList<WindowState>();
/**
* Windows that are being resized. Used so we can tell the client about
@@ -629,7 +630,7 @@
"KEEP_SCREEN_ON_FLAG");
mHoldingScreenWakeLock.setReferenceCounted(false);
- mInputManager = new InputManager(context, this, pmc, mPowerManager);
+ mInputManager = new InputManager(context, this);
PolicyThread thr = new PolicyThread(mPolicy, this, context, pm);
thr.start();
@@ -664,7 +665,7 @@
}
}
- private void placeWindowAfter(Object pos, WindowState window) {
+ private void placeWindowAfter(WindowState pos, WindowState window) {
final int i = mWindows.indexOf(pos);
if (DEBUG_FOCUS || DEBUG_WINDOW_MOVEMENT) Slog.v(
TAG, "Adding window " + window + " at "
@@ -673,7 +674,7 @@
mWindowsChanged = true;
}
- private void placeWindowBefore(Object pos, WindowState window) {
+ private void placeWindowBefore(WindowState pos, WindowState window) {
final int i = mWindows.indexOf(pos);
if (DEBUG_FOCUS || DEBUG_WINDOW_MOVEMENT) Slog.v(
TAG, "Adding window " + window + " at "
@@ -686,13 +687,13 @@
//win. used for z ordering the windows in mWindows
private int findIdxBasedOnAppTokens(WindowState win) {
//use a local variable to cache mWindows
- ArrayList localmWindows = mWindows;
+ ArrayList<WindowState> localmWindows = mWindows;
int jmax = localmWindows.size();
if(jmax == 0) {
return -1;
}
for(int j = (jmax-1); j >= 0; j--) {
- WindowState wentry = (WindowState)localmWindows.get(j);
+ WindowState wentry = localmWindows.get(j);
if(wentry.mAppToken == win.mAppToken) {
return j;
}
@@ -703,7 +704,7 @@
private void addWindowToListInOrderLocked(WindowState win, boolean addToToken) {
final IWindow client = win.mClient;
final WindowToken token = win.mToken;
- final ArrayList localmWindows = mWindows;
+ final ArrayList<WindowState> localmWindows = mWindows;
final int N = localmWindows.size();
final WindowState attached = win.mAttachedWindow;
@@ -748,7 +749,7 @@
// Figure out where the window should go, based on the
// order of applications.
final int NA = mAppTokens.size();
- Object pos = null;
+ WindowState pos = null;
for (i=NA-1; i>=0; i--) {
AppWindowToken t = mAppTokens.get(i);
if (t == token) {
@@ -768,8 +769,7 @@
// we need to look some more.
if (pos != null) {
// Move behind any windows attached to this one.
- WindowToken atoken =
- mTokenMap.get(((WindowState)pos).mClient.asBinder());
+ WindowToken atoken = mTokenMap.get(pos.mClient.asBinder());
if (atoken != null) {
final int NC = atoken.windows.size();
if (NC > 0) {
@@ -795,8 +795,7 @@
if (pos != null) {
// Move in front of any windows attached to this
// one.
- WindowToken atoken =
- mTokenMap.get(((WindowState)pos).mClient.asBinder());
+ WindowToken atoken = mTokenMap.get(pos.mClient.asBinder());
if (atoken != null) {
final int NC = atoken.windows.size();
if (NC > 0) {
@@ -811,7 +810,7 @@
// Just search for the start of this layer.
final int myLayer = win.mBaseLayer;
for (i=0; i<N; i++) {
- WindowState w = (WindowState)localmWindows.get(i);
+ WindowState w = localmWindows.get(i);
if (w.mBaseLayer > myLayer) {
break;
}
@@ -828,7 +827,7 @@
// Figure out where window should go, based on layer.
final int myLayer = win.mBaseLayer;
for (i=N-1; i>=0; i--) {
- if (((WindowState)localmWindows.get(i)).mBaseLayer <= myLayer) {
+ if (localmWindows.get(i).mBaseLayer <= myLayer) {
i++;
break;
}
@@ -911,13 +910,13 @@
}
int findDesiredInputMethodWindowIndexLocked(boolean willMove) {
- final ArrayList localmWindows = mWindows;
+ final ArrayList<WindowState> localmWindows = mWindows;
final int N = localmWindows.size();
WindowState w = null;
int i = N;
while (i > 0) {
i--;
- w = (WindowState)localmWindows.get(i);
+ w = localmWindows.get(i);
//Slog.i(TAG, "Checking window @" + i + " " + w + " fl=0x"
// + Integer.toHexString(w.mAttrs.flags));
@@ -932,7 +931,7 @@
if (!willMove
&& w.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING
&& i > 0) {
- WindowState wb = (WindowState)localmWindows.get(i-1);
+ WindowState wb = localmWindows.get(i-1);
if (wb.mAppToken == w.mAppToken && canBeImeTarget(wb)) {
i--;
w = wb;
@@ -962,7 +961,7 @@
int pos = 0;
pos = localmWindows.indexOf(curTarget);
while (pos >= 0) {
- WindowState win = (WindowState)localmWindows.get(pos);
+ WindowState win = localmWindows.get(pos);
if (win.mAppToken != token) {
break;
}
@@ -1067,7 +1066,7 @@
int wi = imw.mChildWindows.size();
while (wi > 0) {
wi--;
- WindowState cw = (WindowState)imw.mChildWindows.get(wi);
+ WindowState cw = imw.mChildWindows.get(wi);
cw.mAnimLayer = cw.mLayer + adj;
if (DEBUG_LAYERS) Slog.v(TAG, "IM win " + cw
+ " anim layer: " + cw.mAnimLayer);
@@ -1093,7 +1092,7 @@
int NC = win.mChildWindows.size();
while (NC > 0) {
NC--;
- WindowState cw = (WindowState)win.mChildWindows.get(NC);
+ WindowState cw = win.mChildWindows.get(NC);
int cpos = mWindows.indexOf(cw);
if (cpos >= 0) {
if (cpos < interestingPos) interestingPos--;
@@ -1145,7 +1144,7 @@
if (pos >= 0) {
final AppWindowToken targetAppToken = mInputMethodTarget.mAppToken;
if (pos < mWindows.size()) {
- WindowState wp = (WindowState)mWindows.get(pos);
+ WindowState wp = mWindows.get(pos);
if (wp == mInputMethodWindow) {
pos++;
}
@@ -1189,14 +1188,14 @@
// located here, and contiguous.
final int N = mWindows.size();
WindowState firstImWin = imPos < N
- ? (WindowState)mWindows.get(imPos) : null;
+ ? mWindows.get(imPos) : null;
// Figure out the actual input method window that should be
// at the bottom of their stack.
WindowState baseImWin = imWin != null
? imWin : mInputMethodDialogs.get(0);
if (baseImWin.mChildWindows.size() > 0) {
- WindowState cw = (WindowState)baseImWin.mChildWindows.get(0);
+ WindowState cw = baseImWin.mChildWindows.get(0);
if (cw.mSubLayer < 0) baseImWin = cw;
}
@@ -1205,7 +1204,7 @@
// First find the top IM window.
int pos = imPos+1;
while (pos < N) {
- if (!((WindowState)mWindows.get(pos)).mIsImWindow) {
+ if (!(mWindows.get(pos)).mIsImWindow) {
break;
}
pos++;
@@ -1213,7 +1212,7 @@
pos++;
// Now there should be no more input method windows above.
while (pos < N) {
- if (((WindowState)mWindows.get(pos)).mIsImWindow) {
+ if ((mWindows.get(pos)).mIsImWindow) {
break;
}
pos++;
@@ -1301,7 +1300,7 @@
// First find top-most window that has asked to be on top of the
// wallpaper; all wallpapers go behind it.
- final ArrayList localmWindows = mWindows;
+ final ArrayList<WindowState> localmWindows = mWindows;
int N = localmWindows.size();
WindowState w = null;
WindowState foundW = null;
@@ -1311,7 +1310,7 @@
int i = N;
while (i > 0) {
i--;
- w = (WindowState)localmWindows.get(i);
+ w = localmWindows.get(i);
if ((w.mAttrs.type == WindowManager.LayoutParams.TYPE_WALLPAPER)) {
if (topCurW == null) {
topCurW = w;
@@ -1482,7 +1481,7 @@
// AND any starting window associated with it, AND below the
// maximum layer the policy allows for wallpapers.
while (foundI > 0) {
- WindowState wb = (WindowState)localmWindows.get(foundI-1);
+ WindowState wb = localmWindows.get(foundI-1);
if (wb.mBaseLayer < maxLayer &&
wb.mAttachedWindow != foundW &&
(wb.mAttrs.type != TYPE_APPLICATION_STARTING ||
@@ -1506,7 +1505,7 @@
} else {
// Okay i is the position immediately above the wallpaper. Look at
// what is below it for later.
- foundW = foundI > 0 ? (WindowState)localmWindows.get(foundI-1) : null;
+ foundW = foundI > 0 ? localmWindows.get(foundI-1) : null;
}
if (visible) {
@@ -1565,7 +1564,7 @@
if (wallpaper == foundW) {
foundI--;
foundW = foundI > 0
- ? (WindowState)localmWindows.get(foundI-1) : null;
+ ? localmWindows.get(foundI-1) : null;
continue;
}
@@ -2017,6 +2016,8 @@
+ ", surface=" + win.mSurface);
final long origId = Binder.clearCallingIdentity();
+
+ win.disposeInputChannel();
if (DEBUG_APP_TRANSITIONS) Slog.v(
TAG, "Remove " + win + ": mSurface=" + win.mSurface
@@ -2077,8 +2078,6 @@
}
private void removeWindowInnerLocked(Session session, WindowState win) {
- mInputMonitor.windowIsBeingRemovedLw(win);
-
win.mRemoved = true;
if (mInputMethodTarget == win) {
@@ -2157,6 +2156,8 @@
win.mAppToken.updateReportedVisibilityLocked();
}
}
+
+ mInputMonitor.updateInputWindowsLw();
}
private static void logSurface(WindowState w, String msg, RuntimeException where) {
@@ -2400,6 +2401,8 @@
outSurface.release();
}
} catch (Exception e) {
+ mInputMonitor.updateInputWindowsLw();
+
Slog.w(TAG, "Exception thrown when creating surface for client "
+ client + " (" + win.mAttrs.getTitle() + ")",
e);
@@ -2446,7 +2449,6 @@
applyAnimationLocked(win, transit, false)) {
focusMayChange = true;
win.mExiting = true;
- mInputMonitor.windowIsBecomingInvisibleLw(win);
} else if (win.isAnimating()) {
// Currently in a hide animation... turn this into
// an exit.
@@ -2541,6 +2543,8 @@
TAG, "Relayout of " + win + ": focusMayChange=" + focusMayChange);
inTouchMode = mInTouchMode;
+
+ mInputMonitor.updateInputWindowsLw();
}
if (configChanged) {
@@ -2907,7 +2911,6 @@
if (win.isVisibleNow()) {
applyAnimationLocked(win,
WindowManagerPolicy.TRANSIT_EXIT, false);
- mInputMonitor.windowIsBeingRemovedLw(win);
changed = true;
}
}
@@ -2925,6 +2928,7 @@
}
}
+ mInputMonitor.updateInputWindowsLw();
} else {
Slog.w(TAG, "Attempted to remove non-existing token: " + token);
}
@@ -2996,7 +3000,7 @@
public int getOrientationFromWindowsLocked() {
int pos = mWindows.size() - 1;
while (pos >= 0) {
- WindowState wtoken = (WindowState) mWindows.get(pos);
+ WindowState wtoken = mWindows.get(pos);
pos--;
if (wtoken.mAppToken != null) {
// We hit an application window. so the orientation will be determined by the
@@ -3550,7 +3554,6 @@
applyAnimationLocked(win,
WindowManagerPolicy.TRANSIT_EXIT, false);
}
- mInputMonitor.windowIsBecomingInvisibleLw(win);
changed = true;
}
}
@@ -3578,6 +3581,8 @@
if (performLayout) {
updateFocusedWindowLocked(UPDATE_FOCUS_WILL_PLACE_SURFACES);
performLayoutAndPlaceSurfacesLocked();
+ } else {
+ mInputMonitor.updateInputWindowsLw();
}
}
}
@@ -3865,7 +3870,7 @@
int j = win.mChildWindows.size();
while (j > 0) {
j--;
- WindowState cwin = (WindowState)win.mChildWindows.get(j);
+ WindowState cwin = win.mChildWindows.get(j);
if (DEBUG_WINDOW_MOVEMENT) Slog.v(TAG,
"Tmp removing child window " + cwin);
mWindows.remove(cwin);
@@ -3893,7 +3898,7 @@
int i = NW;
while (i > 0) {
i--;
- WindowState win = (WindowState)mWindows.get(i);
+ WindowState win = mWindows.get(i);
if (win.getAppToken() != null) {
return i+1;
}
@@ -3919,7 +3924,7 @@
int j = win.mChildWindows.size();
while (j > 0) {
j--;
- WindowState cwin = (WindowState)win.mChildWindows.get(j);
+ WindowState cwin = win.mChildWindows.get(j);
if (cwin.mSubLayer >= 0) {
for (int pos=NW-1; pos>=0; pos--) {
if (mWindows.get(pos) == cwin) {
@@ -3947,7 +3952,7 @@
final int NCW = win.mChildWindows.size();
boolean added = false;
for (int j=0; j<NCW; j++) {
- WindowState cwin = (WindowState)win.mChildWindows.get(j);
+ WindowState cwin = win.mChildWindows.get(j);
if (!added && cwin.mSubLayer >= 0) {
if (DEBUG_WINDOW_MOVEMENT) Slog.v(TAG, "Re-adding child window at "
+ index + ": " + cwin);
@@ -4231,7 +4236,7 @@
public void closeSystemDialogs(String reason) {
synchronized(mWindowMap) {
for (int i=mWindows.size()-1; i>=0; i--) {
- WindowState w = (WindowState)mWindows.get(i);
+ WindowState w = mWindows.get(i);
if (w.mSurface != null) {
try {
w.mClient.closeSystemDialogs(reason);
@@ -4415,7 +4420,7 @@
// have been drawn.
final int N = mWindows.size();
for (int i=0; i<N; i++) {
- WindowState w = (WindowState)mWindows.get(i);
+ WindowState w = mWindows.get(i);
if (w.isVisibleLw() && !w.mObscured
&& (w.mOrientationChanging || !w.isDrawnLw())) {
return;
@@ -4528,7 +4533,7 @@
Surface.setOrientation(0, rotation, animFlags);
}
for (int i=mWindows.size()-1; i>=0; i--) {
- WindowState w = (WindowState)mWindows.get(i);
+ WindowState w = mWindows.get(i);
if (w.mSurface != null) {
w.mOrientationChanging = true;
}
@@ -4684,11 +4689,10 @@
boolean result = true;
- Object[] windows;
+ WindowState[] windows;
synchronized (mWindowMap) {
- windows = new Object[mWindows.size()];
//noinspection unchecked
- windows = mWindows.toArray(windows);
+ windows = mWindows.toArray(new WindowState[mWindows.size()]);
}
BufferedWriter out = null;
@@ -4700,7 +4704,7 @@
final int count = windows.length;
for (int i = 0; i < count; i++) {
- final WindowState w = (WindowState) windows[i];
+ final WindowState w = windows[i];
out.write(Integer.toHexString(System.identityHashCode(w)));
out.write(' ');
out.append(w.mAttrs.getTitle());
@@ -4853,11 +4857,11 @@
}
synchronized (mWindowMap) {
- final ArrayList windows = mWindows;
+ final ArrayList<WindowState> windows = mWindows;
final int count = windows.size();
for (int i = 0; i < count; i++) {
- WindowState w = (WindowState) windows.get(i);
+ WindowState w = windows.get(i);
if (System.identityHashCode(w) == hashCode) {
return w;
}
@@ -5091,7 +5095,7 @@
private WindowState getWindowStateForInputChannelLocked(InputChannel inputChannel) {
int windowCount = mWindows.size();
for (int i = 0; i < windowCount; i++) {
- WindowState windowState = (WindowState) mWindows.get(i);
+ WindowState windowState = mWindows.get(i);
if (windowState.mInputChannel == inputChannel) {
return windowState;
}
@@ -5107,11 +5111,11 @@
// As an optimization, we could try to prune the list of windows but this turns
// out to be difficult because only the native code knows for sure which window
// currently has touch focus.
- final ArrayList windows = mWindows;
+ final ArrayList<WindowState> windows = mWindows;
final int N = windows.size();
for (int i = N - 1; i >= 0; i--) {
- final WindowState child = (WindowState) windows.get(i);
- if (child.mInputChannel == null) {
+ final WindowState child = windows.get(i);
+ if (child.mInputChannel == null || child.mRemoved) {
// Skip this window because it cannot possibly receive input.
continue;
}
@@ -5255,17 +5259,6 @@
}
}
- public void windowIsBecomingInvisibleLw(WindowState window) {
- // The window is becoming invisible. Preempt input dispatch in progress
- // so that the next window below can receive focus.
- if (window == mInputFocus) {
- mInputFocus = null;
- preemptInputDispatchLw();
- }
-
- updateInputWindowsLw();
- }
-
/* Tells the dispatcher to stop waiting for its current synchronous event targets.
* Essentially, just makes those dispatches asynchronous so a new dispatch cycle
* can begin.
@@ -5288,11 +5281,6 @@
}
}
- public void windowIsBeingRemovedLw(WindowState window) {
- // Window is being removed.
- updateInputWindowsLw();
- }
-
public void pauseDispatchingLw(WindowToken window) {
if (! window.paused) {
if (DEBUG_INPUT) {
@@ -5410,19 +5398,24 @@
int metaState = ev.getMetaState();
int deviceId = ev.getDeviceId();
int scancode = ev.getScanCode();
+ int source = ev.getSource();
+
+ if (source == InputDevice.SOURCE_UNKNOWN) {
+ source = InputDevice.SOURCE_KEYBOARD;
+ }
if (eventTime == 0) eventTime = SystemClock.uptimeMillis();
if (downTime == 0) downTime = eventTime;
KeyEvent newEvent = new KeyEvent(downTime, eventTime, action, code, repeatCount, metaState,
- deviceId, scancode, KeyEvent.FLAG_FROM_SYSTEM);
+ deviceId, scancode, KeyEvent.FLAG_FROM_SYSTEM, source);
final int pid = Binder.getCallingPid();
final int uid = Binder.getCallingUid();
final long ident = Binder.clearCallingIdentity();
final int result = mInputManager.injectKeyEvent(newEvent,
- InputQueue.INPUT_EVENT_NATURE_KEY, pid, uid, sync, INJECTION_TIMEOUT_MILLIS);
+ pid, uid, sync, INJECTION_TIMEOUT_MILLIS);
Binder.restoreCallingIdentity(ident);
return reportInjectionResult(result);
@@ -5442,8 +5435,13 @@
final int uid = Binder.getCallingUid();
final long ident = Binder.clearCallingIdentity();
- final int result = mInputManager.injectMotionEvent(ev,
- InputQueue.INPUT_EVENT_NATURE_TOUCH, pid, uid, sync, INJECTION_TIMEOUT_MILLIS);
+ MotionEvent newEvent = MotionEvent.obtain(ev);
+ if ((newEvent.getSource() & InputDevice.SOURCE_CLASS_POINTER) == 0) {
+ newEvent.setSource(InputDevice.SOURCE_TOUCHSCREEN);
+ }
+
+ final int result = mInputManager.injectMotionEvent(newEvent,
+ pid, uid, sync, INJECTION_TIMEOUT_MILLIS);
Binder.restoreCallingIdentity(ident);
return reportInjectionResult(result);
@@ -5463,8 +5461,13 @@
final int uid = Binder.getCallingUid();
final long ident = Binder.clearCallingIdentity();
- final int result = mInputManager.injectMotionEvent(ev,
- InputQueue.INPUT_EVENT_NATURE_TRACKBALL, pid, uid, sync, INJECTION_TIMEOUT_MILLIS);
+ MotionEvent newEvent = MotionEvent.obtain(ev);
+ if ((newEvent.getSource() & InputDevice.SOURCE_CLASS_TRACKBALL) == 0) {
+ newEvent.setSource(InputDevice.SOURCE_TRACKBALL);
+ }
+
+ final int result = mInputManager.injectMotionEvent(newEvent,
+ pid, uid, sync, INJECTION_TIMEOUT_MILLIS);
Binder.restoreCallingIdentity(ident);
return reportInjectionResult(result);
@@ -5766,7 +5769,7 @@
final WindowManager.LayoutParams mAttrs = new WindowManager.LayoutParams();
final DeathRecipient mDeathRecipient;
final WindowState mAttachedWindow;
- final ArrayList mChildWindows = new ArrayList();
+ final ArrayList<WindowState> mChildWindows = new ArrayList<WindowState>();
final int mBaseLayer;
final int mSubLayer;
final boolean mLayoutAttached;
@@ -6322,10 +6325,8 @@
int i = mChildWindows.size();
while (i > 0) {
i--;
- WindowState c = (WindowState)mChildWindows.get(i);
+ WindowState c = mChildWindows.get(i);
c.mAttachedHidden = true;
-
- mInputMonitor.windowIsBecomingInvisibleLw(c);
}
if (mReportDestroySurface) {
@@ -6435,7 +6436,7 @@
int i = mChildWindows.size();
while (i > 0) {
i--;
- WindowState c = (WindowState)mChildWindows.get(i);
+ WindowState c = mChildWindows.get(i);
if (c.mAttachedHidden) {
c.mAttachedHidden = false;
if (c.mSurface != null) {
@@ -6608,7 +6609,7 @@
final int N = mChildWindows.size();
for (int i=0; i<N; i++) {
- ((WindowState)mChildWindows.get(i)).finishExit();
+ mChildWindows.get(i).finishExit();
}
if (!mExiting) {
@@ -6633,10 +6634,6 @@
Slog.w(TAG, "Error hiding surface in " + this, e);
}
mLastHidden = true;
-
- for (int i=0; i<N; i++) {
- mInputMonitor.windowIsBecomingInvisibleLw((WindowState)mChildWindows.get(i));
- }
}
mExiting = false;
if (mRemoveOnExit) {
@@ -6960,6 +6957,8 @@
}
void removeLocked() {
+ disposeInputChannel();
+
if (mAttachedWindow != null) {
mAttachedWindow.mChildWindows.remove(this);
}
@@ -6971,7 +6970,9 @@
// Ignore if it has already been removed (usually because
// we are doing this as part of processing a death note.)
}
-
+ }
+
+ void disposeInputChannel() {
if (mInputChannel != null) {
mInputManager.unregisterInputChannel(mInputChannel);
@@ -7537,7 +7538,7 @@
final int N = windows.size();
for (int i=0; i<N; i++) {
- ((WindowState)windows.get(i)).finishExit();
+ windows.get(i).finishExit();
}
updateReportedVisibilityLocked();
@@ -7963,7 +7964,7 @@
int i = mWindows.size();
while (i > 0) {
i--;
- WindowState w = (WindowState)mWindows.get(i);
+ WindowState w = mWindows.get(i);
if (w.mOrientationChanging) {
w.mOrientationChanging = false;
Slog.w(TAG, "Force clearing orientation change: " + w);
@@ -8102,7 +8103,7 @@
int idx = findDesiredInputMethodWindowIndexLocked(false);
WindowState imFocus;
if (idx > 0) {
- imFocus = (WindowState)mWindows.get(idx-1);
+ imFocus = mWindows.get(idx-1);
if (imFocus != null) {
if (imFocus.mSession.mClient != null &&
imFocus.mSession.mClient.asBinder() == client.asBinder()) {
@@ -8160,9 +8161,9 @@
// First remove all existing app windows.
i=0;
while (i < NW) {
- WindowState w = (WindowState)mWindows.get(i);
+ WindowState w = mWindows.get(i);
if (w.mAppToken != null) {
- WindowState win = (WindowState)mWindows.remove(i);
+ WindowState win = mWindows.remove(i);
mWindowsChanged = true;
if (DEBUG_WINDOW_MOVEMENT) Slog.v(TAG,
"Rebuild removing window: " + win);
@@ -8210,7 +8211,7 @@
int i;
for (i=0; i<N; i++) {
- WindowState w = (WindowState)mWindows.get(i);
+ WindowState w = mWindows.get(i);
if (w.mBaseLayer == curBaseLayer || w.mIsImWindow
|| (i > 0 && w.mIsWallpaper)) {
curLayer += WINDOW_LAYER_MULTIPLIER;
@@ -8335,7 +8336,7 @@
// to another window).
int topAttached = -1;
for (i = N-1; i >= 0; i--) {
- WindowState win = (WindowState) mWindows.get(i);
+ WindowState win = mWindows.get(i);
// Don't do layout of a window if it is not visible, or
// soon won't be visible, to avoid wasting time and funky
@@ -8384,7 +8385,7 @@
// XXX does not deal with windows that are attached to windows
// that are themselves attached.
for (i = topAttached; i >= 0; i--) {
- WindowState win = (WindowState) mWindows.get(i);
+ WindowState win = mWindows.get(i);
// If this view is GONE, then skip it -- keep the current
// frame, and let the caller know so they can ignore it
@@ -8531,7 +8532,7 @@
final int N = mWindows.size();
for (i=N-1; i>=0; i--) {
- WindowState w = (WindowState)mWindows.get(i);
+ WindowState w = mWindows.get(i);
final WindowManager.LayoutParams attrs = w.mAttrs;
@@ -8964,7 +8965,7 @@
// Clear them out.
forceHiding = false;
for (i=N-1; i>=0; i--) {
- WindowState w = (WindowState)mWindows.get(i);
+ WindowState w = mWindows.get(i);
if (w.mSurface != null) {
final WindowManager.LayoutParams attrs = w.mAttrs;
if (mPolicy.doesForceHide(w, attrs) && w.isVisibleLw()) {
@@ -9014,6 +9015,7 @@
if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, "*** ANIM STEP: changes=0x"
+ Integer.toHexString(changes));
+ mInputMonitor.updateInputWindowsLw();
} while (changes != 0);
// THIRD LOOP: Update the surfaces of all windows.
@@ -9030,7 +9032,7 @@
final int N = mWindows.size();
for (i=N-1; i>=0; i--) {
- WindowState w = (WindowState)mWindows.get(i);
+ WindowState w = mWindows.get(i);
boolean displayed = false;
final WindowManager.LayoutParams attrs = w.mAttrs;
@@ -9210,7 +9212,6 @@
Slog.w(TAG, "Exception hiding surface in " + w);
}
}
- mInputMonitor.windowIsBecomingInvisibleLw(w);
}
// If we are waiting for this window to handle an
// orientation change, well, it is hidden, so
@@ -9470,6 +9471,8 @@
Slog.e(TAG, "Unhandled exception in Window Manager", e);
}
+ mInputMonitor.updateInputWindowsLw();
+
Surface.closeTransaction();
if (DEBUG_ORIENTATION && mDisplayFrozen) Slog.v(TAG,
@@ -9595,6 +9598,8 @@
requestAnimationLocked(currentTime+(1000/60)-SystemClock.uptimeMillis());
}
+ mInputMonitor.updateInputWindowsLw();
+
if (DEBUG_FREEZE) Slog.v(TAG, "Layout: mDisplayFrozen=" + mDisplayFrozen
+ " holdScreen=" + holdScreen);
if (!mDisplayFrozen) {
@@ -9701,7 +9706,7 @@
boolean leakedSurface = false;
Slog.i(TAG, "Out of memory for surface! Looking for leaks...");
for (int i=0; i<N; i++) {
- WindowState ws = (WindowState)mWindows.get(i);
+ WindowState ws = mWindows.get(i);
if (ws.mSurface != null) {
if (!mSessions.contains(ws.mSession)) {
Slog.w(TAG, "LEAKED SURFACE (session doesn't exist): "
@@ -9733,7 +9738,7 @@
Slog.w(TAG, "No leaked surfaces; killing applicatons!");
SparseIntArray pidCandidates = new SparseIntArray();
for (int i=0; i<N; i++) {
- WindowState ws = (WindowState)mWindows.get(i);
+ WindowState ws = mWindows.get(i);
if (ws.mSurface != null) {
pidCandidates.append(ws.mSession.mPid, ws.mSession.mPid);
}
@@ -9825,7 +9830,7 @@
? mAppTokens.get(nextAppIndex) : null;
while (i >= 0) {
- win = (WindowState)mWindows.get(i);
+ win = mWindows.get(i);
if (localLOGV || DEBUG_FOCUS) Slog.v(
TAG, "Looking for focus: " + i
@@ -9973,14 +9978,13 @@
return;
}
- pw.println("Input Dispatcher State:");
mInputManager.dump(pw);
pw.println(" ");
synchronized(mWindowMap) {
pw.println("Current Window Manager state:");
for (int i=mWindows.size()-1; i>=0; i--) {
- WindowState w = (WindowState)mWindows.get(i);
+ WindowState w = mWindows.get(i);
pw.print(" Window #"); pw.print(i); pw.print(' ');
pw.print(w); pw.println(":");
w.dump(pw, " ");
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 93122c4..e333a82 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -542,6 +542,15 @@
private static final int MAX_DUP_SUPPRESSED_STACKS = 5000;
/**
+ * Strict Mode background batched logging state.
+ *
+ * The string buffer is guarded by itself, and its lock is also
+ * used to determine if another batched write is already
+ * in-flight.
+ */
+ private final StringBuilder mStrictModeBuffer = new StringBuilder();
+
+ /**
* Intent broadcast that we have tried to start, but are
* waiting for its application's process to be created. We only
* need one (instead of a list) because we always process broadcasts
@@ -6115,7 +6124,7 @@
}
}
if (logIt) {
- addErrorToDropBox("strictmode", r, null, null, null, null, null, crashInfo);
+ logStrictModeViolationToDropBox(r, crashInfo);
}
}
@@ -6141,6 +6150,89 @@
}
}
+ // Depending on the policy in effect, there could be a bunch of
+ // these in quick succession so we try to batch these together to
+ // minimize disk writes, number of dropbox entries, and maximize
+ // compression, by having more fewer, larger records.
+ private void logStrictModeViolationToDropBox(ProcessRecord process,
+ ApplicationErrorReport.CrashInfo crashInfo) {
+ if (crashInfo == null) {
+ return;
+ }
+ final boolean isSystemApp = process == null ||
+ (process.info.flags & (ApplicationInfo.FLAG_SYSTEM |
+ ApplicationInfo.FLAG_UPDATED_SYSTEM_APP)) != 0;
+ final String dropboxTag = isSystemApp ? "system_app_strictmode" : "data_app_strictmode";
+ final DropBoxManager dbox = (DropBoxManager)
+ mContext.getSystemService(Context.DROPBOX_SERVICE);
+
+ // Exit early if the dropbox isn't configured to accept this report type.
+ if (dbox == null || !dbox.isTagEnabled(dropboxTag)) return;
+
+ boolean bufferWasEmpty;
+
+ final StringBuilder sb = isSystemApp ? mStrictModeBuffer : new StringBuilder(1024);
+ synchronized (sb) {
+ bufferWasEmpty = sb.length() == 0;
+ appendDropBoxProcessHeaders(process, sb);
+ sb.append("Build: ").append(Build.FINGERPRINT).append("\n");
+ sb.append("System-App: ").append(isSystemApp).append("\n");
+ if (crashInfo != null && crashInfo.durationMillis != -1) {
+ sb.append("Duration-Millis: ").append(crashInfo.durationMillis).append("\n");
+ }
+ sb.append("\n");
+ if (crashInfo != null && crashInfo.stackTrace != null) {
+ sb.append(crashInfo.stackTrace);
+ }
+ sb.append("\n");
+ }
+
+ // Non-system apps are isolated with a different tag & policy.
+ // They're also not batched. Batching is useful during system
+ // boot with strict system-wide logging policies and lots of
+ // things firing, but not common with regular apps, which
+ // won't ship with StrictMode dropboxing enabled.
+ if (!isSystemApp) {
+ new Thread("Error dump: " + dropboxTag) {
+ @Override
+ public void run() {
+ dbox.addText(dropboxTag, sb.toString());
+ }
+ }.start();
+ return;
+ }
+
+ // System app batching:
+ if (!bufferWasEmpty) {
+ // An existing dropbox-writing thread is outstanding and
+ // will handle it.
+ return;
+ }
+
+ // Worker thread to both batch writes and to avoid blocking the caller on I/O.
+ // (After this point, we shouldn't access AMS internal data structures.)
+ new Thread("Error dump: " + dropboxTag) {
+ @Override
+ public void run() {
+ // 5 second sleep to let stacks arrive and be batched together
+ try {
+ Thread.sleep(5000); // 5 seconds
+ } catch (InterruptedException e) {}
+
+ String errorReport;
+ synchronized (mStrictModeBuffer) {
+ errorReport = mStrictModeBuffer.toString();
+ if (errorReport.length() == 0) {
+ return;
+ }
+ mStrictModeBuffer.delete(0, mStrictModeBuffer.length());
+ mStrictModeBuffer.trimToSize();
+ }
+ dbox.addText(dropboxTag, errorReport);
+ }
+ }.start();
+ }
+
/**
* Used by {@link Log} via {@link com.android.internal.os.RuntimeInit} to report serious errors.
* @param app object of the crashing app, null for the system server
@@ -6194,40 +6286,10 @@
}
/**
- * Write a description of an error (crash, WTF, ANR) to the drop box.
- * @param eventType to include in the drop box tag ("crash", "wtf", etc.)
- * @param process which caused the error, null means the system server
- * @param activity which triggered the error, null if unknown
- * @param parent activity related to the error, null if unknown
- * @param subject line related to the error, null if absent
- * @param report in long form describing the error, null if absent
- * @param logFile to include in the report, null if none
- * @param crashInfo giving an application stack trace, null if absent
+ * Utility function for addErrorToDropBox and handleStrictModeViolation's logging
+ * to append various headers to the dropbox log text.
*/
- public void addErrorToDropBox(String eventType,
- ProcessRecord process, ActivityRecord activity, ActivityRecord parent, String subject,
- final String report, final File logFile,
- final ApplicationErrorReport.CrashInfo crashInfo) {
- // NOTE -- this must never acquire the ActivityManagerService lock,
- // otherwise the watchdog may be prevented from resetting the system.
-
- String prefix;
- if (process == null || process.pid == MY_PID) {
- prefix = "system_server_";
- } else if ((process.info.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
- prefix = "system_app_";
- } else {
- prefix = "data_app_";
- }
-
- final String dropboxTag = prefix + eventType;
- final DropBoxManager dbox = (DropBoxManager)
- mContext.getSystemService(Context.DROPBOX_SERVICE);
-
- // Exit early if the dropbox isn't configured to accept this report type.
- if (dbox == null || !dbox.isTagEnabled(dropboxTag)) return;
-
- final StringBuilder sb = new StringBuilder(1024);
+ private static void appendDropBoxProcessHeaders(ProcessRecord process, StringBuilder sb) {
if (process == null || process.pid == MY_PID) {
sb.append("Process: system_server\n");
} else {
@@ -6253,6 +6315,45 @@
sb.append("\n");
}
}
+ }
+
+ private static String processClass(ProcessRecord process) {
+ if (process == null || process.pid == MY_PID) {
+ return "system_server";
+ } else if ((process.info.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
+ return "system_app";
+ } else {
+ return "data_app";
+ }
+ }
+
+ /**
+ * Write a description of an error (crash, WTF, ANR) to the drop box.
+ * @param eventType to include in the drop box tag ("crash", "wtf", etc.)
+ * @param process which caused the error, null means the system server
+ * @param activity which triggered the error, null if unknown
+ * @param parent activity related to the error, null if unknown
+ * @param subject line related to the error, null if absent
+ * @param report in long form describing the error, null if absent
+ * @param logFile to include in the report, null if none
+ * @param crashInfo giving an application stack trace, null if absent
+ */
+ public void addErrorToDropBox(String eventType,
+ ProcessRecord process, ActivityRecord activity, ActivityRecord parent, String subject,
+ final String report, final File logFile,
+ final ApplicationErrorReport.CrashInfo crashInfo) {
+ // NOTE -- this must never acquire the ActivityManagerService lock,
+ // otherwise the watchdog may be prevented from resetting the system.
+
+ final String dropboxTag = processClass(process) + "_" + eventType;
+ final DropBoxManager dbox = (DropBoxManager)
+ mContext.getSystemService(Context.DROPBOX_SERVICE);
+
+ // Exit early if the dropbox isn't configured to accept this report type.
+ if (dbox == null || !dbox.isTagEnabled(dropboxTag)) return;
+
+ final StringBuilder sb = new StringBuilder(1024);
+ appendDropBoxProcessHeaders(process, sb);
if (activity != null) {
sb.append("Activity: ").append(activity.shortComponentName).append("\n");
}
@@ -6266,9 +6367,6 @@
sb.append("Subject: ").append(subject).append("\n");
}
sb.append("Build: ").append(Build.FINGERPRINT).append("\n");
- if (crashInfo != null && crashInfo.durationMillis != -1) {
- sb.append("Duration-Millis: ").append(crashInfo.durationMillis).append("\n");
- }
sb.append("\n");
// Do the rest in a worker thread to avoid blocking the caller on I/O
diff --git a/services/jni/com_android_server_InputManager.cpp b/services/jni/com_android_server_InputManager.cpp
index 26e105a..0992b33 100644
--- a/services/jni/com_android_server_InputManager.cpp
+++ b/services/jni/com_android_server_InputManager.cpp
@@ -199,6 +199,8 @@
inline sp<InputManager> getInputManager() const { return mInputManager; }
+ String8 dump();
+
void setDisplaySize(int32_t displayId, int32_t width, int32_t height);
void setDisplayOrientation(int32_t displayId, int32_t orientation);
@@ -341,7 +343,8 @@
InputApplication* mFocusedApplication;
InputApplication mFocusedApplicationStorage; // preallocated storage for mFocusedApplication
- void dumpDispatchStateLd();
+ void dumpDispatchStateLd(String8& dump);
+ void logDispatchStateLd();
bool notifyANR(jobject tokenObj, nsecs_t& outNewTimeout);
void releaseFocusedApplicationLd(JNIEnv* env);
@@ -354,7 +357,7 @@
void releaseTouchedWindowLd();
- int32_t waitForTrackballEventTargets(MotionEvent* motionEvent, uint32_t policyFlags,
+ int32_t waitForNonTouchEventTargets(MotionEvent* motionEvent, uint32_t policyFlags,
int32_t injectorPid, int32_t injectorUid, Vector<InputTarget>& outTargets);
int32_t waitForTouchEventTargets(MotionEvent* motionEvent, uint32_t policyFlags,
int32_t injectorPid, int32_t injectorUid, Vector<InputTarget>& outTargets);
@@ -404,6 +407,17 @@
releaseFocusedApplicationLd(env);
}
+String8 NativeInputManager::dump() {
+ String8 dump;
+ dump.append("Native Input Dispatcher State:\n");
+
+ { // acquire lock
+ AutoMutex _l(mDisplayLock);
+ dumpDispatchStateLd(dump);
+ } // release lock
+ return dump;
+}
+
bool NativeInputManager::isAppSwitchKey(int32_t keyCode) {
return keyCode == AKEYCODE_HOME || keyCode == AKEYCODE_ENDCALL;
}
@@ -921,6 +935,8 @@
mTouchedWallpaperWindows.clear();
}
+ bool hadFocusedWindow = mFocusedWindow != NULL;
+
mWindows.clear();
mFocusedWindow = NULL;
mWallpaperWindows.clear();
@@ -972,10 +988,15 @@
mTempTouchedWallpaperChannels.clear();
+ if ((hadFocusedWindow && ! mFocusedWindow)
+ || (mFocusedWindow && ! mFocusedWindow->visible)) {
+ preemptInputDispatch();
+ }
+
mDispatchStateChanged.broadcast();
#if DEBUG_FOCUS
- dumpDispatchStateLd();
+ logDispatchStateLd();
#endif
} // release lock
}
@@ -1092,7 +1113,7 @@
mDispatchStateChanged.broadcast();
#if DEBUG_FOCUS
- dumpDispatchStateLd();
+ logDispatchStateLd();
#endif
} // release lock
}
@@ -1120,7 +1141,7 @@
}
#if DEBUG_FOCUS
- dumpDispatchStateLd();
+ logDispatchStateLd();
#endif
} // release lock
}
@@ -1217,19 +1238,22 @@
#if DEBUG_FOCUS
LOGD("waitForFocusedWindow finished: injectionResult=%d",
injectionResult);
- dumpDispatchStateLd();
+ logDispatchStateLd();
#endif
return injectionResult;
}
+enum InjectionPermission {
+ INJECTION_PERMISSION_UNKNOWN,
+ INJECTION_PERMISSION_GRANTED,
+ INJECTION_PERMISSION_DENIED
+};
+
int32_t NativeInputManager::waitForTouchedWindowLd(MotionEvent* motionEvent, uint32_t policyFlags,
int32_t injectorPid, int32_t injectorUid, Vector<InputTarget>& outTargets,
InputWindow*& outTouchedWindow) {
nsecs_t startTime = now();
- int32_t injectionResult = INPUT_EVENT_INJECTION_SUCCEEDED;
- int32_t action = motionEvent->getAction();
-
// For security reasons, we defer updating the touch state until we are sure that
// event injection will be allowed.
//
@@ -1255,8 +1279,13 @@
// instead of POLICY_FLAG_WOKE_HERE...
//
bool screenWasOff = false; // original policy: policyFlags & POLICY_FLAG_BRIGHT_HERE;
+
+ int32_t action = motionEvent->getAction();
+
bool firstIteration = true;
ANRTimer anrTimer;
+ int32_t injectionResult;
+ InjectionPermission injectionPermission;
for (;;) {
if (firstIteration) {
firstIteration = false;
@@ -1265,7 +1294,8 @@
LOGW("Dropping event because the dispatcher timed out waiting to identify "
"the window that should receive it.");
injectionResult = INPUT_EVENT_INJECTION_TIMED_OUT;
- break;
+ injectionPermission = INJECTION_PERMISSION_UNKNOWN;
+ break; // timed out, exit wait loop
}
}
@@ -1273,6 +1303,7 @@
if (! mDispatchEnabled) {
LOGI("Dropping event because input dispatch is disabled.");
injectionResult = INPUT_EVENT_INJECTION_FAILED;
+ injectionPermission = INJECTION_PERMISSION_UNKNOWN;
break; // failed, exit wait loop
}
@@ -1286,7 +1317,9 @@
}
// Update the touch state as needed based on the properties of the touch event.
- if (action == MOTION_EVENT_ACTION_DOWN) {
+ if (action == AMOTION_EVENT_ACTION_DOWN) {
+ /* Case 1: ACTION_DOWN */
+
InputWindow* newTouchedWindow = NULL;
mTempTouchedOutsideWindows.clear();
@@ -1348,12 +1381,14 @@
LOGI("Dropping event because there is no touched window or focused application.");
injectionResult = INPUT_EVENT_INJECTION_FAILED;
+ injectionPermission = INJECTION_PERMISSION_UNKNOWN;
break; // failed, exit wait loop
}
// Check permissions.
if (! checkInjectionPermission(newTouchedWindow, injectorPid, injectorUid)) {
injectionResult = INPUT_EVENT_INJECTION_PERMISSION_DENIED;
+ injectionPermission = INJECTION_PERMISSION_DENIED;
break; // failed, exit wait loop
}
@@ -1374,18 +1409,33 @@
if (newTouchedWindow->hasWallpaper) {
mTouchedWallpaperWindows.appendVector(mWallpaperWindows);
}
+
+ injectionResult = INPUT_EVENT_INJECTION_SUCCEEDED;
+ injectionPermission = INJECTION_PERMISSION_GRANTED;
break; // done
} else {
+ /* Case 2: Everything but ACTION_DOWN */
+
// Check permissions.
if (! checkInjectionPermission(mTouchedWindow, injectorPid, injectorUid)) {
injectionResult = INPUT_EVENT_INJECTION_PERMISSION_DENIED;
+ injectionPermission = INJECTION_PERMISSION_DENIED;
+ break; // failed, exit wait loop
+ }
+
+ // If the pointer is not currently down, then ignore the event.
+ if (! mTouchDown) {
+ LOGI("Dropping event because the pointer is not down.");
+ injectionResult = INPUT_EVENT_INJECTION_FAILED;
+ injectionPermission = INJECTION_PERMISSION_GRANTED;
break; // failed, exit wait loop
}
// If there is no currently touched window then fail.
- if (! mTouchedWindow || ! mTouchDown) {
- LOGI("Dropping event because touched window is no longer valid.");
+ if (! mTouchedWindow) {
+ LOGW("Dropping event because there is no touched window to receive it.");
injectionResult = INPUT_EVENT_INJECTION_FAILED;
+ injectionPermission = INJECTION_PERMISSION_GRANTED;
break; // failed, exit wait loop
}
@@ -1399,16 +1449,14 @@
}
// Success!
+ injectionResult = INPUT_EVENT_INJECTION_SUCCEEDED;
+ injectionPermission = INJECTION_PERMISSION_GRANTED;
break; // done
}
}
// Output targets.
- bool havePermission;
if (injectionResult == INPUT_EVENT_INJECTION_SUCCEEDED) {
- // Injection succeeded so the injector must have permission.
- havePermission = true;
-
size_t numWallpaperWindows = mTouchedWallpaperWindows.size();
for (size_t i = 0; i < numWallpaperWindows; i++) {
addTarget(mTouchedWallpaperWindows[i], 0, 0, outTargets);
@@ -1423,25 +1471,23 @@
anrTimer.getTimeSpentWaitingForApplication(), outTargets);
outTouchedWindow = mTouchedWindow;
} else {
- if (injectionResult != INPUT_EVENT_INJECTION_PERMISSION_DENIED
- && checkInjectionPermission(NULL, injectorPid, injectorUid)) {
- // Injection failed but the injector does have permission to inject events.
- // While we might not have found a valid target for the injected event, we
- // still want to update the dispatch state to take it into account.
- havePermission = true;
- } else {
- // Injector does not have permission to inject events.
- // We make sure to leave the dispatch state unchanged.
- havePermission = false;
- }
outTouchedWindow = NULL;
}
mTempTouchedOutsideWindows.clear();
- // Update final pieces of touch state now that we know for sure whether the injector
- // had permission to perform the injection.
- if (havePermission) {
- if (action == MOTION_EVENT_ACTION_DOWN) {
+ // Check injection permission once and for all.
+ if (injectionPermission == INJECTION_PERMISSION_UNKNOWN) {
+ if (checkInjectionPermission(action == AMOTION_EVENT_ACTION_DOWN ? NULL : mTouchedWindow,
+ injectorPid, injectorUid)) {
+ injectionPermission = INJECTION_PERMISSION_GRANTED;
+ } else {
+ injectionPermission = INJECTION_PERMISSION_DENIED;
+ }
+ }
+
+ // Update final pieces of touch state if the injector had permission.
+ if (injectionPermission == INJECTION_PERMISSION_GRANTED) {
+ if (action == AMOTION_EVENT_ACTION_DOWN) {
if (mTouchDown) {
// This is weird. We got a down but we thought it was already down!
LOGW("Pointer down received while already down.");
@@ -1454,16 +1500,18 @@
// be holding on to an earlier target from a previous touch down. Release it.
releaseTouchedWindowLd();
}
- } else if (action == MOTION_EVENT_ACTION_UP) {
+ } else if (action == AMOTION_EVENT_ACTION_UP) {
mTouchDown = false;
releaseTouchedWindowLd();
}
+ } else {
+ LOGW("Not updating touch focus because injection was denied.");
}
#if DEBUG_FOCUS
LOGD("waitForTouchedWindow finished: injectionResult=%d",
injectionResult);
- dumpDispatchStateLd();
+ logDispatchStateLd();
#endif
return injectionResult;
}
@@ -1557,26 +1605,21 @@
policyFlags, injectorPid, injectorUid);
#endif
- switch (motionEvent->getNature()) {
- case INPUT_EVENT_NATURE_TRACKBALL:
- return waitForTrackballEventTargets(motionEvent, policyFlags, injectorPid, injectorUid,
- outTargets);
-
- case INPUT_EVENT_NATURE_TOUCH:
+ int32_t source = motionEvent->getSource();
+ if (source & AINPUT_SOURCE_CLASS_POINTER) {
return waitForTouchEventTargets(motionEvent, policyFlags, injectorPid, injectorUid,
outTargets);
-
- default:
- assert(false);
- return INPUT_EVENT_INJECTION_FAILED;
+ } else {
+ return waitForNonTouchEventTargets(motionEvent, policyFlags, injectorPid, injectorUid,
+ outTargets);
}
}
-int32_t NativeInputManager::waitForTrackballEventTargets(MotionEvent* motionEvent,
+int32_t NativeInputManager::waitForNonTouchEventTargets(MotionEvent* motionEvent,
uint32_t policyFlags, int32_t injectorPid, int32_t injectorUid,
Vector<InputTarget>& outTargets) {
#if DEBUG_INPUT_DISPATCHER_POLICY
- LOGD("waitForTrackballEventTargets - policyFlags=%d, injectorPid=%d, injectorUid=%d",
+ LOGD("waitForNonTouchEventTargets - policyFlags=%d, injectorPid=%d, injectorUid=%d",
policyFlags, injectorPid, injectorUid);
#endif
@@ -1622,10 +1665,10 @@
int32_t eventType;
switch (motionEvent->getAction()) {
- case MOTION_EVENT_ACTION_DOWN:
+ case AMOTION_EVENT_ACTION_DOWN:
eventType = POWER_MANAGER_TOUCH_EVENT;
break;
- case MOTION_EVENT_ACTION_UP:
+ case AMOTION_EVENT_ACTION_UP:
eventType = POWER_MANAGER_TOUCH_UP_EVENT;
break;
default:
@@ -1675,31 +1718,38 @@
android_server_PowerManagerService_userActivity(eventTime, eventType);
}
-void NativeInputManager::dumpDispatchStateLd() {
-#if DEBUG_FOCUS
- LOGD(" dispatcherState: dispatchEnabled=%d, dispatchFrozen=%d, windowsReady=%d",
- mDispatchEnabled, mDispatchFrozen, mWindowsReady);
+void NativeInputManager::logDispatchStateLd() {
+ String8 dump;
+ dumpDispatchStateLd(dump);
+ LOGD("%s", dump.string());
+}
+
+void NativeInputManager::dumpDispatchStateLd(String8& dump) {
+ dump.appendFormat(" dispatchEnabled: %d\n", mDispatchEnabled);
+ dump.appendFormat(" dispatchFrozen: %d\n", mDispatchFrozen);
+ dump.appendFormat(" windowsReady: %d\n", mWindowsReady);
+
if (mFocusedApplication) {
- LOGD(" focusedApplication: name='%s', dispatchingTimeout=%0.3fms",
+ dump.appendFormat(" focusedApplication: name='%s', dispatchingTimeout=%0.3fms\n",
mFocusedApplication->name.string(),
mFocusedApplication->dispatchingTimeout / 1000000.0);
} else {
- LOGD(" focusedApplication: <null>");
+ dump.append(" focusedApplication: <null>\n");
}
- LOGD(" focusedWindow: '%s'",
+ dump.appendFormat(" focusedWindow: '%s'\n",
mFocusedWindow != NULL ? mFocusedWindow->inputChannel->getName().string() : "<null>");
- LOGD(" touchedWindow: '%s', touchDown=%d",
+ dump.appendFormat(" touchedWindow: '%s', touchDown=%d\n",
mTouchedWindow != NULL ? mTouchedWindow->inputChannel->getName().string() : "<null>",
mTouchDown);
for (size_t i = 0; i < mTouchedWallpaperWindows.size(); i++) {
- LOGD(" touchedWallpaperWindows[%d]: '%s'",
+ dump.appendFormat(" touchedWallpaperWindows[%d]: '%s'\n",
i, mTouchedWallpaperWindows[i]->inputChannel->getName().string());
}
for (size_t i = 0; i < mWindows.size(); i++) {
- LOGD(" windows[%d]: '%s', paused=%d, hasFocus=%d, hasWallpaper=%d, visible=%d, "
- "flags=0x%08x, type=0x%08x, "
+ dump.appendFormat(" windows[%d]: '%s', paused=%d, hasFocus=%d, hasWallpaper=%d, "
+ "visible=%d, flags=0x%08x, type=0x%08x, "
"frame=[%d,%d], touchableArea=[%d,%d][%d,%d], "
- "ownerPid=%d, ownerUid=%d, dispatchingTimeout=%0.3fms",
+ "ownerPid=%d, ownerUid=%d, dispatchingTimeout=%0.3fms\n",
i, mWindows[i].inputChannel->getName().string(),
mWindows[i].paused, mWindows[i].hasFocus, mWindows[i].hasWallpaper,
mWindows[i].visible, mWindows[i].layoutParamsFlags, mWindows[i].layoutParamsType,
@@ -1709,7 +1759,6 @@
mWindows[i].ownerPid, mWindows[i].ownerUid,
mWindows[i].dispatchingTimeout / 1000000.0);
}
-#endif
}
// ----------------------------------------------------------------------------
@@ -1852,7 +1901,7 @@
static jint android_server_InputManager_nativeGetScanCodeState(JNIEnv* env, jclass clazz,
jint deviceId, jint deviceClasses, jint scanCode) {
if (checkInputManagerUnitialized(env)) {
- return KEY_STATE_UNKNOWN;
+ return AKEY_STATE_UNKNOWN;
}
return gNativeInputManager->getInputManager()->getScanCodeState(
@@ -1862,7 +1911,7 @@
static jint android_server_InputManager_nativeGetKeyCodeState(JNIEnv* env, jclass clazz,
jint deviceId, jint deviceClasses, jint keyCode) {
if (checkInputManagerUnitialized(env)) {
- return KEY_STATE_UNKNOWN;
+ return AKEY_STATE_UNKNOWN;
}
return gNativeInputManager->getInputManager()->getKeyCodeState(
@@ -1872,7 +1921,7 @@
static jint android_server_InputManager_nativeGetSwitchState(JNIEnv* env, jclass clazz,
jint deviceId, jint deviceClasses, jint sw) {
if (checkInputManagerUnitialized(env)) {
- return KEY_STATE_UNKNOWN;
+ return AKEY_STATE_UNKNOWN;
}
return gNativeInputManager->getInputManager()->getSwitchState(deviceId, deviceClasses, sw);
@@ -1963,28 +2012,28 @@
}
static jint android_server_InputManager_nativeInjectKeyEvent(JNIEnv* env, jclass clazz,
- jobject keyEventObj, jint nature, jint injectorPid, jint injectorUid,
+ jobject keyEventObj, jint injectorPid, jint injectorUid,
jboolean sync, jint timeoutMillis) {
if (checkInputManagerUnitialized(env)) {
return INPUT_EVENT_INJECTION_FAILED;
}
KeyEvent keyEvent;
- android_view_KeyEvent_toNative(env, keyEventObj, nature, & keyEvent);
+ android_view_KeyEvent_toNative(env, keyEventObj, & keyEvent);
return gNativeInputManager->getInputManager()->injectInputEvent(& keyEvent,
injectorPid, injectorUid, sync, timeoutMillis);
}
static jint android_server_InputManager_nativeInjectMotionEvent(JNIEnv* env, jclass clazz,
- jobject motionEventObj, jint nature, jint injectorPid, jint injectorUid,
+ jobject motionEventObj, jint injectorPid, jint injectorUid,
jboolean sync, jint timeoutMillis) {
if (checkInputManagerUnitialized(env)) {
return INPUT_EVENT_INJECTION_FAILED;
}
MotionEvent motionEvent;
- android_view_MotionEvent_toNative(env, motionEventObj, nature, & motionEvent);
+ android_view_MotionEvent_toNative(env, motionEventObj, & motionEvent);
return gNativeInputManager->getInputManager()->injectInputEvent(& motionEvent,
injectorPid, injectorUid, sync, timeoutMillis);
@@ -2026,6 +2075,15 @@
gNativeInputManager->preemptInputDispatch();
}
+static jstring android_server_InputManager_nativeDump(JNIEnv* env, jclass clazz) {
+ if (checkInputManagerUnitialized(env)) {
+ return NULL;
+ }
+
+ String8 dump(gNativeInputManager->dump());
+ return env->NewStringUTF(dump.string());
+}
+
// ----------------------------------------------------------------------------
static JNINativeMethod gInputManagerMethods[] = {
@@ -2050,9 +2108,9 @@
(void*) android_server_InputManager_nativeRegisterInputChannel },
{ "nativeUnregisterInputChannel", "(Landroid/view/InputChannel;)V",
(void*) android_server_InputManager_nativeUnregisterInputChannel },
- { "nativeInjectKeyEvent", "(Landroid/view/KeyEvent;IIIZI)I",
+ { "nativeInjectKeyEvent", "(Landroid/view/KeyEvent;IIZI)I",
(void*) android_server_InputManager_nativeInjectKeyEvent },
- { "nativeInjectMotionEvent", "(Landroid/view/MotionEvent;IIIZI)I",
+ { "nativeInjectMotionEvent", "(Landroid/view/MotionEvent;IIZI)I",
(void*) android_server_InputManager_nativeInjectMotionEvent },
{ "nativeSetInputWindows", "([Lcom/android/server/InputWindow;)V",
(void*) android_server_InputManager_nativeSetInputWindows },
@@ -2061,7 +2119,9 @@
{ "nativeSetInputDispatchMode", "(ZZ)V",
(void*) android_server_InputManager_nativeSetInputDispatchMode },
{ "nativePreemptInputDispatch", "()V",
- (void*) android_server_InputManager_nativePreemptInputDispatch }
+ (void*) android_server_InputManager_nativePreemptInputDispatch },
+ { "nativeDump", "()Ljava/lang/String;",
+ (void*) android_server_InputManager_nativeDump },
};
#define FIND_CLASS(var, className) \
diff --git a/tools/layoutlib/bridge/src/android/graphics/Paint.java b/tools/layoutlib/bridge/src/android/graphics/Paint.java
index 619ab30..d13b5fe 100644
--- a/tools/layoutlib/bridge/src/android/graphics/Paint.java
+++ b/tools/layoutlib/bridge/src/android/graphics/Paint.java
@@ -283,6 +283,8 @@
mStyle = src.mStyle;
mFlags = src.mFlags;
+ updateFontObject();
+
super.set(src);
}
}