Raspberry Piでコンポジットで起動した後に解像度やディスプレイを変更する

コンポジット出力の解像度変更

Raspberry Piを起動するときにHDMIを接続した状態で起動すると高解像度で起動しますが,繋いでいないとコンポジット出力で起動してXの解像度が720×480になってちょっと手狭です.
xrandrで解像度を追加するとXの再起動もせずに高解像度に出来ます.

※xrandrコマンドは対象のX端末上か,DISPLAY変数を対象のものを指定して実行すること

  • 720x480しか選べない
$ xrandr 
Screen 0: minimum 320 x 200, current 720 x 480, maximum 2048 x 2048
HDMI-0 disconnected (normal left inverted right x axis y axis)
Composite-0 unknown connection 720x480+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
   720x480       62.69* 
DSI-0 disconnected (normal left inverted right x axis y axis)
  • cvtコマンドで設定したい解像度を指定してModelineを調べる
$ cvt 1360 768
# 1360x768 59.80 Hz (CVT) hsync: 47.72 kHz; pclk: 84.75 MHz
Modeline "1360x768_60.00"   84.75  1360 1432 1568 1776  768 771 781 798 -hsync +vsync
  • xrandrのmodeを作成する
$ xrandr --newmode "1360x768_60.00"   84.75  1360 1432 1568 1776  768 771 781 798 -hsync +vsync
  • modeが増えている
$ xrandr 
Screen 0: minimum 320 x 200, current 720 x 480, maximum 2048 x 2048
HDMI-0 disconnected (normal left inverted right x axis y axis)
Composite-0 unknown connection 720x480+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
   720x480       62.69* 
DSI-0 disconnected (normal left inverted right x axis y axis)
  1360x768_60.00 (0x248) 84.750MHz
        h: width  1360 start 1432 end 1568 total 1776 skew    0 clock  47.72KHz
        v: height  768 start  771 end  781 total  798           clock  59.80Hz
  • modeをComposite-0に追加する
$ xrandr --addmode Composite-0 1368x768_60.00
$ xrandr 
Screen 0: minimum 320 x 200, current 720 x 480, maximum 2048 x 2048
HDMI-0 disconnected (normal left inverted right x axis y axis)
Composite-0 unknown connection 720x480+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
   720x480       62.69* 
   1360x768_60.00  59.80  
DSI-0 disconnected (normal left inverted right x axis y axis)
  • 設定したmodeに切り替える
$ xrandr --output Composite-0 --mode 1360x768_60.00

起動後にHDMIに切り替える

解像度の変更ではなく起動後にHDMI接続に切り替えるのもxrandrで出来ます.こちらもXの再起動は必要ありません.

  • HDMIケーブルを接続するとHDMI-0 connectedとなってmodeが選べるようになる
$ xrandr 
Screen 0: minimum 320 x 200, current 1366 x 768, maximum 2048 x 2048
HDMI-0 connected 1366x768+0+0 (normal left inverted right x axis y axis) 580mm x 360mm
   1366x768      59.79*+
   1920x1080     60.00    59.94  
   1920x1080i    60.00    50.00    59.94  
   1280x1024     60.02  
   1152x864      75.00  
   1280x720      60.00    58.68    50.00    59.94  
   1024x768      75.03    70.07    60.00  
   832x624       74.55  
   800x600       72.19    75.00    60.32    56.25  
   720x576       50.00  
   720x576i      50.00  
   720x480       60.00    59.94  
   720x480i      60.00    59.94  
   640x480       75.00    72.81    66.67    60.00    59.94  
   720x400       70.08  
Composite-0 unknown connection (normal left inverted right x axis y axis)
   720x480       62.69  
   1360x768_60.00  59.80  
DSI-0 disconnected (normal left inverted right x axis y axis)
  • 一度にコンポジットを無効にしてHDMIを有効にしようとするとエラーとなる
$ xrandr --output Composite-0 --off --output HDMI-0 --auto
xrandr: cannot find crtc for output HDMI-0
  • 一度に行うのではなく先にコンポジットを無効にしてからHDMIを有効にするとうまく行った
$ DISPLAY=:0 xrandr --output Composite-0 --off
$ DISPLAY=:0 xrandr --output HDMI-0 --auto
  • 逆にHDMIからコンポジットに切り替えることも出来る
$ xrandr --output HDMI-0 --off
$ xrandr --output Composite-0 --mode 1360x768_60.00

環境

  • HW : Raspberry Pi B 2
$ screenfetch 
    .',;:cc;,'.    .,;::c:,,.    pi@raspberrypi
   ,ooolcloooo:  'oooooccloo:    OS: Unknown 8.0 jessie
   .looooc;;:ol  :oc;;:ooooo'    Kernel: armv7l Linux 4.9.11-v7+
     ;oooooo:      ,ooooooc.     Uptime: 4h 28m
       .,:;'.       .;:;'.       Packages: 1541
       .... ..'''''. ....        Shell: 3362
     .''.   ..'''''.  ..''.      Resolution: 1368x768
     ..  .....    .....  ..      DE: LXDE lxpanel 0.7.2
    .  .'''''''  .''''''.  .     WM: OpenBox
  .'' .''''''''  .'''''''. ''.   GTK Theme: Clearlooks [GTK2], Not Found [GTK3]
  '''  '''''''    .''''''  '''   Icon Theme: nuoveXT2
  .'    ........... ...    .'.   Font: Sans 10
    ....    ''''''''.   .''.     CPU: ARMv7 rev 5 (v7l) @ 900MHz
    '''''.  ''''''''. .'''''     RAM: 258MB / 922MB
     '''''.  .'''''. .'''''.    
      ..''.     .    .''..      
            .'''''''            
             ......