Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c2f03e98 authored by StevenHarperUK's avatar StevenHarperUK Committed by Ethan Chen
Browse files

Add Dock USB Audio Support for Samsung Car / Desk Docks

Ported from CM10, original patch: http://review.cyanogenmod.com/20586

Also includes patches:
DockAudio: Always route audio back to normal on undock.
http://review.cyanogenmod.org/24830

Bugfix: Dock events can have state greater than 1
http://review.cyanogenmod.org/24995

------------------------------------------------------

Samsung docks have a non-sensing USB adio port.
Samsung get around this by having a separate Setting to route the Audio
The Changes made will only add the extra Observer if the Kernel supports the endpoint

  /sys/class/switch/dock/state

Change-Id: I8e8f5001d5c651b07bb6af496bbf806732be21fa
parent f502a9c4
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -69,6 +69,7 @@ final class WiredAccessoryManager implements WiredAccessoryCallbacks {

    private static final String NAME_H2W = "h2w";
    private static final String NAME_USB_AUDIO = "usb_audio";
    private static final String NAME_SAMSUNG_USB_AUDIO = "dock";
    private static final String NAME_HDMI_AUDIO = "hdmi_audio";
    private static final String NAME_HDMI = "hdmi";

@@ -346,8 +347,10 @@ final class WiredAccessoryManager implements WiredAccessoryCallbacks {
            }

            // At any given time accessories could be inserted
            // one on the board, one on the dock and one on HDMI:
            // observe three UEVENTs
            // one on the board, one on the dock, one on the
            // samsung dock and one on HDMI:
            // observe all UEVENTs that have valid switch supported
            // by the Kernel
            for (int i = 0; i < mUEventInfo.size(); ++i) {
                UEventInfo uei = mUEventInfo.get(i);
                startObserving("DEVPATH="+uei.getDevPath());
@@ -383,6 +386,15 @@ final class WiredAccessoryManager implements WiredAccessoryCallbacks {
                Slog.w(TAG, "This kernel does not have usb audio support");
            }

            // Monitor Samsung USB audio
            uei = new UEventInfo(NAME_SAMSUNG_USB_AUDIO, BIT_USB_HEADSET_DGTL,
                                 BIT_USB_HEADSET_ANLG, 0);
            if (uei.checkSwitchExists()) {
                retVal.add(uei);
            } else {
                Slog.w(TAG, "This kernel does not have samsung usb dock audio support");
            }

            // Monitor HDMI
            //
            // If the kernel has support for the "hdmi_audio" switch, use that.  It will be