NeXTSTEPDRIVERKIT:Chapter3 3

From 흡혈양파의 번역工房
Jump to navigation Jump to search
Display Devices

디스플레이 장치

A driver for a display card is a subclass of one of these two classes:
디스플레이 카드용 드라이버는 이 두 클래스 중 하나의 하위 클래스가 됩니다.

  • IOFrameBufferDisplay, for cards that can linearly map the entire frame buffer
    IOFrameBufferDisplay, 전체 프레임 버퍼를 선형 매핑(linearly map)[1][2] 할 수 있는 카드
  • IOSVGADisplay, for other display cards
    IOSVGADisplay, 다른 디스플레이 카드


Figure 3-1 shows display device classes' position in the Driver Kit class hierarchy.
그림 3-1 은 Driver Kit 클래스 계층에서 디스플레이 장치 클래스의 위치를 ​​보여줍니다.


IOFrameBufferDisplay supports the following modes:
IOFrameBufferDisplay는 다음 모드를 지원합니다:

  • 2-bit grayscale
  • 8-bit grayscale
  • 8-bit color
  • 16-bit color (4 or 5 bits each for red, green, and blue, but only 4096 colors in either case)
  • 24-bit color (8 bits each for red, green, and blue).


IOSVGADisplay supports only 2-bit grayscale.
IOSVGADisplay는 2 비트 회색조만 지원합니다.


Note: All display cards with VGA support work with NEXTSTEP. Without special drivers, however, they have a small display area (640480) and are 2-bit grayscale.
Note: VGA를 지원하는 모든 디스플레이 카드는 NEXTSTEP 과 호환됩니다. 하지만 특별한 드라이버가 없다면, 2 비트 회색조의 작은 디스플레이 영역 (640480)을 가지게 됩니다.


Both classes support EISA and VL-Bus display cards. A limited number of ISA display cards are supported for performance reasons. PCI display cards are supported, but not PCMCIA display cards.
두 클래스 모두 EISA 및 VL-Bus 디스플레이 카드를 지원합니다. 성능상의 이유로 제한된 수의 ISA 디스플레이 카드만 지원됩니다. PCI 디스플레이 카드는 지원되지만 PCMCIA 디스플레이 카드[3]는 지원되지 않습니다.


Driver Kit display drivers are simpler than their DOS or WindowsTMcounterparts because they perform no graphics operations--the Window Server handles all graphics.
Driver Kit 디스플레이 드라이버는 그래픽 작업을 수행하지 않기 때문에 DOS 또는 WindowsTMcounterparts 보다는 간단합니다. (NeXTSTEP 에서는)Window Server 가 모든 그래픽을 처리합니다.


See the IODisplay, IOFrameBufferDisplay, and IOSVGADisplay class specifications for additional information about how to implement a driver.
드라이버를 구현하는 방법에 대한 추가 정보는 IODisplay, IOFrameBufferDisplay 및 IOSVGADisplay 클래스 사양(specifications)을 참조하십시오.


Directories in /NextDeveloper/Examples/DriverKit with examples of video drivers include ATI, CirrusLogicGD542X, QVision, S3, and TsengLabsET4000.
ATI, CirrusLogicGD542X, QVision, S3 및 TsengLabsET4000과 같은 비디오 드라이버의 예가 포함 된 /NextDeveloper/Examples/DriverKit 의 디렉토리.

Figure 3-2. Classes for Display Drivers


개발 요구사항(Development Requirements)

The following hardware is required or recommended for development and support efforts:
개발 및 지원 노력을 위해 다음의 하드웨어가 필요하거나 권장됩니다.

  • A workstation with NEXTSTEP User and Developer software
    NEXTSTEP 사용자 및 개발자 소프트웨어가 (설치되어)있는 워크스테이션
  • A second NEXTSTEP workstation for the target system (optional, but recommended)
    타겟 시스템을 위한 두 번째 NEXTSTEP 워크스테이션 (선택적이지만 권장 됨)
  • Adapter hardware
    어댑터(그래픽) 하드웨어
  • Multisync monitor
    멀티싱크 모니터
  • Frequency counter (optional, but recommended)
    주파수(Frequency) 카운터 (선택 사항이지만 권장 됨)
  • Oscilloscope (optional)
    오실로스코프(선택 사항)


프레임 버퍼 주소 범위 설정(Setting the Frame Buffer Address Range)

If you implement an IOFrameBufferDisplay driver, you must supply the frame buffer memory range as the first range in the memory range list. This is normally done by placing this range as the first range of the "Memory Maps" key in Default.table. (You can also set this list with the setMemoryRangeList:num: method in IODeviceDescription.) The value should be the physical address memory byte range of the frame buffer. This range should be high in memory--above 2 GB, for example--to avoid conflicting with physical memory.
IOFrameBufferDisplay 드라이버를 구현하는 경우 메모리 범위 목록의 첫 번째 범위로 프레임 버퍼 메모리 범위(frame buffer memory range)를 제공해야 합니다. 이 작업은 일반적으로 범위를 Default.table 의 "Memory Maps" 키의 첫 번째 범위로 배치하는 것으로 수행됩니다. (IODeviceDescription에서 setMemoryRangeList:num: 메소드를 사용해서 이 목록을 설정할 수도 있습니다.) 이 값은 프레임 버퍼의 실제 주소 메모리 바이트 범위여야 합니다. 이 범위는 실제 메모리와의 충돌을 피하기 위해서, 예를 들자면 2GB 보다 높은 메모리가 되어야 합니다.


On PCI-based systems, the BIOS attempts to allocate the frame buffer address range for you. The BIOS places this address range in the PCI configuration data but not in the device description, so you need to update the device description with this range. Furthermore, the BIOS doesn't always succeed in determining a valid frame buffer address, so you need to check the address. Follow these steps to check and set the frame buffer address range for PCI-based systems:
PCI 기반 시스템에서 BIOS 는 프레임 버퍼 주소 범위를 할당하려고 시도합니다. BIOS는이 주소 범위를 PCI 구성 데이터에 배치하지만 장치 설명에는 배치하지 않기때문에, 이 범위를 장치 설명(device description)에 업데이트[4]해야 합니다. 또한 BIOS가 유효한 프레임 버퍼 주소를 결정하는 데 항상 성공하는건 아니기 때문에 주소는 확인해야 합니다. 다음 단계에 따라 PCI 기반 시스템의 프레임 버퍼 주소 범위를 확인하고 설정하십시오:

  1. Get the memory ranges from the device description by invoking IODeviceDescription's memoryRangeList method. The frame buffer address range is the first one in the list--this is the range value provided in the Default.table.
    IODeviceDescription 의 memoryRangeList 메소드를 호출하여 장치 설명(device description)에서 메모리 범위를 가져옵니다. 프레임 버퍼 주소 범위는 목록의 첫 번째 주소 범위입니다. 이 주소는 Default.table 에 제공된 범위값입니다.
  2. Get the PCI configuration space's frame address range, which was determined by the BIOS. Read the PCI configuration space by using the getPCIConfigData:atRegister:withDeviceDescription: method. Consult your device's hardware specifications to determine which PCI register holds the frame buffer address.
    BIOS 가 결정한 PCI 설정 공간(PCI configuration space)의 프레임 주소 범위를 가져옵니다. getPCIConfigData:atRegister:withDeviceDescription: 메소드를 사용해서 PCI 구성 공간을 읽습니다. 어떤 PCI 레지스터가 프레임 버퍼 주소를 보유하고 있는지를 확인하려면 장치의 하드웨어 사양을 참조하십시오.
  3. Check that the range's starting address is greater than or equal to 4 MB and correctly aligned for your hardware.
    범위의 시작 주소가 4MB 이상이며 하드웨어에 맞게 정렬되어 있는지를 확인하십시오.
  4. If the address is invalid, don't update the device description with this range. Instead, update the PCI configuration space with the range from the device description. Take the device description's address range you determined in the first step and write it to the PCI configuration space using the setPCIConfigData:atRegister:withDeviceDescription: method.
    주소가 유효하지 않으면이 범위의 장치 설명을 업데이트하지 마십시오. 그 대신에 장치 설명(device description)의 범위를 사용해서 PCI 설정 공간을 업데이트 하십시오. 첫 번째 단계에서 결정한 장치 설명의 주소 범위를 가져온 다음에 setPCIConfigData:atRegister:withDeviceDescription: 메소드를 사용해서 PCI 설정 공간에 작성합니다.
  5. If the address is valid, update the device description. Replace the first range in the list you obtained in step 1 with the range you got from the PCI configuration. Set the ranges with the setMemoryRangeList:num: method in IODeviceDescription.
    주소가 유효하다면 장치 설명을 갱신하십시오. 1 단계에서 얻은 목록의 첫 번째 범위를 PCI 구성에서 가져온 범위로 바꿉니다. IODeviceDescription 에서 setMemoryRangeList:num: 메서드를 사용하여 범위를 설정합니다. PCI 기반 드라이버의 경우 probe: 는 "Setting the Frame Buffer Address Range"에 표시된대로 프레임 버퍼 범위 주소를 확인하고 설정해야 하며, IOFrameBufferDisplay 또는 IOSVGADisplay 의 드라이버 인스턴스를 생성해야 합니다.


You should go through these steps in your probe: method, prior to invoking 'initFromDeviceDescription:'.
initFromDeviceDescription: 을 호출하기 전에 probe: 메소드에서 다음 단계를 수행해야합니다.


기본 작업(Basic Operations)

A display driver must perform the following basic operations:
디스플레이 드라이버는 다음과 같은 기본 작업을 수행해야합니다.

  • Instantiating and initializing a driver object
    드라이버 객체 인스턴스화 및 초기화
  • Selecting the display mode
    디스플레이 모드 선택
  • Reconfiguring display hardware for the selected display mode
    선택한 디스플레이 모드에 맞게 디스플레이 하드웨어 재구성
  • Reverting to VGA display mode
    VGA 디스플레이 모드로 되돌리기
  • Adjusting display brightness
    디스플레이 밝기 조정


드라이버 객체 인스턴스화 및 초기화(Instantiating and Initializing a Driver Object)

Override the probe: method in IODevice. Your probe: method should find and characterize the hardware. It must verify the presence and operation of the graphics controller (CRTC) and determine its revision. The probe: method should also determine the DAC type, the memory size, and the clock chip type, if necessary. For PCI-based drivers, probe: should check and set the frame buffer range address, as indicated in "Setting the Frame Buffer Address Range." It should create a driver instance of IOFrameBufferDisplay or IOSVGADisplay. If invalid values are found during verification, the method shouldn't create a driver instance but should send an appropriate diagnostic message and return NO.
IODevice 에서 probe: 메소드를 재정의 하십시오. probe: 메소드는 하드웨어를 찾아 특징(characterize)지어야 합니다. 그래픽 컨트롤러(CRTC)의 존재 여부와 동작을 확인하고 버전을 결정해야합니다. 또한 probe: 메서드는 필요한 경우 DAC 유형, 메모리 크기 및 클럭칩 유형을 결정해야 합니다. PCI 기반 드라이버의 경우 probe: 는 "Setting the Frame Buffer Address Range"에 표시된대로 프레임 버퍼 범위 주소를 확인하고 설정해야 하며, IOFrameBufferDisplay 또는 IOSVGADisplay 의 드라이버 인스턴스를 생성해야 합니다. 확인하는 동안 유효하지 않은 값이 발견되면 이 메소드는 드라이버 인스턴스를 생성해서는 안되기 때문에, 적절한 진단 메시지를 보내고 NO 를 반환해야합니다.


Note: Instead of using probe:, the current display driver examples use initFromDeviceDescription: to perform all this initialization, because they were written before the API was fully developed. The probe: method is preferred.
Note: 'probe:' 를 사용하는 대신에 현재 디스플레이 드라이버 예제에서는 'initFromDeviceDescription:' 을 사용해서 이 초기화를 모두 수행하는데, 문서 자체가 API 가 완전히 개발되기 전에 작성 되었기 때문입니다. probe: 방법이 선호됩니다.


디스플레이 모드 선택

IOFrameBufferDisplay's method selectMode:count:valid: selects the display mode for you. To use it, you need to declare an IODisplayInfo array with one element per mode and initialize it, as in this example:
IOFrameBufferDisplay 의 selectMode:count:valid: 메소드는 사용자를 위한 디스플레이 모드를 선택합니다. 이를 사용하려면, 다음의 예제처럼, 모드 당 하나의 요소를 가진 IODisplayInfo 배열을 선언하고 초기화해야 합니다:

const IODisplayInfo QVisionModeTable[] = {
    /* 0: QVision 1024 x 768 x 8 (Mode 0x38) @ 60Hz. */
    {
        1024, 768, 1024, 1024, 60, 0,
        IO_8BitsPerPixel, IO_OneIsWhiteColorSpace, "WWWWWWWW",
        0, (void *)&Mode_38_60Hz,
    },

    /* 1: QVision 1024 x 768 x 8 (Mode 0x38) @ 66Hz. */
    {
        1024, 768, 1024, 1024, 66, 0,
        IO_8BitsPerPixel, IO_OneIsWhiteColorSpace, "WWWWWWWW",
        0, (void *)&Mode_38_66Hz,
    },
}


Declare an array of boolean values with one element per display mode and fill it. In the following example, italicized text delineated in angle brackets, that is << >>, is to be filled in with driver-specific code.
표시 모드(display mode)당 하나의 요소로 부울(boolean) 값의 배열을 선언하고 채웁니다. 다음 예에서 꺾쇠 괄호로 표시된 기울임 꼴 텍스트, 즉 << >> 는 드라이버 관련 코드로 채워집니다.

BOOL validModes[QVisionModeTableCount];

for (k = 0; k < QVisionModeTableCount; k++) {
    if (<< current hardware supports this mode >>)
        validModes[k] = YES;
    else
        validModes[k] = NO;
}


Finally, send a message to select a mode and handle the result, as this code section illustrates:
마지막으로, 모드를 선택하고 결과를 처리하라는 메시지를 보냅니다:

mode = [self selectMode:QVisionModeTable count:QVisionModeTableCount valid:validModes];

if (mode < 0) {
    IOLog("%s: Sorry, cannot use requested display mode.\n",
            [self name]);

    /*
     * Pick a reasonable default
     */
    mode = DEFAULT_QVISION_MODE;
}


선택한 디스플레이 모드에 맞게 디스플레이 하드웨어를 재설정

Using the appropriate commands for your display hardware, reconfigure it for the selected mode with these operations, the order of which is hardware-dependent:
디스플레이 하드웨어에 적절한 명령을 사용해서, 앞의 작업으로 선택한 모드에 맞게 명령을 재설정하는데, 순서는 하드웨어에 따라 다릅니다:

  • Turn off the CRTC
  • Configure the CRTC
  • Configure the DAC
  • Configure the clock chip
  • Configure memory, if necessary
  • Restart the CRTC
  • Enable linear frame buffer mode


VGA 디스플레이 모드로 되돌리기(Reverting to VGA Display Mode)

Return the adapter to the state it would be in after a hard reset, and, in the typical case, set VGA mode to 3.
어댑터의 상태(state)를 하드 리셋 한 후로 되돌리고, 전형적인 경우 VGA 모드를 3 으로 설정하십시오.


디스플레이 밝기 조정

If the hardware supports changing the brightness of the display, implement the setBrightness:token: and use the setTransferTable:count: method to adjust it as desired.
하드웨어가 디스플레이 밝기 변경을 지원하면 setBrightness:token: 을 구현하고 setTransferTable:count: 메서드를 사용해서 원하는대로 조정하십시오.


If the DAC supports downloading a color palette, override setTransferTable:count: to receive a gamma-corrected transfer table from the Window Server, or declare your own table in a static array. Override setBrightness:token: and then download the transfer table to the DAC. Look at an example of the setGammaTable method in one of the display driver examples in /NextDeveloper/Examples/DriverKit. Finally, indicate that you've implemented a transfer table by setting a flag:
DAC가 컬러 팔레트 다운로드를 지원하는 경우라면, setTransferTable:count: 를 재정의(override)해서 Window Server 에서 감마보정된 전송 테이블을 받거나 정적 배열에 자체 테이블을 선언하십시오. setBrightness:token: 을 재정의(Override)한 다음, DAC 에 전송 테이블을 다운로드합니다. /NextDeveloper/Examples/DriverKit 의 디스플레이 드라이버 예제 중 하나에서 setGammaTable 메서드의 예제를 살펴보십시오. 마지막으로 플래그를 설정(setting)해서 전송 표(transfer table)를 구현했음을 나타내면(indicate) 됩니다.

displayInfo->flags |= IO_DISPLAY_HAS_TRANSFER_TABLE;


If the DAC doesn't support downloading a color palette, don't override these methods, and set the flag to indicate there's no transfer table:
DAC 가 컬러 팔레트 다운로드를 지원하지 않는 경우라면, 이 메서드를 재정의하지 말고 플래그가 전송 테이블이 없음을 나타내도록 설정하십시오:

displayInfo->flags |= IO_DISPLAY_NEEDS_SOFTWARE_GAMMA_CORRECTION;


Notes

  1. display card 상의 화면 표시용 메모리 버퍼가 2중배열등이 아닌 선형구조이기 때문에. 예를들어 비디오메모리가 1GB 짜리 카드가 있으면 mmap 으로 0x00000000 ~ 0x40000000 까지 매핑하면 이걸 linearly map 이라고 한다. 프레임버퍼 영역을 cpu 에서 사용할 수 있게 특정 연속된 주소로 매핑.
  2. 비디오 메모리 100메가짜리 카드가 있다고 가정했을때, 그중 맨 앞부분의 16MB 가 모니터에 그대로 표시된다고 하면, 이를 frame buffer 라고 보통 부르며(vga 의 프레임 버퍼), 화면에 뭔가를 표시하려면(점을 찍으려면) cpu 가 access 할 수 있어야 하는데 그 16MB 를 0x0000000 ~ 0x0200000 쯤의 주소로 묶어주는게 mmap 이다(32bit 주소체계). 그래서 0x0100000 주소 쯤에 0xFFFFFFFF 값을 쓰면 점이 찍힌다.
  3. 정말 이런 물건이 있기는 합니다. https://www.cnet.com/products/appian-traveler-graphics-card-4-mb/specs/
  4. 이전 장에서 봤다시피 꺽쇠괄호로 묶인 부분