galbi: stock g2 msm8974 20a kk LGE source

* update d803 LGE left out and didn't update
* update 20b source updates from lg source
* fixes, my stock defconfigs, etc...
* fix compile warning "use of swp{b} is deprecated for ARMv6 and ARMv7"

Signed-off-by: houst0nn <houstonn@gmail.com>
g2: squash all g2 aosp fixes

kcal_ctrl: Remove the lower limits from the RGB values
Allow the full range of kcal to be applied.

lge_touch_core: Don't announce support for ALL the tools
This confuses the heck out of some apps, and it's simply not true

Reduce voltage to LCD screen to save power.

bluesleep: Reset the check timer interval to the original 10 seconds

bluesleep: Remove remnants of LGE_BLUESLEEP
The patching of msm_serial_hs should make the clock workarounds
unnecessary

Conflicts:
	drivers/tty/serial/serial_core.c

bluesleep: Fix L2 crash with host-initiated bluetooth connections

bluesleep: Back out LGE_BLUESLEEP changes and add bluedroid support
Conflicts:
	drivers/bluetooth/bluesleep.c

Change-Id: If11e3cbed60d65eaba10e5b27f967aa34b49d91a

leds: At disable, set the trigger to default instead of wiping it

msm_ipc_router: Allow processes in the oncrpc group to use it freely
Instead of adding rild to the current catch-all net-raw group,
treat the oncrpc group as another catch-all.

lge_touch: Move gesture KEY_POWER event out of interrupt context
That's generally an awful idea, put it in the workqueue instead

Conflicts:
	drivers/input/touchscreen/lge_touch_core.c

Change-Id: I21974275363c6b83beb2795b11da05d718747be8

lge_touch: Generate KEY_POWER events for wakeup gestures
Conflicts:
	drivers/input/touchscreen/lge_touch_core.c

Change-Id: I76950b6f920f48797379ddf1ff518253f6b6840b

tspdrv: Add LG's timed_output based interface
Change-Id: I43383ad9e0ba4e0ba13837c0741885162cf40b63

 This is the 2nd commit message:

tspdrv: Make the timed state atomic

This should fix race conditions with fast bursts of short tones

Change-Id: I2c369da0a80dedebf7346613437d2b69d6a92c3c

 This is the 3rd commit message:

tspdrv: Add a sysfs control for timed vibrator strength

Change-Id: I66dec312e52a3c8834a93f6b8970c94a0d6af923

Conflicts:
	drivers/misc/tspdrv/ImmVibeSPI.c

Remove log spam.
Change-Id: I2f715844e9f416707a01f62abe0b81f05de0ec56

imx135 / fix GPIO Setting
Change-Id: I6f34fe8fba4696b3327166f1a716e00c5c380191

mmc: Get rid of CONFIG_MACH_MSM8974_EMMC_HW_RESET
Change-Id: Ibeb4d8c4c0e8188a48d468907dc42adce40be136

BU52031NVX: Add lid events to support the smartcover

*credits rmcc Ricardo

Add device tree stubs.
LG's 4.2 aboot searches for

/soc/qcom,mdss_dsi_lgit_video
/soc/qcom,mdss_dsi_jdi_video
/soc/qcom,mdss_dsi_jdi_cmd
/soc/qcom,mdss_dsi_lgit_cmd

before booting the kernel; and it will explicitly fail to boot if they aren't
present, as defined somewhere in their aboot source. This will appease the
4.2 bootloader and allow us to boot a kernel built on 4.4 sources.

The 4.4 aboot will also append:
"mdss_mdp.panel=1:dsi:0:qcom,mdss_dsi_g2_lgd_cmd" to kernel's command line, so
adding the above to the BOARD_KERNEL_CMDLINE in the device folder is necessary
to get the panel to work. (Thanks to xda user garyd9 for pulling /proc/cmdline)

A big thank you to Dan Rosenberg (djrbliss) for loki (the exploit that allows
for custom boot images)

credits: JackPotCalvin

Signed-off-by: houst0nn <houstonn@gmail.com>
drivers/staging: reduce buffer size to save kernel memory size

Signed-off-by: houst0nn <houstonn@gmail.com>
g2: mmc: msm_sdcc: Support for WIFI_CONTROL_FUNC

PS2: bcmdhd: Reset the hang flag after the notifications are sent
... and put back the pseudo-tuning code in mmc to avoid erroring out
on reinit (thanks rmcc)

Change-Id: I9fea5950378db5041373fc22e65fad4ebf106fea

Signed-off-by: houst0nn <houstonn@gmail.com>
msm: sdcc: Move vdd to optional property

Some devices might not use the vdd. So move vdd to optional property and
avoid controling the vdd in that device if qcom,not-use-vdd exists.

Change-Id: Ic504e7c2f6311cf158fc77fdc28b2723679826af
Signed-off-by: Devin Kim <dojip.kim@lge.com>
Signed-off-by: houst0nn <houstonn@gmail.com>
g2: Linaro 4.8 fixes & use cortex-a15

Signed-off-by: houst0nn <houstonn@gmail.com>
g2: Flesh out the mac address reader & Enable the static buf options

partial fixes from rmcc thanks cm

Signed-off-by: houst0nn <houstonn@gmail.com>
msm: vidc: change interface for opening driver instance

This change will ensure that vidc clients specify the
core id as venus or q6 to open a driver session.
Without this change, sometimes due to driver probe deferral,
core_id_0 would be taken by q6 and vidc clients intending to open a
venus decode session ended up opening a q6 decode session.

Change-Id: I4f9c862b8057999e4db7ca75be493138737a58a8
Signed-off-by: Arun Menon <avmenon@codeaurora.org>
Signed-off-by: houst0nn <houstonn@gmail.com>
msm: vidc: fix corruption of registered buffer list

The buffer list for output buffers is accessed from
different threads leading to race conditions. Consider
the case of firmware throwing up a fatal error, which gets
propagated to v4l2 client. The v4l2 client closes the
driver fd, which will trigger msm_vidc_release_buffers
to release all output buffers and free node from
the registered buffer list. During this time, if
firmware sends a release reference event, the buffer
node being accessed in msm_vidc_release_buffers could
be freed, triggering kernel panic.

Change-Id: I522edff06a62dbc2ab60d6cca5990babb18d5c6c
Signed-off-by: Arun Menon <avmenon@codeaurora.org>
Signed-off-by: houst0nn <houstonn@gmail.com>
msm: vidc: Send ABORT in FLUSH command from the Client

When session error is sent to the client, client issues FLUSH
and release buffers commands. But as instance state is INVALID,
these commands are never sent to the firmware, instead FLUSH
DONE and Release buffer done are sent back to client even
though firmware might be working on these buffers which may
result into page faults.
This change fixes the issue by sending ABORT command to the
firmware at the time when driver receives FLUSH command. Then
firmware will release all buffers, clean up session and send
ABORT_DONE back to the driver.

Change-Id: Ie4c79a312d2336c68b858f5f5e2a85331cf55f7b
CRs-fixed: 592920
Signed-off-by: Deepak Verma <dverma@codeaurora.org>
Signed-off-by: houst0nn <houstonn@gmail.com>
msm: vidc: reduce clk frquency before disable

The change ensures that the clock frequency is reduced to min
before we disable it.
With just clk_disable, rpm still votes for high voltage on CX
as venus vote is not removed.
To unvote, the frequency is set to min.

CRs-Fixed: 574365
Change-Id: I8e0515b9816f8c451d545443573afaba611aafe7
Signed-off-by: Vikash Garodia <vgarodia@codeaurora.org>
Signed-off-by: houst0nn <houstonn@gmail.com>
msm: vidc: Fix unsupported codec error from video driver

- Client is getting unsupported codec error for set format
  sometimes after opening the video driver because driver
  was not updated with supported codecs information from
  video hardware.
- The same issue can be fixed by waiting for the driver state
  changed to CORE_INIT_DONE, which ensures the supported codecs
  information will be updated in video driver, before checking
  the supported codecs information.

CRs-fixed: 590158
Change-Id: Ia9132fdc01e4fa53533a3c9d14069d49501fa7d7
Signed-off-by: Maheshwar Ajja <majja@codeaurora.org>
Signed-off-by: houst0nn <houstonn@gmail.com>
msm: vidc: Fix a race condition in masking interrupts

Fix a race condition when interaction with firmware happens
in following sequence:

1. Firmware writes IDLE message into the message queue.
2. Driver writes a new command into command queue.
3. Firmware reads this command and starts processing it.
4. Driver checks if command queue is empty and finds it empty.
5. Firmware writes the response (of the command sent in 2) in
   message queue. Firmware also writes another IDLE message and
   sets the idle register.
6. Driver check if the IDLE register is set and finds it set.
7. Driver masks the interrupts. Since interrupts are masked,
   driver misses the response written by firmware in 5.

This race condition is fixed by checking if message queue is
empty or not between 6 and 7.

Change-Id: I4e11210deeef855bb67337b8958aea73ae77d16b
Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>
Signed-off-by: houst0nn <houstonn@gmail.com>

Conflicts:
	drivers/media/platform/msm/vidc/venus_hfi.c
msm: vidc: avoid re-initialize of v4l2 spin lock

The fh_lock and fh_list variables are initialized
during probe in video_register_device. This was
re-initialized again when a new video instance was
opened. Since all video instances shared the same
fh_lock and fh_list variable, this gave rise to a race
condition in the v4l2 video driver. Consider the
case of multiple video instances being opened simultaneously.
One video instance has acquired the fh_lock and
calls a v4l2 function which calls v4l2_event_subscribe.
During this time another video instance is opened
and it re-intializes the fh_lock, so the first
instance no longer holds the spin lock and hits
ASSERT in v4l2_event_subscribed. This change
fixes the race condition.

Change-Id: I7af98c8f091cb94e6118c9e2ea1ba5d5d44c6833
Signed-off-by: Arun Menon <avmenon@codeaurora.org>
Signed-off-by: houst0nn <houstonn@gmail.com>

Conflicts:
	drivers/media/platform/msm/vidc/msm_vidc.c
msm: vidc: defer probe if iommu_group_find fails

v4l2 video driver probe needs to defer till
iommu domains probe has been called. Without this
change, v4l2 video driver probe will fail if
iommu domains probe is not invoked prior to it.

Change-Id: Idbc1a4c90e558952f41f51ec96fdd3e7974490cd
Signed-off-by: Arun Menon <avmenon@codeaurora.org>
Signed-off-by: houst0nn <houstonn@gmail.com>
msm: vidc: enable deferred probe support for Q6

Add support to defer probe for Q6 driver. Also fixes
a bug in venus hfi, whereby probe for venus hfi fails
if the core_id is not zero.

Change-Id: I67269107132bf352186fad1e177e4099cf9f4534
Signed-off-by: Arun Menon <avmenon@codeaurora.org>
Signed-off-by: houst0nn <houstonn@gmail.com>
msm: vidc: Disable clock gating for 8x26

There are stability issue observed on 8x26 with
inter-frame clock gating enabled so disable
interframe clock gating on 8x26.

Change-Id: I0e2b89a0ce36ed4d5f15903ffe68b7c7275719c9
Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>
Signed-off-by: houst0nn <houstonn@gmail.com>
msm: vidc: fix memory leak issue in dynamic buffer mode

While flushing output buffers held in v4l2 video
driver, i.e, with ref count equal to 2, the driver
was freeing the binfo structure. This would leak
the mapped output buffer memory. By avoiding
freeing of the binfo structure, the driver waits
for the release reference event from the firmware
to free and unmap the output buffer. Also move
initialization of dequeued flag for buffers to be
held in driver, till the time we queue this buffer
to firmware. By not doing so, the video driver can
enter a race condition, whereby, a output buffer could
be unmapped and freed before v4l2 client has called
dequeue on the buffer.

Change-Id: Ic95f13b9f4426574012539a76c0b87bedb8e805a
Signed-off-by: Arun Menon <avmenon@codeaurora.org>
Signed-off-by: houst0nn <houstonn@gmail.com>
msm: vidc: add sleep of 100us before clock disable

ARM9 execute following sequence when venus is idle
1. Disable ARM9 watchdog
2. Set bit 30 of A_VENUS_CPU_CS_SCIACMDARG0 register
   to indicate venus is idle
3. Write HFI_MSG_SYS_IDLE to message queue
4. Raise interrupt to host
5. ARM9 execute wait for interrupt instruction to go
   into low power state. This will internally drain the
   ARM9 write buffer which can generate bus transaction.
6. ARM9 in idle

Host clock gate venus based on following sequence
1. Host receive HFI_MSG_SYS_IDLE from the msg queue
2. Host check both cmd / msg queue are empty by
   comparing the queue read/write pointers.
3. Host check bit 30 of A_VENUS_CPU_CS_SCIACMDARG0
   register to confirm it indicate idle
4. Host clock gate whole venus

As the host clock gate venus in step 4, ARM9 is still
in step 5&6. The sleep will ensure that step 5 and 6
are completed before host clock gates venus.

CRs-Fixed: 589417
CRs-Fixed: 595251
Change-Id: Idf1f788718adea2dacceca97afa4ba4fe4562ddd
Signed-off-by: Vikash Garodia <vgarodia@codeaurora.org>
Signed-off-by: houst0nn <houstonn@gmail.com>
msm: vidc: NULL terminate devicetree match table

Without NULL termination, of_dev_lookup() can run
off the end of the array and looking at invalid data.

Change-Id: Ib7d8b3afdc76d3f196d620d47eb77d4e0bc74d53
CRs-fixed: 582111
Signed-off-by: Sachin Shah <sachins@codeaurora.org>
Signed-off-by: houst0nn <houstonn@gmail.com>