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