OMAP4: AudioHAL: Add audio device priority table

The audio device priority table is added to correctly
set the audio device used during a call if there's
several audio devices enabled in the same time.

Change-Id: Icef8f72878b9d8b78dd94e99dd79b03d1212e976
Signed-off-by: Francois Mazard <f-mazard@ti.com>
Thermal Manager: Make ThermalDaemon not dependent on hwmon instance

To make the thermal daemon more generic and not dependent on HWMON instance
number, this patch replaces usage of /sys/class/hwmon/hwmonx/device path by
direct access to device driver instance when it is possible.
When it is not possible, the detection of uevent source excludes the HWMON
instance number.

Change-Id: Ic9db1087fd73f7c86e6b2568e0ea4f881039a257
Signed-off-by: Sebastien Sabatier <s-sabatier1@ti.com>
Thermal Manager: Cleaned-up incorrect coding mechanisms

This patch fixes some incorrect coding mechanisms that could generate errors later
  1/ Use int instead of u32 (unsigned int) for all temperature variables
    (this allows managing negative temperature)
  2/ Define all global variables as static
  3/ Fix some issues related to strings management
    (they were tagged as FIXME)

Change-Id: I53f3b091f6ae356a44ddd5449bf38430691f2d63
Signed-off-by: Sebastien Sabatier <s-sabatier1@ti.com>
CameraHAL OMAP4: Prevent deadlock while smooth zoom

Android Camera API designed to be able to stop preview while pending
notification event from CameraHAL is active in another thread.

This leads to potential deadlock when CameraHAL in stopping preview
attempts to wait until pending notification event processing by
CameraService will be finished. But it will not be finished, because on
the other hand CameraService is awaiting for CameraHAL to finish
processing preview stop first.

This patch removes potential infinite waiting routines from CameraHAL
and moves function bodies directly into caller thread.

Backported from HC Change-Id: I0de0e8b96a78f39020f825aadfc9c1466a327e73

Signed-off-by: Daniel Levin <x0155538@ti.com>

Change-Id: Ia3c8fb2da62b2a66ed5728507c5386e1b8a3d232
CameraHAL OMAP4: Improved logging

Added logging current line, thread id and file names into DBGUTILS_LOG*
macros and function enter/exit.

Implemented logging offset by call stack size per current thread to
improve readability of printed logs.

Moved LOG_TAG macro from sources into common CameraHAL's Android.mk.

Signed-off-by: Daniel Levin <x0155538@ti.com>

Change-Id: Id6da7fdf0ebc109a8446a1137c5d37c2e539b0b8
Thermal Manager: Use PCB temp for extrapolation of hot spot temp

Even if OMAP4460/4470 on-die temperature sensor is located as close
as possible to OMAP MPU-SS, there is still an offset between on-die
sensor and OMAP hot spot.
This offset depends a lot on the additional system power:
various laws could be defined depending on the system power.
Relying on a PCB sensor allows correcting this offset temperature:
linear law can be used in thermal policy to adjust the temperature
read on the sensor and correct the offset at run time.
This requires to have PCB sensor close to OMAP die: this config
is available on TI OMAP4460 ES1.1 SOM (processor board).

This patch adds the support of PCB temperature:
  - Added parameters in libthermal-manager.cfg to support or not the
    external PCB sensor
    This allows keeping backward compatibility with current
    implementation
  - Added support of external Thermistor on OMAP4460 ES1.1 SOM
    This requires as well a dedicated kernel driver for TWL6030_GPADC
  - Updated formula to extrapolate hot spot from on-die sensor
    and PCB sensor
  - Updated reconfiguration of thresholds that should take into
    account the variation of PCB temperature
  - Added additional thread to monitor the on-die temperature and make
    average on latest 20 measurements:
    This average temperature is mandatory to take care of huge delta
    between on-die sensor and PCB sensor when the temperature
    increases quickly (burst CPU activity).
    This huge delta is coming from different response time between
    on-die sensor and PCB sensor.

Change-Id: I36dae8008d8ed9bfad4a6e6e54cf9a4aa297892a
Signed-off-by: Sebastien Sabatier <s-sabatier1@ti.com>
Merge "OMAP4: AudioHAL: Add audio device priority table" into gingerbread
Merge "Thermal Manager: Make ThermalDaemon not dependent on hwmon instance" into gingerbread
Merge "Thermal Manager: Cleaned-up incorrect coding mechanisms" into gingerbread
Merge "Thermal Manager: Use PCB temp for extrapolation of hot spot temp" into gingerbread
Thermal Manager: manage dynamically the support of PCB temp

This patch checks if from SW Kernel point-of-view the PCB temperature sensor
is accessible.
If it is not accessible and even if configuration file requests the support
of this PCB temperature sensor, then the thermal manager disables dynamically
the support of the PCB temperature sensor and force some parameters.
This patch does not protect against bad location of the PCB temperature sensor.

Change-Id: Ie797aab6cb81683a29531598b8011487607db435
Signed-off-by: Sebastien Sabatier <s-sabatier1@ti.com
CameraHAL OMAP4: Removed camera adapter reloading

Dead code cleanup.

Backported from HC Change-Id: I66d66367e4df3d02b3ea4e8fb65f59ca6117a245

Change-Id: I7e68b4cadfd9735432d666034923345e99dc73fb
Signed-off-by: Dmytro Sirenko <x0158317@ti.com>
CameraHAL OMAP4: Fixed GPS timestamp

Value passed as KEY_GPS_TIMESTAMP parameter should be
interpreted as UTC time, not local time.

Backported from HC Change-Id: If031ba24fa5f780c45354f8e3d1aefc23c22f9f7

Change-Id: Ie2451bda18b49d94b42fd26e2625fb9343db3f30
Signed-off-by: Dmytro Sirenko <x0158317@ti.com>
Merge "CameraHAL OMAP4: Fixed GPS timestamp" into gingerbread
CameraHAL OMAP4: Handling error of switching to Executing state

Added error handling while switching OMX component into Executing
state from startPreview() method.

This prevents hang in case transition into Executing state has failed.

Backported from HC Change-Id: Ie6c30086bb9b6e15e6265f051b1b3638af29e432

Change-Id: Ife3fc381582bd24ac46c3097f27b1eeaaf6663af
Signed-off-by: Dmytro Sirenko <x0158317@ti.com>
Merge "CameraHAL OMAP4: Removed camera adapter reloading" into gingerbread
CameraHAL OMAP4: Sets buffer reference count only when subscriber lock is held

- Reference counting should be done while holding the subscriber lock.
  This requirement stems from the fact that the subscribers could
  change dynamically and the reference count value may become invalid
  when we start sending the buffer to the subscribers.

Change-Id: Ifd792d643b31ca80ff7984199c3fd96a36b251e6
Signed-off-by: Dmytro Sirenko <x0158317@ti.com>
Merge "CameraHAL OMAP4: Sets buffer reference count only when subscriber lock is held" into gingerbread
CameraHAL OMAP4: Fixed sending video frames

When OMXCameraAdapter is in recording mode is sends incoming
preview buffer two times:
1. As video frame, this frame is received by AppCallbackNotifier.
2. As preview frame, this frame is received by ANativeWindowDisplayAdapter.

The code that do those sendings is supposed to be solid, because
buffer behavior depends on refcounting for both subscriber lists at
the same time: video subscriber list and preview subscriber list
(because preview buffer is shared between them).

AppCallbackNotifier does processing incoming video frames in separate
thread that is extremely quick - it reads frames messages in infinite
loop without sleep.

This lead into race condition when OMXCameraAdapter is about to send
second frame to preview subscribers - AppCallbackNotifier has already
finished processing his video frame and triggered new fillThisBuffer()
request for the same buffer.

This lead to double fillThisBuffer() request and double buffer unlock
attempt later.

This patch fixes such behavior by providing method
BaseCameraAdapter::sendFramesToSubscribers() that sends several
frames at once. It starts with setup buffer refcounters and only then
notifies frame subscribers.

Backported from HC Change-Id: I0293316dc1fbbd398ef703aee1feb9e0f0cf3239

Change-Id: Ife398de19c5b82b9e6c570ed9a95f1c3e434b352
Signed-off-by: Dmytro Sirenko <x0158317@ti.com>
CameraHAL OMAP4: Removed CameraAdapter deinitialization by timeout

Removed CameraAdapter timeouts on CamerHal deinitialization -
it useless and causes race condition on fast reinitialization.

Now all CameraAdapter instances are destroyed in place of
CameraHAl destruction.

Backported from HC Change-Id: I157828a40e44d719f48a206126d526a854396600

Signed-off-by: Andriy Chepurnyy <x0155536@ti.com>
Signed-off-by: Daniel Levin <x0155538@ti.com>
Signed-off-by: Dmytro Sirenko <x0158317@ti.com>

Change-Id: I186be997c56f2a7e567f05a67b7cbcfa9270785f