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