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