DVBCore  17.9.0
Open Source DVB Engine
 All Data Structures Files Functions Typedefs Macros Pages
Macros | Typedefs | Enumerations | Functions
stbebutt.c File Reference

EBU Teletext driver. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <techtype.h>
#include <dbgfuncs.h>
#include <stbhwmem.h>
#include "stbebutt.h"
#include "stbhwos.h"
#include "stbheap.h"
#include "stbpes.h"
#include "stbhwosd.h"
#include "stbdpc.h"
#include "stbhwav.h"

Macros

#define _STBEBUTT_C
 
#define COLLATION_QUEUE_SIZE   400
 
#define SD_WIDTH   720
 
#define SD_HEIGHT   576
 
#define EBU_DBG(x)
 
#define EBU_PRINT(x,...)
 
#define EBU_TPRINT(x,...)
 
#define PES_DATA_FIELD_WIDTH   46
 
#define HAMMING_8_4_DATA_MASK   0x000f
 
#define HAMMING_CORRECTION_MASK   0x03f0
 
#define HAMMING_ERROR_MASK   0xfc00
 
#define HAMMING_CORRECTION_COUNT(a)   ((a & HAMMING_CORRECTION_MASK) >> 4)
 
#define HAMMING_ERROR_COUNT(a)   ((a & HAMMING_ERROR_MASK) >> 10)
 
#define COLLATION_TASK_PRIORITY   10
 
#define COLLATION_TASK_STACK_SIZE   4096
 
#define DISPLAY_TASK_PRIORITY   10
 
#define DISPLAY_TASK_STACK_SIZE   4096
 
#define CACHE_PAGE_NUMBER_MASK   0x0fff
 
#define CACHE_PAGE_FLOF_REQUESTED   0x8000
 
#define CACHE_PAGE_HISTORY_REQUESTED   0x4000
 
#define CACHE_PAGE_PREVNEXT_REQUESTED   0x2000
 
#define CACHE_PAGE_LOCKED   0x1000
 
#define PAGE_SUB_CODE_UNDEFINED   0xffff
 
#define MAX_HISTORY_CACHE_REQUESTS   32
 
#define MAX_EDITORIAL_LINKS   6
 
#define MAX_EDITORIAL_LINK_TIERS   5
 
#define NUM_NEXT_CACHE_REQUESTS   16
 
#define NUM_PREVIOUS_CACHE_REQUESTS   8
 
#define INVALID_PREVNEXT_CACHE_PAGE_NUMBER   0x1000
 
#define MAX_PAGE_HISTORY   32
 
#define PALETTE_BACKGROUND_TRANSPARENT   0
 
#define PALETTE_BACKGROUND_BLACK_FIXED   1
 
#define PALETTE_BACKGROUND_BLACK   2
 
#define PALETTE_BACKGROUND_RED   3
 
#define PALETTE_BACKGROUND_GREEN   4
 
#define PALETTE_BACKGROUND_YELLOW   5
 
#define PALETTE_BACKGROUND_BLUE   6
 
#define PALETTE_BACKGROUND_MAGENTA   7
 
#define PALETTE_BACKGROUND_CYAN   8
 
#define PALETTE_BACKGROUND_WHITE   9
 
#define PALETTE_FOREGROUND_BLACK   10
 
#define PALETTE_FOREGROUND_RED   11
 
#define PALETTE_FOREGROUND_GREEN   12
 
#define PALETTE_FOREGROUND_YELLOW   13
 
#define PALETTE_FOREGROUND_BLUE   14
 
#define PALETTE_FOREGROUND_MAGENTA   15
 
#define PALETTE_FOREGROUND_CYAN   16
 
#define PALETTE_FOREGROUND_WHITE   17
 
#define PALETTE_FOREGROUND_UNBOXED   0
 
#define PALETTE_EFFECT_ORIGIN   18
 
#define NUM_PALETTE_EFFECTS   (256 - PALETTE_EFFECT_ORIGIN)
 
#define PALETTE_EFFECT_FLASH   0x01
 
#define PALETTE_EFFECT_CONCEAL   0x02
 
#define PALETTE_EFFECT_UNDEFINED   0
 
#define FONT_INDEX_LATIN_G0_SET   0
 
#define FONT_INDEX_LATIN_G2_SUPPLIMENTARY_SET   1
 
#define FONT_INDEX_CYRILLIC_G0_SET_OPTION_1_SERBIAN_CROATIAN   2
 
#define FONT_INDEX_CYRILLIC_G0_SET_OPTION_2_RUSSIAN_BULGARIAN   3
 
#define FONT_INDEX_CYRILLIC_G0_SET_OPTION_3_UKRANIAN   4
 
#define FONT_INDEX_CYRILLIC_G2_SUPPLIMENTARY_SET   5
 
#define FONT_INDEX_GREEK_G0_SET   6
 
#define FONT_INDEX_GREEK_G2_SUPPLIMENTARY_SET   7
 
#define FONT_INDEX_ARABIC_G0_SET   8
 
#define FONT_INDEX_ARABIC_G2_SUPPLIMENTARY_SET   9
 
#define FONT_INDEX_HEBREW_G0_SET   10
 
#define FONT_INDEX_G1_BLOCK_MOSAICS_SET   11
 
#define FONT_INDEX_G3_SMOOTH_MOSAICS_LINE_DRAWING_SET   12
 
#define FONT_INDEX_UNDEFINED   13
 
#define FONT_INDEX_NATIONAL_OPTION_SUBSET   14
 
#define FONT_INDEX_NO_BITMAP   15
 
#define NATIONALITY_INDEX_CZECH_SLOVAK   0
 
#define NATIONALITY_INDEX_ENGLISH   1
 
#define NATIONALITY_INDEX_ESTONIAN   2
 
#define NATIONALITY_INDEX_FRENCH   3
 
#define NATIONALITY_INDEX_GERMAN   4
 
#define NATIONALITY_INDEX_ITALIAN   5
 
#define NATIONALITY_INDEX_LETTISH_LITHUANIAN   6
 
#define NATIONALITY_INDEX_POLISH   7
 
#define NATIONALITY_INDEX_PORTUGUESE_SPANISH   8
 
#define NATIONALITY_INDEX_RUMANIAN   9
 
#define NATIONALITY_INDEX_SERB_CROAT_SLOVENIAN   10
 
#define NATIONALITY_INDEX_SWEDISH_FINNISH   11
 
#define NATIONALITY_INDEX_TURKISH   12
 
#define NATIONALITY_INDEX_UNDEFINED   13
 
#define TELETEXT_CHARACTER_FONT_INDEX_MASK   0x0f00
 
#define TELETEXT_CHARACTER_BITMAP_INDEX_MASK   0x00ff
 
#define TELETEXT_CHARACTER_DOUBLE_HEIGHT   0x8000
 
#define TELETEXT_CHARACTER_SEPERATED_MOSAIC   0x4000
 
#define MAX_DISPLAY_ZOOM_SCALAR   2
 
#define MAX_COLUMN   40
 
#define MAX_ROWS   25
 
#define display_x_scalar   1
 
#define display_y_scalar   2
 
#define SUBTITLE_TIMEOUT   5000 /*5 secs*/
 

Typedefs

typedef enum e_page_control_state E_PAGE_CONTROL_STATE
 
typedef enum e_request_type E_REQUEST_TYPE
 
typedef enum E_PAGE_INDEX_DIGIT E_PAGE_INDEX_DIGIT
 
typedef enum e_page_scale_status E_PAGE_SCALE_STATUS
 
typedef enum e_page_reference_type E_PAGE_REFERENCE_TYPE
 
typedef struct s_page_control_info S_PAGE_CONTROL_INFO
 
typedef struct s_page_request_info S_PAGE_REQUEST_INFO
 
typedef struct s_packet_validation S_PACKET_VALIDATION
 
typedef struct s_specific_data S_SPECIFIC_DATA
 
typedef struct s_magazine_page S_MAGAZINE_PAGE
 
typedef struct s_cache_subpage S_CACHE_SUBPAGE
 
typedef struct s_cache_page S_CACHE_PAGE
 
typedef struct s_magazine_info S_MAGAZINE_INFO
 
typedef struct
s_page_reference_data 
S_PAGE_REFERENCE_DATA
 
typedef struct
s_history_cache_request 
S_HISTORY_CACHE_REQUEST
 
typedef struct
s_editorial_link_cache_request_sub_page 
S_EDITORIAL_LINK_CACHE_REQUEST_SUB_PAGE
 
typedef struct
s_editorial_link_cache_request 
S_EDITORIAL_LINK_CACHE_REQUEST
 
typedef struct s_teletext_character S_TELETEXT_CHARACTER
 
typedef struct s_palette_attribute S_PALETTE_ATTRIBUTE
 
typedef struct s_palette_alias S_PALETTE_ALIAS
 
typedef struct s_page_display_info S_PAGE_DISPLAY_INFO
 
typedef struct
s_character_set_mapping 
S_CHARACTER_SET_MAPPING
 
typedef struct
s_diacritic_equivalent 
S_DIACRITIC_EQUIVALENT
 
typedef struct
s_diacritic_substitution 
S_DIACRITIC_SUBSTITUTION
 
typedef struct
s_collation_queue_item 
S_COLLATION_QUEUE_ITEM
 

Enumerations

enum  e_page_control_state { PAGE_CONTROL_STATE_IDLE, PAGE_CONTROL_STATE_INPUT, PAGE_CONTROL_STATE_HOLD }
 
enum  e_request_type {
  REQUEST_TYPE_UNDEFINED = 0, REQUEST_TYPE_EXPLICIT, REQUEST_TYPE_INDEX, REQUEST_TYPE_NEXT_PREV_AVAILABLE,
  REQUEST_TYPE_NEXT_PREV_VISITED, REQUEST_TYPE_NEXT_PREV_SUB, REQUEST_TYPE_EDITORIAL_LINK, REQUEST_TYPE_CANCEL
}
 
enum  E_PAGE_INDEX_DIGIT {
  PAGE_INDEX_DIGIT_0, PAGE_INDEX_DIGIT_1, PAGE_INDEX_DIGIT_2, PAGE_INDEX_DIGIT_3,
  PAGE_INDEX_DIGIT_4, PAGE_INDEX_DIGIT_5, PAGE_INDEX_DIGIT_6, PAGE_INDEX_DIGIT_7,
  PAGE_INDEX_DIGIT_8, PAGE_INDEX_DIGIT_9, PAGE_INDEX_DIGIT_A, PAGE_INDEX_DIGIT_B,
  PAGE_INDEX_DIGIT_C, PAGE_INDEX_DIGIT_D, PAGE_INDEX_DIGIT_E, PAGE_INDEX_DIGIT_F,
  PAGE_INDEX_DIGIT_UNDEFINED
}
 
enum  e_page_scale_status { PAGE_SCALE_STATUS_NORMAL = 0, PAGE_SCALE_STATUS_ZOOM_TOP, PAGE_SCALE_STATUS_ZOOM_BOTTOM }
 
enum  e_page_reference_type { PAGE_REFERENCE_TYPE_HEADER, PAGE_REFERENCE_TYPE_EDITORIAL_LINK, PAGE_REFERENCE_TYPE_GLOBAL_INDEX }
 

Functions

BOOLEAN PerformPESCollation (U8BIT *data_ptr, BOOLEAN pts_valid, U8BIT *pts)
 This process is called to service the queue populated with Teletext packets by the PES collectiom callback. Here the process of analysing each data packet, and grouping these packets into whole page data blocks is perfomred,. More...
 
BOOLEAN STB_EBUTT_Initialise (void)
 This must be called to invoke the EBU TeleText driver module before all other functionality can be accessed. This initiates the relevant resources used by the driver module. As a consequence of calling this function, no TeleText processing will occur until other functions are called. It is envisaged that this function may be called within the general initialisation of the STB layer. More...
 
void STB_EBUTT_Kill (U8BIT path)
 This is the accompanying function to STB_EBUTT_Initialise( ), and is called to shut-down the EBU TeleText driver module and release the relevant resources used by the driver module. This may not be used in some implementations. More...
 
BOOLEAN STB_EBUTT_InjectData (U8BIT *data_ptr, U32BIT data_length)
 Allows teletext PES data packets to be injected by an external module, which will be decoded and displayed. More...
 
void STB_EBUTT_Start (U8BIT path, U16BIT text_pid, U8BIT magazine, U8BIT page)
 These functions are called to control whether received TeleText data is processed. Using this functionality ensures that the process of collating page information can be halted when processing resources are a consideration. It is envisaged that some implementations may wish only to collate TeleText content only when the display is being shown, whilst other designs may which to cache significant page content as a background process. Abstracting this functionality from the initialisation routines gives the option to support both solution types. More...
 
void STB_EBUTT_Stop (U8BIT path, BOOLEAN reset_cache)
 
BOOLEAN STB_EBUTT_Show (E_EBUTT_CHARACTER_SET_DESIGNATION character_set_designation, BOOLEAN navigate_to_index_page, BOOLEAN show_header)
 Called to initiate continuous display of TeleText page content. This will result in either the index page defined in the service data stream being selected, or the previously displayed page (prior to a call to STB_EBUTT_Hide( ) being made) from being reinstated. This function can be called irrespective of the use of the STB_EBUTT_Start( ) / STB_EBUTT_Stop( ) functions, but of course may result in no TeleText data being displayed if none already exists within the cache. The return value indicates whether initialisation of the display mechanism has been successful or not. More...
 
void STB_EBUTT_Hide (void)
 Called to halt the continuous display of TeleText page content, and to clear the relevant area of the application display.
 
void STB_EBUTT_SetCacheMethod (E_EBUTT_CACHING_METHOD ebutt_caching_method)
 Called to define the strategy used to determine what page content is to be displayed form the TeleText carousel content. More...
 
void STB_EBUTT_NotifyEvent (E_EBUTT_EVENT event_type)
 Called whenever a TeleText-specific event being invoked. This is used to pass relevant user input to the driver, and the enumerate type supplied is defined independently of any IR handset / keypad. More...
 
void STB_EBUTT_NotifyServiceChange (void)
 Called whenever the application permits a TV/Radio service change during a TeleText display session. This is provided because an update of the display to new page content is required.
 
void STB_EBUTT_SetDisplayBrightness (U8BIT gun_intensity)
 Called to adjust the display brightness (colour intensity) of the Teletext pages. More...
 
void STB_EBUTT_IncreaseDisplayBrightness (void)
 Called to adjust the display brightness (colour intensity) of the Teletext pages.
 
void STB_EBUTT_DecreaseDisplayBrightness (void)
 
void STB_EBUTT_SetDisplayAntiAliasing (U8BIT antialias_level)
 Called to adjust the display anti-aliasing level of the Teletext pages. This is used to control 'flicker' on TV displays. More...
 
void STB_EBUTT_IncreaseDisplayAntiAliasing (void)
 Called to adjust the display anti-aliasing level of the Teletext pages.
 
void STB_EBUTT_DecreaseDisplayAntiAliasing (void)
 
void STB_EBUTT_SetDisplayMixTransparency (U8BIT transparency_level)
 Called to adjust the display video-mix transparency level of the Teletext pages. More...
 
void STB_EBUTT_IncreaseDisplayMixTransparency (void)
 Called to adjust the display video-mix transparency level of the Teletext pages.
 
void STB_EBUTT_DecreaseDisplayMixTransparency (void)
 
BOOLEAN STB_EBUTT_IsDisplayHeld (void)
 Called to ascertain whether the present page is in 'hold' mode or not. Thus function is useful when allocating handet keys to events on the basis of the current functional state of the Teletext driver. More...
 
BOOLEAN STB_EBUTT_IsDisplayDoubleHeight (void)
 Called to ascertain whether the present page is in 'double height' mode or not. Thus function is useful when allocating handet keys to events on the basis of the current functional state of the Teletext driver. More...
 

Detailed Description

EBU Teletext driver.

Date
04/02/2004
Author
Ocean Blue

Function Documentation

BOOLEAN PerformPESCollation ( U8BIT *  data_ptr,
BOOLEAN  pts_valid,
U8BIT *  pts 
)

This process is called to service the queue populated with Teletext packets by the PES collectiom callback. Here the process of analysing each data packet, and grouping these packets into whole page data blocks is perfomred,.

Returns
TRUE if a PES packet was avaiable on the colleation queue (and has subsequently been processed, FALSE if no data was avaiable.
BOOLEAN STB_EBUTT_Initialise ( void  )

This must be called to invoke the EBU TeleText driver module before all other functionality can be accessed. This initiates the relevant resources used by the driver module. As a consequence of calling this function, no TeleText processing will occur until other functions are called. It is envisaged that this function may be called within the general initialisation of the STB layer.

Returns
TRUE if initialisation was successful, FALSE otherwise.
BOOLEAN STB_EBUTT_InjectData ( U8BIT *  data_ptr,
U32BIT  data_length 
)

Allows teletext PES data packets to be injected by an external module, which will be decoded and displayed.


Parameters
data_ptr- pointer to first whole PES packet data
data_length- number of bytes of data provided
Returns
TRUE if the data is valid EBU teletext PES data, FALSE otherwise
BOOLEAN STB_EBUTT_IsDisplayDoubleHeight ( void  )

Called to ascertain whether the present page is in 'double height' mode or not. Thus function is useful when allocating handet keys to events on the basis of the current functional state of the Teletext driver.

Returns
TRUE if the displayed page is double height, FALSE otherwise.
BOOLEAN STB_EBUTT_IsDisplayHeld ( void  )

Called to ascertain whether the present page is in 'hold' mode or not. Thus function is useful when allocating handet keys to events on the basis of the current functional state of the Teletext driver.

Returns
TRUE if the displayed page is held, FALSE otherwise.
void STB_EBUTT_Kill ( U8BIT  path)

This is the accompanying function to STB_EBUTT_Initialise( ), and is called to shut-down the EBU TeleText driver module and release the relevant resources used by the driver module. This may not be used in some implementations.

Parameters
U8BITpath - the path of where to kill teletext.
void STB_EBUTT_NotifyEvent ( E_EBUTT_EVENT  event_type)

Called whenever a TeleText-specific event being invoked. This is used to pass relevant user input to the driver, and the enumerate type supplied is defined independently of any IR handset / keypad.

Parameters
E_EBUTT_EVENTevent_type -
void STB_EBUTT_SetCacheMethod ( E_EBUTT_CACHING_METHOD  ebutt_caching_method)

Called to define the strategy used to determine what page content is to be displayed form the TeleText carousel content.

Parameters
E_EBUTT_CACHING_METHODebutt_caching_method -
void STB_EBUTT_SetDisplayAntiAliasing ( U8BIT  antialias_level)

Called to adjust the display anti-aliasing level of the Teletext pages. This is used to control 'flicker' on TV displays.

Parameters
U8BITantialias_level - a factor between zero (no anti-alaising) to 8 (full anti-aliasing)
void STB_EBUTT_SetDisplayBrightness ( U8BIT  gun_intensity)

Called to adjust the display brightness (colour intensity) of the Teletext pages.

Parameters
U8BITgun_intensity - a RGB gun intensity, ranging from 255 (brightest) to 127 (darkest)
void STB_EBUTT_SetDisplayMixTransparency ( U8BIT  transparency_level)

Called to adjust the display video-mix transparency level of the Teletext pages.

Parameters
U8BITtransparency_level - a factor between zero (no transparency) to 255 (full transparency)
BOOLEAN STB_EBUTT_Show ( E_EBUTT_CHARACTER_SET_DESIGNATION  character_set_designation,
BOOLEAN  navigate_to_index_page,
BOOLEAN  show_header 
)

Called to initiate continuous display of TeleText page content. This will result in either the index page defined in the service data stream being selected, or the previously displayed page (prior to a call to STB_EBUTT_Hide( ) being made) from being reinstated. This function can be called irrespective of the use of the STB_EBUTT_Start( ) / STB_EBUTT_Stop( ) functions, but of course may result in no TeleText data being displayed if none already exists within the cache. The return value indicates whether initialisation of the display mechanism has been successful or not.

Parameters
E_STB_EBUTT_CHARACTER_SET_DESIGNATIONcharacter_set_designation - used to specifiy the default character set designation for a level 1.0 Teletext broadcast. This is useful to configure the implementation to work correctly when used with regionalised broadcasts.
BOOLEANnavigate_to_index_page - set it TRUE if the index page defined within the Teletext service is used, or the last visited page is re-displayed.
Returns
TRUE if initialisation of diaply mechanism was successful, FALSE otherwise.
void STB_EBUTT_Start ( U8BIT  path,
U16BIT  text_pid,
U8BIT  magazine,
U8BIT  page 
)

These functions are called to control whether received TeleText data is processed. Using this functionality ensures that the process of collating page information can be halted when processing resources are a consideration. It is envisaged that some implementations may wish only to collate TeleText content only when the display is being shown, whilst other designs may which to cache significant page content as a background process. Abstracting this functionality from the initialisation routines gives the option to support both solution types.

Parameters
magazine- initial magazine to be loaded page - initial page to show from the magazine