Add arguments to set the desired resolution.#71
Conversation
151d817 to
41166ae
Compare
|
I updated the commit to address the two issues described in "Future Work" from the initial post. TestingI looked at the test suite more closely. It looks like the build system only runs one test, from Fallback modeThe new version of the commit keeps the previous semantics for the I think it would be preferable to check how much memory is available before setting the mode and just do the right thing to begin with, but I could not find a good way of doing that. As far as I can tell, there is no uniform way to ask the system "how much memory is available for whatever backend you happen to be using". I would need to add a lot of code that is driver (and possibly kernel) specific. I think that it would be more appropriate for this kind of function to be in libdrm (if such a function makes sense at all), but it does not provide one. So I think recovery from failure is the most practical strategy for this situation. Improvement AreasI am not entirely comfortable adding On the topic of the test suite, I would expect that the ideal test suite would connect kmscon to mock/simulated displays to check that it does everything it is supposed to. However, I am suspicious that setting this up would require refactoring the API to take this into account. I expect it would be simple to make the above update to Finally, I am not sure if there are other aspects of the mode that users might want to configure and if so, what we would want the interface to look like there. Perhaps it would make sense to have a flag with an argument formatted similarly to the format of the kernel's The above work interests me, but I am not sure if/when I will have the time to act on it. It looks like this repository is unmaintained based on the age of some of the other pull requests and the most recent commit to this branch, so anything further I do will be uploaded to https://git.sr.ht/~skyvine/kmscon until there is a reply to this thread. |
|
Added one more commit to use retry logic when activating displays, otherwise there is undesirable behavior when switching between ttys on a system running multiple instances of kmscon. I assume there would be a similar issue if you run X or Wayland by default and switch over to kmscon. |
|
hey @skyvine - can refresh rate be also added in here? I don't think it can be adjusted on fbdev, but shouldn't it be possible with drm? |
|
Sorry, I'm not sure. I prepared this change with no background knowledge, so I would have to do some research to understand how the refresh rates are handled. =) |
|
Thanks for the nice PR! Could you rebase and resolve conflicts? |
|
Thanks for looking at this. I've rebased locally but I'll need to set up a few things again before I can test. The conflicts revolve around the commit that adds It is not sensible to supply a desired width/height if if (seat->conf->use_original_mode)
ret = uterm_display_activate(d->disp,
uterm_display_get_original(d->disp));
else {
ret = uterm_display_activate(d->disp, NULL);
if (ret == -EAGAIN)
ret = uterm_display_activate(d->disp, NULL);
}In principle, it should be an error to supply a desired width/height while I'm a little nervous that we could end up in some sort of convoluted infinite loop due to the retry logic in |
|
I think it's fine to make it a hard error when a desired width/height is supplied while |
This adds the --desired-width and --desired-height arguments which tell kmscon what resolution the user *desires*. They are specifically called desired because it is not guaranteed that this resolution will be used: it will only work if the exact width and height match a supported mode as reported by the system, and it will only work in DRM mode (kmscon does not generally support modesetting in fbdev). Additionally, it might not be possible to use the mode if there is not enough memory to store the framebuffers. Using `video=<width>x<height>` on the kernel's command line was enough to make sure that sufficient memory was available on my machine. In this case, if we try to use the desired mode then the user will be presented with a blank screen. In either of the above cases, kmscon will revert to using the default mode, which is what kmscon always uses prior to this patch.
Also add intermediate error checks to the retry logic added in the previous commit.
61cdb46 to
9a6ba8c
Compare
Both use-original-mode and the desired-width/desired-height options tell kmscon to use a specific mode. If both of them are specified, it is ambiguous which one should take precedence. Instead, log an error telling the user about the problem and return an error code.
|
I have rebased and added an error message if --no-use-original-mode is not given. I added this check immediately after the check for |
|
Thanks for rebasing your PR. Instead of desired_width/desired_height, I would prefer one argument accepting a string, like: I don't think we really need the retry logic. |
|
The error I ran into when setting that mode is that the kernel didn't allocate enough memory to the framebuffers; I had to additionally add "video=widthxheight" to the kernel's command line in order for it to work. Without this, I was simply presented with a blank screen. The retry logic allows us to display something to the user in this case even though it's not exactly what they asked for. I can update the input format accordingly. |
|
Ok, that's a bit surprising that you need the video= kernel argument, but as you mention it's in a VM, that can explain it. Out of curiosity, which driver are you using in your VM? |
|
My responses might be a bit delayed, I'm working a shift job right now so my computer time during the week is limited. I uploaded a new commit which uses the updated input format. If the format is incorrect then kmscon will add a warning to the log and ignore the argument. As far as the driver goes, I think |
|
Thanks, your last upload looks good to me, I will merge it before the end of the week if no other comments. Regarding bochs-drm driver, maybe this memory problem has been fixed in the kernel with https://lists.freedesktop.org/archives/dri-devel/2024-August/466783.html that should be in v6.13+ |
Hi @Aetf! I prepared this change for personal use because I wanted a larger resolution in my VM, and wanted to offer it to you because it seems generally useful (and as noted below, other users have had this problem). I saw your README stating that this is a personal fork just because the upstream repository has not been updated in a long time, so if you don't want to deal with extra random patches being added that makes perfect sense, but since you have a repository that has been updated more recently I thought it made sense to offer it to you before going elsewhere. Let me know what you think! =)
Problem Being Solved
It is currently not possible to set the resolution that kmscon displays at. This was a pain point for me, using kmscon instead of agetty in a VM, because the mode it selected used less than half of my screen space. The unmaintained repository has an issue open about this, so it is a pain point for others too.
Solution
This commit adds 2 new arguments to the command-line interface, which allow the user to specify their desired resolution. This only works in DRM mode, because kmscon does not support modesetting in fbdev:
kmscon/src/uterm_fbdev_video.c
Line 149 in 662884a
Additionally, it only works if there is a mode which exactly matches the resolution specified. If no mode matches, or if fbdev is used, then the current behavior is preserved.
There are one root changes which facilitate this, another significant change which enables it, and some minor changes required for compatibility. The root change is that [the loop that selects a mode now checks if any mode matches the desired resolution, and sets it as the default if so]. This loop does not have direct access to the configuration data, so the desired width and height are stored in the uterm_video struct - this seemed like the least intrusive way to transfer the data, but I could update the commit to pass these values as separate arguments if desired. The other changes are related to making sure that the struct is fully initialized and updating the help output/man page.
Risks
These arguments can break kmscon if other system components are not configured correctly. In particular, on my VM kmscon initially output a blank screen due to an out of memory error. I had to pass video=1920x1080 as a kernel argument in order to resolve this issue. Restarting kmscon without specifying the resolution was sufficient to restore functionality.
I do not consider this commit to cause any regression because the behavior of the program is unchanged when the new arguments are not used.
Future Work
There are 2 items which I think are beyond the scope of this commit, but I will note as things I would like to add in the future (time allowing, a lot of things are up in the air right now for me).
First, using the mode that kmscon would previously select as a fallback mode when loading the desired resolution fails. In the case I encountered, it is easy to detect the fail state because the ioctl's that underlie either uterm_display_activate or uterm_display_swap return an out of memory error code. I tried adding simple logic to both of these functions to load the fallback mode, but this resulted in a screen that only rendered one line of output even though the correct mode was listed in the log output (and kmscon was clearly trying to print below the first line because the terminal didn't scroll after running commands, but the output was not rendered). As the fallback system is not needed to avoid a regression, I think it is fine for this to be considered out of scope for this commit.
Second, the test file does not allow for modesetting. I'm not sure what the scope of work required is here, since setting the mode after kmscon has initialized a display did not go well when I tried to do it for the fallback mode. I am less comfortable with having an untested feature than a less robust feature, if you happen to know what's needed here I'd love to hear about it.
Thank you for your consideration!
- Skyler