[Previous] [Contents] [Index] [Next]

Caution: This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs.

disp_modefuncs_t

Table of your driver's modeswitcher functions

Synopsis:

#include <mode.h>

typedef struct disp_modefuncs {
    int  (*init) (...);
    void (*fini) (...);
    void (*module_info) (...);
    int  (*get_modeinfo) (...);
    void (*get_modelist) (...);
    int  (*set_mode) (...);
    int  (*wait_vsync) (...);
    int  (*set_dpms_mode) (...);
    int  (*set_display_offset) (...);
    int  (*set_palette) (...);
    void (*set_scroll_position (...);
    int  (*layer_query (...);
    int  (*layer_select_format  (...);
    int  (*layer_enable  (...);
    int  (*layer_disable  (...);
    int  (*layer_set_surface  (...);
    int  (*layer_set_source_viewport  (...);
    int  (*layer_set_dest_viewport  (...); 
    int  (*layer_set_blending  (...);
    int  (*layer_set_chromakey  (...);
    int  (*layer_set_brightness  (...);    
    int  (*layer_set_saturation  (...);    
    int  (*layer_set_contrast  (...);    
    int  (*layer_set_flags  (...);
    void (*layer_update_begin  (...);
    void (*layer_update_end  (...);
    void (*layer_reset  (...);


} disp_modefuncs_t;

Description:

The disp_modefuncs_t structure is a table that your driver uses to define the modeswitcher functions that it provides to the graphics framework. Your driver's devg_get_modefuncs() entry point must fill in this structure.

init()

The graphics framework calls this function to initialize your hardware. The prototype is:

int (*init) (disp_adapter_t *ctx,
             char *optstring)

This function should return the number of displays that this modeswitcher controls, or -1 to indicate an error. For example, if a display card controls both a flat-panel and a monitor simultaneously, this function should return 2.

For more information on where this function fits into the general flow, see "Calling sequence" in the Writing a Graphics Driver chapter.

fini()

The graphics framework calls this function to return your hardware to the uninitialized state, deallocate resources, and so on. The prototype is:

void (*fini) (disp_adapter_t *ctx)

For more information on where this function fits into the general flow, see "Calling sequence" in the Writing a Graphics Driver chapter.

module_info()

The graphics framework calls this function to get information about the module, such as its description and revision numbers. The prototype is:

void (*module_info) (disp_adapter_t *adapter,
                     disp_module_info_t *info);

This function should fill in the disp_module_info_t structure pointed to by info.

get_modeinfo()

The graphics framework calls this function to get mode information. The prototype is:

int (*get_modeinfo) (disp_adapter_t *ctx,
                     int dispno,
                     unsigned mode,
                     disp_mode_info_t *info)

This function should populate the disp_module_info_t structure pointed to by info with information pertaining to the mode specified in mode for the display referenced by dispno. See the note about modes in get_modelist() below for more information.

get_modelist()

The graphics framework calls this function to get a list of the modes that your driver supports. The prototype is:

void (*get_modelist) (disp_adapter_t *ctx,
                      int dispno,
                      disp_mode_t *list,
                      int index,
                      int size)

This function should place a maximum of size modes into the array list, starting at the index index, for the display referenced by dispno. The index parameter is in place to allow multiple calls to the get_modelist() function in case there are more modes than will fit into the list array on any given call.

The list of modes is terminated with the constant DISP_MODE_LISTEND -- don't return this as a valid mode. The list of modes must be returned in the exact same order each time, but there's no requirement to arrange the list by any sorting criteria.


Note: It's the mode number (the content of the list array) that's important for subsequent calls, and not the mode index itself.

For example, if your driver returns the following array:

list [0] = 0x1234;
list [1] = 0x070B;
list [2] = 0x4321;
list [3] = DISP_MODE_LISTEND; // terminate list

then your get_modeinfo() and set_mode() functions are called with, for example, 0x4321 and not the index 2.


Note: The driver should use only the 15 least significant bits of the disp_mode_t type. Thus each entry in list must be less than or equal to 0x7fff.

set_mode()

The graphics framework calls this function to set the hardware for the display referenced by dispno to the mode specified by mode. The prototype is:

int (*set_mode) (disp_adapter_t *ctx,
                 int dispno,
                 unsigned mode,
                 disp_crtc_settings_t *settings,
                 disp_surface_t *surf,
                 unsigned flags)

See the note about modes in get_modelist() above for more information.

The settings parameter is valid only if the mode is a generic mode, which means that the framework can pass an arbitrary X and Y resolution and refresh rate. The driver advertises that it can support generic modes by setting the appropriate flag in the disp_mode_info_t structure when get_modeinfo() is called.

If your driver supports virtual panning, the virtual screen might be larger than the physical screen resolution of the requested mode. The virtual x and y resolutions are passed in surf->width and surf->height. The surf->stride member specifies the stride, in bytes, that the driver should use to program the CRTC controller.

For more information on where this function fits into the general flow, see "Calling sequence" in the Writing a Graphics Driver chapter.

wait_vsync()

This function must wait until the display controller for the display referenced by dispno enters the vertical-retrace period. The prototype is:

int  (*wait_vsync) (disp_adapter_t *adapter,
                    int dispno);

set_dpms_mode()

The graphics framework calls this function to set the DPMS mode. mode. The prototype is:

void (*set_dpms_mode) (disp_adapter_t *ctx,
                       int dispno,
                       int mode)

Select a DPMS mode for the display referenced by dispno as follows:

Mode Meaning
0 On
1 Standby
2 Suspend
4 (not a typo) Off

set_display_offset()

The graphics framework calls this function to set the frame buffer base of the visible display for the display controller referenced by dispno. The prototype is:

void (*set_display_offset) (disp_adapter_t *ctx,
                            int dispno,
                            unsigned offset,
                            int wait_vsync)

Note: The offset member must be a multiple of the crtc_start_gran member of the disp_mode_info_t structure.

If wait_vsync is nonzero, your driver should wait for the next vertical retrace period before returning from this function.

set_palette()

The graphics framework calls this function to set the palette for the display referenced by dispno. The prototype is:

void (*set_palette) (disp_adapter_t *ctx, 
                     int dispno,
                     int index,
                     int count,
                     disp_color_t *pal)

One or more entries in the palette can be set at a time with this function call. The index indicates the starting palette index, and count indicates the number of entries being set. Finally, pal contains an array of color values, one per entry, to set.


Note: If this function is specified (i.e. not NULL in the function pointer set_palette), then it's called regardless of whether or not the set_palette() function in the miscellaneous callouts structure, disp_draw_miscfuncs_t, has been supplied:
if (disp_modefuncs -> set_palette) {
    (*disp_modefuncs -> set_palette) (...);
} else if (disp_draw_miscfuncs -> set_palette) {
    (*disp_draw_miscfuncs -> set_palette (...);
}

set_scroll_position()

The graphics framework calls this function to scroll, or pan around a virtual desktop when the virtual display surface is bigger than the physical display. If your driver supports Virtual Panning, you must provide this function. The prototype is:

void (*set_scroll_position) (
        disp_adapter_t *adapter,
        int dispno,
        int xoff,
        int yoff )

This function should set the physical viewport into the virtual display surface such that the point (xoff, yoff) within the virtual display appears at the upper left corner of the physical display.

layer_query()

The graphics framework calls this function to query the capabilities of a given layer. The prototype is:

int (*layer_query) (
        disp_adapter_t *adapter,
        int dispno,
        int layer_idx,
        int fmt_idx,
disp_layer_query_t  *info);

The arguments to layer_query are:

adapter
A pointer to the disp_adapter_t structure.
dispno
The display associated with the layer selected by layer_idx.
layer_idx
The index of the layer being queried. Layers are indexed starting at 0.
fmt_idx
The index that pertains to the data format that's returned. Formats are indexed starting at 0.
info
A pointer to a structure that the driver fills in based on the selected layer and data format. The information returned for a layer can vary for different pixel formats. For more information on pixel formats for layers, see "Pixel formats for layers" in the Writing a Graphics Driver chapter.

If the layer_idx or fmt_idx indexes are out of range, this function should return -1, otherwise it should return 0.

layer_select_format()

The graphics framework calls this function to select the pixel format of the the layer specified by layer_idx. The prototype is:

int (*layer_select_format) (
        disp_adapter_t *adapter,
        int dispno,
        int layer_idx,
        int fmt_idx )

The format specified by fmt_idx corresponds to the fmt_idx that was passed to layer_query.

The arguments to layer_select_format are:

adapter
A pointer to the disp_adapter_t structure.
dispno
The display associated with the layer selected by layer_idx.
layer_idx
The index of the layer that corresponds to the pixel format selected. Layers are indexed starting at 0.
fmt_idx
The index that pertains to the pixel format selected. Formats are indexed starting at 0.

If the dispno, layer_idx, or fmt_idx indexes are out of range, this function should return -1 to indicate an error, otherwise it should return 0.

layer_enable()

The graphics framework calls this function to make the layer specified by layer_idx visible. The prototype is:

int (*layer_enable) (
        disp_adapter_t *adapter,
        int dispno,
        int layer_idx )

The arguments to layer_enable are:

adapter
A pointer to the disp_adapter_t structure.
dispno
The display associated with the layer selected by layer_idx.
layer_idx
The index of the layer that layer_idx makes visible. Layers are indexed starting at 0.

If the dispno or layer_idx indexes are out of range, or the layer can't be disabled or reenabled, this function should return -1 to indicate an error, otherwise it should return 0.

layer_disable()

The graphics framework calls this function to make the layer specified by layer_idx invisible. The prototype is:

int (*layer_enable) (
        disp_adapter_t *adapter,
        int dispno,
        int layer_idx )

The arguments to layer_disable are:

adapter
A pointer to the disp_adapter_t structure.
dispno
The display associated with the layer selected by layer_idx.
layer_idx
The index of the layer that layer_idx makes invisible. Layers are indexed starting at 0.

If the dispno, or layer_idx indexes are out of range, or the layer can't be disabled or re-enabled, this function should return -1 to indicate an error, otherwise it should return 0.

layer_set_surface()

The graphics framework calls this function to associate a memory surface with the layer specified by layer_idx. The prototype is:

int (*layer_set_surface) (
        disp_adapter_t *adapter,
        int dispno,
        int layer_idx,
        int surface_idx,
        disp_surface_t *surf )

The arguments to layer_set_surface are:

adapter
A pointer to the disp_adapter_t structure.
dispno
The display associated with the layer selected by layer_idx.
layer_idx
The index of the layer associated with the memory surface. Layers are indexed starting at 0.
surface_idx
The meaning of this argument depends on the layer image format selected by layer_select_format.

Some layer formats split the image components across multiple buffers. A planar YUV surface, for example, requires three buffers to store a valid image. In this case, the surface_idx argument specifies whether a Y, U, or V buffer gets allocated.

surf
A pointer to the surface created by disp_surface_t.

The memory surface was created by the driver's alloc_layer_surface() management entry point. The layer_select_format entry point is called before this entry point.

If the dispno or layer_idx indexes are out of range, this function should return -1 to indicate an error, otherwise it should return 0.

layer_set_source_viewport()

The graphics framework calls this function to set the size of the source viewport for the layer that layer_idx specifies. The prototype is:

int (*layer_set_source_viewport) (
        disp_adapter_t *adapter,
        int dispno,
        int layer_idx,
        int x1, y1,
        int x2, y2 )
       

The arguments to layer_set_source_viewport are:

adapter
A pointer to the disp_adapter_t structure.
dispno
The display associated with the layer selected by layer_idx.
layer_idx
The index of the layer that corresponds to the source viewport. Layers are indexed starting at 0.
x1, y1
The location of the top-left edge of the source viewport.
x2, y2
The location of the bottom-right edge of the source viewport.

This function should return -1 if:

Otherwise the function should return 0.

layer_set_dest_viewport()

The graphics framework calls this function to set the size of the destination viewport for the layer that layer_idx specifies. The prototype is:

int (*layer_set_dest_viewport) (
        disp_adapter_t *adapter,
        int dispno,
        int layer_idx,
        int x1, y1,
        int x2, y2 )
    

The arguments to layer_set_dest_viewport are:

adapter
A pointer to the disp_adapter_t structure.
dispno
The display associated with the layer selected by layer_idx.
layer_idx
The index of the layer that corresponds to the destination viewport. Layers are indexed starting at 0.
x1, y1
The location of the top-left edge of the destination viewport.
x2, y2
The location of the bottom-right edge of the destination viewport.

If the dispno or layer_idx indexes are out of range, or the viewport width for the capabilities structure for this layer is outside the ranges specified by dst_max_height, dst_min_height, dst_max_width, and dst_min_width, this function should return -1 to indicate an error, otherwise it should return 0.

layer_set_blending()

The graphics framework calls this function to set the layer's blending configuration for the layer specified by layer_idx. The prototype is:

int (*layer_set_blending) (
        disp_adapter_t *adapter,
        int dispno,
        int layer_idx,
        unsigned alpha_mode,
        int m1,
        int m2 )

The arguments to layer_set_blending are:

adapter
A pointer to the disp_adapter_t structure.
dispno
The display associated with the layer selected by layer_idx.
layer_idx
The index of layer to blend. Layers are indexed starting at 0.
alpha_mode
The logical OR of up to four different flags. Four groups of flags are available, and either zero or one flags can be selected from each group. When a value of 0 is passed for alpha_mode, alpha blending is disabled.
m1
A primary alpha multiplier that's used when there's a request for blending using global alpha multipliers.
m2
A secondary alpha multiplier that's used when there's a request for blending using global alpha multipliers.

If the dispno or layer_idx indexes are out of range, this function should return -1 to indicate an error, otherwise it should return 0.

If the layer selected by layer_idx doesn't support the combination of flags specified by alpha_mode, this function should return -1, otherwise it should return 0.

For more information on global alpha multipliers, and the currently defined flags, see "Alpha mode bits."

layer_set_chromakey()

The graphics framework calls this function to set the layer's chroma-key configuration for the layer specified by layer_idx. The prototype is:

int (*layer_set_chromakey) (
        disp_adapter_t *adapter,
        int dispno,
        int layer_idx,
        unsigned chroma_mode,
        disp_color_t color0,
        disp_color_t color1,
        disp_color_t mask );      

The arguments to layer_set_chromakey are:

adapter
A pointer to the disp_adapter_t structure.
dispno
The display associated with the layer selected by layer_idx.
layer_idx
The layer index for the chroma-key configuration.
chroma_mode
Selected from: DISP_CHROMA_OP_SRC_MATCH, DISP_CHROMA_OP_DST_MATCH, DISP_CHROMA_OP_DRAW, DISP_CHROMA_OP_NO_DRAW

DISP_CHROMA_OP_SRC_MATCH and DISP_CHROMA_OP_DST_MATCH are mutually exclusive.

DISP_CHROMA_OP_DRAW and DISP_CHROMA_OP_NO_DRAW are also mutually exclusive.

If 0 is passed for chroma-mode, chroma-keying is disabled.

For more information on chroma key mode bits, see "Chroma mode bits"

color0
The color to test on.
color1
Reserved; ignore this argument.
mask
Reserved; ignore this argument.

If the layer selected by layer_idx doesn't support the combination of flags specified by chroma_mode, this function should return -1, otherwise it should return 0.

layer_set_brightness()

The graphics framework calls this function to set the brightness attribute of the layer specified by layer_idx. The prototype is:

int (*layer_set_brightness) (
        disp_adapter_t *adapter,
        int dispno,
        int layer_idx,
        int brightness );

The arguments to layer_set_brightness are:

adapter
A pointer to the disp_adapter_t structure.
dispno
The display associated with the layer selected by layer_idx.
layer_idx
The layer index for the brightness adjustment. Layers are indexed starting at 0.
brightness
The brightness value, in the range from 127 to -128, where 127 is brightest, and -128 is darkest. A value of 0 is normal brightness.

If the selected layer doesn't support brightness adjustment, this function should return -1 to indicate an error, otherwise it should return 0.

layer_set_saturation()

The graphics framework calls this function to set the color saturation attribute of the layer specified by layer_idx. The prototype is:

int (*layer_set_saturation) (
        disp_adapter_t *adapter,
        int dispno,
        int layer_idx,
        int saturation );

The arguments to layer_set_saturation are:

adapter
A pointer to the disp_adapter_t structure.
dispno
The display associated with the layer selected by layer_idx.
layer_idx
The layer index for the saturation adjustment. Layers are indexed starting at 0.
saturation
The saturation value, in the range from 127 to -128, where 127 is most saturated, and -128 is least saturated. A value of 0 is normal saturation.

If the selected layer doesn't support saturation adjustment, this function should return -1 to indicate an error, otherwise it should return 0.

layer_set_contrast()

The graphics framework calls this function to set the contrast attribute of the layer specified by layer_idx. The prototype is:

int (*layer_set_contrast) (
        disp_adapter_t *adapter,
        int dispno,
        int layer_idx,
        int contrast );

The arguments to layer_set_contrast are:

adapter
A pointer to the disp_adapter_t structure.
dispno
The display associated with the layer selected by layer_idx.
layer_idx
The layer index for the contrast adjustment. Layers are indexed starting at 0.
contrast
The contrast value, in the range from 127 to -128, where 127 is the highest contrast, and -128 is the lowest contrast. A value of 0 is normal contrast.

If the selected layer doesn't support contrast adjustment, this function should return -1 to indicate an error, otherwise it should return 0.

layer_set_flags()

The graphics framework calls this function to set various attributes of the layer specified by layer_idx. The prototype is:

int (*layer_set_flags) (
        disp_adapter_t *adapter,
        int dispno,
        int layer_idx,
        unsigned flag_mask
        unsigned flag_values );

The arguments to layer_set_flags are:

adapter
A pointer to the disp_adapter_t structure.
dispno
The display associated with the layer selected by layer_idx.
layer_idx
The layer index for the attributes that are set. Layers are indexed starting at 0.
flag_mask
The bits whose values are to be changed. If a bit isn't set in flag_mask, the corresponding flag isn't affected.
flag_values
The new settings that correspond to the bits set in flag_mask.

The following flags are supported:

DISP_LAYER_FLAG_DISABLE_FILTERING
Disable any filtering algorthims that are applied to the image data before the image is displayed. When scaling is in effect, pixel replication is used instead of filtering to produce the scaled image, if pixel replication is supported.
DISP_LAYER_FLAG_EDGE_CLAMP
If the image being displayed isn't large enough to fill the destination viewport, then the unfilled right and bottom portions of the viewport are filled by replicating the last pixel that was displayed to the edge of the viewport.
DISP_LAYER_FLAG_EDGE_WRAP
If the image being displayed isn't large enough to fill the destination viewport, then the unfilled right and bottom portions of the viewport are filled by wrapping around to the top, left portions of the image.

If the selected layer isn't supported by one or more of the flags specified by flag_mask, this function should return -1 to indicate an error, otherwise it should return 0.

layer_update_begin()

This function must be called before you make any adjustments to the layer configuration. The driver should attempt to make multiple adjustments atomic, by having the adjustments take effect at the time layer_update_end() is called. The prototype is:

void  (*layer_update_begin) (
        disp_adapter_t *adapter,
        int dispno,
        int layer_idx );

The arguments to layer_update_begin are:

adapter
A pointer to the disp_adapter_t structure.
dispno
The display associated with the layer selected by layer_idx.
layer_idx
The layer index for the updates. Layers are indexed starting at 0.

layer_update_end()

The prototype is:

void  (*layer_update_end) (
        disp_adapter_t *adapter,
        int dispno,
        int layer_idx );

The arguments to layer_update_end are:

adapter
A pointer to the disp_adapter_t structure.
dispno
The display associated with the layer selected by layer_idx.
layer_idx
The layer index for the updates. Layers are indexed starting at 0.

Before any calls are made that affect the layer configuration, layer_update_begin() is called, and subsequently layer_update_end() makes the changes effective.

This function runs after adjustments are made to the layer configuration. Any adjustments made since layer_update_begin() was called, will now take effect.


Note: The layer_query() function doesn't affect the layer configuration and is therefore an exception to this rule.

layer_reset()

The prototype is:

void  (*layer_reset) (
        disp_adapter_t *adapter,
        int dispno,
        int layer_idx );

The arguments to layer_reset are:

adapter
A pointer to the disp_adapter_t structure.
dispno
The display associated with the layer selected by layer_idx.
layer_idx
The index for the reset layers. Layers are indexed starting at 0.

This function resets the specified layer to its initial state.

A layer should be reset to its initial state after a modeswitch.

The initial state is defined as one where:

Classification:

Photon

See also:

devg_get_modefuncs(), disp_adapter_t, disp_crtc_settings_t, disp_mode_info_t, disp_module_info_t, disp_surface_t


[Previous] [Contents] [Index] [Next]