1 /*******************************************************************************
2 * vout_ggi.c: GGI video output display method
4 *******************************************************************************/
6 /*******************************************************************************
8 *******************************************************************************/
17 #include "vlc_thread.h"
20 #include "video_output.h"
21 #include "video_sys.h"
24 /*******************************************************************************
25 * vout_sys_t: video output GGI method descriptor
26 *******************************************************************************
27 * This structure is part of the video output thread descriptor.
28 * It describes the GGI specific properties of an output thread.
29 *******************************************************************************/
30 typedef struct vout_sys_s
32 /* GGI system informations */
33 ggi_visual_t p_display; /* display device */
39 /*******************************************************************************
41 *******************************************************************************/
42 static int GGIOpenDisplay ( vout_thread_t *p_vout );
43 static void GGICloseDisplay ( vout_thread_t *p_vout );
45 /*******************************************************************************
46 * vout_SysCreate: allocate GGI video thread output method
47 *******************************************************************************
48 * This function allocate and initialize a GGI vout method. It uses some of the
49 * vout properties to choose the correct mode, and change them according to the
51 *******************************************************************************/
52 int vout_SysCreate( vout_thread_t *p_vout )
54 /* Allocate structure */
55 p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
56 if( p_vout->p_sys == NULL )
58 intf_ErrMsg("error: %s\n", strerror(ENOMEM) );
62 /* Open and initialize device */
63 if( GGIOpenDisplay( p_vout ) )
65 intf_ErrMsg("error: can't initialize GGI display\n");
66 free( p_vout->p_sys );
73 /*******************************************************************************
74 * vout_SysInit: initialize GGI video thread output method
75 *******************************************************************************
76 * This function initialize the GGI display device.
77 *******************************************************************************/
78 int vout_SysInit( vout_thread_t *p_vout )
80 p_vout->p_sys->i_buffer_index = 0;
84 /*******************************************************************************
85 * vout_SysEnd: terminate Sys video thread output method
86 *******************************************************************************
87 * Terminate an output method created by vout_SysCreateOutputMethod
88 *******************************************************************************/
89 void vout_SysEnd( vout_thread_t *p_vout )
94 /*******************************************************************************
95 * vout_SysDestroy: destroy Sys video thread output method
96 *******************************************************************************
97 * Terminate an output method created by vout_SysCreateOutputMethod
98 *******************************************************************************/
99 void vout_SysDestroy( vout_thread_t *p_vout )
101 GGICloseDisplay( p_vout );
102 free( p_vout->p_sys );
105 /*******************************************************************************
106 * vout_SysManage: handle Sys events
107 *******************************************************************************
108 * This function should be called regularly by video output thread. It returns
109 * a negative value if something happened which does not allow the thread to
110 * continue, and a positive one if the thread can go on, but the images have
111 * been modified and therefore it is useless to display them.
112 *******************************************************************************/
113 int vout_SysManage( vout_thread_t *p_vout )
120 /*******************************************************************************
121 * vout_SysDisplay: displays previously rendered output
122 *******************************************************************************
123 * This function send the currently rendered image to the display, wait until
124 * it is displayed and switch the two rendering buffer, preparing next frame.
125 *******************************************************************************/
126 void vout_SysDisplay( vout_thread_t *p_vout )
128 /* Change display frame */
129 ggiFlush( p_vout->p_sys->p_display ); // ??
130 ggiSetDisplayFrame( p_vout->p_sys->p_display, p_vout->p_sys->i_buffer_index );
132 /* Swap buffers and change write frame */
133 p_vout->p_sys->i_buffer_index = ++p_vout->p_sys->i_buffer_index & 1;
134 ggiSetWriteFrame( p_vout->p_sys->p_display, p_vout->p_sys->i_buffer_index );
137 /*******************************************************************************
138 * vout_SysGetPicture: get current display buffer informations
139 *******************************************************************************
140 * This function returns the address of the current display buffer.
141 *******************************************************************************/
142 byte_t * vout_SysGetPicture( vout_thread_t *p_vout )
145 // return( p_vout->p_sys->p_ximage[ p_vout->p_sys->i_buffer_index ].data );
148 /* following functions are local */
150 /*******************************************************************************
151 * GGIOpenDisplay: open and initialize GGI device
152 *******************************************************************************
153 * Open and initialize display according to preferences specified in the vout
155 *******************************************************************************/
156 static int GGIOpenDisplay( vout_thread_t *p_vout )
158 ggi_mode mode; /* mode descriptor */
160 /* Initialize library */
163 intf_ErrMsg("error: can't initialize GGI library\n");
168 p_vout->p_sys->p_display = ggiOpen( NULL );
169 if( p_vout->p_sys->p_display == NULL )
171 intf_ErrMsg("error: can't open GGI default display\n");
176 /* Find most appropriate mode */
177 mode.frames = 2; /* 2 buffers */
178 mode.visible.x = p_vout->i_width; /* minimum width */
179 mode.visible.y = p_vout->i_width; /* maximum width */
180 mode.virt.x = GGI_AUTO;
181 mode.virt.y = GGI_AUTO;
182 mode.size.x = GGI_AUTO;
183 mode.size.y = GGI_AUTO;
184 mode.graphtype = GT_15BIT; /* minimum usable screen depth */
185 mode.dpp.x = GGI_AUTO;
186 mode.dpp.y = GGI_AUTO;
187 ggiCheckMode( p_vout->p_sys->p_display, &mode );
189 /* Check that returned mode has some minimum properties */
193 if( ggiSetMode( p_vout->p_sys->p_display, &mode ) )
195 intf_ErrMsg("error: can't set GGI mode\n");
196 ggiClose( p_vout->p_sys->p_display );
201 /* Set thread information */
202 p_vout->i_width = mode.visible.x;
203 p_vout->i_height = mode.visible.y;
204 switch( mode.graphtype )
207 p_vout->i_screen_depth = 15;
208 p_vout->i_bytes_per_pixel = 2;
211 p_vout->i_screen_depth = 16;
212 p_vout->i_bytes_per_pixel = 2;
215 p_vout->i_screen_depth = 24;
216 p_vout->i_bytes_per_pixel = 3;
219 p_vout->i_screen_depth = 32;
220 p_vout->i_bytes_per_pixel = 4;
223 intf_ErrMsg("error: unsupported screen depth\n");
224 ggiClose( p_vout->p_sys->p_display );
233 /*******************************************************************************
234 * GGICloseDisplay: close and reset GGI device
235 *******************************************************************************
236 * This function returns all resources allocated by GGIOpenDisplay and restore
237 * the original state of the device.
238 *******************************************************************************/
239 static void GGICloseDisplay( vout_thread_t *p_vout )
241 // Restore original mode and close display
242 ggiClose( p_vout->p_sys->p_display );