annotate vidix/s3_vid.c @ 26625:5b89b42f6d50

Only compile and use libmpeg2 AltiVec code when AltiVec is available. The AltiVec code needs -maltivec to compile, but then AltiVec instructions appear in other places of the code causing MPlayer to sigill. Somehow upstream libmpeg2 manages not to sigill under what appear to be the same circumstances. Enlightenment welcome.
author diego
date Sat, 03 May 2008 15:23:22 +0000
parents 0d255d03016f
children 051b2632f121
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
26096
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
1 /*
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
2 * VIDIX driver for S3 chipsets.
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
3 * Copyright (C) 2004 Reza Jelveh
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
4 *
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
5 * This file is part of MPlayer.
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
6 *
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
7 * MPlayer is free software; you can redistribute it and/or modify
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
10 * (at your option) any later version.
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
11 *
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
12 * MPlayer is distributed in the hope that it will be useful,
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
15 * GNU General Public License for more details.
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
16 *
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
18 * along with MPlayer; if not, write to the Free Software
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
20 *
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
21 * Thanks to Alex Deucher for Support
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
22 *
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
23 * Trio/Virge support by Michael Kostylev
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
24 *
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
25 */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
26
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
27 #include <errno.h>
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
28 #include <stdio.h>
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
29 #include <stdlib.h>
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
30 #include <string.h>
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
31 #include <inttypes.h>
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
32 #include <unistd.h>
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
33 #include <math.h>
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
34
26203
0d255d03016f #include config.h before all other headers.
diego
parents: 26099
diff changeset
35 #include "config.h"
26096
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
36 #include "vidix.h"
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
37 #include "vidixlib.h"
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
38 #include "fourcc.h"
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
39 #include "dha.h"
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
40 #include "pci_ids.h"
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
41 #include "pci_names.h"
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
42
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
43 #include "s3_regs.h"
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
44
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
45 static void S3SetColorKeyOld (void);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
46 static void S3SetColorKeyNew (void);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
47 static void S3SetColorKey2000 (void);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
48 static void (*S3SetColorKey) (void) = NULL;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
49
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
50 static void S3SetColorOld (void);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
51 static void S3SetColorNew (void);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
52 static void S3SetColor2000 (void);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
53 static void (*S3SetColor) (void) = NULL;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
54
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
55 static void S3DisplayVideoOld (void);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
56 static void S3DisplayVideoNew (void);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
57 static void S3DisplayVideo2000 (void);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
58 static void (*S3DisplayVideo) (void) = NULL;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
59
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
60 static void S3InitStreamsOld (void);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
61 static void S3InitStreamsNew (void);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
62 static void S3InitStreams2000 (void);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
63 static void (*S3InitStreams) (void) = NULL;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
64
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
65 pciinfo_t pci_info;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
66
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
67 struct s3_chip
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
68 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
69 int arch;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
70 unsigned long fbsize;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
71 void (*lock) (struct s3_chip *, int);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
72 };
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
73 typedef struct s3_chip s3_chip;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
74
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
75 struct s3_info
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
76 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
77 vidix_video_eq_t eq;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
78 unsigned int use_colorkey;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
79 unsigned int colorkey;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
80 unsigned int vidixcolorkey;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
81 unsigned int depth;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
82 unsigned int bpp;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
83 unsigned int format;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
84 unsigned int pitch;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
85 unsigned int blendBase;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
86 unsigned int displayWidth, displayHeight;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
87 unsigned int src_w, src_h;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
88 unsigned int drw_w, drw_h;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
89 unsigned int wx, wy;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
90 unsigned int screen_x;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
91 unsigned int screen_y;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
92 unsigned long frame_size;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
93 struct s3_chip chip;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
94 void *video_base;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
95 void *control_base;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
96 unsigned long picture_base;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
97 unsigned long picture_offset;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
98 unsigned int num_frames;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
99 int bps;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
100 };
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
101 typedef struct s3_info s3_info;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
102
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
103 static s3_info *info;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
104
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
105 static vidix_capability_t s3_cap = {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
106 "S3 BES",
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
107 "Reza Jelveh, Michael Kostylev",
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
108 TYPE_OUTPUT,
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
109 {0, 0, 0, 0},
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
110 4096,
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
111 4096,
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
112 4,
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
113 4,
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
114 -1,
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
115 FLAG_UPSCALER | FLAG_DOWNSCALER,
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
116 VENDOR_S3_INC,
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
117 -1,
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
118 {0, 0, 0, 0}
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
119 };
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
120
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
121 struct s3_cards
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
122 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
123 unsigned short chip_id;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
124 unsigned short arch;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
125 };
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
126
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
127 static struct s3_cards s3_card_ids[] = {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
128 /* Trio64V */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
129 {DEVICE_S3_INC_86C764_765_TRIO32_64_64V, S3_TRIO64V},
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
130 {DEVICE_S3_INC_86C767_TRIO_64UV, S3_TRIO64V},
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
131 {DEVICE_S3_INC_86C755_TRIO_64V2_DX, S3_TRIO64V},
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
132 {DEVICE_S3_INC_86C775_86C785_TRIO_64V2_DX, S3_TRIO64V},
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
133 {DEVICE_S3_INC_TRIO_64V_FAMILY, S3_TRIO64V},
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
134 {DEVICE_S3_INC_TRIO_64V_FAMILY2, S3_TRIO64V},
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
135 {DEVICE_S3_INC_TRIO_64V_FAMILY3, S3_TRIO64V},
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
136 {DEVICE_S3_INC_TRIO_64V_FAMILY4, S3_TRIO64V},
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
137 {DEVICE_S3_INC_TRIO_64V_FAMILY5, S3_TRIO64V},
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
138 {DEVICE_S3_INC_TRIO_64V_FAMILY6, S3_TRIO64V},
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
139 {DEVICE_S3_INC_TRIO_64V_FAMILY7, S3_TRIO64V},
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
140 {DEVICE_S3_INC_TRIO_64V_FAMILY8, S3_TRIO64V},
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
141 {DEVICE_S3_INC_TRIO_64V_FAMILY9, S3_TRIO64V},
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
142 {DEVICE_S3_INC_TRIO_64V_FAMILY10, S3_TRIO64V},
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
143 {DEVICE_S3_INC_TRIO_64V_FAMILY11, S3_TRIO64V},
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
144 /* Virge */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
145 {DEVICE_S3_INC_86C325_VIRGE, S3_VIRGE},
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
146 {DEVICE_S3_INC_86C988_VIRGE_VX, S3_VIRGE},
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
147 {DEVICE_S3_INC_VIRGE_DX_OR_GX, S3_VIRGE},
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
148 {DEVICE_S3_INC_VIRGE_GX2, S3_VIRGE},
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
149 {DEVICE_S3_INC_VIRGE_M3, S3_VIRGE},
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
150 {DEVICE_S3_INC_VIRGE_MX, S3_VIRGE},
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
151 {DEVICE_S3_INC_VIRGE_MX2, S3_VIRGE},
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
152 {DEVICE_S3_INC_VIRGE_MX_MV, S3_VIRGE},
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
153 /* Savage3D */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
154 {DEVICE_S3_INC_86C794_SAVAGE_3D, S3_SAVAGE3D},
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
155 {DEVICE_S3_INC_86C390_SAVAGE_3D_MV, S3_SAVAGE3D},
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
156 /* Savage4 */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
157 {DEVICE_S3_INC_SAVAGE_4, S3_SAVAGE4},
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
158 {DEVICE_S3_INC_SAVAGE_42, S3_SAVAGE4},
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
159 /* SavageMX */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
160 {DEVICE_S3_INC_86C270_294_SAVAGE_MX_MV, S3_SAVAGE_MX},
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
161 {DEVICE_S3_INC_82C270_294_SAVAGE_MX, S3_SAVAGE_MX},
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
162 {DEVICE_S3_INC_86C270_294_SAVAGE_IX_MV, S3_SAVAGE_MX},
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
163 /* SuperSavage */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
164 {DEVICE_S3_INC_SUPERSAVAGE_MX_128, S3_SUPERSAVAGE},
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
165 {DEVICE_S3_INC_SUPERSAVAGE_MX_64, S3_SUPERSAVAGE},
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
166 {DEVICE_S3_INC_SUPERSAVAGE_MX_64C, S3_SUPERSAVAGE},
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
167 {DEVICE_S3_INC_SUPERSAVAGE_IX_128_SDR, S3_SUPERSAVAGE},
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
168 {DEVICE_S3_INC_SUPERSAVAGE_IX_128_DDR, S3_SUPERSAVAGE},
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
169 {DEVICE_S3_INC_SUPERSAVAGE_IX_64_SDR, S3_SUPERSAVAGE},
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
170 {DEVICE_S3_INC_SUPERSAVAGE_IX_64_DDR, S3_SUPERSAVAGE},
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
171 {DEVICE_S3_INC_SUPERSAVAGE_IX_C_SDR, S3_SUPERSAVAGE},
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
172 {DEVICE_S3_INC_SUPERSAVAGE_IX_C_DDR, S3_SUPERSAVAGE},
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
173 /* ProSavage */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
174 {DEVICE_S3_INC_PROSAVAGE_PM133, S3_PROSAVAGE},
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
175 {DEVICE_S3_INC_PROSAVAGE_KM133, S3_PROSAVAGE},
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
176 {DEVICE_S3_INC_86C380_PROSAVAGEDDR_K4M266, S3_PROSAVAGE},
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
177 {DEVICE_S3_INC_VT8636A_PROSAVAGE_KN133, S3_PROSAVAGE},
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
178 {DEVICE_S3_INC_VT8751_PROSAVAGEDDR_P4M266, S3_PROSAVAGE},
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
179 {DEVICE_S3_INC_VT8375_PROSAVAGE8_KM266_KL266, S3_PROSAVAGE},
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
180 /* Savage2000 */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
181 {DEVICE_S3_INC_86C410_SAVAGE_2000, S3_SAVAGE2000}
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
182 };
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
183
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
184 static unsigned int GetBlendForFourCC (int id)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
185 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
186 switch (id)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
187 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
188 case IMGFMT_UYVY:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
189 return 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
190 case IMGFMT_YUY2:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
191 return 1;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
192 case IMGFMT_Y211:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
193 return 4;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
194 case IMGFMT_BGR15:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
195 return 3;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
196 case IMGFMT_BGR16:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
197 return 5;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
198 case IMGFMT_BGR24:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
199 return 6;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
200 case IMGFMT_BGR32:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
201 return 7;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
202 default:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
203 return 1;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
204 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
205 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
206
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
207 static void S3SetColorOld (void)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
208 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
209 char sat = (info->eq.saturation + 1000) * 15 / 2000;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
210 double hue = info->eq.hue * 3.1415926 / 1000.0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
211 char hsx = ((char) (sat * cos (hue))) & 0x1f;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
212 char hsy = ((char) (sat * sin (hue))) & 0x1f;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
213
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
214 OUTREG (COLOR_ADJUSTMENT_REG, 0x80008000 | hsy << 24 | hsx << 16 |
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
215 ((info->eq.contrast + 1000) * 31 / 2000) << 8 |
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
216 (info->eq.brightness + 1000) * 255 / 2000);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
217 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
218
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
219 static void S3SetColorNew (void)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
220 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
221 /* not yet */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
222 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
223
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
224 static void S3SetColor2000 (void)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
225 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
226 /* not yet */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
227 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
228
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
229 static void S3SetColorKeyOld (void)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
230 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
231 int red, green, blue;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
232
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
233 /* Here, we reset the colorkey and all the controls */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
234
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
235 red = (info->vidixcolorkey & 0x00FF0000) >> 16;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
236 green = (info->vidixcolorkey & 0x0000FF00) >> 8;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
237 blue = info->vidixcolorkey & 0x000000FF;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
238
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
239 if (!info->vidixcolorkey)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
240 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
241 OUTREG (COL_CHROMA_KEY_CONTROL_REG, 0);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
242 OUTREG (CHROMA_KEY_UPPER_BOUND_REG, 0);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
243 OUTREG (BLEND_CONTROL_REG, 0);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
244 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
245 else
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
246 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
247 switch (info->depth)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
248 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
249 // FIXME: isnt fixed yet
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
250 case 8:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
251 OUTREG (COL_CHROMA_KEY_CONTROL_REG, 0x37000000 | (info->vidixcolorkey & 0xFF));
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
252 OUTREG (CHROMA_KEY_UPPER_BOUND_REG, 0x00000000 | (info->vidixcolorkey & 0xFF));
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
253 break;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
254 case 15:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
255 /* 15 bpp 555 */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
256 red &= 0x1f;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
257 green &= 0x1f;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
258 blue &= 0x1f;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
259 OUTREG (COL_CHROMA_KEY_CONTROL_REG, 0x05000000 | (red << 19) | (green << 11) | (blue << 3));
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
260 OUTREG (CHROMA_KEY_UPPER_BOUND_REG, 0x00000000 | (red << 19) | (green << 11) | (blue << 3));
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
261 break;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
262 case 16:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
263 /* 16 bpp 565 */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
264 red &= 0x1f;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
265 green &= 0x3f;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
266 blue &= 0x1f;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
267 OUTREG (COL_CHROMA_KEY_CONTROL_REG, 0x16000000 | (red << 19) | (green << 10) | (blue << 3));
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
268 OUTREG (CHROMA_KEY_UPPER_BOUND_REG, 0x00020002 | (red << 19) | (green << 10) | (blue << 3));
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
269 break;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
270 case 24:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
271 /* 24 bpp 888 */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
272 OUTREG (COL_CHROMA_KEY_CONTROL_REG, 0x17000000 | (red << 16) | (green << 8) | (blue));
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
273 OUTREG (CHROMA_KEY_UPPER_BOUND_REG, 0x00000000 | (red << 16) | (green << 8) | (blue));
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
274 break;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
275 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
276
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
277 /* We use destination colorkey */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
278 OUTREG (BLEND_CONTROL_REG, 0x05000000);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
279 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
280 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
281
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
282 static void S3SetColorKeyNew (void)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
283 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
284 /* not yet */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
285 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
286
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
287 static void S3SetColorKey2000 (void)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
288 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
289 /* not yet */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
290 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
291
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
292 static void S3DisplayVideoOld (void)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
293 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
294 unsigned int ssControl;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
295 int cr92;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
296
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
297 /* Set surface location and stride */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
298 OUTREG (SSTREAM_FBADDR0_REG, info->picture_offset);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
299 OUTREG (SSTREAM_FBADDR1_REG, 0);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
300 OUTREG (SSTREAM_STRIDE_REG, info->pitch);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
301 /* Set window parameters */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
302 OUTREG (SSTREAM_WINDOW_START_REG, OS_XY (info->wx, info->wy));
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
303 OUTREG (SSTREAM_WINDOW_SIZE_REG, OS_WH (info->drw_w, info->drw_h));
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
304
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
305 /* Set surface format and adjust scaling */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
306 if (info->chip.arch <= S3_VIRGE)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
307 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
308 ssControl = ((info->src_w - 1) << 1) - ((info->drw_w - 1) & 0xffff);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
309 ssControl |= GetBlendForFourCC (info->format) << 24;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
310 if (info->src_w != info->drw_w)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
311 ssControl |= 2 << 28;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
312
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
313 OUTREG (SSTREAM_CONTROL_REG, ssControl);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
314 OUTREG (SSTREAM_STRETCH_REG, (((info->src_w - info->drw_w) & 0x7ff) << 16) | (info->src_w - 1));
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
315 /* Calculate vertical scale factor */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
316 OUTREG (K1_VSCALE_REG, info->src_h - 1);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
317 OUTREG (K2_VSCALE_REG, (info->src_h - info->drw_h) & 0x7ff);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
318 OUTREG (DDA_VERT_REG, (1 - info->drw_h) & 0xfff);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
319 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
320 else
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
321 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
322 ssControl = GetBlendForFourCC (info->format) << 24 | info->src_w;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
323 if (info->src_w > (info->drw_w << 1))
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
324 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
325 /* BUGBUG shouldn't this be >=? */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
326 if (info->src_w <= (info->drw_w << 2))
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
327 ssControl |= HDSCALE_4;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
328 else if (info->src_w > (info->drw_w << 3))
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
329 ssControl |= HDSCALE_8;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
330 else if (info->src_w > (info->drw_w << 4))
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
331 ssControl |= HDSCALE_16;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
332 else if (info->src_w > (info->drw_w << 5))
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
333 ssControl |= HDSCALE_32;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
334 else if (info->src_w > (info->drw_w << 6))
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
335 ssControl |= HDSCALE_64;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
336 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
337
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
338 OUTREG (SSTREAM_CONTROL_REG, ssControl);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
339 OUTREG (SSTREAM_STRETCH_REG, (info->src_w << 15) / info->drw_w);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
340 OUTREG (SSTREAM_LINES_REG, info->src_h);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
341 /* Calculate vertical scale factor. */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
342 OUTREG (SSTREAM_VSCALE_REG, VSCALING (info->src_h, info->drw_h));
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
343 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
344
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
345 if (info->chip.arch == S3_TRIO64V)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
346 OUTREG (STREAMS_FIFO_REG, (6 << 10) | (14 << 5) | 16);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
347 else
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
348 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
349 // FIXME: this should actually be enabled
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
350 info->pitch = (info->pitch + 7) / 8;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
351 VGAOUT8 (vgaCRIndex, 0x92);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
352 cr92 = VGAIN8 (vgaCRReg);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
353 VGAOUT8 (vgaCRReg, (cr92 & 0x40) | (info->pitch >> 8) | 0x80);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
354 VGAOUT8 (vgaCRIndex, 0x93);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
355 VGAOUT8 (vgaCRReg, info->pitch);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
356 OUTREG (STREAMS_FIFO_REG, 2 | 25 << 5 | 32 << 11);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
357 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
358 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
359
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
360 static void S3DisplayVideoNew (void)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
361 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
362 /* not yet */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
363 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
364
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
365 static void S3DisplayVideo2000 (void)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
366 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
367 /* not yet */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
368 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
369
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
370 static void S3InitStreamsOld (void)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
371 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
372 /*unsigned long jDelta; */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
373 unsigned long format = 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
374
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
375 /*jDelta = pScrn->displayWidth * (pScrn->bitsPerPixel + 7) / 8; */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
376 switch (info->depth)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
377 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
378 case 8:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
379 format = 0 << 24;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
380 break;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
381 case 15:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
382 format = 3 << 24;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
383 break;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
384 case 16:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
385 format = 5 << 24;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
386 break;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
387 case 24:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
388 format = 7 << 24;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
389 break;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
390 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
391 //#warning enable this again
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
392 OUTREG (PSTREAM_FBSIZE_REG, info->screen_y * info->screen_x * (info->bpp >> 3));
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
393 OUTREG (PSTREAM_WINDOW_START_REG, OS_XY (0, 0));
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
394 OUTREG (PSTREAM_WINDOW_SIZE_REG, OS_WH (info->screen_x, info->screen_y));
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
395 OUTREG (PSTREAM_FBADDR1_REG, 0);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
396 /*OUTREG( PSTREAM_STRIDE_REG, jDelta ); */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
397 OUTREG (PSTREAM_CONTROL_REG, format);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
398 OUTREG (PSTREAM_FBADDR0_REG, 0);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
399
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
400 OUTREG (COL_CHROMA_KEY_CONTROL_REG, 0);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
401 OUTREG (SSTREAM_CONTROL_REG, 0);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
402 OUTREG (CHROMA_KEY_UPPER_BOUND_REG, 0);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
403 OUTREG (SSTREAM_STRETCH_REG, 0);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
404 OUTREG (COLOR_ADJUSTMENT_REG, 0);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
405 OUTREG (BLEND_CONTROL_REG, 1 << 24);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
406 OUTREG (DOUBLE_BUFFER_REG, 0);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
407 OUTREG (SSTREAM_FBADDR0_REG, 0);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
408 OUTREG (SSTREAM_FBADDR1_REG, 0);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
409 OUTREG (SSTREAM_FBADDR2_REG, 0);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
410 OUTREG (SSTREAM_FBSIZE_REG, 0);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
411 OUTREG (SSTREAM_STRIDE_REG, 0);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
412 OUTREG (SSTREAM_VSCALE_REG, 0);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
413 OUTREG (SSTREAM_LINES_REG, 0);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
414 OUTREG (SSTREAM_VINITIAL_REG, 0);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
415 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
416
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
417 static void S3InitStreamsNew (void)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
418 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
419 /* not yet */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
420 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
421
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
422 static void S3InitStreams2000 (void)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
423 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
424 /* not yet */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
425 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
426
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
427 static void S3StreamsOn (void)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
428 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
429 unsigned char jStreamsControl;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
430
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
431 VGAOUT8 (vgaCRIndex, EXT_MISC_CTRL2);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
432
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
433 if (S3_SAVAGE_MOBILE_SERIES (info->chip.arch))
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
434 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
435 jStreamsControl = VGAIN8 (vgaCRReg) | ENABLE_STREAM1;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
436 VerticalRetraceWait ();
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
437 VGAOUT16 (vgaCRIndex, (jStreamsControl << 8) | EXT_MISC_CTRL2);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
438
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
439 S3InitStreams = S3InitStreamsNew;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
440 S3SetColor = S3SetColorNew;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
441 S3SetColorKey = S3SetColorKeyNew;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
442 S3DisplayVideo = S3DisplayVideoNew;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
443 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
444 else if (info->chip.arch == S3_SAVAGE2000)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
445 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
446 jStreamsControl = VGAIN8 (vgaCRReg) | ENABLE_STREAM1;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
447 VerticalRetraceWait ();
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
448 VGAOUT16 (vgaCRIndex, (jStreamsControl << 8) | EXT_MISC_CTRL2);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
449
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
450 S3InitStreams = S3InitStreams2000;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
451 S3SetColor = S3SetColor2000;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
452 S3SetColorKey = S3SetColorKey2000;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
453 S3DisplayVideo = S3DisplayVideo2000;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
454 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
455 else
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
456 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
457 jStreamsControl = VGAIN8 (vgaCRReg) | ENABLE_STREAMS_OLD;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
458 VerticalRetraceWait ();
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
459 VGAOUT16 (vgaCRIndex, (jStreamsControl << 8) | EXT_MISC_CTRL2);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
460
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
461 S3InitStreams = S3InitStreamsOld;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
462 S3SetColor = S3SetColorOld;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
463 S3SetColorKey = S3SetColorKeyOld;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
464 S3DisplayVideo = S3DisplayVideoOld;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
465 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
466
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
467 S3InitStreams ();
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
468
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
469 VerticalRetraceWait ();
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
470 /* Turn on secondary stream TV flicker filter, once we support TV. */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
471 /* SR70 |= 0x10 */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
472 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
473
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
474 static void S3GetScrProp (struct s3_info *info)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
475 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
476 unsigned char bpp = 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
477
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
478 VGAOUT8 (vgaCRIndex, EXT_MISC_CTRL2);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
479 bpp = VGAIN8 (vgaCRReg);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
480
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
481 switch (bpp & 0xf0)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
482 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
483 case 0x00:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
484 case 0x10:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
485 info->depth = 8;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
486 info->bpp = 8;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
487 break;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
488 case 0x20:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
489 case 0x30:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
490 info->depth = 15;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
491 info->bpp = 16;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
492 break;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
493 case 0x40:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
494 case 0x50:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
495 info->depth = 16;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
496 info->bpp = 16;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
497 break;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
498 case 0x70:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
499 case 0xd0:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
500 info->depth = 24;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
501 info->bpp = 32;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
502 break;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
503 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
504
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
505 VGAOUT8 (vgaCRIndex, 0x1);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
506 info->screen_x = (1 + VGAIN8 (vgaCRReg)) << 3;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
507 VGAOUT8 (vgaCRIndex, 0x12);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
508 info->screen_y = VGAIN8 (vgaCRReg);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
509 VGAOUT8 (vgaCRIndex, 0x07);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
510 info->screen_y |= (VGAIN8 (vgaCRReg) & 0x02) << 7;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
511 info->screen_y |= (VGAIN8 (vgaCRReg) & 0x40) << 3;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
512 ++info->screen_y;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
513
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
514 printf ("[s3_vid] x = %d, y = %d, bpp = %d\n", info->screen_x, info->screen_y, info->bpp);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
515 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
516
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
517 static void S3StreamsOff (void)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
518 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
519 unsigned char jStreamsControl;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
520
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
521 if (info->chip.arch == S3_TRIO64V)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
522 OUTREG (STREAMS_FIFO_REG, (20 << 10));
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
523
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
524 VGAOUT8 (vgaCRIndex, EXT_MISC_CTRL2);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
525 if (S3_SAVAGE_MOBILE_SERIES (info->chip.arch) ||
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
526 (info->chip.arch == S3_SUPERSAVAGE) || (info->chip.arch == S3_SAVAGE2000))
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
527 jStreamsControl = VGAIN8 (vgaCRReg) & NO_STREAMS;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
528 else
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
529 jStreamsControl = VGAIN8 (vgaCRReg) & NO_STREAMS_OLD;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
530
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
531 VerticalRetraceWait ();
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
532 VGAOUT16 (vgaCRIndex, (jStreamsControl << 8) | EXT_MISC_CTRL2);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
533
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
534 if (S3_SAVAGE_SERIES (info->chip.arch))
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
535 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
536 VGAOUT16 (vgaCRIndex, 0x0093);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
537 VGAOUT8 (vgaCRIndex, 0x92);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
538 VGAOUT8 (vgaCRReg, VGAIN8 (vgaCRReg) & 0x40);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
539 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
540 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
541
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
542 static int find_chip (unsigned chip_id)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
543 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
544 unsigned i;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
545
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
546 for (i = 0; i < sizeof (s3_card_ids) / sizeof (struct s3_cards); i++)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
547 if (chip_id == s3_card_ids[i].chip_id)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
548 return i;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
549 return -1;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
550 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
551
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
552 static int s3_probe (int verbose, int force)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
553 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
554 pciinfo_t lst[MAX_PCI_DEVICES];
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
555 unsigned i, num_pci;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
556 int err;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
557
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
558 if (force)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
559 printf ("[s3_vid] Warning: forcing not supported yet!\n");
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
560 err = pci_scan (lst, &num_pci);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
561 if (err)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
562 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
563 printf ("[s3_vid] Error occurred during pci scan: %s\n", strerror (err));
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
564 return err;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
565 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
566 else
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
567 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
568 err = ENXIO;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
569 for (i = 0; i < num_pci; i++)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
570 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
571 if (lst[i].vendor == VENDOR_S3_INC)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
572 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
573 int idx;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
574 const char *dname;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
575 idx = find_chip (lst[i].device);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
576 if (idx == -1)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
577 continue;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
578 dname = pci_device_name (lst[i].vendor, lst[i].device);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
579 dname = dname ? dname : "Unknown chip";
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
580 printf ("[s3_vid] Found chip: %s\n", dname);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
581 // FIXME: whats wrong here?
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
582 if ((lst[i].command & PCI_COMMAND_IO) == 0)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
583 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
584 printf ("[s3_vid] Device is disabled, ignoring\n");
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
585 continue;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
586 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
587 s3_cap.device_id = lst[i].device;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
588 err = 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
589 memcpy (&pci_info, &lst[i], sizeof (pciinfo_t));
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
590 break;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
591 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
592 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
593 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
594 if (err && verbose)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
595 printf ("[s3_vid] Can't find chip\n");
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
596 return err;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
597 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
598
26099
13af6fff168d fix bad function prototype
ben
parents: 26096
diff changeset
599 static int s3_init (void)
26096
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
600 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
601 unsigned char cr36;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
602 int mtrr, videoRam;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
603 static unsigned char RamTrioVirge[] = { 4, 0, 3, 8, 2, 6, 1, 0 };
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
604 static unsigned char RamSavage3D[] = { 8, 4, 4, 2 };
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
605 static unsigned char RamSavage4[] = { 2, 4, 8, 12, 16, 32, 64, 32 };
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
606 static unsigned char RamSavageMX[] = { 2, 8, 4, 16, 8, 16, 4, 16 };
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
607 static unsigned char RamSavageNB[] = { 0, 2, 4, 8, 16, 32, 16, 2 };
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
608
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
609 enable_app_io ();
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
610
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
611 info = calloc (1, sizeof (s3_info));
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
612
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
613 info->chip.arch = s3_card_ids[find_chip (pci_info.device)].arch;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
614
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
615 /* Switch to vga registers */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
616 OUTPORT8 (0x3c3, INPORT8 (0x3c3) | 0x01);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
617 OUTPORT8 (0x3c2, INPORT8 (0x3cc) | 0x01);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
618 /* Unlock extended registers */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
619 OUTPORT8 (vgaCRIndex, 0x38);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
620 OUTPORT8 (vgaCRReg, 0x48);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
621 OUTPORT8 (vgaCRIndex, 0x39);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
622 OUTPORT8 (vgaCRReg, 0xa0);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
623
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
624 if (info->chip.arch <= S3_VIRGE)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
625 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
626 /* TODO: Improve detecting code */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
627
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
628 /* Enable LFB */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
629 OUTPORT8 (vgaCRIndex, LIN_ADDR_CTRL);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
630 OUTPORT8 (vgaCRReg, INPORT8 (vgaCRReg) | ENABLE_LFB);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
631 /* Enable NewMMIO */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
632 OUTPORT8 (vgaCRIndex, EXT_MEM_CTRL1);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
633 OUTPORT8 (vgaCRReg, INPORT8 (vgaCRReg) | ENABLE_NEWMMIO);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
634 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
635
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
636 if (info->chip.arch < S3_SAVAGE3D)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
637 info->control_base = map_phys_mem (pci_info.base0 + S3_NEWMMIO_REGBASE, S3_NEWMMIO_REGSIZE);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
638 else if (info->chip.arch == S3_SAVAGE3D)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
639 info->control_base = map_phys_mem (pci_info.base0 + S3_NEWMMIO_REGBASE, S3_NEWMMIO_REGSIZE_SAVAGE);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
640 else
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
641 info->control_base = map_phys_mem (pci_info.base0, S3_NEWMMIO_REGSIZE_SAVAGE);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
642
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
643 /* Unlock CRTC[0-7] */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
644 VGAOUT8 (vgaCRIndex, 0x11);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
645 VGAOUT8 (vgaCRReg, VGAIN8 (vgaCRReg) & 0x7f);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
646 /* Unlock sequencer */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
647 VGAOUT16 (0x3c4, 0x0608);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
648 /* Detect amount of installed ram */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
649 VGAOUT8 (vgaCRIndex, 0x36);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
650 cr36 = VGAIN8 (vgaCRReg);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
651
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
652 switch (info->chip.arch)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
653 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
654 case S3_TRIO64V:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
655 case S3_VIRGE:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
656 videoRam = RamTrioVirge[(cr36 & 0xE0) >> 5] * 1024;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
657 break;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
658
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
659 case S3_SAVAGE3D:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
660 videoRam = RamSavage3D[(cr36 & 0xC0) >> 6] * 1024;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
661 break;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
662
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
663 case S3_SAVAGE4:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
664 /*
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
665 * The Savage4 has one ugly special case to consider. On
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
666 * systems with 4 banks of 2Mx32 SDRAM, the BIOS says 4MB
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
667 * when it really means 8MB. Why do it the same when you
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
668 * can do it different...
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
669 */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
670 VGAOUT8 (vgaCRIndex, 0x68);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
671 if ((VGAIN8 (vgaCRReg) & 0xC0) == (0x01 << 6))
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
672 RamSavage4[1] = 8;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
673
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
674 case S3_SAVAGE2000:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
675 videoRam = RamSavage4[(cr36 & 0xE0) >> 5] * 1024;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
676 break;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
677
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
678 case S3_SAVAGE_MX:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
679 videoRam = RamSavageMX[(cr36 & 0x0E) >> 1] * 1024;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
680 break;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
681
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
682 case S3_PROSAVAGE:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
683 videoRam = RamSavageNB[(cr36 & 0xE0) >> 5] * 1024;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
684 break;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
685
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
686 default:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
687 /* How did we get here? */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
688 videoRam = 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
689 break;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
690 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
691
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
692 printf ("[s3_vid] VideoRam = %d\n", videoRam);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
693 info->chip.fbsize = videoRam * 1024;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
694
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
695 if (info->chip.arch <= S3_SAVAGE3D)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
696 mtrr = mtrr_set_type (pci_info.base0, info->chip.fbsize, MTRR_TYPE_WRCOMB);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
697 else
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
698 mtrr = mtrr_set_type (pci_info.base1, info->chip.fbsize, MTRR_TYPE_WRCOMB);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
699
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
700 if (mtrr != 0)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
701 printf ("[s3_vid] Unable to setup MTRR: %s\n", strerror (mtrr));
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
702 else
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
703 printf ("[s3_vid] MTRR set up\n");
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
704
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
705 S3GetScrProp (info);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
706 S3StreamsOn ();
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
707
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
708 return 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
709 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
710
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
711 static void s3_destroy (void)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
712 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
713 unmap_phys_mem (info->video_base, info->chip.fbsize);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
714 if (S3_SAVAGE_SERIES (info->chip.arch))
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
715 unmap_phys_mem (info->control_base, S3_NEWMMIO_REGSIZE_SAVAGE);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
716 else
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
717 unmap_phys_mem (info->control_base, S3_NEWMMIO_REGSIZE);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
718
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
719 free (info);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
720 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
721
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
722 static int s3_get_caps (vidix_capability_t * to)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
723 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
724 memcpy (to, &s3_cap, sizeof (vidix_capability_t));
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
725 return 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
726 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
727
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
728 static int is_supported_fourcc (uint32_t fourcc)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
729 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
730 switch (fourcc)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
731 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
732 //FIXME: Burst Command Interface should be used
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
733 // for planar to packed conversion
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
734 // case IMGFMT_YV12:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
735 // case IMGFMT_I420:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
736 case IMGFMT_UYVY:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
737 case IMGFMT_YUY2:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
738 case IMGFMT_Y211:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
739 case IMGFMT_BGR15:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
740 case IMGFMT_BGR16:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
741 case IMGFMT_BGR24:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
742 case IMGFMT_BGR32:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
743 return 1;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
744 default:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
745 return 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
746 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
747 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
748
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
749 static int s3_query_fourcc (vidix_fourcc_t * to)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
750 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
751 if (is_supported_fourcc (to->fourcc))
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
752 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
753 to->depth = VID_DEPTH_ALL;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
754 to->flags = VID_CAP_EXPAND | VID_CAP_SHRINK | VID_CAP_COLORKEY;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
755 return 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
756 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
757 else
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
758 to->depth = to->flags = 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
759
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
760 return ENOSYS;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
761 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
762
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
763 #if 0
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
764 static int s3_get_gkeys (vidix_grkey_t * grkey)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
765 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
766 return 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
767 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
768 #endif
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
769
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
770 static int s3_set_gkeys (const vidix_grkey_t * grkey)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
771 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
772 if (grkey->ckey.op == CKEY_FALSE)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
773 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
774 info->use_colorkey = 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
775 info->vidixcolorkey = 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
776 printf ("[s3_vid] Colorkeying disabled\n");
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
777 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
778 else
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
779 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
780 info->use_colorkey = 1;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
781 info->vidixcolorkey = ((grkey->ckey.red << 16) | (grkey->ckey.green << 8) | grkey->ckey.blue);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
782 printf ("[s3_vid] Set colorkey 0x%x\n", info->vidixcolorkey);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
783 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
784 if (S3SetColorKey)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
785 S3SetColorKey ();
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
786 return 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
787 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
788
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
789 static int s3_get_eq (vidix_video_eq_t * eq)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
790 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
791 memcpy (eq, &(info->eq), sizeof (vidix_video_eq_t));
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
792 return 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
793 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
794
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
795 static int s3_set_eq (const vidix_video_eq_t * eq)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
796 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
797 if (eq->cap & VEQ_CAP_BRIGHTNESS)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
798 info->eq.brightness = eq->brightness;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
799 if (eq->cap & VEQ_CAP_CONTRAST)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
800 info->eq.contrast = eq->contrast;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
801 if (eq->cap & VEQ_CAP_SATURATION)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
802 info->eq.saturation = eq->saturation;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
803 if (eq->cap & VEQ_CAP_HUE)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
804 info->eq.hue = eq->hue;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
805 if (S3SetColor)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
806 S3SetColor ();
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
807 return 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
808 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
809
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
810 static int s3_config_playback (vidix_playback_t * vinfo)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
811 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
812 unsigned int i, bpp;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
813
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
814 if (!is_supported_fourcc (vinfo->fourcc))
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
815 return -1;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
816
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
817 info->src_w = vinfo->src.w;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
818 info->src_h = vinfo->src.h;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
819
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
820 info->drw_w = vinfo->dest.w;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
821 info->drw_h = vinfo->dest.h;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
822
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
823 info->wx = vinfo->dest.x;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
824 info->wy = vinfo->dest.y;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
825 info->format = vinfo->fourcc;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
826
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
827 info->eq.cap = VEQ_CAP_BRIGHTNESS | VEQ_CAP_CONTRAST |
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
828 VEQ_CAP_SATURATION | VEQ_CAP_HUE;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
829 info->eq.brightness = 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
830 info->eq.contrast = 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
831 info->eq.saturation = 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
832 info->eq.hue = 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
833
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
834 vinfo->offset.y = 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
835 vinfo->offset.v = 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
836 vinfo->offset.u = 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
837
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
838 vinfo->dest.pitch.y = 32;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
839 vinfo->dest.pitch.u = 32;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
840 vinfo->dest.pitch.v = 32;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
841
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
842 switch (vinfo->fourcc)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
843 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
844 case IMGFMT_Y211:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
845 bpp = 1;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
846 break;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
847 case IMGFMT_BGR24:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
848 bpp = 3;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
849 break;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
850 case IMGFMT_BGR32:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
851 bpp = 4;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
852 break;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
853 default:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
854 bpp = 2;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
855 break;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
856 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
857
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
858 info->pitch = ((info->src_w * bpp) + 15) & ~15;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
859 info->pitch |= ((info->pitch / bpp) << 16);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
860
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
861 vinfo->frame_size = (info->pitch & 0xffff) * info->src_h;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
862 info->frame_size = vinfo->frame_size;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
863
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
864 info->picture_offset = info->screen_x * info->screen_y * (info->bpp >> 3);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
865 if (info->picture_offset > (info->chip.fbsize - vinfo->frame_size))
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
866 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
867 printf ("[s3_vid] Not enough memory for overlay\n");
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
868 return -1;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
869 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
870
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
871 if (info->chip.arch <= S3_SAVAGE3D)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
872 info->video_base = map_phys_mem (pci_info.base0, info->chip.fbsize);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
873 else
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
874 info->video_base = map_phys_mem (pci_info.base1, info->chip.fbsize);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
875
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
876 if (info->video_base == NULL)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
877 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
878 printf ("[s3_vid] errno = %s\n", strerror (errno));
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
879 return -1;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
880 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
881
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
882 info->picture_base = (uint32_t) info->video_base + info->picture_offset;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
883
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
884 vinfo->dga_addr = (void *) (info->picture_base);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
885
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
886 vinfo->num_frames = (info->chip.fbsize - info->picture_offset) / vinfo->frame_size;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
887 if (vinfo->num_frames > VID_PLAY_MAXFRAMES)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
888 vinfo->num_frames = VID_PLAY_MAXFRAMES;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
889
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
890 for (i = 0; i < vinfo->num_frames; i++)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
891 vinfo->offsets[i] = vinfo->frame_size * i;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
892
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
893 return 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
894 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
895
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
896 static int s3_playback_on (void)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
897 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
898 S3DisplayVideo ();
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
899 return 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
900 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
901
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
902 static int s3_playback_off (void)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
903 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
904 S3StreamsOff ();
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
905 return 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
906 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
907
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
908 static int s3_frame_sel (unsigned int frame)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
909 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
910 OUTREG (SSTREAM_FBADDR0_REG, info->picture_offset + (info->frame_size * frame));
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
911 return 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
912 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
913
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
914 VDXDriver s3_drv = {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
915 "s3",
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
916 NULL,
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
917 .probe = s3_probe,
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
918 .get_caps = s3_get_caps,
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
919 .query_fourcc = s3_query_fourcc,
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
920 .init = s3_init,
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
921 .destroy = s3_destroy,
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
922 .config_playback = s3_config_playback,
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
923 .playback_on = s3_playback_on,
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
924 .playback_off = s3_playback_off,
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
925 .frame_sel = s3_frame_sel,
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
926 .get_eq = s3_get_eq,
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
927 .set_eq = s3_set_eq,
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
928 .set_gkey = s3_set_gkeys,
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
929 };