annotate vidix/s3_vid.c @ 29688:94f1bca4f4b6

Add a -nosub option that allows disabling auto-selected subtitles as e.g. the mkv demuxer supports.
author reimar
date Mon, 28 Sep 2009 11:32:27 +0000
parents 0f1b5b68af32
children 914208d188b9
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 //#warning enable this again
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
389 OUTREG (PSTREAM_FBSIZE_REG, info->screen_y * info->screen_x * (info->bpp >> 3));
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
390 OUTREG (PSTREAM_WINDOW_START_REG, OS_XY (0, 0));
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
391 OUTREG (PSTREAM_WINDOW_SIZE_REG, OS_WH (info->screen_x, info->screen_y));
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
392 OUTREG (PSTREAM_FBADDR1_REG, 0);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
393 /*OUTREG( PSTREAM_STRIDE_REG, jDelta ); */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
394 OUTREG (PSTREAM_CONTROL_REG, format);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
395 OUTREG (PSTREAM_FBADDR0_REG, 0);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
396
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
397 OUTREG (COL_CHROMA_KEY_CONTROL_REG, 0);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
398 OUTREG (SSTREAM_CONTROL_REG, 0);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
399 OUTREG (CHROMA_KEY_UPPER_BOUND_REG, 0);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
400 OUTREG (SSTREAM_STRETCH_REG, 0);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
401 OUTREG (COLOR_ADJUSTMENT_REG, 0);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
402 OUTREG (BLEND_CONTROL_REG, 1 << 24);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
403 OUTREG (DOUBLE_BUFFER_REG, 0);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
404 OUTREG (SSTREAM_FBADDR0_REG, 0);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
405 OUTREG (SSTREAM_FBADDR1_REG, 0);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
406 OUTREG (SSTREAM_FBADDR2_REG, 0);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
407 OUTREG (SSTREAM_FBSIZE_REG, 0);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
408 OUTREG (SSTREAM_STRIDE_REG, 0);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
409 OUTREG (SSTREAM_VSCALE_REG, 0);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
410 OUTREG (SSTREAM_LINES_REG, 0);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
411 OUTREG (SSTREAM_VINITIAL_REG, 0);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
412 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
413
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
414 static void S3InitStreamsNew (void)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
415 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
416 /* not yet */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
417 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
418
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
419 static void S3InitStreams2000 (void)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
420 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
421 /* not yet */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
422 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
423
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
424 static void S3StreamsOn (void)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
425 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
426 unsigned char jStreamsControl;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
427
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
428 VGAOUT8 (vgaCRIndex, EXT_MISC_CTRL2);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
429
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
430 if (S3_SAVAGE_MOBILE_SERIES (info->chip.arch))
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
431 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
432 jStreamsControl = VGAIN8 (vgaCRReg) | ENABLE_STREAM1;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
433 VerticalRetraceWait ();
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
434 VGAOUT16 (vgaCRIndex, (jStreamsControl << 8) | EXT_MISC_CTRL2);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
435
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
436 S3InitStreams = S3InitStreamsNew;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
437 S3SetColor = S3SetColorNew;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
438 S3SetColorKey = S3SetColorKeyNew;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
439 S3DisplayVideo = S3DisplayVideoNew;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
440 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
441 else if (info->chip.arch == S3_SAVAGE2000)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
442 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
443 jStreamsControl = VGAIN8 (vgaCRReg) | ENABLE_STREAM1;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
444 VerticalRetraceWait ();
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
445 VGAOUT16 (vgaCRIndex, (jStreamsControl << 8) | EXT_MISC_CTRL2);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
446
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
447 S3InitStreams = S3InitStreams2000;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
448 S3SetColor = S3SetColor2000;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
449 S3SetColorKey = S3SetColorKey2000;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
450 S3DisplayVideo = S3DisplayVideo2000;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
451 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
452 else
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
453 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
454 jStreamsControl = VGAIN8 (vgaCRReg) | ENABLE_STREAMS_OLD;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
455 VerticalRetraceWait ();
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
456 VGAOUT16 (vgaCRIndex, (jStreamsControl << 8) | EXT_MISC_CTRL2);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
457
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
458 S3InitStreams = S3InitStreamsOld;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
459 S3SetColor = S3SetColorOld;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
460 S3SetColorKey = S3SetColorKeyOld;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
461 S3DisplayVideo = S3DisplayVideoOld;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
462 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
463
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
464 S3InitStreams ();
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
465
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
466 VerticalRetraceWait ();
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
467 /* Turn on secondary stream TV flicker filter, once we support TV. */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
468 /* SR70 |= 0x10 */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
469 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
470
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
471 static void S3GetScrProp (struct s3_info *info)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
472 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
473 unsigned char bpp = 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
474
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
475 VGAOUT8 (vgaCRIndex, EXT_MISC_CTRL2);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
476 bpp = VGAIN8 (vgaCRReg);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
477
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
478 switch (bpp & 0xf0)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
479 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
480 case 0x00:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
481 case 0x10:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
482 info->depth = 8;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
483 info->bpp = 8;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
484 break;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
485 case 0x20:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
486 case 0x30:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
487 info->depth = 15;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
488 info->bpp = 16;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
489 break;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
490 case 0x40:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
491 case 0x50:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
492 info->depth = 16;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
493 info->bpp = 16;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
494 break;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
495 case 0x70:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
496 case 0xd0:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
497 info->depth = 24;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
498 info->bpp = 32;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
499 break;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
500 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
501
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
502 VGAOUT8 (vgaCRIndex, 0x1);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
503 info->screen_x = (1 + VGAIN8 (vgaCRReg)) << 3;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
504 VGAOUT8 (vgaCRIndex, 0x12);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
505 info->screen_y = VGAIN8 (vgaCRReg);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
506 VGAOUT8 (vgaCRIndex, 0x07);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
507 info->screen_y |= (VGAIN8 (vgaCRReg) & 0x02) << 7;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
508 info->screen_y |= (VGAIN8 (vgaCRReg) & 0x40) << 3;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
509 ++info->screen_y;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
510
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
511 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
512 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
513
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
514 static void S3StreamsOff (void)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
515 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
516 unsigned char jStreamsControl;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
517
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
518 if (info->chip.arch == S3_TRIO64V)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
519 OUTREG (STREAMS_FIFO_REG, (20 << 10));
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
520
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
521 VGAOUT8 (vgaCRIndex, EXT_MISC_CTRL2);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
522 if (S3_SAVAGE_MOBILE_SERIES (info->chip.arch) ||
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
523 (info->chip.arch == S3_SUPERSAVAGE) || (info->chip.arch == S3_SAVAGE2000))
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
524 jStreamsControl = VGAIN8 (vgaCRReg) & NO_STREAMS;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
525 else
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
526 jStreamsControl = VGAIN8 (vgaCRReg) & NO_STREAMS_OLD;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
527
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
528 VerticalRetraceWait ();
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
529 VGAOUT16 (vgaCRIndex, (jStreamsControl << 8) | EXT_MISC_CTRL2);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
530
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
531 if (S3_SAVAGE_SERIES (info->chip.arch))
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
532 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
533 VGAOUT16 (vgaCRIndex, 0x0093);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
534 VGAOUT8 (vgaCRIndex, 0x92);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
535 VGAOUT8 (vgaCRReg, VGAIN8 (vgaCRReg) & 0x40);
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
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
539 static int find_chip (unsigned chip_id)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
540 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
541 unsigned i;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
542
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
543 for (i = 0; i < sizeof (s3_card_ids) / sizeof (struct s3_cards); i++)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
544 if (chip_id == s3_card_ids[i].chip_id)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
545 return i;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
546 return -1;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
547 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
548
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
549 static int s3_probe (int verbose, int force)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
550 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
551 pciinfo_t lst[MAX_PCI_DEVICES];
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
552 unsigned i, num_pci;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
553 int err;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
554
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
555 if (force)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
556 printf ("[s3_vid] Warning: forcing not supported yet!\n");
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
557 err = pci_scan (lst, &num_pci);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
558 if (err)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
559 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
560 printf ("[s3_vid] Error occurred during pci scan: %s\n", strerror (err));
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
561 return err;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
562 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
563 else
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
564 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
565 err = ENXIO;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
566 for (i = 0; i < num_pci; i++)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
567 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
568 if (lst[i].vendor == VENDOR_S3_INC)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
569 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
570 int idx;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
571 const char *dname;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
572 idx = find_chip (lst[i].device);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
573 if (idx == -1)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
574 continue;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
575 dname = pci_device_name (lst[i].vendor, lst[i].device);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
576 dname = dname ? dname : "Unknown chip";
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
577 printf ("[s3_vid] Found chip: %s\n", dname);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
578 // FIXME: whats wrong here?
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
579 if ((lst[i].command & PCI_COMMAND_IO) == 0)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
580 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
581 printf ("[s3_vid] Device is disabled, ignoring\n");
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
582 continue;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
583 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
584 s3_cap.device_id = lst[i].device;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
585 err = 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
586 memcpy (&pci_info, &lst[i], sizeof (pciinfo_t));
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
587 break;
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 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
591 if (err && verbose)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
592 printf ("[s3_vid] Can't find chip\n");
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
593 return err;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
594 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
595
26099
13af6fff168d fix bad function prototype
ben
parents: 26096
diff changeset
596 static int s3_init (void)
26096
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
597 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
598 unsigned char cr36;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
599 int mtrr, videoRam;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
600 static unsigned char RamTrioVirge[] = { 4, 0, 3, 8, 2, 6, 1, 0 };
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
601 static unsigned char RamSavage3D[] = { 8, 4, 4, 2 };
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
602 static unsigned char RamSavage4[] = { 2, 4, 8, 12, 16, 32, 64, 32 };
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
603 static unsigned char RamSavageMX[] = { 2, 8, 4, 16, 8, 16, 4, 16 };
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
604 static unsigned char RamSavageNB[] = { 0, 2, 4, 8, 16, 32, 16, 2 };
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
605
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
606 enable_app_io ();
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
607
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
608 info = calloc (1, sizeof (s3_info));
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
609
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
610 info->chip.arch = s3_card_ids[find_chip (pci_info.device)].arch;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
611
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
612 /* Switch to vga registers */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
613 OUTPORT8 (0x3c3, INPORT8 (0x3c3) | 0x01);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
614 OUTPORT8 (0x3c2, INPORT8 (0x3cc) | 0x01);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
615 /* Unlock extended registers */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
616 OUTPORT8 (vgaCRIndex, 0x38);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
617 OUTPORT8 (vgaCRReg, 0x48);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
618 OUTPORT8 (vgaCRIndex, 0x39);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
619 OUTPORT8 (vgaCRReg, 0xa0);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
620
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
621 if (info->chip.arch <= S3_VIRGE)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
622 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
623 /* TODO: Improve detecting code */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
624
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
625 /* Enable LFB */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
626 OUTPORT8 (vgaCRIndex, LIN_ADDR_CTRL);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
627 OUTPORT8 (vgaCRReg, INPORT8 (vgaCRReg) | ENABLE_LFB);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
628 /* Enable NewMMIO */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
629 OUTPORT8 (vgaCRIndex, EXT_MEM_CTRL1);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
630 OUTPORT8 (vgaCRReg, INPORT8 (vgaCRReg) | ENABLE_NEWMMIO);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
631 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
632
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
633 if (info->chip.arch < S3_SAVAGE3D)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
634 info->control_base = map_phys_mem (pci_info.base0 + S3_NEWMMIO_REGBASE, S3_NEWMMIO_REGSIZE);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
635 else if (info->chip.arch == S3_SAVAGE3D)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
636 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
637 else
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
638 info->control_base = map_phys_mem (pci_info.base0, S3_NEWMMIO_REGSIZE_SAVAGE);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
639
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
640 /* Unlock CRTC[0-7] */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
641 VGAOUT8 (vgaCRIndex, 0x11);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
642 VGAOUT8 (vgaCRReg, VGAIN8 (vgaCRReg) & 0x7f);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
643 /* Unlock sequencer */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
644 VGAOUT16 (0x3c4, 0x0608);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
645 /* Detect amount of installed ram */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
646 VGAOUT8 (vgaCRIndex, 0x36);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
647 cr36 = VGAIN8 (vgaCRReg);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
648
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
649 switch (info->chip.arch)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
650 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
651 case S3_TRIO64V:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
652 case S3_VIRGE:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
653 videoRam = RamTrioVirge[(cr36 & 0xE0) >> 5] * 1024;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
654 break;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
655
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
656 case S3_SAVAGE3D:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
657 videoRam = RamSavage3D[(cr36 & 0xC0) >> 6] * 1024;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
658 break;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
659
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
660 case S3_SAVAGE4:
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27079
diff changeset
661 /*
26096
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
662 * The Savage4 has one ugly special case to consider. On
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
663 * systems with 4 banks of 2Mx32 SDRAM, the BIOS says 4MB
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
664 * when it really means 8MB. Why do it the same when you
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
665 * can do it different...
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
666 */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
667 VGAOUT8 (vgaCRIndex, 0x68);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
668 if ((VGAIN8 (vgaCRReg) & 0xC0) == (0x01 << 6))
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
669 RamSavage4[1] = 8;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
670
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
671 case S3_SAVAGE2000:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
672 videoRam = RamSavage4[(cr36 & 0xE0) >> 5] * 1024;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
673 break;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
674
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
675 case S3_SAVAGE_MX:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
676 videoRam = RamSavageMX[(cr36 & 0x0E) >> 1] * 1024;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
677 break;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
678
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
679 case S3_PROSAVAGE:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
680 videoRam = RamSavageNB[(cr36 & 0xE0) >> 5] * 1024;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
681 break;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
682
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
683 default:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
684 /* How did we get here? */
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
685 videoRam = 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
686 break;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
687 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
688
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
689 printf ("[s3_vid] VideoRam = %d\n", videoRam);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
690 info->chip.fbsize = videoRam * 1024;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
691
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
692 if (info->chip.arch <= S3_SAVAGE3D)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
693 mtrr = mtrr_set_type (pci_info.base0, info->chip.fbsize, MTRR_TYPE_WRCOMB);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
694 else
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
695 mtrr = mtrr_set_type (pci_info.base1, info->chip.fbsize, MTRR_TYPE_WRCOMB);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
696
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
697 if (mtrr != 0)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
698 printf ("[s3_vid] Unable to setup MTRR: %s\n", strerror (mtrr));
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
699 else
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
700 printf ("[s3_vid] MTRR set up\n");
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
701
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
702 S3GetScrProp (info);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
703 S3StreamsOn ();
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
704
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
705 return 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
706 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
707
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
708 static void s3_destroy (void)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
709 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
710 unmap_phys_mem (info->video_base, info->chip.fbsize);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
711 if (S3_SAVAGE_SERIES (info->chip.arch))
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
712 unmap_phys_mem (info->control_base, S3_NEWMMIO_REGSIZE_SAVAGE);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
713 else
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
714 unmap_phys_mem (info->control_base, S3_NEWMMIO_REGSIZE);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
715
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
716 free (info);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
717 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
718
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
719 static int s3_get_caps (vidix_capability_t * to)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
720 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
721 memcpy (to, &s3_cap, sizeof (vidix_capability_t));
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
722 return 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
723 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
724
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
725 static int is_supported_fourcc (uint32_t fourcc)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
726 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
727 switch (fourcc)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
728 {
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27079
diff changeset
729 //FIXME: Burst Command Interface should be used
26096
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
730 // for planar to packed conversion
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
731 // case IMGFMT_YV12:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
732 // case IMGFMT_I420:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
733 case IMGFMT_UYVY:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
734 case IMGFMT_YUY2:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
735 case IMGFMT_Y211:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
736 case IMGFMT_BGR15:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
737 case IMGFMT_BGR16:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
738 case IMGFMT_BGR24:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
739 case IMGFMT_BGR32:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
740 return 1;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
741 default:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
742 return 0;
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
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
746 static int s3_query_fourcc (vidix_fourcc_t * to)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
747 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
748 if (is_supported_fourcc (to->fourcc))
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
749 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
750 to->depth = VID_DEPTH_ALL;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
751 to->flags = VID_CAP_EXPAND | VID_CAP_SHRINK | VID_CAP_COLORKEY;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
752 return 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
753 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
754 else
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
755 to->depth = to->flags = 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
756
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
757 return ENOSYS;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
758 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
759
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
760 #if 0
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
761 static int s3_get_gkeys (vidix_grkey_t * grkey)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
762 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
763 return 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
764 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
765 #endif
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
766
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
767 static int s3_set_gkeys (const vidix_grkey_t * grkey)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
768 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
769 if (grkey->ckey.op == CKEY_FALSE)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
770 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
771 info->use_colorkey = 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
772 info->vidixcolorkey = 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
773 printf ("[s3_vid] Colorkeying disabled\n");
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
774 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
775 else
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
776 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
777 info->use_colorkey = 1;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
778 info->vidixcolorkey = ((grkey->ckey.red << 16) | (grkey->ckey.green << 8) | grkey->ckey.blue);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
779 printf ("[s3_vid] Set colorkey 0x%x\n", info->vidixcolorkey);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
780 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
781 if (S3SetColorKey)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
782 S3SetColorKey ();
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
783 return 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
784 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
785
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
786 static int s3_get_eq (vidix_video_eq_t * eq)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
787 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
788 memcpy (eq, &(info->eq), sizeof (vidix_video_eq_t));
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
789 return 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
790 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
791
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
792 static int s3_set_eq (const vidix_video_eq_t * eq)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
793 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
794 if (eq->cap & VEQ_CAP_BRIGHTNESS)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
795 info->eq.brightness = eq->brightness;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
796 if (eq->cap & VEQ_CAP_CONTRAST)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
797 info->eq.contrast = eq->contrast;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
798 if (eq->cap & VEQ_CAP_SATURATION)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
799 info->eq.saturation = eq->saturation;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
800 if (eq->cap & VEQ_CAP_HUE)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
801 info->eq.hue = eq->hue;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
802 if (S3SetColor)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
803 S3SetColor ();
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
804 return 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
805 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
806
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
807 static int s3_config_playback (vidix_playback_t * vinfo)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
808 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
809 unsigned int i, bpp;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
810
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
811 if (!is_supported_fourcc (vinfo->fourcc))
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
812 return -1;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
813
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
814 info->src_w = vinfo->src.w;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
815 info->src_h = vinfo->src.h;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
816
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
817 info->drw_w = vinfo->dest.w;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
818 info->drw_h = vinfo->dest.h;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
819
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
820 info->wx = vinfo->dest.x;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
821 info->wy = vinfo->dest.y;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
822 info->format = vinfo->fourcc;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
823
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
824 info->eq.cap = VEQ_CAP_BRIGHTNESS | VEQ_CAP_CONTRAST |
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
825 VEQ_CAP_SATURATION | VEQ_CAP_HUE;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
826 info->eq.brightness = 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
827 info->eq.contrast = 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
828 info->eq.saturation = 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
829 info->eq.hue = 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
830
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
831 vinfo->offset.y = 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
832 vinfo->offset.v = 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
833 vinfo->offset.u = 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
834
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
835 vinfo->dest.pitch.y = 32;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
836 vinfo->dest.pitch.u = 32;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
837 vinfo->dest.pitch.v = 32;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
838
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
839 switch (vinfo->fourcc)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
840 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
841 case IMGFMT_Y211:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
842 bpp = 1;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
843 break;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
844 case IMGFMT_BGR24:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
845 bpp = 3;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
846 break;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
847 case IMGFMT_BGR32:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
848 bpp = 4;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
849 break;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
850 default:
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
851 bpp = 2;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
852 break;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
853 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
854
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
855 info->pitch = ((info->src_w * bpp) + 15) & ~15;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
856 info->pitch |= ((info->pitch / bpp) << 16);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
857
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
858 vinfo->frame_size = (info->pitch & 0xffff) * info->src_h;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
859 info->frame_size = vinfo->frame_size;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
860
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
861 info->picture_offset = info->screen_x * info->screen_y * (info->bpp >> 3);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
862 if (info->picture_offset > (info->chip.fbsize - vinfo->frame_size))
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
863 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
864 printf ("[s3_vid] Not enough memory for overlay\n");
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
865 return -1;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
866 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
867
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
868 if (info->chip.arch <= S3_SAVAGE3D)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
869 info->video_base = map_phys_mem (pci_info.base0, info->chip.fbsize);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
870 else
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
871 info->video_base = map_phys_mem (pci_info.base1, info->chip.fbsize);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
872
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
873 if (info->video_base == NULL)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
874 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
875 printf ("[s3_vid] errno = %s\n", strerror (errno));
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
876 return -1;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
877 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
878
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
879 info->picture_base = (uint32_t) info->video_base + info->picture_offset;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
880
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
881 vinfo->dga_addr = (void *) (info->picture_base);
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
882
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
883 vinfo->num_frames = (info->chip.fbsize - info->picture_offset) / vinfo->frame_size;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
884 if (vinfo->num_frames > VID_PLAY_MAXFRAMES)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
885 vinfo->num_frames = VID_PLAY_MAXFRAMES;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
886
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
887 for (i = 0; i < vinfo->num_frames; i++)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
888 vinfo->offsets[i] = vinfo->frame_size * i;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
889
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
890 return 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
891 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
892
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
893 static int s3_playback_on (void)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
894 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
895 S3DisplayVideo ();
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
896 return 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
897 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
898
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
899 static int s3_playback_off (void)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
900 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
901 S3StreamsOff ();
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
902 return 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
903 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
904
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
905 static int s3_frame_sel (unsigned int frame)
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
906 {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
907 OUTREG (SSTREAM_FBADDR0_REG, info->picture_offset + (info->frame_size * frame));
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
908 return 0;
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
909 }
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
910
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
911 VDXDriver s3_drv = {
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
912 "s3",
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
913 NULL,
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
914 .probe = s3_probe,
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
915 .get_caps = s3_get_caps,
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
916 .query_fourcc = s3_query_fourcc,
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
917 .init = s3_init,
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
918 .destroy = s3_destroy,
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
919 .config_playback = s3_config_playback,
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
920 .playback_on = s3_playback_on,
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
921 .playback_off = s3_playback_off,
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
922 .frame_sel = s3_frame_sel,
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
923 .get_eq = s3_get_eq,
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
924 .set_eq = s3_set_eq,
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
925 .set_gkey = s3_set_gkeys,
e6a565ec1a3b New S3 VIDIX driver.
ben
parents:
diff changeset
926 };