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

Commit d2a82466 authored by Changyeon Jo's avatar Changyeon Jo
Browse files

Add methods to get or set camera parameters



This change adds new methods to set and get camera parameters.  As the
vendor may handle a parameter set request with invalid value, a set
method returns an effective value with a status code.

Bug: 138328396
Test: VTS
Change-Id: I278dad6c285fb9b341be3517cde09359da14cda6
Signed-off-by: default avatarChangyeon Jo <changyeon@google.com>
parent bdcf6589
Loading
Loading
Loading
Loading
+55 −0
Original line number Diff line number Diff line
@@ -54,4 +54,59 @@ interface IEvsCamera extends @1.0::IEvsCamera {
     * @return result Return EvsResult::OK if this call is successful.
     */
    doneWithFrame_1_1(BufferDesc buffer) generates (EvsResult result);

    /**
     * Requests to be a master client.
     *
     * When multiple clients subscribe to a single camera hardware and one of
     * them adjusts a camera parameter such as the contrast, it may disturb
     * other clients' operations.  Therefore, the client must call this method
     * to be a master client.  Once it becomes a master, it will be able to
     * change camera parameters until either it dies or explicitly gives up the
     * role.
     *
     * @return result EvsResult::OK if a master role is granted.
     *                EvsResult::OWNERSHIP_LOST if there is already a
     *                master client.
     */
    setMaster() generates (EvsResult result);


    /**
     * Retires from a master client role.
     *
     * @return result EvsResult::OK if this call is successful.
     *                EvsResult::INVALID_ARG if the caller client is not a
     *                master client.
     */
    unsetMaster() generates (EvsResult result);

    /**
     * Requests to set a camera parameter.
     *
     * @param  id             The identifier of camera parameter, CameraParam enum.
     *         value          A desired parameter value.
     * @return result         EvsResult::OK if it succeeds to set a parameter.
     *                        EvsResult::INVALID_ARG if either the request is
     *                        not made by a master client, or a requested
     *                        parameter is not supported.
     *                        EvsResult::UNDERLYING_SERVICE_ERROR if it fails to
     *                        program a value by any other reason.
     *         effectiveValue A programmed parameter value.  This may differ
     *                        from what the client gives if, for example, the
     *                        driver does not support a target parameter.
     */
    setParameter(CameraParam id, int32_t value)
        generates (EvsResult result, int32_t effectiveValue);

    /**
     * Retrieves a value of given camera parameter.
     *
     * @param  id     The identifier of camera parameter, CameraParam enum.
     * @return result EvsResult::OK if it succeeds to read a parameter.
     *                EvsResult::INVALID_ARG if either a requested parameter is
     *                not supported.
     *         value  A value of requested camera parameter.
     */
    getParameter(CameraParam id) generates(EvsResult result, int32_t value);
};
+1 −1
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ package android.hardware.automotive.evs@1.1;
import @1.0::IEvsCameraStream;

/**
 * Implemented on client side to receive asynchronous video frame deliveries.
 * Implemented on client side to receive asynchronous streaming event deliveries.
 */
interface IEvsCameraStream extends @1.0::IEvsCameraStream {
    /**
+35 −1
Original line number Diff line number Diff line
@@ -258,6 +258,38 @@ Return<EvsResult> EvsCamera::resumeVideoStream() {
}


Return<EvsResult> EvsCamera::setMaster() {
    // Default implementation does not expect multiple subscribers and therefore
    // return a success code always.
    return EvsResult::OK;
}


Return<EvsResult> EvsCamera::unsetMaster() {
    // Default implementation does not expect multiple subscribers and therefore
    // return a success code always.
    return EvsResult::OK;
}


Return<void> EvsCamera::setParameter(CameraParam id, int32_t value,
                                     setParameter_cb _hidl_cb) {
    // Default implementation does not support this.
    (void)id;
    (void)value;
    _hidl_cb(EvsResult::INVALID_ARG, 0);
    return Void();
}


Return<void> EvsCamera::getParameter(CameraParam id, getParameter_cb _hidl_cb) {
    // Default implementation does not support this.
    (void)id;
    _hidl_cb(EvsResult::INVALID_ARG, 0);
    return Void();
}


bool EvsCamera::setAvailableFrames_Locked(unsigned bufferCount) {
    if (bufferCount < 1) {
        ALOGE("Ignoring request to set buffer count to zero");
@@ -468,7 +500,9 @@ void EvsCamera::generateFrames() {

    // If we've been asked to stop, send an event to signal the actual end of stream
    EvsEvent event;
    event.info(EvsEventType::STREAM_STOPPED);
    InfoEventDesc desc = {};
    desc.aType = InfoEventType::STREAM_STOPPED;
    event.info(desc);
    auto result = mStream->notifyEvent(event);
    if (!result.isOk()) {
        ALOGE("Error delivering end of stream marker");
+5 −0
Original line number Diff line number Diff line
@@ -60,6 +60,11 @@ public:
    Return<EvsResult> pauseVideoStream() override;
    Return<EvsResult> resumeVideoStream() override;
    Return<EvsResult> doneWithFrame_1_1(const BufferDesc_1_1& buffer) override;
    Return<EvsResult> setMaster() override;
    Return<EvsResult> unsetMaster() override;
    Return<void>      setParameter(CameraParam id, int32_t value,
                                   setParameter_cb _hidl_cb) override;
    Return<void>      getParameter(CameraParam id, getParameter_cb _hidl_cb) override;

    // Implementation details
    EvsCamera(const char *id);
+91 −3
Original line number Diff line number Diff line
@@ -48,9 +48,9 @@ struct BufferDesc {
};

/**
 * EVS event types
 * Types of informative streaming events
 */
enum EvsEventType : uint32_t {
enum InfoEventType : uint32_t {
    /**
     * Video stream is started
     */
@@ -67,6 +67,25 @@ enum EvsEventType : uint32_t {
     * Timeout happens
     */
    TIMEOUT,
    /**
     * Camera parameter is changed; payload contains a changed parameter ID and
     * its value
     */
    PARAMETER_CHANGED,
};

/**
 * Structure that describes informative events occurred during EVS is streaming
 */
struct InfoEventDesc {
    /**
     * Type of an informative event
     */
    InfoEventType aType;
    /**
     * Possible additional information
     */
    uint32_t[4] payload;
};

/**
@@ -80,5 +99,74 @@ safe_union EvsEvent {
    /**
     * General streaming events
     */
    EvsEventType info;
    InfoEventDesc info;
};

/**
 * EVS Camera Parameter
 */
enum CameraParam : uint32_t {
    /**
     * The brightness of image frames
     */
    BRIGHTNESS,
    /**
     * The contrast of image frames
     */
    CONTRAST,
    /**
     * Automatic gain/exposure control
     */
    AUTOGAIN,
    /**
     * Gain control
     */
    GAIN,
    /**
     * Mirror the image horizontally
     */
    HFLIP,
    /**
     * Mirror the image vertically
     */
    VFLIP,
    /**
     * Automatic Whitebalance
     */
    AUTO_WHITE_BALANCE,
    /**
     * Manual white balance setting as a color temperature in Kelvin.
     */
    WHITE_BALANCE_TEMPERATURE,
    /**
     * Image sharpness adjustment
     */
    SHARPNESS,
    /**
     * Auto Exposure Control modes; auto, manual, shutter priority, or
     * aperture priority.
     */
    AUTO_EXPOSURE,
    /**
     * Manual exposure time of the camera
     */
    ABSOLUTE_EXPOSURE,
    /**
     * When AEC is running in either auto or aperture priority, this parameter
     * sets whether a frame rate varies.
     */
    AUTO_EXPOSURE_PRIORITY,
    /**
     * Set the focal point of the camera to the specified position.  This
     * parameter may not be effective when auto focus is enabled.
     */
    ABSOLUTE_FOCUS,
    /**
     * Enables continuous automatic focus adjustments.
     */
    AUTO_FOCUS,
    /**
     * Specify the objective lens focal length as an absolute value.
     */
    ABSOLUTE_ZOOM,
};
Loading