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

Fix memory region in framebuffer #65

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

a1091150
Copy link
Contributor

@a1091150 a1091150 commented Oct 26, 2024

Issue #62
The width of screen may be different from the virtual resolution.
In apps/main.c, the default value of WIDTH and HEIGHT are 640 and 480, but the visual resolution are set to 1920 and 1080 on my machine.
The different width will draw three screens on the display as the below screenshot.

Before:
screen

After:
screen

The reason to use xres_virtual line_length as the width and not to use xres in struct fb_var_screeninfo:
On VirtualBox, the visible resolution of virtual terminal, which switched by ctrl+alt+f3, is set to 800x600, but the virtual solution is set to 2048x2048. On my physical machine, Asus latop and Ubuntu system, these are the same values.

The information from sudo fbset -i on my laptop and VirtualBox.
Laptop:

mode "1920x1080"
    geometry 1920 1080 1920 1080 32
    ....
endmode
Frame buffer device information:
    ....
    LineLength  : 7680
    Accelerator : No

VirtualBox:

mode "800x600"
    geometry 800 600 2048 2048 32
endmode

Frame buffer device information:
    ......
    LineLength  : 8192
    Accelerator : No

jserv

This comment was marked as duplicate.

backend/fbdev.c Outdated Show resolved Hide resolved
backend/fbdev.c Outdated Show resolved Hide resolved
backend/fbdev.c Outdated Show resolved Hide resolved
backend/fbdev.c Outdated Show resolved Hide resolved
backend/fbdev.c Outdated
@@ -85,6 +97,7 @@ static bool twin_fbdev_work(void *closure)

if (twin_screen_damaged(screen))
twin_screen_update(screen);
twin_fbdev_cache_sync(closure);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain why twin_fbdev_cache_sync should be called here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After some search, this is driver-specificed code and should not be used, I will remove this code.
This code has a side-effect on my machine that it updates the smooth display but on VirtualBox is not.

@a1091150 a1091150 changed the title Fix memory region in framebuffer and cache synchronization Fix memory region in framebuffer and pan display Oct 29, 2024
Copy link
Contributor

@jserv jserv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improve the git commit message to address the consideration of FBIOPAN_DISPLAY.

@a1091150
Copy link
Contributor Author

@shengwen-tw, May you test the pull request on you machine to see if it is running correctly?

@shengwen-tw
Copy link
Collaborator

@shengwen-tw, May you test the pull request on you machine to see if it is running correctly?

Okay, I'll test it soon.

@shengwen-tw
Copy link
Collaborator

@shengwen-tw, May you test the pull request on you machine to see if it is running correctly?

I have ran the modification code and have some observations:

Firstly, I want to point out that I wasn’t able to reproduce the issue you encountered, as we previously discussed. From my side, I can only confirm the functionality remains the same.

However, although the framebuffer output appears correct, I noticed that the rendering update is not smooth, with significant lag when dragging windows or even just moving the cursor.

Could you analyze any potential performance bottlenecks in your code and look into ways to address this issue?

@shengwen-tw
Copy link
Collaborator

Please check the video I recorded:
https://www.youtube.com/watch?v=1FK8XkVnP8k

jserv

This comment was marked as duplicate.

@jserv
Copy link
Contributor

jserv commented Nov 4, 2024

Rebase the latest main branch and resolve the conflicts.

Copy link
Contributor

@jserv jserv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use git merge. Always enforce git rebase.

backend/fbdev.c Outdated Show resolved Hide resolved
@a1091150 a1091150 force-pushed the fixVideoSync2 branch 2 times, most recently from acf5c4d to bbc35ff Compare November 4, 2024 14:47
@a1091150
Copy link
Contributor Author

a1091150 commented Nov 4, 2024

Please check the video I recorded: https://www.youtube.com/watch?v=1FK8XkVnP8k

I find out that ioctl(fb_fd, FBIOPAN_DISPLAY, &var); causes your machine lagging, but my laptop and VirtualBox are not. Without it, my laptop can not show the mado's screen.
I see you are using two display, so I plug my laptop another display without the code ioctl(fb_fd, FBIOPAN_DISPLAY, &var);

mado's screen work fine on second display, subtly.

Check the video: https://youtu.be/XvhigZefDfc

The commit bbc35ff removed code ioctl(fb_fd, FBIOPAN_DISPLAY, &var);. I believe this commit is ready to pull (may be?)

Copy link
Contributor

@jserv jserv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refine the statement "The same setting may not be applied on different hardware" to address the consideration and use scenario.

@jserv jserv changed the title Fix memory region in framebuffer and pan display Fix memory region in framebuffer Nov 4, 2024
The size of the screen may be different to the virtual resolution. If the size
is less than virtual resolution, it will draw multiple windows on display. Use
`line_length` to calculate instead of the size of the screen.
Changable information like virtual resoultion or setting different information
on virtual terminal may not be applied on different hardware and driver. For
example on VirtualBox, virtual resolution's width and height are 2048 and 2048,
visible resolutions' are 800 and 600, and line length is 2048 * 4. Any setting
from guest machine to these maybe ignored.
Copy link
Contributor

@jserv jserv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read https://cbea.ms/git-commit/ carefully and enforce the rules.

@shengwen-tw
Copy link
Collaborator

You mentioned that

I find out that ioctl(fb_fd, FBIOPAN_DISPLAY, &var); causes your machine lagging, but my laptop and VirtualBox are not. Without it, my laptop can not show the mado's screen.

Are you planning to open a new pull request to resolve issue #62?

@a1091150
Copy link
Contributor Author

a1091150 commented Nov 7, 2024

Are you planning to open a new pull request to resolve issue #62?

Nope. I notice another drm pull request #69 . The updated may followed and discussed on it.

Issue #62 mentioned some problems:

  1. Different screen size causes multiple windwos and weird behavior(will be fixed by this pull request)
  2. Update and render after switching back to virtual terminal.
  3. ioctl(fb_fd, FBIOPAN_DISPLAY, &var) have different behavior on different machine, mentioned in this pull request before.

For third problem, I suspect it is just my laptop and i915drmfb (Intel DRM) will need this pan display and it is not a bug in Mado but in Intel DRM.

For second problem, I did write some switch code for switching, and I notice the proposed DRM backend (#69). The updated may followed and discussed on it.

@shengwen-tw
Copy link
Collaborator

I did various tests and found that the problem might not be caused by ioctl(fb_fd, FBIOPAN_DISPLAY, &var);, as the issue still occurs on my machine even after removing that line of code. (it also happens with the upstream code, though not consistently.)

If ioctl(fb_fd, FBIOPAN_DISPLAY, &var); resolves the issue you encountered, it would be reasonable to adopt the change you proposed earlier. (But could you clarify why the FBIOPAN_DISPLAY operation helps in this case?)

I suspect that the lag might be due to the button events being sent from the Linux input subsystem we recently integrated, as the current implementation does not ensure atomic updates for mouse events. I may open another new issue once I have a clearer understanding of this phenomenon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants