1 /*
2 (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
3 (c) Copyright 2000-2004 Convergence (integrated media) GmbH
4
5 All rights reserved.
6
7 Written by Denis Oliver Kropp <dok@directfb.org>,
8 Andreas Hundt <andi@fischlustig.de>,
9 Sven Neumann <neo@directfb.org>,
10 Ville Syrjälä <syrjala@sci.fi> and
11 Claudio Ciccani <klan@users.sf.net>.
12
13 This library is free software; you can redistribute it and/or
14 modify it under the terms of the GNU Lesser General Public
15 License as published by the Free Software Foundation; either
16 version 2 of the License, or (at your option) any later version.
17
18 This library is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 Lesser General Public License for more details.
22
23 You should have received a copy of the GNU Lesser General Public
24 License along with this library; if not, write to the
25 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27 */
28
29 #ifndef ___MATROX_H__
30 #define ___MATROX_H__
31
32 #include <dfb_types.h>
33
34 #include <core/layers.h>
35 #include <core/screens.h>
36
37 #define PCI_VENDOR_ID_MATROX 0x102B
38 #define PCI_DEVICE_ID_MATROX_2064W_PCI 0x0519
39 #define PCI_DEVICE_ID_MATROX_1064SG_PCI 0x051A
40 #define PCI_DEVICE_ID_MATROX_2164W_PCI 0x051B
41 #define PCI_DEVICE_ID_MATROX_1064SG_AGP 0x051E
42 #define PCI_DEVICE_ID_MATROX_2164W_AGP 0x051F
43 #define PCI_DEVICE_ID_MATROX_G100_PCI 0x1000
44 #define PCI_DEVICE_ID_MATROX_G100_AGP 0x1001
45 #define PCI_DEVICE_ID_MATROX_G200_PCI 0x0520
46 #define PCI_DEVICE_ID_MATROX_G200_AGP 0x0521
47 #define PCI_DEVICE_ID_MATROX_G400_AGP 0x0525
48 #define PCI_DEVICE_ID_MATROX_G550_AGP 0x2527
49
50 typedef enum {
51 m_Source = 0x0001,
52 m_source = 0x0002,
53
54 m_drawColor = 0x0010,
55 m_blitColor = 0x0020,
56 m_color = 0x0040,
57
58 m_SrcKey = 0x0100,
59 m_srckey = 0x0200,
60
61 m_drawBlend = 0x1000,
62 m_blitBlend = 0x2000,
63
64 m_destination = 0x4000,
65 m_clip = 0x8000,
66 } MatroxStateBits;
67
68 #define MGA_VALIDATE(b) (mdev->valid |= (b))
69 #define MGA_INVALIDATE(b) (mdev->valid &= ~(b))
70 #define MGA_IS_VALID(b) (mdev->valid & (b))
71
72 typedef struct {
73 /* Old cards are older than G200/G400, e.g. Mystique or Millennium */
74 bool old_matrox;
75 /* G450/G550 */
76 bool g450_matrox;
77 /* G550 */
78 bool g550_matrox;
79
80 /* FIFO Monitoring */
81 unsigned int fifo_space;
82 unsigned int waitfifo_sum;
83 unsigned int waitfifo_calls;
84 unsigned int fifo_waitcycles;
85 unsigned int idle_waitcycles;
86 unsigned int fifo_cache_hits;
87
88 /* ATYPE_BLK or ATYPE_RSTR, depending on SGRAM setting */
89 u32 atype_blk_rstr;
90
91 /* State handling */
92 MatroxStateBits valid;
93
94 /* Stored values */
95 int dst_pitch;
96 int dst_offset[2][3];
97 int src_pitch;
98 int src_offset[2][3];
99 int w, h, w2, h2;
100 u32 color[3];
101
102 bool draw_blend;
103 bool blit_src_colorkey;
104
105 bool blit_deinterlace;
106 bool blit_fields;
107 int field;
108
109 bool depth_buffer;
110
111 u32 texctl;
112
113 u32 idle_status;
114
115 DFBRegion clip;
116
117 struct {
118 unsigned long offset;
119 unsigned long physical;
120 } fb;
121 unsigned int tlut_offset;
122 CorePalette *rgb332_palette;
123
124 bool crtc2_separated;
125 } MatroxDeviceData;
126
127 typedef struct {
128 int accelerator;
129 int maven_fd;
130 volatile u8 *mmio_base;
131
132 CoreScreen *primary;
133 CoreScreen *secondary;
134
135 MatroxDeviceData *device_data;
136 } MatroxDriverData;
137
138
139 extern DisplayLayerFuncs matroxBesFuncs;
140 extern DisplayLayerFuncs matroxCrtc2Funcs;
141 extern DisplayLayerFuncs matroxSpicFuncs;
142
143 extern ScreenFuncs matroxCrtc2ScreenFuncs;
144
mga_log2(int val)145 static inline int mga_log2( int val )
146 {
147 register int ret = 0;
148
149 while (val >> ++ret);
150
151 if ((1 << --ret) < val)
152 ret++;
153
154 return ret;
155 }
156
157 #endif
158