1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#include "smscoreapi.h"
21
22#include <linux/kernel.h>
23#include <linux/init.h>
24#include <linux/module.h>
25#include <linux/moduleparam.h>
26#include <linux/dma-mapping.h>
27#include <linux/delay.h>
28#include <linux/io.h>
29#include <linux/slab.h>
30
31#include <linux/firmware.h>
32#include <linux/wait.h>
33#include <asm/byteorder.h>
34
35#include "sms-cards.h"
36#include "smsir.h"
37
38struct smscore_device_notifyee_t {
39 struct list_head entry;
40 hotplug_t hotplug;
41};
42
43struct smscore_idlist_t {
44 struct list_head entry;
45 int id;
46 int data_type;
47};
48
49struct smscore_client_t {
50 struct list_head entry;
51 struct smscore_device_t *coredev;
52 void *context;
53 struct list_head idlist;
54 onresponse_t onresponse_handler;
55 onremove_t onremove_handler;
56};
57
58static char *siano_msgs[] = {
59 [MSG_TYPE_BASE_VAL - MSG_TYPE_BASE_VAL] = "MSG_TYPE_BASE_VAL",
60 [MSG_SMS_GET_VERSION_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_GET_VERSION_REQ",
61 [MSG_SMS_GET_VERSION_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_GET_VERSION_RES",
62 [MSG_SMS_MULTI_BRIDGE_CFG - MSG_TYPE_BASE_VAL] = "MSG_SMS_MULTI_BRIDGE_CFG",
63 [MSG_SMS_GPIO_CONFIG_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_GPIO_CONFIG_REQ",
64 [MSG_SMS_GPIO_CONFIG_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_GPIO_CONFIG_RES",
65 [MSG_SMS_GPIO_SET_LEVEL_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_GPIO_SET_LEVEL_REQ",
66 [MSG_SMS_GPIO_SET_LEVEL_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_GPIO_SET_LEVEL_RES",
67 [MSG_SMS_GPIO_GET_LEVEL_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_GPIO_GET_LEVEL_REQ",
68 [MSG_SMS_GPIO_GET_LEVEL_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_GPIO_GET_LEVEL_RES",
69 [MSG_SMS_EEPROM_BURN_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_EEPROM_BURN_IND",
70 [MSG_SMS_LOG_ENABLE_CHANGE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_LOG_ENABLE_CHANGE_REQ",
71 [MSG_SMS_LOG_ENABLE_CHANGE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_LOG_ENABLE_CHANGE_RES",
72 [MSG_SMS_SET_MAX_TX_MSG_LEN_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_SET_MAX_TX_MSG_LEN_REQ",
73 [MSG_SMS_SET_MAX_TX_MSG_LEN_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_SET_MAX_TX_MSG_LEN_RES",
74 [MSG_SMS_SPI_HALFDUPLEX_TOKEN_HOST_TO_DEVICE - MSG_TYPE_BASE_VAL] = "MSG_SMS_SPI_HALFDUPLEX_TOKEN_HOST_TO_DEVICE",
75 [MSG_SMS_SPI_HALFDUPLEX_TOKEN_DEVICE_TO_HOST - MSG_TYPE_BASE_VAL] = "MSG_SMS_SPI_HALFDUPLEX_TOKEN_DEVICE_TO_HOST",
76 [MSG_SMS_BACKGROUND_SCAN_FLAG_CHANGE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_BACKGROUND_SCAN_FLAG_CHANGE_REQ",
77 [MSG_SMS_BACKGROUND_SCAN_FLAG_CHANGE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_BACKGROUND_SCAN_FLAG_CHANGE_RES",
78 [MSG_SMS_BACKGROUND_SCAN_SIGNAL_DETECTED_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_BACKGROUND_SCAN_SIGNAL_DETECTED_IND",
79 [MSG_SMS_BACKGROUND_SCAN_NO_SIGNAL_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_BACKGROUND_SCAN_NO_SIGNAL_IND",
80 [MSG_SMS_CONFIGURE_RF_SWITCH_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_CONFIGURE_RF_SWITCH_REQ",
81 [MSG_SMS_CONFIGURE_RF_SWITCH_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_CONFIGURE_RF_SWITCH_RES",
82 [MSG_SMS_MRC_PATH_DISCONNECT_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_MRC_PATH_DISCONNECT_REQ",
83 [MSG_SMS_MRC_PATH_DISCONNECT_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_MRC_PATH_DISCONNECT_RES",
84 [MSG_SMS_RECEIVE_1SEG_THROUGH_FULLSEG_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_RECEIVE_1SEG_THROUGH_FULLSEG_REQ",
85 [MSG_SMS_RECEIVE_1SEG_THROUGH_FULLSEG_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_RECEIVE_1SEG_THROUGH_FULLSEG_RES",
86 [MSG_SMS_RECEIVE_VHF_VIA_VHF_INPUT_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_RECEIVE_VHF_VIA_VHF_INPUT_REQ",
87 [MSG_SMS_RECEIVE_VHF_VIA_VHF_INPUT_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_RECEIVE_VHF_VIA_VHF_INPUT_RES",
88 [MSG_WR_REG_RFT_REQ - MSG_TYPE_BASE_VAL] = "MSG_WR_REG_RFT_REQ",
89 [MSG_WR_REG_RFT_RES - MSG_TYPE_BASE_VAL] = "MSG_WR_REG_RFT_RES",
90 [MSG_RD_REG_RFT_REQ - MSG_TYPE_BASE_VAL] = "MSG_RD_REG_RFT_REQ",
91 [MSG_RD_REG_RFT_RES - MSG_TYPE_BASE_VAL] = "MSG_RD_REG_RFT_RES",
92 [MSG_RD_REG_ALL_RFT_REQ - MSG_TYPE_BASE_VAL] = "MSG_RD_REG_ALL_RFT_REQ",
93 [MSG_RD_REG_ALL_RFT_RES - MSG_TYPE_BASE_VAL] = "MSG_RD_REG_ALL_RFT_RES",
94 [MSG_HELP_INT - MSG_TYPE_BASE_VAL] = "MSG_HELP_INT",
95 [MSG_RUN_SCRIPT_INT - MSG_TYPE_BASE_VAL] = "MSG_RUN_SCRIPT_INT",
96 [MSG_SMS_EWS_INBAND_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_EWS_INBAND_REQ",
97 [MSG_SMS_EWS_INBAND_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_EWS_INBAND_RES",
98 [MSG_SMS_RFS_SELECT_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_RFS_SELECT_REQ",
99 [MSG_SMS_RFS_SELECT_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_RFS_SELECT_RES",
100 [MSG_SMS_MB_GET_VER_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_MB_GET_VER_REQ",
101 [MSG_SMS_MB_GET_VER_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_MB_GET_VER_RES",
102 [MSG_SMS_MB_WRITE_CFGFILE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_MB_WRITE_CFGFILE_REQ",
103 [MSG_SMS_MB_WRITE_CFGFILE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_MB_WRITE_CFGFILE_RES",
104 [MSG_SMS_MB_READ_CFGFILE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_MB_READ_CFGFILE_REQ",
105 [MSG_SMS_MB_READ_CFGFILE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_MB_READ_CFGFILE_RES",
106 [MSG_SMS_RD_MEM_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_RD_MEM_REQ",
107 [MSG_SMS_RD_MEM_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_RD_MEM_RES",
108 [MSG_SMS_WR_MEM_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_WR_MEM_REQ",
109 [MSG_SMS_WR_MEM_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_WR_MEM_RES",
110 [MSG_SMS_UPDATE_MEM_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_UPDATE_MEM_REQ",
111 [MSG_SMS_UPDATE_MEM_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_UPDATE_MEM_RES",
112 [MSG_SMS_ISDBT_ENABLE_FULL_PARAMS_SET_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_ISDBT_ENABLE_FULL_PARAMS_SET_REQ",
113 [MSG_SMS_ISDBT_ENABLE_FULL_PARAMS_SET_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_ISDBT_ENABLE_FULL_PARAMS_SET_RES",
114 [MSG_SMS_RF_TUNE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_RF_TUNE_REQ",
115 [MSG_SMS_RF_TUNE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_RF_TUNE_RES",
116 [MSG_SMS_ISDBT_ENABLE_HIGH_MOBILITY_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_ISDBT_ENABLE_HIGH_MOBILITY_REQ",
117 [MSG_SMS_ISDBT_ENABLE_HIGH_MOBILITY_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_ISDBT_ENABLE_HIGH_MOBILITY_RES",
118 [MSG_SMS_ISDBT_SB_RECEPTION_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_ISDBT_SB_RECEPTION_REQ",
119 [MSG_SMS_ISDBT_SB_RECEPTION_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_ISDBT_SB_RECEPTION_RES",
120 [MSG_SMS_GENERIC_EPROM_WRITE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_GENERIC_EPROM_WRITE_REQ",
121 [MSG_SMS_GENERIC_EPROM_WRITE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_GENERIC_EPROM_WRITE_RES",
122 [MSG_SMS_GENERIC_EPROM_READ_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_GENERIC_EPROM_READ_REQ",
123 [MSG_SMS_GENERIC_EPROM_READ_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_GENERIC_EPROM_READ_RES",
124 [MSG_SMS_EEPROM_WRITE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_EEPROM_WRITE_REQ",
125 [MSG_SMS_EEPROM_WRITE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_EEPROM_WRITE_RES",
126 [MSG_SMS_CUSTOM_READ_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_CUSTOM_READ_REQ",
127 [MSG_SMS_CUSTOM_READ_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_CUSTOM_READ_RES",
128 [MSG_SMS_CUSTOM_WRITE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_CUSTOM_WRITE_REQ",
129 [MSG_SMS_CUSTOM_WRITE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_CUSTOM_WRITE_RES",
130 [MSG_SMS_INIT_DEVICE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_INIT_DEVICE_REQ",
131 [MSG_SMS_INIT_DEVICE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_INIT_DEVICE_RES",
132 [MSG_SMS_ATSC_SET_ALL_IP_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_ATSC_SET_ALL_IP_REQ",
133 [MSG_SMS_ATSC_SET_ALL_IP_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_ATSC_SET_ALL_IP_RES",
134 [MSG_SMS_ATSC_START_ENSEMBLE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_ATSC_START_ENSEMBLE_REQ",
135 [MSG_SMS_ATSC_START_ENSEMBLE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_ATSC_START_ENSEMBLE_RES",
136 [MSG_SMS_SET_OUTPUT_MODE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_SET_OUTPUT_MODE_REQ",
137 [MSG_SMS_SET_OUTPUT_MODE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_SET_OUTPUT_MODE_RES",
138 [MSG_SMS_ATSC_IP_FILTER_GET_LIST_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_ATSC_IP_FILTER_GET_LIST_REQ",
139 [MSG_SMS_ATSC_IP_FILTER_GET_LIST_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_ATSC_IP_FILTER_GET_LIST_RES",
140 [MSG_SMS_SUB_CHANNEL_START_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_SUB_CHANNEL_START_REQ",
141 [MSG_SMS_SUB_CHANNEL_START_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_SUB_CHANNEL_START_RES",
142 [MSG_SMS_SUB_CHANNEL_STOP_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_SUB_CHANNEL_STOP_REQ",
143 [MSG_SMS_SUB_CHANNEL_STOP_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_SUB_CHANNEL_STOP_RES",
144 [MSG_SMS_ATSC_IP_FILTER_ADD_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_ATSC_IP_FILTER_ADD_REQ",
145 [MSG_SMS_ATSC_IP_FILTER_ADD_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_ATSC_IP_FILTER_ADD_RES",
146 [MSG_SMS_ATSC_IP_FILTER_REMOVE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_ATSC_IP_FILTER_REMOVE_REQ",
147 [MSG_SMS_ATSC_IP_FILTER_REMOVE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_ATSC_IP_FILTER_REMOVE_RES",
148 [MSG_SMS_ATSC_IP_FILTER_REMOVE_ALL_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_ATSC_IP_FILTER_REMOVE_ALL_REQ",
149 [MSG_SMS_ATSC_IP_FILTER_REMOVE_ALL_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_ATSC_IP_FILTER_REMOVE_ALL_RES",
150 [MSG_SMS_WAIT_CMD - MSG_TYPE_BASE_VAL] = "MSG_SMS_WAIT_CMD",
151 [MSG_SMS_ADD_PID_FILTER_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_ADD_PID_FILTER_REQ",
152 [MSG_SMS_ADD_PID_FILTER_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_ADD_PID_FILTER_RES",
153 [MSG_SMS_REMOVE_PID_FILTER_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_REMOVE_PID_FILTER_REQ",
154 [MSG_SMS_REMOVE_PID_FILTER_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_REMOVE_PID_FILTER_RES",
155 [MSG_SMS_FAST_INFORMATION_CHANNEL_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_FAST_INFORMATION_CHANNEL_REQ",
156 [MSG_SMS_FAST_INFORMATION_CHANNEL_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_FAST_INFORMATION_CHANNEL_RES",
157 [MSG_SMS_DAB_CHANNEL - MSG_TYPE_BASE_VAL] = "MSG_SMS_DAB_CHANNEL",
158 [MSG_SMS_GET_PID_FILTER_LIST_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_GET_PID_FILTER_LIST_REQ",
159 [MSG_SMS_GET_PID_FILTER_LIST_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_GET_PID_FILTER_LIST_RES",
160 [MSG_SMS_POWER_DOWN_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_POWER_DOWN_REQ",
161 [MSG_SMS_POWER_DOWN_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_POWER_DOWN_RES",
162 [MSG_SMS_ATSC_SLT_EXIST_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_ATSC_SLT_EXIST_IND",
163 [MSG_SMS_ATSC_NO_SLT_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_ATSC_NO_SLT_IND",
164 [MSG_SMS_GET_STATISTICS_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_GET_STATISTICS_REQ",
165 [MSG_SMS_GET_STATISTICS_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_GET_STATISTICS_RES",
166 [MSG_SMS_SEND_DUMP - MSG_TYPE_BASE_VAL] = "MSG_SMS_SEND_DUMP",
167 [MSG_SMS_SCAN_START_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_SCAN_START_REQ",
168 [MSG_SMS_SCAN_START_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_SCAN_START_RES",
169 [MSG_SMS_SCAN_STOP_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_SCAN_STOP_REQ",
170 [MSG_SMS_SCAN_STOP_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_SCAN_STOP_RES",
171 [MSG_SMS_SCAN_PROGRESS_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_SCAN_PROGRESS_IND",
172 [MSG_SMS_SCAN_COMPLETE_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_SCAN_COMPLETE_IND",
173 [MSG_SMS_LOG_ITEM - MSG_TYPE_BASE_VAL] = "MSG_SMS_LOG_ITEM",
174 [MSG_SMS_DAB_SUBCHANNEL_RECONFIG_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_DAB_SUBCHANNEL_RECONFIG_REQ",
175 [MSG_SMS_DAB_SUBCHANNEL_RECONFIG_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_DAB_SUBCHANNEL_RECONFIG_RES",
176 [MSG_SMS_HO_PER_SLICES_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_HO_PER_SLICES_IND",
177 [MSG_SMS_HO_INBAND_POWER_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_HO_INBAND_POWER_IND",
178 [MSG_SMS_MANUAL_DEMOD_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_MANUAL_DEMOD_REQ",
179 [MSG_SMS_HO_TUNE_ON_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_HO_TUNE_ON_REQ",
180 [MSG_SMS_HO_TUNE_ON_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_HO_TUNE_ON_RES",
181 [MSG_SMS_HO_TUNE_OFF_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_HO_TUNE_OFF_REQ",
182 [MSG_SMS_HO_TUNE_OFF_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_HO_TUNE_OFF_RES",
183 [MSG_SMS_HO_PEEK_FREQ_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_HO_PEEK_FREQ_REQ",
184 [MSG_SMS_HO_PEEK_FREQ_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_HO_PEEK_FREQ_RES",
185 [MSG_SMS_HO_PEEK_FREQ_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_HO_PEEK_FREQ_IND",
186 [MSG_SMS_MB_ATTEN_SET_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_MB_ATTEN_SET_REQ",
187 [MSG_SMS_MB_ATTEN_SET_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_MB_ATTEN_SET_RES",
188 [MSG_SMS_ENABLE_STAT_IN_I2C_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_ENABLE_STAT_IN_I2C_REQ",
189 [MSG_SMS_ENABLE_STAT_IN_I2C_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_ENABLE_STAT_IN_I2C_RES",
190 [MSG_SMS_SET_ANTENNA_CONFIG_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_SET_ANTENNA_CONFIG_REQ",
191 [MSG_SMS_SET_ANTENNA_CONFIG_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_SET_ANTENNA_CONFIG_RES",
192 [MSG_SMS_GET_STATISTICS_EX_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_GET_STATISTICS_EX_REQ",
193 [MSG_SMS_GET_STATISTICS_EX_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_GET_STATISTICS_EX_RES",
194 [MSG_SMS_SLEEP_RESUME_COMP_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_SLEEP_RESUME_COMP_IND",
195 [MSG_SMS_SWITCH_HOST_INTERFACE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_SWITCH_HOST_INTERFACE_REQ",
196 [MSG_SMS_SWITCH_HOST_INTERFACE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_SWITCH_HOST_INTERFACE_RES",
197 [MSG_SMS_DATA_DOWNLOAD_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_DATA_DOWNLOAD_REQ",
198 [MSG_SMS_DATA_DOWNLOAD_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_DATA_DOWNLOAD_RES",
199 [MSG_SMS_DATA_VALIDITY_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_DATA_VALIDITY_REQ",
200 [MSG_SMS_DATA_VALIDITY_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_DATA_VALIDITY_RES",
201 [MSG_SMS_SWDOWNLOAD_TRIGGER_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_SWDOWNLOAD_TRIGGER_REQ",
202 [MSG_SMS_SWDOWNLOAD_TRIGGER_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_SWDOWNLOAD_TRIGGER_RES",
203 [MSG_SMS_SWDOWNLOAD_BACKDOOR_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_SWDOWNLOAD_BACKDOOR_REQ",
204 [MSG_SMS_SWDOWNLOAD_BACKDOOR_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_SWDOWNLOAD_BACKDOOR_RES",
205 [MSG_SMS_GET_VERSION_EX_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_GET_VERSION_EX_REQ",
206 [MSG_SMS_GET_VERSION_EX_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_GET_VERSION_EX_RES",
207 [MSG_SMS_CLOCK_OUTPUT_CONFIG_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_CLOCK_OUTPUT_CONFIG_REQ",
208 [MSG_SMS_CLOCK_OUTPUT_CONFIG_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_CLOCK_OUTPUT_CONFIG_RES",
209 [MSG_SMS_I2C_SET_FREQ_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_I2C_SET_FREQ_REQ",
210 [MSG_SMS_I2C_SET_FREQ_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_I2C_SET_FREQ_RES",
211 [MSG_SMS_GENERIC_I2C_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_GENERIC_I2C_REQ",
212 [MSG_SMS_GENERIC_I2C_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_GENERIC_I2C_RES",
213 [MSG_SMS_DVBT_BDA_DATA - MSG_TYPE_BASE_VAL] = "MSG_SMS_DVBT_BDA_DATA",
214 [MSG_SW_RELOAD_REQ - MSG_TYPE_BASE_VAL] = "MSG_SW_RELOAD_REQ",
215 [MSG_SMS_DATA_MSG - MSG_TYPE_BASE_VAL] = "MSG_SMS_DATA_MSG",
216 [MSG_TABLE_UPLOAD_REQ - MSG_TYPE_BASE_VAL] = "MSG_TABLE_UPLOAD_REQ",
217 [MSG_TABLE_UPLOAD_RES - MSG_TYPE_BASE_VAL] = "MSG_TABLE_UPLOAD_RES",
218 [MSG_SW_RELOAD_START_REQ - MSG_TYPE_BASE_VAL] = "MSG_SW_RELOAD_START_REQ",
219 [MSG_SW_RELOAD_START_RES - MSG_TYPE_BASE_VAL] = "MSG_SW_RELOAD_START_RES",
220 [MSG_SW_RELOAD_EXEC_REQ - MSG_TYPE_BASE_VAL] = "MSG_SW_RELOAD_EXEC_REQ",
221 [MSG_SW_RELOAD_EXEC_RES - MSG_TYPE_BASE_VAL] = "MSG_SW_RELOAD_EXEC_RES",
222 [MSG_SMS_SPI_INT_LINE_SET_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_SPI_INT_LINE_SET_REQ",
223 [MSG_SMS_SPI_INT_LINE_SET_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_SPI_INT_LINE_SET_RES",
224 [MSG_SMS_GPIO_CONFIG_EX_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_GPIO_CONFIG_EX_REQ",
225 [MSG_SMS_GPIO_CONFIG_EX_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_GPIO_CONFIG_EX_RES",
226 [MSG_SMS_WATCHDOG_ACT_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_WATCHDOG_ACT_REQ",
227 [MSG_SMS_WATCHDOG_ACT_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_WATCHDOG_ACT_RES",
228 [MSG_SMS_LOOPBACK_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_LOOPBACK_REQ",
229 [MSG_SMS_LOOPBACK_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_LOOPBACK_RES",
230 [MSG_SMS_RAW_CAPTURE_START_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_RAW_CAPTURE_START_REQ",
231 [MSG_SMS_RAW_CAPTURE_START_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_RAW_CAPTURE_START_RES",
232 [MSG_SMS_RAW_CAPTURE_ABORT_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_RAW_CAPTURE_ABORT_REQ",
233 [MSG_SMS_RAW_CAPTURE_ABORT_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_RAW_CAPTURE_ABORT_RES",
234 [MSG_SMS_RAW_CAPTURE_COMPLETE_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_RAW_CAPTURE_COMPLETE_IND",
235 [MSG_SMS_DATA_PUMP_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_DATA_PUMP_IND",
236 [MSG_SMS_DATA_PUMP_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_DATA_PUMP_REQ",
237 [MSG_SMS_DATA_PUMP_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_DATA_PUMP_RES",
238 [MSG_SMS_FLASH_DL_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_FLASH_DL_REQ",
239 [MSG_SMS_EXEC_TEST_1_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_EXEC_TEST_1_REQ",
240 [MSG_SMS_EXEC_TEST_1_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_EXEC_TEST_1_RES",
241 [MSG_SMS_ENBALE_TS_INTERFACE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_ENBALE_TS_INTERFACE_REQ",
242 [MSG_SMS_ENBALE_TS_INTERFACE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_ENBALE_TS_INTERFACE_RES",
243 [MSG_SMS_SPI_SET_BUS_WIDTH_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_SPI_SET_BUS_WIDTH_REQ",
244 [MSG_SMS_SPI_SET_BUS_WIDTH_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_SPI_SET_BUS_WIDTH_RES",
245 [MSG_SMS_SEND_EMM_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_SEND_EMM_REQ",
246 [MSG_SMS_SEND_EMM_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_SEND_EMM_RES",
247 [MSG_SMS_DISABLE_TS_INTERFACE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_DISABLE_TS_INTERFACE_REQ",
248 [MSG_SMS_DISABLE_TS_INTERFACE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_DISABLE_TS_INTERFACE_RES",
249 [MSG_SMS_IS_BUF_FREE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_IS_BUF_FREE_REQ",
250 [MSG_SMS_IS_BUF_FREE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_IS_BUF_FREE_RES",
251 [MSG_SMS_EXT_ANTENNA_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_EXT_ANTENNA_REQ",
252 [MSG_SMS_EXT_ANTENNA_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_EXT_ANTENNA_RES",
253 [MSG_SMS_CMMB_GET_NET_OF_FREQ_REQ_OBSOLETE - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_GET_NET_OF_FREQ_REQ_OBSOLETE",
254 [MSG_SMS_CMMB_GET_NET_OF_FREQ_RES_OBSOLETE - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_GET_NET_OF_FREQ_RES_OBSOLETE",
255 [MSG_SMS_BATTERY_LEVEL_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_BATTERY_LEVEL_REQ",
256 [MSG_SMS_BATTERY_LEVEL_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_BATTERY_LEVEL_RES",
257 [MSG_SMS_CMMB_INJECT_TABLE_REQ_OBSOLETE - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_INJECT_TABLE_REQ_OBSOLETE",
258 [MSG_SMS_CMMB_INJECT_TABLE_RES_OBSOLETE - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_INJECT_TABLE_RES_OBSOLETE",
259 [MSG_SMS_FM_RADIO_BLOCK_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_FM_RADIO_BLOCK_IND",
260 [MSG_SMS_HOST_NOTIFICATION_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_HOST_NOTIFICATION_IND",
261 [MSG_SMS_CMMB_GET_CONTROL_TABLE_REQ_OBSOLETE - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_GET_CONTROL_TABLE_REQ_OBSOLETE",
262 [MSG_SMS_CMMB_GET_CONTROL_TABLE_RES_OBSOLETE - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_GET_CONTROL_TABLE_RES_OBSOLETE",
263 [MSG_SMS_CMMB_GET_NETWORKS_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_GET_NETWORKS_REQ",
264 [MSG_SMS_CMMB_GET_NETWORKS_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_GET_NETWORKS_RES",
265 [MSG_SMS_CMMB_START_SERVICE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_START_SERVICE_REQ",
266 [MSG_SMS_CMMB_START_SERVICE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_START_SERVICE_RES",
267 [MSG_SMS_CMMB_STOP_SERVICE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_STOP_SERVICE_REQ",
268 [MSG_SMS_CMMB_STOP_SERVICE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_STOP_SERVICE_RES",
269 [MSG_SMS_CMMB_ADD_CHANNEL_FILTER_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_ADD_CHANNEL_FILTER_REQ",
270 [MSG_SMS_CMMB_ADD_CHANNEL_FILTER_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_ADD_CHANNEL_FILTER_RES",
271 [MSG_SMS_CMMB_REMOVE_CHANNEL_FILTER_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_REMOVE_CHANNEL_FILTER_REQ",
272 [MSG_SMS_CMMB_REMOVE_CHANNEL_FILTER_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_REMOVE_CHANNEL_FILTER_RES",
273 [MSG_SMS_CMMB_START_CONTROL_INFO_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_START_CONTROL_INFO_REQ",
274 [MSG_SMS_CMMB_START_CONTROL_INFO_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_START_CONTROL_INFO_RES",
275 [MSG_SMS_CMMB_STOP_CONTROL_INFO_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_STOP_CONTROL_INFO_REQ",
276 [MSG_SMS_CMMB_STOP_CONTROL_INFO_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_STOP_CONTROL_INFO_RES",
277 [MSG_SMS_ISDBT_TUNE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_ISDBT_TUNE_REQ",
278 [MSG_SMS_ISDBT_TUNE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_ISDBT_TUNE_RES",
279 [MSG_SMS_TRANSMISSION_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_TRANSMISSION_IND",
280 [MSG_SMS_PID_STATISTICS_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_PID_STATISTICS_IND",
281 [MSG_SMS_POWER_DOWN_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_POWER_DOWN_IND",
282 [MSG_SMS_POWER_DOWN_CONF - MSG_TYPE_BASE_VAL] = "MSG_SMS_POWER_DOWN_CONF",
283 [MSG_SMS_POWER_UP_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_POWER_UP_IND",
284 [MSG_SMS_POWER_UP_CONF - MSG_TYPE_BASE_VAL] = "MSG_SMS_POWER_UP_CONF",
285 [MSG_SMS_POWER_MODE_SET_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_POWER_MODE_SET_REQ",
286 [MSG_SMS_POWER_MODE_SET_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_POWER_MODE_SET_RES",
287 [MSG_SMS_DEBUG_HOST_EVENT_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_DEBUG_HOST_EVENT_REQ",
288 [MSG_SMS_DEBUG_HOST_EVENT_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_DEBUG_HOST_EVENT_RES",
289 [MSG_SMS_NEW_CRYSTAL_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_NEW_CRYSTAL_REQ",
290 [MSG_SMS_NEW_CRYSTAL_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_NEW_CRYSTAL_RES",
291 [MSG_SMS_CONFIG_SPI_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_CONFIG_SPI_REQ",
292 [MSG_SMS_CONFIG_SPI_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_CONFIG_SPI_RES",
293 [MSG_SMS_I2C_SHORT_STAT_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_I2C_SHORT_STAT_IND",
294 [MSG_SMS_START_IR_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_START_IR_REQ",
295 [MSG_SMS_START_IR_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_START_IR_RES",
296 [MSG_SMS_IR_SAMPLES_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_IR_SAMPLES_IND",
297 [MSG_SMS_CMMB_CA_SERVICE_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_CA_SERVICE_IND",
298 [MSG_SMS_SLAVE_DEVICE_DETECTED - MSG_TYPE_BASE_VAL] = "MSG_SMS_SLAVE_DEVICE_DETECTED",
299 [MSG_SMS_INTERFACE_LOCK_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_INTERFACE_LOCK_IND",
300 [MSG_SMS_INTERFACE_UNLOCK_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_INTERFACE_UNLOCK_IND",
301 [MSG_SMS_SEND_ROSUM_BUFF_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_SEND_ROSUM_BUFF_REQ",
302 [MSG_SMS_SEND_ROSUM_BUFF_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_SEND_ROSUM_BUFF_RES",
303 [MSG_SMS_ROSUM_BUFF - MSG_TYPE_BASE_VAL] = "MSG_SMS_ROSUM_BUFF",
304 [MSG_SMS_SET_AES128_KEY_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_SET_AES128_KEY_REQ",
305 [MSG_SMS_SET_AES128_KEY_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_SET_AES128_KEY_RES",
306 [MSG_SMS_MBBMS_WRITE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_MBBMS_WRITE_REQ",
307 [MSG_SMS_MBBMS_WRITE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_MBBMS_WRITE_RES",
308 [MSG_SMS_MBBMS_READ_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_MBBMS_READ_IND",
309 [MSG_SMS_IQ_STREAM_START_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_IQ_STREAM_START_REQ",
310 [MSG_SMS_IQ_STREAM_START_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_IQ_STREAM_START_RES",
311 [MSG_SMS_IQ_STREAM_STOP_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_IQ_STREAM_STOP_REQ",
312 [MSG_SMS_IQ_STREAM_STOP_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_IQ_STREAM_STOP_RES",
313 [MSG_SMS_IQ_STREAM_DATA_BLOCK - MSG_TYPE_BASE_VAL] = "MSG_SMS_IQ_STREAM_DATA_BLOCK",
314 [MSG_SMS_GET_EEPROM_VERSION_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_GET_EEPROM_VERSION_REQ",
315 [MSG_SMS_GET_EEPROM_VERSION_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_GET_EEPROM_VERSION_RES",
316 [MSG_SMS_SIGNAL_DETECTED_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_SIGNAL_DETECTED_IND",
317 [MSG_SMS_NO_SIGNAL_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_NO_SIGNAL_IND",
318 [MSG_SMS_MRC_SHUTDOWN_SLAVE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_MRC_SHUTDOWN_SLAVE_REQ",
319 [MSG_SMS_MRC_SHUTDOWN_SLAVE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_MRC_SHUTDOWN_SLAVE_RES",
320 [MSG_SMS_MRC_BRINGUP_SLAVE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_MRC_BRINGUP_SLAVE_REQ",
321 [MSG_SMS_MRC_BRINGUP_SLAVE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_MRC_BRINGUP_SLAVE_RES",
322 [MSG_SMS_EXTERNAL_LNA_CTRL_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_EXTERNAL_LNA_CTRL_REQ",
323 [MSG_SMS_EXTERNAL_LNA_CTRL_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_EXTERNAL_LNA_CTRL_RES",
324 [MSG_SMS_SET_PERIODIC_STATISTICS_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_SET_PERIODIC_STATISTICS_REQ",
325 [MSG_SMS_SET_PERIODIC_STATISTICS_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_SET_PERIODIC_STATISTICS_RES",
326 [MSG_SMS_CMMB_SET_AUTO_OUTPUT_TS0_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_SET_AUTO_OUTPUT_TS0_REQ",
327 [MSG_SMS_CMMB_SET_AUTO_OUTPUT_TS0_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_SET_AUTO_OUTPUT_TS0_RES",
328 [LOCAL_TUNE - MSG_TYPE_BASE_VAL] = "LOCAL_TUNE",
329 [LOCAL_IFFT_H_ICI - MSG_TYPE_BASE_VAL] = "LOCAL_IFFT_H_ICI",
330 [MSG_RESYNC_REQ - MSG_TYPE_BASE_VAL] = "MSG_RESYNC_REQ",
331 [MSG_SMS_CMMB_GET_MRC_STATISTICS_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_GET_MRC_STATISTICS_REQ",
332 [MSG_SMS_CMMB_GET_MRC_STATISTICS_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_GET_MRC_STATISTICS_RES",
333 [MSG_SMS_LOG_EX_ITEM - MSG_TYPE_BASE_VAL] = "MSG_SMS_LOG_EX_ITEM",
334 [MSG_SMS_DEVICE_DATA_LOSS_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_DEVICE_DATA_LOSS_IND",
335 [MSG_SMS_MRC_WATCHDOG_TRIGGERED_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_MRC_WATCHDOG_TRIGGERED_IND",
336 [MSG_SMS_USER_MSG_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_USER_MSG_REQ",
337 [MSG_SMS_USER_MSG_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_USER_MSG_RES",
338 [MSG_SMS_SMART_CARD_INIT_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_SMART_CARD_INIT_REQ",
339 [MSG_SMS_SMART_CARD_INIT_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_SMART_CARD_INIT_RES",
340 [MSG_SMS_SMART_CARD_WRITE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_SMART_CARD_WRITE_REQ",
341 [MSG_SMS_SMART_CARD_WRITE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_SMART_CARD_WRITE_RES",
342 [MSG_SMS_SMART_CARD_READ_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_SMART_CARD_READ_IND",
343 [MSG_SMS_TSE_ENABLE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_TSE_ENABLE_REQ",
344 [MSG_SMS_TSE_ENABLE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_TSE_ENABLE_RES",
345 [MSG_SMS_CMMB_GET_SHORT_STATISTICS_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_GET_SHORT_STATISTICS_REQ",
346 [MSG_SMS_CMMB_GET_SHORT_STATISTICS_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_GET_SHORT_STATISTICS_RES",
347 [MSG_SMS_LED_CONFIG_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_LED_CONFIG_REQ",
348 [MSG_SMS_LED_CONFIG_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_LED_CONFIG_RES",
349 [MSG_PWM_ANTENNA_REQ - MSG_TYPE_BASE_VAL] = "MSG_PWM_ANTENNA_REQ",
350 [MSG_PWM_ANTENNA_RES - MSG_TYPE_BASE_VAL] = "MSG_PWM_ANTENNA_RES",
351 [MSG_SMS_CMMB_SMD_SN_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_SMD_SN_REQ",
352 [MSG_SMS_CMMB_SMD_SN_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_SMD_SN_RES",
353 [MSG_SMS_CMMB_SET_CA_CW_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_SET_CA_CW_REQ",
354 [MSG_SMS_CMMB_SET_CA_CW_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_SET_CA_CW_RES",
355 [MSG_SMS_CMMB_SET_CA_SALT_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_SET_CA_SALT_REQ",
356 [MSG_SMS_CMMB_SET_CA_SALT_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_SET_CA_SALT_RES",
357 [MSG_SMS_NSCD_INIT_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_NSCD_INIT_REQ",
358 [MSG_SMS_NSCD_INIT_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_NSCD_INIT_RES",
359 [MSG_SMS_NSCD_PROCESS_SECTION_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_NSCD_PROCESS_SECTION_REQ",
360 [MSG_SMS_NSCD_PROCESS_SECTION_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_NSCD_PROCESS_SECTION_RES",
361 [MSG_SMS_DBD_CREATE_OBJECT_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_DBD_CREATE_OBJECT_REQ",
362 [MSG_SMS_DBD_CREATE_OBJECT_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_DBD_CREATE_OBJECT_RES",
363 [MSG_SMS_DBD_CONFIGURE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_DBD_CONFIGURE_REQ",
364 [MSG_SMS_DBD_CONFIGURE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_DBD_CONFIGURE_RES",
365 [MSG_SMS_DBD_SET_KEYS_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_DBD_SET_KEYS_REQ",
366 [MSG_SMS_DBD_SET_KEYS_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_DBD_SET_KEYS_RES",
367 [MSG_SMS_DBD_PROCESS_HEADER_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_DBD_PROCESS_HEADER_REQ",
368 [MSG_SMS_DBD_PROCESS_HEADER_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_DBD_PROCESS_HEADER_RES",
369 [MSG_SMS_DBD_PROCESS_DATA_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_DBD_PROCESS_DATA_REQ",
370 [MSG_SMS_DBD_PROCESS_DATA_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_DBD_PROCESS_DATA_RES",
371 [MSG_SMS_DBD_PROCESS_GET_DATA_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_DBD_PROCESS_GET_DATA_REQ",
372 [MSG_SMS_DBD_PROCESS_GET_DATA_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_DBD_PROCESS_GET_DATA_RES",
373 [MSG_SMS_NSCD_OPEN_SESSION_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_NSCD_OPEN_SESSION_REQ",
374 [MSG_SMS_NSCD_OPEN_SESSION_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_NSCD_OPEN_SESSION_RES",
375 [MSG_SMS_SEND_HOST_DATA_TO_DEMUX_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_SEND_HOST_DATA_TO_DEMUX_REQ",
376 [MSG_SMS_SEND_HOST_DATA_TO_DEMUX_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_SEND_HOST_DATA_TO_DEMUX_RES",
377 [MSG_LAST_MSG_TYPE - MSG_TYPE_BASE_VAL] = "MSG_LAST_MSG_TYPE",
378};
379
380char *smscore_translate_msg(enum msg_types msgtype)
381{
382 int i = msgtype - MSG_TYPE_BASE_VAL;
383 char *msg;
384
385 if (i < 0 || i >= ARRAY_SIZE(siano_msgs))
386 return "Unknown msg type";
387
388 msg = siano_msgs[i];
389
390 if (!*msg)
391 return "Unknown msg type";
392
393 return msg;
394}
395EXPORT_SYMBOL_GPL(smscore_translate_msg);
396
397void smscore_set_board_id(struct smscore_device_t *core, int id)
398{
399 core->board_id = id;
400}
401
402int smscore_led_state(struct smscore_device_t *core, int led)
403{
404 if (led >= 0)
405 core->led_state = led;
406 return core->led_state;
407}
408EXPORT_SYMBOL_GPL(smscore_set_board_id);
409
410int smscore_get_board_id(struct smscore_device_t *core)
411{
412 return core->board_id;
413}
414EXPORT_SYMBOL_GPL(smscore_get_board_id);
415
416struct smscore_registry_entry_t {
417 struct list_head entry;
418 char devpath[32];
419 int mode;
420 enum sms_device_type_st type;
421};
422
423static struct list_head g_smscore_notifyees;
424static struct list_head g_smscore_devices;
425static struct mutex g_smscore_deviceslock;
426
427static struct list_head g_smscore_registry;
428static struct mutex g_smscore_registrylock;
429
430static int default_mode = DEVICE_MODE_NONE;
431
432module_param(default_mode, int, 0644);
433MODULE_PARM_DESC(default_mode, "default firmware id (device mode)");
434
435static struct smscore_registry_entry_t *smscore_find_registry(char *devpath)
436{
437 struct smscore_registry_entry_t *entry;
438 struct list_head *next;
439
440 kmutex_lock(&g_smscore_registrylock);
441 for (next = g_smscore_registry.next;
442 next != &g_smscore_registry;
443 next = next->next) {
444 entry = (struct smscore_registry_entry_t *) next;
445 if (!strncmp(entry->devpath, devpath, sizeof(entry->devpath))) {
446 kmutex_unlock(&g_smscore_registrylock);
447 return entry;
448 }
449 }
450 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
451 if (entry) {
452 entry->mode = default_mode;
453 strlcpy(entry->devpath, devpath, sizeof(entry->devpath));
454 list_add(&entry->entry, &g_smscore_registry);
455 } else
456 pr_err("failed to create smscore_registry.\n");
457 kmutex_unlock(&g_smscore_registrylock);
458 return entry;
459}
460
461int smscore_registry_getmode(char *devpath)
462{
463 struct smscore_registry_entry_t *entry;
464
465 entry = smscore_find_registry(devpath);
466 if (entry)
467 return entry->mode;
468 else
469 pr_err("No registry found.\n");
470
471 return default_mode;
472}
473EXPORT_SYMBOL_GPL(smscore_registry_getmode);
474
475static enum sms_device_type_st smscore_registry_gettype(char *devpath)
476{
477 struct smscore_registry_entry_t *entry;
478
479 entry = smscore_find_registry(devpath);
480 if (entry)
481 return entry->type;
482 else
483 pr_err("No registry found.\n");
484
485 return -EINVAL;
486}
487
488static void smscore_registry_setmode(char *devpath, int mode)
489{
490 struct smscore_registry_entry_t *entry;
491
492 entry = smscore_find_registry(devpath);
493 if (entry)
494 entry->mode = mode;
495 else
496 pr_err("No registry found.\n");
497}
498
499static void smscore_registry_settype(char *devpath,
500 enum sms_device_type_st type)
501{
502 struct smscore_registry_entry_t *entry;
503
504 entry = smscore_find_registry(devpath);
505 if (entry)
506 entry->type = type;
507 else
508 pr_err("No registry found.\n");
509}
510
511
512static void list_add_locked(struct list_head *new, struct list_head *head,
513 spinlock_t *lock)
514{
515 unsigned long flags;
516
517 spin_lock_irqsave(lock, flags);
518
519 list_add(new, head);
520
521 spin_unlock_irqrestore(lock, flags);
522}
523
524
525
526
527
528
529
530
531
532int smscore_register_hotplug(hotplug_t hotplug)
533{
534 struct smscore_device_notifyee_t *notifyee;
535 struct list_head *next, *first;
536 int rc = 0;
537
538 kmutex_lock(&g_smscore_deviceslock);
539 notifyee = kmalloc(sizeof(*notifyee), GFP_KERNEL);
540 if (notifyee) {
541
542 first = &g_smscore_devices;
543 for (next = first->next;
544 next != first && !rc;
545 next = next->next) {
546 struct smscore_device_t *coredev =
547 (struct smscore_device_t *) next;
548 rc = hotplug(coredev, coredev->device, 1);
549 }
550
551 if (rc >= 0) {
552 notifyee->hotplug = hotplug;
553 list_add(¬ifyee->entry, &g_smscore_notifyees);
554 } else
555 kfree(notifyee);
556 } else
557 rc = -ENOMEM;
558
559 kmutex_unlock(&g_smscore_deviceslock);
560
561 return rc;
562}
563EXPORT_SYMBOL_GPL(smscore_register_hotplug);
564
565
566
567
568
569
570
571void smscore_unregister_hotplug(hotplug_t hotplug)
572{
573 struct list_head *next, *first;
574
575 kmutex_lock(&g_smscore_deviceslock);
576
577 first = &g_smscore_notifyees;
578
579 for (next = first->next; next != first;) {
580 struct smscore_device_notifyee_t *notifyee =
581 (struct smscore_device_notifyee_t *) next;
582 next = next->next;
583
584 if (notifyee->hotplug == hotplug) {
585 list_del(¬ifyee->entry);
586 kfree(notifyee);
587 }
588 }
589
590 kmutex_unlock(&g_smscore_deviceslock);
591}
592EXPORT_SYMBOL_GPL(smscore_unregister_hotplug);
593
594static void smscore_notify_clients(struct smscore_device_t *coredev)
595{
596 struct smscore_client_t *client;
597
598
599 while (!list_empty(&coredev->clients)) {
600 client = (struct smscore_client_t *) coredev->clients.next;
601 client->onremove_handler(client->context);
602 }
603}
604
605static int smscore_notify_callbacks(struct smscore_device_t *coredev,
606 struct device *device, int arrival)
607{
608 struct smscore_device_notifyee_t *elem;
609 int rc = 0;
610
611
612
613 list_for_each_entry(elem, &g_smscore_notifyees, entry) {
614 rc = elem->hotplug(coredev, device, arrival);
615 if (rc < 0)
616 break;
617 }
618
619 return rc;
620}
621
622static struct
623smscore_buffer_t *smscore_createbuffer(u8 *buffer, void *common_buffer,
624 dma_addr_t common_buffer_phys)
625{
626 struct smscore_buffer_t *cb;
627
628 cb = kzalloc(sizeof(*cb), GFP_KERNEL);
629 if (!cb)
630 return NULL;
631
632 cb->p = buffer;
633 cb->offset_in_common = buffer - (u8 *) common_buffer;
634 if (common_buffer_phys)
635 cb->phys = common_buffer_phys + cb->offset_in_common;
636
637 return cb;
638}
639
640
641
642
643
644
645
646
647
648
649
650int smscore_register_device(struct smsdevice_params_t *params,
651 struct smscore_device_t **coredev,
652 gfp_t gfp_buf_flags,
653 void *mdev)
654{
655 struct smscore_device_t *dev;
656 u8 *buffer;
657
658 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
659 if (!dev)
660 return -ENOMEM;
661
662#ifdef CONFIG_MEDIA_CONTROLLER_DVB
663 dev->media_dev = mdev;
664#endif
665 dev->gfp_buf_flags = gfp_buf_flags;
666
667
668 INIT_LIST_HEAD(&dev->entry);
669
670
671 INIT_LIST_HEAD(&dev->clients);
672 INIT_LIST_HEAD(&dev->buffers);
673
674
675 spin_lock_init(&dev->clientslock);
676 spin_lock_init(&dev->bufferslock);
677
678
679 init_completion(&dev->version_ex_done);
680 init_completion(&dev->data_download_done);
681 init_completion(&dev->data_validity_done);
682 init_completion(&dev->trigger_done);
683 init_completion(&dev->init_device_done);
684 init_completion(&dev->reload_start_done);
685 init_completion(&dev->resume_done);
686 init_completion(&dev->gpio_configuration_done);
687 init_completion(&dev->gpio_set_level_done);
688 init_completion(&dev->gpio_get_level_done);
689 init_completion(&dev->ir_init_done);
690
691
692 init_waitqueue_head(&dev->buffer_mng_waitq);
693
694
695 dev->common_buffer_size = params->buffer_size * params->num_buffers;
696 if (params->usb_device)
697 buffer = kzalloc(dev->common_buffer_size, GFP_KERNEL);
698 else
699 buffer = dma_alloc_coherent(params->device,
700 dev->common_buffer_size,
701 &dev->common_buffer_phys,
702 GFP_KERNEL | dev->gfp_buf_flags);
703 if (!buffer) {
704 smscore_unregister_device(dev);
705 return -ENOMEM;
706 }
707 dev->common_buffer = buffer;
708
709
710 for (; dev->num_buffers < params->num_buffers;
711 dev->num_buffers++, buffer += params->buffer_size) {
712 struct smscore_buffer_t *cb;
713
714 cb = smscore_createbuffer(buffer, dev->common_buffer,
715 dev->common_buffer_phys);
716 if (!cb) {
717 smscore_unregister_device(dev);
718 return -ENOMEM;
719 }
720
721 smscore_putbuffer(dev, cb);
722 }
723
724 pr_debug("allocated %d buffers\n", dev->num_buffers);
725
726 dev->mode = DEVICE_MODE_NONE;
727 dev->board_id = SMS_BOARD_UNKNOWN;
728 dev->context = params->context;
729 dev->device = params->device;
730 dev->usb_device = params->usb_device;
731 dev->setmode_handler = params->setmode_handler;
732 dev->detectmode_handler = params->detectmode_handler;
733 dev->sendrequest_handler = params->sendrequest_handler;
734 dev->preload_handler = params->preload_handler;
735 dev->postload_handler = params->postload_handler;
736
737 dev->device_flags = params->flags;
738 strlcpy(dev->devpath, params->devpath, sizeof(dev->devpath));
739
740 smscore_registry_settype(dev->devpath, params->device_type);
741
742
743 kmutex_lock(&g_smscore_deviceslock);
744 list_add(&dev->entry, &g_smscore_devices);
745 kmutex_unlock(&g_smscore_deviceslock);
746
747 *coredev = dev;
748
749 pr_debug("device %p created\n", dev);
750
751 return 0;
752}
753EXPORT_SYMBOL_GPL(smscore_register_device);
754
755
756static int smscore_sendrequest_and_wait(struct smscore_device_t *coredev,
757 void *buffer, size_t size, struct completion *completion) {
758 int rc;
759
760 if (!completion)
761 return -EINVAL;
762 init_completion(completion);
763
764 rc = coredev->sendrequest_handler(coredev->context, buffer, size);
765 if (rc < 0) {
766 pr_info("sendrequest returned error %d\n", rc);
767 return rc;
768 }
769
770 return wait_for_completion_timeout(completion,
771 msecs_to_jiffies(SMS_PROTOCOL_MAX_RAOUNDTRIP_MS)) ?
772 0 : -ETIME;
773}
774
775
776
777
778
779
780static int smscore_init_ir(struct smscore_device_t *coredev)
781{
782 int ir_io;
783 int rc;
784 void *buffer;
785
786 coredev->ir.dev = NULL;
787 ir_io = sms_get_board(smscore_get_board_id(coredev))->board_cfg.ir;
788 if (ir_io) {
789 pr_debug("IR loading\n");
790 rc = sms_ir_init(coredev);
791
792 if (rc != 0)
793 pr_err("Error initialization DTV IR sub-module\n");
794 else {
795 buffer = kmalloc(sizeof(struct sms_msg_data2) +
796 SMS_DMA_ALIGNMENT,
797 GFP_KERNEL | coredev->gfp_buf_flags);
798 if (buffer) {
799 struct sms_msg_data2 *msg =
800 (struct sms_msg_data2 *)
801 SMS_ALIGN_ADDRESS(buffer);
802
803 SMS_INIT_MSG(&msg->x_msg_header,
804 MSG_SMS_START_IR_REQ,
805 sizeof(struct sms_msg_data2));
806 msg->msg_data[0] = coredev->ir.controller;
807 msg->msg_data[1] = coredev->ir.timeout;
808
809 rc = smscore_sendrequest_and_wait(coredev, msg,
810 msg->x_msg_header. msg_length,
811 &coredev->ir_init_done);
812
813 kfree(buffer);
814 } else
815 pr_err("Sending IR initialization message failed\n");
816 }
817 } else
818 pr_info("IR port has not been detected\n");
819
820 return 0;
821}
822
823
824
825
826
827
828
829
830
831static int smscore_configure_board(struct smscore_device_t *coredev)
832{
833 struct sms_board *board;
834
835 board = sms_get_board(coredev->board_id);
836 if (!board) {
837 pr_err("no board configuration exist.\n");
838 return -EINVAL;
839 }
840
841 if (board->mtu) {
842 struct sms_msg_data mtu_msg;
843 pr_debug("set max transmit unit %d\n", board->mtu);
844
845 mtu_msg.x_msg_header.msg_src_id = 0;
846 mtu_msg.x_msg_header.msg_dst_id = HIF_TASK;
847 mtu_msg.x_msg_header.msg_flags = 0;
848 mtu_msg.x_msg_header.msg_type = MSG_SMS_SET_MAX_TX_MSG_LEN_REQ;
849 mtu_msg.x_msg_header.msg_length = sizeof(mtu_msg);
850 mtu_msg.msg_data[0] = board->mtu;
851
852 coredev->sendrequest_handler(coredev->context, &mtu_msg,
853 sizeof(mtu_msg));
854 }
855
856 if (board->crystal) {
857 struct sms_msg_data crys_msg;
858 pr_debug("set crystal value %d\n", board->crystal);
859
860 SMS_INIT_MSG(&crys_msg.x_msg_header,
861 MSG_SMS_NEW_CRYSTAL_REQ,
862 sizeof(crys_msg));
863 crys_msg.msg_data[0] = board->crystal;
864
865 coredev->sendrequest_handler(coredev->context, &crys_msg,
866 sizeof(crys_msg));
867 }
868
869 return 0;
870}
871
872
873
874
875
876
877
878
879
880int smscore_start_device(struct smscore_device_t *coredev)
881{
882 int rc;
883 int board_id = smscore_get_board_id(coredev);
884 int mode = smscore_registry_getmode(coredev->devpath);
885
886
887 if (board_id != SMS_BOARD_UNKNOWN && mode == DEVICE_MODE_NONE)
888 mode = sms_get_board(board_id)->default_mode;
889
890 rc = smscore_set_device_mode(coredev, mode);
891 if (rc < 0) {
892 pr_info("set device mode failed , rc %d\n", rc);
893 return rc;
894 }
895 rc = smscore_configure_board(coredev);
896 if (rc < 0) {
897 pr_info("configure board failed , rc %d\n", rc);
898 return rc;
899 }
900
901 kmutex_lock(&g_smscore_deviceslock);
902
903 rc = smscore_notify_callbacks(coredev, coredev->device, 1);
904 smscore_init_ir(coredev);
905
906 pr_debug("device %p started, rc %d\n", coredev, rc);
907
908 kmutex_unlock(&g_smscore_deviceslock);
909
910 return rc;
911}
912EXPORT_SYMBOL_GPL(smscore_start_device);
913
914
915static int smscore_load_firmware_family2(struct smscore_device_t *coredev,
916 void *buffer, size_t size)
917{
918 struct sms_firmware *firmware = (struct sms_firmware *) buffer;
919 struct sms_msg_data4 *msg;
920 u32 mem_address, calc_checksum = 0;
921 u32 i, *ptr;
922 u8 *payload = firmware->payload;
923 int rc = 0;
924 firmware->start_address = le32_to_cpup((__le32 *)&firmware->start_address);
925 firmware->length = le32_to_cpup((__le32 *)&firmware->length);
926
927 mem_address = firmware->start_address;
928
929 pr_debug("loading FW to addr 0x%x size %d\n",
930 mem_address, firmware->length);
931 if (coredev->preload_handler) {
932 rc = coredev->preload_handler(coredev->context);
933 if (rc < 0)
934 return rc;
935 }
936
937
938 msg = kmalloc(PAGE_SIZE, GFP_KERNEL | coredev->gfp_buf_flags);
939 if (!msg)
940 return -ENOMEM;
941
942 if (coredev->mode != DEVICE_MODE_NONE) {
943 pr_debug("sending reload command.\n");
944 SMS_INIT_MSG(&msg->x_msg_header, MSG_SW_RELOAD_START_REQ,
945 sizeof(struct sms_msg_hdr));
946 rc = smscore_sendrequest_and_wait(coredev, msg,
947 msg->x_msg_header.msg_length,
948 &coredev->reload_start_done);
949 if (rc < 0) {
950 pr_err("device reload failed, rc %d\n", rc);
951 goto exit_fw_download;
952 }
953 mem_address = *(u32 *) &payload[20];
954 }
955
956 for (i = 0, ptr = (u32 *)firmware->payload; i < firmware->length/4 ;
957 i++, ptr++)
958 calc_checksum += *ptr;
959
960 while (size && rc >= 0) {
961 struct sms_data_download *data_msg =
962 (struct sms_data_download *) msg;
963 int payload_size = min_t(int, size, SMS_MAX_PAYLOAD_SIZE);
964
965 SMS_INIT_MSG(&msg->x_msg_header, MSG_SMS_DATA_DOWNLOAD_REQ,
966 (u16)(sizeof(struct sms_msg_hdr) +
967 sizeof(u32) + payload_size));
968
969 data_msg->mem_addr = mem_address;
970 memcpy(data_msg->payload, payload, payload_size);
971
972 rc = smscore_sendrequest_and_wait(coredev, data_msg,
973 data_msg->x_msg_header.msg_length,
974 &coredev->data_download_done);
975
976 payload += payload_size;
977 size -= payload_size;
978 mem_address += payload_size;
979 }
980
981 if (rc < 0)
982 goto exit_fw_download;
983
984 pr_debug("sending MSG_SMS_DATA_VALIDITY_REQ expecting 0x%x\n",
985 calc_checksum);
986 SMS_INIT_MSG(&msg->x_msg_header, MSG_SMS_DATA_VALIDITY_REQ,
987 sizeof(msg->x_msg_header) +
988 sizeof(u32) * 3);
989 msg->msg_data[0] = firmware->start_address;
990
991 msg->msg_data[1] = firmware->length;
992 msg->msg_data[2] = 0;
993 rc = smscore_sendrequest_and_wait(coredev, msg,
994 msg->x_msg_header.msg_length,
995 &coredev->data_validity_done);
996 if (rc < 0)
997 goto exit_fw_download;
998
999 if (coredev->mode == DEVICE_MODE_NONE) {
1000 struct sms_msg_data *trigger_msg =
1001 (struct sms_msg_data *) msg;
1002
1003 pr_debug("sending MSG_SMS_SWDOWNLOAD_TRIGGER_REQ\n");
1004 SMS_INIT_MSG(&msg->x_msg_header,
1005 MSG_SMS_SWDOWNLOAD_TRIGGER_REQ,
1006 sizeof(struct sms_msg_hdr) +
1007 sizeof(u32) * 5);
1008
1009 trigger_msg->msg_data[0] = firmware->start_address;
1010
1011 trigger_msg->msg_data[1] = 6;
1012 trigger_msg->msg_data[2] = 0x200;
1013 trigger_msg->msg_data[3] = 0;
1014 trigger_msg->msg_data[4] = 4;
1015
1016 rc = smscore_sendrequest_and_wait(coredev, trigger_msg,
1017 trigger_msg->x_msg_header.msg_length,
1018 &coredev->trigger_done);
1019 } else {
1020 SMS_INIT_MSG(&msg->x_msg_header, MSG_SW_RELOAD_EXEC_REQ,
1021 sizeof(struct sms_msg_hdr));
1022 rc = coredev->sendrequest_handler(coredev->context, msg,
1023 msg->x_msg_header.msg_length);
1024 }
1025
1026 if (rc < 0)
1027 goto exit_fw_download;
1028
1029
1030
1031
1032
1033 msleep(400);
1034
1035exit_fw_download:
1036 kfree(msg);
1037
1038 if (coredev->postload_handler) {
1039 pr_debug("rc=%d, postload=0x%p\n",
1040 rc, coredev->postload_handler);
1041 if (rc >= 0)
1042 return coredev->postload_handler(coredev->context);
1043 }
1044
1045 pr_debug("rc=%d\n", rc);
1046 return rc;
1047}
1048
1049static char *smscore_fw_lkup[][DEVICE_MODE_MAX] = {
1050 [SMS_NOVA_A0] = {
1051 [DEVICE_MODE_DVBT] = SMS_FW_DVB_NOVA_12MHZ,
1052 [DEVICE_MODE_DVBH] = SMS_FW_DVB_NOVA_12MHZ,
1053 [DEVICE_MODE_DAB_TDMB] = SMS_FW_TDMB_NOVA_12MHZ,
1054 [DEVICE_MODE_DVBT_BDA] = SMS_FW_DVB_NOVA_12MHZ,
1055 [DEVICE_MODE_ISDBT] = SMS_FW_ISDBT_NOVA_12MHZ,
1056 [DEVICE_MODE_ISDBT_BDA] = SMS_FW_ISDBT_NOVA_12MHZ,
1057 },
1058 [SMS_NOVA_B0] = {
1059 [DEVICE_MODE_DVBT] = SMS_FW_DVB_NOVA_12MHZ_B0,
1060 [DEVICE_MODE_DVBH] = SMS_FW_DVB_NOVA_12MHZ_B0,
1061 [DEVICE_MODE_DAB_TDMB] = SMS_FW_TDMB_NOVA_12MHZ_B0,
1062 [DEVICE_MODE_DVBT_BDA] = SMS_FW_DVB_NOVA_12MHZ_B0,
1063 [DEVICE_MODE_ISDBT] = SMS_FW_ISDBT_NOVA_12MHZ_B0,
1064 [DEVICE_MODE_ISDBT_BDA] = SMS_FW_ISDBT_NOVA_12MHZ_B0,
1065 [DEVICE_MODE_FM_RADIO] = SMS_FW_FM_RADIO,
1066 [DEVICE_MODE_FM_RADIO_BDA] = SMS_FW_FM_RADIO,
1067 },
1068 [SMS_VEGA] = {
1069 [DEVICE_MODE_CMMB] = SMS_FW_CMMB_VEGA_12MHZ,
1070 },
1071 [SMS_VENICE] = {
1072 [DEVICE_MODE_CMMB] = SMS_FW_CMMB_VENICE_12MHZ,
1073 },
1074 [SMS_MING] = {
1075 [DEVICE_MODE_CMMB] = SMS_FW_CMMB_MING_APP,
1076 },
1077 [SMS_PELE] = {
1078 [DEVICE_MODE_ISDBT] = SMS_FW_ISDBT_PELE,
1079 [DEVICE_MODE_ISDBT_BDA] = SMS_FW_ISDBT_PELE,
1080 },
1081 [SMS_RIO] = {
1082 [DEVICE_MODE_DVBT] = SMS_FW_DVB_RIO,
1083 [DEVICE_MODE_DVBH] = SMS_FW_DVBH_RIO,
1084 [DEVICE_MODE_DVBT_BDA] = SMS_FW_DVB_RIO,
1085 [DEVICE_MODE_ISDBT] = SMS_FW_ISDBT_RIO,
1086 [DEVICE_MODE_ISDBT_BDA] = SMS_FW_ISDBT_RIO,
1087 [DEVICE_MODE_FM_RADIO] = SMS_FW_FM_RADIO_RIO,
1088 [DEVICE_MODE_FM_RADIO_BDA] = SMS_FW_FM_RADIO_RIO,
1089 },
1090 [SMS_DENVER_1530] = {
1091 [DEVICE_MODE_ATSC] = SMS_FW_ATSC_DENVER,
1092 },
1093 [SMS_DENVER_2160] = {
1094 [DEVICE_MODE_DAB_TDMB] = SMS_FW_TDMB_DENVER,
1095 },
1096};
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109static char *smscore_get_fw_filename(struct smscore_device_t *coredev,
1110 int mode)
1111{
1112 char **fw;
1113 int board_id = smscore_get_board_id(coredev);
1114 enum sms_device_type_st type;
1115
1116 type = smscore_registry_gettype(coredev->devpath);
1117
1118
1119 if (type <= SMS_UNKNOWN_TYPE || type >= SMS_NUM_OF_DEVICE_TYPES)
1120 return NULL;
1121 if (mode <= DEVICE_MODE_NONE || mode >= DEVICE_MODE_MAX)
1122 return NULL;
1123
1124 pr_debug("trying to get fw name from sms_boards board_id %d mode %d\n",
1125 board_id, mode);
1126 fw = sms_get_board(board_id)->fw;
1127 if (!fw || !fw[mode]) {
1128 pr_debug("cannot find fw name in sms_boards, getting from lookup table mode %d type %d\n",
1129 mode, type);
1130 return smscore_fw_lkup[type][mode];
1131 }
1132
1133 return fw[mode];
1134}
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146static int smscore_load_firmware_from_file(struct smscore_device_t *coredev,
1147 int mode,
1148 loadfirmware_t loadfirmware_handler)
1149{
1150 int rc = -ENOENT;
1151 u8 *fw_buf;
1152 u32 fw_buf_size;
1153 const struct firmware *fw;
1154
1155 char *fw_filename = smscore_get_fw_filename(coredev, mode);
1156 if (!fw_filename) {
1157 pr_err("mode %d not supported on this device\n", mode);
1158 return -ENOENT;
1159 }
1160 pr_debug("Firmware name: %s\n", fw_filename);
1161
1162 if (!loadfirmware_handler &&
1163 !(coredev->device_flags & SMS_DEVICE_FAMILY2))
1164 return -EINVAL;
1165
1166 rc = request_firmware(&fw, fw_filename, coredev->device);
1167 if (rc < 0) {
1168 pr_err("failed to open firmware file '%s'\n", fw_filename);
1169 return rc;
1170 }
1171 pr_debug("read fw %s, buffer size=0x%zx\n", fw_filename, fw->size);
1172 fw_buf = kmalloc(ALIGN(fw->size + sizeof(struct sms_firmware),
1173 SMS_ALLOC_ALIGNMENT), GFP_KERNEL | coredev->gfp_buf_flags);
1174 if (!fw_buf) {
1175 pr_err("failed to allocate firmware buffer\n");
1176 rc = -ENOMEM;
1177 } else {
1178 memcpy(fw_buf, fw->data, fw->size);
1179 fw_buf_size = fw->size;
1180
1181 rc = (coredev->device_flags & SMS_DEVICE_FAMILY2) ?
1182 smscore_load_firmware_family2(coredev, fw_buf, fw_buf_size)
1183 : loadfirmware_handler(coredev->context, fw_buf,
1184 fw_buf_size);
1185 }
1186
1187 kfree(fw_buf);
1188 release_firmware(fw);
1189
1190 return rc;
1191}
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202void smscore_unregister_device(struct smscore_device_t *coredev)
1203{
1204 struct smscore_buffer_t *cb;
1205 int num_buffers = 0;
1206 int retry = 0;
1207
1208 kmutex_lock(&g_smscore_deviceslock);
1209
1210
1211 sms_ir_exit(coredev);
1212
1213 smscore_notify_clients(coredev);
1214 smscore_notify_callbacks(coredev, NULL, 0);
1215
1216
1217
1218
1219 while (1) {
1220 while (!list_empty(&coredev->buffers)) {
1221 cb = (struct smscore_buffer_t *) coredev->buffers.next;
1222 list_del(&cb->entry);
1223 kfree(cb);
1224 num_buffers++;
1225 }
1226 if (num_buffers == coredev->num_buffers)
1227 break;
1228 if (++retry > 10) {
1229 pr_info("exiting although not all buffers released.\n");
1230 break;
1231 }
1232
1233 pr_debug("waiting for %d buffer(s)\n",
1234 coredev->num_buffers - num_buffers);
1235 kmutex_unlock(&g_smscore_deviceslock);
1236 msleep(100);
1237 kmutex_lock(&g_smscore_deviceslock);
1238 }
1239
1240 pr_debug("freed %d buffers\n", num_buffers);
1241
1242 if (coredev->common_buffer) {
1243 if (coredev->usb_device)
1244 kfree(coredev->common_buffer);
1245 else
1246 dma_free_coherent(coredev->device,
1247 coredev->common_buffer_size,
1248 coredev->common_buffer,
1249 coredev->common_buffer_phys);
1250 }
1251 kfree(coredev->fw_buf);
1252
1253 list_del(&coredev->entry);
1254 kfree(coredev);
1255
1256 kmutex_unlock(&g_smscore_deviceslock);
1257
1258 pr_debug("device %p destroyed\n", coredev);
1259}
1260EXPORT_SYMBOL_GPL(smscore_unregister_device);
1261
1262static int smscore_detect_mode(struct smscore_device_t *coredev)
1263{
1264 void *buffer = kmalloc(sizeof(struct sms_msg_hdr) + SMS_DMA_ALIGNMENT,
1265 GFP_KERNEL | coredev->gfp_buf_flags);
1266 struct sms_msg_hdr *msg =
1267 (struct sms_msg_hdr *) SMS_ALIGN_ADDRESS(buffer);
1268 int rc;
1269
1270 if (!buffer)
1271 return -ENOMEM;
1272
1273 SMS_INIT_MSG(msg, MSG_SMS_GET_VERSION_EX_REQ,
1274 sizeof(struct sms_msg_hdr));
1275
1276 rc = smscore_sendrequest_and_wait(coredev, msg, msg->msg_length,
1277 &coredev->version_ex_done);
1278 if (rc == -ETIME) {
1279 pr_err("MSG_SMS_GET_VERSION_EX_REQ failed first try\n");
1280
1281 if (wait_for_completion_timeout(&coredev->resume_done,
1282 msecs_to_jiffies(5000))) {
1283 rc = smscore_sendrequest_and_wait(
1284 coredev, msg, msg->msg_length,
1285 &coredev->version_ex_done);
1286 if (rc < 0)
1287 pr_err("MSG_SMS_GET_VERSION_EX_REQ failed second try, rc %d\n",
1288 rc);
1289 } else
1290 rc = -ETIME;
1291 }
1292
1293 kfree(buffer);
1294
1295 return rc;
1296}
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307static int smscore_init_device(struct smscore_device_t *coredev, int mode)
1308{
1309 void *buffer;
1310 struct sms_msg_data *msg;
1311 int rc = 0;
1312
1313 buffer = kmalloc(sizeof(struct sms_msg_data) +
1314 SMS_DMA_ALIGNMENT, GFP_KERNEL | coredev->gfp_buf_flags);
1315 if (!buffer)
1316 return -ENOMEM;
1317
1318 msg = (struct sms_msg_data *)SMS_ALIGN_ADDRESS(buffer);
1319 SMS_INIT_MSG(&msg->x_msg_header, MSG_SMS_INIT_DEVICE_REQ,
1320 sizeof(struct sms_msg_data));
1321 msg->msg_data[0] = mode;
1322
1323 rc = smscore_sendrequest_and_wait(coredev, msg,
1324 msg->x_msg_header. msg_length,
1325 &coredev->init_device_done);
1326
1327 kfree(buffer);
1328 return rc;
1329}
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341int smscore_set_device_mode(struct smscore_device_t *coredev, int mode)
1342{
1343 int rc = 0;
1344
1345 pr_debug("set device mode to %d\n", mode);
1346 if (coredev->device_flags & SMS_DEVICE_FAMILY2) {
1347 if (mode <= DEVICE_MODE_NONE || mode >= DEVICE_MODE_MAX) {
1348 pr_err("invalid mode specified %d\n", mode);
1349 return -EINVAL;
1350 }
1351
1352 smscore_registry_setmode(coredev->devpath, mode);
1353
1354 if (!(coredev->device_flags & SMS_DEVICE_NOT_READY)) {
1355 rc = smscore_detect_mode(coredev);
1356 if (rc < 0) {
1357 pr_err("mode detect failed %d\n", rc);
1358 return rc;
1359 }
1360 }
1361
1362 if (coredev->mode == mode) {
1363 pr_debug("device mode %d already set\n", mode);
1364 return 0;
1365 }
1366
1367 if (!(coredev->modes_supported & (1 << mode))) {
1368 rc = smscore_load_firmware_from_file(coredev,
1369 mode, NULL);
1370 if (rc >= 0)
1371 pr_debug("firmware download success\n");
1372 } else {
1373 pr_debug("mode %d is already supported by running firmware\n",
1374 mode);
1375 }
1376 if (coredev->fw_version >= 0x800) {
1377 rc = smscore_init_device(coredev, mode);
1378 if (rc < 0)
1379 pr_err("device init failed, rc %d.\n", rc);
1380 }
1381 } else {
1382 if (mode <= DEVICE_MODE_NONE || mode >= DEVICE_MODE_MAX) {
1383 pr_err("invalid mode specified %d\n", mode);
1384 return -EINVAL;
1385 }
1386
1387 smscore_registry_setmode(coredev->devpath, mode);
1388
1389 if (coredev->detectmode_handler)
1390 coredev->detectmode_handler(coredev->context,
1391 &coredev->mode);
1392
1393 if (coredev->mode != mode && coredev->setmode_handler)
1394 rc = coredev->setmode_handler(coredev->context, mode);
1395 }
1396
1397 if (rc >= 0) {
1398 char *buffer;
1399 coredev->mode = mode;
1400 coredev->device_flags &= ~SMS_DEVICE_NOT_READY;
1401
1402 buffer = kmalloc(sizeof(struct sms_msg_data) +
1403 SMS_DMA_ALIGNMENT, GFP_KERNEL | coredev->gfp_buf_flags);
1404 if (buffer) {
1405 struct sms_msg_data *msg = (struct sms_msg_data *) SMS_ALIGN_ADDRESS(buffer);
1406
1407 SMS_INIT_MSG(&msg->x_msg_header, MSG_SMS_INIT_DEVICE_REQ,
1408 sizeof(struct sms_msg_data));
1409 msg->msg_data[0] = mode;
1410
1411 rc = smscore_sendrequest_and_wait(
1412 coredev, msg, msg->x_msg_header.msg_length,
1413 &coredev->init_device_done);
1414
1415 kfree(buffer);
1416 }
1417 }
1418
1419 if (rc < 0)
1420 pr_err("return error code %d.\n", rc);
1421 else
1422 pr_debug("Success setting device mode.\n");
1423
1424 return rc;
1425}
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435int smscore_get_device_mode(struct smscore_device_t *coredev)
1436{
1437 return coredev->mode;
1438}
1439EXPORT_SYMBOL_GPL(smscore_get_device_mode);
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451static struct
1452smscore_client_t *smscore_find_client(struct smscore_device_t *coredev,
1453 int data_type, int id)
1454{
1455 struct list_head *first;
1456 struct smscore_client_t *client;
1457 unsigned long flags;
1458 struct list_head *firstid;
1459 struct smscore_idlist_t *client_id;
1460
1461 spin_lock_irqsave(&coredev->clientslock, flags);
1462 first = &coredev->clients;
1463 list_for_each_entry(client, first, entry) {
1464 firstid = &client->idlist;
1465 list_for_each_entry(client_id, firstid, entry) {
1466 if ((client_id->id == id) &&
1467 (client_id->data_type == data_type ||
1468 (client_id->data_type == 0)))
1469 goto found;
1470 }
1471 }
1472 client = NULL;
1473found:
1474 spin_unlock_irqrestore(&coredev->clientslock, flags);
1475 return client;
1476}
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487void smscore_onresponse(struct smscore_device_t *coredev,
1488 struct smscore_buffer_t *cb) {
1489 struct sms_msg_hdr *phdr = (struct sms_msg_hdr *) ((u8 *) cb->p
1490 + cb->offset);
1491 struct smscore_client_t *client;
1492 int rc = -EBUSY;
1493 static unsigned long last_sample_time;
1494 static int data_total;
1495 unsigned long time_now = jiffies_to_msecs(jiffies);
1496
1497 if (!last_sample_time)
1498 last_sample_time = time_now;
1499
1500 if (time_now - last_sample_time > 10000) {
1501 pr_debug("data rate %d bytes/secs\n",
1502 (int)((data_total * 1000) /
1503 (time_now - last_sample_time)));
1504
1505 last_sample_time = time_now;
1506 data_total = 0;
1507 }
1508
1509 data_total += cb->size;
1510
1511 if ((phdr->msg_type == MSG_SMS_HO_PER_SLICES_IND) ||
1512 (phdr->msg_type == MSG_SMS_TRANSMISSION_IND)) {
1513 if (coredev->mode == DEVICE_MODE_DVBT_BDA)
1514 phdr->msg_dst_id = DVBT_BDA_CONTROL_MSG_ID;
1515 }
1516
1517
1518 client = smscore_find_client(coredev, phdr->msg_type, phdr->msg_dst_id);
1519
1520
1521
1522 if (client)
1523 rc = client->onresponse_handler(client->context, cb);
1524
1525 if (rc < 0) {
1526 switch (phdr->msg_type) {
1527 case MSG_SMS_ISDBT_TUNE_RES:
1528 break;
1529 case MSG_SMS_RF_TUNE_RES:
1530 break;
1531 case MSG_SMS_SIGNAL_DETECTED_IND:
1532 break;
1533 case MSG_SMS_NO_SIGNAL_IND:
1534 break;
1535 case MSG_SMS_SPI_INT_LINE_SET_RES:
1536 break;
1537 case MSG_SMS_INTERFACE_LOCK_IND:
1538 break;
1539 case MSG_SMS_INTERFACE_UNLOCK_IND:
1540 break;
1541 case MSG_SMS_GET_VERSION_EX_RES:
1542 {
1543 struct sms_version_res *ver =
1544 (struct sms_version_res *) phdr;
1545 pr_debug("Firmware id %d prots 0x%x ver %d.%d\n",
1546 ver->firmware_id, ver->supported_protocols,
1547 ver->rom_ver_major, ver->rom_ver_minor);
1548
1549 coredev->mode = ver->firmware_id == 255 ?
1550 DEVICE_MODE_NONE : ver->firmware_id;
1551 coredev->modes_supported = ver->supported_protocols;
1552 coredev->fw_version = ver->rom_ver_major << 8 |
1553 ver->rom_ver_minor;
1554
1555 complete(&coredev->version_ex_done);
1556 break;
1557 }
1558 case MSG_SMS_INIT_DEVICE_RES:
1559 complete(&coredev->init_device_done);
1560 break;
1561 case MSG_SW_RELOAD_START_RES:
1562 complete(&coredev->reload_start_done);
1563 break;
1564 case MSG_SMS_DATA_VALIDITY_RES:
1565 {
1566 struct sms_msg_data *validity = (struct sms_msg_data *) phdr;
1567
1568 pr_debug("MSG_SMS_DATA_VALIDITY_RES, checksum = 0x%x\n",
1569 validity->msg_data[0]);
1570 complete(&coredev->data_validity_done);
1571 break;
1572 }
1573 case MSG_SMS_DATA_DOWNLOAD_RES:
1574 complete(&coredev->data_download_done);
1575 break;
1576 case MSG_SW_RELOAD_EXEC_RES:
1577 break;
1578 case MSG_SMS_SWDOWNLOAD_TRIGGER_RES:
1579 complete(&coredev->trigger_done);
1580 break;
1581 case MSG_SMS_SLEEP_RESUME_COMP_IND:
1582 complete(&coredev->resume_done);
1583 break;
1584 case MSG_SMS_GPIO_CONFIG_EX_RES:
1585 complete(&coredev->gpio_configuration_done);
1586 break;
1587 case MSG_SMS_GPIO_SET_LEVEL_RES:
1588 complete(&coredev->gpio_set_level_done);
1589 break;
1590 case MSG_SMS_GPIO_GET_LEVEL_RES:
1591 {
1592 u32 *msgdata = (u32 *) phdr;
1593 coredev->gpio_get_res = msgdata[1];
1594 pr_debug("gpio level %d\n",
1595 coredev->gpio_get_res);
1596 complete(&coredev->gpio_get_level_done);
1597 break;
1598 }
1599 case MSG_SMS_START_IR_RES:
1600 complete(&coredev->ir_init_done);
1601 break;
1602 case MSG_SMS_IR_SAMPLES_IND:
1603 sms_ir_event(coredev,
1604 (const char *)
1605 ((char *)phdr
1606 + sizeof(struct sms_msg_hdr)),
1607 (int)phdr->msg_length
1608 - sizeof(struct sms_msg_hdr));
1609 break;
1610
1611 case MSG_SMS_DVBT_BDA_DATA:
1612
1613
1614
1615
1616
1617
1618 break;
1619
1620 default:
1621 pr_debug("message %s(%d) not handled.\n",
1622 smscore_translate_msg(phdr->msg_type),
1623 phdr->msg_type);
1624 break;
1625 }
1626 smscore_putbuffer(coredev, cb);
1627 }
1628}
1629EXPORT_SYMBOL_GPL(smscore_onresponse);
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640static struct smscore_buffer_t *get_entry(struct smscore_device_t *coredev)
1641{
1642 struct smscore_buffer_t *cb = NULL;
1643 unsigned long flags;
1644
1645 spin_lock_irqsave(&coredev->bufferslock, flags);
1646 if (!list_empty(&coredev->buffers)) {
1647 cb = (struct smscore_buffer_t *) coredev->buffers.next;
1648 list_del(&cb->entry);
1649 }
1650 spin_unlock_irqrestore(&coredev->bufferslock, flags);
1651 return cb;
1652}
1653
1654struct smscore_buffer_t *smscore_getbuffer(struct smscore_device_t *coredev)
1655{
1656 struct smscore_buffer_t *cb = NULL;
1657
1658 wait_event(coredev->buffer_mng_waitq, (cb = get_entry(coredev)));
1659
1660 return cb;
1661}
1662EXPORT_SYMBOL_GPL(smscore_getbuffer);
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672void smscore_putbuffer(struct smscore_device_t *coredev,
1673 struct smscore_buffer_t *cb) {
1674 wake_up_interruptible(&coredev->buffer_mng_waitq);
1675 list_add_locked(&cb->entry, &coredev->buffers, &coredev->bufferslock);
1676}
1677EXPORT_SYMBOL_GPL(smscore_putbuffer);
1678
1679static int smscore_validate_client(struct smscore_device_t *coredev,
1680 struct smscore_client_t *client,
1681 int data_type, int id)
1682{
1683 struct smscore_idlist_t *listentry;
1684 struct smscore_client_t *registered_client;
1685
1686 if (!client) {
1687 pr_err("bad parameter.\n");
1688 return -EINVAL;
1689 }
1690 registered_client = smscore_find_client(coredev, data_type, id);
1691 if (registered_client == client)
1692 return 0;
1693
1694 if (registered_client) {
1695 pr_err("The msg ID already registered to another client.\n");
1696 return -EEXIST;
1697 }
1698 listentry = kzalloc(sizeof(*listentry), GFP_KERNEL);
1699 if (!listentry)
1700 return -ENOMEM;
1701
1702 listentry->id = id;
1703 listentry->data_type = data_type;
1704 list_add_locked(&listentry->entry, &client->idlist,
1705 &coredev->clientslock);
1706 return 0;
1707}
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723int smscore_register_client(struct smscore_device_t *coredev,
1724 struct smsclient_params_t *params,
1725 struct smscore_client_t **client)
1726{
1727 struct smscore_client_t *newclient;
1728
1729 if (smscore_find_client(coredev, params->data_type,
1730 params->initial_id)) {
1731 pr_err("Client already exist.\n");
1732 return -EEXIST;
1733 }
1734
1735 newclient = kzalloc(sizeof(*newclient), GFP_KERNEL);
1736 if (!newclient)
1737 return -ENOMEM;
1738
1739 INIT_LIST_HEAD(&newclient->idlist);
1740 newclient->coredev = coredev;
1741 newclient->onresponse_handler = params->onresponse_handler;
1742 newclient->onremove_handler = params->onremove_handler;
1743 newclient->context = params->context;
1744 list_add_locked(&newclient->entry, &coredev->clients,
1745 &coredev->clientslock);
1746 smscore_validate_client(coredev, newclient, params->data_type,
1747 params->initial_id);
1748 *client = newclient;
1749 pr_debug("%p %d %d\n", params->context, params->data_type,
1750 params->initial_id);
1751
1752 return 0;
1753}
1754EXPORT_SYMBOL_GPL(smscore_register_client);
1755
1756
1757
1758
1759
1760
1761
1762
1763void smscore_unregister_client(struct smscore_client_t *client)
1764{
1765 struct smscore_device_t *coredev = client->coredev;
1766 unsigned long flags;
1767
1768 spin_lock_irqsave(&coredev->clientslock, flags);
1769
1770
1771 while (!list_empty(&client->idlist)) {
1772 struct smscore_idlist_t *identry =
1773 (struct smscore_idlist_t *) client->idlist.next;
1774 list_del(&identry->entry);
1775 kfree(identry);
1776 }
1777
1778 pr_debug("%p\n", client->context);
1779
1780 list_del(&client->entry);
1781 kfree(client);
1782
1783 spin_unlock_irqrestore(&coredev->clientslock, flags);
1784}
1785EXPORT_SYMBOL_GPL(smscore_unregister_client);
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798int smsclient_sendrequest(struct smscore_client_t *client,
1799 void *buffer, size_t size)
1800{
1801 struct smscore_device_t *coredev;
1802 struct sms_msg_hdr *phdr = (struct sms_msg_hdr *) buffer;
1803 int rc;
1804
1805 if (!client) {
1806 pr_err("Got NULL client\n");
1807 return -EINVAL;
1808 }
1809
1810 coredev = client->coredev;
1811
1812
1813 if (!coredev) {
1814 pr_err("Got NULL coredev\n");
1815 return -EINVAL;
1816 }
1817
1818 rc = smscore_validate_client(client->coredev, client, 0,
1819 phdr->msg_src_id);
1820 if (rc < 0)
1821 return rc;
1822
1823 return coredev->sendrequest_handler(coredev->context, buffer, size);
1824}
1825EXPORT_SYMBOL_GPL(smsclient_sendrequest);
1826
1827
1828
1829int smscore_configure_gpio(struct smscore_device_t *coredev, u32 pin,
1830 struct smscore_config_gpio *pinconfig)
1831{
1832 struct {
1833 struct sms_msg_hdr hdr;
1834 u32 data[6];
1835 } msg;
1836
1837 if (coredev->device_flags & SMS_DEVICE_FAMILY2) {
1838 msg.hdr.msg_src_id = DVBT_BDA_CONTROL_MSG_ID;
1839 msg.hdr.msg_dst_id = HIF_TASK;
1840 msg.hdr.msg_flags = 0;
1841 msg.hdr.msg_type = MSG_SMS_GPIO_CONFIG_EX_REQ;
1842 msg.hdr.msg_length = sizeof(msg);
1843
1844 msg.data[0] = pin;
1845 msg.data[1] = pinconfig->pullupdown;
1846
1847
1848 msg.data[2] = pinconfig->outputslewrate == 0 ? 3 : 0;
1849
1850 switch (pinconfig->outputdriving) {
1851 case SMS_GPIO_OUTPUTDRIVING_S_16mA:
1852 msg.data[3] = 7;
1853 break;
1854 case SMS_GPIO_OUTPUTDRIVING_S_12mA:
1855 msg.data[3] = 5;
1856 break;
1857 case SMS_GPIO_OUTPUTDRIVING_S_8mA:
1858 msg.data[3] = 3;
1859 break;
1860 case SMS_GPIO_OUTPUTDRIVING_S_4mA:
1861 default:
1862 msg.data[3] = 2;
1863 break;
1864 }
1865
1866 msg.data[4] = pinconfig->direction;
1867 msg.data[5] = 0;
1868 } else
1869 return -EINVAL;
1870
1871 return coredev->sendrequest_handler(coredev->context,
1872 &msg, sizeof(msg));
1873}
1874
1875int smscore_set_gpio(struct smscore_device_t *coredev, u32 pin, int level)
1876{
1877 struct {
1878 struct sms_msg_hdr hdr;
1879 u32 data[3];
1880 } msg;
1881
1882 if (pin > MAX_GPIO_PIN_NUMBER)
1883 return -EINVAL;
1884
1885 msg.hdr.msg_src_id = DVBT_BDA_CONTROL_MSG_ID;
1886 msg.hdr.msg_dst_id = HIF_TASK;
1887 msg.hdr.msg_flags = 0;
1888 msg.hdr.msg_type = MSG_SMS_GPIO_SET_LEVEL_REQ;
1889 msg.hdr.msg_length = sizeof(msg);
1890
1891 msg.data[0] = pin;
1892 msg.data[1] = level ? 1 : 0;
1893 msg.data[2] = 0;
1894
1895 return coredev->sendrequest_handler(coredev->context,
1896 &msg, sizeof(msg));
1897}
1898
1899
1900static int get_gpio_pin_params(u32 pin_num, u32 *p_translatedpin_num,
1901 u32 *p_group_num, u32 *p_group_cfg) {
1902
1903 *p_group_cfg = 1;
1904
1905 if (pin_num <= 1) {
1906 *p_translatedpin_num = 0;
1907 *p_group_num = 9;
1908 *p_group_cfg = 2;
1909 } else if (pin_num >= 2 && pin_num <= 6) {
1910 *p_translatedpin_num = 2;
1911 *p_group_num = 0;
1912 *p_group_cfg = 2;
1913 } else if (pin_num >= 7 && pin_num <= 11) {
1914 *p_translatedpin_num = 7;
1915 *p_group_num = 1;
1916 } else if (pin_num >= 12 && pin_num <= 15) {
1917 *p_translatedpin_num = 12;
1918 *p_group_num = 2;
1919 *p_group_cfg = 3;
1920 } else if (pin_num == 16) {
1921 *p_translatedpin_num = 16;
1922 *p_group_num = 23;
1923 } else if (pin_num >= 17 && pin_num <= 24) {
1924 *p_translatedpin_num = 17;
1925 *p_group_num = 3;
1926 } else if (pin_num == 25) {
1927 *p_translatedpin_num = 25;
1928 *p_group_num = 6;
1929 } else if (pin_num >= 26 && pin_num <= 28) {
1930 *p_translatedpin_num = 26;
1931 *p_group_num = 4;
1932 } else if (pin_num == 29) {
1933 *p_translatedpin_num = 29;
1934 *p_group_num = 5;
1935 *p_group_cfg = 2;
1936 } else if (pin_num == 30) {
1937 *p_translatedpin_num = 30;
1938 *p_group_num = 8;
1939 } else if (pin_num == 31) {
1940 *p_translatedpin_num = 31;
1941 *p_group_num = 17;
1942 } else
1943 return -1;
1944
1945 *p_group_cfg <<= 24;
1946
1947 return 0;
1948}
1949
1950int smscore_gpio_configure(struct smscore_device_t *coredev, u8 pin_num,
1951 struct smscore_config_gpio *p_gpio_config) {
1952
1953 u32 total_len;
1954 u32 translatedpin_num = 0;
1955 u32 group_num = 0;
1956 u32 electric_char;
1957 u32 group_cfg;
1958 void *buffer;
1959 int rc;
1960
1961 struct set_gpio_msg {
1962 struct sms_msg_hdr x_msg_header;
1963 u32 msg_data[6];
1964 } *p_msg;
1965
1966
1967 if (pin_num > MAX_GPIO_PIN_NUMBER)
1968 return -EINVAL;
1969
1970 if (!p_gpio_config)
1971 return -EINVAL;
1972
1973 total_len = sizeof(struct sms_msg_hdr) + (sizeof(u32) * 6);
1974
1975 buffer = kmalloc(total_len + SMS_DMA_ALIGNMENT,
1976 GFP_KERNEL | coredev->gfp_buf_flags);
1977 if (!buffer)
1978 return -ENOMEM;
1979
1980 p_msg = (struct set_gpio_msg *) SMS_ALIGN_ADDRESS(buffer);
1981
1982 p_msg->x_msg_header.msg_src_id = DVBT_BDA_CONTROL_MSG_ID;
1983 p_msg->x_msg_header.msg_dst_id = HIF_TASK;
1984 p_msg->x_msg_header.msg_flags = 0;
1985 p_msg->x_msg_header.msg_length = (u16) total_len;
1986 p_msg->msg_data[0] = pin_num;
1987
1988 if (!(coredev->device_flags & SMS_DEVICE_FAMILY2)) {
1989 p_msg->x_msg_header.msg_type = MSG_SMS_GPIO_CONFIG_REQ;
1990 if (get_gpio_pin_params(pin_num, &translatedpin_num, &group_num,
1991 &group_cfg) != 0) {
1992 rc = -EINVAL;
1993 goto free;
1994 }
1995
1996 p_msg->msg_data[1] = translatedpin_num;
1997 p_msg->msg_data[2] = group_num;
1998 electric_char = (p_gpio_config->pullupdown)
1999 | (p_gpio_config->inputcharacteristics << 2)
2000 | (p_gpio_config->outputslewrate << 3)
2001 | (p_gpio_config->outputdriving << 4);
2002 p_msg->msg_data[3] = electric_char;
2003 p_msg->msg_data[4] = p_gpio_config->direction;
2004 p_msg->msg_data[5] = group_cfg;
2005 } else {
2006 p_msg->x_msg_header.msg_type = MSG_SMS_GPIO_CONFIG_EX_REQ;
2007 p_msg->msg_data[1] = p_gpio_config->pullupdown;
2008 p_msg->msg_data[2] = p_gpio_config->outputslewrate;
2009 p_msg->msg_data[3] = p_gpio_config->outputdriving;
2010 p_msg->msg_data[4] = p_gpio_config->direction;
2011 p_msg->msg_data[5] = 0;
2012 }
2013
2014 rc = smscore_sendrequest_and_wait(coredev, p_msg, total_len,
2015 &coredev->gpio_configuration_done);
2016
2017 if (rc != 0) {
2018 if (rc == -ETIME)
2019 pr_err("smscore_gpio_configure timeout\n");
2020 else
2021 pr_err("smscore_gpio_configure error\n");
2022 }
2023free:
2024 kfree(buffer);
2025
2026 return rc;
2027}
2028
2029int smscore_gpio_set_level(struct smscore_device_t *coredev, u8 pin_num,
2030 u8 new_level) {
2031
2032 u32 total_len;
2033 int rc;
2034 void *buffer;
2035
2036 struct set_gpio_msg {
2037 struct sms_msg_hdr x_msg_header;
2038 u32 msg_data[3];
2039 } *p_msg;
2040
2041 if ((new_level > 1) || (pin_num > MAX_GPIO_PIN_NUMBER))
2042 return -EINVAL;
2043
2044 total_len = sizeof(struct sms_msg_hdr) +
2045 (3 * sizeof(u32));
2046
2047 buffer = kmalloc(total_len + SMS_DMA_ALIGNMENT,
2048 GFP_KERNEL | coredev->gfp_buf_flags);
2049 if (!buffer)
2050 return -ENOMEM;
2051
2052 p_msg = (struct set_gpio_msg *) SMS_ALIGN_ADDRESS(buffer);
2053
2054 p_msg->x_msg_header.msg_src_id = DVBT_BDA_CONTROL_MSG_ID;
2055 p_msg->x_msg_header.msg_dst_id = HIF_TASK;
2056 p_msg->x_msg_header.msg_flags = 0;
2057 p_msg->x_msg_header.msg_type = MSG_SMS_GPIO_SET_LEVEL_REQ;
2058 p_msg->x_msg_header.msg_length = (u16) total_len;
2059 p_msg->msg_data[0] = pin_num;
2060 p_msg->msg_data[1] = new_level;
2061
2062
2063 rc = smscore_sendrequest_and_wait(coredev, p_msg, total_len,
2064 &coredev->gpio_set_level_done);
2065
2066 if (rc != 0) {
2067 if (rc == -ETIME)
2068 pr_err("smscore_gpio_set_level timeout\n");
2069 else
2070 pr_err("smscore_gpio_set_level error\n");
2071 }
2072 kfree(buffer);
2073
2074 return rc;
2075}
2076
2077int smscore_gpio_get_level(struct smscore_device_t *coredev, u8 pin_num,
2078 u8 *level) {
2079
2080 u32 total_len;
2081 int rc;
2082 void *buffer;
2083
2084 struct set_gpio_msg {
2085 struct sms_msg_hdr x_msg_header;
2086 u32 msg_data[2];
2087 } *p_msg;
2088
2089
2090 if (pin_num > MAX_GPIO_PIN_NUMBER)
2091 return -EINVAL;
2092
2093 total_len = sizeof(struct sms_msg_hdr) + (2 * sizeof(u32));
2094
2095 buffer = kmalloc(total_len + SMS_DMA_ALIGNMENT,
2096 GFP_KERNEL | coredev->gfp_buf_flags);
2097 if (!buffer)
2098 return -ENOMEM;
2099
2100 p_msg = (struct set_gpio_msg *) SMS_ALIGN_ADDRESS(buffer);
2101
2102 p_msg->x_msg_header.msg_src_id = DVBT_BDA_CONTROL_MSG_ID;
2103 p_msg->x_msg_header.msg_dst_id = HIF_TASK;
2104 p_msg->x_msg_header.msg_flags = 0;
2105 p_msg->x_msg_header.msg_type = MSG_SMS_GPIO_GET_LEVEL_REQ;
2106 p_msg->x_msg_header.msg_length = (u16) total_len;
2107 p_msg->msg_data[0] = pin_num;
2108 p_msg->msg_data[1] = 0;
2109
2110
2111 rc = smscore_sendrequest_and_wait(coredev, p_msg, total_len,
2112 &coredev->gpio_get_level_done);
2113
2114 if (rc != 0) {
2115 if (rc == -ETIME)
2116 pr_err("smscore_gpio_get_level timeout\n");
2117 else
2118 pr_err("smscore_gpio_get_level error\n");
2119 }
2120 kfree(buffer);
2121
2122
2123
2124
2125 *level = coredev->gpio_get_res;
2126
2127 return rc;
2128}
2129
2130static int __init smscore_module_init(void)
2131{
2132 INIT_LIST_HEAD(&g_smscore_notifyees);
2133 INIT_LIST_HEAD(&g_smscore_devices);
2134 kmutex_init(&g_smscore_deviceslock);
2135
2136 INIT_LIST_HEAD(&g_smscore_registry);
2137 kmutex_init(&g_smscore_registrylock);
2138
2139 return 0;
2140}
2141
2142static void __exit smscore_module_exit(void)
2143{
2144 kmutex_lock(&g_smscore_deviceslock);
2145 while (!list_empty(&g_smscore_notifyees)) {
2146 struct smscore_device_notifyee_t *notifyee =
2147 (struct smscore_device_notifyee_t *)
2148 g_smscore_notifyees.next;
2149
2150 list_del(¬ifyee->entry);
2151 kfree(notifyee);
2152 }
2153 kmutex_unlock(&g_smscore_deviceslock);
2154
2155 kmutex_lock(&g_smscore_registrylock);
2156 while (!list_empty(&g_smscore_registry)) {
2157 struct smscore_registry_entry_t *entry =
2158 (struct smscore_registry_entry_t *)
2159 g_smscore_registry.next;
2160
2161 list_del(&entry->entry);
2162 kfree(entry);
2163 }
2164 kmutex_unlock(&g_smscore_registrylock);
2165
2166 pr_debug("\n");
2167}
2168
2169module_init(smscore_module_init);
2170module_exit(smscore_module_exit);
2171
2172MODULE_DESCRIPTION("Siano MDTV Core module");
2173MODULE_AUTHOR("Siano Mobile Silicon, Inc. (uris@siano-ms.com)");
2174MODULE_LICENSE("GPL");
2175
2176
2177MODULE_FIRMWARE(SMS_FW_ATSC_DENVER);
2178MODULE_FIRMWARE(SMS_FW_CMMB_MING_APP);
2179MODULE_FIRMWARE(SMS_FW_CMMB_VEGA_12MHZ);
2180MODULE_FIRMWARE(SMS_FW_CMMB_VENICE_12MHZ);
2181MODULE_FIRMWARE(SMS_FW_DVBH_RIO);
2182MODULE_FIRMWARE(SMS_FW_DVB_NOVA_12MHZ_B0);
2183MODULE_FIRMWARE(SMS_FW_DVB_NOVA_12MHZ);
2184MODULE_FIRMWARE(SMS_FW_DVB_RIO);
2185MODULE_FIRMWARE(SMS_FW_FM_RADIO);
2186MODULE_FIRMWARE(SMS_FW_FM_RADIO_RIO);
2187MODULE_FIRMWARE(SMS_FW_DVBT_HCW_55XXX);
2188MODULE_FIRMWARE(SMS_FW_ISDBT_HCW_55XXX);
2189MODULE_FIRMWARE(SMS_FW_ISDBT_NOVA_12MHZ_B0);
2190MODULE_FIRMWARE(SMS_FW_ISDBT_NOVA_12MHZ);
2191MODULE_FIRMWARE(SMS_FW_ISDBT_PELE);
2192MODULE_FIRMWARE(SMS_FW_ISDBT_RIO);
2193MODULE_FIRMWARE(SMS_FW_DVBT_NOVA_A);
2194MODULE_FIRMWARE(SMS_FW_DVBT_NOVA_B);
2195MODULE_FIRMWARE(SMS_FW_DVBT_STELLAR);
2196MODULE_FIRMWARE(SMS_FW_TDMB_DENVER);
2197MODULE_FIRMWARE(SMS_FW_TDMB_NOVA_12MHZ_B0);
2198MODULE_FIRMWARE(SMS_FW_TDMB_NOVA_12MHZ);
2199