FS#7654 - LCD garbled top two lines.

Attached to Project: Rockbox
Opened by Jonathan Backer (jrbil) - Saturday, 25 August 2007, 06:20 GMT
Last edited by Michael Sevakis (MikeS) - Wednesday, 05 September 2007, 08:32 GMT
Task Type Patches
Category LCD
Status Closed
Assigned To No-one
Operating System Sansa e200
Severity Low
Priority Normal
Reported Version Daily build (which?)
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


Original code had the DMA controller writing two extra lines. When data was transferred to the GRAM on the LCD controller it wrapped around with the extra two lines of data (from outside of the allocated framebuffer). Hence the top two lines were garbled.

However, just changing the 0xde (222) to 0xdc (220) didn't entirely fix the problem. The top two lines were now blank instead of randomly changing. By offseting at least two lines lower

lcd_write_reg(R_RAM_ADDR_SET, (y << 2)+175) where y >= 2

the problem goes away. But then everything is offset by y lines.

So I worked around by filling in the GRAM from the bottom up.

lcd_write_reg(R_ENTRY_MODE, 0x6000);
lcd_write_reg(R_RAM_ADDR_SET, (219 << 2)+175)

The image was now flipped. So I flipped it back by changing R_DRV_OUTPUT_CONTROL_NORMAL.

It's a workaround, but without knowing exactly that all the LCD_REG_? do (no docs), it the best that I can do.

To use this patch, you must build a bootloader and install it as well (sansapatch -a new_bootloader).

It also clears up the garbled lines when you load the original firmware. To my knowledge, it should work on older e200s, but it has not been tested.
   patch (1.6 KiB)
This task depends upon

Closed by  Michael Sevakis (MikeS)
Wednesday, 05 September 2007, 08:32 GMT
Reason for closing:  Fixed
Additional comments about closing:  Committed fix better and compatible with older models.
Comment by Michael Sevakis (MikeS) - Saturday, 25 August 2007, 11:39 GMT
There is a vertical blanking interval of two lines as is set up currently. Removing them will, I believe, increase the refresh rate (not sure if that's so bad). The LCD driver chip is also supposed to match that and has setup in the registers. I'm pretty sure there would be a way without reversing the write direction or using an offset. If this one works on older models, I suppose this is far a more genuine fix than the line copying.

One problem with removing that interval is there'd be no blanking for synchronized display updates if we ever do that.
Comment by Jonathan Backer (jrbil) - Saturday, 25 August 2007, 17:00 GMT
I thought that the blank lines (back porch) was part of the problem, but it's not. Current the the front porch is set to default, which makes the BP+FP=16 given BP. Increasing the BP does not affect how many lines are blank.

The patch does not change the BP or FP. It just draws from the bottom up, perhaps sidestepping synchronization issues (writing to the GRAM as the display is refreshed? I'm not sure why it works). All the offset does is tell it to draw from the bottom right instead of the top right.
Comment by Michael Sevakis (MikeS) - Monday, 27 August 2007, 00:54 GMT
I'm going to have a look at this on my model and I'll commit it if I have no problems. If anyone gets to that first, feel free.
Comment by Michael Sevakis (MikeS) - Wednesday, 29 August 2007, 06:55 GMT
Just tried this and the image is flipped along the horizontal axis (vertical mirror) though it doesn't introduce any other artifacts.
Comment by Michael Sevakis (MikeS) - Wednesday, 29 August 2007, 06:59 GMT
I might have mentioned to feel free to get a register dump of the LCD controller registers (any of the SoC ones) _before_ the bootloader changes the controller settings. Would be a nice comparison.
Comment by Jonathan Backer (jrbil) - Wednesday, 29 August 2007, 15:31 GMT
I'm just packing for holidays. I'll be back in a week and look into it then. Thanks for testing it.
Comment by Jesse Lockwood (JL) - Tuesday, 04 September 2007, 11:29 GMT
Hello I made a patch that fixed this for me. see if it works for you  FS#7692 .
Some one posted that it does not seem to be a patch file. but I followed the directions to make one.
Let me know if i need to remake the patch file.
I did "svn diff firmware/target/arm/sandisk/sansa-e200/lcd-e200.c" is this wrong?
Thanks Jesse
Comment by Jonathan Backer (jrbil) - Wednesday, 05 September 2007, 01:12 GMT
Checked out Jesse's patch. Looks good. Added my 2 cents, but not really necessary (think it's closer to what the code should be).