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