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