Copy/Past mach-msm from tiamat
defconfig
arm: msm: Use proper irq accessor functions

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

Conflicts:

	arch/arm/mach-msm/irq.c
Revert "arm: msm: Use proper irq accessor functions"

This reverts commit 98840506db8404b84990d8b56b6d0e59310ee853.
Revert "Copy/Past mach-msm from tiamat"

This reverts commit e0b803f275e12d3974fdf997d446e5ba42272a6b.
bravo import
Revert "bravo import"

This reverts commit 9fb16397f07af84dee48367cb61c912f27fe02a6.
bravo import
droping tiamat/cm qdsp6 over ours :D
Revert "droping tiamat/cm qdsp6 over ours :D"

This reverts commit 13023c87bda6b86b8e64b488b0c1fe43cd424ea8.
[ARM] msm: qsd8k: DSP / DAL / Audio / Video MEGAPATCH

[ARM] msm: qsd8k: Device Access Layer (DAL) RPC

Device Access Layer (DAL) RPC is yet another remote interface to software
on the baseband and dsp processors of the msm7k/qsd8k family.  It uses SMD
as a transport.

Signed-off-by: Brian Swetland <swetland@google.com>

[ARM] msm: Add qdsp6 config option and makefile

Change-Id: I6120d03a96339139d4d88f32e165d26b75ac805e
Signed-off-by: Dima Zavin <dima@android.com>

{ARM] msm: qsd8k: support for qdsp6 audio subsystem

Provide support for QDSP6's AUDIO service, as well as the A9's
ACDB (Audio Config Database) and ADIE services, necessary for audio
operation. Provide pcm in/out drivers.

Major contributions, and submitted on behalf of HK Chen @ HTC.

Signed-off-by: Brian Swetland <swetland@google.com>
Cc: HK Chen <hk_chen@htc.com>

[ARM] msm: qdsp6: Add video decode support for AMSS 3180+

- sometimes dal_call_f0 rpc returns failure need to investigate

Signed-off-by: Dima Zavin <dima@android.com>

[ARM]: msm: q6vdec: close the dsp in vdec_release to free up the pmem and proper cleanup of qdsp6

Signed-off-by: Tom Liu <tliu@quicinc.com>
Signed-off-by: Colin Cross <ccross@android.com>
Change-Id: I6c9203685abbc50c8ef9633dfc99024dd720e17a

qsd8k: vdec: hold wake/idlelocks while decoder is active

DSP interrupts are being lost if we go to sleep while playing video.
This usually doesn't happen because we usually have an audio channel
open, providing its own wake/idlelocks, but this fixes the other
case.

Signed-off-by: Brian Swetland <swetland@google.com>

qsd8k: vdec: don't leak wakelocks

Fix a stupid cut-and-paste error.

Signed-off-by: Brian Swetland <swetland@google.com>

[ARM] msm: qdsp6: Add support for h/w video encode.

Change-Id: If3d8c1d836955f834f4988f364cce07fce22bfa6
Signed-off-by: Dima Zavin <dima@android.com>

[ARM] msm: qdsp6: flush and invalidate cahces in venc

Signed-off-by: Erik Gilling <konkers@android.com>

[ARM] msm: qdsp6: Invalidate video encoder output buffers before encode

When an output buffer is passed to the DSP, we have to invalidate it first
to make sure no dirty cache lines are later written to the physical memory
while the DSP is using it.

Also fixes problems with cleaning the input buffer cache before the DSP.
Userspace is not setting the size of the input buffer on each ioctl, so
we have to pre-compute the size based on the encoder paramters.

Signed-off-by: Colin Cross <ccross@android.com>
Change-Id: I7a858f0d833e82b296ac7e32eeaff820d52acba9

[ARM] msm: qdsp6: Invalidate encoder buffers before DSP initialization

The DSP may write to the rlc_bufs during initialization.  Invalidate them
so that a later flush doesn't cause corruption.

Change-Id: Ic482334526712c14e48c790dbeeb7c0f5e1d0cbc
Signed-off-by: Colin Cross <ccross@android.com>

[ARM] msm: q6venc: Use flush_pmem_file to flush the input buffers to the DSP

Change-Id: I37ca4ee3e85144cf1f0ccacceb3e2d7d5f0b334c
Signed-off-by: Colin Cross <ccross@android.com>

[ARM] msm: q6_venc: detach the dal client before releasing the buffers

Change-Id: Ib96c0fb6227c53b97a68d51d627f6fe2d45b5aee
Signed-off-by: Dima Zavin <dima@android.com>

qsd8k: audio: combined changes

qsd8k: audio: handle transient errors during pcm stream open

Sometimes we get an EUNSUPPORTED (?!) error while trying to open
a pcm stream.  If we retry in 1ms it succeeds.

Add some debugging/tracing code handy for diagnosing issues like
this (disabled by default).

Signed-off-by: Brian Swetland <swetland@google.com>

[ARM] msm: qdsp: add wakelocks

Signed-off-by: Mike Chan <mike@android.com>

qsd8k: audio: move to new dsp protocol (3200.04+)

Signed-off-by: Brian Swetland <swetland@bulgaria.(none)>

qsd8k: audio: fix q6audio_update_acdb().

Correctly indicate RX or TX device.

Signed-off-by: Brian Swetland <swetland@google.com>

qsd8k: add receiver analog control

Signed-off-by: Brian Swetland <swetland@google.com>

qsd8k: audio: support ACDB reinitialization

Signed-off-by: Brian Swetland <swetland@google.com>

qsd8k: audio: add support for stream volume.

Signed-off-by: Brian Swetland <swetland@google.com>

qsd8k: audio: fix recording fail issue when sampling rate higher than 8K.

Signed-off-by: Brian Swetland <swetland@google.com>

qsd8k: audio: change the buffer size in pcm driver from 8192 to 4800.

Userspace expects 4800 default.  Easier to fix it on this side.

Signed-off-by: Brian Swetland <swetland@google.com>

qsd8k: audio: tracing, and stuck dsp panic code

If the dsp doesn't respond in 5s, it will probably never respond,
leaving the device in a bad state -- panic in that case.

Add some debug chatter on pcm in/out open and close as well.

Signed-off-by: Brian Swetland <swetland@google.com>

qsd8k: audio: fix volume control.

Per QCT's comments, volume control only works when there are
active audio/voice sessions, or DSP will return status 20
(UNSUPPORTED). To solve this issue, QCT has introduced new
voice device ID which is using for in-call volume control.
It will directly apply the volume setting to next voice call.
Also, for in-call uplink volume, remove the redundant volume
setting and use the default setting in DSP (0dB as default).

Signed-off-by: Brian Swetland <swetland@google.com>

qsd8k: audio: fix ordering of analog/digital power up sequencing for tx

Avoids noise on audio input.

Change-Id: Ib1baab87e99a09f9e1284d32cf1d6a5b5fc3a6c8
Signed-off-by: Brian Swetland <swetland@google.com>

qsd8k: dal: add tracing capabilities to DAL channels

If requested, log the last 32 calls, replies, and/or events.

Signed-off-by: Brian Swetland <swetland@google.com>

qsd8k: trace dal io and dump it on fatal error

Signed-off-by: Brian Swetland <swetland@google.com>

qsd8k: audio: correctly release the firmware on acdb change

Signed-off-by: Brian Swetland <swetland@google.com>

qsd8k: audio: fix bongus ID look up in q6audio_set_rx_volume().

Signed-off-by: Brian Swetland <swetland@google.com>

qsd8k: audio: enhance stuck dal debugging

Dump the packet we were in the act of sending, if we timed out while
waiting for a reply.  This covers the situation of failing on a
different channel than one being traced.

Signed-off-by: Brian Swetland <swetland@google.com>

qsd8k: audio: pcm_out: default buffer size is now 3072

Signed-off-by: Brian Swetland <swetland@google.com>

[ARM] qsd8k: audio: fix typo in q6audio_devices.h

Signed-off-by: Iliyan Malchev <malchev@google.com>

qsd8k: audio combined changes

qsd8k: audio: clean up code for ACDB update.

Signed-off-by: Brian Swetland <swetland@google.com>

qsd8k: audio: remove redundant ACDB updates for audio playback and recording.

q6audio_open_*() now takes an acdb_id to allow the device to be changed
as part of the channel open process.

Signed-off-by: Brian Swetland <swetland@google.com>

qsd8k: audio: remove redundant ACDB updates during audio route changes.

Audio HAL will pass the ACDB ID to audio driver when audio route changes.

Signed-off-by: Brian Swetland <swetland@google.com>

qsd8k: audio: change the timing for ADIE enable/disable.

Avoid pop noises.

Signed-off-by: Brian Swetland <swetland@google.com>

qsd8k: audio: change the timing when ACDB updates to avoid tick sound during voice call.

Signed-off-by: Brian Swetland <swetland@google.com>

qsd8k: audio: do not require acdb_ids on channel open

This allows the simple case of using the default device to work.

Signed-off-by: Brian Swetland <swetland@google.com>

qsd8k: dal: don't use dch before setting it

Harmless on a UP, non-spinlock-debug build, but quite very wrong.

Signed-off-by: Brian Swetland <swetland@google.com>

qsd8k: audio: reorder audio path setup around pcm open

Some clicks and pops on stream start are avoided if the audio
path setup is deferred until after the stream is opened but
before the stream is started.  The whole audio path management
scheme wants some serious rewriting, but for now we'll stick
with a minimal-risk change.

Signed-off-by: Brian Swetland <swetland@google.com>

[ARM] qsd8k: initialize the spinlock in dal_client

Signed-off-by: Iliyan Malchev <malchev@google.com>

qsd8k: audio: avoid incorrect sampling rate on first input pcm open

Also avoid double calling audio_tx_analog_enable()

Signed-off-by: Brian Swetland <swetland@google.com>
Signed-off-by: Paul Eastham <eastham@google.com>

[ARM] msm: q6audio: remove device gain control for pcm playback.

Change-Id: Id243b6771a6a324931afa86c662eef8b907b213b

Signed-off-by: Dima Zavin <dima@android.com>

[ARM] qsd8k: audio: combined changes

[ARM] qsd8k: audio: use default settings if ACDB-table query fails

Signed-off-by: Iliyan Malchev <malchev@google.com>

[ARM] qsd8k: audio: remove device gain control for mp3 playback

Fixes the problem where in-call downlink volume gets degraded after tone is
played.

Signed-off-by: Iliyan Malchev <malchev@google.com>

[ARM] qsd8k: audio: add HAC ACDB ID support

-- q6_voice_start, q6voice_open take an ACDB-ID parameter
-- q6_ioctl AUDIO_START_VOICE passes ACDB ID
-- q6voice_open passes the ACDB ID to audio_rx/tx_path_enable

Signed-off-by: Iliyan Malchev <malchev@google.com>

[ARM] qsdk8k: audio: remove in-call volume control from driver

Will move to board file.

Signed-off-by: Iliyan Malchev <malchev@google.com>

[ARM] qsd8k: audio: add function to override default ACDB file.

Signed-off-by: Iliyan Malchev <malchev@google.com>

[ARM] qsd8k: audio: enable selection of input and output buffer size

-- through AUDIO_SET_CONFIG ioctl
-- lowers default buffer size from 4k to 256 bytes

Signed-off-by: Eric Laurent <elaurent@google.com>

Conflicts:

	arch/arm/mach-msm/Kconfig
	arch/arm/mach-msm/Makefile
	arch/arm/mach-msm/include/mach/msm_qdsp6_audio.h
	arch/arm/mach-msm/qdsp6/Makefile
	arch/arm/mach-msm/qdsp6/analog_audio.c
	arch/arm/mach-msm/qdsp6/audio_ctl.c
	arch/arm/mach-msm/qdsp6/dal.c
	arch/arm/mach-msm/qdsp6/dal.h
	arch/arm/mach-msm/qdsp6/dal_acdb.h
	arch/arm/mach-msm/qdsp6/dal_adie.h
	arch/arm/mach-msm/qdsp6/dal_audio.h
	arch/arm/mach-msm/qdsp6/dal_audio_format.h
	arch/arm/mach-msm/qdsp6/mp3.c
	arch/arm/mach-msm/qdsp6/msm_q6vdec.c
	arch/arm/mach-msm/qdsp6/msm_q6venc.c
	arch/arm/mach-msm/qdsp6/pcm_in.c
	arch/arm/mach-msm/qdsp6/pcm_out.c
	arch/arm/mach-msm/qdsp6/q6audio.c
	arch/arm/mach-msm/qdsp6/q6audio_devices.h
	arch/arm/mach-msm/qdsp6/routing.c
	include/linux/msm_audio.h
	include/linux/msm_q6vdec.h
	include/linux/msm_q6venc.h
[ARM] qsd8k: audio: fix device auto reboot for first MT call (CDMA revs)

Signed-off-by: Iliyan Malchev <malchev@google.com>

Conflicts:

	arch/arm/mach-msm/qdsp6/q6audio.c
qsd8k: audio: call q6audio_dsp_not_responding() instead of BUG()

This hooks into the DSP crash notification / dumping mechanism.

Signed-off-by: Brian Swetland <swetland@google.com>

Conflicts:

	arch/arm/mach-msm/qdsp6/dal.c
msm: move DAL support out of qdsp6 subdirectory

Since 7x30/qdsp5v2 uses DAL as well, we will move this into the common
directory for the msm architecture.

Change-Id: I79a5ca71171a0c6cbaf82bef8e72fea51d617d75
Signed-off-by: Brian Swetland <swetland@google.com>

Conflicts:

	arch/arm/mach-msm/Kconfig
	arch/arm/mach-msm/Makefile
	arch/arm/mach-msm/qdsp6/msm_q6venc.c
[ARM] msm: qsd8k: audio

When muting mic input, always update saved mute state
regardless of completion status returned by audio dsp.
This ensures that saved mute state is coherent with mute state in
phone application that has no feedback on completion status.

Signed-off-by: Eric Laurent <elaurent@google.com>
support FM Radio in kernel
msm: audio: 8k: Send ACDB data after the PREPARE stage of device switch

As per the Q6 API, the ACDB configuration need to be sent to Q6 after the
PREPARE stage of the device switch. But in the current code it is in the
reverse order. Hence correcting the code as per the Q6 API.

Change-Id: I9f947d44f73b1fc71ddea8259ca54402edc895c2
Signed-off-by: Phani Kumar Allada <pallad@codeaurora.org>
msm: audio: 8k: Send ACDB configuration during device switch

In the current code, for a device switch command, ACDB configuration
is sent to Q6 only if there is any active tx/rx session.
As per Q6 API, changing the code to send ACDB configuration after
the PREPARE stage of the device switch even if there's no active
tx/rx session.

Change-Id: I895f5da5d23f586ae829c4856a5b39b4399422ee
CRs-Fixed: 267703
Signed-off-by: Phani Kumar Allada <pallad@codeaurora.org>
mahimahi: adjust in-call audio
mahimahi: q6audio: adjust in-call audio