summaryrefslogtreecommitdiff
path: root/amber/camera/libhdrplusclient/include/EaselManagerClient.h
blob: b7d51682d4ba9cc437c3c30590521342cd2d3684 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/*
 * Copyright 2017 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.
 */
#ifndef EASEL_MANAGER_CLIENT_H
#define EASEL_MANAGER_CLIENT_H

#include <future>

#include <utils/Errors.h>
#include <utils/Mutex.h>

#define FW_VER_SIZE 24

namespace android {

class EaselManagerClientListener;
class HdrPlusClient;
class HdrPlusClientListener;

class EaselManagerClient {
public:
    static std::unique_ptr<EaselManagerClient> create();

    EaselManagerClient() {};
    virtual ~EaselManagerClient() {};

    /*
     * Return if Easel is present on the device.
     *
     * If Easel is not present, all other calls to HdrPlusClient are invalid.
     */
    virtual bool isEaselPresentOnDevice() const = 0;

    /*
     * Open Easel manager client.
     *
     * This will power on Easel and initialize Easel manager client.
     */
    virtual status_t open() = 0;

    /*
     * Suspend Easel.
     *
     * Put Easel on suspend mode.
     */
    virtual status_t suspend() = 0;

    /*
     * Resume Easel.
     *
     * Resume Easel from suspend mode.
     *
     * listener will be invoked for Easel status.
     */
    virtual status_t resume(EaselManagerClientListener *listener) = 0;

    /*
     * Retrieve Easel firmware version.
     *
     * Firmware version string is added to image exif
     */
    virtual status_t getFwVersion(char *fwVersion) = 0;

    /*
     * Start MIPI with an output pixel lock rate for a camera.
     *
     * Can be called when Easel is powered on or resumed, for Easel to start sending sensor data
     * to AP.
     *
     * cameraId is the camera ID to start MIPI for.
     * outputPixelClkHz is the output pixel rate.
     * enableCapture is whether to enable MIPI capture on Easel.
     */
    virtual status_t startMipi(uint32_t cameraId, uint32_t outputPixelClkHz,
            bool enableCapture) = 0;

    /*
     * Stop MIPI for a camera.
     *
     * cameraId is the camera is ID to stop MIPI for.
     */
    virtual status_t stopMipi(uint32_t cameraId) = 0;

    /*
     * Open an HDR+ client asynchronously.
     *
     * Open an HDR+ client asynchronouly. When an HDR+ client is opened,
     * HdrPlusClientListener::onOpened() will be invoked with the created HDR+ client. If opening
     * an HDR+ client failed, HdrPlusClientListener::onOpenFailed() will be invoked with the error.
     * If this method returns an error, HdrPlusClientListener::onOpenFailed() will not be invoked.
     *
     * listener is an HDR+ client listener.
     *
     * Returns:
     *  OK:             if initiating opening an HDR+ client asynchronously was successful.
     *                  HdrPlusClientListener::onOpened() or HdrPlusClientListener::onOpenFailed()
     *                  will be invoked when opening an HDR+ client completed.
     *  ALREADY_EXISTS: if there is already a pending HDR+ client being opened.
     */
    virtual status_t openHdrPlusClientAsync(HdrPlusClientListener *listener) = 0;

    /*
     * Open an HDR+ client synchronously and block until it completes.
     *
     * listener is an HDR+ client listener.
     * client is an output parameter for created HDR+ client.
     *
     * Returns:
     *  OK:         on success.
     *  -EEXIST:    if an HDR+ client is already opened.
     *  -ENODEV:    if opening an HDR+ failed due to a serious error.
     */
    virtual status_t openHdrPlusClient(HdrPlusClientListener *listener,
            std::unique_ptr<HdrPlusClient> *client) = 0;

    /*
     * Close an HDR+ client.
     *
     * client is the HDR+ client to be closed.
     */
    virtual void closeHdrPlusClient(std::unique_ptr<HdrPlusClient> client) = 0;

private:
    // Disallow copy and assign.
    EaselManagerClient(const EaselManagerClient&) = delete;
    void operator=(const EaselManagerClient&) = delete;
};


/*
 * EaselManagerClientListener defines callbacks that will be invoked by EaselManagerClient.
 */
class EaselManagerClientListener {
public:
    virtual ~EaselManagerClientListener() {};

    // Invoked when Easel encountered a fatal error. Client should shut down Easel.
    virtual void onEaselFatalError(std::string errMsg) = 0;

    // Invoked when device is in a thermal condition not suitable for HDR+ processing.
    // Client should disable HDR+ as soon as possible.
    virtual void onThermalThrottle() = 0;
};

} // namespace android

#endif // EASEL_MANAGER_CLIENT_H