<font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><div>Hi all,</div><div><br></div><div>Please pardon the rather lengthy question.</div><div><br></div><div>I&#39;ve got a question on how to properly handle a case where the device memory </div>
<div>endian-ness is different from the CPU endianness.</div><div><br></div><div>A little bit of back-ground:</div><div><br></div><div>The CPU being arm-based is little-endian.</div><div>The Display peripheral is:</div><div>
<br></div><div>1. In big-endian format.</div><div>2. Configured to operate in 4bpp grayscale mode.</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>The pixel order (according to cpu on a 32 bit word boundary) is:</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>p0p1p2p3p4p5p6p7 -&gt;</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>MSByte: p6p7</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>p4p5</div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>p2p3</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>LSByte:<span class="Apple-tab-span" style="white-space:pre">        </span>p1p0</div>
<div><br></div><div>To handle this setup, I have made the following mods to X and pixman:</div><div><br></div><div>1.Modified IMAGE_BYTE_ORDER and BITMAP_BIT_ORDER in servermd.h to MSByte</div><div>2. Added a format in pixman</div>
<div><br></div><div>This works in most cases, but the memcpy fbBlt causes issues where the dst </div><div>(when writing to the FB) and src (when reading from the FB) are not word</div><div>aligned.</div><div><br></div><div>
I&#39;ve highlighted the 4 alignment cases of writes to the FB:</div><div><br></div><div>LEGEND:</div><div>[nm]: pixel numbers</div><div>src(alignment): src buffer and its alignment - image to be copied</div><div>dst-n(alignment): dst address with a -n offset to aligning it to word boundary</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>and contents after memcpy(src, dst, 8)</div><div>disp: How the pixels are displayed on the screen</div><div><br></div><div><br></div><div>OFFSET 1</div><div>
--------</div><div><br></div><div>what we have:</div><div>                    |               |</div><div>src(0):             [67][45][23][01][ef][cd][ab][89]</div><div>                |               |               |          </div>
<div>dst-1(0):       [..][67][45][23][01][ef][cd][ab][89][..][..][..]</div><div>disp:           [23][45][67][..][ab][cd][ef][01][..][..][..][89]</div><div><br></div><div>what we want:</div><div><br></div><div>disp:           [..][01][23][45][67][89][ab][cd][ef][..][..][..]</div>
<div>dst-1(0)        [45][23][01][..][cd][ab][89][67][..][..][..][ef]</div><div>src(0):             [67][45][23][01][ef][cd][ab][89]</div><div><br></div><div><br></div><div>OFFSET 2</div><div>--------</div><div>what we have:</div>
<div>                        |               |</div><div>src(0):                 [67][45][23][01][ef][cd][ab][89]</div><div>                |               |               |          </div><div>dst-2(0):       [..][..][67][45][23][01][ef][cd][ab][89][..][..]</div>
<div>disp:           [45][67][..][..][cd][ef][01][23][..][..][89][ab]</div><div><br></div><div>what we want:</div><div><br></div><div>disp:           [..][..][01][23][45][67][89][ab][cd][ef][..][..]</div><div>dst-2(0)        [23][01][..][..][ab][89][67][45][..][..][ef][cd]</div>
<div>src(0):                 [67][45][23][01][ef][cd][ab][89]</div><div><br></div><div><br></div><div>OFFSET 3</div><div>--------</div><div>what we have:</div><div>                        |               |</div><div>src(0):                 [67][45][23][01][ef][cd][ab][89]</div>
<div>                |               |               |          </div><div>dst-3(0):       [..][..][..][67][45][23][01][ef][cd][ab][89][..]</div><div>disp:           [67][..][..][..][ef][01][23][45][..][89][ab][cd]</div><div>
<br></div><div>what we want:</div><div><br></div><div>disp:           [..][..][..][01][23][45][67][89][ab][cd][ef][..]</div><div>dst-3(0)        [01][..][..][..][89][67][45][23][..][ef][cd][ab]</div><div>src(0):                 [67][45][23][01][ef][cd][ab][89]</div>
<div><br></div><div><br></div><div>I&#39;ve tested this out by writing my own memcpy that writes the bytes in the</div><div>expected order. But unfortunately this works when writing to the screen.</div><div>When reading from the screen (I think scrolling does this), the data is all</div>
<div>garbled because the memcpy is not symmetrical.</div><div><br></div><div>What is the best way to handle this particular configuration? I&#39;ve come across</div><div>references to shadow frame buffers. Is that the right approach to it?</div>
<div><br></div><div>Thanks in advance,</div><div>D</div><div><br></div></font>