According to this:
The firmware and kernel as of 19. November 2012 supports CMA, which
means the memory split between ARM and GPU is managed dynamically at
runtime.
If you enable that, you should not have to do anything -- when you start X, if the GPU needs memory, it can request some from the CPU. The configuration goes in /boot/config.txt
and is explained in that elinux link. I've tried:
coherent_pool=6M
smsc95xx.turbo_mode=N
gpu_mem=128
cma_lwm=16
cma_hwm=32
This works with the latest stock raspbian kernel (3.10.25), but beware if you have a custom kernel you will need to enable CMA or this will give you grief. I don't think the first two directives are strictly necessary, YMMV.
Afterward, you should be able to run vcgencmd commands
and see a list including cma_config
and get_mem
(the last one requires a parameter, either arm
or gpu
). If you run free
, you should have a base mem of ~475 MB, more than the ~448 MB without CMA using the default 64 MB of video mem, even though gpu_mem=128
.
However...
If all you need the monitor for is special occasions ("usually after I mess up my SSH configuration"), you don't need this, and you don't two configurations either, because you'll get the most RAM (~497 MB) this way:
gpu_mem=8
No CMA configuration, etc. This is my preference, and I can plug in an HDMI monitor and start X. Most of the memory needed to run a GUI desktop is actually CPU memory.
In short, you don't need much gpu mem at all1 -- certainly the display will work with much less than the default 64 MB -- and you don't need two configurations.
1. Without having looked into it, I would guess most of time you could never use more than X resolution
x Y resolution
x 4 (32-bits/pixel) x 2 (double buffer?) bytes; e.g. for HD 1920 x 1080 x 4 x 2 = 16 MB -- and the use of a double buffer there is a big assumption, so likely only half that. Much larger amounts of GPU memory probably only come into play when openGL-ES, or some other special feature (GPU accelerated video playback) is in use.