52 #include "ci_appmmi.h" 61 #define DBG_OP(x, ...) STB_SPDebugWrite( "%s:%d " x, __FUNCTION__, __LINE__, ##__VA_ARGS__); 63 #define DBG_OP(x, ...) 66 #define CIP_SERVICE_TYPE_TV 0x00000001 67 #define CIP_SERVICE_TYPE_RADIO 0x00000002 68 #define CIP_SERVICE_TYPE_TELETEXT 0x00000004 69 #define CIP_SERVICE_TYPE_AVC_RADIO 0x00000008 70 #define CIP_SERVICE_TYPE_DATA 0x00000010 71 #define CIP_SERVICE_TYPE_HD_TV 0x00000020 72 #define CIP_SERVICE_TYPE_AVC_SD_TV 0x00000040 73 #define CIP_SERVICE_TYPE_AVC_HD_TV 0x00000080 75 #define CIP_DELIVERY_TYPE_DVBT 0x0001 76 #define CIP_DELIVERY_TYPE_DVBT2 0x0002 77 #define CIP_DELIVERY_TYPE_DVBC 0x0004 78 #define CIP_DELIVERY_TYPE_DVBC2 0x0008 79 #define CIP_DELIVERY_TYPE_DVBS 0x0010 80 #define CIP_DELIVERY_TYPE_DVBS2 0x0020 82 #define CIP_APP_TYPE_MHEG 0x0001 83 #define CIP_APP_TYPE_HBBTV 0x0002 84 #define CIP_APP_TYPE_OIPF 0x0004 86 #define INVALID_MODULE 0xFFFFFFFF 88 #define CIP_NUM_FREE_LCNS 2 94 CIP_OPERATOR_SEARCH_DEFERRED,
95 CIP_OPERATOR_SEARCH_IMMEDIATE,
96 CIP_OPERATOR_SEARCH_SCHEDULED
97 } E_CIP_OPERATOR_SEARCH_REQUEST_TYPE;
101 U16BIT cicam_onet_id;
102 U32BIT cicam_identifier;
104 U8BIT profile_name_length;
112 U8BIT num_service_types;
113 U32BIT service_types;
114 U16BIT delivery_types;
120 E_CIP_OPERATOR_SEARCH_REQUEST_TYPE refresh_request;
137 U16BIT host_delivery_types;
138 U16BIT op_desc_loop_len;
139 U16BIT op_current_loc_len;
141 U8BIT *op_current_location;
142 S_STB_CI_OPERATOR_STATUS op_status;
143 S_STB_CI_OPERATOR_INFO op_info;
144 BOOLEAN tune_started;
145 BOOLEAN op_status_valid;
146 BOOLEAN op_info_valid;
147 BOOLEAN op_nit_received;
148 BOOLEAN op_search_started;
155 static void *ciop_mutex;
156 static U32BIT op_module;
157 static U32BIT default_und_lang = ADB_LANG_CODE_UNDEF;
163 static BOOLEAN StartOperatorSearch(
S_OP_STATUS *op_state);
164 static BOOLEAN PrepareSearchInfo(
S_CIP_HOST_INFO *host_info, S_STB_CI_SEARCH_START_INFO *search_info);
165 static void PerformOperatorTune(
S_OP_STATUS *op_state);
166 static U32BIT ConvertLangCode(U8BIT *data);
167 static U8BIT GetCharacterCodeTable(S_STB_CI_OPERATOR_INFO *op_info);
197 DBG_OP(
"(slot_id=%u)", slot_id)
201 while (state != NULL)
203 if (state->slot_id == slot_id)
205 ADB_MarkCIModuleNotPresent(state->module);
206 *pstate = state->next;
212 pstate = &(state->next);
234 DBG_OP(
"(%u)", module)
236 if (op_module == INVALID_MODULE)
238 retval = STB_CIRequestOperatorStatus(module);
244 op_state = FindOpState(module);
245 if (op_state != NULL)
247 DBG_OP(
"(%u): Setting character table 0x%x", module,
248 op_state->op_info.character_code_table)
251 if (((op_state->op_info.iso_639_language_code[0] !=
'u') ||
252 (op_state->op_info.iso_639_language_code[1] !=
'n') ||
253 (op_state->op_info.iso_639_language_code[2] !=
'd')) &&
254 ((op_state->op_info.iso_639_language_code[0] !=
'q') ||
255 (op_state->op_info.iso_639_language_code[1] !=
'a') ||
256 (op_state->op_info.iso_639_language_code[2] !=
'a')))
260 ConvertLangCode(op_state->op_info.iso_639_language_code));
267 DBG_OP(
"STB_CIRequestOperatorStatus(%u) failed", module)
273 DBG_OP(
"Previous operator module hasn't been exited")
293 if (op_module != INVALID_MODULE)
295 retval = STB_CISendOperatorExit(op_module);
298 DBG_OP(
"STB_CISendOperatorExit(%u) failed", op_module)
300 op_module = INVALID_MODULE;
302 DBG_OP(
"Setting character table 0x%x (default)", 0)
309 DBG_OP(
"no profile to exit")
330 DBG_OP(
"(%u):", module)
333 op_state = FindOpState(module);
334 if (op_state != NULL)
336 retval = StartOperatorSearch(op_state);
358 BOOLEAN retval = FALSE;
363 op_state = ciop_list;
364 while (op_state != NULL)
366 if (op_state->op_info_valid &&
367 op_state->op_info.cicam_identifier == cicam_id)
369 *module = op_state->module;
373 op_state = op_state->next;
399 DBG_OP(
"(%u): slot_id=%u", module, STB_GetCIOperatorProfileSlotId(module))
400 DBG_OP(
" info_version: %u", status->info_version)
401 DBG_OP(
" nit_version: %u", status->nit_version)
402 DBG_OP(
" profile_type: %u", status->profile_type)
403 DBG_OP(
" initialised_flag: %u", status->initialised_flag)
404 DBG_OP(
" entitlement_change: %u", status->entitlement_change_flag)
405 DBG_OP(
" entitlement_valid: %u", status->entitlement_valid_flag)
406 DBG_OP(
" refresh_request: %u", status->refresh_request_flag)
407 DBG_OP(
" del system hint: 0x%02x", status->delivery_system_hint)
408 DBG_OP(
" error: %u", status->error_flag)
411 op_state = FindOpState(module);
412 if (op_state == NULL)
415 if (op_state != NULL)
418 op_state->module = module;
419 op_state->slot_id = STB_GetCIOperatorProfileSlotId(module);
420 op_state->next = ciop_list;
421 ciop_list = op_state;
424 if (op_state != NULL)
426 if (!op_state->op_status_valid || (status->initialised_flag == 0) ||
427 (op_state->op_status.info_version != status->info_version))
429 if ((status->initialised_flag != 0) && op_state->op_status_valid &&
430 (status->nit_version != op_state->op_status.nit_version))
433 op_state->op_nit_received = FALSE;
438 DBG_OP(
"(%u): Requesting operator info", module)
439 STB_CIRequestOperatorInfo(module);
444 if ((status->initialised_flag == 0) ||
445 (status->refresh_request_flag != STB_CI_REFRESH_NOT_REQUIRED))
449 memset(&op_search, 0,
sizeof(op_search));
453 if ((status->initialised_flag == 0) ||
454 (status->refresh_request_flag == STB_CI_REFRESH_REQUIRED_IMMEDIATE))
456 op_search.refresh_request = CIP_OPERATOR_SEARCH_IMMEDIATE;
458 else if (status->refresh_request_flag == STB_CI_REFRESH_REQUIRED_SCHEDULED)
460 if (status->refresh_request_date.mjd != 0)
462 op_search.refresh_request = CIP_OPERATOR_SEARCH_SCHEDULED;
463 op_search.refresh_date = status->refresh_request_date.mjd;
464 op_search.refresh_hour = status->refresh_request_time.hour;
465 op_search.refresh_min = status->refresh_request_time.minute;
466 op_search.
cicam_id = op_state->op_info.cicam_identifier;
476 op_search.refresh_request = CIP_OPERATOR_SEARCH_DEFERRED;
481 if (RequestOperatorSearch(module,&op_search))
484 StartOperatorSearch(op_state);
488 else if ((op_state->op_status_valid &&
489 (op_state->op_status.nit_version != status->nit_version)) ||
490 (status->entitlement_change_flag &&
491 (status->refresh_request_flag == STB_CI_REFRESH_NOT_REQUIRED)))
494 DBG_OP(
"(%u): Requesting operator NIT", module)
495 op_state->op_nit_received = FALSE;
496 STB_CIRequestOperatorNit(module);
501 memcpy(&op_state->op_status, status,
sizeof(S_STB_CI_OPERATOR_STATUS));
502 op_state->op_status_valid = TRUE;
506 DBG_OP(
"(%u): unrecognised operator module", module)
521 S_STB_CI_OPERATOR_INFO *info)
529 DBG_OP(
"(%u, version=%u)", module, info_version)
532 DBG_OP(
" cicam_onet_id: 0x%04x", info->cicam_original_network_id)
533 DBG_OP(
" cicam_identifier: 0x%08x", info->cicam_identifier)
534 DBG_OP(
" char_code_table: %u", info->character_code_table)
535 DBG_OP(
" encoding_type_id: 0x%02x", info->encoding_type_id)
536 DBG_OP(
" iso lang_code: %c%c%c", info->iso_639_language_code[0], info->iso_639_language_code[1],
537 info->iso_639_language_code[2])
538 DBG_OP(
" eit_present_following_usage: %u", info->eit_present_following_usage)
539 DBG_OP(
" eit_schedule_usage: %u", info->eit_schedule_usage)
540 DBG_OP(
" profile name len: %u", info->profile_name_length)
541 if (info->profile_name != NULL)
543 DBG_OP(
" profile_name: \"%.*s\"", info->profile_name_length, info->profile_name)
548 op_state = FindOpState(module);
549 if (op_state != NULL)
551 if ((op_state->op_status.initialised_flag == 0) ||
552 (op_state->op_status.refresh_request_flag != STB_CI_REFRESH_NOT_REQUIRED))
555 memset(&op_search, 0,
sizeof(op_search));
559 if ((op_state->op_status.initialised_flag == 0) ||
560 (op_state->op_status.refresh_request_flag == STB_CI_REFRESH_REQUIRED_IMMEDIATE))
562 op_search.refresh_request = CIP_OPERATOR_SEARCH_IMMEDIATE;
564 else if (op_state->op_status.refresh_request_flag == STB_CI_REFRESH_REQUIRED_SCHEDULED)
566 if (op_state->op_status.refresh_request_date.mjd != 0)
568 op_search.refresh_request = CIP_OPERATOR_SEARCH_SCHEDULED;
569 op_search.refresh_date = op_state->op_status.refresh_request_date.mjd;
570 op_search.refresh_hour = op_state->op_status.refresh_request_time.hour;
571 op_search.refresh_min = op_state->op_status.refresh_request_time.minute;
572 op_search.
cicam_id = info->cicam_identifier;
582 op_search.refresh_request = CIP_OPERATOR_SEARCH_DEFERRED;
587 if (RequestOperatorSearch(module,&op_search))
590 StartOperatorSearch(op_state);
595 if ((op_state->op_status.profile_type == 1) &&
596 (op_state->op_status.refresh_request_flag != STB_CI_REFRESH_REQUIRED_IMMEDIATE) &&
597 (op_state->op_status.initialised_flag == 1) && !op_state->op_nit_received)
600 DBG_OP(
"(%u): No NIT, or entitlement changed, requesting operator NIT", module)
601 STB_CIRequestOperatorNit(module);
604 if ((op_module != INVALID_MODULE) && op_state->op_info_valid &&
605 (op_state->op_info.character_code_table != info->character_code_table))
608 DBG_OP(
"(%u): Setting character table 0x%x", module, info->character_code_table)
613 if (op_state->op_info_valid && (op_state->op_info.profile_name != NULL))
616 op_state->op_info.profile_name = NULL;
617 op_state->op_info.profile_name_length = 0;
623 memcpy(&op_state->op_info, info,
sizeof(S_STB_CI_OPERATOR_INFO));
625 if (info->profile_name != NULL)
627 if (info->profile_name_length > 0)
629 if ((op_state->op_info.profile_name =
STB_GetMemory(info->profile_name_length)) != NULL)
631 memcpy(op_state->op_info.profile_name, info->profile_name, info->profile_name_length);
635 op_state->op_info.profile_name_length = 0;
640 op_state->op_info.profile_name = NULL;
644 if (!op_state->op_info_valid)
648 DBG_OP(
"(%u): Inform DVB that CAM is available for profile onet=0x%04x, cam_id=0x%08x",
649 module, info->cicam_original_network_id, info->cicam_identifier)
651 ADB_MarkCIModulePresent(info->cicam_original_network_id, info->cicam_identifier);
654 op_state->op_info_valid = TRUE;
658 op_state->op_info_valid = FALSE;
662 op_state->op_status.info_version = info_version;
667 DBG_OP(
"(%u): unrecognised operator module", module)
694 DBG_OP(
"(%u, desc_loop_len=%u)", module, desc_loop_len)
696 op_state = FindOpState(module);
697 if (op_state != NULL)
699 if (op_state->op_search_started)
704 if ((op_state->op_desc_loop = (U8BIT *)
STB_GetMemory(desc_loop_len)) != NULL)
706 memcpy(op_state->op_desc_loop, desc_loop, desc_loop_len);
707 op_state->op_desc_loop_len = desc_loop_len;
708 op_state->op_desc_num = 0;
710 PerformOperatorTune(op_state);
715 DBG_OP(
"(%u): Received operator tune request but search hasn't been started", module)
720 DBG_OP(
"(%u): unrecognised operator module", module)
740 DBG_OP(
"(%u)", module)
741 DBG_OP(
" info_version: %u", status->info_version)
742 DBG_OP(
" nit_version: %u", status->nit_version)
743 DBG_OP(
" profile_type: %u", status->profile_type)
744 DBG_OP(
" initialised_flag: %u", status->initialised_flag)
745 DBG_OP(
" entitlement_change: %u", status->entitlement_change_flag)
746 DBG_OP(
" entitlement_valid: %u", status->entitlement_valid_flag)
747 DBG_OP(
" refresh_request: %u", status->refresh_request_flag)
748 DBG_OP(
" del system hint: 0x%02x", status->delivery_system_hint)
749 DBG_OP(
" error: %u", status->error_flag)
752 op_state = FindOpState(module);
753 if (op_state != NULL)
758 if (status->error_flag != STB_CI_OPERATOR_CANCELLED)
761 op_state->op_nit_received = FALSE;
765 if (status->error_flag == STB_CI_OPERATOR_NO_ERROR)
767 if (!op_state->op_info_valid || (op_state->op_status.info_version != status->info_version))
770 DBG_OP(
"(%u): Requesting operator info", module)
771 STB_CIRequestOperatorInfo(module);
776 DBG_OP(
"(%u): Requesting operator NIT", module)
777 STB_CIRequestOperatorNit(module);
782 memcpy(&op_state->op_status, status,
sizeof(S_STB_CI_OPERATOR_STATUS));
783 op_state->op_status_valid = TRUE;
786 STB_ERSendEvent(FALSE, FALSE, EV_CLASS_CI, EV_TYPE_CI_OPERATOR_SEARCH_FINISHED, NULL, 0);
790 DBG_OP(
"(%u): unrecognised operator module", module)
816 U16BIT l, section_size;
821 DBG_OP(
"(%u, nit_size=%u)", module, nit_loop_length)
824 op_state = FindOpState(module);
825 if (op_state != NULL)
827 if (nit_loop_length != 0)
832 while (l < nit_loop_length)
834 ptr = nit_sections + l;
835 section_size = ((ptr[1] & 0xf) << 8) + ptr[2] + 3;
842 sect->sect_num = ptr[6];
843 sect->data_len = section_size;
844 memcpy(§->data_start, ptr, section_size);
845 table_rec.num_sect++;
852 table_rec.path = INVALID_RES_ID;
853 table_rec.tid = nit_sections[0];
854 table_rec.version = (nit_sections[5] >> 1) & 0x1f;
855 table_rec.xtid = (nit_sections[3] << 8) + nit_sections[4];
856 table_rec.section_list = sect;
861 nit.table = nit_table;
862 nit.cicam_onet_id = op_state->op_info.cicam_original_network_id;
863 nit.cicam_identifier = op_state->op_info.cicam_identifier;
864 nit.lang_code = ConvertLangCode(op_state->op_info.iso_639_language_code);
865 nit.profile_name_length = op_state->op_info.profile_name_length;
866 nit.profile_name = op_state->op_info.profile_name;
868 ProcessNit(module,&nit);
870 if (op_state->op_status.entitlement_change_flag)
873 DBG_OP(
"(%u): Acknowledging entitlement change", module)
874 STB_CISendEntitlementAck(module);
888 DBG_OP(
"(%u): Failed to allocate memory to parse the NIT", module)
894 DBG_OP(
"(%u): unrecognised operator module", module)
916 op_state = FindOpState(module);
918 if (op_state == NULL)
925 DBG_OP(
"(%u)", module)
931 reply_data.path = path;
932 reply_data.module = module;
933 reply_data.reply = 0;
934 STB_ERSendEvent(FALSE, FALSE, EV_CLASS_CI, EV_TYPE_CI_RELEASE_REPLY, &reply_data,
sizeof(reply_data));
955 S_STB_CI_OPERATOR_TUNE_STATUS op_status;
961 DBG_OP(
"(%u, status=%u)", module, status)
965 op_state = FindOpState(module);
966 if (op_state != NULL)
968 if (op_state->tune_started)
970 op_state->tune_started = FALSE;
972 if (status == STB_CI_TUNE_OK)
975 op_status.descriptor_number = op_state->op_desc_num;
976 op_status.status = STB_CI_OPERATOR_TUNE_OK;
977 op_status.desc_loop = op_state->op_current_location;
978 op_status.desc_loop_len = op_state->op_current_loc_len;
980 if (path != INVALID_RES_ID)
989 DBG_OP(
"Path %u doesn't have a tuner!", path)
990 op_status.signal_strength = 0;
991 op_status.signal_quality = 0;
996 DBG_OP(
"Tuner locked but invalid decode path")
997 op_status.signal_strength = 0;
998 op_status.signal_quality = 0;
1001 retval = STB_CISendOperatorTuneStatus(op_state->module, &op_status);
1003 if (op_state->op_current_location != NULL)
1006 op_state->op_current_location = NULL;
1007 op_state->op_current_loc_len = 0;
1013 PerformOperatorTune(op_state);
1018 DBG_OP(
" The tune was not started by module %u", module)
1035 op_state = ciop_list;
1036 while (op_state != NULL && module != op_state->module)
1038 op_state = op_state->next;
1047 static BOOLEAN StartOperatorSearch(
S_OP_STATUS *op_state)
1051 S_STB_CI_SEARCH_START_INFO search_info;
1053 FUNCTION_START(StartOperatorSearch);
1058 RequestHostInfo(&host_info);
1060 if (PrepareSearchInfo(&host_info, &search_info))
1063 op_state->host_delivery_types = host_info.delivery_types;
1065 if (STB_CIRequestOperatorSearchStart(op_state->module, &search_info))
1067 DBG_OP(
"Starting operator search to setup network")
1072 op_state->op_nit_received = FALSE;
1073 op_state->op_search_started = TRUE;
1074 op_state->op_desc_loop_len = 0;
1075 op_state->op_desc_loop = NULL;
1081 DBG_OP(
"Failed to start operator search")
1084 if (search_info.service_type != NULL)
1088 if (search_info.delivery_capability != NULL)
1092 if (search_info.application_capability != NULL)
1099 DBG_OP(
"PrepareSearchInfo failed")
1102 FUNCTION_FINISH(StartOperatorSearch);
1115 static BOOLEAN PrepareSearchInfo(
S_CIP_HOST_INFO *host_info, S_STB_CI_SEARCH_START_INFO *search_info)
1120 FUNCTION_START(PrepareSearchInfo);
1124 search_info->unattended_flag = host_info->standby;
1127 if ((search_info->service_type =
STB_GetMemory(host_info->num_service_types)) != NULL)
1129 search_info->service_type_loop_length = host_info->num_service_types;
1132 if ((host_info->service_types & CIP_SERVICE_TYPE_TV) != 0)
1134 search_info->service_type[counter] = 0x01;
1137 if ((host_info->service_types & CIP_SERVICE_TYPE_RADIO) != 0)
1139 search_info->service_type[counter] = 0x02;
1142 if ((host_info->service_types & CIP_SERVICE_TYPE_TELETEXT) != 0)
1144 search_info->service_type[counter] = 0x03;
1147 if ((host_info->service_types & CIP_SERVICE_TYPE_AVC_RADIO) != 0)
1149 search_info->service_type[counter] = 0x0a;
1152 if ((host_info->service_types & CIP_SERVICE_TYPE_DATA) != 0)
1154 search_info->service_type[counter] = 0x0c;
1157 if ((host_info->service_types & CIP_SERVICE_TYPE_HD_TV) != 0)
1159 search_info->service_type[counter] = 0x11;
1162 if ((host_info->service_types & CIP_SERVICE_TYPE_AVC_SD_TV) != 0)
1164 search_info->service_type[counter] = 0x16;
1167 if ((host_info->service_types & CIP_SERVICE_TYPE_AVC_HD_TV) != 0)
1169 search_info->service_type[counter] = 0x19;
1174 search_info->service_type_loop_length = 0;
1180 if ((host_info->delivery_types & CIP_DELIVERY_TYPE_DVBT) != 0)
1184 if ((host_info->delivery_types & CIP_DELIVERY_TYPE_DVBT2) != 0)
1188 if ((host_info->delivery_types & CIP_DELIVERY_TYPE_DVBC) != 0)
1192 if ((host_info->delivery_types & CIP_DELIVERY_TYPE_DVBC2) != 0)
1196 if ((host_info->delivery_types & CIP_DELIVERY_TYPE_DVBS) != 0)
1200 if ((host_info->delivery_types & CIP_DELIVERY_TYPE_DVBS2) != 0)
1205 if ((search_info->delivery_capability =
STB_GetMemory(counter)) != NULL)
1207 search_info->delivery_capability_loop_length = counter;
1210 if ((host_info->delivery_types & CIP_DELIVERY_TYPE_DVBT) != 0)
1212 search_info->delivery_capability[counter] = 0x5a;
1215 if ((host_info->delivery_types & CIP_DELIVERY_TYPE_DVBT2) != 0)
1217 search_info->delivery_capability[counter] = 0x7f;
1218 search_info->delivery_capability[counter + 1] = 0x04;
1221 if ((host_info->delivery_types & CIP_DELIVERY_TYPE_DVBC) != 0)
1223 search_info->delivery_capability[counter] = 0x44;
1226 if ((host_info->delivery_types & CIP_DELIVERY_TYPE_DVBC2) != 0)
1228 search_info->delivery_capability[counter] = 0x7f;
1229 search_info->delivery_capability[counter + 1] = 0x0d;
1232 if ((host_info->delivery_types & CIP_DELIVERY_TYPE_DVBS) != 0)
1234 search_info->delivery_capability[counter] = 0x43;
1237 if ((host_info->delivery_types & CIP_DELIVERY_TYPE_DVBS2) != 0)
1239 search_info->delivery_capability[counter] = 0x79;
1244 search_info->delivery_capability_loop_length = 0;
1250 if ((host_info->app_types & CIP_APP_TYPE_MHEG) != 0)
1254 if ((host_info->app_types & CIP_APP_TYPE_HBBTV) != 0)
1258 if ((host_info->app_types & CIP_APP_TYPE_OIPF) != 0)
1265 if ((search_info->application_capability =
STB_GetMemory(counter)) != NULL)
1267 search_info->application_capability_loop_length = counter;
1270 if ((host_info->app_types & CIP_APP_TYPE_MHEG) != 0)
1272 search_info->application_capability[counter] = 0x01;
1273 search_info->application_capability[counter + 1] = 0x06;
1276 if ((host_info->app_types & CIP_APP_TYPE_HBBTV) != 0)
1278 search_info->application_capability[counter] = 0x01;
1279 search_info->application_capability[counter + 1] = 0x23;
1282 if ((host_info->app_types & CIP_APP_TYPE_OIPF) != 0)
1284 search_info->application_capability[counter] = 0x01;
1285 search_info->application_capability[counter + 1] = 0x50;
1290 search_info->application_capability_loop_length = 0;
1296 search_info->application_capability_loop_length = 0;
1297 search_info->application_capability = NULL;
1300 FUNCTION_FINISH(PrepareSearchInfo);
1305 static BOOLEAN ValidateFrequency(SI_DELIVERY_SYS_DESC_TYPE del_type, U32BIT frequency)
1307 BOOLEAN valid, done;
1309 E_STB_TUNE_SYSTEM_TYPE type;
1310 U32BIT tnr_min_freq;
1311 U32BIT tnr_max_freq;
1313 FUNCTION_START(ValidateFrequency);
1319 for (tuner = 0; tuner < n; tuner++)
1324 case TUNE_SYSTEM_TYPE_DVBT:
1325 case TUNE_SYSTEM_TYPE_DVBT2:
1327 if (del_type == SI_DEL_SYS_DESC_TYPE_TERR)
1333 case TUNE_SYSTEM_TYPE_DVBS:
1334 case TUNE_SYSTEM_TYPE_DVBS2:
1336 if (del_type == SI_DEL_SYS_DESC_TYPE_SAT)
1342 case TUNE_SYSTEM_TYPE_DVBC:
1344 if (del_type == SI_DEL_SYS_DESC_TYPE_CABLE)
1364 DBG_OP(
"min=%u, max=%u", tnr_min_freq, tnr_max_freq)
1365 if ((frequency > tnr_min_freq) && (frequency < tnr_max_freq))
1371 DBG_OP(
"frequency=%u del_type=%d valid=%s", frequency, del_type,
1372 valid ?
"TRUE" :
"FALSE")
1374 FUNCTION_FINISH(ValidateFrequency);
1384 static void PerformOperatorTune(
S_OP_STATUS *op_state)
1390 U8BIT *current_location_info;
1391 U8BIT current_location_len;
1392 S_STB_CI_OPERATOR_TUNE_STATUS tune_status;
1393 SI_DELIVERY_SYS_DESC_TYPE del_type;
1395 BOOLEAN send_status;
1399 FUNCTION_START(PerformOperatorTune);
1401 if (op_state->op_current_location != NULL)
1404 op_state->op_current_location = NULL;
1405 op_state->op_current_loc_len = 0;
1408 desc_ptr = op_state->op_desc_loop;
1409 end_ptr = desc_ptr + op_state->op_desc_loop_len;
1412 for (desc_num = 0; (desc_num < op_state->op_desc_num) && (desc_ptr < end_ptr); )
1414 desc_len = *(desc_ptr + 1);
1415 desc_ptr += (desc_len + 2);
1418 if (*desc_ptr != 0x79)
1424 if (desc_ptr < end_ptr)
1426 send_status = FALSE;
1429 while (desc_ptr < end_ptr)
1431 desc_len = *(desc_ptr + 1);
1433 if (*desc_ptr == 0x43)
1437 if ((desc_ptr + desc_len + 2 < end_ptr) && (*(desc_ptr + desc_len + 2) == 0x79))
1439 desc_len += *(desc_ptr + desc_len + 3) + 2;
1444 if ((current_location_info = (U8BIT *)
STB_GetMemory(desc_len + 2)) != NULL)
1446 memcpy(current_location_info, desc_ptr, desc_len + 2);
1447 current_location_len = desc_len + 2;
1453 desc_ptr += (desc_len + 2);
1455 if (desc_ptr == end_ptr)
1458 op_state->op_desc_num = 0xFF;
1464 op_state->op_desc_num++;
1474 case SI_DEL_SYS_DESC_TYPE_TERR:
1475 if (desc->terr.is_t2)
1477 if ((op_state->host_delivery_types & CIP_DELIVERY_TYPE_DVBT2) == 0)
1480 tune_status.status = STB_CI_OPERATOR_TUNE_NOT_SUPPORTED;
1485 if ((desc->terr.u.t2.num_cells > 0) &&
1486 (desc->terr.u.t2.cell[0].num_freqs > 0))
1488 frequency = desc->terr.u.t2.cell[0].freq_hz[0] / 1000;
1498 if ((op_state->host_delivery_types & CIP_DELIVERY_TYPE_DVBT) == 0)
1501 tune_status.status = STB_CI_OPERATOR_TUNE_NOT_SUPPORTED;
1506 frequency = desc->terr.u.t1.freq_hz / 1000;
1511 case SI_DEL_SYS_DESC_TYPE_CABLE:
1512 if ((op_state->host_delivery_types & CIP_DELIVERY_TYPE_DVBC) == 0)
1515 tune_status.status = STB_CI_OPERATOR_TUNE_NOT_SUPPORTED;
1520 frequency = desc->cable.freq_hz / 1000;
1524 case SI_DEL_SYS_DESC_TYPE_SAT:
1525 if ((op_state->host_delivery_types & CIP_DELIVERY_TYPE_DVBS) == 0)
1528 tune_status.status = STB_CI_OPERATOR_TUNE_NOT_SUPPORTED;
1534 frequency = desc->sat.freq_hz * 1000;
1541 send_status = !ValidateFrequency(del_type, frequency);
1544 tune_status.status = STB_CI_OPERATOR_TUNE_INVALID;
1557 op_state->tune_started = TRUE;
1559 op_state->op_current_location = current_location_info;
1560 op_state->op_current_loc_len = current_location_len;
1562 memset(&tune_del_sys, 0,
sizeof(tune_del_sys));
1563 tune_del_sys.type = del_type;
1564 tune_del_sys.desc = desc;
1571 tune_status.status = STB_CI_OPERATOR_TUNE_INVALID;
1580 tune_status.descriptor_number = op_state->op_desc_num;
1581 tune_status.signal_strength = 0;
1582 tune_status.signal_quality = 0;
1583 tune_status.desc_loop = current_location_info;
1584 tune_status.desc_loop_len = current_location_len;
1586 STB_CISendOperatorTuneStatus(op_state->module, &tune_status);
1595 tune_status.descriptor_number = 0xff;
1596 tune_status.signal_strength = 0;
1597 tune_status.signal_quality = 0;
1598 tune_status.status = STB_CI_OPERATOR_TUNE_NO_SIGNAL;
1599 tune_status.desc_loop_len = 0;
1600 tune_status.desc_loop = NULL;
1602 STB_CISendOperatorTuneStatus(op_state->module, &tune_status);
1605 if (op_state->op_desc_loop != NULL)
1608 op_state->op_desc_loop = NULL;
1609 op_state->op_desc_loop_len = 0;
1613 FUNCTION_FINISH(PerformOperatorTune);
1616 static U32BIT ConvertLangCode(U8BIT *data)
1622 FUNCTION_START(ConvertLangCode);
1625 for (i = 0; i < 3; i++)
1629 if ((code_char >=
'A') && (code_char <=
'Z'))
1633 lcode = (lcode << 8) | code_char;
1636 FUNCTION_FINISH(ConvertLangCode);
1649 static U8BIT GetCharacterCodeTable(S_STB_CI_OPERATOR_INFO *op_info)
1653 FUNCTION_START(GetCharacterCodeTable);
1658 if ((op_info->character_code_table >= 1) && (op_info->character_code_table <= 11))
1663 table = op_info->character_code_table + 4;
1665 else if (op_info->character_code_table == 0x10)
1668 table = (op_info->second_byte_value << 8) | (op_info->third_byte_value);
1671 FUNCTION_FINISH(GetCharacterCodeTable);
1687 U16BIT *destination_num_linkage_desc)
1691 FUNCTION_START(CopyLinkageDesc);
1694 if (desc_ptr != NULL)
1696 desc_ptr->next = NULL;
1697 desc_ptr->tran_id = source_desc_entry->tran_id;
1698 desc_ptr->orig_net_id = source_desc_entry->orig_net_id;
1699 desc_ptr->serv_id = source_desc_entry->serv_id;
1700 desc_ptr->link_type = source_desc_entry->link_type;
1701 desc_ptr->data_length = source_desc_entry->data_length;
1703 if (source_desc_entry->data_length != 0)
1705 memcpy(&(desc_ptr->data), &(source_desc_entry->data), source_desc_entry->data_length);
1709 if (*destination_last_entry == NULL)
1712 *destination_list_head = desc_ptr;
1717 (*destination_last_entry)->next = desc_ptr;
1719 *destination_last_entry = desc_ptr;
1720 (*destination_num_linkage_desc)++;
1722 DBG_OP(
"Linkage desc: tid=0x%04x, onid=0x%04x, sid=0x%04x, type=%d, dlen=%d",
1723 desc_ptr->tran_id, desc_ptr->orig_net_id, desc_ptr->serv_id,
1724 desc_ptr->link_type, desc_ptr->data_length)
1727 FUNCTION_FINISH(CopyLinkageDesc);
1738 FUNCTION_START(DeleteLinkageDescriptorArray);
1740 desc_ptr = list_ptr;
1741 while (desc_ptr != NULL)
1743 tmp_ptr = desc_ptr->next;
1748 FUNCTION_FINISH(DeleteLinkageDescriptorArray);
1759 FUNCTION_START(GetServiceFromLcn);
1761 while (s_ptr != NULL)
1763 if (s_ptr->allocated_lcn == lcn)
1769 FUNCTION_FINISH(GetServiceFromLcn);
1780 static U8BIT GetFreeLcns(U16BIT start_lcn, U16BIT *free_lcns)
1783 U16BIT num_services, nx, lcn;
1784 U16BIT *existing_lcns;
1787 FUNCTION_START(GetFreeLcns);
1794 if (num_services != 0 && free_lcns != NULL)
1797 if (existing_lcns != NULL)
1800 for (nx = 0; nx != num_services && s_ptr != NULL; nx++)
1802 existing_lcns[nx] = s_ptr->allocated_lcn;
1808 for (nx = 0; nx != num_services; nx++)
1810 if (existing_lcns[nx] == lcn)
1815 if (nx == num_services)
1818 free_lcns[num_found] = lcn;
1824 while (++lcn <= 9999)
1826 for (nx = 0; nx != num_services; nx++)
1828 if (existing_lcns[nx] == lcn)
1833 if (nx == num_services)
1836 free_lcns[num_found] = lcn;
1838 if (num_found == CIP_NUM_FREE_LCNS)
1847 FUNCTION_FINISH(GetFreeLcns);
1871 dlen = 5 + event_info_len;
1872 if (name_str != NULL)
1874 dlen += name_str->nbytes;
1877 if (event_desc != NULL)
1881 data = (U8BIT *)(event_desc + 1);
1882 event_desc->desc_data = data;
1883 data[0] = SHORT_EVENT_DTAG;
1885 data[2] = (lang >> 16) & 0xFF;
1886 data[3] = (lang >> 8) & 0xFF;
1887 data[4] = lang & 0xFF;
1889 if (name_str != NULL)
1892 dlen = name_str->nbytes;
1895 memcpy(data, name_str->str_ptr, dlen);
1905 dlen = event_info_len;
1907 memcpy(data, event_info, dlen);
1908 e_ptr->desc_list_head = event_desc;
1909 e_ptr->desc_list_tail = event_desc;
1912 e_ptr->duration = DHMS_CREATE(0, 23, 59, 59);
1931 static S_STB_CI_OPERATOR_NIT_MANAGEMENT_SERVICE_ITEM_DATA *
1936 S_STB_CI_OPERATOR_NIT_MANAGEMENT_SERVICE_ITEM_DATA *s_item;
1938 FUNCTION_START(AddVirtualChannel);
1939 if (!STB_CIIsMmiEngineRegistered(v_chan->app_domain_id))
1941 s_item =
STB_AppGetMemory(
sizeof(S_STB_CI_OPERATOR_NIT_MANAGEMENT_SERVICE_ITEM_DATA));
1944 s_item->channel_issue_type = STB_CI_OPERATOR_NIT_DOMAIN_NOT_SUPPORTED;
1945 s_item->logical_channel_number = v_chan->lcn;
1946 if (v_chan->name_str != NULL)
1948 s_item->length_service_name = v_chan->name_str->nbytes;
1949 s_item->service_name = v_chan->name_str->str_ptr;
1953 s_item->length_service_name = 0;
1954 s_item->service_name = NULL;
1956 s_item->number_free_lcn = 0;
1957 s_item->free_lcn = NULL;
1962 s_ptr = GetServiceFromLcn(v_chan->lcn);
1966 s_item =
STB_AppGetMemory(
sizeof(S_STB_CI_OPERATOR_NIT_MANAGEMENT_SERVICE_ITEM_DATA));
1969 s_item->channel_issue_type = STB_CI_OPERATOR_NIT_LCN_COLLISION;
1970 s_item->logical_channel_number = v_chan->lcn;
1971 if (v_chan->name_str != NULL)
1973 s_item->length_service_name = v_chan->name_str->nbytes;
1974 s_item->service_name = v_chan->name_str->str_ptr;
1978 s_item->length_service_name = 0;
1979 s_item->service_name = NULL;
1981 s_item->free_lcn = (U16BIT *)
STB_AppGetMemory(CIP_NUM_FREE_LCNS *
sizeof(U16BIT));
1982 s_item->number_free_lcn = GetFreeLcns(v_chan->lcn, s_item->free_lcn);
1990 t_ptr = DBDEF_AddVirtualTransportRec(network);
1995 s_ptr->new_service = TRUE;
1996 s_ptr->serv_lcn = v_chan->lcn;
1997 s_ptr->allocated_lcn = v_chan->lcn;
1999 if (v_chan->name_str != NULL)
2004 if (v_chan->provider_str != NULL)
2008 if (v_chan->event_info_len != 0)
2010 s_ptr->now_event = CreateVirtualEventRec(v_chan->name_str, v_chan->event_info, v_chan->event_info_len);
2015 DBG_OP(
"failed to create Virtual channel");
2021 DBG_OP(
"failed to create Virtual transport");
2025 FUNCTION_FINISH(AddVirtualChannel);
2047 U16BIT profile_name_bytes;
2050 S_STB_CI_OPERATOR_NIT_MANAGEMENT_SERVICE_ITEM_DATA *serv_items;
2051 U8BIT serv_item_count;
2053 FUNCTION_START(ProcessNit);
2058 DBDEF_PushCIPlusProfile(nit->cicam_onet_id, nit->cicam_identifier);
2061 if ((n_ptr = DBDEF_FindNetworkForCIPlusProfile(nit->cicam_onet_id, nit->cicam_identifier)) == NULL)
2065 DBG_OP(
"(%lu): Added network %p", module, n_ptr)
2067 n_ptr->profile_type = ADB_PROFILE_TYPE_CIPLUS;
2068 DBA_SetFieldValue(n_ptr->dba_rec, DBA_FIELD_PROFILE_TYPE, (U32BIT)n_ptr->profile_type);
2070 n_ptr->cicam_onet_id = nit->cicam_onet_id;
2073 n_ptr->cicam_identifier = nit->cicam_identifier;
2074 DBA_SetFieldValue(n_ptr->dba_rec, DBA_FIELD_PROFILE_CAM_ID, n_ptr->cicam_identifier);
2080 if (n_ptr->profile_name != NULL)
2082 profile_name_bytes = n_ptr->profile_name->nbytes;
2086 profile_name_bytes = 0;
2088 if ((profile_name_bytes != nit->profile_name_length + 2) ||
2089 (memcmp(n_ptr->profile_name->str_ptr, nit->profile_name, nit->profile_name_length) != 0))
2091 if (n_ptr->profile_name != NULL)
2098 if ((tmp_str = (U8BIT *)
STB_AppGetMemory(nit->profile_name_length + 2)) != NULL)
2100 memset(tmp_str, 0, nit->profile_name_length + 2);
2101 if (nit->profile_name_length > 0)
2103 memcpy(tmp_str, nit->profile_name, nit->profile_name_length);
2106 n_ptr->profile_name =
DBDEF_MakeString(nit->lang_code, tmp_str, nit->profile_name_length + 2);
2112 if (n_ptr->fav_list_id != 0)
2115 if (fav_list != NULL)
2121 if (fav_list == NULL)
2124 if (fav_list != NULL)
2126 n_ptr->fav_list_id = fav_list->list_id;
2131 n_ptr->module_present = TRUE;
2132 n_ptr->module = module;
2134 DBG_OP(
" NIT v%u", nit->table->version)
2137 n_ptr->nit_version = nit->table->version;
2139 n_ptr->nit_version_changed = FALSE;
2143 if ((n_ptr->name_str != NULL) && (nit->table->name_str != NULL))
2145 str_desc = nit->table->name_str;
2146 if (str_desc->nbytes == n_ptr->name_str->nbytes)
2148 if (memcmp(n_ptr->name_str->str_ptr, str_desc->str_ptr, n_ptr->name_str->nbytes) == 0)
2158 if (n_ptr->name_str != NULL)
2161 n_ptr->name_str = NULL;
2165 if (nit->table->name_str != NULL)
2167 str_desc = nit->table->name_str;
2168 n_ptr->name_str =
DBDEF_MakeString(nit->lang_code, str_desc->str_ptr, str_desc->nbytes);
2170 DBG_OP(
" Network name \"%s\"", str_desc->str_ptr)
2174 serv_item_count = 0;
2175 if (nit->table->ciplus_virtual_channel != NULL)
2177 serv_items = AddVirtualChannel(n_ptr, nit->table->ciplus_virtual_channel);
2178 if (serv_items != NULL)
2191 while (t_ptr != NULL)
2193 if (t_ptr->network == n_ptr)
2195 t_ptr->available = FALSE;
2201 nit_entry = nit->table->transport_list;
2202 while (nit_entry != NULL)
2207 if ((t_ptr->network == NULL) || (t_ptr->network->profile_type == ADB_PROFILE_TYPE_BROADCAST))
2222 if (nit_entry->del_sys_desc != NULL)
2225 switch (nit_entry->del_sys_desc_type)
2227 case SI_DEL_SYS_DESC_TYPE_TERR:
2229 if (nit_entry->del_sys_desc->terr.is_t2)
2231 if ((nit_entry->del_sys_desc->terr.u.t2.num_cells > 0) &&
2232 (nit_entry->del_sys_desc->terr.u.t2.cell[0].num_freqs > 0))
2235 nit_entry->del_sys_desc->terr.u.t2.plp_id, n_ptr);
2237 DBG_OP(
"Add DVB-T2 transport %p, freq %lu Hz", t_ptr, nit_entry->del_sys_desc->terr.u.t2.cell[0].freq_hz[0])
2244 DBG_OP(
"Add DVB-T transport %p, freq %lu Hz", t_ptr,nit_entry->del_sys_desc->terr.u.t1.freq_hz)
2249 case SI_DEL_SYS_DESC_TYPE_CABLE:
2252 nit_entry->del_sys_desc->cable.symbol_rate, n_ptr);
2253 DBG_OP(
"Add DVB-C transport %p, freq %lu Hz, symbol rate %u Kbits", t_ptr,
2254 nit_entry->del_sys_desc->cable.freq_hz,
2255 nit_entry->del_sys_desc->cable.symbol_rate)
2259 case SI_DEL_SYS_DESC_TYPE_SAT:
2262 nit_entry->del_sys_desc->sat.sym_rate,
2263 nit_entry->del_sys_desc->sat.polarity,
2264 nit_entry->del_sys_desc->sat.dvb_s2,
2265 nit_entry->del_sys_desc->sat.modulation, n_ptr);
2266 DBG_OP(
"Add DVB-%s transport %p, %lu Hz, symrate %u, polarity %u, modulation %u",
2267 (nit_entry->del_sys_desc->sat.dvb_s2 ?
"S2" :
"S"),
2268 t_ptr, nit_entry->del_sys_desc->sat.freq_hz,
2269 nit_entry->del_sys_desc->sat.sym_rate,
2270 nit_entry->del_sys_desc->sat.polarity,
2271 nit_entry->del_sys_desc->sat.modulation)
2286 t_ptr->available = TRUE;
2288 DBG_OP(
"Transport ids: %u/%u", t_ptr->orig_net_id, t_ptr->tran_id)
2293 while (s_ptr != NULL)
2295 s_ptr->unavailable = TRUE;
2299 serv_entry = nit_entry->ciplus_service_list;
2300 while (serv_entry != NULL)
2303 nit_entry->orig_net_id, nit_entry->tran_id, serv_entry->id);
2306 if ((s_ptr->transport->network->profile_type == ADB_PROFILE_TYPE_BROADCAST) ||
2307 (s_ptr->allocated_lcn != serv_entry->lcn))
2318 next_s_ptr = GetServiceFromLcn(serv_entry->lcn);
2319 if (next_s_ptr != NULL)
2323 (serv_item_count+1) *
sizeof(S_STB_CI_OPERATOR_NIT_MANAGEMENT_SERVICE_ITEM_DATA));
2324 if (serv_items != NULL)
2326 serv_items[serv_item_count].channel_issue_type = STB_CI_OPERATOR_NIT_LCN_COLLISION;
2327 serv_items[serv_item_count].logical_channel_number = serv_entry->lcn;
2328 if (serv_entry->name_str != NULL)
2330 serv_items[serv_item_count].length_service_name = serv_entry->name_str->nbytes;
2331 serv_items[serv_item_count].service_name = serv_entry->name_str->str_ptr;
2335 serv_items[serv_item_count].length_service_name = 0;
2336 serv_items[serv_item_count].service_name = NULL;
2338 serv_items[serv_item_count].free_lcn = (U16BIT *)
STB_AppGetMemory(CIP_NUM_FREE_LCNS *
sizeof(U16BIT));
2339 serv_items[serv_item_count].number_free_lcn = GetFreeLcns(serv_entry->lcn, serv_items[serv_item_count].free_lcn);
2348 s_ptr->new_service = TRUE;
2354 s_ptr->new_service = FALSE;
2359 s_ptr->found = TRUE;
2362 if (s_ptr->new_service || (s_ptr->serv_type != serv_entry->type))
2364 s_ptr->serv_type = serv_entry->type;
2366 if (s_ptr->new_service || (s_ptr->serv_lcn != serv_entry->lcn))
2368 s_ptr->serv_lcn = serv_entry->lcn;
2369 s_ptr->allocated_lcn = serv_entry->lcn;
2371 s_ptr->hidden = !serv_entry->visible;
2374 s_ptr->selectable = serv_entry->selectable;
2375 DBA_SetFieldValue(s_ptr->dba_rec, DBA_FIELD_SERV_SELECTABLE, s_ptr->selectable);
2379 if ((s_ptr->name_str != NULL) && (serv_entry->name_str != NULL))
2381 str_desc = serv_entry->name_str;
2382 if (str_desc->nbytes == s_ptr->name_str->nbytes)
2384 if (memcmp(s_ptr->name_str->str_ptr, str_desc->str_ptr, str_desc->nbytes) == 0)
2394 if (s_ptr->name_str != NULL)
2397 s_ptr->name_str = NULL;
2400 if (serv_entry->name_str != NULL)
2402 str_desc = serv_entry->name_str;
2403 s_ptr->name_str =
DBDEF_MakeString(nit->lang_code, str_desc->str_ptr, str_desc->nbytes);
2408 if (s_ptr->provider_str != NULL)
2411 s_ptr->provider_str = NULL;
2414 if (serv_entry->provider_str != NULL)
2416 str_desc = serv_entry->provider_str;
2417 s_ptr->provider_str =
DBDEF_MakeString(nit->lang_code, str_desc->str_ptr, str_desc->nbytes);
2420 s_ptr->unavailable = FALSE;
2422 if (s_ptr->new_service)
2424 DBG_OP(
"Added service %p, \"%s\", LCN=%u", s_ptr, s_ptr->name_str->str_ptr,s_ptr->serv_lcn)
2428 DBG_OP(
"Updated service %p, \"%s\", LCN=%u", s_ptr, s_ptr->name_str->str_ptr,s_ptr->serv_lcn)
2433 serv_entry = serv_entry->next;
2438 while (s_ptr != NULL)
2442 if (s_ptr->unavailable)
2445 DBG_OP(
"Delete unavailable service %p, nm ptr %p, LCN=%u", s_ptr, s_ptr->name_str, s_ptr->serv_lcn)
2446 if (s_ptr->name_str != NULL)
2448 DBG_OP(
" name \"%s\"", s_ptr->name_str->str_ptr)
2451 STB_ERSendEvent(FALSE, FALSE, EV_CLASS_APPLICATION, EV_SERVICE_DELETED,
2452 &s_ptr,
sizeof(s_ptr));
2461 nit_entry = nit_entry->next;
2465 DeleteLinkageDescriptorArray(n_ptr->linkage_desc_list);
2466 n_ptr->last_linkage_entry = NULL;
2467 n_ptr->num_linkage_entries = 0;
2468 n_ptr->linkage_desc_list = NULL;
2471 linkage_desc_ptr = nit->table->linkage_desc_list;
2472 while (linkage_desc_ptr != NULL)
2474 CopyLinkageDesc(linkage_desc_ptr,
2475 &n_ptr->linkage_desc_list,
2476 &n_ptr->last_linkage_entry,
2477 &n_ptr->num_linkage_entries);
2479 linkage_desc_ptr = linkage_desc_ptr->next;
2484 while (t_ptr != NULL)
2490 DBG_OP(
"Delete unavailable transport %p", t_ptr)
2497 if (fav_list != NULL)
2502 if (t_ptr->network == n_ptr)
2516 if (serv_items != NULL)
2519 STB_CISendOperatorNITManagement(module, STB_CI_OPERATOR_NIT_ERROR_NIT_ERROR, serv_item_count, serv_items);
2520 while (serv_item_count != 0)
2523 if (serv_items[serv_item_count].free_lcn != NULL)
2532 STB_CISendOperatorNITManagement(module, STB_CI_OPERATOR_NIT_ERROR_NO_ISSUE, 0, NULL);
2540 FUNCTION_FINISH(ProcessNit);
2551 U8BIT i, num_tuners;
2552 E_STB_TUNE_SYSTEM_TYPE system;
2554 FUNCTION_START(RequestHostInfo);
2559 host_info->num_service_types = 8;
2560 host_info->service_types = CIP_SERVICE_TYPE_TV | CIP_SERVICE_TYPE_RADIO |
2561 CIP_SERVICE_TYPE_TELETEXT | CIP_SERVICE_TYPE_AVC_RADIO | CIP_SERVICE_TYPE_DATA |
2562 CIP_SERVICE_TYPE_HD_TV | CIP_SERVICE_TYPE_AVC_SD_TV | CIP_SERVICE_TYPE_AVC_HD_TV;
2565 host_info->delivery_types = 0;
2568 for (i = 0; i < num_tuners; i++)
2573 case TUNE_SYSTEM_TYPE_DVBT2:
2574 host_info->delivery_types |= CIP_DELIVERY_TYPE_DVBT2;
2576 case TUNE_SYSTEM_TYPE_DVBT:
2577 host_info->delivery_types |= CIP_DELIVERY_TYPE_DVBT;
2579 case TUNE_SYSTEM_TYPE_DVBS2:
2580 host_info->delivery_types |= CIP_DELIVERY_TYPE_DVBS2;
2582 case TUNE_SYSTEM_TYPE_DVBS:
2583 host_info->delivery_types |= CIP_DELIVERY_TYPE_DVBS;
2585 case TUNE_SYSTEM_TYPE_DVBC:
2586 host_info->delivery_types |= CIP_DELIVERY_TYPE_DVBC;
2594 host_info->app_types = 0;
2595 #ifdef INTEGRATE_MHEG5 2596 host_info->app_types |= CIP_APP_TYPE_MHEG;
2599 host_info->app_types |= CIP_APP_TYPE_HBBTV;
2602 FUNCTION_FINISH(RequestHostInfo);
2617 U8BIT hours, mins, secs;
2620 FUNCTION_START(RequestOperatorSearch);
2623 if ((op_search->refresh_request == CIP_OPERATOR_SEARCH_SCHEDULED) &&
2628 op_search->refresh_min);
2631 if ((profile = ADB_FindProfileForModule(module)) != NULL)
2633 ADB_SetProfileSearchRequired(profile, TRUE, op_search->refresh_date,
2634 op_search->refresh_hour, op_search->refresh_min);
2641 case CIP_START_OPERATOR_SEARCH_NO:
2648 case CIP_START_OPERATOR_SEARCH_YES:
2655 case CIP_START_OPERATOR_SEARCH_ASK:
2660 if (op_search->refresh_request == CIP_OPERATOR_SEARCH_IMMEDIATE)
2663 STB_ERSendEvent(FALSE, FALSE, EV_CLASS_CI, EV_TYPE_CI_REQUEST_OPERATOR_SEARCH,
2664 &module,
sizeof(module));
2671 FUNCTION_FINISH(RequestOperatorSearch);
Application level CI control functions.
U32BIT ACFG_GetUndefinedLanguageBehaviour(void)
Gets the language code set by ACFG_SetUndefinedLanguageBehaviour, or 'und' if that function has not b...
CI plus support functions.
U8BIT STB_TuneGetDataIntegrity(U8BIT path)
Returns the current data integrity.
void * STB_GetMemory(U32BIT bytes)
Attempts to allocate memory from the heap.
U32DHMS STB_GCNowDHMSLocal(void)
Reads the current Local date code and time.
U8BIT STB_HWGetTunerPaths(void)
Returns the number of front end (Tuner) paths on the platform.
BOOLEAN DBA_SaveDatabase(void)
Saves any changes made to the working database to non-volatile storage. If saving to a file...
SI_NIT_TABLE * STB_SIParseNitTable(SI_TABLE_RECORD *table_rec)
Parses the Nit table supplied in TABLE_RECORD format to create a NIT_TABLE structure. Returns a pointer to the table. Application must call STB_SIReleaseNitTable to free the data.
ADB_FAVSERV_REC * DBDEF_AddServiceToFavouriteList(ADB_FAVLIST_REC *fav_list, ADB_SERVICE_REC *serv_ptr, S16BIT index)
Adds a new service to the given favourite list at the given position.
Application database control.
BOOLEAN ACI_PathOwnedByModule(U8BIT path, U32BIT module)
Checks whether path is owned by CI module.
BOOLEAN DBDEF_SetServiceType(ADB_SERVICE_REC *s_ptr, ADB_SERVICE_TYPE serv_type)
Sets the service type for the given service record.
void * STB_AppGetMemory(U32BIT bytes)
Attempts to allocate memory from the application heap.
U32BIT STB_TuneGetMinTunerFreqKHz(U8BIT path)
Returns the minimum tuner frequency in KHz.
ADB_SERVICE_REC * DBDEF_FindServiceRecByIds(ADB_SERVICE_REC *servp, U32BIT net_id, U32BIT onet_id, U32BIT tran_id, U32BIT serv_id)
Search for a service with the given IDs.
void DBDEF_SetTransportTransportId(ADB_TRANSPORT_REC *t_ptr, U16BIT tran_id)
Sets the transport ID of the given transport.
void DBA_SaveRecord(void *record)
Forces a record to be saved to non-volatile storage. Depending on the implementation, this function may not do anything if the data is updated to non-volatile storage as any records and/or fields are created or updated.
BOOLEAN ACI_RequestOperatorStatus(U32BIT module)
Called by the host to request changing to an operator profile and request the operator status to be s...
void DBDEF_PopProfile(void)
Restores a previously pushed profile.
BOOLEAN DBDEF_SetServiceName(ADB_SERVICE_REC *s_ptr, U8BIT *name)
Set or change the name of a service.
ADB_TRANSPORT_REC * DBDEF_AddSatTransportRec(U32BIT freq_hz, U16BIT symbol_rate, E_STB_DP_POLARITY polarity, BOOLEAN dvb_s2, E_STB_DP_MODULATION modulation, ADB_NETWORK_REC *network)
Adds a satellite transport record with the given frequency, symbol rate and polarity.
BOOLEAN ACI_OperatorExit(void)
Request the current operator module to exit operator profile.
ADB_FAVLIST_REC * DBDEF_AddFavouriteList(U8BIT list_id, U8BIT *name, U32BIT user_data, S16BIT index)
Creates a new favourite list and adds it to the list of favourite lists. Creation of the new list wil...
void ACI_OpNotifyOperatorStatus(U32BIT module, S_STB_CI_OPERATOR_STATUS *status)
This function is called by the CI+ stack to deliver the operator status to the host. This should be called if the CICAM supports the Operator Profile. This provides the module to be used for other Operator Profile related calls.
void DBDEF_ReleaseString(ADB_STRING *string)
Releases an ADB_STRING.
ADB_TRANSPORT_REC * DBDEF_AddTerrestrialTransportRec(U32BIT freq_hz, U8BIT plp_id, ADB_NETWORK_REC *network)
Adds a terrestrial transport record with the given frequency and PLP id.
U32BIT cicam_id
CICAM ID used when refres_request = CIP_OPERATOR_SEARCH_SCHEDULED to associate a timer to the request...
void ACI_OpNotifyOperatorNit(U32BIT module, U16BIT nit_loop_length, U8BIT *nit_sections)
This function is called by the CI+ stack to deliver the operator NIT to the host. The CICAM delivers ...
void STB_SIReleaseDelSysDesc(SI_DELIVERY_SYS_DESC *desc, SI_DELIVERY_SYS_DESC_TYPE type)
Frees the memory used by the descriptor specified.
ADB_NETWORK_REC * DBDEF_AddNetworkRec(U16BIT net_id, ADB_SATELLITE_REC *satellite)
Adds a new network record to the database with the given network ID.
void ACI_TuneToDelSysDesc(U32BIT module, S_CIP_TUNE_DEL_SYS_DESC *tune, E_CIP_TUNE_FLAGS flags)
Tune to a service/transport defined by a delivery system descriptor, possibly with PMT data...
void STB_OSMutexUnlock(void *mutex)
Unlock a mutex (a.k.a. 'leave', 'signal' or 'release')
void ACI_ScheduleOperatorSearch(U32BIT cicam_id, U16BIT date, U8BIT hour, U8BIT min)
Sets the date/time that an operator search should be started for the given module.
void DBDEF_DeleteServiceRec(ADB_SERVICE_REC *s_ptr)
Deletes specified service record.
ADB_FAVLIST_REC * DBDEF_FindFavouriteList(U8BIT list_id)
Return the favourite list with the given list id.
void STB_ERSendEvent(BOOLEAN latched, BOOLEAN repeat, U16BIT path_class, U16BIT type, void *data, U32BIT data_size)
Sends an event to event reporting control module.
void * STB_AppResizeMemory(void *ptr, U32BIT new_num_bytes)
Re-allocates a given memory area to the new size, ensuring data contained within the original memory ...
void ACI_OpNotifyOperatorInfo(U32BIT module, U8BIT info_version, S_STB_CI_OPERATOR_INFO *info)
This function is called by the CI+ stack to deliver the operator information to the host...
BOOLEAN ACI_FindOperatorProfileModule(U32BIT cicam_id, U32BIT *module)
Returns the Operator Profile module associated with a CICAM ID.
ADB_STRING * DBDEF_MakeString(U32BIT lang_code, U8BIT *str_ptr, U16BIT nbytes)
Creates an ADB_STRING, copying the given data into it. If the string passed in is NULL or the number ...
U8BIT STB_DPGetNumPaths(void)
Returns the maximum number of decode paths.
U16BIT DBDEF_GetNumServices(void)
Returns the total number of services.
U8BIT STB_TuneGetSignalStrength(U8BIT path)
Returns the current signal strength.
ADB_TRANSPORT_REC * DBDEF_GetNextTransportRec(ADB_TRANSPORT_REC *t_ptr)
Returns the transport following the one given. If the argument is NULL then the first transport will ...
void STB_FreeMemory(void *addr)
Releases previously allocated heap memory.
BOOLEAN STB_SIParseDelSysDesc(U8BIT *data, SI_DELIVERY_SYS_DESC_TYPE *type, SI_DELIVERY_SYS_DESC **desc)
Parses and allocates a system delivery descriptor which should be freed by calling STB_SIReleaseDelSy...
void DBDEF_ReleaseAccess(void)
Releases access to the app's database.
void DBDEF_SetTransportOrigNetworkId(ADB_TRANSPORT_REC *t_ptr, U16BIT orig_net_id)
Sets the original network ID of the given transport.
Debug functions header file.
void STB_OSMutexLock(void *mutex)
Lock a mutex (a.k.a. 'enter', 'wait' or 'get').
ADB_TRANSPORT_REC * DBDEF_AddCableTransportRec(U32BIT freq_hz, U32BIT symbol_rate, ADB_NETWORK_REC *network)
Adds a cable transport record with the given frequency and symbol rate.
Database access defines, structures and public functions.
void STB_GCGetGMTDateTime(U16BIT *code, U8BIT *hour, U8BIT *min, U8BIT *secs)
Reads the current GMT date code and time.
ADB_SERVICE_REC * DBDEF_GetNextServiceRec(ADB_SERVICE_REC *s_ptr)
Returns the service after the one given. If NULL is passed then the first service in the list is retu...
Application level CI - internal functions.
U32BIT STB_TuneGetMaxTunerFreqKHz(U8BIT path)
Returns the maximum tuner frequency in KHz.
U8BIT STB_DPGetPathTuner(U8BIT path)
Returns the tuner ID acquired by the given decode path.
Header file - Function prototypes for Event Reporting.
void ACI_OpNotifyOperatorSearchStatus(U32BIT module, S_STB_CI_OPERATOR_STATUS *status)
This function is called by the CI+ stack to deliver the operator search status to the host...
ADB_SERVICE_REC * DBDEF_AddServiceRec(U16BIT serv_id, ADB_TRANSPORT_REC *t_ptr)
Adds a new service record to the service database with the given service ID and parent transport...
Header for STB unicode string handling routines.
void DBDEF_RequestAccess(void)
Requests access to the app's database.
BOOLEAN DBDEF_SetServiceProviderName(ADB_SERVICE_REC *s_ptr, U8BIT *name)
Set or change the name of a service's provider.
BOOLEAN STB_GCIsFutureDateTime(U16BIT code, U8BIT hour, U8BIT min, U8BIT secs)
Tests given date and time against current GMT date and time.
void DBDEF_DeleteTransportRec(ADB_TRANSPORT_REC *t_ptr)
Deletes the given transport from the service database, deleting any service records that it's the par...
void ACI_OpSlotRemove(U8BIT slot_id)
Process CAM removal from slot for CA support.
void ACI_OpInitialise(void)
Initialise CI Operator Profile support.
ADB_SERVICE_REC * DBDEF_GetNextServiceOnTransport(ADB_SERVICE_REC *s_ptr, ADB_TRANSPORT_REC *t_ptr)
Find the next service following the given service that's on the given transport.
void DBDEF_DeleteAllServicesFromFavouriteList(ADB_FAVLIST_REC *fav_list)
Delete the all services from the given favourite list.
Header file - Function prototypes for operating system.
System Wide Global Technical Data Type Definitions.
BOOLEAN DBA_SetFieldValue(void *record, U32BIT field_id, U32BIT value)
Set the value of a record's field. The function will fail if the record doesn't exist, the record doesn't include the given field, or the field is a string value.
void STB_AppFreeMemory(void *addr)
Releases previously allocated application heap memory.
void ACI_OpNotifyOperatorTune(U32BIT module, U16BIT desc_loop_len, U8BIT *desc_loop)
This function is called by the CI+ stack to request that the host performs the tune request as descri...
BOOLEAN ACI_StartOperatorSearch(U32BIT module)
Called by the app to start an operator profile search that has been requested.
void ACFG_SetUndefinedLanguageBehaviour(U32BIT lang_code)
Sets the language code to be used when the SI descriptors contain 'und', 'qaa' or don't contain any l...
BOOLEAN ACI_OpAskRelease(U32BIT module)
Ask the opertaor module to restore replaced PIDs.
BOOLEAN DBDEF_SetServiceShortName(ADB_SERVICE_REC *s_ptr, U8BIT *name)
Set or change the short name of a service.
BOOLEAN ACI_OpTuneReply(U8BIT path, U32BIT module, E_STB_CI_TUNE_STATUS status)
This function is called by the host to send the status of the tune operation to the module...
BOOLEAN ASTE_InStandby(void)
Header file - Function prototypes for heap memory.
void * STB_OSCreateMutex(void)
Create a mutex.
ADB_TRANSPORT_REC * DBDEF_FindTransportRecByIds(ADB_TRANSPORT_REC *transp, U32BIT net_id, U32BIT onet_id, U32BIT tran_id)
Find a transport record matching the given set of IDs, starting from the given transport.
E_STB_TUNE_SYSTEM_TYPE STB_TuneGetSupportedSystemType(U8BIT path)
Returns the system type supported by the path. This function differs from STB_TuneGetSystemType which...
void DBA_LockDatabase(void)
Locks the database to prevent access from other threads or processes.
void DBA_UnlockDatabase(void)
Unlocks the database to allow other threads or processes to access it.
void STB_SetDefaultAsciiTable(U8BIT table)
Sets default ascii table to be used, if not overridden by the table index at the start of a string...
void DBA_SetRecordParent(void *record, void *parent)
Set of change the parent of the given record.
void ACI_OperatorSearchRequired(U32BIT module, BOOLEAN required)
Sets whether an operator profile search needs to be run.
Application database access functions.
void STB_SIReleaseNitTable(SI_NIT_TABLE *nit_table)
Frees the memory used by the nit table.
E_CIP_START_OPERATOR_SEARCH ACI_GetOperatorSearchMode(void)
Return the option for starting an operator profile search (yes/no/ask)
Application level CI Operator Profile functions.