annotate vidix/s3_vid.c @ 35494:9cc5a5de6aa1

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