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