Fix HTC headset handling.

HTC's headset driver adds additional bits to the switch state, which
we're unable to deal with. Fix that by masking out those bits and
keeping only the valid ones.

Based off: https://gerrit.omnirom.org/#/c/5500/

Original author retained :)

Change-Id: I1abca665488e89f76eae97c4aab86bd51afd2a19
Fixup pin-layout on sw320dp-hdpi and sw320dp devices

Based on: http://review.cyanogenmod.org/#/c/57557/

Note: Though this commit seems to have been already picked here: https://github.com/omnirom/android_frameworks_base/commit/b3904d3255f3ec620f317d7d39b195dcda77c9ba
I don't think it was fully picked :|

Change-Id: I13893069102b82ae74169b51863ccf76b863a380
merge changes from Omni 4.4 into local branch