1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
|
/*
* Copyright 2007 Jérôme Glisse
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/*
* Authors:
* Jerome Glisse <glisse@freedesktop.org>
*/
#include "drmP.h"
#include "drm.h"
#include "radeon_ms.h"
static struct radeon_ms_output radeon_ms_dac1 = {
OUTPUT_DAC1,
NULL,
NULL,
radeon_ms_dac1_initialize,
radeon_ms_dac1_detect,
radeon_ms_dac1_dpms,
radeon_ms_dac1_get_modes,
radeon_ms_dac1_mode_fixup,
radeon_ms_dac1_mode_set,
radeon_ms_dac1_restore,
radeon_ms_dac1_save
};
static struct radeon_ms_output radeon_ms_dac2 = {
OUTPUT_DAC2,
NULL,
NULL,
radeon_ms_dac2_initialize,
radeon_ms_dac2_detect,
radeon_ms_dac2_dpms,
radeon_ms_dac2_get_modes,
radeon_ms_dac2_mode_fixup,
radeon_ms_dac2_mode_set,
radeon_ms_dac2_restore,
radeon_ms_dac2_save
};
static struct radeon_ms_connector radeon_ms_vga = {
NULL, NULL, NULL, CONNECTOR_VGA, MT_NONE, 0, GPIO_DDC1,
{
0, -1, -1, -1, -1, -1, -1, -1
},
"VGA"
};
static struct radeon_ms_connector radeon_ms_dvi_i_2 = {
NULL, NULL, NULL, CONNECTOR_DVI_I, MT_NONE, 0, GPIO_DDC2,
{
1, -1, -1, -1, -1, -1, -1, -1
},
"DVI-I"
};
static struct radeon_ms_properties properties[] = {
/* default only one VGA connector */
{
0, 0, 2700, 2500, 20000, 1, 1, 1, 1,
{
&radeon_ms_dac1, NULL, NULL, NULL, NULL, NULL, NULL,
NULL
},
{
&radeon_ms_vga, NULL, NULL, NULL, NULL, NULL, NULL,
NULL
}
},
{
0x1043, 0x176, 2700, 2500, 20000, 1, 1, 1, 1,
{
&radeon_ms_dac1, &radeon_ms_dac2, NULL, NULL, NULL,
NULL, NULL, NULL
},
{
&radeon_ms_vga, &radeon_ms_dvi_i_2, NULL, NULL, NULL,
NULL, NULL, NULL
}
},
{
0x1002, 0x4150, 2700, 2500, 20000, 1, 1, 1, 1,
{
&radeon_ms_dac1, &radeon_ms_dac2, NULL, NULL, NULL,
NULL, NULL, NULL
},
{
&radeon_ms_vga, &radeon_ms_dvi_i_2, NULL, NULL, NULL,
NULL, NULL, NULL
}
},
};
extern const uint32_t radeon_cp_microcode[];
extern const uint32_t r200_cp_microcode[];
extern const uint32_t r300_cp_microcode[];
static void radeon_flush_cache(struct drm_device *dev)
{
struct drm_radeon_private *dev_priv = dev->dev_private;
uint32_t cmd[6];
int i, ret;
cmd[0] = CP_PACKET0(RB2D_DSTCACHE_CTLSTAT, 0);
cmd[1] = REG_S(RB2D_DSTCACHE_CTLSTAT, DC_FLUSH, 3);
cmd[2] = CP_PACKET0(RB3D_DSTCACHE_CTLSTAT, 0);
cmd[3] = REG_S(RB3D_DSTCACHE_CTLSTAT, DC_FLUSH, 3);
cmd[4] = CP_PACKET0(RB3D_ZCACHE_CTLSTAT, 0);
cmd[5] = RB3D_ZCACHE_CTLSTAT__ZC_FLUSH;
/* try to wait but if we timeout we likely are in bad situation */
for (i = 0; i < dev_priv->usec_timeout; i++) {
ret = radeon_ms_ring_emit(dev, cmd, 6);
if (!ret) {
break;
}
}
}
static void r300_flush_cache(struct drm_device *dev)
{
struct drm_radeon_private *dev_priv = dev->dev_private;
uint32_t cmd[6];
int i, ret;
cmd[0] = CP_PACKET0(RB2D_DSTCACHE_CTLSTAT, 0);
cmd[1] = REG_S(RB2D_DSTCACHE_CTLSTAT, DC_FLUSH, 3);
cmd[2] = CP_PACKET0(RB3D_DSTCACHE_CTLSTAT_R3, 0);
cmd[3] = REG_S(RB3D_DSTCACHE_CTLSTAT_R3, DC_FLUSH, 3);
cmd[4] = CP_PACKET0(RB3D_ZCACHE_CTLSTAT_R3, 0);
cmd[5] = RB3D_ZCACHE_CTLSTAT_R3__ZC_FLUSH;
/* try to wait but if we timeout we likely are in bad situation */
for (i = 0; i < dev_priv->usec_timeout; i++) {
ret = radeon_ms_ring_emit(dev, cmd, 6);
if (!ret) {
break;
}
}
}
int radeon_ms_family_init(struct drm_device *dev)
{
struct drm_radeon_private *dev_priv = dev->dev_private;
int i;
dev_priv->microcode = radeon_cp_microcode;
dev_priv->irq_emit = radeon_ms_irq_emit;
switch (dev_priv->family) {
case CHIP_R100:
case CHIP_R200:
dev_priv->microcode = radeon_cp_microcode;
dev_priv->flush_cache = radeon_flush_cache;
break;
case CHIP_RV200:
case CHIP_RV250:
case CHIP_RV280:
case CHIP_RS300:
dev_priv->microcode = r200_cp_microcode;
dev_priv->flush_cache = radeon_flush_cache;
break;
case CHIP_R300:
case CHIP_R350:
case CHIP_R360:
case CHIP_RV350:
case CHIP_RV370:
case CHIP_RV380:
case CHIP_RS400:
case CHIP_RV410:
case CHIP_R420:
case CHIP_R430:
case CHIP_R480:
dev_priv->microcode = r300_cp_microcode;
dev_priv->flush_cache = r300_flush_cache;
break;
default:
DRM_ERROR("Unknown radeon family, aborting\n");
return -EINVAL;
}
switch (dev_priv->bus_type) {
case RADEON_AGP:
dev_priv->create_ttm = drm_agp_init_ttm;
dev_priv->bus_init = radeon_ms_agp_init;
dev_priv->bus_restore = radeon_ms_agp_restore;
dev_priv->bus_save = radeon_ms_agp_save;
break;
case RADEON_PCIE:
dev_priv->create_ttm = radeon_ms_pcie_create_ttm;
dev_priv->bus_finish = radeon_ms_pcie_finish;
dev_priv->bus_init = radeon_ms_pcie_init;
dev_priv->bus_restore = radeon_ms_pcie_restore;
dev_priv->bus_save = radeon_ms_pcie_save;
break;
default:
DRM_ERROR("Unknown radeon bus type, aborting\n");
return -EINVAL;
}
dev_priv->properties = NULL;
for (i = 1; i < sizeof(properties)/sizeof(properties[0]); i++) {
if (dev->pdev->subsystem_vendor == properties[i].subvendor &&
dev->pdev->subsystem_device == properties[i].subdevice) {
DRM_INFO("[radeon_ms] found properties for 0x%04X:0x%04X\n",
properties[i].subvendor, properties[i].subdevice);
dev_priv->properties = &properties[i];
}
}
if (dev_priv->properties == NULL) {
dev_priv->properties = &properties[0];
}
return 0;
}
|