Search
lxdream.org :: lxdream :: r335:fb890e1814c0
lxdream 0.9.1
released Jun 29
Download Now
changeset335:fb890e1814c0
parent334:59073f812bd3
child336:c3455be86ee2
authornkeynes
dateSat Jan 27 12:03:53 2007 +0000 (12 years ago)
Start working towards more thorough interlaced support
src/display.h
src/drivers/video_gtk.c
src/drivers/video_x11.c
src/pvr2/pvr2.c
src/pvr2/pvr2.h
1.1 --- a/src/display.h Sat Jan 27 12:02:54 2007 +0000
1.2 +++ b/src/display.h Sat Jan 27 12:03:53 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: display.h,v 1.3 2007-01-25 11:46:35 nkeynes Exp $
1.6 + * $Id: display.h,v 1.4 2007-01-27 12:03:53 nkeynes Exp $
1.7 *
1.8 * The PC side of the video support (responsible for actually displaying /
1.9 * rendering frames)
1.10 @@ -55,6 +55,7 @@
1.11 uint32_t vres;
1.12 uint32_t rowstride;
1.13 int colour_format;
1.14 + gboolean line_double;
1.15 char *data;
1.16 } *video_buffer_t;
1.17
2.1 --- a/src/drivers/video_gtk.c Sat Jan 27 12:02:54 2007 +0000
2.2 +++ b/src/drivers/video_gtk.c Sat Jan 27 12:03:53 2007 +0000
2.3 @@ -1,5 +1,5 @@
2.4 /**
2.5 - * $Id: video_gtk.c,v 1.8 2006-07-02 04:59:00 nkeynes Exp $
2.6 + * $Id: video_gtk.c,v 1.9 2007-01-27 12:03:53 nkeynes Exp $
2.7 *
2.8 * The PC side of the video support (responsible for actually displaying /
2.9 * rendering frames)
2.10 @@ -74,13 +74,11 @@
2.11 gboolean video_gtk_set_output_format( uint32_t width, uint32_t height,
2.12 int colour_format )
2.13 {
2.14 - video_width = width;
2.15 - video_height = height;
2.16 if( video_win == NULL ) {
2.17 video_win = GTK_WINDOW(gtk_window_new( GTK_WINDOW_TOPLEVEL ));
2.18 gtk_window_set_title( video_win, APP_NAME " - Emulation Window" );
2.19 gtk_window_set_policy( video_win, FALSE, FALSE, FALSE );
2.20 - gtk_window_set_default_size( video_win, width, height );
2.21 + gtk_window_set_default_size( video_win, video_width, video_height );
2.22
2.23 g_signal_connect( video_win, "key_press_event",
2.24 G_CALLBACK(video_gtk_keydown_callback), NULL );
2.25 @@ -98,9 +96,9 @@
2.26 GDK_WINDOW_XWINDOW( GTK_WIDGET(video_win)->window ) );
2.27
2.28 }
2.29 - gtk_window_set_default_size( video_win, width, height );
2.30 + gtk_window_set_default_size( video_win, video_width, video_height );
2.31 video_img = gdk_image_new( GDK_IMAGE_FASTEST, gdk_visual_get_system(),
2.32 - width, height );
2.33 + video_width, video_height );
2.34 gtk_image_set_from_image( GTK_IMAGE(video_area), video_img, NULL );
2.35 /* Note old image is auto de-refed */
2.36 return TRUE;
3.1 --- a/src/drivers/video_x11.c Sat Jan 27 12:02:54 2007 +0000
3.2 +++ b/src/drivers/video_x11.c Sat Jan 27 12:03:53 2007 +0000
3.3 @@ -1,5 +1,5 @@
3.4 /**
3.5 - * $Id: video_x11.c,v 1.10 2007-01-25 11:46:35 nkeynes Exp $
3.6 + * $Id: video_x11.c,v 1.11 2007-01-27 12:03:53 nkeynes Exp $
3.7 *
3.8 * Shared functions for all X11-based display drivers.
3.9 *
3.10 @@ -28,7 +28,7 @@
3.11 Display *video_x11_display = NULL;
3.12 Screen *video_x11_screen = NULL;
3.13 Window video_x11_window = 0;
3.14 -
3.15 +extern uint32_t video_width, video_height;
3.16 /**
3.17 * GLX parameters.
3.18 */
3.19 @@ -52,7 +52,7 @@
3.20 GLX_GREEN_SIZE, 4,
3.21 GLX_BLUE_SIZE, 4,
3.22 GLX_ALPHA_SIZE, 4,
3.23 - GLX_DEPTH_SIZE, 16,
3.24 + GLX_DEPTH_SIZE, 24,
3.25 GLX_DOUBLEBUFFER,
3.26 None };
3.27 int screen = XScreenNumberOfScreen(video_x11_screen);
3.28 @@ -154,18 +154,24 @@
3.29 {
3.30 GLenum type = colour_formats[frame->colour_format].type;
3.31 GLenum format = colour_formats[frame->colour_format].format;
3.32 -
3.33 + int bpp = colour_formats[frame->colour_format].bpp;
3.34 +
3.35 glDrawBuffer( GL_FRONT );
3.36 - glViewport( 0, 0, frame->hres, frame->vres );
3.37 + glViewport( 0, 0, video_width, video_height );
3.38 glMatrixMode(GL_PROJECTION);
3.39 glLoadIdentity();
3.40 glOrtho( 0, frame->hres, frame->vres, 0, 0, -65535 );
3.41 glMatrixMode(GL_MODELVIEW);
3.42 glLoadIdentity();
3.43 glRasterPos2i( 0, 0 );
3.44 - glPixelZoom( 1.0f, -1.0f );
3.45 + glPushClientAttrib( GL_CLIENT_PIXEL_STORE_BIT );
3.46 + float scale = 480.0 / frame->vres;
3.47 + glPixelZoom( 1.0f, -scale );
3.48 + int rowstride = (frame->rowstride / bpp) - frame->hres;
3.49 + glPixelStorei( GL_PACK_ROW_LENGTH, rowstride );
3.50 glDrawPixels( frame->hres, frame->vres, format, type,
3.51 frame->data );
3.52 + glPopClientAttrib();
3.53 glFlush();
3.54 return TRUE;
3.55 }
4.1 --- a/src/pvr2/pvr2.c Sat Jan 27 12:02:54 2007 +0000
4.2 +++ b/src/pvr2/pvr2.c Sat Jan 27 12:03:53 2007 +0000
4.3 @@ -1,5 +1,5 @@
4.4 /**
4.5 - * $Id: pvr2.c,v 1.41 2007-01-18 11:13:12 nkeynes Exp $
4.6 + * $Id: pvr2.c,v 1.42 2007-01-27 12:03:53 nkeynes Exp $
4.7 *
4.8 * PVR2 (Video) Core module implementation and MMIO registers.
4.9 *
4.10 @@ -238,24 +238,38 @@
4.11 */
4.12 void pvr2_display_frame( void )
4.13 {
4.14 - uint32_t display_addr = MMIO_READ( PVR2, DISP_ADDR1 );
4.15 -
4.16 + uint32_t display_addr;
4.17 int dispsize = MMIO_READ( PVR2, DISP_SIZE );
4.18 int dispmode = MMIO_READ( PVR2, DISP_MODE );
4.19 int vidcfg = MMIO_READ( PVR2, DISP_SYNCCFG );
4.20 - int vid_stride = ((dispsize & DISPSIZE_MODULO) >> 20) - 1;
4.21 + int vid_stride = (((dispsize & DISPSIZE_MODULO) >> 20) - 1);
4.22 int vid_lpf = ((dispsize & DISPSIZE_LPF) >> 10) + 1;
4.23 int vid_ppl = ((dispsize & DISPSIZE_PPL)) + 1;
4.24 - gboolean bEnabled = (dispmode & DISPMODE_DE) && (vidcfg & DISPCFG_VO ) ? TRUE : FALSE;
4.25 + gboolean bEnabled = (dispmode & DISPMODE_ENABLE) && (vidcfg & DISPCFG_VO ) ? TRUE : FALSE;
4.26 gboolean interlaced = (vidcfg & DISPCFG_I ? TRUE : FALSE);
4.27 video_buffer_t buffer = &video_buffer[video_buffer_idx];
4.28 video_buffer_idx = !video_buffer_idx;
4.29 video_buffer_t last = &video_buffer[video_buffer_idx];
4.30 buffer->rowstride = (vid_ppl + vid_stride) << 2;
4.31 buffer->data = video_base + MMIO_READ( PVR2, DISP_ADDR1 );
4.32 + buffer->line_double = (dispmode & DISPMODE_LINEDOUBLE) ? TRUE : FALSE;
4.33 buffer->vres = vid_lpf;
4.34 - if( interlaced ) buffer->vres <<= 1;
4.35 - switch( (dispmode & DISPMODE_COL) >> 2 ) {
4.36 + if( interlaced ) {
4.37 + if( vid_ppl == vid_stride ) { /* Magic deinterlace */
4.38 + buffer->vres <<= 1;
4.39 + buffer->rowstride = vid_ppl << 2;
4.40 + display_addr = MMIO_READ( PVR2, DISP_ADDR1 );
4.41 + } else { /* Just display the field as is, folks */
4.42 + if( pvr2_state.odd_even_field ) {
4.43 + display_addr = MMIO_READ( PVR2, DISP_ADDR1 );
4.44 + } else {
4.45 + display_addr = MMIO_READ( PVR2, DISP_ADDR2 );
4.46 + }
4.47 + }
4.48 + } else {
4.49 + display_addr = MMIO_READ( PVR2, DISP_ADDR1 );
4.50 + }
4.51 + switch( (dispmode & DISPMODE_COLFMT) >> 2 ) {
4.52 case 0:
4.53 buffer->colour_format = COLFMT_ARGB1555;
4.54 buffer->hres = vid_ppl << 1;
4.55 @@ -520,12 +534,7 @@
4.56 case TA_REINIT:
4.57 break;
4.58 /**************** Scaler registers? ****************/
4.59 - case SCALERCFG:
4.60 - /* KOS suggests bits as follows:
4.61 - * 0: enable vertical scaling
4.62 - * 10: ???
4.63 - * 16: enable FSAA
4.64 - */
4.65 + case RENDER_SCALER:
4.66 MMIO_WRITE( PVR2, reg, val&0x0007FFFF );
4.67 break;
4.68
5.1 --- a/src/pvr2/pvr2.h Sat Jan 27 12:02:54 2007 +0000
5.2 +++ b/src/pvr2/pvr2.h Sat Jan 27 12:03:53 2007 +0000
5.3 @@ -1,5 +1,5 @@
5.4 /**
5.5 - * $Id: pvr2.h,v 1.30 2007-01-27 06:21:35 nkeynes Exp $
5.6 + * $Id: pvr2.h,v 1.31 2007-01-27 12:03:53 nkeynes Exp $
5.7 *
5.8 * PVR2 (video chip) functions and macros.
5.9 *
5.10 @@ -25,10 +25,10 @@
5.11 typedef unsigned int pvraddr_t;
5.12 typedef unsigned int pvr64addr_t;
5.13
5.14 -#define DISPMODE_DE 0x00000001 /* Display enable */
5.15 -#define DISPMODE_SD 0x00000002 /* Scan double */
5.16 -#define DISPMODE_COL 0x0000000C /* Colour mode */
5.17 -#define DISPMODE_CD 0x08000000 /* Clock double */
5.18 +#define DISPMODE_ENABLE 0x00000001 /* Display enable */
5.19 +#define DISPMODE_LINEDOUBLE 0x00000002 /* scanline double */
5.20 +#define DISPMODE_COLFMT 0x0000000C /* Colour mode */
5.21 +#define DISPMODE_CLOCKDIV 0x08000000 /* Clock divide-by-2 */
5.22
5.23 #define DISPSIZE_MODULO 0x3FF00000 /* line skip +1 (32-bit words)*/
5.24 #define DISPSIZE_LPF 0x000FFC00 /* lines per field */
.