Search
lxdream.org :: lxdream :: r282:01e53698ff38
lxdream 0.9.1
released Jun 29
Download Now
changeset282:01e53698ff38
parent281:2019e605cb27
child283:b1fbeaaff6bb
authornkeynes
dateSun Jan 14 11:43:00 2007 +0000 (13 years ago)
First cut of YUV converter
src/Makefile.am
src/Makefile.in
src/asic.h
src/pvr2/pvr2.c
src/pvr2/pvr2.h
src/pvr2/texcache.c
src/pvr2/yuv.c
src/sh4/sh4mem.c
1.1 --- a/src/Makefile.am Sun Jan 14 02:55:25 2007 +0000
1.2 +++ b/src/Makefile.am Sun Jan 14 11:43:00 2007 +0000
1.3 @@ -23,7 +23,7 @@
1.4 aica/aica.c aica/aica.h aica/audio.c aica/audio.h \
1.5 pvr2/pvr2.c pvr2/pvr2.h \
1.6 pvr2/tacore.c pvr2/render.c pvr2/rendcore.c pvr2/rendbkg.c pvr2/rendsort.c \
1.7 - pvr2/texcache.c \
1.8 + pvr2/texcache.c pvr2/yuv.c \
1.9 maple/maple.c maple/maple.h \
1.10 maple/controller.c maple/controller.h \
1.11 gui/support.c gui/support.h \
2.1 --- a/src/Makefile.in Sun Jan 14 02:55:25 2007 +0000
2.2 +++ b/src/Makefile.in Sun Jan 14 11:43:00 2007 +0000
2.3 @@ -157,7 +157,7 @@
2.4 aica/aica.c aica/aica.h aica/audio.c aica/audio.h \
2.5 pvr2/pvr2.c pvr2/pvr2.h \
2.6 pvr2/tacore.c pvr2/render.c pvr2/rendcore.c pvr2/rendbkg.c pvr2/rendsort.c \
2.7 - pvr2/texcache.c \
2.8 + pvr2/texcache.c pvr2/yuv.c \
2.9 maple/maple.c maple/maple.h \
2.10 maple/controller.c maple/controller.h \
2.11 gui/support.c gui/support.h \
2.12 @@ -169,7 +169,8 @@
2.13 display.c display.h \
2.14 drivers/audio_null.c drivers/audio_esd.c \
2.15 drivers/video_null.c drivers/video_gtk.c drivers/video_gtk.h \
2.16 - drivers/video_x11.c drivers/video_x11.h
2.17 + drivers/video_x11.c drivers/video_x11.h \
2.18 + drivers/video_gl.c drivers/video_gl.h
2.19
2.20
2.21 lxdream_LDADD = @PACKAGE_LIBS@ $(INTLLIBS) -lesd
2.22 @@ -193,13 +194,14 @@
2.23 armcore.$(OBJEXT) armdasm.$(OBJEXT) armmem.$(OBJEXT) \
2.24 aica.$(OBJEXT) audio.$(OBJEXT) pvr2.$(OBJEXT) tacore.$(OBJEXT) \
2.25 render.$(OBJEXT) rendcore.$(OBJEXT) rendbkg.$(OBJEXT) \
2.26 - rendsort.$(OBJEXT) texcache.$(OBJEXT) maple.$(OBJEXT) \
2.27 - controller.$(OBJEXT) support.$(OBJEXT) interface.$(OBJEXT) \
2.28 - callbacks.$(OBJEXT) gui.$(OBJEXT) mmr_win.$(OBJEXT) \
2.29 - debug_win.$(OBJEXT) dump_win.$(OBJEXT) loader.$(OBJEXT) \
2.30 - bootstrap.$(OBJEXT) util.$(OBJEXT) display.$(OBJEXT) \
2.31 - audio_null.$(OBJEXT) audio_esd.$(OBJEXT) video_null.$(OBJEXT) \
2.32 - video_gtk.$(OBJEXT) video_x11.$(OBJEXT)
2.33 + rendsort.$(OBJEXT) texcache.$(OBJEXT) yuv.$(OBJEXT) \
2.34 + maple.$(OBJEXT) controller.$(OBJEXT) support.$(OBJEXT) \
2.35 + interface.$(OBJEXT) callbacks.$(OBJEXT) gui.$(OBJEXT) \
2.36 + mmr_win.$(OBJEXT) debug_win.$(OBJEXT) dump_win.$(OBJEXT) \
2.37 + loader.$(OBJEXT) bootstrap.$(OBJEXT) util.$(OBJEXT) \
2.38 + display.$(OBJEXT) audio_null.$(OBJEXT) audio_esd.$(OBJEXT) \
2.39 + video_null.$(OBJEXT) video_gtk.$(OBJEXT) video_x11.$(OBJEXT) \
2.40 + video_gl.$(OBJEXT)
2.41 lxdream_OBJECTS = $(am_lxdream_OBJECTS)
2.42 lxdream_DEPENDENCIES =
2.43 lxdream_LDFLAGS =
2.44 @@ -231,8 +233,9 @@
2.45 @AMDEP_TRUE@ ./$(DEPDIR)/support.Po ./$(DEPDIR)/syscall.Po \
2.46 @AMDEP_TRUE@ ./$(DEPDIR)/tacore.Po ./$(DEPDIR)/texcache.Po \
2.47 @AMDEP_TRUE@ ./$(DEPDIR)/timer.Po ./$(DEPDIR)/util.Po \
2.48 -@AMDEP_TRUE@ ./$(DEPDIR)/video_gtk.Po ./$(DEPDIR)/video_null.Po \
2.49 -@AMDEP_TRUE@ ./$(DEPDIR)/video_x11.Po ./$(DEPDIR)/watch.Po
2.50 +@AMDEP_TRUE@ ./$(DEPDIR)/video_gl.Po ./$(DEPDIR)/video_gtk.Po \
2.51 +@AMDEP_TRUE@ ./$(DEPDIR)/video_null.Po ./$(DEPDIR)/video_x11.Po \
2.52 +@AMDEP_TRUE@ ./$(DEPDIR)/watch.Po ./$(DEPDIR)/yuv.Po
2.53 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
2.54 $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
2.55 CCLD = $(CC)
2.56 @@ -332,10 +335,12 @@
2.57 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/texcache.Po@am__quote@
2.58 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timer.Po@am__quote@
2.59 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/util.Po@am__quote@
2.60 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/video_gl.Po@am__quote@
2.61 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/video_gtk.Po@am__quote@
2.62 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/video_null.Po@am__quote@
2.63 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/video_x11.Po@am__quote@
2.64 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/watch.Po@am__quote@
2.65 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/yuv.Po@am__quote@
2.66
2.67 .c.o:
2.68 @am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
2.69 @@ -909,6 +914,28 @@
2.70 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
2.71 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o texcache.obj `if test -f 'pvr2/texcache.c'; then $(CYGPATH_W) 'pvr2/texcache.c'; else $(CYGPATH_W) '$(srcdir)/pvr2/texcache.c'; fi`
2.72
2.73 +yuv.o: pvr2/yuv.c
2.74 +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT yuv.o -MD -MP -MF "$(DEPDIR)/yuv.Tpo" \
2.75 +@am__fastdepCC_TRUE@ -c -o yuv.o `test -f 'pvr2/yuv.c' || echo '$(srcdir)/'`pvr2/yuv.c; \
2.76 +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/yuv.Tpo" "$(DEPDIR)/yuv.Po"; \
2.77 +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/yuv.Tpo"; exit 1; \
2.78 +@am__fastdepCC_TRUE@ fi
2.79 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pvr2/yuv.c' object='yuv.o' libtool=no @AMDEPBACKSLASH@
2.80 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/yuv.Po' tmpdepfile='$(DEPDIR)/yuv.TPo' @AMDEPBACKSLASH@
2.81 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
2.82 +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o yuv.o `test -f 'pvr2/yuv.c' || echo '$(srcdir)/'`pvr2/yuv.c
2.83 +
2.84 +yuv.obj: pvr2/yuv.c
2.85 +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT yuv.obj -MD -MP -MF "$(DEPDIR)/yuv.Tpo" \
2.86 +@am__fastdepCC_TRUE@ -c -o yuv.obj `if test -f 'pvr2/yuv.c'; then $(CYGPATH_W) 'pvr2/yuv.c'; else $(CYGPATH_W) '$(srcdir)/pvr2/yuv.c'; fi`; \
2.87 +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/yuv.Tpo" "$(DEPDIR)/yuv.Po"; \
2.88 +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/yuv.Tpo"; exit 1; \
2.89 +@am__fastdepCC_TRUE@ fi
2.90 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pvr2/yuv.c' object='yuv.obj' libtool=no @AMDEPBACKSLASH@
2.91 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/yuv.Po' tmpdepfile='$(DEPDIR)/yuv.TPo' @AMDEPBACKSLASH@
2.92 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
2.93 +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o yuv.obj `if test -f 'pvr2/yuv.c'; then $(CYGPATH_W) 'pvr2/yuv.c'; else $(CYGPATH_W) '$(srcdir)/pvr2/yuv.c'; fi`
2.94 +
2.95 maple.o: maple/maple.c
2.96 @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT maple.o -MD -MP -MF "$(DEPDIR)/maple.Tpo" \
2.97 @am__fastdepCC_TRUE@ -c -o maple.o `test -f 'maple/maple.c' || echo '$(srcdir)/'`maple/maple.c; \
2.98 @@ -1216,6 +1243,28 @@
2.99 @AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/video_x11.Po' tmpdepfile='$(DEPDIR)/video_x11.TPo' @AMDEPBACKSLASH@
2.100 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
2.101 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o video_x11.obj `if test -f 'drivers/video_x11.c'; then $(CYGPATH_W) 'drivers/video_x11.c'; else $(CYGPATH_W) '$(srcdir)/drivers/video_x11.c'; fi`
2.102 +
2.103 +video_gl.o: drivers/video_gl.c
2.104 +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT video_gl.o -MD -MP -MF "$(DEPDIR)/video_gl.Tpo" \
2.105 +@am__fastdepCC_TRUE@ -c -o video_gl.o `test -f 'drivers/video_gl.c' || echo '$(srcdir)/'`drivers/video_gl.c; \
2.106 +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/video_gl.Tpo" "$(DEPDIR)/video_gl.Po"; \
2.107 +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/video_gl.Tpo"; exit 1; \
2.108 +@am__fastdepCC_TRUE@ fi
2.109 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='drivers/video_gl.c' object='video_gl.o' libtool=no @AMDEPBACKSLASH@
2.110 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/video_gl.Po' tmpdepfile='$(DEPDIR)/video_gl.TPo' @AMDEPBACKSLASH@
2.111 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
2.112 +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o video_gl.o `test -f 'drivers/video_gl.c' || echo '$(srcdir)/'`drivers/video_gl.c
2.113 +
2.114 +video_gl.obj: drivers/video_gl.c
2.115 +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT video_gl.obj -MD -MP -MF "$(DEPDIR)/video_gl.Tpo" \
2.116 +@am__fastdepCC_TRUE@ -c -o video_gl.obj `if test -f 'drivers/video_gl.c'; then $(CYGPATH_W) 'drivers/video_gl.c'; else $(CYGPATH_W) '$(srcdir)/drivers/video_gl.c'; fi`; \
2.117 +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/video_gl.Tpo" "$(DEPDIR)/video_gl.Po"; \
2.118 +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/video_gl.Tpo"; exit 1; \
2.119 +@am__fastdepCC_TRUE@ fi
2.120 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='drivers/video_gl.c' object='video_gl.obj' libtool=no @AMDEPBACKSLASH@
2.121 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/video_gl.Po' tmpdepfile='$(DEPDIR)/video_gl.TPo' @AMDEPBACKSLASH@
2.122 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
2.123 +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o video_gl.obj `if test -f 'drivers/video_gl.c'; then $(CYGPATH_W) 'drivers/video_gl.c'; else $(CYGPATH_W) '$(srcdir)/drivers/video_gl.c'; fi`
2.124 uninstall-info-am:
2.125
2.126 ETAGS = etags
3.1 --- a/src/asic.h Sun Jan 14 02:55:25 2007 +0000
3.2 +++ b/src/asic.h Sun Jan 14 11:43:00 2007 +0000
3.3 @@ -1,5 +1,5 @@
3.4 /**
3.5 - * $Id: asic.h,v 1.15 2007-01-06 04:06:36 nkeynes Exp $
3.6 + * $Id: asic.h,v 1.16 2007-01-14 11:43:00 nkeynes Exp $
3.7 *
3.8 * Support for the miscellaneous ASIC functions (Primarily event multiplexing,
3.9 * and DMA). Includes MMIO definitions for the 5f6000 and 5f7000 regions,
3.10 @@ -176,7 +176,7 @@
3.11 #define EVENT_SCANLINE2 3
3.12 #define EVENT_SCANLINE1 4
3.13 #define EVENT_RETRACE 5
3.14 -#define EVENT_PVR_UNK 6
3.15 +#define EVENT_PVR_YUV_DONE 6
3.16 #define EVENT_PVR_OPAQUE_DONE 7
3.17 #define EVENT_PVR_OPAQUEMOD_DONE 8
3.18 #define EVENT_PVR_TRANS_DONE 9
4.1 --- a/src/pvr2/pvr2.c Sun Jan 14 02:55:25 2007 +0000
4.2 +++ b/src/pvr2/pvr2.c Sun Jan 14 11:43:00 2007 +0000
4.3 @@ -1,5 +1,5 @@
4.4 /**
4.5 - * $Id: pvr2.c,v 1.37 2007-01-11 12:14:57 nkeynes Exp $
4.6 + * $Id: pvr2.c,v 1.38 2007-01-14 11:43:00 nkeynes Exp $
4.7 *
4.8 * PVR2 (Video) Core module implementation and MMIO registers.
4.9 *
4.10 @@ -474,7 +474,6 @@
4.11 MMIO_WRITE( PVR2, reg, val&0x00FFFFF8 );
4.12 break;
4.13 case YUV_CFG:
4.14 - DEBUG( "YUV config set to %08X", val );
4.15 MMIO_WRITE( PVR2, reg, val&0x01013F3F );
4.16 break;
4.17
4.18 @@ -683,6 +682,51 @@
4.19 }
4.20 }
4.21
4.22 +/**
4.23 + * Write an image to 64-bit vram, with a line-stride different from the line-size.
4.24 + * The destaddr must be 32-bit aligned, and both line_bytes and line_stride_bytes
4.25 + * must be multiples of 4.
4.26 + */
4.27 +void pvr2_vram64_write_stride( sh4addr_t destaddr, char *src, uint32_t line_bytes,
4.28 + uint32_t line_stride_bytes, uint32_t line_count )
4.29 +{
4.30 + int bank_flag = (destaddr & 0x04) >> 2;
4.31 + uint32_t *banks[2];
4.32 + uint32_t *dwsrc;
4.33 + uint32_t line_gap;
4.34 + int line_gap_flag;
4.35 + int i,j;
4.36 +
4.37 + destaddr = destaddr & 0x7FFFF8;
4.38 + i = line_stride_bytes - line_bytes;
4.39 + line_gap_flag = i & 0x04;
4.40 + line_gap = i >> 3;
4.41 +
4.42 +
4.43 + for( i=destaddr & 0xFFFFF000; i < destaddr + line_stride_bytes*line_count; i+= PAGE_SIZE ) {
4.44 + texcache_invalidate_page( i );
4.45 + }
4.46 +
4.47 + banks[0] = (uint32_t *)(video_base + (destaddr >>1));
4.48 + banks[1] = banks[0] + 0x100000;
4.49 + if( bank_flag )
4.50 + banks[0]++;
4.51 +
4.52 + dwsrc = (uint32_t *)src;
4.53 + for( i=0; i<line_count; i++ ) {
4.54 + for( j=0; j<line_bytes; j++ ) {
4.55 + *banks[bank_flag]++ = *dwsrc++;
4.56 + bank_flag = !bank_flag;
4.57 + }
4.58 + *banks[0] += line_gap;
4.59 + *banks[1] += line_gap;
4.60 + if( line_gap_flag ) {
4.61 + *banks[bank_flag]++;
4.62 + bank_flag = !bank_flag;
4.63 + }
4.64 + }
4.65 +}
4.66 +
4.67 void pvr2_vram_write_invert( sh4addr_t destaddr, char *src, uint32_t length, uint32_t line_length )
4.68 {
4.69 char *dest = video_base + (destaddr & 0x007FFFFF);
5.1 --- a/src/pvr2/pvr2.h Sun Jan 14 02:55:25 2007 +0000
5.2 +++ b/src/pvr2/pvr2.h Sun Jan 14 11:43:00 2007 +0000
5.3 @@ -1,5 +1,5 @@
5.4 /**
5.5 - * $Id: pvr2.h,v 1.18 2006-09-12 11:54:19 nkeynes Exp $
5.6 + * $Id: pvr2.h,v 1.19 2007-01-14 11:43:00 nkeynes Exp $
5.7 *
5.8 * PVR2 (video chip) functions and macros.
5.9 *
5.10 @@ -114,6 +114,13 @@
5.11 void pvr2_vram64_write( sh4addr_t dest, char *src, uint32_t length );
5.12
5.13 /**
5.14 + * Write to the interleaved memory address space (aka 64-bit address space),
5.15 + * using a line length and stride.
5.16 + */
5.17 +void pvr2_vram64_write_stride( sh4addr_t dest, char *src, uint32_t line_bytes,
5.18 + uint32_t line_stride_bytes, uint32_t line_count );
5.19 +
5.20 +/**
5.21 * Read from the interleaved memory address space (aka 64-bit address space)
5.22 */
5.23 void pvr2_vram64_read( char *dest, sh4addr_t src, uint32_t length );
5.24 @@ -138,6 +145,19 @@
5.25 */
5.26 void pvr2_ta_init( void );
5.27
5.28 +
5.29 +/****************************** YUV Converter ****************************/
5.30 +
5.31 +/**
5.32 + * Process a block of YUV data.
5.33 + */
5.34 +void pvr2_yuv_write( char *buf, uint32_t length );
5.35 +
5.36 +/**
5.37 + * Initialize the YUV converter.
5.38 + */
5.39 +void pvr2_yuv_init( uint32_t target_addr, uint32_t config );
5.40 +
5.41 /********************************* Renderer ******************************/
5.42
5.43 /**
5.44 @@ -220,8 +240,8 @@
5.45
5.46 #define POLY2_SRC_BLEND(poly2) ( pvr2_poly_srcblend[(poly2) >> 29] )
5.47 #define POLY2_DEST_BLEND(poly2) ( pvr2_poly_dstblend[((poly2)>>26)&0x07] )
5.48 -#define POLY2_SRC_BLEND_ENABLE(poly2) ((poly2)&0x02000000)
5.49 -#define POLY2_DEST_BLEND_ENABLE(poly2) ((poly2)&0x01000000)
5.50 +#define POLY2_SRC_BLEND_TARGET(poly2) ((poly2)&0x02000000)
5.51 +#define POLY2_DEST_BLEND_TARGET(poly2) ((poly2)&0x01000000)
5.52 #define POLY2_COLOUR_CLAMP_ENABLE(poly2) ((poly2)&0x00200000)
5.53 #define POLY2_ALPHA_ENABLE(poly2) ((poly2)&0x001000000)
5.54 #define POLY2_TEX_ALPHA_ENABLE(poly2) (((poly2)&0x00080000) == 0 )
6.1 --- a/src/pvr2/texcache.c Sun Jan 14 02:55:25 2007 +0000
6.2 +++ b/src/pvr2/texcache.c Sun Jan 14 11:43:00 2007 +0000
6.3 @@ -1,5 +1,5 @@
6.4 /**
6.5 - * $Id: texcache.c,v 1.9 2007-01-11 06:51:11 nkeynes Exp $
6.6 + * $Id: texcache.c,v 1.10 2007-01-14 11:43:00 nkeynes Exp $
6.7 *
6.8 * Texture cache. Responsible for maintaining a working set of OpenGL
6.9 * textures.
6.10 @@ -280,6 +280,42 @@
6.11 }
6.12 }
6.13
6.14 +static inline uint32_t yuv_to_rgb32( float y, float u, float v )
6.15 +{
6.16 + u -= 128;
6.17 + v -= 128;
6.18 + int r = (int)(y + v*1.375);
6.19 + int g = (int)(y - u*0.34375 - v*0.6875);
6.20 + int b = (int)(y + u*1.71875);
6.21 + if( r > 255 ) { r = 255; } else if( r < 0 ) { r = 0; }
6.22 + if( g > 255 ) { g = 255; } else if( g < 0 ) { g = 0; }
6.23 + if( b > 255 ) { b = 255; } else if( b < 0 ) { b = 0; }
6.24 + return 0xFF000000 | (r<<24) | (g<<16) | (b<<16);
6.25 +}
6.26 +
6.27 +
6.28 +/**
6.29 + * Convert non-twiddled YUV texture data into RGB32 data - most GL implementations don't
6.30 + * directly support this format unfortunately. The input data is formatted as
6.31 + * 32 bits = 2 horizontal pixels, UYVY. This is currently done rather inefficiently
6.32 + * in floating point.
6.33 + */
6.34 +static void yuv_decode( int width, int height, uint32_t *input, uint32_t *output )
6.35 +{
6.36 + int x, y;
6.37 + uint32_t *p = input;
6.38 + for( y=0; y<height; y++ ) {
6.39 + for( x=0; x<width; x+=2 ) {
6.40 + float u = (float)(*p & 0xFF);
6.41 + float y0 = (float)( (*p>>8)&0xFF );
6.42 + float v = (float)( (*p>>16)&0xFF );
6.43 + float y1 = (float)( (*p>>24)&0xFF );
6.44 + *output++ = yuv_to_rgb32( y0, u, v );
6.45 + *output++ = yuv_to_rgb32( y1, u, v );
6.46 + }
6.47 + }
6.48 +}
6.49 +
6.50 /**
6.51 * Load texture data from the given address and parameters into the currently
6.52 * bound OpenGL texture.
6.53 @@ -343,7 +379,10 @@
6.54 type = GL_UNSIGNED_SHORT_4_4_4_4_REV;
6.55 break;
6.56 case PVR2_TEX_FORMAT_YUV422:
6.57 - ERROR( "YUV textures not supported" );
6.58 + bytes <<= 2;
6.59 + intFormat = GL_RGBA8;
6.60 + format = GL_BGRA;
6.61 + type = GL_UNSIGNED_INT_8_8_8_8_REV;
6.62 break;
6.63 case PVR2_TEX_FORMAT_BUMPMAP:
6.64 ERROR( "Bumpmap not supported" );
6.65 @@ -385,6 +424,11 @@
6.66 detwiddle_pal8_to_16( 0, 0, mip_width, mip_width, &p,
6.67 (uint16_t *)data, (uint16_t *)palette );
6.68 }
6.69 + } else if( tex_format == PVR2_TEX_FORMAT_YUV422 ) {
6.70 + int inputlength = ((mip_width*mip_height)<<1);
6.71 + char tmp[inputlength];
6.72 + pvr2_vram64_read( tmp, texture_addr, inputlength );
6.73 + yuv_decode( mip_width, mip_height, tmp, (uint32_t *)&data );
6.74 } else if( PVR2_TEX_IS_COMPRESSED(mode) ) {
6.75 int inputlength = ((mip_width*mip_height) >> 2);
6.76 char tmp[inputlength];
7.1 --- a/src/pvr2/yuv.c Sun Jan 14 02:55:25 2007 +0000
7.2 +++ b/src/pvr2/yuv.c Sun Jan 14 11:43:00 2007 +0000
7.3 @@ -1,5 +1,5 @@
7.4 /**
7.5 - * $Id: yuv.c,v 1.1 2007-01-14 02:55:25 nkeynes Exp $
7.6 + * $Id: yuv.c,v 1.2 2007-01-14 11:43:00 nkeynes Exp $
7.7 *
7.8 * YUV420 and YUV422 decoding
7.9 *
7.10 @@ -16,46 +16,142 @@
7.11 * GNU General Public License for more details.
7.12 */
7.13 #include "dream.h"
7.14 +#include "asic.h"
7.15 +#include "pvr2/pvr2.h"
7.16
7.17 #define YUV420_BLOCK_SIZE 384
7.18 +#define YUV422_BLOCK_SIZE 512
7.19
7.20 -static inline uint16_t decode_yuv420_to_rgb565_pixel( uint8_t y, uint8_t u, uint8_t v )
7.21 +#define FORMAT_YUV420 0
7.22 +#define FORMAT_YUV422 1
7.23 +
7.24 +
7.25 +static int yuv_block_size[2] = { YUV420_BLOCK_SIZE, YUV422_BLOCK_SIZE };
7.26 +
7.27 +struct yuv_state {
7.28 + uint32_t target;
7.29 + int width;
7.30 + int height;
7.31 + int input_format;
7.32 + char data[512];
7.33 + int data_length;
7.34 + int x, y;
7.35 +} pvr2_yuv_state;
7.36 +
7.37 +/**
7.38 + * Transformation table for yuv420.
7.39 + */
7.40 +uint16_t yuv420_lut[512] = { 0, 128, 64, 129, 1, 130, 65, 131, 2, 132, 66, 133, 3, 134, 67, 135, 4, 192, 68, 193, 5, 194, 69, 195, 6, 196, 70, 197, 7, 198, 71, 199,
7.41 + 0, 136, 64, 137, 1, 138, 65, 139, 2, 140, 66, 141, 3, 142, 67, 143, 4, 200, 68, 201, 5, 202, 69, 203, 6, 204, 70, 205, 7, 206, 71, 207,
7.42 + 8, 144, 72, 145, 9, 146, 73, 147, 10, 148, 74, 149, 11, 150, 75, 151, 12, 208, 76, 209, 13, 210, 77, 211, 14, 212, 78, 213, 15, 214, 79, 215,
7.43 + 8, 152, 72, 153, 9, 154, 73, 155, 10, 156, 74, 157, 11, 158, 75, 159, 12, 216, 76, 217, 13, 218, 77, 219, 14, 220, 78, 221, 15, 222, 79, 223,
7.44 + 16, 160, 80, 161, 17, 162, 81, 163, 18, 164, 82, 165, 19, 166, 83, 167, 20, 224, 84, 225, 21, 226, 85, 227, 22, 228, 86, 229, 23, 230, 87, 231,
7.45 + 16, 168, 80, 169, 17, 170, 81, 171, 18, 172, 82, 173, 19, 174, 83, 175, 20, 232, 84, 233, 21, 234, 85, 235, 22, 236, 86, 237, 23, 238, 87, 239,
7.46 + 24, 176, 88, 177, 25, 178, 89, 179, 26, 180, 90, 181, 27, 182, 91, 183, 28, 240, 92, 241, 29, 242, 93, 243, 30, 244, 94, 245, 31, 246, 95, 247,
7.47 + 24, 184, 88, 185, 25, 186, 89, 187, 26, 188, 90, 189, 27, 190, 91, 191, 28, 248, 92, 249, 29, 250, 93, 251, 30, 252, 94, 253, 31, 254, 95, 255,
7.48 + 32, 256, 96, 257, 33, 258, 97, 259, 34, 260, 98, 261, 35, 262, 99, 263, 36, 320, 100, 321, 37, 322, 101, 323, 38, 324, 102, 325, 39, 326, 103, 327,
7.49 + 32, 264, 96, 265, 33, 266, 97, 267, 34, 268, 98, 269, 35, 270, 99, 271, 36, 328, 100, 329, 37, 330, 101, 331, 38, 332, 102, 333, 39, 334, 103, 335,
7.50 + 40, 272, 104, 273, 41, 274, 105, 275, 42, 276, 106, 277, 43, 278, 107, 279, 44, 336, 108, 337, 45, 338, 109, 339, 46, 340, 110, 341, 47, 342, 111, 343,
7.51 + 40, 280, 104, 281, 41, 282, 105, 283, 42, 284, 106, 285, 43, 286, 107, 287, 44, 344, 108, 345, 45, 346, 109, 347, 46, 348, 110, 349, 47, 350, 111, 351,
7.52 + 48, 288, 112, 289, 49, 290, 113, 291, 50, 292, 114, 293, 51, 294, 115, 295, 52, 352, 116, 353, 53, 354, 117, 355, 54, 356, 118, 357, 55, 358, 119, 359,
7.53 + 48, 296, 112, 297, 49, 298, 113, 299, 50, 300, 114, 301, 51, 302, 115, 303, 52, 360, 116, 361, 53, 362, 117, 363, 54, 364, 118, 365, 55, 366, 119, 367,
7.54 + 56, 304, 120, 305, 57, 306, 121, 307, 58, 308, 122, 309, 59, 310, 123, 311, 60, 368, 124, 369, 61, 370, 125, 371, 62, 372, 126, 373, 63, 374, 127, 375,
7.55 + 56, 312, 120, 313, 57, 314, 121, 315, 58, 316, 122, 317, 59, 318, 123, 319, 60, 376, 124, 377, 61, 378, 125, 379, 62, 380, 126, 381, 63, 382, 127, 383 };
7.56 +
7.57 +
7.58 +/**
7.59 + * Input is 8x8 U, 8x8 V, 8x8 Y00, 8x8 Y01, 8x8 Y10, 8x8 Y11, 8 bits each,
7.60 + * for a total of 384 bytes.
7.61 + * Output is UVYV = 32 bits = 2 horizontal pixels, 8x16 = 512 bytes
7.62 + */
7.63 +void pvr2_decode_yuv420( char *dest, char *src )
7.64 {
7.65 -
7.66 + int i;
7.67 + for( i=0; i<512; i++ ) {
7.68 + dest[i] = src[yuv420_lut[i]];
7.69 + }
7.70 +}
7.71 +
7.72 +void pvr2_decode_yuv422( char *dest, char *src )
7.73 +{
7.74
7.75 }
7.76
7.77 /**
7.78 - * Convert a single 16x16 yuv420 block to rgb565.
7.79 - * @param dest output memory location for this block
7.80 - * @param src start of source block
7.81 - * @param stride length of overall line in pixels (ie 16-bit words)
7.82 + * Process a single macroblock of YUV data and write it out to
7.83 + * texture vram.
7.84 */
7.85 -static void decode_yuv420_to_rgb565_block( uint16_t *dest, uint8_t *src, uint32_t stride )
7.86 +void pvr2_yuv_process_block( char *data )
7.87 {
7.88 - uint8_t *up = *src;
7.89 - uint8_t *vp = u + 64;
7.90 - uint8_t *yp = v + 64;
7.91 + char output[512];
7.92 +
7.93 + if( pvr2_yuv_state.input_format == FORMAT_YUV420 ) {
7.94 + pvr2_decode_yuv420( output, data );
7.95 + } else {
7.96 + pvr2_decode_yuv422( output, data );
7.97 + }
7.98
7.99 - for( int yb=0; yb<16; yb++ ) {
7.100 - for( int xb=0; xb<16; xb++ ) {
7.101 - uint8_t y = *yp++;
7.102 - uint8_t u = up[xb>>1 + (yb>>1)<<3];
7.103 - uint8_t v = vp[xb>>1 + (yb>>1)<<3];
7.104 - *dest++ = decode_yuv420_to_rgb565_block(y,u,v);
7.105 + uint32_t target = pvr2_yuv_state.target +
7.106 + (pvr2_yuv_state.y * pvr2_yuv_state.width * 512) +
7.107 + (pvr2_yuv_state.x * 32);
7.108 +
7.109 + pvr2_vram64_write_stride( target, output, 32, pvr2_yuv_state.width*32, 16 );
7.110 + if( ++pvr2_yuv_state.x >= pvr2_yuv_state.width ) {
7.111 + pvr2_yuv_state.x = 0;
7.112 + pvr2_yuv_state.y++;
7.113 + if( pvr2_yuv_state.y >= pvr2_yuv_state.height ) {
7.114 + asic_event( EVENT_PVR_YUV_DONE );
7.115 }
7.116 - dest = dest + stride - 16;
7.117 + }
7.118 +
7.119 + MMIO_WRITE( PVR2, YUV_COUNT, MMIO_READ( PVR2, YUV_COUNT ) + 1 );
7.120 +}
7.121 +
7.122 +/**
7.123 + * Receive data from the SH4, usually via DMA. This method is mainly responsible
7.124 + * for buffering the data into macroblock chunks and then passing it on to the
7.125 + * real processing
7.126 + */
7.127 +void pvr2_yuv_write( char *data, uint32_t length )
7.128 +{
7.129 + int block_size = yuv_block_size[pvr2_yuv_state.input_format];
7.130 +
7.131 + if( pvr2_yuv_state.data_length != 0 ) { /* Append to existing data */
7.132 + int tmp = MIN( length, block_size - pvr2_yuv_state.data_length );
7.133 + memcpy( pvr2_yuv_state.data + pvr2_yuv_state.data_length,
7.134 + data, tmp );
7.135 + pvr2_yuv_state.data_length += tmp;
7.136 + data += tmp;
7.137 + length -= tmp;
7.138 + if( pvr2_yuv_state.data_length == block_size ) {
7.139 + pvr2_yuv_process_block( pvr2_yuv_state.data );
7.140 + }
7.141 + }
7.142 +
7.143 + while( length >= block_size ) {
7.144 + pvr2_yuv_process_block( data );
7.145 + data += block_size;
7.146 + length -= block_size;
7.147 + }
7.148 +
7.149 + if( length != 0 ) { /* Save the left over data */
7.150 + memcpy( pvr2_yuv_state.data, data, length );
7.151 + pvr2_yuv_state.data_length = length;
7.152 }
7.153 }
7.154
7.155 -void decode_yuv420_to_rgb565( uint16_t *dest, uint8_t *src, int width, int height )
7.156 +void pvr2_yuv_init( uint32_t target, uint32_t config )
7.157 {
7.158 - uint16_t *p;
7.159 - for( int j=0; j<height; j++ ) {
7.160 - for( int i=0; i<width; i++ ) {
7.161 - p = dest + (j<<5)*width + i<<5;
7.162 - decode_yuv420_to_rgb565_block( p, src, width );
7.163 - src += YUV420_BLOCK_SIZE;
7.164 - }
7.165 + pvr2_yuv_state.target = target;
7.166 + pvr2_yuv_state.width = (config & 0x3f) + 1;
7.167 + pvr2_yuv_state.height = ((config>>8) & 0x3f) +1;
7.168 + pvr2_yuv_state.x = 0;
7.169 + pvr2_yuv_state.y = 0;
7.170 + pvr2_yuv_state.data_length = 0;
7.171 + pvr2_yuv_state.input_format = (config & 0x01000000) ? FORMAT_YUV420 : FORMAT_YUV422;
7.172 + if( config & 0x00010000 ) {
7.173 + pvr2_yuv_state.height *= pvr2_yuv_state.width;
7.174 + pvr2_yuv_state.width = 1;
7.175 }
7.176 + MMIO_WRITE( PVR2, YUV_COUNT, 0 );
7.177 }
8.1 --- a/src/sh4/sh4mem.c Sun Jan 14 02:55:25 2007 +0000
8.2 +++ b/src/sh4/sh4mem.c Sun Jan 14 11:43:00 2007 +0000
8.3 @@ -1,5 +1,5 @@
8.4 /**
8.5 - * $Id: sh4mem.c,v 1.16 2006-12-12 09:18:47 nkeynes Exp $
8.6 + * $Id: sh4mem.c,v 1.17 2007-01-14 11:43:00 nkeynes Exp $
8.7 * sh4mem.c is responsible for the SH4's access to memory (including memory
8.8 * mapped I/O), using the page maps created in mem.c
8.9 *
8.10 @@ -65,7 +65,11 @@
8.11 {
8.12 struct mmio_region *io = P4_io[(addr&0x1FFFFFFF)>>19];
8.13 if( !io ) {
8.14 - ERROR( "Attempted read from unknown P4 region: %08X", addr );
8.15 + if( (addr & 0xFF000000) != 0xF4000000 ) {
8.16 + /* OC address cache isn't implemented, but don't complain about it.
8.17 + * Complain about anything else though */
8.18 + ERROR( "Attempted read from unknown P4 region: %08X", addr );
8.19 + }
8.20 return 0;
8.21 } else {
8.22 int32_t val = io->io_read( addr&0xFFF );
8.23 @@ -367,8 +371,11 @@
8.24 }
8.25
8.26 void mem_copy_to_sh4( uint32_t destaddr, char *src, size_t count ) {
8.27 - if( destaddr >= 0x10000000 && destaddr < 0x11000000 ) {
8.28 + if( destaddr >= 0x10000000 && destaddr < 0x10800000 ) {
8.29 pvr2_ta_write( src, count );
8.30 + } else if( destaddr >= 0x10800000 && destaddr < 0x11000000 ) {
8.31 + /* YUV data */
8.32 + pvr2_yuv_write( src, count );
8.33 } else if( destaddr >= 0x04000000 && destaddr < 0x05000000 ||
8.34 destaddr >= 0x11000000 && destaddr < 0x12000000 ) {
8.35 pvr2_vram64_write( destaddr, src, count );
.