We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 49 - Better approach to VT switching in fbcon driver...
Summary: Better approach to VT switching in fbcon driver...
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: HG 1.2
Hardware: x86 Linux
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-01-19 04:05 UTC by Ryan C. Gordon
Modified: 2006-05-10 01:06 UTC (History)
0 users

See Also:


Attachments
fbcon-nonblocking-switch.diff (9.38 KB, patch)
2006-03-23 03:33 UTC, Sam Lantinga
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ryan C. Gordon 2006-01-19 04:05:37 UTC
Originally mentioned in Bug #37 ...

"By the way, does anyone know why SDL freezes the application when switched away using fbcon? It could catch a signal for flipping back, and provide a fake frame buffer at a fixed position so that the application can work in the background."

I like the idea, and would be inclined to also post SDL_ACTIVEEVENT events to the SDL app when switching to/from the SDL-controlled virtual terminal.

--ryan.
Comment 1 Ryan C. Gordon 2006-01-27 11:23:16 UTC
Setting Sam as "QA Contact" on all bugs (even resolved ones) so he'll definitely be in the loop to any further discussion here about SDL.

--ryan.

Comment 2 Sam Lantinga 2006-03-22 02:53:17 UTC
Out of curiousity, how would we handle the application setting a new video mode while switched away?
Comment 3 Ryan C. Gordon 2006-03-22 03:53:30 UTC
This is why I changed this back from ASSIGNED to NEW.  :)

We _could_ spend a lot of time emulating the surface and switching as appropriate, including rebuilding a shadow surface behind the scenes if the vidmode changes.

I think it's possible, but after thinking about it, I'm wondering if it's worth the effort.

--ryan.


Comment 4 Sam Lantinga 2006-03-22 04:44:58 UTC
(In reply to comment #3)
> I think it's possible, but after thinking about it, I'm wondering if it's worth
> the effort.

Doesn't seem like it to me.

It would be relatively easy to support switching away as long as the video mode isn't changed, but a completely bulletproof system would be really hard to do.

Here are some notes in case anybody is interested:
* At video mode set, we'd need to lock the video mode switch.
* In switch_vt(), we'd just need to keep the saved memory around, set a global variable inside the hw_lock, unlock the vt switch, send an APPACTIVE event, and return.
* In all code that accesses video memory, we need to check that variable (inside the lock) and return if the switched away variable was true.
* If the video mode is resized while switched away, I think maybe failing the mode switch is the best way to go.
* In the event handling code, if we're switched away, lock hw_lock, check to see if we've switched back.  If so, relock the vt switch, restore the saved memory, send an APPACTIVE event, clear the global variable, and return.

All in all, pretty easy if we can say that setting a video mode fails. :)
Comment 5 Sam Lantinga 2006-03-22 04:48:48 UTC
Actually, nevermind, we already block in the video mode setting code, until we can set the current vt.

Heheh, it sounds like this would be fairly easy to do...  I just hope everybody is checking their return codes. :)
Comment 6 Ryan C. Gordon 2006-03-22 04:53:51 UTC
Dereferencing a NULL pointer is the ultimate return code check.  :)

If you think it's trivial and worth doing, feel free to reassign this one to yourself. I'm busy fighting with Xrandr at the moment.

--ryan.

Comment 7 Sam Lantinga 2006-03-22 04:56:21 UTC
You got it.  Thanks for tangling with XRandR, btw. :)
Comment 8 Sam Lantinga 2006-03-23 03:33:47 UTC
Created attachment 93 [details]
fbcon-nonblocking-switch.diff

Here's a patch to add non-blocking VT switch support.  I don't have a working fb at the moment, so could you check it out and apply it if it's good?
Comment 9 Sam Lantinga 2006-03-23 03:39:21 UTC
Whoops, forgot the APPACTIVE stuff.  Can you add that while you're at it?
Comment 10 Ryan C. Gordon 2006-03-23 04:11:17 UTC
In switch_vt_done(), should we call SDL_UpdateRect() in all cases? Right now we don't update the display on the return to the SDL VT, so testsprite.c is rendering over the contents of the VT that I switched away to, once I return.

--ryan.

Comment 11 Ryan C. Gordon 2006-03-23 04:25:22 UTC
Also, we'll need to clear the border if the logical resolution is smaller than the physical resolution.

--ryan.

Comment 12 Sam Lantinga 2006-05-08 01:32:54 UTC
This patch, with the addition of always saving/restoring the video memory and the addition of appactive events, is now in Subversion.
Comment 13 Sam Lantinga 2006-05-08 01:33:51 UTC
Just for the record, we should also probably save and restore the entire hardware surface memory pool...  Maybe that should be a separate bug?
Comment 14 Ryan C. Gordon 2006-05-10 00:46:32 UTC
If we're going to do that, shouldn't we do it for DirectX, too, and remove the notes about BlitSurface() returning -2 from the docs? If you want to do that, yeah, seperate bug, but I don't know that it's worth it, honestly.

--ryan.
Comment 15 Sam Lantinga 2006-05-10 01:06:56 UTC
(In reply to comment #14)
> If we're going to do that, shouldn't we do it for DirectX, too, and remove the
> notes about BlitSurface() returning -2 from the docs? If you want to do that,
> yeah, seperate bug, but I don't know that it's worth it, honestly.

DirectX doesn't give you a warning - you can lose surfaces at any time.  With the framebuffer console, we're in control, and can do any saving/restoring necessary behind the scenes.  Anyway, punting for now.