Author: lwalter
Date: Tue Aug 9 20:24:33 2011
New Revision: 2444
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2444
Log:
Add mfgtest support
Added:
cpu/x86/pc/alex/vstest.fth
Added: cpu/x86/pc/alex/vstest.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/x86/pc/alex/vstest.fth Tue Aug 9 20:24:33 2011 (r2444)
@@ -0,0 +1,57 @@
+purpose: Video streaming test helper words
+\ See license at end of file
+
+hex
+headers
+
+load-base value vs-adr
+0 value vs-/frame
+0 value vs-height
+0 value vs-width
+0 value vs-x
+0 value vs-y
+d# 16 buffer: vs-guid
+\ XXX Need support for other format than YUV2 frames.
+: vs>screen ( -- )
+ vs-adr dup vs-/frame yuv2>rgb
+ vs-adr vs-x vs-y vs-width vs-height " draw-rectangle" $call-screen
+;
+
+: cfg-vs-test ( guid w h /frame -- xt adr )
+ to vs-/frame to vs-height to vs-width
+ vs-guid d# 16 move
+
+ ." Press a key to exit"
+ cursor-off
+ " dimensions" $call-screen ( w h )
+ vs-height - 2/ to vs-y
+ vs-width - 2/ to vs-x
+
+ ['] vs>screen vs-adr
+;
+
+
+\ LICENSE_BEGIN
+\ Copyright (c) 2011 FirmWorks
+\
+\ Permission is hereby granted, free of charge, to any person obtaining
+\ a copy of this software and associated documentation files (the
+\ "Software"), to deal in the Software without restriction, including
+\ without limitation the rights to use, copy, modify, merge, publish,
+\ distribute, sublicense, and/or sell copies of the Software, and to
+\ permit persons to whom the Software is furnished to do so, subject to
+\ the following conditions:
+\
+\ The above copyright notice and this permission notice shall be
+\ included in all copies or substantial portions of the Software.
+\
+\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+\
+\ LICENSE_END
+
Author: lwalter
Date: Tue Aug 9 20:23:58 2011
New Revision: 2441
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2441
Log:
Add mfgtest support
Added:
cpu/x86/pc/alex/yuv2rgb.fth
Added: cpu/x86/pc/alex/yuv2rgb.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/x86/pc/alex/yuv2rgb.fth Tue Aug 9 20:23:58 2011 (r2441)
@@ -0,0 +1,174 @@
+purpose: YUY2 to RGB-565 conversion
+\ See license at end of file
+
+\ B = 1.164(Y - 16) + 2.018(U - 128)
+\ G = 1.164(Y - 16) - 0.813(V - 128) - 0.391(U - 128)
+\ R = 1.164(Y - 16) + 1.596(V - 128)
+
+[ifdef] 386-assembler
+
+\ This code operates on pixel values in memory using scaler of 128
+\ Src bytes are Y0 U Y1 V
+\ Dst bytes are 565RGB 565RGB (2 16-bit pixels)
+
+code yuv2>rgb ( src dst count -- )
+ 4 [sp] di xchg \ di: dst
+ 8 [sp] si xchg \ si: src
+
+ ax push ax push ax push \ Save space on stack for V U Y0
+
+ begin
+ \ Get Y0, make signed, multiply by 1.164 * 128, save on stack
+ ax ax xor al lods d# 16 # ax sub d# 149 # ax ax imul-imm ax 0 [sp] mov
+ ax ax xor al lods d# 128 # ax sub ax 4 [sp] mov \ Get U, make signed, save on stack
+ \ Get Y1, make signed, multiply by 1.164 * 128, save in BX
+ ax ax xor al lods d# 16 # ax sub d# 149 # ax bx imul-imm
+ ax ax xor al lods d# 128 # ax sub ax 8 [sp] mov \ Get V, make signed, save on stack
+
+ \ Generate R
+ d# 204 # 8 [sp] ax imul-imm \ Multiply V by 1.596 * 128
+ bx ax add \ Add Y1
+ d# 7 # ax sar \ Scale down by 128
+
+ 0< if ax ax xor then \ Clip to 0
+ d# 255 # ax cmp > if d# 255 # ax mov then \ Clip to 255
+
+ h# f8 # ax and \ Use upper 5 bits only
+ d# 8 # ax shl \ Shift R into position
+ ax cx mov \ Save it
+
+ \ Generate B
+ d# 258 # 4 [sp] ax imul-imm \ Multiply U by 2.018 * 128
+ bx ax add \ Add Y1
+ d# 7 # ax sar \ Scale down by 128
+
+ 0< if ax ax xor then \ Clip to 0
+ d# 255 # ax cmp > if d# 255 # ax mov then \ Clip to 255
+
+ h# f8 # ax and \ Use upper 5 bits only
+ d# 3 # ax shr \ Shift B into position
+ ax cx or \ Save it
+
+ \ Generate G
+ d# -104 # 8 [sp] dx imul-imm \ Multiply V by -0.813 * 128
+ d# -50 # 4 [sp] ax imul-imm \ Multiply U by -0.391 * 128
+ dx ax add \ Add
+ ax dx mov \ Save to be used for the 2nd RGB
+ bx ax add \ Add Y1
+ d# 7 # ax sar \ Scale down by 128
+
+ 0< if ax ax xor then \ Clip to 0
+ d# 255 # ax cmp > if d# 255 # ax mov then \ Clip to 255
+
+ h# fc # ax and \ Use upper 6 bits only
+ d# 3 # ax shl \ Shift G into position
+ ax cx or \ Save it
+ d# 16 # cx shl \ Save second RGB
+
+ \ Generate 2nd R
+ 0 [sp] bx mov \ Work on Y0
+ d# 204 # 8 [sp] ax imul-imm \ Multiply V by 1.596 * 128
+ bx ax add \ Add Y0
+ d# 7 # ax sar \ Scale down by 128
+
+ 0< if ax ax xor then \ Clip to 0
+ d# 255 # ax cmp > if d# 255 # ax mov then \ Clip to 255
+
+ h# f8 # ax and \ Use upper 5 bits only
+ d# 8 # ax shl \ Shift R into position
+ ax cx or \ Save it
+
+ \ Generate 2nd B
+ d# 258 # 4 [sp] ax imul-imm \ Multiply U by 2.018 * 128
+ bx ax add \ Add Y0
+ d# 7 # ax sar \ Scale down by 128
+
+ 0< if ax ax xor then \ Clip to 0
+ d# 255 # ax cmp > if d# 255 # ax mov then \ Clip to 255
+
+ h# f8 # ax and \ Use upper 5 bits only
+ d# 3 # ax shr \ Shift B into position
+ ax cx or \ Save it
+
+ \ Generate 2nd G
+ dx ax mov \ v*0.813+u*0.391
+ bx ax add \ Add Y-
+ d# 7 # ax sar \ Scale down by 128
+
+ 0< if ax ax xor then \ Clip to 0
+ d# 255 # ax cmp > if d# 255 # ax mov then \ Clip to 255
+
+ h# fc # ax and \ Use upper 6 bits only
+ d# 3 # ax shl \ Shift G into position
+ cx ax or \ Save it
+
+ ax stos \ Output both RGB
+
+ d# 4 # h# c [sp] sub
+ 0= until
+
+ d# 16 [sp] sp lea \ Clean stack
+ di pop
+ si pop
+c;
+[then]
+
+[ifndef] yuv2>rgb
+
+\ Forth code: no division; use scaler of 128
+0 value y1
+0 value v 0 value v*0.813+u*0.391 0 value v*1.596
+0 value u 0 value u*2.018
+
+: do-uv-comp ( -- )
+ u d# 258 * to u*2.018
+ v d# -104 * u d# -50 * + to v*0.813+u*0.391
+ v d# 204 * to v*1.596
+;
+: y>rgb ( y -- rgb )
+ d# 16 - d# 149 * ( 1.164 ) ( y' )
+ dup u*2.018 + 7 >>a 0 max d# 255 min h# f8 and 3 >> ( y b )
+ over v*0.813+u*0.391 + 7 >>a 0 max d# 255 min h# fc and 3 << or ( y gb )
+ swap v*1.596 + 7 >>a 0 max d# 255 min h# f8 and 8 << or ( rgb )
+;
+: yuyv>rgb ( y0uy1v -- rgb0 rgb1 )
+ lbsplit ( v y1 u y0 )
+ swap d# 128 - to u rot d# 128 - to v ( y1 y0 )
+ do-uv-comp ( y1 y0 )
+ y>rgb ( y1 rgb0 )
+ swap y>rgb ( rgb0 rgb1 )
+;
+
+: yuv2>rgb ( src dst len -- )
+ 4 / 0 do ( src dst )
+ over i la+ be-l@ yuyv>rgb ( src dst rgb0 rgb1 )
+ wljoin over i la+ le-l! ( src dst )
+ loop 2drop
+;
+
+[then]
+
+\ LICENSE_BEGIN
+\ Copyright (c) 2011 FirmWorks
+\
+\ Permission is hereby granted, free of charge, to any person obtaining
+\ a copy of this software and associated documentation files (the
+\ "Software"), to deal in the Software without restriction, including
+\ without limitation the rights to use, copy, modify, merge, publish,
+\ distribute, sublicense, and/or sell copies of the Software, and to
+\ permit persons to whom the Software is furnished to do so, subject to
+\ the following conditions:
+\
+\ The above copyright notice and this permission notice shall be
+\ included in all copies or substantial portions of the Software.
+\
+\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+\
+\ LICENSE_END
+
Author: lwalter
Date: Tue Aug 9 20:23:31 2011
New Revision: 2439
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2439
Log:
Add mfgtest support
Added:
cpu/x86/pc/alex/disptest.fth
Added: cpu/x86/pc/alex/disptest.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/x86/pc/alex/disptest.fth Tue Aug 9 20:23:31 2011 (r2439)
@@ -0,0 +1,236 @@
+purpose: Display test
+\ See license at end of file
+
+\needs final-test? 0 value final-test?
+\needs smt-test? 0 value smt-test?
+
+dev /display
+
+d# 100 constant bar-int
+h# 7 constant test-colors16-mask
+create test-colors16
+\ white magenta yellow red green blue cyan black
+ ffff w, f81f w, ffe0 w, f800 w, 07e0 w, 001f w, 07ff w, 0000 w,
+
+: fill-rect ( -- ) " fill-rectangle" $call-screen ;
+: dimens ( -- w h ) " dimensions" $call-screen ;
+: ht ( -- h ) " height" $call-screen ;
+: wth ( -- w ) " width" $call-screen ;
+
+: whole-screen ( -- x y w h ) 0 0 dimens ;
+
+: black-screen ( -- ) 0 whole-screen fill-rect ;
+
+: test-color16 ( n -- color )
+ test-colors16 swap bar-int / test-colors16-mask and wa+ w@
+;
+: .horizontal-bars16 ( -- )
+ dimens ( width height )
+ 0 ?do ( width )
+ i test-color16 0 i 3 pick bar-int fill-rect
+ bar-int +loop drop
+;
+: .vertical-bars16 ( -- )
+ dimens ( width height )
+ swap 0 ?do ( height )
+ i test-color16 i 0 bar-int 4 pick fill-rect
+ bar-int +loop drop
+;
+
+instance variable rn \ Random number
+d# 5,000 constant burnin-time \ 5 seconds
+
+: random ( -- n )
+ rn @ d# 1103515245 * d# 12345 + h# 7FFFFFFF and dup rn !
+;
+
+: randomize-color ( -- c )
+ random h# 1f and d# 11 <<
+ random h# 3f and d# 5 << or
+ random h# 1f and or
+;
+: randomize-xy ( -- x y )
+ dimens ( width height )
+ random 3ff and min swap ( y width )
+ random 7ff and min swap ( x y )
+;
+: randomize-wh ( x y -- w h )
+ dimens ( x y width height )
+ rot - -rot ( max-h x width )
+ swap - swap ( max-w max-h )
+ randomize-xy ( max-w max-h w h )
+ rot min -rot min swap ( w' h' )
+;
+: .random-rect ( -- )
+ randomize-color ( c )
+ randomize-xy ( c x y )
+ 2dup randomize-wh ( c x y w h )
+ " fill-rectangle" $call-screen ( )
+;
+
+: random-selftest ( -- )
+ get-msecs rn !
+ get-msecs burnin-time + ( limit )
+ begin
+ get-msecs over u< ( limit reached? )
+ while ( limit )
+ .random-rect ( limit )
+ key? if key 2drop exit then
+ repeat ( limit )
+ drop
+;
+
+0 value xbias
+0 value ybias
+0 value hstripe
+0 value vstripe
+: set-stripes ( -- )
+ wth d# 256 / to hstripe
+ ht d# 256 / to vstripe
+ wth hstripe d# 256 * - to xbias
+ ht vstripe d# 256 * - to ybias
+;
+: half-bias ( -- ) xbias 2/ to xbias ybias 2/ to ybias ;
+: gvsr ( -- )
+ set-stripes half-bias black-screen ( )
+ d# 256 0 do ( )
+ d# 256 0 do ( )
+ i j 0 rgb>565 ( color )
+ hstripe i * xbias + ( color x )
+ vstripe j * ybias + ( color x y )
+ hstripe vstripe ( color x y w h )
+ fill-rect
+ loop
+ loop
+;
+: gvsb ( -- )
+ set-stripes half-bias black-screen ( )
+ d# 256 0 do ( )
+ d# 256 0 do ( )
+ 0 j i rgb>565 ( color )
+ hstripe i * xbias + ( color x )
+ vstripe j * ybias + ( color x y )
+ hstripe vstripe ( color x y )
+ fill-rect
+ loop
+ loop
+;
+: hgradient ( -- )
+ set-stripes black-screen ( )
+ d# 256 0 do ( )
+ i i i rgb>565 ( color )
+ hstripe i * xbias + 0 ( color x y )
+ hstripe ht ( color x y sw h )
+ fill-rect ( )
+ loop ( )
+;
+
+: vgradient ( -- )
+ set-stripes black-screen ( )
+ d# 256 0 do ( )
+ i i i rgb>565 ( color )
+ 0 vstripe i * ybias + ( color x y )
+ wth vstripe ( color x y w sh )
+ fill-rect ( )
+ loop ( )
+;
+
+
+h# ff h# ff h# ff rgb>565 constant white-color
+
+: hline ( y -- ) >r white-color 0 r> wth 1 fill-rect ;
+: vline ( y -- ) >r white-color r> 0 1 ht fill-rect ;
+
+: crosshatch ( -- )
+ black-screen
+ ht 0 do i hline d# 10 +loop
+ wth 0 do i vline d# 10 +loop
+;
+: short-wait ( -- ) smt-test? if d# 250 ms else d# 500 ms then ;
+: brightness-ramp ( -- )
+ 0 h# 0f do i bright! short-wait -1 +loop
+ backlight-off short-wait backlight-on
+ h# f bright!
+;
+
+: red-screen ( -- )
+ load-base whole-screen " read-rectangle" $call-screen
+ h# ff 00 00 rgb>565 whole-screen fill-rect
+ d# 1000 ms
+ load-base whole-screen fill-rect
+;
+: hold-time ( -- )
+ smt-test? if
+ d# 500 ms
+ else
+ final-test? if d# 500 ms else d# 1000 ms then
+ then
+;
+
+: hold-time2 ( -- )
+ smt-test? if
+ d# 500 ms
+ else
+ final-test? if key drop then
+ d# 1000 ms
+ then
+;
+: wait ( -- )
+ hold-time
+\ 0 set-source \ Freeze image
+ hold-time
+\ 1 set-source \ Unfreeze image
+ hold-time2
+;
+
+warning @ warning off
+: selftest ( -- error? )
+ depth d# 16 < if false exit then
+ smt-test? 0= if
+ .horizontal-bars16 wait
+ .vertical-bars16 wait
+ then
+ gvsr wait
+ gvsb wait
+ hgradient wait
+ vgradient wait
+ crosshatch wait
+ brightness-ramp
+
+ smt-test? 0= if
+ burnin-time d# 5000 > if
+ ." Press a key to stop early." cr
+ d# 1000 ms
+ then
+ random-selftest
+ then
+
+ confirm-selftest?
+;
+warning !
+
+device-end
+
+\ LICENSE_BEGIN
+\ Copyright (c) 2007 FirmWorks
+\
+\ Permission is hereby granted, free of charge, to any person obtaining
+\ a copy of this software and associated documentation files (the
+\ "Software"), to deal in the Software without restriction, including
+\ without limitation the rights to use, copy, modify, merge, publish,
+\ distribute, sublicense, and/or sell copies of the Software, and to
+\ permit persons to whom the Software is furnished to do so, subject to
+\ the following conditions:
+\
+\ The above copyright notice and this permission notice shall be
+\ included in all copies or substantial portions of the Software.
+\
+\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+\
+\ LICENSE_END