Skip to content

Support VT switching for fbdev backend #89

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

Merged
merged 1 commit into from
Jan 21, 2025
Merged

Conversation

huaxinliao
Copy link
Collaborator

The fbdev backend supports framebuffer rendering on a specifiend VT. To enhancce its compatibility in environments with multiple TTYs, the following improvements ensure that each framebuffer device operates independently on its own VT without affecting others.

  • Implement signal handlers to manage virtual terminal switching.
  • Pause screen rendering when switching to another VT.
  • Resume screen rendering when switching back to the original VT.

@jserv
Copy link
Contributor

jserv commented Jan 12, 2025

Specify which environments and hardware models have been validated with the proposed updates.

@huaxinliao
Copy link
Collaborator Author

huaxinliao commented Jan 12, 2025

Specify which environments and hardware models have been validated with the proposed updates.

These updates have been validated on Ubuntu 24.04 in a virtual machine. However, they cause a error on the Raspberry Pi 3B. I am currently investigating the issue.

@jserv jserv requested a review from shengwen-tw January 12, 2025 15:26
@shengwen-tw
Copy link
Collaborator

I will help reviewing the pull request this week.
Thanks.

@huaxinliao
Copy link
Collaborator Author

These updates have been validated on Ubuntu 24.04 in a virtual machine. However, they cause a error on the Raspberry Pi 3B. I am currently investigating the issue.

When I switch back and forth between tty2 and tty3, the Pi 3B would shut down.

Pi.mp4

@shengwen-tw
Copy link
Collaborator

These updates have been validated on Ubuntu 24.04 in a virtual machine. However, they cause a error on the Raspberry Pi 3B. I am currently investigating the issue.

When I switch back and forth between tty2 and tty3, the Pi 3B would shut down.

Pi.mp4

Raspberry Pi 4B requires power supply that can sustain at least 1.2A, and the recommended value is 3A, could you check for that?

https://github.com/raspberrypi/documentation/blob/develop/documentation/asciidoc/computers/raspberry-pi/power-supplies.adoc

@huaxinliao
Copy link
Collaborator Author

Raspberry Pi 4B requires power supply that can sustain at least 1.2A, and the recommended value is 3A, could you check for that?

https://github.com/raspberrypi/documentation/blob/develop/documentation/asciidoc/computers/raspberry-pi/power-supplies.adoc

For my Raspberry Pi 3B, the recommended power supply is a 2.5A micro USB adapter. However, I am currently using a 1.5A micro USB adapter.

@huaxinliao
Copy link
Collaborator Author

This is the experimental result obtained on a Raspberry Pi 3B.

Pi_3B.mp4

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.

Make the VT switch code reusable with DRM by consolidating linux_vt.h.


static int *vt_fd;

static bool *is_vt_active;
Copy link
Contributor

Choose a reason for hiding this comment

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

Rename to is_vt_actived.

Copy link
Contributor

Choose a reason for hiding this comment

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

What is is_vt_active used for?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

After setting is_vt_active, it can help twin_fbdev_work determine whether to proceed with screen rendering.

Copy link
Contributor

Choose a reason for hiding this comment

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

After setting is_vt_active, it can help twin_fbdev_work determine whether to proceed with screen rendering.

Check the necessity.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Without the is_vt_active flag, proper VT switching cannot be ensured. The primary reason for utilizing is_vt_active is the need to pass tx->vt_fd and tx->vt_active as parameters to the signal handler for configuration. However, achieving this directly is challenging. This discussion on passing multiple parameters to a signal handler using sigaction() suggests using global variables as a solution.

A similar scenario is discussed in Updating global variable in signal handlers, which provides valuable insights. It highlights that variables of type sig_atomic_t are guaranteed to be updated safely in signal handlers. Furthermore, it cautions against using locks in signal handlers, as they might be invoked while a lock is already held.

The code can be updated as follows:

static volatile sig_atomic_t *vt_fd;
static volatile sig_atomic_t *is_vt_actived;

The fbdev backend supports framebuffer rendering on a specifiend
VT. To enhancce its compatibility in environments with multiple
TTYs, the following improvements ensure that each framebuffer
device operates independently on its own VT without affecting
others.

- Implement signal handlers to manage virtual terminal switching.
- Pause screen rendering when switching to another VT.
- Resume screen rendering when switching back to the original VT.

The improvement has been validated on Ubuntu 24.04 running in a
virtual machine and on a Raspberry Pi 3B.
@jserv jserv merged commit 62cf542 into sysprog21:main Jan 21, 2025
3 checks passed
@jserv
Copy link
Contributor

jserv commented Jan 21, 2025

Thank @huaxinliao for contributing!

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