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