blob: b7deb89bfbf3c1f122bc57386b5011b742eefdd6 [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 */
Steve Paik159349e2016-02-09 18:45:58 -0800282enum vehicle_hvac_fan_direction {
283 VEHICLE_HVAC_FAN_DIRECTION_FACE = 0x1,
284 VEHICLE_HVAC_FAN_DIRECTION_FLOOR = 0x2,
285 VEHICLE_HVAC_FAN_DIRECTION_FACE_AND_FLOOR = 0x3,
286 VEHICLE_HVAC_FAN_DIRECTION_DEFROST = 0x4,
287 VEHICLE_HVAC_FAN_DIRECTION_DEFROST_AND_FLOOR = 0x5
Steve Paikd2ba70f2015-12-10 14:58:27 -0800288};
289
Sanket Agarwalfb636682015-08-11 14:34:29 -0700290/**
291 * HVAC current temperature.
292 * @value_type VEHICLE_VALUE_TYPE_ZONED_FLOAT
293 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE|VEHICLE_PROP_CHANGE_MODE_CONTINUOUS
294 * @access VEHICLE_PROP_ACCESS_READ_WRITE
Keun-young Parkbf877a72015-12-21 14:16:05 -0800295 * @config_flags Supported zones
Keun-young Park14f09002016-01-22 16:29:22 -0800296 * @zone_type VEHICLE_ZONE
Sanket Agarwalfb636682015-08-11 14:34:29 -0700297 * @data_member hvac.temperature_current
298 */
299#define VEHICLE_PROPERTY_HVAC_TEMPERATURE_CURRENT (0x00000502)
300
301/**
302 * HVAC, target temperature set.
303 * @value_type VEHICLE_VALUE_TYPE_ZONED_FLOAT
304 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE|VEHICLE_PROP_CHANGE_MODE_CONTINUOUS
Keun-young Parkbf877a72015-12-21 14:16:05 -0800305 * @config_flags Supported zones
Sanket Agarwalfb636682015-08-11 14:34:29 -0700306 * @access VEHICLE_PROP_ACCESS_READ_WRITE
Keun-young Park14f09002016-01-22 16:29:22 -0800307 * @zone_type VEHICLE_ZONE
Sanket Agarwalfb636682015-08-11 14:34:29 -0700308 * @data_member hvac.temperature_set
309 */
310#define VEHICLE_PROPERTY_HVAC_TEMPERATURE_SET (0x00000503)
311
312/**
313 * On/off defrost
314 * @value_type VEHICLE_VALUE_TYPE_ZONED_BOOLEAN
315 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE
316 * @access VEHICLE_PROP_ACCESS_READ_WRITE
Keun-young Parkbf877a72015-12-21 14:16:05 -0800317 * @config_flags Supported zones
Sanket Agarwalfb636682015-08-11 14:34:29 -0700318 * @data_member hvac.defrost_on
319 */
320#define VEHICLE_PROPERTY_HVAC_DEFROSTER (0x00000504)
321
322/**
323 * On/off AC
324 * @value_type VEHICLE_VALUE_TYPE_ZONED_BOOLEAN
325 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE
326 * @access VEHICLE_PROP_ACCESS_READ_WRITE
Keun-young Parkbf877a72015-12-21 14:16:05 -0800327 * @config_flags Supported zones
Keun-young Park14f09002016-01-22 16:29:22 -0800328 * @zone_type VEHICLE_ZONE
Sanket Agarwalfb636682015-08-11 14:34:29 -0700329 * @data_member hvac.ac_on
330 */
331#define VEHICLE_PROPERTY_HVAC_AC_ON (0x00000505)
332
333/**
Steve Paikd2ba70f2015-12-10 14:58:27 -0800334 * On/off max AC
335 * @value_type VEHICLE_VALUE_TYPE_BOOLEAN
336 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE
337 * @access VEHICLE_PROP_ACCESS_READ_WRITE
338 * @data_member hvac.max_ac_on
339 */
340#define VEHICLE_PROPERTY_HVAC_MAX_AC_ON (0x00000506)
341
342/**
343 * On/off max defrost
344 * @value_type VEHICLE_VALUE_TYPE_BOOLEAN
345 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE
346 * @access VEHICLE_PROP_ACCESS_READ_WRITE
347 * @data_member hvac.max_defrost_on
348 */
349#define VEHICLE_PROPERTY_HVAC_MAX_DEFROST_ON (0x00000507)
350
351/**
352 * On/off re-circulation
353 * @value_type VEHICLE_VALUE_TYPE_BOOLEAN
354 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE
355 * @access VEHICLE_PROP_ACCESS_READ_WRITE
356 * @data_member hvac.max_recirc_on
357 */
358#define VEHICLE_PROPERTY_HVAC_RECIRC_ON (0x00000508)
359
360/**
361 * On/off dual
362 * @value_type VEHICLE_VALUE_TYPE_BOOLEAN
363 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE
364 * @access VEHICLE_PROP_ACCESS_READ_WRITE
365 * @data_member hvac.dual_on
366 */
367#define VEHICLE_PROPERTY_HVAC_DUAL_ON (0x00000509)
368
369/**
Sanket Agarwalfb636682015-08-11 14:34:29 -0700370 * Outside temperature
371 * @value_type VEHICLE_VALUE_TYPE_FLOAT
372 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE|VEHICLE_PROP_CHANGE_MODE_CONTINUOUS
373 * @access VEHICLE_PROP_ACCESS_READ
374 * @data_member outside_temperature
375 * @unit VEHICLE_UNIT_TYPE_CELCIUS
376 */
Keun-young Parkcb354502016-02-08 18:15:55 -0800377#define VEHICLE_PROPERTY_ENV_OUTSIDE_TEMPERATURE (0x00000703)
378
379
380/**
381 * Cabin temperature
382 * @value_type VEHICLE_VALUE_TYPE_FLOAT
383 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE|VEHICLE_PROP_CHANGE_MODE_CONTINUOUS
384 * @access VEHICLE_PROP_ACCESS_READ
385 * @data_member cabin_temperature
386 * @unit VEHICLE_UNIT_TYPE_CELCIUS
387 */
388#define VEHICLE_PROPERTY_ENV_CABIN_TEMPERATURE (0x00000704)
Sanket Agarwalfb636682015-08-11 14:34:29 -0700389
390
391/*
392 * Radio features.
393 */
394/**
395 * Radio presets stored on the Car radio module. The data type used is int32
396 * array with the following fields:
397 * <ul>
398 * <li> int32_array[0]: Preset number </li>
399 * <li> int32_array[1]: Band type (see #RADIO_BAND_FM in
400 * system/core/include/system/radio.h).
401 * <li> int32_array[2]: Channel number </li>
402 * <li> int32_array[3]: Sub channel number </li>
403 * </ul>
404 *
405 * NOTE: When getting a current preset config ONLY set preset number (i.e.
406 * int32_array[0]). For setting a preset other fields are required.
407 *
408 * @value_type VEHICLE_VALUE_TYPE_INT32_VEC4
409 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE
410 * @access VEHICLE_PROP_ACCESS_READ_WRITE
Keun-young Parkbf877a72015-12-21 14:16:05 -0800411 * @config_flags Number of presets supported
Sanket Agarwalfb636682015-08-11 14:34:29 -0700412 * @data_member int32_array
413 */
414#define VEHICLE_PROPERTY_RADIO_PRESET (0x0000801)
415
416/**
417 * Constants relevant to radio.
418 */
419enum vehicle_radio_consts {
420 /** Minimum value for the radio preset */
421 VEHICLE_RADIO_PRESET_MIN_VALUE = 1,
422};
423
424/**
425 * Represents audio focus state of Android side. Note that car's audio module will own audio
426 * focus and grant audio focus to Android side when requested by Android side. The focus has both
427 * per stream characteristics and global characteristics.
428 *
429 * Focus request (get of this property) will take the following form in int32_vec4:
Keun-young Park08c255e2015-12-09 13:47:30 -0800430 * int32_array[0]: vehicle_audio_focus_request type
Sanket Agarwalfb636682015-08-11 14:34:29 -0700431 * int32_array[1]: bit flags of streams requested by this focus request. There can be up to
432 * 32 streams.
433 * int32_array[2]: External focus state flags. For request, only flag like
434 * VEHICLE_AUDIO_EXT_FOCUS_CAR_PLAY_ONLY_FLAG can be used.
435 * This is for case like radio where android side app still needs to hold focus
436 * but playback is done outside Android.
Keun-young Parkfe599a82016-02-12 14:26:57 -0800437 * int32_array[3]: Currently active audio contexts in android side. Use combination of flags from
438 * vehicle_audio_context_flag.
439 * This can be used as a hint to adjust audio policy or other policy decision.
440 * Note that there can be multiple context active at the same time. And android
441 * can send the same focus request type gain due to change in audio contexts.
Sanket Agarwalfb636682015-08-11 14:34:29 -0700442 * Note that each focus request can request multiple streams that is expected to be used for
443 * the current request. But focus request itself is global behavior as GAIN or GAIN_TRANSIENT
444 * expects all sounds played by car's audio module to stop. Note that stream already allocated to
445 * android before this focus request should not be affected by focus request.
446 *
447 * Focus response (set and subscription callback for this property) will take the following form:
Keun-young Park08c255e2015-12-09 13:47:30 -0800448 * int32_array[0]: vehicle_audio_focus_state type
Sanket Agarwalfb636682015-08-11 14:34:29 -0700449 * int32_array[1]: bit flags of streams allowed.
450 * int32_array[2]: External focus state: bit flags of currently active audio focus in car
451 * side (outside Android). Active audio focus does not necessarily mean currently
452 * playing, but represents the state of having focus or waiting for focus
453 * (pause state).
454 * One or combination of flags from vehicle_audio_ext_focus_flag.
455 * 0 means no active audio focus holder outside Android.
456 * The state will have following values for each vehicle_audio_focus_state_type:
457 * GAIN: 0 or VEHICLE_AUDIO_EXT_FOCUS_CAR_PLAY_ONLY when radio is active in
458 * Android side.
459 * GAIN_TRANSIENT: 0. Can be VEHICLE_AUDIO_EXT_FOCUS_CAR_PERMANENT or
460 * VEHICLE_AUDIO_EXT_FOCUS_CAR_TRANSIENT if android side has requested
461 * GAIN_TRANSIENT_MAY_DUCK and car side is ducking.
462 * LOSS: 0 when no focus is audio is active in car side.
463 * VEHICLE_AUDIO_EXT_FOCUS_CAR_PERMANENT when car side is playing something
464 * permanent.
465 * LOSS_TRANSIENT: always should be VEHICLE_AUDIO_EXT_FOCUS_CAR_TRANSIENT
Keun-young Parkfe599a82016-02-12 14:26:57 -0800466 * int32_array[3]: should be zero.
Sanket Agarwalfb636682015-08-11 14:34:29 -0700467 *
468 * If car does not support VEHICLE_PROPERTY_AUDIO_FOCUS, focus is assumed to be granted always.
469 *
Keun-young Parkfe599a82016-02-12 14:26:57 -0800470 * @value_type VEHICLE_VALUE_TYPE_INT32_VEC4
Sanket Agarwalfb636682015-08-11 14:34:29 -0700471 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE
472 * @access VEHICLE_PROP_ACCESS_READ_WRITE
473 * @data_member int32_array
474 */
475#define VEHICLE_PROPERTY_AUDIO_FOCUS (0x00000900)
476
477enum vehicle_audio_focus_request {
478 VEHICLE_AUDIO_FOCUS_REQUEST_GAIN = 0x1,
479 VEHICLE_AUDIO_FOCUS_REQUEST_GAIN_TRANSIENT = 0x2,
480 VEHICLE_AUDIO_FOCUS_REQUEST_GAIN_TRANSIENT_MAY_DUCK = 0x3,
Keun-young Parkcb354502016-02-08 18:15:55 -0800481 /**
482 * This is for the case where android side plays sound like UI feedback
483 * and car side does not need to duck existing playback as long as
484 * requested stream is available.
485 */
486 VEHICLE_AUDIO_FOCUS_REQUEST_GAIN_TRANSIENT_NO_DUCK = 0x4,
487 VEHICLE_AUDIO_FOCUS_REQUEST_RELEASE = 0x5,
Sanket Agarwalfb636682015-08-11 14:34:29 -0700488};
489
490enum vehicle_audio_focus_state {
491 /**
492 * Android side has permanent focus and can play allowed streams.
493 */
494 VEHICLE_AUDIO_FOCUS_STATE_GAIN = 0x1,
495 /**
496 * Android side has transient focus and can play allowed streams.
497 */
498 VEHICLE_AUDIO_FOCUS_STATE_GAIN_TRANSIENT = 0x2,
499 /**
500 * Car audio module is playing guidance kind of sound outside Android. Android side can
501 * still play through allowed streams with ducking.
502 */
503 VEHICLE_AUDIO_FOCUS_STATE_LOSS_TRANSIENT_CAN_DUCK = 0x3,
504 /**
505 * Car audio module is playing transient sound outside Android. Android side should stop
506 * playing any sounds.
507 */
508 VEHICLE_AUDIO_FOCUS_STATE_LOSS_TRANSIENT = 0x4,
509 /**
510 * Android side has lost focus and cannot play any sound.
511 */
512 VEHICLE_AUDIO_FOCUS_STATE_LOSS = 0x5,
513 /**
514 * car audio module is playing safety critical sound, and Android side cannot request focus
515 * until the current state is finished. car audio module should restore it to the previous
516 * state when it can allow Android to play.
517 */
518 VEHICLE_AUDIO_FOCUS_STATE_LOSS_TRANSIENT_EXLCUSIVE = 0x6,
519};
520
521/**
522 * Flags to represent multiple streams by combining these.
523 */
524enum vehicle_audio_stream_flag {
525 VEHICLE_AUDIO_STREAM_STREAM0_FLAG = (0x1<<0),
526 VEHICLE_AUDIO_STREAM_STREAM1_FLAG = (0x1<<1),
527 VEHICLE_AUDIO_STREAM_STREAM2_FLAG = (0x1<<2),
528};
529
530/**
531 * Represents stream number (always 0 to N -1 where N is max number of streams).
532 * Can be used for audio related property expecting one stream.
533 */
534enum vehicle_audio_stream {
535 VEHICLE_AUDIO_STREAM0 = 0,
536 VEHICLE_AUDIO_STREAM1 = 1,
537};
538
539/**
540 * Flag to represent external focus state (outside Android).
541 */
542enum vehicle_audio_ext_focus_flag {
543 /**
544 * No external focus holder.
545 */
546 VEHICLE_AUDIO_EXT_FOCUS_NONE_FLAG = 0x0,
547 /**
548 * Car side (outside Android) has component holding GAIN kind of focus state.
549 */
550 VEHICLE_AUDIO_EXT_FOCUS_CAR_PERMANENT_FLAG = 0x1,
551 /**
552 * Car side (outside Android) has component holding GAIN_TRANSIENT kind of focus state.
553 */
554 VEHICLE_AUDIO_EXT_FOCUS_CAR_TRANSIENT_FLAG = 0x2,
555 /**
556 * Car side is expected to play something while focus is held by Android side. One example
557 * can be radio attached in car side. But Android's radio app still should have focus,
558 * and Android side should be in GAIN state, but media stream will not be allocated to Android
559 * side and car side can play radio any time while this flag is active.
560 */
561 VEHICLE_AUDIO_EXT_FOCUS_CAR_PLAY_ONLY_FLAG = 0x4,
562};
563
564/**
565 * Index in int32_array for VEHICLE_PROPERTY_AUDIO_FOCUS property.
566 */
567enum vehicle_audio_focus_index {
568 VEHICLE_AUDIO_FOCUS_INDEX_FOCUS = 0,
569 VEHICLE_AUDIO_FOCUS_INDEX_STREAMS = 1,
570 VEHICLE_AUDIO_FOCUS_INDEX_EXTERNAL_FOCUS_STATE = 2,
Keun-young Parkfe599a82016-02-12 14:26:57 -0800571 VEHICLE_AUDIO_FOCUS_INDEX_AUDIO_CONTEXTS = 3,
572};
573
574/**
575 * Flags to tell the current audio context.
576 */
577enum vehicle_audio_context_flag {
578 /** Music playback is currently active. */
579 VEHICLE_AUDIO_CONTEXT_MUSIC_FLAG = 0x1,
580 /** Navigation is currently running. */
581 VEHICLE_AUDIO_CONTEXT_NAVIGATION_FLAG = 0x2,
582 /** Voice command session is currently running. */
583 VEHICLE_AUDIO_CONTEXT_VOICE_COMMAND_FLAG = 0x4,
584 /** Voice call is currently active. */
585 VEHICLE_AUDIO_CONTEXT_CALL_FLAG = 0x8,
586 /** Alarm is active. This may be only used in VEHICLE_PROPERTY_AUDIO_ROUTING_POLICY. */
587 VEHICLE_AUDIO_CONTEXT_ALARM_FLAG = 0x10,
588 /**
589 * Notification sound is active. This may be only used in VEHICLE_PROPERTY_AUDIO_ROUTING_POLICY.
590 */
591 VEHICLE_AUDIO_CONTEXT_NOTIFICATION_FLAG = 0x20,
592 /**
593 * Context unknown. Only used for VEHICLE_PROPERTY_AUDIO_ROUTING_POLICY to represent default
594 * stream for unknown contents.
595 */
596 VEHICLE_AUDIO_CONTEXT_UNKNOWN_FLAG = 0x40,
597 /** Safety alert / warning is played. */
598 VEHICLE_AUDIO_CONTEXT_SAFETY_ALERT_FLAG = 0x80,
599 /** CD / DVD kind of audio is played */
Keun-young Park9f376f52016-03-03 17:47:18 -0800600 VEHICLE_AUDIO_CONTEXT_CD_ROM_FLAG = 0x100,
Keun-young Parkfe599a82016-02-12 14:26:57 -0800601 /** Aux audio input is played */
Keun-young Park9f376f52016-03-03 17:47:18 -0800602 VEHICLE_AUDIO_CONTEXT_AUX_AUDIO_FLAG = 0x200,
Keun-young Parkfe599a82016-02-12 14:26:57 -0800603 /** system sound like UI feedback */
Keun-young Park9f376f52016-03-03 17:47:18 -0800604 VEHICLE_AUDIO_CONTEXT_SYSTEM_SOUND_FLAG = 0x400,
Keun-young Parkfe599a82016-02-12 14:26:57 -0800605 /** Radio is played */
Keun-young Park9f376f52016-03-03 17:47:18 -0800606 VEHICLE_AUDIO_CONTEXT_RADIO_FLAG = 0x800,
Sanket Agarwalfb636682015-08-11 14:34:29 -0700607};
608
609/**
Keun-young Parkbf877a72015-12-21 14:16:05 -0800610 * Property to control audio volume of each audio context.
Sanket Agarwalfb636682015-08-11 14:34:29 -0700611 *
Keun-young Park12a3c012016-03-23 17:58:29 -0700612 * vehicle_prop_config_t
613 * config_array[0] : bit flags of all supported audio contexts. If this is 0,
614 * audio volume is controlled per physical stream
615 * config_array[1] : flags defined in vehicle_audio_volume_capability_flag to
616 * represent audio module's capability.
617 *
Sanket Agarwalfb636682015-08-11 14:34:29 -0700618 * Data type looks like:
Keun-young Park12a3c012016-03-23 17:58:29 -0700619 * int32_array[0] : stream context as defined in vehicle_audio_context_flag. If only physical
620 stream is supported (config_array[0] == 0), this will represent physical
621 stream number.
Sanket Agarwalfb636682015-08-11 14:34:29 -0700622 * int32_array[1] : volume level, valid range is 0 to int32_max_value defined in config.
623 * 0 will be mute state. int32_min_value in config should be always 0.
624 * int32_array[2] : One of vehicle_audio_volume_state.
625 *
626 * This property requires per stream based get. HAL implementation should check stream number
627 * in get call to return the right volume.
628 *
629 * @value_type VEHICLE_VALUE_TYPE_INT32_VEC3
630 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE
631 * @access VEHICLE_PROP_ACCESS_READ_WRITE
Keun-young Parkbf877a72015-12-21 14:16:05 -0800632 * @config_flags all audio contexts supported.
Sanket Agarwalfb636682015-08-11 14:34:29 -0700633 * @data_member int32_array
634 */
635#define VEHICLE_PROPERTY_AUDIO_VOLUME (0x00000901)
636
Keun-young Park12a3c012016-03-23 17:58:29 -0700637
638/**
639 * flags to represent capability of audio volume property.
640 * used in config_array[1] of vehicle_prop_config_t.
641 */
642enum vehicle_audio_volume_capability_flag {
643 /**
644 * External audio module or vehicle hal has persistent storage
645 * to keep the volume level. This should be set only when per context
646 * volume level is supproted. When this is set, audio volume level per
647 * each context will be retrieved from the property when systen starts up.
648 * And external audio module is also expected to adjust volume automatically
649 * whenever there is an audio context change.
650 * When this flag is not set, android side will assume that there is no
651 * persistent storage and stored value in android side will be used to
652 * initialize the volume level. And android side will set volume level
653 * of each physical streams whenever there is an audio context change.
654 */
655 VEHICLE_AUDIO_VOLUME_CAPABILITY_PERSISTENT_STORAGE = 0x1,
656};
657
Sanket Agarwalfb636682015-08-11 14:34:29 -0700658/**
659 * enum to represent audio volume state.
660 */
661enum vehicle_audio_volume_state {
662 VEHICLE_AUDIO_VOLUME_STATE_OK = 0,
663 /**
664 * Audio volume has reached volume limit set in VEHICLE_PROPERTY_AUDIO_VOLUME_LIMIT
665 * and user's request to increase volume further is not allowed.
666 */
667 VEHICLE_AUDIO_VOLUME_STATE_LIMIT_REACHED = 1,
668};
669
670/**
671 * Index in int32_array for VEHICLE_PROPERTY_AUDIO_VOLUME property.
672 */
673enum vehicle_audio_volume_index {
674 VEHICLE_AUDIO_VOLUME_INDEX_STREAM = 0,
675 VEHICLE_AUDIO_VOLUME_INDEX_VOLUME = 1,
676 VEHICLE_AUDIO_VOLUME_INDEX_STATE = 2,
677};
678
679/**
680 * Property for handling volume limit set by user. This limits maximum volume that can be set
Keun-young Park12a3c012016-03-23 17:58:29 -0700681 * per each context or physical stream.
682 *
683 * vehicle_prop_config_t
684 * config_array[0] : bit flags of all supported audio contexts. If this is 0,
685 * audio volume is controlled per physical stream
686 * config_array[1] : flags defined in vehicle_audio_volume_capability_flag to
687 * represent audio module's capability.
688 *
689 * Data type looks like:
690 * int32_array[0] : stream context as defined in vehicle_audio_context_flag. If only physical
691 * stream is supported (config_array[0] == 0), this will represent physical
692 * stream number.
Sanket Agarwalfb636682015-08-11 14:34:29 -0700693 * int32_array[1] : maximum volume set to the stream. If there is no restriction, this value
694 * will be bigger than VEHICLE_PROPERTY_AUDIO_VOLUME's max value.
695 *
696 * If car does not support this feature, this property should not be populated by HAL.
697 * This property requires per stream based get. HAL implementation should check stream number
698 * in get call to return the right volume.
699 *
700 * @value_type VEHICLE_VALUE_TYPE_INT32_VEC2
701 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE
702 * @access VEHICLE_PROP_ACCESS_READ_WRITE
Keun-young Parkbf877a72015-12-21 14:16:05 -0800703 * @config_flags all audio contexts supported.
Sanket Agarwalfb636682015-08-11 14:34:29 -0700704 * @data_member int32_array
705 */
706#define VEHICLE_PROPERTY_AUDIO_VOLUME_LIMIT (0x00000902)
707
708/**
709 * Index in int32_array for VEHICLE_PROPERTY_AUDIO_VOLUME_LIMIT property.
710 */
711enum vehicle_audio_volume_limit_index {
712 VEHICLE_AUDIO_VOLUME_LIMIT_INDEX_STREAM = 0,
713 VEHICLE_AUDIO_VOLUME_LIMIT_INDEX_MAX_VOLUME = 1,
714};
715
716/**
717 * Property to share audio routing policy of android side. This property is set at the beginning
718 * to pass audio policy in android side down to vehicle HAL and car audio module.
719 * This can be used as a hint to adjust audio policy or other policy decision.
720 *
721 * int32_array[0] : audio stream where the audio for the application context will be routed
722 * by default. Note that this is the default setting from system, but each app
723 * may still use different audio stream for whatever reason.
Keun-young Parkbf877a72015-12-21 14:16:05 -0800724 * int32_array[1] : All audio contexts that will be sent through the physical stream. Flag
725 * is defined in vehicle_audio_context_flag.
Sanket Agarwalfb636682015-08-11 14:34:29 -0700726
727 * Setting of this property will be done for all available physical streams based on audio H/W
728 * variant information acquired from VEHICLE_PROPERTY_AUDIO_HW_VARIANT property.
729 *
730 * @value_type VEHICLE_VALUE_TYPE_INT32_VEC2
731 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE
732 * @access VEHICLE_PROP_ACCESS_WRITE
733 * @data_member int32_array
734 */
735#define VEHICLE_PROPERTY_AUDIO_ROUTING_POLICY (0x00000903)
736
737/**
738 * Index in int32_array for VEHICLE_PROPERTY_AUDIO_ROUTING_POLICY property.
739 */
740enum vehicle_audio_routing_policy_index {
741 VEHICLE_AUDIO_ROUTING_POLICY_INDEX_STREAM = 0,
742 VEHICLE_AUDIO_ROUTING_POLICY_INDEX_CONTEXTS = 1,
743};
744
745/**
746* Property to return audio H/W variant type used in this car. This allows android side to
747* support different audio policy based on H/W variant used. Note that other components like
748* CarService may need overlay update to support additional variants. If this property does not
749* exist, default audio policy will be used.
750*
751* @value_type VEHICLE_VALUE_TYPE_INT32
752* @change_mode VEHICLE_PROP_CHANGE_MODE_STATIC
753* @access VEHICLE_PROP_ACCESS_READ
Keun-young Parkbf877a72015-12-21 14:16:05 -0800754* @config_flags Additional info on audio H/W. Should use vehicle_audio_hw_variant_config_flag for
755* this.
Sanket Agarwalfb636682015-08-11 14:34:29 -0700756* @data_member int32_value
757*/
758#define VEHICLE_PROPERTY_AUDIO_HW_VARIANT (0x00000904)
759
760/**
761 * Flag to be used in vehicle_prop_config.config_flags for VEHICLE_PROPERTY_AUDIO_HW_VARIANT.
762 */
763enum vehicle_audio_hw_variant_config_flag {
764 /**
765 * This is a flag to disable the default behavior of not sending focus request for radio module.
766 * By default, when radio app request audio focus, that focus request is filtered out and
767 * is not sent to car audio module as radio is supposed to be played by car radio module and
768 * android side should have have audio focus for media stream.
769 * But in some H/W, radio may be directly played from android side, and in that case,
770 * android side should take focus for media stream. This flag should be enabled in such case.
771 */
772 VEHICLE_AUDIO_HW_VARIANT_FLAG_PASS_RADIO_AUDIO_FOCUS_FLAG = 0x1,
773};
774
Keun-young Parkcb8c8872016-01-08 09:41:19 -0800775
776/**
Sanket Agarwalfb636682015-08-11 14:34:29 -0700777 * Property to control power state of application processor.
778 *
779 * It is assumed that AP's power state is controller by separate power controller.
780 *
781 * For configuration information, vehicle_prop_config.config_flags can have bit flag combining
782 * values in vehicle_ap_power_state_config_type.
783 *
784 * For get / notification, data type looks like this:
785 * int32_array[0] : vehicle_ap_power_state_type
786 * int32_array[1] : additional parameter relevant for each state. should be 0 if not used.
787 * For set, data type looks like this:
788 * int32_array[0] : vehicle_ap_power_state_set_type
789 * int32_array[1] : additional parameter relevant for each request. should be 0 if not used.
790 *
791 * @value_type VEHICLE_VALUE_TYPE_INT32_VEC2
792 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE
793 * @access VEHICLE_PROP_ACCESS_READ_WRITE
Keun-young Parkbf877a72015-12-21 14:16:05 -0800794 * @config_flags Additional info on power state. Should use vehicle_ap_power_state_config_flag.
Sanket Agarwalfb636682015-08-11 14:34:29 -0700795 * @data_member int32_array
796 */
797#define VEHICLE_PROPERTY_AP_POWER_STATE (0x00000A00)
798
799enum vehicle_ap_power_state_config_flag {
800 /**
801 * AP can enter deep sleep state. If not set, AP will always shutdown from
802 * VEHICLE_AP_POWER_STATE_SHUTDOWN_PREPARE power state.
803 */
804 VEHICLE_AP_POWER_STATE_CONFIG_ENABLE_DEEP_SLEEP_FLAG = 0x1,
805
806 /**
807 * The power controller can power on AP from off state after timeout specified in
808 * VEHICLE_AP_POWER_SET_SHUTDOWN_READY message.
809 */
810 VEHICLE_AP_POWER_STATE_CONFIG_SUPPORT_TIMER_POWER_ON_FLAG = 0x2,
811};
812
813enum vehicle_ap_power_state {
814 /** vehicle HAL will never publish this state to AP */
815 VEHICLE_AP_POWER_STATE_OFF = 0,
816 /** vehicle HAL will never publish this state to AP */
817 VEHICLE_AP_POWER_STATE_DEEP_SLEEP = 1,
818 /** AP is on but display should be off. */
819 VEHICLE_AP_POWER_STATE_ON_DISP_OFF = 2,
820 /** AP is on with display on. This state allows full user interaction. */
821 VEHICLE_AP_POWER_STATE_ON_FULL = 3,
822 /**
823 * The power controller has requested AP to shutdown. AP can either enter sleep state or start
824 * full shutdown. AP can also request postponing shutdown by sending
825 * VEHICLE_AP_POWER_SET_SHUTDOWN_POSTPONE message. The power controller should change power
826 * state to this state to shutdown system.
827 *
828 * int32_array[1] : one of enum_vehicle_ap_power_state_shutdown_param_type
829 */
830 VEHICLE_AP_POWER_STATE_SHUTDOWN_PREPARE = 4,
831};
832
833enum vehicle_ap_power_state_shutdown_param {
834 /** AP should shutdown immediately. Postponing is not allowed. */
835 VEHICLE_AP_POWER_SHUTDOWN_PARAM_SHUTDOWN_IMMEDIATELY = 1,
836 /** AP can enter deep sleep instead of shutting down completely. */
837 VEHICLE_AP_POWER_SHUTDOWN_PARAM_CAN_SLEEP = 2,
838 /** AP can only shutdown with postponing allowed. */
839 VEHICLE_AP_POWER_SHUTDOWN_PARAM_SHUTDOWN_ONLY = 3,
840};
841
842enum vehicle_ap_power_set_state {
843 /**
844 * AP has finished boot up, and can start shutdown if requested by power controller.
845 */
846 VEHICLE_AP_POWER_SET_BOOT_COMPLETE = 0x1,
847 /**
848 * AP is entering deep sleep state. How this state is implemented may vary depending on
849 * each H/W, but AP's power should be kept in this state.
850 */
851 VEHICLE_AP_POWER_SET_DEEP_SLEEP_ENTRY = 0x2,
852 /**
853 * AP is exiting from deep sleep state, and is in VEHICLE_AP_POWER_STATE_SHUTDOWN_PREPARE state.
854 * The power controller may change state to other ON states based on the current state.
855 */
856 VEHICLE_AP_POWER_SET_DEEP_SLEEP_EXIT = 0x3,
857 /**
858 * int32_array[1]: Time to postpone shutdown in ms. Maximum value can be 5000 ms.
859 * If AP needs more time, it will send another POSTPONE message before
860 * the previous one expires.
861 */
862 VEHICLE_AP_POWER_SET_SHUTDOWN_POSTPONE = 0x4,
863 /**
864 * AP is starting shutting down. When system completes shutdown, everything will stop in AP
865 * as kernel will stop all other contexts. It is responsibility of vehicle HAL or lower level
866 * to synchronize that state with external power controller. As an example, some kind of ping
867 * with timeout in power controller can be a solution.
868 *
869 * int32_array[1]: Time to turn on AP in secs. Power controller may turn on AP after specified
870 * time so that AP can run tasks like update. If it is set to 0, there is no
871 * wake up, and power controller may not necessarily support wake-up.
872 * If power controller turns on AP due to timer, it should start with
873 * VEHICLE_AP_POWER_STATE_ON_DISP_OFF state, and after receiving
874 * VEHICLE_AP_POWER_SET_BOOT_COMPLETE, it shall do state transition to
875 * VEHICLE_AP_POWER_STATE_SHUTDOWN_PREPARE.
876 */
877 VEHICLE_AP_POWER_SET_SHUTDOWN_START = 0x5,
878 /**
879 * User has requested to turn off headunit's display, which is detected in android side.
880 * The power controller may change the power state to VEHICLE_AP_POWER_STATE_ON_DISP_OFF.
881 */
882 VEHICLE_AP_POWER_SET_DISPLAY_OFF = 0x6,
883 /**
884 * User has requested to turn on headunit's display, most probably from power key input which
885 * is attached to headunit. The power controller may change the power state to
886 * VEHICLE_AP_POWER_STATE_ON_FULL.
887 */
888 VEHICLE_AP_POWER_SET_DISPLAY_ON = 0x7,
889};
890
891/**
892 * Property to represent brightness of the display. Some cars have single control for
893 * the brightness of all displays and this property is to share change in that control.
894 *
895 * If this is writable, android side can set this value when user changes display brightness
896 * from Settings. If this is read only, user may still change display brightness from Settings,
897 * but that will not be reflected to other displays.
898 *
899 * @value_type VEHICLE_VALUE_TYPE_INT32
900 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE
901 * @access VEHICLE_PROP_ACCESS_READ|VEHICLE_PROP_ACCESS_READ_WRITE
902 * @data_member int32
903 */
904#define VEHICLE_PROPERTY_DISPLAY_BRIGHTNESS (0x00000A01)
905
906
907/**
908 * Index in int32_array for VEHICLE_PROPERTY_AP_POWER_STATE property.
909 */
910enum vehicle_ap_power_state_index {
911 VEHICLE_AP_POWER_STATE_INDEX_STATE = 0,
912 VEHICLE_AP_POWER_STATE_INDEX_ADDITIONAL = 1,
913};
914
915/**
916* Property to report bootup reason for the current power on. This is a static property that will
917* not change for the whole duration until power off. For example, even if user presses power on
918* button after automatic power on with door unlock, bootup reason should stay with
919* VEHICLE_AP_POWER_BOOTUP_REASON_USER_UNLOCK.
920*
921* int32_value should be vehicle_ap_power_bootup_reason.
922*
923* @value_type VEHICLE_VALUE_TYPE_INT32
924* @change_mode VEHICLE_PROP_CHANGE_MODE_STATIC
925* @access VEHICLE_PROP_ACCESS_READ
926* @data_member int32_value
927*/
928#define VEHICLE_PROPERTY_AP_POWER_BOOTUP_REASON (0x00000A02)
929
930/**
931 * Enum to represent bootup reason.
932 */
933enum vehicle_ap_power_bootup_reason {
934 /**
935 * Power on due to user's pressing of power key or rotating of ignition switch.
936 */
937 VEHICLE_AP_POWER_BOOTUP_REASON_USER_POWER_ON = 0,
938 /**
939 * Automatic power on triggered by door unlock or any other kind of automatic user detection.
940 */
941 VEHICLE_AP_POWER_BOOTUP_REASON_USER_UNLOCK = 1,
942 /**
943 * Automatic power on triggered by timer. This only happens when AP has asked wake-up after
944 * certain time through time specified in VEHICLE_AP_POWER_SET_SHUTDOWN_START.
945 */
946 VEHICLE_AP_POWER_BOOTUP_REASON_TIMER = 2,
947};
948
Keun-young Parkcb354502016-02-08 18:15:55 -0800949
950/**
951 * Property to feed H/W input events to android
952 *
953 * int32_array[0] : action defined by vehicle_hw_key_input_action
954 * int32_array[1] : key code, should use standard android key code
955 * int32_array[2] : target display defined in vehicle_display. Events not tied
956 * to specific display should be sent to DISPLAY_MAIN.
957 * int32_array[3] : reserved for now. should be zero
958 * @value_type VEHICLE_VALUE_TYPE_INT32_VEC4
959 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE
960 * @access VEHICLE_PROP_ACCESS_READ
961 * @config_flags
962 * @data_member int32_array
963 */
964#define VEHICLE_PROPERTY_HW_KEY_INPUT (0x00000A10)
965
966enum vehicle_hw_key_input_action {
967 /** Key down */
968 VEHICLE_HW_KEY_INPUT_ACTION_DOWN = 0,
969 /** Key up */
970 VEHICLE_HW_KEY_INPUT_ACTION_UP = 1,
971};
972
973enum vehicle_display {
974 /** center console */
975 VEHICLE_DISPLAY_MAIN = 0,
976 VEHICLE_DISPLAY_INSTRUMENT_CLUSTER = 1,
977};
978
Sanket Agarwalfb636682015-08-11 14:34:29 -0700979/**
Keun-young Parkfe599a82016-02-12 14:26:57 -0800980 * Property to define instrument cluster information.
981 * For CLUSTER_TYPE_EXTERNAL_DISPLAY:
982 * READ:
983 * int32_array[0] : The current screen mode index. Screen mode is defined
984 * as a configuration in car service and represents which
985 * area of screen is renderable.
986 * int32_array[1] : Android can render to instrument cluster (=1) or not(=0). When this is 0,
987 * instrument cluster may be rendering some information in the area
988 * allocated for android and android side rendering is invisible. *
989 * int32_array[2..3] : should be zero
990 * WRITE from android:
991 * int32_array[0] : Preferred mode for android side. Depending on the app rendering to instrument
992 * cluster, preferred mode can change. Instrument cluster still needs to send
993 * event with new mode to trigger actual mode change.
994 * int32_array[1] : The current app context relevant for instrument cluster. Use the same flag
995 * with vehicle_audio_context_flag but this context represents active apps, not
996 * active audio. Instrument cluster side may change mode depending on the
997 * currently active contexts.
998 * int32_array[2..3] : should be zero
999 * When system boots up, Android side will write {0, 0, 0, 0} when it is ready to render to
1000 * instrument cluster. Before this message, rendering from android should not be visible in the
1001 * cluster.
1002 * @value_type VEHICLE_VALUE_TYPE_INT32_VEC4
1003 * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE
1004 * @access VEHICLE_PROP_ACCESS_READ_WRITE
1005 * @config_array 0:vehicle_instument_cluster_type 1:hw type
1006 * @data_member int32_array
1007 */
1008#define VEHICLE_PROPERTY_INSTRUMENT_CLUSTER_INFO (0x00000A20)
1009
1010/**
1011 * Represents instrument cluster type available in system
1012 */
1013enum vehicle_instument_cluster_type {
1014 /** Android has no access to instument cluster */
1015 VEHICLE_INSTRUMENT_CLUSTER_TYPE_NONE = 0,
1016 /**
1017 * Instrument cluster can communicate through vehicle hal with additional
1018 * properties to exchange meta-data
1019 */
1020 VEHICLE_INSTRUMENT_CLUSTER_TYPE_HAL_INTERFACE = 1,
1021 /**
1022 * Instrument cluster is external display where android can render contents
1023 */
1024 VEHICLE_INSTRUMENT_CLUSTER_TYPE_EXTERNAL_DISPLAY = 2,
1025};
1026
1027/**
Sanket Agarwalfb636682015-08-11 14:34:29 -07001028 * H/W specific, non-standard property can be added as necessary. Such property should use
1029 * property number in range of [VEHICLE_PROPERTY_CUSTOM_START, VEHICLE_PROPERTY_CUSTOM_END].
1030 * Definition of property in this range is completely up to each HAL implementation.
1031 * For such property, it is recommended to fill vehicle_prop_config.config_string with some
1032 * additional information to help debugging. For example, company XYZ's custom extension may
1033 * include config_string of "com.XYZ.some_further_details".
1034 * @range_start
1035 */
Keun-young Park77d3c392016-01-25 11:37:24 -08001036#define VEHICLE_PROPERTY_CUSTOM_START (0x70000000)
Sanket Agarwalfb636682015-08-11 14:34:29 -07001037/** @range_end */
Keun-young Park77d3c392016-01-25 11:37:24 -08001038#define VEHICLE_PROPERTY_CUSTOM_END (0x73ffffff)
Sanket Agarwalfb636682015-08-11 14:34:29 -07001039
1040/**
1041 * Property range allocated for system's internal usage like testing. HAL should never declare
1042 * property in this range.
1043 * @range_start
1044 */
Keun-young Park77d3c392016-01-25 11:37:24 -08001045#define VEHICLE_PROPERTY_INTERNAL_START (0x74000000)
Sanket Agarwalfb636682015-08-11 14:34:29 -07001046/**
1047 * @range_end
1048 */
Keun-young Park77d3c392016-01-25 11:37:24 -08001049#define VEHICLE_PROPERTY_INTERNAL_END (0x74ffffff)
Sanket Agarwalfb636682015-08-11 14:34:29 -07001050
1051/**
1052 * Value types for various properties.
1053 */
1054enum vehicle_value_type {
1055 VEHICLE_VALUE_TYPE_SHOUD_NOT_USE = 0x00, // value_type should never set to 0.
1056 VEHICLE_VALUE_TYPE_STRING = 0x01,
1057 VEHICLE_VALUE_TYPE_BYTES = 0x02,
1058 VEHICLE_VALUE_TYPE_BOOLEAN = 0x03,
Keun-young Park73d7f222016-01-14 11:02:38 -08001059 VEHICLE_VALUE_TYPE_ZONED_BOOLEAN = 0x04,
1060 VEHICLE_VALUE_TYPE_INT64 = 0x05,
Sanket Agarwalfb636682015-08-11 14:34:29 -07001061 VEHICLE_VALUE_TYPE_FLOAT = 0x10,
1062 VEHICLE_VALUE_TYPE_FLOAT_VEC2 = 0x11,
1063 VEHICLE_VALUE_TYPE_FLOAT_VEC3 = 0x12,
1064 VEHICLE_VALUE_TYPE_FLOAT_VEC4 = 0x13,
1065 VEHICLE_VALUE_TYPE_INT32 = 0x20,
1066 VEHICLE_VALUE_TYPE_INT32_VEC2 = 0x21,
1067 VEHICLE_VALUE_TYPE_INT32_VEC3 = 0x22,
1068 VEHICLE_VALUE_TYPE_INT32_VEC4 = 0x23,
Keun-young Park73d7f222016-01-14 11:02:38 -08001069 VEHICLE_VALUE_TYPE_ZONED_FLOAT = 0x30,
1070 VEHICLE_VALUE_TYPE_ZONED_FLOAT_VEC2 = 0x31,
1071 VEHICLE_VALUE_TYPE_ZONED_FLOAT_VEC3 = 0x32,
Keun-young Parkab68e372016-03-10 16:28:42 -08001072 VEHICLE_VALUE_TYPE_ZONED_FLOAT_VEC4 = 0x33,
Keun-young Park73d7f222016-01-14 11:02:38 -08001073 VEHICLE_VALUE_TYPE_ZONED_INT32 = 0x40,
1074 VEHICLE_VALUE_TYPE_ZONED_INT32_VEC2 = 0x41,
1075 VEHICLE_VALUE_TYPE_ZONED_INT32_VEC3 = 0x42,
Keun-young Parkab68e372016-03-10 16:28:42 -08001076 VEHICLE_VALUE_TYPE_ZONED_INT32_VEC4 = 0x43,
Sanket Agarwalfb636682015-08-11 14:34:29 -07001077};
1078
1079/**
1080 * Units used for int or float type with no attached enum types.
1081 */
1082enum vehicle_unit_type {
1083 VEHICLE_UNIT_TYPE_SHOULD_NOT_USE = 0x00000000,
1084 // speed related items
1085 VEHICLE_UNIT_TYPE_METER_PER_SEC = 0x00000001,
1086 VEHICLE_UNIT_TYPE_RPM = 0x00000002,
1087 VEHICLE_UNIT_TYPE_HZ = 0x00000003,
1088 // kind of ratio
1089 VEHICLE_UNIT_TYPE_PERCENTILE = 0x00000010,
1090 // length
1091 VEHICLE_UNIT_TYPE_MILLIMETER = 0x00000020,
1092 VEHICLE_UNIT_TYPE_METER = 0x00000021,
1093 VEHICLE_UNIT_TYPE_KILOMETER = 0x00000023,
1094 // temperature
1095 VEHICLE_UNIT_TYPE_CELCIUS = 0x00000030,
1096 // volume
1097 VEHICLE_UNIT_TYPE_MILLILITER = 0x00000040,
1098 // time
1099 VEHICLE_UNIT_TYPE_NANO_SECS = 0x00000050,
1100 VEHICLE_UNOT_TYPE_SECS = 0x00000053,
1101 VEHICLE_UNIT_TYPE_YEAR = 0x00000059,
1102};
1103
1104/**
Sanket Agarwalfb636682015-08-11 14:34:29 -07001105 * This describes how value of property can change.
1106 */
1107enum vehicle_prop_change_mode {
1108 /**
1109 * Property of this type will *never* change. This property will not support subscription, but
1110 * will support get
1111 */
1112 VEHICLE_PROP_CHANGE_MODE_STATIC = 0x00,
1113 /**
1114 * Property of this type will be reported when there is a change. get should return the
1115 * current value.
1116 */
1117 VEHICLE_PROP_CHANGE_MODE_ON_CHANGE = 0x01,
1118 /**
1119 * Property of this type change continuously and requires fixed rate of sampling to retrieve
1120 * the data.
1121 */
1122 VEHICLE_PROP_CHANGE_MODE_CONTINUOUS = 0x02,
1123};
1124
1125/**
1126 * Property config defines the capabilities of it. User of the API
1127 * should first get the property config to understand the output from get()
1128 * commands and also to ensure that set() or events commands are in sync with
1129 * the expected output.
1130 */
1131enum vehicle_prop_access {
1132 VEHICLE_PROP_ACCESS_READ = 0x01,
1133 VEHICLE_PROP_ACCESS_WRITE = 0x02,
1134 VEHICLE_PROP_ACCESS_READ_WRITE = 0x03
1135};
1136
1137/**
1138 * These permissions define how the OEMs want to distribute their information and security they
1139 * want to apply. On top of these restrictions, android will have additional
1140 * 'app-level' permissions that the apps will need to ask the user before the apps have the
1141 * information.
1142 * This information should be kept in vehicle_prop_config.permission_model.
1143 */
1144enum vehicle_permission_model {
1145 /**
1146 * No special restriction, but each property can still require specific android app-level
1147 * permission.
1148 */
1149 VEHICLE_PERMISSION_NO_RESTRICTION = 0,
1150 /** Signature only. Only APKs signed with OEM keys are allowed. */
1151 VEHICLE_PERMISSION_OEM_ONLY = 0x1,
1152 /** System only. APKs built-in to system can access the property. */
1153 VEHICLE_PERMISSION_SYSTEM_APP_ONLY = 0x2,
1154 /** Equivalent to “system|signature” */
1155 VEHICLE_PERMISSION_OEM_OR_SYSTEM_APP = 0x3
1156};
1157
1158/**
1159 * Car states.
1160 *
1161 * The driving states determine what features of the UI will be accessible.
1162 */
1163enum vehicle_driving_status {
1164 VEHICLE_DRIVING_STATUS_UNRESTRICTED = 0x00,
1165 VEHICLE_DRIVING_STATUS_NO_VIDEO = 0x01,
1166 VEHICLE_DRIVING_STATUS_NO_KEYBOARD_INPUT = 0x02,
1167 VEHICLE_DRIVING_STATUS_NO_VOICE_INPUT = 0x04,
1168 VEHICLE_DRIVING_STATUS_NO_CONFIG = 0x08,
1169 VEHICLE_DRIVING_STATUS_LIMIT_MESSAGE_LEN = 0x10
1170};
1171
1172/**
1173 * Various gears which can be selected by user and chosen in system.
1174 */
1175enum vehicle_gear {
1176 // Gear selections present in both automatic and manual cars.
1177 VEHICLE_GEAR_NEUTRAL = 0x0001,
1178 VEHICLE_GEAR_REVERSE = 0x0002,
1179
1180 // Gear selections (mostly) present only in automatic cars.
Keun-young Park77761e22016-03-08 15:02:44 -08001181 VEHICLE_GEAR_PARK = 0x0004,
Sanket Agarwalfb636682015-08-11 14:34:29 -07001182 VEHICLE_GEAR_DRIVE = 0x0008,
Keun-young Park77761e22016-03-08 15:02:44 -08001183 VEHICLE_GEAR_LOW = 0x0010,
Sanket Agarwalfb636682015-08-11 14:34:29 -07001184
1185 // Other possible gear selections (maybe present in manual or automatic
1186 // cars).
1187 VEHICLE_GEAR_1 = 0x0010,
1188 VEHICLE_GEAR_2 = 0x0020,
1189 VEHICLE_GEAR_3 = 0x0040,
1190 VEHICLE_GEAR_4 = 0x0080,
1191 VEHICLE_GEAR_5 = 0x0100,
1192 VEHICLE_GEAR_6 = 0x0200,
1193 VEHICLE_GEAR_7 = 0x0400,
1194 VEHICLE_GEAR_8 = 0x0800,
1195 VEHICLE_GEAR_9 = 0x1000
1196};
1197
1198
1199/**
1200 * Various zones in the car.
1201 *
1202 * Zones are used for Air Conditioning purposes and divide the car into physical
1203 * area zones.
1204 */
1205enum vehicle_zone {
1206 VEHICLE_ZONE_ROW_1_LEFT = 0x00000001,
1207 VEHICLE_ZONE_ROW_1_CENTER = 0x00000002,
1208 VEHICLE_ZONE_ROW_1_RIGHT = 0x00000004,
1209 VEHICLE_ZONE_ROW_1_ALL = 0x00000008,
1210 VEHICLE_ZONE_ROW_2_LEFT = 0x00000010,
1211 VEHICLE_ZONE_ROW_2_CENTER = 0x00000020,
1212 VEHICLE_ZONE_ROW_2_RIGHT = 0x00000040,
1213 VEHICLE_ZONE_ROW_2_ALL = 0x00000080,
1214 VEHICLE_ZONE_ROW_3_LEFT = 0x00000100,
1215 VEHICLE_ZONE_ROW_3_CENTER = 0x00000200,
1216 VEHICLE_ZONE_ROW_3_RIGHT = 0x00000400,
1217 VEHICLE_ZONE_ROW_3_ALL = 0x00000800,
1218 VEHICLE_ZONE_ROW_4_LEFT = 0x00001000,
1219 VEHICLE_ZONE_ROW_4_CENTER = 0x00002000,
1220 VEHICLE_ZONE_ROW_4_RIGHT = 0x00004000,
1221 VEHICLE_ZONE_ROW_4_ALL = 0x00008000,
1222 VEHICLE_ZONE_ALL = 0x80000000,
1223};
1224
1225/**
1226 * Various Seats in the car.
1227 */
1228enum vehicle_seat {
Keun-young Parka384f832016-02-11 16:50:42 -08001229 VEHICLE_SEAT_DRIVER_LHD = 0x0001,
1230 VEHICLE_SEAT_DRIVER_RHD = 0x0002,
1231 VEHICLE_SEAT_ROW_1_PASSENGER_LEFT = 0x0010,
1232 VEHICLE_SEAT_ROW_1_PASSENGER_CENTER = 0x0020,
1233 VEHICLE_SEAT_ROW_1_PASSENGER_RIGHT = 0x0040,
1234 VEHICLE_SEAT_ROW_2_PASSENGER_LEFT = 0x0100,
1235 VEHICLE_SEAT_ROW_2_PASSENGER_CENTER = 0x0200,
1236 VEHICLE_SEAT_ROW_2_PASSENGER_RIGHT = 0x0400,
1237 VEHICLE_SEAT_ROW_3_PASSENGER_LEFT = 0x1000,
1238 VEHICLE_SEAT_ROW_3_PASSENGER_CENTER = 0x2000,
1239 VEHICLE_SEAT_ROW_3_PASSENGER_RIGHT = 0x4000
Sanket Agarwalfb636682015-08-11 14:34:29 -07001240};
1241
1242/**
1243 * Various windshields/windows in the car.
1244 */
1245enum vehicle_window {
1246 VEHICLE_WINDOW_FRONT_WINDSHIELD = 0x0001,
1247 VEHICLE_WINDOW_REAR_WINDSHIELD = 0x0002,
1248 VEHICLE_WINDOW_ROOF_TOP = 0x0004,
1249 VEHICLE_WINDOW_ROW_1_LEFT = 0x0010,
1250 VEHICLE_WINDOW_ROW_1_RIGHT = 0x0020,
1251 VEHICLE_WINDOW_ROW_2_LEFT = 0x0100,
1252 VEHICLE_WINDOW_ROW_2_RIGHT = 0x0200,
1253 VEHICLE_WINDOW_ROW_3_LEFT = 0x1000,
1254 VEHICLE_WINDOW_ROW_3_RIGHT = 0x2000,
1255};
1256
Keun-young Parkcb354502016-02-08 18:15:55 -08001257enum vehicle_door {
1258 VEHICLE_DOOR_ROW_1_LEFT = 0x00000001,
1259 VEHICLE_DOOR_ROW_1_RIGHT = 0x00000004,
1260 VEHICLE_DOOR_ROW_2_LEFT = 0x00000010,
1261 VEHICLE_DOOR_ROW_2_RIGHT = 0x00000040,
1262 VEHICLE_DOOR_ROW_3_LEFT = 0x00000100,
1263 VEHICLE_DOOR_ROW_3_RIGHT = 0x00000400,
1264 VEHICLE_DOOR_HOOD = 0x10000000,
1265 VEHICLE_DOOR_REAR = 0x20000000,
1266};
1267
1268enum vehicle_mirror {
1269 VEHICLE_MIRROR_DRIVER_LEFT = 0x00000001,
1270 VEHICLE_MIRROR_DRIVER_RIGHT = 0x00000002,
1271 VEHICLE_MIRROR_DRIVER_CENTER = 0x00000004,
1272};
Sanket Agarwalfb636682015-08-11 14:34:29 -07001273enum vehicle_turn_signal {
1274 VEHICLE_SIGNAL_NONE = 0x00,
1275 VEHICLE_SIGNAL_RIGHT = 0x01,
1276 VEHICLE_SIGNAL_LEFT = 0x02,
1277 VEHICLE_SIGNAL_EMERGENCY = 0x04
1278};
1279
1280/*
1281 * Boolean type.
1282 */
1283enum vehicle_boolean {
1284 VEHICLE_FALSE = 0x00,
1285 VEHICLE_TRUE = 0x01
1286};
1287
1288typedef int32_t vehicle_boolean_t;
1289
1290/**
1291 * Vehicle string.
1292 *
1293 * Defines a UTF8 encoded sequence of bytes that should be used for string
1294 * representation throughout.
1295 */
1296typedef struct vehicle_str {
1297 uint8_t* data;
1298 int32_t len;
1299} vehicle_str_t;
1300
1301/**
1302 * Vehicle byte array.
1303 * This is for passing generic raw data.
1304 */
1305typedef vehicle_str_t vehicle_bytes_t;
1306
Sanket Agarwalfb636682015-08-11 14:34:29 -07001307typedef struct vehicle_prop_config {
1308 int32_t prop;
1309
1310 /**
1311 * Defines if the property is read or write. Value should be one of
1312 * enum vehicle_prop_access.
1313 */
1314 int32_t access;
1315
1316 /**
1317 * Defines if the property is continuous or on-change. Value should be one
1318 * of enum vehicle_prop_change_mode.
1319 */
1320 int32_t change_mode;
1321
1322 /**
1323 * Type of data used for this property. This type is fixed per each property.
1324 * Check vehicle_value_type for allowed value.
1325 */
1326 int32_t value_type;
1327
1328 /**
1329 * Define necessary permission model to access the data.
1330 */
1331 int32_t permission_model;
Keun-young Parkab68e372016-03-10 16:28:42 -08001332
Sanket Agarwalfb636682015-08-11 14:34:29 -07001333 /**
1334 * Some of the properties may have associated zones (such as hvac), in these
1335 * cases the config should contain an ORed value for the associated zone.
1336 */
1337 union {
1338 /**
Sanket Agarwalfb636682015-08-11 14:34:29 -07001339 * The value is derived by ORing one or more of enum vehicle_zone members.
1340 */
1341 int32_t vehicle_zone_flags;
1342 /** The value is derived by ORing one or more of enum vehicle_seat members. */
1343 int32_t vehicle_seat_flags;
1344 /** The value is derived by ORing one or more of enum vehicle_window members. */
1345 int32_t vehicle_window_flags;
Keun-young Parkab68e372016-03-10 16:28:42 -08001346 };
Sanket Agarwalfb636682015-08-11 14:34:29 -07001347
Keun-young Parkab68e372016-03-10 16:28:42 -08001348 /**
1349 * Property specific configuration information. Usage of this will be defined per each property.
1350 */
1351 union {
1352 /**
1353 * For generic configuration information
1354 */
1355 int32_t config_flags;
Sanket Agarwalfb636682015-08-11 14:34:29 -07001356 /** The number of presets that are stored by the radio module. Pass 0 if
1357 * there are no presets available. The range of presets is defined to be
1358 * from 1 (see VEHICLE_RADIO_PRESET_MIN_VALUE) to vehicle_radio_num_presets.
1359 */
1360 int32_t vehicle_radio_num_presets;
Keun-young Parkbf877a72015-12-21 14:16:05 -08001361 int32_t config_array[4];
Sanket Agarwalfb636682015-08-11 14:34:29 -07001362 };
1363
1364 /**
1365 * Some properties may require additional information passed over this string. Most properties
1366 * do not need to set this and in that case, config_string.data should be NULL and
1367 * config_string.len should be 0.
1368 */
1369 vehicle_str_t config_string;
1370
1371 /**
1372 * Specify minimum allowed value for the property. This is necessary for property which does
1373 * not have specified enum.
1374 */
1375 union {
1376 float float_min_value;
1377 int32_t int32_min_value;
1378 int64_t int64_min_value;
1379 };
1380
1381 /**
1382 * Specify maximum allowed value for the property. This is necessary for property which does
1383 * not have specified enum.
1384 */
1385 union {
1386 float float_max_value;
1387 int32_t int32_max_value;
1388 int64_t int64_max_value;
1389 };
1390
1391 /**
Keun-young Parkfe599a82016-02-12 14:26:57 -08001392 * Array of min values for zoned properties. Zoned property can specify min / max value in two
1393 * different ways:
1394 * 1. All zones having the same min / max value: *_min/max_value should be set and this
1395 * array should be set to NULL.
1396 * 2. All zones having separate min / max value: *_min/max_values array should be populated
1397 * and its length should be the same as number of active zones specified by *_zone_flags.
Keun-young Parkab68e372016-03-10 16:28:42 -08001398 *
1399 * Should be NULL if each zone does not have separate max values.
Keun-young Parkfe599a82016-02-12 14:26:57 -08001400 */
1401 union {
1402 float* float_min_values;
1403 int32_t* int32_min_values;
1404 int64_t* int64_min_values;
1405 };
1406
1407 /**
1408 * Array of max values for zoned properties. See above for its usage.
Keun-young Parkab68e372016-03-10 16:28:42 -08001409 * Should be NULL if each zone does not have separate max values.
1410 * If not NULL, length of array should match that of min_values.
Keun-young Parkfe599a82016-02-12 14:26:57 -08001411 */
1412 union {
1413 float* float_max_values;
1414 int32_t* int32_max_values;
1415 int64_t* int64_max_values;
1416 };
1417
1418 /**
Sanket Agarwalfb636682015-08-11 14:34:29 -07001419 * Min sample rate in Hz. Should be 0 for sensor type of VEHICLE_PROP_CHANGE_MODE_ON_CHANGE
1420 */
1421 float min_sample_rate;
1422 /**
1423 * Max sample rate in Hz. Should be 0 for sensor type of VEHICLE_PROP_CHANGE_MODE_ON_CHANGE
1424 */
1425 float max_sample_rate;
1426 /**
1427 * Place holder for putting HAL implementation specific data. Usage is wholly up to HAL
1428 * implementation.
1429 */
1430 void* hal_data;
1431} vehicle_prop_config_t;
1432
1433/**
1434 * HVAC property fields.
1435 *
1436 * Defines various HVAC properties which are packed into vehicle_hvac_t (see
1437 * below). We define these properties outside in global scope so that HAL
1438 * implementation and HAL users (JNI) can typecast vehicle_hvac correctly.
1439 */
Sanket Agarwalfb636682015-08-11 14:34:29 -07001440typedef struct vehicle_hvac {
1441 /**
1442 * Define one structure for each possible HVAC property.
1443 * NOTES:
Keun-young Parkab68e372016-03-10 16:28:42 -08001444 * a) Fan speed is a number from (0 - 6) where 6 is the highest speed. (TODO define enum)
1445 * b) Temperature is a floating point Celcius scale.
1446 * c) Direction is defined in enum vehicle_fan_direction.
Sanket Agarwalfb636682015-08-11 14:34:29 -07001447 *
1448 * The HAL should create #entries number of vehicle_hvac_properties and
1449 * assign it to "properties" variable below.
1450 */
1451 union {
Keun-young Parkab68e372016-03-10 16:28:42 -08001452 int32_t fan_speed;
1453 int32_t fan_direction;
1454 vehicle_boolean_t ac_on;
1455 vehicle_boolean_t max_ac_on;
1456 vehicle_boolean_t max_defrost_on;
1457 vehicle_boolean_t recirc_on;
1458 vehicle_boolean_t dual_on;
Sanket Agarwalfb636682015-08-11 14:34:29 -07001459
Keun-young Parkab68e372016-03-10 16:28:42 -08001460 float temperature_current;
1461 float temperature_set;
Sanket Agarwalfb636682015-08-11 14:34:29 -07001462
Keun-young Parkab68e372016-03-10 16:28:42 -08001463 vehicle_boolean_t defrost_on;
Sanket Agarwalfb636682015-08-11 14:34:29 -07001464 };
1465} vehicle_hvac_t;
1466
1467/*
1468 * Defines how the values for various properties are represented.
1469 *
1470 * There are two ways to populate and access the fields:
1471 * a) Using the individual fields. Use this mechanism (see
1472 * info_manufacture_date, fuel_capacity fields etc).
1473 * b) Using the union accessors (see uint32_value, float_value etc).
1474 *
1475 * To add a new field make sure that it does not exceed the total union size
1476 * (defined in int_array) and it is one of the vehicle_value_type. Then add the
1477 * field name with its unit to union. If the field type is not yet defined (as
1478 * of this draft, we don't use int64_t) then add that type to vehicle_value_type
1479 * and have an accessor (so for int64_t it will be int64_t int64_value).
1480 */
1481typedef union vehicle_value {
1482 /** Define the max size of this structure. */
1483 int32_t int32_array[4];
1484 float float_array[4];
1485
1486 // Easy accessors for union members (HAL implementation SHOULD NOT USE these
1487 // fields while populating, use the property specific fields below instead).
1488 int32_t int32_value;
1489 int64_t int64_value;
1490 float float_value;
1491 vehicle_str_t str_value;
1492 vehicle_bytes_t bytes_value;
1493 vehicle_boolean_t boolean_value;
Sanket Agarwalfb636682015-08-11 14:34:29 -07001494
1495 // Vehicle Information.
1496 vehicle_str_t info_vin;
1497 vehicle_str_t info_make;
1498 vehicle_str_t info_model;
1499 int32_t info_model_year;
1500
1501 // Represented in milliliters.
1502 float info_fuel_capacity;
1503
1504 float vehicle_speed;
1505 float odometer;
1506
1507 // Engine sensors.
1508
1509 // Represented in milliliters.
1510 //float engine_coolant_level;
1511 // Represented in celcius.
1512 float engine_coolant_temperature;
1513 // Represented in a percentage value.
1514 //float engine_oil_level;
1515 // Represented in celcius.
1516 float engine_oil_temperature;
1517 float engine_rpm;
1518
1519 // Event sensors.
1520 // Value should be one of enum vehicle_gear_selection.
1521 int32_t gear_selection;
1522 // Value should be one of enum vehicle_gear.
1523 int32_t gear_current_gear;
1524 // Value should be one of enum vehicle_boolean.
1525 int32_t parking_brake;
1526 // If cruise_set_speed > 0 then cruise is ON otherwise cruise is OFF.
1527 // Unit: meters / second (m/s).
1528 //int32_t cruise_set_speed;
1529 // Value should be one of enum vehicle_boolean.
1530 int32_t is_fuel_level_low;
1531 // Value should be one of enum vehicle_driving_status.
1532 int32_t driving_status;
1533 int32_t night_mode;
1534 // Value should be one of emum vehicle_turn_signal.
1535 int32_t turn_signals;
1536 // Value should be one of enum vehicle_boolean.
1537 //int32_t engine_on;
1538
1539 // HVAC properties.
1540 vehicle_hvac_t hvac;
1541
1542 float outside_temperature;
Keun-young Parkcb354502016-02-08 18:15:55 -08001543 float cabin_temperature;
1544
Sanket Agarwalfb636682015-08-11 14:34:29 -07001545} vehicle_value_t;
1546
1547/*
1548 * Encapsulates the property name and the associated value. It
1549 * is used across various API calls to set values, get values or to register for
1550 * events.
1551 */
1552typedef struct vehicle_prop_value {
1553 /* property identifier */
1554 int32_t prop;
1555
1556 /* value type of property for quick conversion from union to appropriate
1557 * value. The value must be one of enum vehicle_value_type.
1558 */
1559 int32_t value_type;
1560
1561 /** time is elapsed nanoseconds since boot */
1562 int64_t timestamp;
1563
Keun-young Parkab68e372016-03-10 16:28:42 -08001564 /**
1565 * Zone information for zoned property. For non-zoned property, this should be ignored.
1566 */
1567 union {
1568 int32_t zone;
1569 int32_t seat;
1570 int32_t window;
1571 };
1572
Sanket Agarwalfb636682015-08-11 14:34:29 -07001573 vehicle_value_t value;
1574} vehicle_prop_value_t;
1575
1576/*
1577 * Event callback happens whenever a variable that the API user has subscribed
1578 * to needs to be reported. This may be based purely on threshold and frequency
1579 * (a regular subscription, see subscribe call's arguments) or when the set()
1580 * command is executed and the actual change needs to be reported.
1581 *
1582 * event_data is OWNED by the HAL and should be copied before the callback
1583 * finishes.
1584 */
1585typedef int (*vehicle_event_callback_fn)(const vehicle_prop_value_t *event_data);
1586
1587
1588/**
1589 * Represent the operation where the current error has happened.
1590 */
1591enum vehicle_property_operation {
1592 /** Generic error to this property which is not tied to any operation. */
1593 VEHICLE_OPERATION_GENERIC = 0,
1594 /** Error happened while handling property set. */
1595 VEHICLE_OPERATION_SET = 1,
1596 /** Error happened while handling property get. */
1597 VEHICLE_OPERATION_GET = 2,
1598 /** Error happened while handling property subscription. */
1599 VEHICLE_OPERATION_SUBSCRIBE = 3,
1600};
1601
1602/*
Keun-young Parkab68e372016-03-10 16:28:42 -08001603 * Suggests that an error condition has occurred.
Sanket Agarwalfb636682015-08-11 14:34:29 -07001604 *
Keun-young Parkab68e372016-03-10 16:28:42 -08001605 * @param error_code Error code. error_code should be standard error code with
1606 * negative value like -EINVAL.
Sanket Agarwalfb636682015-08-11 14:34:29 -07001607 * @parm property Note a property where error has happened. If this is generic error, property
1608 * should be VEHICLE_PROPERTY_INVALID.
1609 * @param operation Represent the operation where the error has happened. Should be one of
1610 * vehicle_property_operation.
1611 */
1612typedef int (*vehicle_error_callback_fn)(int32_t error_code, int32_t property, int32_t operation);
1613
1614/************************************************************************************/
1615
1616/*
1617 * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM
1618 * and the fields of this data structure must begin with hw_module_t
1619 * followed by module specific information.
1620 */
1621typedef struct vehicle_module {
1622 struct hw_module_t common;
1623} vehicle_module_t;
1624
1625
1626typedef struct vehicle_hw_device {
1627 struct hw_device_t common;
1628
1629 /**
1630 * After calling open on device the user should register callbacks for event and error
1631 * functions.
1632 */
1633 int (*init)(struct vehicle_hw_device* device,
1634 vehicle_event_callback_fn event_fn, vehicle_error_callback_fn err_fn);
1635 /**
1636 * Before calling close the user should destroy the registered callback
1637 * functions.
1638 * In case the unsubscribe() call is not called on all properties before
1639 * release() then release() will unsubscribe the properties itself.
1640 */
1641 int (*release)(struct vehicle_hw_device* device);
1642
1643 /**
1644 * Enumerate all available properties. The list is returned in "list".
1645 * @param num_properties number of properties contained in the retuned array.
1646 * @return array of property configs supported by this car. Note that returned data is const
1647 * and caller cannot modify it. HAL implementation should keep this memory until HAL
1648 * is released to avoid copying this again.
1649 */
1650 vehicle_prop_config_t const *(*list_properties)(struct vehicle_hw_device* device,
1651 int* num_properties);
1652
1653 /**
1654 * Get a vehicle property value immediately. data should be allocated
1655 * properly.
1656 * The caller of the API OWNS the data field.
Keun-young Park08c255e2015-12-09 13:47:30 -08001657 * Caller will set data->prop, data->value_type, and optionally zone value for zoned property.
1658 * But HAL implementation needs to fill all entries properly when returning.
Sanket Agarwalfb636682015-08-11 14:34:29 -07001659 * For pointer type, HAL implementation should allocate necessary memory and caller is
Keun-young Parkab68e372016-03-10 16:28:42 -08001660 * responsible for calling release_memory_from_get, which allows HAL to release allocated
1661 * memory.
Sanket Agarwalfb636682015-08-11 14:34:29 -07001662 * For VEHICLE_PROP_CHANGE_MODE_STATIC type of property, get should return the same value
1663 * always.
1664 * For VEHICLE_PROP_CHANGE_MODE_ON_CHANGE type of property, it should return the latest value.
Keun-young Parkab68e372016-03-10 16:28:42 -08001665 * If there is no data available yet, which can happen during initial stage, this call should
1666 * return immediately with error code of -EAGAIN.
Sanket Agarwalfb636682015-08-11 14:34:29 -07001667 */
1668 int (*get)(struct vehicle_hw_device* device, vehicle_prop_value_t *data);
1669
1670 /**
Keun-young Parkab68e372016-03-10 16:28:42 -08001671 * Release memory allocated to data in previous get call. get call for byte or string involves
1672 * allocating necessary memory from vehicle hal.
1673 * To be safe, memory allocated by vehicle hal should be released by vehicle hal and vehicle
1674 * network service will call this when data from vehicle hal is no longer necessary.
1675 * vehicle hal implementation should only release member of vehicle_prop_value_t like
1676 * data->str_value.data or data->bytes_value.data but not data itself as data itself is
1677 * allocated from vehicle network service. Once memory is freed, corresponding pointer should
1678 * be set to NULL bu vehicle hal.
1679 */
1680 void (*release_memory_from_get)(struct vehicle_hw_device* device, vehicle_prop_value_t *data);
1681
1682 /**
Sanket Agarwalfb636682015-08-11 14:34:29 -07001683 * Set a vehicle property value. data should be allocated properly and not
1684 * NULL.
1685 * The caller of the API OWNS the data field.
1686 * timestamp of data will be ignored for set operation.
1687 */
1688 int (*set)(struct vehicle_hw_device* device, const vehicle_prop_value_t *data);
1689
1690 /**
1691 * Subscribe to events.
1692 * Depending on output of list_properties if the property is:
1693 * a) on-change: sample_rate should be set to 0.
1694 * b) supports frequency: sample_rate should be set from min_sample_rate to
1695 * max_sample_rate.
1696 * Subscribing to properties in-correctly may result in error callbacks and
1697 * will depend on HAL implementation.
1698 * @param device
1699 * @param prop
1700 * @param sample_rate
Keun-young Parkbf877a72015-12-21 14:16:05 -08001701 * @param zones All subscribed zones for zoned property. can be ignored for non-zoned property.
1702 * 0 means all zones supported instead of no zone.
Sanket Agarwalfb636682015-08-11 14:34:29 -07001703 */
Keun-young Parkbf877a72015-12-21 14:16:05 -08001704 int (*subscribe)(struct vehicle_hw_device* device, int32_t prop, float sample_rate,
1705 int32_t zones);
Sanket Agarwalfb636682015-08-11 14:34:29 -07001706
1707 /** Cancel subscription on a property. */
1708 int (*unsubscribe)(struct vehicle_hw_device* device, int32_t prop);
1709} vehicle_hw_device_t;
1710
1711__END_DECLS
1712
1713#endif // ANDROID_VEHICLE_INTERFACE_H