comparison chipsetsw/drivers/drv_app/kpd/kpd_handle_message.c @ 0:509db1a7b7b8

initial import: leo2moko-r1
author Space Falcon <falcon@ivan.Harhan.ORG>
date Mon, 01 Jun 2015 03:24:05 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:509db1a7b7b8
1 /**
2 * @file kpd_handle_msg.c
3 *
4 * Coding of the kpd_handle_msg function, which is called when the SWE
5 * receives a new message.
6 *
7 * @author Laurent Sollier (l-sollier@ti.com)
8 * @version 0.1
9 */
10
11 /*
12 * History:
13 *
14 * Date Author Modification
15 * ----------------------------------------
16 * 10/12/2001 L Sollier Create
17 *
18 *
19 * (C) Copyright 2001 by Texas Instruments Incorporated, All Rights Reserved
20 */
21
22 #include "kpd/kpd_messages_i.h"
23 #include "kpd/kpd_scan_functions.h"
24 #include "kpd/kpd_process_internal_msg.h"
25 #include "kpd/kpd_physical_key_def.h"
26
27 #include "rv/rv_general.h"
28 #include "rvf/rvf_api.h"
29 #include "rvm/rvm_use_id_list.h"
30
31 /**
32 * @name Functions implementation
33 *
34 */
35 /*@{*/
36
37 /**
38 * function: kpd_handle_msg
39 */
40 T_RV_RET kpd_handle_msg(T_RV_HDR *msg_p)
41 {
42 if (msg_p != NULL)
43 {
44 switch (msg_p->msg_id)
45 {
46 case KPD_SUBSCRIBE_MSG:
47 {
48 T_KPD_SUBSCRIBE_MSG* msg_subscribe_p= (T_KPD_SUBSCRIBE_MSG*) msg_p;
49
50 KPD_SEND_TRACE_PARAM("KPD: 'Subscription' message received,Id:",
51 msg_subscribe_p->subscription_info.subscriber_id,
52 RV_TRACE_LEVEL_DEBUG_LOW);
53
54 kpd_subscribe_i(msg_subscribe_p->subscription_info.subscriber_id,
55 msg_subscribe_p->subscription_info.mode,
56 &msg_subscribe_p->subscription_info.notified_keys,
57 msg_subscribe_p->subscription_info.return_path);
58 break;
59 }
60 case KPD_UNSUBSCRIBE_MSG:
61 {
62 T_KPD_UNSUBSCRIBE_MSG* msg_unsubscribe_p= (T_KPD_UNSUBSCRIBE_MSG*) msg_p;
63
64 KPD_SEND_TRACE_PARAM("KPD: 'Unsubscription' message received,Id:",
65 msg_unsubscribe_p->subscriber_id,
66 RV_TRACE_LEVEL_DEBUG_LOW);
67
68 kpd_unsubscribe_i(msg_unsubscribe_p->subscriber_id);
69 break;
70 }
71 case KPD_NOTIF_KEYS_MSG:
72 {
73 T_KPD_NOTIF_KEYS_MSG* msg_notif_keys_p= (T_KPD_NOTIF_KEYS_MSG*) msg_p;
74
75 KPD_SEND_TRACE("KPD: 'Notification keys level' message received",
76 RV_TRACE_LEVEL_DEBUG_LOW);
77
78 kpd_define_key_notification_i(msg_notif_keys_p->subscriber_id,
79 &msg_notif_keys_p->notif_key_table,
80 msg_notif_keys_p->notif_level,
81 msg_notif_keys_p->long_press_time,
82 msg_notif_keys_p->repeat_time);
83 break;
84 }
85 case KPD_CHANGE_MODE_MSG:
86 {
87 T_KPD_CHANGE_MODE_MSG* msg_change_mode_p= (T_KPD_CHANGE_MODE_MSG*) msg_p;
88
89 KPD_SEND_TRACE("KPD: 'Change mode' message received:",
90 RV_TRACE_LEVEL_DEBUG_LOW);
91
92 kpd_change_mode_i(msg_change_mode_p->subscriber_id,
93 &msg_change_mode_p->notified_keys,
94 msg_change_mode_p->new_mode);
95
96 break;
97 }
98 case KPD_OWN_KEYPAD_MSG:
99 {
100 T_KPD_OWN_KEYPAD_MSG* msg_own_keypad_p= (T_KPD_OWN_KEYPAD_MSG*) msg_p;
101
102 KPD_SEND_TRACE("KPD: 'Own keypad' message received",
103 RV_TRACE_LEVEL_DEBUG_LOW);
104
105 kpd_own_keypad_i(msg_own_keypad_p->subscriber_id,
106 msg_own_keypad_p->is_keypad_owner,
107 &msg_own_keypad_p->keys_owner);
108
109 break;
110 }
111 case KPD_SET_CONFIG_MODE_MSG:
112 {
113 T_KPD_SET_CONFIG_MODE_MSG* msg_change_mode_p= (T_KPD_SET_CONFIG_MODE_MSG*) msg_p;
114
115 KPD_SEND_TRACE("KPD: 'Set config mode' message received",
116 RV_TRACE_LEVEL_DEBUG_LOW);
117
118 kpd_set_key_config_i(msg_change_mode_p->subscriber_id,
119 &msg_change_mode_p->reference_keys,
120 &msg_change_mode_p->new_keys);
121
122 break;
123 }
124 case KPD_KEY_PRESSED_MSG:
125 {
126 T_KPD_PHYSICAL_KEY_ID physical_key_pressed_id;
127 T_KPD_KEY_PRESSED_MSG* msg_key_pressed= (T_KPD_KEY_PRESSED_MSG*) msg_p;
128
129 KPD_SEND_TRACE_PARAM("KPD: Message key pressed received by keypad task",
130 msg_key_pressed->value,
131 RV_TRACE_LEVEL_DEBUG_LOW);
132 #ifdef _WINDOWS
133 /* In case of Riviera Tool test and in order to avoid losing key event,
134 key pressed Id is set in the message, and unset only when keypad task
135 have read the value */
136 kpd_set_key_value(msg_key_pressed->value);
137 #endif
138 /* If there is enough memory to process the key */
139 if (msg_key_pressed->key_to_process)
140 {
141 /* if value = KPD_SHORT_PRESS_PWR_KEY, it's PWR SWE which sent the message,
142 physical key id cannot be retrieved by function kpd_scan_keypad */
143 if (msg_key_pressed->value == KPD_SHORT_PRESS_PWR_KEY)
144 physical_key_pressed_id = KPD_SHORT_PRESS_PWR_KEY;
145 else
146 {
147 #if (CHIPSET == 12)
148 kpd_init_ctrl_reg(1, SOFTWARE_MODE_ENABLE, KPD_CLK_DIV32,
149 KPD_DETECTION_DISABLED, KPD_DETECTION_DISABLED,
150 KPD_DETECTION_DISABLED, KPD_DETECTION_DISABLED);
151 #endif
152 physical_key_pressed_id = kpd_scan_keypad();
153 }
154
155 /* The processing is different if keypad is in SN mode and the key is
156 in the table of keypad owner */
157 if (kpd_is_key_in_sn_mode(physical_key_pressed_id) == TRUE)
158 {
159 kpd_process_key_pressed_sn_mode_i(physical_key_pressed_id);
160 }
161 else
162 {
163 kpd_process_key_pressed_i(physical_key_pressed_id);
164 }
165 }
166 else
167 {
168 KPD_SEND_TRACE("KPD: Lost key event due to memory lack",
169 RV_TRACE_LEVEL_DEBUG_HIGH);
170 kpd_wait_for_key_release();
171 }
172 break;
173 }
174 default:
175 {
176 /* Unknow message has been received */
177 KPD_SEND_TRACE("KPD: Message received unknown",
178 RV_TRACE_LEVEL_ERROR);
179 break;
180 }
181 }
182
183 /* Free message */
184 rvf_free_buf(msg_p);
185 }
186
187 return RV_OK;
188 }
189
190 /*@}*/