Professional Documents
Culture Documents
5500 SW 1
5500 SW 1
Reference Design
Software
Confidential
Information furnished is believed to be accurate and reliable. However, SGS-THOMSON Microelectronics assumes no
responsibility for the consequences of use of such information nor for any infringement of patents or other rights of third
parties which may result from its use. No license is granted by implication or otherwise under any patent or patent rights
of SGS-THOMSON Microelectronics. Specifications mentioned in this publication are subject to change without notice.
This publication supersedes and replaces all information previously supplied. SGS-THOMSON Microelectronics products
are not authorized for use as critical components in life support devices or systems without express written approval of
SGS-THOMSON Microelectronics.
© 1997 SGS-THOMSON Microelectronics - All Rights Reserved
Contents
Contents
1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Confidential 1
Contents
2 Confidential
1 Introduction
1 Introduction
This document describes the main software libraries supplied for application level
programming as part of the EVAL-5500 set top box reference design. The information
in this document is advance information and is subject to change.
The libraries described are as follows:
• The programmable transport interface library is described in Chapter 2 and the
functions are described alphabetically in Chapter 3.
• The device driver libraries for driving the I2C bus interfaces, the non-volatile
memory driver, the PWM/counter module, the PCR module, the SmartCard
interface, the UART drivers, and the MPEG A/V module are described in
Chapter 4.
• The GPRIM graphics primitives library is described in Chapter 5 and the
functions are listed alphabetically and described in detail in Chapter 6. These
functions are used to provide 2 dimensional on-screen graphics and text.
Confidential 1
1 Introduction
2 Confidential
2 Programmable transport interface API
Function Purpose
pti_init Initialize the PTI driver.
pti_test Return a test report for the PTI.
Table 2.1 Initialization and test functions
Slot and PID management
Function Purpose
pti_allocate_dynamic_slot Allocate a dynamic slot.
pti_deallocate_dynamic_slot Deallocate a dynamic slot.
pti_set_pid Set the PID for a slot.
pti_clear_pid Stop PID capture on a slot.
pti_query_pid Given a PID find which slot (if any) is being used to capture it.
Table 2.2 Slot and PID management functions
Confidential 3
2 Programmable transport interface API
PCR management
Function Purpose
pti_set_pcr_register_fn Register the function to be called when a new PCR is ob-
tained.
pti_set_pcr_pid Set a specific PID for PCR capture.
pti_clear_pcr_pid Clear the specific PID for PCR capture.
pti_set_stc_to_next_pcr Force the STC (System Time Clock) to be updated with the
value contained in the next PCR.
pti_get_pts Get the audio video presentation timestamps.
Table 2.3 PCR management functions
Audio, video and data DMA
Function Purpose
pti_audio_dma_reset Reset the audio DMA engine.
pti_video_dma_reset Reset the video DMA engine.
pti_data_dma_reset Reset the data DMA engine.
pti_audio_dma_state Set the state of the audio DMA engine.
pti_video_dma_state Set the state of the video DMA engine.
pti_data_dma_state Set the state of the data DMA engine.
Table 2.4 Audio, video and data DMA management functions
Buffer management
Function Purpose
pti_set_buffer Set up buffering for a slot.
pti_set_consumer_ptr Inform the PTI that data has been consumed from a buffer.
pti_copy_circular_to_linear A utility function to copy the contents of the circular buffer to
a linear buffer.
pti_copy_section_to_linear A utility function to copy a section in a circular buffer to a
linear buffer.
Table 2.5 Buffer management functions
4 Confidential
2 Programmable transport interface API
Function Purpose
pti_allocate_dynamic_key Allocate a dynamic key.
pti_deallocate_dynamic_key Deallocate a dynamic key.
pti_associate_descramble_key Associate a descrambler key to a slot.
pti_disassociate_descramble_key Disassociate a descrambler key and a slot.
pti_set_descramble_key Specify a descrambler key to be used on a stream.
pti_allocate_dynamic_filter Allocate a dynamic section filter.
pti_deallocate_dynamic_filter Deallocate a dynamic section filter.
pti_associate_section_filter Associate a section filter to a slot.
pti_disassociate_section_filter Disassociate a section filter and a slot.
pti_set_section_filter Update the section filter to be used in filtering.
Table 2.6 Special stream-related functions
Confidential 5
2 Programmable transport interface API
2.3 Examples
This section gives examples of using the API.
2.3.1 Initialization
In order to initialize the PTI:
boolean error;
error = pti_init();
if( error ) report( severity_error, "Failed to init PTI" );
semaphore_fifo_init( &got_some_data, 0 );
pti_set_buffer( my_slot,
stream_type_pes,
buffer,
BUFFER_SIZE,
&producer,
&consumer,
&got_some_data );
pti_set_pid( PTI_DATA_SLOT, 42 );
In order to loop collecting data from this PID:
while ( getting_data )
{
semaphore_wait( &got_some_data);
6 Confidential
2 Programmable transport interface API
pti_set_consumer_ptr( consumer );
}
semaphore_fifo_init( &got_some_data, 0 );
pti_set_buffer( section_slot,
stream_type_section,
buffer,
BUFFER_SIZE,
&producer,
&consumer,
&got_some_data );
.
.
Confidential 7
2 Programmable transport interface API
.
Same loop as before, but using pti_copy_section_to_linear to
copy the section and identify the filter that collected the packet
8 Confidential
3 Alphabetical list of PTI functions
Confidential 9
3 Alphabetical list of PTI functions
Synopsis:
boolean pti_allocate_dynamic_filter (filter_t *filter);
Arguments:
filter_t *filter The pointer to the returned identifier of the
allocated filter.
Description:
pti_allocate_dynamic_filter allocates one of the available section filters for
use on the specified slot, several filters may be used on one slot.
Results:
Returns false if no error has occurred, and true otherwise.
See also:
pti_deallocate_dynamic_filter
10 Confidential
3 Alphabetical list of PTI functions
Synopsis:
boolean pti_allocate_dynamic_key (key_t *key);
Arguments:
key_t *key The pointer to the returned number of the
allocated key.
Description:
pti_allocate_dynamic_key allocates one of the non-reserved descramble
keys for use.
Results:
Returns false if no error has occurred, and true otherwise.
See also:
pti_deallocate_dynamic_key
Confidential 11
3 Alphabetical list of PTI functions
Synopsis:
boolean pti_allocate_dynamic_slot (slot_t *slot);
Arguments:
slot_t *slot The pointer to the returned allocated slot.
Description:
pti_allocate_dynamic_slot allocates one of the non-reserved PID slots for
use.
Results:
Returns false if no error has occurred, and true otherwise.
See also:
pti_deallocate_dynamic_slot
12 Confidential
3 Alphabetical list of PTI functions
pti_associate_descramble_key Associate a
descrambler key with a slot
Synopsis:
boolean pti_associate_descramble_key (slot_t slot,
key_t key_number);
Arguments:
slot_t slot The slot to be associated.
key_t key_number The key number and A/B field.
Description:
pti_associate_descramble_key ties a slot to use a particular descramble key.
Disassociation occurs automatically when the slot is deallocated, or when the key is
deallocated, or it can be done explicitly using pti_disassociate_descramble_
key.
Results:
Returns false if no error has occurred, and true otherwise.
See also:
pti_disassociate_descramble_key
pti_set_descramble_key
Confidential 13
3 Alphabetical list of PTI functions
Synopsis:
boolean pti_associate_section_filter (slot_t slot,
filter_t filter);
Arguments:
slot The slot to be associated.
filter The identifier of the filter to be associated.
Description:
pti_associate_section_filter defines a section filter to be used on a partic-
ular slot, the relationship is many to many. NOTE disassociation occurs automati-
cally when the slot is deallocated, or when the filter is deallocated, it can be also be
done explicitly using the following call.
Results:
Returns false if no error has occurred, and true otherwise.
See also:
pti_disassociate_section_filter
14 Confidential
3 Alphabetical list of PTI functions
Synopsis:
boolean pti_audio_dma_reset (void);
Arguments:
None.
Description:
pti_audio_dma_reset causes the MPEG audio DMA engine to be reset, it will
also cause any associated internal DMA management process to be reset.
Results:
Returns false if no error has occurred, and true otherwise.
See also:
pti_audio_dma_state
pti_data_dma_reset
pti_video_dma_reset
Confidential 15
3 Alphabetical list of PTI functions
Synopsis:
boolean pti_audio_dma_state (avddma_state_t state);
Arguments:
avddma_state_t state The new state of the audio DMA engine.
Description:
pti_audio_dma_state controls whether audio data is transferred to the DMA
engine. The meanings of the possible values of the parameter state are given in
Table 3.1.
Value Meaning
discard_data Discard the audio data.
transfer_data Transfer the audio data to the DMA engine.
Table 3.1 Values of parameter state
Results:
Returns false if no error has occurred, and true otherwise.
See also:
pti_audio_dma_reset
pti_data_dma_state
pti_video_dma_state
16 Confidential
3 Alphabetical list of PTI functions
Synopsis:
boolean pti_clear_pcr_pid (void);
Arguments:
None.
Description:
pti_clear_pcr_pid informs the PTI to stop collecting the PCR from the previ-
ously specified PID.
Results:
Returns false if no error has occurred, and true otherwise.
See also:
pti_set_pcr_pid
pti_set_pcr_register_fn
Confidential 17
3 Alphabetical list of PTI functions
Synopsis:
boolean pti_clear_pid (slot_t slot);
Arguments:
slot_t slot The slot to be cleared.
Description:
pti_clear_pid halts PID capture on the specified slot.
Results:
Returns false if no error has occurred, and true otherwise.
See also:
pti_query_pid
pti_set_pid
18 Confidential
3 Alphabetical list of PTI functions
Synopsis:
boolean pti_copy_circular_to_linear (
unsigned char *circular_base,
unsigned int circular_size,
unsigned char **consumer,
unsigned char *producer,
unsigned char *linear_base,
unsigned int linear_size,
unsigned int *data_size);
Arguments:
unsigned char *circular_base The base of the circular buffer.
unsigned int circular_size The size of the circular buffer in bytes.
unsigned char **consumer A pointer to the returned updated
consumer pointer.
unsigned char *producer Producer pointer.
unsigned char *linear_base The base of the linear buffer.
unsigned char linear_size The size of the linear buffer in bytes.
unsigned char *data_size The returned number of bytes copied.
Description:
pti_copy_circular_to_linear is a utility function that copies a packet from a
circular buffer used by the PTI to a linear buffer for processing, after this function is
called, it is wise to call the pti_set_consumer_ptr function with the updated
consumer pointer as its parameter.
Results:
Returns false if no error has occurred, and true otherwise.
See also:
pti_copy_section_to_linear
pti_set_buffer
Confidential 19
3 Alphabetical list of PTI functions
Synopsis:
boolean pti_copy_section_to_linear (
unsigned char *circular_base,
unsigned int circular_size,
unsigned char **consumer,
unsigned char *producer,
filter_t *filter,
unsigned char *linear_base,
unsigned int linear_size,
unsigned int *data_size);
Arguments:
unsigned char *circular_base The base of the circular buffer.
unsigned int circular_size The size of the circular buffer in bytes.
unsigned char **consumer A pointer to the returned consumer pointer.
unsigned char *producer Producer pointer.
filter_t *filter A pointer to the returned identifier of the
section filter that captured the packet.
unsigned char *linear_base The base of the linear buffer.
unsigned int linear_size The size of the linear buffer in bytes.
unsigned int *data_size The returned number of bytes copied.
Description:
pti_copy_circular_to_linear is a utility function that copies a packet from a
circular buffer used by the PTI to a linear buffer for processing, for a section. After
this function is called it is wise to call the pti_set_consumer_ptr function with
the updated consumer pointer as its parameter. NOTE this function copies only one
section from the buffer, and updates the consumer pointer to point after that section.
Results:
Returns false if no error has occurred, and true otherwise.
See also:
pti_copy_circular_to_linear
pti_set_buffer
20 Confidential
3 Alphabetical list of PTI functions
Synopsis:
boolean pti_data_dma_reset (void);
Arguments:
None.
Description:
pti_data_dma_reset causes the data DMA engine to be reset. It will also cause
any associated internal DMA management process to be reset.
Results:
Returns false if no error has occurred, and true otherwise.
See also:
pti_audio_dma_reset
pti_data_dma_state
pti_video_dma_reset
Confidential 21
3 Alphabetical list of PTI functions
Synopsis:
boolean pti_data_dma_state (avddma_state_t state);
Arguments:
avddma_state_t state The new state of data DMA engine.
Description:
pti_data_dma_state controls whether data is transferred to the DMA engine.
The meanings of the possible values of the parameter state are given in Table 3.1.
Value Meaning
discard_data Discard the audio data.
transfer_data Transfer the audio data to the DMA engine.
Table 3.2 Values of parameter state
Results:
Returns false if no error has occurred, and true otherwise.
See also:
pti_audio_dma_state
pti_data_dma_reset
pti_video_dma_state
22 Confidential
3 Alphabetical list of PTI functions
Synopsis:
boolean pti_deallocate_dynamic_filter (filter_t filter);
Arguments:
filter_t filter The identifier of the filter to be deallocated.
Description:
pti_deallocate_dynamic_filter frees up a previously allocated section filter.
Results:
Returns false if no error has occurred, and true otherwise.
See also:
pti_allocate_dynamic_filter
Confidential 23
3 Alphabetical list of PTI functions
Synopsis:
boolean pti_deallocate_dynamic_key (key_t key);
Arguments:
key_t key The descramble key to be deallocated.
Description:
pti_deallocate_dynamic_key frees up a previously allocated descramble key.
Results:
Returns false if no error has occurred, and true otherwise.
See also:
pti_allocate_dynamic_key
24 Confidential
3 Alphabetical list of PTI functions
Synopsis:
boolean pti_deallocate_dynamic_slot (slot_t slot);
Arguments:
slot_t slot The PID slot to be deallocated.
Description:
pti_deallocate_dynamic_slot frees up a previously allocated PID slot.
Results:
Returns false if no error has occurred, and true otherwise.
See also:
pti_allocate_dynamic_slot
Confidential 25
3 Alphabetical list of PTI functions
pti_disassociate_descramble_key Disassociate a
descrambler key and a slot
Synopsis:
boolean pti_disassociate_descramble_key (slot_t slot,
key_t key_number);
Arguments:
slot_t slot The slot to be disassociated.
key_t key_number The number of the key and A/B field to be
disassociated.
Description:
pti_disassociate_descramble_key disassociates a key from a slot, so this
key will no longer be used on data coming in on this slot.
Results:
Returns false if no error has occurred, and true otherwise.
See also:
pti_associate_descramble_key
pti_set_descramble_key
26 Confidential
3 Alphabetical list of PTI functions
pti_disassociate_section_filter Disassociate a
section filter and a slot
Synopsis:
boolean pti_disassociate_section_filter (slot_t slot,
filter_t filter);
Arguments:
slot_t slot The slot to be disassociated.
filter_t filter The identifier of the filter to be disassoci-
ated.
Description:
pti_disassociate_section_filter disassociates a section filter from a slot,
so this filter will no longer be used to filter data coming in on this slot.
Results:
Returns false if no error has occurred, and true otherwise.
See also:
pti_associate_section_filter
Confidential 27
3 Alphabetical list of PTI functions
Synopsis:
boolean pti_get_pts (unsigned int *audio_pts,
unsigned int *video_pts);
Arguments:
unsigned int *audio_pts The pointer to the returned bottom 32 bits
of the audio PTS.
unsigned int *video_pts The pointer to the returned bottom 32 bits
of the video PTS.
Description:
pti_get_pts gets the presentation timestamps stored in the PTI block of some
hardware configurations.
Results:
Returns false if no error has occurred, and true otherwise.
See also:
pti_set_stc_to_next_pcr
28 Confidential
3 Alphabetical list of PTI functions
Synopsis:
boolean pti_init (void);
Arguments:
None.
Description:
pti_init initializes the PTI driver.
Results:
Returns false if no error has occurred, and true otherwise.
See also:
pti_test
Confidential 29
3 Alphabetical list of PTI functions
pti_query_pid Query which slot (if any) is being used to capture the
PID.
Synopsis:
boolean pti_query_pid (pid_t pid,
boolean *received,
slot_t *slot);
Arguments:
pid_t pid The PID.
boolean *received The pointer to the returned flag indicating if
anyone is capturing this PID.
slot_t slot The slot on which the PID is being
captured.
Description:
pti_query_pid tells the user if a PID is being captured, and if so on what slot.
Results:
Returns false if no error has occurred, and true otherwise.
See also:
pti_clear_pid
pti_set_pid
30 Confidential
3 Alphabetical list of PTI functions
Synopsis:
boolean pti_set_buffer (slot_t slot,
stream_type_t stream_type,
unsigned char *buffer_memory,
unsigned int buffer_size,
unsigned char **producer_ptr,
unsigned char **consumer_ptr,
signal_t signal);
Arguments:
slot_t slot The slot to tie the buffer to.
stream_type_t stream_type The type of stream this buffer is used for.
unsigned char *buffer_memory The memory to be used for the buffers.
unsigned char buffer_size The size of the buffer in bytes, which must
be a power of 2.
unsigned char **producer_ptr A pointer to the producer pointer.
unsigned char **consumer_ptr A pointer to the consumer pointer.
signal_t signal A semaphore or its equivalent for the
relevant operating system.
Description:
pti_set_buffer initializes a circular buffer to be used for incoming data on a
stream. The size of the buffer in bytes must be a power of 2. The PTI maintains a
producer pointer into the buffer indicating where the next input data will be stored,
the consumer (or caller of this function) maintains a consumer pointer. The PTI can
be instructed to update its copy of the consumer pointer by calling
pti_set_consumer_ptr(). NOTE when a signal has been sent indicating the
buffer is non-empty, another signal will not be sent before the user has called
pti_set_consumer_ptr().
Results:
Returns false if no error has occurred, and true otherwise.
See also:
pti_set_consumer_ptr
pti_copy_circular_to_linear
pti_copy_section_to_linear
Confidential 31
3 Alphabetical list of PTI functions
Synopsis:
boolean pti_set_consumer_ptr (slot_t slot,
unsigned char *consumer_ptr);
Arguments:
slot_t slot The slot that data has been consumed on.
unsigned char *consumer_ptr The new value of the consumer pointer.
Description:
pti_set_consumer_ptr informs the PTI that data has been consumed from a
buffer.
Results:
Returns false if no error has occurred, and true otherwise.
See also:
pti_set_buffer
pti_copy_circular_to_linear
pti_copy_section_to_linear
32 Confidential
3 Alphabetical list of PTI functions
Synopsis:
boolean pti_set_descramble_key (key_t key_number,
boolean valid,
unsigned char *key);
Arguments:
key_t key_number The key number and A/B field to be used.
boolean valid Whether the key is valid or not.
unsigned char *key A pointer to the returned new key.
Description:
pti_set_descramble_key sets the descramble key to be used by the specified
slot.
Results:
Returns false if no error has occurred, and true otherwise.
See also:
pti_associate_descramble_key
pti_disassociate_descramble_key
Confidential 33
3 Alphabetical list of PTI functions
Synopsis:
boolean pti_set_pcr_pid (pid_t pid);
Arguments:
pid_t pid The PID on which to find a PCR.
Description:
pti_set_pcr_pid informs the PTI on which PID it should look to find a PCR.
Results:
Returns false if no error has occurred, and true otherwise.
See also:
pti_clear_pcr_pid
pti_set_pcr_register_fn
34 Confidential
3 Alphabetical list of PTI functions
Synopsis:
boolean pti_set_pcr_register_fn (
pcr_register_fn_t pcr_handler);
Arguments:
pcr_register_fn_t pcr_handler The name of the function to be called.
Description:
pti_set_pcr_register_fn registers the user function to be called whenever a
PCR is received.
Results:
Returns false if no error has occurred, and true otherwise.
See also:
pti_clear_pcr_pid
pti_set_pcr_pid
Confidential 35
3 Alphabetical list of PTI functions
Synopsis:
boolean pti_set_pid (slot_t slot, pid_t pid);
Arguments:
slot_t slot The slot on which to capture this PID.
pid_t pid The PID to capture.
Description:
pti_set_pid specifies which PID is to be captured on the specified slot.
Results:
Returns false if no error has occurred, and true otherwise.
See also:
pti_clear_pid
36 Confidential
3 Alphabetical list of PTI functions
Synopsis:
boolean pti_set_section_filter (filter_t filter,
section_filter_t filter_data);
Arguments:
filter_t filter The identifier of the filter to be updated.
section_filter_t filter_data The new filter data to be used.
Description:
pti_set_section_filter sets the filter data to be used in section filtering on
the specified filter identifier.
Results:
Returns false if no error has occurred, and true otherwise.
See also:
pti_associate_section_filter
pti_disassociate_section_filter
Confidential 37
3 Alphabetical list of PTI functions
Synopsis:
boolean pti_set_stc_to_next_pcr (void);
Arguments:
None.
Description:
pti_set_stc_to_next_pcr forces the STC (System Time Clock) to be updated
with the value contained in the next PCR.
Results:
Returns false if no error has occurred, and true otherwise.
See also:
pti_get_pts
38 Confidential
3 Alphabetical list of PTI functions
Synopsis:
boolean pti_test (char *report, unsigned int report_length);
Arguments:
char *report The pointer to the string buffer to receive a
test report.
unsigned int report_length The size of the report buffer in bytes.
Description:
pti_test puts a test report in the report buffer. The size of the report is limited by
the buffer length supplied in the call.
Results:
Returns false if no error has occurred, and true otherwise.
See also:
pti_init
Confidential 39
3 Alphabetical list of PTI functions
Synopsis:
boolean pti_video_dma_reset (void);
Arguments:
None.
Description:
pti_video_dma_reset causes the MPEG video DMA engine to be reset. It will
also cause any associated internal DMA management process to be reset.
Results:
Returns false if no error has occurred, and true otherwise.
See also:
pti_audio_dma_reset
pti_data_dma_reset
pti_video_dma_state
40 Confidential
3 Alphabetical list of PTI functions
Synopsis:
boolean pti_video_dma_state (avddma_state_t state);
Arguments:
avddma_state_t state The new state of video DMA engine.
Description:
pti_video_dma_state controls whether video data is transferred to the DMA
engine or discarded. The meanings of the possible values of the parameter state
are given in Table 3.1.
Value Meaning
discard_data Discard the audio data.
transfer_data Transfer the audio data to the DMA engine.
Table 3.3 Values of parameter state
Results:
Returns false if no error has occurred, and true otherwise.
See also:
pti_audio_dma_state
pti_data_dma_state
pti_video_dma_reset
Confidential 41
3 Alphabetical list of PTI functions
42 Confidential
4 Device driver functions
Confidential 43
4 Device driver functions
44 Confidential
4 Device driver functions
Synopsis:
#include <i2c.h>
Description:
Initialize the I2C semaphores, interrupt handlers, identifier and parameters from the
data supplied in the structure params.
Arguments:
i2c_params_t *params I2C initial parameter data.
i2c_handle_t *handle Returned initialized I2C interface identifier.
The i2c_params_t struct is defined in i2c.h and contains the fields shown in
Table 4.2.
Field Type Description
volatile Base address of the I2C interface.
i2c_base unsigned
int *
volatile Base address of the PIO.
pio_base unsigned
int *
i2c_interrupt int CPU interrupt number.
i2c_interrupt CPU interrupt level.
int
_level
master boolean true if the device is an I2C bus master or false otherwise.
baud_rate int The I2C bus baud rate.
max_retries int The maximum number of retries for a read or write.
Results:
Returns false if no error has occurred, and true otherwise.
Confidential 45
4 Device driver functions
Synopsis:
#include <i2c.h>
Description:
Read into buffer from a device on the I2C bus at address.
Arguments:
i2c_handle_t handle I2C interface identifier.
unsigned char address Address of the device on the I2C bus.
unsigned char *buffer A pointer to the returned input data.
int maximum_length The maximum number of bytes to read.
int *actual_length A pointer to the returned actual number of
bytes read.
Results:
Returns false if no error has occurred, and true otherwise.
46 Confidential
4 Device driver functions
Synopsis:
#include <i2c.h>
Description:
Send the data in buffer to the device on the I2C bus at address.
Arguments:
i2c_handle_t handle I2C interface identifier.
unsigned char address The address of the device on the I2C bus.
unsigned char *buffer The buffer containing the data to send.
int length The number of bytes to send.
int *actual_length A pointer to the returned actual number of
bytes sent.
Results:
Returns false if no error has occurred, and true otherwise.
Confidential 47
4 Device driver functions
48 Confidential
4 Device driver functions
Synopsis:
#include <nvm.h>
Description:
Gain access to, or create, a managed segment of NVM. Given a unique identifier of
an NVM region, nvm_access will return the handle. If the region does not exist it
will create it. This function will reset the NVM and raise a fatal error if the region
already exists but is not of the specified size.
Arguments:
unsigned int segment A unique segment identifier.
unsigned int length The length of the segment.
nvm_handle_t *segment_handle A pointer to the returned segment handle.
Results:
Returns true if the segment did not previously exist, or false otherwise.
Confidential 49
4 Device driver functions
Synopsis:
#include <nvm.h>
Description:
Perform an unmanaged read from EEPROM.
Arguments:
unsigned int address Address in EEPROM.
unsigned int data_length The number of bytes to be read.
unsigned char *data A pointer to the buffer for the received
data.
Results:
Returns false if no error has occurred, and true otherwise.
50 Confidential
4 Device driver functions
Synopsis:
#include <nvm.h>
Description:
Perform an unmanaged write to EEPROM.
Arguments:
address The address in the EEPROM.
unsigned int data_length The number of bytes to be written.
unsigned char *data A pointer to the data to be written.
Results:
Returns false if no error has occurred, and true otherwise.
Confidential 51
4 Device driver functions
Synopsis:
#include <nvm.h>
Description:
Initialize the managed NVM data structures.
Arguments:
None.
Results:
Returns false if no error has occurred, and true otherwise.
52 Confidential
4 Device driver functions
Synopsis:
#include <nvm.h>
Description:
Read from a managed segment of NVM.
Arguments:
nvm_handle_t segment_handleThe unique segment identifier.
unsigned int segment_offsetThe offset into the segment.
unsigned int data_length The number of bytes to be read.
unsigned char *data A pointer to the buffer for the returned
data.
Results:
Returns false if no error has occurred, and true otherwise.
Confidential 53
4 Device driver functions
Synopsis:
#include <nvm.h>
Description:
Return a test report. The report will be truncated to buffer_length bytes if
necessary.
Arguments:
char *report_buffer A pointer to the buffer to store returned
report.
unsigned int buffer_length The size of the buffer in bytes.
Results:
Returns false if no error has occurred, and true otherwise.
54 Confidential
4 Device driver functions
Synopsis:
#include <nvm.h>
Description:
Write to a managed segment of NVM.
Arguments:
nvm_handle_t segment_handle A unique segment identifier.
unsigned int segment_offset The offset into the segment.
unsigned int data_length The number of bytes to be written.
unsigned char *data A pointer to the data to be written.
Results:
Returns false if no error has occurred, and true otherwise.
Confidential 55
4 Device driver functions
56 Confidential
4 Device driver functions
Synopsis:
#include <pwm.h>
Description:
Display the values in the filter context data structure for debugging purposes.
Arguments:
None.
Results:
None.
Confidential 57
4 Device driver functions
Synopsis:
#include <pwm.h>
Description:
Perform a simple filter function. The function decides on an appropriate control
value given the latest difference value.
Arguments:
unsigned int pcr Current system clock.
unsigned int difference Capture clock value.
Results:
None.
58 Confidential
4 Device driver functions
Synopsis:
#include <pwm.h>
Description:
Initialize the filter context data structure and reset the PWM module hardware. This
function is for use when the ST20 is reset.
Arguments:
None.
Results:
Returns false if pwm_init has already been run, true otherwise.
Confidential 59
4 Device driver functions
Synopsis:
#include <pwm.h>
Description:
Restart the synchronizing of the PWM filter. This function is usually used when
changing channels.
Arguments:
None.
Results:
None.
60 Confidential
4 Device driver functions
Confidential 61
4 Device driver functions
Synopsis:
#include <pcr.h>
Arguments:
unsigned int *clock_value Clock value.
Description:
Give the current system clock in clock_value.
Results:
Returns true if no valid PCR is available on which to base the system clock,
false otherwise.
62 Confidential
4 Device driver functions
Synopsis:
#include <pcr.h>
Arguments:
None.
Description:
Initializes the PCR driver.
Results:
Returns false if no error has occurred, and true otherwise.
Confidential 63
4 Device driver functions
Synopsis:
#include <pcr.h>
Arguments:
None.
Description:
Starts capturing PCRs. Before PCR capture is started the function
pcr_current_studio_clock always returns true.
Results:
Returns false if no error has occurred, and true otherwise.
64 Confidential
4 Device driver functions
Synopsis:
#include <pcr.h>
Arguments:
None.
Description:
Stops capturing PCRs. This will invalidate the currently held PCR and
pcr_current_studio_clock will return true until capturing is restarted and a
new PCR has been captured.
Results:
Returns false if no error has occurred, and true otherwise.
Confidential 65
4 Device driver functions
66 Confidential
4 Device driver functions
Synopsis:
#include "smart.h"
Description:
Deactivate the smart card, removing the power supply and all other connections.
Arguments:
smart_handle_t handle Identifier handle to access the SmartCard.
Results:
Returns false if no error has occurred, and true otherwise.
Errors:
An error code of true is returned if an invalid handle is used.
Confidential 67
4 Device driver functions
Synopsis:
#include "smart.h"
Description:
Read one or two procedure bytes, when using protocol T=0.
Smart cards reply to a command sent from the interface with a procedure byte, as
defined in ISO 7816-3. The instruction code is the second byte of the 5-byte
command. The function discards NULL characters that are sent by the card.
Arguments:
smart_handle_t handle Identifier handle to access the SmartCard.
unsigned char INS The instruction code for which we are
getting the procedure byte.
unsigned char reply[2] Returned reply from the SmartCard inter-
face.
int *reply_length Returned reply length.
Results:
Returns false if no error has occurred, and true otherwise.
Errors:
An error code of true is returned if:
• an invalid handle is used,
• bad characters are received or
• a communication error is detected.
See also:
smart_t0_command
68 Confidential
4 Device driver functions
Synopsis:
#include "smart.h"
Description:
Perform all the actions needed to initialize the ST20 hardware in order to drive a
smart card. smart_init also registers and installs the appropriate interrupt
handler.
Arguments:
smart_params_t *params A pointer to a structure containing all the
smart card parameters.
smart_handle_t *handle_p A pointer to the returned identifier handle
to access the SmartCard.
The parameters structure smart_params_t is defined in smart.h and contains
the fields shown in Table 4.7.
The SmartCard interface must supply a clock during reset, called the initial clock.
The initial clock is described by the Fs_xxx fields in the parameters structure.The
smart card may have an internal clock for subsequent use, in which case
ext_clock should be set to false. Otherwise an external subsequent clock is
needed, so ext_clock should be set to true and the external clock should be
described by the Fs_xxx fields in the parameter structure.
Confidential 69
4 Device driver functions
Errors:
An error code of true is returned if a memory allocation failure occurs.
70 Confidential
4 Device driver functions
Synopsis:
#include "smart.h"
Description:
Perform a smart card protocol selection.
Arguments:
smart_handle_t handle Identifier handle to access the SmartCard.
unsigned char *pts_request Up to three byte array which holds the PTS
request without the first byte (0xFF) and
the check character.
Results:
Returns false if no error has occurred, and true otherwise.
Errors:
An error code of true is returned if protocol errors occurs.
Confidential 71
4 Device driver functions
Synopsis:
#include "smart.h"
Description:
Receive a block of data bytes from the smart card using the current parameters.
Arguments:
smart_handle_t handle Identifier handle to access the SmartCard.
unsigned char *buffer Data buffer where the returned read data
will be put.
int len Number of bytes wanted.
int *actlen Pointer to the returned number of bytes
actually read.
Results:
Returns false if no error has occurred, and true otherwise.
Errors:
An error code of true is returned if using an invalid handle or on receiving error
See also:
smart_send
72 Confidential
4 Device driver functions
Synopsis:
#include "smart.h"
Description:
Perform the smart card reset phase, getting the Answer-to-reset from the card.
Arguments:
smart_handle_t handle The identifier handle to access the Smart-
Card.
unsigned char *atr A buffer where the Answer to reset is
returned.
int *atr_size A pointer to the returned length of the
Answer to reset buffer.
Results:
Returns false if no error has occurred, and true otherwise.
Errors:
An error code of true is returned if no answer is received from the card.
Confidential 73
4 Device driver functions
Synopsis:
#include "smart.h"
Description:
Send a block of bytes to the smart card using the current parameters.
Arguments:
smart_handle_t handle Identifier handle to access the SmartCard.
unsigned char *buffer The data buffer.
int len The data buffer length.
int *actlen A pointer to the returned number of bytes
actually sent.
Results:
Returns false if no error has occurred, and true otherwise.
Errors:
An error code of true is returned if an invalid handle is used or if transmission
errors are detected.
See also:
smart_receive
74 Confidential
4 Device driver functions
Synopsis:
#include <smart.h>
Description:
Return the current status of the smart card driver.
Arguments:
iohandle_t handle Identifier handle to access the SmartCard.
smart_status_t *status Output parameter to return the smart card
status.
The smart_status_t structure are defined in smart.h and contains the fields
shown in Table 4.8. The error codes are defined in smart.h and are shown in
Table 4.9.
Field Type Description
inserted boolean true if the smart card is inserted and false otherwise.
smart_operation The code of the last error that occurred. The codes are listed in
error
_error_t Table 4.9.
Confidential 75
4 Device driver functions
Errors:
An error code of true is returned if an invalid handle is used.
76 Confidential
4 Device driver functions
Synopsis:
#include "smart.h"
Description:
Execute a protocol T=0 command on the smart card, getting the reply from the card.
Subsequent procedure bytes can be obtained using smart_get_procedure_
byte.
Arguments:
smart_handle_t handle The identifier handle to access the Smart-
Card.
unsigned char *command A 5-byte array containing the command to
be sent to the card.
unsigned char *reply A pointer to the returned reply from the
card.
int *reply_length A pointer to the returned length of the
reply.
Results:
Returns false if no error has occurred, and true otherwise.
Errors:
An error code of true is returned if
• an invalid handle is used,
• the command is badly formed or
• a communication error is detected.
See also:
smart_get_procedure_byte, smart_send, smart_receive
Confidential 77
4 Device driver functions
78 Confidential
4 Device driver functions
Synopsis:
#include <uart.h>
Description:
Flush from the UART read-ahead buffer any characters stored there.
Arguments:
uart_handle_t handle UART identifier.
Results:
Returns false if no error has occurred, and true otherwise.
Confidential 79
4 Device driver functions
Synopsis:
#include <uart.h>
Description:
Initialize the UART semaphores, interrupt handler, buffers, identifier and parameters
from the parameters in params.
Arguments:
uart_params_t *params UART initial parameters.
uart_handle_t *handle Returned UART identifier.
The uart_params_t struct is defined in uart.h and contains the fields shown in
Table 4.11. See uart.h for the possible values of stop_bits and parity.
Results:
Returns false if no error has occurred, and true otherwise.
80 Confidential
4 Device driver functions
Synopsis:
#include <uart.h>
Description:
Read up to maximum_length bytes from the UART into buffer.
Arguments:
uart_handle_t handle UART identifier.
unsigned char *buffer Buffer for input data.
int maximum_length Maximum number of bytes of input data.
int *actual_length Actual number of bytes of input data.
int timeout_period Time-out in units of 10msecs. Zero means
no time-out.
Results:
Returns false if no error has occurred, and true otherwise.
Confidential 81
4 Device driver functions
Synopsis:
#include <uart.h>
Description:
Change the parameters for a UART without resetting it.
Arguments:
uart_handle_t handle UART identifier.
uart_params_t *params New UART parameters.
Results:
Returns false if no error has occurred, and true otherwise.
82 Confidential
4 Device driver functions
Synopsis:
#include <uart.h>
Description:
Write length bytes from buffer to the UART.
Arguments:
uart_handle_t handle UART identifier.
unsigned char *buffer Buffer containing output data.
int length Number of bytes to send.
int *actual_length Returned actual number of bytes sent.
Results:
Returns false if no error has occurred, and true otherwise.
Confidential 83
4 Device driver functions
84 Confidential
4 Device driver functions
Synopsis:
#include <st_api.h>
Arguments:
pid_t pidVideo pid containing video.
pid_t pidAudio pid containing audio.
pid_t pidPcr pid containing PCR.
Results:
Returns false if no error, true otherwise.
Description:
mpeg_channel_change is the highest level function for starting decoding on a
new channel. It initialises and starts full decoding with the given pids.
Confidential 85
4 Device driver functions
Synopsis:
#include <st_api.h>
Arguments:
None.
Description:
Turns off the display and calls mpeg_disable_video_decode and
mpeg_disable_audio_decode.
Note: If separate treatment is needed for audio and video, use
mpeg_disable_video_decode and mpeg_disable_audio_decode directly.
See also:
mpeg_disable_video_decode, mpeg_disable_audio_decode
86 Confidential
4 Device driver functions
Synopsis:
#include <st_api.h>
Arguments:
None.
Description:
Mutes audio and resets the decoding task.
Note: mpeg_disable_audio_decode should be used only if a separate
treatment is needed for audio and video; if this is not the case mpeg_disable
should be used.
See also:
mpeg_disable
Confidential 87
4 Device driver functions
Synopsis:
#include <st_api.h>
Arguments:
None.
Description:
Freezes the display on the last I or P picture (top field), and resets the decoding task
and the decoder (Soft Reset + PES parser).
Note: mpeg_disable_video_decode should be used only if a separate
treatment is needed for audio and video; if this is not the case mpeg_disable
should be used.
See also:
mpeg_disable
88 Confidential
4 Device driver functions
Synopsis:
#include <st_api.h>
Arguments:
boolean enable_video Whether the function actually enables
video decode.
boolean enable_audio Whether the function actually enables
audio decode.
Description:
Resets the decoder and calls mpeg_enable_video_decode and
mpeg_enable_audio_decode.
Note: If separate treatment is needed for audio and video, use
mpeg_enable_video_decode and mpeg_enable_audio_decode directly.
See also:
mpeg_enable_video_decode, mpeg_enable_audio_decode
Confidential 89
4 Device driver functions
Synopsis:
#include <st_api.h>
Arguments:
boolean enable_audio Whether the function actually enables
audio decode.
Description:
Resets, initialises and starts the decoding task.
Note: mpeg_enable_audio_decode should be used only if a separate treatment
is needed for audio and video; if this is not the case mpeg_enable should be used.
See also:
mpeg_enable
90 Confidential
4 Device driver functions
Synopsis:
#include <st_api.h>
Arguments:
boolean enable_video Whether the function actually enables
video decode.
Description:
Resets, initialises and starts the decoding task.
Note: mpeg_enable_video_decode should be used only if a separate treatment
is needed for audio and video; if this is not the case mpeg_enable should be used.
See also:
mpeg_enable
Confidential 91
4 Device driver functions
Synopsis:
#include <st_api.h>
Arguments:
None.
Description:
Stops and immediately restarts the decoding process. This is used to reset the
process without stopping the decoder when a serious error is encountered.
92 Confidential
4 Device driver functions
Synopsis:
#include <st_api.h>
Arguments:
None.
Description:
Disables audio output.
Confidential 93
4 Device driver functions
Synopsis:
#include <st_api.h>
Arguments:
unsigned int volume Value between 0 and 63.
Description:
Sets the volume of the audio output of the decoder. 0 is lowest volume, 63 is highest
volume.
94 Confidential
4 Device driver functions
Synopsis:
#include <st_api.h>
Arguments:
None.
Description:
Enables audio output.
Confidential 95
4 Device driver functions
96 Confidential
5 The GPRIM library
Confidential 97
5 The GPRIM library
98 Confidential
5 The GPRIM library
Line functions
gprim_line Draw a straight line.
gprim_styled_line Draw a line at an angle with specified pixel values.
gprim_rect Draw a rectangle outline.
gprim_polyline Draw consecutive line segments.
gprim_disjpolyline Draw straight line segments.
gprim_polygon Draw a polygon outline.
gprim_circle Draw an ellipse outline.
gprim_arc Draw a partial ellipse outline.
gprim_arcc Draw a closed partial ellipse outline.
gprim_dot Plot a single point.
Table 5.3 Line functions
Text functions
gprim_max_chars_in_width Truncate string to pixel width.
gprim_text Print text at position.
gprim_textsize Find width of text in pixels.
gprim_addtext Add text at current position.
gprim_rotatedtext Print text at an angle.
gprim_overstrike_addtext Add text at current position preserving background.
gprim_overstrike_text Print text preserving background.
gprim_chrbegin Set character position.
gprim_chrspace Set character spacing.
gprim_setfont Set up the current character font.
Table 5.4 Text functions
Filled area functions
gprim_cls Clear the screen.
gprim_frect Draw a filled rectangle.
gprim_fcircle Draw a filled ellipse.
gprim_paint Flood fill an area.
Table 5.5 Filled area functions
Confidential 99
5 The GPRIM library
Image functions
gprim_getimage Save image copy.
gprim_putimage Put image copy.
gprim_copy Copy region of a screen.
gprim_search Search for color change.
gprim_setpel Set custom pel pattern.
gprim_setpelstyle Set custom pel pattern.
gprim_pel Put pel on screen.
Table 5.6 Image functions
Graphic/video mixing functions
gprim_set_colour_mixing_mask Specify which colors to mix with video.
gprim_set_colour_mixing_weight Specify how colors are mixed with video.
Table 5.7 Graphic/video mixing functions
Color specification and selection
gprim_setbcol Specify the background color.
gprim_setfcol Specify the foreground color.
gprim_setpalette Set palette entry.
Table 5.8 Color specification and selection
Control functions
gprim_init Initialize GPRIM system.
gprim_reset Reset GPRIM, delete all regions.
gprim_standby Set OSD in standby mode.
gprim_out_of_standby Take OSD out of standby mode.
gprim_display Enable/disable OSD.
gprim_query Discover dimensions of current region.
gprim_create_region Create a drawable region.
gprim_set_draw_region Specify region to draw to.
gprim_display_region Add region to, or remove from, display list.
gprim_move_region_to Update the display position of a region.
Table 5.9 Control functions
100 Confidential
5 The GPRIM library
5.1.3 Screen
All GPRIM operations are performed onto the current drawable region in sti5500
memory, there is no default region, regions must be created by the application, and
selected for drawing. The entire on-screen display (OSD) is enabled or disabled by the
function gprim_display, and regions may be added to, or removed from, the display
by use of the gprim_display_region function. The function gprim_set_draw_
region selects the region where the drawing will take place. These functions can be
used together to control whether or not the graphics are displayed while drawing is
being done.
The display can be put in standby mode by gprim_standby and returned to normal
by gprim_out_of_standby. Initially the display is in standby mode.
5.1.4 Coordinates
Graphics and text elements can be placed anywhere within a region. The coordinates
for placing the elements are shown in Figure 5.1, with the origin at the top left corner
of the region. The first coordinate is the horizontal distance in pixels from the left side
and the second coordinate is the vertical distance in pixels down from the top of the
region. Regions may have different sizes, and a different number of bits per pixel.
(0, 0)
y pixels
(x, y)
x pixels
5.1.5 Color
Drawing, filling and text are all in the foreground color, possibly mixed with the under-
lying video data. The foreground color is set by gprim_setfcol. The background
Confidential 101
5 The GPRIM library
color is used to fill the region when the region is cleared, possibly mixed with the
underlying video data, and is set by gprim_setbcol.
The OSD implementation of GPRIM uses 4/8-bit pixels, resulting in regions containing
up to 15/255 different colors plus transparent. Pixel values are used to address a color
palette, which is a table to generate for each pixel value the actual display color from a
possibly larger range. Each entry in the color palette is defined by using the function
gprim_setpalette.
In the STi5500, on-screen graphics can be mixed with video. The default is that an on-
screen pixel non-zero value completely overwrites the underlying video data. However
some or all of the palette colors can be mixed with underlying video data to produce
semi-transparent graphics or text. The two graphic/video mixing functions specify the
palette entries that are to be combined and the weighting of the resultant mix toward
video or OSD data.
5.1.7 Text
A current text position in a region is maintained, which is the coordinates of the top left
corner of the next text character. This is initialized by some text drawing functions or it
can be initialized explicitly by gprim_chrbegin. It is updated whenever text is drawn,
allowing for the width of the characters, the spacing between characters and the angle
of the text line. The text is drawn in the foreground color using the current font.
Defining the current font is described in section section 5.2. NOTE the position is lost
when you switch to a new drawable region.
102 Confidential
5 The GPRIM library
A font may have a fixed character width or a variable character width, in which case
the width is different for each character. Variable character widths are defined as an
array parameter to gprim_setfont. If the character widths are set to NULL then a
fixed character width is used. The inter-character spacing for a fixed character width
font, both vertical and horizontal, is defined by gprim_chrspace. This writes the
fixed width into each element of the font width array.
When specifying a font, the gprim_setfont function requires various font character-
istics to be defined, as shown in Table 5.10. These specify, for example, the number of
32-bit words used to hold the bit pattern of a single character cell.
Font parameter Purpose
font Actual character bitmaps
font_width Array containing width for each character
nchars Number of characters in the font
famw Font area memory width (in bits)
famh Font height (in rows)
fwpc Number of 32-bit words per character
flpw Number of character lines per 32-bit word
Table 5.10 Font characteristics
If necessary, the programmer can define additional fonts or convert existing fonts from
some other environment into this format.
Confidential 103
5 The GPRIM library
104 Confidential
6 Alphabetical list of GPRIM functions
Confidential 105
6 Alphabetical list of GPRIM functions
Synopsis:
void gprim_addtext (int n, char *str)
Arguments:
int n Number of characters to plot.
char *str Character string.
Description:
gprim_addtext plots n characters from the character string str according to the
current font description. Characters are plotted at the current character position
which is then incremented. If the font is a variable width font then only the X position
is incremented by the width of the character. If the font is not variable width then the
X and Y positions are incremented by the inter-character spacing distances
specified to gprim_chrspace. The current character position after the operation
completes is offset from the last character plotted by these distances.
Characters are reproduced at the size of the current font, as set by
gprim_setfont. Bits set in the font description are plotted in the foreground color,
set using gprim_setfcol. Clear bits are plotted in the background color, set by
gprim_setbcol.
Diagram:
See also:
gprim_overstrike_addtext gprim_chrspace gprim_setfont
gprim_setfcol gprim_setbcol
106 Confidential
6 Alphabetical list of GPRIM functions
Synopsis:
void gprim_arc (int Xc, int Yc, int A, int B,
int start_angle, int end_angle)
Arguments:
int Xc,int Yc Centre coordinates.
int A Length of X direction semi axis.
int B Length of Y direction semi axis.
int start_angle Angle of start of arc.
int end_angle Angle of end of arc.
Description:
gprim_arc plots part of the outline of an axis-aligned ellipse centered at (Xc,Yc)
and with semi-axis lengths of A and B pixels. Both A and B must be positive; the
larger of the two values is the semi-major axis length, while the smaller specifies the
semi-minor axis length.
start_angle and end_angle define which portion of the circle/ellipse to draw.
These angles are normalized so that 0x10000 represents 360 degrees, and the arc
is drawn anti-clockwise from the right hand horizontal semi-axis of the ellipse. For
example the following diagram shows an arc of an ellipse with start angle 0xe000
and end angle 0x2000.
Diagram:
X
Y
start_angle
A end_angle
(Xc,Yc)
Confidential 107
6 Alphabetical list of GPRIM functions
Synopsis:
void gprim_arcc (int Xc, int Yc, int A, int B,
int start_angle, int end_angle,
int CloseMode)
Arguments:
int Xc,int Yc Centre coordinates.
int A Length of X direction semi axis.
int B Length of Y direction semi axis.
int start_angle Angle of start of arc.
int end_angle Angle of end of arc.
int CloseMode Close mode.
Description:
gprim_arcc plots part of the outline of an axis aligned ellipse centered at
(Xc,Yc) and with semi-axis lengths of A and B pixels. Both A and B must be
positive; the larger of the two values is the semi-major axis length, while the smaller
specifies the semi-minor axis length.
start_angle and end_angle define which portion of the circle/ellipse to draw.
These angles are normalized so that 0x10000 represents 360 degrees, and the arc
is drawn anti-clockwise from the right hand horizontal semi-axis of the ellipse. For
example the following diagram shows an arc of an ellipse with start angle 0xe000
and end angle 0x2000.
The partial outline is closed with either:
• a single chord line, joining the two end points, or
• a pair of segment lines, connecting each end point to the centre of the ellipse
at (Xc,Yc).
The value of CloseMode determines which method is used. Valid values are given
in the following table:
CloseMode Comment
CM_CHORD Close outline with a chord line
CM_SEGMENT Close outline with two segment lines
108 Confidential
6 Alphabetical list of GPRIM functions
Diagram:
X
Y
start_angle
A end_angle
(Xc,Yc)
Y
start_angle
A end_angle
(Xc,Yc)
See also:
gprim_arc gprim_circle
Confidential 109
6 Alphabetical list of GPRIM functions
Synopsis:
void gprim_chrbegin (int X, int Y)
Arguments:
int X,int Y Character position coordinates.
Description:
gprim_chrbegin sets the current character position to (X,Y). The next text
operation will start plotting characters at this position. All text operations update the
current character position as characters are plotted.
110 Confidential
6 Alphabetical list of GPRIM functions
Synopsis:
void gprim_chrspace (int dX, int dY)
Arguments:
int dX X axis character spacing distance.
int dY Y axis character spacing distance.
Description:
gprim_chrspace sets the current inter-character spacing distances. These values
are used to increment the current character position, in the X and Y axis directions,
after each character is plotted from a fixed width font. dX specifies the inter-
character spacing distance in the X axis direction, dY specifies the Y axis distance.
See also:
gprim_setfont
Confidential 111
6 Alphabetical list of GPRIM functions
Synopsis:
void gprim_circle (int Xc, int Yc, int A, int B)
Arguments:
int Xc,int Yc Centre coordinates.
int A Length of X direction semi axis.
int B Length of Y direction semi axis.
Description:
gprim_circle plots the outline of an axis aligned ellipse centered at (Xc,Yc)
and with semi-axis lengths of A and B pixels. Both A and B must be positive, the
larger of the two values is the semi-major axis length, while the lesser specifies the
semi-minor axis length. If A and B are equal, an outline of a circle is plotted with a
diameter equal to either A or B.
Diagram:
X
(Xc,Yc) A
112 Confidential
6 Alphabetical list of GPRIM functions
Synopsis:
void gprim_cls (int color)
Arguments:
int color Color.
Description:
gprim_cls clears the entire screen area to the color specified by color.
Confidential 113
6 Alphabetical list of GPRIM functions
Synopsis:
void gprim_copy (gprim_screen_t source,
int xstart, int ystart, int xsize, int ysize,
gprim_screen_t destination,
int xdstart, int ydstart)
Arguments:
gprim_region_t source Source region.
int xstart, int ystart Coordinates of region to be copied.
int xsize Width of region to be copied.
int ysize Height of region to be copied.
gprim_region_t destination Destination region.
int xdstart, int ydstart Coordinates of destination.
Description:
gprim_copy provides a function for copying rectangular regions around and
between the regions defined by calls to gprim_create_region, supplying NULL
as a region will result in a copy to/from the current drawable region.
114 Confidential
6 Alphabetical list of GPRIM functions
Synopsis:
#include "gprim.h"
Description:
Create a region suitable for drawing into, and optionally displaying. The function
takes co-ordinates for display based on a notional screen (PAL 720x625) (NTSC
720x525). When drawing in the region, top left is (0,0).
Arguments:
gprim_region_t *region Pointer to returned region id.
int xstart X coordinate of starting corner of region.
int ystart Y coordinate of starting corner of region.
int xend X coordinate of ending corner of region.
int yend X coordinate of ending corner of region.
int bits_per_pixelPixel size, 4/8 bits
Results:
Returns true if an error has occurred, false otherwise
Diagram:
X
(xstart, ystart)
(xend, yend)
Confidential 115
6 Alphabetical list of GPRIM functions
Synopsis:
void gprim_disjpolyline (int n, int *points)
Arguments:
int n Number of (X, Y) points.
int *points List of line start and end points.
Description:
gprim_disjpolyline draws a sequence of disjoint (unconnected) straight lines
between points defined by the integer vector points.
The points listed in points are alternately a start point followed by an end point. The
lines are drawn from each start point to the immediately following end point. Each
coordinate is used only once, as either a line start point or as an end point. The first
coordinate contained in points is always treated as a line start point and the next
its corresponding end point. The ith line is drawn from the point (points[4*i],
points[(4*i)+1]) to the point (points[(4*i)+2], points[(4*i)+3]).
The number of points is given by n which will usually be even, because a line is
described by two points. If n is odd a single point is plotted instead of the last line. If
n is 1 only a single point is plotted.
Diagram:
X
(points[0], points[1])
(points[4], points[5])
Y
(points[2], points[3])
(points[6], points[7])
n=4
116 Confidential
6 Alphabetical list of GPRIM functions
Synopsis:
boolean gprim_display (gprim_enable_disable_t flag)
Arguments:
gprim_enable_disable_t flag OSD_enable or OSD_disable flag.
Description:
gprim_display enables or disables the OSD.
Confidential 117
6 Alphabetical list of GPRIM functions
Synopsis:
boolean gprim_display_region (gprim_region_t region,
gprim_enable_disable_t flag)
Arguments:
gprim_region_t region Region to add or remove
gprim_enable_disable_flag flagAdd or remove?
Description:
gprim_display_region Is used to dynamically add or remove regions to or from
the screen.
See also:
gprim_display for enabling and disabling the display of OSD screens.
gprim_set_draw_region for controlling which region is currently being drawn to.
118 Confidential
6 Alphabetical list of GPRIM functions
Synopsis:
void gprim_dot (int X, int Y)
Arguments:
int X, int Y Coordinates of point.
Description:
gprim_dot plots a single point at (X,Y).
Diagram:
(X,Y)
Confidential 119
6 Alphabetical list of GPRIM functions
Synopsis:
void gprim_fcircle (int Xc, int Yc, int A, int B)
Arguments:
int Xc,int Yc Centre coordinate.
int A Length of X direction semi axis.
int B Length of Y direction semi axis.
Description:
gprim_fcircle plots a filled, axis aligned, ellipse centered at (Xc,Yc) and with
semi-axis lengths of A and B pixels. Both A and B must be positive; the larger of the
two values is the semi-major axis length, while the lesser specifies the semi-minor
axis length. A filled circle is plotted with a diameter equal to either A or B, if they
have identical values.
Diagram:
A
(Xc,Yc)
120 Confidential
6 Alphabetical list of GPRIM functions
Synopsis:
void gprim_frect (int X0, int Y0, int X1, int Y1)
Arguments:
int X0,int Y0 Corner point coordinate.
int X1,int Y1 Opposite point coordinate.
Description:
gprim_frect plots a filled, axis aligned, rectangle between two diagonally
opposite points specified by the coordinates (X0,Y0) and (X1,Y1).
Diagram:
(X0,Y0)
Y
(X1,Y1)
Confidential 121
6 Alphabetical list of GPRIM functions
Synopsis:
void gprim_getimage (int XS, int YS, int XE, int YE)
Arguments:
int XS,int YS Top left hand coordinate of screen region.
int XE,int YE Bottom right hand coordinate of screen
region.
Description:
gprim_getimage copies a region of the screen memory to the image buffer, this
allows saving of screen regions when an alert box needs to be displayed, or the
copying of regions about the screen.
See also:
gprim_putimage
122 Confidential
6 Alphabetical list of GPRIM functions
Synopsis:
boolean gprim_init (void)
Arguments:
none
Description:
gprim_init initializes the GPRIM system to the following state:
• Setup default variable width16-bit text font
• No current pel style
• No palette
• Clear screen
• Set OSD in standby
Confidential 123
6 Alphabetical list of GPRIM functions
Synopsis:
void gprim_line (int X0, int Y0, int X1, int Y1)
Arguments:
int X0,int Y0 Start point coordinate.
int X1,int Y1 End point coordinate.
Description:
gprim_line plots a straight line between two points specified by the coordinates
(X0,Y0) and (X1,Y1).
Diagram:
(X1,Y1)
Y
(X0,Y0)
124 Confidential
6 Alphabetical list of GPRIM functions
Synopsis:
int gprim_max_chars_in_width (int max_number_of_chars,
const char *text,
unsigned int width,
unsigned int *trimmed_width)
Arguments:
int max_number_of_chars Number of characters in the string.
const char *text String to be fitted.
unsigned int width Maximum line length in pixels.
unsigned int *trimmed_width Returned fitted line length in pixels.
Description:
gprim_max_chars_in_width takes a string of length max_number_of_chars
and returns the number of characters that will fit in a space of width pixels. The
string is not changed.
Confidential 125
6 Alphabetical list of GPRIM functions
Synopsis:
boolean gprim_out_of_standby (void)
Arguments:
none
Description:
gprim_out_of_standby performs any required hardware functions to take the
OSD hardware out of standby mode. This leaves the OSD disabled, since it may not
be required to display anything.
See also:
gprim_standby
126 Confidential
6 Alphabetical list of GPRIM functions
Synopsis:
void gprim_overstrike_addtext (int n, char *str)
Arguments:
int n Number of characters to plot.
char *str Character string.
Description:
gprim_overstrike_addtext plots n characters from the character string str
according to the current font description. Characters are plotted at the current
character position which is then incremented. If the font is a variable width font then
only the X position is incremented by the width of the character. If the font is not
variable width then the X and Y positions are incremented by the inter-character
spacing distances specified to gprim_chrspace. The current character position
after the operation completes is offset from the last character plotted by these
distances.
Characters are reproduced at the size of the current font, as set by
gprim_setfont. Bits set in the font description are plotted in the foreground color,
set using gprim_setfcol. This function differs from gprim_addtext in that clear
bits retain the background values of the current draw screen. This function is much
slower than gprim_addtext and it should be used sparingly.
See also:
gprim_addtext gprim_chrspace gprim_setfont gprim_setfcol
Confidential 127
6 Alphabetical list of GPRIM functions
Synopsis:
void gprim_text (int X, int Y, int n, char *str)
Arguments:
int X,int Y Start coordinate.
int n Number of characters to plot.
char *str Character string.
Description:
gprim_overstrike_text plots n characters from the character string str
according to the current font description. Characters are plotted at the current
character position which is then incremented. If the font is a variable width font then
only the X position is incremented by the width of the character. If the font is not
variable width then the X and Y positions are incremented by the inter-character
spacing distances specified to gprim_chrspace. The current character position
after the operation completes is offset from the last character plotted by these
distances.
Characters are reproduced at the size of the current font which is set using
gprim_setfont. Bits set in the font description are plotted in the foreground color,
set by gprim_setfcol. This function differs from gprim_text in that clear bits
retain the background values of the current draw screen. This function is much
slower than gprim_text and it should be used sparingly.
See also:
gprim_text gprim_chrspace gprim_setfont gprim_setfcol
128 Confidential
6 Alphabetical list of GPRIM functions
Synopsis:
void gprim_paint (int Xs, int Ys, int Bcol)
Arguments:
int Xs,int Ys Interior point coordinate.
int Bcol Boundary color.
Description:
gprim_paint flood fills a bounded region. The region is specified by a boundary of
constant color Bcol and filling starts at an interior point given by the coordinate
(Xs,Ys). If the pixel at this point already has the value Bcol then no filling occurs.
The current foreground color may be equal to the defined boundary color if required.
The fill region is clipped to the screen.
Diagram:
(Xs,Ys)
Bcol
Confidential 129
6 Alphabetical list of GPRIM functions
Synopsis:
void gprim_pel (int X, int Y)
Arguments:
int X, int Y Coordinates of pel.
Description:
gprim_pel plots a pel, placing its origin at (X,Y).
Diagram:
130 Confidential
6 Alphabetical list of GPRIM functions
Synopsis:
void gprim_polygon (int n, int *points)
Arguments:
int n Number of (X,Y) points.
int *points List of polygon vertex points.
Description:
gprim_polygon plots the outline of a polygon by drawing a sequence of
connected, straight lines, between its vertex points. The polygon’s last vertex point
is connected to its first to complete the outline. The coordinate of the point i is given
by the integer pair (points[2*i], points[(2*i)+1]) taken from the vector
points. The number of points is specified by n. Lines are drawn in the same order
as they are listed in points. If only one coordinate is present, or if all the points are
coincident, then a single point is plotted.
Diagram:
X (points[2],points[3])
Y(points[0],points[1])
(points[4],points[5])
(points[8],points[9])
n=5 (points[6],points[7])
Confidential 131
6 Alphabetical list of GPRIM functions
Synopsis:
void gprim_polyline (int n, int *points)
Arguments:
int n Number of (X,Y) points.
int *points List of line start and end points.
Description:
gprim_polyline draws a sequence of straight lines connecting the points defined
by the integer vector points. The number of points is specified by n. The coordi-
nate of the ith point are given by the integer pair (points[2*i],
points[(2*i)+1]). A line is drawn between each pair of coordinates and the
following pair. The drawing order is defined by the order of the coordinates in
points. The resulting continuous line is called a polyline.
Diagram:
X
(points[0],points[1]) (points[4],points[5])
(points[2],points[3])
(points[8],points[9]) (points[6],points[7])
n=5
132 Confidential
6 Alphabetical list of GPRIM functions
Synopsis:
void gprim_putimage (int X, int Y)
Arguments:
int X,int Y Top left hand coordinates of where to put
the buffer on screen.
Description:
gprim_putimage copies the contents of the image buffer to the screen.This allows
restoration of screen regions after display of an alert box, using (XS,YS) supplied
to gprim_getimage as (X,Y) for gprim_putimage, or the copying of previously
saved regions about the screen by supplying the destination as (X,Y) for
gprim_putimage, see gprim_getimage.
Confidential 133
6 Alphabetical list of GPRIM functions
Synopsis:
void gprim_query (int *xsize, int *ysize)
Arguments:
int *xsize Returned width of drawable area.
int *ysize Returned height of drawable area.
Description:
gprim_query provides information about the current region allowing graphics to
be sized based on the size of the current draw region.
134 Confidential
6 Alphabetical list of GPRIM functions
Synopsis:
void gprim_rect (int X0, int Y0, int X1, int Y1)
Arguments:
int X0,int Y0 Corner point coordinates.
int X1,int Y1 Opposite point coordinates.
Description:
gprim_rect plots an outline of an axis aligned rectangle between two diagonally
opposite points specified by the coordinates (X0,Y0) and (X1,Y1).
Diagram:
(X0,Y0)
Y
(X1,Y1)
Confidential 135
6 Alphabetical list of GPRIM functions
Synopsis:
#include "gprim.h"
Arguments:
none.
Results:
Returns true if an error is detected, false otherwise
136 Confidential
6 Alphabetical list of GPRIM functions
Synopsis:
void gprim_text (int X, int Y, int angle, int n, char *str)
Arguments:
int X,int Y Start coordinates.
int angle Angle from horizontal.
int n Number of characters to plot.
char *str Character string.
Description:
gprim_rotatedtext plots n characters from the character string str according
to the current font description. Characters are plotted at an angle from the current
character position which is then incremented. The angle is normalized so that
0x10000 represents 360 degrees, and 0 gives normal horizontal text.
Characters are reproduced at the size of the current font which is set by
gprim_setfont. Bits set in the font description are plotted in the foreground color;
set by gprim_setfcol. Clear bits are plotted in the background color, set by
gprim_setbcol.
Diagram:
X
Y str[3]
str[2]
str[1]
str[0]
(X, Y)
n=4
Confidential 137
6 Alphabetical list of GPRIM functions
Synopsis:
int gprim_search (int Xs, int Ys,
int Bcol, int sense, int direction)
Arguments:
int Xs,int Ys Search point coordinate.
int Bcol Color transition.
int sense Search criterion S_WHILENOT or
S_WHILEGOT.
int direction Search direction S_LEFT or S_RIGHT.
Results:
gprim_search returns xposn.
Description:
gprim_search is used to discover where on a horizontal line, a particular color
change occurs. The start point for the search is specified by the coordinate
(Xs,Ys), and the search occurs along a horizontal line drawn through that point.
The search proceeds in one of two directions - either to the left of the start point, or
to its right, as specified by direction. Valid search direction values for
direction are given in the following table:
Search direction value Meaning
S_LEFT Search left of start point
S_RIGHT Search right of start point
If sense is set to S_WHILENOT then searching continues until a pixel of the transi-
tion color Bcol is discovered. If sense is set to S_WHILEGOT then searching
continues until a pixel of some other color is found. The search criterion sense
defines which method to use. Valid search criterion values are given in the following
table:
Search test value Meaning
S_WHILENOT Search until a pixel of color Bcol is discovered
S_WHILEGOT Search until a pixel not equal in color to Bcol is discovered
138 Confidential
6 Alphabetical list of GPRIM functions
Diagram:
Current drawable
X
Confidential 139
6 Alphabetical list of GPRIM functions
Synopsis:
void gprim_set_colour_mixing_mask (unsigned int *mask)
Arguments:
unsigned int *mask Pointer to bit mask indicating colors to be
mixed.
Description:
gprim_set_colour_mixing_mask sets a mask indicating which colors, in the
palette, are to be mixed with the video signal on the TV display. Each palette entry
(1..15 for 4 bit, 1..255 for 8 bit) has an associated bit in the mask. If the mask bit is
set for a particular color, then that color will be mixed with the video according to the
value of the current mixing weight, set by gprim_set_colour_mixing_weight.
If a bit is not set for a particular color, then any pixels of that color on the display will
completely override the video display at that pixel. The bits in the mask are ordered
such that word 0 contains bits 0..31, word1 bits 32..63 etc.
140 Confidential
6 Alphabetical list of GPRIM functions
Synopsis:
void gprim_set_colour_mixing_weight (unsigned int weight)
Arguments:
unsigned int weight Weight to be given to graphics pixels.
Description:
gprim_set_colour_mixing_weight specifies how video and graphic pixels,
that are to be mixed, are mixed. The weight may have a value between 0 and 15
inclusive. At 0 the video pixel completely overrides the graphic, while at 15 the
graphic pixel completely overrides the video. Between these values the two pixel
values are combined to form a composite pixel value according to the weighting
value. See gprim_set_colour_mixing_mask for controlling which colors are to
be mixed.
Confidential 141
6 Alphabetical list of GPRIM functions
Synopsis:
boolean gprim_set_draw_region (gprim_region_t region)
Arguments:
gprim_region_t region Region to select.
Description:
gprim_set_draw_region sets the current drawing area to be region, which
must have been created using gprim_create_region. All future calls to GPRIM
drawing primitives will take place on the specified screen until this routine is called
to select the other drawing screen.
Note: different draw screens may have different dimensions, and different numbers
of bits per pixel depending on the system configuration. See gprim_query for
discovering the current region dimensions.
See also:
gprim_display_region for controlling the display of this region.
142 Confidential
6 Alphabetical list of GPRIM functions
Synopsis:
void gprim_setbcol (int Bcol)
Arguments:
int Bcol Background color.
Description:
gprim_setbcol sets the current background color to Bcol.
Confidential 143
6 Alphabetical list of GPRIM functions
Synopsis:
void gprim_setfcol (int Fcol)
Arguments:
int Fcol Foreground color.
Description:
gprim_setfcol sets the current foreground color to Fcol.
144 Confidential
6 Alphabetical list of GPRIM functions
Synopsis:
BOOLEAN gprim_setfont (unsigned int *packfont,
unsigned char *charact_widths,
int nchars, int famw, int famh,
int fwpc, int flpw)
Arguments:
unsigned int *packfont Encoded font.
unsigned char *charact_widths Array containing individual character
widths, all set to NULL for a fixed width
font.
int nchars Number of characters in font.
int famw Width of unpacked character in bits.
int famh Height of unpacked character in bits.
int fwpc Number of 32-bit words per character.
int flpw Number of encoded rows per 32-bit word.
Results:
Returns FALSE if the font was loaded successfully, TRUE otherwise.
Description:
gprim_setfont records a font description into the GPRIM server. Only one font
may be active at any one instant so this operation will overwrite any existing font
description held by GPRIM. Since gprim_setfont records a pointer to the font
data the function needs no memory to store the font. Currently gprim_setfont
handles only 8- and 16-bit fonts; any other width will return an error status.
Fonts are described by an integer vector which contains a packed representation of
each character contained in the font, and for variable width fonts an array containing
the width of each character. A font can contain any number of characters.
A bit mask is used to represent each character cell; this has a constant width and
height for all the characters of the same font. Bits are listed in horizontal scan line
order for each character; a one bit represents a colored pixel and a zero bit the
background. The bit masks for each character are packed into a number of 32-bit
words, these are then concatenated to produce the packed font. The order defines
how characters are retrieved from the font; the integer value of a character is used
as the index of the corresponding character cell within the font array. If ASCII text
representation is required then the font should contain character descriptions at
positions that correspond to the ASCII encoding.
packfont is an integer vector that describes a font containing nchars characters.
character_widths is an array of unsigned bytes that define the width of each
Confidential 145
6 Alphabetical list of GPRIM functions
character for a variable width font; passing NULL in this parameter gives a fixed
width font of size 8 or 16, as passed in famw.
Character cells are described by the parameters famw, famh, fwpc and flpw. The
width of the bitmap is given by famw; this specifies the number of bits to use per
horizontal row. The height of the bitmap is given by famh; this gives the number of
rows per character in the font. Each bit defines whether a foreground or background
pixel is plotted. fwpc is the number of 32-bit words required to encode one
character cell and flpw is the number of horizontal rows encoded per word.
All text operations use the current font description.
Section 5.2 in Chapter 5 describes the defining of fonts in more detail.
146 Confidential
6 Alphabetical list of GPRIM functions
Synopsis:
boolean gprim_setpalette (int palette_index,
int red, int green, int blue)
Arguments:
int palette_index Entry in palette.
int red Red color value.
int green Green color value.
int blue Blue color value.
Description:
gprim_setpalette sets an entry in the color palette. palette_index is will be
used as a pixel value and must be in the range 1..15 for 4 bit regions, and 1..255 for
8 bit regions, since zero is reserved for transparent. The three color values must be
in the range 0..255. NOTE gprim_setpalette now only applies to the current
draw region.
Confidential 147
6 Alphabetical list of GPRIM functions
Synopsis:
void gprim_setpel (const int pel_xsize, const int pel_ysize,
const gprim_pel_format_t pel_format,
const unsigned int *pel_data,
const unsigned char *pel_mask,
const int pel_xorig, const int pel_yorig)
Arguments:
const int pel_xsize Width of pel style in pixels.
const int pel_ysize Height of pel style in pixels.
const gprim_pel_format_t pel_format
Specify form of pel_data
const unsigned int *pel_data Pel style pixel data.
const unsigned char
*pel_mask Pel style pixel mask.
const int pel_xorig Horizontal offset from top left corner to
origin of pel.
const int pel_yorig Vertical downwards offset from top left
corner to origin of pel.
Description:
gprim_setpel sets the current pel style. Pel styles are represented by a two
dimensional pattern which can be plotted on the screen with gprim_pel.
The size of the pel pattern is given by pel_xsize pixels in the horizontal direction,
and pel_ysize pixels vertically.
The pel style is described by the vector pel_data, which should contain, in hori-
zontal row order, each row of pixels that make up the custom pel pattern, or a run
length encoding of the rows.
pel_format has two possible values (at this time):
• packed_pel
Data is stored in 32 bit words, i.e. each 4 bit pixel is stored as a nibble (4 bits)
of an unsigned integer with zero padding at the end of each row. For example,
a row of 11 pixels with values 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 and 11 would be
packed as 0x12345678, 0x9ab00000, similarly for 8 bit pixels, but with each
word holding only 4 pixels.
• run_length_encoded_pel
Each row is encoded separately. The formats differ for 4- and 8-bit pels:-
• 4 Bit
A sequence of bytes where each byte has a count (top 4 bits), and a
148 Confidential
6 Alphabetical list of GPRIM functions
value (bottom 4 bits). If the count is zero then the value is shifted up by
4 and ORed with the next count field, allowing up to 255 pixels to be
specified in 2 bytes. The value field will be repeated count times.
• 8 Bit
A sequence of byte pairs where the first byte is the count and the
second is the value.
NOTE because of the above format differences 8- and 4-bit pels are not inter-
changeable.
The mask pel_mask allows pels to have a shape other than a rectangle by allowing
the background to show in some pixels. The mask has one bit for each pixel, in the
same order as the data, with each row padded to an 8 bit (byte) boundary. Bits set
to 1 set the corresponding pixel to the color of the pel while bits set to 0 set the
corresponding pixel to the color of the background. Unused pixels are set to 0. If the
mask is NULL then all pel pixels will be visible and the pel will be rectangular.
The pel style has a single point, located within its bulk, that identifies an origin. Pels
are plotted such that their origins are positioned at the coordinate of the replaced
point. (pel_xorig, pel_yorig) defines the origin of the pel style as an offset
from the base of its two dimensional pattern, which is at the top left hand corner.
pel_ysize
pel_xorig
pel_xsize
Confidential 149
6 Alphabetical list of GPRIM functions
Synopsis:
boolean gprim_standby (void)
Arguments:
none
Description:
gprim_standby disables the display, and performs any hardware related function
to set the OSD hardware into standby mode.
See also:
gprim_out_of_standby
150 Confidential
6 Alphabetical list of GPRIM functions
Synopsis:
void gprim_styled_line (int X, int Y, int angle,
int n, unsigned int *data)
Arguments:
int X,int Y Start coordinates.
int angle Angle.
int n Number of pixels to plot.
unsigned int *data Pixel data values.
Description:
gprim_styled_line plots n pixels taking pixel values from memory pointed to by
data. The line is plotted at an angle from the horizontal. The angle is normalized so
that 0x10000 represents 360 degrees, and 0 gives normal horizontal line.
Confidential 151
6 Alphabetical list of GPRIM functions
Synopsis:
void gprim_text (int X, int Y, int n, char *str)
Arguments:
int X,int Y Start coordinate.
int n Number of characters to plot.
char *str Character string.
Description:
gprim_text plots n characters from the character string str according to the
current font description. Characters are plotted at the current character position
which is then incremented. If the font is a variable width font then only the X position
is incremented by the width of the character. If the font is not variable width then the
X and Y positions are incremented by the inter-character spacing distances
specified to gprim_chrspace. The current character position after the operation
completes is offset from the last character plotted by these distances.
Characters are reproduced at the size of the current font which is set by
gprim_setfont. Bits set in the font description are plotted in the foreground color,
set by gprim_setfcol. Clear bits are plotted in the background color, set by
gprim_setbcol.
Diagram:
Y
(x,y)
n = 4
= current character position
= Individual character widths/current inter-character spacing
152 Confidential
6 Alphabetical list of GPRIM functions
Synopsis:
int gprim_textsize (int n, char *str)
Arguments:
int n Number of characters to plot.
char *str Character string.
Results:
gprim_textsize returns the width of the text string str in pixels.
Description:
This function takes a string and calculates its width. It is provided to assist in the use
of variable width fonts and allows the user to center text on the screen.
Confidential 153
6 Alphabetical list of GPRIM functions
154 Confidential