• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2017 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #ifndef EASEL_MANAGER_CLIENT_H
17 #define EASEL_MANAGER_CLIENT_H
18 
19 #include <future>
20 
21 #include <utils/Errors.h>
22 #include <utils/Mutex.h>
23 
24 #define FW_VER_SIZE 24
25 
26 namespace android {
27 
28 class EaselManagerClientListener;
29 class HdrPlusClient;
30 class HdrPlusClientListener;
31 
32 class EaselManagerClient {
33 public:
34     static std::unique_ptr<EaselManagerClient> create();
35 
EaselManagerClient()36     EaselManagerClient() {};
~EaselManagerClient()37     virtual ~EaselManagerClient() {};
38 
39     /*
40      * Return if Easel is present on the device.
41      *
42      * If Easel is not present, all other calls to HdrPlusClient are invalid.
43      */
44     virtual bool isEaselPresentOnDevice() const = 0;
45 
46     /*
47      * Open Easel manager client.
48      *
49      * This will power on Easel and initialize Easel manager client.
50      */
51     virtual status_t open() = 0;
52 
53     /*
54      * Suspend Easel.
55      *
56      * Put Easel on suspend mode.
57      */
58     virtual status_t suspend() = 0;
59 
60     /*
61      * Resume Easel.
62      *
63      * Resume Easel from suspend mode.
64      *
65      * listener will be invoked for Easel status.
66      */
67     virtual status_t resume(EaselManagerClientListener *listener) = 0;
68 
69     /*
70      * Retrieve Easel firmware version.
71      *
72      * Firmware version string is added to image exif
73      */
74     virtual status_t getFwVersion(char *fwVersion) = 0;
75 
76     /*
77      * Start MIPI with an output pixel lock rate for a camera.
78      *
79      * Can be called when Easel is powered on or resumed, for Easel to start sending sensor data
80      * to AP.
81      *
82      * cameraId is the camera ID to start MIPI for.
83      * outputPixelClkHz is the output pixel rate.
84      * enableCapture is whether to enable MIPI capture on Easel.
85      */
86     virtual status_t startMipi(uint32_t cameraId, uint32_t outputPixelClkHz,
87             bool enableCapture) = 0;
88 
89     /*
90      * Stop MIPI for a camera.
91      *
92      * cameraId is the camera is ID to stop MIPI for.
93      */
94     virtual status_t stopMipi(uint32_t cameraId) = 0;
95 
96     /*
97      * Open an HDR+ client asynchronously.
98      *
99      * Open an HDR+ client asynchronouly. When an HDR+ client is opened,
100      * HdrPlusClientListener::onOpened() will be invoked with the created HDR+ client. If opening
101      * an HDR+ client failed, HdrPlusClientListener::onOpenFailed() will be invoked with the error.
102      * If this method returns an error, HdrPlusClientListener::onOpenFailed() will not be invoked.
103      *
104      * listener is an HDR+ client listener.
105      *
106      * Returns:
107      *  OK:             if initiating opening an HDR+ client asynchronously was successful.
108      *                  HdrPlusClientListener::onOpened() or HdrPlusClientListener::onOpenFailed()
109      *                  will be invoked when opening an HDR+ client completed.
110      *  ALREADY_EXISTS: if there is already a pending HDR+ client being opened.
111      */
112     virtual status_t openHdrPlusClientAsync(HdrPlusClientListener *listener) = 0;
113 
114     /*
115      * Open an HDR+ client synchronously and block until it completes.
116      *
117      * listener is an HDR+ client listener.
118      * client is an output parameter for created HDR+ client.
119      *
120      * Returns:
121      *  OK:         on success.
122      *  -EEXIST:    if an HDR+ client is already opened.
123      *  -ENODEV:    if opening an HDR+ failed due to a serious error.
124      */
125     virtual status_t openHdrPlusClient(HdrPlusClientListener *listener,
126             std::unique_ptr<HdrPlusClient> *client) = 0;
127 
128     /*
129      * Close an HDR+ client.
130      *
131      * client is the HDR+ client to be closed.
132      */
133     virtual void closeHdrPlusClient(std::unique_ptr<HdrPlusClient> client) = 0;
134 
135 private:
136     // Disallow copy and assign.
137     EaselManagerClient(const EaselManagerClient&) = delete;
138     void operator=(const EaselManagerClient&) = delete;
139 };
140 
141 
142 /*
143  * EaselManagerClientListener defines callbacks that will be invoked by EaselManagerClient.
144  */
145 class EaselManagerClientListener {
146 public:
~EaselManagerClientListener()147     virtual ~EaselManagerClientListener() {};
148 
149     // Invoked when Easel encountered a fatal error. Client should shut down Easel.
150     virtual void onEaselFatalError(std::string errMsg) = 0;
151 };
152 
153 } // namespace android
154 
155 #endif // EASEL_MANAGER_CLIENT_H
156