50 #define DBG_CA(x, ...) STB_SPDebugWrite( "%s:%d " x, __FUNCTION__, __LINE__, ##__VA_ARGS__); 52 #define DBG_CA(x, ...) 66 U8BIT last_pmt_version;
67 U16BIT last_pmt_program;
74 static void *cica_mutex;
76 static S_CA_INFO *FindSlot(U8BIT slot_id);
77 static BOOLEAN UpdateCASystemInfo(
S_CA_INFO *slot_info, U8BIT *pmt);
99 DBG_CA(
"(slot=%u)", slot_id)
101 slot_info = FindSlot(slot_id);
102 if (slot_info != NULL)
104 slot_info->disabled = TRUE;
119 DBG_CA(
"(slot=%u)", slot_id)
125 if (slot->slot_id == slot_id)
131 pslot = &(slot->next);
145 void STB_CINotifyCaSystems(U32BIT module, U16BIT *ca_ids, U8BIT num_ca_ids)
150 FUNCTION_START(STB_CINotifyCaSystems);
152 DBG_CA(
"mod=%x slot=%u", module, STB_GetCIConditionalAccessSlotId(module))
154 slot_id = STB_GetCIConditionalAccessSlotId(module);
155 slot = FindSlot(slot_id);
156 if (slot != NULL && num_ca_ids > slot->num_ca_ids)
166 slot->slot_id = slot_id;
167 slot->disabled = FALSE;
169 slot->next = cica_slots;
176 slot->module = module;
177 slot->num_ca_ids = num_ca_ids;
178 memcpy(&slot[1], ca_ids, num_ca_ids *
sizeof(U16BIT));
181 slot->last_pmt_version = 0xFF;
182 slot->last_pmt_program = 0xFFFF;
184 STB_ERSendEvent(FALSE, FALSE, EV_CLASS_CI, EV_TYPE_CI_SLOT_STATUS_UPDATED, &slot_id,
sizeof slot_id);
187 FUNCTION_FINISH(STB_CINotifyCaSystems);
190 void STB_CINotifyPmtReply(U32BIT module, U16BIT program_number, U8BIT version_number,
191 U8BIT current_next_indicator, E_STB_CI_DESC ca_enable)
193 FUNCTION_START(STB_CINotifyPmtReply);
194 USE_UNWANTED_PARAM(module);
195 USE_UNWANTED_PARAM(program_number);
196 USE_UNWANTED_PARAM(version_number);
197 USE_UNWANTED_PARAM(current_next_indicator);
198 USE_UNWANTED_PARAM(ca_enable);
199 FUNCTION_FINISH(STB_CINotifyPmtReply);
210 U16BIT program_number;
211 U8BIT version_number;
215 DBG_CA(
"(slot=%u)", slot_id)
216 slot_info = FindSlot(slot_id);
217 if (slot_info != NULL )
219 if (slot_info->num_ca_ids != 0)
222 program_number = pmt[3] << 8 | pmt[4];
223 version_number = (pmt[5] >> 1) & 0x1f;
225 if ((slot_info->last_pmt_program != program_number) ||
226 (slot_info->last_pmt_version != version_number))
228 slot_info->last_pmt_program = program_number;
229 slot_info->last_pmt_version = version_number;
231 DBG_CA(
"mod=%x p_num=%x v_num=%x", slot_info->module, program_number, version_number)
232 STB_CIUpdatePmt(slot_info->module, pmt, TRUE, STB_CI_PMT_CMD_OK_DESCRAMBLE);
254 DBG_CA(
"(slot=%u)", slot_id)
255 slot_info = FindSlot(slot_id);
256 if (slot_info != NULL )
258 supported = UpdateCASystemInfo(slot_info, pmt_data);
272 static S_CA_INFO *FindSlot(U8BIT slot_id)
276 slot_info = cica_slots;
277 while (slot_info != NULL)
279 if (slot_info->slot_id == slot_id)
281 if (slot_info->disabled)
287 slot_info = slot_info->next;
305 static BOOLEAN UpdateCASystemInfo(
S_CA_INFO *slot_info, U8BIT *pmt)
308 U16BIT section_length;
309 U16BIT program_info_length;
310 U16BIT es_info_length;
320 FUNCTION_START(UpdateCASystemInfo);
325 if (pmt != NULL && pmt[0] == 0x02)
328 section_length = (pmt[1] << 8 | pmt[2]) & 0xfff;
331 program_info_length = (pmt[10] << 8 | pmt[11]) & 0xfff;
333 while (!supported && offset < 12 + program_info_length)
335 desc_tag = pmt[offset];
336 desc_len = pmt[offset + 1];
337 if (desc_tag == 0x09)
340 ca_system_id = pmt[offset + 2] << 8 | pmt[offset + 3];
342 ca_ids = (U16BIT*)(slot_info + 1);
343 DBG_CA(
"Found CA system %04x in program info", ca_system_id)
344 for (i = 0; i != slot_info->num_ca_ids; i++)
346 if (ca_ids[i] == ca_system_id)
348 DBG_CA(
"CA system is supported")
354 offset += 2 + desc_len;
358 while (!supported && offset < section_length - 1)
361 es_info_length = (pmt[offset] << 8 | pmt[offset + 1]) & 0xfff;
364 while (!supported && offset < es_offset + es_info_length)
366 desc_tag = pmt[offset];
367 desc_len = pmt[offset + 1];
368 if (desc_tag == 0x09)
371 ca_system_id = pmt[offset + 2] << 8 | pmt[offset + 3];
373 ca_ids = (U16BIT*)(slot_info + 1);
374 DBG_CA(
"Found CA system %04x in ES info", ca_system_id)
375 for (i = 0; i != slot_info->num_ca_ids; i++)
377 if (ca_ids[i] == ca_system_id)
379 DBG_CA(
"CA system is supported")
385 offset += 2 + desc_len;
395 DBG_CA(
"CA system is support")
399 FUNCTION_FINISH(UpdateCASystemInfo);
void STB_CiKeysDisable(U8BIT slot_id)
Disable CC keys for slot, as CAM is being removed.
void * STB_GetMemory(U32BIT bytes)
Attempts to allocate memory from the heap.
Header file - macros and function prototypes for public use.
void STB_CiCaReportPmt(U8BIT slot_id, U8BIT *pmt)
Report PMT to CI stack.
BOOLEAN STB_CiCaSystemSupported(U8BIT slot_id, U8BIT *pmt_data)
Tell whether CA descriptors were found in PMT and that CA system is supported.
void STB_OSMutexUnlock(void *mutex)
Unlock a mutex (a.k.a. 'leave', 'signal' or 'release')
Header file - macros and function prototypes for public use.
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_FreeMemory(void *addr)
Releases previously allocated heap memory.
Debug functions header file.
void STB_OSMutexLock(void *mutex)
Lock a mutex (a.k.a. 'enter', 'wait' or 'get').
void STB_CiCaInitialise(void)
CI conditional access support initialise.
Header file - Function prototypes for Event Reporting.
CI Content Control support - internal header.
void STB_CiCaDisable(U8BIT slot_id)
Disable CA for slot, as CAM is being removed.
Header file - Function prototypes for operating system.
System Wide Global Technical Data Type Definitions.
void STB_CiCaRemove(U8BIT slot_id)
Process CAM removal from slot for CA support.
Header file - Function prototypes for heap memory.
void * STB_OSCreateMutex(void)
Create a mutex.