|
|
1.1 root 1: #! /bin/sh
2:
1.1.1.3 ! root 3: # $Id: fb-xlat-auto.sh,v 1.11 2007/03/29 01:02:43 fredette Exp $
1.1 root 4:
5: # generic/fb-xlat-auto.sh - automatically generates C code
6: # for many framebuffer translation functions:
7:
8: #
1.1.1.2 root 9: # Copyright (c) 2003, 2005 Matt Fredette
1.1 root 10: # All rights reserved.
11: #
12: # Redistribution and use in source and binary forms, with or without
13: # modification, are permitted provided that the following conditions
14: # are met:
15: # 1. Redistributions of source code must retain the above copyright
16: # notice, this list of conditions and the following disclaimer.
17: # 2. Redistributions in binary form must reproduce the above copyright
18: # notice, this list of conditions and the following disclaimer in the
19: # documentation and/or other materials provided with the distribution.
20: # 3. All advertising materials mentioning features or use of this software
21: # must display the following acknowledgement:
22: # This product includes software developed by Matt Fredette.
23: # 4. The name of the author may not be used to endorse or promote products
24: # derived from this software without specific prior written permission.
25: #
26: # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
27: # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28: # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29: # DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
30: # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31: # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32: # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33: # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34: # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35: # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36: # POSSIBILITY OF SUCH DAMAGE.
37: #
38:
39: # this script generates one or more C functions. each function
40: # translates an image from a source image format into a destination
41: # image format, optionally halving or doubling the image size in the
42: # process.
43: #
44: # the source and destination image formats are represented by "keys",
45: # strings that describe the different attributes of a format.
46: #
1.1.1.2 root 47: # a source image format key has the form: WxHdDbBsSpPoO[cC][mMS][_rR_gG_bB][_X]
1.1 root 48: #
1.1.1.2 root 49: # a destination image format key has the form: dDbBsSpPoO[mM][_rR_gG_bB]
1.1 root 50: #
51: # all of the lowercase letters and underscores are literals, and all
52: # of the uppercase letters represent attribute values. the different
53: # attributes are:
54: #
55: # W is the width of the source image. if zero, the generated function
56: # will be able to translate source images of any width, but it will be
57: # suboptimal. if nonzero, the generated function will only be able to
58: # translate source images of that width, but it will have some
59: # optimization. this attribute is only used in source keys, since the
60: # destination width is always the scaled source width.
61: #
62: # H is the height of the source image. if zero, the generated
63: # function will be able to translate source images of any height, but
64: # it will be suboptimal. if nonzero, the generated function will only
65: # be able to translate source images of that height, but it will have
66: # some optimization. this attribute is only used in source keys,
67: # since the destination height is always the scaled source height.
68: #
69: # D is the color (d)epth, in bits, of the source/destination image.
70: # if zero, the generated function will be able to handle
71: # source/destination images of any depth, but it will be suboptimal.
72: # if nonzero, the generated function will only be able to handle
73: # source/destination images of that depth, but it will have some
74: # optimization.
75: #
76: # B is the (b)its-per-pixel of the source/destination image. this
77: # must be at least as large as the depth, and it may be larger. if
78: # zero, the generated function will be able to handle
79: # source/destination images of any bits-per-pixel, but it will be
80: # suboptimal. if nonzero, the generated function will only be able to
81: # handle source/destination images of that bits-per-pixel, but it will
82: # have some optimization.
83: #
84: # S is the (s)kip-x-bits of the source/destination image. this is the
85: # number of bits at the beginning of each image scanline that are not
86: # displayed. if an underscore, the generated function will be able to
87: # handle source/destination images with any skip-x-bits, but it will
88: # be suboptimal. if not an underscore, the generated function will
89: # only be able to handle source/destination images with that many
90: # skip-x-bits, but it will have some optimization.
91: #
92: # P is the (p)adding of the source/destination image. this is how
93: # many bits each image scanline is padded to. if zero, the generated
94: # function will be able to handle source/destination images with any
95: # padding, but it will be suboptimal. if nonzero, the generated
96: # function will only be able to handle source/destination images with
97: # that padding, but it will have some optimization.
98: #
99: # O is the byte and bit (o)rder of the source/destination image. this
100: # is always m or l for most- or least-significant, respectively.
101: # there is no "any" wildcard value. this script cannot handle image
102: # formats where a word-unit of pixels has one order for its bytes in
103: # memory, but the opposite order for its pixels within the word-unit.
104: #
1.1.1.2 root 105: # C is the optional class. it is 'm' for a monochrome (grayscale) image,
106: # and 'c' for a color image. if not given, an image with a depth of
107: # one is considered monochrome, and any other image is considered color.
108: #
109: # M is the optional mapping type. it is 'l' for a monochrome image
110: # that linearly maps pixels into intensities and for a color image
111: # that linearly maps pixel subfields into intensities. it is 'i' for
112: # images that index pixels or pixel subfields into intensities. if
113: # not given, monochrome images and color images with subfields are
114: # assumed to be linear, and color images without subfields are assumed
115: # to be indexed.
116: #
117: # S is the optional mapping size. if the mapping type is given, this
118: # must be given, and it is the size of the mapping range - i.e., the
119: # number of bits per intensity. if the mapping type is not given, and
120: # the image is linearly mapped monochrome, the mapping size is assumed
121: # to be the same as the image depth.
122: #
123: # R, G, and B are the optional subfield masks. if an image's pixels
124: # can be decomposed into subfields for red, green, and blue, these are
125: # the masks for the subfields.
126: #
1.1 root 127: # X is the optional scaling. it is `h' to halve the source image,
128: # or `d' to double it. this attribute is only used in source keys.
129:
130: # this script generates a set of functions for the product of all
131: # source image formats and all destination image formats.
132: #
133: # "all source image formats" includes all source image formats given
134: # on the command line, plus:
135: #
136: # the "any" source image format, unscaled
137: # the "any" source image format, halved
138: # the "any" source image format, doubled
139: #
140: # "all destination image formats" includes all destination
141: # image formats given on the command line, plus:
142: #
143: # the "any" destination image format
144: #
145: src_all=
146: dst_all=
147: for order in m l; do
1.1.1.2 root 148: src_key="0x0d0b0s_p0o${order}_r0x0_g0x0_b0x0"
1.1 root 149: src_all="${src_all} ${src_key} ${src_key}_h ${src_key}_d"
1.1.1.2 root 150: dst_all="${dst_all} d0b0s_p0o${order}_r0x0_g0x0_b0x0"
1.1 root 151: done
152:
153: which=
154: for arg
155: do
156: case $arg in
157: src|dst) which=$arg ;;
158: *)
159: if test "x${which}" != x; then
160: eval "${which}_all=\"$arg \$${which}_all\""
161: fi
162: ;;
163: esac
164: done
165:
166: PROG=`basename $0`
167: cat <<EOF
168: /* automatically generated by $PROG, do not edit! */
169:
170: /*
1.1.1.2 root 171: * Copyright (c) 2003, 2005 Matt Fredette
1.1 root 172: * All rights reserved.
173: *
174: * Redistribution and use in source and binary forms, with or without
175: * modification, are permitted provided that the following conditions
176: * are met:
177: * 1. Redistributions of source code must retain the above copyright
178: * notice, this list of conditions and the following disclaimer.
179: * 2. Redistributions in binary form must reproduce the above copyright
180: * notice, this list of conditions and the following disclaimer in the
181: * documentation and/or other materials provided with the distribution.
182: * 3. All advertising materials mentioning features or use of this software
183: * must display the following acknowledgement:
184: * This product includes software developed by Matt Fredette.
185: * 4. The name of the author may not be used to endorse or promote products
186: * derived from this software without specific prior written permission.
187: *
188: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
189: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
190: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
191: * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
192: * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
193: * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
194: * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
195: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
196: * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
197: * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
198: * POSSIBILITY OF SUCH DAMAGE.
199: */
200:
1.1.1.3 ! root 201: _TME_RCSID("\$Id: fb-xlat-auto.sh,v 1.11 2007/03/29 01:02:43 fredette Exp $");
1.1 root 202:
203: /* the central feature of these translation functions is the "bit
204: FIFO", a first-in, first-out stream of bits. source bit FIFOs are
205: used to read pixel bits out of source images, and destination bit
206: FIFOs are used to write pixel bits into destination images.
207:
208: a bit FIFO has a visible part and an invisible part.
209:
210: the visible part of a bit FIFO is 32 bits wide, meaning the
211: translation code can read (for a source bit FIFO) or write (for a
212: destination bit FIFO) up to 32 bits of pixel data before a bit
213: FIFO shift.
214:
215: the invisible part of a source bit FIFO contains pixel bits that
216: have already been read from the source image memory, but that have
217: yet to be shifted in to the visible part.
218:
219: the invisible part of a destination bit FIFO contains the pixel
220: bits that have been shifted out of the visible part, but that have
221: yet to be written to the destination image memory.
222:
223: depending on various attributes of an image format, it may be
224: possible for the translation code to always read or write the
225: entire 32 visible bits of a bit FIFO at a time, and as a result
226: always shift the bit FIFO 32 bits at a time. this is desirable
227: because it minimizes bit FIFO shifts.
228:
229: when this does happen, it may also be the case that the visible
230: part of the bit FIFO always perfectly corresponds to an aligned
231: 32-bit word in the image buffer.
232:
233: this is the optimal situation, as it makes it unnecessary to track
234: the invisible part in C local variables at all - each 32-bit FIFO
235: shift of a source bit FIFO just reads the next 32-bit word directly
236: into the visible part, and each 32-bit FIFO shift of a destination
237: bit FIFO just writes the next 32-bit word directly out of the
238: visible part.
239:
240: within the visible part of a bit FIFO, which bits belong to which
241: pixels depends on the "order" of the image format. most-significant
242: (big-endian) images have earlier (more to the left on the screen)
243: pixels in more-significant bit positions. least-significant
244: (little-endian) images have earlier pixels in less-significant bit
245: bit positions.
246:
247: bit significance *within* a pixel never depends on image order.
248: once the bits belonging to a pixel have been identified according
249: to image order, the least significant bit in that pixel's value is
250: always the bit with the least absolute value.
251:
252: some pictures may help explain this better. each picture shows the
253: 32 bit visible part of a bit FIFO, with the bits marked from 0
254: (least significant) to 31 (most significant). all of these
255: examples are for a two-bit-deep/two-bits-per-pixel image, and in
256: the visible part sixteen pixels are numbered. lesser numbered
257: pixels are earlier (more to the left on the screen). some of the
258: invisible part is also shown, along with the direction that the bit
259: FIFO shifts in:
260:
261: a source bit FIFO for a little-endian source image with two bits
262: per pixel looks like:
263:
264: |
265: | 31 30 29 28 7 6 5 4 3 2 1 0
266: --+--+--+--+--+--+|+--+--+--+--+- --+--+--+--+--+--+--+--+
267: .. p18 | p17 | p16 ||| p15 | p14 | .. p3 | p2 | p1 | p0 |
268: --+--+--+--+--+--+|+--+--+--+--+- --+--+--+--+--+--+--+--+
269: |
270: invisible part | visible part
271:
272: shift -> shift -> shift -> shift -> shift ->
273:
274: a source bit FIFO for a big-endian source image with two bits per
275: pixel looks like:
276:
277: |
278: 31 30 29 28 27 26 25 26 4 3 2 1 0 |
279: +--+--+--+--+--+--+--+-- -+--+--+--+--+|+--+--+--+--+--+--
280: | p0 | p1 | p2 | p3 .. | p14 | p15 ||| p16 | p17 | p18 ..
281: +--+--+--+--+--+--+--+-- -+--+--+--+--+|+--+--+--+--+--+--
282: |
283: visible part | invisible part
284:
285: <- shift <- shift <- shift <- shift <- shift
286:
287: a destination bit FIFO for a little-endian destination image with
288: two bits per pixel looks like:
289:
290: |
291: 31 30 29 28 27 26 25 26 4 3 2 1 0 |
292: +--+--+--+--+--+--+--+-- -+--+--+--+--+|+--+--+--+--+--+--
293: | p23 | p22 | p21 | p20 .. | p9 | p8 ||| p7 | p6 | p5 ..
294: +--+--+--+--+--+--+--+-- -+--+--+--+--+|+--+--+--+--+--+--
295: |
296: visible part | invisible part
297:
298: shift -> shift -> shift -> shift -> shift ->
299:
300: a destination bit FIFO for a big-endian destination image with
301: two bits per pixel looks like:
302:
303: |
304: | 31 30 29 28 7 6 5 4 3 2 1 0
305: --+--+--+--+--+--+|+--+--+--+--+- --+--+--+--+--+--+--+--+
306: .. p5 | p6 | p7 ||| p8 | p9 | .. p20 | p21 | p22 | p23 |
307: --+--+--+--+--+--+|+--+--+--+--+- --+--+--+--+--+--+--+--+
308: |
309: invisible part | visible part
310:
311: <- shift <- shift <- shift <- shift <- shift
312:
313: each translation function has at least one source bit FIFO and at
314: least one destination bit FIFO. the general idea is to read source
315: pixel value(s) from the source image, map those source pixel
316: value(s) somehow into destination pixel value(s), and write those
317: destination pixel value(s) to the destination image.
318:
319: translation functions that do not scale the image have exactly one
320: source bit FIFO and exactly one destination bit FIFO. one pixel
321: read from the source bit FIFO becomes one pixel written to the
322: destination bit FIFO.
323:
324: translation functions that halve the image size have two source bit
325: FIFOs and one destination bit FIFO. one source bit FIFO sources
326: bits from an even-numbered scanline, and the other sources bits from
327: an odd-numbered scanline. four pixels read from the source bit
328: FIFOs - two from each source bit FIFO, making a 2x2 square - become
329: one pixel written to the destination bit FIFO.
330:
331: translation functions that double the image size have one source
332: bit FIFO and two destination bit FIFOs. one destination bit FIFO
333: sinks bits for an even-numbered scanline, and the other sinks bits
334: for an odd-numbered scanline. one pixel read from the source bit
335: FIFO becomes four pixels written to the destination bit FIFOs -
336: two to each destination bit FIFO, making a 2x2 square.
337:
338: translation functions don't necessarily always translate the entire
339: source image into the entire destination image. instead, the buffer
340: holding the current source image is expected to be twice as large as
341: necessary (plus some overhead), with the second half of the buffer
342: holding a copy of the last translated ("old") source image.
343:
344: before setting up and translating pixels using bit FIFOs, a
345: translation function treats the the current and old source images as
346: an array of aligned 32-bit words and compares them. if it finds no
347: 32-bit word that has changed, no translation is done and the
348: function returns.
349:
350: otherwise, initial source pixel x and y coordinates are derived from
351: the offset of the 32-bit word that failed comparison, and the source
352: primary bit FIFO is primed. if this translation function halves the
353: image size, the source secondary bit FIFO is primed from the same x
354: coordinate on the "other" (think y ^ 1) scanline.
355:
356: then, initial destination pixel x and y coordinates are derived from
357: the initial source x and y coordinates, and the destination primary
358: bit FIFO is primed. if this translation function doubles the image
359: size, the destination secondary bit FIFO is primed from the same x
360: coordinate on the "other" (think y ^ 1) scanline.
361:
362: as mentioned previously, the buffer holding the current source image
363: is expected to be twice as large as necessary (plus some overhead),
364: with the second half of the buffer holding a copy of the last
365: translated ("old") source image.
366:
367: this "overhead" is approximately two extra scanlines worth of data,
368: that is initialized to all-bits-zero and must always remain zero.
369: this extra data is present at the end of both the current ("new")
370: and last translated ("old") source images.
371:
372: these extra, always-blank scanlines guarantee that the pixel
373: translation loop terminates. the pixel translation loop *never*
374: checks for the end of the image buffer. instead, it terminates only
375: after it has read in TME_FB_XLAT_RUN consecutive aligned 32-bit
376: words that have *not* changed between the new and old source images.
377: this small amount of extra memory overhead simplifies the pixel
378: translation loop, because it doesn't have to worry about going past
379: the end of the actual image.
380: */
381:
382:
383: /* macros: */
384:
385: /* given a 32-bit aligned pointer into the current source image, this
386: returns the corresponding 32-bit aligned pointer in the last
387: translated ("old") source image. since the old source image
388: follows the current source image, this is simple pointer arithmetic
389: using src_bypb: */
390: #define TME_FB_XLAT_SRC_OLD(raw) \\
391: ((tme_uint32_t *) (((tme_uint8_t *) (raw)) + src_bypb))
392:
393: /* when the fast, aligned 32-bit word comparison loop finds a word
394: that has changed in the source image, pixels are translated until
395: TME_FB_XLAT_RUN consecutive aligned 32-bit words are processed that
396: have *not* changed in the source image, at which point the fast
397: comparison loop resumes.
398:
399: the idea is that after you've started translating pixels, once the
400: FIFO shift operation has read TME_FB_XLAT_RUN consecutive raw,
401: unchanged 32-bit words, all of the pixels from previous, changed
402: 32-bit words have been translated and shifted out of the source bit
403: FIFO(s), and all bits remaining in the source bit FIFO(s) are for
404: pixels in those unchanged 32-bit words. since the pixels are
405: unchanged, pixel translation can stop, and the entire state of the
406: source bit FIFO(s) can be discarded.
407:
408: so, each time a raw, changed 32-bit word is read, xlat_run is
409: reloaded with TME_FB_XLAT_RUN, and each time 32 bits worth of
410: source image pixels are processed, it is decremented. when it
411: reaches zero, the source bit FIFO(s) are discarded, the destination
412: bit FIFO(s) are flushed, the pixel translation loop breaks and the
413: fast comparison loop continues: */
414: #define TME_FB_XLAT_RUN (2)
415:
416: /* this shifts a source FIFO: */
417: #define TME_FB_XLAT_SHIFT_SRC(unaligned, fifo, next, bits, shift, raw, order)\\
418: do { \\
419: \\
420: /* if the source FIFO may not be 32-bit aligned: */ \\
421: if (unaligned) { \\
422: \\
423: /* we must be shifting between 1 and 32 bits: */ \\
424: assert ((shift) >= 1 && (shift) <= 32); \\
425: \\
426: /* the FIFO must have more than 32 bits in it already: */ \\
427: assert (bits > 32); \\
428: \\
429: /* shift the FIFO: */ \\
430: if ((shift) == 32) { \\
431: fifo = next; \\
432: } \\
433: else if (order == TME_ENDIAN_BIG) { \\
434: fifo = (fifo << ((shift) & 31)) | (next >> (32 - (shift)));\\
435: next <<= ((shift) & 31); \\
436: } \\
437: else { \\
438: fifo = (fifo >> ((shift) & 31)) | (next << (32 - (shift)));\\
439: next >>= ((shift) & 31); \\
440: } \\
441: bits -= (shift); \\
442: \\
443: /* if we have a new 32-bit word to read: */ \\
444: if (bits <= 32) { \\
445: next = *raw; \\
446: if (*TME_FB_XLAT_SRC_OLD(raw) != next) { \\
447: *TME_FB_XLAT_SRC_OLD(raw) = next; \\
448: xlat_run = TME_FB_XLAT_RUN; \\
449: } \\
450: raw++; \\
451: next = (order == TME_ENDIAN_BIG \\
452: ? tme_betoh_u32(next) \\
453: : tme_letoh_u32(next)); \\
454: \\
455: /* before the load, if there were fewer than 32 bits \\
456: remaining in the FIFO, shift bits from the word \\
457: we just loaded into their proper positions: */ \\
458: if (bits < 32) { \\
459: if (order == TME_ENDIAN_BIG) { \\
460: fifo |= (next >> bits); \\
461: next <<= (32 - bits); \\
462: } \\
463: else { \\
464: fifo |= (next << bits); \\
465: next >>= (32 - bits); \\
466: } \\
467: } \\
468: \\
469: /* there are now 32 more bits in the FIFO: */ \\
470: bits += 32; \\
471: } \\
472: } \\
473: \\
474: /* otherwise, if the source FIFO is always 32-bit aligned: */ \\
475: else { \\
476: \\
477: /* we must be shifting exactly 32 bits: */ \\
478: assert((shift) == 32); \\
479: \\
480: /* load the next 32-bit word: */ \\
481: fifo = *raw; \\
482: if (*TME_FB_XLAT_SRC_OLD(raw) != fifo) { \\
483: *TME_FB_XLAT_SRC_OLD(raw) = fifo; \\
484: xlat_run = TME_FB_XLAT_RUN; \\
485: } \\
486: raw++; \\
487: fifo = (order == TME_ENDIAN_BIG \\
488: ? tme_betoh_u32(fifo) \\
489: : tme_letoh_u32(fifo)); \\
490: } \\
491: } while (/* CONSTCOND */ 0)
492:
493: /* this shifts a destination FIFO: */
494: #define TME_FB_XLAT_SHIFT_DST(unaligned, fifo, next, bits, shift, raw, order)\\
495: do { \\
496: \\
497: /* if the destination FIFO may not be 32-bit aligned: */ \\
498: if (unaligned) { \\
499: \\
500: /* we must be shifting between 1 and 32 bits: */ \\
501: assert ((shift) >= 1 && (shift) <= 32); \\
502: \\
503: /* the FIFO must have fewer than 32 bits in it: */ \\
504: assert (bits < 32); \\
505: \\
506: /* shift the FIFO: */ \\
507: if (order == TME_ENDIAN_BIG) { \\
508: next |= (fifo >> bits); \\
509: fifo <<= (32 - bits); \\
510: } \\
511: else { \\
512: next |= (fifo << bits); \\
513: fifo >>= (32 - bits); \\
514: } \\
1.1.1.3 ! root 515: if (SHIFTMAX_INT32_T < 32 && bits == 0) { \\
! 516: fifo = 0; \\
! 517: } \\
1.1 root 518: bits += (shift); \\
519: \\
520: /* if we have a completed 32-bit word to write: */ \\
521: if (bits >= 32) { \\
522: *(raw++) = (order == TME_ENDIAN_BIG \\
523: ? tme_htobe_u32(next) \\
524: : tme_htole_u32(next)); \\
525: bits -= 32; \\
526: assert(bits != 0 || fifo == 0); \\
527: next = fifo; \\
528: } \\
529: } \\
530: \\
531: /* the destination FIFO is always 32-bit aligned: */ \\
532: else { \\
533: \\
534: /* we must be shifting exactly 32 bits: */ \\
535: assert((shift) == 32); \\
536: \\
537: /* store the next 32-bit word: */ \\
538: *(raw++) = (order == TME_ENDIAN_BIG \\
539: ? tme_htobe_u32(fifo) \\
540: : tme_htole_u32(fifo)); \\
541: \\
542: } \\
543: \\
544: /* clear the writable part of the FIFO: */ \\
545: fifo = 0; \\
546: } while (/* CONSTCOND */ 0)
1.1.1.2 root 547:
548: /* _TME_FB_XLAT_MAP_LINEAR_SCALE gives the factor needed to scale a
549: masked value up or down to a given size in bits. for example, if a
550: value's mask is 0xf800 (a five bit mask), and the value needs to be
551: scaled up to seven bits, this gives an factor of four. if a
552: value's mask is 0x7e0 (a six bit mask), and the value needs to be
553: scaled down to three bits, this gives a factor of eight: */
554: #define _TME_FB_XLAT_MAP_LINEAR_SCALE(mask_in, mask_out) \\
555: (TME_FB_XLAT_MAP_BASE_MASK(mask_in) \\
556: ^ TME_FB_XLAT_MAP_BASE_MASK(mask_out))
557: #define TME_FB_XLAT_MAP_LINEAR_SCALE(mask_in, mask_out) \\
558: (_TME_FB_XLAT_MAP_LINEAR_SCALE(mask_in, mask_out) \\
559: ? (TME_FB_XLAT_MAP_BASE_MASK(_TME_FB_XLAT_MAP_LINEAR_SCALE(mask_in, mask_out))\\
560: + 1) \\
561: : 1)
562:
563: /* this linearly maps a value from one mask to another: */
564: #define _TME_FB_XLAT_MAP_LINEAR(value, mask_in, mask_out) \\
565: \\
566: /* if the value does not need to be scaled up: */ \\
567: (((TME_FB_XLAT_MAP_BASE_MASK(mask_out) \\
568: <= TME_FB_XLAT_MAP_BASE_MASK(mask_in)) \\
569: ? \\
570: \\
571: /* extract the value and scale it down: */ \\
572: (TME_FIELD_MASK_EXTRACTU(value, mask_in) \\
573: / TME_FB_XLAT_MAP_LINEAR_SCALE(mask_in, mask_out)) \\
574: \\
575: /* otherwise, the value needs to be scaled up: */ \\
576: : \\
577: \\
578: /* extract the value: */ \\
579: ((TME_FIELD_MASK_EXTRACTU(value, mask_in) \\
580: \\
581: /* scale it up: */ \\
582: * TME_FB_XLAT_MAP_LINEAR_SCALE(mask_in, mask_out)) \\
583: \\
584: /* if the least significant bit of the value is set, add \\
585: in the scale minus one. this makes the linear mapping \\
586: at least cover the entire range: */ \\
587: + (((value / \\
588: _TME_FIELD_MASK_FACTOR(mask_in)) \\
589: & 1) \\
590: * (TME_FB_XLAT_MAP_LINEAR_SCALE(mask_in, mask_out) \\
591: - 1)))) \\
592: \\
593: /* finally, shift the value into position: */ \\
594: * _TME_FIELD_MASK_FACTOR(mask_out))
595:
596: /* this indexes a value: */
597: #define _TME_FB_XLAT_MAP_INDEX(value, mask_out, index) \\
598: \\
599: /* intensities are either stored as 8 or 16 bits: */ \\
600: (((TME_FB_XLAT_MAP_BASE_MASK(mask_out) <= 0xff) \\
601: ? ((const tme_uint8_t *) (index))[(value)] \\
602: : ((const tme_uint16_t *) (index))[(value)]) \\
603: \\
604: /* shift the value into position: */ \\
605: * _TME_FIELD_MASK_FACTOR(mask_out))
606:
607: /* this maps one subfield or intensity value into another subfield or
608: intensity value: */
609: #define TME_FB_XLAT_MAP(value, mask_in, mask_out, indexed, index)\\
610: \\
611: /* do the linear mapping or the index mapping: */ \\
612: ((!(indexed)) \\
613: ? _TME_FB_XLAT_MAP_LINEAR(value, mask_in, mask_out) \\
614: : _TME_FB_XLAT_MAP_INDEX(TME_FIELD_MASK_EXTRACTU(value, mask_in), mask_out, index))
1.1 root 615: EOF
616:
617: # the next function number:
618: xlat_next=0
619: xlat_array=
620:
621: # permute over the source possibilities:
622: for src_key in ${src_all}; do
623:
624: # take apart the source possibility:
625: src_parts=${src_key}
626:
627: # get the width:
628: width=`echo ${src_parts} | sed -e 's/^\([0-9][0-9]*\)\(.*\)$/\1/'`
629: src_parts=`echo ${src_parts} | sed -e 's/^\([0-9][0-9]*\)\(.*\)$/\2/'`
630:
631: # get the height:
632: height=`echo ${src_parts} | sed -e 's/^x\([0-9][0-9]*\)\(.*\)$/\1/'`
633: src_parts=`echo ${src_parts} | sed -e 's/^x\([0-9][0-9]*\)\(.*\)$/\2/'`
634:
635: # get the source depth:
636: src_depth=`echo ${src_parts} | sed -e 's/^d\([0-9][0-9]*\)\(.*\)$/\1/'`
637: src_parts=`echo ${src_parts} | sed -e 's/^d\([0-9][0-9]*\)\(.*\)$/\2/'`
638:
639: # get the source bits per pixel:
640: src_bipp=`echo ${src_parts} | sed -e 's/^b\([0-9][0-9]*\)\(.*\)$/\1/'`
641: src_parts=`echo ${src_parts} | sed -e 's/^b\([0-9][0-9]*\)\(.*\)$/\2/'`
642:
643: # get the source skip pixel count:
644: src_skipx=`echo ${src_parts} | sed -e 's/^s\([_0-9][0-9]*\)\(.*\)$/\1/'`
645: src_parts=`echo ${src_parts} | sed -e 's/^s\([_0-9][0-9]*\)\(.*\)$/\2/'`
646:
647: # get the source scanline pad:
648: src_pad=`echo ${src_parts} | sed -e 's/^p\([0-9][0-9]*\)\(.*\)$/\1/'`
649: src_parts=`echo ${src_parts} | sed -e 's/^p\([0-9][0-9]*\)\(.*\)$/\2/'`
650:
651: # get the source "order" - i.e., byte order and leftmost (first)
652: # pixel significance:
653: src_order=`echo ${src_parts} | sed -e 's/^o\([ml]\)\(.*\)$/\1/'`
654: src_parts=`echo ${src_parts} | sed -e 's/^o\([ml]\)\(.*\)$/\2/'`
655:
1.1.1.2 root 656: # get the optional source "class" - monochrome or color:
657: src_class=`echo ${src_parts} | sed -e 's/^c\([mc]\)\(.*\)$/\1/'`
658: if test "x${src_class}" = "x${src_parts}"; then src_class= ; fi
659: src_parts=`echo ${src_parts} | sed -e 's/^c\([mc]\)\(.*\)$/\2/'`
660:
661: # get the optional source pixel mapping - linear or indexed, and
662: # the optional number of bits in the map range:
663: src_map=`echo ${src_parts} | sed -e 's/^m\([li]\)\([0-9]*\)\(.*\)$/\1/'`
664: src_map_bits=`echo ${src_parts} | sed -e 's/^m\([li]\)\([0-9]*\)\(.*\)$/\2/'`
665: if test "x${src_map}" = "x${src_parts}"; then src_map= ; src_map_bits= ; fi
666: src_parts=`echo ${src_parts} | sed -e 's/^m\([li]\)\([0-9]*\)\(.*\)$/\3/'`
667:
668: # get the optional source pixel subfield masks:
669: src_mask_g= ; src_mask_r= ; src_mask_b=
670: while true; do
671: src_mask=`echo ${src_parts} | sed -e 's/^\(_[rgb]\)\(0x[0-9A-Fa-f][0-9A-Fa-f]*\)\(.*\)$/src_mask\1=\2/'`
672: if test "x${src_mask}" = "x${src_parts}"; then break; fi
673: eval ${src_mask}
674: src_parts=`echo ${src_parts} | sed -e 's/^\(_[rgb]\)\(0x[0-9A-Fa-f][0-9A-Fa-f]*\)\(.*\)$/\3/'`
675: done
676:
1.1 root 677: # get the source scaling:
678: scale="${src_parts}_"
679:
1.1.1.2 root 680: # if the source class is not given, but the source depth is
681: # known, assume monochrome if the source depth is one, else
682: # assume color:
683: #
684: if test "x${src_class}" = x; then
685: case "${src_depth}" in
686: 0) src_class= ;;
687: 1) src_class=m ;;
688: *) src_class=c ;;
689: esac
690: fi
691:
692: # if the source mapping type is not given:
693: #
694: if test "x${src_map}" = x; then
695:
696: # if the source class is known as color:
697: #
698: if test "x${src_class}" = "xc"; then
699:
700: # if it is known that there are not any subfield masks, assume an indexed
701: # mapping, else if it is known that there are subfield masks, assume a
702: # linear mapping:
703: #
704: case "x${src_mask_r}" in
705: x0x0) ;;
706: x) src_map=i ;;
707: *) src_map=l ;;
708: esac
709:
710: # if the source class is known as monochrome:
711: #
712: elif test "x${src_class}" = "xm"; then
713:
714: # assume a linear mapping:
715: #
716: src_map=l
717: fi
718: fi
719:
720: # if the size of the source mapping range in bits is not given:
721: #
722: if test "x${src_map_bits}" = x; then
723:
724: # if the source class is known as mono and the source mapping
725: # type is known as linear, assume that the source depth is the
726: # size of the mapping range in bits:
727: #
728: if test "x${src_class}" = xm && test "x${src_map}" = xl; then
729: src_map_bits=${src_depth}
730:
731: # otherwise, set the size of the mapping range to zero to indicate
732: # unknown:
733: #
734: else
735: src_map_bits=0
736: fi
737: fi
738:
1.1 root 739: # permute over the destination possibilities:
740: for dst_key in ${dst_all}; do
741:
742: # take apart the destination possibility:
743: dst_parts=${dst_key}
744:
745: # get the destination depth:
746: dst_depth=`echo ${dst_parts} | sed -e 's/^d\([0-9][0-9]*\)\(.*\)$/\1/'`
747: dst_parts=`echo ${dst_parts} | sed -e 's/^d\([0-9][0-9]*\)\(.*\)$/\2/'`
748:
749: # get the destination bits per pixel:
750: dst_bipp=`echo ${dst_parts} | sed -e 's/^b\([0-9][0-9]*\)\(.*\)$/\1/'`
751: dst_parts=`echo ${dst_parts} | sed -e 's/^b\([0-9][0-9]*\)\(.*\)$/\2/'`
752:
753: # get the destination skip pixel count:
754: dst_skipx=`echo ${dst_parts} | sed -e 's/^s\([_0-9][0-9]*\)\(.*\)$/\1/'`
755: dst_parts=`echo ${dst_parts} | sed -e 's/^s\([_0-9][0-9]*\)\(.*\)$/\2/'`
756:
757: # get the destination scanline pad:
758: dst_pad=`echo ${dst_parts} | sed -e 's/^p\([0-9][0-9]*\)\(.*\)$/\1/'`
759: dst_parts=`echo ${dst_parts} | sed -e 's/^p\([0-9][0-9]*\)\(.*\)$/\2/'`
760:
761: # get the destination "order" - i.e., byte order and leftmost
762: # (first) pixel significance:
763: dst_order=`echo ${dst_parts} | sed -e 's/^o\([ml]\)\(.*\)$/\1/'`
764: dst_parts=`echo ${dst_parts} | sed -e 's/^o\([ml]\)\(.*\)$/\2/'`
765:
1.1.1.2 root 766: # get the optional destination pixel mapping - linear or indexed:
767: dst_map=`echo ${dst_parts} | sed -e 's/^m\([li]\)\(.*\)$/\1/'`
768: if test "x${dst_map}" = "x${dst_parts}"; then dst_map= ; fi
769: dst_parts=`echo ${dst_parts} | sed -e 's/^m\([li]\)\(.*\)$/\2/'`
770:
771: # get the optional destination pixel subfield masks:
772: dst_mask_g= ; dst_mask_r= ; dst_mask_b=
773: while true; do
774: dst_mask=`echo ${dst_parts} | sed -e 's/^\(_[rgb]\)\(0x[0-9A-Fa-f][0-9A-Fa-f]*\)\(.*\)$/dst_mask\1=\2/'`
775: if test "x${dst_mask}" = "x${dst_parts}"; then break; fi
776: eval ${dst_mask}
777: dst_parts=`echo ${dst_parts} | sed -e 's/^\(_[rgb]\)\(0x[0-9A-Fa-f][0-9A-Fa-f]*\)\(.*\)$/\3/'`
778: done
1.1 root 779:
780: # allocate the xlat number:
781: xlat=${xlat_next}
782: xlat_next=`expr ${xlat_next} + 1`
783: xlat_info="tme_fb_xlat${xlat}"
784:
785: # start the function:
786: echo ""
787: echo "/* this translates frame buffer contents from this source format:"
788: case "${width}x${height}" in
789: 0x0) echo -n " any dimensions" ;;
790: *x0) echo -n " width $width, any height" ;;
791: 0x*) echo -n " any width, height ${height}" ;;
792: *) echo -n " ${width}x${height}" ;;
793: esac
794: xlat_info="${xlat_info}, ${width}, ${height}"
795: case ${scale} in
796: _h_) echo " (image will be halved)" ; value="HALF" ;;
797: _d_) echo " (image will be doubled)" ; value="DOUBLE" ;;
798: *) echo "" ; value="NONE" ;;
799: esac
800: xlat_info="${xlat_info}, TME_FB_XLAT_SCALE_${value}"
801: echo -n " "
802: case ${src_depth} in
803: 0) echo -n "any depth" ;;
804: 1) echo -n "1 bit deep" ;;
805: *) echo -n "${src_depth} bits deep" ;;
806: esac
807: xlat_info="${xlat_info}, ${src_depth}"
808: case ${src_bipp} in
809: 0) echo -n ", any bits per pixel" ;;
810: 1) echo -n ", 1 bit per pixel" ;;
811: *) echo -n ", ${src_bipp} bits per pixel" ;;
812: esac
813: xlat_info="${xlat_info}, ${src_bipp}"
814: case ${src_skipx} in
815: _) echo -n ", any number of pixels skipped" ; value="-1";;
816: *) echo -n ", ${src_skipx} pixels skipped" ; value=${src_skipx} ;;
817: esac
818: xlat_info="${xlat_info}, ${value}"
819: case ${src_pad} in
820: 0) echo -n ", any scanline padding" ;;
821: *) echo -n ", ${src_pad}-bit scanline padding" ;;
822: esac
823: xlat_info="${xlat_info}, ${src_pad}"
824: case ${src_order} in
825: m) echo -n ", MSB-first" ; value="BIG" ;;
826: l) echo -n ", LSB-first" ; value="LITTLE" ;;
827: esac
828: xlat_info="${xlat_info}, TME_ENDIAN_${value}"
1.1.1.2 root 829: case "x${src_class}" in
830: xm) echo -n ", monochrome" ; value="MONOCHROME" ;;
831: xc) echo -n ", color" ; value="COLOR" ;;
832: *) echo -n ", either color or monochrome" ; value="ANY" ;;
833: esac
834: xlat_info="${xlat_info}, TME_FB_XLAT_CLASS_${value}"
835: case "x${src_map}" in
836: xl) echo -n ", linearly mapped pixels" ; value="LINEAR" ;;
837: xi) echo -n ", index mapped pixels" ; value="INDEX" ;;
838: *) echo -n ", any pixel mapping" ; value="ANY" ;;
839: esac
840: xlat_info="${xlat_info}, TME_FB_XLAT_MAP_${value}"
841: value=${src_map_bits}
842: case "${src_map_bits}" in
843: 0) echo -n ", any bits per mapped intensity" ;;
844: 1) echo -n ", 1 bit per mapped intensity" ;;
845: *) echo -n ", ${src_map_bits} bits per mapped intensity" ;;
846: esac
847: xlat_info="${xlat_info}, ${value}"
848: for primary in g r b; do
849: eval "src_mask=\$src_mask_${primary}"
850: case "x${src_mask}" in
851: x) echo -n ", no ${primary} mask" ; value=0 ;;
852: x0x0) echo -n ", any ${primary} mask" ; value=TME_FB_XLAT_MASK_ANY ;;
853: *) echo -n ", a ${primary} mask of ${src_mask}" ; value=${src_mask} ;;
854: esac
855: xlat_info="${xlat_info}, ${value}"
856: done
1.1 root 857: echo ""
858: echo " to this destination format:"
859: echo -n " "
860: case ${dst_depth} in
861: 0) echo -n "any depth" ;;
862: 1) echo -n "1 bit deep" ;;
863: *) echo -n "${dst_depth} bits deep" ;;
864: esac
865: xlat_info="${xlat_info}, ${dst_depth}"
866: case ${dst_bipp} in
867: 0) echo -n ", any bits per pixel" ;;
868: 1) echo -n ", 1 bit per pixel" ;;
869: *) echo -n ", ${dst_bipp} bits per pixel" ;;
870: esac
871: xlat_info="${xlat_info}, ${dst_bipp}"
872: case ${dst_skipx} in
873: _) echo -n ", any number of pixels skipped" ; value="-1";;
874: *) echo -n ", ${dst_skipx} pixels skipped" ; value=${dst_skipx} ;;
875: esac
876: xlat_info="${xlat_info}, ${value}"
877: case ${dst_pad} in
878: 0) echo -n ", any scanline padding" ;;
879: *) echo -n ", ${dst_pad}-bit scanline padding" ;;
880: esac
881: xlat_info="${xlat_info}, ${dst_pad}"
882: case ${dst_order} in
883: m) echo -n ", MSB-first" ; value="BIG" ;;
884: l) echo -n ", LSB-first" ; value="LITTLE" ;;
885: esac
886: xlat_info="${xlat_info}, TME_ENDIAN_${value}"
1.1.1.2 root 887: case "x${dst_map}" in
888: xl) echo -n ", linearly mapped pixels" ; value="LINEAR" ;;
889: xi) echo -n ", index mapped pixels" ; value="INDEX" ;;
890: *) echo -n ", any pixel mapping" ; value="ANY" ;;
891: esac
892: xlat_info="${xlat_info}, TME_FB_XLAT_MAP_${value}"
893: for primary in g r b; do
894: eval "dst_mask=\$dst_mask_${primary}"
895: case "x${dst_mask}" in
896: x) echo -n ", no ${primary} mask" ; value=0 ;;
897: x0x0) echo -n ", any ${primary} mask" ; value=TME_FB_XLAT_MASK_ANY ;;
898: *) echo -n ", a ${primary} mask of ${dst_mask}" ; value=${dst_mask} ;;
899: esac
900: xlat_info="${xlat_info}, ${value}"
901: done
1.1 root 902: save_IFS=$IFS
903: IFS=
904: xlat_array="${xlat_array}
905: { $xlat_info }, "
906: IFS=$save_IFS
907: echo ""
908: echo "*/"
909: echo "static int"
910: echo "tme_fb_xlat${xlat}(struct tme_fb_connection *src,"
911: echo " struct tme_fb_connection *dst)"
912: echo "{"
913: undef_macros=
914:
915: echo ""
916: echo " /* whenever possible we define macros instead of declaring"
917: echo " variables, for optimization: */"
918:
919: echo ""
920: echo " /* declare src_x and src_y. these are the current translation"
921: echo " coordinates in the source image: */"
922: echo " unsigned int src_x, src_y;"
923:
924: echo ""
925: echo " /* declare dst_x and dst_y. these are the current translation"
926: echo " coordinates in the destination image. since this function"
927: if test $scale = _; then
928: echo " does not scale the image, these coordinates are always"
929: echo " the same as the coordinates in the source image: */"
930: echo "#define dst_x (src_x)"
931: echo "#define dst_y (src_y)"
932: undef_macros="${undef_macros} dst_x dst_y"
933: scale_op=
934: scale_math=
935: else
936: if test $scale = _h_; then
937: scale_op='/'
938: scale_name='halves'
939: else
940: scale_op='*'
941: scale_name='doubles'
942: fi
943: scale_math=" ${scale_op} 2"
944: echo " ${scale_name} the image, the coordinates in the destination image"
945: echo " are always the coordinates in the source image${scale_math}: */"
946: echo " unsigned int dst_x, dst_y;"
947: fi
948:
949: echo ""
950: echo " /* declare pixel. this holds a single pixel value being translated"
951: echo " for the destination image: */"
952: echo " tme_uint32_t pixel;"
953:
954: echo ""
955: echo " /* declare src_width and dst_width. these are in terms of pixels: */"
956: value="(src_width${scale_math})"
957: if test ${width} = 0; then
958: echo " const unsigned int src_width = src->tme_fb_connection_width;"
959: if test $scale != _; then
960: echo " const unsigned int dst_width = ${value};"
961: else
962: echo "#define dst_width ${value}"
963: undef_macros="${undef_macros} dst_width"
964: fi
965: else
966: echo "#define src_width (${width})"
967: echo "#define dst_width ${value}"
968: undef_macros="${undef_macros} src_width dst_width"
969: fi
970:
971: echo ""
972: echo " /* declare src_depth, the source pixel depth, which is in"
973: echo " terms of bits. declare src_mask, which is the corresponding"
974: echo " mask of one bits: */"
975: value="(0xffffffff >> (32 - src_depth))"
976: if test ${src_depth} = 0; then
977: echo " const unsigned int src_depth = src->tme_fb_connection_depth;"
978: echo " const tme_uint32_t src_mask = ${value};"
979: else
980: echo "#define src_depth (${src_depth})"
981: echo "#define src_mask ${value}"
982: undef_macros="${undef_macros} src_depth src_mask"
983: fi
984:
1.1.1.2 root 985: # if we are halving, or if source pixels may have subfields,
986: # we may need to deal with intensities:
987: #
988: if test ${scale} = _h_ || test "x${src_mask_g}" != x; then
989:
990: echo ""
991: echo " /* declare src_indexed. this is nonzero if source pixel subfields"
992: echo " are index-mapped into intensities: */"
993: if test "x${src_map}" = x; then
994: echo " const unsigned int src_indexed = (src->tme_fb_connection_map_g != NULL);"
995: else
996: if test "x${src_map}" = xi; then value=TRUE; else value=FALSE; fi
997: echo "#define src_indexed (${value})"
998: undef_macros="${undef_macros} src_indexed"
999: fi
1000:
1001: echo ""
1002: echo " /* declare src_mask_i, which is the mask for a source intensity: */"
1003: if test "${src_map_bits}" = 0; then
1004: echo " const tme_uint32_t src_mask_i = (0xffffffff >> (32 - src->tme_fb_connection_map_bits));"
1005: else
1006: echo "#define src_mask_i (0xffffffff >> (32 - ${src_map_bits}))"
1007: undef_macros="${undef_macros} src_mask_i"
1008: fi
1009:
1010: if test "x${src_class}" != xm; then
1011: echo ""
1012: echo " /* declare dst_indexed. this is nonzero if intensities are index-mapped"
1013: echo " into destination pixel subfields: */"
1014: if test "x${dst_map}" = x; then
1015: echo " const unsigned int dst_indexed = (dst->tme_fb_connection_map_g != NULL);"
1016: else
1017: if test "x${dst_map}" = xi; then value=TRUE; else value=FALSE; fi
1018: echo "#define dst_indexed (${value})"
1019: undef_macros="${undef_macros} dst_indexed"
1020: fi
1021:
1022: echo ""
1023: echo " /* declare dst_masks_default. this is nonzero if the destination"
1024: echo " subfield masks are the default: */"
1025: if test "x${dst_mask_g}" = "x0x0"; then
1026: echo " const unsigned int dst_masks_default = (dst->tme_fb_connection_mask_g == 0);"
1027: else
1028: if test "x${dst_mask_g}" = x; then value=TRUE; else value=FALSE; fi
1029: echo "#define dst_masks_default (${value})"
1030: undef_macros="${undef_macros} dst_masks_default"
1031: fi
1032: fi
1033:
1034: for primary in g r b; do
1035: primary_cap=`echo ${primary} | tr a-z A-Z`
1036: echo ""
1037: echo " /* declare src_mask_${primary}, the mask for the ${primary} subfield in a source pixel: */"
1038: eval "src_mask=\$src_mask_${primary}"
1039: if test "x${src_mask}" = x0x0; then
1040: echo " const tme_uint32_t src_mask_${primary}"
1041: echo " = (src->tme_fb_connection_mask_${primary} != 0"
1042: echo " ? src->tme_fb_connection_mask_${primary}"
1043: echo " : src_mask);"
1044: else
1045: if test "x${src_mask}" = x; then src_mask="src_mask"; fi
1046: echo "#define src_mask_${primary} (${src_mask})"
1047: undef_macros="${undef_macros} src_mask_${primary}"
1048: fi
1049: echo ""
1050: echo " /* declare value_${primary}, the intensity value for the ${primary} subfield in a pixel: */"
1051: echo " tme_uint32_t value_${primary};"
1052: if test "x${src_class}" = xm; then break; fi
1053: echo ""
1054: echo " /* declare dst_mask_${primary}, the mask for the ${primary} subfield in a destination pixel: */"
1055: eval "dst_mask=\$dst_mask_${primary}"
1056: if test "x${dst_mask}" = x0x0; then
1057: echo " const tme_uint32_t dst_mask_${primary}"
1058: echo " = (dst->tme_fb_connection_mask_${primary} != 0"
1059: echo " ? dst->tme_fb_connection_mask_${primary}"
1060: echo " : TME_FB_XLAT_MASK_DEFAULT_${primary_cap});"
1061: else
1062: if test "x${dst_mask}" = x; then dst_mask="TME_FB_XLAT_MASK_DEFAULT_${primary_cap}"; fi
1063: echo "#define dst_mask_${primary} (${dst_mask})"
1064: undef_macros="${undef_macros} dst_mask_${primary}"
1065: fi
1066: done
1067: fi
1068:
1.1 root 1069: echo ""
1070: echo " /* declare src_bipp and dst_bipp. these are the bits-per-pixel"
1071: echo " values for the source and destination images: */"
1072: if test ${src_bipp} = 0; then
1073: echo " const unsigned int src_bipp = src->tme_fb_connection_bits_per_pixel;"
1074: else
1075: echo "#define src_bipp (${src_bipp})"
1076: undef_macros="${undef_macros} src_bipp"
1077: fi
1078: if test ${dst_bipp} = 0; then
1079: echo " const unsigned int dst_bipp = dst->tme_fb_connection_bits_per_pixel;"
1080: else
1081: echo "#define dst_bipp (${dst_bipp})"
1082: undef_macros="${undef_macros} dst_bipp"
1083: fi
1084:
1085: echo ""
1086: echo " /* declare src_skipx and dst_skipx. these are the counts of"
1087: echo " undisplayed pixels at the beginning of each scanline in the"
1088: echo " source and destination images: */"
1089: if test ${src_skipx} = _; then
1090: echo " const unsigned int src_skipx = src->tme_fb_connection_skipx;"
1091: else
1092: echo "#define src_skipx (${src_skipx})"
1093: undef_macros="${undef_macros} src_skipx"
1094: fi
1095: if test ${dst_skipx} = _; then
1096: echo " const unsigned int dst_skipx = dst->tme_fb_connection_skipx;"
1097: else
1098: echo "#define dst_skipx (${dst_skipx})"
1099: undef_macros="${undef_macros} dst_skipx"
1100: fi
1101:
1102: echo ""
1103: echo " /* declare src_pad and dst_pad. these are the paddings, in bits,"
1104: echo " of each scanline in the source and destination images: */"
1105: if test ${src_pad} = 0; then
1106: echo " const unsigned int src_pad = src->tme_fb_connection_scanline_pad;"
1107: else
1108: echo "#define src_pad (${src_pad})"
1109: undef_macros="${undef_macros} src_pad"
1110: fi
1111: if test ${dst_pad} = 0; then
1112: echo " const unsigned int dst_pad = dst->tme_fb_connection_scanline_pad;"
1113: else
1114: echo "#define dst_pad (${dst_pad})"
1115: undef_macros="${undef_macros} dst_pad"
1116: fi
1117:
1118: echo ""
1119: echo " /* declare src_order and dst_order. these are the bit and byte"
1120: echo " orders (either TME_ENDIAN_BIG or TME_ENDIAN_LITTLE) of the"
1121: echo " source and destination images. since these values profoundly"
1122: echo " affect optimization, they are always constant: */"
1123: if test ${src_order} = m; then value=BIG; else value=LITTLE; fi
1124: echo "#define src_order (TME_ENDIAN_${value})"
1125: undef_macros="${undef_macros} src_order"
1126: if test ${dst_order} = m; then value=BIG; else value=LITTLE; fi
1127: echo "#define dst_order (TME_ENDIAN_${value})"
1128: undef_macros="${undef_macros} dst_order"
1129:
1130: echo ""
1131: echo " /* declare src_bypl and dst_bypl. these are the bytes per scanline"
1132: echo " in the source and destination images. these values are calculated"
1133: echo " from the count of undisplayed and displayed pixels per scanline,"
1134: echo " the number of bits per pixel, and the scanline padding: */"
1135: value="(((((src_skipx + src_width) * src_bipp) + (src_pad - 1)) & -src_pad) / 8)"
1136: if test ${src_skipx} = _ || test ${width} = 0 || test ${src_bipp} = 0 || test ${src_pad} = 0; then
1137: echo " const unsigned int src_bypl = ${value};"
1138: src_bypl_var=true
1139: else
1140: echo "#define src_bypl ${value}"
1141: undef_macros="${undef_macros} src_bypl"
1142: src_bypl_var=false
1143: fi
1144: value="(((((dst_skipx + dst_width) * dst_bipp) + (dst_pad - 1)) & -dst_pad) / 8)"
1145: if test ${dst_skipx} = _ || test ${width} = 0 || test ${dst_bipp} = 0 || test ${dst_pad} = 0; then
1146: echo " const unsigned int dst_bypl = ${value};"
1147: dst_bypl_var=true
1148: else
1149: echo "#define dst_bypl ${value}"
1150: undef_macros="${undef_macros} dst_bypl"
1151: dst_bypl_var=false
1152: fi
1153:
1154: echo ""
1155: echo " /* declare src_packed and dst_packed. these are nonzero iff"
1156: echo " every last bit in a scanline belongs to a displayed pixel."
1157: echo " put another way, this is zero iff a scanline has undisplayed"
1158: echo " pixels at its beginning or padding bits at its end. when"
1159: echo " a source image or destination image is packed, translation"
1160: echo " doesn't have to worry about skipping FIFO bits to get to"
1161: echo " bits belonging to displayed pixels: */"
1162: value="((src_width * src_bipp) == (src_bypl * 8))"
1163: if $src_bypl_var; then
1164: echo " const unsigned int src_packed = ${value};"
1165: else
1166: echo "#define src_packed ${value}"
1167: undef_macros="${undef_macros} src_packed"
1168: fi
1169: value="((dst_width * dst_bipp) == (dst_bypl * 8))"
1170: if $dst_bypl_var; then
1171: echo " const unsigned int dst_packed = ${value};"
1172: else
1173: echo "#define dst_packed ${value}"
1174: undef_macros="${undef_macros} dst_packed"
1175: fi
1176:
1177: echo ""
1178: echo " /* declare src_bypb and src_bypb_real. src_bypb is the bytes"
1179: echo " per source image buffer with the \"translation termination"
1180: echo " overhead\" of approximately two extra scanlines. src_bypb_real"
1181: echo " is the real bytes per source image buffer with no overhead."
1182: echo " both values are padded to a multiple of 4 bytes (32 bits): */"
1183: if test ${height} = 0; then
1184: value="src->tme_fb_connection_height"
1185: else
1186: value="${height}"
1187: fi
1188: value_real="(((${value} * src_bypl) + 3) & -4)"
1189: value="((src_bypb_real + (src_bypl * 2)) & -4)"
1190: if test ${height} = 0 || $src_bypl_var; then
1191: echo " const unsigned int src_bypb_real = ${value_real};"
1192: echo " const unsigned int src_bypb = ${value};"
1193: else
1194: echo "#define src_bypb_real ${value_real}"
1195: echo "#define src_bypb ${value}"
1196: undef_macros="${undef_macros} src_bypb_real src_bypb"
1197: fi
1198:
1199: echo ""
1200: echo " /* declare the source primary bit FIFO:"
1201: echo ""
1202: echo " src_raw0 points to the next aligned 32-bit word to be"
1203: echo " read from the image buffer."
1204: echo ""
1205: echo " src_fifo0 is the visible part of the bit FIFO."
1206: echo ""
1207: echo " src_fifo0_next and src_fifo0_bits are only used when the"
1208: echo " visible part of the bit FIFO is not guaranteed to always"
1209: echo " correspond to an aligned 32-bit word in the image buffer."
1210: echo " src_fifo0_next is the invisible part of the bit FIFO,"
1211: echo " and src_fifo0_bits tracks the total number of bits in the"
1212: echo " visible and invisible parts of the FIFO. */"
1213: echo " const tme_uint32_t *src_raw0;"
1214: echo " tme_uint32_t src_fifo0, src_fifo0_next;"
1215: echo " unsigned int src_fifo0_bits;"
1216:
1217: if test ${scale} = _h_; then
1218: echo ""
1219: echo " /* since this function ${scale_name} the image, declare the"
1220: echo " source secondary bit FIFO. these variables work in "
1221: echo " exactly the same way that their primary counterparts do: */"
1222: echo " const tme_uint32_t *src_raw1;"
1223: echo " tme_uint32_t src_fifo1, src_fifo1_next;"
1224: echo " unsigned int src_fifo1_bits;"
1225: fi
1226:
1227: echo ""
1228: echo " /* declare the destination primary bit FIFO:"
1229: echo ""
1230: echo " dst_raw0 points to the next aligned 32-bit word to be"
1231: echo " written into the image buffer."
1232: echo ""
1233: echo " dst_fifo0 is the visible part of the bit FIFO."
1234: echo ""
1235: echo " dst_fifo0_next and dst_fifo0_bits are only used when the"
1236: echo " visible part of the bit FIFO is not guaranteed to always"
1237: echo " correspond to an aligned 32-bit word in the image buffer."
1238: echo " dst_fifo0_next is the invisible part of the bit FIFO,"
1239: echo " and dst_fifo0_bits tracks the total number of bits in the"
1240: echo " invisible part of the FIFO. */"
1241: echo " tme_uint32_t *dst_raw0;"
1242: echo " tme_uint32_t dst_fifo0, dst_fifo0_next;"
1243: echo " unsigned int dst_fifo0_bits;"
1244:
1245: if test ${scale} = _d_; then
1246: echo ""
1247: echo " /* since this function ${scale_name} the image, declare"
1248: echo " the destination secondary bit FIFO. these variables work"
1249: echo " in exactly the same way that their primary counterparts"
1250: echo " do: */"
1251: echo " tme_uint32_t *dst_raw1;"
1252: echo " tme_uint32_t dst_fifo1, dst_fifo1_next;"
1253: echo " unsigned int dst_fifo1_bits;"
1254: fi
1255:
1256: echo ""
1257: echo " /* declare src_off and dst_off. these are used when priming a"
1258: echo " source or destination bit FIFO, to identify an initial aligned"
1259: echo " 32-bit word in the source or destination image buffer, and an"
1260: echo " initial bit offset within that word: */"
1261: echo " unsigned int src_off, dst_off;"
1262:
1263: echo ""
1264: echo " /* declare src_fifo0_may_be_unaligned. this is zero iff all"
1265: echo " aligned 32-bit words in the source buffer contain a whole"
1.1.1.2 root 1266: echo " number of displayed pixels, and at *all times during the"
1267: echo " translation* the visible part of the bit FIFO is guaranteed"
1268: echo " to correspond to an aligned 32-bit word in the image buffer."
1269: echo ""
1270: echo " this is *not* so if any of the following are true:"
1271: echo ""
1272: echo " - the source bits-per-pixel value is not known at compile"
1273: echo " time. in this case, we can't unroll the translation loop"
1274: echo " for source pixels, and are forced to shift the FIFO after"
1275: echo " each one."
1276: echo ""
1277: echo " - if the source image is not packed. in this case, there may"
1278: echo " be undisplayed pixels in the FIFO, which we will need to"
1279: echo " shift out."
1280: echo ""
1281: echo " - if there are 24 bits per source pixel. in this case, a"
1282: echo " source pixel may cross a 32-bit boundary: */"
1283: src_fifo0_may_be_unaligned_var=false
1284: if test ${src_bipp} = 0; then
1285: value=TRUE
1286: else
1287: value="(!src_packed || (src_bipp == 24))"
1288: src_fifo0_may_be_unaligned_var=${src_bypl_var}
1289: fi
1290: if $src_fifo0_may_be_unaligned_var; then
1.1 root 1291: echo " const unsigned int src_fifo0_may_be_unaligned = ${value};"
1292: else
1293: echo "#define src_fifo0_may_be_unaligned ${value}"
1294: undef_macros="${undef_macros} src_fifo0_may_be_unaligned"
1295: fi
1296:
1297: if test $scale = _h_; then
1298: echo ""
1299: echo " /* declare src_fifo1_may_be_unaligned. this is zero iff all"
1300: echo " aligned 32-bit words in the source buffer contain a"
1301: echo " whole number of displayed pixels, *and* for every aligned"
1302: echo " 32-bit word on one scanline all other scanlines have an"
1303: echo " aligned 32-bit word corresponding to the same x coordinate: */"
1304: value="(src_fifo0_may_be_unaligned || (src_bypl & 3))"
1305: if $src_bypl_var; then
1306: echo " const unsigned int src_fifo1_may_be_unaligned = ${value};"
1307: else
1308: echo "#define src_fifo1_may_be_unaligned ${value}"
1309: undef_macros="${undef_macros} src_fifo1_may_be_unaligned"
1310: fi
1311: fi
1312:
1313: echo ""
1.1.1.2 root 1314: echo " /* declare dst_fifo0_may_be_unaligned. this is zero iff all"
1315: echo " aligned 32-bit words in the destination buffer contain a whole"
1316: echo " number of displayed pixels, and at *all times during the"
1317: echo " translation* the visible part of the bit FIFO is guaranteed"
1318: echo " to correspond to an aligned 32-bit word in the image buffer."
1319: echo ""
1320: echo " this is *not* so if any of the following are true:"
1321: echo ""
1322: echo " - the destination bits-per-pixel value is not known at compile"
1323: echo " time. in this case, we can't unroll the translation loop"
1324: echo " for destination pixels, and are forced to shift the FIFO"
1325: echo " after each one."
1326: echo ""
1327: echo " - if src_fifo0_may_be_unaligned is true. in this case, we"
1328: echo " definitely can't guarantee that any initial dst_x will"
1329: echo " correspond to an aligned 32-bit word in the destination buffer."
1330: echo ""
1331: echo " - if the destination image is not packed. in this case, there may"
1332: echo " be undisplayed pixels in the FIFO, which we will need to"
1333: echo " shift out."
1334: echo ""
1335: echo " - if there are 24 bits per destination pixel. in this case,"
1336: echo " a destination pixel may cross a 32-bit boundary."
1337: echo ""
1338: echo " - if a possible initial dst_x doesn't correspond to an aligned"
1339: echo " 32-bit word in the destination buffer. for this last one:"
1.1 root 1340: echo ""
1341: echo " since we require that src_fifo0_may_be_unaligned is zero, we"
1342: echo " know that the initial src_x = (Z * 32) / src_bipp for "
1343: echo " some Z. we also have the initial dst_x = src_x${scale_math}."
1344: echo " the initial destination bit offset will then be:"
1345: echo ""
1346: echo " (dst_skipx + dst_x) * dst_bipp"
1347: echo " = (dst_skipx * dst_bipp) + (dst_x * dst_bipp)"
1348: echo ""
1349: echo " if we additionally require that (dst_skipx * dst_bipp)"
1350: echo " be 32-bit aligned, this reduces things to:"
1351: echo ""
1352: echo " dst_x * dst_bipp"
1353: echo " = (src_x${scale_math}) * dst_bipp"
1354: echo " = (((Z * 32) / src_bipp)${scale_math}) * dst_bipp"
1355: echo ""
1356: echo " which will be a multiple of 32 iff:"
1357: echo ""
1358: echo " ((1 / src_bipp)${scale_math}) * dst_bipp >= 1 and integral"
1.1.1.2 root 1359: echo ""
1360: echo " or, equivalently:"
1361: echo ""
1.1 root 1362: denom="src_bipp"
1363: numer="dst_bipp"
1364: case $scale in
1365: _) ;;
1366: _h_) denom="(${denom} * 2)" ;;
1367: _d_) numer="(${numer} * 2)" ;;
1368: esac
1.1.1.2 root 1369: echo " (${numer} % ${denom}) == 0"
1370: echo " */"
1371: dst_fifo0_may_be_unaligned_var=false
1372: if test ${dst_bipp} = 0; then
1373: value=TRUE
1374: else
1375: value="(src_fifo0_may_be_unaligned || !dst_packed || (dst_bipp == 24) || (dst_bypl % 4) || ((dst_skipx * dst_bipp) % 32) || (${numer} % ${denom}))"
1376: if $src_bypl_var || $dst_bypl_var; then
1377: dst_fifo0_may_be_unaligned_var=true
1378: fi
1379: fi
1380: if $dst_fifo0_may_be_unaligned_var; then
1.1 root 1381: echo " const unsigned int dst_fifo0_may_be_unaligned = ${value};"
1382: else
1383: echo "#define dst_fifo0_may_be_unaligned ${value}"
1384: undef_macros="${undef_macros} dst_fifo0_may_be_unaligned"
1385: fi
1386:
1387: if test $scale = _d_; then
1388: echo ""
1389: echo " /* declare dst_fifo1_may_be_unaligned. this is zero iff all"
1390: echo " 32-bit aligned values in the destination buffer contain a"
1391: echo " whole number of displayed pixels, and for every 32-bit"
1392: echo " aligned value on one scanline all other scanlines have a"
1393: echo " 32-bit aligned value corresponding to the same x coordinate: */"
1394: value="(dst_fifo0_may_be_unaligned || (dst_bypl & 3))"
1395: if $src_bypl_var || $dst_bypl_var; then
1396: echo " const unsigned int dst_fifo1_may_be_unaligned = ${value};"
1397: else
1398: echo "#define dst_fifo1_may_be_unaligned ${value}"
1399: undef_macros="${undef_macros} dst_fifo1_may_be_unaligned"
1400: fi
1401: fi
1402:
1403: echo ""
1404: echo " /* declare src_raw0_end. when treating the source image as"
1405: echo " an array of aligned 32-bit words, this variable holds the"
1406: echo " address of the first word after the real source image."
1407: echo " if the fast, aligned 32-bit word comparison loop passes"
1408: echo " this point, the entire source image has been processed and"
1409: echo " the function terminates: */"
1410: echo " const tme_uint32_t *src_raw0_end;"
1411:
1412: echo ""
1413: echo " /* declare xlat_run. see the comment for the TME_FB_XLAT_RUN"
1414: echo " macro for an explanation of what this variable does: */"
1415: echo " int xlat_run;"
1416:
1417: echo ""
1418: echo " /* this silences gcc -Wuninitialized: */"
1419: echo " src_fifo0_next = 0;"
1420: echo " src_fifo0_bits = 0;"
1421: if test ${scale} = _h_; then
1422: echo " src_fifo1_next = 0;"
1423: echo " src_fifo1_bits = 0;"
1424: fi
1425: echo " dst_fifo0_next = 0;"
1426: echo " dst_fifo0_bits = 0;"
1427: if test ${scale} = _d_; then
1428: echo " dst_fifo1_next = 0;"
1429: echo " dst_fifo1_bits = 0;"
1430: fi
1431:
1432: echo ""
1433: echo " /* initialize src_raw0 and src_raw0_end for the fast aligned 32-bit"
1434: echo " word comparison loop. on entry to (and when continuing) that loop,"
1435: echo " src_raw0 always points to the aligned 32-bit word *before* the"
1436: echo " next word to check. src_raw0_end always points after the last"
1437: echo " word to check."
1438: echo ""
1439: echo " src_raw0 is actually part of the source primary bit FIFO, which"
1440: echo " is good, because when the fast comparison fails on a word, src_raw0"
1441: echo " is already primed and ready to work for that bit FIFO: */"
1442: echo " src_raw0 = ((const tme_uint32_t *) src->tme_fb_connection_buffer) - 1;"
1443: echo " src_raw0_end = (const tme_uint32_t *) (src->tme_fb_connection_buffer + src_bypb_real);"
1444:
1445: echo ""
1446: echo " /* initialize xlat_run to -1. it can never go negative inside the"
1447: echo " pixel translation loop, so if xlat_run stays negative for the"
1448: echo " entire translation, it means that the source image hasn't changed"
1449: echo " since the last translation. this information is returned to the"
1450: echo " caller to hopefully save more work in updating the display: */"
1451: echo " xlat_run = -1;"
1452:
1453: echo ""
1454: echo " /* this is the main translation loop, which contains the fast aligned"
1455: echo " 32-bit word comparison loop, and the pixel translation loop: */"
1456: echo " for (;;) {"
1457:
1458: echo ""
1459: echo " /* this is the fast aligned 32-bit word comparison loop. it"
1460: echo " terminates either when a word fails comparison, or when the"
1461: echo " entire source image has been compared. the if test that"
1462: echo " follows checks for the latter case and breaks the main"
1463: echo " translation loop: */"
1464: echo " for (; (++src_raw0 < src_raw0_end"
1465: echo " && *src_raw0 == *TME_FB_XLAT_SRC_OLD(src_raw0)); );"
1466: echo " if (src_raw0 >= src_raw0_end) {"
1467: echo " break;"
1468: echo " }"
1469:
1470: echo ""
1471: echo " /* calculate the byte offset into the source buffer of the"
1472: echo " 32-bit word that failed comparison: */"
1473: echo " src_off = ((tme_uint8_t *) src_raw0) - src->tme_fb_connection_buffer;"
1474:
1475: echo ""
1476: echo " /* calculate the source y pixel coordinate, and reduce"
1477: echo " src_off from the byte offset into the buffer to the"
1478: echo " byte offset into that scanline: */"
1479: echo " src_y = src_off / src_bypl;"
1480: echo " src_off = src_off % src_bypl;"
1481:
1482: echo ""
1483: echo " /* while translating pixels, we use one or more \"bit FIFOs\","
1484: echo " each composed of one or more 32-bit integers. we load these"
1485: echo " FIFOs 32 bits at a time. */"
1486: echo ""
1487: echo " /* prime the visible part of the source primary bit FIFO: */"
1488: echo " src_fifo0 = *src_raw0;"
1489: echo " *TME_FB_XLAT_SRC_OLD(src_raw0) = src_fifo0;"
1490: echo " src_raw0++;"
1491: echo " src_fifo0 = ((src_order == TME_ENDIAN_BIG)"
1492: echo " ? tme_betoh_u32(src_fifo0)"
1493: echo " : tme_letoh_u32(src_fifo0));"
1494: echo ""
1495: echo " /* if the source primary bit FIFO may be unaligned: */"
1496: echo " if (src_fifo0_may_be_unaligned) {"
1497: echo ""
1498: echo " /* prime the invisible part of the source primary bit FIFO and"
1499: echo " assume that we will not have to shift it to finish: */"
1500: echo " src_fifo0_next = *src_raw0;"
1501: echo " *TME_FB_XLAT_SRC_OLD(src_raw0) = src_fifo0_next;"
1502: echo " src_raw0++;"
1503: echo " src_fifo0_next = ((src_order == TME_ENDIAN_BIG)"
1504: echo " ? tme_betoh_u32(src_fifo0_next)"
1505: echo " : tme_letoh_u32(src_fifo0_next));"
1506: echo " src_fifo0_bits = 0;"
1507: echo ""
1508: echo " /* if there are pixels that need to be skipped, the first 32 bits"
1509: echo " we loaded into the FIFO may have first bits that belong to"
1510: echo " those undisplayed (skipped) pixels. it is *not* possible for"
1511: echo " it to have first bits that belong to the scanline pad; there"
1512: echo " might be pad bits in the *middle* of the first 32 bits, but any"
1513: echo " first bits *must* belong to pixels, displayed or not: */"
1514: echo " if (src_skipx > 0"
1515: echo " && (src_off * 8) < (src_skipx * src_bipp)) {"
1516: echo ""
1517: echo " /* see how many bits we will need to skip: */"
1518: echo " src_fifo0_bits = (src_skipx * src_bipp) - (src_off * 8);"
1519: echo ""
1520: echo " /* if it is more than 31 bits, this is an entire 32 bits of"
1521: echo " undisplayed pixels. just advance: */"
1522: echo " if (src_fifo0_bits > 31) {"
1523: echo " src_raw0--;"
1524: echo " continue;"
1525: echo " }"
1526: echo ""
1527: echo " /* set the source x coordinate to zero: */"
1528: echo " src_x = 0;"
1529: echo " }"
1530: echo ""
1531: echo " /* otherwise, the first 32 bits we load will have first bits for"
1532: echo " a displayable pixel: */"
1533: echo " else {"
1534: echo ""
1535: echo " /* if the source bits per pixel is 24, calculate the number of"
1536: echo " bytes *before* the original src_raw0 of any split pixel, and"
1537: echo " subtract this from src_off, to leave src_off as the byte offset"
1538: echo " into the scanline of the beginning of a pixel: */"
1539: echo " if (src_bipp == 24) {"
1540: echo " src_fifo0_bits = (src_off % 3);"
1541: echo " src_off -= src_fifo0_bits;"
1542: echo ""
1543: echo " /* if this is a split pixel, we need to prime the source primary"
1544: echo " bit FIFO starting with the part *before* the original src_raw0."
1545: echo " we do not have to copy to the old; it passed comparison: */"
1546: echo " if (src_fifo0_bits) {"
1547: echo " src_raw0--;"
1548: echo " src_fifo0_next = src_fifo0;"
1549: echo " src_fifo0 = ((src_order == TME_ENDIAN_BIG)"
1550: echo " ? tme_betoh_u32(*(src_raw0 - 2))"
1551: echo " : tme_letoh_u32(*(src_raw0 - 2)));"
1552: echo " }"
1553: echo " }"
1554: echo ""
1555: echo " /* calculate the source x coordinate: */"
1556: echo " src_x = ((src_off * 8) / src_bipp) - src_skipx;"
1557: echo " }"
1558: echo ""
1559: echo " /* do any shifting to finish priming the source primary FIFO: */"
1560: echo " if (src_fifo0_bits) {"
1561: echo " if (src_order == TME_ENDIAN_BIG) {"
1562: echo " src_fifo0 = (src_fifo0 << src_fifo0_bits) | (src_fifo0_next >> (32 - src_fifo0_bits));"
1563: echo " src_fifo0_next <<= src_fifo0_bits;"
1564: echo " }"
1565: echo " else {"
1566: echo " src_fifo0 = (src_fifo0 >> src_fifo0_bits) | (src_fifo0_next << (32 - src_fifo0_bits));"
1567: echo " src_fifo0_next >>= src_fifo0_bits;"
1568: echo " }"
1569: echo " }"
1570: echo " src_fifo0_bits = 64 - src_fifo0_bits;"
1571: echo " }"
1572: echo ""
1573: echo " /* otherwise, the source primary FIFO is aligned: */"
1574: echo " else {"
1575: echo " src_x = ((src_off * 8) / src_bipp) - src_skipx;"
1576: echo " }"
1577:
1578: if test $scale = _h_; then
1579: echo ""
1580: echo " /* when halving the image, we have a source secondary bit "
1581: echo " FIFO, providing pixel values at the same source x coordinate"
1582: echo " but on the \"other\" line. prime the source secondary"
1583: echo " bit FIFO: */"
1584: echo " if (src_fifo1_may_be_unaligned) {"
1585: echo ""
1586: echo " /* calculate the bit offset into the source buffer of"
1587: echo " this exact same pixel on the other line: */"
1588: echo " src_off = ((src_y ^ 1) * src_bypl * 8) + ((src_skipx + src_x) * src_bipp);"
1589: echo ""
1590: echo " /* calculate how many bits offset from a 32-bit boundary the pixel is: */"
1591: echo " src_fifo1_bits = src_off % 32;"
1592: echo ""
1593: echo " /* set src_raw1: */"
1594: echo " src_raw1 = (const tme_uint32_t *)"
1595: echo " (src->tme_fb_connection_buffer"
1596: echo " + ((src_off - src_fifo1_bits) / 8));"
1597: echo ""
1598: echo " /* actually prime the FIFO by loading the first two words and"
1599: echo " shifting off any offset bits: */"
1600: echo " src_fifo1 = *src_raw1;"
1601: echo " *TME_FB_XLAT_SRC_OLD(src_raw1) = src_fifo1;"
1602: echo " src_raw1++;"
1603: echo " src_fifo1_next = *src_raw1;"
1604: echo " *TME_FB_XLAT_SRC_OLD(src_raw1) = src_fifo1_next;"
1605: echo " src_raw1++;"
1606: echo " if (src_order == TME_ENDIAN_BIG) {"
1607: echo " src_fifo1 = tme_betoh_u32(src_fifo1);"
1608: echo " src_fifo1_next = tme_betoh_u32(src_fifo1_next);"
1609: echo " if (src_fifo1_bits) {"
1610: echo " src_fifo1 = (src_fifo1 << src_fifo1_bits) | (src_fifo1_next >> (32 - src_fifo1_bits));"
1611: echo " src_fifo1_next <<= src_fifo1_bits;"
1612: echo " }"
1613: echo " }"
1614: echo " else {"
1615: echo " src_fifo1 = tme_letoh_u32(src_fifo1);"
1616: echo " src_fifo1_next = tme_letoh_u32(src_fifo1_next);"
1617: echo " if (src_fifo1_bits) {"
1618: echo " src_fifo1 = (src_fifo1 >> src_fifo1_bits) | (src_fifo1_next << (32 - src_fifo1_bits));"
1619: echo " src_fifo1_next >>= src_fifo1_bits;"
1620: echo " }"
1621: echo " }"
1622: echo " src_fifo1_bits = 64 - src_fifo1_bits;"
1623: echo " }"
1624: echo ""
1625: echo " /* otherwise the source secondary FIFO is aligned: */"
1626: echo " else {"
1627: echo " src_raw1 = (const tme_uint32_t *)"
1628: echo " (((tme_uint8_t *) src_raw0)"
1629: echo " + (("
1630: echo " /* if src_y is even, this addend is now src_bypl * 4,"
1631: echo " else if src_y is odd, this addend is now src_bypl * 2: */"
1632: echo " ((src_bypl * 4) >> (src_y & 1))"
1633: echo " /* if src_y is even, this addend is now src_bypl,"
1634: echo " else if src_y is odd, this addend is now -src_bypl: */"
1635: echo " - (src_bypl * 3))"
1636: echo " /* this -4 compensates for src_raw0 already having"
1637: echo " been advanced by one: */"
1638: echo " - 4));"
1639: echo " src_fifo1 = *src_raw1;"
1640: echo " *TME_FB_XLAT_SRC_OLD(src_raw1) = src_fifo1;"
1641: echo " src_raw1++;"
1642: echo " src_fifo1 = ((src_order == TME_ENDIAN_BIG)"
1643: echo " ? tme_betoh_u32(src_fifo1)"
1644: echo " : tme_letoh_u32(src_fifo1));"
1645: echo " }"
1646: fi
1647:
1648: if test $scale != _; then
1649: echo ""
1650: echo " /* calculate the destination coordinates: */"
1651: echo " dst_y = src_y${scale_math};"
1652: echo " dst_x = src_x${scale_math};"
1653: fi
1654:
1655: echo ""
1656: echo " /* prime the destination primary bit FIFO: */"
1657: echo " dst_fifo0 = 0;"
1658: echo " if (dst_fifo0_may_be_unaligned) {"
1659: echo ""
1660: echo " /* calculate the bit offset into the destination buffer of"
1661: echo " the destination pixel: */"
1662: echo " dst_off = (dst_y * dst_bypl * 8) + ((dst_skipx + dst_x) * dst_bipp);"
1663: echo ""
1664: echo " /* calculate the number of bits that will be in the primed FIFO: */"
1665: echo " dst_fifo0_bits = dst_off % 32;"
1666: echo ""
1667: echo " /* set dst_raw0: */"
1668: echo " dst_raw0 = (tme_uint32_t *)"
1669: echo " (dst->tme_fb_connection_buffer"
1670: echo " + ((dst_off - dst_fifo0_bits) / 8));"
1671: echo ""
1672: echo " /* prime the primary destination FIFO: */"
1673: echo " dst_fifo0_next = 0;"
1674: echo " if (dst_fifo0_bits) {"
1675: echo " dst_fifo0_next = (src_order == TME_ENDIAN_BIG"
1676: echo " ? (tme_betoh_u32(*dst_raw0) & (0xffffffffUL << (32 - dst_fifo0_bits)))"
1677: echo " : (tme_letoh_u32(*dst_raw0) & (0xffffffffUL >> (32 - dst_fifo0_bits))));"
1678: echo " }"
1679: echo " }"
1680: echo ""
1681: echo " /* otherwise the destination primary FIFO is aligned: */"
1682: echo " else {"
1683: echo " dst_off = (dst_y * dst_bypl) + (((dst_skipx + dst_x) * dst_bipp) / 8);"
1684: echo " dst_raw0 = (tme_uint32_t *) (dst->tme_fb_connection_buffer + dst_off);"
1685: echo " }"
1686:
1687: if test $scale = _d_; then
1688: echo ""
1689: echo " /* when doubling the image, we have a destination secondary bit "
1690: echo " FIFO, for pixel values at the same source x coordinate"
1691: echo " but on the \"other\" line. prime the destination secondary"
1692: echo " bit FIFO: */"
1693: echo " dst_fifo1 = 0;"
1694: echo " if (dst_fifo1_may_be_unaligned) {"
1695: echo ""
1696: echo " /* calculate the bit offset into the destination buffer of"
1697: echo " the destination pixel: */"
1698: echo " dst_off = ((dst_y + 1) * dst_bypl * 8) + ((dst_skipx + dst_x) * dst_bipp);"
1699: echo ""
1700: echo " /* calculate the number of bits that will be in the primed FIFO: */"
1701: echo " dst_fifo1_bits = dst_off % 32;"
1702: echo ""
1703: echo " /* set dst_raw1: */"
1704: echo " dst_raw1 = (tme_uint32_t *)"
1705: echo " (dst->tme_fb_connection_buffer"
1706: echo " + ((dst_off - dst_fifo1_bits) / 8));"
1707: echo ""
1708: echo " /* prime the primary destination FIFO: */"
1709: echo " dst_fifo1_next = 0;"
1710: echo " if (dst_fifo1_bits) {"
1711: echo " dst_fifo1_next = (src_order == TME_ENDIAN_BIG"
1712: echo " ? (tme_betoh_u32(*dst_raw1) & (0xffffffffUL << (32 - dst_fifo1_bits)))"
1713: echo " : (tme_letoh_u32(*dst_raw1) & (0xffffffffUL >> (32 - dst_fifo1_bits))));"
1714: echo " }"
1715: echo " }"
1716: echo ""
1717: echo " /* otherwise, the destination secondary FIFO is aligned: */"
1718: echo " else {"
1719: echo " dst_raw1 = (tme_uint32_t *)"
1720: echo " (((tme_uint8_t *) dst_raw0)"
1721: echo " + dst_bypl);"
1722: echo " }"
1723: fi
1724:
1725: # we want to unroll the pixel translation loop to read as many
1726: # source pixels as possible out of the source bit FIFOs and
1727: # write as many destination pixels as possible into the
1728: # destination bit FIFOs before shifting them.
1729: #
1730: # it is very common to want to unroll the translation loop a
1731: # different number of times on source and destination pixels,
1732: # so we always unroll the maximum possible, tracking within
1733: # each unrolled iteration the relative unrolled iteration for
1734: # the source and destination bit FIFOs.
1735: #
1736:
1737: # src_unroll and dst_unroll are the number of times we will
1738: # unroll the translation loop on source and destination
1739: # pixels, respectively. assume no unrolling:
1740: #
1741: src_unroll=1
1742: dst_unroll=1
1743:
1744: # src_iter_scale is the number of source pixels read out of a
1745: # source bit FIFO in one unrolled iteration of the translation
1746: # loop. if this function halves the source image, this is
1747: # two, otherwise this is one.
1748: #
1749: # dst_iter_scale is the number of destination pixels written
1750: # to a destination bit FIFO in one unrolled iteration of the
1751: # translation loop. if this function doubles the source
1752: # image, this is two, otherwise this is one.
1753: #
1754: # src_fifo_shift is the number of bits that the source bit
1755: # FIFO(s) must be shifted after all unrolled iterations on
1756: # source pixels. assume no unrolling, so if this function
1757: # halves the source image and src_bipp is less than 24, two
1758: # pixels' bits must be shifted, otherwise one pixel's bits
1759: # must be shifted.
1760: #
1761: # dst_fifo_shift is the number of bits that the destination bit
1762: # FIFO(s) must be shifted after all unrolled iterations on
1763: # destination pixels. we are assuming no unrolling, so if this
1764: # function doubles the source image and dst_bipp is less than
1765: # 24, two pixels' bits must be shifted, otherwise one pixel's
1766: # bits must be shifted:
1767: #
1768: if test $scale = _h_; then
1769: src_iter_scale=2
1770: src_fifo_shift="(src_bipp < 24 ? (src_bipp * 2) : src_bipp)"
1771: else
1772: src_iter_scale=1
1773: src_fifo_shift="src_bipp"
1774: fi
1775: if test $scale = _d_; then
1776: dst_iter_scale=2
1777: dst_fifo_shift="(dst_bipp < 24 ? (dst_bipp * 2) : dst_bipp)"
1778: else
1779: dst_iter_scale=1
1780: dst_fifo_shift="dst_bipp"
1781: fi
1782:
1783: # if src_bipp is known now, see how many times we can unroll the
1784: # translation loop on source pixels:
1785: #
1786: if test ${src_bipp} != 0; then
1787:
1788: # in general, we can unroll once for each pixel in the
1789: # visible part of a source bit FIFO:
1790: #
1791: src_unroll=`expr 32 / ${src_bipp}`
1792:
1793: # if this function halves the source image, we can unroll
1794: # half as many times:
1795: #
1796: src_unroll=`expr ${src_unroll} / ${src_iter_scale}`
1797:
1798: # if we think we can unroll zero times, this means that
1799: # src_bipp is greater than 16 and this function halves the
1800: # source image - the zero is telling us that two whole
1801: # pixels cannot fit in the visible part of a source bit
1802: # FIFO. so we unroll once on source pixels, and shift
1803: # only one pixel's bits after the unrolling (the halving
1804: # code will be shifting one pixel's worth of bits to get
1805: # to the next pixel it has to read):
1806: #
1807: if test ${src_unroll} = 0; then
1808: src_unroll=1
1809: src_fifo_shift=${src_bipp}
1810:
1811: # otherwise, we will be shifting the entire visible part
1812: # of the source bit FIFO(s) after all unrolled iterations:
1813: #
1814: else
1815: src_fifo_shift=32
1816: fi
1817:
1818: echo ""
1819: echo " /* since src_bipp is known at code-generation time, the"
1820: echo " pixel translation loop is unrolled to translate all"
1821: echo " source pixels in the 32-bit visible part of the source"
1822: echo " bit FIFO(s) before shifting."
1823: echo ""
1824: echo " in this case, src_bipp is known to be ${src_bipp}, so "`expr ${src_unroll} \* ${src_iter_scale}`" pixels will"
1825: echo " be read out of the source bit FIFO(s) before shifting, and"
1826: echo " when the source bit FIFO(s) are shifted, they are shifted"
1827: echo " ${src_fifo_shift} bits at a time: */"
1828: fi
1829:
1830: # if dst_bipp is known now, see how many times we can unroll the
1831: # translation loop on destination pixels:
1832: #
1833: if test ${dst_bipp} != 0; then
1834:
1835: # in general, we can unroll once for each pixel in the
1836: # visible part of a destination bit FIFO:
1837: #
1838: dst_unroll=`expr 32 / ${dst_bipp}`
1839:
1840: # if this function doubles the source image, we can unroll
1841: # half as many times:
1842: #
1843: dst_unroll=`expr ${dst_unroll} / ${dst_iter_scale}`
1844:
1845: # if we think we can unroll zero times, this means that
1846: # dst_bipp is greater than 16 and this function doubles the
1847: # source image - the zero is telling us that two whole
1848: # pixels cannot fit in the visible part of a destination bit
1849: # FIFO. so we unroll once on destination pixels, and shift
1850: # only one pixel's bits after the unrolling (the doubling
1851: # code will be shifting one pixel's worth of bits to get
1852: # out the first pixel it has to write):
1853: #
1854: if test ${dst_unroll} = 0; then
1855: dst_unroll=1
1856: dst_fifo_shift=${dst_bipp}
1857:
1858: # otherwise, we will be shifting the entire visible part
1859: # of the source bit FIFO(s) after all unrolled iterations:
1860: #
1861: else
1862: dst_fifo_shift=32
1863: fi
1864:
1865: echo ""
1866: echo " /* since dst_bipp is known at code-generation time, the pixel"
1867: echo " translation loop is unrolled to translate all destination"
1868: echo " pixels in the 32-bit visible part of the destination bit"
1869: echo " FIFO(s) before shifting."
1870: echo ""
1871: echo " in this case, dst_bipp is known to be ${dst_bipp}, so "`expr ${dst_unroll} \* ${dst_iter_scale}`" pixels will"
1872: echo " be written into the destination bit FIFO(s) before shifting,"
1873: echo " and when the destination bit FIFO(s) are shifted, they are"
1874: echo " shifted ${dst_fifo_shift} bits at a time: */"
1875: fi
1876:
1877: # unroll the translation loop the maximum number amount of times:
1878: #
1879: if test `expr ${src_unroll} \> ${dst_unroll}` = 1; then
1880: unroll=${src_unroll}
1881: else
1882: unroll=${dst_unroll}
1883: fi
1884:
1885: echo ""
1886: echo " /* src_unroll = ${src_unroll}, src_iter_scale = ${src_iter_scale}"
1887: echo " dst_unroll = ${dst_unroll}, dst_iter_scale = ${dst_iter_scale} */"
1888: echo " for (xlat_run = TME_FB_XLAT_RUN;"
1889: echo " xlat_run > 0; ) {"
1890: iter=0
1891:
1892: while test `expr ${iter} \< ${unroll}` = 1; do
1893: echo ""
1894: echo " /* iter #${iter} */"
1895: echo ""
1896: iter_next=`expr ${iter} + 1`
1897:
1898: # the number of bits to skip in a source FIFO to get to
1899: # this iteration's pixel:
1900: src_shift=`expr ${iter} % ${src_unroll}`
1901: src_shift='('`expr ${src_shift} \* ${src_iter_scale}`' * src_bipp)'
1902:
1903: echo " /* get a pixel from the source primary FIFO: */"
1904: echo " pixel ="
1905: echo " ((src_fifo0"
1906: echo " >> (src_order == TME_ENDIAN_BIG"
1907: echo " ? (32 - (src_bipp + ${src_shift}))"
1.1.1.2 root 1908: echo " : ${src_shift})));"
1909: indent0=X
1.1 root 1910:
1.1.1.2 root 1911: if test $scale != _h_; then
1.1 root 1912:
1.1.1.2 root 1913: if test "x${src_mask_g}" = x; then
1914: echo ""
1915: echo " /* since source pixels are known at compile time to"
1916: echo " not have subfields, map the source pixel into the"
1917: echo " destination pixel: */"
1918: echo " pixel = dst->tme_fb_connection_map_pixel[pixel & src_mask];"
1919: else
1920: echo ""
1921: echo " /* if the source depth is within the threshold for pixel"
1922: echo " mapping, or if source pixels don't have subfields,"
1923: echo " map the source pixel into the destination pixel: */"
1924: echo " if (src_mask <= TME_FB_XLAT_MAP_INDEX_MASK_MAX"
1925: echo " || src_mask_g == src_mask) {"
1926: echo " pixel = dst->tme_fb_connection_map_pixel[pixel & src_mask];"
1927: echo " }"
1928: echo ""
1929: echo " /* otherwise, we will decompose this source pixel"
1930: echo " and then compose the destination pixel: */"
1931: echo " else {"
1932: echo ""
1933: echo " /* map the pixel subfields into intensities: */"
1934: echo " value_g = TME_FB_XLAT_MAP(pixel, src_mask_g, src_mask_i, src_indexed, src->tme_fb_connection_map_g);"
1935: if test "x${src_class}" != xm; then
1936: echo " value_r = TME_FB_XLAT_MAP(pixel, src_mask_r, src_mask_i, src_indexed, src->tme_fb_connection_map_r);"
1937: echo " value_b = TME_FB_XLAT_MAP(pixel, src_mask_b, src_mask_i, src_indexed, src->tme_fb_connection_map_b);"
1938: fi
1939: indent0=" "
1940: src_mask_i=src_mask_i
1941: src_mask_i_max=TME_FB_XLAT_MAP_INDEX_MASK_MAX
1942: fi
1943:
1944: else
1.1 root 1945:
1946: echo ""
1.1.1.2 root 1947: echo " /* map the pixel subfields into intensities: */"
1948: echo " value_g = TME_FB_XLAT_MAP(pixel, src_mask_g, src_mask_i, src_indexed, src->tme_fb_connection_map_g);"
1949: if test "x${src_class}" != xm; then
1950: echo " value_r = TME_FB_XLAT_MAP(pixel, src_mask_r, src_mask_i, src_indexed, src->tme_fb_connection_map_r);"
1951: echo " value_b = TME_FB_XLAT_MAP(pixel, src_mask_b, src_mask_i, src_indexed, src->tme_fb_connection_map_b);"
1.1 root 1952: fi
1.1.1.2 root 1953:
1954: echo ""
1955: echo " /* get a second pixel, from the source secondary FIFO: */"
1956: echo " pixel ="
1.1 root 1957: echo " ((src_fifo1"
1958: echo " >> (src_order == TME_ENDIAN_BIG"
1959: echo " ? (32 - (src_bipp + ${src_shift}))"
1.1.1.2 root 1960: echo " : ${src_shift})));"
1961:
1962: echo ""
1963: echo " /* map the pixel subfields into intensities and accumulate them: */"
1964: echo " value_g += TME_FB_XLAT_MAP(pixel, src_mask_g, src_mask_i, src_indexed, src->tme_fb_connection_map_g);"
1965: if test "x${src_class}" != xm; then
1966: echo " value_r += TME_FB_XLAT_MAP(pixel, src_mask_r, src_mask_i, src_indexed, src->tme_fb_connection_map_r);"
1967: echo " value_b += TME_FB_XLAT_MAP(pixel, src_mask_b, src_mask_i, src_indexed, src->tme_fb_connection_map_b);"
1968: fi
1.1 root 1969:
1970: echo ""
1971: echo " /* get third and fourth pixels, from the source primary"
1972: echo " FIFO and source secondary FIFO, respectively. if"
1973: echo " src_bipp is 24 or greater, these pixels are not yet"
1974: echo " entirely in the first parts of the FIFOs, so we need"
1975: echo " to shift: */"
1976: echo " if (src_bipp >= 24) {"
1977: echo " TME_FB_XLAT_SHIFT_SRC(src_fifo0_may_be_unaligned,"
1978: echo " src_fifo0,"
1979: echo " src_fifo0_next,"
1980: echo " src_fifo0_bits,"
1981: echo " src_bipp,"
1982: echo " src_raw0,"
1983: echo " src_order);"
1984: echo " TME_FB_XLAT_SHIFT_SRC(src_fifo1_may_be_unaligned,"
1985: echo " src_fifo1,"
1986: echo " src_fifo1_next,"
1987: echo " src_fifo1_bits,"
1988: echo " src_bipp,"
1989: echo " src_raw1,"
1990: echo " src_order);"
1.1.1.2 root 1991: echo " pixel ="
1.1 root 1992: echo " ((src_fifo0"
1993: echo " >> (src_order == TME_ENDIAN_BIG"
1994: echo " ? (32 - (src_bipp + ${src_shift}))"
1.1.1.2 root 1995: echo " : ${src_shift})));"
1996:
1997: echo ""
1998: echo " /* map the pixel subfields into intensities and accumulate them: */"
1999: echo " value_g += TME_FB_XLAT_MAP(pixel, src_mask_g, src_mask_i, src_indexed, src->tme_fb_connection_map_g);"
2000: if test "x${src_class}" != xm; then
2001: echo " value_r += TME_FB_XLAT_MAP(pixel, src_mask_r, src_mask_i, src_indexed, src->tme_fb_connection_map_r);"
2002: echo " value_b += TME_FB_XLAT_MAP(pixel, src_mask_b, src_mask_i, src_indexed, src->tme_fb_connection_map_b);"
1.1 root 2003: fi
1.1.1.2 root 2004: echo ""
2005:
2006: echo " pixel ="
1.1 root 2007: echo " ((src_fifo1"
2008: echo " >> (src_order == TME_ENDIAN_BIG"
2009: echo " ? (32 - (src_bipp + ${src_shift}))"
1.1.1.2 root 2010: echo " : ${src_shift})));"
2011:
2012: echo ""
2013: echo " /* map the pixel subfields into intensities and accumulate them: */"
2014: echo " value_g += TME_FB_XLAT_MAP(pixel, src_mask_g, src_mask_i, src_indexed, src->tme_fb_connection_map_g);"
2015: if test "x${src_class}" != xm; then
2016: echo " value_r += TME_FB_XLAT_MAP(pixel, src_mask_r, src_mask_i, src_indexed, src->tme_fb_connection_map_r);"
2017: echo " value_b += TME_FB_XLAT_MAP(pixel, src_mask_b, src_mask_i, src_indexed, src->tme_fb_connection_map_b);"
2018: fi
1.1 root 2019: echo " }"
2020: echo ""
1.1.1.2 root 2021: echo " /* otherwise, the third and fourth pixels are already in the"
1.1 root 2022: echo " visible parts of the source bit FIFOs; we just have to"
2023: echo " reach over the pixels we already read to get at them: */"
2024: echo " else {"
1.1.1.2 root 2025: echo " pixel ="
1.1 root 2026: echo " ((src_fifo0"
2027: echo " >> (src_order == TME_ENDIAN_BIG"
2028: echo " ? (32 - (src_bipp + (${src_shift} + src_bipp)))"
1.1.1.2 root 2029: echo " : (${src_shift} + src_bipp))));"
2030: echo ""
2031: echo " /* map the pixel subfields into intensities and accumulate them: */"
2032: echo " value_g += TME_FB_XLAT_MAP(pixel, src_mask_g, src_mask_i, src_indexed, src->tme_fb_connection_map_g);"
2033: if test "x${src_class}" != xm; then
2034: echo " value_r += TME_FB_XLAT_MAP(pixel, src_mask_r, src_mask_i, src_indexed, src->tme_fb_connection_map_r);"
2035: echo " value_b += TME_FB_XLAT_MAP(pixel, src_mask_b, src_mask_i, src_indexed, src->tme_fb_connection_map_b);"
1.1 root 2036: fi
1.1.1.2 root 2037: echo ""
2038: echo " pixel ="
1.1 root 2039: echo " ((src_fifo1"
2040: echo " >> (src_order == TME_ENDIAN_BIG"
2041: echo " ? (32 - (src_bipp + (${src_shift} + src_bipp)))"
1.1.1.2 root 2042: echo " : (${src_shift} + src_bipp))));"
2043: echo ""
2044: echo " /* map the pixel subfields into intensities and accumulate them: */"
2045: echo " value_g += TME_FB_XLAT_MAP(pixel, src_mask_g, src_mask_i, src_indexed, src->tme_fb_connection_map_g);"
2046: if test "x${src_class}" != xm; then
2047: echo " value_r += TME_FB_XLAT_MAP(pixel, src_mask_r, src_mask_i, src_indexed, src->tme_fb_connection_map_r);"
2048: echo " value_b += TME_FB_XLAT_MAP(pixel, src_mask_b, src_mask_i, src_indexed, src->tme_fb_connection_map_b);"
2049: fi
1.1 root 2050: echo " }"
1.1.1.2 root 2051: indent0=
2052: src_mask_i='((src_mask_i * 4) + 3)'
2053: src_mask_i_max='(TME_FB_XLAT_MAP_INDEX_MASK_MAX / 4)'
2054: fi
1.1 root 2055:
1.1.1.2 root 2056: # if we may have intensities:
2057: #
2058: if test "X${indent0}" != XX; then
1.1 root 2059: echo ""
1.1.1.2 root 2060: indent1=X
2061: case "x${src_class}" in
2062: xm)
2063: echo "${indent0} /* since the source_class is known as monochrome at code-generation"
2064: echo "${indent0} time, we map the green intensity directly into a pixel. we may have"
2065: echo "${indent0} to scale the intensity to be in the lookup range: */"
2066: echo "${indent0} if (src_mask_i > ${src_mask_i_max}) {"
1.1.1.3 ! root 2067: echo "${indent0} value_g /= TME_FB_XLAT_MAP_LINEAR_SCALE(${src_mask_i}, TME_FB_XLAT_MAP_INDEX_MASK_MAX);"
1.1.1.2 root 2068: echo "${indent0} }"
2069: echo "${indent0} pixel = dst->tme_fb_connection_map_pixel[value_g];"
2070: ;;
2071: x)
2072: echo "${indent0} /* if the source class is monochrome, we map the green intensity"
2073: echo "${indent0} directly into a pixel. we may have to scale the intensity"
2074: echo "${indent0} to be in the lookup range: */"
2075: echo "${indent0} if (src->tme_fb_connection_class == TME_FB_XLAT_CLASS_MONOCHROME) {"
2076: echo "${indent0} if (src_mask_i > ${src_mask_i_max}) {"
1.1.1.3 ! root 2077: echo "${indent0} value_g /= TME_FB_XLAT_MAP_LINEAR_SCALE(${src_mask_i}, TME_FB_XLAT_MAP_INDEX_MASK_MAX);"
1.1.1.2 root 2078: echo "${indent0} }"
2079: echo "${indent0} pixel = dst->tme_fb_connection_map_pixel[value_g];"
2080: echo "${indent0} }"
1.1 root 2081: echo ""
1.1.1.2 root 2082: echo "${indent0} /* otherwise, we have to consider all three intensities: */"
2083: echo "${indent0} else {"
2084: indent1="${indent0} "
2085: ;;
2086: *)
2087: echo "${indent0} /* we have to consider all three intensities: */"
2088: indent1="${indent0}"
2089: esac
2090:
2091: if test "X${indent1}" != "XX"; then
2092: echo ""
2093: echo "${indent1} /* if destination intensities are indexed: */"
2094: echo "${indent1} if (dst_indexed) {"
2095: echo ""
2096: echo "${indent1} /* we may have to scale the intensities to be in the lookup range: */"
2097: echo "${indent1} if (src_mask_i > ${src_mask_i_max}) {"
1.1.1.3 ! root 2098: echo "${indent1} value_g /= TME_FB_XLAT_MAP_LINEAR_SCALE(${src_mask_i}, TME_FB_XLAT_MAP_INDEX_MASK_MAX);"
! 2099: echo "${indent1} value_r /= TME_FB_XLAT_MAP_LINEAR_SCALE(${src_mask_i}, TME_FB_XLAT_MAP_INDEX_MASK_MAX);"
! 2100: echo "${indent1} value_b /= TME_FB_XLAT_MAP_LINEAR_SCALE(${src_mask_i}, TME_FB_XLAT_MAP_INDEX_MASK_MAX);"
1.1.1.2 root 2101: echo "${indent1} }"
2102: echo ""
2103: echo "${indent1} /* form the pixel: */"
2104: echo "${indent1} pixel = _TME_FB_XLAT_MAP_INDEX(value_g, dst_mask_g, dst->tme_fb_connection_map_g);"
2105: echo "${indent1} pixel |= _TME_FB_XLAT_MAP_INDEX(value_r, dst_mask_r, dst->tme_fb_connection_map_r);"
2106: echo "${indent1} pixel |= _TME_FB_XLAT_MAP_INDEX(value_b, dst_mask_b, dst->tme_fb_connection_map_b);"
2107: echo "${indent1} }"
2108: echo ""
2109: echo "${indent1} /* otherwise, destination intensities are linear: */"
2110: echo "${indent1} else {"
2111: echo ""
2112: echo "${indent1} /* form the pixel: */"
2113: echo "${indent1} pixel = _TME_FB_XLAT_MAP_LINEAR(value_g, ${src_mask_i}, dst_mask_g);"
2114: echo "${indent1} pixel |= _TME_FB_XLAT_MAP_LINEAR(value_r, ${src_mask_i}, dst_mask_r);"
2115: echo "${indent1} pixel |= _TME_FB_XLAT_MAP_LINEAR(value_b, ${src_mask_i}, dst_mask_b);"
2116: echo ""
2117: echo "${indent1} /* if destination pixels are indexed: */"
2118: echo "${indent1} if (dst_masks_default) {"
2119: echo "${indent1} pixel = dst->tme_fb_connection_map_pixel[pixel];"
2120: echo "${indent1} }"
2121: echo "${indent1} }"
2122:
2123: if test "X${indent1}" != "X${indent0}"; then
2124: echo "${indent0} }"
2125: fi
2126: if test "X${indent0}" != X; then
2127: echo "${indent0} }"
2128: fi
1.1 root 2129: fi
2130: fi
2131:
2132: echo ""
2133: if test $scale = _h_; then
2134:
2135: echo " /* if we just read the last pixels on these"
2136: echo " source scanlines: */"
2137: if test `expr ${iter_next} % ${src_unroll}` = 0; then
2138: echo " if ((src_x +="
2139: echo " (src_packed"
2140: echo " ? `expr ${src_unroll} \* 2`"
2141: echo " : 2))"
2142: echo " == src_width) {"
2143: else
2144: echo " if (!src_packed"
2145: echo " && (src_x += 2) == src_width) {"
2146: fi
2147: echo ""
2148: echo " /* we need to rapidly shift the source FIFOs"
2149: echo " to skip not only pad bits and undisplayed"
2150: echo " pixels on the next line, but actually the"
2151: echo " *entire* next line."
2152: echo ""
2153: echo " note that this sounds like when we're done,"
2154: echo " the bits at the fronts of the FIFOs will be"
2155: echo " the *first* pixels on the next scanlines."
2156: echo ""
2157: echo " but the bits at the fronts of the FIFOs now"
2158: echo " are the *last* pixels on the current scanlines -"
2159: echo " they haven't been shifted off yet. so when"
2160: echo " we're done, we want one pixel's worth of bits"
2161: echo " in the FIFOs before the first pixel on the"
2162: echo " next scanlines: */"
2163: echo ""
2164: echo " /* calculate the number of bits that we need"
2165: echo " to shift the source primary FIFO, after"
2166: echo " discarding any bits in it now: */"
2167: echo " src_off = ((src_bypl * 8) - (src_width * src_bipp)) + (src_bypl * 8);"
2168: echo " src_off -= (src_fifo0_may_be_unaligned"
2169: echo " ? src_fifo0_bits"
2170: echo " : 32);"
2171: echo ""
2172: echo " /* rapidly advance src_raw0 by the number of"
2173: echo " whole 32-bit words. this will leave it pointing"
2174: echo " to the 32-bit word that has the first bit that"
2175: echo " we want to end up as the first bit in the source"
2176: echo " primary FIFO: */"
2177: echo " src_raw0 += (src_off / 32);"
2178: echo ""
2179: echo " /* reprime the source primary FIFO: */"
2180: echo " src_fifo0 = *src_raw0;"
2181: echo " *TME_FB_XLAT_SRC_OLD(src_raw0) = src_fifo0;"
2182: echo " src_raw0++;"
2183: echo " src_fifo0 = ((src_order == TME_ENDIAN_BIG)"
2184: echo " ? tme_betoh_u32(src_fifo0)"
2185: echo " : tme_letoh_u32(src_fifo0));"
2186: echo ""
2187: echo " /* if the source primary FIFO may be unaligned: */"
2188: echo " if (src_fifo0_may_be_unaligned) {"
2189: echo ""
2190: echo " /* reprime the top half of the FIFO, leaving a"
2191: echo " total of 64 bits in it: */"
2192: echo " src_fifo0_next = *src_raw0;"
2193: echo " *TME_FB_XLAT_SRC_OLD(src_raw0) = src_fifo0_next;"
2194: echo " src_raw0++;"
2195: echo " src_fifo0_next = ((src_order == TME_ENDIAN_BIG)"
2196: echo " ? tme_betoh_u32(src_fifo0_next)"
2197: echo " : tme_letoh_u32(src_fifo0_next));"
2198: echo " src_fifo0_bits = 64;"
2199: echo ""
2200: echo " /* if we have to shift off bits left over"
2201: echo " from rapidly advancing whole 32-bit words: */"
2202: echo " src_off %= 32;"
2203: echo " if (src_off > 0) {"
1.1.1.2 root 2204: echo " TME_FB_XLAT_SHIFT_SRC(TRUE,"
1.1 root 2205: echo " src_fifo0,"
2206: echo " src_fifo0_next,"
2207: echo " src_fifo0_bits,"
2208: echo " src_off,"
2209: echo " src_raw0,"
2210: echo " src_order);"
2211: echo " }"
2212: echo " }"
2213: echo ""
2214: echo " /* otherwise, the source primary FIFO is always aligned: */"
2215: echo " else {"
2216: echo " assert ((src_off % 32) == 0);"
2217: echo " }"
2218: echo ""
2219: echo " /* calculate the number of bits that we need"
2220: echo " to shift the source secondary FIFO, after"
2221: echo " discarding any bits in it now: */"
2222: echo " src_off = ((src_bypl * 8) - (src_width * src_bipp)) + (src_bypl * 8);"
2223: echo " src_off -= (src_fifo1_may_be_unaligned"
2224: echo " ? src_fifo1_bits"
2225: echo " : 32);"
2226: echo ""
2227: echo " /* rapidly advance src_raw1 by the number of"
2228: echo " whole 32-bit words. this will leave it pointing"
2229: echo " to the 32-bit word that has the first bit that"
2230: echo " we want to end up as the first bit in the source"
2231: echo " secondary FIFO: */"
2232: echo " src_raw1 += (src_off / 32);"
2233: echo ""
2234: echo " /* reprime the source secondary FIFO: */"
2235: echo " src_fifo1 = *src_raw1;"
2236: echo " *TME_FB_XLAT_SRC_OLD(src_raw1) = src_fifo1;"
2237: echo " src_raw1++;"
2238: echo " src_fifo1 = ((src_order == TME_ENDIAN_BIG)"
2239: echo " ? tme_betoh_u32(src_fifo1)"
2240: echo " : tme_letoh_u32(src_fifo1));"
2241: echo ""
2242: echo " /* if the source secondary FIFO may be unaligned: */"
2243: echo " if (src_fifo1_may_be_unaligned) {"
2244: echo ""
2245: echo " /* reprime the top half of the FIFO, leaving a"
2246: echo " total of 64 bits in it: */"
2247: echo " src_fifo1_next = *src_raw1;"
2248: echo " *TME_FB_XLAT_SRC_OLD(src_raw1) = src_fifo1_next;"
2249: echo " src_raw1++;"
2250: echo " src_fifo1_next = ((src_order == TME_ENDIAN_BIG)"
2251: echo " ? tme_betoh_u32(src_fifo1_next)"
2252: echo " : tme_letoh_u32(src_fifo1_next));"
2253: echo " src_fifo1_bits = 64;"
2254: echo ""
2255: echo " /* if we have to shift off bits left over"
2256: echo " from rapidly advancing whole 32-bit words: */"
2257: echo " src_off %= 32;"
2258: echo " if (src_off > 0) {"
1.1.1.2 root 2259: echo " TME_FB_XLAT_SHIFT_SRC(TRUE,"
1.1 root 2260: echo " src_fifo1,"
2261: echo " src_fifo1_next,"
2262: echo " src_fifo1_bits,"
2263: echo " src_off,"
2264: echo " src_raw1,"
2265: echo " src_order);"
2266: echo " }"
2267: echo " }"
2268: echo ""
2269: echo " /* otherwise, the source secondary FIFO is always aligned: */"
2270: echo " else {"
2271: echo " assert ((src_off % 32) == 0);"
2272: echo " }"
2273: echo ""
2274: echo " /* we are now on the first pixel of the next scanline: */"
2275: echo " src_x = 0;"
2276: echo " }"
2277: else
2278: echo " /* if the source buffer is not packed, and we just"
2279: echo " read the last pixel on this source scanline: */"
2280: echo " if (!src_packed"
2281: echo " && ++src_x == src_width) {"
2282: echo ""
2283: echo " /* calculate the number of bits between the"
2284: echo " last bit of the last pixel and the first bit"
2285: echo " of the first displayed pixel on the next"
2286: echo " scanline. this is equal to the number of"
2287: echo " pad bits plus bits for undisplayed pixels: */"
2288: echo " src_off = ((src_bypl * 8) - (src_width * src_bipp));"
2289: echo ""
2290: echo " /* while there are bits to shift: */"
2291: echo " for (; src_off > 0; src_off -= TME_MIN(src_off, 32)) {"
2292: echo ""
2293: echo " /* shift the source primary FIFO: */"
2294: echo " TME_FB_XLAT_SHIFT_SRC(src_fifo0_may_be_unaligned,"
2295: echo " src_fifo0,"
2296: echo " src_fifo0_next,"
2297: echo " src_fifo0_bits,"
2298: echo " TME_MIN(src_off, 32),"
2299: echo " src_raw0,"
2300: echo " src_order);"
2301: echo " }"
2302: echo ""
2303: echo " /* we are now on the first pixel of the next scanline: */"
2304: echo " src_x = 0;"
2305: echo " }"
2306: fi
2307:
2308: if test `expr ${iter_next} % ${src_unroll}` = 0; then
1.1.1.2 root 2309:
2310: echo ""
2311: if test "${src_fifo_shift}" = 32; then
2312: echo " /* we've just translated another 32-bit word of the"
2313: echo " source image, so decrement xlat_run: */"
2314: echo " xlat_run--;"
2315: else
2316: echo " /* if we've just finished translating another 32-bit"
2317: echo " word of the source image, decrement xlat_run: */"
2318: echo " if (src_fifo0_bits <= 32 + ${src_fifo_shift}) {"
2319: echo " xlat_run--;"
2320: echo " }"
2321: fi
1.1 root 2322: echo ""
2323: echo " /* shift the source primary FIFO: */"
2324: echo " TME_FB_XLAT_SHIFT_SRC(src_fifo0_may_be_unaligned,"
2325: echo " src_fifo0,"
2326: echo " src_fifo0_next,"
2327: echo " src_fifo0_bits,"
2328: echo " ${src_fifo_shift},"
2329: echo " src_raw0,"
2330: echo " src_order);"
2331: if test $scale = _h_; then
2332: echo ""
2333: echo " /* shift the source secondary FIFO: */"
2334: echo " TME_FB_XLAT_SHIFT_SRC(src_fifo1_may_be_unaligned,"
2335: echo " src_fifo1,"
2336: echo " src_fifo1_next,"
2337: echo " src_fifo1_bits,"
2338: echo " ${src_fifo_shift},"
2339: echo " src_raw1,"
2340: echo " src_order);"
2341: fi
2342: fi
2343:
2344: # the number of bits to skip in a destination FIFO to get to
2345: # this iteration's pixel:
2346: dst_shift=`expr ${iter} % ${dst_unroll}`
2347: dst_shift='('`expr ${dst_shift} \* ${dst_iter_scale}`' * dst_bipp)'
2348:
2349: echo ""
2350: echo " /* put the pixel into the destination primary FIFO: */"
2351: echo " dst_fifo0 |="
2352: echo " (pixel"
2353: echo " << (dst_order == TME_ENDIAN_BIG"
2354: echo " ? ((32 - dst_bipp) - ${dst_shift})"
2355: echo " : ${dst_shift}));"
2356:
2357: if test $scale = _d_; then
2358:
2359: echo ""
2360: echo " /* put the pixel into the destination secondary FIFO: */"
2361: echo " dst_fifo1 |="
2362: echo " (pixel"
2363: echo " << (dst_order == TME_ENDIAN_BIG"
2364: echo " ? ((32 - dst_bipp) - ${dst_shift})"
2365: echo " : ${dst_shift}));"
2366:
2367: echo ""
1.1.1.2 root 2368: if test `expr ${dst_bipp} \>= 24` = 1; then
2369: echo " /* put the pixel into both FIFOs again. in"
2370: echo " this case, dst_bipp is known to be ${dst_bipp},"
2371: echo " meaning the FIFOs cannot entirely take these"
2372: echo " further pixels, so we need to shift the FIFOs: */"
2373: indent0=""
2374: indent1=X
2375: elif test ${dst_bipp} = 0; then
2376: echo " /* put the pixel into both FIFOs again. if"
2377: echo " dst_bipp is 24 or greater, the FIFOs can"
2378: echo " not entirely take these further pixels,"
2379: echo " so we need to shift the FIFOs: */"
2380: echo " if (dst_bipp >= 24) {"
2381: indent0=" "
2382: indent1=" "
2383: else
2384: echo " /* put the pixel into both FIFOs again. in"
2385: echo " this case, dst_bipp is known to be ${dst_bipp},"
2386: echo " meaning the FIFOs can take these further pixels"
2387: echo " without shifting the FIFOs, as long as we shift"
2388: echo " the pixels one pixel further: */"
2389: indent0=X
2390: indent1=""
2391: fi
2392: if test "X${indent0}" != "XX"; then
2393: echo "${indent0} TME_FB_XLAT_SHIFT_DST(dst_fifo0_may_be_unaligned,"
2394: echo "${indent0} dst_fifo0,"
2395: echo "${indent0} dst_fifo0_next,"
2396: echo "${indent0} dst_fifo0_bits,"
2397: echo "${indent0} dst_bipp,"
2398: echo "${indent0} dst_raw0,"
2399: echo "${indent0} dst_order);"
2400: echo "${indent0} TME_FB_XLAT_SHIFT_DST(dst_fifo1_may_be_unaligned,"
2401: echo "${indent0} dst_fifo1,"
2402: echo "${indent0} dst_fifo1_next,"
2403: echo "${indent0} dst_fifo1_bits,"
2404: echo "${indent0} dst_bipp,"
2405: echo "${indent0} dst_raw1,"
2406: echo "${indent0} dst_order);"
2407: echo ""
2408: echo "${indent0} /* now that we've shifted by dst_bipp, we can"
2409: echo "${indent0} put the further pixels exactly where the"
2410: echo "${indent0} first pixels went in the FIFOs: */"
2411: echo "${indent0} dst_fifo0 |="
2412: echo "${indent0} (pixel"
2413: echo "${indent0} << (dst_order == TME_ENDIAN_BIG"
2414: echo "${indent0} ? ((32 - dst_bipp) - ${dst_shift})"
2415: echo "${indent0} : ${dst_shift}));"
2416: echo "${indent0} dst_fifo1 |="
2417: echo "${indent0} (pixel"
2418: echo "${indent0} << (dst_order == TME_ENDIAN_BIG"
2419: echo "${indent0} ? ((32 - dst_bipp) - ${dst_shift})"
2420: echo "${indent0} : ${dst_shift}));"
2421: fi
2422: if test ${dst_bipp} = 0; then
2423: echo " }"
2424: echo ""
2425: echo " /* otherwise, the FIFOs can take these further pixels,"
2426: echo " as long as we shift the pixels one pixel further: */"
2427: echo " else {"
2428: fi
2429: if test "X${indent1}" != "XX"; then
2430: echo "${indent1} dst_fifo0 |="
2431: echo "${indent1} (pixel"
2432: echo "${indent1} << (dst_order == TME_ENDIAN_BIG"
2433: echo "${indent1} ? ((32 - dst_bipp) - (${dst_shift} + dst_bipp))"
2434: echo "${indent1} : (${dst_shift} + dst_bipp)));"
2435: echo "${indent1} dst_fifo1 |="
2436: echo "${indent1} (pixel"
2437: echo "${indent1} << (dst_order == TME_ENDIAN_BIG"
2438: echo "${indent1} ? ((32 - dst_bipp) - (${dst_shift} + dst_bipp))"
2439: echo "${indent1} : (${dst_shift} + dst_bipp)));"
2440: fi
2441: if test ${dst_bipp} = 0; then
2442: echo " }"
2443: fi
1.1 root 2444: fi
2445:
2446: echo ""
2447: echo " /* if the destination buffer is not packed, and we just"
2448: echo " wrote the last pixel on this destination scanline: */"
2449: if test $scale = _d_; then value=2; else value=1; fi
2450: echo " if (!dst_packed"
2451: echo " && (dst_x += ${value}) == dst_width) {"
2452: echo ""
2453: echo " /* calculate the number of bits between the"
2454: echo " last bit of the last pixel and the first bit"
2455: echo " of the first displayed pixel on the next"
2456: echo " scanline. this is equal to the number of"
2457: echo " pad bits plus bits for undisplayed pixels: */"
2458: echo " dst_off = ((dst_bypl * 8) - (dst_width * dst_bipp));"
2459: echo ""
2460: echo " /* while there are bits to shift: */"
2461: echo " for (; dst_off > 0; dst_off -= TME_MIN(dst_off, 32)) {"
2462: echo ""
2463: echo " /* shift the destination primary FIFO: */"
2464: echo " TME_FB_XLAT_SHIFT_DST(dst_fifo0_may_be_unaligned,"
2465: echo " dst_fifo0,"
2466: echo " dst_fifo0_next,"
2467: echo " dst_fifo0_bits,"
2468: echo " TME_MIN(dst_off, 32),"
2469: echo " dst_raw0,"
2470: echo " dst_order);"
2471: if test $scale = _d_; then
2472: echo ""
2473: echo " /* shift the destination secondary FIFO: */"
2474: echo " TME_FB_XLAT_SHIFT_DST(dst_fifo1_may_be_unaligned,"
2475: echo " dst_fifo1,"
2476: echo " dst_fifo1_next,"
2477: echo " dst_fifo1_bits,"
2478: echo " TME_MIN(dst_off, 32),"
2479: echo " dst_raw1,"
2480: echo " dst_order);"
2481: fi
2482: echo " }"
2483: echo ""
2484: echo " /* we are now on the first pixel of the next scanline: */"
2485: echo " dst_x = 0;"
2486: echo " }"
2487:
2488: if test `expr ${iter_next} % ${dst_unroll}` = 0; then
2489: echo ""
2490: echo " /* shift the destination primary FIFO: */"
2491: echo " TME_FB_XLAT_SHIFT_DST(dst_fifo0_may_be_unaligned,"
2492: echo " dst_fifo0,"
2493: echo " dst_fifo0_next,"
2494: echo " dst_fifo0_bits,"
2495: echo " ${dst_fifo_shift},"
2496: echo " dst_raw0,"
2497: echo " dst_order);"
2498: if test $scale = _d_; then
2499: echo ""
2500: echo " /* shift the destination secondary FIFO: */"
2501: echo " TME_FB_XLAT_SHIFT_DST(dst_fifo1_may_be_unaligned,"
2502: echo " dst_fifo1,"
2503: echo " dst_fifo1_next,"
2504: echo " dst_fifo1_bits,"
2505: echo " ${dst_fifo_shift},"
2506: echo " dst_raw1,"
2507: echo " dst_order);"
2508: fi
2509: fi
2510:
2511: iter=${iter_next}
2512: done
2513: echo ""
2514: echo " }"
2515:
2516: if test `expr ${iter} % ${dst_unroll}` != 0; then
2517: echo "$PROG internal error - the last iter did not shift the destination FIFOs ($iter and $dst_unroll)" 1>&2
2518: exit 1
2519: fi
2520:
2521: echo ""
2522: echo " /* if the destination FIFOs may be unaligned, there"
2523: echo " may be bits left in the FIFO that we need to flush: */"
2524: echo " if (dst_fifo0_may_be_unaligned"
2525: echo " && dst_fifo0_bits > 0) {"
2526: echo " dst_fifo0 = *dst_raw0;"
2527: echo " if (dst_order == TME_ENDIAN_BIG) {"
2528: echo " dst_fifo0_next |= (tme_betoh_u32(dst_fifo0) & (0xffffffff >> dst_fifo0_bits));"
2529: echo " dst_fifo0_next = tme_htobe_u32(dst_fifo0_next);"
2530: echo " }"
2531: echo " else {"
2532: echo " dst_fifo0_next |= (tme_letoh_u32(dst_fifo0) & (0xffffffff << dst_fifo0_bits));"
2533: echo " dst_fifo0_next = tme_htole_u32(dst_fifo0_next);"
2534: echo " }"
2535: echo " *dst_raw0 = dst_fifo0;"
2536: echo " }"
2537: if test $scale = _d_; then
2538: echo " if (dst_fifo1_may_be_unaligned"
2539: echo " && dst_fifo1_bits > 0) {"
2540: echo " dst_fifo1 = *dst_raw1;"
2541: echo " if (dst_order == TME_ENDIAN_BIG) {"
2542: echo " dst_fifo1_next |= (tme_betoh_u32(dst_fifo1) & (0xffffffff >> dst_fifo1_bits));"
2543: echo " dst_fifo1_next = tme_htobe_u32(dst_fifo1_next);"
2544: echo " }"
2545: echo " else {"
2546: echo " dst_fifo1_next |= (tme_letoh_u32(dst_fifo1) & (0xffffffff << dst_fifo1_bits));"
2547: echo " dst_fifo1_next = tme_htole_u32(dst_fifo1_next);"
2548: echo " }"
2549: echo " *dst_raw1 = dst_fifo1;"
2550: echo " }"
2551: fi
2552:
2553: echo ""
2554: echo " /* loop back to compare more 32-bit words: */"
2555: echo " src_raw0--;"
2556: echo " }"
2557:
2558: echo ""
2559: echo " /* return nonzero iff we did some translating: */"
2560: echo " return (xlat_run >= 0);"
2561:
2562: echo ""
2563: for macro in ${undef_macros}; do
2564: echo "#undef ${macro}"
2565: done
2566: echo "}"
2567:
2568: done
2569: done
2570:
2571: echo ""
2572: echo "/* the xlat function array: */"
2573: echo "static const struct tme_fb_xlat tme_fb_xlats[] = {$xlat_array
2574: };"
2575:
2576: # done:
2577: exit 0
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.