17. 모니터의 성능을 그려보기

모니터 모드 다이어그램을 그려보려면 우선 gnuplot 패키지(Unix 류 운영체제 용의 공개된 플로팅 언어)와 modeplot 이라는 쉘/gnuplot 스크립트를 이용해 모니터의 특성치를 명령어 라인에서 입력해서 그려야 합니다.

다음은 modeplot 프로그램입니다.

#!/bin/sh
#
# modeplot -- generate X mode plot of available monitor modes
#
# Do `modeplot -?' to see the control options.
#

# Monitor description. Bandwidth in MHz, horizontal frequencies in kHz
# and vertical frequencies in Hz.
TITLE="Viewsonic 21PS"
BANDWIDTH=185
MINHSF=31
MAXHSF=85
MINVSF=50
MAXVSF=160
ASPECT="4/3"
vesa=72.5	# VESA-recommended minimum refresh rate

while [ "$1" != "" ] 
do
	case $1 in
	-t) TITLE="$2"; shift;; 
	-b) BANDWIDTH="$2"; shift;; 
	-h) MINHSF="$2" MAXHSF="$3"; shift; shift;; 
	-v) MINVSF="$2" MAXVSF="$3"; shift; shift;; 
	-a) ASPECT="$2"; shift;; 
	-g) GNUOPTS="$2"; shift;; 
	-?) cat <<EOF
modeplot control switches:

-t "<description>"	name of monitor            defaults to "Viewsonic 21PS"
-b <nn>           	bandwidth in MHz           defaults to 185
-h <min> <max>   	min & max HSF (kHz)        defaults to 31 85
-v <min> <max>   	min & max VSF (Hz)         defaults to 50 160
-a <aspect ratio>	aspect ratio               defaults to 4/3
-g "<options>"   	pass options to gnuplot

The -b, -h and -v options are required, -a, -t, -g optional.  You can
use -g to pass a device type to gnuplot so that (for example) modeplot's
output can be redirected to a printer.  See gnuplot(1) for  details.

The modeplot tool was created by Eric S. Raymond <esr@thyrsus.com> based on
analysis and scratch code by Martin Lottermoser <Martin.Lottermoser@mch.sni.de>

This is modeplot $Revision: 1.2 $
EOF
		exit;;
	esac
	shift
done

gnuplot $GNUOPTS <<EOF
set title "$TITLE Mode Plot"

# Magic numbers.  Unfortunately, the plot is quite sensitive to changes in
# these, and they may fail to represent reality on some monitors.  We need
# to fix values to get even an approximation of the mode diagram.  These come
# from looking at lots of values in the ModeDB database.
F1 = 1.30	# multiplier to convert horizontal resolution to frame width
F2 = 1.05	# multiplier to convert vertical resolution to frame height

# Function definitions (multiplication by 1.0 forces real-number arithmetic)
ac = (1.0*$ASPECT)*F1/F2
refresh(hsync, dcf) = ac * (hsync**2)/(1.0*dcf)
dotclock(hsync, rr) = ac * (hsync**2)/(1.0*rr)
resolution(hv, dcf) = dcf * (10**6)/(hv * F1 * F2)

# Put labels on the axes
set xlabel 'DCF (MHz)'
set ylabel 'RR (Hz)' 6	# Put it right over the Y axis

# Generate diagram
set grid
set label "VB" at $BANDWIDTH+1, ($MAXVSF + $MINVSF) / 2 left
set arrow from $BANDWIDTH, $MINVSF to $BANDWIDTH, $MAXVSF nohead
set label "max VSF" at 1, $MAXVSF-1.5
set arrow from 0, $MAXVSF to $BANDWIDTH, $MAXVSF nohead
set label "min VSF" at 1, $MINVSF-1.5
set arrow from 0, $MINVSF to $BANDWIDTH, $MINVSF nohead
set label "min HSF" at dotclock($MINHSF, $MAXVSF+17), $MAXVSF + 17 right
set label "max HSF" at dotclock($MAXHSF, $MAXVSF+17), $MAXVSF + 17 right
set label "VESA $vesa" at 1, $vesa-1.5
set arrow from 0, $vesa to $BANDWIDTH, $vesa nohead # style -1
plot [dcf=0:1.1*$BANDWIDTH] [$MINVSF-10:$MAXVSF+20] \
  refresh($MINHSF, dcf) notitle with lines 1, \
  refresh($MAXHSF, dcf) notitle with lines 1, \
  resolution(640*480,   dcf) title "640x480  " with points 2, \
  resolution(800*600,   dcf) title "800x600  " with points 3, \
  resolution(1024*768,  dcf) title "1024x768 " with points 4, \
  resolution(1280*1024, dcf) title "1280x1024" with points 5, \
  resolution(1600*1280, dcf) title "1600x1200" with points 6

pause 9999
EOF

일단 modeplot 와 gnuplot 패키지를 제대로 준비했다면 이제 다음 모니터 특성치가 필요합니다.

플롯 프로그램은 단순화시킨 조건하에서 그림을 그리게 됩니다. 이 조건이 항상 타당한 것은 아니므로 결과로 나오는 다이어그램은 대략적인 그림일 뿐입니다. 조건은 다음과 같습니다.

대략적인 값으로서 F1= 1.30, F2 = 1.05 정도로 잡습니다(프레임 크기를 계산하기 부분을 보세요).

이제 특정한 동기 주파수 HSF 를 생각해 봅시다. 방금 말한 가정하에서 보면, 클럭 레이트 DCF 의 모든 값은 이미 리프레쉬 레이트 RR 을 결정짓습니다. 즉, HSF 의 모든 값에 대한 함수값 RR(DCF)가 존재하는 것입니다. 이는 다음과 같이 유도됩니다.

리프레쉬 레이트는 프레임 사이즈들의 곱으로 클럭 레이트를 나눈 값과 같습니다.

       RR = DCF / (HFL * VFL)            (*)

한편, 수평 프레임 길이는 수평 동기주파수로 클럭 레이트를 나눈 값과 같습니다.

       HFL = DCF / HSF                   (**)

VFL 가 HFL 로 귀결될수 있는 것은 위의 두가지 가정 때문입니다.

       VFL = F2 * VR
           = F2 * (HR / AR)
           = (F2/F1) * HFL / AR          (***)

(**) 와 (***) 를 (*) 에 넣으면 다음을 얻습니다.

                      RR = DCF / ((F2/F1) * HFL**2 / AR)
                         = (F1/F2) * AR * DCF * (HSF/DCF)**2
                         = (F1/F2) * AR * HSF**2 / DCF

고정된 HSF, F1, F2 ,AR 에 대해서 다이어그램에는 쌍곡선이 하나 나타납니다. 수평 동기주파수의 최소값과 최대값에 대해 이와같은 커브를 그리면 두개의 경계선을 가지게 되고 그 사이가 바로 가능한 영역입니다.

가능한 영역을 가로지르는 직선들은 특정한 해상도를 나타냅니다. 이것은 (*) 와 두번째 가정에 근거합니다.

                      RR = DCF / (HFL * VFL) = DCF / (F1 * HR * F2 * VR)

원하는 모든 해상도에 대해 이런 라인을 그려봄으로써 당신은 즉각 그 모니터에서 가능한 해상도, 클럭 레이트, 리프레쉬레이트간의 관계를 알아챌 수 있습니다. 이들 라인들은 모니터의 특성에 의존하는 것이 아니라 두번째 가정에서 비롯되는 것임에 주의하십시요.

modeplot 프로그램은 이것을 쉽게 보여줍니다. modeplot -? 하면 그 옵션을 알 수 있습니다. 대표적인 예는 다음과 같습니다.

             modeplot -t "Swan SW617" -b 85 -v 50 90 -h 31 58

-b 옵션은 비디오 대역폭을 지정합니다; -v 와 -h 는 각각 수평과 수직 동기 주파수의 범위를 설정합니다.

modeplot의 출력을 읽을 때는 항상 이것이 대략적인 묘사에 불과함에 유념하십시요. 예를 들자면, 동기 펄스는 최소한 일정 폭을 필요로 하며, 따라서 이에 비롯한 HFL 값에 제약이 있음을 이 프로그램은 무시하고 있습니다. 또한 그림의 정확도는 가정들의 타당성에 좌우됩니다. 따라서 종합 부분에서 제시한 것과 같은 정밀한 계산(위에서 부린 마술같은 것)을 대신할 수는 없습니다. 하지만 이 프로그램을 통해 무엇이 가능하고 어떤 타협이 가능한지에 대해 감을 잡을수는 있을 것입니다.