Applied patch by Gerald Zajac: Adds hardware overlay support to the ATI
mach64/Rage driver. Resolves #5314. Thanks! git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42335 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
a2d074a765
commit
124cdd4f57
@ -1,9 +1,9 @@
|
||||
/*
|
||||
Copyright 2007-2009 Haiku, Inc. All rights reserved.
|
||||
Copyright 2007-2011 Haiku, Inc. All rights reserved.
|
||||
Distributed under the terms of the MIT license.
|
||||
|
||||
Authors:
|
||||
Gerald Zajac 2007-2009
|
||||
Gerald Zajac
|
||||
*/
|
||||
|
||||
#ifndef DRIVERINTERFACE_H
|
||||
@ -14,6 +14,7 @@
|
||||
#include <GraphicsDefs.h>
|
||||
#include <Drivers.h>
|
||||
#include <edid.h>
|
||||
#include <video_overlay.h>
|
||||
|
||||
|
||||
// This file contains info that is shared between the kernel driver and the
|
||||
@ -163,6 +164,12 @@ struct DisplayModeEx : display_mode {
|
||||
};
|
||||
|
||||
|
||||
struct OverlayBuffer : overlay_buffer {
|
||||
OverlayBuffer* nextBuffer; // pointer to next buffer in chain, NULL = none
|
||||
uint32 size; // size of overlay buffer
|
||||
};
|
||||
|
||||
|
||||
struct SharedInfo {
|
||||
// Device ID info.
|
||||
uint16 vendorID; // PCI vendor ID, from pci_info
|
||||
@ -180,8 +187,8 @@ struct SharedInfo {
|
||||
area_id regsArea; // area_id for the memory mapped registers. It will
|
||||
// be cloned into accelerant's address space.
|
||||
area_id videoMemArea; // video memory area_id. The addresses are shared with all teams.
|
||||
void* videoMemAddr; // video memory addr as viewed from virtual memory
|
||||
void* videoMemPCI; // video memory addr as viewed from the PCI bus (for DMA)
|
||||
addr_t videoMemAddr; // video memory addr as viewed from virtual memory
|
||||
phys_addr_t videoMemPCI; // video memory addr as viewed from the PCI bus (for DMA)
|
||||
uint32 videoMemSize; // video memory size in bytes.
|
||||
|
||||
uint32 cursorOffset; // offset of cursor in video memory
|
||||
@ -209,6 +216,11 @@ struct SharedInfo {
|
||||
bool bHaveEDID; // true = EDID info from device is in edidInfo
|
||||
|
||||
Benaphore engineLock; // for serializing access to the acceleration engine
|
||||
Benaphore overlayLock; // for overlay operations
|
||||
|
||||
int32 overlayAllocated; // non-zero if overlay is allocated
|
||||
uint32 overlayToken;
|
||||
OverlayBuffer* overlayBuffer; // pointer to linked list of buffers; NULL = none
|
||||
|
||||
MonitorType displayType;
|
||||
|
||||
@ -227,7 +239,7 @@ struct SharedInfo {
|
||||
R128_RAMSpec r128MemSpec; // Rage128 memory timing spec's
|
||||
R128_PLLParams r128PLLParams; // Rage128 PLL parameters from video BIOS ROM
|
||||
|
||||
uint32 r128_dpGuiMasterCntl; // flags for accelerated drawing
|
||||
uint32 r128_dpGuiMasterCntl; // flags for accelerated drawing
|
||||
};
|
||||
|
||||
|
||||
|
@ -10,12 +10,14 @@ Addon ati.accelerant :
|
||||
engine.cpp
|
||||
hooks.cpp
|
||||
mode.cpp
|
||||
overlay.cpp
|
||||
|
||||
mach64_cursor.cpp
|
||||
mach64_dpms.cpp
|
||||
mach64_draw.cpp
|
||||
mach64_init.cpp
|
||||
mach64_mode.cpp
|
||||
mach64_overlay.cpp
|
||||
mach64_util.cpp
|
||||
|
||||
rage128_cursor.cpp
|
||||
@ -23,6 +25,7 @@ Addon ati.accelerant :
|
||||
rage128_draw.cpp
|
||||
rage128_init.cpp
|
||||
rage128_mode.cpp
|
||||
rage128_overlay.cpp
|
||||
|
||||
: be libaccelerantscommon.a
|
||||
;
|
||||
|
@ -1,9 +1,9 @@
|
||||
/*
|
||||
Copyright 2007-2009 Haiku, Inc. All rights reserved.
|
||||
Copyright 2007-2011 Haiku, Inc. All rights reserved.
|
||||
Distributed under the terms of the MIT license.
|
||||
|
||||
Authors:
|
||||
Gerald Zajac 2007-2009
|
||||
Gerald Zajac
|
||||
*/
|
||||
|
||||
#ifndef _ACCELERANT_H
|
||||
@ -52,22 +52,27 @@ struct AccelerantInfo {
|
||||
status_t (*SetDPMSMode)(uint32 dpms_flags);
|
||||
|
||||
// Pointers to cursor functions.
|
||||
bool (*LoadCursorImage)(int width, int height, uint8* and_mask, uint8* xor_mask);
|
||||
bool (*LoadCursorImage)(int width, int height, uint8* and_mask,
|
||||
uint8* xor_mask);
|
||||
void (*SetCursorPosition)(int x, int y);
|
||||
void (*ShowCursor)(bool bShow);
|
||||
|
||||
// Pointers to 2D acceleration functions.
|
||||
void (*FillRectangle)(engine_token*, uint32 color, fill_rect_params*, uint32 count);
|
||||
void (*FillSpan)(engine_token*, uint32 color, uint16* list, uint32 count);
|
||||
void (*FillRectangle)(engine_token*, uint32 color, fill_rect_params*,
|
||||
uint32 count);
|
||||
void (*FillSpan)(engine_token*, uint32 color, uint16* list,
|
||||
uint32 count);
|
||||
void (*InvertRectangle)(engine_token*, fill_rect_params*, uint32 count);
|
||||
void (*ScreenToScreenBlit)(engine_token*, blit_params*, uint32 count);
|
||||
|
||||
// Pointers to other functions.
|
||||
void (*AdjustFrame)(const DisplayModeEx& mode);
|
||||
status_t (*ChipInit)(void);
|
||||
bool (*GetColorSpaceParams)(int colorSpace, uint8& bpp, uint32& maxPixelClk);
|
||||
bool (*GetColorSpaceParams)(int colorSpace, uint8& bpp,
|
||||
uint32& maxPixelClk);
|
||||
status_t (*SetDisplayMode)(const DisplayModeEx& mode);
|
||||
void (*SetIndexedColors)(uint count, uint8 first, uint8* color_data, uint32 flags);
|
||||
void (*SetIndexedColors)(uint count, uint8 first, uint8* color_data,
|
||||
uint32 flags);
|
||||
};
|
||||
|
||||
extern AccelerantInfo gInfo;
|
||||
@ -95,15 +100,18 @@ sem_id AccelerantRetraceSemaphore(void);
|
||||
// Mode Configuration
|
||||
uint32 AccelerantModeCount(void);
|
||||
status_t GetModeList(display_mode* dm);
|
||||
status_t ProposeDisplayMode(display_mode* target, const display_mode* low, const display_mode* high);
|
||||
status_t ProposeDisplayMode(display_mode* target, const display_mode* low,
|
||||
const display_mode* high);
|
||||
status_t SetDisplayMode(display_mode* mode_to_set);
|
||||
status_t GetDisplayMode(display_mode* current_mode);
|
||||
status_t GetFrameBufferConfig(frame_buffer_config* a_frame_buffer);
|
||||
status_t GetPixelClockLimits(display_mode* dm, uint32* low, uint32* high);
|
||||
status_t MoveDisplay(uint16 h_display_start, uint16 v_display_start);
|
||||
status_t GetTimingConstraints(display_timing_constraints* dtc);
|
||||
void Mach64_SetIndexedColors(uint count, uint8 first, uint8* color_data, uint32 flags);
|
||||
void Rage128_SetIndexedColors(uint count, uint8 first, uint8* color_data, uint32 flags);
|
||||
void Mach64_SetIndexedColors(uint count, uint8 first, uint8* color_data,
|
||||
uint32 flags);
|
||||
void Rage128_SetIndexedColors(uint count, uint8 first, uint8* color_data,
|
||||
uint32 flags);
|
||||
status_t GetPreferredDisplayMode(display_mode* preferredMode);
|
||||
status_t GetEdidInfo(void* info, size_t size, uint32* _version);
|
||||
|
||||
@ -118,27 +126,50 @@ status_t Rage128_SetDPMSMode(uint32 dpms_flags);
|
||||
|
||||
// Cursor
|
||||
status_t SetCursorShape(uint16 width, uint16 height, uint16 hot_x, uint16 hot_y,
|
||||
uint8* andMask, uint8* xorMask);
|
||||
uint8* andMask, uint8* xorMask);
|
||||
void MoveCursor(uint16 x, uint16 y);
|
||||
|
||||
// Engine Management
|
||||
uint32 AccelerantEngineCount(void);
|
||||
status_t AcquireEngine(uint32 capabilities, uint32 max_wait, sync_token* st, engine_token** et);
|
||||
status_t AcquireEngine(uint32 capabilities, uint32 max_wait, sync_token* st,
|
||||
engine_token** et);
|
||||
status_t ReleaseEngine(engine_token* et, sync_token* st);
|
||||
void WaitEngineIdle(void);
|
||||
status_t GetSyncToken(engine_token* et, sync_token* st);
|
||||
status_t SyncToToken(sync_token* st);
|
||||
|
||||
// 2D acceleration
|
||||
void Mach64_FillRectangle(engine_token* et, uint32 color, fill_rect_params* list, uint32 count);
|
||||
void Mach64_FillSpan(engine_token* et, uint32 color, uint16* list, uint32 count);
|
||||
void Mach64_InvertRectangle(engine_token* et, fill_rect_params* list, uint32 count);
|
||||
void Mach64_ScreenToScreenBlit(engine_token* et, blit_params* list, uint32 count);
|
||||
void Mach64_FillRectangle(engine_token* et, uint32 color,
|
||||
fill_rect_params* list, uint32 count);
|
||||
void Mach64_FillSpan(engine_token* et, uint32 color, uint16* list,
|
||||
uint32 count);
|
||||
void Mach64_InvertRectangle(engine_token* et, fill_rect_params* list,
|
||||
uint32 count);
|
||||
void Mach64_ScreenToScreenBlit(engine_token* et, blit_params* list,
|
||||
uint32 count);
|
||||
|
||||
void Rage128_FillRectangle(engine_token* et, uint32 color, fill_rect_params* list, uint32 count);
|
||||
void Rage128_FillSpan(engine_token* et, uint32 color, uint16* list, uint32 count);
|
||||
void Rage128_InvertRectangle(engine_token* et, fill_rect_params* list, uint32 count);
|
||||
void Rage128_ScreenToScreenBlit(engine_token* et, blit_params* list, uint32 count);
|
||||
void Rage128_FillRectangle(engine_token* et, uint32 color,
|
||||
fill_rect_params* list, uint32 count);
|
||||
void Rage128_FillSpan(engine_token* et, uint32 color, uint16* list,
|
||||
uint32 count);
|
||||
void Rage128_InvertRectangle(engine_token* et, fill_rect_params* list,
|
||||
uint32 count);
|
||||
void Rage128_ScreenToScreenBlit(engine_token* et, blit_params* list,
|
||||
uint32 count);
|
||||
|
||||
// Video_overlay
|
||||
uint32 OverlayCount(const display_mode* dm);
|
||||
const uint32* OverlaySupportedSpaces(const display_mode* dm);
|
||||
uint32 OverlaySupportedFeatures(uint32 a_color_space);
|
||||
const overlay_buffer* AllocateOverlayBuffer(color_space cs, uint16 width,
|
||||
uint16 height);
|
||||
status_t ReleaseOverlayBuffer(const overlay_buffer* ob);
|
||||
status_t GetOverlayConstraints(const display_mode* dm,
|
||||
const overlay_buffer* ob, overlay_constraints* oc);
|
||||
overlay_token AllocateOverlay(void);
|
||||
status_t ReleaseOverlay(overlay_token ot);
|
||||
status_t ConfigureOverlay(overlay_token ot, const overlay_buffer* ob,
|
||||
const overlay_window* ow, const overlay_view* ov);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
@ -156,10 +187,15 @@ bool IsModeUsable(const display_mode* mode);
|
||||
|
||||
// Mach64 functions.
|
||||
|
||||
bool Mach64_DisplayOverlay(const overlay_window* window,
|
||||
const overlay_buffer* buffer);
|
||||
void Mach64_StopOverlay(void);
|
||||
|
||||
void Mach64_EngineReset(void);
|
||||
void Mach64_EngineInit(const DisplayModeEx& mode);
|
||||
|
||||
bool Mach64_LoadCursorImage(int width, int height, uint8* and_mask, uint8* xor_mask);
|
||||
bool Mach64_LoadCursorImage(int width, int height, uint8* and_mask,
|
||||
uint8* xor_mask);
|
||||
void Mach64_SetCursorPosition(int x, int y);
|
||||
void Mach64_ShowCursor(bool bShow);
|
||||
|
||||
@ -167,19 +203,25 @@ void Mach64_AdjustFrame(const DisplayModeEx& mode);
|
||||
status_t Mach64_SetDisplayMode(const DisplayModeEx& mode);
|
||||
void Mach64_SetFunctionPointers(void);
|
||||
|
||||
int Mach64_Divide(int numerator, int denom, int shift, const int roundingKind);
|
||||
void Mach64_ReduceRatio(int *numerator, int *denominator);
|
||||
int Mach64_Divide(int numerator, int denom, int shift,
|
||||
const int roundingKind);
|
||||
void Mach64_ReduceRatio(int* numerator, int* denominator);
|
||||
|
||||
|
||||
// Rage128 functions.
|
||||
|
||||
bool Rage128_DisplayOverlay(const overlay_window* window,
|
||||
const overlay_buffer* buffer);
|
||||
void Rage128_StopOverlay(void);
|
||||
|
||||
void Rage128_EngineFlush(void);
|
||||
void Rage128_EngineReset(void);
|
||||
void Rage128_EngineInit(const DisplayModeEx& mode);
|
||||
|
||||
bool Rage128_GetEdidInfo(void);
|
||||
|
||||
bool Rage128_LoadCursorImage(int width, int height, uint8* and_mask, uint8* xor_mask);
|
||||
bool Rage128_LoadCursorImage(int width, int height, uint8* and_mask,
|
||||
uint8* xor_mask);
|
||||
void Rage128_SetCursorPosition(int x, int y);
|
||||
void Rage128_ShowCursor(bool bShow);
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
/*
|
||||
Copyright 2008 Haiku, Inc. All rights reserved.
|
||||
Copyright 2008, 2011 Haiku, Inc. All rights reserved.
|
||||
Distributed under the terms of the MIT license.
|
||||
|
||||
Authors:
|
||||
Gerald Zajac 2008
|
||||
Gerald Zajac
|
||||
*/
|
||||
|
||||
#include "accelerant.h"
|
||||
@ -16,51 +16,106 @@ get_accelerant_hook(uint32 feature, void* data)
|
||||
|
||||
switch (feature) {
|
||||
// General
|
||||
case B_INIT_ACCELERANT: return (void*)InitAccelerant;
|
||||
case B_UNINIT_ACCELERANT: return (void*)UninitAccelerant;
|
||||
case B_CLONE_ACCELERANT: return (void*)CloneAccelerant;
|
||||
case B_ACCELERANT_CLONE_INFO_SIZE: return (void*)AccelerantCloneInfoSize;
|
||||
case B_GET_ACCELERANT_CLONE_INFO: return (void*)GetAccelerantCloneInfo;
|
||||
case B_GET_ACCELERANT_DEVICE_INFO: return (void*)GetAccelerantDeviceInfo;
|
||||
case B_ACCELERANT_RETRACE_SEMAPHORE: return (void*)AccelerantRetraceSemaphore;
|
||||
case B_INIT_ACCELERANT:
|
||||
return (void*)InitAccelerant;
|
||||
case B_UNINIT_ACCELERANT:
|
||||
return (void*)UninitAccelerant;
|
||||
case B_CLONE_ACCELERANT:
|
||||
return (void*)CloneAccelerant;
|
||||
case B_ACCELERANT_CLONE_INFO_SIZE:
|
||||
return (void*)AccelerantCloneInfoSize;
|
||||
case B_GET_ACCELERANT_CLONE_INFO:
|
||||
return (void*)GetAccelerantCloneInfo;
|
||||
case B_GET_ACCELERANT_DEVICE_INFO:
|
||||
return (void*)GetAccelerantDeviceInfo;
|
||||
case B_ACCELERANT_RETRACE_SEMAPHORE:
|
||||
return (void*)AccelerantRetraceSemaphore;
|
||||
|
||||
// Mode Configuration
|
||||
case B_ACCELERANT_MODE_COUNT: return (void*)AccelerantModeCount;
|
||||
case B_GET_MODE_LIST: return (void*)GetModeList;
|
||||
case B_PROPOSE_DISPLAY_MODE: return (void*)ProposeDisplayMode;
|
||||
case B_SET_DISPLAY_MODE: return (void*)SetDisplayMode;
|
||||
case B_GET_DISPLAY_MODE: return (void*)GetDisplayMode;
|
||||
case B_GET_PREFERRED_DISPLAY_MODE: return (void*)GetPreferredDisplayMode;
|
||||
case B_GET_EDID_INFO: return (void*)GetEdidInfo;
|
||||
case B_GET_FRAME_BUFFER_CONFIG: return (void*)GetFrameBufferConfig;
|
||||
case B_GET_PIXEL_CLOCK_LIMITS: return (void*)GetPixelClockLimits;
|
||||
case B_MOVE_DISPLAY: return (void*)MoveDisplay;
|
||||
case B_SET_INDEXED_COLORS: return (void*)(gInfo.SetIndexedColors);
|
||||
case B_GET_TIMING_CONSTRAINTS: return (void*)GetTimingConstraints;
|
||||
case B_ACCELERANT_MODE_COUNT:
|
||||
return (void*)AccelerantModeCount;
|
||||
case B_GET_MODE_LIST:
|
||||
return (void*)GetModeList;
|
||||
case B_PROPOSE_DISPLAY_MODE:
|
||||
return (void*)ProposeDisplayMode;
|
||||
case B_SET_DISPLAY_MODE:
|
||||
return (void*)SetDisplayMode;
|
||||
case B_GET_DISPLAY_MODE:
|
||||
return (void*)GetDisplayMode;
|
||||
case B_GET_PREFERRED_DISPLAY_MODE:
|
||||
return (void*)GetPreferredDisplayMode;
|
||||
case B_GET_EDID_INFO:
|
||||
return (void*)GetEdidInfo;
|
||||
case B_GET_FRAME_BUFFER_CONFIG:
|
||||
return (void*)GetFrameBufferConfig;
|
||||
case B_GET_PIXEL_CLOCK_LIMITS:
|
||||
return (void*)GetPixelClockLimits;
|
||||
case B_MOVE_DISPLAY:
|
||||
return (void*)MoveDisplay;
|
||||
case B_SET_INDEXED_COLORS:
|
||||
return (void*)(gInfo.SetIndexedColors);
|
||||
case B_GET_TIMING_CONSTRAINTS:
|
||||
return (void*)GetTimingConstraints;
|
||||
|
||||
// DPMS
|
||||
case B_DPMS_CAPABILITIES: return (void*)(gInfo.DPMSCapabilities);
|
||||
case B_DPMS_MODE: return (void*)(gInfo.GetDPMSMode);
|
||||
case B_SET_DPMS_MODE: return (void*)(gInfo.SetDPMSMode);
|
||||
case B_DPMS_CAPABILITIES:
|
||||
return (void*)(gInfo.DPMSCapabilities);
|
||||
case B_DPMS_MODE:
|
||||
return (void*)(gInfo.GetDPMSMode);
|
||||
case B_SET_DPMS_MODE:
|
||||
return (void*)(gInfo.SetDPMSMode);
|
||||
|
||||
// Cursor
|
||||
case B_SET_CURSOR_SHAPE: return (void*)SetCursorShape;
|
||||
case B_MOVE_CURSOR: return (void*)MoveCursor;
|
||||
case B_SHOW_CURSOR: return (void*)(gInfo.ShowCursor);
|
||||
case B_SET_CURSOR_SHAPE:
|
||||
return (void*)SetCursorShape;
|
||||
case B_MOVE_CURSOR:
|
||||
return (void*)MoveCursor;
|
||||
case B_SHOW_CURSOR:
|
||||
return (void*)(gInfo.ShowCursor);
|
||||
|
||||
// Engine Management
|
||||
case B_ACCELERANT_ENGINE_COUNT: return (void*)AccelerantEngineCount;
|
||||
case B_ACQUIRE_ENGINE: return (void*)AcquireEngine;
|
||||
case B_RELEASE_ENGINE: return (void*)ReleaseEngine;
|
||||
case B_WAIT_ENGINE_IDLE: return (void*)WaitEngineIdle;
|
||||
case B_GET_SYNC_TOKEN: return (void*)GetSyncToken;
|
||||
case B_SYNC_TO_TOKEN: return (void*)SyncToToken;
|
||||
case B_ACCELERANT_ENGINE_COUNT:
|
||||
return (void*)AccelerantEngineCount;
|
||||
case B_ACQUIRE_ENGINE:
|
||||
return (void*)AcquireEngine;
|
||||
case B_RELEASE_ENGINE:
|
||||
return (void*)ReleaseEngine;
|
||||
case B_WAIT_ENGINE_IDLE:
|
||||
return (void*)WaitEngineIdle;
|
||||
case B_GET_SYNC_TOKEN:
|
||||
return (void*)GetSyncToken;
|
||||
case B_SYNC_TO_TOKEN:
|
||||
return (void*)SyncToToken;
|
||||
|
||||
// 2D acceleration
|
||||
case B_SCREEN_TO_SCREEN_BLIT: return (void*)(gInfo.ScreenToScreenBlit);
|
||||
case B_FILL_RECTANGLE: return (void*)(gInfo.FillRectangle);
|
||||
case B_INVERT_RECTANGLE: return (void*)(gInfo.InvertRectangle);
|
||||
case B_FILL_SPAN: return (void*)(gInfo.FillSpan);
|
||||
case B_SCREEN_TO_SCREEN_BLIT:
|
||||
return (void*)(gInfo.ScreenToScreenBlit);
|
||||
case B_FILL_RECTANGLE:
|
||||
return (void*)(gInfo.FillRectangle);
|
||||
case B_INVERT_RECTANGLE:
|
||||
return (void*)(gInfo.InvertRectangle);
|
||||
case B_FILL_SPAN:
|
||||
return (void*)(gInfo.FillSpan);
|
||||
|
||||
// Overlay
|
||||
case B_OVERLAY_COUNT:
|
||||
return (void*)OverlayCount;
|
||||
case B_OVERLAY_SUPPORTED_SPACES:
|
||||
return (void*)OverlaySupportedSpaces;
|
||||
case B_OVERLAY_SUPPORTED_FEATURES:
|
||||
return (void*)OverlaySupportedFeatures;
|
||||
case B_ALLOCATE_OVERLAY_BUFFER:
|
||||
return (void*)AllocateOverlayBuffer;
|
||||
case B_RELEASE_OVERLAY_BUFFER:
|
||||
return (void*)ReleaseOverlayBuffer;
|
||||
case B_GET_OVERLAY_CONSTRAINTS:
|
||||
return (void*)GetOverlayConstraints;
|
||||
case B_ALLOCATE_OVERLAY:
|
||||
return (void*)AllocateOverlay;
|
||||
case B_RELEASE_OVERLAY:
|
||||
return (void*)ReleaseOverlay;
|
||||
case B_CONFIGURE_OVERLAY:
|
||||
return (void*)ConfigureOverlay;
|
||||
}
|
||||
|
||||
return NULL; // Return null pointer for any feature not handled above
|
||||
|
@ -1,13 +1,14 @@
|
||||
/*
|
||||
Haiku ATI video driver adapted from the X.org ATI driver.
|
||||
Haiku ATI video driver adapted from the X.org ATI driver which has the
|
||||
following copyright:
|
||||
|
||||
Copyright 1992,1993,1994,1995,1996,1997 by Kevin E. Martin, Chapel Hill, North Carolina.
|
||||
|
||||
Copyright 2009 Haiku, Inc. All rights reserved.
|
||||
Copyright 2009, 2011 Haiku, Inc. All rights reserved.
|
||||
Distributed under the terms of the MIT license.
|
||||
|
||||
Authors:
|
||||
Gerald Zajac 2009
|
||||
Gerald Zajac
|
||||
*/
|
||||
|
||||
#ifndef __MACH64_H__
|
||||
@ -178,6 +179,39 @@ enum Mach64_MemoryType
|
||||
#define GUI_STAT (0x0c00 + 0x0338) // Dword offset CE
|
||||
|
||||
|
||||
// Definitions used for overlays.
|
||||
//===============================
|
||||
|
||||
#define REG_BLOCK_1 0x0800 // offset of register block 1 in register area
|
||||
|
||||
#define OVERLAY_Y_X_START (REG_BLOCK_1 + 0x0000) // Dword offset 00
|
||||
#define OVERLAY_LOCK_START 0x80000000ul
|
||||
#define OVERLAY_Y_X_END (REG_BLOCK_1 + 0x0004) // Dword offset 01
|
||||
#define OVERLAY_GRAPHICS_KEY_CLR (REG_BLOCK_1 + 0x0010) // Dword offset 04
|
||||
#define OVERLAY_GRAPHICS_KEY_MSK (REG_BLOCK_1 + 0x0014) // Dword offset 05
|
||||
#define OVERLAY_KEY_CNTL (REG_BLOCK_1 + 0x0018) // Dword offset 06
|
||||
#define OVERLAY_MIX_FALSE 0x00
|
||||
#define OVERLAY_MIX_EQUAL 0x50
|
||||
#define OVERLAY_SCALE_INC (REG_BLOCK_1 + 0x0020) // Dword offset 08
|
||||
#define OVERLAY_SCALE_CNTL (REG_BLOCK_1 + 0x0024) // Dword offset 09
|
||||
#define SCALE_PIX_EXPAND 0x00000001
|
||||
#define OVERLAY_EN 0x40000000
|
||||
#define SCALE_EN 0x80000000
|
||||
#define SCALER_HEIGHT_WIDTH (REG_BLOCK_1 + 0x0028) // Dword offset 0a
|
||||
#define SCALER_BUF0_OFFSET (REG_BLOCK_1 + 0x0034) // Dword offset 0d
|
||||
#define SCALER_BUF0_PITCH (REG_BLOCK_1 + 0x003c) // Dword offset 0f
|
||||
#define VIDEO_FORMAT (REG_BLOCK_1 + 0x0048) // Dword offset 12
|
||||
#define SCALE_IN_VYUY422 0x000b0000
|
||||
#define BUF0_OFFSET (REG_BLOCK_1 + 0x0080) // Dword offset 20
|
||||
#define BUF0_PITCH (REG_BLOCK_1 + 0x008c) // Dword offset 23
|
||||
#define SCALER_COLOUR_CNTL (REG_BLOCK_1 + 0x0150) // Dword offset 54
|
||||
#define SCALER_H_COEFF0 (REG_BLOCK_1 + 0x0154) // Dword offset 55
|
||||
#define SCALER_H_COEFF1 (REG_BLOCK_1 + 0x0158) // Dword offset 56
|
||||
#define SCALER_H_COEFF2 (REG_BLOCK_1 + 0x015c) // Dword offset 57
|
||||
#define SCALER_H_COEFF3 (REG_BLOCK_1 + 0x0160) // Dword offset 58
|
||||
#define SCALER_H_COEFF4 (REG_BLOCK_1 + 0x0164) // Dword offset 59
|
||||
|
||||
|
||||
// CRTC control values.
|
||||
|
||||
#define CRTC_H_SYNC_NEG 0x00200000
|
||||
@ -225,11 +259,10 @@ enum Mach64_MemoryType
|
||||
#define CRTC_PITCH 0xffc00000
|
||||
|
||||
// DAC control values.
|
||||
|
||||
#define DAC_8BIT_EN 0x00000100
|
||||
|
||||
// Mix control values.
|
||||
|
||||
// Mix control values.
|
||||
#define MIX_NOT_DST 0x0000
|
||||
#define MIX_0 0x0001
|
||||
#define MIX_1 0x0002
|
||||
@ -250,7 +283,7 @@ enum Mach64_MemoryType
|
||||
// BUS_CNTL register constants.
|
||||
#define BUS_FIFO_ERR_ACK 0x00200000
|
||||
#define BUS_HOST_ERR_ACK 0x00800000
|
||||
#define BUS_APER_REG_DIS 0x00000010
|
||||
#define BUS_EXT_REG_EN 0x08000000
|
||||
|
||||
// GEN_TEST_CNTL register constants.
|
||||
#define GEN_OVR_OUTPUT_EN 0x20
|
||||
@ -361,13 +394,13 @@ enum Mach64_MemoryType
|
||||
#define BYTE_ORDER_LSB_TO_MSB 0x1000000
|
||||
|
||||
// DP_SRC register constants.
|
||||
#define BKGD_SRC_BKGD_CLR 0
|
||||
#define FRGD_SRC_FRGD_CLR 0x100
|
||||
#define FRGD_SRC_BLIT 0x300
|
||||
#define MONO_SRC_ONE 0
|
||||
#define BKGD_SRC_BKGD_CLR 0
|
||||
#define FRGD_SRC_FRGD_CLR 0x100
|
||||
#define FRGD_SRC_BLIT 0x300
|
||||
#define MONO_SRC_ONE 0
|
||||
|
||||
// GUI_STAT register constants.
|
||||
#define ENGINE_BUSY 1
|
||||
#define ENGINE_BUSY 1
|
||||
|
||||
// LCD Index register constants.
|
||||
#define LCD_REG_INDEX 0x0000003F
|
||||
|
@ -1,15 +1,16 @@
|
||||
/*
|
||||
Haiku ATI video driver adapted from the X.org ATI driver.
|
||||
Haiku ATI video driver adapted from the X.org ATI driver which has the
|
||||
following copyright:
|
||||
|
||||
Copyright 1999, 2000 ATI Technologies Inc., Markham, Ontario,
|
||||
Precision Insight, Inc., Cedar Park, Texas, and
|
||||
VA Linux Systems Inc., Fremont, California.
|
||||
|
||||
Copyright 2009 Haiku, Inc. All rights reserved.
|
||||
Copyright 2009, 2011 Haiku, Inc. All rights reserved.
|
||||
Distributed under the terms of the MIT license.
|
||||
|
||||
Authors:
|
||||
Gerald Zajac 2009
|
||||
Gerald Zajac
|
||||
*/
|
||||
|
||||
|
||||
@ -17,7 +18,7 @@
|
||||
#define __RAGE128_H__
|
||||
|
||||
|
||||
#define CURSOR_BYTES 1024 // bytes used for cursor image in video memory
|
||||
#define CURSOR_BYTES 1024 // bytes used for cursor image in video memory
|
||||
|
||||
#define R128_TIMEOUT 2000000 // Fall out of wait loops after this count
|
||||
|
||||
@ -203,7 +204,6 @@
|
||||
#define R128_OVR_CLR 0x0230
|
||||
#define R128_OVR_WID_LEFT_RIGHT 0x0234
|
||||
#define R128_OVR_WID_TOP_BOTTOM 0x0238
|
||||
#define R128_OV0_SCALE_CNTL 0x0420
|
||||
|
||||
#define R128_PALETTE_DATA 0x00b4
|
||||
#define R128_PALETTE_INDEX 0x00b0
|
||||
@ -231,13 +231,46 @@
|
||||
|
||||
#define R128_TMDS_CRC 0x02a0
|
||||
|
||||
#define R128_VCLK_ECP_CNTL 0x0008 // PLL
|
||||
# define R128_VCLK_SRC_SEL_MASK 0x03
|
||||
# define R128_VCLK_SRC_SEL_CPUCLK 0x00
|
||||
# define R128_VCLK_SRC_SEL_PPLLCLK 0x03
|
||||
#define R128_VCLK_ECP_CNTL 0x0008 // PLL
|
||||
# define R128_VCLK_SRC_SEL_MASK 0x03
|
||||
# define R128_VCLK_SRC_SEL_CPUCLK 0x00
|
||||
# define R128_VCLK_SRC_SEL_PPLLCLK 0x03
|
||||
# define R128_ECP_DIV_MASK (3 << 8)
|
||||
#define R128_VIPH_CONTROL 0x01D0 // ?
|
||||
|
||||
|
||||
// Definitions used for overlays.
|
||||
//===============================
|
||||
|
||||
#define R128_OV0_Y_X_START 0x0400
|
||||
#define R128_OV0_Y_X_END 0x0404
|
||||
#define R128_OV0_EXCLUSIVE_HORZ 0x0408
|
||||
#define R128_OV0_REG_LOAD_CNTL 0x0410
|
||||
#define R128_OV0_SCALE_CNTL 0x0420
|
||||
#define R128_OV0_V_INC 0x0424
|
||||
#define R128_OV0_P1_V_ACCUM_INIT 0x0428
|
||||
#define R128_OV0_P23_V_ACCUM_INIT 0x042C
|
||||
#define R128_OV0_P1_BLANK_LINES_AT_TOP 0x0430
|
||||
#define R128_OV0_VID_BUF0_BASE_ADRS 0x0440
|
||||
#define R128_OV0_VID_BUF_PITCH0_VALUE 0x0460
|
||||
#define R128_OV0_AUTO_FLIP_CNTL 0x0470
|
||||
#define R128_OV0_H_INC 0x0480
|
||||
#define R128_OV0_STEP_BY 0x0484
|
||||
#define R128_OV0_P1_H_ACCUM_INIT 0x0488
|
||||
#define R128_OV0_P23_H_ACCUM_INIT 0x048C
|
||||
#define R128_OV0_P1_X_START_END 0x0494
|
||||
#define R128_OV0_P2_X_START_END 0x0498
|
||||
#define R128_OV0_P3_X_START_END 0x049C
|
||||
#define R128_OV0_FILTER_CNTL 0x04A0
|
||||
#define R128_OV0_COLOUR_CNTL 0x04E0
|
||||
#define R128_OV0_GRAPHICS_KEY_CLR 0x04EC
|
||||
#define R128_OV0_GRAPHICS_KEY_MSK 0x04F0
|
||||
#define R128_OV0_KEY_CNTL 0x04F4
|
||||
# define R128_GRAPHIC_KEY_FN_EQ 0x00000040L
|
||||
# define R128_GRAPHIC_KEY_FN_NE 0x00000050L
|
||||
#define R128_OV0_TEST 0x04F8
|
||||
|
||||
|
||||
|
||||
// Functions to get/set PLL registers.
|
||||
//=======================================
|
||||
|
@ -1,9 +1,9 @@
|
||||
/*
|
||||
Copyright 2007-2009 Haiku, Inc. All rights reserved.
|
||||
Copyright 2007-2011 Haiku, Inc. All rights reserved.
|
||||
Distributed under the terms of the MIT license.
|
||||
|
||||
Authors:
|
||||
Gerald Zajac 2007-2009
|
||||
Gerald Zajac
|
||||
*/
|
||||
|
||||
#include <KernelExport.h>
|
||||
@ -20,7 +20,6 @@
|
||||
|
||||
#undef TRACE
|
||||
|
||||
//#define ENABLE_DEBUG_TRACE
|
||||
#ifdef ENABLE_DEBUG_TRACE
|
||||
# define TRACE(x...) dprintf("ati: " x)
|
||||
#else
|
||||
@ -41,7 +40,7 @@
|
||||
#define M64_BIOS_SIZE 0x10000 // 64KB
|
||||
#define R128_BIOS_SIZE 0x10000 // 64KB
|
||||
|
||||
int32 api_version = B_CUR_DRIVER_API_VERSION; // revision of driver API we support
|
||||
int32 api_version = B_CUR_DRIVER_API_VERSION; // revision of driver API used
|
||||
|
||||
#define VENDOR_ID 0x1002 // ATI vendor ID
|
||||
|
||||
@ -54,7 +53,8 @@ int32 api_version = B_CUR_DRIVER_API_VERSION; // revision of driver API we suppo
|
||||
struct ChipInfo {
|
||||
uint16 chipID; // PCI device id of the chip
|
||||
ChipType chipType; // assigned chip type identifier
|
||||
const char* chipName; // user recognizable name for chip (must be < 32 chars)
|
||||
const char* chipName; // user recognizable name for chip
|
||||
// (must be < 32 chars)
|
||||
};
|
||||
|
||||
|
||||
@ -199,14 +199,16 @@ static device_hooks gDeviceHooks =
|
||||
static inline uint32
|
||||
GetPCI(pci_info& info, uint8 offset, uint8 size)
|
||||
{
|
||||
return gPCI->read_pci_config(info.bus, info.device, info.function, offset, size);
|
||||
return gPCI->read_pci_config(info.bus, info.device, info.function, offset,
|
||||
size);
|
||||
}
|
||||
|
||||
|
||||
static inline void
|
||||
SetPCI(pci_info& info, uint8 offset, uint8 size, uint32 value)
|
||||
{
|
||||
gPCI->write_pci_config(info.bus, info.device, info.function, offset, size, value);
|
||||
gPCI->write_pci_config(info.bus, info.device, info.function, offset, size,
|
||||
value);
|
||||
}
|
||||
|
||||
|
||||
@ -251,7 +253,8 @@ GetEdidFromBIOS(edid1_raw& edidRaw)
|
||||
|
||||
status_t status = vm86_prepare(&vmState, 0x2000);
|
||||
if (status != B_OK) {
|
||||
TRACE("GetEdidFromBIOS(); vm86_prepare() failed, status: 0x%lx\n", status);
|
||||
TRACE("GetEdidFromBIOS(); vm86_prepare() failed, status: 0x%lx\n",
|
||||
status);
|
||||
return status;
|
||||
}
|
||||
|
||||
@ -337,7 +340,8 @@ SetVesaDisplayMode(uint16 mode)
|
||||
|
||||
status_t status = vm86_prepare(&vmState, 0x2000);
|
||||
if (status != B_OK) {
|
||||
TRACE("SetVesaDisplayMode(); vm86_prepare() failed, status: 0x%lx\n", status);
|
||||
TRACE("SetVesaDisplayMode(); vm86_prepare() failed, status: 0x%lx\n",
|
||||
status);
|
||||
return status;
|
||||
}
|
||||
|
||||
@ -505,8 +509,9 @@ Rage128_GetBiosParameters(DeviceInfo& di)
|
||||
pll.max_pll_freq = BIOS32(pllInfoBlock + 0x16);
|
||||
pll.xclk = BIOS16(pllInfoBlock + 0x08);
|
||||
|
||||
TRACE("PLL parameters: rf=%d rd=%d min=%ld max=%ld; xclk=%d\n", pll.reference_freq,
|
||||
pll.reference_div, pll.min_pll_freq, pll.max_pll_freq, pll.xclk);
|
||||
TRACE("PLL parameters: rf=%d rd=%d min=%ld max=%ld; xclk=%d\n",
|
||||
pll.reference_freq, pll.reference_div, pll.min_pll_freq,
|
||||
pll.max_pll_freq, pll.xclk);
|
||||
|
||||
// If Mobility chip, get the LCD panel width & height and a few other
|
||||
// related parameters.
|
||||
@ -537,7 +542,8 @@ Rage128_GetBiosParameters(DeviceInfo& di)
|
||||
si.panelY = BIOS16(fpStart + 27);
|
||||
si.panelPowerDelay = BIOS8(fpStart + 56);
|
||||
TRACE("LCD Panel size: %dx%d Panel type: 0x%x power delay: %d\n",
|
||||
si.panelX, si.panelY, BIOS16(fpStart + 29), si.panelPowerDelay);
|
||||
si.panelX, si.panelY, BIOS16(fpStart + 29),
|
||||
si.panelPowerDelay);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -566,9 +572,9 @@ MapDevice(DeviceInfo& di)
|
||||
|
||||
// Map the video memory.
|
||||
|
||||
uint32 videoRamAddr = pciInfo.u.h0.base_registers[0];
|
||||
phys_addr_t videoRamAddr = pciInfo.u.h0.base_registers[0];
|
||||
uint32 videoRamSize = pciInfo.u.h0.base_register_sizes[0];
|
||||
si.videoMemPCI = (void *)videoRamAddr;
|
||||
si.videoMemPCI = videoRamAddr;
|
||||
char frameBufferAreaName[] = "ATI frame buffer";
|
||||
|
||||
si.videoMemArea = map_physical_memory(
|
||||
@ -577,7 +583,7 @@ MapDevice(DeviceInfo& di)
|
||||
videoRamSize,
|
||||
B_ANY_KERNEL_BLOCK_ADDRESS | B_MTR_WC,
|
||||
B_READ_AREA + B_WRITE_AREA,
|
||||
&(si.videoMemAddr));
|
||||
(void**)&(si.videoMemAddr));
|
||||
|
||||
if (si.videoMemArea < 0) {
|
||||
// Try to map this time without write combining.
|
||||
@ -587,7 +593,7 @@ MapDevice(DeviceInfo& di)
|
||||
videoRamSize,
|
||||
B_ANY_KERNEL_BLOCK_ADDRESS,
|
||||
B_READ_AREA + B_WRITE_AREA,
|
||||
&(si.videoMemAddr));
|
||||
(void**)&(si.videoMemAddr));
|
||||
}
|
||||
|
||||
if (si.videoMemArea < 0)
|
||||
@ -595,7 +601,7 @@ MapDevice(DeviceInfo& di)
|
||||
|
||||
// Map the MMIO register area.
|
||||
|
||||
uint32 regsBase = pciInfo.u.h0.base_registers[2];
|
||||
phys_addr_t regsBase = pciInfo.u.h0.base_registers[2];
|
||||
uint32 regAreaSize = pciInfo.u.h0.base_register_sizes[2];
|
||||
|
||||
// If the register area address or size is not in the PCI info, it should
|
||||
@ -619,7 +625,8 @@ MapDevice(DeviceInfo& di)
|
||||
|
||||
regsBase = videoRamAddr + regsOffset;
|
||||
regAreaSize = 0x1000;
|
||||
TRACE("Register address is at end of frame buffer memory at 0x%lx\n", regsBase);
|
||||
TRACE("Register address is at end of frame buffer memory at 0x%lx\n",
|
||||
uint32(regsBase));
|
||||
}
|
||||
|
||||
si.regsArea = map_physical_memory("ATI mmio registers",
|
||||
@ -627,7 +634,7 @@ MapDevice(DeviceInfo& di)
|
||||
regAreaSize,
|
||||
B_ANY_KERNEL_ADDRESS,
|
||||
0, // neither read nor write, to hide it from user space apps
|
||||
(void**)(&(di.regs)));
|
||||
(void**)&di.regs);
|
||||
|
||||
// If there was an error, delete other areas.
|
||||
if (si.regsArea < 0) {
|
||||
@ -650,7 +657,7 @@ UnmapDevice(DeviceInfo& di)
|
||||
delete_area(si.videoMemArea);
|
||||
|
||||
si.regsArea = si.videoMemArea = -1;
|
||||
si.videoMemAddr = NULL;
|
||||
si.videoMemAddr = (addr_t)NULL;
|
||||
di.regs = NULL;
|
||||
}
|
||||
|
||||
@ -768,7 +775,8 @@ InitDevice(DeviceInfo& di)
|
||||
si.vesaModeTableOffset = sharedSize;
|
||||
si.vesaModeCount = vesaModeTableSize / sizeof(VesaMode);
|
||||
|
||||
memcpy((uint8*)&si + si.vesaModeTableOffset, vesaModes, vesaModeTableSize);
|
||||
memcpy((uint8*)&si + si.vesaModeTableOffset, vesaModes,
|
||||
vesaModeTableSize);
|
||||
}
|
||||
|
||||
pci_info& pciInfo = di.pciInfo;
|
||||
@ -892,7 +900,8 @@ init_hardware(void)
|
||||
pci_info pciInfo;
|
||||
const ChipInfo* pDevice = GetNextSupportedDevice(pciIndex, pciInfo);
|
||||
|
||||
TRACE("init_hardware() - %s\n", pDevice == NULL ? "no supported devices" : "device supported");
|
||||
TRACE("init_hardware() - %s\n",
|
||||
pDevice == NULL ? "no supported devices" : "device supported");
|
||||
|
||||
put_module(B_PCI_MODULE_NAME); // put away the module manager
|
||||
|
||||
@ -900,7 +909,8 @@ init_hardware(void)
|
||||
}
|
||||
|
||||
|
||||
status_t init_driver(void)
|
||||
status_t
|
||||
init_driver(void)
|
||||
{
|
||||
// Get handle for the pci bus.
|
||||
|
||||
@ -1011,7 +1021,8 @@ device_open(const char* name, uint32 /*flags*/, void** cookie)
|
||||
*cookie = &di; // send cookie to opener
|
||||
}
|
||||
|
||||
TRACE("device_open() returning 0x%lx, open count: %ld\n", status, di.openCount);
|
||||
TRACE("device_open() returning 0x%lx, open count: %ld\n", status,
|
||||
di.openCount);
|
||||
return status;
|
||||
}
|
||||
|
||||
@ -1019,7 +1030,8 @@ device_open(const char* name, uint32 /*flags*/, void** cookie)
|
||||
static status_t
|
||||
device_read(void* dev, off_t pos, void* buf, size_t* len)
|
||||
{
|
||||
// Following 3 lines of code are here to eliminate "unused parameter" warnings.
|
||||
// Following 3 lines of code are here to eliminate "unused parameter"
|
||||
// warnings.
|
||||
(void)dev;
|
||||
(void)pos;
|
||||
(void)buf;
|
||||
@ -1032,7 +1044,8 @@ device_read(void* dev, off_t pos, void* buf, size_t* len)
|
||||
static status_t
|
||||
device_write(void* dev, off_t pos, const void* buf, size_t* len)
|
||||
{
|
||||
// Following 3 lines of code are here to eliminate "unused parameter" warnings.
|
||||
// Following 3 lines of code are here to eliminate "unused parameter"
|
||||
// warnings.
|
||||
(void)dev;
|
||||
(void)pos;
|
||||
(void)buf;
|
||||
@ -1068,10 +1081,12 @@ device_free(void* dev)
|
||||
DisableVBI(); // disable & clear any pending interrupts
|
||||
|
||||
if (si.bInterruptAssigned) {
|
||||
remove_io_interrupt_handler(pciInfo.u.h0.interrupt_line, InterruptHandler, &di);
|
||||
remove_io_interrupt_handler(pciInfo.u.h0.interrupt_line,
|
||||
InterruptHandler, &di);
|
||||
}
|
||||
|
||||
// Delete the semaphores, ignoring any errors because the owning team may have died.
|
||||
// Delete the semaphores, ignoring any errors because the owning team
|
||||
// may have died.
|
||||
if (si.vertBlankSem >= 0)
|
||||
delete_sem(si.vertBlankSem);
|
||||
si.vertBlankSem = -1;
|
||||
@ -1098,7 +1113,8 @@ device_ioctl(void* dev, uint32 msg, void* buffer, size_t bufferLength)
|
||||
{
|
||||
DeviceInfo& di = *((DeviceInfo*)dev);
|
||||
|
||||
// TRACE("device_ioctl(); ioctl: %lu, buffer: 0x%08lx, bufLen: %lu\n", msg, (uint32)buffer, bufferLength);
|
||||
// TRACE("device_ioctl(); ioctl: %lu, buffer: 0x%08lx, bufLen: %lu\n", msg,
|
||||
// (uint32)buffer, bufferLength);
|
||||
|
||||
switch (msg) {
|
||||
case B_GET_ACCELERANT_SIGNATURE:
|
||||
|
Loading…
Reference in New Issue
Block a user