2 * @copyright Copyright (c) 2017-2020 TOYOTA MOTOR CORPORATION.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef HAL_API_INPUT_HAL_H_
18 #define HAL_API_INPUT_HAL_H_
20 #include <native_service/frameworkunified_types.h>
22 #include "peripheral_service/aglinput.h"
28 /** @addtogroup switchhandler
31 /** @addtogroup input_hal
32 * @ingroup switchhandler
36 /************************************************************************
38 ************************************************************************/
40 * \~english Return value type
42 enum HalInputRetType {
46 HAL_INPUT_RET_NORMAL = 0,
48 * \~english Process abnormality
52 * \~english Not support
54 HAL_INPUT_RET_NOT_SUPPORT,
57 * \~english Touch panel IC type
59 enum HalInputTouchDeviceType {
61 * \~english Touch panel IC is invalid
63 HAL_INPUT_TOUCH_DEVICE_INVALID = 0,
65 * \~english Touch panel IC is ILITEK
67 HAL_INPUT_TOUCH_DEVICE_ILITEK,
71 * \~english Radio band type
73 enum HalInputBandType {
75 * \~english Radio band is AM
77 HAL_INPUT_BAND_TYPE_AM = 0,
79 * \~english Radio band isn't AM
81 HAL_INPUT_BAND_TYPE_NOT_AM,
85 * \~english Radio reception status
87 enum HalInputTuneStatus {
89 * \~english Radio is in normal state
91 HAL_INPUT_TUNE_STATUS_NORMAL = 0,
93 * \~english Radio is in search state
95 HAL_INPUT_TUNE_STATUS_SERACH,
99 * \~english Sensitivity Level
101 enum HalInputTouchSensitivityLevel {
103 * \~english Sensitivity level low
105 HAL_INPUT_TOUCH_SENSITIVITY_LEVEL_LOW = 1,
107 * \~english Sensitivity level middle
109 HAL_INPUT_TOUCH_SENSITIVITY_LEVEL_MIDDLE,
111 * \~english Sensitivity level high
113 HAL_INPUT_TOUCH_SENSITIVITY_LEVEL_HIGH,
115 * \~english Sensitivity level none
117 HAL_INPUT_TOUCH_SENSITIVITY_LEVEL_NONE,
121 * \~english input device type
123 enum HalInputDeviceType {
125 * \~english The device type invalid
127 HAL_INPUT_DEVICE_INVALID,
129 * \~english The device is keyboard
131 HAL_INPUT_DEVICE_KEYBOARD,
133 * \~english The device is touch
135 HAL_INPUT_DEVICE_TOUCH,
137 * \~english The device is ESC-KEY
139 HAL_INPUT_DEVICE_TOUCH_ESCKEY,
141 * \~english The device is steering SW
143 HAL_INPUT_DEVICE_STEERING,
145 * \~english The device is tablet finger
147 HAL_INPUT_DEVICE_TABLET_FINGER,
149 * \~english The device is rotary key
151 HAL_INPUT_DEVICE_ROTARY_KEY,
155 * \~english Don't need to config touch panel
157 #define HAL_INPUT_TOUCH_CONFIG_OFF (0)
159 * \~english Touch panel configed
161 #define HAL_INPUT_TOUCH_CONFIG_ON (1)
164 * \~english Touch panel touch press
166 #define HAL_INPUT_TOUCH_PRESS (0)
168 * \~english Touch panel touch release
170 #define HAL_INPUT_TOUCH_RELEASE (1)
173 * \~english Don't report touch panel's touch event
175 #define HAL_INPUT_TOUCH_UNREPORT (0)
177 * \~english Report touch panel's touch event
179 #define HAL_INPUT_TOUCH_REPORT (1)
182 * \~english Test all case
184 #define HAL_INPUT_TOUCH_SELFTEST_ID_ALL (0xFE)
186 * \~english Selftest data length
188 #define HAL_INPUT_TOUCH_SELFTEST_DATA_LEN (5)
190 * \~english Selftest mode not support
192 #define HAL_INPUT_TOUCH_SELFTEST_NOT_SUPPORT (0xEE)
195 * \~english max number of input_event per package.
197 #define HAL_INPUT_EVENT_COUNT 64
200 * \~english Thread name defined
202 #define HAL_INPUT_SOURCE_NAME "input_hal_mon"
205 * \~english Notify input event from touch panel,
206 * The data of the notification please refer the following two type.\n
207 * @ref HAL_INPUT_TOUCH_PRESS \n
208 * @ref HAL_INPUT_TOUCH_RELEASE \n
209 * Please use IF of NSFW as follows to receive this event.
211 * l_eStatus = FrameworkunifiedAttachCallbackToDispatcher(happ, HAL_INPUT_SOURCE_NAME, HAL_INPUT_NOTIFY_TOUCH, fpOnCmd);
213 * \~english note:FrameworkunifiedAttachCallbacksToDispatcher is available, too.
215 #define HAL_INPUT_NOTIFY_TOUCH 100
217 * \~english Notify input event from touch panel ESC-KEY,
218 * The data format of the notification please refer to @ref EventsPackageInput.\n
219 * Please use IF of NSFW as follows to receive this event.
221 * l_eStatus = FrameworkunifiedAttachCallbackToDispatcher(happ, HAL_INPUT_SOURCE_NAME, HAL_INPUT_NOTIFY_ESC_KEY, fpOnCmd)
223 * \~english note:FrameworkunifiedAttachCallbacksToDispatcher is available, too.
225 #define HAL_INPUT_NOTIFY_ESC_KEY 101
227 * \~english Notify input event from key board,
228 * The data format of the notification please refer to @ref EventsPackageInput.\n
229 * Please use IF of NSFW as follows to receive this event.
231 * l_eStatus = FrameworkunifiedAttachCallbackToDispatcher(happ, HAL_INPUT_SOURCE_NAME, HAL_INPUT_NOTIFY_KEY_BOARD, fpOnCmd)
233 * \~english note:FrameworkunifiedAttachCallbacksToDispatcher is available, too.
235 #define HAL_INPUT_NOTIFY_KEY_BOARD 102
237 * \~english Notify input event from steering,
238 * The data format of the notification please refer to @ref EventsPackageInput.\n
239 * Please use IF of NSFW as follows to receive this event.
241 * l_eStatus = FrameworkunifiedAttachCallbackToDispatcher(happ, HAL_INPUT_SOURCE_NAME, HAL_INPUT_NOTIFY_STEERING, fpOnCmd)
243 * \~english note:FrameworkunifiedAttachCallbacksToDispatcher is available, too.
245 #define HAL_INPUT_NOTIFY_STEERING 104
247 * \~english Notify input event from tablet finger,
248 * The data format of the notification please refer to @ref EventsPackageInput.\n
249 * Please use IF of NSFW as follows to receive this event.
251 * l_eStatus = FrameworkunifiedAttachCallbackToDispatcher(happ, HAL_INPUT_SOURCE_NAME, HAL_INPUT_NOTIFY_TABLET_FINGER, fpOnCmd)
253 * \~english note:FrameworkunifiedAttachCallbacksToDispatcher is available, too.
255 #define HAL_INPUT_NOTIFY_TABLET_FINGER 105
257 * \~english Notify input event from rotary-key,
258 * The data format of the notification please refer to @ref EventsPackageInput.\n
259 * Please use IF of NSFW as follows to receive this event.
261 * l_eStatus = FrameworkunifiedAttachCallbackToDispatcher(happ, HAL_INPUT_SOURCE_NAME, HAL_INPUT_NOTIFY_ROTARY_KEY, fpOnCmd)
263 * \~english note:FrameworkunifiedAttachCallbacksToDispatcher is available, too.
265 #define HAL_INPUT_NOTIFY_ROTARY_KEY 106
268 * \~english Initialzing touch result notify,
269 * The data format of the notification please refer to @ref TouchInitFinishInput.\n
270 * Please use IF of NSFW as follows to receive this event.
272 * l_eStatus = FrameworkunifiedAttachCallbackToDispatcher(happ, HAL_INPUT_SOURCE_NAME, HAL_INPUT_NOTIFY_TOUCH_INIT_FINISH, fpOnCmd)
274 * \~english note:FrameworkunifiedAttachCallbacksToDispatcher is available, too.
276 #define HAL_INPUT_NOTIFY_TOUCH_INIT_FINISH 120
279 * @struct RadioInfoTouch
280 * \~english @par Brief
283 struct RadioInfoTouch {
285 * \~english Radio band type
286 * \~english Please ref to @ref HalInputBandType
290 * \~english Frequency of the tuner[kHz]
291 * (Use only at the time of AM reception)
295 * \~english Reception status (Use only at the time of AM reception)
296 * \~english Please refer to @ref HalInputBandType
302 * @struct SelftestTouch
303 * \~english @par Brief
304 * Touch panel selftest mode result
306 struct SelftestTouch {
308 * \~english Touch panel selftest mode result
310 unsigned char r_code;
312 * \~english Touch panel selftest mode data.
313 * The datail info is depend on hardware spec.
315 unsigned char r_data[HAL_INPUT_TOUCH_SELFTEST_DATA_LEN];
319 * @struct EventsPackageInput
320 * \~english @par Brief
321 * Input event package defined
323 struct EventsPackageInput {
325 * \~english device type
329 * \~english event count
333 * \~english input event data.
335 struct input_event event[HAL_INPUT_EVENT_COUNT];
339 * @struct TouchInitFinishInput
340 * \~english @par Brief
341 * The result of initializing touch
343 struct TouchInitFinishInput {
345 * \~english If initializing the touch successful, the result was set HAL_INPUT_RET_NORMAL.
346 * If an error occurred, the result was set HAL_INPUT_RET_ERROR.
350 /************************************************************************
351 * Function prototype *
352 ************************************************************************/
354 ////////////////////////////////////////////////////////////////////////////////
355 /// \ingroup input_hal
356 /// \~english @par Brief
357 /// initializing input_hal.
358 /// \~english @param [in] app_name
359 /// const char* - the app name for receive input event.
360 /// \~english @retval HAL_INPUT_RET_NORMAL : Success
361 /// \~english @retval HAL_INPUT_RET_ERROR : Process abnormality
362 /// \~english @par Prerequisite
363 /// - Have called @ref InitTouch()
364 /// \~english @par Change of internal state
365 /// - Change of internal state according to the API does not occur
366 /// \~english @par Conditions of processing failure
368 /// \~english @par Classification
370 /// \~english @par Type
372 /// \~english @par Detail
373 /// - Listen input devices and send input event.
374 /// - After initializing touch panel, the event(@ref HAL_INPUT_NOTIFY_TOUCH_INIT_FINISH) will be sent.
375 /// - The API can be used by 1 process.
376 /// \~english @see None.
377 ////////////////////////////////////////////////////////////////////////////////
378 int InitInput(const char* app_name);
380 ////////////////////////////////////////////////////////////////////////////////
381 /// \ingroup input_hal
382 /// \~english @par Brief
383 /// finalize input_hal
384 /// \~english @param none
385 /// \~english @retval HAL_INPUT_RET_NORMAL : Success
386 /// \~english @par Prerequisite
388 /// \~english @par Change of internal state
389 /// - Change of internal state according to the API does not occur
390 /// \~english @par Conditions of processing failure
392 /// \~english @par Classification
394 /// \~english @par Type
396 /// \~english @par Detail
397 /// - This API is to finalize input_hal.
398 /// - The API can be used by 1 process.
399 /// \~english @see None
400 ////////////////////////////////////////////////////////////////////////////////
403 ////////////////////////////////////////////////////////////////////////////////
404 /// \ingroup input_hal
405 /// \~english @par Brief
406 /// Init those operating function of touch panel driver
407 /// \~english @param none
408 /// \~english @retval HAL_INPUT_RET_NORMAL : Success
409 /// \~english @par Prerequisite
410 /// - Touch panel function exist
411 /// \~english @par Change of internal state
412 /// - Change of internal state according to the API does not occur
413 /// \~english @par Conditions of processing failure
415 /// \~english @par Classification
417 /// \~english @par Type
419 /// \~english @par Detail
420 /// - The API is a block I/F which initializes those operating functions of touch panel driver.
421 /// - The API can be used by 1 process.
422 /// \~english @see None
423 ////////////////////////////////////////////////////////////////////////////////
426 ////////////////////////////////////////////////////////////////////////////////
427 /// \ingroup input_hal
428 /// \~english @par Brief
429 /// Make touch panel start work
430 /// \~english @param none
431 /// \~english @retval HAL_INPUT_RET_NORMAL : Success
432 /// \~english @retval HAL_INPUT_RET_ERROR : Process abnormality
433 /// \~english @par Prerequisite
434 /// - Have called @ref InitTouch()
435 /// \~english @par Change of internal state
436 /// - Change of internal state according to the API does not occur
437 /// \~english @par Conditions of processing failure
438 /// - Haven't called @ref InitTouch()
439 /// - @ref HAL_INPUT_RET_ERROR
441 /// - @ref HAL_INPUT_RET_ERROR
442 /// \~english @par Classification
444 /// \~english @par Type
446 /// \~english @par Detail
447 /// - This API is to prepare touch panel and make it start work.
448 /// - The API can be used by 1 process.
449 /// \~english @see None
450 ////////////////////////////////////////////////////////////////////////////////
453 ////////////////////////////////////////////////////////////////////////////////
454 /// \ingroup input_hal
455 /// \~english @par Brief
456 /// Execute touch panel self test
457 /// \~english @param [in] id
458 /// int - selftest id(Pass HAL_INPUT_TOUCH_SELFTEST_ID_ALL :
459 /// Execute all test(disconnection check))
460 /// \~english @param [out] result
461 /// void* - Touch panel selftest mode check result
462 /// \~english @note Result struct SelftestTouch depend on hardware spec
463 /// \~english @retval HAL_INPUT_RET_NORMAL : Success
464 /// \~english @retval HAL_INPUT_RET_ERROR : Process abnormality
465 /// \~english @retval HAL_INPUT_RET_NOT_SUPPORT : Not support
466 /// \~english @par Prerequisite
467 /// - Have called @ref InitTouch()
468 /// \~english @par Change of internal state
469 /// - Change of internal state according to the API does not occur
470 /// \~english @par Conditions of processing failure
471 /// - Haven't called @ref InitTouch()
472 /// - @ref HAL_INPUT_RET_ERROR
473 /// - Not support this function
474 /// - @ref HAL_INPUT_RET_NOT_SUPPORT
475 /// - Param result is NULL
476 /// - @ref HAL_INPUT_RET_ERROR
478 /// - @ref HAL_INPUT_RET_ERROR
479 /// \~english @par Classification
481 /// \~english @par Type
483 /// \~english @par Detail
484 /// - This API is to execute touch panel self test and get test result.
485 /// - The API can be used by 1 process.
486 /// \~english @see None
487 ////////////////////////////////////////////////////////////////////////////////
488 int SelfTestTouch(int id, void *result);
490 ////////////////////////////////////////////////////////////////////////////////
491 /// \ingroup input_hal
492 /// \~english @par Brief
493 /// Set whether the driver sends touch panel data or not.
494 /// \~english @param [in] status
495 /// int - Touch panel whether report/unreport event\n
496 /// HAL_INPUT_TOUCH_REPORT : Report touch panel's touch event\n
497 /// HAL_INPUT_TOUCH_UNREPORT : Don't report touch panel's touch event\n
498 /// \~english @retval HAL_INPUT_RET_NORMAL : Success
499 /// \~english @retval HAL_INPUT_RET_ERROR : Process abnormality
500 /// \~english @retval HAL_INPUT_RET_NOT_SUPPORT : Not support
501 /// \~english @note It means this API isn't support when return
502 /// @ref HAL_INPUT_RET_NOT_SUPPORT.
503 /// The user need to implement it
504 /// if don't need to report touch event.
505 /// \~english @par Prerequisite
506 /// - Have called @ref InitTouch()
507 /// \~english @par Change of internal state
508 /// - Change of internal state according to the API does not occur
509 /// \~english @par Conditions of processing failure
510 /// - Haven't called @ref InitTouch()
511 /// - @ref HAL_INPUT_RET_ERROR
512 /// - Not support this function
513 /// - @ref HAL_INPUT_RET_NOT_SUPPORT
514 /// - Status is none of @ref HAL_INPUT_TOUCH_REPORT /
515 /// @ref HAL_INPUT_TOUCH_UNREPORT
516 /// - @ref HAL_INPUT_RET_ERROR
518 /// - @ref HAL_INPUT_RET_ERROR
519 /// \~english @par Classification
521 /// \~english @par Type
523 /// \~english @par Detail
524 /// - This API is to set whether the driver sends touch panel data or not.
525 /// - The API can be used by 1 process.
526 /// \~english @see None
527 ////////////////////////////////////////////////////////////////////////////////
528 int LockTouch(int status);
530 ////////////////////////////////////////////////////////////////////////////////
531 /// \ingroup input_hal
532 /// \~english @par Brief
533 /// Suspend touch panel
534 /// \~english @param none
535 /// \~english @retval HAL_INPUT_RET_NORMAL : Success
536 /// \~english @retval HAL_INPUT_RET_ERROR : Process abnormality
537 /// \~english @retval HAL_INPUT_RET_NOT_SUPPORT : Not support
538 /// \~english @note It means this API isn't support when return
539 /// @ref HAL_INPUT_RET_NOT_SUPPORT.
540 /// The user need to implement it
541 /// if don't need to report touch event.
542 /// \~english @par Prerequisite
543 /// - Have called @ref InitTouch()
544 /// \~english @par Change of internal state
545 /// - Change of internal state according to the API does not occur
546 /// \~english @par Conditions of processing failure
547 /// - Haven't called @ref InitTouch()
548 /// - @ref HAL_INPUT_RET_ERROR
549 /// - Not support this function
550 /// - @ref HAL_INPUT_RET_NOT_SUPPORT
552 /// - @ref HAL_INPUT_RET_ERROR
553 /// \~english @par Classification
555 /// \~english @par Type
557 /// \~english @par Detail
558 /// - This API is to suspend touch panel.
559 /// - The API can be used by 1 process.
560 /// \~english @see None
561 ////////////////////////////////////////////////////////////////////////////////
564 ////////////////////////////////////////////////////////////////////////////////
565 /// \ingroup input_hal
566 /// \~english @par Brief
567 /// Set touch panel sensitivity level
568 /// \~english @param [in] level
569 /// int - Sensitivity level.
570 /// \~english @retval HAL_INPUT_RET_NORMAL : Success
571 /// \~english @retval HAL_INPUT_RET_ERROR : Process abnormality
572 /// \~english @retval HAL_INPUT_RET_NOT_SUPPORT : Not support
573 /// \~english @par Prerequisite
574 /// - Have called @ref InitTouch()
575 /// \~english @par Change of internal state
576 /// - Change of internal state according to the API does not occur
577 /// \~english @par Conditions of processing failure
578 /// - Haven't called @ref InitTouch()
579 /// - @ref HAL_INPUT_RET_ERROR
580 /// - Not support this function
581 /// - @ref HAL_INPUT_RET_NOT_SUPPORT
582 /// - Sensitivity level is none of @ref HalInputTouchSensitivityLevel
583 /// - @ref HAL_INPUT_RET_ERROR
585 /// - @ref HAL_INPUT_RET_ERROR
586 /// \~english @par Classification
588 /// \~english @par Type
590 /// \~english @par Detail
591 /// - This API is to set touch panel sensitivity level.
592 /// - The API can be used by 1 process.
593 /// \~english @see None
594 ////////////////////////////////////////////////////////////////////////////////
595 int SetSensitivityLevelTouch(int level);
597 ////////////////////////////////////////////////////////////////////////////////
598 /// \ingroup input_hal
599 /// \~english @par Brief
600 /// Get touch panel sensitivity level
601 /// \~english @param [out] level
602 /// int* - Sensitivity level.
603 /// \~english @retval HAL_INPUT_RET_NORMAL : Success
604 /// \~english @retval HAL_INPUT_RET_ERROR : Process abnormality
605 /// \~english @retval HAL_INPUT_RET_NOT_SUPPORT : Not support
606 /// \~english @par Prerequisite
607 /// - Have called @ref InitTouch()
608 /// \~english @par Change of internal state
609 /// - Change of internal state according to the API does not occur
610 /// \~english @par Conditions of processing failure
611 /// - Haven't called @ref InitTouch()
612 /// - @ref HAL_INPUT_RET_ERROR
613 /// - Not support this function
614 /// - @ref HAL_INPUT_RET_NOT_SUPPORT
615 /// - Param level is NULL
616 /// - @ref HAL_INPUT_RET_ERROR
618 /// - @ref HAL_INPUT_RET_ERROR
619 /// \~english @par Classification
621 /// \~english @par Type
623 /// \~english @par Detail
624 /// - This API is to get touch panel sensitivity level.
625 /// - The API can be used by 1 process.
626 /// \~english @see None
627 ////////////////////////////////////////////////////////////////////////////////
628 int GetSensitivityLevelTouch(int *level);
630 ////////////////////////////////////////////////////////////////////////////////
631 /// \ingroup input_hal
632 /// \~english @par Brief
633 /// Notify radio scan frequency
634 /// \~english @param [in] info
635 /// RadioInfoTouch* - SCAN frequence info
636 /// \~english @retval HAL_INPUT_RET_NORMAL : Success
637 /// \~english @retval HAL_INPUT_RET_ERROR : Process abnormality
638 /// \~english @retval HAL_INPUT_RET_NOT_SUPPORT : Not support
639 /// \~english @par Prerequisite
640 /// - Have called @ref InitTouch()
641 /// \~english @par Change of internal state
642 /// - Change of internal state according to the API does not occur
643 /// \~english @par Conditions of processing failure
644 /// - Haven't called @ref InitTouch()
645 /// - @ref HAL_INPUT_RET_ERROR
646 /// - Not support this function
647 /// - @ref HAL_INPUT_RET_NOT_SUPPORT
648 /// - Param info is NULL
649 /// - @ref HAL_INPUT_RET_ERROR
651 /// - @ref HAL_INPUT_RET_ERROR
652 /// \~english @par Classification
654 /// \~english @par Type
656 /// \~english @par Detail
657 /// - This API is to notify radio scan frequency.
658 /// - The API can be used by 1 process.
659 /// \~english @see None
660 ////////////////////////////////////////////////////////////////////////////////
661 int NotifyRadioScanFreqTouch(struct RadioInfoTouch *info);
663 ////////////////////////////////////////////////////////////////////////////////
664 /// \ingroup input_hal
665 /// \~english @par Brief
666 /// Get panel resolution
667 /// \~english @param [in] reso_h
668 /// int* - horizontal resolution
669 /// \~english @param [in] reso_v
670 /// int* - vertical resolution
671 /// \~english @retval HAL_INPUT_RET_NORMAL : Success
672 /// \~english @retval HAL_INPUT_RET_ERROR : Process abnormality
673 /// \~english @par Prerequisite
674 /// - Have called @ref InitTouch()
675 /// \~english @par Change of internal state
676 /// - Change of internal state according to the API does not occur
677 /// \~english @par Conditions of processing failure
678 /// - Param reso_h or reso_v is NULL
679 /// - @ref HAL_INPUT_RET_ERROR
681 /// - @ref HAL_INPUT_RET_ERROR
682 /// \~english @par Classification
684 /// \~english @par Type
686 /// \~english @par Detail
687 /// - This API is to get horizontal and vertical resolution.
688 /// - The API can be used by 1 process.
689 /// \~english @see None
690 ////////////////////////////////////////////////////////////////////////////////
691 int GetPanelSpecResolutionInput(int *reso_h, int *reso_v);
693 /** @}*/ // end of input_hal
694 /** @}*/ // end of switchhandler
696 #endif // HAL_API_INPUT_HAL_H_