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

Commit c2d3f6ee authored by Badhri Jagan Sridharan's avatar Badhri Jagan Sridharan Committed by Android (Google) Code Review
Browse files

Merge "USB V1.2 interface"

parents 4ee03d1b b577571f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -443,7 +443,7 @@
    </hal>
    <hal format="hidl" optional="true">
        <name>android.hardware.usb</name>
        <version>1.0-1</version>
        <version>1.0-2</version>
        <interface>
            <name>IUsb</name>
            <instance>default</instance>

usb/1.2/Android.bp

0 → 100644
+29 −0
Original line number Diff line number Diff line
// This file is autogenerated by hidl-gen -Landroidbp.

hidl_interface {
    name: "android.hardware.usb@1.2",
    root: "android.hardware",
    vndk: {
        enabled: true,
    },
    srcs: [
        "types.hal",
        "IUsb.hal",
        "IUsbCallback.hal",
    ],
    interfaces: [
        "android.hardware.usb@1.0",
        "android.hardware.usb@1.1",
        "android.hidl.base@1.0",
    ],
    types: [
        "ContaminantDetectionStatus",
        "ContaminantProtectionMode",
        "ContaminantProtectionStatus",
        "PortStatus",
        "Status",
    ],
    gen_java: true,
    gen_java_constants: true,
}

usb/1.2/IUsb.hal

0 → 100644
+65 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.hardware.usb@1.2;

import android.hardware.usb@1.1::IUsb;

/**
 * The setCallback function in V1_0 is used to register the V1_2
 * IUsbCallback object as well. The implementation can use the
 * castFrom method to cast the IUsbCallback object.
 */
interface IUsb extends @1.1::IUsb {
    /**
     * When supportsEnableContaminantPresenceDetection is true,
     * enableContaminantPresenceDetection enables/disables contaminant
     * presence detection algorithm. Calling enableContaminantPresenceDetection
     * when supportsEnableContaminantPresenceDetection is false does
     * not have any effect.
     * Change in contantaminant presence status should notify should
     * be notified to the client via notifyPortStatusChange_1_2 through
     * PortStatus.
     *
     * @param portName name of the port.
     * @param enable true Enable contaminant presence detection algorithm.
     *               false Disable contaminant presence detection algorithm.
     */
    oneway enableContaminantPresenceDetection(string portName, bool enable);

    /**
     * When supportsEnableContaminantPresenceProtection is true,
     * enableContaminantPresenceProtection enables/disables contaminant
     * presence protection algorithm. Calling
     * enableContaminantPresenceProtection
     * when supportsEnableContaminantPresenceProtection is false does
     * not have any effect.
     * Used to enable/disable contaminant presence protection algorithm.
     * Enabling port protection algoritm must make the lower layers to autonomously
     * act on taking the corresponding preventive measure mentioned at
     * ContaminantProtectionModes when contaminant is detected on the USB Port.
     * Calling this method with enable set to true must set to contaminantProtectionEnabled
     * to true upon success and vice versa.
     * currentContaminantProtectionMode should be updated whenever there is a
     * change in the status of contaminant presence protection algorithm.
     *
     * @param portName name of the port.
     * @param enable true Reduce capabilities of the port to protect port
     *                    from damage due to contaminant presence.
     *               false No action is taken upon contaminant presence.
     */
    oneway enableContaminantPresenceProtection(string portName, bool enable);
};
+42 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.hardware.usb@1.2;

import android.hardware.usb@1.1::IUsbCallback;
import android.hardware.usb@1.0::Status;

/**
 * Callback object used for all the IUsb async methods which expects a result.
 * Caller is expected to register the callback object using setCallback method
 * to receive updates on the PortStatus.
 */
interface IUsbCallback extends @1.1::IUsbCallback {
    /**
     * Used to convey the current port status to the caller.
     * Must be called either when PortState changes due to the port partner or
     * when caller requested for the PortStatus update through queryPortStatus.
     *
     * @param currentPortStatus vector object of current status(PortStatus
     * of all the typeC ports in the device.
     * @param retval SUCCESS when the required information was enquired form
     *               kernel and the PortStatus_1_2 object was built.
     *               ERROR otherwise.
     */
    oneway notifyPortStatusChange_1_2(vec<PortStatus> currentPortStatus,
        @1.0::Status retval);
};

usb/1.2/types.hal

0 → 100644
+120 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.hardware.usb@1.2;

import android.hardware.usb@1.1::PortStatus_1_1;
import android.hardware.usb@1.0::Status;

enum Status : @1.0::Status {
    /**
     * Error value returned when the operation is not supported.
     */
    NOT_SUPPORTED = 4,
};

@export
enum ContaminantDetectionStatus : uint32_t {
    /**
     * Contaminant presence detection is not supported.
     */
    NOT_SUPPORTED = 0,

    /**
     * Contaminant presence detection is supported but disabled.
     */
    DISABLED = 1,

    /**
     * Contaminant presence detection is enabled and contaminant not detected.
     */
    NOT_DETECTED = 2,

    /**
     * Contaminant presence detection is enabled and contaminant detected.
     */
    DETECTED = 3,
};

@export
enum ContaminantProtectionMode : uint32_t {
    /**
     * No action performed upon detection of contaminant presence.
     */
    NONE = 0,

    /**
     * Upon detection of contaminant presence, Port is forced to sink only
     * mode where a port shall only detect chargers until contaminant presence
     * is no longer detected.
     */
    FORCE_SINK = 1 << 0,

    /**
     * Upon detection of contaminant presence, Port is forced to source only
     * mode where a port shall only detect usb accessories such as headsets
     * until contaminant presence is no longer detected.
     */
    FORCE_SOURCE = 1 << 1,

    /**
     * Upon detection of contaminant presence, port is disabled until contaminant
     * presence is no longer detected. In the disabled state port will
     * not respond to connection of chargers or usb accessories.
     */
    FORCE_DISABLE = 1 << 2,
};

@export
enum ContaminantProtectionStatus : ContaminantProtectionMode {
    /**
     * Client disabled cotaminant protection by calling
     * enableContaminantPresencePortProtection set to false. Low level drivers should
     * not autmomously take any corrective action when contaminant presence is detected.
     */
    DISABLED = 1 << 3,
};

struct PortStatus {
    PortStatus_1_1 status_1_1;

    /**
     * Contaminant presence protection modes supported by the port.
     */
    bitfield<ContaminantProtectionMode> supportedContaminantProtectionModes;

    /**
     * Client can enable/disable contaminant presence protection through
     * enableContaminantPresenceProtection when true.
     */
    bool supportsEnableContaminantPresenceProtection;

    /**
     * Contaminant presence protection modes currently active for the port.
     */
    ContaminantProtectionStatus contaminantProtectionStatus;

    /**
     * Client can enable/disable contaminant presence detection through
     * enableContaminantPresenceDetection when true.
     */
    bool supportsEnableContaminantPresenceDetection;

    /**
     * Current status of contaminant detection algorithm.
     */
    ContaminantDetectionStatus contaminantDetectionStatus;
};