1/*
2 * Copyright © 2008 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 *
23 * Author:
24 *    Zou Nan hai <nanhai.zou@intel.com>
25 *    Yan Li <li.l.yan@intel.com>
26 *    Liu Xi bin<xibin.liu@intel.com>
27 */
28/* GRF allocation:
29   g1~g30: constant buffer
30           g1~g2:intra IQ matrix
31           g3~g4:non intra IQ matrix
32           g5~g20:IDCT table
33   g31:    thread payload 
34   g32:    message descriptor for reading reference data
35   g58~g81:reference data
36   g82:    thread payload backup
37   g83~g106:IDCT data                           */
38mov (2) g31.0<1>UD g82.12<2,2,1>UW {align1};          //restore x and y
39
40and.nz (1) null g82.2<1,1,1>UW 0x20UW {align1};       //dct_type
41(f0) jmpi field_dct;
42
43add (16) g58.0<1>W g83.0<16,16,1>W g58.0<16,16,2>UB {align1};
44add (16) g59.0<1>W g84.0<16,16,1>W g59.0<16,16,2>UB {align1};
45add (16) g60.0<1>W g85.0<16,16,1>W g60.0<16,16,2>UB {align1};
46add (16) g61.0<1>W g86.0<16,16,1>W g61.0<16,16,2>UB {align1};
47add (16) g62.0<1>W g87.0<16,16,1>W g62.0<16,16,2>UB {align1};
48add (16) g63.0<1>W g88.0<16,16,1>W g63.0<16,16,2>UB {align1};
49add (16) g64.0<1>W g89.0<16,16,1>W g64.0<16,16,2>UB {align1};
50add (16) g65.0<1>W g90.0<16,16,1>W g65.0<16,16,2>UB {align1};
51add (16) g66.0<1>W g91.0<16,16,1>W g66.0<16,16,2>UB {align1};
52add (16) g67.0<1>W g92.0<16,16,1>W g67.0<16,16,2>UB {align1};
53add (16) g68.0<1>W g93.0<16,16,1>W g68.0<16,16,2>UB {align1};
54add (16) g69.0<1>W g94.0<16,16,1>W g69.0<16,16,2>UB {align1};
55add (16) g70.0<1>W g95.0<16,16,1>W g70.0<16,16,2>UB {align1};
56add (16) g71.0<1>W g96.0<16,16,1>W g71.0<16,16,2>UB {align1};
57add (16) g72.0<1>W g97.0<16,16,1>W g72.0<16,16,2>UB {align1};
58add (16) g73.0<1>W g98.0<16,16,1>W g73.0<16,16,2>UB {align1};
59jmpi write_back;
60
61field_dct:
62add (16) g58.0<1>W g83.0<16,16,1>W g58.0<16,16,2>UB {align1};
63add (16) g59.0<1>W g91.0<16,16,1>W g59.0<16,16,2>UB {align1};
64add (16) g60.0<1>W g84.0<16,16,1>W g60.0<16,16,2>UB {align1};
65add (16) g61.0<1>W g92.0<16,16,1>W g61.0<16,16,2>UB {align1};
66add (16) g62.0<1>W g85.0<16,16,1>W g62.0<16,16,2>UB {align1};
67add (16) g63.0<1>W g93.0<16,16,1>W g63.0<16,16,2>UB {align1};
68add (16) g64.0<1>W g86.0<16,16,1>W g64.0<16,16,2>UB {align1};
69add (16) g65.0<1>W g94.0<16,16,1>W g65.0<16,16,2>UB {align1};
70add (16) g66.0<1>W g87.0<16,16,1>W g66.0<16,16,2>UB {align1};
71add (16) g67.0<1>W g95.0<16,16,1>W g67.0<16,16,2>UB {align1};
72add (16) g68.0<1>W g88.0<16,16,1>W g68.0<16,16,2>UB {align1};
73add (16) g69.0<1>W g96.0<16,16,1>W g69.0<16,16,2>UB {align1};
74add (16) g70.0<1>W g89.0<16,16,1>W g70.0<16,16,2>UB {align1};
75add (16) g71.0<1>W g97.0<16,16,1>W g71.0<16,16,2>UB {align1};
76add (16) g72.0<1>W g90.0<16,16,1>W g72.0<16,16,2>UB {align1};
77add (16) g73.0<1>W g98.0<16,16,1>W g73.0<16,16,2>UB {align1};
78
79write_back:
80mov (1) g31.8<1>UD 0x00F000FUD {align1};
81mov.sat (16) g58.0<2>UB g58.0<16,16,1>W {align1};
82mov.sat (16) g59.0<2>UB g59.0<16,16,1>W {align1};
83mov.sat (16) g60.0<2>UB g60.0<16,16,1>W {align1};
84mov.sat (16) g61.0<2>UB g61.0<16,16,1>W {align1};
85mov.sat (16) g62.0<2>UB g62.0<16,16,1>W {align1};
86mov.sat (16) g63.0<2>UB g63.0<16,16,1>W {align1};
87mov.sat (16) g64.0<2>UB g64.0<16,16,1>W {align1};
88mov.sat (16) g65.0<2>UB g65.0<16,16,1>W {align1};
89mov.sat (16) g66.0<2>UB g66.0<16,16,1>W {align1};
90mov.sat (16) g67.0<2>UB g67.0<16,16,1>W {align1};
91mov.sat (16) g68.0<2>UB g68.0<16,16,1>W {align1};
92mov.sat (16) g69.0<2>UB g69.0<16,16,1>W {align1};
93mov.sat (16) g70.0<2>UB g70.0<16,16,1>W {align1};
94mov.sat (16) g71.0<2>UB g71.0<16,16,1>W {align1};
95mov.sat (16) g72.0<2>UB g72.0<16,16,1>W {align1};
96mov.sat (16) g73.0<2>UB g73.0<16,16,1>W {align1};
97
98mov (16) m1.0<1>UB  g58.0<16,16,2>UB {align1};
99mov (16) m1.16<1>UB g59.0<16,16,2>UB {align1};
100mov (16) m2.0<1>UB  g60.0<16,16,2>UB {align1};
101mov (16) m2.16<1>UB g61.0<16,16,2>UB {align1};
102mov (16) m3.0<1>UB  g62.0<16,16,2>UB {align1};
103mov (16) m3.16<1>UB g63.0<16,16,2>UB {align1};
104mov (16) m4.0<1>UB  g64.0<16,16,2>UB {align1};
105mov (16) m4.16<1>UB g65.0<16,16,2>UB {align1};
106mov (16) m5.0<1>UB  g66.0<16,16,2>UB {align1};
107mov (16) m5.16<1>UB g67.0<16,16,2>UB {align1};
108mov (16) m6.0<1>UB  g68.0<16,16,2>UB {align1};
109mov (16) m6.16<1>UB g69.0<16,16,2>UB {align1};
110mov (16) m7.0<1>UB  g70.0<16,16,2>UB {align1};
111mov (16) m7.16<1>UB g71.0<16,16,2>UB {align1};
112mov (16) m8.0<1>UB  g72.0<16,16,2>UB {align1};
113mov (16) m8.16<1>UB g73.0<16,16,2>UB {align1};
114send (16) 0 acc0<1>UW g31<8,8,1>UW write(0,0,2,0) mlen 9 rlen 0 {align1};
115
116//U
117mov (1) g31.8<1>UD 0x0070007UD  { align1 };
118shr (2) g31.0<1>UD g31.0<2,2,1>UD 1D {align1};
119add (16) g74.0<1>W g99.0<16,16,1>W g74.0<16,16,1>UW {align1};
120add (16) g75.0<1>W g100.0<16,16,1>W g75.0<16,16,1>UW {align1};
121add (16) g76.0<1>W g101.0<16,16,1>W g76.0<16,16,1>UW {align1};
122add (16) g77.0<1>W g102.0<16,16,1>W g77.0<16,16,1>UW {align1};
123mov.sat (16) g74.0<2>UB g74.0<16,16,1>W {align1};
124mov.sat (16) g75.0<2>UB g75.0<16,16,1>W {align1};
125mov.sat (16) g76.0<2>UB g76.0<16,16,1>W {align1};
126mov.sat (16) g77.0<2>UB g77.0<16,16,1>W {align1};
127
128mov (16) m1.0<1>UB g74.0<16,16,2>UB {align1};
129mov (16) m1.16<1>UB g75.0<16,16,2>UB {align1};
130mov (16) m2.0<1>UB g76.0<16,16,2>UB {align1};
131mov (16) m2.16<1>UB g77.0<16,16,2>UB {align1};
132send (16) 0 acc0<1>UW g31<8,8,1>UW write(1, 0, 2, 0) mlen 3 rlen 0 { align1 };
133
134//V
135add (16) g78.0<1>UW g103.0<16,16,1>W g78.0<16,16,1>UW {align1};
136add (16) g79.0<1>UW g104.0<16,16,1>W g79.0<16,16,1>UW {align1};
137add (16) g80.0<1>UW g105.0<16,16,1>W g80.0<16,16,1>UW {align1};
138add (16) g81.0<1>UW g106.0<16,16,1>W g81.0<16,16,1>UW {align1};
139mov.sat (16) g78.0<2>UB g78.0<16,16,1>W {align1};
140mov.sat (16) g79.0<2>UB g79.0<16,16,1>W {align1};
141mov.sat (16) g80.0<2>UB g80.0<16,16,1>W {align1};
142mov.sat (16) g81.0<2>UB g81.0<16,16,1>W {align1};
143
144mov (16) m1.0<1>UB g78.0<16,16,2>UB {align1};
145mov (16) m1.16<1>UB g79.0<16,16,2>UB {align1};
146mov (16) m2.0<1>UB g80.0<16,16,2>UB {align1};
147mov (16) m2.16<1>UB g81.0<16,16,2>UB {align1};
148send (16) 0 acc0<1>UW g31<8,8,1>UW write(2, 0, 2, 0) mlen 3 rlen 0 { align1 };
149
150send (16) 0 acc0<1>UW g0<8,8,1>UW
151        thread_spawner(0, 0, 0) mlen 1 rlen 0 { align1 EOT};
152
153