1 /* 2 * Copyright (C) 2015 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_INTERFACE_H 18 #define ANDROID_VEHICLE_INTERFACE_H 19 20 #include <stdint.h> 21 #include <sys/cdefs.h> 22 #include <sys/types.h> 23 #include <math.h> 24 #include <errno.h> 25 26 #include <hardware/hardware.h> 27 #include <cutils/native_handle.h> 28 29 __BEGIN_DECLS 30 31 /*****************************************************************************/ 32 33 #define VEHICLE_HEADER_VERSION 1 34 #define VEHICLE_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0) 35 #define VEHICLE_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION_2(1, 0, VEHICLE_HEADER_VERSION) 36 37 /** 38 * Vehicle HAL to provide interfaces to various Car related sensors. The HAL is 39 * designed in a property, value maping where each property has a value which 40 * can be "get", "set" and "(un)subscribed" to. Subscribing will require the 41 * user of this HAL to provide parameters such as sampling rate. 42 */ 43 44 45 /* 46 * The id of this module 47 */ 48 #define VEHICLE_HARDWARE_MODULE_ID "vehicle" 49 50 /** 51 * Name of the vehicle device to open 52 */ 53 #define VEHICLE_HARDWARE_DEVICE "vehicle_hw_device" 54 55 /** 56 * Each vehicle property is defined with various annotations to specify the type of information. 57 * Annotations will be used by scripts to run some type check or generate some boiler-plate codes. 58 * Also the annotations are the specification for each property, and each HAL implementation should 59 * follow what is specified as annotations. 60 * Here is the list of annotations with explanation on what it does: 61 * @value_type: Type of data for this property. One of the value from vehicle_value_type should be 62 * set here. 63 * @change_mode: How this property changes. Value set is from vehicle_prop_change_mode. Some 64 * properties can allow either on change or continuous mode and it is up to HAL 65 * implementation to choose which mode to use. 66 * @access: Define how this property can be accessed. read only, write only or R/W from 67 * vehicle_prop_access 68 * @data_member: Name of member from vehicle_value union to access this data. 69 * @data_enum: enum type that should be used for the data. 70 * @unit: Unit of data. Should be from vehicle_unit_type. 71 * @config_flags: Usage of config_flags in vehicle_prop_config 72 * @config_array: Usage of config_array in vehicle_prop_config. When this is specified, 73 * @config_flags will not be used. 74 * @config_string: Explains the usage of config_string in vehicle_prop_config. Property with 75 * this annotation is expected to have additional information in config_string 76 * for that property to work. 77 * @zone_type type of zoned used. defined for zoned property 78 * @range_start, @range_end : define range of specific property values. 79 * @allow_out_of_range_value : This property allows out of range value to deliver additional 80 * information. Check VEHICLE_*_OUT_OF_RANGE_* for applicable values. 81 */ 82 //===== Vehicle Information ==== 83 84 /** 85 * Invalid property value used for argument where invalid property gives different result. 86 * @range_start 87 */ 88 #define VEHICLE_PROPERTY_INVALID (0x0) 89 90 /** 91 * VIN of vehicle 92 * @value_type VEHICLE_VALUE_TYPE_STRING 93 * @change_mode VEHICLE_PROP_CHANGE_MODE_STATIC 94 * @access VEHICLE_PROP_ACCESS_READ 95 * @data_member info_vin 96 */ 97 #define VEHICLE_PROPERTY_INFO_VIN (0x00000100) 98 99 /** 100 * Maker name of vehicle 101 * @value_type VEHICLE_VALUE_TYPE_STRING 102 * @change_mode VEHICLE_PROP_CHANGE_MODE_STATIC 103 * @access VEHICLE_PROP_ACCESS_READ 104 * @data_member info_make 105 */ 106 #define VEHICLE_PROPERTY_INFO_MAKE (0x00000101) 107 108 /** 109 * Model of vehicle 110 * @value_type VEHICLE_VALUE_TYPE_STRING 111 * @change_mode VEHICLE_PROP_CHANGE_MODE_STATIC 112 * @access VEHICLE_PROP_ACCESS_READ 113 * @data_member info_model 114 */ 115 #define VEHICLE_PROPERTY_INFO_MODEL (0x00000102) 116 117 /** 118 * Model year of vehicle. 119 * @value_type VEHICLE_VALUE_TYPE_INT32 120 * @change_mode VEHICLE_PROP_CHANGE_MODE_STATIC 121 * @access VEHICLE_PROP_ACCESS_READ 122 * @data_member info_model_year 123 * @unit VEHICLE_UNIT_TYPE_YEAR 124 */ 125 #define VEHICLE_PROPERTY_INFO_MODEL_YEAR (0x00000103) 126 127 /** 128 * Fuel capacity of the vehicle 129 * @value_type VEHICLE_VALUE_TYPE_FLOAT 130 * @change_mode VEHICLE_PROP_CHANGE_MODE_STATIC 131 * @access VEHICLE_PROP_ACCESS_READ 132 * @data_member info_fuel_capacity 133 * @unit VEHICLE_UNIT_TYPE_VEHICLE_UNIT_TYPE_MILLILITER 134 */ 135 #define VEHICLE_PROPERTY_INFO_FUEL_CAPACITY (0x00000104) 136 137 138 //==== Vehicle Performance Sensors ==== 139 140 /** 141 * Current odometer value of the vehicle 142 * @value_type VEHICLE_VALUE_TYPE_FLOAT 143 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE|VEHICLE_PROP_CHANGE_MODE_CONTINUOUS 144 * @access VEHICLE_PROP_ACCESS_READ 145 * @data_member odometer 146 * @unit VEHICLE_UNIT_TYPE_KILOMETER 147 */ 148 #define VEHICLE_PROPERTY_PERF_ODOMETER (0x00000204) 149 150 /** 151 * Speed of the vehicle 152 * @value_type VEHICLE_VALUE_TYPE_FLOAT 153 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE|VEHICLE_PROP_CHANGE_MODE_CONTINUOUS 154 * @access VEHICLE_PROP_ACCESS_READ 155 * @data_member vehicle_speed 156 * @unit VEHICLE_UNIT_TYPE_METER_PER_SEC 157 */ 158 #define VEHICLE_PROPERTY_PERF_VEHICLE_SPEED (0x00000207) 159 160 161 //==== Engine Sensors ==== 162 163 /** 164 * Temperature of engine coolant 165 * @value_type VEHICLE_VALUE_TYPE_FLOAT 166 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE|VEHICLE_PROP_CHANGE_MODE_CONTINUOUS 167 * @access VEHICLE_PROP_ACCESS_READ 168 * @data_member engine_coolant_temperature 169 * @unit VEHICLE_UNIT_TYPE_CELCIUS 170 */ 171 #define VEHICLE_PROPERTY_ENGINE_COOLANT_TEMP (0x00000301) 172 173 /** 174 * Temperature of engine oil 175 * @value_type VEHICLE_VALUE_TYPE_FLOAT 176 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE|VEHICLE_PROP_CHANGE_MODE_CONTINUOUS 177 * @access VEHICLE_PROP_ACCESS_READ 178 * @data_member engine_oil_temperature 179 * @unit VEHICLE_UNIT_TYPE_CELCIUS 180 */ 181 #define VEHICLE_PROPERTY_ENGINE_OIL_TEMP (0x00000304) 182 /** 183 * Engine rpm 184 * @value_type VEHICLE_VALUE_TYPE_FLOAT 185 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE|VEHICLE_PROP_CHANGE_MODE_CONTINUOUS 186 * @access VEHICLE_PROP_ACCESS_READ 187 * @data_member engine_rpm 188 * @unit VEHICLE_UNIT_TYPE_RPM 189 */ 190 #define VEHICLE_PROPERTY_ENGINE_RPM (0x00000305) 191 192 //==== Event Sensors ==== 193 194 /** 195 * Currently selected gear 196 * @value_type VEHICLE_VALUE_TYPE_INT32 197 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE 198 * @access VEHICLE_PROP_ACCESS_READ 199 * @data_member gear_selection 200 * @data_enum vehicle_gear 201 */ 202 #define VEHICLE_PROPERTY_GEAR_SELECTION (0x00000400) 203 204 /** 205 * Current gear. In non-manual case, selected gear does not necessarily match the current gear 206 * @value_type VEHICLE_VALUE_TYPE_INT32 207 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE 208 * @access VEHICLE_PROP_ACCESS_READ 209 * @data_member gear_current_gear 210 * @data_enum vehicle_gear 211 */ 212 #define VEHICLE_PROPERTY_CURRENT_GEAR (0x00000401) 213 214 /** 215 * Parking brake state. 216 * @value_type VEHICLE_VALUE_TYPE_BOOLEAN 217 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE 218 * @access VEHICLE_PROP_ACCESS_READ 219 * @data_member parking_brake 220 * @data_enum vehicle_boolean 221 */ 222 #define VEHICLE_PROPERTY_PARKING_BRAKE_ON (0x00000402) 223 224 /** 225 * Driving status policy. 226 * @value_type VEHICLE_VALUE_TYPE_INT32 227 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE 228 * @access VEHICLE_PROP_ACCESS_READ 229 * @data_member driving_status 230 * @data_enum vehicle_driving_status 231 */ 232 #define VEHICLE_PROPERTY_DRIVING_STATUS (0x00000404) 233 234 /** 235 * Warning for fuel low level. 236 * @value_type VEHICLE_VALUE_TYPE_BOOLEAN 237 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE 238 * @access VEHICLE_PROP_ACCESS_READ 239 * @data_member is_fuel_level_low 240 * @data_enum vehicle_boolean 241 */ 242 #define VEHICLE_PROPERTY_FUEL_LEVEL_LOW (0x00000405) 243 244 /** 245 * Night mode or not. 246 * @value_type VEHICLE_VALUE_TYPE_BOOLEAN 247 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE 248 * @access VEHICLE_PROP_ACCESS_READ 249 * @data_member night_mode 250 * @data_enum vehicle_boolean 251 */ 252 #define VEHICLE_PROPERTY_NIGHT_MODE (0x00000407) 253 254 255 256 //==== HVAC Properties ==== 257 258 /** 259 * Fan speed setting 260 * @value_type VEHICLE_VALUE_TYPE_ZONED_INT32 261 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE 262 * @access VEHICLE_PROP_ACCESS_READ_WRITE 263 * @data_member hvac.fan_speed 264 * @zone_type VEHICLE_ZONE 265 * @data_enum TODO 266 * @allow_out_of_range_value : OFF 267 */ 268 #define VEHICLE_PROPERTY_HVAC_FAN_SPEED (0x00000500) 269 270 /** 271 * Fan direction setting 272 * @value_type VEHICLE_VALUE_TYPE_ZONED_INT32 273 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE 274 * @access VEHICLE_PROP_ACCESS_READ_WRITE 275 * @data_member hvac.fan_direction 276 * @zone_type VEHICLE_ZONE 277 * @data_enum TODO 278 * @allow_out_of_range_value : OFF 279 */ 280 #define VEHICLE_PROPERTY_HVAC_FAN_DIRECTION (0x00000501) 281 282 /* 283 * Bit flags for fan direction 284 */ 285 enum vehicle_hvac_fan_direction { 286 VEHICLE_HVAC_FAN_DIRECTION_FACE = 0x1, 287 VEHICLE_HVAC_FAN_DIRECTION_FLOOR = 0x2, 288 VEHICLE_HVAC_FAN_DIRECTION_FACE_AND_FLOOR = 0x3, 289 VEHICLE_HVAC_FAN_DIRECTION_DEFROST = 0x4, 290 VEHICLE_HVAC_FAN_DIRECTION_DEFROST_AND_FLOOR = 0x5 291 }; 292 293 /** 294 * HVAC current temperature. 295 * @value_type VEHICLE_VALUE_TYPE_ZONED_FLOAT 296 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE|VEHICLE_PROP_CHANGE_MODE_CONTINUOUS 297 * @access VEHICLE_PROP_ACCESS_READ_WRITE 298 * @zone_type VEHICLE_ZONE 299 * @data_member hvac.temperature_current 300 */ 301 #define VEHICLE_PROPERTY_HVAC_TEMPERATURE_CURRENT (0x00000502) 302 303 /** 304 * HVAC, target temperature set. 305 * @value_type VEHICLE_VALUE_TYPE_ZONED_FLOAT 306 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE|VEHICLE_PROP_CHANGE_MODE_CONTINUOUS 307 * @access VEHICLE_PROP_ACCESS_READ_WRITE 308 * @zone_type VEHICLE_ZONE 309 * @data_member hvac.temperature_set 310 * @allow_out_of_range_value : MIN / MAX / OFF 311 */ 312 #define VEHICLE_PROPERTY_HVAC_TEMPERATURE_SET (0x00000503) 313 314 /** 315 * On/off defrost 316 * @value_type VEHICLE_VALUE_TYPE_ZONED_BOOLEAN 317 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE 318 * @access VEHICLE_PROP_ACCESS_READ_WRITE 319 * @zone_type VEHICLE_WINDOW 320 * @data_member hvac.defrost_on 321 */ 322 #define VEHICLE_PROPERTY_HVAC_DEFROSTER (0x00000504) 323 324 /** 325 * On/off AC 326 * @value_type VEHICLE_VALUE_TYPE_ZONED_BOOLEAN 327 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE 328 * @access VEHICLE_PROP_ACCESS_READ_WRITE 329 * @config_flags Supported zones 330 * @zone_type VEHICLE_ZONE 331 * @data_member hvac.ac_on 332 */ 333 #define VEHICLE_PROPERTY_HVAC_AC_ON (0x00000505) 334 335 /** 336 * On/off max AC 337 * @value_type VEHICLE_VALUE_TYPE_ZONED_BOOLEAN 338 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE 339 * @access VEHICLE_PROP_ACCESS_READ_WRITE 340 * @zone_type VEHICLE_ZONE 341 * @data_member hvac.max_ac_on 342 */ 343 #define VEHICLE_PROPERTY_HVAC_MAX_AC_ON (0x00000506) 344 345 /** 346 * On/off max defrost 347 * @value_type VEHICLE_VALUE_TYPE_ZONED_BOOLEAN 348 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE 349 * @access VEHICLE_PROP_ACCESS_READ_WRITE 350 * @zone_type VEHICLE_ZONE 351 * @data_member hvac.max_defrost_on 352 */ 353 #define VEHICLE_PROPERTY_HVAC_MAX_DEFROST_ON (0x00000507) 354 355 /** 356 * On/off re-circulation 357 * @value_type VEHICLE_VALUE_TYPE_ZONED_BOOLEAN 358 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE 359 * @access VEHICLE_PROP_ACCESS_READ_WRITE 360 * @zone_type VEHICLE_ZONE 361 * @data_member hvac.max_recirc_on 362 */ 363 #define VEHICLE_PROPERTY_HVAC_RECIRC_ON (0x00000508) 364 365 /** 366 * On/off dual. This will be defined per each row. 367 * @value_type VEHICLE_VALUE_TYPE_ZONED_BOOLEAN 368 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE 369 * @access VEHICLE_PROP_ACCESS_READ_WRITE 370 * @zone_type VEHICLE_ZONE 371 * @data_member hvac.dual_on 372 */ 373 #define VEHICLE_PROPERTY_HVAC_DUAL_ON (0x00000509) 374 375 /** 376 * Represents power state for HVAC. Some HVAC properties will require matching power to be turned on 377 * to get out of OFF state. For non-zoned HVAC properties, VEHICLE_ALL_ZONE corresponds to 378 * global power state. 379 * 380 * @value_type VEHICLE_VALUE_TYPE_ZONED_BOOLEAN 381 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE 382 * @access VEHICLE_PROP_ACCESS_READ_WRITE 383 * @config_string list of HVAC properties whose power is controlled by this property. Format is 384 * hexa-decimal number (0x...) separated by comma like "0x500,0x503". All zones 385 * defined in these affected properties should be available in the property. 386 * @zone_type VEHICLE_ZONE 387 * @data_member hvac.power_on 388 */ 389 #define VEHICLE_PROPERTY_HVAC_POWER_ON (0x00000510) 390 391 /** 392 * Outside temperature 393 * @value_type VEHICLE_VALUE_TYPE_FLOAT 394 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE|VEHICLE_PROP_CHANGE_MODE_CONTINUOUS 395 * @access VEHICLE_PROP_ACCESS_READ 396 * @data_member outside_temperature 397 * @unit VEHICLE_UNIT_TYPE_CELCIUS 398 */ 399 400 #define VEHICLE_PROPERTY_ENV_OUTSIDE_TEMPERATURE (0x00000703) 401 402 403 /** 404 * Cabin temperature 405 * @value_type VEHICLE_VALUE_TYPE_FLOAT 406 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE|VEHICLE_PROP_CHANGE_MODE_CONTINUOUS 407 * @access VEHICLE_PROP_ACCESS_READ 408 * @data_member cabin_temperature 409 * @unit VEHICLE_UNIT_TYPE_CELCIUS 410 */ 411 #define VEHICLE_PROPERTY_ENV_CABIN_TEMPERATURE (0x00000704) 412 413 414 /* 415 * Radio features. 416 */ 417 /** 418 * Radio presets stored on the Car radio module. The data type used is int32 419 * array with the following fields: 420 * <ul> 421 * <li> int32_array[0]: Preset number </li> 422 * <li> int32_array[1]: Band type (see #RADIO_BAND_FM in 423 * system/core/include/system/radio.h). 424 * <li> int32_array[2]: Channel number </li> 425 * <li> int32_array[3]: Sub channel number </li> 426 * </ul> 427 * 428 * NOTE: When getting a current preset config ONLY set preset number (i.e. 429 * int32_array[0]). For setting a preset other fields are required. 430 * 431 * @value_type VEHICLE_VALUE_TYPE_INT32_VEC4 432 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE 433 * @access VEHICLE_PROP_ACCESS_READ_WRITE 434 * @config_flags Number of presets supported 435 * @data_member int32_array 436 */ 437 #define VEHICLE_PROPERTY_RADIO_PRESET (0x0000801) 438 439 /** 440 * Constants relevant to radio. 441 */ 442 enum vehicle_radio_consts { 443 /** Minimum value for the radio preset */ 444 VEHICLE_RADIO_PRESET_MIN_VALUE = 1, 445 }; 446 447 /** 448 * Represents audio focus state of Android side. Note that car's audio module will own audio 449 * focus and grant audio focus to Android side when requested by Android side. The focus has both 450 * per stream characteristics and global characteristics. 451 * 452 * Focus request (get of this property) will take the following form in int32_vec4: 453 * int32_array[0]: vehicle_audio_focus_request type 454 * int32_array[1]: bit flags of streams requested by this focus request. There can be up to 455 * 32 streams. 456 * int32_array[2]: External focus state flags. For request, only flag like 457 * VEHICLE_AUDIO_EXT_FOCUS_CAR_PLAY_ONLY_FLAG or 458 * VEHICLE_AUDIO_EXT_FOCUS_CAR_MUTE_MEDIA_FLAG can be used. 459 * VEHICLE_AUDIO_EXT_FOCUS_CAR_PLAY_ONLY_FLAG is for case like radio where android 460 * side app still needs to hold focus but playback is done outside Android. 461 * VEHICLE_AUDIO_EXT_FOCUS_CAR_MUTE_MEDIA_FLAG is for muting media channel 462 * including radio. VEHICLE_AUDIO_EXT_FOCUS_CAR_MUTE_MEDIA_FLAG can be set even 463 * if android side releases focus (request type REQUEST_RELEASE). In that case, 464 * audio module should maintain mute state until user's explicit action to 465 * play some media. 466 * int32_array[3]: Currently active audio contexts. Use combination of flags from 467 * vehicle_audio_context_flag. 468 * This can be used as a hint to adjust audio policy or other policy decision. 469 * Note that there can be multiple context active at the same time. And android 470 * can send the same focus request type gain due to change in audio contexts. 471 * Note that each focus request can request multiple streams that is expected to be used for 472 * the current request. But focus request itself is global behavior as GAIN or GAIN_TRANSIENT 473 * expects all sounds played by car's audio module to stop. Note that stream already allocated to 474 * android before this focus request should not be affected by focus request. 475 * 476 * Focus response (set and subscription callback for this property) will take the following form: 477 * int32_array[0]: vehicle_audio_focus_state type 478 * int32_array[1]: bit flags of streams allowed. 479 * int32_array[2]: External focus state: bit flags of currently active audio focus in car 480 * side (outside Android). Active audio focus does not necessarily mean currently 481 * playing, but represents the state of having focus or waiting for focus 482 * (pause state). 483 * One or combination of flags from vehicle_audio_ext_focus_flag. 484 * 0 means no active audio focus holder outside Android. 485 * The state will have following values for each vehicle_audio_focus_state_type: 486 * GAIN: 0 or VEHICLE_AUDIO_EXT_FOCUS_CAR_PLAY_ONLY when radio is active in 487 * Android side. 488 * GAIN_TRANSIENT: 0. Can be VEHICLE_AUDIO_EXT_FOCUS_CAR_PERMANENT or 489 * VEHICLE_AUDIO_EXT_FOCUS_CAR_TRANSIENT if android side has requested 490 * GAIN_TRANSIENT_MAY_DUCK and car side is ducking. 491 * LOSS: 0 when no focus is audio is active in car side. 492 * VEHICLE_AUDIO_EXT_FOCUS_CAR_PERMANENT when car side is playing something 493 * permanent. 494 * LOSS_TRANSIENT: always should be VEHICLE_AUDIO_EXT_FOCUS_CAR_TRANSIENT 495 * int32_array[3]: should be zero. 496 * 497 * If car does not support VEHICLE_PROPERTY_AUDIO_FOCUS, focus is assumed to be granted always. 498 * 499 * @value_type VEHICLE_VALUE_TYPE_INT32_VEC4 500 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE 501 * @access VEHICLE_PROP_ACCESS_READ_WRITE 502 * @data_member int32_array 503 */ 504 #define VEHICLE_PROPERTY_AUDIO_FOCUS (0x00000900) 505 506 enum vehicle_audio_focus_request { 507 VEHICLE_AUDIO_FOCUS_REQUEST_GAIN = 0x1, 508 VEHICLE_AUDIO_FOCUS_REQUEST_GAIN_TRANSIENT = 0x2, 509 VEHICLE_AUDIO_FOCUS_REQUEST_GAIN_TRANSIENT_MAY_DUCK = 0x3, 510 /** 511 * This is for the case where android side plays sound like UI feedback 512 * and car side does not need to duck existing playback as long as 513 * requested stream is available. 514 */ 515 VEHICLE_AUDIO_FOCUS_REQUEST_GAIN_TRANSIENT_NO_DUCK = 0x4, 516 VEHICLE_AUDIO_FOCUS_REQUEST_RELEASE = 0x5, 517 }; 518 519 enum vehicle_audio_focus_state { 520 /** 521 * Android side has permanent focus and can play allowed streams. 522 */ 523 VEHICLE_AUDIO_FOCUS_STATE_GAIN = 0x1, 524 /** 525 * Android side has transient focus and can play allowed streams. 526 */ 527 VEHICLE_AUDIO_FOCUS_STATE_GAIN_TRANSIENT = 0x2, 528 /** 529 * Car audio module is playing guidance kind of sound outside Android. Android side can 530 * still play through allowed streams with ducking. 531 */ 532 VEHICLE_AUDIO_FOCUS_STATE_LOSS_TRANSIENT_CAN_DUCK = 0x3, 533 /** 534 * Car audio module is playing transient sound outside Android. Android side should stop 535 * playing any sounds. 536 */ 537 VEHICLE_AUDIO_FOCUS_STATE_LOSS_TRANSIENT = 0x4, 538 /** 539 * Android side has lost focus and cannot play any sound. 540 */ 541 VEHICLE_AUDIO_FOCUS_STATE_LOSS = 0x5, 542 /** 543 * car audio module is playing safety critical sound, and Android side cannot request focus 544 * until the current state is finished. car audio module should restore it to the previous 545 * state when it can allow Android to play. 546 */ 547 VEHICLE_AUDIO_FOCUS_STATE_LOSS_TRANSIENT_EXLCUSIVE = 0x6, 548 }; 549 550 /** 551 * Flags to represent multiple streams by combining these. 552 */ 553 enum vehicle_audio_stream_flag { 554 VEHICLE_AUDIO_STREAM_STREAM0_FLAG = (0x1<<0), 555 VEHICLE_AUDIO_STREAM_STREAM1_FLAG = (0x1<<1), 556 VEHICLE_AUDIO_STREAM_STREAM2_FLAG = (0x1<<2), 557 }; 558 559 /** 560 * Represents stream number (always 0 to N -1 where N is max number of streams). 561 * Can be used for audio related property expecting one stream. 562 */ 563 enum vehicle_audio_stream { 564 VEHICLE_AUDIO_STREAM0 = 0, 565 VEHICLE_AUDIO_STREAM1 = 1, 566 }; 567 568 /** 569 * Flag to represent external focus state (outside Android). 570 */ 571 enum vehicle_audio_ext_focus_flag { 572 /** 573 * No external focus holder. 574 */ 575 VEHICLE_AUDIO_EXT_FOCUS_NONE_FLAG = 0x0, 576 /** 577 * Car side (outside Android) has component holding GAIN kind of focus state. 578 */ 579 VEHICLE_AUDIO_EXT_FOCUS_CAR_PERMANENT_FLAG = 0x1, 580 /** 581 * Car side (outside Android) has component holding GAIN_TRANSIENT kind of focus state. 582 */ 583 VEHICLE_AUDIO_EXT_FOCUS_CAR_TRANSIENT_FLAG = 0x2, 584 /** 585 * Car side is expected to play something while focus is held by Android side. One example 586 * can be radio attached in car side. But Android's radio app still should have focus, 587 * and Android side should be in GAIN state, but media stream will not be allocated to Android 588 * side and car side can play radio any time while this flag is active. 589 */ 590 VEHICLE_AUDIO_EXT_FOCUS_CAR_PLAY_ONLY_FLAG = 0x4, 591 /** 592 * Car side should mute any media including radio. This can be used with any focus request 593 * including GAIN* and RELEASE. 594 */ 595 VEHICLE_AUDIO_EXT_FOCUS_CAR_MUTE_MEDIA_FLAG = 0x8, 596 }; 597 598 /** 599 * Index in int32_array for VEHICLE_PROPERTY_AUDIO_FOCUS property. 600 */ 601 enum vehicle_audio_focus_index { 602 VEHICLE_AUDIO_FOCUS_INDEX_FOCUS = 0, 603 VEHICLE_AUDIO_FOCUS_INDEX_STREAMS = 1, 604 VEHICLE_AUDIO_FOCUS_INDEX_EXTERNAL_FOCUS_STATE = 2, 605 VEHICLE_AUDIO_FOCUS_INDEX_AUDIO_CONTEXTS = 3, 606 }; 607 608 /** 609 * Flags to tell the current audio context. 610 */ 611 enum vehicle_audio_context_flag { 612 /** Music playback is currently active. */ 613 VEHICLE_AUDIO_CONTEXT_MUSIC_FLAG = 0x1, 614 /** Navigation is currently running. */ 615 VEHICLE_AUDIO_CONTEXT_NAVIGATION_FLAG = 0x2, 616 /** Voice command session is currently running. */ 617 VEHICLE_AUDIO_CONTEXT_VOICE_COMMAND_FLAG = 0x4, 618 /** Voice call is currently active. */ 619 VEHICLE_AUDIO_CONTEXT_CALL_FLAG = 0x8, 620 /** Alarm is active. This may be only used in VEHICLE_PROPERTY_AUDIO_ROUTING_POLICY. */ 621 VEHICLE_AUDIO_CONTEXT_ALARM_FLAG = 0x10, 622 /** 623 * Notification sound is active. This may be only used in VEHICLE_PROPERTY_AUDIO_ROUTING_POLICY. 624 */ 625 VEHICLE_AUDIO_CONTEXT_NOTIFICATION_FLAG = 0x20, 626 /** 627 * Context unknown. Only used for VEHICLE_PROPERTY_AUDIO_ROUTING_POLICY to represent default 628 * stream for unknown contents. 629 */ 630 VEHICLE_AUDIO_CONTEXT_UNKNOWN_FLAG = 0x40, 631 /** Safety alert / warning is played. */ 632 VEHICLE_AUDIO_CONTEXT_SAFETY_ALERT_FLAG = 0x80, 633 /** CD / DVD kind of audio is played */ 634 VEHICLE_AUDIO_CONTEXT_CD_ROM_FLAG = 0x100, 635 /** Aux audio input is played */ 636 VEHICLE_AUDIO_CONTEXT_AUX_AUDIO_FLAG = 0x200, 637 /** system sound like UI feedback */ 638 VEHICLE_AUDIO_CONTEXT_SYSTEM_SOUND_FLAG = 0x400, 639 /** Radio is played */ 640 VEHICLE_AUDIO_CONTEXT_RADIO_FLAG = 0x800, 641 }; 642 643 /** 644 * Property to control audio volume of each audio context. 645 * 646 * Data type looks like: 647 * int32_array[0] : stream context as defined in vehicle_audio_context_flag. 648 * int32_array[1] : volume level, valid range is 0 to int32_max_value defined in config. 649 * 0 will be mute state. int32_min_value in config should be always 0. 650 * int32_array[2] : One of vehicle_audio_volume_state. 651 * 652 * This property requires per stream based get. HAL implementation should check stream number 653 * in get call to return the right volume. 654 * 655 * @value_type VEHICLE_VALUE_TYPE_INT32_VEC3 656 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE 657 * @access VEHICLE_PROP_ACCESS_READ_WRITE 658 * @config_flags all audio contexts supported. 659 * @data_member int32_array 660 */ 661 #define VEHICLE_PROPERTY_AUDIO_VOLUME (0x00000901) 662 663 /** 664 * enum to represent audio volume state. 665 */ 666 enum vehicle_audio_volume_state { 667 VEHICLE_AUDIO_VOLUME_STATE_OK = 0, 668 /** 669 * Audio volume has reached volume limit set in VEHICLE_PROPERTY_AUDIO_VOLUME_LIMIT 670 * and user's request to increase volume further is not allowed. 671 */ 672 VEHICLE_AUDIO_VOLUME_STATE_LIMIT_REACHED = 1, 673 }; 674 675 /** 676 * Index in int32_array for VEHICLE_PROPERTY_AUDIO_VOLUME property. 677 */ 678 enum vehicle_audio_volume_index { 679 VEHICLE_AUDIO_VOLUME_INDEX_STREAM = 0, 680 VEHICLE_AUDIO_VOLUME_INDEX_VOLUME = 1, 681 VEHICLE_AUDIO_VOLUME_INDEX_STATE = 2, 682 }; 683 684 /** 685 * Property for handling volume limit set by user. This limits maximum volume that can be set 686 * per each context. 687 * int32_array[0] : stream context as defined in vehicle_audio_context_flag. 688 * int32_array[1] : maximum volume set to the stream. If there is no restriction, this value 689 * will be bigger than VEHICLE_PROPERTY_AUDIO_VOLUME's max value. 690 * 691 * If car does not support this feature, this property should not be populated by HAL. 692 * This property requires per stream based get. HAL implementation should check stream number 693 * in get call to return the right volume. 694 * 695 * @value_type VEHICLE_VALUE_TYPE_INT32_VEC2 696 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE 697 * @access VEHICLE_PROP_ACCESS_READ_WRITE 698 * @config_flags all audio contexts supported. 699 * @data_member int32_array 700 */ 701 #define VEHICLE_PROPERTY_AUDIO_VOLUME_LIMIT (0x00000902) 702 703 /** 704 * Index in int32_array for VEHICLE_PROPERTY_AUDIO_VOLUME_LIMIT property. 705 */ 706 enum vehicle_audio_volume_limit_index { 707 VEHICLE_AUDIO_VOLUME_LIMIT_INDEX_STREAM = 0, 708 VEHICLE_AUDIO_VOLUME_LIMIT_INDEX_MAX_VOLUME = 1, 709 }; 710 711 /** 712 * Property to share audio routing policy of android side. This property is set at the beginning 713 * to pass audio policy in android side down to vehicle HAL and car audio module. 714 * This can be used as a hint to adjust audio policy or other policy decision. 715 * 716 * int32_array[0] : audio stream where the audio for the application context will be routed 717 * by default. Note that this is the default setting from system, but each app 718 * may still use different audio stream for whatever reason. 719 * int32_array[1] : All audio contexts that will be sent through the physical stream. Flag 720 * is defined in vehicle_audio_context_flag. 721 722 * Setting of this property will be done for all available physical streams based on audio H/W 723 * variant information acquired from VEHICLE_PROPERTY_AUDIO_HW_VARIANT property. 724 * 725 * @value_type VEHICLE_VALUE_TYPE_INT32_VEC2 726 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE 727 * @access VEHICLE_PROP_ACCESS_WRITE 728 * @data_member int32_array 729 */ 730 #define VEHICLE_PROPERTY_AUDIO_ROUTING_POLICY (0x00000903) 731 732 /** 733 * Index in int32_array for VEHICLE_PROPERTY_AUDIO_ROUTING_POLICY property. 734 */ 735 enum vehicle_audio_routing_policy_index { 736 VEHICLE_AUDIO_ROUTING_POLICY_INDEX_STREAM = 0, 737 VEHICLE_AUDIO_ROUTING_POLICY_INDEX_CONTEXTS = 1, 738 }; 739 740 /** 741 * Property to return audio H/W variant type used in this car. This allows android side to 742 * support different audio policy based on H/W variant used. Note that other components like 743 * CarService may need overlay update to support additional variants. If this property does not 744 * exist, default audio policy will be used. 745 * 746 * @value_type VEHICLE_VALUE_TYPE_INT32 747 * @change_mode VEHICLE_PROP_CHANGE_MODE_STATIC 748 * @access VEHICLE_PROP_ACCESS_READ 749 * @config_flags Additional info on audio H/W. Should use vehicle_audio_hw_variant_config_flag for 750 * this. 751 * @data_member int32_value 752 */ 753 #define VEHICLE_PROPERTY_AUDIO_HW_VARIANT (0x00000904) 754 755 /** 756 * Flag to be used in vehicle_prop_config.config_flags for VEHICLE_PROPERTY_AUDIO_HW_VARIANT. 757 */ 758 enum vehicle_audio_hw_variant_config_flag { 759 /** 760 * Flag to tell that radio is internal to android and radio should 761 * be treated like other android stream like media. 762 * When this flag is not set or AUDIO_HW_VARIANT does not exist, 763 * radio is treated as external module. This brins some delta in audio focus 764 * handling as well. 765 */ 766 VEHICLE_AUDIO_HW_VARIANT_FLAG_INTERNAL_RADIO_FLAG = 0x1, 767 }; 768 769 770 /** 771 * Property to control power state of application processor. 772 * 773 * It is assumed that AP's power state is controller by separate power controller. 774 * 775 * For configuration information, vehicle_prop_config.config_flags can have bit flag combining 776 * values in vehicle_ap_power_state_config_type. 777 * 778 * For get / notification, data type looks like this: 779 * int32_array[0] : vehicle_ap_power_state_type 780 * int32_array[1] : additional parameter relevant for each state. should be 0 if not used. 781 * For set, data type looks like this: 782 * int32_array[0] : vehicle_ap_power_state_set_type 783 * int32_array[1] : additional parameter relevant for each request. should be 0 if not used. 784 * 785 * @value_type VEHICLE_VALUE_TYPE_INT32_VEC2 786 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE 787 * @access VEHICLE_PROP_ACCESS_READ_WRITE 788 * @config_flags Additional info on power state. Should use vehicle_ap_power_state_config_flag. 789 * @data_member int32_array 790 */ 791 #define VEHICLE_PROPERTY_AP_POWER_STATE (0x00000A00) 792 793 enum vehicle_ap_power_state_config_flag { 794 /** 795 * AP can enter deep sleep state. If not set, AP will always shutdown from 796 * VEHICLE_AP_POWER_STATE_SHUTDOWN_PREPARE power state. 797 */ 798 VEHICLE_AP_POWER_STATE_CONFIG_ENABLE_DEEP_SLEEP_FLAG = 0x1, 799 800 /** 801 * The power controller can power on AP from off state after timeout specified in 802 * VEHICLE_AP_POWER_SET_SHUTDOWN_READY message. 803 */ 804 VEHICLE_AP_POWER_STATE_CONFIG_SUPPORT_TIMER_POWER_ON_FLAG = 0x2, 805 }; 806 807 enum vehicle_ap_power_state { 808 /** vehicle HAL will never publish this state to AP */ 809 VEHICLE_AP_POWER_STATE_OFF = 0, 810 /** vehicle HAL will never publish this state to AP */ 811 VEHICLE_AP_POWER_STATE_DEEP_SLEEP = 1, 812 /** AP is on but display should be off. */ 813 VEHICLE_AP_POWER_STATE_ON_DISP_OFF = 2, 814 /** AP is on with display on. This state allows full user interaction. */ 815 VEHICLE_AP_POWER_STATE_ON_FULL = 3, 816 /** 817 * The power controller has requested AP to shutdown. AP can either enter sleep state or start 818 * full shutdown. AP can also request postponing shutdown by sending 819 * VEHICLE_AP_POWER_SET_SHUTDOWN_POSTPONE message. The power controller should change power 820 * state to this state to shutdown system. 821 * 822 * int32_array[1] : one of enum_vehicle_ap_power_state_shutdown_param_type 823 */ 824 VEHICLE_AP_POWER_STATE_SHUTDOWN_PREPARE = 4, 825 }; 826 827 enum vehicle_ap_power_state_shutdown_param { 828 /** AP should shutdown immediately. Postponing is not allowed. */ 829 VEHICLE_AP_POWER_SHUTDOWN_PARAM_SHUTDOWN_IMMEDIATELY = 1, 830 /** AP can enter deep sleep instead of shutting down completely. */ 831 VEHICLE_AP_POWER_SHUTDOWN_PARAM_CAN_SLEEP = 2, 832 /** AP can only shutdown with postponing allowed. */ 833 VEHICLE_AP_POWER_SHUTDOWN_PARAM_SHUTDOWN_ONLY = 3, 834 }; 835 836 enum vehicle_ap_power_set_state { 837 /** 838 * AP has finished boot up, and can start shutdown if requested by power controller. 839 */ 840 VEHICLE_AP_POWER_SET_BOOT_COMPLETE = 0x1, 841 /** 842 * AP is entering deep sleep state. How this state is implemented may vary depending on 843 * each H/W, but AP's power should be kept in this state. 844 */ 845 VEHICLE_AP_POWER_SET_DEEP_SLEEP_ENTRY = 0x2, 846 /** 847 * AP is exiting from deep sleep state, and is in VEHICLE_AP_POWER_STATE_SHUTDOWN_PREPARE state. 848 * The power controller may change state to other ON states based on the current state. 849 */ 850 VEHICLE_AP_POWER_SET_DEEP_SLEEP_EXIT = 0x3, 851 /** 852 * int32_array[1]: Time to postpone shutdown in ms. Maximum value can be 5000 ms. 853 * If AP needs more time, it will send another POSTPONE message before 854 * the previous one expires. 855 */ 856 VEHICLE_AP_POWER_SET_SHUTDOWN_POSTPONE = 0x4, 857 /** 858 * AP is starting shutting down. When system completes shutdown, everything will stop in AP 859 * as kernel will stop all other contexts. It is responsibility of vehicle HAL or lower level 860 * to synchronize that state with external power controller. As an example, some kind of ping 861 * with timeout in power controller can be a solution. 862 * 863 * int32_array[1]: Time to turn on AP in secs. Power controller may turn on AP after specified 864 * time so that AP can run tasks like update. If it is set to 0, there is no 865 * wake up, and power controller may not necessarily support wake-up. 866 * If power controller turns on AP due to timer, it should start with 867 * VEHICLE_AP_POWER_STATE_ON_DISP_OFF state, and after receiving 868 * VEHICLE_AP_POWER_SET_BOOT_COMPLETE, it shall do state transition to 869 * VEHICLE_AP_POWER_STATE_SHUTDOWN_PREPARE. 870 */ 871 VEHICLE_AP_POWER_SET_SHUTDOWN_START = 0x5, 872 /** 873 * User has requested to turn off headunit's display, which is detected in android side. 874 * The power controller may change the power state to VEHICLE_AP_POWER_STATE_ON_DISP_OFF. 875 */ 876 VEHICLE_AP_POWER_SET_DISPLAY_OFF = 0x6, 877 /** 878 * User has requested to turn on headunit's display, most probably from power key input which 879 * is attached to headunit. The power controller may change the power state to 880 * VEHICLE_AP_POWER_STATE_ON_FULL. 881 */ 882 VEHICLE_AP_POWER_SET_DISPLAY_ON = 0x7, 883 }; 884 885 /** 886 * Property to represent brightness of the display. Some cars have single control for 887 * the brightness of all displays and this property is to share change in that control. 888 * 889 * If this is writable, android side can set this value when user changes display brightness 890 * from Settings. If this is read only, user may still change display brightness from Settings, 891 * but that will not be reflected to other displays. 892 * 893 * @value_type VEHICLE_VALUE_TYPE_INT32 894 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE 895 * @access VEHICLE_PROP_ACCESS_READ|VEHICLE_PROP_ACCESS_READ_WRITE 896 * @data_member int32 897 */ 898 #define VEHICLE_PROPERTY_DISPLAY_BRIGHTNESS (0x00000A01) 899 900 901 /** 902 * Index in int32_array for VEHICLE_PROPERTY_AP_POWER_STATE property. 903 */ 904 enum vehicle_ap_power_state_index { 905 VEHICLE_AP_POWER_STATE_INDEX_STATE = 0, 906 VEHICLE_AP_POWER_STATE_INDEX_ADDITIONAL = 1, 907 }; 908 909 /** 910 * Property to report bootup reason for the current power on. This is a static property that will 911 * not change for the whole duration until power off. For example, even if user presses power on 912 * button after automatic power on with door unlock, bootup reason should stay with 913 * VEHICLE_AP_POWER_BOOTUP_REASON_USER_UNLOCK. 914 * 915 * int32_value should be vehicle_ap_power_bootup_reason. 916 * 917 * @value_type VEHICLE_VALUE_TYPE_INT32 918 * @change_mode VEHICLE_PROP_CHANGE_MODE_STATIC 919 * @access VEHICLE_PROP_ACCESS_READ 920 * @data_member int32_value 921 */ 922 #define VEHICLE_PROPERTY_AP_POWER_BOOTUP_REASON (0x00000A02) 923 924 /** 925 * Enum to represent bootup reason. 926 */ 927 enum vehicle_ap_power_bootup_reason { 928 /** 929 * Power on due to user's pressing of power key or rotating of ignition switch. 930 */ 931 VEHICLE_AP_POWER_BOOTUP_REASON_USER_POWER_ON = 0, 932 /** 933 * Automatic power on triggered by door unlock or any other kind of automatic user detection. 934 */ 935 VEHICLE_AP_POWER_BOOTUP_REASON_USER_UNLOCK = 1, 936 /** 937 * Automatic power on triggered by timer. This only happens when AP has asked wake-up after 938 * certain time through time specified in VEHICLE_AP_POWER_SET_SHUTDOWN_START. 939 */ 940 VEHICLE_AP_POWER_BOOTUP_REASON_TIMER = 2, 941 }; 942 943 944 /** 945 * Property to feed H/W input events to android 946 * 947 * int32_array[0] : action defined by vehicle_hw_key_input_action 948 * int32_array[1] : key code, should use standard android key code 949 * int32_array[2] : target display defined in vehicle_display. Events not tied 950 * to specific display should be sent to DISPLAY_MAIN. 951 * int32_array[3] : reserved for now. should be zero 952 * @value_type VEHICLE_VALUE_TYPE_INT32_VEC4 953 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE 954 * @access VEHICLE_PROP_ACCESS_READ 955 * @config_flags 956 * @data_member int32_array 957 */ 958 #define VEHICLE_PROPERTY_HW_KEY_INPUT (0x00000A10) 959 960 enum vehicle_hw_key_input_action { 961 /** Key down */ 962 VEHICLE_HW_KEY_INPUT_ACTION_DOWN = 0, 963 /** Key up */ 964 VEHICLE_HW_KEY_INPUT_ACTION_UP = 1, 965 }; 966 967 enum vehicle_display { 968 /** center console */ 969 VEHICLE_DISPLAY_MAIN = 0, 970 VEHICLE_DISPLAY_INSTRUMENT_CLUSTER = 1, 971 }; 972 973 /** 974 * Property to define instrument cluster information. 975 * For CLUSTER_TYPE_EXTERNAL_DISPLAY: 976 * READ: 977 * int32_array[0] : The current screen mode index. Screen mode is defined 978 * as a configuration in car service and represents which 979 * area of screen is renderable. 980 * int32_array[1] : Android can render to instrument cluster (=1) or not(=0). When this is 0, 981 * instrument cluster may be rendering some information in the area 982 * allocated for android and android side rendering is invisible. * 983 * int32_array[2..3] : should be zero 984 * WRITE from android: 985 * int32_array[0] : Preferred mode for android side. Depending on the app rendering to instrument 986 * cluster, preferred mode can change. Instrument cluster still needs to send 987 * event with new mode to trigger actual mode change. 988 * int32_array[1] : The current app context relevant for instrument cluster. Use the same flag 989 * with vehicle_audio_context_flag but this context represents active apps, not 990 * active audio. Instrument cluster side may change mode depending on the 991 * currently active contexts. 992 * int32_array[2..3] : should be zero 993 * When system boots up, Android side will write {0, 0, 0, 0} when it is ready to render to 994 * instrument cluster. Before this message, rendering from android should not be visible in the 995 * cluster. 996 * @value_type VEHICLE_VALUE_TYPE_INT32_VEC4 997 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE 998 * @access VEHICLE_PROP_ACCESS_READ_WRITE 999 * @config_array 0:vehicle_instument_cluster_type 1:hw type 1000 * @data_member int32_array 1001 */ 1002 #define VEHICLE_PROPERTY_INSTRUMENT_CLUSTER_INFO (0x00000A20) 1003 1004 /** 1005 * Represents instrument cluster type available in system 1006 */ 1007 enum vehicle_instument_cluster_type { 1008 /** Android has no access to instument cluster */ 1009 VEHICLE_INSTRUMENT_CLUSTER_TYPE_NONE = 0, 1010 /** 1011 * Instrument cluster can communicate through vehicle hal with additional 1012 * properties to exchange meta-data 1013 */ 1014 VEHICLE_INSTRUMENT_CLUSTER_TYPE_HAL_INTERFACE = 1, 1015 /** 1016 * Instrument cluster is external display where android can render contents 1017 */ 1018 VEHICLE_INSTRUMENT_CLUSTER_TYPE_EXTERNAL_DISPLAY = 2, 1019 }; 1020 1021 /** 1022 * H/W specific, non-standard property can be added as necessary. Such property should use 1023 * property number in range of [VEHICLE_PROPERTY_CUSTOM_START, VEHICLE_PROPERTY_CUSTOM_END]. 1024 * Definition of property in this range is completely up to each HAL implementation. 1025 * For such property, it is recommended to fill vehicle_prop_config.config_string with some 1026 * additional information to help debugging. For example, company XYZ's custom extension may 1027 * include config_string of "com.XYZ.some_further_details". 1028 * @range_start 1029 */ 1030 #define VEHICLE_PROPERTY_CUSTOM_START (0x70000000) 1031 /** @range_end */ 1032 #define VEHICLE_PROPERTY_CUSTOM_END (0x73ffffff) 1033 1034 /** 1035 * Property range allocated for system's internal usage like testing. HAL should never declare 1036 * property in this range. 1037 * @range_start 1038 */ 1039 #define VEHICLE_PROPERTY_INTERNAL_START (0x74000000) 1040 /** 1041 * @range_end 1042 */ 1043 #define VEHICLE_PROPERTY_INTERNAL_END (0x74ffffff) 1044 1045 /** 1046 * Value types for various properties. 1047 */ 1048 enum vehicle_value_type { 1049 VEHICLE_VALUE_TYPE_SHOUD_NOT_USE = 0x00, // value_type should never set to 0. 1050 VEHICLE_VALUE_TYPE_STRING = 0x01, 1051 VEHICLE_VALUE_TYPE_BYTES = 0x02, 1052 VEHICLE_VALUE_TYPE_BOOLEAN = 0x03, 1053 VEHICLE_VALUE_TYPE_ZONED_BOOLEAN = 0x04, 1054 VEHICLE_VALUE_TYPE_INT64 = 0x05, 1055 VEHICLE_VALUE_TYPE_FLOAT = 0x10, 1056 VEHICLE_VALUE_TYPE_FLOAT_VEC2 = 0x11, 1057 VEHICLE_VALUE_TYPE_FLOAT_VEC3 = 0x12, 1058 VEHICLE_VALUE_TYPE_FLOAT_VEC4 = 0x13, 1059 VEHICLE_VALUE_TYPE_INT32 = 0x20, 1060 VEHICLE_VALUE_TYPE_INT32_VEC2 = 0x21, 1061 VEHICLE_VALUE_TYPE_INT32_VEC3 = 0x22, 1062 VEHICLE_VALUE_TYPE_INT32_VEC4 = 0x23, 1063 VEHICLE_VALUE_TYPE_ZONED_FLOAT = 0x30, 1064 VEHICLE_VALUE_TYPE_ZONED_FLOAT_VEC2 = 0x31, 1065 VEHICLE_VALUE_TYPE_ZONED_FLOAT_VEC3 = 0x32, 1066 VEHICLE_VALUE_TYPE_ZONED_FLOAT_VEC4 = 0x33, 1067 VEHICLE_VALUE_TYPE_ZONED_INT32 = 0x40, 1068 VEHICLE_VALUE_TYPE_ZONED_INT32_VEC2 = 0x41, 1069 VEHICLE_VALUE_TYPE_ZONED_INT32_VEC3 = 0x42, 1070 VEHICLE_VALUE_TYPE_ZONED_INT32_VEC4 = 0x43, 1071 }; 1072 1073 /** 1074 * Units used for int or float type with no attached enum types. 1075 */ 1076 enum vehicle_unit_type { 1077 VEHICLE_UNIT_TYPE_SHOULD_NOT_USE = 0x00000000, 1078 // speed related items 1079 VEHICLE_UNIT_TYPE_METER_PER_SEC = 0x00000001, 1080 VEHICLE_UNIT_TYPE_RPM = 0x00000002, 1081 VEHICLE_UNIT_TYPE_HZ = 0x00000003, 1082 // kind of ratio 1083 VEHICLE_UNIT_TYPE_PERCENTILE = 0x00000010, 1084 // length 1085 VEHICLE_UNIT_TYPE_MILLIMETER = 0x00000020, 1086 VEHICLE_UNIT_TYPE_METER = 0x00000021, 1087 VEHICLE_UNIT_TYPE_KILOMETER = 0x00000023, 1088 // temperature 1089 VEHICLE_UNIT_TYPE_CELCIUS = 0x00000030, 1090 // volume 1091 VEHICLE_UNIT_TYPE_MILLILITER = 0x00000040, 1092 // time 1093 VEHICLE_UNIT_TYPE_NANO_SECS = 0x00000050, 1094 VEHICLE_UNOT_TYPE_SECS = 0x00000053, 1095 VEHICLE_UNIT_TYPE_YEAR = 0x00000059, 1096 }; 1097 1098 /** 1099 * This describes how value of property can change. 1100 */ 1101 enum vehicle_prop_change_mode { 1102 /** 1103 * Property of this type will *never* change. This property will not support subscription, but 1104 * will support get 1105 */ 1106 VEHICLE_PROP_CHANGE_MODE_STATIC = 0x00, 1107 /** 1108 * Property of this type will be reported when there is a change. get should return the 1109 * current value. 1110 */ 1111 VEHICLE_PROP_CHANGE_MODE_ON_CHANGE = 0x01, 1112 /** 1113 * Property of this type change continuously and requires fixed rate of sampling to retrieve 1114 * the data. 1115 */ 1116 VEHICLE_PROP_CHANGE_MODE_CONTINUOUS = 0x02, 1117 }; 1118 1119 /** 1120 * Property config defines the capabilities of it. User of the API 1121 * should first get the property config to understand the output from get() 1122 * commands and also to ensure that set() or events commands are in sync with 1123 * the expected output. 1124 */ 1125 enum vehicle_prop_access { 1126 VEHICLE_PROP_ACCESS_READ = 0x01, 1127 VEHICLE_PROP_ACCESS_WRITE = 0x02, 1128 VEHICLE_PROP_ACCESS_READ_WRITE = 0x03 1129 }; 1130 1131 /** 1132 * These permissions define how the OEMs want to distribute their information and security they 1133 * want to apply. On top of these restrictions, android will have additional 1134 * 'app-level' permissions that the apps will need to ask the user before the apps have the 1135 * information. 1136 * This information should be kept in vehicle_prop_config.permission_model. 1137 */ 1138 enum vehicle_permission_model { 1139 /** 1140 * No special restriction, but each property can still require specific android app-level 1141 * permission. 1142 */ 1143 VEHICLE_PERMISSION_NO_RESTRICTION = 0, 1144 /** Signature only. Only APKs signed with OEM keys are allowed. */ 1145 VEHICLE_PERMISSION_OEM_ONLY = 0x1, 1146 /** System only. APKs built-in to system can access the property. */ 1147 VEHICLE_PERMISSION_SYSTEM_APP_ONLY = 0x2, 1148 /** Equivalent to “system|signature” */ 1149 VEHICLE_PERMISSION_OEM_OR_SYSTEM_APP = 0x3 1150 }; 1151 1152 1153 /** 1154 * Special values for INT32/FLOAT (including ZONED types) 1155 * These values represent special state, which is outside MIN/MAX range but can happen. 1156 * For example, HVAC temperature may use out of range min / max to represent that 1157 * it is working in full power although target temperature has separate min / max. 1158 * OUT_OF_RANGE_OFF can represent a state where the property is powered off. 1159 * Usually such property will have separate property to control power. 1160 */ 1161 1162 #define VEHICLE_INT_OUT_OF_RANGE_MAX (INT32_MAX) 1163 #define VEHICLE_INT_OUT_OF_RANGE_MIN (INT32_MIN) 1164 #define VEHICLE_INT_OUT_OF_RANGE_OFF (INT32_MIN + 1) 1165 1166 #define VEHICLE_FLOAT_OUT_OF_RANGE_MAX (INFINITY) 1167 #define VEHICLE_FLOAT_OUT_OF_RANGE_MIN (-INFINITY) 1168 #define VEHICLE_FLOAT_OUT_OF_RANGE_OFF (NAN) 1169 1170 /** 1171 * Car states. 1172 * 1173 * The driving states determine what features of the UI will be accessible. 1174 */ 1175 enum vehicle_driving_status { 1176 VEHICLE_DRIVING_STATUS_UNRESTRICTED = 0x00, 1177 VEHICLE_DRIVING_STATUS_NO_VIDEO = 0x01, 1178 VEHICLE_DRIVING_STATUS_NO_KEYBOARD_INPUT = 0x02, 1179 VEHICLE_DRIVING_STATUS_NO_VOICE_INPUT = 0x04, 1180 VEHICLE_DRIVING_STATUS_NO_CONFIG = 0x08, 1181 VEHICLE_DRIVING_STATUS_LIMIT_MESSAGE_LEN = 0x10 1182 }; 1183 1184 /** 1185 * Various gears which can be selected by user and chosen in system. 1186 */ 1187 enum vehicle_gear { 1188 // Gear selections present in both automatic and manual cars. 1189 VEHICLE_GEAR_NEUTRAL = 0x0001, 1190 VEHICLE_GEAR_REVERSE = 0x0002, 1191 1192 // Gear selections (mostly) present only in automatic cars. 1193 VEHICLE_GEAR_PARK = 0x0004, 1194 VEHICLE_GEAR_DRIVE = 0x0008, 1195 VEHICLE_GEAR_LOW = 0x0010, 1196 1197 // Other possible gear selections (maybe present in manual or automatic 1198 // cars). 1199 VEHICLE_GEAR_1 = 0x0010, 1200 VEHICLE_GEAR_2 = 0x0020, 1201 VEHICLE_GEAR_3 = 0x0040, 1202 VEHICLE_GEAR_4 = 0x0080, 1203 VEHICLE_GEAR_5 = 0x0100, 1204 VEHICLE_GEAR_6 = 0x0200, 1205 VEHICLE_GEAR_7 = 0x0400, 1206 VEHICLE_GEAR_8 = 0x0800, 1207 VEHICLE_GEAR_9 = 0x1000 1208 }; 1209 1210 1211 /** 1212 * Various zones in the car. 1213 * 1214 * Zones are used for Air Conditioning purposes and divide the car into physical 1215 * area zones. 1216 */ 1217 enum vehicle_zone { 1218 VEHICLE_ZONE_ROW_1_LEFT = 0x00000001, 1219 VEHICLE_ZONE_ROW_1_CENTER = 0x00000002, 1220 VEHICLE_ZONE_ROW_1_RIGHT = 0x00000004, 1221 VEHICLE_ZONE_ROW_1_ALL = 0x00000008, 1222 VEHICLE_ZONE_ROW_2_LEFT = 0x00000010, 1223 VEHICLE_ZONE_ROW_2_CENTER = 0x00000020, 1224 VEHICLE_ZONE_ROW_2_RIGHT = 0x00000040, 1225 VEHICLE_ZONE_ROW_2_ALL = 0x00000080, 1226 VEHICLE_ZONE_ROW_3_LEFT = 0x00000100, 1227 VEHICLE_ZONE_ROW_3_CENTER = 0x00000200, 1228 VEHICLE_ZONE_ROW_3_RIGHT = 0x00000400, 1229 VEHICLE_ZONE_ROW_3_ALL = 0x00000800, 1230 VEHICLE_ZONE_ROW_4_LEFT = 0x00001000, 1231 VEHICLE_ZONE_ROW_4_CENTER = 0x00002000, 1232 VEHICLE_ZONE_ROW_4_RIGHT = 0x00004000, 1233 VEHICLE_ZONE_ROW_4_ALL = 0x00008000, 1234 VEHICLE_ZONE_ALL = 0x80000000, 1235 }; 1236 1237 /** 1238 * Various Seats in the car. 1239 */ 1240 enum vehicle_seat { 1241 VEHICLE_SEAT_DRIVER_LHD = 0x0001, 1242 VEHICLE_SEAT_DRIVER_RHD = 0x0002, 1243 VEHICLE_SEAT_ROW_1_PASSENGER_LEFT = 0x0010, 1244 VEHICLE_SEAT_ROW_1_PASSENGER_CENTER = 0x0020, 1245 VEHICLE_SEAT_ROW_1_PASSENGER_RIGHT = 0x0040, 1246 VEHICLE_SEAT_ROW_2_PASSENGER_LEFT = 0x0100, 1247 VEHICLE_SEAT_ROW_2_PASSENGER_CENTER = 0x0200, 1248 VEHICLE_SEAT_ROW_2_PASSENGER_RIGHT = 0x0400, 1249 VEHICLE_SEAT_ROW_3_PASSENGER_LEFT = 0x1000, 1250 VEHICLE_SEAT_ROW_3_PASSENGER_CENTER = 0x2000, 1251 VEHICLE_SEAT_ROW_3_PASSENGER_RIGHT = 0x4000 1252 }; 1253 1254 /** 1255 * Various windshields/windows in the car. 1256 */ 1257 enum vehicle_window { 1258 VEHICLE_WINDOW_FRONT_WINDSHIELD = 0x0001, 1259 VEHICLE_WINDOW_REAR_WINDSHIELD = 0x0002, 1260 VEHICLE_WINDOW_ROOF_TOP = 0x0004, 1261 VEHICLE_WINDOW_ROW_1_LEFT = 0x0010, 1262 VEHICLE_WINDOW_ROW_1_RIGHT = 0x0020, 1263 VEHICLE_WINDOW_ROW_2_LEFT = 0x0100, 1264 VEHICLE_WINDOW_ROW_2_RIGHT = 0x0200, 1265 VEHICLE_WINDOW_ROW_3_LEFT = 0x1000, 1266 VEHICLE_WINDOW_ROW_3_RIGHT = 0x2000, 1267 }; 1268 1269 enum vehicle_door { 1270 VEHICLE_DOOR_ROW_1_LEFT = 0x00000001, 1271 VEHICLE_DOOR_ROW_1_RIGHT = 0x00000004, 1272 VEHICLE_DOOR_ROW_2_LEFT = 0x00000010, 1273 VEHICLE_DOOR_ROW_2_RIGHT = 0x00000040, 1274 VEHICLE_DOOR_ROW_3_LEFT = 0x00000100, 1275 VEHICLE_DOOR_ROW_3_RIGHT = 0x00000400, 1276 VEHICLE_DOOR_HOOD = 0x10000000, 1277 VEHICLE_DOOR_REAR = 0x20000000, 1278 }; 1279 1280 enum vehicle_mirror { 1281 VEHICLE_MIRROR_DRIVER_LEFT = 0x00000001, 1282 VEHICLE_MIRROR_DRIVER_RIGHT = 0x00000002, 1283 VEHICLE_MIRROR_DRIVER_CENTER = 0x00000004, 1284 }; 1285 enum vehicle_turn_signal { 1286 VEHICLE_SIGNAL_NONE = 0x00, 1287 VEHICLE_SIGNAL_RIGHT = 0x01, 1288 VEHICLE_SIGNAL_LEFT = 0x02, 1289 VEHICLE_SIGNAL_EMERGENCY = 0x04 1290 }; 1291 1292 /* 1293 * Boolean type. 1294 */ 1295 enum vehicle_boolean { 1296 VEHICLE_FALSE = 0x00, 1297 VEHICLE_TRUE = 0x01 1298 }; 1299 1300 typedef int32_t vehicle_boolean_t; 1301 1302 /** 1303 * Vehicle string. 1304 * 1305 * Defines a UTF8 encoded sequence of bytes that should be used for string 1306 * representation throughout. 1307 */ 1308 typedef struct vehicle_str { 1309 uint8_t* data; 1310 int32_t len; 1311 } vehicle_str_t; 1312 1313 /** 1314 * Vehicle byte array. 1315 * This is for passing generic raw data. 1316 */ 1317 typedef vehicle_str_t vehicle_bytes_t; 1318 1319 typedef struct vehicle_prop_config { 1320 int32_t prop; 1321 1322 /** 1323 * Defines if the property is read or write. Value should be one of 1324 * enum vehicle_prop_access. 1325 */ 1326 int32_t access; 1327 1328 /** 1329 * Defines if the property is continuous or on-change. Value should be one 1330 * of enum vehicle_prop_change_mode. 1331 */ 1332 int32_t change_mode; 1333 1334 /** 1335 * Type of data used for this property. This type is fixed per each property. 1336 * Check vehicle_value_type for allowed value. 1337 */ 1338 int32_t value_type; 1339 1340 /** 1341 * Define necessary permission model to access the data. 1342 */ 1343 int32_t permission_model; 1344 1345 /** 1346 * Some of the properties may have associated zones (such as hvac), in these 1347 * cases the config should contain an ORed value for the associated zone. 1348 */ 1349 union { 1350 /** 1351 * The value is derived by ORing one or more of enum vehicle_zone members. 1352 */ 1353 int32_t vehicle_zone_flags; 1354 /** The value is derived by ORing one or more of enum vehicle_seat members. */ 1355 int32_t vehicle_seat_flags; 1356 /** The value is derived by ORing one or more of enum vehicle_window members. */ 1357 int32_t vehicle_window_flags; 1358 }; 1359 1360 /** 1361 * Property specific configuration information. Usage of this will be defined per each property. 1362 */ 1363 union { 1364 /** 1365 * For generic configuration information 1366 */ 1367 int32_t config_flags; 1368 /** The number of presets that are stored by the radio module. Pass 0 if 1369 * there are no presets available. The range of presets is defined to be 1370 * from 1 (see VEHICLE_RADIO_PRESET_MIN_VALUE) to vehicle_radio_num_presets. 1371 */ 1372 int32_t vehicle_radio_num_presets; 1373 int32_t config_array[4]; 1374 }; 1375 1376 /** 1377 * Some properties may require additional information passed over this string. Most properties 1378 * do not need to set this and in that case, config_string.data should be NULL and 1379 * config_string.len should be 0. 1380 */ 1381 vehicle_str_t config_string; 1382 1383 /** 1384 * Specify minimum allowed value for the property. This is necessary for property which does 1385 * not have specified enum. 1386 */ 1387 union { 1388 float float_min_value; 1389 int32_t int32_min_value; 1390 int64_t int64_min_value; 1391 }; 1392 1393 /** 1394 * Specify maximum allowed value for the property. This is necessary for property which does 1395 * not have specified enum. 1396 */ 1397 union { 1398 float float_max_value; 1399 int32_t int32_max_value; 1400 int64_t int64_max_value; 1401 }; 1402 1403 /** 1404 * Array of min values for zoned properties. Zoned property can specify min / max value in two 1405 * different ways: 1406 * 1. All zones having the same min / max value: *_min/max_value should be set and this 1407 * array should be set to NULL. 1408 * 2. All zones having separate min / max value: *_min/max_values array should be populated 1409 * and its length should be the same as number of active zones specified by *_zone_flags. 1410 * 1411 * Should be NULL if each zone does not have separate max values. 1412 */ 1413 union { 1414 float* float_min_values; 1415 int32_t* int32_min_values; 1416 int64_t* int64_min_values; 1417 }; 1418 1419 /** 1420 * Array of max values for zoned properties. See above for its usage. 1421 * Should be NULL if each zone does not have separate max values. 1422 * If not NULL, length of array should match that of min_values. 1423 */ 1424 union { 1425 float* float_max_values; 1426 int32_t* int32_max_values; 1427 int64_t* int64_max_values; 1428 }; 1429 1430 /** 1431 * Min sample rate in Hz. Should be 0 for sensor type of VEHICLE_PROP_CHANGE_MODE_ON_CHANGE 1432 */ 1433 float min_sample_rate; 1434 /** 1435 * Max sample rate in Hz. Should be 0 for sensor type of VEHICLE_PROP_CHANGE_MODE_ON_CHANGE 1436 */ 1437 float max_sample_rate; 1438 /** 1439 * Place holder for putting HAL implementation specific data. Usage is wholly up to HAL 1440 * implementation. 1441 */ 1442 void* hal_data; 1443 } vehicle_prop_config_t; 1444 1445 /** 1446 * HVAC property fields. 1447 * 1448 * Defines various HVAC properties which are packed into vehicle_hvac_t (see 1449 * below). We define these properties outside in global scope so that HAL 1450 * implementation and HAL users (JNI) can typecast vehicle_hvac correctly. 1451 */ 1452 typedef struct vehicle_hvac { 1453 /** 1454 * Define one structure for each possible HVAC property. 1455 * NOTES: 1456 * a) Fan speed is a number from (0 - 6) where 6 is the highest speed. (TODO define enum) 1457 * b) Temperature is a floating point Celcius scale. 1458 * c) Direction is defined in enum vehicle_fan_direction. 1459 * 1460 * The HAL should create #entries number of vehicle_hvac_properties and 1461 * assign it to "properties" variable below. 1462 */ 1463 union { 1464 int32_t fan_speed; 1465 int32_t fan_direction; 1466 vehicle_boolean_t ac_on; 1467 vehicle_boolean_t max_ac_on; 1468 vehicle_boolean_t max_defrost_on; 1469 vehicle_boolean_t recirc_on; 1470 vehicle_boolean_t dual_on; 1471 vehicle_boolean_t power_on; 1472 1473 float temperature_current; 1474 float temperature_set; 1475 1476 vehicle_boolean_t defrost_on; 1477 }; 1478 } vehicle_hvac_t; 1479 1480 /* 1481 * Defines how the values for various properties are represented. 1482 * 1483 * There are two ways to populate and access the fields: 1484 * a) Using the individual fields. Use this mechanism (see 1485 * info_manufacture_date, fuel_capacity fields etc). 1486 * b) Using the union accessors (see uint32_value, float_value etc). 1487 * 1488 * To add a new field make sure that it does not exceed the total union size 1489 * (defined in int_array) and it is one of the vehicle_value_type. Then add the 1490 * field name with its unit to union. If the field type is not yet defined (as 1491 * of this draft, we don't use int64_t) then add that type to vehicle_value_type 1492 * and have an accessor (so for int64_t it will be int64_t int64_value). 1493 */ 1494 typedef union vehicle_value { 1495 /** Define the max size of this structure. */ 1496 int32_t int32_array[4]; 1497 float float_array[4]; 1498 1499 // Easy accessors for union members (HAL implementation SHOULD NOT USE these 1500 // fields while populating, use the property specific fields below instead). 1501 int32_t int32_value; 1502 int64_t int64_value; 1503 float float_value; 1504 vehicle_str_t str_value; 1505 vehicle_bytes_t bytes_value; 1506 vehicle_boolean_t boolean_value; 1507 1508 // Vehicle Information. 1509 vehicle_str_t info_vin; 1510 vehicle_str_t info_make; 1511 vehicle_str_t info_model; 1512 int32_t info_model_year; 1513 1514 // Represented in milliliters. 1515 float info_fuel_capacity; 1516 1517 float vehicle_speed; 1518 float odometer; 1519 1520 // Engine sensors. 1521 1522 // Represented in milliliters. 1523 //float engine_coolant_level; 1524 // Represented in celcius. 1525 float engine_coolant_temperature; 1526 // Represented in a percentage value. 1527 //float engine_oil_level; 1528 // Represented in celcius. 1529 float engine_oil_temperature; 1530 float engine_rpm; 1531 1532 // Event sensors. 1533 // Value should be one of enum vehicle_gear_selection. 1534 int32_t gear_selection; 1535 // Value should be one of enum vehicle_gear. 1536 int32_t gear_current_gear; 1537 // Value should be one of enum vehicle_boolean. 1538 int32_t parking_brake; 1539 // If cruise_set_speed > 0 then cruise is ON otherwise cruise is OFF. 1540 // Unit: meters / second (m/s). 1541 //int32_t cruise_set_speed; 1542 // Value should be one of enum vehicle_boolean. 1543 int32_t is_fuel_level_low; 1544 // Value should be one of enum vehicle_driving_status. 1545 int32_t driving_status; 1546 int32_t night_mode; 1547 // Value should be one of emum vehicle_turn_signal. 1548 int32_t turn_signals; 1549 // Value should be one of enum vehicle_boolean. 1550 //int32_t engine_on; 1551 1552 // HVAC properties. 1553 vehicle_hvac_t hvac; 1554 1555 float outside_temperature; 1556 float cabin_temperature; 1557 1558 } vehicle_value_t; 1559 1560 /* 1561 * Encapsulates the property name and the associated value. It 1562 * is used across various API calls to set values, get values or to register for 1563 * events. 1564 */ 1565 typedef struct vehicle_prop_value { 1566 /* property identifier */ 1567 int32_t prop; 1568 1569 /* value type of property for quick conversion from union to appropriate 1570 * value. The value must be one of enum vehicle_value_type. 1571 */ 1572 int32_t value_type; 1573 1574 /** time is elapsed nanoseconds since boot */ 1575 int64_t timestamp; 1576 1577 /** 1578 * Zone information for zoned property. For non-zoned property, this should be ignored. 1579 */ 1580 union { 1581 int32_t zone; 1582 int32_t seat; 1583 int32_t window; 1584 }; 1585 1586 vehicle_value_t value; 1587 } vehicle_prop_value_t; 1588 1589 /* 1590 * Event callback happens whenever a variable that the API user has subscribed 1591 * to needs to be reported. This may be based purely on threshold and frequency 1592 * (a regular subscription, see subscribe call's arguments) or when the set() 1593 * command is executed and the actual change needs to be reported. 1594 * 1595 * event_data is OWNED by the HAL and should be copied before the callback 1596 * finishes. 1597 */ 1598 typedef int (*vehicle_event_callback_fn)(const vehicle_prop_value_t *event_data); 1599 1600 1601 /** 1602 * Represent the operation where the current error has happened. 1603 */ 1604 enum vehicle_property_operation { 1605 /** Generic error to this property which is not tied to any operation. */ 1606 VEHICLE_OPERATION_GENERIC = 0, 1607 /** Error happened while handling property set. */ 1608 VEHICLE_OPERATION_SET = 1, 1609 /** Error happened while handling property get. */ 1610 VEHICLE_OPERATION_GET = 2, 1611 /** Error happened while handling property subscription. */ 1612 VEHICLE_OPERATION_SUBSCRIBE = 3, 1613 }; 1614 1615 /* 1616 * Suggests that an error condition has occurred. 1617 * 1618 * @param error_code Error code. error_code should be standard error code with 1619 * negative value like -EINVAL. 1620 * @parm property Note a property where error has happened. If this is generic error, property 1621 * should be VEHICLE_PROPERTY_INVALID. 1622 * @param operation Represent the operation where the error has happened. Should be one of 1623 * vehicle_property_operation. 1624 */ 1625 typedef int (*vehicle_error_callback_fn)(int32_t error_code, int32_t property, int32_t operation); 1626 1627 /************************************************************************************/ 1628 1629 /* 1630 * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM 1631 * and the fields of this data structure must begin with hw_module_t 1632 * followed by module specific information. 1633 */ 1634 typedef struct vehicle_module { 1635 struct hw_module_t common; 1636 } vehicle_module_t; 1637 1638 1639 typedef struct vehicle_hw_device { 1640 struct hw_device_t common; 1641 1642 /** 1643 * After calling open on device the user should register callbacks for event and error 1644 * functions. 1645 */ 1646 int (*init)(struct vehicle_hw_device* device, 1647 vehicle_event_callback_fn event_fn, vehicle_error_callback_fn err_fn); 1648 /** 1649 * Before calling close the user should destroy the registered callback 1650 * functions. 1651 * In case the unsubscribe() call is not called on all properties before 1652 * release() then release() will unsubscribe the properties itself. 1653 */ 1654 int (*release)(struct vehicle_hw_device* device); 1655 1656 /** 1657 * Enumerate all available properties. The list is returned in "list". 1658 * @param num_properties number of properties contained in the retuned array. 1659 * @return array of property configs supported by this car. Note that returned data is const 1660 * and caller cannot modify it. HAL implementation should keep this memory until HAL 1661 * is released to avoid copying this again. 1662 */ 1663 vehicle_prop_config_t const *(*list_properties)(struct vehicle_hw_device* device, 1664 int* num_properties); 1665 1666 /** 1667 * Get a vehicle property value immediately. data should be allocated 1668 * properly. 1669 * The caller of the API OWNS the data field. 1670 * Caller will set data->prop, data->value_type, and optionally zone value for zoned property. 1671 * But HAL implementation needs to fill all entries properly when returning. 1672 * For pointer type, HAL implementation should allocate necessary memory and caller is 1673 * responsible for calling release_memory_from_get, which allows HAL to release allocated 1674 * memory. 1675 * For VEHICLE_PROP_CHANGE_MODE_STATIC type of property, get should return the same value 1676 * always. 1677 * For VEHICLE_PROP_CHANGE_MODE_ON_CHANGE type of property, it should return the latest value. 1678 * If there is no data available yet, which can happen during initial stage, this call should 1679 * return immediately with error code of -EAGAIN. 1680 */ 1681 int (*get)(struct vehicle_hw_device* device, vehicle_prop_value_t *data); 1682 1683 /** 1684 * Release memory allocated to data in previous get call. get call for byte or string involves 1685 * allocating necessary memory from vehicle hal. 1686 * To be safe, memory allocated by vehicle hal should be released by vehicle hal and vehicle 1687 * network service will call this when data from vehicle hal is no longer necessary. 1688 * vehicle hal implementation should only release member of vehicle_prop_value_t like 1689 * data->str_value.data or data->bytes_value.data but not data itself as data itself is 1690 * allocated from vehicle network service. Once memory is freed, corresponding pointer should 1691 * be set to NULL bu vehicle hal. 1692 */ 1693 void (*release_memory_from_get)(struct vehicle_hw_device* device, vehicle_prop_value_t *data); 1694 1695 /** 1696 * Set a vehicle property value. data should be allocated properly and not 1697 * NULL. 1698 * The caller of the API OWNS the data field. 1699 * timestamp of data will be ignored for set operation. 1700 * Setting some properties require having initial state available. Depending on the vehicle hal, 1701 * such initial data may not be available for short time after init. In such case, set call 1702 * can return -EAGAIN like get call. 1703 * For a property with separate power control, set can fail if the property is not powered on. 1704 * In such case, hal should return -ESHUTDOWN error. 1705 */ 1706 int (*set)(struct vehicle_hw_device* device, const vehicle_prop_value_t *data); 1707 1708 /** 1709 * Subscribe to events. 1710 * Depending on output of list_properties if the property is: 1711 * a) on-change: sample_rate should be set to 0. 1712 * b) supports frequency: sample_rate should be set from min_sample_rate to 1713 * max_sample_rate. 1714 * For on-change type of properties, vehicle network service will make another get call to check 1715 * the initial state. Due to this, vehicle hal implementation does not need to send initial 1716 * state for on-change type of properties. 1717 * @param device 1718 * @param prop 1719 * @param sample_rate 1720 * @param zones All subscribed zones for zoned property. can be ignored for non-zoned property. 1721 * 0 means all zones supported instead of no zone. 1722 */ 1723 int (*subscribe)(struct vehicle_hw_device* device, int32_t prop, float sample_rate, 1724 int32_t zones); 1725 1726 /** Cancel subscription on a property. */ 1727 int (*unsubscribe)(struct vehicle_hw_device* device, int32_t prop); 1728 1729 /** 1730 * Print out debugging state for the vehicle hal. This will be called by 1731 * the vehicle network service and will be included into the service' dump. 1732 * 1733 * The passed-in file descriptor can be used to write debugging text using 1734 * dprintf() or write(). The text should be in ASCII encoding only. 1735 * 1736 * Performance requirements: 1737 * 1738 * This must be a non-blocking call. The HAL should return from this call 1739 * in 1ms, must return from this call in 10ms. This call must avoid 1740 * deadlocks, as it may be called at any point of operation. 1741 * Any synchronization primitives used (such as mutex locks or semaphores) 1742 * should be acquired with a timeout. 1743 */ 1744 int (*dump)(struct vehicle_hw_device* device, int fd); 1745 1746 } vehicle_hw_device_t; 1747 1748 __END_DECLS 1749 1750 #endif // ANDROID_VEHICLE_INTERFACE_H 1751