Search
lxdream.org :: lxdream/src/pvr2/pvr2.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/pvr2/pvr2.c
changeset 284:808617ee7135
prev282:01e53698ff38
next295:6637664291a8
author nkeynes
date Mon Jan 15 08:32:09 2007 +0000 (13 years ago)
permissions -rw-r--r--
last change Break vram routines out into pvr2mem.c
Initial (untested) implementation of stride textures
Hookup YUV converter code in pvr2.c
file annotate diff log raw
1.1 --- a/src/pvr2/pvr2.c Sun Jan 14 11:43:00 2007 +0000
1.2 +++ b/src/pvr2/pvr2.c Mon Jan 15 08:32:09 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: pvr2.c,v 1.38 2007-01-14 11:43:00 nkeynes Exp $
1.6 + * $Id: pvr2.c,v 1.39 2007-01-15 08:32:09 nkeynes Exp $
1.7 *
1.8 * PVR2 (Video) Core module implementation and MMIO registers.
1.9 *
1.10 @@ -137,6 +137,8 @@
1.11 pvr2_state.back_porch_ns = 4000;
1.12 mmio_region_PVR2_write( DISP_TOTAL, 0x0270035F );
1.13 mmio_region_PVR2_write( DISP_SYNCTIME, 0x07D6A53F );
1.14 + mmio_region_PVR2_write( YUV_ADDR, 0 );
1.15 + mmio_region_PVR2_write( YUV_CFG, 0 );
1.16 video_buffer_idx = 0;
1.17
1.18 pvr2_ta_init();
1.19 @@ -466,18 +468,19 @@
1.20 * 10: ???
1.21 * 16: enable FSAA
1.22 */
1.23 - DEBUG( "Scaler config set to %08X", val );
1.24 MMIO_WRITE( PVR2, reg, val&0x0007FFFF );
1.25 break;
1.26
1.27 case YUV_ADDR:
1.28 - MMIO_WRITE( PVR2, reg, val&0x00FFFFF8 );
1.29 + val = val & 0x00FFFFF8;
1.30 + MMIO_WRITE( PVR2, reg, val );
1.31 + pvr2_yuv_init( val );
1.32 break;
1.33 case YUV_CFG:
1.34 MMIO_WRITE( PVR2, reg, val&0x01013F3F );
1.35 + pvr2_yuv_set_config(val);
1.36 break;
1.37
1.38 -
1.39 /**************** Unknowns ***************/
1.40 case PVRUNK1:
1.41 MMIO_WRITE( PVR2, reg, val&0x000007FF );
1.42 @@ -634,155 +637,3 @@
1.43 pvr2_ta_write( (char *)&val, sizeof(uint32_t) );
1.44 }
1.45
1.46 -
1.47 -void pvr2_vram64_write( sh4addr_t destaddr, char *src, uint32_t length )
1.48 -{
1.49 - int bank_flag = (destaddr & 0x04) >> 2;
1.50 - uint32_t *banks[2];
1.51 - uint32_t *dwsrc;
1.52 - int i;
1.53 -
1.54 - destaddr = destaddr & 0x7FFFFF;
1.55 - if( destaddr + length > 0x800000 ) {
1.56 - length = 0x800000 - destaddr;
1.57 - }
1.58 -
1.59 - for( i=destaddr & 0xFFFFF000; i < destaddr + length; i+= PAGE_SIZE ) {
1.60 - texcache_invalidate_page( i );
1.61 - }
1.62 -
1.63 - banks[0] = ((uint32_t *)(video_base + ((destaddr & 0x007FFFF8) >>1)));
1.64 - banks[1] = banks[0] + 0x100000;
1.65 - if( bank_flag )
1.66 - banks[0]++;
1.67 -
1.68 - /* Handle non-aligned start of source */
1.69 - if( destaddr & 0x03 ) {
1.70 - char *dest = ((char *)banks[bank_flag]) + (destaddr & 0x03);
1.71 - for( i= destaddr & 0x03; i < 4 && length > 0; i++, length-- ) {
1.72 - *dest++ = *src++;
1.73 - }
1.74 - bank_flag = !bank_flag;
1.75 - }
1.76 -
1.77 - dwsrc = (uint32_t *)src;
1.78 - while( length >= 4 ) {
1.79 - *banks[bank_flag]++ = *dwsrc++;
1.80 - bank_flag = !bank_flag;
1.81 - length -= 4;
1.82 - }
1.83 -
1.84 - /* Handle non-aligned end of source */
1.85 - if( length ) {
1.86 - src = (char *)dwsrc;
1.87 - char *dest = (char *)banks[bank_flag];
1.88 - while( length-- > 0 ) {
1.89 - *dest++ = *src++;
1.90 - }
1.91 - }
1.92 -}
1.93 -
1.94 -/**
1.95 - * Write an image to 64-bit vram, with a line-stride different from the line-size.
1.96 - * The destaddr must be 32-bit aligned, and both line_bytes and line_stride_bytes
1.97 - * must be multiples of 4.
1.98 - */
1.99 -void pvr2_vram64_write_stride( sh4addr_t destaddr, char *src, uint32_t line_bytes,
1.100 - uint32_t line_stride_bytes, uint32_t line_count )
1.101 -{
1.102 - int bank_flag = (destaddr & 0x04) >> 2;
1.103 - uint32_t *banks[2];
1.104 - uint32_t *dwsrc;
1.105 - uint32_t line_gap;
1.106 - int line_gap_flag;
1.107 - int i,j;
1.108 -
1.109 - destaddr = destaddr & 0x7FFFF8;
1.110 - i = line_stride_bytes - line_bytes;
1.111 - line_gap_flag = i & 0x04;
1.112 - line_gap = i >> 3;
1.113 -
1.114 -
1.115 - for( i=destaddr & 0xFFFFF000; i < destaddr + line_stride_bytes*line_count; i+= PAGE_SIZE ) {
1.116 - texcache_invalidate_page( i );
1.117 - }
1.118 -
1.119 - banks[0] = (uint32_t *)(video_base + (destaddr >>1));
1.120 - banks[1] = banks[0] + 0x100000;
1.121 - if( bank_flag )
1.122 - banks[0]++;
1.123 -
1.124 - dwsrc = (uint32_t *)src;
1.125 - for( i=0; i<line_count; i++ ) {
1.126 - for( j=0; j<line_bytes; j++ ) {
1.127 - *banks[bank_flag]++ = *dwsrc++;
1.128 - bank_flag = !bank_flag;
1.129 - }
1.130 - *banks[0] += line_gap;
1.131 - *banks[1] += line_gap;
1.132 - if( line_gap_flag ) {
1.133 - *banks[bank_flag]++;
1.134 - bank_flag = !bank_flag;
1.135 - }
1.136 - }
1.137 -}
1.138 -
1.139 -void pvr2_vram_write_invert( sh4addr_t destaddr, char *src, uint32_t length, uint32_t line_length )
1.140 -{
1.141 - char *dest = video_base + (destaddr & 0x007FFFFF);
1.142 - char *p = src + length - line_length;
1.143 - while( p >= src ) {
1.144 - memcpy( dest, p, line_length );
1.145 - p -= line_length;
1.146 - dest += line_length;
1.147 - }
1.148 -}
1.149 -
1.150 -void pvr2_vram64_read( char *dest, sh4addr_t srcaddr, uint32_t length )
1.151 -{
1.152 - int bank_flag = (srcaddr & 0x04) >> 2;
1.153 - uint32_t *banks[2];
1.154 - uint32_t *dwdest;
1.155 - int i;
1.156 -
1.157 - srcaddr = srcaddr & 0x7FFFFF;
1.158 - if( srcaddr + length > 0x800000 )
1.159 - length = 0x800000 - srcaddr;
1.160 -
1.161 - banks[0] = ((uint32_t *)(video_base + ((srcaddr&0x007FFFF8)>>1)));
1.162 - banks[1] = banks[0] + 0x100000;
1.163 - if( bank_flag )
1.164 - banks[0]++;
1.165 -
1.166 - /* Handle non-aligned start of source */
1.167 - if( srcaddr & 0x03 ) {
1.168 - char *src = ((char *)banks[bank_flag]) + (srcaddr & 0x03);
1.169 - for( i= srcaddr & 0x03; i < 4 && length > 0; i++, length-- ) {
1.170 - *dest++ = *src++;
1.171 - }
1.172 - bank_flag = !bank_flag;
1.173 - }
1.174 -
1.175 - dwdest = (uint32_t *)dest;
1.176 - while( length >= 4 ) {
1.177 - *dwdest++ = *banks[bank_flag]++;
1.178 - bank_flag = !bank_flag;
1.179 - length -= 4;
1.180 - }
1.181 -
1.182 - /* Handle non-aligned end of source */
1.183 - if( length ) {
1.184 - dest = (char *)dwdest;
1.185 - char *src = (char *)banks[bank_flag];
1.186 - while( length-- > 0 ) {
1.187 - *dest++ = *src++;
1.188 - }
1.189 - }
1.190 -}
1.191 -
1.192 -void pvr2_vram64_dump( sh4addr_t addr, uint32_t length, FILE *f )
1.193 -{
1.194 - char tmp[length];
1.195 - pvr2_vram64_read( tmp, addr, length );
1.196 - fwrite_dump( tmp, length, f );
1.197 -}
.