Steve Paik | 0ed145e | 2016-01-25 11:30:16 -0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2016 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 | |
| 17 | #ifndef ANDROID_VEHICLE_RVC_INTERFACE_H |
| 18 | #define ANDROID_VEHICLE_RVC_INTERFACE_H |
| 19 | |
| 20 | #include <stdint.h> |
| 21 | #include <sys/cdefs.h> |
| 22 | #include <sys/types.h> |
| 23 | #include <errno.h> |
| 24 | |
| 25 | #include <hardware/hardware.h> |
| 26 | #include <cutils/native_handle.h> |
| 27 | |
| 28 | __BEGIN_DECLS |
| 29 | |
| 30 | /*****************************************************************************/ |
| 31 | |
| 32 | #define VEHICLE_RVC_HEADER_VERSION 1 |
| 33 | #define VEHICLE_RVC_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0) |
| 34 | #define VEHICLE_RVC_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION_2(1, 0, VEHICLE_RVC_HEADER_VERSION) |
| 35 | |
| 36 | /** |
| 37 | * Vehicle Rearview Camera to provide interfaces for controlling |
| 38 | * the RVC. |
| 39 | */ |
| 40 | |
| 41 | /** |
| 42 | * The id of this module |
| 43 | */ |
| 44 | #define VEHICLE_RVC_HARDWARE_MODULE_ID "vehicle_rvc" |
| 45 | |
| 46 | /** |
| 47 | * Name of the vehicle device to open |
| 48 | */ |
| 49 | #define VEHICLE_RVC_HARDWARE_DEVICE "vehicle_rvc_hw_device" |
| 50 | |
| 51 | /** |
| 52 | * Describes the current state of RVC module |
| 53 | */ |
| 54 | typedef struct { |
| 55 | uint32_t overlay_on; |
| 56 | uint32_t rvc_on; |
| 57 | } vehicle_rvc_state_t; |
| 58 | |
| 59 | /** |
| 60 | * Describes a rectangle for cropping and positioning objects |
| 61 | * uint32_t left Position of left border of rectangle |
| 62 | * uint32_t top Position of top border of rectangle |
| 63 | * uint32_t width Width of rectangle |
| 64 | * uint32_t height Height of rectangle |
| 65 | */ |
| 66 | typedef struct { |
| 67 | uint32_t left; |
| 68 | uint32_t top; |
| 69 | uint32_t width; |
| 70 | uint32_t height; |
| 71 | } vehicle_rvc_rect_t; |
| 72 | |
| 73 | /** |
| 74 | * Bitmask of features supported by RVC module |
| 75 | */ |
| 76 | enum vehicle_rvc_config_flag { |
| 77 | ANDROID_OVERLAY_SUPPORT_FLAG = 0x1, |
| 78 | CAMERA_CROP_SUPPORT_FLAG = 0x2, |
| 79 | CAMERA_POSITIONING_SUPPORT_FLAG = 0x4 |
| 80 | }; |
| 81 | |
| 82 | typedef struct { |
| 83 | uint32_t capabilites_flags; |
| 84 | uint32_t camera_width; |
| 85 | uint32_t camera_height; |
| 86 | uint32_t display_width; |
| 87 | uint32_t display_height; |
| 88 | } vehicle_rvc_cap_t; |
| 89 | |
| 90 | /************************************************************************************/ |
| 91 | |
| 92 | /** |
| 93 | * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM |
| 94 | * and the fields of this data structure must begin with hw_module_t |
| 95 | * followed by module specific information. |
| 96 | */ |
| 97 | typedef struct { |
| 98 | struct hw_module_t common; |
| 99 | } vehicle_rvc_module_t; |
| 100 | |
| 101 | |
| 102 | typedef struct vehicle_rvc_device_t { |
| 103 | struct hw_device_t common; |
| 104 | |
| 105 | /** |
| 106 | * Returns the capabilities of this RVC. |
| 107 | * @param device |
| 108 | * @return |
| 109 | */ |
| 110 | int (*get_capabilities)(struct vehicle_rvc_device_t *device, vehicle_rvc_cap_t *cap); |
| 111 | /** |
| 112 | * Gets the current RVC crop settings. |
| 113 | * @param device |
| 114 | * @return |
| 115 | */ |
| 116 | int (*get_rvc_crop)(struct vehicle_rvc_device_t *device, vehicle_rvc_rect_t *rect); |
| 117 | /** |
| 118 | * Sets the RVC crop. |
| 119 | * @param device |
| 120 | * @param rect Area of RVC camera input to crop |
| 121 | * @return |
| 122 | */ |
| 123 | int (*set_rvc_crop)(struct vehicle_rvc_device_t *device, const vehicle_rvc_rect_t *rect); |
| 124 | /** |
| 125 | * Gets position of the RVC on the dispaly. |
| 126 | * @param device |
| 127 | * @param rect Area of display the RVC will appear when on |
| 128 | * @return |
| 129 | */ |
| 130 | int (*get_rvc_position)(struct vehicle_rvc_device_t *device, vehicle_rvc_rect_t *rect); |
| 131 | /** |
| 132 | * Sets position of the RVC on the display. |
| 133 | * @param device |
| 134 | * @param rect |
| 135 | * @return |
| 136 | */ |
| 137 | int (*set_rvc_position)(struct vehicle_rvc_device_t *device, const vehicle_rvc_rect_t *rect); |
| 138 | /** |
| 139 | * Gets the current camera state. |
| 140 | * @param device |
| 141 | * @return |
| 142 | */ |
| 143 | int (*get_camera_state)(struct vehicle_rvc_device_t *device, vehicle_rvc_state_t *state); |
| 144 | /** |
| 145 | * Sets the camera state. Calling this function will generate a |
| 146 | * callback notifying the user that the camera state has |
| 147 | * changed. |
| 148 | * @param device |
| 149 | * @return |
| 150 | */ |
| 151 | int (*set_camera_state)(struct vehicle_rvc_device_t *device, const vehicle_rvc_state_t *state); |
| 152 | } vehicle_rvc_device_t; |
| 153 | |
| 154 | __END_DECLS |
| 155 | |
| 156 | #endif // ANDROID_VEHICLE_RVC_INTERFACE_H |