49 #define EVENT_LATCHED_MAX 10 // Max number of outstanding latched events 51 #define INTERACTION_STACK_SIZE 1024 52 #define INTERACTION_TASK_PRIORITY 8 59 BOOLEAN (*app_func)(BOOLEAN latched, BOOLEAN repeat, U16BIT
class, U16BIT type,
void *data, U32BIT data_size);
71 static void *er_protect;
73 static ER_LATCHED latched_events[EVENT_LATCHED_MAX];
75 static void *user_interaction_sem = NULL;
76 static void *user_interaction_task = NULL;
77 static U32BIT user_interaction_timeout = 0;
78 static U32BIT last_user_interaction_time = 0;
83 static void EventCallback(BOOLEAN repeat, U16BIT path_class, U16BIT type,
void *data, U32BIT data_size);
84 static void UserInteractionTask(
void *param);
99 static void EventCallback(BOOLEAN repeat, U16BIT path_class, U16BIT type,
void *data, U32BIT data_size)
110 class = (U8BIT)(path_class & 0xff);
114 case HW_EV_CLASS_HANDSET:
116 DBGPRINT(
"handset: r=%d t=%x", repeat, type);
122 case HW_EV_CLASS_KEYPAD:
130 case HW_EV_CLASS_SCART:
134 case HW_EV_TYPE_TRUE:
136 STB_ERSendEvent(FALSE, repeat, EV_CLASS_SCART, EV_TYPE_FORCE, data, data_size);
140 case HW_EV_TYPE_FALSE:
142 STB_ERSendEvent(FALSE, repeat, EV_CLASS_SCART, EV_TYPE_DISCONNECTED, data, data_size);
148 STB_ERSendEvent(FALSE, repeat, EV_CLASS_SCART, EV_TYPE_4_3, data, data_size);
152 case HW_EV_TYPE_16_9:
154 STB_ERSendEvent(FALSE, repeat, EV_CLASS_SCART, EV_TYPE_16_9, data, data_size);
161 case HW_EV_CLASS_LNB:
163 if (type == HW_EV_TYPE_FALSE)
165 STB_ERSendEvent(TRUE, repeat, EV_CLASS_LNB, EV_TYPE_FAIL, data, data_size);
170 case HW_EV_CLASS_TUNER:
176 path = INVALID_RES_ID;
177 tuner_num = *(U8BIT *)data;
183 case HW_EV_TYPE_LOCKED:
192 case HW_EV_TYPE_NOTLOCKED:
207 case HW_EV_TYPE_LOCKED:
209 STB_ERSendEvent(FALSE, repeat, EV_CLASS_TUNE, EV_TYPE_LOCKED, data, data_size);
213 case HW_EV_TYPE_NOTLOCKED:
219 path = INVALID_RES_ID;
227 STB_ERSendEvent(FALSE, repeat, EV_CLASS_TUNE, EV_TYPE_NOTLOCKED, data, data_size);
232 case HW_EV_TYPE_SIGNAL_DATA_BAD:
234 STB_ERSendEvent(FALSE, repeat, EV_CLASS_TUNE, EV_TYPE_SIGNAL_DATA_BAD, data, data_size);
238 case HW_EV_TYPE_SIGNAL_DATA_OK:
240 STB_ERSendEvent(FALSE, repeat, EV_CLASS_TUNE, EV_TYPE_SIGNAL_DATA_OK, data, data_size);
248 case HW_EV_CLASS_DECODE:
253 if ((type == HW_EV_TYPE_AUDIO_STARTED) || (type == HW_EV_TYPE_AUDIO_STOPPED) ||
254 (type == HW_EV_TYPE_SAMPLE_STOPPED))
258 else if ((type == HW_EV_TYPE_VIDEO_STARTED) || (type == HW_EV_TYPE_VIDEO_STOPPED))
262 else if ((type == HW_EV_TYPE_AD_STARTED) || (type == HW_EV_TYPE_AD_STOPPED))
269 path = INVALID_RES_ID;
272 if (path != INVALID_RES_ID)
274 if (type == HW_EV_TYPE_AUDIO_STARTED)
277 STB_ERSendEvent(FALSE, repeat, EV_CLASS_DECODE, EV_TYPE_AUDIO_STARTED, data, data_size);
279 if (type == HW_EV_TYPE_VIDEO_STARTED)
282 STB_ERSendEvent(FALSE, repeat, EV_CLASS_DECODE, EV_TYPE_VIDEO_STARTED, data, data_size);
284 if (type == HW_EV_TYPE_AD_STARTED)
287 STB_ERSendEvent(FALSE, repeat, EV_CLASS_DECODE, EV_TYPE_AD_STARTED, data, data_size);
289 if (type == HW_EV_TYPE_AUDIO_STOPPED)
292 STB_ERSendEvent(FALSE, repeat, EV_CLASS_DECODE, EV_TYPE_AUDIO_STOPPED, data, data_size);
294 if (type == HW_EV_TYPE_VIDEO_STOPPED)
299 STB_ERSendEvent(FALSE, repeat, EV_CLASS_DECODE, EV_TYPE_VIDEO_STOPPED, data, data_size);
304 STB_ERSendEvent(FALSE, repeat, EV_CLASS_DECODE, EV_TYPE_FAIL, data, data_size);
307 if (type == HW_EV_TYPE_AD_STOPPED)
310 STB_ERSendEvent(FALSE, repeat, EV_CLASS_DECODE, EV_TYPE_AD_STOPPED, data, data_size);
312 if (type == HW_EV_TYPE_VIDEO_UNDERFLOW)
314 STB_ERSendEvent(FALSE, repeat, EV_CLASS_DECODE, EV_TYPE_VIDEO_UNDERFLOW, data, data_size);
316 if (type == HW_EV_TYPE_AUDIO_UNDERFLOW)
318 STB_ERSendEvent(FALSE, repeat, EV_CLASS_DECODE, EV_TYPE_AUDIO_UNDERFLOW, data, data_size);
320 if (type == HW_EV_TYPE_SAMPLE_STOPPED)
323 STB_ERSendEvent(FALSE, repeat, EV_CLASS_DECODE, EV_TYPE_SAMPLE_STOPPED, data, data_size);
329 case HW_EV_CLASS_DVD:
331 if (type == HW_EV_TYPE_DVD_DISK_INSERTED)
333 STB_ERSendEvent(FALSE, FALSE, EV_CLASS_DVD, EV_TYPE_DVD_DISK_INSERTED, data, data_size);
335 else if (type == HW_EV_TYPE_DVD_DISK_REMOVED)
337 STB_ERSendEvent(FALSE, FALSE, EV_CLASS_DVD, EV_TYPE_DVD_DISK_REMOVED, data, data_size);
342 case HW_EV_CLASS_DISK:
344 if (type == HW_EV_TYPE_DISK_CONNECTED)
352 STB_ERSendEvent(FALSE, FALSE, EV_CLASS_DISK, EV_TYPE_DISK_CONNECTED, data, data_size);
354 else if (type == HW_EV_TYPE_DISK_REMOVED)
362 STB_ERSendEvent(FALSE, FALSE, EV_CLASS_DISK, EV_TYPE_DISK_REMOVED, data, data_size);
364 else if (type == HW_EV_TYPE_DISK_FULL)
366 STB_ERSendEvent(FALSE, FALSE, EV_CLASS_DISK, EV_TYPE_DISK_FULL, data, data_size);
371 case HW_EV_CLASS_PVR:
375 case HW_EV_TYPE_PVR_REC_START:
376 if ((data != NULL) && (data_size ==
sizeof(U8BIT)))
392 rec_handle = STB_PVR_INVALID_HANDLE;
394 STB_ERSendEvent(FALSE, repeat, EV_CLASS_PVR, EV_TYPE_PVR_REC_START, &rec_handle,
sizeof(U32BIT));
396 case HW_EV_TYPE_PVR_REC_STOP:
398 if ((data != NULL) && (data_size ==
sizeof(U8BIT)))
409 STB_ERSendEvent(FALSE, repeat, EV_CLASS_PVR, EV_TYPE_PVR_REC_STOP, NULL, 0);
411 case HW_EV_TYPE_PVR_PLAY_START:
413 STB_ERSendEvent(FALSE, repeat, EV_CLASS_PVR, EV_TYPE_PVR_PLAY_START, &path,
sizeof(path));
415 case HW_EV_TYPE_PVR_PLAY_STOP:
417 STB_ERSendEvent(FALSE, repeat, EV_CLASS_PVR, EV_TYPE_PVR_PLAY_STOP, &path,
sizeof(path));
419 case HW_EV_TYPE_PVR_PLAY_BOF:
421 STB_ERSendEvent(FALSE, repeat, EV_CLASS_PVR, EV_TYPE_PVR_PLAY_BOF, &path,
sizeof(path));
423 case HW_EV_TYPE_PVR_PLAY_EOF:
425 STB_ERSendEvent(FALSE, repeat, EV_CLASS_PVR, EV_TYPE_PVR_PLAY_EOF, &path,
sizeof(path));
427 case HW_EV_TYPE_PVR_PLAY_NOTIFY_TIME:
437 case HW_EV_CLASS_HDMI:
441 case HW_EV_TYPE_HDMI_CONNECT:
443 STB_ERSendEvent(FALSE, repeat, EV_CLASS_HDMI, EV_TYPE_CONNECTED, data, data_size);
447 case HW_EV_TYPE_HDMI_DISCONNECT:
449 STB_ERSendEvent(FALSE, repeat, EV_CLASS_HDMI, EV_TYPE_DISCONNECTED, data, data_size);
459 case HW_EV_CLASS_PRIVATE:
462 STB_ERSendEvent(FALSE, repeat, EV_CLASS_PRIVATE, type, data, data_size);
511 void *data, U32BIT data_size))
515 event_status.app_func = func;
539 while (latch_index < EVENT_LATCHED_MAX)
542 if ((latched_events[latch_index].
class == event_class) &&
543 (latched_events[latch_index].type == event_type))
546 latched_events[latch_index].class = 0;
547 latched_events[latch_index].type = 0;
571 void STB_ERSendEvent(BOOLEAN latched, BOOLEAN repeat, U16BIT path_class, U16BIT type,
void *data, U32BIT data_size)
573 BOOLEAN do_queue_event;
583 do_queue_event = TRUE;
588 class = (U8BIT)(path_class & 0xff);
590 free_index = EVENT_LATCHED_MAX;
591 for (latch_index = 0; latch_index < EVENT_LATCHED_MAX; latch_index++)
594 if ((latched_events[latch_index].
class ==
class) &&
595 (latched_events[latch_index].type == type))
597 do_queue_event = FALSE;
601 if ((free_index == EVENT_LATCHED_MAX) && (latched_events[latch_index].class != 0))
603 free_index = latch_index;
608 if (do_queue_event && (free_index != EVENT_LATCHED_MAX))
611 latched_events[free_index].class =
class;
612 latched_events[free_index].type = type;
617 if (do_queue_event == TRUE)
620 if (event_status.app_func != NULL)
623 (*event_status.app_func)(latched, repeat, path_class, type, data, data_size);
642 if (user_interaction_timeout != timeout * 1000)
644 user_interaction_timeout = timeout * 1000;
646 if (user_interaction_task == NULL)
654 user_interaction_task =
STB_OSCreateTask(UserInteractionTask, user_interaction_sem,
655 INTERACTION_STACK_SIZE, INTERACTION_TASK_PRIORITY, (U8BIT*)
"UserInteractionTask");
668 static void UserInteractionTask(
void *sem)
675 if (user_interaction_timeout == 0)
693 if (user_interaction_timeout != 0)
698 STB_ERSendEvent(FALSE, FALSE, EV_CLASS_TIMER, EV_TYPE_USER_INTERACTION_TIMEOUT, NULL, 0);
U8BIT STB_DPPathForADDecoder(U8BIT decoder_num)
Returns the decode path that is using the given AD decoder.
void STB_DPSetAudioStatus(U8BIT path, E_STB_DP_DECODE_STATUS state)
Writes the audio status into decode path store.
U32BIT STB_OSGetClockDiff(U32BIT timestamp)
Get Difference between Given Time and Current Time.
Header file - macros and function prototypes for public use.
void * STB_OSCreateSemaphore(void)
Create a Semaphore.
U8BIT STB_DPPathForTuner(U8BIT start_path, U8BIT tuner_num)
Returns the decode path that is using the given tuner ID.
void STB_ERInitialise(void)
Initialises STB layer Event Reporting control.
void STB_ERRegisterHandler(BOOLEAN(*func)(BOOLEAN latched, BOOLEAN repeat, U16BIT class, U16BIT type, void *data, U32BIT data_size))
Called by app to register callback function for events.
void STB_ERNotifyEvent(U8BIT event_class, U16BIT event_type)
Called by app to notify consumption of latched event.
BOOLEAN STB_OSSemaphoreWaitTimeout(void *semaphore, U16BIT timeout)
Wait on Semaphore for Set Time Period in an Attempt to Acquire.
void STB_OSSemaphoreSignal(void *semaphore)
Signal a Semaphore to Release it by decrementing its counter.
void STB_DPSetADStatus(U8BIT path, E_STB_DP_DECODE_STATUS state)
Writes the AD status into decode path store.
void STB_ERSetUserInteractionTimeout(U32BIT timeout)
Sets the time, in seconds, after which the STB_EVENT_USER_INTERACTION_TIMEOUT event will be sent to i...
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.
BOOLEAN STB_PVRIsInitialised(void)
Returns Initialised status.
void STB_PVRPlaybackNotifyTime(U8BIT path)
Handles the notification received from the platform code when playback reaches a set position...
void STB_CANotifyRecordingStatus(U32BIT handle, BOOLEAN status)
This function is called when a recording starts and when it stops.
void STB_OSSemaphoreWait(void *semaphore)
Wait on Semaphore Indefinity or Until Released.
Header file - macros and function prototypes for public use.
void STB_DPSetAdditionalFrequencies(U8BIT path, U8BIT num_freqs, U32BIT *frequencies)
Sets an array of frequencies that can be tried when tuning to a transport if the tuner fails to lock ...
U8BIT STB_PVRGetPathForRecordingIndex(U8BIT rec_index)
Returns the path for the given recording index.
void STB_DPSetVideoStatus(U8BIT path, E_STB_DP_DECODE_STATUS decoder)
Writes the video status into decode path store.
U8BIT STB_DPGetPlaybackPath(void)
Returns the ID of the decode path being used for playback.
void STB_OSRegisterCallback(void(*func)(BOOLEAN, U16BIT, U16BIT, void *, U32BIT))
Register the function that will be called when STB_OSSendEvent is used.
Debug functions header file.
void STB_DPStartTune(U8BIT path)
Requests start of tuning process.
BOOLEAN STB_DPTryAdditionalFrequency(U8BIT path)
Checks to see if there's an additional frequency available on the given decode path that hasn't yet b...
Header file - Function prototypes for Event Reporting.
Glue layer between DVB and conditional access systems.
E_STB_DP_DECODE_STATUS STB_DPGetVideoStatus(U8BIT path)
Reads the video status from decode path store.
Header file - Function prototypes for operating system.
System Wide Global Technical Data Type Definitions.
BOOLEAN STB_DPGetPathCADescrambler(U8BIT path, U32BIT *handle)
Get the handle of the CA descrambler associated with the given path.
void * STB_OSCreateTask(void(*function)(void *), void *param, U32BIT stack, U8BIT priority, U8BIT *name)
Create a New Task to the calling process. Upon success, the created task runs on its own stack...
U8BIT STB_DPPathForAudioDecoder(U8BIT decoder_num)
Returns the decode path that is using the given audio decoder.
U32BIT STB_OSGetClockMilliseconds(void)
Get Current Computer Clock Time.
U32BIT STB_PVRGetHandleForRecordingIndex(U8BIT rec_index)
Returns the handle for the given recording index.
void STB_DPSetTuneStatus(U8BIT path, E_STB_DP_TUNE_STATUS state)
Writes the tuning status into decode path store.
void STB_PVRUpdateRecordings(BOOLEAN force_load)
Called when a disk is added or removed and updates the disk database and the recordings that are now ...
U8BIT STB_DPPathForVideoDecoder(U8BIT decoder_num)
Returns the decode path that is using the given video decoder.