Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing 'Regal' WaveForm update mode support on Carta E-ink screens (PW2) #550

Closed
bugportal opened this issue Apr 7, 2014 · 44 comments
Closed

Comments

@bugportal
Copy link

The rendering effect of Koreader on KPW2 seems different from that of KPW1. In KPW1, the rendering effect is good while in KPW2, 2 or 3 pages partial refresh after one full screen fresh, there remains a lot of e-ink in the screen. As can be seen from the figures attached, in KPW1, the blank region (upper part) is as white as expected, but in KPW2 the blank region (below part) seems contain a lot of "boundary" ink of the characters from previous pages. Such phenomenon is more obvious for the screen regions which is changing from text to images.

kpw2
kpw1

One of the developer told me that it may be because the default waveform setting is incorrect. He suggested changing line 26 in frontend/ui/uimanager.lua into:

default_waveform_mode = 8; -- REAGL waveform

However, such change disables the full refresh. Could any developer who owns a KPW2 help to solve this problem?

@houqp
Copy link
Member

houqp commented Apr 16, 2014

Just to make sure, the full refresh has the same render effect right?

@NiLuJe
Copy link
Member

NiLuJe commented Apr 16, 2014

AFAICT, that's just the usual difference between the Pearl & Carta screens. The PW2 (Carta) ghosts very differently. It does appear to leave a bit more ghosting around, but on the other hand, it does almost no (much more annoying, IMHO) reverse ghosting when said ghosting 'eats' into black text on a new page.

As usual, YMMV, because of the usual prod/QA variances of the eInk tech. (And the fact that I personally always had mostly not-that-great Viz/Pearl screens, while the Carta on my PW2 is very good).

(I'm talking about the 'no-black-flash' refresh mode here [can't remember the constants that corresponds to for the eInk driver], the situation with full refreshes is totally different (and again, much better on the Carta than Viz/Pearl), and Kobo's weird gray (actually, checkered black) flash on their latest device (Aura?) is another beast entirely).

@houqp
Copy link
Member

houqp commented Apr 16, 2014

@NiLuJe , OK, that's interesting. By 'black-flash' refresh mode, you mean full refresh right?

@bugportal , do you get the same render result with official reader?

@NiLuJe
Copy link
Member

NiLuJe commented Apr 16, 2014

@houqp : Yep!

@houqp
Copy link
Member

houqp commented Apr 17, 2014

@NiLuJe , i am just being too lazy to search the web since you are the expert here :P Did Amazon release the driver code for PW2?

@NiLuJe
Copy link
Member

NiLuJe commented Apr 17, 2014

They've released the source packages, and the Kernel's in there, but they're notorious for leaving stuff out of those, and I haven't checked how complete the latest source releases were in that regard, sorry ;).

@houqp
Copy link
Member

houqp commented Apr 18, 2014

cool, I will take a look at the kernel source when I have time :)

@bugportal
Copy link
Author

@houqp : I think the full refresh of Koreder is OK. It do clear all the ghost and leave a brand new page rendering. It appears that for PDF files, the official reader "black-flash" every time when turning to a new page or movement in "zoom in" mode. While for MOBI files, it usually wait around 12 pages to the next "black-flash", although there may be other situations this number varies. The rendering effect of the official reader is great, when compared to the current Koreader on PW2.
@NiLuJe : I don't think this imperfect rendering is related to the quality of the screen. With the official reader, the rendering effect is OK. One of my friend who also owns a PW2 reported the same problem as mine.
I agree with you that PW2 does appear to leave a bit more ghosting around when in "no-black-flash" mode, at least that is what it appears to be when using the official reader for MOBI files.

@chrox chrox changed the title wrong rendering mode for Kindle Paperwhite 2? better rendering mode for Kindle Paperwhite 2? May 2, 2014
@chrox chrox changed the title better rendering mode for Kindle Paperwhite 2? better rendering mode for Carta E-ink screen? Jul 2, 2014
@chrox chrox added question and removed enhancement labels Jul 2, 2014
@NiLuJe
Copy link
Member

NiLuJe commented Jul 4, 2014

FWIW, nothing weird jumped out at me when I checked out KOReader on a PW2 for #519 ;).

@chrox
Copy link
Member

chrox commented Jul 4, 2014

So we will close it.

@chrox chrox closed this as completed Jul 4, 2014
@NiLuJe
Copy link
Member

NiLuJe commented Jul 4, 2014

Yep, I mostly think this boils down to how CRe/MuPDF use FT, which I mostly gave up on trying to understand (and make behave like I actually prefer to...).

To expand a bit: mostly how fonts are hinted. I can't figure out what CRe does, but it's mostly 'fuzzier' than it should, which makes ghosting worse with no black flash.

@NiLuJe
Copy link
Member

NiLuJe commented Jul 5, 2014

Okay, I might have been a bit hasty...

We do seem to refresh slower than the stock reader, and that leads to a slightly more pronounced ghosting effect...

I'll see if I can dig up something w/ strace, but it's going to take a while, I have to build a strace against the correct kernel to get meaningful stuff...

@NiLuJe NiLuJe reopened this Jul 5, 2014
@NiLuJe
Copy link
Member

NiLuJe commented Jul 5, 2014

Ugh.

This is with

strace -fitv -e trace=ioctl

Built against a stock kernel, because I'm lazy and I'm not even sure it'd be that helpful to build against Amazon's anyway.

So, KOReader page turns:

[pid  5986] 19:56:38 [4027bd4c] ioctl(3, 0x4048462e, 0x40f88768) = 0
[pid  5986] 19:56:39 [4027bd4c] ioctl(3, 0x4048462e, 0x40f8a538) = 0
[pid  5986] 19:56:53 [4027bd4c] ioctl(3, 0x4048462e, 0x40fa0458) = 0
[pid  5986] 19:56:57 [4027bd4c] ioctl(3, 0x4048462e, 0x40fb4c08) = 0
[pid  5986] 19:56:59 [4027bd4c] ioctl(3, 0x4048462e, 0x40fc71f8) = 0
[pid  5986] 19:57:01 [4027bd4c] ioctl(3, 0x4048462e, 0x40fe8e68) = 0
[pid  5986] 19:57:03 [4027bd4c] ioctl(3, 0x4048462e, 0x40991258) = 0
[pid  5986] 19:57:04 [4027bd4c] ioctl(3, 0x4048462e, 0x408bca28) = 0

Stock KF8 reader page turns (by attaching to awesome, fd 18 is indeed /dev/fb0)

[pid  3421] 20:02:00 [40651d4c] ioctl(18, 0xc008462f, 0x4007aaa4) = 0
[pid  3421] 20:02:00 [40651d4c] ioctl(18, 0x4048462e, 0x4007ac1c) = 0
[pid  3421] 20:02:00 [40651d4c] ioctl(18, 0xc008462f, 0x4007ac34) = 448
[pid  3421] 20:02:03 [40651d4c] ioctl(18, 0xc008462f, 0x4007aaa4) = 0
[pid  3421] 20:02:03 [40651d4c] ioctl(18, 0x4048462e, 0x4007ac1c) = 0
[pid  3421] 20:02:03 [40651d4c] ioctl(18, 0xc008462f, 0x4007ac34) = 447
[pid  3421] 20:02:05 [40651d4c] ioctl(18, 0xc008462f, 0x4007aaa4) = 0
[pid  3421] 20:02:05 [40651d4c] ioctl(18, 0x4048462e, 0x4007ac1c) = 0
[pid  3421] 20:02:05 [40651d4c] ioctl(18, 0xc008462f, 0x4007ac34) = 448
[pid  3421] 20:02:08 [40651d4c] ioctl(18, 0xc008462f, 0x4007aaa4) = 0
[pid  3421] 20:02:08 [40651d4c] ioctl(18, 0x4048462e, 0x4007ac1c) = 0
[pid  3421] 20:02:08 [40651d4c] ioctl(18, 0xc008462f, 0x4007ac34) = 448

So, three calls per refresh, they do something more. Yay.

I'll check the Kernel just for kicks, but this is mostly way, way over my head, so, good luck :D.

If someone wants to go the extra mile, maybe going in with gdb to inspect those addresses might be helpful to decode the struct, but, err, good luck :D.

@NiLuJe
Copy link
Member

NiLuJe commented Jul 5, 2014

Yep, there's new stuff in the mxcfb.h header.

Among a lot of other things:

#define WAVEFORM_MODE_REAGL     0x8 /* Ghost compensation waveform */
#define WAVEFORM_MODE_REAGLD    0x9     /* Ghost compensation waveform with dithering */

woot? That 'nearly' matches the 'regal waveform tech' PR spiel.


TL;DR: We can probably do better, but this is way over my head.

@NiLuJe
Copy link
Member

NiLuJe commented Jul 5, 2014

With a smarter* strace build:

KOReader:

[pid  8388] 22:30:34 [4027cd4c] ioctl(3, MXCFB_SEND_UPDATE, 0x40f4c4e8) = 0
[pid  8388] 22:30:35 [4027cd4c] ioctl(3, MXCFB_SEND_UPDATE, 0x40f4fa18) = 0
[pid  8388] 22:30:37 [4027cd4c] ioctl(3, MXCFB_SEND_UPDATE, 0x40f6d890) = 0
[pid  8388] 22:30:41 [4027cd4c] ioctl(3, MXCFB_SEND_UPDATE, 0x40f81850) = 0
[pid  8388] 22:30:45 [4027cd4c] ioctl(3, MXCFB_SEND_UPDATE, 0x40f8d818) = 0
[pid  8388] 22:30:46 [4027cd4c] ioctl(3, MXCFB_SEND_UPDATE, 0x408fbb50) = 0
[pid  8388] 22:30:48 [4027cd4c] ioctl(3, MXCFB_SEND_UPDATE, 0x4094ee38) = 0
[pid  8388] 22:30:49 [4027cd4c] ioctl(3, MXCFB_SEND_UPDATE, 0x400a6468) = 0

Awesome:

Process 3307 attached with 9 threads
[pid  3421] 22:31:30 [40651d4c] ioctl(18, MXCFB_SEND_UPDATE, 0x4007ac1c) = 0
[pid  3307] 22:31:30 [40651d4c] ioctl(18, MXCFB_WAIT_FOR_UPDATE_SUBMISSION, 0x40d28868) = 0
[pid  3307] 22:31:31 [40651d4c] ioctl(18, MXCFB_WAIT_FOR_UPDATE_COMPLETE, 0xbeb48594) = 0
[pid  3307] 22:31:31 [40651d4c] ioctl(18, MXCFB_SEND_UPDATE, 0xbeb485e8) = 0
[pid  3307] 22:31:31 [40651d4c] ioctl(18, MXCFB_WAIT_FOR_UPDATE_COMPLETE, 0xbeb48600) = 441
[pid  3307] 22:31:31 [40651d4c] ioctl(18, MXCFB_SET_PWRDOWN_DELAY, 0xbeb48688) = 0
[pid  3307] 22:31:35 [40651d4c] ioctl(18, MXCFB_GET_TEMPERATURE, 0xbeb48580) = 0
Process 8431 attached
[pid  8431] 22:31:35 [40651d4c] ioctl(18, MXCFB_GET_TEMPERATURE, 0x42487bd8) = 0
[pid  8431] 22:31:35 [????????] +++ exited with 0 +++
[pid  3307] 22:31:35 [40651d4c] ioctl(18, MXCFB_WAIT_FOR_UPDATE_SUBMISSION, 0x40d28868) = 0
[pid  3307] 22:31:35 [40651d4c] ioctl(18, MXCFB_WAIT_FOR_UPDATE_COMPLETE, 0xbeb48594) = 0
[pid  3307] 22:31:35 [40651d4c] ioctl(18, MXCFB_SEND_UPDATE, 0xbeb485e8) = 0
[pid  3307] 22:31:35 [40651d4c] ioctl(18, MXCFB_WAIT_FOR_UPDATE_COMPLETE, 0xbeb48600) = 441
[pid  3307] 22:31:36 [40651d4c] ioctl(18, MXCFB_GET_TEMPERATURE, 0xbeb48648) = 0
[pid  3421] 22:31:41 [40651d4c] ioctl(18, MXCFB_WAIT_FOR_UPDATE_COMPLETE, 0x4007aaa4) = 0
[pid  3421] 22:31:41 [40651d4c] ioctl(18, MXCFB_SEND_UPDATE, 0x4007ac1c) = 0
[pid  3421] 22:31:41 [40651d4c] ioctl(18, MXCFB_WAIT_FOR_UPDATE_COMPLETE, 0x4007ac34) = 437
[pid  3421] 22:31:46 [40651d4c] ioctl(18, MXCFB_WAIT_FOR_UPDATE_COMPLETE, 0x4007aaa4) = 0
[pid  3421] 22:31:46 [40651d4c] ioctl(18, MXCFB_SEND_UPDATE, 0x4007ac1c) = 0
[pid  3421] 22:31:46 [40651d4c] ioctl(18, MXCFB_WAIT_FOR_UPDATE_COMPLETE, 0x4007ac34) = 438
[pid  3421] 22:31:48 [40651d4c] ioctl(18, MXCFB_WAIT_FOR_UPDATE_COMPLETE, 0x4007aaa4) = 0
[pid  3421] 22:31:48 [40651d4c] ioctl(18, MXCFB_SEND_UPDATE, 0x4007ac1c) = 0
[pid  3421] 22:31:48 [40651d4c] ioctl(18, MXCFB_WAIT_FOR_UPDATE_COMPLETE, 0x4007ac34) = 437
[pid  3421] 22:31:57 [40651d4c] ioctl(18, MXCFB_WAIT_FOR_UPDATE_COMPLETE, 0x4007aaa4) = 0
[pid  3421] 22:31:57 [40651d4c] ioctl(18, MXCFB_SEND_UPDATE, 0x4007ac1c) = 0
[pid  3421] 22:31:57 [40651d4c] ioctl(18, MXCFB_WAIT_FOR_UPDATE_COMPLETE, 0x4007ac34) = 437
[pid  3421] 22:32:01 [40651d4c] ioctl(18, MXCFB_WAIT_FOR_UPDATE_COMPLETE, 0x4007aaa4) = 0
[pid  3421] 22:32:01 [40651d4c] ioctl(18, MXCFB_SEND_UPDATE, 0x4007ac1c) = 0
[pid  3421] 22:32:01 [40651d4c] ioctl(18, MXCFB_WAIT_FOR_UPDATE_COMPLETE, 0x4007ac34) = 438
[pid  3421] 22:32:14 [40651d4c] ioctl(18, MXCFB_WAIT_FOR_UPDATE_COMPLETE, 0x4007aaa4) = 0
[pid  3421] 22:32:14 [40651d4c] ioctl(18, MXCFB_SEND_UPDATE, 0x4007ac1c) = 0
[pid  3421] 22:32:14 [40651d4c] ioctl(18, MXCFB_WAIT_FOR_UPDATE_COMPLETE, 0x4007ac34) = 437
[pid  3421] 22:32:16 [40651d4c] ioctl(18, MXCFB_WAIT_FOR_UPDATE_COMPLETE, 0x4007aaa4) = 0
[pid  3421] 22:32:16 [40651d4c] ioctl(18, MXCFB_SEND_UPDATE, 0x4007ac1c) = 0
[pid  3421] 22:32:16 [40651d4c] ioctl(18, MXCFB_WAIT_FOR_UPDATE_COMPLETE, 0x4007ac34) = 434
[pid  3421] 22:32:18 [40651d4c] ioctl(18, MXCFB_WAIT_FOR_UPDATE_COMPLETE, 0x4007aaa4) = 0
[pid  3421] 22:32:18 [40651d4c] ioctl(18, MXCFB_SEND_UPDATE, 0x4007ac1c) = 0
[pid  3421] 22:32:18 [40651d4c] ioctl(18, MXCFB_WAIT_FOR_UPDATE_COMPLETE, 0x4007ac34) = 438
[pid  3421] 22:32:20 [40651d4c] ioctl(18, MXCFB_WAIT_FOR_UPDATE_COMPLETE, 0x4007aaa4) = 0
[pid  3421] 22:32:20 [40651d4c] ioctl(18, MXCFB_SEND_UPDATE, 0x4007ac1c) = 0
[pid  3421] 22:32:20 [40651d4c] ioctl(18, MXCFB_WAIT_FOR_UPDATE_COMPLETE, 0x4007ac34) = 438
[pid  3421] 22:32:22 [40651d4c] ioctl(18, MXCFB_WAIT_FOR_UPDATE_COMPLETE, 0x4007aaa4) = 0
[pid  3421] 22:32:22 [40651d4c] ioctl(18, MXCFB_SEND_UPDATE, 0x4007ac1c) = 0
[pid  3421] 22:32:22 [40651d4c] ioctl(18, MXCFB_WAIT_FOR_UPDATE_COMPLETE, 0x4007ac34) = 438
[pid  3307] 22:32:23 [40651d4c] ioctl(18, MXCFB_WAIT_FOR_UPDATE_SUBMISSION, 0x40d28868) = 0
[pid  3307] 22:32:23 [40651d4c] ioctl(18, MXCFB_WAIT_FOR_UPDATE_COMPLETE, 0xbeb48594) = 0
[pid  3307] 22:32:23 [40651d4c] ioctl(18, MXCFB_SEND_UPDATE, 0xbeb485e8) = 0
[pid  3307] 22:32:23 [40651d4c] ioctl(18, MXCFB_WAIT_FOR_UPDATE_COMPLETE, 0xbeb48600) = 441
[pid  3307] 22:32:24 [40651d4c] ioctl(18, MXCFB_GET_TEMPERATURE, 0xbeb48648) = 0
[pid  3307] 22:32:33 [40651d4c] ioctl(18, MXCFB_WAIT_FOR_UPDATE_SUBMISSION, 0x40d28868) = 0
[pid  3307] 22:32:33 [40651d4c] ioctl(18, MXCFB_SEND_UPDATE, 0xbeb485e8) = 0
[pid  3307] 22:32:33 [40651d4c] ioctl(18, MXCFB_SET_PWRDOWN_DELAY, 0xbeb48688) = 0
[pid  3421] 22:32:35 [40651d4c] ioctl(18, MXCFB_SEND_UPDATE, 0x4007ac1c) = 0
[pid  3307] 22:32:35 [40651d4c] ioctl(18, MXCFB_SET_PWRDOWN_DELAY, 0xbeb48308) = 0
[pid  3307] 22:32:35 [40651d4c] ioctl(18, MXCFB_GET_TEMPERATURE, 0xbeb482c8) = 0
[pid  3307] 22:32:35 [40651d4c] ioctl(18, MXCFB_WAIT_FOR_UPDATE_SUBMISSION, 0x40d28868) = 0
[pid  3307] 22:32:35 [40651d4c] ioctl(18, MXCFB_WAIT_FOR_UPDATE_COMPLETE, 0xbeb48594) = 0
[pid  3307] 22:32:35 [40651d4c] ioctl(18, MXCFB_SEND_UPDATE, 0xbeb485e8) = 0
[pid  3307] 22:32:35 [40651d4c] ioctl(18, MXCFB_WAIT_FOR_UPDATE_COMPLETE, 0xbeb48600) = 441
[pid  3307] 22:32:36 [40651d4c] ioctl(18, MXCFB_SET_PWRDOWN_DELAY, 0xbeb48688) = 0
[pid  3421] 22:32:36 [40651d4c] ioctl(18, MXCFB_SEND_UPDATE, 0x4007ac1c) = 0

(Homescreen -> Booklet -> Homescreen)


*: cf. HACKING-scripts in a git checkout of strace, the ioctlent.sh script did wonders with the 5.4.3.2 kernel ;).

@NiLuJe
Copy link
Member

NiLuJe commented Jul 5, 2014

If the headers are not enough, some kobo guys used this at one point to decode the struct.

@NiLuJe
Copy link
Member

NiLuJe commented Jul 5, 2014

So, that's it.

I can provide the strace build and be an obedient guinea pig, but the rest is over my head ;).

@NiLuJe NiLuJe added Kindle and removed question labels Jul 5, 2014
@NiLuJe NiLuJe changed the title better rendering mode for Carta E-ink screen? Missing 'Regal' WaveForm update mode support on Carta E-ink screen (PW2) Jul 5, 2014
@NiLuJe NiLuJe changed the title Missing 'Regal' WaveForm update mode support on Carta E-ink screen (PW2) Missing 'Regal' WaveForm update mode support on Carta E-ink screens (PW2) Jul 5, 2014
@NiLuJe
Copy link
Member

NiLuJe commented Jul 5, 2014

Slightly more accurate title/labels for the issue ;).

@NiLuJe
Copy link
Member

NiLuJe commented Jul 6, 2014

Well, digging into old posts by GM can be insightful, more info on the marker thing (which likely saw some changes on the PW2, given the new data structure & ioctl): http://www.mobileread.com/forums/showpost.php?p=2065117&postcount=34

And another tracing tool: http://www.mobileread.com/forums/showpost.php?p=1908766&postcount=4

The FreeScale iMX6 doc might also be useful, but I haven't looked at it.

@NiLuJe
Copy link
Member

NiLuJe commented Jul 6, 2014

And for the Kobo guys:

       /*
         * reagl_flow
         */
        int mode_aa;
        int mode_aad;

OHAI! ;D

(Which means mxcfb-kobo.h is also outdated. That's just a heads up, I don't have a Kobo, I was just investigating why we're using the wrong temp value on the Kindle: and that's because it's a Kindle-only one ;))

@NiLuJe
Copy link
Member

NiLuJe commented Jul 7, 2014

Eh, just read a few chapters, might actually be better now. I need new glasses. >_<".

@bugportal
Copy link
Author

@NiLuJe 👍 Thank you for your help. It looks quite better now. Although I found a problem of the build when I was turning the pages very fast. (It is totally OK when I turned the pages at "normal" speed).
Attached please find a figure which may help you understand what is happening (I was reading a PDF file with reflow enabled)
quit_turning
It seems that the rendering becomes "unpredictable" when the pages was turned very fast.

Cheers,

@hwhw
Copy link
Member

hwhw commented Jul 7, 2014

Ah, that's probably why the Kindle framework makes sure the last transition is already done (MXCFB_WAIT_FOR_UPDATE_COMPLETE). Seems to be a typical asynchronous interface.

@NiLuJe
Copy link
Member

NiLuJe commented Jul 7, 2014

@hwhw: Wild guess here, because I'm fairly certain I don't quite get how everything works, but I'm guessing that's a no-no for us, because we're not multi-process/multi-thread, so a blocking ioctl would be bad? Or does the ioctl return immediately, and the blocking happens elsewhere?

@bugportal: Yay, thanks for looking at this, I'm starting to get cross-eyed, wasn't sure it was actually any better ;).
Shouldn't you have hit a full flash at one point though, or did you tweak the refresh settings? (Or did the full flash also get lost in the storm of updates?)


I'll update the kobo headers if I have time later tonight, but since I don't have one, I'll leave the actual implementation to someone with an actual device :). The snippet earlier was from the Aura Kernel, but I'm guessing the AuraHD should handle that too.

@houqp
Copy link
Member

houqp commented Jul 7, 2014

Both MXCFB_WAIT_FOR_UPDATE_COMPLETE and MXCFB_WAIT_FOR_UPDATE_SUBMISSION calls wait_for_completion_timeout with 5000 msec as timeout. I think they are blocking ioctls. But 5000 msec sounds like a long time -_-

@bugportal
Copy link
Author

@NiLuJe Yes, The "unpredictable" rendering will disappear when a full flash is hit, i.e., when I came across the "unpredictable" rendering, just turned the pages at a normal speed, then after some steps, a full flash will make the page clear and rendering back to normal again.

I did not change any refresh settings.

@NiLuJe
Copy link
Member

NiLuJe commented Jul 8, 2014

@bugportal: Yup, you didn't do anything wrong ;). FWIW, a Touch behaves the exact same way (albeit with a slightly different kind of ghosting).

Depending on if you happen to stop right after a full refresh or not, it's more or less readable ;p.

@NiLuJe
Copy link
Member

NiLuJe commented Jul 8, 2014

And here's an updated build with my latest PRs baked in.

Granted, the two PRs in question haven't much to do with this issue, but, hey :D.

I did move the waveform selection code, so do shout at me if I broke it :p.

@NiLuJe
Copy link
Member

NiLuJe commented Jul 8, 2014

I think I just kernel panic'ed a PW2. :D. The kernel log buffer is a bit messed up, so no real idea of what crashed, but FWIW, I was clicking the "decrease" contrast button (something that now works just fine after the reboot, so, yay).

Good news: the watchdog works really well, ended up rebooting all alone.

Probably a good sign it's time to go to sleep!

@NiLuJe
Copy link
Member

NiLuJe commented Jul 8, 2014

Okay, I'm doing experiments w/ the WAIT_FOR_STUFF, and I have something that works.

I handle everything in fb_linux, because it's easier, and seems saner, and I went with:

tweakign refresh() to do:
WAIT_FOR_COMPLETE(cur_marker)
UPDATE(new_marker)
WAIT_FOR_SUBMISSION(cur_marker [which is now new_marker])

Because that seems like the right way to do it? No idea why the PW2 seems to be doing WAIT_FOR_COMPLETE twice, but there's a kfree() in that function that scares me, so I'm not doing it twice on the same marker :D.

The marker is an uint32_t, increasing from 1 to 16 and wrapping.

That seems to work, and the 'click next page like a madman' thing indeed behaves more like the Stock reader (in that it, well, waits ;D).

The good news is: I forgot to put timestamps around, and I'll probably do it before the end to check, but the blocking appears to be relatively minimal, and the timeout only triggers if you did something wrong ;). I don't handle return values right now, so we just eat a timeout and continue if something wrong happens.

Stracing appears to confirm that we're doing something right, I get the same kind of output as the stock reader.

I have a couple of issues, though:

  • I need to be able to tell the PW2 from the rest from inside fb_linux, and I can't require Device from there, can I?
  • Right now, I'm doing this on every refresh. The Touch/PW1 only does it on full refresh. That'd be trivial to implement, but again, I need a way to tell them apart.

So, I guess that boils down to: can I require Device from inside ffi/framebuffer_linux, or do I have to reimplement the device check myself, and essentially duplicate some code?

@NiLuJe
Copy link
Member

NiLuJe commented Jul 8, 2014

Pushed to the mxcb_wait_for branch in my tree if someone wants to take a look.

@NiLuJe
Copy link
Member

NiLuJe commented Jul 8, 2014

AFAIR, there's nothing in the fb info to tell a PW1 from a PW2. I'll check, but I don't have high hopes ;p.

@houqp
Copy link
Member

houqp commented Jul 9, 2014

Good work 👍 ! kindle_pearl_mxc_wait_for_update_complete function should be used in PW1 right? Strangely, I wasn't able to find that MXCFB_WAIT_FOR_UPDATE_COMPLETE_PEARL ioctl command in PW1 and PW2's driver code.

@NiLuJe
Copy link
Member

NiLuJe commented Jul 9, 2014

@houqp: It's MXCFB_WAIT_FOR_UPDATE_COMPLETE in both cases, but the arg changed on the PW2, so I renamed the onstant for the 'old' ioctl to be able to use both ;). I made that clearer in the header now, thanks :).

It appears that I got lucky, and there may be a way to differentiate the PW2 from the fb info. I got sidetracked by the whole gcc-lua/gcc-lua-cdecl stuff (cf. the mess I made in my koreader-misc tree and the latest batch of commits in mxc_wait_for), I'll get back to it now that I tracked down what was broken. (Well, not exactly, but at least it works with the latest versions xD).

@NiLuJe
Copy link
Member

NiLuJe commented Jul 9, 2014

Because it might come in handy later, framebuffer info (via eips -i) on the Kindles:

Touch (5.3.7.1):

Fixed framebuffer info
    id:              mxc_epdc_fb    smem_start:       0x75400000
    smem_len:            2179072    type:          PACKED_PIXELS
    type_aux:                  0    visual:   STATIC_PSEUDOCOLOR
    xpanstep:                  1    ypanstep:                  1
    ywrapstep:                 0    line_length:             608
    mmio_start:       0x00000000    mmio_len:                  0
    accel:                     0

Variable framebuffer info
    xres:                    600    yres:                    800
    xres_virtual:            608    yres_virtual:           3584
    xoffset:                   0    yoffset:                   0
    bits_per_pixel:            8    grayscale:                 1
    red.offset:                0    green.offset:              0
    red.length:                8    green.length:              8
    red.msb_right:             0    green.msb_right:           0
    blue.offset:               0    transp.offset:             0
    blue.length:               8    transp.length:             0
    blue.msb_right:            0    transp.msb_right:          0
    nonstd:                    0    activate:                128
    width:                    -1    height:                   -1
    accel_flags:               0    pixclock:           32258064
    left_margin:              17    right_margin:            172
    upper_margin:              4    lower_margin:             18
    hsync_len:                15    vsync_len:                 4
    sync:                      0    vmode:                     0
    rotate:                    1

PW1 (5.4.4.2):

Fixed framebuffer info
    id:              mxc_epdc_fb    smem_start:       0x75800000
    smem_len:            4718592    type:          PACKED_PIXELS
    type_aux:                  0    visual:   STATIC_PSEUDOCOLOR
    xpanstep:                  1    ypanstep:                  1
    ywrapstep:                 0    line_length:             768
    mmio_start:       0x00000000    mmio_len:                  0
    accel:                     0

Variable framebuffer info
    xres:                    758    yres:                   1024
    xres_virtual:            768    yres_virtual:           6144
    xoffset:                   0    yoffset:                   0
    bits_per_pixel:            8    grayscale:                 1
    red.offset:                0    green.offset:              0
    red.length:                8    green.length:              8
    red.msb_right:             0    green.msb_right:           0
    blue.offset:               0    transp.offset:             0
    blue.length:               8    transp.length:             0
    blue.msb_right:            0    transp.msb_right:          0
    nonstd:                    0    activate:                128
    width:                    -1    height:                   -1
    accel_flags:               0    pixclock:           40000000
    left_margin:              12    right_margin:             76
    upper_margin:              4    lower_margin:              5
    hsync_len:                12    vsync_len:                 2
    sync:                      0    vmode:                     0
    rotate:                    3

PW2 (5.4.3.2):

Fixed framebuffer info
    id:              mxc_epdc_fb    smem_start:       0x80C00000
    smem_len:            3145728    type:          PACKED_PIXELS
    type_aux:                  0    visual:   STATIC_PSEUDOCOLOR
    xpanstep:                  1    ypanstep:                  1
    ywrapstep:                 0    line_length:             768
    mmio_start:       0x00000000    mmio_len:                  0
    accel:                     0

Variable framebuffer info
    xres:                    758    yres:                   1024
    xres_virtual:            768    yres_virtual:           4096
    xoffset:                   0    yoffset:                   0
    bits_per_pixel:            8    grayscale:                 1
    red.offset:                0    green.offset:              0
    red.length:                8    green.length:              8
    red.msb_right:             0    green.msb_right:           0
    blue.offset:               0    transp.offset:             0
    blue.length:               8    transp.length:             0
    blue.msb_right:            0    transp.msb_right:          0
    nonstd:                    0    activate:                128
    width:                    -1    height:                   -1
    accel_flags:               0    pixclock:           40000000
    left_margin:              12    right_margin:             76
    upper_margin:              4    lower_margin:              5
    hsync_len:                12    vsync_len:                 2
    sync:                      0    vmode:                     0
    rotate:                    3

And for ref., on a Touch w/ FW 5.0, see GM's post here ;). [Meaning we have a way to detect those, so we could support it, if it wasn't fairly useless to do so ^^]

@NiLuJe
Copy link
Member

NiLuJe commented Jul 9, 2014

There, the branch should be in a saner state now. More testing tomorrow :).

@NiLuJe
Copy link
Member

NiLuJe commented Jul 10, 2014

And this is now KOReader on a PW2:

[pid  6109] 23:20:10 [4025dd4c] ioctl(3, MXCFB_WAIT_FOR_UPDATE_COMPLETE, 0x40947e90) = 0
[pid  6109] 23:20:10 [4025dd4c] ioctl(3, MXCFB_SEND_UPDATE, 0x40f95250) = 0
[pid  6109] 23:20:10 [4025dd4c] ioctl(3, MXCFB_WAIT_FOR_UPDATE_SUBMISSION, 0x402ceed8) = 496
[pid  6109] 23:20:10 [4025dd4c] ioctl(3, MXCFB_WAIT_FOR_UPDATE_COMPLETE, 0x40f15aa8) = 0
[pid  6109] 23:20:10 [4025dd4c] ioctl(3, MXCFB_SEND_UPDATE, 0x4141dc88) = 0
[pid  6109] 23:20:10 [4025dd4c] ioctl(3, MXCFB_WAIT_FOR_UPDATE_SUBMISSION, 0x402ceed8) = 497
[pid  6109] 23:20:12 [4025dd4c] ioctl(3, MXCFB_WAIT_FOR_UPDATE_COMPLETE, 0x40d25f68) = 0
[pid  6109] 23:20:12 [4025dd4c] ioctl(3, MXCFB_SEND_UPDATE, 0x40f4c0a8) = 0
[pid  6109] 23:20:12 [4025dd4c] ioctl(3, MXCFB_WAIT_FOR_UPDATE_SUBMISSION, 0x402ceed8) = 497
[pid  6109] 23:20:13 [4025dd4c] ioctl(3, MXCFB_WAIT_FOR_UPDATE_COMPLETE, 0x40f164f8) = 0
[pid  6109] 23:20:13 [4025dd4c] ioctl(3, MXCFB_SEND_UPDATE, 0x40958bf8) = 0
[pid  6109] 23:20:13 [4025dd4c] ioctl(3, MXCFB_WAIT_FOR_UPDATE_SUBMISSION, 0x402ceed8) = 496
[pid  6109] 23:20:14 [4025dd4c] ioctl(3, MXCFB_WAIT_FOR_UPDATE_COMPLETE, 0x40933908) = 0
[pid  6109] 23:20:14 [4025dd4c] ioctl(3, MXCFB_SEND_UPDATE, 0x40854318) = 0
[pid  6109] 23:20:14 [4025dd4c] ioctl(3, MXCFB_WAIT_FOR_UPDATE_SUBMISSION, 0x402ceed8) = 496
[pid  6109] 23:20:15 [4025dd4c] ioctl(3, MXCFB_WAIT_FOR_UPDATE_COMPLETE, 0x40889ba8) = 0
[pid  6109] 23:20:15 [4025dd4c] ioctl(3, MXCFB_SEND_UPDATE, 0x40f2f5b8) = 0
[pid  6109] 23:20:15 [4025dd4c] ioctl(3, MXCFB_WAIT_FOR_UPDATE_SUBMISSION, 0x402ceed8) = 499
[pid  6109] 23:20:16 [4025dd4c] ioctl(3, MXCFB_WAIT_FOR_UPDATE_COMPLETE, 0x409428e0) = 0
[pid  6109] 23:20:16 [4025dd4c] ioctl(3, MXCFB_SEND_UPDATE, 0x40d556a0) = 0
[pid  6109] 23:20:16 [4025dd4c] ioctl(3, MXCFB_WAIT_FOR_UPDATE_SUBMISSION, 0x402ceed8) = 497
[pid  6109] 23:20:17 [4025dd4c] ioctl(3, MXCFB_WAIT_FOR_UPDATE_COMPLETE, 0x408b2630) = 0
[pid  6109] 23:20:17 [4025dd4c] ioctl(3, MXCFB_SEND_UPDATE, 0x408b99f0) = 0
[pid  6109] 23:20:17 [4025dd4c] ioctl(3, MXCFB_WAIT_FOR_UPDATE_SUBMISSION, 0x402ceed8) = 497
[pid  6109] 23:20:18 [4025dd4c] ioctl(3, MXCFB_WAIT_FOR_UPDATE_COMPLETE, 0x408c3478) = 0
[pid  6109] 23:20:18 [4025dd4c] ioctl(3, MXCFB_SEND_UPDATE, 0x40f11040) = 0
[pid  6109] 23:20:18 [4025dd4c] ioctl(3, MXCFB_WAIT_FOR_UPDATE_SUBMISSION, 0x402ceed8) = 497
[pid  6109] 23:20:19 [4025dd4c] ioctl(3, MXCFB_WAIT_FOR_UPDATE_COMPLETE, 0x4093cb68) = 0
[pid  6109] 23:20:19 [4025dd4c] ioctl(3, MXCFB_SEND_UPDATE, 0x40d4d550) = 0
[pid  6109] 23:20:19 [4025dd4c] ioctl(3, MXCFB_WAIT_FOR_UPDATE_SUBMISSION, 0x402ceed8) = 497
[pid  6109] 23:20:27 [4025dd4c] ioctl(3, MXCFB_WAIT_FOR_UPDATE_COMPLETE, 0x402c9468) = 0
[pid  6109] 23:20:27 [4025dd4c] ioctl(3, MXCFB_SEND_UPDATE, 0x40f9e670) = 0
[pid  6109] 23:20:27 [4025dd4c] ioctl(3, MXCFB_WAIT_FOR_UPDATE_SUBMISSION, 0x402ceed8) = 497
[pid  6109] 23:20:32 [4025dd4c] ioctl(3, MXCFB_WAIT_FOR_UPDATE_COMPLETE, 0x40912ee8) = 0
[pid  6109] 23:20:32 [4025dd4c] ioctl(3, MXCFB_SEND_UPDATE, 0x408eb7c8) = 0
[pid  6109] 23:20:32 [4025dd4c] ioctl(3, MXCFB_WAIT_FOR_UPDATE_SUBMISSION, 0x402ceed8) = 499
[pid  6109] 23:20:34 [4025dd4c] ioctl(3, MXCFB_WAIT_FOR_UPDATE_COMPLETE, 0x40940ee8) = 0
[pid  6109] 23:20:34 [4025dd4c] ioctl(3, MXCFB_SEND_UPDATE, 0x40dcfd88) = 0
[pid  6109] 23:20:34 [4025dd4c] ioctl(3, MXCFB_WAIT_FOR_UPDATE_SUBMISSION, 0x402ceed8) = 497
[pid  6109] 23:20:36 [4025dd4c] ioctl(3, MXCFB_WAIT_FOR_UPDATE_COMPLETE, 0x40928f48) = 0
[pid  6109] 23:20:36 [4025dd4c] ioctl(3, MXCFB_SEND_UPDATE, 0x40f32060) = 0
[pid  6109] 23:20:36 [4025dd4c] ioctl(3, MXCFB_WAIT_FOR_UPDATE_SUBMISSION, 0x402ceed8) = 497
[pid  6109] 23:20:39 [4025dd4c] ioctl(3, MXCFB_WAIT_FOR_UPDATE_COMPLETE, 0x40923768) = 0
[pid  6109] 23:20:39 [4025dd4c] ioctl(3, MXCFB_SEND_UPDATE, 0x40f58d60) = 0
[pid  6109] 23:20:39 [4025dd4c] ioctl(3, MXCFB_WAIT_FOR_UPDATE_SUBMISSION, 0x402ceed8) = 497
[pid  6109] 23:20:41 [4025dd4c] ioctl(3, MXCFB_WAIT_FOR_UPDATE_COMPLETE, 0x40f008b8) = 0
[pid  6109] 23:20:41 [4025dd4c] ioctl(3, MXCFB_SEND_UPDATE, 0x412bc0a0) = 0
[pid  6109] 23:20:41 [4025dd4c] ioctl(3, MXCFB_WAIT_FOR_UPDATE_SUBMISSION, 0x402ceed8) = 496
[pid  6109] 23:20:43 [4025dd4c] ioctl(3, MXCFB_WAIT_FOR_UPDATE_COMPLETE, 0x409331d8) = 0
[pid  6109] 23:20:43 [4025dd4c] ioctl(3, MXCFB_SEND_UPDATE, 0x40bf0bb8) = 0
[pid  6109] 23:20:43 [4025dd4c] ioctl(3, MXCFB_WAIT_FOR_UPDATE_SUBMISSION, 0x402ceed8) = 497
[pid  6109] 23:20:44 [4025dd4c] ioctl(3, MXCFB_WAIT_FOR_UPDATE_COMPLETE, 0x4122e4b0) = 0
[pid  6109] 23:20:44 [4025dd4c] ioctl(3, MXCFB_SEND_UPDATE, 0x412cecd0) = 0
[pid  6109] 23:20:44 [4025dd4c] ioctl(3, MXCFB_WAIT_FOR_UPDATE_SUBMISSION, 0x402ceed8) = 500

\o/

@NiLuJe
Copy link
Member

NiLuJe commented Jul 10, 2014

The behavior @bugportal encountered is now fixed, as we behave mostly like the stock reader. (Which means, yeah, you can't really tap next page like a crazy person anymore, but you can't do that anymore with the stock reader either on a PW2 ;)).

@NiLuJe
Copy link
Member

NiLuJe commented Jul 10, 2014

And here's an updated build with these changes :).

@NiLuJe
Copy link
Member

NiLuJe commented Jul 13, 2014

Landed in master, closing ;).

(As usual, reopen if stuff suddenly starts catching fire ;)).

@NiLuJe NiLuJe closed this as completed Jul 13, 2014
@NiLuJe
Copy link
Member

NiLuJe commented Jul 13, 2014

And a new build, post merge (so, technically, only the version number should have changed ;)).

EDIT: Except I built 352 w/ O3 and 356 w/ the default CFLAGS, which explains the size difference.

benoit-pierre pushed a commit to benoit-pierre/koreader that referenced this issue Dec 23, 2023
Followup fix to 55fa104: if there's not a single '* {}'
or '.cls {}' in a stylesheet, none of it would have been
matched and applied.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants