| /* |
| * Copyright 2016 The Chromium OS Authors. All rights reserved. |
| * Use of this source code is governed by a BSD-style license that can be |
| * found in the LICENSE file. |
| */ |
| |
| #ifndef HAL_USB_COMMON_TYPES_H_ |
| #define HAL_USB_COMMON_TYPES_H_ |
| |
| #include <string> |
| #include <vector> |
| |
| #include "cros-camera/timezone.h" |
| |
| namespace cros { |
| |
| struct DeviceInfo { |
| // ex: /dev/video0 |
| std::string device_path; |
| // USB vender id |
| std::string usb_vid; |
| // USB product id |
| std::string usb_pid; |
| // Some cameras need to wait several frames to output correct images. |
| uint32_t frames_to_skip_after_streamon; |
| // Power line frequency supported by device. |
| PowerLineFrequency power_line_frequency; |
| |
| // Member definitions can be found in https://developer.android.com/ |
| // reference/android/hardware/camera2/CameraCharacteristics.html |
| uint32_t lens_facing; |
| int32_t sensor_orientation; |
| float horizontal_view_angle_16_9; |
| float horizontal_view_angle_4_3; |
| std::vector<float> lens_info_available_focal_lengths; |
| float lens_info_minimum_focus_distance; |
| float lens_info_optimal_focus_distance; |
| float vertical_view_angle_16_9; |
| float vertical_view_angle_4_3; |
| // The camera doesn't support 1280x960 resolution when the maximum resolution |
| // of the camear is larger than 1080p. |
| bool resolution_1280x960_unsupported; |
| // The camera doesn't support 1600x1200 resolution. |
| bool resolution_1600x1200_unsupported; |
| // The camera doesn't support constant frame rate. That means HAL cannot set |
| // V4L2_CID_EXPOSURE_AUTO_PRIORITY to 0 to have constant frame rate in low |
| // light environment. |
| bool constant_framerate_unsupported; |
| int32_t sensor_info_pixel_array_size_width; |
| int32_t sensor_info_pixel_array_size_height; |
| std::vector<float> lens_info_available_apertures; |
| float sensor_info_physical_size_width; |
| float sensor_info_physical_size_height; |
| }; |
| |
| typedef std::vector<DeviceInfo> DeviceInfos; |
| |
| struct SupportedFormat { |
| uint32_t width; |
| uint32_t height; |
| uint32_t fourcc; |
| // All the supported frame rates in fps with given width, height, and |
| // pixelformat. This is not sorted. For example, suppose width, height, and |
| // fourcc are 640x480 YUYV. If frame rates are 15.0 and 30.0, the camera |
| // supports outputting 640X480 YUYV in 15fps or 30fps. |
| std::vector<float> frame_rates; |
| }; |
| |
| typedef std::vector<SupportedFormat> SupportedFormats; |
| |
| struct Size { |
| Size(uint32_t w, uint32_t h) : width(w), height(h) {} |
| uint32_t width; |
| uint32_t height; |
| uint64_t Area() const { return static_cast<uint64_t>(width) * height; } |
| bool operator<(const Size& rhs) const { |
| if (Area() != rhs.Area()) { |
| return Area() < rhs.Area(); |
| } |
| // No need to compare by height even if widths are same, because we compare |
| // by area first. |
| return width < rhs.width; |
| } |
| bool operator==(const Size& rhs) const { |
| return width == rhs.width && height == rhs.height; |
| } |
| }; |
| |
| } // namespace cros |
| |
| #endif // HAL_USB_COMMON_TYPES_H_ |