diff options
author | android-build-team Robot | 2018-04-08 02:21:02 -0500 |
---|---|---|
committer | android-build-team Robot | 2018-04-08 02:21:02 -0500 |
commit | ebb05da501b44f78c2a19f44db242ee853f13525 (patch) | |
tree | 408efa384686850ab6dc21c2403c0d28a6c118cc | |
parent | 4872521089b0498fb543c0ce09a07cccc99b33a6 (diff) | |
parent | 7f8caede5fde14f1a4601083c1523bd018ea6d81 (diff) | |
download | platform-hardware-interfaces-ebb05da501b44f78c2a19f44db242ee853f13525.tar.gz platform-hardware-interfaces-ebb05da501b44f78c2a19f44db242ee853f13525.tar.xz platform-hardware-interfaces-ebb05da501b44f78c2a19f44db242ee853f13525.zip |
Snap for 4706961 from 7f8caede5fde14f1a4601083c1523bd018ea6d81 to pi-release
Change-Id: I793952fc632a383c57e298e59492ac9e0feac19b
-rw-r--r-- | camera/device/3.4/default/ExternalCameraDevice.cpp | 24 | ||||
-rw-r--r-- | camera/device/3.4/default/ExternalCameraDeviceSession.cpp | 41 | ||||
-rw-r--r-- | camera/device/3.4/default/include/ext_device_v3_4_impl/ExternalCameraDeviceSession.h | 4 | ||||
-rw-r--r-- | camera/provider/2.4/default/ExternalCameraProvider.cpp | 32 | ||||
-rw-r--r-- | health/2.0/README | 25 | ||||
-rw-r--r-- | health/2.0/default/Health.cpp | 12 |
6 files changed, 115 insertions, 23 deletions
diff --git a/camera/device/3.4/default/ExternalCameraDevice.cpp b/camera/device/3.4/default/ExternalCameraDevice.cpp index 6b05d4a5..ee7ffaa8 100644 --- a/camera/device/3.4/default/ExternalCameraDevice.cpp +++ b/camera/device/3.4/default/ExternalCameraDevice.cpp | |||
@@ -42,6 +42,9 @@ const std::array<uint32_t, /*size*/1> kSupportedFourCCs {{ | |||
42 | V4L2_PIX_FMT_MJPEG | 42 | V4L2_PIX_FMT_MJPEG |
43 | }}; // double braces required in C++11 | 43 | }}; // double braces required in C++11 |
44 | 44 | ||
45 | constexpr int MAX_RETRY = 5; // Allow retry v4l2 open failures a few times. | ||
46 | constexpr int OPEN_RETRY_SLEEP_US = 100000; // 100ms * MAX_RETRY = 0.5 seconds | ||
47 | |||
45 | } // anonymous namespace | 48 | } // anonymous namespace |
46 | 49 | ||
47 | ExternalCameraDevice::ExternalCameraDevice( | 50 | ExternalCameraDevice::ExternalCameraDevice( |
@@ -122,11 +125,22 @@ Return<void> ExternalCameraDevice::open( | |||
122 | 125 | ||
123 | unique_fd fd(::open(mCameraId.c_str(), O_RDWR)); | 126 | unique_fd fd(::open(mCameraId.c_str(), O_RDWR)); |
124 | if (fd.get() < 0) { | 127 | if (fd.get() < 0) { |
125 | ALOGE("%s: v4l2 device open %s failed: %s", | 128 | int numAttempt = 0; |
126 | __FUNCTION__, mCameraId.c_str(), strerror(errno)); | 129 | do { |
127 | mLock.unlock(); | 130 | ALOGW("%s: v4l2 device %s open failed, wait 33ms and try again", |
128 | _hidl_cb(Status::INTERNAL_ERROR, nullptr); | 131 | __FUNCTION__, mCameraId.c_str()); |
129 | return Void(); | 132 | usleep(OPEN_RETRY_SLEEP_US); // sleep and try again |
133 | fd.reset(::open(mCameraId.c_str(), O_RDWR)); | ||
134 | numAttempt++; | ||
135 | } while (fd.get() < 0 && numAttempt <= MAX_RETRY); | ||
136 | |||
137 | if (fd.get() < 0) { | ||
138 | ALOGE("%s: v4l2 device open %s failed: %s", | ||
139 | __FUNCTION__, mCameraId.c_str(), strerror(errno)); | ||
140 | mLock.unlock(); | ||
141 | _hidl_cb(Status::INTERNAL_ERROR, nullptr); | ||
142 | return Void(); | ||
143 | } | ||
130 | } | 144 | } |
131 | 145 | ||
132 | session = new ExternalCameraDeviceSession( | 146 | session = new ExternalCameraDeviceSession( |
diff --git a/camera/device/3.4/default/ExternalCameraDeviceSession.cpp b/camera/device/3.4/default/ExternalCameraDeviceSession.cpp index bb11d7cd..1af3f39e 100644 --- a/camera/device/3.4/default/ExternalCameraDeviceSession.cpp +++ b/camera/device/3.4/default/ExternalCameraDeviceSession.cpp | |||
@@ -49,7 +49,7 @@ const int kBadFramesAfterStreamOn = 1; // drop x frames after streamOn to get ri | |||
49 | // method | 49 | // method |
50 | constexpr int MAX_RETRY = 15; // Allow retry some ioctl failures a few times to account for some | 50 | constexpr int MAX_RETRY = 15; // Allow retry some ioctl failures a few times to account for some |
51 | // webcam showing temporarily ioctl failures. | 51 | // webcam showing temporarily ioctl failures. |
52 | constexpr int IOCTL_RETRY_SLEEP_US = 33000; // 33ms * MAX_RETRY = 5 seconds | 52 | constexpr int IOCTL_RETRY_SLEEP_US = 33000; // 33ms * MAX_RETRY = 0.5 seconds |
53 | 53 | ||
54 | // Constants for tryLock during dumpstate | 54 | // Constants for tryLock during dumpstate |
55 | static constexpr int kDumpLockRetries = 50; | 55 | static constexpr int kDumpLockRetries = 50; |
@@ -115,6 +115,35 @@ bool ExternalCameraDeviceSession::initialize() { | |||
115 | return true; | 115 | return true; |
116 | } | 116 | } |
117 | 117 | ||
118 | struct v4l2_capability capability; | ||
119 | int ret = ioctl(mV4l2Fd.get(), VIDIOC_QUERYCAP, &capability); | ||
120 | std::string make, model; | ||
121 | if (ret < 0) { | ||
122 | ALOGW("%s v4l2 QUERYCAP failed", __FUNCTION__); | ||
123 | make = "Generic UVC webcam"; | ||
124 | model = "Generic UVC webcam"; | ||
125 | } else { | ||
126 | // capability.card is UTF-8 encoded | ||
127 | char card[32]; | ||
128 | int j = 0; | ||
129 | for (int i = 0; i < 32; i++) { | ||
130 | if (capability.card[i] < 128) { | ||
131 | card[j++] = capability.card[i]; | ||
132 | } | ||
133 | if (capability.card[i] == '\0') { | ||
134 | break; | ||
135 | } | ||
136 | } | ||
137 | if (j == 0 || card[j - 1] != '\0') { | ||
138 | make = "Generic UVC webcam"; | ||
139 | model = "Generic UVC webcam"; | ||
140 | } else { | ||
141 | make = card; | ||
142 | model = card; | ||
143 | } | ||
144 | } | ||
145 | mOutputThread->setExifMakeModel(make, model); | ||
146 | |||
118 | status_t status = initDefaultRequests(); | 147 | status_t status = initDefaultRequests(); |
119 | if (status != OK) { | 148 | if (status != OK) { |
120 | ALOGE("%s: init default requests failed!", __FUNCTION__); | 149 | ALOGE("%s: init default requests failed!", __FUNCTION__); |
@@ -826,6 +855,12 @@ ExternalCameraDeviceSession::OutputThread::OutputThread( | |||
826 | 855 | ||
827 | ExternalCameraDeviceSession::OutputThread::~OutputThread() {} | 856 | ExternalCameraDeviceSession::OutputThread::~OutputThread() {} |
828 | 857 | ||
858 | void ExternalCameraDeviceSession::OutputThread::setExifMakeModel( | ||
859 | const std::string& make, const std::string& model) { | ||
860 | mExifMake = make; | ||
861 | mExifModel = model; | ||
862 | } | ||
863 | |||
829 | uint32_t ExternalCameraDeviceSession::OutputThread::getFourCcFromLayout( | 864 | uint32_t ExternalCameraDeviceSession::OutputThread::getFourCcFromLayout( |
830 | const YCbCrLayout& layout) { | 865 | const YCbCrLayout& layout) { |
831 | intptr_t cb = reinterpret_cast<intptr_t>(layout.cb); | 866 | intptr_t cb = reinterpret_cast<intptr_t>(layout.cb); |
@@ -1611,6 +1646,8 @@ int ExternalCameraDeviceSession::OutputThread::createJpegLocked( | |||
1611 | utils->initialize(); | 1646 | utils->initialize(); |
1612 | 1647 | ||
1613 | utils->setFromMetadata(meta, jpegSize.width, jpegSize.height); | 1648 | utils->setFromMetadata(meta, jpegSize.width, jpegSize.height); |
1649 | utils->setMake(mExifMake); | ||
1650 | utils->setModel(mExifModel); | ||
1614 | 1651 | ||
1615 | ret = utils->generateApp1(outputThumbnail ? &thumbCode[0] : 0, thumbCodeSize); | 1652 | ret = utils->generateApp1(outputThumbnail ? &thumbCode[0] : 0, thumbCodeSize); |
1616 | 1653 | ||
@@ -2150,7 +2187,7 @@ int ExternalCameraDeviceSession::configureV4l2StreamLocked( | |||
2150 | int numAttempt = 0; | 2187 | int numAttempt = 0; |
2151 | while (ret < 0) { | 2188 | while (ret < 0) { |
2152 | ALOGW("%s: VIDIOC_S_FMT failed, wait 33ms and try again", __FUNCTION__); | 2189 | ALOGW("%s: VIDIOC_S_FMT failed, wait 33ms and try again", __FUNCTION__); |
2153 | usleep(IOCTL_RETRY_SLEEP_US); // sleep 100 ms and try again | 2190 | usleep(IOCTL_RETRY_SLEEP_US); // sleep and try again |
2154 | ret = TEMP_FAILURE_RETRY(ioctl(mV4l2Fd.get(), VIDIOC_S_FMT, &fmt)); | 2191 | ret = TEMP_FAILURE_RETRY(ioctl(mV4l2Fd.get(), VIDIOC_S_FMT, &fmt)); |
2155 | if (numAttempt == MAX_RETRY) { | 2192 | if (numAttempt == MAX_RETRY) { |
2156 | break; | 2193 | break; |
diff --git a/camera/device/3.4/default/include/ext_device_v3_4_impl/ExternalCameraDeviceSession.h b/camera/device/3.4/default/include/ext_device_v3_4_impl/ExternalCameraDeviceSession.h index 14e5c9a4..0b94c112 100644 --- a/camera/device/3.4/default/include/ext_device_v3_4_impl/ExternalCameraDeviceSession.h +++ b/camera/device/3.4/default/include/ext_device_v3_4_impl/ExternalCameraDeviceSession.h | |||
@@ -231,6 +231,7 @@ protected: | |||
231 | void dump(int fd); | 231 | void dump(int fd); |
232 | virtual bool threadLoop() override; | 232 | virtual bool threadLoop() override; |
233 | 233 | ||
234 | void setExifMakeModel(const std::string& make, const std::string& model); | ||
234 | private: | 235 | private: |
235 | static const uint32_t FLEX_YUV_GENERIC = static_cast<uint32_t>('F') | | 236 | static const uint32_t FLEX_YUV_GENERIC = static_cast<uint32_t>('F') | |
236 | static_cast<uint32_t>('L') << 8 | static_cast<uint32_t>('E') << 16 | | 237 | static_cast<uint32_t>('L') << 8 | static_cast<uint32_t>('E') << 16 | |
@@ -288,6 +289,9 @@ protected: | |||
288 | std::unordered_map<Size, sp<AllocatedFrame>, SizeHasher> mScaledYu12Frames; | 289 | std::unordered_map<Size, sp<AllocatedFrame>, SizeHasher> mScaledYu12Frames; |
289 | YCbCrLayout mYu12FrameLayout; | 290 | YCbCrLayout mYu12FrameLayout; |
290 | YCbCrLayout mYu12ThumbFrameLayout; | 291 | YCbCrLayout mYu12ThumbFrameLayout; |
292 | |||
293 | std::string mExifMake; | ||
294 | std::string mExifModel; | ||
291 | }; | 295 | }; |
292 | 296 | ||
293 | // Protect (most of) HIDL interface methods from synchronized-entering | 297 | // Protect (most of) HIDL interface methods from synchronized-entering |
diff --git a/camera/provider/2.4/default/ExternalCameraProvider.cpp b/camera/provider/2.4/default/ExternalCameraProvider.cpp index 285e96bc..a4046d09 100644 --- a/camera/provider/2.4/default/ExternalCameraProvider.cpp +++ b/camera/provider/2.4/default/ExternalCameraProvider.cpp | |||
@@ -164,29 +164,35 @@ void ExternalCameraProvider::addExternalCamera(const char* devName) { | |||
164 | } | 164 | } |
165 | 165 | ||
166 | void ExternalCameraProvider::deviceAdded(const char* devName) { | 166 | void ExternalCameraProvider::deviceAdded(const char* devName) { |
167 | int fd = -1; | 167 | { |
168 | if ((fd = ::open(devName, O_RDWR)) < 0) { | 168 | base::unique_fd fd(::open(devName, O_RDWR)); |
169 | ALOGE("%s open v4l2 device %s failed:%s", __FUNCTION__, devName, strerror(errno)); | 169 | if (fd.get() < 0) { |
170 | return; | 170 | ALOGE("%s open v4l2 device %s failed:%s", __FUNCTION__, devName, strerror(errno)); |
171 | } | 171 | return; |
172 | } | ||
172 | 173 | ||
173 | do { | ||
174 | struct v4l2_capability capability; | 174 | struct v4l2_capability capability; |
175 | int ret = ioctl(fd, VIDIOC_QUERYCAP, &capability); | 175 | int ret = ioctl(fd.get(), VIDIOC_QUERYCAP, &capability); |
176 | if (ret < 0) { | 176 | if (ret < 0) { |
177 | ALOGE("%s v4l2 QUERYCAP %s failed", __FUNCTION__, devName); | 177 | ALOGE("%s v4l2 QUERYCAP %s failed", __FUNCTION__, devName); |
178 | break; | 178 | return; |
179 | } | 179 | } |
180 | 180 | ||
181 | if (!(capability.device_caps & V4L2_CAP_VIDEO_CAPTURE)) { | 181 | if (!(capability.device_caps & V4L2_CAP_VIDEO_CAPTURE)) { |
182 | ALOGW("%s device %s does not support VIDEO_CAPTURE", __FUNCTION__, devName); | 182 | ALOGW("%s device %s does not support VIDEO_CAPTURE", __FUNCTION__, devName); |
183 | break; | 183 | return; |
184 | } | 184 | } |
185 | } | ||
186 | // See if we can initialize ExternalCameraDevice correctly | ||
187 | sp<device::V3_4::implementation::ExternalCameraDevice> deviceImpl = | ||
188 | new device::V3_4::implementation::ExternalCameraDevice(devName, mCfg); | ||
189 | if (deviceImpl == nullptr || deviceImpl->isInitFailed()) { | ||
190 | ALOGW("%s: Attempt to init camera device %s failed!", __FUNCTION__, devName); | ||
191 | return; | ||
192 | } | ||
193 | deviceImpl.clear(); | ||
185 | 194 | ||
186 | addExternalCamera(devName); | 195 | addExternalCamera(devName); |
187 | } while (0); | ||
188 | |||
189 | close(fd); | ||
190 | return; | 196 | return; |
191 | } | 197 | } |
192 | 198 | ||
diff --git a/health/2.0/README b/health/2.0/README index 49b2b1eb..11e6a7aa 100644 --- a/health/2.0/README +++ b/health/2.0/README | |||
@@ -1,11 +1,18 @@ | |||
1 | Upgrading from health@1.0 HAL | 1 | Upgrading from health@1.0 HAL |
2 | 2 | ||
3 | 0. Remove android.hardware.health@1.0* from PRDOUCT_PACKAGES | 3 | 0. Remove android.hardware.health@1.0* from PRODUCT_PACKAGES |
4 | in device/<manufacturer>/<device>/device.mk | 4 | in device/<manufacturer>/<device>/device.mk |
5 | 5 | ||
6 | 1. If the device does not have a vendor-specific libhealthd AND does not | 6 | 1. If the device does not have a vendor-specific libhealthd AND does not |
7 | implement storage-related APIs, just add the following to PRODUCT_PACKAGES: | 7 | implement storage-related APIs, just do the following: |
8 | android.hardware.health@2.0-service | 8 | |
9 | 1.1 (recommended) To remove healthd from the build, | ||
10 | PRODUCT_PACKAGES += android.hardware.health@2.0-service.override | ||
11 | DEVICE_FRAMEWORK_MANIFEST_FILE += \ | ||
12 | system/libhidl/vintfdata/manifest_healthd_exclude.xml | ||
13 | 1.2 To keep healthd in the build, | ||
14 | PRODUCT_PACKAGES += android.hardware.health@2.0-service | ||
15 | |||
9 | Otherwise, continue to Step 2. | 16 | Otherwise, continue to Step 2. |
10 | 17 | ||
11 | 2. Create directory | 18 | 2. Create directory |
@@ -45,14 +52,26 @@ cc_binary { | |||
45 | ], | 52 | ], |
46 | 53 | ||
47 | header_libs: ["libhealthd_headers"], | 54 | header_libs: ["libhealthd_headers"], |
55 | |||
56 | // Uncomment the following to remove healthd from the build. | ||
57 | // overrides: [ | ||
58 | // "healthd", | ||
59 | // ], | ||
48 | } | 60 | } |
49 | 61 | ||
62 | 3.1 (recommended) To remove healthd from the build, keep "overrides" | ||
63 | section, and include the following in device.mk: | ||
64 | DEVICE_FRAMEWORK_MANIFEST_FILE += \ | ||
65 | system/libhidl/vintfdata/manifest_healthd_exclude.xml | ||
66 | 3.2 To keep healthd in the build, remove "overrides" section. | ||
67 | |||
50 | 4. Create device/<manufacturer>/<device>/health/android.hardware.health@2.0-service.<device>.rc | 68 | 4. Create device/<manufacturer>/<device>/health/android.hardware.health@2.0-service.<device>.rc |
51 | 69 | ||
52 | service vendor.health-hal-2-0 /vendor/bin/hw/android.hardware.health@2.0-service.<device> | 70 | service vendor.health-hal-2-0 /vendor/bin/hw/android.hardware.health@2.0-service.<device> |
53 | class hal | 71 | class hal |
54 | user system | 72 | user system |
55 | group system | 73 | group system |
74 | file /dev/kmsg w | ||
56 | 75 | ||
57 | 5. Create device/<manufacturer>/<device>/health/HealthService.cpp: | 76 | 5. Create device/<manufacturer>/<device>/health/HealthService.cpp: |
58 | 77 | ||
diff --git a/health/2.0/default/Health.cpp b/health/2.0/default/Health.cpp index 7a3e6504..6d3be992 100644 --- a/health/2.0/default/Health.cpp +++ b/health/2.0/default/Health.cpp | |||
@@ -16,6 +16,7 @@ | |||
16 | #define LOG_TAG "android.hardware.health@2.0-impl" | 16 | #define LOG_TAG "android.hardware.health@2.0-impl" |
17 | #include <android-base/logging.h> | 17 | #include <android-base/logging.h> |
18 | 18 | ||
19 | #include <android-base/file.h> | ||
19 | #include <health2/Health.h> | 20 | #include <health2/Health.h> |
20 | 21 | ||
21 | #include <hal_conversion.h> | 22 | #include <hal_conversion.h> |
@@ -189,6 +190,17 @@ Return<void> Health::debug(const hidl_handle& handle, const hidl_vec<hidl_string | |||
189 | if (handle != nullptr && handle->numFds >= 1) { | 190 | if (handle != nullptr && handle->numFds >= 1) { |
190 | int fd = handle->data[0]; | 191 | int fd = handle->data[0]; |
191 | battery_monitor_->dumpState(fd); | 192 | battery_monitor_->dumpState(fd); |
193 | |||
194 | getHealthInfo([fd](auto res, const auto& info) { | ||
195 | android::base::WriteStringToFd("\ngetHealthInfo -> ", fd); | ||
196 | if (res == Result::SUCCESS) { | ||
197 | android::base::WriteStringToFd(toString(info), fd); | ||
198 | } else { | ||
199 | android::base::WriteStringToFd(toString(res), fd); | ||
200 | } | ||
201 | android::base::WriteStringToFd("\n", fd); | ||
202 | }); | ||
203 | |||
192 | fsync(fd); | 204 | fsync(fd); |
193 | } | 205 | } |
194 | return Void(); | 206 | return Void(); |